@camstack/addon-provider-tuya 0.2.20 → 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 +179 -44
  2. package/dist/addon.mjs +179 -44
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -819,7 +819,7 @@ async function discoverDevices(options = {}, binder = createDgramBinder()) {
819
819
  return [...byId.values()];
820
820
  }
821
821
  //#endregion
822
- //#region ../types/dist/event-category-Bxo5yJjt.mjs
822
+ //#region ../types/dist/event-category-XfKNtfCc.mjs
823
823
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
824
824
  EventCategory["SystemBoot"] = "system.boot";
825
825
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -836,9 +836,10 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
836
836
  EventCategory["SystemRestartCompleted"] = "system.restart-completed";
837
837
  /**
838
838
  * A newer addon or server-root package version was found by the
839
- * authoritative registry check. Emitted once per
840
- * `(target, packageName, currentVersion, latestVersion)` transition; repeated
841
- * polling of the same result is deduplicated by the checker.
839
+ * authoritative registry check. Emitted once when any observed
840
+ * `latestVersion` changes (or a package/node first appears behind);
841
+ * the payload carries the full currently-available list. Repeated
842
+ * polling of the same latests is silent.
842
843
  */
843
844
  EventCategory["UpdateAvailable"] = "update.available";
844
845
  /**
@@ -857,6 +858,22 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
857
858
  EventCategory["AddonInstalled"] = "addon.installed";
858
859
  EventCategory["AddonUninstalled"] = "addon.uninstalled";
859
860
  EventCategory["AddonCrashed"] = "addon.crashed";
861
+ /**
862
+ * A RUNNER the D6 crash circuit-breaker gave up on — terminal.
863
+ *
864
+ * `AddonCrashed` is the routine, self-healing fact ("it crashed; it is being
865
+ * respawned"); this is the one that never resolves itself. Emitted exactly
866
+ * once per trip, by `process-service.ts`, carrying the node, the runner, the
867
+ * addons it hosted and the crash count that tripped the breaker.
868
+ *
869
+ * It exists because a runner marked terminally `failed` used to be SILENT:
870
+ * on 2026-08-18 the `recorder` runner died of three unhandled ffmpeg spawn
871
+ * errors, the breaker stopped respawning it (correctly), `/health` kept
872
+ * returning 200, and fleet-wide recording was gone for 3h15 before the
873
+ * operator's phone told him. The Notification Center's system-event intake
874
+ * consumes this category and maps it to the `addon-crash-loop` kind.
875
+ */
876
+ EventCategory["AddonRunnerFailed"] = "addon.runner-failed";
860
877
  EventCategory["AddonError"] = "addon.error";
861
878
  EventCategory["AddonPageReady"] = "addon.page-ready";
862
879
  EventCategory["AddonWidgetReady"] = "addon.widget-ready";
@@ -8368,6 +8385,10 @@ var RecordingBandSchema = object({
8368
8385
  preBufferSec: number().min(0).optional(),
8369
8386
  postBufferSec: number().min(0).optional()
8370
8387
  });
8388
+ ({
8389
+ preBufferSec: 10,
8390
+ postBufferSec: 30
8391
+ }).postBufferSec * 1e3;
8371
8392
  /**
8372
8393
  * Per-device retention overrides. Every field is optional; an unset or `0`
8373
8394
  * value inherits the node-wide recorder default. Only footage-lifetime limits
@@ -8415,6 +8436,12 @@ var RecordingConfigSchema = object({
8415
8436
  /** DERIVED summary of `bands`, stamped by the recorder on every save.
8416
8437
  * Authoring it has no effect — see {@link RecordingStorageModeSchema}. */
8417
8438
  mode: RecordingStorageModeSchema.optional(),
8439
+ /**
8440
+ * Which assigned broker slots to record. Absent / empty = {@link
8441
+ * DEFAULT_RECORDING_PROFILES} (`high`+`low`) intersected with the
8442
+ * camera's currently assigned slots — never `mid` unless the operator
8443
+ * picks it, and never a slot the broker has not assigned.
8444
+ */
8418
8445
  profiles: array(CamProfileSchema).optional(),
8419
8446
  segmentSeconds: number().int().positive().optional(),
8420
8447
  /**
@@ -8495,7 +8522,11 @@ var RelocateFootageInputSchema = object({
8495
8522
  profiles: array(string()).optional(),
8496
8523
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
8497
8524
  * never allowed to starve live writers. */
8498
- throttleMbps: number().min(1).max(1e3).optional()
8525
+ throttleMbps: number().min(1).max(1e3).optional(),
8526
+ /** Move only segments whose startMs is >= this. Absent = the whole source
8527
+ * pile. Used when a full drain is too expensive and the operator only
8528
+ * wants the recent window on the new disk. */
8529
+ sinceMs: number().int().optional()
8499
8530
  });
8500
8531
  /** Internal, lease-scoped participant operation. It is intentionally separate
8501
8532
  * from persistent recording settings: a migration never changes
@@ -15377,6 +15408,7 @@ var NcSystemEventKindSchema = _enum([
15377
15408
  "node-offline",
15378
15409
  "node-inference-unavailable",
15379
15410
  "detection-blind",
15411
+ "addon-crash-loop",
15380
15412
  "addon-update-available",
15381
15413
  "server-update-available",
15382
15414
  "alarm-triggered",
@@ -15384,6 +15416,9 @@ var NcSystemEventKindSchema = _enum([
15384
15416
  "alarm-disarmed",
15385
15417
  "alarm-arming",
15386
15418
  "alarm-arm-refused",
15419
+ "addon-updated",
15420
+ "server-updated",
15421
+ "export-completed",
15387
15422
  "camera-online",
15388
15423
  "camera-offline",
15389
15424
  "camera-disabled",
@@ -17277,13 +17312,19 @@ var RetrainStatusSchema = _enum([
17277
17312
  * "never marked" from "already trained" must read `retrainStatus`.
17278
17313
  *
17279
17314
  * `debug` does NOT pin; it is attention, not durability.
17315
+ *
17316
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17317
+ * A favourited track is skipped by retention the same way `staging` is, but
17318
+ * it does not enter `none|staging|trained` and has no staging budget.
17280
17319
  */
17281
17320
  var TrackFlagFields = {
17282
17321
  /** Operator marked this track as training material — i.e. `retrainStatus` is
17283
17322
  * `'staging'`. */
17284
17323
  markForTrain: boolean().optional(),
17285
17324
  /** Operator marked this track for diagnostic attention. */
17286
- debug: boolean().optional()
17325
+ debug: boolean().optional(),
17326
+ /** Operator favourited this track. Pins it against pruning. */
17327
+ favourited: boolean().optional()
17287
17328
  };
17288
17329
  /**
17289
17330
  * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
@@ -17308,6 +17349,7 @@ var TrackFlagsSchema = object({
17308
17349
  trackId: string(),
17309
17350
  markForTrain: boolean(),
17310
17351
  debug: boolean(),
17352
+ favourited: boolean(),
17311
17353
  /** The lifecycle state the boolean was derived from. Required here (unlike on
17312
17354
  * a track row) because this shape is only ever produced by the write body,
17313
17355
  * which always knows it — and a surface that has just written needs to render
@@ -17940,6 +17982,12 @@ var TrackCascadeCountsSchema = object({
17940
17982
  /** Per-track CLIP search vectors removed (best-effort). */
17941
17983
  embeddings: number().int()
17942
17984
  });
17985
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17986
+ var DiskReconcileCountsSchema = object({
17987
+ mediaDropped: number().int(),
17988
+ tracks: number().int(),
17989
+ events: number().int()
17990
+ });
17943
17991
  /** Event-store footprint for one camera. */
17944
17992
  var EventStoreDeviceFootprintSchema = object({
17945
17993
  deviceId: number(),
@@ -18116,6 +18164,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
18116
18164
  }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18117
18165
  kind: "mutation",
18118
18166
  auth: "admin"
18167
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18168
+ kind: "mutation",
18169
+ auth: "admin"
18119
18170
  }), method(object({
18120
18171
  deviceId: number(),
18121
18172
  trackIds: array(string()).min(1)
@@ -19666,6 +19717,24 @@ var CameraStatusDegradationSchema = object({
19666
19717
  *
19667
19718
  * See spec: `docs/superpowers/specs/2026-06-24-camera-status-aggregator-cap.md`
19668
19719
  */
19720
+ var DiskReconcileJobSchema = object({
19721
+ state: _enum([
19722
+ "idle",
19723
+ "running",
19724
+ "done",
19725
+ "error"
19726
+ ]),
19727
+ total: number().int().nonnegative(),
19728
+ completed: number().int().nonnegative(),
19729
+ currentDeviceId: number().int().nullable(),
19730
+ failed: array(number().int()).readonly(),
19731
+ mediaDropped: number().int().nonnegative(),
19732
+ tracks: number().int().nonnegative(),
19733
+ events: number().int().nonnegative(),
19734
+ startedAtMs: number().int().nullable(),
19735
+ finishedAtMs: number().int().nullable(),
19736
+ error: string().nullable()
19737
+ });
19669
19738
  var CameraStatusSchema = object({
19670
19739
  deviceId: number(),
19671
19740
  assignment: CameraAssignmentStatusSchema,
@@ -19897,7 +19966,10 @@ method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
19897
19966
  }), CameraSwitchGroupSchema, {
19898
19967
  kind: "mutation",
19899
19968
  auth: "admin"
19900
- }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
19969
+ }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), DiskReconcileJobSchema, {
19970
+ kind: "mutation",
19971
+ auth: "admin"
19972
+ }), method(_void(), DiskReconcileJobSchema, { auth: "admin" }), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
19901
19973
  name: string(),
19902
19974
  description: string().optional(),
19903
19975
  config: CameraPipelineConfigSchema
@@ -20970,20 +21042,6 @@ var VectorStatsResultSchema = object({
20970
21042
  exact: boolean()
20971
21043
  });
20972
21044
  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);
20973
- /**
20974
- * `videoclips` — the unified, navigable-clip surface for a camera.
20975
- *
20976
- * A device-scoped WRAPPER cap (like `pipeline-analytics`): exactly one active
20977
- * provider per device, substitutable. The DEFAULT provider (registered by
20978
- * `addon-post-analysis`, `defaultActive: true`) composes the analytics event
20979
- * log (markers + thumbnails) with the recorder's `getPlaybackManifest` — a clip
20980
- * is a time-WINDOW over existing footage, never a separate file. A camera that
20981
- * exposes NATIVE onboard clips (Reolink/Hikvision NVR) can later substitute the
20982
- * wrapper provider for its device and serve its own clip catalog + URLs.
20983
- *
20984
- * A `Clip` is purely time-based (subtree-blind): playback resolves segments by
20985
- * temporal overlap, so the API never decides `continuous` vs `events`.
20986
- */
20987
21045
  var ClipSchema = object({
20988
21046
  /** Opaque, provider-namespaced id. The default provider encodes the time
20989
21047
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -21000,8 +21058,57 @@ var ClipSchema = object({
21000
21058
  startMs: number(),
21001
21059
  endMs: number()
21002
21060
  }),
21003
- /** Thumbnail URL (lazy; e.g. analytics `getEventMedia`). Never inlined. */
21004
- thumbnail: string().optional()
21061
+ /**
21062
+ * Lazy thumbnail URL, never inlined.
21063
+ *
21064
+ * Recording-derived clips (events-mode keep-window, and the prepared
21065
+ * continuous event+fragment visit) MUST use the snapshot of the **main
21066
+ * event of the interval** — `getEventMedia({ eventId, kind: 'snapshot' })`
21067
+ * of the event that owns `kind` (object > motion > audio). Do not extract
21068
+ * a keyframe from the recorded segments. Other providers (onboard, HKSV)
21069
+ * mint their own stills.
21070
+ *
21071
+ * **VOUCHED, never fabricated.** A provider emits this only for an event it
21072
+ * has CONFIRMED owns at least one media row (its own, or its owning track's).
21073
+ * Absent is meaningful — "this visit has no event still" — never "we did not
21074
+ * look". Stamping it from a URL template made 35% of one camera's clips point
21075
+ * at a 404 (device 3836, 2026-08-17: 64 of 179 clips dead, 63 of them motion).
21076
+ * A read that FAILS drops the claim; it never invents it.
21077
+ */
21078
+ thumbnail: string().optional(),
21079
+ /**
21080
+ * An instant INSIDE this visit's footage, hole-safe, where a recorded still
21081
+ * can be decoded. Present whenever the visit came from recorded availability;
21082
+ * absent on a per-event padded window (there is no footage to promise).
21083
+ *
21084
+ * This is not a thumbnail and not a second byte path: it is the argument to
21085
+ * the recorder's existing still route. The surface — never the provider —
21086
+ * decides whether to use it. It is the midpoint of the visit's LONGEST
21087
+ * contiguous range, not of the visit: a visit spans its holes by
21088
+ * construction, so a naive midpoint lands in dead air.
21089
+ */
21090
+ stillAtMs: number().optional(),
21091
+ /**
21092
+ * Analytics event ids that overlap this visit — a BOUNDED sample, newest
21093
+ * first within kind (object → motion → audio), capped at
21094
+ * {@link MAX_CLIP_EVENT_IDS}. Empty on footage-only clips.
21095
+ *
21096
+ * Bounded because it is not a payload the surface pages through: one visit on
21097
+ * device 615 carried 2 345 ids, and `eventIds` was 99% of a 153 KB
21098
+ * camera-day. Read {@link eventCount} for the true total.
21099
+ */
21100
+ eventIds: array(string()).optional(),
21101
+ /** How many analytics events actually overlap this visit. Differs from
21102
+ * `eventIds.length` exactly when the sample was capped — so a truncated
21103
+ * list is never mistaken for a quiet visit. */
21104
+ eventCount: number().int().nonnegative().optional(),
21105
+ /** Intra-visit footage holes (GOP rolls, discarded segments) still shorter
21106
+ * than `VISIT_MERGE_GAP_MS`. Playback concatenates around them; the timeline
21107
+ * bar keeps showing them via `recording.getAvailability`. */
21108
+ holes: array(object({
21109
+ startMs: number(),
21110
+ endMs: number()
21111
+ })).optional()
21005
21112
  });
21006
21113
  var ClipPlaybackSchema = object({
21007
21114
  /** HLS master URL through the hub data-plane (Range + token in path). */
@@ -21465,7 +21572,14 @@ var SearchResultSchema = object({
21465
21572
  });
21466
21573
  var AutoUpdateSettingsSchema = object({
21467
21574
  channel: ChannelSchema,
21468
- intervalSeconds: number()
21575
+ intervalSeconds: number(),
21576
+ /**
21577
+ * Cadence of the "an update exists" POLLER, in seconds. Independent of
21578
+ * `channel`: the poller runs while auto-apply is `off`, because being told
21579
+ * about a publish and installing it are different decisions. Clamped
21580
+ * server-side to 900 s … 604800 s; defaults to 21600 s (6 h).
21581
+ */
21582
+ updateCheckIntervalSeconds: number()
21469
21583
  });
21470
21584
  var AddonAutoUpdateSchema = ChannelWithInheritSchema;
21471
21585
  var RestartAddonResultSchema = unknown();
@@ -21606,7 +21720,9 @@ method(_void(), array(AddonListItemSchema).readonly()), method(object({
21606
21720
  auth: "admin"
21607
21721
  }), method(_void(), AutoUpdateSettingsSchema, { auth: "admin" }), method(object({
21608
21722
  channel: ChannelSchema,
21609
- intervalSeconds: number().min(300).max(86400).optional()
21723
+ intervalSeconds: number().min(300).max(86400).optional(),
21724
+ /** Availability-poll cadence; see AutoUpdateSettingsSchema. */
21725
+ updateCheckIntervalSeconds: number().min(900).max(604800).optional()
21610
21726
  }), unknown(), {
21611
21727
  kind: "mutation",
21612
21728
  auth: "admin"
@@ -27295,7 +27411,9 @@ var ExportOptionsSchema = object({
27295
27411
  includeAudio: boolean(),
27296
27412
  maxLifeMs: number().int().positive(),
27297
27413
  deleteAfterDownload: boolean(),
27298
- title: string().max(200).optional()
27414
+ title: string().max(200).optional(),
27415
+ /** Notification-output target ids to ping when this export becomes ready. */
27416
+ notifyTargetIds: array(string().min(1)).max(20).optional()
27299
27417
  }).superRefine((v, ctx) => {
27300
27418
  if (v.speed !== void 0 && v.timelapse !== void 0) ctx.addIssue({
27301
27419
  code: ZodIssueCode.custom,
@@ -27354,10 +27472,18 @@ var ExportBytesSchema = object({
27354
27472
  });
27355
27473
  method(object({
27356
27474
  deviceId: number(),
27357
- profile: string(),
27475
+ /** @deprecated Prefer `profiles`. Kept so timelapse/notifiers keep working. */
27476
+ profile: string().optional(),
27477
+ profiles: array(string()).min(1).optional(),
27358
27478
  fromMs: number(),
27359
27479
  toMs: number(),
27360
27480
  options: ExportOptionsSchema
27481
+ }).superRefine((v, ctx) => {
27482
+ if ((v.profiles !== void 0 && v.profiles.length > 0 ? v.profiles : v.profile !== void 0 ? [v.profile] : []).length < 1) ctx.addIssue({
27483
+ code: ZodIssueCode.custom,
27484
+ message: "pass profiles[] (min 1) or legacy profile",
27485
+ path: ["profiles"]
27486
+ });
27361
27487
  }), ExportRecordSchema, {
27362
27488
  kind: "mutation",
27363
27489
  auth: "protected"
@@ -30299,15 +30425,6 @@ var BaseDeviceProvider = class extends BaseAddon {
30299
30425
  labels: ["probe not implemented"]
30300
30426
  };
30301
30427
  }
30302
- /**
30303
- * Top-level devices restored at once in {@link onRestoreDevices}.
30304
- *
30305
- * Four covers the fleets this ships to without turning a boot into a burst a
30306
- * camera NVR answers with a refusal. A provider whose upstream is a single
30307
- * session with a serial command channel (a Baichuan hub, an NVR that
30308
- * serialises ISAPI) should lower it; nothing needs to raise it.
30309
- */
30310
- restoreConcurrency = 4;
30311
30428
  async restoreDevices(savedDevices) {
30312
30429
  await this.onRestoreDevices(savedDevices);
30313
30430
  if (savedDevices.length > 0) this.ctx.logger.info(`Restored ${savedDevices.length} ${this.providerName} device(s)`);
@@ -30362,14 +30479,7 @@ var BaseDeviceProvider = class extends BaseAddon {
30362
30479
  });
30363
30480
  }
30364
30481
  };
30365
- let nextTopLevel = 0;
30366
- await Promise.all(Array.from({ length: Math.min(Math.max(1, this.restoreConcurrency), topLevel.length) }, async () => {
30367
- for (;;) {
30368
- const saved = topLevel[nextTopLevel++];
30369
- if (saved === void 0) return;
30370
- await restoreOne(saved);
30371
- }
30372
- }));
30482
+ await Promise.all(topLevel.map((saved) => restoreOne(saved)));
30373
30483
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
30374
30484
  for (const saved of childRows) {
30375
30485
  const Class = this.deviceClasses[saved.type];
@@ -33642,6 +33752,12 @@ Object.freeze({
33642
33752
  addonId: null,
33643
33753
  access: "create"
33644
33754
  },
33755
+ "pipelineAnalytics.reconcileFromDisk": {
33756
+ capName: "pipeline-analytics",
33757
+ capScope: "device",
33758
+ addonId: null,
33759
+ access: "create"
33760
+ },
33645
33761
  "pipelineAnalytics.refreshStorageLocationsForMigration": {
33646
33762
  capName: "pipeline-analytics",
33647
33763
  capScope: "device",
@@ -34044,6 +34160,12 @@ Object.freeze({
34044
34160
  addonId: null,
34045
34161
  access: "view"
34046
34162
  },
34163
+ "pipelineOrchestrator.getReconcileFromDiskStatus": {
34164
+ capName: "pipeline-orchestrator",
34165
+ capScope: "system",
34166
+ addonId: null,
34167
+ access: "view"
34168
+ },
34047
34169
  "pipelineOrchestrator.listAgentSettings": {
34048
34170
  capName: "pipeline-orchestrator",
34049
34171
  capScope: "system",
@@ -34068,6 +34190,12 @@ Object.freeze({
34068
34190
  addonId: null,
34069
34191
  access: "create"
34070
34192
  },
34193
+ "pipelineOrchestrator.reconcileFromDisk": {
34194
+ capName: "pipeline-orchestrator",
34195
+ capScope: "system",
34196
+ addonId: null,
34197
+ access: "create"
34198
+ },
34071
34199
  "pipelineOrchestrator.removeAgentSettings": {
34072
34200
  capName: "pipeline-orchestrator",
34073
34201
  capScope: "system",
@@ -37059,6 +37187,11 @@ Object.freeze({
37059
37187
  form: "single",
37060
37188
  optional: true
37061
37189
  }],
37190
+ "pipelineAnalytics.reconcileFromDisk": [{
37191
+ name: "deviceId",
37192
+ form: "single",
37193
+ optional: false
37194
+ }],
37062
37195
  "pipelineAnalytics.restageRetrainTrack": [{
37063
37196
  name: "deviceId",
37064
37197
  form: "single",
@@ -38124,6 +38257,8 @@ DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
38124
38257
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
38125
38258
  DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
38126
38259
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
38260
+ var MB = 1024 * 1024;
38261
+ 1024 * MB, 3072 * MB;
38127
38262
  //#endregion
38128
38263
  //#region src/config.ts
38129
38264
  /**
package/dist/addon.mjs CHANGED
@@ -818,7 +818,7 @@ async function discoverDevices(options = {}, binder = createDgramBinder()) {
818
818
  return [...byId.values()];
819
819
  }
820
820
  //#endregion
821
- //#region ../types/dist/event-category-Bxo5yJjt.mjs
821
+ //#region ../types/dist/event-category-XfKNtfCc.mjs
822
822
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
823
823
  EventCategory["SystemBoot"] = "system.boot";
824
824
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -835,9 +835,10 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
835
835
  EventCategory["SystemRestartCompleted"] = "system.restart-completed";
836
836
  /**
837
837
  * A newer addon or server-root package version was found by the
838
- * authoritative registry check. Emitted once per
839
- * `(target, packageName, currentVersion, latestVersion)` transition; repeated
840
- * polling of the same result is deduplicated by the checker.
838
+ * authoritative registry check. Emitted once when any observed
839
+ * `latestVersion` changes (or a package/node first appears behind);
840
+ * the payload carries the full currently-available list. Repeated
841
+ * polling of the same latests is silent.
841
842
  */
842
843
  EventCategory["UpdateAvailable"] = "update.available";
843
844
  /**
@@ -856,6 +857,22 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
856
857
  EventCategory["AddonInstalled"] = "addon.installed";
857
858
  EventCategory["AddonUninstalled"] = "addon.uninstalled";
858
859
  EventCategory["AddonCrashed"] = "addon.crashed";
860
+ /**
861
+ * A RUNNER the D6 crash circuit-breaker gave up on — terminal.
862
+ *
863
+ * `AddonCrashed` is the routine, self-healing fact ("it crashed; it is being
864
+ * respawned"); this is the one that never resolves itself. Emitted exactly
865
+ * once per trip, by `process-service.ts`, carrying the node, the runner, the
866
+ * addons it hosted and the crash count that tripped the breaker.
867
+ *
868
+ * It exists because a runner marked terminally `failed` used to be SILENT:
869
+ * on 2026-08-18 the `recorder` runner died of three unhandled ffmpeg spawn
870
+ * errors, the breaker stopped respawning it (correctly), `/health` kept
871
+ * returning 200, and fleet-wide recording was gone for 3h15 before the
872
+ * operator's phone told him. The Notification Center's system-event intake
873
+ * consumes this category and maps it to the `addon-crash-loop` kind.
874
+ */
875
+ EventCategory["AddonRunnerFailed"] = "addon.runner-failed";
859
876
  EventCategory["AddonError"] = "addon.error";
860
877
  EventCategory["AddonPageReady"] = "addon.page-ready";
861
878
  EventCategory["AddonWidgetReady"] = "addon.widget-ready";
@@ -8367,6 +8384,10 @@ var RecordingBandSchema = object({
8367
8384
  preBufferSec: number().min(0).optional(),
8368
8385
  postBufferSec: number().min(0).optional()
8369
8386
  });
8387
+ ({
8388
+ preBufferSec: 10,
8389
+ postBufferSec: 30
8390
+ }).postBufferSec * 1e3;
8370
8391
  /**
8371
8392
  * Per-device retention overrides. Every field is optional; an unset or `0`
8372
8393
  * value inherits the node-wide recorder default. Only footage-lifetime limits
@@ -8414,6 +8435,12 @@ var RecordingConfigSchema = object({
8414
8435
  /** DERIVED summary of `bands`, stamped by the recorder on every save.
8415
8436
  * Authoring it has no effect — see {@link RecordingStorageModeSchema}. */
8416
8437
  mode: RecordingStorageModeSchema.optional(),
8438
+ /**
8439
+ * Which assigned broker slots to record. Absent / empty = {@link
8440
+ * DEFAULT_RECORDING_PROFILES} (`high`+`low`) intersected with the
8441
+ * camera's currently assigned slots — never `mid` unless the operator
8442
+ * picks it, and never a slot the broker has not assigned.
8443
+ */
8417
8444
  profiles: array(CamProfileSchema).optional(),
8418
8445
  segmentSeconds: number().int().positive().optional(),
8419
8446
  /**
@@ -8494,7 +8521,11 @@ var RelocateFootageInputSchema = object({
8494
8521
  profiles: array(string()).optional(),
8495
8522
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
8496
8523
  * never allowed to starve live writers. */
8497
- throttleMbps: number().min(1).max(1e3).optional()
8524
+ throttleMbps: number().min(1).max(1e3).optional(),
8525
+ /** Move only segments whose startMs is >= this. Absent = the whole source
8526
+ * pile. Used when a full drain is too expensive and the operator only
8527
+ * wants the recent window on the new disk. */
8528
+ sinceMs: number().int().optional()
8498
8529
  });
8499
8530
  /** Internal, lease-scoped participant operation. It is intentionally separate
8500
8531
  * from persistent recording settings: a migration never changes
@@ -15376,6 +15407,7 @@ var NcSystemEventKindSchema = _enum([
15376
15407
  "node-offline",
15377
15408
  "node-inference-unavailable",
15378
15409
  "detection-blind",
15410
+ "addon-crash-loop",
15379
15411
  "addon-update-available",
15380
15412
  "server-update-available",
15381
15413
  "alarm-triggered",
@@ -15383,6 +15415,9 @@ var NcSystemEventKindSchema = _enum([
15383
15415
  "alarm-disarmed",
15384
15416
  "alarm-arming",
15385
15417
  "alarm-arm-refused",
15418
+ "addon-updated",
15419
+ "server-updated",
15420
+ "export-completed",
15386
15421
  "camera-online",
15387
15422
  "camera-offline",
15388
15423
  "camera-disabled",
@@ -17276,13 +17311,19 @@ var RetrainStatusSchema = _enum([
17276
17311
  * "never marked" from "already trained" must read `retrainStatus`.
17277
17312
  *
17278
17313
  * `debug` does NOT pin; it is attention, not durability.
17314
+ *
17315
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17316
+ * A favourited track is skipped by retention the same way `staging` is, but
17317
+ * it does not enter `none|staging|trained` and has no staging budget.
17279
17318
  */
17280
17319
  var TrackFlagFields = {
17281
17320
  /** Operator marked this track as training material — i.e. `retrainStatus` is
17282
17321
  * `'staging'`. */
17283
17322
  markForTrain: boolean().optional(),
17284
17323
  /** Operator marked this track for diagnostic attention. */
17285
- debug: boolean().optional()
17324
+ debug: boolean().optional(),
17325
+ /** Operator favourited this track. Pins it against pruning. */
17326
+ favourited: boolean().optional()
17286
17327
  };
17287
17328
  /**
17288
17329
  * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
@@ -17307,6 +17348,7 @@ var TrackFlagsSchema = object({
17307
17348
  trackId: string(),
17308
17349
  markForTrain: boolean(),
17309
17350
  debug: boolean(),
17351
+ favourited: boolean(),
17310
17352
  /** The lifecycle state the boolean was derived from. Required here (unlike on
17311
17353
  * a track row) because this shape is only ever produced by the write body,
17312
17354
  * which always knows it — and a surface that has just written needs to render
@@ -17939,6 +17981,12 @@ var TrackCascadeCountsSchema = object({
17939
17981
  /** Per-track CLIP search vectors removed (best-effort). */
17940
17982
  embeddings: number().int()
17941
17983
  });
17984
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17985
+ var DiskReconcileCountsSchema = object({
17986
+ mediaDropped: number().int(),
17987
+ tracks: number().int(),
17988
+ events: number().int()
17989
+ });
17942
17990
  /** Event-store footprint for one camera. */
17943
17991
  var EventStoreDeviceFootprintSchema = object({
17944
17992
  deviceId: number(),
@@ -18115,6 +18163,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
18115
18163
  }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18116
18164
  kind: "mutation",
18117
18165
  auth: "admin"
18166
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18167
+ kind: "mutation",
18168
+ auth: "admin"
18118
18169
  }), method(object({
18119
18170
  deviceId: number(),
18120
18171
  trackIds: array(string()).min(1)
@@ -19665,6 +19716,24 @@ var CameraStatusDegradationSchema = object({
19665
19716
  *
19666
19717
  * See spec: `docs/superpowers/specs/2026-06-24-camera-status-aggregator-cap.md`
19667
19718
  */
19719
+ var DiskReconcileJobSchema = object({
19720
+ state: _enum([
19721
+ "idle",
19722
+ "running",
19723
+ "done",
19724
+ "error"
19725
+ ]),
19726
+ total: number().int().nonnegative(),
19727
+ completed: number().int().nonnegative(),
19728
+ currentDeviceId: number().int().nullable(),
19729
+ failed: array(number().int()).readonly(),
19730
+ mediaDropped: number().int().nonnegative(),
19731
+ tracks: number().int().nonnegative(),
19732
+ events: number().int().nonnegative(),
19733
+ startedAtMs: number().int().nullable(),
19734
+ finishedAtMs: number().int().nullable(),
19735
+ error: string().nullable()
19736
+ });
19668
19737
  var CameraStatusSchema = object({
19669
19738
  deviceId: number(),
19670
19739
  assignment: CameraAssignmentStatusSchema,
@@ -19896,7 +19965,10 @@ method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
19896
19965
  }), CameraSwitchGroupSchema, {
19897
19966
  kind: "mutation",
19898
19967
  auth: "admin"
19899
- }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
19968
+ }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), DiskReconcileJobSchema, {
19969
+ kind: "mutation",
19970
+ auth: "admin"
19971
+ }), method(_void(), DiskReconcileJobSchema, { auth: "admin" }), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
19900
19972
  name: string(),
19901
19973
  description: string().optional(),
19902
19974
  config: CameraPipelineConfigSchema
@@ -20969,20 +21041,6 @@ var VectorStatsResultSchema = object({
20969
21041
  exact: boolean()
20970
21042
  });
20971
21043
  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);
20972
- /**
20973
- * `videoclips` — the unified, navigable-clip surface for a camera.
20974
- *
20975
- * A device-scoped WRAPPER cap (like `pipeline-analytics`): exactly one active
20976
- * provider per device, substitutable. The DEFAULT provider (registered by
20977
- * `addon-post-analysis`, `defaultActive: true`) composes the analytics event
20978
- * log (markers + thumbnails) with the recorder's `getPlaybackManifest` — a clip
20979
- * is a time-WINDOW over existing footage, never a separate file. A camera that
20980
- * exposes NATIVE onboard clips (Reolink/Hikvision NVR) can later substitute the
20981
- * wrapper provider for its device and serve its own clip catalog + URLs.
20982
- *
20983
- * A `Clip` is purely time-based (subtree-blind): playback resolves segments by
20984
- * temporal overlap, so the API never decides `continuous` vs `events`.
20985
- */
20986
21044
  var ClipSchema = object({
20987
21045
  /** Opaque, provider-namespaced id. The default provider encodes the time
20988
21046
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -20999,8 +21057,57 @@ var ClipSchema = object({
20999
21057
  startMs: number(),
21000
21058
  endMs: number()
21001
21059
  }),
21002
- /** Thumbnail URL (lazy; e.g. analytics `getEventMedia`). Never inlined. */
21003
- thumbnail: string().optional()
21060
+ /**
21061
+ * Lazy thumbnail URL, never inlined.
21062
+ *
21063
+ * Recording-derived clips (events-mode keep-window, and the prepared
21064
+ * continuous event+fragment visit) MUST use the snapshot of the **main
21065
+ * event of the interval** — `getEventMedia({ eventId, kind: 'snapshot' })`
21066
+ * of the event that owns `kind` (object > motion > audio). Do not extract
21067
+ * a keyframe from the recorded segments. Other providers (onboard, HKSV)
21068
+ * mint their own stills.
21069
+ *
21070
+ * **VOUCHED, never fabricated.** A provider emits this only for an event it
21071
+ * has CONFIRMED owns at least one media row (its own, or its owning track's).
21072
+ * Absent is meaningful — "this visit has no event still" — never "we did not
21073
+ * look". Stamping it from a URL template made 35% of one camera's clips point
21074
+ * at a 404 (device 3836, 2026-08-17: 64 of 179 clips dead, 63 of them motion).
21075
+ * A read that FAILS drops the claim; it never invents it.
21076
+ */
21077
+ thumbnail: string().optional(),
21078
+ /**
21079
+ * An instant INSIDE this visit's footage, hole-safe, where a recorded still
21080
+ * can be decoded. Present whenever the visit came from recorded availability;
21081
+ * absent on a per-event padded window (there is no footage to promise).
21082
+ *
21083
+ * This is not a thumbnail and not a second byte path: it is the argument to
21084
+ * the recorder's existing still route. The surface — never the provider —
21085
+ * decides whether to use it. It is the midpoint of the visit's LONGEST
21086
+ * contiguous range, not of the visit: a visit spans its holes by
21087
+ * construction, so a naive midpoint lands in dead air.
21088
+ */
21089
+ stillAtMs: number().optional(),
21090
+ /**
21091
+ * Analytics event ids that overlap this visit — a BOUNDED sample, newest
21092
+ * first within kind (object → motion → audio), capped at
21093
+ * {@link MAX_CLIP_EVENT_IDS}. Empty on footage-only clips.
21094
+ *
21095
+ * Bounded because it is not a payload the surface pages through: one visit on
21096
+ * device 615 carried 2 345 ids, and `eventIds` was 99% of a 153 KB
21097
+ * camera-day. Read {@link eventCount} for the true total.
21098
+ */
21099
+ eventIds: array(string()).optional(),
21100
+ /** How many analytics events actually overlap this visit. Differs from
21101
+ * `eventIds.length` exactly when the sample was capped — so a truncated
21102
+ * list is never mistaken for a quiet visit. */
21103
+ eventCount: number().int().nonnegative().optional(),
21104
+ /** Intra-visit footage holes (GOP rolls, discarded segments) still shorter
21105
+ * than `VISIT_MERGE_GAP_MS`. Playback concatenates around them; the timeline
21106
+ * bar keeps showing them via `recording.getAvailability`. */
21107
+ holes: array(object({
21108
+ startMs: number(),
21109
+ endMs: number()
21110
+ })).optional()
21004
21111
  });
21005
21112
  var ClipPlaybackSchema = object({
21006
21113
  /** HLS master URL through the hub data-plane (Range + token in path). */
@@ -21464,7 +21571,14 @@ var SearchResultSchema = object({
21464
21571
  });
21465
21572
  var AutoUpdateSettingsSchema = object({
21466
21573
  channel: ChannelSchema,
21467
- intervalSeconds: number()
21574
+ intervalSeconds: number(),
21575
+ /**
21576
+ * Cadence of the "an update exists" POLLER, in seconds. Independent of
21577
+ * `channel`: the poller runs while auto-apply is `off`, because being told
21578
+ * about a publish and installing it are different decisions. Clamped
21579
+ * server-side to 900 s … 604800 s; defaults to 21600 s (6 h).
21580
+ */
21581
+ updateCheckIntervalSeconds: number()
21468
21582
  });
21469
21583
  var AddonAutoUpdateSchema = ChannelWithInheritSchema;
21470
21584
  var RestartAddonResultSchema = unknown();
@@ -21605,7 +21719,9 @@ method(_void(), array(AddonListItemSchema).readonly()), method(object({
21605
21719
  auth: "admin"
21606
21720
  }), method(_void(), AutoUpdateSettingsSchema, { auth: "admin" }), method(object({
21607
21721
  channel: ChannelSchema,
21608
- intervalSeconds: number().min(300).max(86400).optional()
21722
+ intervalSeconds: number().min(300).max(86400).optional(),
21723
+ /** Availability-poll cadence; see AutoUpdateSettingsSchema. */
21724
+ updateCheckIntervalSeconds: number().min(900).max(604800).optional()
21609
21725
  }), unknown(), {
21610
21726
  kind: "mutation",
21611
21727
  auth: "admin"
@@ -27294,7 +27410,9 @@ var ExportOptionsSchema = object({
27294
27410
  includeAudio: boolean(),
27295
27411
  maxLifeMs: number().int().positive(),
27296
27412
  deleteAfterDownload: boolean(),
27297
- title: string().max(200).optional()
27413
+ title: string().max(200).optional(),
27414
+ /** Notification-output target ids to ping when this export becomes ready. */
27415
+ notifyTargetIds: array(string().min(1)).max(20).optional()
27298
27416
  }).superRefine((v, ctx) => {
27299
27417
  if (v.speed !== void 0 && v.timelapse !== void 0) ctx.addIssue({
27300
27418
  code: ZodIssueCode.custom,
@@ -27353,10 +27471,18 @@ var ExportBytesSchema = object({
27353
27471
  });
27354
27472
  method(object({
27355
27473
  deviceId: number(),
27356
- profile: string(),
27474
+ /** @deprecated Prefer `profiles`. Kept so timelapse/notifiers keep working. */
27475
+ profile: string().optional(),
27476
+ profiles: array(string()).min(1).optional(),
27357
27477
  fromMs: number(),
27358
27478
  toMs: number(),
27359
27479
  options: ExportOptionsSchema
27480
+ }).superRefine((v, ctx) => {
27481
+ if ((v.profiles !== void 0 && v.profiles.length > 0 ? v.profiles : v.profile !== void 0 ? [v.profile] : []).length < 1) ctx.addIssue({
27482
+ code: ZodIssueCode.custom,
27483
+ message: "pass profiles[] (min 1) or legacy profile",
27484
+ path: ["profiles"]
27485
+ });
27360
27486
  }), ExportRecordSchema, {
27361
27487
  kind: "mutation",
27362
27488
  auth: "protected"
@@ -30298,15 +30424,6 @@ var BaseDeviceProvider = class extends BaseAddon {
30298
30424
  labels: ["probe not implemented"]
30299
30425
  };
30300
30426
  }
30301
- /**
30302
- * Top-level devices restored at once in {@link onRestoreDevices}.
30303
- *
30304
- * Four covers the fleets this ships to without turning a boot into a burst a
30305
- * camera NVR answers with a refusal. A provider whose upstream is a single
30306
- * session with a serial command channel (a Baichuan hub, an NVR that
30307
- * serialises ISAPI) should lower it; nothing needs to raise it.
30308
- */
30309
- restoreConcurrency = 4;
30310
30427
  async restoreDevices(savedDevices) {
30311
30428
  await this.onRestoreDevices(savedDevices);
30312
30429
  if (savedDevices.length > 0) this.ctx.logger.info(`Restored ${savedDevices.length} ${this.providerName} device(s)`);
@@ -30361,14 +30478,7 @@ var BaseDeviceProvider = class extends BaseAddon {
30361
30478
  });
30362
30479
  }
30363
30480
  };
30364
- let nextTopLevel = 0;
30365
- await Promise.all(Array.from({ length: Math.min(Math.max(1, this.restoreConcurrency), topLevel.length) }, async () => {
30366
- for (;;) {
30367
- const saved = topLevel[nextTopLevel++];
30368
- if (saved === void 0) return;
30369
- await restoreOne(saved);
30370
- }
30371
- }));
30481
+ await Promise.all(topLevel.map((saved) => restoreOne(saved)));
30372
30482
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
30373
30483
  for (const saved of childRows) {
30374
30484
  const Class = this.deviceClasses[saved.type];
@@ -33641,6 +33751,12 @@ Object.freeze({
33641
33751
  addonId: null,
33642
33752
  access: "create"
33643
33753
  },
33754
+ "pipelineAnalytics.reconcileFromDisk": {
33755
+ capName: "pipeline-analytics",
33756
+ capScope: "device",
33757
+ addonId: null,
33758
+ access: "create"
33759
+ },
33644
33760
  "pipelineAnalytics.refreshStorageLocationsForMigration": {
33645
33761
  capName: "pipeline-analytics",
33646
33762
  capScope: "device",
@@ -34043,6 +34159,12 @@ Object.freeze({
34043
34159
  addonId: null,
34044
34160
  access: "view"
34045
34161
  },
34162
+ "pipelineOrchestrator.getReconcileFromDiskStatus": {
34163
+ capName: "pipeline-orchestrator",
34164
+ capScope: "system",
34165
+ addonId: null,
34166
+ access: "view"
34167
+ },
34046
34168
  "pipelineOrchestrator.listAgentSettings": {
34047
34169
  capName: "pipeline-orchestrator",
34048
34170
  capScope: "system",
@@ -34067,6 +34189,12 @@ Object.freeze({
34067
34189
  addonId: null,
34068
34190
  access: "create"
34069
34191
  },
34192
+ "pipelineOrchestrator.reconcileFromDisk": {
34193
+ capName: "pipeline-orchestrator",
34194
+ capScope: "system",
34195
+ addonId: null,
34196
+ access: "create"
34197
+ },
34070
34198
  "pipelineOrchestrator.removeAgentSettings": {
34071
34199
  capName: "pipeline-orchestrator",
34072
34200
  capScope: "system",
@@ -37058,6 +37186,11 @@ Object.freeze({
37058
37186
  form: "single",
37059
37187
  optional: true
37060
37188
  }],
37189
+ "pipelineAnalytics.reconcileFromDisk": [{
37190
+ name: "deviceId",
37191
+ form: "single",
37192
+ optional: false
37193
+ }],
37061
37194
  "pipelineAnalytics.restageRetrainTrack": [{
37062
37195
  name: "deviceId",
37063
37196
  form: "single",
@@ -38123,6 +38256,8 @@ DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
38123
38256
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
38124
38257
  DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
38125
38258
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
38259
+ var MB = 1024 * 1024;
38260
+ 1024 * MB, 3072 * MB;
38126
38261
  //#endregion
38127
38262
  //#region src/config.ts
38128
38263
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-tuya",
3
- "version": "0.2.20",
3
+ "version": "0.2.21",
4
4
  "description": "Tuya / Smart Life device-provider addon for CamStack — account-onboarded (Tuya IoT cloud fetch of device localKeys) + LOCAL DP control via the @apocaliss92/nodetuya encrypted-LAN client, exposing switch / water-heater-family kettle entities",
5
5
  "keywords": [
6
6
  "camstack",