@camstack/addon-provider-wyze 0.2.19 → 0.2.24

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 +369 -55
  2. package/dist/addon.mjs +369 -55
  3. package/package.json +4 -1
package/dist/addon.js CHANGED
@@ -30,7 +30,8 @@ let events = require("events");
30
30
  let net = require("net");
31
31
  net = __toESM(net, 1);
32
32
  let node_child_process = require("node:child_process");
33
- //#region ../types/dist/event-category-Bxo5yJjt.mjs
33
+ let node_tls = require("node:tls");
34
+ //#region ../types/dist/event-category-XfKNtfCc.mjs
34
35
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
35
36
  EventCategory["SystemBoot"] = "system.boot";
36
37
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -47,9 +48,10 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
47
48
  EventCategory["SystemRestartCompleted"] = "system.restart-completed";
48
49
  /**
49
50
  * A newer addon or server-root package version was found by the
50
- * authoritative registry check. Emitted once per
51
- * `(target, packageName, currentVersion, latestVersion)` transition; repeated
52
- * polling of the same result is deduplicated by the checker.
51
+ * authoritative registry check. Emitted once when any observed
52
+ * `latestVersion` changes (or a package/node first appears behind);
53
+ * the payload carries the full currently-available list. Repeated
54
+ * polling of the same latests is silent.
53
55
  */
54
56
  EventCategory["UpdateAvailable"] = "update.available";
55
57
  /**
@@ -68,6 +70,22 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
68
70
  EventCategory["AddonInstalled"] = "addon.installed";
69
71
  EventCategory["AddonUninstalled"] = "addon.uninstalled";
70
72
  EventCategory["AddonCrashed"] = "addon.crashed";
73
+ /**
74
+ * A RUNNER the D6 crash circuit-breaker gave up on — terminal.
75
+ *
76
+ * `AddonCrashed` is the routine, self-healing fact ("it crashed; it is being
77
+ * respawned"); this is the one that never resolves itself. Emitted exactly
78
+ * once per trip, by `process-service.ts`, carrying the node, the runner, the
79
+ * addons it hosted and the crash count that tripped the breaker.
80
+ *
81
+ * It exists because a runner marked terminally `failed` used to be SILENT:
82
+ * on 2026-08-18 the `recorder` runner died of three unhandled ffmpeg spawn
83
+ * errors, the breaker stopped respawning it (correctly), `/health` kept
84
+ * returning 200, and fleet-wide recording was gone for 3h15 before the
85
+ * operator's phone told him. The Notification Center's system-event intake
86
+ * consumes this category and maps it to the `addon-crash-loop` kind.
87
+ */
88
+ EventCategory["AddonRunnerFailed"] = "addon.runner-failed";
71
89
  EventCategory["AddonError"] = "addon.error";
72
90
  EventCategory["AddonPageReady"] = "addon.page-ready";
73
91
  EventCategory["AddonWidgetReady"] = "addon.widget-ready";
@@ -7579,6 +7597,10 @@ var RecordingBandSchema = object({
7579
7597
  preBufferSec: number().min(0).optional(),
7580
7598
  postBufferSec: number().min(0).optional()
7581
7599
  });
7600
+ ({
7601
+ preBufferSec: 10,
7602
+ postBufferSec: 30
7603
+ }).postBufferSec * 1e3;
7582
7604
  /**
7583
7605
  * Per-device retention overrides. Every field is optional; an unset or `0`
7584
7606
  * value inherits the node-wide recorder default. Only footage-lifetime limits
@@ -7626,6 +7648,12 @@ var RecordingConfigSchema = object({
7626
7648
  /** DERIVED summary of `bands`, stamped by the recorder on every save.
7627
7649
  * Authoring it has no effect — see {@link RecordingStorageModeSchema}. */
7628
7650
  mode: RecordingStorageModeSchema.optional(),
7651
+ /**
7652
+ * Which assigned broker slots to record. Absent / empty = {@link
7653
+ * DEFAULT_RECORDING_PROFILES} (`high`+`low`) intersected with the
7654
+ * camera's currently assigned slots — never `mid` unless the operator
7655
+ * picks it, and never a slot the broker has not assigned.
7656
+ */
7629
7657
  profiles: array(CamProfileSchema).optional(),
7630
7658
  segmentSeconds: number().int().positive().optional(),
7631
7659
  /**
@@ -7706,7 +7734,11 @@ var RelocateFootageInputSchema = object({
7706
7734
  profiles: array(string()).optional(),
7707
7735
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7708
7736
  * never allowed to starve live writers. */
7709
- throttleMbps: number().min(1).max(1e3).optional()
7737
+ throttleMbps: number().min(1).max(1e3).optional(),
7738
+ /** Move only segments whose startMs is >= this. Absent = the whole source
7739
+ * pile. Used when a full drain is too expensive and the operator only
7740
+ * wants the recent window on the new disk. */
7741
+ sinceMs: number().int().optional()
7710
7742
  });
7711
7743
  /** Internal, lease-scoped participant operation. It is intentionally separate
7712
7744
  * from persistent recording settings: a migration never changes
@@ -14588,6 +14620,7 @@ var NcSystemEventKindSchema = _enum([
14588
14620
  "node-offline",
14589
14621
  "node-inference-unavailable",
14590
14622
  "detection-blind",
14623
+ "addon-crash-loop",
14591
14624
  "addon-update-available",
14592
14625
  "server-update-available",
14593
14626
  "alarm-triggered",
@@ -14595,6 +14628,9 @@ var NcSystemEventKindSchema = _enum([
14595
14628
  "alarm-disarmed",
14596
14629
  "alarm-arming",
14597
14630
  "alarm-arm-refused",
14631
+ "addon-updated",
14632
+ "server-updated",
14633
+ "export-completed",
14598
14634
  "camera-online",
14599
14635
  "camera-offline",
14600
14636
  "camera-disabled",
@@ -16488,13 +16524,19 @@ var RetrainStatusSchema = _enum([
16488
16524
  * "never marked" from "already trained" must read `retrainStatus`.
16489
16525
  *
16490
16526
  * `debug` does NOT pin; it is attention, not durability.
16527
+ *
16528
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16529
+ * A favourited track is skipped by retention the same way `staging` is, but
16530
+ * it does not enter `none|staging|trained` and has no staging budget.
16491
16531
  */
16492
16532
  var TrackFlagFields = {
16493
16533
  /** Operator marked this track as training material — i.e. `retrainStatus` is
16494
16534
  * `'staging'`. */
16495
16535
  markForTrain: boolean().optional(),
16496
16536
  /** Operator marked this track for diagnostic attention. */
16497
- debug: boolean().optional()
16537
+ debug: boolean().optional(),
16538
+ /** Operator favourited this track. Pins it against pruning. */
16539
+ favourited: boolean().optional()
16498
16540
  };
16499
16541
  /**
16500
16542
  * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
@@ -16519,6 +16561,7 @@ var TrackFlagsSchema = object({
16519
16561
  trackId: string(),
16520
16562
  markForTrain: boolean(),
16521
16563
  debug: boolean(),
16564
+ favourited: boolean(),
16522
16565
  /** The lifecycle state the boolean was derived from. Required here (unlike on
16523
16566
  * a track row) because this shape is only ever produced by the write body,
16524
16567
  * which always knows it — and a surface that has just written needs to render
@@ -17151,6 +17194,12 @@ var TrackCascadeCountsSchema = object({
17151
17194
  /** Per-track CLIP search vectors removed (best-effort). */
17152
17195
  embeddings: number().int()
17153
17196
  });
17197
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17198
+ var DiskReconcileCountsSchema = object({
17199
+ mediaDropped: number().int(),
17200
+ tracks: number().int(),
17201
+ events: number().int()
17202
+ });
17154
17203
  /** Event-store footprint for one camera. */
17155
17204
  var EventStoreDeviceFootprintSchema = object({
17156
17205
  deviceId: number(),
@@ -17327,6 +17376,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17327
17376
  }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17328
17377
  kind: "mutation",
17329
17378
  auth: "admin"
17379
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17380
+ kind: "mutation",
17381
+ auth: "admin"
17330
17382
  }), method(object({
17331
17383
  deviceId: number(),
17332
17384
  trackIds: array(string()).min(1)
@@ -18877,6 +18929,24 @@ var CameraStatusDegradationSchema = object({
18877
18929
  *
18878
18930
  * See spec: `docs/superpowers/specs/2026-06-24-camera-status-aggregator-cap.md`
18879
18931
  */
18932
+ var DiskReconcileJobSchema = object({
18933
+ state: _enum([
18934
+ "idle",
18935
+ "running",
18936
+ "done",
18937
+ "error"
18938
+ ]),
18939
+ total: number().int().nonnegative(),
18940
+ completed: number().int().nonnegative(),
18941
+ currentDeviceId: number().int().nullable(),
18942
+ failed: array(number().int()).readonly(),
18943
+ mediaDropped: number().int().nonnegative(),
18944
+ tracks: number().int().nonnegative(),
18945
+ events: number().int().nonnegative(),
18946
+ startedAtMs: number().int().nullable(),
18947
+ finishedAtMs: number().int().nullable(),
18948
+ error: string().nullable()
18949
+ });
18880
18950
  var CameraStatusSchema = object({
18881
18951
  deviceId: number(),
18882
18952
  assignment: CameraAssignmentStatusSchema,
@@ -19108,7 +19178,10 @@ method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
19108
19178
  }), CameraSwitchGroupSchema, {
19109
19179
  kind: "mutation",
19110
19180
  auth: "admin"
19111
- }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
19181
+ }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), DiskReconcileJobSchema, {
19182
+ kind: "mutation",
19183
+ auth: "admin"
19184
+ }), method(_void(), DiskReconcileJobSchema, { auth: "admin" }), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
19112
19185
  name: string(),
19113
19186
  description: string().optional(),
19114
19187
  config: CameraPipelineConfigSchema
@@ -20285,20 +20358,6 @@ var VectorStatsResultSchema = object({
20285
20358
  exact: boolean()
20286
20359
  });
20287
20360
  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);
20288
- /**
20289
- * `videoclips` — the unified, navigable-clip surface for a camera.
20290
- *
20291
- * A device-scoped WRAPPER cap (like `pipeline-analytics`): exactly one active
20292
- * provider per device, substitutable. The DEFAULT provider (registered by
20293
- * `addon-post-analysis`, `defaultActive: true`) composes the analytics event
20294
- * log (markers + thumbnails) with the recorder's `getPlaybackManifest` — a clip
20295
- * is a time-WINDOW over existing footage, never a separate file. A camera that
20296
- * exposes NATIVE onboard clips (Reolink/Hikvision NVR) can later substitute the
20297
- * wrapper provider for its device and serve its own clip catalog + URLs.
20298
- *
20299
- * A `Clip` is purely time-based (subtree-blind): playback resolves segments by
20300
- * temporal overlap, so the API never decides `continuous` vs `events`.
20301
- */
20302
20361
  var ClipSchema = object({
20303
20362
  /** Opaque, provider-namespaced id. The default provider encodes the time
20304
20363
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -20315,8 +20374,57 @@ var ClipSchema = object({
20315
20374
  startMs: number(),
20316
20375
  endMs: number()
20317
20376
  }),
20318
- /** Thumbnail URL (lazy; e.g. analytics `getEventMedia`). Never inlined. */
20319
- thumbnail: string().optional()
20377
+ /**
20378
+ * Lazy thumbnail URL, never inlined.
20379
+ *
20380
+ * Recording-derived clips (events-mode keep-window, and the prepared
20381
+ * continuous event+fragment visit) MUST use the snapshot of the **main
20382
+ * event of the interval** — `getEventMedia({ eventId, kind: 'snapshot' })`
20383
+ * of the event that owns `kind` (object > motion > audio). Do not extract
20384
+ * a keyframe from the recorded segments. Other providers (onboard, HKSV)
20385
+ * mint their own stills.
20386
+ *
20387
+ * **VOUCHED, never fabricated.** A provider emits this only for an event it
20388
+ * has CONFIRMED owns at least one media row (its own, or its owning track's).
20389
+ * Absent is meaningful — "this visit has no event still" — never "we did not
20390
+ * look". Stamping it from a URL template made 35% of one camera's clips point
20391
+ * at a 404 (device 3836, 2026-08-17: 64 of 179 clips dead, 63 of them motion).
20392
+ * A read that FAILS drops the claim; it never invents it.
20393
+ */
20394
+ thumbnail: string().optional(),
20395
+ /**
20396
+ * An instant INSIDE this visit's footage, hole-safe, where a recorded still
20397
+ * can be decoded. Present whenever the visit came from recorded availability;
20398
+ * absent on a per-event padded window (there is no footage to promise).
20399
+ *
20400
+ * This is not a thumbnail and not a second byte path: it is the argument to
20401
+ * the recorder's existing still route. The surface — never the provider —
20402
+ * decides whether to use it. It is the midpoint of the visit's LONGEST
20403
+ * contiguous range, not of the visit: a visit spans its holes by
20404
+ * construction, so a naive midpoint lands in dead air.
20405
+ */
20406
+ stillAtMs: number().optional(),
20407
+ /**
20408
+ * Analytics event ids that overlap this visit — a BOUNDED sample, newest
20409
+ * first within kind (object → motion → audio), capped at
20410
+ * {@link MAX_CLIP_EVENT_IDS}. Empty on footage-only clips.
20411
+ *
20412
+ * Bounded because it is not a payload the surface pages through: one visit on
20413
+ * device 615 carried 2 345 ids, and `eventIds` was 99% of a 153 KB
20414
+ * camera-day. Read {@link eventCount} for the true total.
20415
+ */
20416
+ eventIds: array(string()).optional(),
20417
+ /** How many analytics events actually overlap this visit. Differs from
20418
+ * `eventIds.length` exactly when the sample was capped — so a truncated
20419
+ * list is never mistaken for a quiet visit. */
20420
+ eventCount: number().int().nonnegative().optional(),
20421
+ /** Intra-visit footage holes (GOP rolls, discarded segments) still shorter
20422
+ * than `VISIT_MERGE_GAP_MS`. Playback concatenates around them; the timeline
20423
+ * bar keeps showing them via `recording.getAvailability`. */
20424
+ holes: array(object({
20425
+ startMs: number(),
20426
+ endMs: number()
20427
+ })).optional()
20320
20428
  });
20321
20429
  var ClipPlaybackSchema = object({
20322
20430
  /** HLS master URL through the hub data-plane (Range + token in path). */
@@ -20780,7 +20888,14 @@ var SearchResultSchema = object({
20780
20888
  });
20781
20889
  var AutoUpdateSettingsSchema = object({
20782
20890
  channel: ChannelSchema,
20783
- intervalSeconds: number()
20891
+ intervalSeconds: number(),
20892
+ /**
20893
+ * Cadence of the "an update exists" POLLER, in seconds. Independent of
20894
+ * `channel`: the poller runs while auto-apply is `off`, because being told
20895
+ * about a publish and installing it are different decisions. Clamped
20896
+ * server-side to 900 s … 604800 s; defaults to 21600 s (6 h).
20897
+ */
20898
+ updateCheckIntervalSeconds: number()
20784
20899
  });
20785
20900
  var AddonAutoUpdateSchema = ChannelWithInheritSchema;
20786
20901
  var RestartAddonResultSchema = unknown();
@@ -20921,7 +21036,9 @@ method(_void(), array(AddonListItemSchema).readonly()), method(object({
20921
21036
  auth: "admin"
20922
21037
  }), method(_void(), AutoUpdateSettingsSchema, { auth: "admin" }), method(object({
20923
21038
  channel: ChannelSchema,
20924
- intervalSeconds: number().min(300).max(86400).optional()
21039
+ intervalSeconds: number().min(300).max(86400).optional(),
21040
+ /** Availability-poll cadence; see AutoUpdateSettingsSchema. */
21041
+ updateCheckIntervalSeconds: number().min(900).max(604800).optional()
20925
21042
  }), unknown(), {
20926
21043
  kind: "mutation",
20927
21044
  auth: "admin"
@@ -21891,10 +22008,18 @@ settings: record(string(), unknown()) });
21891
22008
  * descriptive — it never changes routing.
21892
22009
  */
21893
22010
  var ConnectionTestDescriptorSchema = object({ label: string() });
21894
- method(ConnectionTestInputSchema, ConnectionTestOutcomeSchema, {
21895
- kind: "mutation",
21896
- auth: "admin"
21897
- }), method(_void(), ConnectionTestDescriptorSchema, { auth: "admin" });
22011
+ var connectionTestCapability = {
22012
+ name: "connection-test",
22013
+ scope: "system",
22014
+ mode: "collection",
22015
+ methods: {
22016
+ testSettings: method(ConnectionTestInputSchema, ConnectionTestOutcomeSchema, {
22017
+ kind: "mutation",
22018
+ auth: "admin"
22019
+ }),
22020
+ describeTest: method(_void(), ConnectionTestDescriptorSchema, { auth: "admin" })
22021
+ }
22022
+ };
21898
22023
  /**
21899
22024
  * Upstream-system connectivity sensor — distinct from `device-status`,
21900
22025
  * which is the kernel-managed online/offline flag for the device's
@@ -26602,7 +26727,9 @@ var ExportOptionsSchema = object({
26602
26727
  includeAudio: boolean(),
26603
26728
  maxLifeMs: number().int().positive(),
26604
26729
  deleteAfterDownload: boolean(),
26605
- title: string().max(200).optional()
26730
+ title: string().max(200).optional(),
26731
+ /** Notification-output target ids to ping when this export becomes ready. */
26732
+ notifyTargetIds: array(string().min(1)).max(20).optional()
26606
26733
  }).superRefine((v, ctx) => {
26607
26734
  if (v.speed !== void 0 && v.timelapse !== void 0) ctx.addIssue({
26608
26735
  code: ZodIssueCode.custom,
@@ -26661,10 +26788,18 @@ var ExportBytesSchema = object({
26661
26788
  });
26662
26789
  method(object({
26663
26790
  deviceId: number(),
26664
- profile: string(),
26791
+ /** @deprecated Prefer `profiles`. Kept so timelapse/notifiers keep working. */
26792
+ profile: string().optional(),
26793
+ profiles: array(string()).min(1).optional(),
26665
26794
  fromMs: number(),
26666
26795
  toMs: number(),
26667
26796
  options: ExportOptionsSchema
26797
+ }).superRefine((v, ctx) => {
26798
+ if ((v.profiles !== void 0 && v.profiles.length > 0 ? v.profiles : v.profile !== void 0 ? [v.profile] : []).length < 1) ctx.addIssue({
26799
+ code: ZodIssueCode.custom,
26800
+ message: "pass profiles[] (min 1) or legacy profile",
26801
+ path: ["profiles"]
26802
+ });
26668
26803
  }), ExportRecordSchema, {
26669
26804
  kind: "mutation",
26670
26805
  auth: "protected"
@@ -29606,15 +29741,6 @@ var BaseDeviceProvider = class extends BaseAddon {
29606
29741
  labels: ["probe not implemented"]
29607
29742
  };
29608
29743
  }
29609
- /**
29610
- * Top-level devices restored at once in {@link onRestoreDevices}.
29611
- *
29612
- * Four covers the fleets this ships to without turning a boot into a burst a
29613
- * camera NVR answers with a refusal. A provider whose upstream is a single
29614
- * session with a serial command channel (a Baichuan hub, an NVR that
29615
- * serialises ISAPI) should lower it; nothing needs to raise it.
29616
- */
29617
- restoreConcurrency = 4;
29618
29744
  async restoreDevices(savedDevices) {
29619
29745
  await this.onRestoreDevices(savedDevices);
29620
29746
  if (savedDevices.length > 0) this.ctx.logger.info(`Restored ${savedDevices.length} ${this.providerName} device(s)`);
@@ -29669,14 +29795,7 @@ var BaseDeviceProvider = class extends BaseAddon {
29669
29795
  });
29670
29796
  }
29671
29797
  };
29672
- let nextTopLevel = 0;
29673
- await Promise.all(Array.from({ length: Math.min(Math.max(1, this.restoreConcurrency), topLevel.length) }, async () => {
29674
- for (;;) {
29675
- const saved = topLevel[nextTopLevel++];
29676
- if (saved === void 0) return;
29677
- await restoreOne(saved);
29678
- }
29679
- }));
29798
+ await Promise.all(topLevel.map((saved) => restoreOne(saved)));
29680
29799
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
29681
29800
  for (const saved of childRows) {
29682
29801
  const Class = this.deviceClasses[saved.type];
@@ -32949,6 +33068,12 @@ Object.freeze({
32949
33068
  addonId: null,
32950
33069
  access: "create"
32951
33070
  },
33071
+ "pipelineAnalytics.reconcileFromDisk": {
33072
+ capName: "pipeline-analytics",
33073
+ capScope: "device",
33074
+ addonId: null,
33075
+ access: "create"
33076
+ },
32952
33077
  "pipelineAnalytics.refreshStorageLocationsForMigration": {
32953
33078
  capName: "pipeline-analytics",
32954
33079
  capScope: "device",
@@ -33351,6 +33476,12 @@ Object.freeze({
33351
33476
  addonId: null,
33352
33477
  access: "view"
33353
33478
  },
33479
+ "pipelineOrchestrator.getReconcileFromDiskStatus": {
33480
+ capName: "pipeline-orchestrator",
33481
+ capScope: "system",
33482
+ addonId: null,
33483
+ access: "view"
33484
+ },
33354
33485
  "pipelineOrchestrator.listAgentSettings": {
33355
33486
  capName: "pipeline-orchestrator",
33356
33487
  capScope: "system",
@@ -33375,6 +33506,12 @@ Object.freeze({
33375
33506
  addonId: null,
33376
33507
  access: "create"
33377
33508
  },
33509
+ "pipelineOrchestrator.reconcileFromDisk": {
33510
+ capName: "pipeline-orchestrator",
33511
+ capScope: "system",
33512
+ addonId: null,
33513
+ access: "create"
33514
+ },
33378
33515
  "pipelineOrchestrator.removeAgentSettings": {
33379
33516
  capName: "pipeline-orchestrator",
33380
33517
  capScope: "system",
@@ -36366,6 +36503,11 @@ Object.freeze({
36366
36503
  form: "single",
36367
36504
  optional: true
36368
36505
  }],
36506
+ "pipelineAnalytics.reconcileFromDisk": [{
36507
+ name: "deviceId",
36508
+ form: "single",
36509
+ optional: false
36510
+ }],
36369
36511
  "pipelineAnalytics.restageRetrainTrack": [{
36370
36512
  name: "deviceId",
36371
36513
  form: "single",
@@ -37431,6 +37573,8 @@ DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
37431
37573
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
37432
37574
  DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
37433
37575
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
37576
+ var MB = 1024 * 1024;
37577
+ 1024 * MB, 3072 * MB;
37434
37578
  //#endregion
37435
37579
  //#region ../../node_modules/@apocaliss92/wyze-bridge-js/dist/index.js
37436
37580
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
@@ -40631,7 +40775,8 @@ var WyzeClientRegistry = class {
40631
40775
  credentials,
40632
40776
  cameraListCache: [],
40633
40777
  cameraListFetchedAt: 0,
40634
- cameraListInFlight: null
40778
+ cameraListInFlight: null,
40779
+ lastFetchError: null
40635
40780
  });
40636
40781
  }
40637
40782
  /** Drop the client for an integration that no longer exists / was disabled. */
@@ -40659,6 +40804,14 @@ var WyzeClientRegistry = class {
40659
40804
  this.#entries.clear();
40660
40805
  }
40661
40806
  /**
40807
+ * The last classified error from a `getCameraList` fetch failure for an
40808
+ * integration, or null when the last fetch succeeded (or no fetch has run
40809
+ * yet). Used by `getStatus` to surface the reason for an empty adoption list.
40810
+ */
40811
+ getLastFetchError(integrationId) {
40812
+ return this.#entries.get(integrationId)?.lastFetchError ?? null;
40813
+ }
40814
+ /**
40662
40815
  * Cloud camera list for ONE integration, cached + debounced + single-flight
40663
40816
  * to avoid auth rate-limits. Returns the last cache (possibly empty) when the
40664
40817
  * integration is unknown or the fetch fails.
@@ -40672,9 +40825,11 @@ var WyzeClientRegistry = class {
40672
40825
  const run = entry.client.getCameraList().then((cams) => {
40673
40826
  entry.cameraListCache = cams;
40674
40827
  entry.cameraListFetchedAt = Date.now();
40828
+ entry.lastFetchError = null;
40675
40829
  return cams;
40676
40830
  }).catch((err) => {
40677
40831
  const classified = classifyCloudError(err);
40832
+ entry.lastFetchError = classified;
40678
40833
  this.#deps.logger.error("Wyze getCameraList failed", { meta: {
40679
40834
  integrationId,
40680
40835
  kind: classified.kind,
@@ -41170,11 +41325,16 @@ function buildWyzeAdoptionProvider(deps) {
41170
41325
  let candidateCount = 0;
41171
41326
  for (const integrationId of listIntegrations()) candidateCount += (await candidatesForIntegration(integrationId)).length;
41172
41327
  const adoptedCount = (await listAdopted()).length;
41328
+ const fetchErrors = [];
41329
+ if (deps.getLastFetchError) for (const integrationId of listIntegrations()) {
41330
+ const err = deps.getLastFetchError(integrationId);
41331
+ if (err) fetchErrors.push(`[${integrationId}] ${err.message}`);
41332
+ }
41173
41333
  return {
41174
41334
  lastDiscoveryAt: Date.now(),
41175
41335
  candidateCount,
41176
41336
  adoptedCount,
41177
- lastError: null
41337
+ lastError: fetchErrors.length > 0 ? fetchErrors.join("; ") : null
41178
41338
  };
41179
41339
  } catch (err) {
41180
41340
  logger.warn("wyze adoption: getStatus failed", { meta: { error: errMsg(err) } });
@@ -41189,11 +41349,12 @@ function buildWyzeAdoptionProvider(deps) {
41189
41349
  refresh: async ({ integrationId }) => {
41190
41350
  const candidateCount = (await candidatesForIntegration(integrationId, true)).length;
41191
41351
  const adoptedCount = adoptedMapForIntegration(integrationId, await listAdopted()).size;
41352
+ const fetchErr = deps.getLastFetchError?.(integrationId);
41192
41353
  return {
41193
41354
  lastDiscoveryAt: Date.now(),
41194
41355
  candidateCount,
41195
41356
  adoptedCount,
41196
- lastError: null
41357
+ lastError: fetchErr ? fetchErr.message : null
41197
41358
  };
41198
41359
  },
41199
41360
  adopt: async ({ integrationId, childNativeIds, perCandidate }) => {
@@ -41925,6 +42086,139 @@ var WyzeCamera = class extends BaseDevice {
41925
42086
  static fromCloud = cameraConfigFromCloud;
41926
42087
  };
41927
42088
  //#endregion
42089
+ //#region src/wyze-connection-test.ts
42090
+ /**
42091
+ * Production default: creates a `WyzeCloud` with no-op session hooks so
42092
+ * `testSettings` never writes or reads `wyze-session.json`.
42093
+ */
42094
+ function defaultWyzeCloudFacadeFactory(credentials) {
42095
+ const cloud = new WyzeCloud({
42096
+ apiKey: credentials.apiKey,
42097
+ apiId: credentials.apiId,
42098
+ loadSession: () => null,
42099
+ saveSession: () => void 0,
42100
+ clearSession: () => void 0
42101
+ });
42102
+ return {
42103
+ ensureSession: (email, password) => cloud.ensureSession(email, password),
42104
+ getCameraList: () => cloud.getCameraList()
42105
+ };
42106
+ }
42107
+ var wyzeCredentialsSchema = object({
42108
+ email: string().min(1).describe("Wyze account email"),
42109
+ password: string().min(1).describe("Wyze account password"),
42110
+ apiKey: string().min(1).describe("Wyze developer API key"),
42111
+ apiId: string().min(1).describe("Wyze developer Key ID")
42112
+ });
42113
+ var TEST_LABEL = "Signs in to the Wyze cloud with these account credentials";
42114
+ function buildWyzeConnectionTestProvider(deps) {
42115
+ const { makeCloud, logger } = deps;
42116
+ return {
42117
+ describeTest: async () => ({ label: TEST_LABEL }),
42118
+ testSettings: async ({ settings }) => {
42119
+ const parsed = wyzeCredentialsSchema.safeParse(settings);
42120
+ if (!parsed.success) {
42121
+ const missing = parsed.error.issues.map((i) => i.path.join(".") || "(root)").join(", ");
42122
+ logger.warn("Wyze connection test: settings incomplete", { meta: { missing } });
42123
+ return {
42124
+ outcome: "rejected",
42125
+ error: `Wyze account settings are incomplete or invalid: ${missing}`
42126
+ };
42127
+ }
42128
+ const { email, password, apiKey, apiId } = parsed.data;
42129
+ const startedAt = Date.now();
42130
+ const cloud = makeCloud({
42131
+ email,
42132
+ password,
42133
+ apiKey,
42134
+ apiId
42135
+ });
42136
+ try {
42137
+ await cloud.ensureSession(email, password);
42138
+ let cameraCount = null;
42139
+ try {
42140
+ cameraCount = (await cloud.getCameraList()).length;
42141
+ } catch {}
42142
+ return {
42143
+ outcome: "validated",
42144
+ latencyMs: Date.now() - startedAt,
42145
+ ...cameraCount !== null ? { detail: `Found ${cameraCount} camera${cameraCount === 1 ? "" : "s"} on this account` } : {}
42146
+ };
42147
+ } catch (err) {
42148
+ const classified = classifyCloudError(err);
42149
+ if (classified.kind === "mfa") {
42150
+ logger.warn("Wyze connection test: MFA required", { meta: { email } });
42151
+ return {
42152
+ outcome: "rejected",
42153
+ error: classified.message
42154
+ };
42155
+ }
42156
+ if (classified.kind === "credentials") {
42157
+ logger.warn("Wyze connection test: credentials refused", { meta: { email } });
42158
+ return {
42159
+ outcome: "rejected",
42160
+ error: "Wyze refused these credentials — check the email, password, API Key and Key ID. " + classified.message
42161
+ };
42162
+ }
42163
+ logger.warn("Wyze connection test: could not complete", { meta: {
42164
+ email,
42165
+ kind: classified.kind,
42166
+ error: errMsg(err)
42167
+ } });
42168
+ return {
42169
+ outcome: "inconclusive",
42170
+ error: classified.kind === "rate-limited" ? `Could not verify credentials — rate-limited by the Wyze cloud. Retry in ~30 s. ${classified.message}` : `Could not reach the Wyze cloud to verify these credentials: ${errMsg(err)}`
42171
+ };
42172
+ }
42173
+ }
42174
+ };
42175
+ }
42176
+ //#endregion
42177
+ //#region src/wyze-tls-trust.ts
42178
+ /**
42179
+ * Ubuntu 24.04's `ca-certificates` (2026-06) dropped DigiCert Global Root CA
42180
+ * (the 2006 SHA-1-era root, still valid until 2031). Wyze's `*.wyzecam.com`
42181
+ * leaf is issued by "DigiCert TLS RSA SHA256 2020 CA1", which chains to that
42182
+ * root. Node fetch then fails with `UNABLE_TO_GET_ISSUER_CERT_LOCALLY` and
42183
+ * the adoption panel shows an empty camera list.
42184
+ *
42185
+ * macOS still trusts this root in the system keychain, which is why the same
42186
+ * URL verifies on the developer Mac and fails inside the hub container.
42187
+ *
42188
+ * The PEM is DigiCert's public root (https://cacerts.digicert.com/DigiCertGlobalRootCA.crt.pem).
42189
+ * Applied once per addon process via `tls.setDefaultCACertificates` — does
42190
+ * NOT disable verification, it only restores the missing root.
42191
+ */
42192
+ var DIGICERT_GLOBAL_ROOT_CA_PEM = `-----BEGIN CERTIFICATE-----
42193
+ MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh
42194
+ MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
42195
+ d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD
42196
+ QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT
42197
+ MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j
42198
+ b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG
42199
+ 9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB
42200
+ CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97
42201
+ nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt
42202
+ 43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P
42203
+ T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4
42204
+ gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO
42205
+ BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR
42206
+ TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw
42207
+ DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr
42208
+ hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg
42209
+ 06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF
42210
+ PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls
42211
+ YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk
42212
+ CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
42213
+ -----END CERTIFICATE-----
42214
+ `;
42215
+ var applied = false;
42216
+ function applyWyzeCloudTlsTrust() {
42217
+ if (applied) return;
42218
+ applied = true;
42219
+ (0, node_tls.setDefaultCACertificates)([...(0, node_tls.getCACertificates)(), DIGICERT_GLOBAL_ROOT_CA_PEM]);
42220
+ }
42221
+ //#endregion
41928
42222
  //#region src/addon.ts
41929
42223
  function getString(obj, key) {
41930
42224
  const v = obj[key];
@@ -41971,6 +42265,7 @@ var WyzeProviderAddon = class extends BaseDeviceProvider {
41971
42265
  super({});
41972
42266
  }
41973
42267
  async onInitialize() {
42268
+ applyWyzeCloudTlsTrust();
41974
42269
  const regs = await super.onInitialize();
41975
42270
  this.clients = new WyzeClientRegistry({
41976
42271
  dataDir: this.ctx.dataDir,
@@ -41992,10 +42287,17 @@ var WyzeProviderAddon = class extends BaseDeviceProvider {
41992
42287
  });
41993
42288
  await this.reconcileIntegrations();
41994
42289
  this.subscribeIntegrationLifecycle();
41995
- return [...regs, {
41996
- capability: deviceAdoptionCapability,
41997
- provider: this.buildAdoptionProvider()
41998
- }];
42290
+ return [
42291
+ ...regs,
42292
+ {
42293
+ capability: deviceAdoptionCapability,
42294
+ provider: this.buildAdoptionProvider()
42295
+ },
42296
+ {
42297
+ capability: connectionTestCapability,
42298
+ provider: this.buildConnectionTestProvider()
42299
+ }
42300
+ ];
41999
42301
  }
42000
42302
  async onShutdown() {
42001
42303
  this.clients?.clear();
@@ -42058,10 +42360,22 @@ var WyzeProviderAddon = class extends BaseDeviceProvider {
42058
42360
  this.wireCameraDeps(dev);
42059
42361
  await dev.materializeStreamSocket(camStreamId);
42060
42362
  }
42363
+ /**
42364
+ * Pre-creation credential check. Registered unconditionally — it must answer
42365
+ * BEFORE any integration for this addon exists, so it depends on nothing in
42366
+ * {@link WyzeClientRegistry} and opens its own throwaway session (no disk I/O).
42367
+ */
42368
+ buildConnectionTestProvider() {
42369
+ return buildWyzeConnectionTestProvider({
42370
+ makeCloud: defaultWyzeCloudFacadeFactory,
42371
+ logger: this.ctx.logger
42372
+ });
42373
+ }
42061
42374
  buildAdoptionProvider() {
42062
42375
  return buildWyzeAdoptionProvider({
42063
42376
  logger: this.ctx.logger,
42064
42377
  getCameraList: (integrationId, force) => this.requireClients().getCameraList(integrationId, force),
42378
+ getLastFetchError: (integrationId) => this.requireClients().getLastFetchError(integrationId),
42065
42379
  hasIntegration: (integrationId) => this.requireClients().has(integrationId),
42066
42380
  listIntegrations: () => this.requireClients().list(),
42067
42381
  listAdopted: async () => {