@camstack/addon-ai 0.1.7 → 0.1.9

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
@@ -7701,6 +7701,160 @@ var CAP_NODE_PIN_CONTEXT_KEY = "__camstackNodePin";
7701
7701
  function nodePin(nodeId) {
7702
7702
  return { context: { [CAP_NODE_PIN_CONTEXT_KEY]: nodeId } };
7703
7703
  }
7704
+ var COCO_TO_MACRO = {
7705
+ mapping: {
7706
+ person: "person",
7707
+ bicycle: "vehicle",
7708
+ car: "vehicle",
7709
+ motorcycle: "vehicle",
7710
+ airplane: "vehicle",
7711
+ bus: "vehicle",
7712
+ train: "vehicle",
7713
+ truck: "vehicle",
7714
+ boat: "vehicle",
7715
+ bird: "animal",
7716
+ cat: "animal",
7717
+ dog: "animal",
7718
+ horse: "animal",
7719
+ sheep: "animal",
7720
+ cow: "animal",
7721
+ elephant: "animal",
7722
+ bear: "animal",
7723
+ zebra: "animal",
7724
+ giraffe: "animal",
7725
+ suitcase: "package",
7726
+ backpack: "package",
7727
+ handbag: "package"
7728
+ },
7729
+ preserveOriginal: false
7730
+ };
7731
+ var AUDIO_MACRO_LABELS = [
7732
+ {
7733
+ id: "speech",
7734
+ name: "Speech",
7735
+ icon: "🗣️"
7736
+ },
7737
+ {
7738
+ id: "scream",
7739
+ name: "Scream / Shout",
7740
+ icon: "😱"
7741
+ },
7742
+ {
7743
+ id: "crying",
7744
+ name: "Crying / Baby",
7745
+ icon: "😢"
7746
+ },
7747
+ {
7748
+ id: "laughter",
7749
+ name: "Laughter",
7750
+ icon: "😂"
7751
+ },
7752
+ {
7753
+ id: "music",
7754
+ name: "Music",
7755
+ icon: "🎵"
7756
+ },
7757
+ {
7758
+ id: "dog",
7759
+ name: "Dog",
7760
+ icon: "🐕"
7761
+ },
7762
+ {
7763
+ id: "cat",
7764
+ name: "Cat",
7765
+ icon: "🐈"
7766
+ },
7767
+ {
7768
+ id: "bird",
7769
+ name: "Bird",
7770
+ icon: "🐦"
7771
+ },
7772
+ {
7773
+ id: "animal",
7774
+ name: "Animal (other)",
7775
+ icon: "🐾"
7776
+ },
7777
+ {
7778
+ id: "alarm",
7779
+ name: "Alarm / Siren",
7780
+ icon: "🚨"
7781
+ },
7782
+ {
7783
+ id: "doorbell",
7784
+ name: "Doorbell / Knock",
7785
+ icon: "🔔"
7786
+ },
7787
+ {
7788
+ id: "glass_breaking",
7789
+ name: "Glass Breaking",
7790
+ icon: "💥"
7791
+ },
7792
+ {
7793
+ id: "gunshot",
7794
+ name: "Gunshot / Explosion",
7795
+ icon: "💣"
7796
+ },
7797
+ {
7798
+ id: "vehicle",
7799
+ name: "Vehicle",
7800
+ icon: "🚗"
7801
+ },
7802
+ {
7803
+ id: "siren",
7804
+ name: "Emergency Siren",
7805
+ icon: "🚑"
7806
+ },
7807
+ {
7808
+ id: "fire",
7809
+ name: "Fire / Smoke",
7810
+ icon: "🔥"
7811
+ },
7812
+ {
7813
+ id: "water",
7814
+ name: "Water",
7815
+ icon: "💧"
7816
+ },
7817
+ {
7818
+ id: "wind",
7819
+ name: "Wind / Weather",
7820
+ icon: "🌬️"
7821
+ },
7822
+ {
7823
+ id: "door",
7824
+ name: "Door",
7825
+ icon: "🚪"
7826
+ },
7827
+ {
7828
+ id: "footsteps",
7829
+ name: "Footsteps",
7830
+ icon: "👣"
7831
+ },
7832
+ {
7833
+ id: "crowd",
7834
+ name: "Crowd / Chatter",
7835
+ icon: "👥"
7836
+ },
7837
+ {
7838
+ id: "telephone",
7839
+ name: "Telephone",
7840
+ icon: "📞"
7841
+ },
7842
+ {
7843
+ id: "engine",
7844
+ name: "Engine / Motor",
7845
+ icon: "⚙️"
7846
+ },
7847
+ {
7848
+ id: "tools",
7849
+ name: "Tools / Construction",
7850
+ icon: "🔨"
7851
+ },
7852
+ {
7853
+ id: "silence",
7854
+ name: "Silence",
7855
+ icon: "🤫"
7856
+ }
7857
+ ];
7704
7858
  var YAMNET_TO_MACRO = {
7705
7859
  mapping: {
7706
7860
  Speech: "speech",
@@ -7967,6 +8121,125 @@ var _macroLookup = /* @__PURE__ */ new Map();
7967
8121
  for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7968
8122
  for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7969
8123
  /**
8124
+ * Unified event-kind taxonomy — THE single source of truth for
8125
+ * `kind → { parentKind, category, level, color, iconId, labelKey, label,
8126
+ * icon }`.
8127
+ *
8128
+ * This dictionary folds together what used to be scattered across four
8129
+ * copies:
8130
+ * - `capabilities/sensor-event-kinds.ts` (sensor cap colors)
8131
+ * - `addon-post-analysis/.../services/event-kinds.ts`
8132
+ * (MOTION/PERSON/VEHICLE… _COLOR constants)
8133
+ * - `ui-library/composites/detection-colors.ts` (CLASS_COLORS)
8134
+ * - `addon-post-analysis/shared/frame/box-drawer.ts` (DEFAULT_COLOR)
8135
+ * - the COCO / audio class maps (macro ↔ sub relationships)
8136
+ *
8137
+ * The DATA (serializable — color/iconId/labelKey/parentKind) lives here in
8138
+ * `@camstack/types`. The UI-side mapping `iconId → lucide component` and
8139
+ * `labelKey → t()` lives in `@camstack/ui-library`. UIs never hardcode a
8140
+ * color or an icon: they read this dictionary (server descriptors carry the
8141
+ * fields inline; the client resolves color/icon/label from `iconId`/`kind`).
8142
+ *
8143
+ * Two levels only (v1 YAGNI): macro → sub. `person` is a leaf macro.
8144
+ */
8145
+ var TAXONOMY_COLORS = {
8146
+ motion: "#f59e0b",
8147
+ audio: "#06b6d4",
8148
+ person: "#22c55e",
8149
+ vehicle: "#3b82f6",
8150
+ animal: "#f97316",
8151
+ package: "#a855f7",
8152
+ sensor: "#8b5cf6",
8153
+ control: "#10b981",
8154
+ genericDetection: "#64748b"
8155
+ };
8156
+ var DETECTION_SUB_COLORS = {
8157
+ car: "#f59e0b",
8158
+ truck: "#d97706",
8159
+ bus: "#b45309",
8160
+ motorcycle: "#eab308",
8161
+ bicycle: "#ca8a04",
8162
+ airplane: "#60a5fa",
8163
+ boat: "#2563eb",
8164
+ train: "#1d4ed8",
8165
+ bird: "#14b8a6",
8166
+ dog: "#84cc16",
8167
+ cat: "#f97316",
8168
+ horse: "#a16207",
8169
+ sheep: "#a3a3a3",
8170
+ cow: "#78716c",
8171
+ elephant: "#6b7280",
8172
+ bear: "#7c2d12",
8173
+ zebra: "#404040",
8174
+ giraffe: "#d4a373"
8175
+ };
8176
+ function titleCase(id) {
8177
+ return id.split(/[-_ ]/).filter((p) => p.length > 0).map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join(" ");
8178
+ }
8179
+ var entries = /* @__PURE__ */ new Map();
8180
+ function macro(kind, category, color, iconId, label) {
8181
+ entries.set(kind, {
8182
+ kind,
8183
+ parentKind: null,
8184
+ level: "macro",
8185
+ category,
8186
+ color,
8187
+ iconId,
8188
+ labelKey: `eventKind.${kind}`,
8189
+ label
8190
+ });
8191
+ }
8192
+ function sub(kind, parentKind, category, color, iconId, label) {
8193
+ entries.set(kind, {
8194
+ kind,
8195
+ parentKind,
8196
+ level: "sub",
8197
+ category,
8198
+ color,
8199
+ iconId,
8200
+ labelKey: `eventKind.${kind}`,
8201
+ label
8202
+ });
8203
+ }
8204
+ macro("motion", "motion", TAXONOMY_COLORS.motion, "motion", "Motion");
8205
+ macro("audio", "audio", TAXONOMY_COLORS.audio, "audio", "Audio");
8206
+ macro("person", "detection", TAXONOMY_COLORS.person, "person", "Person");
8207
+ macro("vehicle", "detection", TAXONOMY_COLORS.vehicle, "vehicle", "Vehicle");
8208
+ macro("animal", "detection", TAXONOMY_COLORS.animal, "animal", "Animal");
8209
+ macro("package", "package", TAXONOMY_COLORS.package, "package", "Package");
8210
+ macro("sensor", "sensor", TAXONOMY_COLORS.sensor, "sensor", "Sensor");
8211
+ macro("control", "control", TAXONOMY_COLORS.control, "control", "Control");
8212
+ for (const [cocoClass, macroClass] of Object.entries(COCO_TO_MACRO.mapping)) {
8213
+ if (macroClass !== "vehicle" && macroClass !== "animal") continue;
8214
+ if (entries.has(cocoClass)) continue;
8215
+ sub(cocoClass, macroClass, "detection", DETECTION_SUB_COLORS[cocoClass] ?? TAXONOMY_COLORS.genericDetection, cocoClass, titleCase(cocoClass));
8216
+ }
8217
+ sub("package-delivered", "package", "package", TAXONOMY_COLORS.package, "package", "Package delivered");
8218
+ sub("package-picked-up", "package", "package", TAXONOMY_COLORS.package, "package", "Package picked up");
8219
+ sub("contact", "sensor", "sensor", "#f59e0b", "door", "Contact");
8220
+ sub("motion-sensor", "sensor", "sensor", TAXONOMY_COLORS.sensor, "pir", "Motion sensor");
8221
+ sub("smoke", "sensor", "sensor", "#ef4444", "smoke", "Smoke");
8222
+ sub("flood", "sensor", "sensor", "#3b82f6", "water", "Water leak");
8223
+ sub("gas", "sensor", "sensor", "#ef4444", "gas", "Gas");
8224
+ sub("carbon-monoxide", "sensor", "sensor", "#dc2626", "smoke", "Carbon monoxide");
8225
+ sub("vibration", "sensor", "sensor", "#eab308", "vibration", "Vibration");
8226
+ sub("tamper", "sensor", "sensor", "#f97316", "tamper", "Tamper");
8227
+ sub("presence", "sensor", "sensor", "#22c55e", "presence", "Presence");
8228
+ sub("enum-sensor", "sensor", "sensor", TAXONOMY_COLORS.sensor, "generic", "Sensor state");
8229
+ sub("device-event", "sensor", "sensor", "#10b981", "button", "Device event");
8230
+ sub("lock", "control", "control", "#0ea5e9", "lock", "Lock");
8231
+ sub("switch", "control", "control", TAXONOMY_COLORS.control, "switch", "Switch");
8232
+ sub("siren", "control", "control", "#dc2626", "siren", "Siren");
8233
+ sub("button", "control", "control", "#10b981", "button", "Button");
8234
+ sub("doorbell", "control", "control", "#a855f7", "doorbell", "Doorbell");
8235
+ for (const l of AUDIO_MACRO_LABELS) {
8236
+ const kind = `audio-${l.id}`;
8237
+ if (entries.has(kind)) continue;
8238
+ sub(kind, "audio", "audio", TAXONOMY_COLORS.audio, kind, l.name);
8239
+ }
8240
+ /** The complete taxonomy dictionary, keyed by kind. */
8241
+ var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
8242
+ /**
7970
8243
  * Error types for the safe expression engine. Two distinct classes so callers
7971
8244
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
7972
8245
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -15961,17 +16234,30 @@ var EventKindCategorySchema = _enum([
15961
16234
  "audio",
15962
16235
  "detection",
15963
16236
  "sensor",
16237
+ "control",
15964
16238
  "custom",
15965
16239
  "package"
15966
16240
  ]);
16241
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
16242
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
15967
16243
  var EventKindDescriptorSchema = object({
15968
- /** Stable kind id (e.g. 'motion', 'person', 'contact'). */
16244
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
15969
16245
  kind: string(),
16246
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
16247
+ labelKey: string(),
16248
+ /** English fallback label (kept for clients that don't translate). */
15970
16249
  label: string(),
15971
16250
  /** Hex color for timeline/legend rendering. */
15972
16251
  color: string(),
16252
+ /** Dictionary id → lucide component on the UI side. */
16253
+ iconId: string(),
16254
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
15973
16255
  icon: EventKindIconSchema,
15974
16256
  category: EventKindCategorySchema,
16257
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
16258
+ parentKind: string().nullable(),
16259
+ /** Derived from `parentKind`, explicit for the client tree. */
16260
+ level: EventKindLevelSchema,
15975
16261
  /** Which cap + device contributes this kind. For built-ins the camera
15976
16262
  * itself; for sensor kinds the LINKED source device. */
15977
16263
  source: object({
@@ -16044,11 +16330,21 @@ var TrackAudioLabelSchema = object({
16044
16330
  firstAt: number(),
16045
16331
  lastAt: number()
16046
16332
  });
16333
+ /**
16334
+ * How a track was produced. `pipeline` (default / absent) = the spatial
16335
+ * detection+tracking pipeline. `sensor` = a SYNTHETIC track projected from a
16336
+ * linked sensor/control state change (no positions; carries a snapshot). The
16337
+ * spatial subsystems (tracker association, occupancy count, re-id/embedding,
16338
+ * resurrection) MUST skip `sensor` tracks — they have no bbox trajectory.
16339
+ */
16340
+ var TrackSourceSchema = _enum(["pipeline", "sensor"]);
16047
16341
  var TrackSchema = object({
16048
16342
  trackId: string(),
16049
16343
  deviceId: number(),
16050
16344
  className: string(),
16051
16345
  label: string().optional(),
16346
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
16347
+ source: TrackSourceSchema.optional(),
16052
16348
  firstSeen: number(),
16053
16349
  lastSeen: number(),
16054
16350
  /** Frame-rate position history (subject to maxPositionHistory cap). */
@@ -16425,6 +16721,76 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
16425
16721
  eventId: string(),
16426
16722
  timestamp: number()
16427
16723
  });
16724
+ /**
16725
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
16726
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
16727
+ * caps into per-camera event-kind descriptors.
16728
+ *
16729
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
16730
+ * is NOT duplicated here — every entry is derived from the single
16731
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
16732
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
16733
+ * control cap means adding one line here (and a taxonomy entry); the anti-
16734
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
16735
+ * eventful cap is missing.
16736
+ */
16737
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
16738
+ var LEGACY_ICON = {
16739
+ motion: "motion",
16740
+ audio: "audio",
16741
+ person: "person",
16742
+ vehicle: "vehicle",
16743
+ animal: "animal",
16744
+ package: "package",
16745
+ door: "door",
16746
+ pir: "pir",
16747
+ smoke: "smoke",
16748
+ water: "water",
16749
+ button: "button",
16750
+ generic: "generic",
16751
+ gas: "smoke",
16752
+ vibration: "generic",
16753
+ tamper: "generic",
16754
+ presence: "person",
16755
+ lock: "generic",
16756
+ siren: "generic",
16757
+ switch: "generic",
16758
+ doorbell: "button"
16759
+ };
16760
+ function legacyIcon(iconId) {
16761
+ return LEGACY_ICON[iconId] ?? "generic";
16762
+ }
16763
+ /**
16764
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
16765
+ * The anti-drift guard cross-checks this against the eventful caps declared
16766
+ * in `packages/types/src/capabilities/*.cap.ts`.
16767
+ */
16768
+ var CAP_TO_KIND = {
16769
+ contact: "contact",
16770
+ motion: "motion-sensor",
16771
+ smoke: "smoke",
16772
+ flood: "flood",
16773
+ gas: "gas",
16774
+ "carbon-monoxide": "carbon-monoxide",
16775
+ vibration: "vibration",
16776
+ tamper: "tamper",
16777
+ presence: "presence",
16778
+ "enum-sensor": "enum-sensor",
16779
+ "event-emitter": "device-event",
16780
+ "lock-control": "lock",
16781
+ switch: "switch",
16782
+ button: "button",
16783
+ doorbell: "doorbell"
16784
+ };
16785
+ function buildDescriptor(capName, kind) {
16786
+ const t = EVENT_TAXONOMY[kind];
16787
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
16788
+ return {
16789
+ ...t,
16790
+ icon: legacyIcon(t.iconId)
16791
+ };
16792
+ }
16793
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
16428
16794
  var CameraPipelineConfigSchema = object({
16429
16795
  engine: PipelineEngineChoiceSchema.optional(),
16430
16796
  steps: array(PipelineStepInputSchema).readonly(),
package/dist/addon.mjs CHANGED
@@ -7663,6 +7663,160 @@ var CAP_NODE_PIN_CONTEXT_KEY = "__camstackNodePin";
7663
7663
  function nodePin(nodeId) {
7664
7664
  return { context: { [CAP_NODE_PIN_CONTEXT_KEY]: nodeId } };
7665
7665
  }
7666
+ var COCO_TO_MACRO = {
7667
+ mapping: {
7668
+ person: "person",
7669
+ bicycle: "vehicle",
7670
+ car: "vehicle",
7671
+ motorcycle: "vehicle",
7672
+ airplane: "vehicle",
7673
+ bus: "vehicle",
7674
+ train: "vehicle",
7675
+ truck: "vehicle",
7676
+ boat: "vehicle",
7677
+ bird: "animal",
7678
+ cat: "animal",
7679
+ dog: "animal",
7680
+ horse: "animal",
7681
+ sheep: "animal",
7682
+ cow: "animal",
7683
+ elephant: "animal",
7684
+ bear: "animal",
7685
+ zebra: "animal",
7686
+ giraffe: "animal",
7687
+ suitcase: "package",
7688
+ backpack: "package",
7689
+ handbag: "package"
7690
+ },
7691
+ preserveOriginal: false
7692
+ };
7693
+ var AUDIO_MACRO_LABELS = [
7694
+ {
7695
+ id: "speech",
7696
+ name: "Speech",
7697
+ icon: "🗣️"
7698
+ },
7699
+ {
7700
+ id: "scream",
7701
+ name: "Scream / Shout",
7702
+ icon: "😱"
7703
+ },
7704
+ {
7705
+ id: "crying",
7706
+ name: "Crying / Baby",
7707
+ icon: "😢"
7708
+ },
7709
+ {
7710
+ id: "laughter",
7711
+ name: "Laughter",
7712
+ icon: "😂"
7713
+ },
7714
+ {
7715
+ id: "music",
7716
+ name: "Music",
7717
+ icon: "🎵"
7718
+ },
7719
+ {
7720
+ id: "dog",
7721
+ name: "Dog",
7722
+ icon: "🐕"
7723
+ },
7724
+ {
7725
+ id: "cat",
7726
+ name: "Cat",
7727
+ icon: "🐈"
7728
+ },
7729
+ {
7730
+ id: "bird",
7731
+ name: "Bird",
7732
+ icon: "🐦"
7733
+ },
7734
+ {
7735
+ id: "animal",
7736
+ name: "Animal (other)",
7737
+ icon: "🐾"
7738
+ },
7739
+ {
7740
+ id: "alarm",
7741
+ name: "Alarm / Siren",
7742
+ icon: "🚨"
7743
+ },
7744
+ {
7745
+ id: "doorbell",
7746
+ name: "Doorbell / Knock",
7747
+ icon: "🔔"
7748
+ },
7749
+ {
7750
+ id: "glass_breaking",
7751
+ name: "Glass Breaking",
7752
+ icon: "💥"
7753
+ },
7754
+ {
7755
+ id: "gunshot",
7756
+ name: "Gunshot / Explosion",
7757
+ icon: "💣"
7758
+ },
7759
+ {
7760
+ id: "vehicle",
7761
+ name: "Vehicle",
7762
+ icon: "🚗"
7763
+ },
7764
+ {
7765
+ id: "siren",
7766
+ name: "Emergency Siren",
7767
+ icon: "🚑"
7768
+ },
7769
+ {
7770
+ id: "fire",
7771
+ name: "Fire / Smoke",
7772
+ icon: "🔥"
7773
+ },
7774
+ {
7775
+ id: "water",
7776
+ name: "Water",
7777
+ icon: "💧"
7778
+ },
7779
+ {
7780
+ id: "wind",
7781
+ name: "Wind / Weather",
7782
+ icon: "🌬️"
7783
+ },
7784
+ {
7785
+ id: "door",
7786
+ name: "Door",
7787
+ icon: "🚪"
7788
+ },
7789
+ {
7790
+ id: "footsteps",
7791
+ name: "Footsteps",
7792
+ icon: "👣"
7793
+ },
7794
+ {
7795
+ id: "crowd",
7796
+ name: "Crowd / Chatter",
7797
+ icon: "👥"
7798
+ },
7799
+ {
7800
+ id: "telephone",
7801
+ name: "Telephone",
7802
+ icon: "📞"
7803
+ },
7804
+ {
7805
+ id: "engine",
7806
+ name: "Engine / Motor",
7807
+ icon: "⚙️"
7808
+ },
7809
+ {
7810
+ id: "tools",
7811
+ name: "Tools / Construction",
7812
+ icon: "🔨"
7813
+ },
7814
+ {
7815
+ id: "silence",
7816
+ name: "Silence",
7817
+ icon: "🤫"
7818
+ }
7819
+ ];
7666
7820
  var YAMNET_TO_MACRO = {
7667
7821
  mapping: {
7668
7822
  Speech: "speech",
@@ -7929,6 +8083,125 @@ var _macroLookup = /* @__PURE__ */ new Map();
7929
8083
  for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7930
8084
  for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7931
8085
  /**
8086
+ * Unified event-kind taxonomy — THE single source of truth for
8087
+ * `kind → { parentKind, category, level, color, iconId, labelKey, label,
8088
+ * icon }`.
8089
+ *
8090
+ * This dictionary folds together what used to be scattered across four
8091
+ * copies:
8092
+ * - `capabilities/sensor-event-kinds.ts` (sensor cap colors)
8093
+ * - `addon-post-analysis/.../services/event-kinds.ts`
8094
+ * (MOTION/PERSON/VEHICLE… _COLOR constants)
8095
+ * - `ui-library/composites/detection-colors.ts` (CLASS_COLORS)
8096
+ * - `addon-post-analysis/shared/frame/box-drawer.ts` (DEFAULT_COLOR)
8097
+ * - the COCO / audio class maps (macro ↔ sub relationships)
8098
+ *
8099
+ * The DATA (serializable — color/iconId/labelKey/parentKind) lives here in
8100
+ * `@camstack/types`. The UI-side mapping `iconId → lucide component` and
8101
+ * `labelKey → t()` lives in `@camstack/ui-library`. UIs never hardcode a
8102
+ * color or an icon: they read this dictionary (server descriptors carry the
8103
+ * fields inline; the client resolves color/icon/label from `iconId`/`kind`).
8104
+ *
8105
+ * Two levels only (v1 YAGNI): macro → sub. `person` is a leaf macro.
8106
+ */
8107
+ var TAXONOMY_COLORS = {
8108
+ motion: "#f59e0b",
8109
+ audio: "#06b6d4",
8110
+ person: "#22c55e",
8111
+ vehicle: "#3b82f6",
8112
+ animal: "#f97316",
8113
+ package: "#a855f7",
8114
+ sensor: "#8b5cf6",
8115
+ control: "#10b981",
8116
+ genericDetection: "#64748b"
8117
+ };
8118
+ var DETECTION_SUB_COLORS = {
8119
+ car: "#f59e0b",
8120
+ truck: "#d97706",
8121
+ bus: "#b45309",
8122
+ motorcycle: "#eab308",
8123
+ bicycle: "#ca8a04",
8124
+ airplane: "#60a5fa",
8125
+ boat: "#2563eb",
8126
+ train: "#1d4ed8",
8127
+ bird: "#14b8a6",
8128
+ dog: "#84cc16",
8129
+ cat: "#f97316",
8130
+ horse: "#a16207",
8131
+ sheep: "#a3a3a3",
8132
+ cow: "#78716c",
8133
+ elephant: "#6b7280",
8134
+ bear: "#7c2d12",
8135
+ zebra: "#404040",
8136
+ giraffe: "#d4a373"
8137
+ };
8138
+ function titleCase(id) {
8139
+ return id.split(/[-_ ]/).filter((p) => p.length > 0).map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join(" ");
8140
+ }
8141
+ var entries = /* @__PURE__ */ new Map();
8142
+ function macro(kind, category, color, iconId, label) {
8143
+ entries.set(kind, {
8144
+ kind,
8145
+ parentKind: null,
8146
+ level: "macro",
8147
+ category,
8148
+ color,
8149
+ iconId,
8150
+ labelKey: `eventKind.${kind}`,
8151
+ label
8152
+ });
8153
+ }
8154
+ function sub(kind, parentKind, category, color, iconId, label) {
8155
+ entries.set(kind, {
8156
+ kind,
8157
+ parentKind,
8158
+ level: "sub",
8159
+ category,
8160
+ color,
8161
+ iconId,
8162
+ labelKey: `eventKind.${kind}`,
8163
+ label
8164
+ });
8165
+ }
8166
+ macro("motion", "motion", TAXONOMY_COLORS.motion, "motion", "Motion");
8167
+ macro("audio", "audio", TAXONOMY_COLORS.audio, "audio", "Audio");
8168
+ macro("person", "detection", TAXONOMY_COLORS.person, "person", "Person");
8169
+ macro("vehicle", "detection", TAXONOMY_COLORS.vehicle, "vehicle", "Vehicle");
8170
+ macro("animal", "detection", TAXONOMY_COLORS.animal, "animal", "Animal");
8171
+ macro("package", "package", TAXONOMY_COLORS.package, "package", "Package");
8172
+ macro("sensor", "sensor", TAXONOMY_COLORS.sensor, "sensor", "Sensor");
8173
+ macro("control", "control", TAXONOMY_COLORS.control, "control", "Control");
8174
+ for (const [cocoClass, macroClass] of Object.entries(COCO_TO_MACRO.mapping)) {
8175
+ if (macroClass !== "vehicle" && macroClass !== "animal") continue;
8176
+ if (entries.has(cocoClass)) continue;
8177
+ sub(cocoClass, macroClass, "detection", DETECTION_SUB_COLORS[cocoClass] ?? TAXONOMY_COLORS.genericDetection, cocoClass, titleCase(cocoClass));
8178
+ }
8179
+ sub("package-delivered", "package", "package", TAXONOMY_COLORS.package, "package", "Package delivered");
8180
+ sub("package-picked-up", "package", "package", TAXONOMY_COLORS.package, "package", "Package picked up");
8181
+ sub("contact", "sensor", "sensor", "#f59e0b", "door", "Contact");
8182
+ sub("motion-sensor", "sensor", "sensor", TAXONOMY_COLORS.sensor, "pir", "Motion sensor");
8183
+ sub("smoke", "sensor", "sensor", "#ef4444", "smoke", "Smoke");
8184
+ sub("flood", "sensor", "sensor", "#3b82f6", "water", "Water leak");
8185
+ sub("gas", "sensor", "sensor", "#ef4444", "gas", "Gas");
8186
+ sub("carbon-monoxide", "sensor", "sensor", "#dc2626", "smoke", "Carbon monoxide");
8187
+ sub("vibration", "sensor", "sensor", "#eab308", "vibration", "Vibration");
8188
+ sub("tamper", "sensor", "sensor", "#f97316", "tamper", "Tamper");
8189
+ sub("presence", "sensor", "sensor", "#22c55e", "presence", "Presence");
8190
+ sub("enum-sensor", "sensor", "sensor", TAXONOMY_COLORS.sensor, "generic", "Sensor state");
8191
+ sub("device-event", "sensor", "sensor", "#10b981", "button", "Device event");
8192
+ sub("lock", "control", "control", "#0ea5e9", "lock", "Lock");
8193
+ sub("switch", "control", "control", TAXONOMY_COLORS.control, "switch", "Switch");
8194
+ sub("siren", "control", "control", "#dc2626", "siren", "Siren");
8195
+ sub("button", "control", "control", "#10b981", "button", "Button");
8196
+ sub("doorbell", "control", "control", "#a855f7", "doorbell", "Doorbell");
8197
+ for (const l of AUDIO_MACRO_LABELS) {
8198
+ const kind = `audio-${l.id}`;
8199
+ if (entries.has(kind)) continue;
8200
+ sub(kind, "audio", "audio", TAXONOMY_COLORS.audio, kind, l.name);
8201
+ }
8202
+ /** The complete taxonomy dictionary, keyed by kind. */
8203
+ var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
8204
+ /**
7932
8205
  * Error types for the safe expression engine. Two distinct classes so callers
7933
8206
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
7934
8207
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -15923,17 +16196,30 @@ var EventKindCategorySchema = _enum([
15923
16196
  "audio",
15924
16197
  "detection",
15925
16198
  "sensor",
16199
+ "control",
15926
16200
  "custom",
15927
16201
  "package"
15928
16202
  ]);
16203
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
16204
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
15929
16205
  var EventKindDescriptorSchema = object({
15930
- /** Stable kind id (e.g. 'motion', 'person', 'contact'). */
16206
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
15931
16207
  kind: string(),
16208
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
16209
+ labelKey: string(),
16210
+ /** English fallback label (kept for clients that don't translate). */
15932
16211
  label: string(),
15933
16212
  /** Hex color for timeline/legend rendering. */
15934
16213
  color: string(),
16214
+ /** Dictionary id → lucide component on the UI side. */
16215
+ iconId: string(),
16216
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
15935
16217
  icon: EventKindIconSchema,
15936
16218
  category: EventKindCategorySchema,
16219
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
16220
+ parentKind: string().nullable(),
16221
+ /** Derived from `parentKind`, explicit for the client tree. */
16222
+ level: EventKindLevelSchema,
15937
16223
  /** Which cap + device contributes this kind. For built-ins the camera
15938
16224
  * itself; for sensor kinds the LINKED source device. */
15939
16225
  source: object({
@@ -16006,11 +16292,21 @@ var TrackAudioLabelSchema = object({
16006
16292
  firstAt: number(),
16007
16293
  lastAt: number()
16008
16294
  });
16295
+ /**
16296
+ * How a track was produced. `pipeline` (default / absent) = the spatial
16297
+ * detection+tracking pipeline. `sensor` = a SYNTHETIC track projected from a
16298
+ * linked sensor/control state change (no positions; carries a snapshot). The
16299
+ * spatial subsystems (tracker association, occupancy count, re-id/embedding,
16300
+ * resurrection) MUST skip `sensor` tracks — they have no bbox trajectory.
16301
+ */
16302
+ var TrackSourceSchema = _enum(["pipeline", "sensor"]);
16009
16303
  var TrackSchema = object({
16010
16304
  trackId: string(),
16011
16305
  deviceId: number(),
16012
16306
  className: string(),
16013
16307
  label: string().optional(),
16308
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
16309
+ source: TrackSourceSchema.optional(),
16014
16310
  firstSeen: number(),
16015
16311
  lastSeen: number(),
16016
16312
  /** Frame-rate position history (subject to maxPositionHistory cap). */
@@ -16387,6 +16683,76 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
16387
16683
  eventId: string(),
16388
16684
  timestamp: number()
16389
16685
  });
16686
+ /**
16687
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
16688
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
16689
+ * caps into per-camera event-kind descriptors.
16690
+ *
16691
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
16692
+ * is NOT duplicated here — every entry is derived from the single
16693
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
16694
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
16695
+ * control cap means adding one line here (and a taxonomy entry); the anti-
16696
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
16697
+ * eventful cap is missing.
16698
+ */
16699
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
16700
+ var LEGACY_ICON = {
16701
+ motion: "motion",
16702
+ audio: "audio",
16703
+ person: "person",
16704
+ vehicle: "vehicle",
16705
+ animal: "animal",
16706
+ package: "package",
16707
+ door: "door",
16708
+ pir: "pir",
16709
+ smoke: "smoke",
16710
+ water: "water",
16711
+ button: "button",
16712
+ generic: "generic",
16713
+ gas: "smoke",
16714
+ vibration: "generic",
16715
+ tamper: "generic",
16716
+ presence: "person",
16717
+ lock: "generic",
16718
+ siren: "generic",
16719
+ switch: "generic",
16720
+ doorbell: "button"
16721
+ };
16722
+ function legacyIcon(iconId) {
16723
+ return LEGACY_ICON[iconId] ?? "generic";
16724
+ }
16725
+ /**
16726
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
16727
+ * The anti-drift guard cross-checks this against the eventful caps declared
16728
+ * in `packages/types/src/capabilities/*.cap.ts`.
16729
+ */
16730
+ var CAP_TO_KIND = {
16731
+ contact: "contact",
16732
+ motion: "motion-sensor",
16733
+ smoke: "smoke",
16734
+ flood: "flood",
16735
+ gas: "gas",
16736
+ "carbon-monoxide": "carbon-monoxide",
16737
+ vibration: "vibration",
16738
+ tamper: "tamper",
16739
+ presence: "presence",
16740
+ "enum-sensor": "enum-sensor",
16741
+ "event-emitter": "device-event",
16742
+ "lock-control": "lock",
16743
+ switch: "switch",
16744
+ button: "button",
16745
+ doorbell: "doorbell"
16746
+ };
16747
+ function buildDescriptor(capName, kind) {
16748
+ const t = EVENT_TAXONOMY[kind];
16749
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
16750
+ return {
16751
+ ...t,
16752
+ icon: legacyIcon(t.iconId)
16753
+ };
16754
+ }
16755
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
16390
16756
  var CameraPipelineConfigSchema = object({
16391
16757
  engine: PipelineEngineChoiceSchema.optional(),
16392
16758
  steps: array(PipelineStepInputSchema).readonly(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-ai",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "AI addon for CamStack — the `llm` collection provider (cloud, LAN, and camstack-managed local llama.cpp profiles) plus the per-node `llm-runtime` managed executor.",
5
5
  "keywords": [
6
6
  "camstack",