@camstack/addon-provider-onvif 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 -44
  2. package/dist/addon.mjs +187 -44
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region \0rolldown/runtime.js
3
3
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
4
4
  //#endregion
5
- //#region ../types/dist/event-category-Bxo5yJjt.mjs
5
+ //#region ../types/dist/event-category-XfKNtfCc.mjs
6
6
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
7
7
  EventCategory["SystemBoot"] = "system.boot";
8
8
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -19,9 +19,10 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
19
19
  EventCategory["SystemRestartCompleted"] = "system.restart-completed";
20
20
  /**
21
21
  * A newer addon or server-root package version was found by the
22
- * authoritative registry check. Emitted once per
23
- * `(target, packageName, currentVersion, latestVersion)` transition; repeated
24
- * polling of the same result is deduplicated by the checker.
22
+ * authoritative registry check. Emitted once when any observed
23
+ * `latestVersion` changes (or a package/node first appears behind);
24
+ * the payload carries the full currently-available list. Repeated
25
+ * polling of the same latests is silent.
25
26
  */
26
27
  EventCategory["UpdateAvailable"] = "update.available";
27
28
  /**
@@ -40,6 +41,22 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
40
41
  EventCategory["AddonInstalled"] = "addon.installed";
41
42
  EventCategory["AddonUninstalled"] = "addon.uninstalled";
42
43
  EventCategory["AddonCrashed"] = "addon.crashed";
44
+ /**
45
+ * A RUNNER the D6 crash circuit-breaker gave up on — terminal.
46
+ *
47
+ * `AddonCrashed` is the routine, self-healing fact ("it crashed; it is being
48
+ * respawned"); this is the one that never resolves itself. Emitted exactly
49
+ * once per trip, by `process-service.ts`, carrying the node, the runner, the
50
+ * addons it hosted and the crash count that tripped the breaker.
51
+ *
52
+ * It exists because a runner marked terminally `failed` used to be SILENT:
53
+ * on 2026-08-18 the `recorder` runner died of three unhandled ffmpeg spawn
54
+ * errors, the breaker stopped respawning it (correctly), `/health` kept
55
+ * returning 200, and fleet-wide recording was gone for 3h15 before the
56
+ * operator's phone told him. The Notification Center's system-event intake
57
+ * consumes this category and maps it to the `addon-crash-loop` kind.
58
+ */
59
+ EventCategory["AddonRunnerFailed"] = "addon.runner-failed";
43
60
  EventCategory["AddonError"] = "addon.error";
44
61
  EventCategory["AddonPageReady"] = "addon.page-ready";
45
62
  EventCategory["AddonWidgetReady"] = "addon.widget-ready";
@@ -7547,6 +7564,10 @@ var RecordingBandSchema = object({
7547
7564
  preBufferSec: number().min(0).optional(),
7548
7565
  postBufferSec: number().min(0).optional()
7549
7566
  });
7567
+ ({
7568
+ preBufferSec: 10,
7569
+ postBufferSec: 30
7570
+ }).postBufferSec * 1e3;
7550
7571
  /**
7551
7572
  * Per-device retention overrides. Every field is optional; an unset or `0`
7552
7573
  * value inherits the node-wide recorder default. Only footage-lifetime limits
@@ -7594,6 +7615,12 @@ var RecordingConfigSchema = object({
7594
7615
  /** DERIVED summary of `bands`, stamped by the recorder on every save.
7595
7616
  * Authoring it has no effect — see {@link RecordingStorageModeSchema}. */
7596
7617
  mode: RecordingStorageModeSchema.optional(),
7618
+ /**
7619
+ * Which assigned broker slots to record. Absent / empty = {@link
7620
+ * DEFAULT_RECORDING_PROFILES} (`high`+`low`) intersected with the
7621
+ * camera's currently assigned slots — never `mid` unless the operator
7622
+ * picks it, and never a slot the broker has not assigned.
7623
+ */
7597
7624
  profiles: array(CamProfileSchema).optional(),
7598
7625
  segmentSeconds: number().int().positive().optional(),
7599
7626
  /**
@@ -7674,7 +7701,11 @@ var RelocateFootageInputSchema = object({
7674
7701
  profiles: array(string()).optional(),
7675
7702
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7676
7703
  * never allowed to starve live writers. */
7677
- throttleMbps: number().min(1).max(1e3).optional()
7704
+ throttleMbps: number().min(1).max(1e3).optional(),
7705
+ /** Move only segments whose startMs is >= this. Absent = the whole source
7706
+ * pile. Used when a full drain is too expensive and the operator only
7707
+ * wants the recent window on the new disk. */
7708
+ sinceMs: number().int().optional()
7678
7709
  });
7679
7710
  /** Internal, lease-scoped participant operation. It is intentionally separate
7680
7711
  * from persistent recording settings: a migration never changes
@@ -14292,6 +14323,7 @@ var NcSystemEventKindSchema = _enum([
14292
14323
  "node-offline",
14293
14324
  "node-inference-unavailable",
14294
14325
  "detection-blind",
14326
+ "addon-crash-loop",
14295
14327
  "addon-update-available",
14296
14328
  "server-update-available",
14297
14329
  "alarm-triggered",
@@ -14299,6 +14331,9 @@ var NcSystemEventKindSchema = _enum([
14299
14331
  "alarm-disarmed",
14300
14332
  "alarm-arming",
14301
14333
  "alarm-arm-refused",
14334
+ "addon-updated",
14335
+ "server-updated",
14336
+ "export-completed",
14302
14337
  "camera-online",
14303
14338
  "camera-offline",
14304
14339
  "camera-disabled",
@@ -16192,13 +16227,19 @@ var RetrainStatusSchema = _enum([
16192
16227
  * "never marked" from "already trained" must read `retrainStatus`.
16193
16228
  *
16194
16229
  * `debug` does NOT pin; it is attention, not durability.
16230
+ *
16231
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16232
+ * A favourited track is skipped by retention the same way `staging` is, but
16233
+ * it does not enter `none|staging|trained` and has no staging budget.
16195
16234
  */
16196
16235
  var TrackFlagFields = {
16197
16236
  /** Operator marked this track as training material — i.e. `retrainStatus` is
16198
16237
  * `'staging'`. */
16199
16238
  markForTrain: boolean().optional(),
16200
16239
  /** Operator marked this track for diagnostic attention. */
16201
- debug: boolean().optional()
16240
+ debug: boolean().optional(),
16241
+ /** Operator favourited this track. Pins it against pruning. */
16242
+ favourited: boolean().optional()
16202
16243
  };
16203
16244
  /**
16204
16245
  * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
@@ -16223,6 +16264,7 @@ var TrackFlagsSchema = object({
16223
16264
  trackId: string(),
16224
16265
  markForTrain: boolean(),
16225
16266
  debug: boolean(),
16267
+ favourited: boolean(),
16226
16268
  /** The lifecycle state the boolean was derived from. Required here (unlike on
16227
16269
  * a track row) because this shape is only ever produced by the write body,
16228
16270
  * which always knows it — and a surface that has just written needs to render
@@ -16855,6 +16897,12 @@ var TrackCascadeCountsSchema = object({
16855
16897
  /** Per-track CLIP search vectors removed (best-effort). */
16856
16898
  embeddings: number().int()
16857
16899
  });
16900
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
16901
+ var DiskReconcileCountsSchema = object({
16902
+ mediaDropped: number().int(),
16903
+ tracks: number().int(),
16904
+ events: number().int()
16905
+ });
16858
16906
  /** Event-store footprint for one camera. */
16859
16907
  var EventStoreDeviceFootprintSchema = object({
16860
16908
  deviceId: number(),
@@ -17031,6 +17079,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17031
17079
  }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17032
17080
  kind: "mutation",
17033
17081
  auth: "admin"
17082
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17083
+ kind: "mutation",
17084
+ auth: "admin"
17034
17085
  }), method(object({
17035
17086
  deviceId: number(),
17036
17087
  trackIds: array(string()).min(1)
@@ -18541,6 +18592,24 @@ var CameraStatusDegradationSchema = object({
18541
18592
  *
18542
18593
  * See spec: `docs/superpowers/specs/2026-06-24-camera-status-aggregator-cap.md`
18543
18594
  */
18595
+ var DiskReconcileJobSchema = object({
18596
+ state: _enum([
18597
+ "idle",
18598
+ "running",
18599
+ "done",
18600
+ "error"
18601
+ ]),
18602
+ total: number().int().nonnegative(),
18603
+ completed: number().int().nonnegative(),
18604
+ currentDeviceId: number().int().nullable(),
18605
+ failed: array(number().int()).readonly(),
18606
+ mediaDropped: number().int().nonnegative(),
18607
+ tracks: number().int().nonnegative(),
18608
+ events: number().int().nonnegative(),
18609
+ startedAtMs: number().int().nullable(),
18610
+ finishedAtMs: number().int().nullable(),
18611
+ error: string().nullable()
18612
+ });
18544
18613
  var CameraStatusSchema = object({
18545
18614
  deviceId: number(),
18546
18615
  assignment: CameraAssignmentStatusSchema,
@@ -18772,7 +18841,10 @@ method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18772
18841
  }), CameraSwitchGroupSchema, {
18773
18842
  kind: "mutation",
18774
18843
  auth: "admin"
18775
- }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
18844
+ }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), DiskReconcileJobSchema, {
18845
+ kind: "mutation",
18846
+ auth: "admin"
18847
+ }), method(_void(), DiskReconcileJobSchema, { auth: "admin" }), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
18776
18848
  name: string(),
18777
18849
  description: string().optional(),
18778
18850
  config: CameraPipelineConfigSchema
@@ -19949,20 +20021,6 @@ var VectorStatsResultSchema = object({
19949
20021
  exact: boolean()
19950
20022
  });
19951
20023
  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);
19952
- /**
19953
- * `videoclips` — the unified, navigable-clip surface for a camera.
19954
- *
19955
- * A device-scoped WRAPPER cap (like `pipeline-analytics`): exactly one active
19956
- * provider per device, substitutable. The DEFAULT provider (registered by
19957
- * `addon-post-analysis`, `defaultActive: true`) composes the analytics event
19958
- * log (markers + thumbnails) with the recorder's `getPlaybackManifest` — a clip
19959
- * is a time-WINDOW over existing footage, never a separate file. A camera that
19960
- * exposes NATIVE onboard clips (Reolink/Hikvision NVR) can later substitute the
19961
- * wrapper provider for its device and serve its own clip catalog + URLs.
19962
- *
19963
- * A `Clip` is purely time-based (subtree-blind): playback resolves segments by
19964
- * temporal overlap, so the API never decides `continuous` vs `events`.
19965
- */
19966
20024
  var ClipSchema = object({
19967
20025
  /** Opaque, provider-namespaced id. The default provider encodes the time
19968
20026
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -19979,8 +20037,65 @@ var ClipSchema = object({
19979
20037
  startMs: number(),
19980
20038
  endMs: number()
19981
20039
  }),
19982
- /** Thumbnail URL (lazy; e.g. analytics `getEventMedia`). Never inlined. */
19983
- thumbnail: string().optional()
20040
+ /**
20041
+ * Distinct object classes attached to this visit (`person`, `car`, …),
20042
+ * dominant first, capped at {@link MAX_CLIP_LABELS}. The ribbon renders these
20043
+ * instead of the bare kind — "Object" tells the operator nothing a colour bar
20044
+ * did not. Absent (never empty) when the visit attached no classified object
20045
+ * event, so a motion/audio-only visit keeps its kind label.
20046
+ */
20047
+ labels: array(string()).max(3).optional(),
20048
+ /**
20049
+ * Lazy thumbnail URL, never inlined.
20050
+ *
20051
+ * Recording-derived clips (events-mode keep-window, and the prepared
20052
+ * continuous event+fragment visit) MUST use the snapshot of the **main
20053
+ * event of the interval** — `getEventMedia({ eventId, kind: 'snapshot' })`
20054
+ * of the event that owns `kind` (object > motion > audio). Do not extract
20055
+ * a keyframe from the recorded segments. Other providers (onboard, HKSV)
20056
+ * mint their own stills.
20057
+ *
20058
+ * **VOUCHED, never fabricated.** A provider emits this only for an event it
20059
+ * has CONFIRMED owns at least one media row (its own, or its owning track's).
20060
+ * Absent is meaningful — "this visit has no event still" — never "we did not
20061
+ * look". Stamping it from a URL template made 35% of one camera's clips point
20062
+ * at a 404 (device 3836, 2026-08-17: 64 of 179 clips dead, 63 of them motion).
20063
+ * A read that FAILS drops the claim; it never invents it.
20064
+ */
20065
+ thumbnail: string().optional(),
20066
+ /**
20067
+ * An instant INSIDE this visit's footage, hole-safe, where a recorded still
20068
+ * can be decoded. Present whenever the visit came from recorded availability;
20069
+ * absent on a per-event padded window (there is no footage to promise).
20070
+ *
20071
+ * This is not a thumbnail and not a second byte path: it is the argument to
20072
+ * the recorder's existing still route. The surface — never the provider —
20073
+ * decides whether to use it. It is the midpoint of the visit's LONGEST
20074
+ * contiguous range, not of the visit: a visit spans its holes by
20075
+ * construction, so a naive midpoint lands in dead air.
20076
+ */
20077
+ stillAtMs: number().optional(),
20078
+ /**
20079
+ * Analytics event ids that overlap this visit — a BOUNDED sample, newest
20080
+ * first within kind (object → motion → audio), capped at
20081
+ * {@link MAX_CLIP_EVENT_IDS}. Empty on footage-only clips.
20082
+ *
20083
+ * Bounded because it is not a payload the surface pages through: one visit on
20084
+ * device 615 carried 2 345 ids, and `eventIds` was 99% of a 153 KB
20085
+ * camera-day. Read {@link eventCount} for the true total.
20086
+ */
20087
+ eventIds: array(string()).optional(),
20088
+ /** How many analytics events actually overlap this visit. Differs from
20089
+ * `eventIds.length` exactly when the sample was capped — so a truncated
20090
+ * list is never mistaken for a quiet visit. */
20091
+ eventCount: number().int().nonnegative().optional(),
20092
+ /** Intra-visit footage holes (GOP rolls, discarded segments) still shorter
20093
+ * than `VISIT_MERGE_GAP_MS`. Playback concatenates around them; the timeline
20094
+ * bar keeps showing them via `recording.getAvailability`. */
20095
+ holes: array(object({
20096
+ startMs: number(),
20097
+ endMs: number()
20098
+ })).optional()
19984
20099
  });
19985
20100
  var ClipPlaybackSchema = object({
19986
20101
  /** HLS master URL through the hub data-plane (Range + token in path). */
@@ -20444,7 +20559,14 @@ var SearchResultSchema = object({
20444
20559
  });
20445
20560
  var AutoUpdateSettingsSchema = object({
20446
20561
  channel: ChannelSchema,
20447
- intervalSeconds: number()
20562
+ intervalSeconds: number(),
20563
+ /**
20564
+ * Cadence of the "an update exists" POLLER, in seconds. Independent of
20565
+ * `channel`: the poller runs while auto-apply is `off`, because being told
20566
+ * about a publish and installing it are different decisions. Clamped
20567
+ * server-side to 900 s … 604800 s; defaults to 21600 s (6 h).
20568
+ */
20569
+ updateCheckIntervalSeconds: number()
20448
20570
  });
20449
20571
  var AddonAutoUpdateSchema = ChannelWithInheritSchema;
20450
20572
  var RestartAddonResultSchema = unknown();
@@ -20585,7 +20707,9 @@ method(_void(), array(AddonListItemSchema).readonly()), method(object({
20585
20707
  auth: "admin"
20586
20708
  }), method(_void(), AutoUpdateSettingsSchema, { auth: "admin" }), method(object({
20587
20709
  channel: ChannelSchema,
20588
- intervalSeconds: number().min(300).max(86400).optional()
20710
+ intervalSeconds: number().min(300).max(86400).optional(),
20711
+ /** Availability-poll cadence; see AutoUpdateSettingsSchema. */
20712
+ updateCheckIntervalSeconds: number().min(900).max(604800).optional()
20589
20713
  }), unknown(), {
20590
20714
  kind: "mutation",
20591
20715
  auth: "admin"
@@ -24620,7 +24744,9 @@ var ExportOptionsSchema = object({
24620
24744
  includeAudio: boolean(),
24621
24745
  maxLifeMs: number().int().positive(),
24622
24746
  deleteAfterDownload: boolean(),
24623
- title: string().max(200).optional()
24747
+ title: string().max(200).optional(),
24748
+ /** Notification-output target ids to ping when this export becomes ready. */
24749
+ notifyTargetIds: array(string().min(1)).max(20).optional()
24624
24750
  }).superRefine((v, ctx) => {
24625
24751
  if (v.speed !== void 0 && v.timelapse !== void 0) ctx.addIssue({
24626
24752
  code: ZodIssueCode.custom,
@@ -24679,10 +24805,18 @@ var ExportBytesSchema = object({
24679
24805
  });
24680
24806
  method(object({
24681
24807
  deviceId: number(),
24682
- profile: string(),
24808
+ /** @deprecated Prefer `profiles`. Kept so timelapse/notifiers keep working. */
24809
+ profile: string().optional(),
24810
+ profiles: array(string()).min(1).optional(),
24683
24811
  fromMs: number(),
24684
24812
  toMs: number(),
24685
24813
  options: ExportOptionsSchema
24814
+ }).superRefine((v, ctx) => {
24815
+ if ((v.profiles !== void 0 && v.profiles.length > 0 ? v.profiles : v.profile !== void 0 ? [v.profile] : []).length < 1) ctx.addIssue({
24816
+ code: ZodIssueCode.custom,
24817
+ message: "pass profiles[] (min 1) or legacy profile",
24818
+ path: ["profiles"]
24819
+ });
24686
24820
  }), ExportRecordSchema, {
24687
24821
  kind: "mutation",
24688
24822
  auth: "protected"
@@ -26299,15 +26433,6 @@ var BaseDeviceProvider = class extends BaseAddon {
26299
26433
  labels: ["probe not implemented"]
26300
26434
  };
26301
26435
  }
26302
- /**
26303
- * Top-level devices restored at once in {@link onRestoreDevices}.
26304
- *
26305
- * Four covers the fleets this ships to without turning a boot into a burst a
26306
- * camera NVR answers with a refusal. A provider whose upstream is a single
26307
- * session with a serial command channel (a Baichuan hub, an NVR that
26308
- * serialises ISAPI) should lower it; nothing needs to raise it.
26309
- */
26310
- restoreConcurrency = 4;
26311
26436
  async restoreDevices(savedDevices) {
26312
26437
  await this.onRestoreDevices(savedDevices);
26313
26438
  if (savedDevices.length > 0) this.ctx.logger.info(`Restored ${savedDevices.length} ${this.providerName} device(s)`);
@@ -26362,14 +26487,7 @@ var BaseDeviceProvider = class extends BaseAddon {
26362
26487
  });
26363
26488
  }
26364
26489
  };
26365
- let nextTopLevel = 0;
26366
- await Promise.all(Array.from({ length: Math.min(Math.max(1, this.restoreConcurrency), topLevel.length) }, async () => {
26367
- for (;;) {
26368
- const saved = topLevel[nextTopLevel++];
26369
- if (saved === void 0) return;
26370
- await restoreOne(saved);
26371
- }
26372
- }));
26490
+ await Promise.all(topLevel.map((saved) => restoreOne(saved)));
26373
26491
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
26374
26492
  for (const saved of childRows) {
26375
26493
  const Class = this.deviceClasses[saved.type];
@@ -29708,6 +29826,12 @@ Object.freeze({
29708
29826
  addonId: null,
29709
29827
  access: "create"
29710
29828
  },
29829
+ "pipelineAnalytics.reconcileFromDisk": {
29830
+ capName: "pipeline-analytics",
29831
+ capScope: "device",
29832
+ addonId: null,
29833
+ access: "create"
29834
+ },
29711
29835
  "pipelineAnalytics.refreshStorageLocationsForMigration": {
29712
29836
  capName: "pipeline-analytics",
29713
29837
  capScope: "device",
@@ -30110,6 +30234,12 @@ Object.freeze({
30110
30234
  addonId: null,
30111
30235
  access: "view"
30112
30236
  },
30237
+ "pipelineOrchestrator.getReconcileFromDiskStatus": {
30238
+ capName: "pipeline-orchestrator",
30239
+ capScope: "system",
30240
+ addonId: null,
30241
+ access: "view"
30242
+ },
30113
30243
  "pipelineOrchestrator.listAgentSettings": {
30114
30244
  capName: "pipeline-orchestrator",
30115
30245
  capScope: "system",
@@ -30134,6 +30264,12 @@ Object.freeze({
30134
30264
  addonId: null,
30135
30265
  access: "create"
30136
30266
  },
30267
+ "pipelineOrchestrator.reconcileFromDisk": {
30268
+ capName: "pipeline-orchestrator",
30269
+ capScope: "system",
30270
+ addonId: null,
30271
+ access: "create"
30272
+ },
30137
30273
  "pipelineOrchestrator.removeAgentSettings": {
30138
30274
  capName: "pipeline-orchestrator",
30139
30275
  capScope: "system",
@@ -33125,6 +33261,11 @@ Object.freeze({
33125
33261
  form: "single",
33126
33262
  optional: true
33127
33263
  }],
33264
+ "pipelineAnalytics.reconcileFromDisk": [{
33265
+ name: "deviceId",
33266
+ form: "single",
33267
+ optional: false
33268
+ }],
33128
33269
  "pipelineAnalytics.restageRetrainTrack": [{
33129
33270
  name: "deviceId",
33130
33271
  form: "single",
@@ -34190,6 +34331,8 @@ DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
34190
34331
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
34191
34332
  DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
34192
34333
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
34334
+ var MB = 1024 * 1024;
34335
+ 1024 * MB, 3072 * MB;
34193
34336
  //#endregion
34194
34337
  //#region src/onvif-camera.ts
34195
34338
  var onvifCameraSchema = object({
package/dist/addon.mjs CHANGED
@@ -3,7 +3,7 @@ import { createRequire } from "node:module";
3
3
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
4
4
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
5
5
  //#endregion
6
- //#region ../types/dist/event-category-Bxo5yJjt.mjs
6
+ //#region ../types/dist/event-category-XfKNtfCc.mjs
7
7
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
8
8
  EventCategory["SystemBoot"] = "system.boot";
9
9
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -20,9 +20,10 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
20
20
  EventCategory["SystemRestartCompleted"] = "system.restart-completed";
21
21
  /**
22
22
  * A newer addon or server-root package version was found by the
23
- * authoritative registry check. Emitted once per
24
- * `(target, packageName, currentVersion, latestVersion)` transition; repeated
25
- * polling of the same result is deduplicated by the checker.
23
+ * authoritative registry check. Emitted once when any observed
24
+ * `latestVersion` changes (or a package/node first appears behind);
25
+ * the payload carries the full currently-available list. Repeated
26
+ * polling of the same latests is silent.
26
27
  */
27
28
  EventCategory["UpdateAvailable"] = "update.available";
28
29
  /**
@@ -41,6 +42,22 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
41
42
  EventCategory["AddonInstalled"] = "addon.installed";
42
43
  EventCategory["AddonUninstalled"] = "addon.uninstalled";
43
44
  EventCategory["AddonCrashed"] = "addon.crashed";
45
+ /**
46
+ * A RUNNER the D6 crash circuit-breaker gave up on — terminal.
47
+ *
48
+ * `AddonCrashed` is the routine, self-healing fact ("it crashed; it is being
49
+ * respawned"); this is the one that never resolves itself. Emitted exactly
50
+ * once per trip, by `process-service.ts`, carrying the node, the runner, the
51
+ * addons it hosted and the crash count that tripped the breaker.
52
+ *
53
+ * It exists because a runner marked terminally `failed` used to be SILENT:
54
+ * on 2026-08-18 the `recorder` runner died of three unhandled ffmpeg spawn
55
+ * errors, the breaker stopped respawning it (correctly), `/health` kept
56
+ * returning 200, and fleet-wide recording was gone for 3h15 before the
57
+ * operator's phone told him. The Notification Center's system-event intake
58
+ * consumes this category and maps it to the `addon-crash-loop` kind.
59
+ */
60
+ EventCategory["AddonRunnerFailed"] = "addon.runner-failed";
44
61
  EventCategory["AddonError"] = "addon.error";
45
62
  EventCategory["AddonPageReady"] = "addon.page-ready";
46
63
  EventCategory["AddonWidgetReady"] = "addon.widget-ready";
@@ -7548,6 +7565,10 @@ var RecordingBandSchema = object({
7548
7565
  preBufferSec: number().min(0).optional(),
7549
7566
  postBufferSec: number().min(0).optional()
7550
7567
  });
7568
+ ({
7569
+ preBufferSec: 10,
7570
+ postBufferSec: 30
7571
+ }).postBufferSec * 1e3;
7551
7572
  /**
7552
7573
  * Per-device retention overrides. Every field is optional; an unset or `0`
7553
7574
  * value inherits the node-wide recorder default. Only footage-lifetime limits
@@ -7595,6 +7616,12 @@ var RecordingConfigSchema = object({
7595
7616
  /** DERIVED summary of `bands`, stamped by the recorder on every save.
7596
7617
  * Authoring it has no effect — see {@link RecordingStorageModeSchema}. */
7597
7618
  mode: RecordingStorageModeSchema.optional(),
7619
+ /**
7620
+ * Which assigned broker slots to record. Absent / empty = {@link
7621
+ * DEFAULT_RECORDING_PROFILES} (`high`+`low`) intersected with the
7622
+ * camera's currently assigned slots — never `mid` unless the operator
7623
+ * picks it, and never a slot the broker has not assigned.
7624
+ */
7598
7625
  profiles: array(CamProfileSchema).optional(),
7599
7626
  segmentSeconds: number().int().positive().optional(),
7600
7627
  /**
@@ -7675,7 +7702,11 @@ var RelocateFootageInputSchema = object({
7675
7702
  profiles: array(string()).optional(),
7676
7703
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7677
7704
  * never allowed to starve live writers. */
7678
- throttleMbps: number().min(1).max(1e3).optional()
7705
+ throttleMbps: number().min(1).max(1e3).optional(),
7706
+ /** Move only segments whose startMs is >= this. Absent = the whole source
7707
+ * pile. Used when a full drain is too expensive and the operator only
7708
+ * wants the recent window on the new disk. */
7709
+ sinceMs: number().int().optional()
7679
7710
  });
7680
7711
  /** Internal, lease-scoped participant operation. It is intentionally separate
7681
7712
  * from persistent recording settings: a migration never changes
@@ -14293,6 +14324,7 @@ var NcSystemEventKindSchema = _enum([
14293
14324
  "node-offline",
14294
14325
  "node-inference-unavailable",
14295
14326
  "detection-blind",
14327
+ "addon-crash-loop",
14296
14328
  "addon-update-available",
14297
14329
  "server-update-available",
14298
14330
  "alarm-triggered",
@@ -14300,6 +14332,9 @@ var NcSystemEventKindSchema = _enum([
14300
14332
  "alarm-disarmed",
14301
14333
  "alarm-arming",
14302
14334
  "alarm-arm-refused",
14335
+ "addon-updated",
14336
+ "server-updated",
14337
+ "export-completed",
14303
14338
  "camera-online",
14304
14339
  "camera-offline",
14305
14340
  "camera-disabled",
@@ -16193,13 +16228,19 @@ var RetrainStatusSchema = _enum([
16193
16228
  * "never marked" from "already trained" must read `retrainStatus`.
16194
16229
  *
16195
16230
  * `debug` does NOT pin; it is attention, not durability.
16231
+ *
16232
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16233
+ * A favourited track is skipped by retention the same way `staging` is, but
16234
+ * it does not enter `none|staging|trained` and has no staging budget.
16196
16235
  */
16197
16236
  var TrackFlagFields = {
16198
16237
  /** Operator marked this track as training material — i.e. `retrainStatus` is
16199
16238
  * `'staging'`. */
16200
16239
  markForTrain: boolean().optional(),
16201
16240
  /** Operator marked this track for diagnostic attention. */
16202
- debug: boolean().optional()
16241
+ debug: boolean().optional(),
16242
+ /** Operator favourited this track. Pins it against pruning. */
16243
+ favourited: boolean().optional()
16203
16244
  };
16204
16245
  /**
16205
16246
  * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
@@ -16224,6 +16265,7 @@ var TrackFlagsSchema = object({
16224
16265
  trackId: string(),
16225
16266
  markForTrain: boolean(),
16226
16267
  debug: boolean(),
16268
+ favourited: boolean(),
16227
16269
  /** The lifecycle state the boolean was derived from. Required here (unlike on
16228
16270
  * a track row) because this shape is only ever produced by the write body,
16229
16271
  * which always knows it — and a surface that has just written needs to render
@@ -16856,6 +16898,12 @@ var TrackCascadeCountsSchema = object({
16856
16898
  /** Per-track CLIP search vectors removed (best-effort). */
16857
16899
  embeddings: number().int()
16858
16900
  });
16901
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
16902
+ var DiskReconcileCountsSchema = object({
16903
+ mediaDropped: number().int(),
16904
+ tracks: number().int(),
16905
+ events: number().int()
16906
+ });
16859
16907
  /** Event-store footprint for one camera. */
16860
16908
  var EventStoreDeviceFootprintSchema = object({
16861
16909
  deviceId: number(),
@@ -17032,6 +17080,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17032
17080
  }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17033
17081
  kind: "mutation",
17034
17082
  auth: "admin"
17083
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17084
+ kind: "mutation",
17085
+ auth: "admin"
17035
17086
  }), method(object({
17036
17087
  deviceId: number(),
17037
17088
  trackIds: array(string()).min(1)
@@ -18542,6 +18593,24 @@ var CameraStatusDegradationSchema = object({
18542
18593
  *
18543
18594
  * See spec: `docs/superpowers/specs/2026-06-24-camera-status-aggregator-cap.md`
18544
18595
  */
18596
+ var DiskReconcileJobSchema = object({
18597
+ state: _enum([
18598
+ "idle",
18599
+ "running",
18600
+ "done",
18601
+ "error"
18602
+ ]),
18603
+ total: number().int().nonnegative(),
18604
+ completed: number().int().nonnegative(),
18605
+ currentDeviceId: number().int().nullable(),
18606
+ failed: array(number().int()).readonly(),
18607
+ mediaDropped: number().int().nonnegative(),
18608
+ tracks: number().int().nonnegative(),
18609
+ events: number().int().nonnegative(),
18610
+ startedAtMs: number().int().nullable(),
18611
+ finishedAtMs: number().int().nullable(),
18612
+ error: string().nullable()
18613
+ });
18545
18614
  var CameraStatusSchema = object({
18546
18615
  deviceId: number(),
18547
18616
  assignment: CameraAssignmentStatusSchema,
@@ -18773,7 +18842,10 @@ method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18773
18842
  }), CameraSwitchGroupSchema, {
18774
18843
  kind: "mutation",
18775
18844
  auth: "admin"
18776
- }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
18845
+ }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), DiskReconcileJobSchema, {
18846
+ kind: "mutation",
18847
+ auth: "admin"
18848
+ }), method(_void(), DiskReconcileJobSchema, { auth: "admin" }), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
18777
18849
  name: string(),
18778
18850
  description: string().optional(),
18779
18851
  config: CameraPipelineConfigSchema
@@ -19950,20 +20022,6 @@ var VectorStatsResultSchema = object({
19950
20022
  exact: boolean()
19951
20023
  });
19952
20024
  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);
19953
- /**
19954
- * `videoclips` — the unified, navigable-clip surface for a camera.
19955
- *
19956
- * A device-scoped WRAPPER cap (like `pipeline-analytics`): exactly one active
19957
- * provider per device, substitutable. The DEFAULT provider (registered by
19958
- * `addon-post-analysis`, `defaultActive: true`) composes the analytics event
19959
- * log (markers + thumbnails) with the recorder's `getPlaybackManifest` — a clip
19960
- * is a time-WINDOW over existing footage, never a separate file. A camera that
19961
- * exposes NATIVE onboard clips (Reolink/Hikvision NVR) can later substitute the
19962
- * wrapper provider for its device and serve its own clip catalog + URLs.
19963
- *
19964
- * A `Clip` is purely time-based (subtree-blind): playback resolves segments by
19965
- * temporal overlap, so the API never decides `continuous` vs `events`.
19966
- */
19967
20025
  var ClipSchema = object({
19968
20026
  /** Opaque, provider-namespaced id. The default provider encodes the time
19969
20027
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -19980,8 +20038,65 @@ var ClipSchema = object({
19980
20038
  startMs: number(),
19981
20039
  endMs: number()
19982
20040
  }),
19983
- /** Thumbnail URL (lazy; e.g. analytics `getEventMedia`). Never inlined. */
19984
- thumbnail: string().optional()
20041
+ /**
20042
+ * Distinct object classes attached to this visit (`person`, `car`, …),
20043
+ * dominant first, capped at {@link MAX_CLIP_LABELS}. The ribbon renders these
20044
+ * instead of the bare kind — "Object" tells the operator nothing a colour bar
20045
+ * did not. Absent (never empty) when the visit attached no classified object
20046
+ * event, so a motion/audio-only visit keeps its kind label.
20047
+ */
20048
+ labels: array(string()).max(3).optional(),
20049
+ /**
20050
+ * Lazy thumbnail URL, never inlined.
20051
+ *
20052
+ * Recording-derived clips (events-mode keep-window, and the prepared
20053
+ * continuous event+fragment visit) MUST use the snapshot of the **main
20054
+ * event of the interval** — `getEventMedia({ eventId, kind: 'snapshot' })`
20055
+ * of the event that owns `kind` (object > motion > audio). Do not extract
20056
+ * a keyframe from the recorded segments. Other providers (onboard, HKSV)
20057
+ * mint their own stills.
20058
+ *
20059
+ * **VOUCHED, never fabricated.** A provider emits this only for an event it
20060
+ * has CONFIRMED owns at least one media row (its own, or its owning track's).
20061
+ * Absent is meaningful — "this visit has no event still" — never "we did not
20062
+ * look". Stamping it from a URL template made 35% of one camera's clips point
20063
+ * at a 404 (device 3836, 2026-08-17: 64 of 179 clips dead, 63 of them motion).
20064
+ * A read that FAILS drops the claim; it never invents it.
20065
+ */
20066
+ thumbnail: string().optional(),
20067
+ /**
20068
+ * An instant INSIDE this visit's footage, hole-safe, where a recorded still
20069
+ * can be decoded. Present whenever the visit came from recorded availability;
20070
+ * absent on a per-event padded window (there is no footage to promise).
20071
+ *
20072
+ * This is not a thumbnail and not a second byte path: it is the argument to
20073
+ * the recorder's existing still route. The surface — never the provider —
20074
+ * decides whether to use it. It is the midpoint of the visit's LONGEST
20075
+ * contiguous range, not of the visit: a visit spans its holes by
20076
+ * construction, so a naive midpoint lands in dead air.
20077
+ */
20078
+ stillAtMs: number().optional(),
20079
+ /**
20080
+ * Analytics event ids that overlap this visit — a BOUNDED sample, newest
20081
+ * first within kind (object → motion → audio), capped at
20082
+ * {@link MAX_CLIP_EVENT_IDS}. Empty on footage-only clips.
20083
+ *
20084
+ * Bounded because it is not a payload the surface pages through: one visit on
20085
+ * device 615 carried 2 345 ids, and `eventIds` was 99% of a 153 KB
20086
+ * camera-day. Read {@link eventCount} for the true total.
20087
+ */
20088
+ eventIds: array(string()).optional(),
20089
+ /** How many analytics events actually overlap this visit. Differs from
20090
+ * `eventIds.length` exactly when the sample was capped — so a truncated
20091
+ * list is never mistaken for a quiet visit. */
20092
+ eventCount: number().int().nonnegative().optional(),
20093
+ /** Intra-visit footage holes (GOP rolls, discarded segments) still shorter
20094
+ * than `VISIT_MERGE_GAP_MS`. Playback concatenates around them; the timeline
20095
+ * bar keeps showing them via `recording.getAvailability`. */
20096
+ holes: array(object({
20097
+ startMs: number(),
20098
+ endMs: number()
20099
+ })).optional()
19985
20100
  });
19986
20101
  var ClipPlaybackSchema = object({
19987
20102
  /** HLS master URL through the hub data-plane (Range + token in path). */
@@ -20445,7 +20560,14 @@ var SearchResultSchema = object({
20445
20560
  });
20446
20561
  var AutoUpdateSettingsSchema = object({
20447
20562
  channel: ChannelSchema,
20448
- intervalSeconds: number()
20563
+ intervalSeconds: number(),
20564
+ /**
20565
+ * Cadence of the "an update exists" POLLER, in seconds. Independent of
20566
+ * `channel`: the poller runs while auto-apply is `off`, because being told
20567
+ * about a publish and installing it are different decisions. Clamped
20568
+ * server-side to 900 s … 604800 s; defaults to 21600 s (6 h).
20569
+ */
20570
+ updateCheckIntervalSeconds: number()
20449
20571
  });
20450
20572
  var AddonAutoUpdateSchema = ChannelWithInheritSchema;
20451
20573
  var RestartAddonResultSchema = unknown();
@@ -20586,7 +20708,9 @@ method(_void(), array(AddonListItemSchema).readonly()), method(object({
20586
20708
  auth: "admin"
20587
20709
  }), method(_void(), AutoUpdateSettingsSchema, { auth: "admin" }), method(object({
20588
20710
  channel: ChannelSchema,
20589
- intervalSeconds: number().min(300).max(86400).optional()
20711
+ intervalSeconds: number().min(300).max(86400).optional(),
20712
+ /** Availability-poll cadence; see AutoUpdateSettingsSchema. */
20713
+ updateCheckIntervalSeconds: number().min(900).max(604800).optional()
20590
20714
  }), unknown(), {
20591
20715
  kind: "mutation",
20592
20716
  auth: "admin"
@@ -24621,7 +24745,9 @@ var ExportOptionsSchema = object({
24621
24745
  includeAudio: boolean(),
24622
24746
  maxLifeMs: number().int().positive(),
24623
24747
  deleteAfterDownload: boolean(),
24624
- title: string().max(200).optional()
24748
+ title: string().max(200).optional(),
24749
+ /** Notification-output target ids to ping when this export becomes ready. */
24750
+ notifyTargetIds: array(string().min(1)).max(20).optional()
24625
24751
  }).superRefine((v, ctx) => {
24626
24752
  if (v.speed !== void 0 && v.timelapse !== void 0) ctx.addIssue({
24627
24753
  code: ZodIssueCode.custom,
@@ -24680,10 +24806,18 @@ var ExportBytesSchema = object({
24680
24806
  });
24681
24807
  method(object({
24682
24808
  deviceId: number(),
24683
- profile: string(),
24809
+ /** @deprecated Prefer `profiles`. Kept so timelapse/notifiers keep working. */
24810
+ profile: string().optional(),
24811
+ profiles: array(string()).min(1).optional(),
24684
24812
  fromMs: number(),
24685
24813
  toMs: number(),
24686
24814
  options: ExportOptionsSchema
24815
+ }).superRefine((v, ctx) => {
24816
+ if ((v.profiles !== void 0 && v.profiles.length > 0 ? v.profiles : v.profile !== void 0 ? [v.profile] : []).length < 1) ctx.addIssue({
24817
+ code: ZodIssueCode.custom,
24818
+ message: "pass profiles[] (min 1) or legacy profile",
24819
+ path: ["profiles"]
24820
+ });
24687
24821
  }), ExportRecordSchema, {
24688
24822
  kind: "mutation",
24689
24823
  auth: "protected"
@@ -26300,15 +26434,6 @@ var BaseDeviceProvider = class extends BaseAddon {
26300
26434
  labels: ["probe not implemented"]
26301
26435
  };
26302
26436
  }
26303
- /**
26304
- * Top-level devices restored at once in {@link onRestoreDevices}.
26305
- *
26306
- * Four covers the fleets this ships to without turning a boot into a burst a
26307
- * camera NVR answers with a refusal. A provider whose upstream is a single
26308
- * session with a serial command channel (a Baichuan hub, an NVR that
26309
- * serialises ISAPI) should lower it; nothing needs to raise it.
26310
- */
26311
- restoreConcurrency = 4;
26312
26437
  async restoreDevices(savedDevices) {
26313
26438
  await this.onRestoreDevices(savedDevices);
26314
26439
  if (savedDevices.length > 0) this.ctx.logger.info(`Restored ${savedDevices.length} ${this.providerName} device(s)`);
@@ -26363,14 +26488,7 @@ var BaseDeviceProvider = class extends BaseAddon {
26363
26488
  });
26364
26489
  }
26365
26490
  };
26366
- let nextTopLevel = 0;
26367
- await Promise.all(Array.from({ length: Math.min(Math.max(1, this.restoreConcurrency), topLevel.length) }, async () => {
26368
- for (;;) {
26369
- const saved = topLevel[nextTopLevel++];
26370
- if (saved === void 0) return;
26371
- await restoreOne(saved);
26372
- }
26373
- }));
26491
+ await Promise.all(topLevel.map((saved) => restoreOne(saved)));
26374
26492
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
26375
26493
  for (const saved of childRows) {
26376
26494
  const Class = this.deviceClasses[saved.type];
@@ -29709,6 +29827,12 @@ Object.freeze({
29709
29827
  addonId: null,
29710
29828
  access: "create"
29711
29829
  },
29830
+ "pipelineAnalytics.reconcileFromDisk": {
29831
+ capName: "pipeline-analytics",
29832
+ capScope: "device",
29833
+ addonId: null,
29834
+ access: "create"
29835
+ },
29712
29836
  "pipelineAnalytics.refreshStorageLocationsForMigration": {
29713
29837
  capName: "pipeline-analytics",
29714
29838
  capScope: "device",
@@ -30111,6 +30235,12 @@ Object.freeze({
30111
30235
  addonId: null,
30112
30236
  access: "view"
30113
30237
  },
30238
+ "pipelineOrchestrator.getReconcileFromDiskStatus": {
30239
+ capName: "pipeline-orchestrator",
30240
+ capScope: "system",
30241
+ addonId: null,
30242
+ access: "view"
30243
+ },
30114
30244
  "pipelineOrchestrator.listAgentSettings": {
30115
30245
  capName: "pipeline-orchestrator",
30116
30246
  capScope: "system",
@@ -30135,6 +30265,12 @@ Object.freeze({
30135
30265
  addonId: null,
30136
30266
  access: "create"
30137
30267
  },
30268
+ "pipelineOrchestrator.reconcileFromDisk": {
30269
+ capName: "pipeline-orchestrator",
30270
+ capScope: "system",
30271
+ addonId: null,
30272
+ access: "create"
30273
+ },
30138
30274
  "pipelineOrchestrator.removeAgentSettings": {
30139
30275
  capName: "pipeline-orchestrator",
30140
30276
  capScope: "system",
@@ -33126,6 +33262,11 @@ Object.freeze({
33126
33262
  form: "single",
33127
33263
  optional: true
33128
33264
  }],
33265
+ "pipelineAnalytics.reconcileFromDisk": [{
33266
+ name: "deviceId",
33267
+ form: "single",
33268
+ optional: false
33269
+ }],
33129
33270
  "pipelineAnalytics.restageRetrainTrack": [{
33130
33271
  name: "deviceId",
33131
33272
  form: "single",
@@ -34191,6 +34332,8 @@ DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
34191
34332
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
34192
34333
  DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
34193
34334
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
34335
+ var MB = 1024 * 1024;
34336
+ 1024 * MB, 3072 * MB;
34194
34337
  //#endregion
34195
34338
  //#region src/onvif-camera.ts
34196
34339
  var onvifCameraSchema = object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-onvif",
3
- "version": "1.2.19",
3
+ "version": "1.2.21",
4
4
  "description": "ONVIF camera device provider addon for CamStack",
5
5
  "keywords": [
6
6
  "camstack",