@camstack/addon-provider-rtsp 1.2.19 → 1.2.21

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 -45
  2. package/dist/addon.mjs +187 -45
  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
@@ -19619,7 +19691,14 @@ targets: array(object({
19619
19691
  "sleeping",
19620
19692
  "unreachable",
19621
19693
  "waking"
19622
- ]).nullable()
19694
+ ]).nullable(),
19695
+ /** A battery camera (whatever its current state). An AWAKE battery
19696
+ * camera is deliberately NOT recaptured on the poll cadence — every
19697
+ * capture is a camera hit that would keep it out of sleep — so its
19698
+ * cached frame legitimately ages past the currency ceiling while
19699
+ * nothing is streaming. A surface must keep painting it (a fresh
19700
+ * frame is captured at each wake), not blank to "unavailable". */
19701
+ battery: boolean()
19623
19702
  })))
19624
19703
  },
19625
19704
  status: {
@@ -20286,20 +20365,6 @@ var VectorStatsResultSchema = object({
20286
20365
  exact: boolean()
20287
20366
  });
20288
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);
20289
- /**
20290
- * `videoclips` — the unified, navigable-clip surface for a camera.
20291
- *
20292
- * A device-scoped WRAPPER cap (like `pipeline-analytics`): exactly one active
20293
- * provider per device, substitutable. The DEFAULT provider (registered by
20294
- * `addon-post-analysis`, `defaultActive: true`) composes the analytics event
20295
- * log (markers + thumbnails) with the recorder's `getPlaybackManifest` — a clip
20296
- * is a time-WINDOW over existing footage, never a separate file. A camera that
20297
- * exposes NATIVE onboard clips (Reolink/Hikvision NVR) can later substitute the
20298
- * wrapper provider for its device and serve its own clip catalog + URLs.
20299
- *
20300
- * A `Clip` is purely time-based (subtree-blind): playback resolves segments by
20301
- * temporal overlap, so the API never decides `continuous` vs `events`.
20302
- */
20303
20368
  var ClipSchema = object({
20304
20369
  /** Opaque, provider-namespaced id. The default provider encodes the time
20305
20370
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -20316,8 +20381,57 @@ var ClipSchema = object({
20316
20381
  startMs: number(),
20317
20382
  endMs: number()
20318
20383
  }),
20319
- /** Thumbnail URL (lazy; e.g. analytics `getEventMedia`). Never inlined. */
20320
- thumbnail: string().optional()
20384
+ /**
20385
+ * Lazy thumbnail URL, never inlined.
20386
+ *
20387
+ * Recording-derived clips (events-mode keep-window, and the prepared
20388
+ * continuous event+fragment visit) MUST use the snapshot of the **main
20389
+ * event of the interval** — `getEventMedia({ eventId, kind: 'snapshot' })`
20390
+ * of the event that owns `kind` (object > motion > audio). Do not extract
20391
+ * a keyframe from the recorded segments. Other providers (onboard, HKSV)
20392
+ * mint their own stills.
20393
+ *
20394
+ * **VOUCHED, never fabricated.** A provider emits this only for an event it
20395
+ * has CONFIRMED owns at least one media row (its own, or its owning track's).
20396
+ * Absent is meaningful — "this visit has no event still" — never "we did not
20397
+ * look". Stamping it from a URL template made 35% of one camera's clips point
20398
+ * at a 404 (device 3836, 2026-08-17: 64 of 179 clips dead, 63 of them motion).
20399
+ * A read that FAILS drops the claim; it never invents it.
20400
+ */
20401
+ thumbnail: string().optional(),
20402
+ /**
20403
+ * An instant INSIDE this visit's footage, hole-safe, where a recorded still
20404
+ * can be decoded. Present whenever the visit came from recorded availability;
20405
+ * absent on a per-event padded window (there is no footage to promise).
20406
+ *
20407
+ * This is not a thumbnail and not a second byte path: it is the argument to
20408
+ * the recorder's existing still route. The surface — never the provider —
20409
+ * decides whether to use it. It is the midpoint of the visit's LONGEST
20410
+ * contiguous range, not of the visit: a visit spans its holes by
20411
+ * construction, so a naive midpoint lands in dead air.
20412
+ */
20413
+ stillAtMs: number().optional(),
20414
+ /**
20415
+ * Analytics event ids that overlap this visit — a BOUNDED sample, newest
20416
+ * first within kind (object → motion → audio), capped at
20417
+ * {@link MAX_CLIP_EVENT_IDS}. Empty on footage-only clips.
20418
+ *
20419
+ * Bounded because it is not a payload the surface pages through: one visit on
20420
+ * device 615 carried 2 345 ids, and `eventIds` was 99% of a 153 KB
20421
+ * camera-day. Read {@link eventCount} for the true total.
20422
+ */
20423
+ eventIds: array(string()).optional(),
20424
+ /** How many analytics events actually overlap this visit. Differs from
20425
+ * `eventIds.length` exactly when the sample was capped — so a truncated
20426
+ * list is never mistaken for a quiet visit. */
20427
+ eventCount: number().int().nonnegative().optional(),
20428
+ /** Intra-visit footage holes (GOP rolls, discarded segments) still shorter
20429
+ * than `VISIT_MERGE_GAP_MS`. Playback concatenates around them; the timeline
20430
+ * bar keeps showing them via `recording.getAvailability`. */
20431
+ holes: array(object({
20432
+ startMs: number(),
20433
+ endMs: number()
20434
+ })).optional()
20321
20435
  });
20322
20436
  var ClipPlaybackSchema = object({
20323
20437
  /** HLS master URL through the hub data-plane (Range + token in path). */
@@ -20781,7 +20895,14 @@ var SearchResultSchema = object({
20781
20895
  });
20782
20896
  var AutoUpdateSettingsSchema = object({
20783
20897
  channel: ChannelSchema,
20784
- intervalSeconds: number()
20898
+ intervalSeconds: number(),
20899
+ /**
20900
+ * Cadence of the "an update exists" POLLER, in seconds. Independent of
20901
+ * `channel`: the poller runs while auto-apply is `off`, because being told
20902
+ * about a publish and installing it are different decisions. Clamped
20903
+ * server-side to 900 s … 604800 s; defaults to 21600 s (6 h).
20904
+ */
20905
+ updateCheckIntervalSeconds: number()
20785
20906
  });
20786
20907
  var AddonAutoUpdateSchema = ChannelWithInheritSchema;
20787
20908
  var RestartAddonResultSchema = unknown();
@@ -20922,7 +21043,9 @@ method(_void(), array(AddonListItemSchema).readonly()), method(object({
20922
21043
  auth: "admin"
20923
21044
  }), method(_void(), AutoUpdateSettingsSchema, { auth: "admin" }), method(object({
20924
21045
  channel: ChannelSchema,
20925
- intervalSeconds: number().min(300).max(86400).optional()
21046
+ intervalSeconds: number().min(300).max(86400).optional(),
21047
+ /** Availability-poll cadence; see AutoUpdateSettingsSchema. */
21048
+ updateCheckIntervalSeconds: number().min(900).max(604800).optional()
20926
21049
  }), unknown(), {
20927
21050
  kind: "mutation",
20928
21051
  auth: "admin"
@@ -26611,7 +26734,9 @@ var ExportOptionsSchema = object({
26611
26734
  includeAudio: boolean(),
26612
26735
  maxLifeMs: number().int().positive(),
26613
26736
  deleteAfterDownload: boolean(),
26614
- title: string().max(200).optional()
26737
+ title: string().max(200).optional(),
26738
+ /** Notification-output target ids to ping when this export becomes ready. */
26739
+ notifyTargetIds: array(string().min(1)).max(20).optional()
26615
26740
  }).superRefine((v, ctx) => {
26616
26741
  if (v.speed !== void 0 && v.timelapse !== void 0) ctx.addIssue({
26617
26742
  code: ZodIssueCode.custom,
@@ -26670,10 +26795,18 @@ var ExportBytesSchema = object({
26670
26795
  });
26671
26796
  method(object({
26672
26797
  deviceId: number(),
26673
- profile: string(),
26798
+ /** @deprecated Prefer `profiles`. Kept so timelapse/notifiers keep working. */
26799
+ profile: string().optional(),
26800
+ profiles: array(string()).min(1).optional(),
26674
26801
  fromMs: number(),
26675
26802
  toMs: number(),
26676
26803
  options: ExportOptionsSchema
26804
+ }).superRefine((v, ctx) => {
26805
+ if ((v.profiles !== void 0 && v.profiles.length > 0 ? v.profiles : v.profile !== void 0 ? [v.profile] : []).length < 1) ctx.addIssue({
26806
+ code: ZodIssueCode.custom,
26807
+ message: "pass profiles[] (min 1) or legacy profile",
26808
+ path: ["profiles"]
26809
+ });
26677
26810
  }), ExportRecordSchema, {
26678
26811
  kind: "mutation",
26679
26812
  auth: "protected"
@@ -29615,15 +29748,6 @@ var BaseDeviceProvider = class extends BaseAddon {
29615
29748
  labels: ["probe not implemented"]
29616
29749
  };
29617
29750
  }
29618
- /**
29619
- * Top-level devices restored at once in {@link onRestoreDevices}.
29620
- *
29621
- * Four covers the fleets this ships to without turning a boot into a burst a
29622
- * camera NVR answers with a refusal. A provider whose upstream is a single
29623
- * session with a serial command channel (a Baichuan hub, an NVR that
29624
- * serialises ISAPI) should lower it; nothing needs to raise it.
29625
- */
29626
- restoreConcurrency = 4;
29627
29751
  async restoreDevices(savedDevices) {
29628
29752
  await this.onRestoreDevices(savedDevices);
29629
29753
  if (savedDevices.length > 0) this.ctx.logger.info(`Restored ${savedDevices.length} ${this.providerName} device(s)`);
@@ -29678,14 +29802,7 @@ var BaseDeviceProvider = class extends BaseAddon {
29678
29802
  });
29679
29803
  }
29680
29804
  };
29681
- let nextTopLevel = 0;
29682
- await Promise.all(Array.from({ length: Math.min(Math.max(1, this.restoreConcurrency), topLevel.length) }, async () => {
29683
- for (;;) {
29684
- const saved = topLevel[nextTopLevel++];
29685
- if (saved === void 0) return;
29686
- await restoreOne(saved);
29687
- }
29688
- }));
29805
+ await Promise.all(topLevel.map((saved) => restoreOne(saved)));
29689
29806
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
29690
29807
  for (const saved of childRows) {
29691
29808
  const Class = this.deviceClasses[saved.type];
@@ -33024,6 +33141,12 @@ Object.freeze({
33024
33141
  addonId: null,
33025
33142
  access: "create"
33026
33143
  },
33144
+ "pipelineAnalytics.reconcileFromDisk": {
33145
+ capName: "pipeline-analytics",
33146
+ capScope: "device",
33147
+ addonId: null,
33148
+ access: "create"
33149
+ },
33027
33150
  "pipelineAnalytics.refreshStorageLocationsForMigration": {
33028
33151
  capName: "pipeline-analytics",
33029
33152
  capScope: "device",
@@ -33426,6 +33549,12 @@ Object.freeze({
33426
33549
  addonId: null,
33427
33550
  access: "view"
33428
33551
  },
33552
+ "pipelineOrchestrator.getReconcileFromDiskStatus": {
33553
+ capName: "pipeline-orchestrator",
33554
+ capScope: "system",
33555
+ addonId: null,
33556
+ access: "view"
33557
+ },
33429
33558
  "pipelineOrchestrator.listAgentSettings": {
33430
33559
  capName: "pipeline-orchestrator",
33431
33560
  capScope: "system",
@@ -33450,6 +33579,12 @@ Object.freeze({
33450
33579
  addonId: null,
33451
33580
  access: "create"
33452
33581
  },
33582
+ "pipelineOrchestrator.reconcileFromDisk": {
33583
+ capName: "pipeline-orchestrator",
33584
+ capScope: "system",
33585
+ addonId: null,
33586
+ access: "create"
33587
+ },
33453
33588
  "pipelineOrchestrator.removeAgentSettings": {
33454
33589
  capName: "pipeline-orchestrator",
33455
33590
  capScope: "system",
@@ -36441,6 +36576,11 @@ Object.freeze({
36441
36576
  form: "single",
36442
36577
  optional: true
36443
36578
  }],
36579
+ "pipelineAnalytics.reconcileFromDisk": [{
36580
+ name: "deviceId",
36581
+ form: "single",
36582
+ optional: false
36583
+ }],
36444
36584
  "pipelineAnalytics.restageRetrainTrack": [{
36445
36585
  name: "deviceId",
36446
36586
  form: "single",
@@ -37570,6 +37710,8 @@ function maskUrlCredentials(rawUrl) {
37570
37710
  return rawUrl;
37571
37711
  }
37572
37712
  }
37713
+ var MB = 1024 * 1024;
37714
+ 1024 * MB, 3072 * MB;
37573
37715
  //#endregion
37574
37716
  //#region src/rtsp-reachability.ts
37575
37717
  /**
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
@@ -19595,7 +19667,14 @@ targets: array(object({
19595
19667
  "sleeping",
19596
19668
  "unreachable",
19597
19669
  "waking"
19598
- ]).nullable()
19670
+ ]).nullable(),
19671
+ /** A battery camera (whatever its current state). An AWAKE battery
19672
+ * camera is deliberately NOT recaptured on the poll cadence — every
19673
+ * capture is a camera hit that would keep it out of sleep — so its
19674
+ * cached frame legitimately ages past the currency ceiling while
19675
+ * nothing is streaming. A surface must keep painting it (a fresh
19676
+ * frame is captured at each wake), not blank to "unavailable". */
19677
+ battery: boolean()
19599
19678
  })))
19600
19679
  },
19601
19680
  status: {
@@ -20262,20 +20341,6 @@ var VectorStatsResultSchema = object({
20262
20341
  exact: boolean()
20263
20342
  });
20264
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);
20265
- /**
20266
- * `videoclips` — the unified, navigable-clip surface for a camera.
20267
- *
20268
- * A device-scoped WRAPPER cap (like `pipeline-analytics`): exactly one active
20269
- * provider per device, substitutable. The DEFAULT provider (registered by
20270
- * `addon-post-analysis`, `defaultActive: true`) composes the analytics event
20271
- * log (markers + thumbnails) with the recorder's `getPlaybackManifest` — a clip
20272
- * is a time-WINDOW over existing footage, never a separate file. A camera that
20273
- * exposes NATIVE onboard clips (Reolink/Hikvision NVR) can later substitute the
20274
- * wrapper provider for its device and serve its own clip catalog + URLs.
20275
- *
20276
- * A `Clip` is purely time-based (subtree-blind): playback resolves segments by
20277
- * temporal overlap, so the API never decides `continuous` vs `events`.
20278
- */
20279
20344
  var ClipSchema = object({
20280
20345
  /** Opaque, provider-namespaced id. The default provider encodes the time
20281
20346
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -20292,8 +20357,57 @@ var ClipSchema = object({
20292
20357
  startMs: number(),
20293
20358
  endMs: number()
20294
20359
  }),
20295
- /** Thumbnail URL (lazy; e.g. analytics `getEventMedia`). Never inlined. */
20296
- thumbnail: string().optional()
20360
+ /**
20361
+ * Lazy thumbnail URL, never inlined.
20362
+ *
20363
+ * Recording-derived clips (events-mode keep-window, and the prepared
20364
+ * continuous event+fragment visit) MUST use the snapshot of the **main
20365
+ * event of the interval** — `getEventMedia({ eventId, kind: 'snapshot' })`
20366
+ * of the event that owns `kind` (object > motion > audio). Do not extract
20367
+ * a keyframe from the recorded segments. Other providers (onboard, HKSV)
20368
+ * mint their own stills.
20369
+ *
20370
+ * **VOUCHED, never fabricated.** A provider emits this only for an event it
20371
+ * has CONFIRMED owns at least one media row (its own, or its owning track's).
20372
+ * Absent is meaningful — "this visit has no event still" — never "we did not
20373
+ * look". Stamping it from a URL template made 35% of one camera's clips point
20374
+ * at a 404 (device 3836, 2026-08-17: 64 of 179 clips dead, 63 of them motion).
20375
+ * A read that FAILS drops the claim; it never invents it.
20376
+ */
20377
+ thumbnail: string().optional(),
20378
+ /**
20379
+ * An instant INSIDE this visit's footage, hole-safe, where a recorded still
20380
+ * can be decoded. Present whenever the visit came from recorded availability;
20381
+ * absent on a per-event padded window (there is no footage to promise).
20382
+ *
20383
+ * This is not a thumbnail and not a second byte path: it is the argument to
20384
+ * the recorder's existing still route. The surface — never the provider —
20385
+ * decides whether to use it. It is the midpoint of the visit's LONGEST
20386
+ * contiguous range, not of the visit: a visit spans its holes by
20387
+ * construction, so a naive midpoint lands in dead air.
20388
+ */
20389
+ stillAtMs: number().optional(),
20390
+ /**
20391
+ * Analytics event ids that overlap this visit — a BOUNDED sample, newest
20392
+ * first within kind (object → motion → audio), capped at
20393
+ * {@link MAX_CLIP_EVENT_IDS}. Empty on footage-only clips.
20394
+ *
20395
+ * Bounded because it is not a payload the surface pages through: one visit on
20396
+ * device 615 carried 2 345 ids, and `eventIds` was 99% of a 153 KB
20397
+ * camera-day. Read {@link eventCount} for the true total.
20398
+ */
20399
+ eventIds: array(string()).optional(),
20400
+ /** How many analytics events actually overlap this visit. Differs from
20401
+ * `eventIds.length` exactly when the sample was capped — so a truncated
20402
+ * list is never mistaken for a quiet visit. */
20403
+ eventCount: number().int().nonnegative().optional(),
20404
+ /** Intra-visit footage holes (GOP rolls, discarded segments) still shorter
20405
+ * than `VISIT_MERGE_GAP_MS`. Playback concatenates around them; the timeline
20406
+ * bar keeps showing them via `recording.getAvailability`. */
20407
+ holes: array(object({
20408
+ startMs: number(),
20409
+ endMs: number()
20410
+ })).optional()
20297
20411
  });
20298
20412
  var ClipPlaybackSchema = object({
20299
20413
  /** HLS master URL through the hub data-plane (Range + token in path). */
@@ -20757,7 +20871,14 @@ var SearchResultSchema = object({
20757
20871
  });
20758
20872
  var AutoUpdateSettingsSchema = object({
20759
20873
  channel: ChannelSchema,
20760
- intervalSeconds: number()
20874
+ intervalSeconds: number(),
20875
+ /**
20876
+ * Cadence of the "an update exists" POLLER, in seconds. Independent of
20877
+ * `channel`: the poller runs while auto-apply is `off`, because being told
20878
+ * about a publish and installing it are different decisions. Clamped
20879
+ * server-side to 900 s … 604800 s; defaults to 21600 s (6 h).
20880
+ */
20881
+ updateCheckIntervalSeconds: number()
20761
20882
  });
20762
20883
  var AddonAutoUpdateSchema = ChannelWithInheritSchema;
20763
20884
  var RestartAddonResultSchema = unknown();
@@ -20898,7 +21019,9 @@ method(_void(), array(AddonListItemSchema).readonly()), method(object({
20898
21019
  auth: "admin"
20899
21020
  }), method(_void(), AutoUpdateSettingsSchema, { auth: "admin" }), method(object({
20900
21021
  channel: ChannelSchema,
20901
- intervalSeconds: number().min(300).max(86400).optional()
21022
+ intervalSeconds: number().min(300).max(86400).optional(),
21023
+ /** Availability-poll cadence; see AutoUpdateSettingsSchema. */
21024
+ updateCheckIntervalSeconds: number().min(900).max(604800).optional()
20902
21025
  }), unknown(), {
20903
21026
  kind: "mutation",
20904
21027
  auth: "admin"
@@ -26587,7 +26710,9 @@ var ExportOptionsSchema = object({
26587
26710
  includeAudio: boolean(),
26588
26711
  maxLifeMs: number().int().positive(),
26589
26712
  deleteAfterDownload: boolean(),
26590
- title: string().max(200).optional()
26713
+ title: string().max(200).optional(),
26714
+ /** Notification-output target ids to ping when this export becomes ready. */
26715
+ notifyTargetIds: array(string().min(1)).max(20).optional()
26591
26716
  }).superRefine((v, ctx) => {
26592
26717
  if (v.speed !== void 0 && v.timelapse !== void 0) ctx.addIssue({
26593
26718
  code: ZodIssueCode.custom,
@@ -26646,10 +26771,18 @@ var ExportBytesSchema = object({
26646
26771
  });
26647
26772
  method(object({
26648
26773
  deviceId: number(),
26649
- profile: string(),
26774
+ /** @deprecated Prefer `profiles`. Kept so timelapse/notifiers keep working. */
26775
+ profile: string().optional(),
26776
+ profiles: array(string()).min(1).optional(),
26650
26777
  fromMs: number(),
26651
26778
  toMs: number(),
26652
26779
  options: ExportOptionsSchema
26780
+ }).superRefine((v, ctx) => {
26781
+ if ((v.profiles !== void 0 && v.profiles.length > 0 ? v.profiles : v.profile !== void 0 ? [v.profile] : []).length < 1) ctx.addIssue({
26782
+ code: ZodIssueCode.custom,
26783
+ message: "pass profiles[] (min 1) or legacy profile",
26784
+ path: ["profiles"]
26785
+ });
26653
26786
  }), ExportRecordSchema, {
26654
26787
  kind: "mutation",
26655
26788
  auth: "protected"
@@ -29591,15 +29724,6 @@ var BaseDeviceProvider = class extends BaseAddon {
29591
29724
  labels: ["probe not implemented"]
29592
29725
  };
29593
29726
  }
29594
- /**
29595
- * Top-level devices restored at once in {@link onRestoreDevices}.
29596
- *
29597
- * Four covers the fleets this ships to without turning a boot into a burst a
29598
- * camera NVR answers with a refusal. A provider whose upstream is a single
29599
- * session with a serial command channel (a Baichuan hub, an NVR that
29600
- * serialises ISAPI) should lower it; nothing needs to raise it.
29601
- */
29602
- restoreConcurrency = 4;
29603
29727
  async restoreDevices(savedDevices) {
29604
29728
  await this.onRestoreDevices(savedDevices);
29605
29729
  if (savedDevices.length > 0) this.ctx.logger.info(`Restored ${savedDevices.length} ${this.providerName} device(s)`);
@@ -29654,14 +29778,7 @@ var BaseDeviceProvider = class extends BaseAddon {
29654
29778
  });
29655
29779
  }
29656
29780
  };
29657
- let nextTopLevel = 0;
29658
- await Promise.all(Array.from({ length: Math.min(Math.max(1, this.restoreConcurrency), topLevel.length) }, async () => {
29659
- for (;;) {
29660
- const saved = topLevel[nextTopLevel++];
29661
- if (saved === void 0) return;
29662
- await restoreOne(saved);
29663
- }
29664
- }));
29781
+ await Promise.all(topLevel.map((saved) => restoreOne(saved)));
29665
29782
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
29666
29783
  for (const saved of childRows) {
29667
29784
  const Class = this.deviceClasses[saved.type];
@@ -33000,6 +33117,12 @@ Object.freeze({
33000
33117
  addonId: null,
33001
33118
  access: "create"
33002
33119
  },
33120
+ "pipelineAnalytics.reconcileFromDisk": {
33121
+ capName: "pipeline-analytics",
33122
+ capScope: "device",
33123
+ addonId: null,
33124
+ access: "create"
33125
+ },
33003
33126
  "pipelineAnalytics.refreshStorageLocationsForMigration": {
33004
33127
  capName: "pipeline-analytics",
33005
33128
  capScope: "device",
@@ -33402,6 +33525,12 @@ Object.freeze({
33402
33525
  addonId: null,
33403
33526
  access: "view"
33404
33527
  },
33528
+ "pipelineOrchestrator.getReconcileFromDiskStatus": {
33529
+ capName: "pipeline-orchestrator",
33530
+ capScope: "system",
33531
+ addonId: null,
33532
+ access: "view"
33533
+ },
33405
33534
  "pipelineOrchestrator.listAgentSettings": {
33406
33535
  capName: "pipeline-orchestrator",
33407
33536
  capScope: "system",
@@ -33426,6 +33555,12 @@ Object.freeze({
33426
33555
  addonId: null,
33427
33556
  access: "create"
33428
33557
  },
33558
+ "pipelineOrchestrator.reconcileFromDisk": {
33559
+ capName: "pipeline-orchestrator",
33560
+ capScope: "system",
33561
+ addonId: null,
33562
+ access: "create"
33563
+ },
33429
33564
  "pipelineOrchestrator.removeAgentSettings": {
33430
33565
  capName: "pipeline-orchestrator",
33431
33566
  capScope: "system",
@@ -36417,6 +36552,11 @@ Object.freeze({
36417
36552
  form: "single",
36418
36553
  optional: true
36419
36554
  }],
36555
+ "pipelineAnalytics.reconcileFromDisk": [{
36556
+ name: "deviceId",
36557
+ form: "single",
36558
+ optional: false
36559
+ }],
36420
36560
  "pipelineAnalytics.restageRetrainTrack": [{
36421
36561
  name: "deviceId",
36422
36562
  form: "single",
@@ -37546,6 +37686,8 @@ function maskUrlCredentials(rawUrl) {
37546
37686
  return rawUrl;
37547
37687
  }
37548
37688
  }
37689
+ var MB = 1024 * 1024;
37690
+ 1024 * MB, 3072 * MB;
37549
37691
  //#endregion
37550
37692
  //#region src/rtsp-reachability.ts
37551
37693
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-rtsp",
3
- "version": "1.2.19",
3
+ "version": "1.2.21",
4
4
  "description": "Generic RTSP camera device provider addon for CamStack",
5
5
  "keywords": [
6
6
  "camstack",