@camstack/addon-provider-tuya 0.2.20 → 0.2.22

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
@@ -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,65 @@ 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
+ * Distinct object classes attached to this visit (`person`, `car`, …),
21063
+ * dominant first, capped at {@link MAX_CLIP_LABELS}. The ribbon renders these
21064
+ * instead of the bare kind — "Object" tells the operator nothing a colour bar
21065
+ * did not. Absent (never empty) when the visit attached no classified object
21066
+ * event, so a motion/audio-only visit keeps its kind label.
21067
+ */
21068
+ labels: array(string()).max(3).optional(),
21069
+ /**
21070
+ * Lazy thumbnail URL, never inlined.
21071
+ *
21072
+ * Recording-derived clips (events-mode keep-window, and the prepared
21073
+ * continuous event+fragment visit) MUST use the snapshot of the **main
21074
+ * event of the interval** — `getEventMedia({ eventId, kind: 'snapshot' })`
21075
+ * of the event that owns `kind` (object > motion > audio). Do not extract
21076
+ * a keyframe from the recorded segments. Other providers (onboard, HKSV)
21077
+ * mint their own stills.
21078
+ *
21079
+ * **VOUCHED, never fabricated.** A provider emits this only for an event it
21080
+ * has CONFIRMED owns at least one media row (its own, or its owning track's).
21081
+ * Absent is meaningful — "this visit has no event still" — never "we did not
21082
+ * look". Stamping it from a URL template made 35% of one camera's clips point
21083
+ * at a 404 (device 3836, 2026-08-17: 64 of 179 clips dead, 63 of them motion).
21084
+ * A read that FAILS drops the claim; it never invents it.
21085
+ */
21086
+ thumbnail: string().optional(),
21087
+ /**
21088
+ * An instant INSIDE this visit's footage, hole-safe, where a recorded still
21089
+ * can be decoded. Present whenever the visit came from recorded availability;
21090
+ * absent on a per-event padded window (there is no footage to promise).
21091
+ *
21092
+ * This is not a thumbnail and not a second byte path: it is the argument to
21093
+ * the recorder's existing still route. The surface — never the provider —
21094
+ * decides whether to use it. It is the midpoint of the visit's LONGEST
21095
+ * contiguous range, not of the visit: a visit spans its holes by
21096
+ * construction, so a naive midpoint lands in dead air.
21097
+ */
21098
+ stillAtMs: number().optional(),
21099
+ /**
21100
+ * Analytics event ids that overlap this visit — a BOUNDED sample, newest
21101
+ * first within kind (object → motion → audio), capped at
21102
+ * {@link MAX_CLIP_EVENT_IDS}. Empty on footage-only clips.
21103
+ *
21104
+ * Bounded because it is not a payload the surface pages through: one visit on
21105
+ * device 615 carried 2 345 ids, and `eventIds` was 99% of a 153 KB
21106
+ * camera-day. Read {@link eventCount} for the true total.
21107
+ */
21108
+ eventIds: array(string()).optional(),
21109
+ /** How many analytics events actually overlap this visit. Differs from
21110
+ * `eventIds.length` exactly when the sample was capped — so a truncated
21111
+ * list is never mistaken for a quiet visit. */
21112
+ eventCount: number().int().nonnegative().optional(),
21113
+ /** Intra-visit footage holes (GOP rolls, discarded segments) still shorter
21114
+ * than `VISIT_MERGE_GAP_MS`. Playback concatenates around them; the timeline
21115
+ * bar keeps showing them via `recording.getAvailability`. */
21116
+ holes: array(object({
21117
+ startMs: number(),
21118
+ endMs: number()
21119
+ })).optional()
21005
21120
  });
21006
21121
  var ClipPlaybackSchema = object({
21007
21122
  /** HLS master URL through the hub data-plane (Range + token in path). */
@@ -21465,7 +21580,14 @@ var SearchResultSchema = object({
21465
21580
  });
21466
21581
  var AutoUpdateSettingsSchema = object({
21467
21582
  channel: ChannelSchema,
21468
- intervalSeconds: number()
21583
+ intervalSeconds: number(),
21584
+ /**
21585
+ * Cadence of the "an update exists" POLLER, in seconds. Independent of
21586
+ * `channel`: the poller runs while auto-apply is `off`, because being told
21587
+ * about a publish and installing it are different decisions. Clamped
21588
+ * server-side to 900 s … 604800 s; defaults to 21600 s (6 h).
21589
+ */
21590
+ updateCheckIntervalSeconds: number()
21469
21591
  });
21470
21592
  var AddonAutoUpdateSchema = ChannelWithInheritSchema;
21471
21593
  var RestartAddonResultSchema = unknown();
@@ -21606,7 +21728,9 @@ method(_void(), array(AddonListItemSchema).readonly()), method(object({
21606
21728
  auth: "admin"
21607
21729
  }), method(_void(), AutoUpdateSettingsSchema, { auth: "admin" }), method(object({
21608
21730
  channel: ChannelSchema,
21609
- intervalSeconds: number().min(300).max(86400).optional()
21731
+ intervalSeconds: number().min(300).max(86400).optional(),
21732
+ /** Availability-poll cadence; see AutoUpdateSettingsSchema. */
21733
+ updateCheckIntervalSeconds: number().min(900).max(604800).optional()
21610
21734
  }), unknown(), {
21611
21735
  kind: "mutation",
21612
21736
  auth: "admin"
@@ -27295,7 +27419,9 @@ var ExportOptionsSchema = object({
27295
27419
  includeAudio: boolean(),
27296
27420
  maxLifeMs: number().int().positive(),
27297
27421
  deleteAfterDownload: boolean(),
27298
- title: string().max(200).optional()
27422
+ title: string().max(200).optional(),
27423
+ /** Notification-output target ids to ping when this export becomes ready. */
27424
+ notifyTargetIds: array(string().min(1)).max(20).optional()
27299
27425
  }).superRefine((v, ctx) => {
27300
27426
  if (v.speed !== void 0 && v.timelapse !== void 0) ctx.addIssue({
27301
27427
  code: ZodIssueCode.custom,
@@ -27354,10 +27480,18 @@ var ExportBytesSchema = object({
27354
27480
  });
27355
27481
  method(object({
27356
27482
  deviceId: number(),
27357
- profile: string(),
27483
+ /** @deprecated Prefer `profiles`. Kept so timelapse/notifiers keep working. */
27484
+ profile: string().optional(),
27485
+ profiles: array(string()).min(1).optional(),
27358
27486
  fromMs: number(),
27359
27487
  toMs: number(),
27360
27488
  options: ExportOptionsSchema
27489
+ }).superRefine((v, ctx) => {
27490
+ if ((v.profiles !== void 0 && v.profiles.length > 0 ? v.profiles : v.profile !== void 0 ? [v.profile] : []).length < 1) ctx.addIssue({
27491
+ code: ZodIssueCode.custom,
27492
+ message: "pass profiles[] (min 1) or legacy profile",
27493
+ path: ["profiles"]
27494
+ });
27361
27495
  }), ExportRecordSchema, {
27362
27496
  kind: "mutation",
27363
27497
  auth: "protected"
@@ -30299,15 +30433,6 @@ var BaseDeviceProvider = class extends BaseAddon {
30299
30433
  labels: ["probe not implemented"]
30300
30434
  };
30301
30435
  }
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
30436
  async restoreDevices(savedDevices) {
30312
30437
  await this.onRestoreDevices(savedDevices);
30313
30438
  if (savedDevices.length > 0) this.ctx.logger.info(`Restored ${savedDevices.length} ${this.providerName} device(s)`);
@@ -30362,14 +30487,7 @@ var BaseDeviceProvider = class extends BaseAddon {
30362
30487
  });
30363
30488
  }
30364
30489
  };
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
- }));
30490
+ await Promise.all(topLevel.map((saved) => restoreOne(saved)));
30373
30491
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
30374
30492
  for (const saved of childRows) {
30375
30493
  const Class = this.deviceClasses[saved.type];
@@ -33642,6 +33760,12 @@ Object.freeze({
33642
33760
  addonId: null,
33643
33761
  access: "create"
33644
33762
  },
33763
+ "pipelineAnalytics.reconcileFromDisk": {
33764
+ capName: "pipeline-analytics",
33765
+ capScope: "device",
33766
+ addonId: null,
33767
+ access: "create"
33768
+ },
33645
33769
  "pipelineAnalytics.refreshStorageLocationsForMigration": {
33646
33770
  capName: "pipeline-analytics",
33647
33771
  capScope: "device",
@@ -34044,6 +34168,12 @@ Object.freeze({
34044
34168
  addonId: null,
34045
34169
  access: "view"
34046
34170
  },
34171
+ "pipelineOrchestrator.getReconcileFromDiskStatus": {
34172
+ capName: "pipeline-orchestrator",
34173
+ capScope: "system",
34174
+ addonId: null,
34175
+ access: "view"
34176
+ },
34047
34177
  "pipelineOrchestrator.listAgentSettings": {
34048
34178
  capName: "pipeline-orchestrator",
34049
34179
  capScope: "system",
@@ -34068,6 +34198,12 @@ Object.freeze({
34068
34198
  addonId: null,
34069
34199
  access: "create"
34070
34200
  },
34201
+ "pipelineOrchestrator.reconcileFromDisk": {
34202
+ capName: "pipeline-orchestrator",
34203
+ capScope: "system",
34204
+ addonId: null,
34205
+ access: "create"
34206
+ },
34071
34207
  "pipelineOrchestrator.removeAgentSettings": {
34072
34208
  capName: "pipeline-orchestrator",
34073
34209
  capScope: "system",
@@ -37059,6 +37195,11 @@ Object.freeze({
37059
37195
  form: "single",
37060
37196
  optional: true
37061
37197
  }],
37198
+ "pipelineAnalytics.reconcileFromDisk": [{
37199
+ name: "deviceId",
37200
+ form: "single",
37201
+ optional: false
37202
+ }],
37062
37203
  "pipelineAnalytics.restageRetrainTrack": [{
37063
37204
  name: "deviceId",
37064
37205
  form: "single",
@@ -38124,6 +38265,8 @@ DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
38124
38265
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
38125
38266
  DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
38126
38267
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
38268
+ var MB = 1024 * 1024;
38269
+ 1024 * MB, 3072 * MB;
38127
38270
  //#endregion
38128
38271
  //#region src/config.ts
38129
38272
  /**
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,65 @@ 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
+ * Distinct object classes attached to this visit (`person`, `car`, …),
21062
+ * dominant first, capped at {@link MAX_CLIP_LABELS}. The ribbon renders these
21063
+ * instead of the bare kind — "Object" tells the operator nothing a colour bar
21064
+ * did not. Absent (never empty) when the visit attached no classified object
21065
+ * event, so a motion/audio-only visit keeps its kind label.
21066
+ */
21067
+ labels: array(string()).max(3).optional(),
21068
+ /**
21069
+ * Lazy thumbnail URL, never inlined.
21070
+ *
21071
+ * Recording-derived clips (events-mode keep-window, and the prepared
21072
+ * continuous event+fragment visit) MUST use the snapshot of the **main
21073
+ * event of the interval** — `getEventMedia({ eventId, kind: 'snapshot' })`
21074
+ * of the event that owns `kind` (object > motion > audio). Do not extract
21075
+ * a keyframe from the recorded segments. Other providers (onboard, HKSV)
21076
+ * mint their own stills.
21077
+ *
21078
+ * **VOUCHED, never fabricated.** A provider emits this only for an event it
21079
+ * has CONFIRMED owns at least one media row (its own, or its owning track's).
21080
+ * Absent is meaningful — "this visit has no event still" — never "we did not
21081
+ * look". Stamping it from a URL template made 35% of one camera's clips point
21082
+ * at a 404 (device 3836, 2026-08-17: 64 of 179 clips dead, 63 of them motion).
21083
+ * A read that FAILS drops the claim; it never invents it.
21084
+ */
21085
+ thumbnail: string().optional(),
21086
+ /**
21087
+ * An instant INSIDE this visit's footage, hole-safe, where a recorded still
21088
+ * can be decoded. Present whenever the visit came from recorded availability;
21089
+ * absent on a per-event padded window (there is no footage to promise).
21090
+ *
21091
+ * This is not a thumbnail and not a second byte path: it is the argument to
21092
+ * the recorder's existing still route. The surface — never the provider —
21093
+ * decides whether to use it. It is the midpoint of the visit's LONGEST
21094
+ * contiguous range, not of the visit: a visit spans its holes by
21095
+ * construction, so a naive midpoint lands in dead air.
21096
+ */
21097
+ stillAtMs: number().optional(),
21098
+ /**
21099
+ * Analytics event ids that overlap this visit — a BOUNDED sample, newest
21100
+ * first within kind (object → motion → audio), capped at
21101
+ * {@link MAX_CLIP_EVENT_IDS}. Empty on footage-only clips.
21102
+ *
21103
+ * Bounded because it is not a payload the surface pages through: one visit on
21104
+ * device 615 carried 2 345 ids, and `eventIds` was 99% of a 153 KB
21105
+ * camera-day. Read {@link eventCount} for the true total.
21106
+ */
21107
+ eventIds: array(string()).optional(),
21108
+ /** How many analytics events actually overlap this visit. Differs from
21109
+ * `eventIds.length` exactly when the sample was capped — so a truncated
21110
+ * list is never mistaken for a quiet visit. */
21111
+ eventCount: number().int().nonnegative().optional(),
21112
+ /** Intra-visit footage holes (GOP rolls, discarded segments) still shorter
21113
+ * than `VISIT_MERGE_GAP_MS`. Playback concatenates around them; the timeline
21114
+ * bar keeps showing them via `recording.getAvailability`. */
21115
+ holes: array(object({
21116
+ startMs: number(),
21117
+ endMs: number()
21118
+ })).optional()
21004
21119
  });
21005
21120
  var ClipPlaybackSchema = object({
21006
21121
  /** HLS master URL through the hub data-plane (Range + token in path). */
@@ -21464,7 +21579,14 @@ var SearchResultSchema = object({
21464
21579
  });
21465
21580
  var AutoUpdateSettingsSchema = object({
21466
21581
  channel: ChannelSchema,
21467
- intervalSeconds: number()
21582
+ intervalSeconds: number(),
21583
+ /**
21584
+ * Cadence of the "an update exists" POLLER, in seconds. Independent of
21585
+ * `channel`: the poller runs while auto-apply is `off`, because being told
21586
+ * about a publish and installing it are different decisions. Clamped
21587
+ * server-side to 900 s … 604800 s; defaults to 21600 s (6 h).
21588
+ */
21589
+ updateCheckIntervalSeconds: number()
21468
21590
  });
21469
21591
  var AddonAutoUpdateSchema = ChannelWithInheritSchema;
21470
21592
  var RestartAddonResultSchema = unknown();
@@ -21605,7 +21727,9 @@ method(_void(), array(AddonListItemSchema).readonly()), method(object({
21605
21727
  auth: "admin"
21606
21728
  }), method(_void(), AutoUpdateSettingsSchema, { auth: "admin" }), method(object({
21607
21729
  channel: ChannelSchema,
21608
- intervalSeconds: number().min(300).max(86400).optional()
21730
+ intervalSeconds: number().min(300).max(86400).optional(),
21731
+ /** Availability-poll cadence; see AutoUpdateSettingsSchema. */
21732
+ updateCheckIntervalSeconds: number().min(900).max(604800).optional()
21609
21733
  }), unknown(), {
21610
21734
  kind: "mutation",
21611
21735
  auth: "admin"
@@ -27294,7 +27418,9 @@ var ExportOptionsSchema = object({
27294
27418
  includeAudio: boolean(),
27295
27419
  maxLifeMs: number().int().positive(),
27296
27420
  deleteAfterDownload: boolean(),
27297
- title: string().max(200).optional()
27421
+ title: string().max(200).optional(),
27422
+ /** Notification-output target ids to ping when this export becomes ready. */
27423
+ notifyTargetIds: array(string().min(1)).max(20).optional()
27298
27424
  }).superRefine((v, ctx) => {
27299
27425
  if (v.speed !== void 0 && v.timelapse !== void 0) ctx.addIssue({
27300
27426
  code: ZodIssueCode.custom,
@@ -27353,10 +27479,18 @@ var ExportBytesSchema = object({
27353
27479
  });
27354
27480
  method(object({
27355
27481
  deviceId: number(),
27356
- profile: string(),
27482
+ /** @deprecated Prefer `profiles`. Kept so timelapse/notifiers keep working. */
27483
+ profile: string().optional(),
27484
+ profiles: array(string()).min(1).optional(),
27357
27485
  fromMs: number(),
27358
27486
  toMs: number(),
27359
27487
  options: ExportOptionsSchema
27488
+ }).superRefine((v, ctx) => {
27489
+ if ((v.profiles !== void 0 && v.profiles.length > 0 ? v.profiles : v.profile !== void 0 ? [v.profile] : []).length < 1) ctx.addIssue({
27490
+ code: ZodIssueCode.custom,
27491
+ message: "pass profiles[] (min 1) or legacy profile",
27492
+ path: ["profiles"]
27493
+ });
27360
27494
  }), ExportRecordSchema, {
27361
27495
  kind: "mutation",
27362
27496
  auth: "protected"
@@ -30298,15 +30432,6 @@ var BaseDeviceProvider = class extends BaseAddon {
30298
30432
  labels: ["probe not implemented"]
30299
30433
  };
30300
30434
  }
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
30435
  async restoreDevices(savedDevices) {
30311
30436
  await this.onRestoreDevices(savedDevices);
30312
30437
  if (savedDevices.length > 0) this.ctx.logger.info(`Restored ${savedDevices.length} ${this.providerName} device(s)`);
@@ -30361,14 +30486,7 @@ var BaseDeviceProvider = class extends BaseAddon {
30361
30486
  });
30362
30487
  }
30363
30488
  };
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
- }));
30489
+ await Promise.all(topLevel.map((saved) => restoreOne(saved)));
30372
30490
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
30373
30491
  for (const saved of childRows) {
30374
30492
  const Class = this.deviceClasses[saved.type];
@@ -33641,6 +33759,12 @@ Object.freeze({
33641
33759
  addonId: null,
33642
33760
  access: "create"
33643
33761
  },
33762
+ "pipelineAnalytics.reconcileFromDisk": {
33763
+ capName: "pipeline-analytics",
33764
+ capScope: "device",
33765
+ addonId: null,
33766
+ access: "create"
33767
+ },
33644
33768
  "pipelineAnalytics.refreshStorageLocationsForMigration": {
33645
33769
  capName: "pipeline-analytics",
33646
33770
  capScope: "device",
@@ -34043,6 +34167,12 @@ Object.freeze({
34043
34167
  addonId: null,
34044
34168
  access: "view"
34045
34169
  },
34170
+ "pipelineOrchestrator.getReconcileFromDiskStatus": {
34171
+ capName: "pipeline-orchestrator",
34172
+ capScope: "system",
34173
+ addonId: null,
34174
+ access: "view"
34175
+ },
34046
34176
  "pipelineOrchestrator.listAgentSettings": {
34047
34177
  capName: "pipeline-orchestrator",
34048
34178
  capScope: "system",
@@ -34067,6 +34197,12 @@ Object.freeze({
34067
34197
  addonId: null,
34068
34198
  access: "create"
34069
34199
  },
34200
+ "pipelineOrchestrator.reconcileFromDisk": {
34201
+ capName: "pipeline-orchestrator",
34202
+ capScope: "system",
34203
+ addonId: null,
34204
+ access: "create"
34205
+ },
34070
34206
  "pipelineOrchestrator.removeAgentSettings": {
34071
34207
  capName: "pipeline-orchestrator",
34072
34208
  capScope: "system",
@@ -37058,6 +37194,11 @@ Object.freeze({
37058
37194
  form: "single",
37059
37195
  optional: true
37060
37196
  }],
37197
+ "pipelineAnalytics.reconcileFromDisk": [{
37198
+ name: "deviceId",
37199
+ form: "single",
37200
+ optional: false
37201
+ }],
37061
37202
  "pipelineAnalytics.restageRetrainTrack": [{
37062
37203
  name: "deviceId",
37063
37204
  form: "single",
@@ -38123,6 +38264,8 @@ DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
38123
38264
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
38124
38265
  DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
38125
38266
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
38267
+ var MB = 1024 * 1024;
38268
+ 1024 * MB, 3072 * MB;
38126
38269
  //#endregion
38127
38270
  //#region src/config.ts
38128
38271
  /**
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.22",
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",