@camstack/addon-pipeline-orchestrator 1.1.50 → 1.1.52

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/index.js CHANGED
@@ -29,7 +29,7 @@ node_fs = __toESM(node_fs);
29
29
  let node_path = require("node:path");
30
30
  node_path = __toESM(node_path);
31
31
  let node_url = require("node:url");
32
- //#region ../types/dist/event-category-H4AVePnn.mjs
32
+ //#region ../types/dist/event-category-D4HJq7Mw.mjs
33
33
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
34
34
  EventCategory["SystemBoot"] = "system.boot";
35
35
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -182,6 +182,11 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
182
182
  /** Runner-sampled scrub thumbnail (~1/5 s/camera). Telemetry (D8): a lost
183
183
  * thumb is a scrub gap the recorder's keyframe backfill covers. */
184
184
  EventCategory["RecordingThumbSampled"] = "recording.thumb-sampled";
185
+ /** Export render progress (0–100). Telemetry (D8): a lost tick is a stale
186
+ * progress bar the client reconciles via `recordingExport.getExport`. */
187
+ EventCategory["RecordingExportProgress"] = "recording.export.progress";
188
+ EventCategory["RecordingExportCompleted"] = "recording.export.completed";
189
+ EventCategory["RecordingExportFailed"] = "recording.export.failed";
185
190
  EventCategory["DetectionEvent"] = "detection.event";
186
191
  EventCategory["SessionTrackNew"] = "session.track.new";
187
192
  EventCategory["SessionTrackExpired"] = "session.track.expired";
@@ -471,6 +476,25 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
471
476
  */
472
477
  EventCategory["PipelineAnalyticsStationaryChanged"] = "pipeline-analytics.stationary-changed";
473
478
  /**
479
+ * Fired by `addon-post-analysis` when a package-drop is confirmed inside
480
+ * a package zone — a newly-appeared stationary object of a package class
481
+ * that cleared the class / zone / dwell / size gates. Payload:
482
+ * `PipelineAnalyticsPackageDeliveredPayload` carrying `{ deviceId,
483
+ * entryId, className, zoneIds, keyFrameMediaKey?, bbox, timestamp }`.
484
+ * Telemetry (D8): the durable record is the `package-events` store row;
485
+ * this bus topic drives notifier rules + live UI. See
486
+ * docs/superpowers/specs/2026-07-17-package-zones-design.md §5.1.
487
+ */
488
+ EventCategory["PipelineAnalyticsPackageDelivered"] = "pipeline-analytics.package-delivered";
489
+ /**
490
+ * Fired by `addon-post-analysis` when a previously-delivered package
491
+ * leaves its zone (the stationary entry departed — moved or swept).
492
+ * Payload: `PipelineAnalyticsPackagePickedUpPayload` carrying
493
+ * `{ deviceId, entryId, deliveredEventId, className, timestamp }`.
494
+ * Telemetry (D8). See package-zones-design §5.2.
495
+ */
496
+ EventCategory["PipelineAnalyticsPackagePickedUp"] = "pipeline-analytics.package-picked-up";
497
+ /**
474
498
  * Fired by `addon-post-analysis` whenever a gallery face row changes:
475
499
  * `kind:'buffered'` a new detected face was persisted, `'assigned'` /
476
500
  * `'unassigned'` its identity link changed, `'deleted'` the row was
@@ -5209,6 +5233,25 @@ function _instanceof(cls, params = {}) {
5209
5233
  };
5210
5234
  return inst;
5211
5235
  }
5236
+ //#endregion
5237
+ //#region ../../node_modules/zod/v4/classic/compat.js
5238
+ /** @deprecated Use the raw string literal codes instead, e.g. "invalid_type". */
5239
+ var ZodIssueCode = {
5240
+ invalid_type: "invalid_type",
5241
+ too_big: "too_big",
5242
+ too_small: "too_small",
5243
+ invalid_format: "invalid_format",
5244
+ not_multiple_of: "not_multiple_of",
5245
+ unrecognized_keys: "unrecognized_keys",
5246
+ invalid_union: "invalid_union",
5247
+ invalid_key: "invalid_key",
5248
+ invalid_element: "invalid_element",
5249
+ invalid_value: "invalid_value",
5250
+ custom: "custom"
5251
+ };
5252
+ /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5253
+ var ZodFirstPartyTypeKind;
5254
+ ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5212
5255
  Object.fromEntries([
5213
5256
  {
5214
5257
  id: "overview",
@@ -7794,6 +7837,62 @@ var RecordingConfigSchema = object({
7794
7837
  scrubThumbnails: ScrubThumbnailPresetSchema.optional()
7795
7838
  });
7796
7839
  /**
7840
+ * Ops-log — the durable, append-only operations audit shared by the
7841
+ * recordings and events management surfaces.
7842
+ *
7843
+ * ONE row shape is reused for both domains so a single "Activity" view can
7844
+ * merge the recorder's DurableState ring (recordings ops-log) and the
7845
+ * pipeline-analytics SQLite collection (events ops-log). Each row records a
7846
+ * management operation, WHY it ran (reason), and its measurable effect
7847
+ * (itemsAffected + bytesReclaimed). Writes are best-effort — a failed log must
7848
+ * never fail the operation it records.
7849
+ */
7850
+ /** Which management domain the operation belongs to. */
7851
+ var OpsLogDomainSchema = _enum(["recording", "events"]);
7852
+ /** The kind of management operation performed. */
7853
+ var OpsLogOpSchema = _enum([
7854
+ "prune",
7855
+ "manual-delete",
7856
+ "rescan",
7857
+ "retention-run"
7858
+ ]);
7859
+ /** Why the operation ran. */
7860
+ var OpsLogReasonSchema = _enum([
7861
+ "retention",
7862
+ "quota",
7863
+ "manual",
7864
+ "operator"
7865
+ ]);
7866
+ /** One audit row, shared verbatim by both domains. */
7867
+ var OpsLogEntrySchema = object({
7868
+ /** Unique row id. */
7869
+ id: string(),
7870
+ /** Epoch ms the operation completed. */
7871
+ at: number(),
7872
+ domain: OpsLogDomainSchema,
7873
+ op: OpsLogOpSchema,
7874
+ reason: OpsLogReasonSchema,
7875
+ /** The camera the op targeted; null for a cluster/global op. */
7876
+ deviceId: number().nullable(),
7877
+ /** Node that performed the op (the log carries nodeId — no cross-node aggregation). */
7878
+ nodeId: string(),
7879
+ /** Buckets / rows deleted (op-specific unit). */
7880
+ itemsAffected: number(),
7881
+ /** Bytes reclaimed by the op (0 when not measurable). */
7882
+ bytesReclaimed: number(),
7883
+ /** Free-text detail (e.g. "floor moved to <ts>"); null when none. */
7884
+ detail: string().nullable(),
7885
+ /** Who/what triggered the op. */
7886
+ actor: string()
7887
+ });
7888
+ /** Shared query input for the per-domain `listOpsLog` cap methods. */
7889
+ var OpsLogQueryInputSchema = object({
7890
+ /** Restrict to a single camera; omit for every row. */
7891
+ deviceId: number().optional(),
7892
+ /** Max rows returned, newest-first. */
7893
+ limit: number().int().min(1).max(1e3).optional()
7894
+ });
7895
+ /**
7797
7896
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
7798
7897
  * storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
7799
7898
  * so the persisted record schema and the consumer-facing cap can both consume it
@@ -13424,7 +13523,11 @@ array(ZoneRuleSchema).readonly();
13424
13523
  * Extend the enum here when a new gating consumer comes online (audio
13425
13524
  * gating, alert filtering, …) — no other surface needs to change.
13426
13525
  */
13427
- var ZoneRuleStageEnum = _enum(["motion", "detection"]);
13526
+ var ZoneRuleStageEnum = _enum([
13527
+ "motion",
13528
+ "detection",
13529
+ "package"
13530
+ ]);
13428
13531
  /**
13429
13532
  * Zone rules capability — per-camera CRUD over the {@link ZoneRule}
13430
13533
  * arrays that decide how each pipeline stage uses the polygon zones.
@@ -13468,16 +13571,25 @@ var zoneRulesCapability = {
13468
13571
  })
13469
13572
  },
13470
13573
  /**
13471
- * Runtime-state slice — both stages mirrored together so consumers
13574
+ * Runtime-state slice — every stage mirrored together so consumers
13472
13575
  * see one reactive handle (`device.state.zoneRules.value`) instead
13473
- * of two. Bulk-replace mutations on either stage write the full
13474
- * `{motion, detection}` shape, so subscribers always get the
13576
+ * of one per stage. Bulk-replace mutations on any stage write the full
13577
+ * `{motion, detection, package}` shape, so subscribers always get the
13475
13578
  * complete current set. Consumers that only care about one stage
13476
13579
  * just read the matching property.
13580
+ *
13581
+ * `package` backs the package-drop detector — a package zone is a
13582
+ * `ZoneRule` on the `'package'` stage referencing drawn polygons
13583
+ * (see docs/superpowers/specs/2026-07-17-package-zones-design.md §3.1).
13584
+ * The orchestrator provider writes this stage as a first-class slice
13585
+ * (Phase 4): every mutation mirrors the full `{motion, detection,
13586
+ * package}` shape, so consumers read the current package rules directly
13587
+ * off `device.state.zoneRules.value.package`.
13477
13588
  */
13478
13589
  runtimeState: object({
13479
13590
  motion: array(ZoneRuleSchema).readonly(),
13480
- detection: array(ZoneRuleSchema).readonly()
13591
+ detection: array(ZoneRuleSchema).readonly(),
13592
+ package: array(ZoneRuleSchema).readonly()
13481
13593
  })
13482
13594
  };
13483
13595
  var ProviderStatusSchema = object({
@@ -16726,6 +16838,7 @@ var EventKindIconSchema = _enum([
16726
16838
  "smoke",
16727
16839
  "water",
16728
16840
  "button",
16841
+ "package",
16729
16842
  "generic"
16730
16843
  ]);
16731
16844
  var EventKindCategorySchema = _enum([
@@ -16733,7 +16846,8 @@ var EventKindCategorySchema = _enum([
16733
16846
  "audio",
16734
16847
  "detection",
16735
16848
  "sensor",
16736
- "custom"
16849
+ "custom",
16850
+ "package"
16737
16851
  ]);
16738
16852
  var EventKindDescriptorSchema = object({
16739
16853
  /** Stable kind id (e.g. 'motion', 'person', 'contact'). */
@@ -17074,6 +17188,26 @@ var TrackCascadeCountsSchema = object({
17074
17188
  /** Per-track CLIP search vectors removed (best-effort). */
17075
17189
  embeddings: number().int()
17076
17190
  });
17191
+ /** Event-store footprint for one camera. */
17192
+ var EventStoreDeviceFootprintSchema = object({
17193
+ deviceId: number(),
17194
+ /** Persisted event rows (motion + object + audio) for the camera. */
17195
+ rows: number().int(),
17196
+ /** Event-owned media bytes on disk for the camera. */
17197
+ bytes: number().int()
17198
+ });
17199
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
17200
+ var EventStoreFootprintSchema = object({
17201
+ totalRows: number().int(),
17202
+ totalBytes: number().int(),
17203
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
17204
+ });
17205
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
17206
+ var EventPruneCountsSchema = object({
17207
+ motion: number().int(),
17208
+ object: number().int(),
17209
+ audio: number().int()
17210
+ });
17077
17211
  DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
17078
17212
  deviceId: number(),
17079
17213
  trackId: string()
@@ -17137,6 +17271,21 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17137
17271
  }), {
17138
17272
  kind: "mutation",
17139
17273
  auth: "admin"
17274
+ }), method(object({}), EventStoreFootprintSchema, {
17275
+ kind: "query",
17276
+ auth: "admin"
17277
+ }), method(object({
17278
+ olderThanMs: number(),
17279
+ reason: OpsLogReasonSchema.optional()
17280
+ }), EventPruneCountsSchema, {
17281
+ kind: "mutation",
17282
+ auth: "admin"
17283
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
17284
+ kind: "mutation",
17285
+ auth: "admin"
17286
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
17287
+ kind: "query",
17288
+ auth: "admin"
17140
17289
  }), method(object({
17141
17290
  eventId: string(),
17142
17291
  kind: MediaFileKindEnum.optional()
@@ -20581,13 +20730,131 @@ method(object({
20581
20730
  }), method(object({ deviceId: number() }), RecordingStatusSchema, {
20582
20731
  kind: "mutation",
20583
20732
  auth: "admin"
20584
- }), method(object({ deviceId: number() }), object({
20733
+ }), method(object({
20734
+ deviceId: number(),
20735
+ reason: OpsLogReasonSchema.optional()
20736
+ }), object({
20585
20737
  floorMs: number().nullable(),
20586
20738
  deletedBuckets: number().int(),
20587
20739
  reclaimedBytes: number().int()
20588
20740
  }), {
20589
20741
  kind: "mutation",
20590
20742
  auth: "admin"
20743
+ }), method(object({
20744
+ deviceId: number(),
20745
+ fromMs: number().optional(),
20746
+ toMs: number().optional()
20747
+ }), object({
20748
+ deletedBuckets: number().int(),
20749
+ reclaimedBytes: number().int()
20750
+ }), {
20751
+ kind: "mutation",
20752
+ auth: "admin"
20753
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
20754
+ kind: "query",
20755
+ auth: "admin"
20756
+ });
20757
+ /**
20758
+ * `recordingExport` cap — render a footage time range into a single downloadable
20759
+ * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
20760
+ * bounded lifetime with a durable history, auto-expiry, and optional
20761
+ * delete-after-download.
20762
+ *
20763
+ * Like `recording` this is a `scope:'system', mode:'singleton'` cap: the
20764
+ * recorder self-gates so exactly ONE node (the designated `recordingNodeId`,
20765
+ * default `hub`) registers it. Device-scoped methods carry `deviceId` in their
20766
+ * input and dispatch to that single provider; the render runs on the node that
20767
+ * owns the footage (no cross-node segment transfer). Download rides the
20768
+ * framework addon data-plane. State persists in a DurableState blob (NOT
20769
+ * SQLite); history rows survive file deletion for audit.
20770
+ */
20771
+ /** Playback-speed multiplier for the render (1 = realtime). */
20772
+ var ExportSpeedSchema = number().min(.25).max(32);
20773
+ /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
20774
+ var ExportTimelapseSchema = object({
20775
+ everyMs: number().int().positive(),
20776
+ outputFps: number().int().min(1).max(60).optional()
20777
+ });
20778
+ /**
20779
+ * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
20780
+ * is honoured only for a realtime-ish speed (0.5–2×); timelapse is always
20781
+ * silent. `maxLifeMs` bounds how long the finished file is kept;
20782
+ * `deleteAfterDownload` removes it shortly after the first complete download.
20783
+ */
20784
+ var ExportOptionsSchema = object({
20785
+ speed: ExportSpeedSchema.optional(),
20786
+ timelapse: ExportTimelapseSchema.optional(),
20787
+ includeAudio: boolean(),
20788
+ maxLifeMs: number().int().positive(),
20789
+ deleteAfterDownload: boolean(),
20790
+ title: string().max(200).optional()
20791
+ }).superRefine((v, ctx) => {
20792
+ if (v.speed !== void 0 && v.timelapse !== void 0) ctx.addIssue({
20793
+ code: ZodIssueCode.custom,
20794
+ message: "speed and timelapse are mutually exclusive",
20795
+ path: ["timelapse"]
20796
+ });
20797
+ });
20798
+ var ExportStateSchema = _enum([
20799
+ "queued",
20800
+ "rendering",
20801
+ "ready",
20802
+ "failed",
20803
+ "expired",
20804
+ "deleted"
20805
+ ]);
20806
+ /** One export job / history row. */
20807
+ var ExportRecordSchema = object({
20808
+ id: string(),
20809
+ deviceId: number(),
20810
+ profile: string(),
20811
+ fromMs: number(),
20812
+ toMs: number(),
20813
+ options: ExportOptionsSchema,
20814
+ state: ExportStateSchema,
20815
+ /** 0–100 while rendering; null otherwise. */
20816
+ progressPct: number().nullable(),
20817
+ /** File size once ready; null before. */
20818
+ fileBytes: number().nullable(),
20819
+ expiresAt: number(),
20820
+ deleteAfterDownload: boolean(),
20821
+ /** Epoch of the first complete download; null until then. */
20822
+ downloadedAt: number().nullable(),
20823
+ createdAt: number(),
20824
+ /** User id/name that requested the export. */
20825
+ createdBy: string(),
20826
+ /** Failure reason when state is 'failed'; null otherwise. */
20827
+ error: string().nullable()
20828
+ });
20829
+ /** Candidate download URLs (LAN first, then operator extra hosts). */
20830
+ var ExportDownloadSchema = object({
20831
+ url: string(),
20832
+ endpoints: array(string())
20833
+ });
20834
+ method(object({
20835
+ deviceId: number(),
20836
+ profile: string(),
20837
+ fromMs: number(),
20838
+ toMs: number(),
20839
+ options: ExportOptionsSchema
20840
+ }), ExportRecordSchema, {
20841
+ kind: "mutation",
20842
+ auth: "protected"
20843
+ }), method(object({ deviceId: number().optional() }), array(ExportRecordSchema), {
20844
+ kind: "query",
20845
+ auth: "protected"
20846
+ }), method(object({ exportId: string() }), ExportRecordSchema, {
20847
+ kind: "query",
20848
+ auth: "protected"
20849
+ }), method(object({ exportId: string() }), ExportRecordSchema, {
20850
+ kind: "mutation",
20851
+ auth: "protected"
20852
+ }), method(object({ exportId: string() }), ExportRecordSchema, {
20853
+ kind: "mutation",
20854
+ auth: "protected"
20855
+ }), method(object({ exportId: string() }), ExportDownloadSchema, {
20856
+ kind: "query",
20857
+ auth: "protected"
20591
20858
  });
20592
20859
  /**
20593
20860
  * One publishable camera stream as its OWNING PROVIDER describes it — the same
@@ -23607,6 +23874,12 @@ Object.freeze({
23607
23874
  addonId: null,
23608
23875
  access: "delete"
23609
23876
  },
23877
+ "pipelineAnalytics.deleteDeviceEvents": {
23878
+ capName: "pipeline-analytics",
23879
+ capScope: "device",
23880
+ addonId: null,
23881
+ access: "delete"
23882
+ },
23610
23883
  "pipelineAnalytics.deleteTracks": {
23611
23884
  capName: "pipeline-analytics",
23612
23885
  capScope: "device",
@@ -23637,6 +23910,12 @@ Object.freeze({
23637
23910
  addonId: null,
23638
23911
  access: "view"
23639
23912
  },
23913
+ "pipelineAnalytics.getEventStoreFootprint": {
23914
+ capName: "pipeline-analytics",
23915
+ capScope: "device",
23916
+ addonId: null,
23917
+ access: "view"
23918
+ },
23640
23919
  "pipelineAnalytics.getKeyEvents": {
23641
23920
  capName: "pipeline-analytics",
23642
23921
  capScope: "device",
@@ -23679,6 +23958,12 @@ Object.freeze({
23679
23958
  addonId: null,
23680
23959
  access: "view"
23681
23960
  },
23961
+ "pipelineAnalytics.listOpsLog": {
23962
+ capName: "pipeline-analytics",
23963
+ capScope: "device",
23964
+ addonId: null,
23965
+ access: "view"
23966
+ },
23682
23967
  "pipelineAnalytics.listRecentTracks": {
23683
23968
  capName: "pipeline-analytics",
23684
23969
  capScope: "device",
@@ -23691,6 +23976,12 @@ Object.freeze({
23691
23976
  addonId: null,
23692
23977
  access: "view"
23693
23978
  },
23979
+ "pipelineAnalytics.pruneEvents": {
23980
+ capName: "pipeline-analytics",
23981
+ capScope: "device",
23982
+ addonId: null,
23983
+ access: "create"
23984
+ },
23694
23985
  "pipelineAnalytics.pruneEventsBefore": {
23695
23986
  capName: "pipeline-analytics",
23696
23987
  capScope: "device",
@@ -24453,6 +24744,12 @@ Object.freeze({
24453
24744
  addonId: null,
24454
24745
  access: "create"
24455
24746
  },
24747
+ "recording.deleteFootprint": {
24748
+ capName: "recording",
24749
+ capScope: "system",
24750
+ addonId: null,
24751
+ access: "delete"
24752
+ },
24456
24753
  "recording.getAvailability": {
24457
24754
  capName: "recording",
24458
24755
  capScope: "system",
@@ -24483,6 +24780,12 @@ Object.freeze({
24483
24780
  addonId: null,
24484
24781
  access: "view"
24485
24782
  },
24783
+ "recording.listOpsLog": {
24784
+ capName: "recording",
24785
+ capScope: "system",
24786
+ addonId: null,
24787
+ access: "view"
24788
+ },
24486
24789
  "recording.locateSegment": {
24487
24790
  capName: "recording",
24488
24791
  capScope: "system",
@@ -24513,6 +24816,42 @@ Object.freeze({
24513
24816
  addonId: null,
24514
24817
  access: "create"
24515
24818
  },
24819
+ "recordingExport.cancelExport": {
24820
+ capName: "recordingExport",
24821
+ capScope: "system",
24822
+ addonId: null,
24823
+ access: "create"
24824
+ },
24825
+ "recordingExport.createExport": {
24826
+ capName: "recordingExport",
24827
+ capScope: "system",
24828
+ addonId: null,
24829
+ access: "create"
24830
+ },
24831
+ "recordingExport.deleteExport": {
24832
+ capName: "recordingExport",
24833
+ capScope: "system",
24834
+ addonId: null,
24835
+ access: "delete"
24836
+ },
24837
+ "recordingExport.getDownloadUrl": {
24838
+ capName: "recordingExport",
24839
+ capScope: "system",
24840
+ addonId: null,
24841
+ access: "view"
24842
+ },
24843
+ "recordingExport.getExport": {
24844
+ capName: "recordingExport",
24845
+ capScope: "system",
24846
+ addonId: null,
24847
+ access: "view"
24848
+ },
24849
+ "recordingExport.listExports": {
24850
+ capName: "recordingExport",
24851
+ capScope: "system",
24852
+ addonId: null,
24853
+ access: "view"
24854
+ },
24516
24855
  "sceneMonitor.captureReference": {
24517
24856
  capName: "scene-monitor",
24518
24857
  capScope: "device",
@@ -32059,6 +32398,14 @@ var SessionDispatchController = class {
32059
32398
  * since rules drive runtime filtering and a bad payload would silently
32060
32399
  * widen the operator's intended scope.
32061
32400
  */
32401
+ /**
32402
+ * Every zone-rule stage, in the declared enum order. The unified device-state
32403
+ * mirror carries ONE key per stage so a single reactive handle
32404
+ * (`device.state.zoneRules.value`) covers every consumer. Derived from the cap
32405
+ * enum so a new stage (audio gating, alert filtering, …) is picked up here with
32406
+ * no edit — the mirror stays exhaustive over the widened discriminator.
32407
+ */
32408
+ var ALL_STAGES = ZoneRuleStageEnum.options;
32062
32409
  /** Settings store key for stage rules. Kept under a single nested
32063
32410
  * object so a future stage just adds another property without
32064
32411
  * reshuffling the schema. */
@@ -32080,7 +32427,8 @@ var RulesArraySchema = array(ZoneRuleSchema);
32080
32427
  */
32081
32428
  var ZoneRulesBlockSchema = object({
32082
32429
  motion: unknown().optional(),
32083
- detection: unknown().optional()
32430
+ detection: unknown().optional(),
32431
+ package: unknown().optional()
32084
32432
  }).passthrough();
32085
32433
  var ZoneRulesProvider = class {
32086
32434
  ctx;
@@ -32175,15 +32523,7 @@ var ZoneRulesProvider = class {
32175
32523
  ...prev,
32176
32524
  [stage]: rules
32177
32525
  }));
32178
- const otherStage = stage === "motion" ? "detection" : "motion";
32179
- const otherRules = perDevice.get(otherStage) ?? await this.loadRules(deviceId, otherStage);
32180
- const sliceValue = stage === "motion" ? {
32181
- motion: rules,
32182
- detection: otherRules
32183
- } : {
32184
- motion: otherRules,
32185
- detection: rules
32186
- };
32526
+ const sliceValue = await this.buildSliceValue(deviceId, perDevice);
32187
32527
  try {
32188
32528
  await (await this.ctx.fetchDevice(deviceId)).deviceState.setCapSlice({
32189
32529
  capName: ZONE_RULES_CAP_NAME,
@@ -32200,6 +32540,22 @@ var ZoneRulesProvider = class {
32200
32540
  }
32201
32541
  this.ctx.onRulesChanged?.(deviceId, stage, rules);
32202
32542
  }
32543
+ /**
32544
+ * Assemble the unified `{motion, detection, package}` mirror value from every
32545
+ * stage's current rules. The stage just written is already in `perDevice`;
32546
+ * siblings resolve from the cache when present, else a lazy store read (which
32547
+ * also warms the cache). Iterates {@link ALL_STAGES} so it stays exhaustive
32548
+ * over the cap's stage discriminator without a per-stage branch.
32549
+ */
32550
+ async buildSliceValue(deviceId, perDevice) {
32551
+ const slice = {
32552
+ motion: [],
32553
+ detection: [],
32554
+ package: []
32555
+ };
32556
+ for (const s of ALL_STAGES) slice[s] = perDevice.get(s) ?? await this.loadRules(deviceId, s);
32557
+ return slice;
32558
+ }
32203
32559
  };
32204
32560
  //#endregion
32205
32561
  //#region src/zones-provider.ts