@camstack/addon-provider-amcrest 0.2.21 → 0.2.23

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
@@ -4,7 +4,7 @@ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).expor
4
4
  //#endregion
5
5
  let node_crypto = require("node:crypto");
6
6
  let node_os = require("node:os");
7
- //#region ../types/dist/event-category-Bxo5yJjt.mjs
7
+ //#region ../types/dist/event-category-XfKNtfCc.mjs
8
8
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
9
9
  EventCategory["SystemBoot"] = "system.boot";
10
10
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -21,9 +21,10 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
21
21
  EventCategory["SystemRestartCompleted"] = "system.restart-completed";
22
22
  /**
23
23
  * A newer addon or server-root package version was found by the
24
- * authoritative registry check. Emitted once per
25
- * `(target, packageName, currentVersion, latestVersion)` transition; repeated
26
- * polling of the same result is deduplicated by the checker.
24
+ * authoritative registry check. Emitted once when any observed
25
+ * `latestVersion` changes (or a package/node first appears behind);
26
+ * the payload carries the full currently-available list. Repeated
27
+ * polling of the same latests is silent.
27
28
  */
28
29
  EventCategory["UpdateAvailable"] = "update.available";
29
30
  /**
@@ -42,6 +43,22 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
42
43
  EventCategory["AddonInstalled"] = "addon.installed";
43
44
  EventCategory["AddonUninstalled"] = "addon.uninstalled";
44
45
  EventCategory["AddonCrashed"] = "addon.crashed";
46
+ /**
47
+ * A RUNNER the D6 crash circuit-breaker gave up on — terminal.
48
+ *
49
+ * `AddonCrashed` is the routine, self-healing fact ("it crashed; it is being
50
+ * respawned"); this is the one that never resolves itself. Emitted exactly
51
+ * once per trip, by `process-service.ts`, carrying the node, the runner, the
52
+ * addons it hosted and the crash count that tripped the breaker.
53
+ *
54
+ * It exists because a runner marked terminally `failed` used to be SILENT:
55
+ * on 2026-08-18 the `recorder` runner died of three unhandled ffmpeg spawn
56
+ * errors, the breaker stopped respawning it (correctly), `/health` kept
57
+ * returning 200, and fleet-wide recording was gone for 3h15 before the
58
+ * operator's phone told him. The Notification Center's system-event intake
59
+ * consumes this category and maps it to the `addon-crash-loop` kind.
60
+ */
61
+ EventCategory["AddonRunnerFailed"] = "addon.runner-failed";
45
62
  EventCategory["AddonError"] = "addon.error";
46
63
  EventCategory["AddonPageReady"] = "addon.page-ready";
47
64
  EventCategory["AddonWidgetReady"] = "addon.widget-ready";
@@ -7541,6 +7558,10 @@ var RecordingBandSchema = object({
7541
7558
  preBufferSec: number().min(0).optional(),
7542
7559
  postBufferSec: number().min(0).optional()
7543
7560
  });
7561
+ ({
7562
+ preBufferSec: 10,
7563
+ postBufferSec: 30
7564
+ }).postBufferSec * 1e3;
7544
7565
  /**
7545
7566
  * Per-device retention overrides. Every field is optional; an unset or `0`
7546
7567
  * value inherits the node-wide recorder default. Only footage-lifetime limits
@@ -7588,6 +7609,12 @@ var RecordingConfigSchema = object({
7588
7609
  /** DERIVED summary of `bands`, stamped by the recorder on every save.
7589
7610
  * Authoring it has no effect — see {@link RecordingStorageModeSchema}. */
7590
7611
  mode: RecordingStorageModeSchema.optional(),
7612
+ /**
7613
+ * Which assigned broker slots to record. Absent / empty = {@link
7614
+ * DEFAULT_RECORDING_PROFILES} (`high`+`low`) intersected with the
7615
+ * camera's currently assigned slots — never `mid` unless the operator
7616
+ * picks it, and never a slot the broker has not assigned.
7617
+ */
7591
7618
  profiles: array(CamProfileSchema).optional(),
7592
7619
  segmentSeconds: number().int().positive().optional(),
7593
7620
  /**
@@ -7668,7 +7695,11 @@ var RelocateFootageInputSchema = object({
7668
7695
  profiles: array(string()).optional(),
7669
7696
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7670
7697
  * never allowed to starve live writers. */
7671
- throttleMbps: number().min(1).max(1e3).optional()
7698
+ throttleMbps: number().min(1).max(1e3).optional(),
7699
+ /** Move only segments whose startMs is >= this. Absent = the whole source
7700
+ * pile. Used when a full drain is too expensive and the operator only
7701
+ * wants the recent window on the new disk. */
7702
+ sinceMs: number().int().optional()
7672
7703
  });
7673
7704
  /** Internal, lease-scoped participant operation. It is intentionally separate
7674
7705
  * from persistent recording settings: a migration never changes
@@ -14533,6 +14564,7 @@ var NcSystemEventKindSchema = _enum([
14533
14564
  "node-offline",
14534
14565
  "node-inference-unavailable",
14535
14566
  "detection-blind",
14567
+ "addon-crash-loop",
14536
14568
  "addon-update-available",
14537
14569
  "server-update-available",
14538
14570
  "alarm-triggered",
@@ -14540,6 +14572,9 @@ var NcSystemEventKindSchema = _enum([
14540
14572
  "alarm-disarmed",
14541
14573
  "alarm-arming",
14542
14574
  "alarm-arm-refused",
14575
+ "addon-updated",
14576
+ "server-updated",
14577
+ "export-completed",
14543
14578
  "camera-online",
14544
14579
  "camera-offline",
14545
14580
  "camera-disabled",
@@ -16433,13 +16468,19 @@ var RetrainStatusSchema = _enum([
16433
16468
  * "never marked" from "already trained" must read `retrainStatus`.
16434
16469
  *
16435
16470
  * `debug` does NOT pin; it is attention, not durability.
16471
+ *
16472
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16473
+ * A favourited track is skipped by retention the same way `staging` is, but
16474
+ * it does not enter `none|staging|trained` and has no staging budget.
16436
16475
  */
16437
16476
  var TrackFlagFields = {
16438
16477
  /** Operator marked this track as training material — i.e. `retrainStatus` is
16439
16478
  * `'staging'`. */
16440
16479
  markForTrain: boolean().optional(),
16441
16480
  /** Operator marked this track for diagnostic attention. */
16442
- debug: boolean().optional()
16481
+ debug: boolean().optional(),
16482
+ /** Operator favourited this track. Pins it against pruning. */
16483
+ favourited: boolean().optional()
16443
16484
  };
16444
16485
  /**
16445
16486
  * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
@@ -16464,6 +16505,7 @@ var TrackFlagsSchema = object({
16464
16505
  trackId: string(),
16465
16506
  markForTrain: boolean(),
16466
16507
  debug: boolean(),
16508
+ favourited: boolean(),
16467
16509
  /** The lifecycle state the boolean was derived from. Required here (unlike on
16468
16510
  * a track row) because this shape is only ever produced by the write body,
16469
16511
  * which always knows it — and a surface that has just written needs to render
@@ -17096,6 +17138,12 @@ var TrackCascadeCountsSchema = object({
17096
17138
  /** Per-track CLIP search vectors removed (best-effort). */
17097
17139
  embeddings: number().int()
17098
17140
  });
17141
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17142
+ var DiskReconcileCountsSchema = object({
17143
+ mediaDropped: number().int(),
17144
+ tracks: number().int(),
17145
+ events: number().int()
17146
+ });
17099
17147
  /** Event-store footprint for one camera. */
17100
17148
  var EventStoreDeviceFootprintSchema = object({
17101
17149
  deviceId: number(),
@@ -17272,6 +17320,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17272
17320
  }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17273
17321
  kind: "mutation",
17274
17322
  auth: "admin"
17323
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17324
+ kind: "mutation",
17325
+ auth: "admin"
17275
17326
  }), method(object({
17276
17327
  deviceId: number(),
17277
17328
  trackIds: array(string()).min(1)
@@ -18822,6 +18873,24 @@ var CameraStatusDegradationSchema = object({
18822
18873
  *
18823
18874
  * See spec: `docs/superpowers/specs/2026-06-24-camera-status-aggregator-cap.md`
18824
18875
  */
18876
+ var DiskReconcileJobSchema = object({
18877
+ state: _enum([
18878
+ "idle",
18879
+ "running",
18880
+ "done",
18881
+ "error"
18882
+ ]),
18883
+ total: number().int().nonnegative(),
18884
+ completed: number().int().nonnegative(),
18885
+ currentDeviceId: number().int().nullable(),
18886
+ failed: array(number().int()).readonly(),
18887
+ mediaDropped: number().int().nonnegative(),
18888
+ tracks: number().int().nonnegative(),
18889
+ events: number().int().nonnegative(),
18890
+ startedAtMs: number().int().nullable(),
18891
+ finishedAtMs: number().int().nullable(),
18892
+ error: string().nullable()
18893
+ });
18825
18894
  var CameraStatusSchema = object({
18826
18895
  deviceId: number(),
18827
18896
  assignment: CameraAssignmentStatusSchema,
@@ -19053,7 +19122,10 @@ method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
19053
19122
  }), CameraSwitchGroupSchema, {
19054
19123
  kind: "mutation",
19055
19124
  auth: "admin"
19056
- }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
19125
+ }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), DiskReconcileJobSchema, {
19126
+ kind: "mutation",
19127
+ auth: "admin"
19128
+ }), method(_void(), DiskReconcileJobSchema, { auth: "admin" }), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
19057
19129
  name: string(),
19058
19130
  description: string().optional(),
19059
19131
  config: CameraPipelineConfigSchema
@@ -20230,20 +20302,6 @@ var VectorStatsResultSchema = object({
20230
20302
  exact: boolean()
20231
20303
  });
20232
20304
  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);
20233
- /**
20234
- * `videoclips` — the unified, navigable-clip surface for a camera.
20235
- *
20236
- * A device-scoped WRAPPER cap (like `pipeline-analytics`): exactly one active
20237
- * provider per device, substitutable. The DEFAULT provider (registered by
20238
- * `addon-post-analysis`, `defaultActive: true`) composes the analytics event
20239
- * log (markers + thumbnails) with the recorder's `getPlaybackManifest` — a clip
20240
- * is a time-WINDOW over existing footage, never a separate file. A camera that
20241
- * exposes NATIVE onboard clips (Reolink/Hikvision NVR) can later substitute the
20242
- * wrapper provider for its device and serve its own clip catalog + URLs.
20243
- *
20244
- * A `Clip` is purely time-based (subtree-blind): playback resolves segments by
20245
- * temporal overlap, so the API never decides `continuous` vs `events`.
20246
- */
20247
20305
  var ClipSchema = object({
20248
20306
  /** Opaque, provider-namespaced id. The default provider encodes the time
20249
20307
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -20260,8 +20318,65 @@ var ClipSchema = object({
20260
20318
  startMs: number(),
20261
20319
  endMs: number()
20262
20320
  }),
20263
- /** Thumbnail URL (lazy; e.g. analytics `getEventMedia`). Never inlined. */
20264
- thumbnail: string().optional()
20321
+ /**
20322
+ * Distinct object classes attached to this visit (`person`, `car`, …),
20323
+ * dominant first, capped at {@link MAX_CLIP_LABELS}. The ribbon renders these
20324
+ * instead of the bare kind — "Object" tells the operator nothing a colour bar
20325
+ * did not. Absent (never empty) when the visit attached no classified object
20326
+ * event, so a motion/audio-only visit keeps its kind label.
20327
+ */
20328
+ labels: array(string()).max(3).optional(),
20329
+ /**
20330
+ * Lazy thumbnail URL, never inlined.
20331
+ *
20332
+ * Recording-derived clips (events-mode keep-window, and the prepared
20333
+ * continuous event+fragment visit) MUST use the snapshot of the **main
20334
+ * event of the interval** — `getEventMedia({ eventId, kind: 'snapshot' })`
20335
+ * of the event that owns `kind` (object > motion > audio). Do not extract
20336
+ * a keyframe from the recorded segments. Other providers (onboard, HKSV)
20337
+ * mint their own stills.
20338
+ *
20339
+ * **VOUCHED, never fabricated.** A provider emits this only for an event it
20340
+ * has CONFIRMED owns at least one media row (its own, or its owning track's).
20341
+ * Absent is meaningful — "this visit has no event still" — never "we did not
20342
+ * look". Stamping it from a URL template made 35% of one camera's clips point
20343
+ * at a 404 (device 3836, 2026-08-17: 64 of 179 clips dead, 63 of them motion).
20344
+ * A read that FAILS drops the claim; it never invents it.
20345
+ */
20346
+ thumbnail: string().optional(),
20347
+ /**
20348
+ * An instant INSIDE this visit's footage, hole-safe, where a recorded still
20349
+ * can be decoded. Present whenever the visit came from recorded availability;
20350
+ * absent on a per-event padded window (there is no footage to promise).
20351
+ *
20352
+ * This is not a thumbnail and not a second byte path: it is the argument to
20353
+ * the recorder's existing still route. The surface — never the provider —
20354
+ * decides whether to use it. It is the midpoint of the visit's LONGEST
20355
+ * contiguous range, not of the visit: a visit spans its holes by
20356
+ * construction, so a naive midpoint lands in dead air.
20357
+ */
20358
+ stillAtMs: number().optional(),
20359
+ /**
20360
+ * Analytics event ids that overlap this visit — a BOUNDED sample, newest
20361
+ * first within kind (object → motion → audio), capped at
20362
+ * {@link MAX_CLIP_EVENT_IDS}. Empty on footage-only clips.
20363
+ *
20364
+ * Bounded because it is not a payload the surface pages through: one visit on
20365
+ * device 615 carried 2 345 ids, and `eventIds` was 99% of a 153 KB
20366
+ * camera-day. Read {@link eventCount} for the true total.
20367
+ */
20368
+ eventIds: array(string()).optional(),
20369
+ /** How many analytics events actually overlap this visit. Differs from
20370
+ * `eventIds.length` exactly when the sample was capped — so a truncated
20371
+ * list is never mistaken for a quiet visit. */
20372
+ eventCount: number().int().nonnegative().optional(),
20373
+ /** Intra-visit footage holes (GOP rolls, discarded segments) still shorter
20374
+ * than `VISIT_MERGE_GAP_MS`. Playback concatenates around them; the timeline
20375
+ * bar keeps showing them via `recording.getAvailability`. */
20376
+ holes: array(object({
20377
+ startMs: number(),
20378
+ endMs: number()
20379
+ })).optional()
20265
20380
  });
20266
20381
  var ClipPlaybackSchema = object({
20267
20382
  /** HLS master URL through the hub data-plane (Range + token in path). */
@@ -20725,7 +20840,14 @@ var SearchResultSchema = object({
20725
20840
  });
20726
20841
  var AutoUpdateSettingsSchema = object({
20727
20842
  channel: ChannelSchema,
20728
- intervalSeconds: number()
20843
+ intervalSeconds: number(),
20844
+ /**
20845
+ * Cadence of the "an update exists" POLLER, in seconds. Independent of
20846
+ * `channel`: the poller runs while auto-apply is `off`, because being told
20847
+ * about a publish and installing it are different decisions. Clamped
20848
+ * server-side to 900 s … 604800 s; defaults to 21600 s (6 h).
20849
+ */
20850
+ updateCheckIntervalSeconds: number()
20729
20851
  });
20730
20852
  var AddonAutoUpdateSchema = ChannelWithInheritSchema;
20731
20853
  var RestartAddonResultSchema = unknown();
@@ -20866,7 +20988,9 @@ method(_void(), array(AddonListItemSchema).readonly()), method(object({
20866
20988
  auth: "admin"
20867
20989
  }), method(_void(), AutoUpdateSettingsSchema, { auth: "admin" }), method(object({
20868
20990
  channel: ChannelSchema,
20869
- intervalSeconds: number().min(300).max(86400).optional()
20991
+ intervalSeconds: number().min(300).max(86400).optional(),
20992
+ /** Availability-poll cadence; see AutoUpdateSettingsSchema. */
20993
+ updateCheckIntervalSeconds: number().min(900).max(604800).optional()
20870
20994
  }), unknown(), {
20871
20995
  kind: "mutation",
20872
20996
  auth: "admin"
@@ -26635,7 +26759,9 @@ var ExportOptionsSchema = object({
26635
26759
  includeAudio: boolean(),
26636
26760
  maxLifeMs: number().int().positive(),
26637
26761
  deleteAfterDownload: boolean(),
26638
- title: string().max(200).optional()
26762
+ title: string().max(200).optional(),
26763
+ /** Notification-output target ids to ping when this export becomes ready. */
26764
+ notifyTargetIds: array(string().min(1)).max(20).optional()
26639
26765
  }).superRefine((v, ctx) => {
26640
26766
  if (v.speed !== void 0 && v.timelapse !== void 0) ctx.addIssue({
26641
26767
  code: ZodIssueCode.custom,
@@ -26694,10 +26820,18 @@ var ExportBytesSchema = object({
26694
26820
  });
26695
26821
  method(object({
26696
26822
  deviceId: number(),
26697
- profile: string(),
26823
+ /** @deprecated Prefer `profiles`. Kept so timelapse/notifiers keep working. */
26824
+ profile: string().optional(),
26825
+ profiles: array(string()).min(1).optional(),
26698
26826
  fromMs: number(),
26699
26827
  toMs: number(),
26700
26828
  options: ExportOptionsSchema
26829
+ }).superRefine((v, ctx) => {
26830
+ if ((v.profiles !== void 0 && v.profiles.length > 0 ? v.profiles : v.profile !== void 0 ? [v.profile] : []).length < 1) ctx.addIssue({
26831
+ code: ZodIssueCode.custom,
26832
+ message: "pass profiles[] (min 1) or legacy profile",
26833
+ path: ["profiles"]
26834
+ });
26701
26835
  }), ExportRecordSchema, {
26702
26836
  kind: "mutation",
26703
26837
  auth: "protected"
@@ -29837,15 +29971,6 @@ var BaseDeviceProvider = class extends BaseAddon {
29837
29971
  labels: ["probe not implemented"]
29838
29972
  };
29839
29973
  }
29840
- /**
29841
- * Top-level devices restored at once in {@link onRestoreDevices}.
29842
- *
29843
- * Four covers the fleets this ships to without turning a boot into a burst a
29844
- * camera NVR answers with a refusal. A provider whose upstream is a single
29845
- * session with a serial command channel (a Baichuan hub, an NVR that
29846
- * serialises ISAPI) should lower it; nothing needs to raise it.
29847
- */
29848
- restoreConcurrency = 4;
29849
29974
  async restoreDevices(savedDevices) {
29850
29975
  await this.onRestoreDevices(savedDevices);
29851
29976
  if (savedDevices.length > 0) this.ctx.logger.info(`Restored ${savedDevices.length} ${this.providerName} device(s)`);
@@ -29900,14 +30025,7 @@ var BaseDeviceProvider = class extends BaseAddon {
29900
30025
  });
29901
30026
  }
29902
30027
  };
29903
- let nextTopLevel = 0;
29904
- await Promise.all(Array.from({ length: Math.min(Math.max(1, this.restoreConcurrency), topLevel.length) }, async () => {
29905
- for (;;) {
29906
- const saved = topLevel[nextTopLevel++];
29907
- if (saved === void 0) return;
29908
- await restoreOne(saved);
29909
- }
29910
- }));
30028
+ await Promise.all(topLevel.map((saved) => restoreOne(saved)));
29911
30029
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
29912
30030
  for (const saved of childRows) {
29913
30031
  const Class = this.deviceClasses[saved.type];
@@ -33311,6 +33429,12 @@ Object.freeze({
33311
33429
  addonId: null,
33312
33430
  access: "create"
33313
33431
  },
33432
+ "pipelineAnalytics.reconcileFromDisk": {
33433
+ capName: "pipeline-analytics",
33434
+ capScope: "device",
33435
+ addonId: null,
33436
+ access: "create"
33437
+ },
33314
33438
  "pipelineAnalytics.refreshStorageLocationsForMigration": {
33315
33439
  capName: "pipeline-analytics",
33316
33440
  capScope: "device",
@@ -33713,6 +33837,12 @@ Object.freeze({
33713
33837
  addonId: null,
33714
33838
  access: "view"
33715
33839
  },
33840
+ "pipelineOrchestrator.getReconcileFromDiskStatus": {
33841
+ capName: "pipeline-orchestrator",
33842
+ capScope: "system",
33843
+ addonId: null,
33844
+ access: "view"
33845
+ },
33716
33846
  "pipelineOrchestrator.listAgentSettings": {
33717
33847
  capName: "pipeline-orchestrator",
33718
33848
  capScope: "system",
@@ -33737,6 +33867,12 @@ Object.freeze({
33737
33867
  addonId: null,
33738
33868
  access: "create"
33739
33869
  },
33870
+ "pipelineOrchestrator.reconcileFromDisk": {
33871
+ capName: "pipeline-orchestrator",
33872
+ capScope: "system",
33873
+ addonId: null,
33874
+ access: "create"
33875
+ },
33740
33876
  "pipelineOrchestrator.removeAgentSettings": {
33741
33877
  capName: "pipeline-orchestrator",
33742
33878
  capScope: "system",
@@ -36728,6 +36864,11 @@ Object.freeze({
36728
36864
  form: "single",
36729
36865
  optional: true
36730
36866
  }],
36867
+ "pipelineAnalytics.reconcileFromDisk": [{
36868
+ name: "deviceId",
36869
+ form: "single",
36870
+ optional: false
36871
+ }],
36731
36872
  "pipelineAnalytics.restageRetrainTrack": [{
36732
36873
  name: "deviceId",
36733
36874
  form: "single",
@@ -37793,6 +37934,8 @@ DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
37793
37934
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
37794
37935
  DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
37795
37936
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
37937
+ var MB = 1024 * 1024;
37938
+ 1024 * MB, 3072 * MB;
37796
37939
  //#endregion
37797
37940
  //#region src/digest-auth.ts
37798
37941
  /**
package/dist/addon.mjs CHANGED
@@ -5,7 +5,7 @@ import { networkInterfaces } from "node:os";
5
5
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
6
6
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
7
7
  //#endregion
8
- //#region ../types/dist/event-category-Bxo5yJjt.mjs
8
+ //#region ../types/dist/event-category-XfKNtfCc.mjs
9
9
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
10
10
  EventCategory["SystemBoot"] = "system.boot";
11
11
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -22,9 +22,10 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
22
22
  EventCategory["SystemRestartCompleted"] = "system.restart-completed";
23
23
  /**
24
24
  * A newer addon or server-root package version was found by the
25
- * authoritative registry check. Emitted once per
26
- * `(target, packageName, currentVersion, latestVersion)` transition; repeated
27
- * polling of the same result is deduplicated by the checker.
25
+ * authoritative registry check. Emitted once when any observed
26
+ * `latestVersion` changes (or a package/node first appears behind);
27
+ * the payload carries the full currently-available list. Repeated
28
+ * polling of the same latests is silent.
28
29
  */
29
30
  EventCategory["UpdateAvailable"] = "update.available";
30
31
  /**
@@ -43,6 +44,22 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
43
44
  EventCategory["AddonInstalled"] = "addon.installed";
44
45
  EventCategory["AddonUninstalled"] = "addon.uninstalled";
45
46
  EventCategory["AddonCrashed"] = "addon.crashed";
47
+ /**
48
+ * A RUNNER the D6 crash circuit-breaker gave up on — terminal.
49
+ *
50
+ * `AddonCrashed` is the routine, self-healing fact ("it crashed; it is being
51
+ * respawned"); this is the one that never resolves itself. Emitted exactly
52
+ * once per trip, by `process-service.ts`, carrying the node, the runner, the
53
+ * addons it hosted and the crash count that tripped the breaker.
54
+ *
55
+ * It exists because a runner marked terminally `failed` used to be SILENT:
56
+ * on 2026-08-18 the `recorder` runner died of three unhandled ffmpeg spawn
57
+ * errors, the breaker stopped respawning it (correctly), `/health` kept
58
+ * returning 200, and fleet-wide recording was gone for 3h15 before the
59
+ * operator's phone told him. The Notification Center's system-event intake
60
+ * consumes this category and maps it to the `addon-crash-loop` kind.
61
+ */
62
+ EventCategory["AddonRunnerFailed"] = "addon.runner-failed";
46
63
  EventCategory["AddonError"] = "addon.error";
47
64
  EventCategory["AddonPageReady"] = "addon.page-ready";
48
65
  EventCategory["AddonWidgetReady"] = "addon.widget-ready";
@@ -7542,6 +7559,10 @@ var RecordingBandSchema = object({
7542
7559
  preBufferSec: number().min(0).optional(),
7543
7560
  postBufferSec: number().min(0).optional()
7544
7561
  });
7562
+ ({
7563
+ preBufferSec: 10,
7564
+ postBufferSec: 30
7565
+ }).postBufferSec * 1e3;
7545
7566
  /**
7546
7567
  * Per-device retention overrides. Every field is optional; an unset or `0`
7547
7568
  * value inherits the node-wide recorder default. Only footage-lifetime limits
@@ -7589,6 +7610,12 @@ var RecordingConfigSchema = object({
7589
7610
  /** DERIVED summary of `bands`, stamped by the recorder on every save.
7590
7611
  * Authoring it has no effect — see {@link RecordingStorageModeSchema}. */
7591
7612
  mode: RecordingStorageModeSchema.optional(),
7613
+ /**
7614
+ * Which assigned broker slots to record. Absent / empty = {@link
7615
+ * DEFAULT_RECORDING_PROFILES} (`high`+`low`) intersected with the
7616
+ * camera's currently assigned slots — never `mid` unless the operator
7617
+ * picks it, and never a slot the broker has not assigned.
7618
+ */
7592
7619
  profiles: array(CamProfileSchema).optional(),
7593
7620
  segmentSeconds: number().int().positive().optional(),
7594
7621
  /**
@@ -7669,7 +7696,11 @@ var RelocateFootageInputSchema = object({
7669
7696
  profiles: array(string()).optional(),
7670
7697
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7671
7698
  * never allowed to starve live writers. */
7672
- throttleMbps: number().min(1).max(1e3).optional()
7699
+ throttleMbps: number().min(1).max(1e3).optional(),
7700
+ /** Move only segments whose startMs is >= this. Absent = the whole source
7701
+ * pile. Used when a full drain is too expensive and the operator only
7702
+ * wants the recent window on the new disk. */
7703
+ sinceMs: number().int().optional()
7673
7704
  });
7674
7705
  /** Internal, lease-scoped participant operation. It is intentionally separate
7675
7706
  * from persistent recording settings: a migration never changes
@@ -14534,6 +14565,7 @@ var NcSystemEventKindSchema = _enum([
14534
14565
  "node-offline",
14535
14566
  "node-inference-unavailable",
14536
14567
  "detection-blind",
14568
+ "addon-crash-loop",
14537
14569
  "addon-update-available",
14538
14570
  "server-update-available",
14539
14571
  "alarm-triggered",
@@ -14541,6 +14573,9 @@ var NcSystemEventKindSchema = _enum([
14541
14573
  "alarm-disarmed",
14542
14574
  "alarm-arming",
14543
14575
  "alarm-arm-refused",
14576
+ "addon-updated",
14577
+ "server-updated",
14578
+ "export-completed",
14544
14579
  "camera-online",
14545
14580
  "camera-offline",
14546
14581
  "camera-disabled",
@@ -16434,13 +16469,19 @@ var RetrainStatusSchema = _enum([
16434
16469
  * "never marked" from "already trained" must read `retrainStatus`.
16435
16470
  *
16436
16471
  * `debug` does NOT pin; it is attention, not durability.
16472
+ *
16473
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16474
+ * A favourited track is skipped by retention the same way `staging` is, but
16475
+ * it does not enter `none|staging|trained` and has no staging budget.
16437
16476
  */
16438
16477
  var TrackFlagFields = {
16439
16478
  /** Operator marked this track as training material — i.e. `retrainStatus` is
16440
16479
  * `'staging'`. */
16441
16480
  markForTrain: boolean().optional(),
16442
16481
  /** Operator marked this track for diagnostic attention. */
16443
- debug: boolean().optional()
16482
+ debug: boolean().optional(),
16483
+ /** Operator favourited this track. Pins it against pruning. */
16484
+ favourited: boolean().optional()
16444
16485
  };
16445
16486
  /**
16446
16487
  * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
@@ -16465,6 +16506,7 @@ var TrackFlagsSchema = object({
16465
16506
  trackId: string(),
16466
16507
  markForTrain: boolean(),
16467
16508
  debug: boolean(),
16509
+ favourited: boolean(),
16468
16510
  /** The lifecycle state the boolean was derived from. Required here (unlike on
16469
16511
  * a track row) because this shape is only ever produced by the write body,
16470
16512
  * which always knows it — and a surface that has just written needs to render
@@ -17097,6 +17139,12 @@ var TrackCascadeCountsSchema = object({
17097
17139
  /** Per-track CLIP search vectors removed (best-effort). */
17098
17140
  embeddings: number().int()
17099
17141
  });
17142
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17143
+ var DiskReconcileCountsSchema = object({
17144
+ mediaDropped: number().int(),
17145
+ tracks: number().int(),
17146
+ events: number().int()
17147
+ });
17100
17148
  /** Event-store footprint for one camera. */
17101
17149
  var EventStoreDeviceFootprintSchema = object({
17102
17150
  deviceId: number(),
@@ -17273,6 +17321,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17273
17321
  }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17274
17322
  kind: "mutation",
17275
17323
  auth: "admin"
17324
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17325
+ kind: "mutation",
17326
+ auth: "admin"
17276
17327
  }), method(object({
17277
17328
  deviceId: number(),
17278
17329
  trackIds: array(string()).min(1)
@@ -18823,6 +18874,24 @@ var CameraStatusDegradationSchema = object({
18823
18874
  *
18824
18875
  * See spec: `docs/superpowers/specs/2026-06-24-camera-status-aggregator-cap.md`
18825
18876
  */
18877
+ var DiskReconcileJobSchema = object({
18878
+ state: _enum([
18879
+ "idle",
18880
+ "running",
18881
+ "done",
18882
+ "error"
18883
+ ]),
18884
+ total: number().int().nonnegative(),
18885
+ completed: number().int().nonnegative(),
18886
+ currentDeviceId: number().int().nullable(),
18887
+ failed: array(number().int()).readonly(),
18888
+ mediaDropped: number().int().nonnegative(),
18889
+ tracks: number().int().nonnegative(),
18890
+ events: number().int().nonnegative(),
18891
+ startedAtMs: number().int().nullable(),
18892
+ finishedAtMs: number().int().nullable(),
18893
+ error: string().nullable()
18894
+ });
18826
18895
  var CameraStatusSchema = object({
18827
18896
  deviceId: number(),
18828
18897
  assignment: CameraAssignmentStatusSchema,
@@ -19054,7 +19123,10 @@ method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
19054
19123
  }), CameraSwitchGroupSchema, {
19055
19124
  kind: "mutation",
19056
19125
  auth: "admin"
19057
- }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
19126
+ }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), DiskReconcileJobSchema, {
19127
+ kind: "mutation",
19128
+ auth: "admin"
19129
+ }), method(_void(), DiskReconcileJobSchema, { auth: "admin" }), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
19058
19130
  name: string(),
19059
19131
  description: string().optional(),
19060
19132
  config: CameraPipelineConfigSchema
@@ -20231,20 +20303,6 @@ var VectorStatsResultSchema = object({
20231
20303
  exact: boolean()
20232
20304
  });
20233
20305
  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);
20234
- /**
20235
- * `videoclips` — the unified, navigable-clip surface for a camera.
20236
- *
20237
- * A device-scoped WRAPPER cap (like `pipeline-analytics`): exactly one active
20238
- * provider per device, substitutable. The DEFAULT provider (registered by
20239
- * `addon-post-analysis`, `defaultActive: true`) composes the analytics event
20240
- * log (markers + thumbnails) with the recorder's `getPlaybackManifest` — a clip
20241
- * is a time-WINDOW over existing footage, never a separate file. A camera that
20242
- * exposes NATIVE onboard clips (Reolink/Hikvision NVR) can later substitute the
20243
- * wrapper provider for its device and serve its own clip catalog + URLs.
20244
- *
20245
- * A `Clip` is purely time-based (subtree-blind): playback resolves segments by
20246
- * temporal overlap, so the API never decides `continuous` vs `events`.
20247
- */
20248
20306
  var ClipSchema = object({
20249
20307
  /** Opaque, provider-namespaced id. The default provider encodes the time
20250
20308
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -20261,8 +20319,65 @@ var ClipSchema = object({
20261
20319
  startMs: number(),
20262
20320
  endMs: number()
20263
20321
  }),
20264
- /** Thumbnail URL (lazy; e.g. analytics `getEventMedia`). Never inlined. */
20265
- thumbnail: string().optional()
20322
+ /**
20323
+ * Distinct object classes attached to this visit (`person`, `car`, …),
20324
+ * dominant first, capped at {@link MAX_CLIP_LABELS}. The ribbon renders these
20325
+ * instead of the bare kind — "Object" tells the operator nothing a colour bar
20326
+ * did not. Absent (never empty) when the visit attached no classified object
20327
+ * event, so a motion/audio-only visit keeps its kind label.
20328
+ */
20329
+ labels: array(string()).max(3).optional(),
20330
+ /**
20331
+ * Lazy thumbnail URL, never inlined.
20332
+ *
20333
+ * Recording-derived clips (events-mode keep-window, and the prepared
20334
+ * continuous event+fragment visit) MUST use the snapshot of the **main
20335
+ * event of the interval** — `getEventMedia({ eventId, kind: 'snapshot' })`
20336
+ * of the event that owns `kind` (object > motion > audio). Do not extract
20337
+ * a keyframe from the recorded segments. Other providers (onboard, HKSV)
20338
+ * mint their own stills.
20339
+ *
20340
+ * **VOUCHED, never fabricated.** A provider emits this only for an event it
20341
+ * has CONFIRMED owns at least one media row (its own, or its owning track's).
20342
+ * Absent is meaningful — "this visit has no event still" — never "we did not
20343
+ * look". Stamping it from a URL template made 35% of one camera's clips point
20344
+ * at a 404 (device 3836, 2026-08-17: 64 of 179 clips dead, 63 of them motion).
20345
+ * A read that FAILS drops the claim; it never invents it.
20346
+ */
20347
+ thumbnail: string().optional(),
20348
+ /**
20349
+ * An instant INSIDE this visit's footage, hole-safe, where a recorded still
20350
+ * can be decoded. Present whenever the visit came from recorded availability;
20351
+ * absent on a per-event padded window (there is no footage to promise).
20352
+ *
20353
+ * This is not a thumbnail and not a second byte path: it is the argument to
20354
+ * the recorder's existing still route. The surface — never the provider —
20355
+ * decides whether to use it. It is the midpoint of the visit's LONGEST
20356
+ * contiguous range, not of the visit: a visit spans its holes by
20357
+ * construction, so a naive midpoint lands in dead air.
20358
+ */
20359
+ stillAtMs: number().optional(),
20360
+ /**
20361
+ * Analytics event ids that overlap this visit — a BOUNDED sample, newest
20362
+ * first within kind (object → motion → audio), capped at
20363
+ * {@link MAX_CLIP_EVENT_IDS}. Empty on footage-only clips.
20364
+ *
20365
+ * Bounded because it is not a payload the surface pages through: one visit on
20366
+ * device 615 carried 2 345 ids, and `eventIds` was 99% of a 153 KB
20367
+ * camera-day. Read {@link eventCount} for the true total.
20368
+ */
20369
+ eventIds: array(string()).optional(),
20370
+ /** How many analytics events actually overlap this visit. Differs from
20371
+ * `eventIds.length` exactly when the sample was capped — so a truncated
20372
+ * list is never mistaken for a quiet visit. */
20373
+ eventCount: number().int().nonnegative().optional(),
20374
+ /** Intra-visit footage holes (GOP rolls, discarded segments) still shorter
20375
+ * than `VISIT_MERGE_GAP_MS`. Playback concatenates around them; the timeline
20376
+ * bar keeps showing them via `recording.getAvailability`. */
20377
+ holes: array(object({
20378
+ startMs: number(),
20379
+ endMs: number()
20380
+ })).optional()
20266
20381
  });
20267
20382
  var ClipPlaybackSchema = object({
20268
20383
  /** HLS master URL through the hub data-plane (Range + token in path). */
@@ -20726,7 +20841,14 @@ var SearchResultSchema = object({
20726
20841
  });
20727
20842
  var AutoUpdateSettingsSchema = object({
20728
20843
  channel: ChannelSchema,
20729
- intervalSeconds: number()
20844
+ intervalSeconds: number(),
20845
+ /**
20846
+ * Cadence of the "an update exists" POLLER, in seconds. Independent of
20847
+ * `channel`: the poller runs while auto-apply is `off`, because being told
20848
+ * about a publish and installing it are different decisions. Clamped
20849
+ * server-side to 900 s … 604800 s; defaults to 21600 s (6 h).
20850
+ */
20851
+ updateCheckIntervalSeconds: number()
20730
20852
  });
20731
20853
  var AddonAutoUpdateSchema = ChannelWithInheritSchema;
20732
20854
  var RestartAddonResultSchema = unknown();
@@ -20867,7 +20989,9 @@ method(_void(), array(AddonListItemSchema).readonly()), method(object({
20867
20989
  auth: "admin"
20868
20990
  }), method(_void(), AutoUpdateSettingsSchema, { auth: "admin" }), method(object({
20869
20991
  channel: ChannelSchema,
20870
- intervalSeconds: number().min(300).max(86400).optional()
20992
+ intervalSeconds: number().min(300).max(86400).optional(),
20993
+ /** Availability-poll cadence; see AutoUpdateSettingsSchema. */
20994
+ updateCheckIntervalSeconds: number().min(900).max(604800).optional()
20871
20995
  }), unknown(), {
20872
20996
  kind: "mutation",
20873
20997
  auth: "admin"
@@ -26636,7 +26760,9 @@ var ExportOptionsSchema = object({
26636
26760
  includeAudio: boolean(),
26637
26761
  maxLifeMs: number().int().positive(),
26638
26762
  deleteAfterDownload: boolean(),
26639
- title: string().max(200).optional()
26763
+ title: string().max(200).optional(),
26764
+ /** Notification-output target ids to ping when this export becomes ready. */
26765
+ notifyTargetIds: array(string().min(1)).max(20).optional()
26640
26766
  }).superRefine((v, ctx) => {
26641
26767
  if (v.speed !== void 0 && v.timelapse !== void 0) ctx.addIssue({
26642
26768
  code: ZodIssueCode.custom,
@@ -26695,10 +26821,18 @@ var ExportBytesSchema = object({
26695
26821
  });
26696
26822
  method(object({
26697
26823
  deviceId: number(),
26698
- profile: string(),
26824
+ /** @deprecated Prefer `profiles`. Kept so timelapse/notifiers keep working. */
26825
+ profile: string().optional(),
26826
+ profiles: array(string()).min(1).optional(),
26699
26827
  fromMs: number(),
26700
26828
  toMs: number(),
26701
26829
  options: ExportOptionsSchema
26830
+ }).superRefine((v, ctx) => {
26831
+ if ((v.profiles !== void 0 && v.profiles.length > 0 ? v.profiles : v.profile !== void 0 ? [v.profile] : []).length < 1) ctx.addIssue({
26832
+ code: ZodIssueCode.custom,
26833
+ message: "pass profiles[] (min 1) or legacy profile",
26834
+ path: ["profiles"]
26835
+ });
26702
26836
  }), ExportRecordSchema, {
26703
26837
  kind: "mutation",
26704
26838
  auth: "protected"
@@ -29838,15 +29972,6 @@ var BaseDeviceProvider = class extends BaseAddon {
29838
29972
  labels: ["probe not implemented"]
29839
29973
  };
29840
29974
  }
29841
- /**
29842
- * Top-level devices restored at once in {@link onRestoreDevices}.
29843
- *
29844
- * Four covers the fleets this ships to without turning a boot into a burst a
29845
- * camera NVR answers with a refusal. A provider whose upstream is a single
29846
- * session with a serial command channel (a Baichuan hub, an NVR that
29847
- * serialises ISAPI) should lower it; nothing needs to raise it.
29848
- */
29849
- restoreConcurrency = 4;
29850
29975
  async restoreDevices(savedDevices) {
29851
29976
  await this.onRestoreDevices(savedDevices);
29852
29977
  if (savedDevices.length > 0) this.ctx.logger.info(`Restored ${savedDevices.length} ${this.providerName} device(s)`);
@@ -29901,14 +30026,7 @@ var BaseDeviceProvider = class extends BaseAddon {
29901
30026
  });
29902
30027
  }
29903
30028
  };
29904
- let nextTopLevel = 0;
29905
- await Promise.all(Array.from({ length: Math.min(Math.max(1, this.restoreConcurrency), topLevel.length) }, async () => {
29906
- for (;;) {
29907
- const saved = topLevel[nextTopLevel++];
29908
- if (saved === void 0) return;
29909
- await restoreOne(saved);
29910
- }
29911
- }));
30029
+ await Promise.all(topLevel.map((saved) => restoreOne(saved)));
29912
30030
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
29913
30031
  for (const saved of childRows) {
29914
30032
  const Class = this.deviceClasses[saved.type];
@@ -33312,6 +33430,12 @@ Object.freeze({
33312
33430
  addonId: null,
33313
33431
  access: "create"
33314
33432
  },
33433
+ "pipelineAnalytics.reconcileFromDisk": {
33434
+ capName: "pipeline-analytics",
33435
+ capScope: "device",
33436
+ addonId: null,
33437
+ access: "create"
33438
+ },
33315
33439
  "pipelineAnalytics.refreshStorageLocationsForMigration": {
33316
33440
  capName: "pipeline-analytics",
33317
33441
  capScope: "device",
@@ -33714,6 +33838,12 @@ Object.freeze({
33714
33838
  addonId: null,
33715
33839
  access: "view"
33716
33840
  },
33841
+ "pipelineOrchestrator.getReconcileFromDiskStatus": {
33842
+ capName: "pipeline-orchestrator",
33843
+ capScope: "system",
33844
+ addonId: null,
33845
+ access: "view"
33846
+ },
33717
33847
  "pipelineOrchestrator.listAgentSettings": {
33718
33848
  capName: "pipeline-orchestrator",
33719
33849
  capScope: "system",
@@ -33738,6 +33868,12 @@ Object.freeze({
33738
33868
  addonId: null,
33739
33869
  access: "create"
33740
33870
  },
33871
+ "pipelineOrchestrator.reconcileFromDisk": {
33872
+ capName: "pipeline-orchestrator",
33873
+ capScope: "system",
33874
+ addonId: null,
33875
+ access: "create"
33876
+ },
33741
33877
  "pipelineOrchestrator.removeAgentSettings": {
33742
33878
  capName: "pipeline-orchestrator",
33743
33879
  capScope: "system",
@@ -36729,6 +36865,11 @@ Object.freeze({
36729
36865
  form: "single",
36730
36866
  optional: true
36731
36867
  }],
36868
+ "pipelineAnalytics.reconcileFromDisk": [{
36869
+ name: "deviceId",
36870
+ form: "single",
36871
+ optional: false
36872
+ }],
36732
36873
  "pipelineAnalytics.restageRetrainTrack": [{
36733
36874
  name: "deviceId",
36734
36875
  form: "single",
@@ -37794,6 +37935,8 @@ DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
37794
37935
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
37795
37936
  DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
37796
37937
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
37938
+ var MB = 1024 * 1024;
37939
+ 1024 * MB, 3072 * MB;
37797
37940
  //#endregion
37798
37941
  //#region src/digest-auth.ts
37799
37942
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-amcrest",
3
- "version": "0.2.21",
3
+ "version": "0.2.23",
4
4
  "description": "Amcrest/Dahua camera device provider addon for CamStack — Dahua CGI over HTTP(S) with digest auth (snapshot, RTSP catalog, PTZ, image/day-night config)",
5
5
  "keywords": [
6
6
  "camstack",