@camstack/addon-provider-tuya 0.1.11 → 0.1.13

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.
package/dist/addon.js CHANGED
@@ -3,7 +3,7 @@ let crypto$1 = require("crypto");
3
3
  let net = require("net");
4
4
  let events = require("events");
5
5
  let dgram = require("dgram");
6
- //#region ../types/dist/event-category-H4AVePnn.mjs
6
+ //#region ../types/dist/event-category-D4HJq7Mw.mjs
7
7
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
8
8
  EventCategory["SystemBoot"] = "system.boot";
9
9
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -156,6 +156,11 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
156
156
  /** Runner-sampled scrub thumbnail (~1/5 s/camera). Telemetry (D8): a lost
157
157
  * thumb is a scrub gap the recorder's keyframe backfill covers. */
158
158
  EventCategory["RecordingThumbSampled"] = "recording.thumb-sampled";
159
+ /** Export render progress (0–100). Telemetry (D8): a lost tick is a stale
160
+ * progress bar the client reconciles via `recordingExport.getExport`. */
161
+ EventCategory["RecordingExportProgress"] = "recording.export.progress";
162
+ EventCategory["RecordingExportCompleted"] = "recording.export.completed";
163
+ EventCategory["RecordingExportFailed"] = "recording.export.failed";
159
164
  EventCategory["DetectionEvent"] = "detection.event";
160
165
  EventCategory["SessionTrackNew"] = "session.track.new";
161
166
  EventCategory["SessionTrackExpired"] = "session.track.expired";
@@ -445,6 +450,25 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
445
450
  */
446
451
  EventCategory["PipelineAnalyticsStationaryChanged"] = "pipeline-analytics.stationary-changed";
447
452
  /**
453
+ * Fired by `addon-post-analysis` when a package-drop is confirmed inside
454
+ * a package zone — a newly-appeared stationary object of a package class
455
+ * that cleared the class / zone / dwell / size gates. Payload:
456
+ * `PipelineAnalyticsPackageDeliveredPayload` carrying `{ deviceId,
457
+ * entryId, className, zoneIds, keyFrameMediaKey?, bbox, timestamp }`.
458
+ * Telemetry (D8): the durable record is the `package-events` store row;
459
+ * this bus topic drives notifier rules + live UI. See
460
+ * docs/superpowers/specs/2026-07-17-package-zones-design.md §5.1.
461
+ */
462
+ EventCategory["PipelineAnalyticsPackageDelivered"] = "pipeline-analytics.package-delivered";
463
+ /**
464
+ * Fired by `addon-post-analysis` when a previously-delivered package
465
+ * leaves its zone (the stationary entry departed — moved or swept).
466
+ * Payload: `PipelineAnalyticsPackagePickedUpPayload` carrying
467
+ * `{ deviceId, entryId, deliveredEventId, className, timestamp }`.
468
+ * Telemetry (D8). See package-zones-design §5.2.
469
+ */
470
+ EventCategory["PipelineAnalyticsPackagePickedUp"] = "pipeline-analytics.package-picked-up";
471
+ /**
448
472
  * Fired by `addon-post-analysis` whenever a gallery face row changes:
449
473
  * `kind:'buffered'` a new detected face was persisted, `'assigned'` /
450
474
  * `'unassigned'` its identity link changed, `'deleted'` the row was
@@ -5197,6 +5221,25 @@ function preprocess(fn, schema) {
5197
5221
  out: schema
5198
5222
  });
5199
5223
  }
5224
+ //#endregion
5225
+ //#region ../../node_modules/zod/v4/classic/compat.js
5226
+ /** @deprecated Use the raw string literal codes instead, e.g. "invalid_type". */
5227
+ var ZodIssueCode = {
5228
+ invalid_type: "invalid_type",
5229
+ too_big: "too_big",
5230
+ too_small: "too_small",
5231
+ invalid_format: "invalid_format",
5232
+ not_multiple_of: "not_multiple_of",
5233
+ unrecognized_keys: "unrecognized_keys",
5234
+ invalid_union: "invalid_union",
5235
+ invalid_key: "invalid_key",
5236
+ invalid_element: "invalid_element",
5237
+ invalid_value: "invalid_value",
5238
+ custom: "custom"
5239
+ };
5240
+ /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5241
+ var ZodFirstPartyTypeKind;
5242
+ ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5200
5243
  Object.fromEntries([
5201
5244
  {
5202
5245
  id: "overview",
@@ -7319,6 +7362,62 @@ var RecordingConfigSchema = object({
7319
7362
  scrubThumbnails: ScrubThumbnailPresetSchema.optional()
7320
7363
  });
7321
7364
  /**
7365
+ * Ops-log — the durable, append-only operations audit shared by the
7366
+ * recordings and events management surfaces.
7367
+ *
7368
+ * ONE row shape is reused for both domains so a single "Activity" view can
7369
+ * merge the recorder's DurableState ring (recordings ops-log) and the
7370
+ * pipeline-analytics SQLite collection (events ops-log). Each row records a
7371
+ * management operation, WHY it ran (reason), and its measurable effect
7372
+ * (itemsAffected + bytesReclaimed). Writes are best-effort — a failed log must
7373
+ * never fail the operation it records.
7374
+ */
7375
+ /** Which management domain the operation belongs to. */
7376
+ var OpsLogDomainSchema = _enum(["recording", "events"]);
7377
+ /** The kind of management operation performed. */
7378
+ var OpsLogOpSchema = _enum([
7379
+ "prune",
7380
+ "manual-delete",
7381
+ "rescan",
7382
+ "retention-run"
7383
+ ]);
7384
+ /** Why the operation ran. */
7385
+ var OpsLogReasonSchema = _enum([
7386
+ "retention",
7387
+ "quota",
7388
+ "manual",
7389
+ "operator"
7390
+ ]);
7391
+ /** One audit row, shared verbatim by both domains. */
7392
+ var OpsLogEntrySchema = object({
7393
+ /** Unique row id. */
7394
+ id: string(),
7395
+ /** Epoch ms the operation completed. */
7396
+ at: number(),
7397
+ domain: OpsLogDomainSchema,
7398
+ op: OpsLogOpSchema,
7399
+ reason: OpsLogReasonSchema,
7400
+ /** The camera the op targeted; null for a cluster/global op. */
7401
+ deviceId: number().nullable(),
7402
+ /** Node that performed the op (the log carries nodeId — no cross-node aggregation). */
7403
+ nodeId: string(),
7404
+ /** Buckets / rows deleted (op-specific unit). */
7405
+ itemsAffected: number(),
7406
+ /** Bytes reclaimed by the op (0 when not measurable). */
7407
+ bytesReclaimed: number(),
7408
+ /** Free-text detail (e.g. "floor moved to <ts>"); null when none. */
7409
+ detail: string().nullable(),
7410
+ /** Who/what triggered the op. */
7411
+ actor: string()
7412
+ });
7413
+ /** Shared query input for the per-domain `listOpsLog` cap methods. */
7414
+ var OpsLogQueryInputSchema = object({
7415
+ /** Restrict to a single camera; omit for every row. */
7416
+ deviceId: number().optional(),
7417
+ /** Max rows returned, newest-first. */
7418
+ limit: number().int().min(1).max(1e3).optional()
7419
+ });
7420
+ /**
7322
7421
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
7323
7422
  * storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
7324
7423
  * so the persisted record schema and the consumer-facing cap can both consume it
@@ -14674,7 +14773,11 @@ array(ZoneRuleSchema).readonly();
14674
14773
  * Extend the enum here when a new gating consumer comes online (audio
14675
14774
  * gating, alert filtering, …) — no other surface needs to change.
14676
14775
  */
14677
- var ZoneRuleStageEnum = _enum(["motion", "detection"]);
14776
+ var ZoneRuleStageEnum = _enum([
14777
+ "motion",
14778
+ "detection",
14779
+ "package"
14780
+ ]);
14678
14781
  /**
14679
14782
  * Runtime registry: cap-property-name → cap definition. `BaseDevice`'s
14680
14783
  * `state` getter looks up the cap definition here to construct a
@@ -14768,16 +14871,25 @@ var DEVICE_LOCAL_STATE_CAPS = {
14768
14871
  })
14769
14872
  },
14770
14873
  /**
14771
- * Runtime-state slice — both stages mirrored together so consumers
14874
+ * Runtime-state slice — every stage mirrored together so consumers
14772
14875
  * see one reactive handle (`device.state.zoneRules.value`) instead
14773
- * of two. Bulk-replace mutations on either stage write the full
14774
- * `{motion, detection}` shape, so subscribers always get the
14876
+ * of one per stage. Bulk-replace mutations on any stage write the full
14877
+ * `{motion, detection, package}` shape, so subscribers always get the
14775
14878
  * complete current set. Consumers that only care about one stage
14776
14879
  * just read the matching property.
14880
+ *
14881
+ * `package` backs the package-drop detector — a package zone is a
14882
+ * `ZoneRule` on the `'package'` stage referencing drawn polygons
14883
+ * (see docs/superpowers/specs/2026-07-17-package-zones-design.md §3.1).
14884
+ * The orchestrator provider writes this stage as a first-class slice
14885
+ * (Phase 4): every mutation mirrors the full `{motion, detection,
14886
+ * package}` shape, so consumers read the current package rules directly
14887
+ * off `device.state.zoneRules.value.package`.
14777
14888
  */
14778
14889
  runtimeState: object({
14779
14890
  motion: array(ZoneRuleSchema).readonly(),
14780
- detection: array(ZoneRuleSchema).readonly()
14891
+ detection: array(ZoneRuleSchema).readonly(),
14892
+ package: array(ZoneRuleSchema).readonly()
14781
14893
  })
14782
14894
  },
14783
14895
  zones: zonesCapability
@@ -18756,6 +18868,7 @@ var EventKindIconSchema = _enum([
18756
18868
  "smoke",
18757
18869
  "water",
18758
18870
  "button",
18871
+ "package",
18759
18872
  "generic"
18760
18873
  ]);
18761
18874
  var EventKindCategorySchema = _enum([
@@ -18763,7 +18876,8 @@ var EventKindCategorySchema = _enum([
18763
18876
  "audio",
18764
18877
  "detection",
18765
18878
  "sensor",
18766
- "custom"
18879
+ "custom",
18880
+ "package"
18767
18881
  ]);
18768
18882
  var EventKindDescriptorSchema = object({
18769
18883
  /** Stable kind id (e.g. 'motion', 'person', 'contact'). */
@@ -19104,6 +19218,26 @@ var TrackCascadeCountsSchema = object({
19104
19218
  /** Per-track CLIP search vectors removed (best-effort). */
19105
19219
  embeddings: number().int()
19106
19220
  });
19221
+ /** Event-store footprint for one camera. */
19222
+ var EventStoreDeviceFootprintSchema = object({
19223
+ deviceId: number(),
19224
+ /** Persisted event rows (motion + object + audio) for the camera. */
19225
+ rows: number().int(),
19226
+ /** Event-owned media bytes on disk for the camera. */
19227
+ bytes: number().int()
19228
+ });
19229
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
19230
+ var EventStoreFootprintSchema = object({
19231
+ totalRows: number().int(),
19232
+ totalBytes: number().int(),
19233
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
19234
+ });
19235
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
19236
+ var EventPruneCountsSchema = object({
19237
+ motion: number().int(),
19238
+ object: number().int(),
19239
+ audio: number().int()
19240
+ });
19107
19241
  DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
19108
19242
  deviceId: number(),
19109
19243
  trackId: string()
@@ -19167,6 +19301,21 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19167
19301
  }), {
19168
19302
  kind: "mutation",
19169
19303
  auth: "admin"
19304
+ }), method(object({}), EventStoreFootprintSchema, {
19305
+ kind: "query",
19306
+ auth: "admin"
19307
+ }), method(object({
19308
+ olderThanMs: number(),
19309
+ reason: OpsLogReasonSchema.optional()
19310
+ }), EventPruneCountsSchema, {
19311
+ kind: "mutation",
19312
+ auth: "admin"
19313
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
19314
+ kind: "mutation",
19315
+ auth: "admin"
19316
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
19317
+ kind: "query",
19318
+ auth: "admin"
19170
19319
  }), method(object({
19171
19320
  eventId: string(),
19172
19321
  kind: MediaFileKindEnum.optional()
@@ -22400,13 +22549,131 @@ method(object({
22400
22549
  }), method(object({ deviceId: number() }), RecordingStatusSchema, {
22401
22550
  kind: "mutation",
22402
22551
  auth: "admin"
22403
- }), method(object({ deviceId: number() }), object({
22552
+ }), method(object({
22553
+ deviceId: number(),
22554
+ reason: OpsLogReasonSchema.optional()
22555
+ }), object({
22404
22556
  floorMs: number().nullable(),
22405
22557
  deletedBuckets: number().int(),
22406
22558
  reclaimedBytes: number().int()
22407
22559
  }), {
22408
22560
  kind: "mutation",
22409
22561
  auth: "admin"
22562
+ }), method(object({
22563
+ deviceId: number(),
22564
+ fromMs: number().optional(),
22565
+ toMs: number().optional()
22566
+ }), object({
22567
+ deletedBuckets: number().int(),
22568
+ reclaimedBytes: number().int()
22569
+ }), {
22570
+ kind: "mutation",
22571
+ auth: "admin"
22572
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
22573
+ kind: "query",
22574
+ auth: "admin"
22575
+ });
22576
+ /**
22577
+ * `recordingExport` cap — render a footage time range into a single downloadable
22578
+ * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
22579
+ * bounded lifetime with a durable history, auto-expiry, and optional
22580
+ * delete-after-download.
22581
+ *
22582
+ * Like `recording` this is a `scope:'system', mode:'singleton'` cap: the
22583
+ * recorder self-gates so exactly ONE node (the designated `recordingNodeId`,
22584
+ * default `hub`) registers it. Device-scoped methods carry `deviceId` in their
22585
+ * input and dispatch to that single provider; the render runs on the node that
22586
+ * owns the footage (no cross-node segment transfer). Download rides the
22587
+ * framework addon data-plane. State persists in a DurableState blob (NOT
22588
+ * SQLite); history rows survive file deletion for audit.
22589
+ */
22590
+ /** Playback-speed multiplier for the render (1 = realtime). */
22591
+ var ExportSpeedSchema = number().min(.25).max(32);
22592
+ /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
22593
+ var ExportTimelapseSchema = object({
22594
+ everyMs: number().int().positive(),
22595
+ outputFps: number().int().min(1).max(60).optional()
22596
+ });
22597
+ /**
22598
+ * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
22599
+ * is honoured only for a realtime-ish speed (0.5–2×); timelapse is always
22600
+ * silent. `maxLifeMs` bounds how long the finished file is kept;
22601
+ * `deleteAfterDownload` removes it shortly after the first complete download.
22602
+ */
22603
+ var ExportOptionsSchema = object({
22604
+ speed: ExportSpeedSchema.optional(),
22605
+ timelapse: ExportTimelapseSchema.optional(),
22606
+ includeAudio: boolean(),
22607
+ maxLifeMs: number().int().positive(),
22608
+ deleteAfterDownload: boolean(),
22609
+ title: string().max(200).optional()
22610
+ }).superRefine((v, ctx) => {
22611
+ if (v.speed !== void 0 && v.timelapse !== void 0) ctx.addIssue({
22612
+ code: ZodIssueCode.custom,
22613
+ message: "speed and timelapse are mutually exclusive",
22614
+ path: ["timelapse"]
22615
+ });
22616
+ });
22617
+ var ExportStateSchema = _enum([
22618
+ "queued",
22619
+ "rendering",
22620
+ "ready",
22621
+ "failed",
22622
+ "expired",
22623
+ "deleted"
22624
+ ]);
22625
+ /** One export job / history row. */
22626
+ var ExportRecordSchema = object({
22627
+ id: string(),
22628
+ deviceId: number(),
22629
+ profile: string(),
22630
+ fromMs: number(),
22631
+ toMs: number(),
22632
+ options: ExportOptionsSchema,
22633
+ state: ExportStateSchema,
22634
+ /** 0–100 while rendering; null otherwise. */
22635
+ progressPct: number().nullable(),
22636
+ /** File size once ready; null before. */
22637
+ fileBytes: number().nullable(),
22638
+ expiresAt: number(),
22639
+ deleteAfterDownload: boolean(),
22640
+ /** Epoch of the first complete download; null until then. */
22641
+ downloadedAt: number().nullable(),
22642
+ createdAt: number(),
22643
+ /** User id/name that requested the export. */
22644
+ createdBy: string(),
22645
+ /** Failure reason when state is 'failed'; null otherwise. */
22646
+ error: string().nullable()
22647
+ });
22648
+ /** Candidate download URLs (LAN first, then operator extra hosts). */
22649
+ var ExportDownloadSchema = object({
22650
+ url: string(),
22651
+ endpoints: array(string())
22652
+ });
22653
+ method(object({
22654
+ deviceId: number(),
22655
+ profile: string(),
22656
+ fromMs: number(),
22657
+ toMs: number(),
22658
+ options: ExportOptionsSchema
22659
+ }), ExportRecordSchema, {
22660
+ kind: "mutation",
22661
+ auth: "protected"
22662
+ }), method(object({ deviceId: number().optional() }), array(ExportRecordSchema), {
22663
+ kind: "query",
22664
+ auth: "protected"
22665
+ }), method(object({ exportId: string() }), ExportRecordSchema, {
22666
+ kind: "query",
22667
+ auth: "protected"
22668
+ }), method(object({ exportId: string() }), ExportRecordSchema, {
22669
+ kind: "mutation",
22670
+ auth: "protected"
22671
+ }), method(object({ exportId: string() }), ExportRecordSchema, {
22672
+ kind: "mutation",
22673
+ auth: "protected"
22674
+ }), method(object({ exportId: string() }), ExportDownloadSchema, {
22675
+ kind: "query",
22676
+ auth: "protected"
22410
22677
  });
22411
22678
  /**
22412
22679
  * One publishable camera stream as its OWNING PROVIDER describes it — the same
@@ -25426,6 +25693,12 @@ Object.freeze({
25426
25693
  addonId: null,
25427
25694
  access: "delete"
25428
25695
  },
25696
+ "pipelineAnalytics.deleteDeviceEvents": {
25697
+ capName: "pipeline-analytics",
25698
+ capScope: "device",
25699
+ addonId: null,
25700
+ access: "delete"
25701
+ },
25429
25702
  "pipelineAnalytics.deleteTracks": {
25430
25703
  capName: "pipeline-analytics",
25431
25704
  capScope: "device",
@@ -25456,6 +25729,12 @@ Object.freeze({
25456
25729
  addonId: null,
25457
25730
  access: "view"
25458
25731
  },
25732
+ "pipelineAnalytics.getEventStoreFootprint": {
25733
+ capName: "pipeline-analytics",
25734
+ capScope: "device",
25735
+ addonId: null,
25736
+ access: "view"
25737
+ },
25459
25738
  "pipelineAnalytics.getKeyEvents": {
25460
25739
  capName: "pipeline-analytics",
25461
25740
  capScope: "device",
@@ -25498,6 +25777,12 @@ Object.freeze({
25498
25777
  addonId: null,
25499
25778
  access: "view"
25500
25779
  },
25780
+ "pipelineAnalytics.listOpsLog": {
25781
+ capName: "pipeline-analytics",
25782
+ capScope: "device",
25783
+ addonId: null,
25784
+ access: "view"
25785
+ },
25501
25786
  "pipelineAnalytics.listRecentTracks": {
25502
25787
  capName: "pipeline-analytics",
25503
25788
  capScope: "device",
@@ -25510,6 +25795,12 @@ Object.freeze({
25510
25795
  addonId: null,
25511
25796
  access: "view"
25512
25797
  },
25798
+ "pipelineAnalytics.pruneEvents": {
25799
+ capName: "pipeline-analytics",
25800
+ capScope: "device",
25801
+ addonId: null,
25802
+ access: "create"
25803
+ },
25513
25804
  "pipelineAnalytics.pruneEventsBefore": {
25514
25805
  capName: "pipeline-analytics",
25515
25806
  capScope: "device",
@@ -26272,6 +26563,12 @@ Object.freeze({
26272
26563
  addonId: null,
26273
26564
  access: "create"
26274
26565
  },
26566
+ "recording.deleteFootprint": {
26567
+ capName: "recording",
26568
+ capScope: "system",
26569
+ addonId: null,
26570
+ access: "delete"
26571
+ },
26275
26572
  "recording.getAvailability": {
26276
26573
  capName: "recording",
26277
26574
  capScope: "system",
@@ -26302,6 +26599,12 @@ Object.freeze({
26302
26599
  addonId: null,
26303
26600
  access: "view"
26304
26601
  },
26602
+ "recording.listOpsLog": {
26603
+ capName: "recording",
26604
+ capScope: "system",
26605
+ addonId: null,
26606
+ access: "view"
26607
+ },
26305
26608
  "recording.locateSegment": {
26306
26609
  capName: "recording",
26307
26610
  capScope: "system",
@@ -26332,6 +26635,42 @@ Object.freeze({
26332
26635
  addonId: null,
26333
26636
  access: "create"
26334
26637
  },
26638
+ "recordingExport.cancelExport": {
26639
+ capName: "recordingExport",
26640
+ capScope: "system",
26641
+ addonId: null,
26642
+ access: "create"
26643
+ },
26644
+ "recordingExport.createExport": {
26645
+ capName: "recordingExport",
26646
+ capScope: "system",
26647
+ addonId: null,
26648
+ access: "create"
26649
+ },
26650
+ "recordingExport.deleteExport": {
26651
+ capName: "recordingExport",
26652
+ capScope: "system",
26653
+ addonId: null,
26654
+ access: "delete"
26655
+ },
26656
+ "recordingExport.getDownloadUrl": {
26657
+ capName: "recordingExport",
26658
+ capScope: "system",
26659
+ addonId: null,
26660
+ access: "view"
26661
+ },
26662
+ "recordingExport.getExport": {
26663
+ capName: "recordingExport",
26664
+ capScope: "system",
26665
+ addonId: null,
26666
+ access: "view"
26667
+ },
26668
+ "recordingExport.listExports": {
26669
+ capName: "recordingExport",
26670
+ capScope: "system",
26671
+ addonId: null,
26672
+ access: "view"
26673
+ },
26335
26674
  "sceneMonitor.captureReference": {
26336
26675
  capName: "scene-monitor",
26337
26676
  capScope: "device",
package/dist/addon.mjs CHANGED
@@ -2,7 +2,7 @@ import { createCipheriv, createDecipheriv, createHash, createHmac } from "crypto
2
2
  import { Socket } from "net";
3
3
  import { EventEmitter } from "events";
4
4
  import { createSocket } from "dgram";
5
- //#region ../types/dist/event-category-H4AVePnn.mjs
5
+ //#region ../types/dist/event-category-D4HJq7Mw.mjs
6
6
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
7
7
  EventCategory["SystemBoot"] = "system.boot";
8
8
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -155,6 +155,11 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
155
155
  /** Runner-sampled scrub thumbnail (~1/5 s/camera). Telemetry (D8): a lost
156
156
  * thumb is a scrub gap the recorder's keyframe backfill covers. */
157
157
  EventCategory["RecordingThumbSampled"] = "recording.thumb-sampled";
158
+ /** Export render progress (0–100). Telemetry (D8): a lost tick is a stale
159
+ * progress bar the client reconciles via `recordingExport.getExport`. */
160
+ EventCategory["RecordingExportProgress"] = "recording.export.progress";
161
+ EventCategory["RecordingExportCompleted"] = "recording.export.completed";
162
+ EventCategory["RecordingExportFailed"] = "recording.export.failed";
158
163
  EventCategory["DetectionEvent"] = "detection.event";
159
164
  EventCategory["SessionTrackNew"] = "session.track.new";
160
165
  EventCategory["SessionTrackExpired"] = "session.track.expired";
@@ -444,6 +449,25 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
444
449
  */
445
450
  EventCategory["PipelineAnalyticsStationaryChanged"] = "pipeline-analytics.stationary-changed";
446
451
  /**
452
+ * Fired by `addon-post-analysis` when a package-drop is confirmed inside
453
+ * a package zone — a newly-appeared stationary object of a package class
454
+ * that cleared the class / zone / dwell / size gates. Payload:
455
+ * `PipelineAnalyticsPackageDeliveredPayload` carrying `{ deviceId,
456
+ * entryId, className, zoneIds, keyFrameMediaKey?, bbox, timestamp }`.
457
+ * Telemetry (D8): the durable record is the `package-events` store row;
458
+ * this bus topic drives notifier rules + live UI. See
459
+ * docs/superpowers/specs/2026-07-17-package-zones-design.md §5.1.
460
+ */
461
+ EventCategory["PipelineAnalyticsPackageDelivered"] = "pipeline-analytics.package-delivered";
462
+ /**
463
+ * Fired by `addon-post-analysis` when a previously-delivered package
464
+ * leaves its zone (the stationary entry departed — moved or swept).
465
+ * Payload: `PipelineAnalyticsPackagePickedUpPayload` carrying
466
+ * `{ deviceId, entryId, deliveredEventId, className, timestamp }`.
467
+ * Telemetry (D8). See package-zones-design §5.2.
468
+ */
469
+ EventCategory["PipelineAnalyticsPackagePickedUp"] = "pipeline-analytics.package-picked-up";
470
+ /**
447
471
  * Fired by `addon-post-analysis` whenever a gallery face row changes:
448
472
  * `kind:'buffered'` a new detected face was persisted, `'assigned'` /
449
473
  * `'unassigned'` its identity link changed, `'deleted'` the row was
@@ -5196,6 +5220,25 @@ function preprocess(fn, schema) {
5196
5220
  out: schema
5197
5221
  });
5198
5222
  }
5223
+ //#endregion
5224
+ //#region ../../node_modules/zod/v4/classic/compat.js
5225
+ /** @deprecated Use the raw string literal codes instead, e.g. "invalid_type". */
5226
+ var ZodIssueCode = {
5227
+ invalid_type: "invalid_type",
5228
+ too_big: "too_big",
5229
+ too_small: "too_small",
5230
+ invalid_format: "invalid_format",
5231
+ not_multiple_of: "not_multiple_of",
5232
+ unrecognized_keys: "unrecognized_keys",
5233
+ invalid_union: "invalid_union",
5234
+ invalid_key: "invalid_key",
5235
+ invalid_element: "invalid_element",
5236
+ invalid_value: "invalid_value",
5237
+ custom: "custom"
5238
+ };
5239
+ /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5240
+ var ZodFirstPartyTypeKind;
5241
+ ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5199
5242
  Object.fromEntries([
5200
5243
  {
5201
5244
  id: "overview",
@@ -7318,6 +7361,62 @@ var RecordingConfigSchema = object({
7318
7361
  scrubThumbnails: ScrubThumbnailPresetSchema.optional()
7319
7362
  });
7320
7363
  /**
7364
+ * Ops-log — the durable, append-only operations audit shared by the
7365
+ * recordings and events management surfaces.
7366
+ *
7367
+ * ONE row shape is reused for both domains so a single "Activity" view can
7368
+ * merge the recorder's DurableState ring (recordings ops-log) and the
7369
+ * pipeline-analytics SQLite collection (events ops-log). Each row records a
7370
+ * management operation, WHY it ran (reason), and its measurable effect
7371
+ * (itemsAffected + bytesReclaimed). Writes are best-effort — a failed log must
7372
+ * never fail the operation it records.
7373
+ */
7374
+ /** Which management domain the operation belongs to. */
7375
+ var OpsLogDomainSchema = _enum(["recording", "events"]);
7376
+ /** The kind of management operation performed. */
7377
+ var OpsLogOpSchema = _enum([
7378
+ "prune",
7379
+ "manual-delete",
7380
+ "rescan",
7381
+ "retention-run"
7382
+ ]);
7383
+ /** Why the operation ran. */
7384
+ var OpsLogReasonSchema = _enum([
7385
+ "retention",
7386
+ "quota",
7387
+ "manual",
7388
+ "operator"
7389
+ ]);
7390
+ /** One audit row, shared verbatim by both domains. */
7391
+ var OpsLogEntrySchema = object({
7392
+ /** Unique row id. */
7393
+ id: string(),
7394
+ /** Epoch ms the operation completed. */
7395
+ at: number(),
7396
+ domain: OpsLogDomainSchema,
7397
+ op: OpsLogOpSchema,
7398
+ reason: OpsLogReasonSchema,
7399
+ /** The camera the op targeted; null for a cluster/global op. */
7400
+ deviceId: number().nullable(),
7401
+ /** Node that performed the op (the log carries nodeId — no cross-node aggregation). */
7402
+ nodeId: string(),
7403
+ /** Buckets / rows deleted (op-specific unit). */
7404
+ itemsAffected: number(),
7405
+ /** Bytes reclaimed by the op (0 when not measurable). */
7406
+ bytesReclaimed: number(),
7407
+ /** Free-text detail (e.g. "floor moved to <ts>"); null when none. */
7408
+ detail: string().nullable(),
7409
+ /** Who/what triggered the op. */
7410
+ actor: string()
7411
+ });
7412
+ /** Shared query input for the per-domain `listOpsLog` cap methods. */
7413
+ var OpsLogQueryInputSchema = object({
7414
+ /** Restrict to a single camera; omit for every row. */
7415
+ deviceId: number().optional(),
7416
+ /** Max rows returned, newest-first. */
7417
+ limit: number().int().min(1).max(1e3).optional()
7418
+ });
7419
+ /**
7321
7420
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
7322
7421
  * storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
7323
7422
  * so the persisted record schema and the consumer-facing cap can both consume it
@@ -14673,7 +14772,11 @@ array(ZoneRuleSchema).readonly();
14673
14772
  * Extend the enum here when a new gating consumer comes online (audio
14674
14773
  * gating, alert filtering, …) — no other surface needs to change.
14675
14774
  */
14676
- var ZoneRuleStageEnum = _enum(["motion", "detection"]);
14775
+ var ZoneRuleStageEnum = _enum([
14776
+ "motion",
14777
+ "detection",
14778
+ "package"
14779
+ ]);
14677
14780
  /**
14678
14781
  * Runtime registry: cap-property-name → cap definition. `BaseDevice`'s
14679
14782
  * `state` getter looks up the cap definition here to construct a
@@ -14767,16 +14870,25 @@ var DEVICE_LOCAL_STATE_CAPS = {
14767
14870
  })
14768
14871
  },
14769
14872
  /**
14770
- * Runtime-state slice — both stages mirrored together so consumers
14873
+ * Runtime-state slice — every stage mirrored together so consumers
14771
14874
  * see one reactive handle (`device.state.zoneRules.value`) instead
14772
- * of two. Bulk-replace mutations on either stage write the full
14773
- * `{motion, detection}` shape, so subscribers always get the
14875
+ * of one per stage. Bulk-replace mutations on any stage write the full
14876
+ * `{motion, detection, package}` shape, so subscribers always get the
14774
14877
  * complete current set. Consumers that only care about one stage
14775
14878
  * just read the matching property.
14879
+ *
14880
+ * `package` backs the package-drop detector — a package zone is a
14881
+ * `ZoneRule` on the `'package'` stage referencing drawn polygons
14882
+ * (see docs/superpowers/specs/2026-07-17-package-zones-design.md §3.1).
14883
+ * The orchestrator provider writes this stage as a first-class slice
14884
+ * (Phase 4): every mutation mirrors the full `{motion, detection,
14885
+ * package}` shape, so consumers read the current package rules directly
14886
+ * off `device.state.zoneRules.value.package`.
14776
14887
  */
14777
14888
  runtimeState: object({
14778
14889
  motion: array(ZoneRuleSchema).readonly(),
14779
- detection: array(ZoneRuleSchema).readonly()
14890
+ detection: array(ZoneRuleSchema).readonly(),
14891
+ package: array(ZoneRuleSchema).readonly()
14780
14892
  })
14781
14893
  },
14782
14894
  zones: zonesCapability
@@ -18755,6 +18867,7 @@ var EventKindIconSchema = _enum([
18755
18867
  "smoke",
18756
18868
  "water",
18757
18869
  "button",
18870
+ "package",
18758
18871
  "generic"
18759
18872
  ]);
18760
18873
  var EventKindCategorySchema = _enum([
@@ -18762,7 +18875,8 @@ var EventKindCategorySchema = _enum([
18762
18875
  "audio",
18763
18876
  "detection",
18764
18877
  "sensor",
18765
- "custom"
18878
+ "custom",
18879
+ "package"
18766
18880
  ]);
18767
18881
  var EventKindDescriptorSchema = object({
18768
18882
  /** Stable kind id (e.g. 'motion', 'person', 'contact'). */
@@ -19103,6 +19217,26 @@ var TrackCascadeCountsSchema = object({
19103
19217
  /** Per-track CLIP search vectors removed (best-effort). */
19104
19218
  embeddings: number().int()
19105
19219
  });
19220
+ /** Event-store footprint for one camera. */
19221
+ var EventStoreDeviceFootprintSchema = object({
19222
+ deviceId: number(),
19223
+ /** Persisted event rows (motion + object + audio) for the camera. */
19224
+ rows: number().int(),
19225
+ /** Event-owned media bytes on disk for the camera. */
19226
+ bytes: number().int()
19227
+ });
19228
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
19229
+ var EventStoreFootprintSchema = object({
19230
+ totalRows: number().int(),
19231
+ totalBytes: number().int(),
19232
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
19233
+ });
19234
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
19235
+ var EventPruneCountsSchema = object({
19236
+ motion: number().int(),
19237
+ object: number().int(),
19238
+ audio: number().int()
19239
+ });
19106
19240
  DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
19107
19241
  deviceId: number(),
19108
19242
  trackId: string()
@@ -19166,6 +19300,21 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19166
19300
  }), {
19167
19301
  kind: "mutation",
19168
19302
  auth: "admin"
19303
+ }), method(object({}), EventStoreFootprintSchema, {
19304
+ kind: "query",
19305
+ auth: "admin"
19306
+ }), method(object({
19307
+ olderThanMs: number(),
19308
+ reason: OpsLogReasonSchema.optional()
19309
+ }), EventPruneCountsSchema, {
19310
+ kind: "mutation",
19311
+ auth: "admin"
19312
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
19313
+ kind: "mutation",
19314
+ auth: "admin"
19315
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
19316
+ kind: "query",
19317
+ auth: "admin"
19169
19318
  }), method(object({
19170
19319
  eventId: string(),
19171
19320
  kind: MediaFileKindEnum.optional()
@@ -22399,13 +22548,131 @@ method(object({
22399
22548
  }), method(object({ deviceId: number() }), RecordingStatusSchema, {
22400
22549
  kind: "mutation",
22401
22550
  auth: "admin"
22402
- }), method(object({ deviceId: number() }), object({
22551
+ }), method(object({
22552
+ deviceId: number(),
22553
+ reason: OpsLogReasonSchema.optional()
22554
+ }), object({
22403
22555
  floorMs: number().nullable(),
22404
22556
  deletedBuckets: number().int(),
22405
22557
  reclaimedBytes: number().int()
22406
22558
  }), {
22407
22559
  kind: "mutation",
22408
22560
  auth: "admin"
22561
+ }), method(object({
22562
+ deviceId: number(),
22563
+ fromMs: number().optional(),
22564
+ toMs: number().optional()
22565
+ }), object({
22566
+ deletedBuckets: number().int(),
22567
+ reclaimedBytes: number().int()
22568
+ }), {
22569
+ kind: "mutation",
22570
+ auth: "admin"
22571
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
22572
+ kind: "query",
22573
+ auth: "admin"
22574
+ });
22575
+ /**
22576
+ * `recordingExport` cap — render a footage time range into a single downloadable
22577
+ * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
22578
+ * bounded lifetime with a durable history, auto-expiry, and optional
22579
+ * delete-after-download.
22580
+ *
22581
+ * Like `recording` this is a `scope:'system', mode:'singleton'` cap: the
22582
+ * recorder self-gates so exactly ONE node (the designated `recordingNodeId`,
22583
+ * default `hub`) registers it. Device-scoped methods carry `deviceId` in their
22584
+ * input and dispatch to that single provider; the render runs on the node that
22585
+ * owns the footage (no cross-node segment transfer). Download rides the
22586
+ * framework addon data-plane. State persists in a DurableState blob (NOT
22587
+ * SQLite); history rows survive file deletion for audit.
22588
+ */
22589
+ /** Playback-speed multiplier for the render (1 = realtime). */
22590
+ var ExportSpeedSchema = number().min(.25).max(32);
22591
+ /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
22592
+ var ExportTimelapseSchema = object({
22593
+ everyMs: number().int().positive(),
22594
+ outputFps: number().int().min(1).max(60).optional()
22595
+ });
22596
+ /**
22597
+ * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
22598
+ * is honoured only for a realtime-ish speed (0.5–2×); timelapse is always
22599
+ * silent. `maxLifeMs` bounds how long the finished file is kept;
22600
+ * `deleteAfterDownload` removes it shortly after the first complete download.
22601
+ */
22602
+ var ExportOptionsSchema = object({
22603
+ speed: ExportSpeedSchema.optional(),
22604
+ timelapse: ExportTimelapseSchema.optional(),
22605
+ includeAudio: boolean(),
22606
+ maxLifeMs: number().int().positive(),
22607
+ deleteAfterDownload: boolean(),
22608
+ title: string().max(200).optional()
22609
+ }).superRefine((v, ctx) => {
22610
+ if (v.speed !== void 0 && v.timelapse !== void 0) ctx.addIssue({
22611
+ code: ZodIssueCode.custom,
22612
+ message: "speed and timelapse are mutually exclusive",
22613
+ path: ["timelapse"]
22614
+ });
22615
+ });
22616
+ var ExportStateSchema = _enum([
22617
+ "queued",
22618
+ "rendering",
22619
+ "ready",
22620
+ "failed",
22621
+ "expired",
22622
+ "deleted"
22623
+ ]);
22624
+ /** One export job / history row. */
22625
+ var ExportRecordSchema = object({
22626
+ id: string(),
22627
+ deviceId: number(),
22628
+ profile: string(),
22629
+ fromMs: number(),
22630
+ toMs: number(),
22631
+ options: ExportOptionsSchema,
22632
+ state: ExportStateSchema,
22633
+ /** 0–100 while rendering; null otherwise. */
22634
+ progressPct: number().nullable(),
22635
+ /** File size once ready; null before. */
22636
+ fileBytes: number().nullable(),
22637
+ expiresAt: number(),
22638
+ deleteAfterDownload: boolean(),
22639
+ /** Epoch of the first complete download; null until then. */
22640
+ downloadedAt: number().nullable(),
22641
+ createdAt: number(),
22642
+ /** User id/name that requested the export. */
22643
+ createdBy: string(),
22644
+ /** Failure reason when state is 'failed'; null otherwise. */
22645
+ error: string().nullable()
22646
+ });
22647
+ /** Candidate download URLs (LAN first, then operator extra hosts). */
22648
+ var ExportDownloadSchema = object({
22649
+ url: string(),
22650
+ endpoints: array(string())
22651
+ });
22652
+ method(object({
22653
+ deviceId: number(),
22654
+ profile: string(),
22655
+ fromMs: number(),
22656
+ toMs: number(),
22657
+ options: ExportOptionsSchema
22658
+ }), ExportRecordSchema, {
22659
+ kind: "mutation",
22660
+ auth: "protected"
22661
+ }), method(object({ deviceId: number().optional() }), array(ExportRecordSchema), {
22662
+ kind: "query",
22663
+ auth: "protected"
22664
+ }), method(object({ exportId: string() }), ExportRecordSchema, {
22665
+ kind: "query",
22666
+ auth: "protected"
22667
+ }), method(object({ exportId: string() }), ExportRecordSchema, {
22668
+ kind: "mutation",
22669
+ auth: "protected"
22670
+ }), method(object({ exportId: string() }), ExportRecordSchema, {
22671
+ kind: "mutation",
22672
+ auth: "protected"
22673
+ }), method(object({ exportId: string() }), ExportDownloadSchema, {
22674
+ kind: "query",
22675
+ auth: "protected"
22409
22676
  });
22410
22677
  /**
22411
22678
  * One publishable camera stream as its OWNING PROVIDER describes it — the same
@@ -25425,6 +25692,12 @@ Object.freeze({
25425
25692
  addonId: null,
25426
25693
  access: "delete"
25427
25694
  },
25695
+ "pipelineAnalytics.deleteDeviceEvents": {
25696
+ capName: "pipeline-analytics",
25697
+ capScope: "device",
25698
+ addonId: null,
25699
+ access: "delete"
25700
+ },
25428
25701
  "pipelineAnalytics.deleteTracks": {
25429
25702
  capName: "pipeline-analytics",
25430
25703
  capScope: "device",
@@ -25455,6 +25728,12 @@ Object.freeze({
25455
25728
  addonId: null,
25456
25729
  access: "view"
25457
25730
  },
25731
+ "pipelineAnalytics.getEventStoreFootprint": {
25732
+ capName: "pipeline-analytics",
25733
+ capScope: "device",
25734
+ addonId: null,
25735
+ access: "view"
25736
+ },
25458
25737
  "pipelineAnalytics.getKeyEvents": {
25459
25738
  capName: "pipeline-analytics",
25460
25739
  capScope: "device",
@@ -25497,6 +25776,12 @@ Object.freeze({
25497
25776
  addonId: null,
25498
25777
  access: "view"
25499
25778
  },
25779
+ "pipelineAnalytics.listOpsLog": {
25780
+ capName: "pipeline-analytics",
25781
+ capScope: "device",
25782
+ addonId: null,
25783
+ access: "view"
25784
+ },
25500
25785
  "pipelineAnalytics.listRecentTracks": {
25501
25786
  capName: "pipeline-analytics",
25502
25787
  capScope: "device",
@@ -25509,6 +25794,12 @@ Object.freeze({
25509
25794
  addonId: null,
25510
25795
  access: "view"
25511
25796
  },
25797
+ "pipelineAnalytics.pruneEvents": {
25798
+ capName: "pipeline-analytics",
25799
+ capScope: "device",
25800
+ addonId: null,
25801
+ access: "create"
25802
+ },
25512
25803
  "pipelineAnalytics.pruneEventsBefore": {
25513
25804
  capName: "pipeline-analytics",
25514
25805
  capScope: "device",
@@ -26271,6 +26562,12 @@ Object.freeze({
26271
26562
  addonId: null,
26272
26563
  access: "create"
26273
26564
  },
26565
+ "recording.deleteFootprint": {
26566
+ capName: "recording",
26567
+ capScope: "system",
26568
+ addonId: null,
26569
+ access: "delete"
26570
+ },
26274
26571
  "recording.getAvailability": {
26275
26572
  capName: "recording",
26276
26573
  capScope: "system",
@@ -26301,6 +26598,12 @@ Object.freeze({
26301
26598
  addonId: null,
26302
26599
  access: "view"
26303
26600
  },
26601
+ "recording.listOpsLog": {
26602
+ capName: "recording",
26603
+ capScope: "system",
26604
+ addonId: null,
26605
+ access: "view"
26606
+ },
26304
26607
  "recording.locateSegment": {
26305
26608
  capName: "recording",
26306
26609
  capScope: "system",
@@ -26331,6 +26634,42 @@ Object.freeze({
26331
26634
  addonId: null,
26332
26635
  access: "create"
26333
26636
  },
26637
+ "recordingExport.cancelExport": {
26638
+ capName: "recordingExport",
26639
+ capScope: "system",
26640
+ addonId: null,
26641
+ access: "create"
26642
+ },
26643
+ "recordingExport.createExport": {
26644
+ capName: "recordingExport",
26645
+ capScope: "system",
26646
+ addonId: null,
26647
+ access: "create"
26648
+ },
26649
+ "recordingExport.deleteExport": {
26650
+ capName: "recordingExport",
26651
+ capScope: "system",
26652
+ addonId: null,
26653
+ access: "delete"
26654
+ },
26655
+ "recordingExport.getDownloadUrl": {
26656
+ capName: "recordingExport",
26657
+ capScope: "system",
26658
+ addonId: null,
26659
+ access: "view"
26660
+ },
26661
+ "recordingExport.getExport": {
26662
+ capName: "recordingExport",
26663
+ capScope: "system",
26664
+ addonId: null,
26665
+ access: "view"
26666
+ },
26667
+ "recordingExport.listExports": {
26668
+ capName: "recordingExport",
26669
+ capScope: "system",
26670
+ addonId: null,
26671
+ access: "view"
26672
+ },
26334
26673
  "sceneMonitor.captureReference": {
26335
26674
  capName: "scene-monitor",
26336
26675
  capScope: "device",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-tuya",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
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",