@camstack/types 1.1.49 → 1.1.51

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
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_sleep = require("./sleep-BfvNtyu8.js");
2
+ const require_sleep = require("./sleep-CF-UWPp0.js");
3
3
  const require_event_category = require("./event-category-CGj9fI4L.js");
4
4
  const require_enums = require("./enums.js");
5
5
  const require_err_msg = require("./err-msg-COpsHMw2.js");
@@ -1048,6 +1048,71 @@ function migrateConfigToBands(config) {
1048
1048
  return schedules.map((schedule) => bandFromSchedule(schedule, bandMode, config));
1049
1049
  }
1050
1050
  //#endregion
1051
+ //#region src/interfaces/ops-log.ts
1052
+ /**
1053
+ * Ops-log — the durable, append-only operations audit shared by the
1054
+ * recordings and events management surfaces.
1055
+ *
1056
+ * ONE row shape is reused for both domains so a single "Activity" view can
1057
+ * merge the recorder's DurableState ring (recordings ops-log) and the
1058
+ * pipeline-analytics SQLite collection (events ops-log). Each row records a
1059
+ * management operation, WHY it ran (reason), and its measurable effect
1060
+ * (itemsAffected + bytesReclaimed). Writes are best-effort — a failed log must
1061
+ * never fail the operation it records.
1062
+ */
1063
+ /** Which management domain the operation belongs to. */
1064
+ var OpsLogDomainSchema = zod.z.enum(["recording", "events"]);
1065
+ /** The kind of management operation performed. */
1066
+ var OpsLogOpSchema = zod.z.enum([
1067
+ "prune",
1068
+ "manual-delete",
1069
+ "rescan",
1070
+ "retention-run"
1071
+ ]);
1072
+ /** Why the operation ran. */
1073
+ var OpsLogReasonSchema = zod.z.enum([
1074
+ "retention",
1075
+ "quota",
1076
+ "manual",
1077
+ "operator"
1078
+ ]);
1079
+ /** One audit row, shared verbatim by both domains. */
1080
+ var OpsLogEntrySchema = zod.z.object({
1081
+ /** Unique row id. */
1082
+ id: zod.z.string(),
1083
+ /** Epoch ms the operation completed. */
1084
+ at: zod.z.number(),
1085
+ domain: OpsLogDomainSchema,
1086
+ op: OpsLogOpSchema,
1087
+ reason: OpsLogReasonSchema,
1088
+ /** The camera the op targeted; null for a cluster/global op. */
1089
+ deviceId: zod.z.number().nullable(),
1090
+ /** Node that performed the op (the log carries nodeId — no cross-node aggregation). */
1091
+ nodeId: zod.z.string(),
1092
+ /** Buckets / rows deleted (op-specific unit). */
1093
+ itemsAffected: zod.z.number(),
1094
+ /** Bytes reclaimed by the op (0 when not measurable). */
1095
+ bytesReclaimed: zod.z.number(),
1096
+ /** Free-text detail (e.g. "floor moved to <ts>"); null when none. */
1097
+ detail: zod.z.string().nullable(),
1098
+ /** Who/what triggered the op. */
1099
+ actor: zod.z.string()
1100
+ });
1101
+ /** Shared query input for the per-domain `listOpsLog` cap methods. */
1102
+ var OpsLogQueryInputSchema = zod.z.object({
1103
+ /** Restrict to a single camera; omit for every row. */
1104
+ deviceId: zod.z.number().optional(),
1105
+ /** Max rows returned, newest-first. */
1106
+ limit: zod.z.number().int().min(1).max(1e3).optional()
1107
+ });
1108
+ /**
1109
+ * Default cap on the recorder's DurableState ops-log ring — the newest N rows
1110
+ * survive; older ones are evicted on append.
1111
+ */
1112
+ var OPS_LOG_RING_DEFAULT_MAX = 500;
1113
+ /** Default page size for a `listOpsLog` query when the caller omits `limit`. */
1114
+ var OPS_LOG_DEFAULT_LIMIT = 200;
1115
+ //#endregion
1051
1116
  //#region src/interfaces/storage-location.ts
1052
1117
  /**
1053
1118
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
@@ -2707,6 +2772,143 @@ function getAudioMacroClassIds() {
2707
2772
  return AUDIO_MACRO_LABELS.map((l) => l.id);
2708
2773
  }
2709
2774
  //#endregion
2775
+ //#region src/catalogs/event-taxonomy.ts
2776
+ /**
2777
+ * Unified event-kind taxonomy — THE single source of truth for
2778
+ * `kind → { parentKind, category, level, color, iconId, labelKey, label,
2779
+ * icon }`.
2780
+ *
2781
+ * This dictionary folds together what used to be scattered across four
2782
+ * copies:
2783
+ * - `capabilities/sensor-event-kinds.ts` (sensor cap colors)
2784
+ * - `addon-post-analysis/.../services/event-kinds.ts`
2785
+ * (MOTION/PERSON/VEHICLE… _COLOR constants)
2786
+ * - `ui-library/composites/detection-colors.ts` (CLASS_COLORS)
2787
+ * - `addon-post-analysis/shared/frame/box-drawer.ts` (DEFAULT_COLOR)
2788
+ * - the COCO / audio class maps (macro ↔ sub relationships)
2789
+ *
2790
+ * The DATA (serializable — color/iconId/labelKey/parentKind) lives here in
2791
+ * `@camstack/types`. The UI-side mapping `iconId → lucide component` and
2792
+ * `labelKey → t()` lives in `@camstack/ui-library`. UIs never hardcode a
2793
+ * color or an icon: they read this dictionary (server descriptors carry the
2794
+ * fields inline; the client resolves color/icon/label from `iconId`/`kind`).
2795
+ *
2796
+ * Two levels only (v1 YAGNI): macro → sub. `person` is a leaf macro.
2797
+ */
2798
+ var TAXONOMY_COLORS = {
2799
+ motion: "#f59e0b",
2800
+ audio: "#06b6d4",
2801
+ person: "#22c55e",
2802
+ vehicle: "#3b82f6",
2803
+ animal: "#f97316",
2804
+ package: "#a855f7",
2805
+ sensor: "#8b5cf6",
2806
+ control: "#10b981",
2807
+ genericDetection: "#64748b"
2808
+ };
2809
+ /** Global default color when a kind is unknown (matches legacy box-drawer). */
2810
+ var DEFAULT_EVENT_COLOR = "#22ff55";
2811
+ var DETECTION_SUB_COLORS = {
2812
+ car: "#f59e0b",
2813
+ truck: "#d97706",
2814
+ bus: "#b45309",
2815
+ motorcycle: "#eab308",
2816
+ bicycle: "#ca8a04",
2817
+ airplane: "#60a5fa",
2818
+ boat: "#2563eb",
2819
+ train: "#1d4ed8",
2820
+ bird: "#14b8a6",
2821
+ dog: "#84cc16",
2822
+ cat: "#f97316",
2823
+ horse: "#a16207",
2824
+ sheep: "#a3a3a3",
2825
+ cow: "#78716c",
2826
+ elephant: "#6b7280",
2827
+ bear: "#7c2d12",
2828
+ zebra: "#404040",
2829
+ giraffe: "#d4a373"
2830
+ };
2831
+ function titleCase(id) {
2832
+ return id.split(/[-_ ]/).filter((p) => p.length > 0).map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join(" ");
2833
+ }
2834
+ var entries = /* @__PURE__ */ new Map();
2835
+ function macro(kind, category, color, iconId, label) {
2836
+ entries.set(kind, {
2837
+ kind,
2838
+ parentKind: null,
2839
+ level: "macro",
2840
+ category,
2841
+ color,
2842
+ iconId,
2843
+ labelKey: `eventKind.${kind}`,
2844
+ label
2845
+ });
2846
+ }
2847
+ function sub(kind, parentKind, category, color, iconId, label) {
2848
+ entries.set(kind, {
2849
+ kind,
2850
+ parentKind,
2851
+ level: "sub",
2852
+ category,
2853
+ color,
2854
+ iconId,
2855
+ labelKey: `eventKind.${kind}`,
2856
+ label
2857
+ });
2858
+ }
2859
+ macro("motion", "motion", TAXONOMY_COLORS.motion, "motion", "Motion");
2860
+ macro("audio", "audio", TAXONOMY_COLORS.audio, "audio", "Audio");
2861
+ macro("person", "detection", TAXONOMY_COLORS.person, "person", "Person");
2862
+ macro("vehicle", "detection", TAXONOMY_COLORS.vehicle, "vehicle", "Vehicle");
2863
+ macro("animal", "detection", TAXONOMY_COLORS.animal, "animal", "Animal");
2864
+ macro("package", "package", TAXONOMY_COLORS.package, "package", "Package");
2865
+ macro("sensor", "sensor", TAXONOMY_COLORS.sensor, "sensor", "Sensor");
2866
+ macro("control", "control", TAXONOMY_COLORS.control, "control", "Control");
2867
+ for (const [cocoClass, macroClass] of Object.entries(COCO_TO_MACRO.mapping)) {
2868
+ if (macroClass !== "vehicle" && macroClass !== "animal") continue;
2869
+ if (entries.has(cocoClass)) continue;
2870
+ sub(cocoClass, macroClass, "detection", DETECTION_SUB_COLORS[cocoClass] ?? TAXONOMY_COLORS.genericDetection, cocoClass, titleCase(cocoClass));
2871
+ }
2872
+ sub("package-delivered", "package", "package", TAXONOMY_COLORS.package, "package", "Package delivered");
2873
+ sub("package-picked-up", "package", "package", TAXONOMY_COLORS.package, "package", "Package picked up");
2874
+ sub("contact", "sensor", "sensor", "#f59e0b", "door", "Contact");
2875
+ sub("motion-sensor", "sensor", "sensor", TAXONOMY_COLORS.sensor, "pir", "Motion sensor");
2876
+ sub("smoke", "sensor", "sensor", "#ef4444", "smoke", "Smoke");
2877
+ sub("flood", "sensor", "sensor", "#3b82f6", "water", "Water leak");
2878
+ sub("gas", "sensor", "sensor", "#ef4444", "gas", "Gas");
2879
+ sub("carbon-monoxide", "sensor", "sensor", "#dc2626", "smoke", "Carbon monoxide");
2880
+ sub("vibration", "sensor", "sensor", "#eab308", "vibration", "Vibration");
2881
+ sub("tamper", "sensor", "sensor", "#f97316", "tamper", "Tamper");
2882
+ sub("presence", "sensor", "sensor", "#22c55e", "presence", "Presence");
2883
+ sub("enum-sensor", "sensor", "sensor", TAXONOMY_COLORS.sensor, "generic", "Sensor state");
2884
+ sub("device-event", "sensor", "sensor", "#10b981", "button", "Device event");
2885
+ sub("lock", "control", "control", "#0ea5e9", "lock", "Lock");
2886
+ sub("switch", "control", "control", TAXONOMY_COLORS.control, "switch", "Switch");
2887
+ sub("siren", "control", "control", "#dc2626", "siren", "Siren");
2888
+ sub("button", "control", "control", "#10b981", "button", "Button");
2889
+ sub("doorbell", "control", "control", "#a855f7", "doorbell", "Doorbell");
2890
+ for (const l of AUDIO_MACRO_LABELS) {
2891
+ const kind = `audio-${l.id}`;
2892
+ if (entries.has(kind)) continue;
2893
+ sub(kind, "audio", "audio", TAXONOMY_COLORS.audio, kind, l.name);
2894
+ }
2895
+ /** The complete taxonomy dictionary, keyed by kind. */
2896
+ var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
2897
+ /** Taxonomy entry for a kind, or undefined when unknown. */
2898
+ function getTaxonomyEntry(kind) {
2899
+ return EVENT_TAXONOMY[kind];
2900
+ }
2901
+ /** Color for a kind — dictionary value, else the global default. */
2902
+ function colorForKind(kind) {
2903
+ return EVENT_TAXONOMY[kind]?.color ?? "#22ff55";
2904
+ }
2905
+ /** The sub kinds whose `parentKind` is `macro` (empty for a leaf macro). */
2906
+ function subKindsOf(macro) {
2907
+ const out = [];
2908
+ for (const e of Object.values(EVENT_TAXONOMY)) if (e.parentKind === macro) out.push(e);
2909
+ return out;
2910
+ }
2911
+ //#endregion
2710
2912
  //#region src/types/device-type.ts
2711
2913
  var DEVICE_TYPE_INFO = { ["camera"]: {
2712
2914
  type: "camera",
@@ -11066,9 +11268,10 @@ var zoneRulesCapability = {
11066
11268
  * `package` backs the package-drop detector — a package zone is a
11067
11269
  * `ZoneRule` on the `'package'` stage referencing drawn polygons
11068
11270
  * (see docs/superpowers/specs/2026-07-17-package-zones-design.md §3.1).
11069
- * The orchestrator provider that writes this stage lands in a later
11070
- * slice; until then the mirror carries only `{motion, detection}` and
11071
- * consumers read `package` as absent (treat as `[]`).
11271
+ * The orchestrator provider writes this stage as a first-class slice
11272
+ * (Phase 4): every mutation mirrors the full `{motion, detection,
11273
+ * package}` shape, so consumers read the current package rules directly
11274
+ * off `device.state.zoneRules.value.package`.
11072
11275
  */
11073
11276
  runtimeState: zod.z.object({
11074
11277
  motion: zod.z.array(ZoneRuleSchema).readonly(),
@@ -13073,7 +13276,10 @@ function createSystemProxy(api) {
13073
13276
  assignPlates: (input) => dispatch("plateGallery", "assignPlates", "mutation", input),
13074
13277
  unassignPlates: (input) => dispatch("plateGallery", "unassignPlates", "mutation", input)
13075
13278
  },
13076
- recording: { getStorageUsage: (input) => dispatch("recording", "getStorageUsage", "query", input) },
13279
+ recording: {
13280
+ getStorageUsage: (input) => dispatch("recording", "getStorageUsage", "query", input),
13281
+ listOpsLog: (input) => dispatch("recording", "listOpsLog", "query", input)
13282
+ },
13077
13283
  recordingExport: {
13078
13284
  getExport: (input) => dispatch("recordingExport", "getExport", "query", input),
13079
13285
  cancelExport: (input) => dispatch("recordingExport", "cancelExport", "mutation", input),
@@ -18352,17 +18558,30 @@ var EventKindCategorySchema = zod.z.enum([
18352
18558
  "audio",
18353
18559
  "detection",
18354
18560
  "sensor",
18561
+ "control",
18355
18562
  "custom",
18356
18563
  "package"
18357
18564
  ]);
18565
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
18566
+ var EventKindLevelSchema = zod.z.enum(["macro", "sub"]);
18358
18567
  var EventKindDescriptorSchema = zod.z.object({
18359
- /** Stable kind id (e.g. 'motion', 'person', 'contact'). */
18568
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
18360
18569
  kind: zod.z.string(),
18570
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
18571
+ labelKey: zod.z.string(),
18572
+ /** English fallback label (kept for clients that don't translate). */
18361
18573
  label: zod.z.string(),
18362
18574
  /** Hex color for timeline/legend rendering. */
18363
18575
  color: zod.z.string(),
18576
+ /** Dictionary id → lucide component on the UI side. */
18577
+ iconId: zod.z.string(),
18578
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
18364
18579
  icon: EventKindIconSchema,
18365
18580
  category: EventKindCategorySchema,
18581
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
18582
+ parentKind: zod.z.string().nullable(),
18583
+ /** Derived from `parentKind`, explicit for the client tree. */
18584
+ level: EventKindLevelSchema,
18366
18585
  /** Which cap + device contributes this kind. For built-ins the camera
18367
18586
  * itself; for sensor kinds the LINKED source device. */
18368
18587
  source: zod.z.object({
@@ -18435,11 +18654,21 @@ var TrackAudioLabelSchema = zod.z.object({
18435
18654
  firstAt: zod.z.number(),
18436
18655
  lastAt: zod.z.number()
18437
18656
  });
18657
+ /**
18658
+ * How a track was produced. `pipeline` (default / absent) = the spatial
18659
+ * detection+tracking pipeline. `sensor` = a SYNTHETIC track projected from a
18660
+ * linked sensor/control state change (no positions; carries a snapshot). The
18661
+ * spatial subsystems (tracker association, occupancy count, re-id/embedding,
18662
+ * resurrection) MUST skip `sensor` tracks — they have no bbox trajectory.
18663
+ */
18664
+ var TrackSourceSchema = zod.z.enum(["pipeline", "sensor"]);
18438
18665
  var TrackSchema = zod.z.object({
18439
18666
  trackId: zod.z.string(),
18440
18667
  deviceId: zod.z.number(),
18441
18668
  className: zod.z.string(),
18442
18669
  label: zod.z.string().optional(),
18670
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
18671
+ source: TrackSourceSchema.optional(),
18443
18672
  firstSeen: zod.z.number(),
18444
18673
  lastSeen: zod.z.number(),
18445
18674
  /** Frame-rate position history (subject to maxPositionHistory cap). */
@@ -18694,6 +18923,26 @@ var TrackCascadeCountsSchema = zod.z.object({
18694
18923
  /** Per-track CLIP search vectors removed (best-effort). */
18695
18924
  embeddings: zod.z.number().int()
18696
18925
  });
18926
+ /** Event-store footprint for one camera. */
18927
+ var EventStoreDeviceFootprintSchema = zod.z.object({
18928
+ deviceId: zod.z.number(),
18929
+ /** Persisted event rows (motion + object + audio) for the camera. */
18930
+ rows: zod.z.number().int(),
18931
+ /** Event-owned media bytes on disk for the camera. */
18932
+ bytes: zod.z.number().int()
18933
+ });
18934
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18935
+ var EventStoreFootprintSchema = zod.z.object({
18936
+ totalRows: zod.z.number().int(),
18937
+ totalBytes: zod.z.number().int(),
18938
+ devices: zod.z.array(EventStoreDeviceFootprintSchema).readonly()
18939
+ });
18940
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
18941
+ var EventPruneCountsSchema = zod.z.object({
18942
+ motion: zod.z.number().int(),
18943
+ object: zod.z.number().int(),
18944
+ audio: zod.z.number().int()
18945
+ });
18697
18946
  var pipelineAnalyticsCapability = {
18698
18947
  name: "pipeline-analytics",
18699
18948
  scope: "device",
@@ -18855,6 +19104,45 @@ var pipelineAnalyticsCapability = {
18855
19104
  kind: "mutation",
18856
19105
  auth: "admin"
18857
19106
  }),
19107
+ /**
19108
+ * Durable event-store footprint for the management UI: event rows
19109
+ * (motion + object + audio) counted per camera + total, plus the
19110
+ * event-owned media bytes on disk per camera + total. Stat/count-based,
19111
+ * computed on demand.
19112
+ */
19113
+ getEventStoreFootprint: require_sleep.method(zod.z.object({}), EventStoreFootprintSchema, {
19114
+ kind: "query",
19115
+ auth: "admin"
19116
+ }),
19117
+ /**
19118
+ * Cluster-wide prune of events older than `olderThanMs` (exclusive) across
19119
+ * every camera, deleting each event's media in lockstep. Logged to the
19120
+ * events ops-log with `reason` (default `'retention'`). Returns the summed
19121
+ * per-kind deleted counts.
19122
+ */
19123
+ pruneEvents: require_sleep.method(zod.z.object({
19124
+ olderThanMs: zod.z.number(),
19125
+ reason: OpsLogReasonSchema.optional()
19126
+ }), EventPruneCountsSchema, {
19127
+ kind: "mutation",
19128
+ auth: "admin"
19129
+ }),
19130
+ /**
19131
+ * Manually delete EVERY event (motion + object + audio) for one camera and
19132
+ * its event-owned media in lockstep. Logged to the events ops-log as
19133
+ * `op:'manual-delete', reason:'manual'`. Destructive — the admin UI guards
19134
+ * it behind a confirm.
19135
+ */
19136
+ deleteDeviceEvents: require_sleep.method(zod.z.object({ deviceId: zod.z.number() }), EventPruneCountsSchema, {
19137
+ kind: "mutation",
19138
+ auth: "admin"
19139
+ }),
19140
+ /** The events ops-log rows (newest-first), optionally scoped to one camera.
19141
+ * Backed by a declared pipeline-analytics SQLite collection. */
19142
+ listOpsLog: require_sleep.method(OpsLogQueryInputSchema, zod.z.array(OpsLogEntrySchema).readonly(), {
19143
+ kind: "query",
19144
+ auth: "admin"
19145
+ }),
18858
19146
  getEventMedia: require_sleep.method(zod.z.object({
18859
19147
  eventId: zod.z.string(),
18860
19148
  kind: MediaFileKindEnum.optional()
@@ -18911,53 +19199,107 @@ var pipelineAnalyticsCapability = {
18911
19199
  //#endregion
18912
19200
  //#region src/capabilities/sensor-event-kinds.ts
18913
19201
  /**
18914
- * Sensor cap name static event-kind descriptor. A linked device
18915
- * contributes one entry per bound cap present in this map.
19202
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
19203
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
19204
+ * caps into per-camera event-kind descriptors.
19205
+ *
19206
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
19207
+ * is NOT duplicated here — every entry is derived from the single
19208
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
19209
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
19210
+ * control cap means adding one line here (and a taxonomy entry); the anti-
19211
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
19212
+ * eventful cap is missing.
18916
19213
  */
18917
- var EVENT_KIND_BY_CAP = {
18918
- contact: {
18919
- kind: "contact",
18920
- label: "Contact",
18921
- color: "#f59e0b",
18922
- icon: "door",
18923
- category: "sensor"
18924
- },
18925
- flood: {
18926
- kind: "flood",
18927
- label: "Water leak",
18928
- color: "#3b82f6",
18929
- icon: "water",
18930
- category: "sensor"
18931
- },
18932
- gas: {
18933
- kind: "gas",
18934
- label: "Gas",
18935
- color: "#ef4444",
18936
- icon: "smoke",
18937
- category: "sensor"
18938
- },
18939
- "carbon-monoxide": {
18940
- kind: "carbon-monoxide",
18941
- label: "Carbon monoxide",
18942
- color: "#dc2626",
18943
- icon: "smoke",
18944
- category: "sensor"
18945
- },
18946
- "enum-sensor": {
18947
- kind: "enum-sensor",
18948
- label: "Sensor state",
18949
- color: "#8b5cf6",
18950
- icon: "generic",
18951
- category: "sensor"
18952
- },
18953
- "event-emitter": {
18954
- kind: "device-event",
18955
- label: "Device event",
18956
- color: "#10b981",
18957
- icon: "button",
18958
- category: "sensor"
18959
- }
19214
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
19215
+ var LEGACY_ICON = {
19216
+ motion: "motion",
19217
+ audio: "audio",
19218
+ person: "person",
19219
+ vehicle: "vehicle",
19220
+ animal: "animal",
19221
+ package: "package",
19222
+ door: "door",
19223
+ pir: "pir",
19224
+ smoke: "smoke",
19225
+ water: "water",
19226
+ button: "button",
19227
+ generic: "generic",
19228
+ gas: "smoke",
19229
+ vibration: "generic",
19230
+ tamper: "generic",
19231
+ presence: "person",
19232
+ lock: "generic",
19233
+ siren: "generic",
19234
+ switch: "generic",
19235
+ doorbell: "button"
19236
+ };
19237
+ function legacyIcon(iconId) {
19238
+ return LEGACY_ICON[iconId] ?? "generic";
19239
+ }
19240
+ /**
19241
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
19242
+ * The anti-drift guard cross-checks this against the eventful caps declared
19243
+ * in `packages/types/src/capabilities/*.cap.ts`.
19244
+ */
19245
+ var CAP_TO_KIND = {
19246
+ contact: "contact",
19247
+ motion: "motion-sensor",
19248
+ smoke: "smoke",
19249
+ flood: "flood",
19250
+ gas: "gas",
19251
+ "carbon-monoxide": "carbon-monoxide",
19252
+ vibration: "vibration",
19253
+ tamper: "tamper",
19254
+ presence: "presence",
19255
+ "enum-sensor": "enum-sensor",
19256
+ "event-emitter": "device-event",
19257
+ "lock-control": "lock",
19258
+ switch: "switch",
19259
+ button: "button",
19260
+ doorbell: "doorbell"
18960
19261
  };
19262
+ function buildDescriptor(capName, kind) {
19263
+ const t = EVENT_TAXONOMY[kind];
19264
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
19265
+ return {
19266
+ ...t,
19267
+ icon: legacyIcon(t.iconId)
19268
+ };
19269
+ }
19270
+ /**
19271
+ * Sensor / control cap name → static event-kind descriptor. A linked device
19272
+ * contributes one entry per bound cap present in this map.
19273
+ */
19274
+ var EVENT_KIND_BY_CAP = Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
19275
+ /** The cap names covered by the taxonomy (for the anti-drift guard). */
19276
+ var EVENTFUL_CAP_NAMES = Object.keys(CAP_TO_KIND);
19277
+ /**
19278
+ * Build a full `EventKindDescriptor` for a taxonomy `kind`, stamping the
19279
+ * per-device `source`. Returns null when `kind` is not in the taxonomy.
19280
+ * This is THE bridge from the serializable taxonomy dictionary to the cap
19281
+ * wire shape — every event-kind descriptor the server emits goes through it,
19282
+ * so color/iconId/labelKey are never re-declared at a call site.
19283
+ */
19284
+ function buildEventKindDescriptor(kind, source) {
19285
+ const t = EVENT_TAXONOMY[kind];
19286
+ if (t === void 0) return null;
19287
+ return {
19288
+ kind: t.kind,
19289
+ labelKey: t.labelKey,
19290
+ label: t.label,
19291
+ color: t.color,
19292
+ iconId: t.iconId,
19293
+ icon: legacyIcon(t.iconId),
19294
+ category: t.category,
19295
+ parentKind: t.parentKind,
19296
+ level: t.level,
19297
+ source: {
19298
+ capName: source.capName,
19299
+ deviceId: source.deviceId
19300
+ }
19301
+ };
19302
+ }
18961
19303
  //#endregion
18962
19304
  //#region src/capabilities/pipeline-orchestrator.cap.ts
18963
19305
  var CameraPipelineConfigSchema = zod.z.object({
@@ -23592,14 +23934,43 @@ var recordingCapability = {
23592
23934
  auth: "admin"
23593
23935
  }),
23594
23936
  /** Apply this device's retention policy to footage now; returns the oldest
23595
- * surviving footage start (the retention floor) or null if no footage. */
23596
- pruneFootage: require_sleep.method(zod.z.object({ deviceId: zod.z.number() }), zod.z.object({
23937
+ * surviving footage start (the retention floor) or null if no footage. The
23938
+ * prune is logged to the recordings ops-log with `reason` (default
23939
+ * `'retention'` — the policy-driven prune; `'quota'` when disk-pressure
23940
+ * triggered). */
23941
+ pruneFootage: require_sleep.method(zod.z.object({
23942
+ deviceId: zod.z.number(),
23943
+ reason: OpsLogReasonSchema.optional()
23944
+ }), zod.z.object({
23597
23945
  floorMs: zod.z.number().nullable(),
23598
23946
  deletedBuckets: zod.z.number().int(),
23599
23947
  reclaimedBytes: zod.z.number().int()
23600
23948
  }), {
23601
23949
  kind: "mutation",
23602
23950
  auth: "admin"
23951
+ }),
23952
+ /**
23953
+ * Manually delete a camera's footage — the whole footprint, or a
23954
+ * `[fromMs, toMs)` window when either bound is given. Logged to the
23955
+ * recordings ops-log as `op:'manual-delete', reason:'manual'`. Destructive:
23956
+ * the admin UI guards it behind a confirm.
23957
+ */
23958
+ deleteFootprint: require_sleep.method(zod.z.object({
23959
+ deviceId: zod.z.number(),
23960
+ fromMs: zod.z.number().optional(),
23961
+ toMs: zod.z.number().optional()
23962
+ }), zod.z.object({
23963
+ deletedBuckets: zod.z.number().int(),
23964
+ reclaimedBytes: zod.z.number().int()
23965
+ }), {
23966
+ kind: "mutation",
23967
+ auth: "admin"
23968
+ }),
23969
+ /** The recordings ops-log rows (newest-first), optionally scoped to one
23970
+ * camera. Backed by the recorder's bounded DurableState ring. */
23971
+ listOpsLog: require_sleep.method(OpsLogQueryInputSchema, zod.z.array(OpsLogEntrySchema).readonly(), {
23972
+ kind: "query",
23973
+ auth: "admin"
23603
23974
  })
23604
23975
  }
23605
23976
  };
@@ -28062,6 +28433,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
28062
28433
  addonId: null,
28063
28434
  access: "delete"
28064
28435
  },
28436
+ "pipelineAnalytics.deleteDeviceEvents": {
28437
+ capName: "pipeline-analytics",
28438
+ capScope: "device",
28439
+ addonId: null,
28440
+ access: "delete"
28441
+ },
28065
28442
  "pipelineAnalytics.deleteTracks": {
28066
28443
  capName: "pipeline-analytics",
28067
28444
  capScope: "device",
@@ -28092,6 +28469,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
28092
28469
  addonId: null,
28093
28470
  access: "view"
28094
28471
  },
28472
+ "pipelineAnalytics.getEventStoreFootprint": {
28473
+ capName: "pipeline-analytics",
28474
+ capScope: "device",
28475
+ addonId: null,
28476
+ access: "view"
28477
+ },
28095
28478
  "pipelineAnalytics.getKeyEvents": {
28096
28479
  capName: "pipeline-analytics",
28097
28480
  capScope: "device",
@@ -28134,6 +28517,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
28134
28517
  addonId: null,
28135
28518
  access: "view"
28136
28519
  },
28520
+ "pipelineAnalytics.listOpsLog": {
28521
+ capName: "pipeline-analytics",
28522
+ capScope: "device",
28523
+ addonId: null,
28524
+ access: "view"
28525
+ },
28137
28526
  "pipelineAnalytics.listRecentTracks": {
28138
28527
  capName: "pipeline-analytics",
28139
28528
  capScope: "device",
@@ -28146,6 +28535,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
28146
28535
  addonId: null,
28147
28536
  access: "view"
28148
28537
  },
28538
+ "pipelineAnalytics.pruneEvents": {
28539
+ capName: "pipeline-analytics",
28540
+ capScope: "device",
28541
+ addonId: null,
28542
+ access: "create"
28543
+ },
28149
28544
  "pipelineAnalytics.pruneEventsBefore": {
28150
28545
  capName: "pipeline-analytics",
28151
28546
  capScope: "device",
@@ -28908,6 +29303,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
28908
29303
  addonId: null,
28909
29304
  access: "create"
28910
29305
  },
29306
+ "recording.deleteFootprint": {
29307
+ capName: "recording",
29308
+ capScope: "system",
29309
+ addonId: null,
29310
+ access: "delete"
29311
+ },
28911
29312
  "recording.getAvailability": {
28912
29313
  capName: "recording",
28913
29314
  capScope: "system",
@@ -28938,6 +29339,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
28938
29339
  addonId: null,
28939
29340
  access: "view"
28940
29341
  },
29342
+ "recording.listOpsLog": {
29343
+ capName: "recording",
29344
+ capScope: "system",
29345
+ addonId: null,
29346
+ access: "view"
29347
+ },
28941
29348
  "recording.locateSegment": {
28942
29349
  capName: "recording",
28943
29350
  capScope: "system",
@@ -31099,6 +31506,7 @@ exports.DATAPLANE_SECRET_HEADER = require_sleep.DATAPLANE_SECRET_HEADER;
31099
31506
  exports.DEFAULT_ADDON_PLACEMENT = DEFAULT_ADDON_PLACEMENT;
31100
31507
  exports.DEFAULT_AUDIO_ANALYZER_CONFIG = DEFAULT_AUDIO_ANALYZER_CONFIG;
31101
31508
  exports.DEFAULT_DECODER_HWACCEL_CONFIG = DEFAULT_DECODER_HWACCEL_CONFIG;
31509
+ exports.DEFAULT_EVENT_COLOR = DEFAULT_EVENT_COLOR;
31102
31510
  exports.DEFAULT_FEATURES = DEFAULT_FEATURES;
31103
31511
  exports.DEFAULT_RETENTION = DEFAULT_RETENTION;
31104
31512
  exports.DEFAULT_SCRUB_THUMBNAIL_PRESET = DEFAULT_SCRUB_THUMBNAIL_PRESET;
@@ -31138,8 +31546,10 @@ exports.DiscoveredTargetSchema = DiscoveredTargetSchema;
31138
31546
  exports.DisposerChain = require_sleep.DisposerChain;
31139
31547
  exports.DoorbellPressEventSchema = DoorbellPressEventSchema;
31140
31548
  exports.DoorbellStatusSchema = DoorbellStatusSchema;
31549
+ exports.EVENTFUL_CAP_NAMES = EVENTFUL_CAP_NAMES;
31141
31550
  exports.EVENT_KIND_BY_CAP = EVENT_KIND_BY_CAP;
31142
31551
  exports.EVENT_PAD_MS = EVENT_PAD_MS;
31552
+ exports.EVENT_TAXONOMY = EVENT_TAXONOMY;
31143
31553
  exports.EXPRESSION_BUILTINS = EXPRESSION_BUILTINS;
31144
31554
  exports.EXPRESSION_BUILTIN_NAMES = EXPRESSION_BUILTIN_NAMES;
31145
31555
  exports.EXPRESSION_COMPILE_CACHE_CAPACITY = EXPRESSION_COMPILE_CACHE_CAPACITY;
@@ -31303,8 +31713,15 @@ exports.NotificationRuleSchema = NotificationRuleSchema;
31303
31713
  exports.NotificationSchema = NotificationSchema;
31304
31714
  exports.NotifierStatusSchema = NotifierStatusSchema;
31305
31715
  exports.NumericSensorStatusSchema = NumericSensorStatusSchema;
31716
+ exports.OPS_LOG_DEFAULT_LIMIT = OPS_LOG_DEFAULT_LIMIT;
31717
+ exports.OPS_LOG_RING_DEFAULT_MAX = OPS_LOG_RING_DEFAULT_MAX;
31306
31718
  exports.OauthIntegrationDescriptorSchema = OauthIntegrationDescriptorSchema;
31307
31719
  exports.ObjectEventSchema = ObjectEventSchema;
31720
+ exports.OpsLogDomainSchema = OpsLogDomainSchema;
31721
+ exports.OpsLogEntrySchema = OpsLogEntrySchema;
31722
+ exports.OpsLogOpSchema = OpsLogOpSchema;
31723
+ exports.OpsLogQueryInputSchema = OpsLogQueryInputSchema;
31724
+ exports.OpsLogReasonSchema = OpsLogReasonSchema;
31308
31725
  exports.OrchestratorMetricsSchema = OrchestratorMetricsSchema;
31309
31726
  exports.OsdOverlayKindEnum = OsdOverlayKindEnum;
31310
31727
  exports.OsdOverlayPatchSchema = OsdOverlayPatchSchema;
@@ -31477,6 +31894,7 @@ exports.SubscribeFramesResultSchema = require_sleep.SubscribeFramesResultSchema;
31477
31894
  exports.SwitchStatusSchema = SwitchStatusSchema;
31478
31895
  exports.SystemMetricsSchema = SystemMetricsSchema;
31479
31896
  exports.SystemMirror = SystemMirror;
31897
+ exports.TAXONOMY_COLORS = TAXONOMY_COLORS;
31480
31898
  exports.TIMEZONES = TIMEZONES;
31481
31899
  exports.TamperStatusSchema = TamperStatusSchema;
31482
31900
  exports.TankStatusSchema = TankStatusSchema;
@@ -31570,6 +31988,7 @@ exports.bindAddonActions = bindAddonActions;
31570
31988
  exports.brightnessCapability = brightnessCapability;
31571
31989
  exports.brokerCapability = brokerCapability;
31572
31990
  exports.buildAddonRouteProvider = buildAddonRouteProvider;
31991
+ exports.buildEventKindDescriptor = buildEventKindDescriptor;
31573
31992
  exports.buildModelVariantGroups = buildModelVariantGroups;
31574
31993
  exports.buildStreamParamsConfigSchema = buildStreamParamsConfigSchema;
31575
31994
  exports.buttonCapability = buttonCapability;
@@ -31585,6 +32004,7 @@ exports.climateControlCapability = climateControlCapability;
31585
32004
  exports.collectHydratedFieldEntries = require_sleep.collectHydratedFieldEntries;
31586
32005
  exports.collectHydratedFieldValues = require_sleep.collectHydratedFieldValues;
31587
32006
  exports.colorCapability = colorCapability;
32007
+ exports.colorForKind = colorForKind;
31588
32008
  exports.compileExpression = compileExpression;
31589
32009
  exports.compileExpressionSafe = compileExpressionSafe;
31590
32010
  exports.connectivityCapability = connectivityCapability;
@@ -31653,6 +32073,7 @@ exports.gasCapability = gasCapability;
31653
32073
  exports.getAudioMacroClassIds = getAudioMacroClassIds;
31654
32074
  exports.getByPath = getByPath;
31655
32075
  exports.getCapsByProviderKind = getCapsByProviderKind;
32076
+ exports.getTaxonomyEntry = getTaxonomyEntry;
31656
32077
  exports.hfModelUrl = hfModelUrl;
31657
32078
  exports.htmlToText = htmlToText;
31658
32079
  exports.humidifierCapability = humidifierCapability;
@@ -31788,6 +32209,7 @@ exports.streamCatalogCapability = streamCatalogCapability;
31788
32209
  exports.streamParamsCapability = streamParamsCapability;
31789
32210
  exports.streamPixels = streamPixels;
31790
32211
  exports.streamQualityLabel = streamQualityLabel;
32212
+ exports.subKindsOf = subKindsOf;
31791
32213
  exports.supportedRuntimes = supportedRuntimes;
31792
32214
  exports.switchCapability = switchCapability;
31793
32215
  exports.synthesizeSourceInfo = synthesizeSourceInfo;