@camstack/addon-provider-rtsp 1.2.20 → 1.2.22

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 +187 -44
  2. package/dist/addon.mjs +187 -44
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -23,7 +23,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
23
  //#endregion
24
24
  let node_net = require("node:net");
25
25
  node_net = __toESM(node_net);
26
- //#region ../types/dist/event-category-Bxo5yJjt.mjs
26
+ //#region ../types/dist/event-category-XfKNtfCc.mjs
27
27
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
28
28
  EventCategory["SystemBoot"] = "system.boot";
29
29
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -40,9 +40,10 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
40
40
  EventCategory["SystemRestartCompleted"] = "system.restart-completed";
41
41
  /**
42
42
  * A newer addon or server-root package version was found by the
43
- * authoritative registry check. Emitted once per
44
- * `(target, packageName, currentVersion, latestVersion)` transition; repeated
45
- * polling of the same result is deduplicated by the checker.
43
+ * authoritative registry check. Emitted once when any observed
44
+ * `latestVersion` changes (or a package/node first appears behind);
45
+ * the payload carries the full currently-available list. Repeated
46
+ * polling of the same latests is silent.
46
47
  */
47
48
  EventCategory["UpdateAvailable"] = "update.available";
48
49
  /**
@@ -61,6 +62,22 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
61
62
  EventCategory["AddonInstalled"] = "addon.installed";
62
63
  EventCategory["AddonUninstalled"] = "addon.uninstalled";
63
64
  EventCategory["AddonCrashed"] = "addon.crashed";
65
+ /**
66
+ * A RUNNER the D6 crash circuit-breaker gave up on — terminal.
67
+ *
68
+ * `AddonCrashed` is the routine, self-healing fact ("it crashed; it is being
69
+ * respawned"); this is the one that never resolves itself. Emitted exactly
70
+ * once per trip, by `process-service.ts`, carrying the node, the runner, the
71
+ * addons it hosted and the crash count that tripped the breaker.
72
+ *
73
+ * It exists because a runner marked terminally `failed` used to be SILENT:
74
+ * on 2026-08-18 the `recorder` runner died of three unhandled ffmpeg spawn
75
+ * errors, the breaker stopped respawning it (correctly), `/health` kept
76
+ * returning 200, and fleet-wide recording was gone for 3h15 before the
77
+ * operator's phone told him. The Notification Center's system-event intake
78
+ * consumes this category and maps it to the `addon-crash-loop` kind.
79
+ */
80
+ EventCategory["AddonRunnerFailed"] = "addon.runner-failed";
64
81
  EventCategory["AddonError"] = "addon.error";
65
82
  EventCategory["AddonPageReady"] = "addon.page-ready";
66
83
  EventCategory["AddonWidgetReady"] = "addon.widget-ready";
@@ -7604,6 +7621,10 @@ var RecordingBandSchema = object({
7604
7621
  preBufferSec: number().min(0).optional(),
7605
7622
  postBufferSec: number().min(0).optional()
7606
7623
  });
7624
+ ({
7625
+ preBufferSec: 10,
7626
+ postBufferSec: 30
7627
+ }).postBufferSec * 1e3;
7607
7628
  /**
7608
7629
  * Per-device retention overrides. Every field is optional; an unset or `0`
7609
7630
  * value inherits the node-wide recorder default. Only footage-lifetime limits
@@ -7651,6 +7672,12 @@ var RecordingConfigSchema = object({
7651
7672
  /** DERIVED summary of `bands`, stamped by the recorder on every save.
7652
7673
  * Authoring it has no effect — see {@link RecordingStorageModeSchema}. */
7653
7674
  mode: RecordingStorageModeSchema.optional(),
7675
+ /**
7676
+ * Which assigned broker slots to record. Absent / empty = {@link
7677
+ * DEFAULT_RECORDING_PROFILES} (`high`+`low`) intersected with the
7678
+ * camera's currently assigned slots — never `mid` unless the operator
7679
+ * picks it, and never a slot the broker has not assigned.
7680
+ */
7654
7681
  profiles: array(CamProfileSchema).optional(),
7655
7682
  segmentSeconds: number().int().positive().optional(),
7656
7683
  /**
@@ -7731,7 +7758,11 @@ var RelocateFootageInputSchema = object({
7731
7758
  profiles: array(string()).optional(),
7732
7759
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7733
7760
  * never allowed to starve live writers. */
7734
- throttleMbps: number().min(1).max(1e3).optional()
7761
+ throttleMbps: number().min(1).max(1e3).optional(),
7762
+ /** Move only segments whose startMs is >= this. Absent = the whole source
7763
+ * pile. Used when a full drain is too expensive and the operator only
7764
+ * wants the recent window on the new disk. */
7765
+ sinceMs: number().int().optional()
7735
7766
  });
7736
7767
  /** Internal, lease-scoped participant operation. It is intentionally separate
7737
7768
  * from persistent recording settings: a migration never changes
@@ -14596,6 +14627,7 @@ var NcSystemEventKindSchema = _enum([
14596
14627
  "node-offline",
14597
14628
  "node-inference-unavailable",
14598
14629
  "detection-blind",
14630
+ "addon-crash-loop",
14599
14631
  "addon-update-available",
14600
14632
  "server-update-available",
14601
14633
  "alarm-triggered",
@@ -14603,6 +14635,9 @@ var NcSystemEventKindSchema = _enum([
14603
14635
  "alarm-disarmed",
14604
14636
  "alarm-arming",
14605
14637
  "alarm-arm-refused",
14638
+ "addon-updated",
14639
+ "server-updated",
14640
+ "export-completed",
14606
14641
  "camera-online",
14607
14642
  "camera-offline",
14608
14643
  "camera-disabled",
@@ -16496,13 +16531,19 @@ var RetrainStatusSchema = _enum([
16496
16531
  * "never marked" from "already trained" must read `retrainStatus`.
16497
16532
  *
16498
16533
  * `debug` does NOT pin; it is attention, not durability.
16534
+ *
16535
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16536
+ * A favourited track is skipped by retention the same way `staging` is, but
16537
+ * it does not enter `none|staging|trained` and has no staging budget.
16499
16538
  */
16500
16539
  var TrackFlagFields = {
16501
16540
  /** Operator marked this track as training material — i.e. `retrainStatus` is
16502
16541
  * `'staging'`. */
16503
16542
  markForTrain: boolean().optional(),
16504
16543
  /** Operator marked this track for diagnostic attention. */
16505
- debug: boolean().optional()
16544
+ debug: boolean().optional(),
16545
+ /** Operator favourited this track. Pins it against pruning. */
16546
+ favourited: boolean().optional()
16506
16547
  };
16507
16548
  /**
16508
16549
  * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
@@ -16527,6 +16568,7 @@ var TrackFlagsSchema = object({
16527
16568
  trackId: string(),
16528
16569
  markForTrain: boolean(),
16529
16570
  debug: boolean(),
16571
+ favourited: boolean(),
16530
16572
  /** The lifecycle state the boolean was derived from. Required here (unlike on
16531
16573
  * a track row) because this shape is only ever produced by the write body,
16532
16574
  * which always knows it — and a surface that has just written needs to render
@@ -17159,6 +17201,12 @@ var TrackCascadeCountsSchema = object({
17159
17201
  /** Per-track CLIP search vectors removed (best-effort). */
17160
17202
  embeddings: number().int()
17161
17203
  });
17204
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17205
+ var DiskReconcileCountsSchema = object({
17206
+ mediaDropped: number().int(),
17207
+ tracks: number().int(),
17208
+ events: number().int()
17209
+ });
17162
17210
  /** Event-store footprint for one camera. */
17163
17211
  var EventStoreDeviceFootprintSchema = object({
17164
17212
  deviceId: number(),
@@ -17335,6 +17383,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17335
17383
  }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17336
17384
  kind: "mutation",
17337
17385
  auth: "admin"
17386
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17387
+ kind: "mutation",
17388
+ auth: "admin"
17338
17389
  }), method(object({
17339
17390
  deviceId: number(),
17340
17391
  trackIds: array(string()).min(1)
@@ -18885,6 +18936,24 @@ var CameraStatusDegradationSchema = object({
18885
18936
  *
18886
18937
  * See spec: `docs/superpowers/specs/2026-06-24-camera-status-aggregator-cap.md`
18887
18938
  */
18939
+ var DiskReconcileJobSchema = object({
18940
+ state: _enum([
18941
+ "idle",
18942
+ "running",
18943
+ "done",
18944
+ "error"
18945
+ ]),
18946
+ total: number().int().nonnegative(),
18947
+ completed: number().int().nonnegative(),
18948
+ currentDeviceId: number().int().nullable(),
18949
+ failed: array(number().int()).readonly(),
18950
+ mediaDropped: number().int().nonnegative(),
18951
+ tracks: number().int().nonnegative(),
18952
+ events: number().int().nonnegative(),
18953
+ startedAtMs: number().int().nullable(),
18954
+ finishedAtMs: number().int().nullable(),
18955
+ error: string().nullable()
18956
+ });
18888
18957
  var CameraStatusSchema = object({
18889
18958
  deviceId: number(),
18890
18959
  assignment: CameraAssignmentStatusSchema,
@@ -19116,7 +19185,10 @@ method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
19116
19185
  }), CameraSwitchGroupSchema, {
19117
19186
  kind: "mutation",
19118
19187
  auth: "admin"
19119
- }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
19188
+ }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), DiskReconcileJobSchema, {
19189
+ kind: "mutation",
19190
+ auth: "admin"
19191
+ }), method(_void(), DiskReconcileJobSchema, { auth: "admin" }), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
19120
19192
  name: string(),
19121
19193
  description: string().optional(),
19122
19194
  config: CameraPipelineConfigSchema
@@ -20293,20 +20365,6 @@ var VectorStatsResultSchema = object({
20293
20365
  exact: boolean()
20294
20366
  });
20295
20367
  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);
20296
- /**
20297
- * `videoclips` — the unified, navigable-clip surface for a camera.
20298
- *
20299
- * A device-scoped WRAPPER cap (like `pipeline-analytics`): exactly one active
20300
- * provider per device, substitutable. The DEFAULT provider (registered by
20301
- * `addon-post-analysis`, `defaultActive: true`) composes the analytics event
20302
- * log (markers + thumbnails) with the recorder's `getPlaybackManifest` — a clip
20303
- * is a time-WINDOW over existing footage, never a separate file. A camera that
20304
- * exposes NATIVE onboard clips (Reolink/Hikvision NVR) can later substitute the
20305
- * wrapper provider for its device and serve its own clip catalog + URLs.
20306
- *
20307
- * A `Clip` is purely time-based (subtree-blind): playback resolves segments by
20308
- * temporal overlap, so the API never decides `continuous` vs `events`.
20309
- */
20310
20368
  var ClipSchema = object({
20311
20369
  /** Opaque, provider-namespaced id. The default provider encodes the time
20312
20370
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -20323,8 +20381,65 @@ var ClipSchema = object({
20323
20381
  startMs: number(),
20324
20382
  endMs: number()
20325
20383
  }),
20326
- /** Thumbnail URL (lazy; e.g. analytics `getEventMedia`). Never inlined. */
20327
- thumbnail: string().optional()
20384
+ /**
20385
+ * Distinct object classes attached to this visit (`person`, `car`, …),
20386
+ * dominant first, capped at {@link MAX_CLIP_LABELS}. The ribbon renders these
20387
+ * instead of the bare kind — "Object" tells the operator nothing a colour bar
20388
+ * did not. Absent (never empty) when the visit attached no classified object
20389
+ * event, so a motion/audio-only visit keeps its kind label.
20390
+ */
20391
+ labels: array(string()).max(3).optional(),
20392
+ /**
20393
+ * Lazy thumbnail URL, never inlined.
20394
+ *
20395
+ * Recording-derived clips (events-mode keep-window, and the prepared
20396
+ * continuous event+fragment visit) MUST use the snapshot of the **main
20397
+ * event of the interval** — `getEventMedia({ eventId, kind: 'snapshot' })`
20398
+ * of the event that owns `kind` (object > motion > audio). Do not extract
20399
+ * a keyframe from the recorded segments. Other providers (onboard, HKSV)
20400
+ * mint their own stills.
20401
+ *
20402
+ * **VOUCHED, never fabricated.** A provider emits this only for an event it
20403
+ * has CONFIRMED owns at least one media row (its own, or its owning track's).
20404
+ * Absent is meaningful — "this visit has no event still" — never "we did not
20405
+ * look". Stamping it from a URL template made 35% of one camera's clips point
20406
+ * at a 404 (device 3836, 2026-08-17: 64 of 179 clips dead, 63 of them motion).
20407
+ * A read that FAILS drops the claim; it never invents it.
20408
+ */
20409
+ thumbnail: string().optional(),
20410
+ /**
20411
+ * An instant INSIDE this visit's footage, hole-safe, where a recorded still
20412
+ * can be decoded. Present whenever the visit came from recorded availability;
20413
+ * absent on a per-event padded window (there is no footage to promise).
20414
+ *
20415
+ * This is not a thumbnail and not a second byte path: it is the argument to
20416
+ * the recorder's existing still route. The surface — never the provider —
20417
+ * decides whether to use it. It is the midpoint of the visit's LONGEST
20418
+ * contiguous range, not of the visit: a visit spans its holes by
20419
+ * construction, so a naive midpoint lands in dead air.
20420
+ */
20421
+ stillAtMs: number().optional(),
20422
+ /**
20423
+ * Analytics event ids that overlap this visit — a BOUNDED sample, newest
20424
+ * first within kind (object → motion → audio), capped at
20425
+ * {@link MAX_CLIP_EVENT_IDS}. Empty on footage-only clips.
20426
+ *
20427
+ * Bounded because it is not a payload the surface pages through: one visit on
20428
+ * device 615 carried 2 345 ids, and `eventIds` was 99% of a 153 KB
20429
+ * camera-day. Read {@link eventCount} for the true total.
20430
+ */
20431
+ eventIds: array(string()).optional(),
20432
+ /** How many analytics events actually overlap this visit. Differs from
20433
+ * `eventIds.length` exactly when the sample was capped — so a truncated
20434
+ * list is never mistaken for a quiet visit. */
20435
+ eventCount: number().int().nonnegative().optional(),
20436
+ /** Intra-visit footage holes (GOP rolls, discarded segments) still shorter
20437
+ * than `VISIT_MERGE_GAP_MS`. Playback concatenates around them; the timeline
20438
+ * bar keeps showing them via `recording.getAvailability`. */
20439
+ holes: array(object({
20440
+ startMs: number(),
20441
+ endMs: number()
20442
+ })).optional()
20328
20443
  });
20329
20444
  var ClipPlaybackSchema = object({
20330
20445
  /** HLS master URL through the hub data-plane (Range + token in path). */
@@ -20788,7 +20903,14 @@ var SearchResultSchema = object({
20788
20903
  });
20789
20904
  var AutoUpdateSettingsSchema = object({
20790
20905
  channel: ChannelSchema,
20791
- intervalSeconds: number()
20906
+ intervalSeconds: number(),
20907
+ /**
20908
+ * Cadence of the "an update exists" POLLER, in seconds. Independent of
20909
+ * `channel`: the poller runs while auto-apply is `off`, because being told
20910
+ * about a publish and installing it are different decisions. Clamped
20911
+ * server-side to 900 s … 604800 s; defaults to 21600 s (6 h).
20912
+ */
20913
+ updateCheckIntervalSeconds: number()
20792
20914
  });
20793
20915
  var AddonAutoUpdateSchema = ChannelWithInheritSchema;
20794
20916
  var RestartAddonResultSchema = unknown();
@@ -20929,7 +21051,9 @@ method(_void(), array(AddonListItemSchema).readonly()), method(object({
20929
21051
  auth: "admin"
20930
21052
  }), method(_void(), AutoUpdateSettingsSchema, { auth: "admin" }), method(object({
20931
21053
  channel: ChannelSchema,
20932
- intervalSeconds: number().min(300).max(86400).optional()
21054
+ intervalSeconds: number().min(300).max(86400).optional(),
21055
+ /** Availability-poll cadence; see AutoUpdateSettingsSchema. */
21056
+ updateCheckIntervalSeconds: number().min(900).max(604800).optional()
20933
21057
  }), unknown(), {
20934
21058
  kind: "mutation",
20935
21059
  auth: "admin"
@@ -26618,7 +26742,9 @@ var ExportOptionsSchema = object({
26618
26742
  includeAudio: boolean(),
26619
26743
  maxLifeMs: number().int().positive(),
26620
26744
  deleteAfterDownload: boolean(),
26621
- title: string().max(200).optional()
26745
+ title: string().max(200).optional(),
26746
+ /** Notification-output target ids to ping when this export becomes ready. */
26747
+ notifyTargetIds: array(string().min(1)).max(20).optional()
26622
26748
  }).superRefine((v, ctx) => {
26623
26749
  if (v.speed !== void 0 && v.timelapse !== void 0) ctx.addIssue({
26624
26750
  code: ZodIssueCode.custom,
@@ -26677,10 +26803,18 @@ var ExportBytesSchema = object({
26677
26803
  });
26678
26804
  method(object({
26679
26805
  deviceId: number(),
26680
- profile: string(),
26806
+ /** @deprecated Prefer `profiles`. Kept so timelapse/notifiers keep working. */
26807
+ profile: string().optional(),
26808
+ profiles: array(string()).min(1).optional(),
26681
26809
  fromMs: number(),
26682
26810
  toMs: number(),
26683
26811
  options: ExportOptionsSchema
26812
+ }).superRefine((v, ctx) => {
26813
+ if ((v.profiles !== void 0 && v.profiles.length > 0 ? v.profiles : v.profile !== void 0 ? [v.profile] : []).length < 1) ctx.addIssue({
26814
+ code: ZodIssueCode.custom,
26815
+ message: "pass profiles[] (min 1) or legacy profile",
26816
+ path: ["profiles"]
26817
+ });
26684
26818
  }), ExportRecordSchema, {
26685
26819
  kind: "mutation",
26686
26820
  auth: "protected"
@@ -29622,15 +29756,6 @@ var BaseDeviceProvider = class extends BaseAddon {
29622
29756
  labels: ["probe not implemented"]
29623
29757
  };
29624
29758
  }
29625
- /**
29626
- * Top-level devices restored at once in {@link onRestoreDevices}.
29627
- *
29628
- * Four covers the fleets this ships to without turning a boot into a burst a
29629
- * camera NVR answers with a refusal. A provider whose upstream is a single
29630
- * session with a serial command channel (a Baichuan hub, an NVR that
29631
- * serialises ISAPI) should lower it; nothing needs to raise it.
29632
- */
29633
- restoreConcurrency = 4;
29634
29759
  async restoreDevices(savedDevices) {
29635
29760
  await this.onRestoreDevices(savedDevices);
29636
29761
  if (savedDevices.length > 0) this.ctx.logger.info(`Restored ${savedDevices.length} ${this.providerName} device(s)`);
@@ -29685,14 +29810,7 @@ var BaseDeviceProvider = class extends BaseAddon {
29685
29810
  });
29686
29811
  }
29687
29812
  };
29688
- let nextTopLevel = 0;
29689
- await Promise.all(Array.from({ length: Math.min(Math.max(1, this.restoreConcurrency), topLevel.length) }, async () => {
29690
- for (;;) {
29691
- const saved = topLevel[nextTopLevel++];
29692
- if (saved === void 0) return;
29693
- await restoreOne(saved);
29694
- }
29695
- }));
29813
+ await Promise.all(topLevel.map((saved) => restoreOne(saved)));
29696
29814
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
29697
29815
  for (const saved of childRows) {
29698
29816
  const Class = this.deviceClasses[saved.type];
@@ -33031,6 +33149,12 @@ Object.freeze({
33031
33149
  addonId: null,
33032
33150
  access: "create"
33033
33151
  },
33152
+ "pipelineAnalytics.reconcileFromDisk": {
33153
+ capName: "pipeline-analytics",
33154
+ capScope: "device",
33155
+ addonId: null,
33156
+ access: "create"
33157
+ },
33034
33158
  "pipelineAnalytics.refreshStorageLocationsForMigration": {
33035
33159
  capName: "pipeline-analytics",
33036
33160
  capScope: "device",
@@ -33433,6 +33557,12 @@ Object.freeze({
33433
33557
  addonId: null,
33434
33558
  access: "view"
33435
33559
  },
33560
+ "pipelineOrchestrator.getReconcileFromDiskStatus": {
33561
+ capName: "pipeline-orchestrator",
33562
+ capScope: "system",
33563
+ addonId: null,
33564
+ access: "view"
33565
+ },
33436
33566
  "pipelineOrchestrator.listAgentSettings": {
33437
33567
  capName: "pipeline-orchestrator",
33438
33568
  capScope: "system",
@@ -33457,6 +33587,12 @@ Object.freeze({
33457
33587
  addonId: null,
33458
33588
  access: "create"
33459
33589
  },
33590
+ "pipelineOrchestrator.reconcileFromDisk": {
33591
+ capName: "pipeline-orchestrator",
33592
+ capScope: "system",
33593
+ addonId: null,
33594
+ access: "create"
33595
+ },
33460
33596
  "pipelineOrchestrator.removeAgentSettings": {
33461
33597
  capName: "pipeline-orchestrator",
33462
33598
  capScope: "system",
@@ -36448,6 +36584,11 @@ Object.freeze({
36448
36584
  form: "single",
36449
36585
  optional: true
36450
36586
  }],
36587
+ "pipelineAnalytics.reconcileFromDisk": [{
36588
+ name: "deviceId",
36589
+ form: "single",
36590
+ optional: false
36591
+ }],
36451
36592
  "pipelineAnalytics.restageRetrainTrack": [{
36452
36593
  name: "deviceId",
36453
36594
  form: "single",
@@ -37577,6 +37718,8 @@ function maskUrlCredentials(rawUrl) {
37577
37718
  return rawUrl;
37578
37719
  }
37579
37720
  }
37721
+ var MB = 1024 * 1024;
37722
+ 1024 * MB, 3072 * MB;
37580
37723
  //#endregion
37581
37724
  //#region src/rtsp-reachability.ts
37582
37725
  /**
package/dist/addon.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import net from "node:net";
2
- //#region ../types/dist/event-category-Bxo5yJjt.mjs
2
+ //#region ../types/dist/event-category-XfKNtfCc.mjs
3
3
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4
4
  EventCategory["SystemBoot"] = "system.boot";
5
5
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -16,9 +16,10 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
16
16
  EventCategory["SystemRestartCompleted"] = "system.restart-completed";
17
17
  /**
18
18
  * A newer addon or server-root package version was found by the
19
- * authoritative registry check. Emitted once per
20
- * `(target, packageName, currentVersion, latestVersion)` transition; repeated
21
- * polling of the same result is deduplicated by the checker.
19
+ * authoritative registry check. Emitted once when any observed
20
+ * `latestVersion` changes (or a package/node first appears behind);
21
+ * the payload carries the full currently-available list. Repeated
22
+ * polling of the same latests is silent.
22
23
  */
23
24
  EventCategory["UpdateAvailable"] = "update.available";
24
25
  /**
@@ -37,6 +38,22 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
37
38
  EventCategory["AddonInstalled"] = "addon.installed";
38
39
  EventCategory["AddonUninstalled"] = "addon.uninstalled";
39
40
  EventCategory["AddonCrashed"] = "addon.crashed";
41
+ /**
42
+ * A RUNNER the D6 crash circuit-breaker gave up on — terminal.
43
+ *
44
+ * `AddonCrashed` is the routine, self-healing fact ("it crashed; it is being
45
+ * respawned"); this is the one that never resolves itself. Emitted exactly
46
+ * once per trip, by `process-service.ts`, carrying the node, the runner, the
47
+ * addons it hosted and the crash count that tripped the breaker.
48
+ *
49
+ * It exists because a runner marked terminally `failed` used to be SILENT:
50
+ * on 2026-08-18 the `recorder` runner died of three unhandled ffmpeg spawn
51
+ * errors, the breaker stopped respawning it (correctly), `/health` kept
52
+ * returning 200, and fleet-wide recording was gone for 3h15 before the
53
+ * operator's phone told him. The Notification Center's system-event intake
54
+ * consumes this category and maps it to the `addon-crash-loop` kind.
55
+ */
56
+ EventCategory["AddonRunnerFailed"] = "addon.runner-failed";
40
57
  EventCategory["AddonError"] = "addon.error";
41
58
  EventCategory["AddonPageReady"] = "addon.page-ready";
42
59
  EventCategory["AddonWidgetReady"] = "addon.widget-ready";
@@ -7580,6 +7597,10 @@ var RecordingBandSchema = object({
7580
7597
  preBufferSec: number().min(0).optional(),
7581
7598
  postBufferSec: number().min(0).optional()
7582
7599
  });
7600
+ ({
7601
+ preBufferSec: 10,
7602
+ postBufferSec: 30
7603
+ }).postBufferSec * 1e3;
7583
7604
  /**
7584
7605
  * Per-device retention overrides. Every field is optional; an unset or `0`
7585
7606
  * value inherits the node-wide recorder default. Only footage-lifetime limits
@@ -7627,6 +7648,12 @@ var RecordingConfigSchema = object({
7627
7648
  /** DERIVED summary of `bands`, stamped by the recorder on every save.
7628
7649
  * Authoring it has no effect — see {@link RecordingStorageModeSchema}. */
7629
7650
  mode: RecordingStorageModeSchema.optional(),
7651
+ /**
7652
+ * Which assigned broker slots to record. Absent / empty = {@link
7653
+ * DEFAULT_RECORDING_PROFILES} (`high`+`low`) intersected with the
7654
+ * camera's currently assigned slots — never `mid` unless the operator
7655
+ * picks it, and never a slot the broker has not assigned.
7656
+ */
7630
7657
  profiles: array(CamProfileSchema).optional(),
7631
7658
  segmentSeconds: number().int().positive().optional(),
7632
7659
  /**
@@ -7707,7 +7734,11 @@ var RelocateFootageInputSchema = object({
7707
7734
  profiles: array(string()).optional(),
7708
7735
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7709
7736
  * never allowed to starve live writers. */
7710
- throttleMbps: number().min(1).max(1e3).optional()
7737
+ throttleMbps: number().min(1).max(1e3).optional(),
7738
+ /** Move only segments whose startMs is >= this. Absent = the whole source
7739
+ * pile. Used when a full drain is too expensive and the operator only
7740
+ * wants the recent window on the new disk. */
7741
+ sinceMs: number().int().optional()
7711
7742
  });
7712
7743
  /** Internal, lease-scoped participant operation. It is intentionally separate
7713
7744
  * from persistent recording settings: a migration never changes
@@ -14572,6 +14603,7 @@ var NcSystemEventKindSchema = _enum([
14572
14603
  "node-offline",
14573
14604
  "node-inference-unavailable",
14574
14605
  "detection-blind",
14606
+ "addon-crash-loop",
14575
14607
  "addon-update-available",
14576
14608
  "server-update-available",
14577
14609
  "alarm-triggered",
@@ -14579,6 +14611,9 @@ var NcSystemEventKindSchema = _enum([
14579
14611
  "alarm-disarmed",
14580
14612
  "alarm-arming",
14581
14613
  "alarm-arm-refused",
14614
+ "addon-updated",
14615
+ "server-updated",
14616
+ "export-completed",
14582
14617
  "camera-online",
14583
14618
  "camera-offline",
14584
14619
  "camera-disabled",
@@ -16472,13 +16507,19 @@ var RetrainStatusSchema = _enum([
16472
16507
  * "never marked" from "already trained" must read `retrainStatus`.
16473
16508
  *
16474
16509
  * `debug` does NOT pin; it is attention, not durability.
16510
+ *
16511
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16512
+ * A favourited track is skipped by retention the same way `staging` is, but
16513
+ * it does not enter `none|staging|trained` and has no staging budget.
16475
16514
  */
16476
16515
  var TrackFlagFields = {
16477
16516
  /** Operator marked this track as training material — i.e. `retrainStatus` is
16478
16517
  * `'staging'`. */
16479
16518
  markForTrain: boolean().optional(),
16480
16519
  /** Operator marked this track for diagnostic attention. */
16481
- debug: boolean().optional()
16520
+ debug: boolean().optional(),
16521
+ /** Operator favourited this track. Pins it against pruning. */
16522
+ favourited: boolean().optional()
16482
16523
  };
16483
16524
  /**
16484
16525
  * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
@@ -16503,6 +16544,7 @@ var TrackFlagsSchema = object({
16503
16544
  trackId: string(),
16504
16545
  markForTrain: boolean(),
16505
16546
  debug: boolean(),
16547
+ favourited: boolean(),
16506
16548
  /** The lifecycle state the boolean was derived from. Required here (unlike on
16507
16549
  * a track row) because this shape is only ever produced by the write body,
16508
16550
  * which always knows it — and a surface that has just written needs to render
@@ -17135,6 +17177,12 @@ var TrackCascadeCountsSchema = object({
17135
17177
  /** Per-track CLIP search vectors removed (best-effort). */
17136
17178
  embeddings: number().int()
17137
17179
  });
17180
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17181
+ var DiskReconcileCountsSchema = object({
17182
+ mediaDropped: number().int(),
17183
+ tracks: number().int(),
17184
+ events: number().int()
17185
+ });
17138
17186
  /** Event-store footprint for one camera. */
17139
17187
  var EventStoreDeviceFootprintSchema = object({
17140
17188
  deviceId: number(),
@@ -17311,6 +17359,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17311
17359
  }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17312
17360
  kind: "mutation",
17313
17361
  auth: "admin"
17362
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17363
+ kind: "mutation",
17364
+ auth: "admin"
17314
17365
  }), method(object({
17315
17366
  deviceId: number(),
17316
17367
  trackIds: array(string()).min(1)
@@ -18861,6 +18912,24 @@ var CameraStatusDegradationSchema = object({
18861
18912
  *
18862
18913
  * See spec: `docs/superpowers/specs/2026-06-24-camera-status-aggregator-cap.md`
18863
18914
  */
18915
+ var DiskReconcileJobSchema = object({
18916
+ state: _enum([
18917
+ "idle",
18918
+ "running",
18919
+ "done",
18920
+ "error"
18921
+ ]),
18922
+ total: number().int().nonnegative(),
18923
+ completed: number().int().nonnegative(),
18924
+ currentDeviceId: number().int().nullable(),
18925
+ failed: array(number().int()).readonly(),
18926
+ mediaDropped: number().int().nonnegative(),
18927
+ tracks: number().int().nonnegative(),
18928
+ events: number().int().nonnegative(),
18929
+ startedAtMs: number().int().nullable(),
18930
+ finishedAtMs: number().int().nullable(),
18931
+ error: string().nullable()
18932
+ });
18864
18933
  var CameraStatusSchema = object({
18865
18934
  deviceId: number(),
18866
18935
  assignment: CameraAssignmentStatusSchema,
@@ -19092,7 +19161,10 @@ method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
19092
19161
  }), CameraSwitchGroupSchema, {
19093
19162
  kind: "mutation",
19094
19163
  auth: "admin"
19095
- }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
19164
+ }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), DiskReconcileJobSchema, {
19165
+ kind: "mutation",
19166
+ auth: "admin"
19167
+ }), method(_void(), DiskReconcileJobSchema, { auth: "admin" }), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
19096
19168
  name: string(),
19097
19169
  description: string().optional(),
19098
19170
  config: CameraPipelineConfigSchema
@@ -20269,20 +20341,6 @@ var VectorStatsResultSchema = object({
20269
20341
  exact: boolean()
20270
20342
  });
20271
20343
  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);
20272
- /**
20273
- * `videoclips` — the unified, navigable-clip surface for a camera.
20274
- *
20275
- * A device-scoped WRAPPER cap (like `pipeline-analytics`): exactly one active
20276
- * provider per device, substitutable. The DEFAULT provider (registered by
20277
- * `addon-post-analysis`, `defaultActive: true`) composes the analytics event
20278
- * log (markers + thumbnails) with the recorder's `getPlaybackManifest` — a clip
20279
- * is a time-WINDOW over existing footage, never a separate file. A camera that
20280
- * exposes NATIVE onboard clips (Reolink/Hikvision NVR) can later substitute the
20281
- * wrapper provider for its device and serve its own clip catalog + URLs.
20282
- *
20283
- * A `Clip` is purely time-based (subtree-blind): playback resolves segments by
20284
- * temporal overlap, so the API never decides `continuous` vs `events`.
20285
- */
20286
20344
  var ClipSchema = object({
20287
20345
  /** Opaque, provider-namespaced id. The default provider encodes the time
20288
20346
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -20299,8 +20357,65 @@ var ClipSchema = object({
20299
20357
  startMs: number(),
20300
20358
  endMs: number()
20301
20359
  }),
20302
- /** Thumbnail URL (lazy; e.g. analytics `getEventMedia`). Never inlined. */
20303
- thumbnail: string().optional()
20360
+ /**
20361
+ * Distinct object classes attached to this visit (`person`, `car`, …),
20362
+ * dominant first, capped at {@link MAX_CLIP_LABELS}. The ribbon renders these
20363
+ * instead of the bare kind — "Object" tells the operator nothing a colour bar
20364
+ * did not. Absent (never empty) when the visit attached no classified object
20365
+ * event, so a motion/audio-only visit keeps its kind label.
20366
+ */
20367
+ labels: array(string()).max(3).optional(),
20368
+ /**
20369
+ * Lazy thumbnail URL, never inlined.
20370
+ *
20371
+ * Recording-derived clips (events-mode keep-window, and the prepared
20372
+ * continuous event+fragment visit) MUST use the snapshot of the **main
20373
+ * event of the interval** — `getEventMedia({ eventId, kind: 'snapshot' })`
20374
+ * of the event that owns `kind` (object > motion > audio). Do not extract
20375
+ * a keyframe from the recorded segments. Other providers (onboard, HKSV)
20376
+ * mint their own stills.
20377
+ *
20378
+ * **VOUCHED, never fabricated.** A provider emits this only for an event it
20379
+ * has CONFIRMED owns at least one media row (its own, or its owning track's).
20380
+ * Absent is meaningful — "this visit has no event still" — never "we did not
20381
+ * look". Stamping it from a URL template made 35% of one camera's clips point
20382
+ * at a 404 (device 3836, 2026-08-17: 64 of 179 clips dead, 63 of them motion).
20383
+ * A read that FAILS drops the claim; it never invents it.
20384
+ */
20385
+ thumbnail: string().optional(),
20386
+ /**
20387
+ * An instant INSIDE this visit's footage, hole-safe, where a recorded still
20388
+ * can be decoded. Present whenever the visit came from recorded availability;
20389
+ * absent on a per-event padded window (there is no footage to promise).
20390
+ *
20391
+ * This is not a thumbnail and not a second byte path: it is the argument to
20392
+ * the recorder's existing still route. The surface — never the provider —
20393
+ * decides whether to use it. It is the midpoint of the visit's LONGEST
20394
+ * contiguous range, not of the visit: a visit spans its holes by
20395
+ * construction, so a naive midpoint lands in dead air.
20396
+ */
20397
+ stillAtMs: number().optional(),
20398
+ /**
20399
+ * Analytics event ids that overlap this visit — a BOUNDED sample, newest
20400
+ * first within kind (object → motion → audio), capped at
20401
+ * {@link MAX_CLIP_EVENT_IDS}. Empty on footage-only clips.
20402
+ *
20403
+ * Bounded because it is not a payload the surface pages through: one visit on
20404
+ * device 615 carried 2 345 ids, and `eventIds` was 99% of a 153 KB
20405
+ * camera-day. Read {@link eventCount} for the true total.
20406
+ */
20407
+ eventIds: array(string()).optional(),
20408
+ /** How many analytics events actually overlap this visit. Differs from
20409
+ * `eventIds.length` exactly when the sample was capped — so a truncated
20410
+ * list is never mistaken for a quiet visit. */
20411
+ eventCount: number().int().nonnegative().optional(),
20412
+ /** Intra-visit footage holes (GOP rolls, discarded segments) still shorter
20413
+ * than `VISIT_MERGE_GAP_MS`. Playback concatenates around them; the timeline
20414
+ * bar keeps showing them via `recording.getAvailability`. */
20415
+ holes: array(object({
20416
+ startMs: number(),
20417
+ endMs: number()
20418
+ })).optional()
20304
20419
  });
20305
20420
  var ClipPlaybackSchema = object({
20306
20421
  /** HLS master URL through the hub data-plane (Range + token in path). */
@@ -20764,7 +20879,14 @@ var SearchResultSchema = object({
20764
20879
  });
20765
20880
  var AutoUpdateSettingsSchema = object({
20766
20881
  channel: ChannelSchema,
20767
- intervalSeconds: number()
20882
+ intervalSeconds: number(),
20883
+ /**
20884
+ * Cadence of the "an update exists" POLLER, in seconds. Independent of
20885
+ * `channel`: the poller runs while auto-apply is `off`, because being told
20886
+ * about a publish and installing it are different decisions. Clamped
20887
+ * server-side to 900 s … 604800 s; defaults to 21600 s (6 h).
20888
+ */
20889
+ updateCheckIntervalSeconds: number()
20768
20890
  });
20769
20891
  var AddonAutoUpdateSchema = ChannelWithInheritSchema;
20770
20892
  var RestartAddonResultSchema = unknown();
@@ -20905,7 +21027,9 @@ method(_void(), array(AddonListItemSchema).readonly()), method(object({
20905
21027
  auth: "admin"
20906
21028
  }), method(_void(), AutoUpdateSettingsSchema, { auth: "admin" }), method(object({
20907
21029
  channel: ChannelSchema,
20908
- intervalSeconds: number().min(300).max(86400).optional()
21030
+ intervalSeconds: number().min(300).max(86400).optional(),
21031
+ /** Availability-poll cadence; see AutoUpdateSettingsSchema. */
21032
+ updateCheckIntervalSeconds: number().min(900).max(604800).optional()
20909
21033
  }), unknown(), {
20910
21034
  kind: "mutation",
20911
21035
  auth: "admin"
@@ -26594,7 +26718,9 @@ var ExportOptionsSchema = object({
26594
26718
  includeAudio: boolean(),
26595
26719
  maxLifeMs: number().int().positive(),
26596
26720
  deleteAfterDownload: boolean(),
26597
- title: string().max(200).optional()
26721
+ title: string().max(200).optional(),
26722
+ /** Notification-output target ids to ping when this export becomes ready. */
26723
+ notifyTargetIds: array(string().min(1)).max(20).optional()
26598
26724
  }).superRefine((v, ctx) => {
26599
26725
  if (v.speed !== void 0 && v.timelapse !== void 0) ctx.addIssue({
26600
26726
  code: ZodIssueCode.custom,
@@ -26653,10 +26779,18 @@ var ExportBytesSchema = object({
26653
26779
  });
26654
26780
  method(object({
26655
26781
  deviceId: number(),
26656
- profile: string(),
26782
+ /** @deprecated Prefer `profiles`. Kept so timelapse/notifiers keep working. */
26783
+ profile: string().optional(),
26784
+ profiles: array(string()).min(1).optional(),
26657
26785
  fromMs: number(),
26658
26786
  toMs: number(),
26659
26787
  options: ExportOptionsSchema
26788
+ }).superRefine((v, ctx) => {
26789
+ if ((v.profiles !== void 0 && v.profiles.length > 0 ? v.profiles : v.profile !== void 0 ? [v.profile] : []).length < 1) ctx.addIssue({
26790
+ code: ZodIssueCode.custom,
26791
+ message: "pass profiles[] (min 1) or legacy profile",
26792
+ path: ["profiles"]
26793
+ });
26660
26794
  }), ExportRecordSchema, {
26661
26795
  kind: "mutation",
26662
26796
  auth: "protected"
@@ -29598,15 +29732,6 @@ var BaseDeviceProvider = class extends BaseAddon {
29598
29732
  labels: ["probe not implemented"]
29599
29733
  };
29600
29734
  }
29601
- /**
29602
- * Top-level devices restored at once in {@link onRestoreDevices}.
29603
- *
29604
- * Four covers the fleets this ships to without turning a boot into a burst a
29605
- * camera NVR answers with a refusal. A provider whose upstream is a single
29606
- * session with a serial command channel (a Baichuan hub, an NVR that
29607
- * serialises ISAPI) should lower it; nothing needs to raise it.
29608
- */
29609
- restoreConcurrency = 4;
29610
29735
  async restoreDevices(savedDevices) {
29611
29736
  await this.onRestoreDevices(savedDevices);
29612
29737
  if (savedDevices.length > 0) this.ctx.logger.info(`Restored ${savedDevices.length} ${this.providerName} device(s)`);
@@ -29661,14 +29786,7 @@ var BaseDeviceProvider = class extends BaseAddon {
29661
29786
  });
29662
29787
  }
29663
29788
  };
29664
- let nextTopLevel = 0;
29665
- await Promise.all(Array.from({ length: Math.min(Math.max(1, this.restoreConcurrency), topLevel.length) }, async () => {
29666
- for (;;) {
29667
- const saved = topLevel[nextTopLevel++];
29668
- if (saved === void 0) return;
29669
- await restoreOne(saved);
29670
- }
29671
- }));
29789
+ await Promise.all(topLevel.map((saved) => restoreOne(saved)));
29672
29790
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
29673
29791
  for (const saved of childRows) {
29674
29792
  const Class = this.deviceClasses[saved.type];
@@ -33007,6 +33125,12 @@ Object.freeze({
33007
33125
  addonId: null,
33008
33126
  access: "create"
33009
33127
  },
33128
+ "pipelineAnalytics.reconcileFromDisk": {
33129
+ capName: "pipeline-analytics",
33130
+ capScope: "device",
33131
+ addonId: null,
33132
+ access: "create"
33133
+ },
33010
33134
  "pipelineAnalytics.refreshStorageLocationsForMigration": {
33011
33135
  capName: "pipeline-analytics",
33012
33136
  capScope: "device",
@@ -33409,6 +33533,12 @@ Object.freeze({
33409
33533
  addonId: null,
33410
33534
  access: "view"
33411
33535
  },
33536
+ "pipelineOrchestrator.getReconcileFromDiskStatus": {
33537
+ capName: "pipeline-orchestrator",
33538
+ capScope: "system",
33539
+ addonId: null,
33540
+ access: "view"
33541
+ },
33412
33542
  "pipelineOrchestrator.listAgentSettings": {
33413
33543
  capName: "pipeline-orchestrator",
33414
33544
  capScope: "system",
@@ -33433,6 +33563,12 @@ Object.freeze({
33433
33563
  addonId: null,
33434
33564
  access: "create"
33435
33565
  },
33566
+ "pipelineOrchestrator.reconcileFromDisk": {
33567
+ capName: "pipeline-orchestrator",
33568
+ capScope: "system",
33569
+ addonId: null,
33570
+ access: "create"
33571
+ },
33436
33572
  "pipelineOrchestrator.removeAgentSettings": {
33437
33573
  capName: "pipeline-orchestrator",
33438
33574
  capScope: "system",
@@ -36424,6 +36560,11 @@ Object.freeze({
36424
36560
  form: "single",
36425
36561
  optional: true
36426
36562
  }],
36563
+ "pipelineAnalytics.reconcileFromDisk": [{
36564
+ name: "deviceId",
36565
+ form: "single",
36566
+ optional: false
36567
+ }],
36427
36568
  "pipelineAnalytics.restageRetrainTrack": [{
36428
36569
  name: "deviceId",
36429
36570
  form: "single",
@@ -37553,6 +37694,8 @@ function maskUrlCredentials(rawUrl) {
37553
37694
  return rawUrl;
37554
37695
  }
37555
37696
  }
37697
+ var MB = 1024 * 1024;
37698
+ 1024 * MB, 3072 * MB;
37556
37699
  //#endregion
37557
37700
  //#region src/rtsp-reachability.ts
37558
37701
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-rtsp",
3
- "version": "1.2.20",
3
+ "version": "1.2.22",
4
4
  "description": "Generic RTSP camera device provider addon for CamStack",
5
5
  "keywords": [
6
6
  "camstack",