@camstack/addon-provider-ecowitt 0.2.19 → 0.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
  let http = require("http");
3
3
  let events = require("events");
4
4
  let dgram = require("dgram");
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";
@@ -7551,6 +7568,10 @@ var RecordingBandSchema = object({
7551
7568
  preBufferSec: number().min(0).optional(),
7552
7569
  postBufferSec: number().min(0).optional()
7553
7570
  });
7571
+ ({
7572
+ preBufferSec: 10,
7573
+ postBufferSec: 30
7574
+ }).postBufferSec * 1e3;
7554
7575
  /**
7555
7576
  * Per-device retention overrides. Every field is optional; an unset or `0`
7556
7577
  * value inherits the node-wide recorder default. Only footage-lifetime limits
@@ -7598,6 +7619,12 @@ var RecordingConfigSchema = object({
7598
7619
  /** DERIVED summary of `bands`, stamped by the recorder on every save.
7599
7620
  * Authoring it has no effect — see {@link RecordingStorageModeSchema}. */
7600
7621
  mode: RecordingStorageModeSchema.optional(),
7622
+ /**
7623
+ * Which assigned broker slots to record. Absent / empty = {@link
7624
+ * DEFAULT_RECORDING_PROFILES} (`high`+`low`) intersected with the
7625
+ * camera's currently assigned slots — never `mid` unless the operator
7626
+ * picks it, and never a slot the broker has not assigned.
7627
+ */
7601
7628
  profiles: array(CamProfileSchema).optional(),
7602
7629
  segmentSeconds: number().int().positive().optional(),
7603
7630
  /**
@@ -7678,7 +7705,11 @@ var RelocateFootageInputSchema = object({
7678
7705
  profiles: array(string()).optional(),
7679
7706
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7680
7707
  * never allowed to starve live writers. */
7681
- throttleMbps: number().min(1).max(1e3).optional()
7708
+ throttleMbps: number().min(1).max(1e3).optional(),
7709
+ /** Move only segments whose startMs is >= this. Absent = the whole source
7710
+ * pile. Used when a full drain is too expensive and the operator only
7711
+ * wants the recent window on the new disk. */
7712
+ sinceMs: number().int().optional()
7682
7713
  });
7683
7714
  /** Internal, lease-scoped participant operation. It is intentionally separate
7684
7715
  * from persistent recording settings: a migration never changes
@@ -14543,6 +14574,7 @@ var NcSystemEventKindSchema = _enum([
14543
14574
  "node-offline",
14544
14575
  "node-inference-unavailable",
14545
14576
  "detection-blind",
14577
+ "addon-crash-loop",
14546
14578
  "addon-update-available",
14547
14579
  "server-update-available",
14548
14580
  "alarm-triggered",
@@ -14550,6 +14582,9 @@ var NcSystemEventKindSchema = _enum([
14550
14582
  "alarm-disarmed",
14551
14583
  "alarm-arming",
14552
14584
  "alarm-arm-refused",
14585
+ "addon-updated",
14586
+ "server-updated",
14587
+ "export-completed",
14553
14588
  "camera-online",
14554
14589
  "camera-offline",
14555
14590
  "camera-disabled",
@@ -16443,13 +16478,19 @@ var RetrainStatusSchema = _enum([
16443
16478
  * "never marked" from "already trained" must read `retrainStatus`.
16444
16479
  *
16445
16480
  * `debug` does NOT pin; it is attention, not durability.
16481
+ *
16482
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16483
+ * A favourited track is skipped by retention the same way `staging` is, but
16484
+ * it does not enter `none|staging|trained` and has no staging budget.
16446
16485
  */
16447
16486
  var TrackFlagFields = {
16448
16487
  /** Operator marked this track as training material — i.e. `retrainStatus` is
16449
16488
  * `'staging'`. */
16450
16489
  markForTrain: boolean().optional(),
16451
16490
  /** Operator marked this track for diagnostic attention. */
16452
- debug: boolean().optional()
16491
+ debug: boolean().optional(),
16492
+ /** Operator favourited this track. Pins it against pruning. */
16493
+ favourited: boolean().optional()
16453
16494
  };
16454
16495
  /**
16455
16496
  * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
@@ -16474,6 +16515,7 @@ var TrackFlagsSchema = object({
16474
16515
  trackId: string(),
16475
16516
  markForTrain: boolean(),
16476
16517
  debug: boolean(),
16518
+ favourited: boolean(),
16477
16519
  /** The lifecycle state the boolean was derived from. Required here (unlike on
16478
16520
  * a track row) because this shape is only ever produced by the write body,
16479
16521
  * which always knows it — and a surface that has just written needs to render
@@ -17106,6 +17148,12 @@ var TrackCascadeCountsSchema = object({
17106
17148
  /** Per-track CLIP search vectors removed (best-effort). */
17107
17149
  embeddings: number().int()
17108
17150
  });
17151
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17152
+ var DiskReconcileCountsSchema = object({
17153
+ mediaDropped: number().int(),
17154
+ tracks: number().int(),
17155
+ events: number().int()
17156
+ });
17109
17157
  /** Event-store footprint for one camera. */
17110
17158
  var EventStoreDeviceFootprintSchema = object({
17111
17159
  deviceId: number(),
@@ -17282,6 +17330,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17282
17330
  }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17283
17331
  kind: "mutation",
17284
17332
  auth: "admin"
17333
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17334
+ kind: "mutation",
17335
+ auth: "admin"
17285
17336
  }), method(object({
17286
17337
  deviceId: number(),
17287
17338
  trackIds: array(string()).min(1)
@@ -18832,6 +18883,24 @@ var CameraStatusDegradationSchema = object({
18832
18883
  *
18833
18884
  * See spec: `docs/superpowers/specs/2026-06-24-camera-status-aggregator-cap.md`
18834
18885
  */
18886
+ var DiskReconcileJobSchema = object({
18887
+ state: _enum([
18888
+ "idle",
18889
+ "running",
18890
+ "done",
18891
+ "error"
18892
+ ]),
18893
+ total: number().int().nonnegative(),
18894
+ completed: number().int().nonnegative(),
18895
+ currentDeviceId: number().int().nullable(),
18896
+ failed: array(number().int()).readonly(),
18897
+ mediaDropped: number().int().nonnegative(),
18898
+ tracks: number().int().nonnegative(),
18899
+ events: number().int().nonnegative(),
18900
+ startedAtMs: number().int().nullable(),
18901
+ finishedAtMs: number().int().nullable(),
18902
+ error: string().nullable()
18903
+ });
18835
18904
  var CameraStatusSchema = object({
18836
18905
  deviceId: number(),
18837
18906
  assignment: CameraAssignmentStatusSchema,
@@ -19063,7 +19132,10 @@ method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
19063
19132
  }), CameraSwitchGroupSchema, {
19064
19133
  kind: "mutation",
19065
19134
  auth: "admin"
19066
- }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
19135
+ }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), DiskReconcileJobSchema, {
19136
+ kind: "mutation",
19137
+ auth: "admin"
19138
+ }), method(_void(), DiskReconcileJobSchema, { auth: "admin" }), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
19067
19139
  name: string(),
19068
19140
  description: string().optional(),
19069
19141
  config: CameraPipelineConfigSchema
@@ -20136,20 +20208,6 @@ var VectorStatsResultSchema = object({
20136
20208
  exact: boolean()
20137
20209
  });
20138
20210
  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);
20139
- /**
20140
- * `videoclips` — the unified, navigable-clip surface for a camera.
20141
- *
20142
- * A device-scoped WRAPPER cap (like `pipeline-analytics`): exactly one active
20143
- * provider per device, substitutable. The DEFAULT provider (registered by
20144
- * `addon-post-analysis`, `defaultActive: true`) composes the analytics event
20145
- * log (markers + thumbnails) with the recorder's `getPlaybackManifest` — a clip
20146
- * is a time-WINDOW over existing footage, never a separate file. A camera that
20147
- * exposes NATIVE onboard clips (Reolink/Hikvision NVR) can later substitute the
20148
- * wrapper provider for its device and serve its own clip catalog + URLs.
20149
- *
20150
- * A `Clip` is purely time-based (subtree-blind): playback resolves segments by
20151
- * temporal overlap, so the API never decides `continuous` vs `events`.
20152
- */
20153
20211
  var ClipSchema = object({
20154
20212
  /** Opaque, provider-namespaced id. The default provider encodes the time
20155
20213
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -20166,8 +20224,65 @@ var ClipSchema = object({
20166
20224
  startMs: number(),
20167
20225
  endMs: number()
20168
20226
  }),
20169
- /** Thumbnail URL (lazy; e.g. analytics `getEventMedia`). Never inlined. */
20170
- thumbnail: string().optional()
20227
+ /**
20228
+ * Distinct object classes attached to this visit (`person`, `car`, …),
20229
+ * dominant first, capped at {@link MAX_CLIP_LABELS}. The ribbon renders these
20230
+ * instead of the bare kind — "Object" tells the operator nothing a colour bar
20231
+ * did not. Absent (never empty) when the visit attached no classified object
20232
+ * event, so a motion/audio-only visit keeps its kind label.
20233
+ */
20234
+ labels: array(string()).max(3).optional(),
20235
+ /**
20236
+ * Lazy thumbnail URL, never inlined.
20237
+ *
20238
+ * Recording-derived clips (events-mode keep-window, and the prepared
20239
+ * continuous event+fragment visit) MUST use the snapshot of the **main
20240
+ * event of the interval** — `getEventMedia({ eventId, kind: 'snapshot' })`
20241
+ * of the event that owns `kind` (object > motion > audio). Do not extract
20242
+ * a keyframe from the recorded segments. Other providers (onboard, HKSV)
20243
+ * mint their own stills.
20244
+ *
20245
+ * **VOUCHED, never fabricated.** A provider emits this only for an event it
20246
+ * has CONFIRMED owns at least one media row (its own, or its owning track's).
20247
+ * Absent is meaningful — "this visit has no event still" — never "we did not
20248
+ * look". Stamping it from a URL template made 35% of one camera's clips point
20249
+ * at a 404 (device 3836, 2026-08-17: 64 of 179 clips dead, 63 of them motion).
20250
+ * A read that FAILS drops the claim; it never invents it.
20251
+ */
20252
+ thumbnail: string().optional(),
20253
+ /**
20254
+ * An instant INSIDE this visit's footage, hole-safe, where a recorded still
20255
+ * can be decoded. Present whenever the visit came from recorded availability;
20256
+ * absent on a per-event padded window (there is no footage to promise).
20257
+ *
20258
+ * This is not a thumbnail and not a second byte path: it is the argument to
20259
+ * the recorder's existing still route. The surface — never the provider —
20260
+ * decides whether to use it. It is the midpoint of the visit's LONGEST
20261
+ * contiguous range, not of the visit: a visit spans its holes by
20262
+ * construction, so a naive midpoint lands in dead air.
20263
+ */
20264
+ stillAtMs: number().optional(),
20265
+ /**
20266
+ * Analytics event ids that overlap this visit — a BOUNDED sample, newest
20267
+ * first within kind (object → motion → audio), capped at
20268
+ * {@link MAX_CLIP_EVENT_IDS}. Empty on footage-only clips.
20269
+ *
20270
+ * Bounded because it is not a payload the surface pages through: one visit on
20271
+ * device 615 carried 2 345 ids, and `eventIds` was 99% of a 153 KB
20272
+ * camera-day. Read {@link eventCount} for the true total.
20273
+ */
20274
+ eventIds: array(string()).optional(),
20275
+ /** How many analytics events actually overlap this visit. Differs from
20276
+ * `eventIds.length` exactly when the sample was capped — so a truncated
20277
+ * list is never mistaken for a quiet visit. */
20278
+ eventCount: number().int().nonnegative().optional(),
20279
+ /** Intra-visit footage holes (GOP rolls, discarded segments) still shorter
20280
+ * than `VISIT_MERGE_GAP_MS`. Playback concatenates around them; the timeline
20281
+ * bar keeps showing them via `recording.getAvailability`. */
20282
+ holes: array(object({
20283
+ startMs: number(),
20284
+ endMs: number()
20285
+ })).optional()
20171
20286
  });
20172
20287
  var ClipPlaybackSchema = object({
20173
20288
  /** HLS master URL through the hub data-plane (Range + token in path). */
@@ -20631,7 +20746,14 @@ var SearchResultSchema = object({
20631
20746
  });
20632
20747
  var AutoUpdateSettingsSchema = object({
20633
20748
  channel: ChannelSchema,
20634
- intervalSeconds: number()
20749
+ intervalSeconds: number(),
20750
+ /**
20751
+ * Cadence of the "an update exists" POLLER, in seconds. Independent of
20752
+ * `channel`: the poller runs while auto-apply is `off`, because being told
20753
+ * about a publish and installing it are different decisions. Clamped
20754
+ * server-side to 900 s … 604800 s; defaults to 21600 s (6 h).
20755
+ */
20756
+ updateCheckIntervalSeconds: number()
20635
20757
  });
20636
20758
  var AddonAutoUpdateSchema = ChannelWithInheritSchema;
20637
20759
  var RestartAddonResultSchema = unknown();
@@ -20772,7 +20894,9 @@ method(_void(), array(AddonListItemSchema).readonly()), method(object({
20772
20894
  auth: "admin"
20773
20895
  }), method(_void(), AutoUpdateSettingsSchema, { auth: "admin" }), method(object({
20774
20896
  channel: ChannelSchema,
20775
- intervalSeconds: number().min(300).max(86400).optional()
20897
+ intervalSeconds: number().min(300).max(86400).optional(),
20898
+ /** Availability-poll cadence; see AutoUpdateSettingsSchema. */
20899
+ updateCheckIntervalSeconds: number().min(900).max(604800).optional()
20776
20900
  }), unknown(), {
20777
20901
  kind: "mutation",
20778
20902
  auth: "admin"
@@ -26453,7 +26577,9 @@ var ExportOptionsSchema = object({
26453
26577
  includeAudio: boolean(),
26454
26578
  maxLifeMs: number().int().positive(),
26455
26579
  deleteAfterDownload: boolean(),
26456
- title: string().max(200).optional()
26580
+ title: string().max(200).optional(),
26581
+ /** Notification-output target ids to ping when this export becomes ready. */
26582
+ notifyTargetIds: array(string().min(1)).max(20).optional()
26457
26583
  }).superRefine((v, ctx) => {
26458
26584
  if (v.speed !== void 0 && v.timelapse !== void 0) ctx.addIssue({
26459
26585
  code: ZodIssueCode$1.custom,
@@ -26512,10 +26638,18 @@ var ExportBytesSchema = object({
26512
26638
  });
26513
26639
  method(object({
26514
26640
  deviceId: number(),
26515
- profile: string(),
26641
+ /** @deprecated Prefer `profiles`. Kept so timelapse/notifiers keep working. */
26642
+ profile: string().optional(),
26643
+ profiles: array(string()).min(1).optional(),
26516
26644
  fromMs: number(),
26517
26645
  toMs: number(),
26518
26646
  options: ExportOptionsSchema
26647
+ }).superRefine((v, ctx) => {
26648
+ if ((v.profiles !== void 0 && v.profiles.length > 0 ? v.profiles : v.profile !== void 0 ? [v.profile] : []).length < 1) ctx.addIssue({
26649
+ code: ZodIssueCode$1.custom,
26650
+ message: "pass profiles[] (min 1) or legacy profile",
26651
+ path: ["profiles"]
26652
+ });
26519
26653
  }), ExportRecordSchema, {
26520
26654
  kind: "mutation",
26521
26655
  auth: "protected"
@@ -29457,15 +29591,6 @@ var BaseDeviceProvider = class extends BaseAddon {
29457
29591
  labels: ["probe not implemented"]
29458
29592
  };
29459
29593
  }
29460
- /**
29461
- * Top-level devices restored at once in {@link onRestoreDevices}.
29462
- *
29463
- * Four covers the fleets this ships to without turning a boot into a burst a
29464
- * camera NVR answers with a refusal. A provider whose upstream is a single
29465
- * session with a serial command channel (a Baichuan hub, an NVR that
29466
- * serialises ISAPI) should lower it; nothing needs to raise it.
29467
- */
29468
- restoreConcurrency = 4;
29469
29594
  async restoreDevices(savedDevices) {
29470
29595
  await this.onRestoreDevices(savedDevices);
29471
29596
  if (savedDevices.length > 0) this.ctx.logger.info(`Restored ${savedDevices.length} ${this.providerName} device(s)`);
@@ -29520,14 +29645,7 @@ var BaseDeviceProvider = class extends BaseAddon {
29520
29645
  });
29521
29646
  }
29522
29647
  };
29523
- let nextTopLevel = 0;
29524
- await Promise.all(Array.from({ length: Math.min(Math.max(1, this.restoreConcurrency), topLevel.length) }, async () => {
29525
- for (;;) {
29526
- const saved = topLevel[nextTopLevel++];
29527
- if (saved === void 0) return;
29528
- await restoreOne(saved);
29529
- }
29530
- }));
29648
+ await Promise.all(topLevel.map((saved) => restoreOne(saved)));
29531
29649
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
29532
29650
  for (const saved of childRows) {
29533
29651
  const Class = this.deviceClasses[saved.type];
@@ -32800,6 +32918,12 @@ Object.freeze({
32800
32918
  addonId: null,
32801
32919
  access: "create"
32802
32920
  },
32921
+ "pipelineAnalytics.reconcileFromDisk": {
32922
+ capName: "pipeline-analytics",
32923
+ capScope: "device",
32924
+ addonId: null,
32925
+ access: "create"
32926
+ },
32803
32927
  "pipelineAnalytics.refreshStorageLocationsForMigration": {
32804
32928
  capName: "pipeline-analytics",
32805
32929
  capScope: "device",
@@ -33202,6 +33326,12 @@ Object.freeze({
33202
33326
  addonId: null,
33203
33327
  access: "view"
33204
33328
  },
33329
+ "pipelineOrchestrator.getReconcileFromDiskStatus": {
33330
+ capName: "pipeline-orchestrator",
33331
+ capScope: "system",
33332
+ addonId: null,
33333
+ access: "view"
33334
+ },
33205
33335
  "pipelineOrchestrator.listAgentSettings": {
33206
33336
  capName: "pipeline-orchestrator",
33207
33337
  capScope: "system",
@@ -33226,6 +33356,12 @@ Object.freeze({
33226
33356
  addonId: null,
33227
33357
  access: "create"
33228
33358
  },
33359
+ "pipelineOrchestrator.reconcileFromDisk": {
33360
+ capName: "pipeline-orchestrator",
33361
+ capScope: "system",
33362
+ addonId: null,
33363
+ access: "create"
33364
+ },
33229
33365
  "pipelineOrchestrator.removeAgentSettings": {
33230
33366
  capName: "pipeline-orchestrator",
33231
33367
  capScope: "system",
@@ -36217,6 +36353,11 @@ Object.freeze({
36217
36353
  form: "single",
36218
36354
  optional: true
36219
36355
  }],
36356
+ "pipelineAnalytics.reconcileFromDisk": [{
36357
+ name: "deviceId",
36358
+ form: "single",
36359
+ optional: false
36360
+ }],
36220
36361
  "pipelineAnalytics.restageRetrainTrack": [{
36221
36362
  name: "deviceId",
36222
36363
  form: "single",
@@ -37282,6 +37423,8 @@ DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
37282
37423
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
37283
37424
  DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
37284
37425
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
37426
+ var MB = 1024 * 1024;
37427
+ 1024 * MB, 3072 * MB;
37285
37428
  //#endregion
37286
37429
  //#region node_modules/@apocaliss92/nodewitt/node_modules/zod/v3/helpers/util.js
37287
37430
  var util;
package/dist/addon.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createServer } from "http";
2
2
  import { EventEmitter } from "events";
3
3
  import { createSocket } from "dgram";
4
- //#region ../types/dist/event-category-Bxo5yJjt.mjs
4
+ //#region ../types/dist/event-category-XfKNtfCc.mjs
5
5
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
6
6
  EventCategory["SystemBoot"] = "system.boot";
7
7
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -18,9 +18,10 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
18
18
  EventCategory["SystemRestartCompleted"] = "system.restart-completed";
19
19
  /**
20
20
  * A newer addon or server-root package version was found by the
21
- * authoritative registry check. Emitted once per
22
- * `(target, packageName, currentVersion, latestVersion)` transition; repeated
23
- * polling of the same result is deduplicated by the checker.
21
+ * authoritative registry check. Emitted once when any observed
22
+ * `latestVersion` changes (or a package/node first appears behind);
23
+ * the payload carries the full currently-available list. Repeated
24
+ * polling of the same latests is silent.
24
25
  */
25
26
  EventCategory["UpdateAvailable"] = "update.available";
26
27
  /**
@@ -39,6 +40,22 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
39
40
  EventCategory["AddonInstalled"] = "addon.installed";
40
41
  EventCategory["AddonUninstalled"] = "addon.uninstalled";
41
42
  EventCategory["AddonCrashed"] = "addon.crashed";
43
+ /**
44
+ * A RUNNER the D6 crash circuit-breaker gave up on — terminal.
45
+ *
46
+ * `AddonCrashed` is the routine, self-healing fact ("it crashed; it is being
47
+ * respawned"); this is the one that never resolves itself. Emitted exactly
48
+ * once per trip, by `process-service.ts`, carrying the node, the runner, the
49
+ * addons it hosted and the crash count that tripped the breaker.
50
+ *
51
+ * It exists because a runner marked terminally `failed` used to be SILENT:
52
+ * on 2026-08-18 the `recorder` runner died of three unhandled ffmpeg spawn
53
+ * errors, the breaker stopped respawning it (correctly), `/health` kept
54
+ * returning 200, and fleet-wide recording was gone for 3h15 before the
55
+ * operator's phone told him. The Notification Center's system-event intake
56
+ * consumes this category and maps it to the `addon-crash-loop` kind.
57
+ */
58
+ EventCategory["AddonRunnerFailed"] = "addon.runner-failed";
42
59
  EventCategory["AddonError"] = "addon.error";
43
60
  EventCategory["AddonPageReady"] = "addon.page-ready";
44
61
  EventCategory["AddonWidgetReady"] = "addon.widget-ready";
@@ -7550,6 +7567,10 @@ var RecordingBandSchema = object({
7550
7567
  preBufferSec: number().min(0).optional(),
7551
7568
  postBufferSec: number().min(0).optional()
7552
7569
  });
7570
+ ({
7571
+ preBufferSec: 10,
7572
+ postBufferSec: 30
7573
+ }).postBufferSec * 1e3;
7553
7574
  /**
7554
7575
  * Per-device retention overrides. Every field is optional; an unset or `0`
7555
7576
  * value inherits the node-wide recorder default. Only footage-lifetime limits
@@ -7597,6 +7618,12 @@ var RecordingConfigSchema = object({
7597
7618
  /** DERIVED summary of `bands`, stamped by the recorder on every save.
7598
7619
  * Authoring it has no effect — see {@link RecordingStorageModeSchema}. */
7599
7620
  mode: RecordingStorageModeSchema.optional(),
7621
+ /**
7622
+ * Which assigned broker slots to record. Absent / empty = {@link
7623
+ * DEFAULT_RECORDING_PROFILES} (`high`+`low`) intersected with the
7624
+ * camera's currently assigned slots — never `mid` unless the operator
7625
+ * picks it, and never a slot the broker has not assigned.
7626
+ */
7600
7627
  profiles: array(CamProfileSchema).optional(),
7601
7628
  segmentSeconds: number().int().positive().optional(),
7602
7629
  /**
@@ -7677,7 +7704,11 @@ var RelocateFootageInputSchema = object({
7677
7704
  profiles: array(string()).optional(),
7678
7705
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7679
7706
  * never allowed to starve live writers. */
7680
- throttleMbps: number().min(1).max(1e3).optional()
7707
+ throttleMbps: number().min(1).max(1e3).optional(),
7708
+ /** Move only segments whose startMs is >= this. Absent = the whole source
7709
+ * pile. Used when a full drain is too expensive and the operator only
7710
+ * wants the recent window on the new disk. */
7711
+ sinceMs: number().int().optional()
7681
7712
  });
7682
7713
  /** Internal, lease-scoped participant operation. It is intentionally separate
7683
7714
  * from persistent recording settings: a migration never changes
@@ -14542,6 +14573,7 @@ var NcSystemEventKindSchema = _enum([
14542
14573
  "node-offline",
14543
14574
  "node-inference-unavailable",
14544
14575
  "detection-blind",
14576
+ "addon-crash-loop",
14545
14577
  "addon-update-available",
14546
14578
  "server-update-available",
14547
14579
  "alarm-triggered",
@@ -14549,6 +14581,9 @@ var NcSystemEventKindSchema = _enum([
14549
14581
  "alarm-disarmed",
14550
14582
  "alarm-arming",
14551
14583
  "alarm-arm-refused",
14584
+ "addon-updated",
14585
+ "server-updated",
14586
+ "export-completed",
14552
14587
  "camera-online",
14553
14588
  "camera-offline",
14554
14589
  "camera-disabled",
@@ -16442,13 +16477,19 @@ var RetrainStatusSchema = _enum([
16442
16477
  * "never marked" from "already trained" must read `retrainStatus`.
16443
16478
  *
16444
16479
  * `debug` does NOT pin; it is attention, not durability.
16480
+ *
16481
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16482
+ * A favourited track is skipped by retention the same way `staging` is, but
16483
+ * it does not enter `none|staging|trained` and has no staging budget.
16445
16484
  */
16446
16485
  var TrackFlagFields = {
16447
16486
  /** Operator marked this track as training material — i.e. `retrainStatus` is
16448
16487
  * `'staging'`. */
16449
16488
  markForTrain: boolean().optional(),
16450
16489
  /** Operator marked this track for diagnostic attention. */
16451
- debug: boolean().optional()
16490
+ debug: boolean().optional(),
16491
+ /** Operator favourited this track. Pins it against pruning. */
16492
+ favourited: boolean().optional()
16452
16493
  };
16453
16494
  /**
16454
16495
  * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
@@ -16473,6 +16514,7 @@ var TrackFlagsSchema = object({
16473
16514
  trackId: string(),
16474
16515
  markForTrain: boolean(),
16475
16516
  debug: boolean(),
16517
+ favourited: boolean(),
16476
16518
  /** The lifecycle state the boolean was derived from. Required here (unlike on
16477
16519
  * a track row) because this shape is only ever produced by the write body,
16478
16520
  * which always knows it — and a surface that has just written needs to render
@@ -17105,6 +17147,12 @@ var TrackCascadeCountsSchema = object({
17105
17147
  /** Per-track CLIP search vectors removed (best-effort). */
17106
17148
  embeddings: number().int()
17107
17149
  });
17150
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17151
+ var DiskReconcileCountsSchema = object({
17152
+ mediaDropped: number().int(),
17153
+ tracks: number().int(),
17154
+ events: number().int()
17155
+ });
17108
17156
  /** Event-store footprint for one camera. */
17109
17157
  var EventStoreDeviceFootprintSchema = object({
17110
17158
  deviceId: number(),
@@ -17281,6 +17329,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17281
17329
  }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17282
17330
  kind: "mutation",
17283
17331
  auth: "admin"
17332
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17333
+ kind: "mutation",
17334
+ auth: "admin"
17284
17335
  }), method(object({
17285
17336
  deviceId: number(),
17286
17337
  trackIds: array(string()).min(1)
@@ -18831,6 +18882,24 @@ var CameraStatusDegradationSchema = object({
18831
18882
  *
18832
18883
  * See spec: `docs/superpowers/specs/2026-06-24-camera-status-aggregator-cap.md`
18833
18884
  */
18885
+ var DiskReconcileJobSchema = object({
18886
+ state: _enum([
18887
+ "idle",
18888
+ "running",
18889
+ "done",
18890
+ "error"
18891
+ ]),
18892
+ total: number().int().nonnegative(),
18893
+ completed: number().int().nonnegative(),
18894
+ currentDeviceId: number().int().nullable(),
18895
+ failed: array(number().int()).readonly(),
18896
+ mediaDropped: number().int().nonnegative(),
18897
+ tracks: number().int().nonnegative(),
18898
+ events: number().int().nonnegative(),
18899
+ startedAtMs: number().int().nullable(),
18900
+ finishedAtMs: number().int().nullable(),
18901
+ error: string().nullable()
18902
+ });
18834
18903
  var CameraStatusSchema = object({
18835
18904
  deviceId: number(),
18836
18905
  assignment: CameraAssignmentStatusSchema,
@@ -19062,7 +19131,10 @@ method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
19062
19131
  }), CameraSwitchGroupSchema, {
19063
19132
  kind: "mutation",
19064
19133
  auth: "admin"
19065
- }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
19134
+ }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), DiskReconcileJobSchema, {
19135
+ kind: "mutation",
19136
+ auth: "admin"
19137
+ }), method(_void(), DiskReconcileJobSchema, { auth: "admin" }), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
19066
19138
  name: string(),
19067
19139
  description: string().optional(),
19068
19140
  config: CameraPipelineConfigSchema
@@ -20135,20 +20207,6 @@ var VectorStatsResultSchema = object({
20135
20207
  exact: boolean()
20136
20208
  });
20137
20209
  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);
20138
- /**
20139
- * `videoclips` — the unified, navigable-clip surface for a camera.
20140
- *
20141
- * A device-scoped WRAPPER cap (like `pipeline-analytics`): exactly one active
20142
- * provider per device, substitutable. The DEFAULT provider (registered by
20143
- * `addon-post-analysis`, `defaultActive: true`) composes the analytics event
20144
- * log (markers + thumbnails) with the recorder's `getPlaybackManifest` — a clip
20145
- * is a time-WINDOW over existing footage, never a separate file. A camera that
20146
- * exposes NATIVE onboard clips (Reolink/Hikvision NVR) can later substitute the
20147
- * wrapper provider for its device and serve its own clip catalog + URLs.
20148
- *
20149
- * A `Clip` is purely time-based (subtree-blind): playback resolves segments by
20150
- * temporal overlap, so the API never decides `continuous` vs `events`.
20151
- */
20152
20210
  var ClipSchema = object({
20153
20211
  /** Opaque, provider-namespaced id. The default provider encodes the time
20154
20212
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -20165,8 +20223,65 @@ var ClipSchema = object({
20165
20223
  startMs: number(),
20166
20224
  endMs: number()
20167
20225
  }),
20168
- /** Thumbnail URL (lazy; e.g. analytics `getEventMedia`). Never inlined. */
20169
- thumbnail: string().optional()
20226
+ /**
20227
+ * Distinct object classes attached to this visit (`person`, `car`, …),
20228
+ * dominant first, capped at {@link MAX_CLIP_LABELS}. The ribbon renders these
20229
+ * instead of the bare kind — "Object" tells the operator nothing a colour bar
20230
+ * did not. Absent (never empty) when the visit attached no classified object
20231
+ * event, so a motion/audio-only visit keeps its kind label.
20232
+ */
20233
+ labels: array(string()).max(3).optional(),
20234
+ /**
20235
+ * Lazy thumbnail URL, never inlined.
20236
+ *
20237
+ * Recording-derived clips (events-mode keep-window, and the prepared
20238
+ * continuous event+fragment visit) MUST use the snapshot of the **main
20239
+ * event of the interval** — `getEventMedia({ eventId, kind: 'snapshot' })`
20240
+ * of the event that owns `kind` (object > motion > audio). Do not extract
20241
+ * a keyframe from the recorded segments. Other providers (onboard, HKSV)
20242
+ * mint their own stills.
20243
+ *
20244
+ * **VOUCHED, never fabricated.** A provider emits this only for an event it
20245
+ * has CONFIRMED owns at least one media row (its own, or its owning track's).
20246
+ * Absent is meaningful — "this visit has no event still" — never "we did not
20247
+ * look". Stamping it from a URL template made 35% of one camera's clips point
20248
+ * at a 404 (device 3836, 2026-08-17: 64 of 179 clips dead, 63 of them motion).
20249
+ * A read that FAILS drops the claim; it never invents it.
20250
+ */
20251
+ thumbnail: string().optional(),
20252
+ /**
20253
+ * An instant INSIDE this visit's footage, hole-safe, where a recorded still
20254
+ * can be decoded. Present whenever the visit came from recorded availability;
20255
+ * absent on a per-event padded window (there is no footage to promise).
20256
+ *
20257
+ * This is not a thumbnail and not a second byte path: it is the argument to
20258
+ * the recorder's existing still route. The surface — never the provider —
20259
+ * decides whether to use it. It is the midpoint of the visit's LONGEST
20260
+ * contiguous range, not of the visit: a visit spans its holes by
20261
+ * construction, so a naive midpoint lands in dead air.
20262
+ */
20263
+ stillAtMs: number().optional(),
20264
+ /**
20265
+ * Analytics event ids that overlap this visit — a BOUNDED sample, newest
20266
+ * first within kind (object → motion → audio), capped at
20267
+ * {@link MAX_CLIP_EVENT_IDS}. Empty on footage-only clips.
20268
+ *
20269
+ * Bounded because it is not a payload the surface pages through: one visit on
20270
+ * device 615 carried 2 345 ids, and `eventIds` was 99% of a 153 KB
20271
+ * camera-day. Read {@link eventCount} for the true total.
20272
+ */
20273
+ eventIds: array(string()).optional(),
20274
+ /** How many analytics events actually overlap this visit. Differs from
20275
+ * `eventIds.length` exactly when the sample was capped — so a truncated
20276
+ * list is never mistaken for a quiet visit. */
20277
+ eventCount: number().int().nonnegative().optional(),
20278
+ /** Intra-visit footage holes (GOP rolls, discarded segments) still shorter
20279
+ * than `VISIT_MERGE_GAP_MS`. Playback concatenates around them; the timeline
20280
+ * bar keeps showing them via `recording.getAvailability`. */
20281
+ holes: array(object({
20282
+ startMs: number(),
20283
+ endMs: number()
20284
+ })).optional()
20170
20285
  });
20171
20286
  var ClipPlaybackSchema = object({
20172
20287
  /** HLS master URL through the hub data-plane (Range + token in path). */
@@ -20630,7 +20745,14 @@ var SearchResultSchema = object({
20630
20745
  });
20631
20746
  var AutoUpdateSettingsSchema = object({
20632
20747
  channel: ChannelSchema,
20633
- intervalSeconds: number()
20748
+ intervalSeconds: number(),
20749
+ /**
20750
+ * Cadence of the "an update exists" POLLER, in seconds. Independent of
20751
+ * `channel`: the poller runs while auto-apply is `off`, because being told
20752
+ * about a publish and installing it are different decisions. Clamped
20753
+ * server-side to 900 s … 604800 s; defaults to 21600 s (6 h).
20754
+ */
20755
+ updateCheckIntervalSeconds: number()
20634
20756
  });
20635
20757
  var AddonAutoUpdateSchema = ChannelWithInheritSchema;
20636
20758
  var RestartAddonResultSchema = unknown();
@@ -20771,7 +20893,9 @@ method(_void(), array(AddonListItemSchema).readonly()), method(object({
20771
20893
  auth: "admin"
20772
20894
  }), method(_void(), AutoUpdateSettingsSchema, { auth: "admin" }), method(object({
20773
20895
  channel: ChannelSchema,
20774
- intervalSeconds: number().min(300).max(86400).optional()
20896
+ intervalSeconds: number().min(300).max(86400).optional(),
20897
+ /** Availability-poll cadence; see AutoUpdateSettingsSchema. */
20898
+ updateCheckIntervalSeconds: number().min(900).max(604800).optional()
20775
20899
  }), unknown(), {
20776
20900
  kind: "mutation",
20777
20901
  auth: "admin"
@@ -26452,7 +26576,9 @@ var ExportOptionsSchema = object({
26452
26576
  includeAudio: boolean(),
26453
26577
  maxLifeMs: number().int().positive(),
26454
26578
  deleteAfterDownload: boolean(),
26455
- title: string().max(200).optional()
26579
+ title: string().max(200).optional(),
26580
+ /** Notification-output target ids to ping when this export becomes ready. */
26581
+ notifyTargetIds: array(string().min(1)).max(20).optional()
26456
26582
  }).superRefine((v, ctx) => {
26457
26583
  if (v.speed !== void 0 && v.timelapse !== void 0) ctx.addIssue({
26458
26584
  code: ZodIssueCode$1.custom,
@@ -26511,10 +26637,18 @@ var ExportBytesSchema = object({
26511
26637
  });
26512
26638
  method(object({
26513
26639
  deviceId: number(),
26514
- profile: string(),
26640
+ /** @deprecated Prefer `profiles`. Kept so timelapse/notifiers keep working. */
26641
+ profile: string().optional(),
26642
+ profiles: array(string()).min(1).optional(),
26515
26643
  fromMs: number(),
26516
26644
  toMs: number(),
26517
26645
  options: ExportOptionsSchema
26646
+ }).superRefine((v, ctx) => {
26647
+ if ((v.profiles !== void 0 && v.profiles.length > 0 ? v.profiles : v.profile !== void 0 ? [v.profile] : []).length < 1) ctx.addIssue({
26648
+ code: ZodIssueCode$1.custom,
26649
+ message: "pass profiles[] (min 1) or legacy profile",
26650
+ path: ["profiles"]
26651
+ });
26518
26652
  }), ExportRecordSchema, {
26519
26653
  kind: "mutation",
26520
26654
  auth: "protected"
@@ -29456,15 +29590,6 @@ var BaseDeviceProvider = class extends BaseAddon {
29456
29590
  labels: ["probe not implemented"]
29457
29591
  };
29458
29592
  }
29459
- /**
29460
- * Top-level devices restored at once in {@link onRestoreDevices}.
29461
- *
29462
- * Four covers the fleets this ships to without turning a boot into a burst a
29463
- * camera NVR answers with a refusal. A provider whose upstream is a single
29464
- * session with a serial command channel (a Baichuan hub, an NVR that
29465
- * serialises ISAPI) should lower it; nothing needs to raise it.
29466
- */
29467
- restoreConcurrency = 4;
29468
29593
  async restoreDevices(savedDevices) {
29469
29594
  await this.onRestoreDevices(savedDevices);
29470
29595
  if (savedDevices.length > 0) this.ctx.logger.info(`Restored ${savedDevices.length} ${this.providerName} device(s)`);
@@ -29519,14 +29644,7 @@ var BaseDeviceProvider = class extends BaseAddon {
29519
29644
  });
29520
29645
  }
29521
29646
  };
29522
- let nextTopLevel = 0;
29523
- await Promise.all(Array.from({ length: Math.min(Math.max(1, this.restoreConcurrency), topLevel.length) }, async () => {
29524
- for (;;) {
29525
- const saved = topLevel[nextTopLevel++];
29526
- if (saved === void 0) return;
29527
- await restoreOne(saved);
29528
- }
29529
- }));
29647
+ await Promise.all(topLevel.map((saved) => restoreOne(saved)));
29530
29648
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
29531
29649
  for (const saved of childRows) {
29532
29650
  const Class = this.deviceClasses[saved.type];
@@ -32799,6 +32917,12 @@ Object.freeze({
32799
32917
  addonId: null,
32800
32918
  access: "create"
32801
32919
  },
32920
+ "pipelineAnalytics.reconcileFromDisk": {
32921
+ capName: "pipeline-analytics",
32922
+ capScope: "device",
32923
+ addonId: null,
32924
+ access: "create"
32925
+ },
32802
32926
  "pipelineAnalytics.refreshStorageLocationsForMigration": {
32803
32927
  capName: "pipeline-analytics",
32804
32928
  capScope: "device",
@@ -33201,6 +33325,12 @@ Object.freeze({
33201
33325
  addonId: null,
33202
33326
  access: "view"
33203
33327
  },
33328
+ "pipelineOrchestrator.getReconcileFromDiskStatus": {
33329
+ capName: "pipeline-orchestrator",
33330
+ capScope: "system",
33331
+ addonId: null,
33332
+ access: "view"
33333
+ },
33204
33334
  "pipelineOrchestrator.listAgentSettings": {
33205
33335
  capName: "pipeline-orchestrator",
33206
33336
  capScope: "system",
@@ -33225,6 +33355,12 @@ Object.freeze({
33225
33355
  addonId: null,
33226
33356
  access: "create"
33227
33357
  },
33358
+ "pipelineOrchestrator.reconcileFromDisk": {
33359
+ capName: "pipeline-orchestrator",
33360
+ capScope: "system",
33361
+ addonId: null,
33362
+ access: "create"
33363
+ },
33228
33364
  "pipelineOrchestrator.removeAgentSettings": {
33229
33365
  capName: "pipeline-orchestrator",
33230
33366
  capScope: "system",
@@ -36216,6 +36352,11 @@ Object.freeze({
36216
36352
  form: "single",
36217
36353
  optional: true
36218
36354
  }],
36355
+ "pipelineAnalytics.reconcileFromDisk": [{
36356
+ name: "deviceId",
36357
+ form: "single",
36358
+ optional: false
36359
+ }],
36219
36360
  "pipelineAnalytics.restageRetrainTrack": [{
36220
36361
  name: "deviceId",
36221
36362
  form: "single",
@@ -37281,6 +37422,8 @@ DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
37281
37422
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
37282
37423
  DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
37283
37424
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
37425
+ var MB = 1024 * 1024;
37426
+ 1024 * MB, 3072 * MB;
37284
37427
  //#endregion
37285
37428
  //#region node_modules/@apocaliss92/nodewitt/node_modules/zod/v3/helpers/util.js
37286
37429
  var util;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-ecowitt",
3
- "version": "0.2.19",
3
+ "version": "0.2.21",
4
4
  "description": "Ecowitt weather-station device-provider addon for CamStack — wraps the @apocaliss92/nodewitt local-poll / push client",
5
5
  "keywords": [
6
6
  "camstack",