@camstack/addon-model-studio 1.0.27 → 1.0.28

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.
@@ -7691,6 +7691,160 @@ var CAP_NODE_PIN_CONTEXT_KEY = "__camstackNodePin";
7691
7691
  function nodePin(nodeId) {
7692
7692
  return { context: { [CAP_NODE_PIN_CONTEXT_KEY]: nodeId } };
7693
7693
  }
7694
+ var COCO_TO_MACRO = {
7695
+ mapping: {
7696
+ person: "person",
7697
+ bicycle: "vehicle",
7698
+ car: "vehicle",
7699
+ motorcycle: "vehicle",
7700
+ airplane: "vehicle",
7701
+ bus: "vehicle",
7702
+ train: "vehicle",
7703
+ truck: "vehicle",
7704
+ boat: "vehicle",
7705
+ bird: "animal",
7706
+ cat: "animal",
7707
+ dog: "animal",
7708
+ horse: "animal",
7709
+ sheep: "animal",
7710
+ cow: "animal",
7711
+ elephant: "animal",
7712
+ bear: "animal",
7713
+ zebra: "animal",
7714
+ giraffe: "animal",
7715
+ suitcase: "package",
7716
+ backpack: "package",
7717
+ handbag: "package"
7718
+ },
7719
+ preserveOriginal: false
7720
+ };
7721
+ var AUDIO_MACRO_LABELS = [
7722
+ {
7723
+ id: "speech",
7724
+ name: "Speech",
7725
+ icon: "🗣️"
7726
+ },
7727
+ {
7728
+ id: "scream",
7729
+ name: "Scream / Shout",
7730
+ icon: "😱"
7731
+ },
7732
+ {
7733
+ id: "crying",
7734
+ name: "Crying / Baby",
7735
+ icon: "😢"
7736
+ },
7737
+ {
7738
+ id: "laughter",
7739
+ name: "Laughter",
7740
+ icon: "😂"
7741
+ },
7742
+ {
7743
+ id: "music",
7744
+ name: "Music",
7745
+ icon: "🎵"
7746
+ },
7747
+ {
7748
+ id: "dog",
7749
+ name: "Dog",
7750
+ icon: "🐕"
7751
+ },
7752
+ {
7753
+ id: "cat",
7754
+ name: "Cat",
7755
+ icon: "🐈"
7756
+ },
7757
+ {
7758
+ id: "bird",
7759
+ name: "Bird",
7760
+ icon: "🐦"
7761
+ },
7762
+ {
7763
+ id: "animal",
7764
+ name: "Animal (other)",
7765
+ icon: "🐾"
7766
+ },
7767
+ {
7768
+ id: "alarm",
7769
+ name: "Alarm / Siren",
7770
+ icon: "🚨"
7771
+ },
7772
+ {
7773
+ id: "doorbell",
7774
+ name: "Doorbell / Knock",
7775
+ icon: "🔔"
7776
+ },
7777
+ {
7778
+ id: "glass_breaking",
7779
+ name: "Glass Breaking",
7780
+ icon: "💥"
7781
+ },
7782
+ {
7783
+ id: "gunshot",
7784
+ name: "Gunshot / Explosion",
7785
+ icon: "💣"
7786
+ },
7787
+ {
7788
+ id: "vehicle",
7789
+ name: "Vehicle",
7790
+ icon: "🚗"
7791
+ },
7792
+ {
7793
+ id: "siren",
7794
+ name: "Emergency Siren",
7795
+ icon: "🚑"
7796
+ },
7797
+ {
7798
+ id: "fire",
7799
+ name: "Fire / Smoke",
7800
+ icon: "🔥"
7801
+ },
7802
+ {
7803
+ id: "water",
7804
+ name: "Water",
7805
+ icon: "💧"
7806
+ },
7807
+ {
7808
+ id: "wind",
7809
+ name: "Wind / Weather",
7810
+ icon: "🌬️"
7811
+ },
7812
+ {
7813
+ id: "door",
7814
+ name: "Door",
7815
+ icon: "🚪"
7816
+ },
7817
+ {
7818
+ id: "footsteps",
7819
+ name: "Footsteps",
7820
+ icon: "👣"
7821
+ },
7822
+ {
7823
+ id: "crowd",
7824
+ name: "Crowd / Chatter",
7825
+ icon: "👥"
7826
+ },
7827
+ {
7828
+ id: "telephone",
7829
+ name: "Telephone",
7830
+ icon: "📞"
7831
+ },
7832
+ {
7833
+ id: "engine",
7834
+ name: "Engine / Motor",
7835
+ icon: "⚙️"
7836
+ },
7837
+ {
7838
+ id: "tools",
7839
+ name: "Tools / Construction",
7840
+ icon: "🔨"
7841
+ },
7842
+ {
7843
+ id: "silence",
7844
+ name: "Silence",
7845
+ icon: "🤫"
7846
+ }
7847
+ ];
7694
7848
  var YAMNET_TO_MACRO = {
7695
7849
  mapping: {
7696
7850
  Speech: "speech",
@@ -7957,6 +8111,125 @@ var _macroLookup = /* @__PURE__ */ new Map();
7957
8111
  for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7958
8112
  for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7959
8113
  /**
8114
+ * Unified event-kind taxonomy — THE single source of truth for
8115
+ * `kind → { parentKind, category, level, color, iconId, labelKey, label,
8116
+ * icon }`.
8117
+ *
8118
+ * This dictionary folds together what used to be scattered across four
8119
+ * copies:
8120
+ * - `capabilities/sensor-event-kinds.ts` (sensor cap colors)
8121
+ * - `addon-post-analysis/.../services/event-kinds.ts`
8122
+ * (MOTION/PERSON/VEHICLE… _COLOR constants)
8123
+ * - `ui-library/composites/detection-colors.ts` (CLASS_COLORS)
8124
+ * - `addon-post-analysis/shared/frame/box-drawer.ts` (DEFAULT_COLOR)
8125
+ * - the COCO / audio class maps (macro ↔ sub relationships)
8126
+ *
8127
+ * The DATA (serializable — color/iconId/labelKey/parentKind) lives here in
8128
+ * `@camstack/types`. The UI-side mapping `iconId → lucide component` and
8129
+ * `labelKey → t()` lives in `@camstack/ui-library`. UIs never hardcode a
8130
+ * color or an icon: they read this dictionary (server descriptors carry the
8131
+ * fields inline; the client resolves color/icon/label from `iconId`/`kind`).
8132
+ *
8133
+ * Two levels only (v1 YAGNI): macro → sub. `person` is a leaf macro.
8134
+ */
8135
+ var TAXONOMY_COLORS = {
8136
+ motion: "#f59e0b",
8137
+ audio: "#06b6d4",
8138
+ person: "#22c55e",
8139
+ vehicle: "#3b82f6",
8140
+ animal: "#f97316",
8141
+ package: "#a855f7",
8142
+ sensor: "#8b5cf6",
8143
+ control: "#10b981",
8144
+ genericDetection: "#64748b"
8145
+ };
8146
+ var DETECTION_SUB_COLORS = {
8147
+ car: "#f59e0b",
8148
+ truck: "#d97706",
8149
+ bus: "#b45309",
8150
+ motorcycle: "#eab308",
8151
+ bicycle: "#ca8a04",
8152
+ airplane: "#60a5fa",
8153
+ boat: "#2563eb",
8154
+ train: "#1d4ed8",
8155
+ bird: "#14b8a6",
8156
+ dog: "#84cc16",
8157
+ cat: "#f97316",
8158
+ horse: "#a16207",
8159
+ sheep: "#a3a3a3",
8160
+ cow: "#78716c",
8161
+ elephant: "#6b7280",
8162
+ bear: "#7c2d12",
8163
+ zebra: "#404040",
8164
+ giraffe: "#d4a373"
8165
+ };
8166
+ function titleCase(id) {
8167
+ return id.split(/[-_ ]/).filter((p) => p.length > 0).map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join(" ");
8168
+ }
8169
+ var entries = /* @__PURE__ */ new Map();
8170
+ function macro(kind, category, color, iconId, label) {
8171
+ entries.set(kind, {
8172
+ kind,
8173
+ parentKind: null,
8174
+ level: "macro",
8175
+ category,
8176
+ color,
8177
+ iconId,
8178
+ labelKey: `eventKind.${kind}`,
8179
+ label
8180
+ });
8181
+ }
8182
+ function sub(kind, parentKind, category, color, iconId, label) {
8183
+ entries.set(kind, {
8184
+ kind,
8185
+ parentKind,
8186
+ level: "sub",
8187
+ category,
8188
+ color,
8189
+ iconId,
8190
+ labelKey: `eventKind.${kind}`,
8191
+ label
8192
+ });
8193
+ }
8194
+ macro("motion", "motion", TAXONOMY_COLORS.motion, "motion", "Motion");
8195
+ macro("audio", "audio", TAXONOMY_COLORS.audio, "audio", "Audio");
8196
+ macro("person", "detection", TAXONOMY_COLORS.person, "person", "Person");
8197
+ macro("vehicle", "detection", TAXONOMY_COLORS.vehicle, "vehicle", "Vehicle");
8198
+ macro("animal", "detection", TAXONOMY_COLORS.animal, "animal", "Animal");
8199
+ macro("package", "package", TAXONOMY_COLORS.package, "package", "Package");
8200
+ macro("sensor", "sensor", TAXONOMY_COLORS.sensor, "sensor", "Sensor");
8201
+ macro("control", "control", TAXONOMY_COLORS.control, "control", "Control");
8202
+ for (const [cocoClass, macroClass] of Object.entries(COCO_TO_MACRO.mapping)) {
8203
+ if (macroClass !== "vehicle" && macroClass !== "animal") continue;
8204
+ if (entries.has(cocoClass)) continue;
8205
+ sub(cocoClass, macroClass, "detection", DETECTION_SUB_COLORS[cocoClass] ?? TAXONOMY_COLORS.genericDetection, cocoClass, titleCase(cocoClass));
8206
+ }
8207
+ sub("package-delivered", "package", "package", TAXONOMY_COLORS.package, "package", "Package delivered");
8208
+ sub("package-picked-up", "package", "package", TAXONOMY_COLORS.package, "package", "Package picked up");
8209
+ sub("contact", "sensor", "sensor", "#f59e0b", "door", "Contact");
8210
+ sub("motion-sensor", "sensor", "sensor", TAXONOMY_COLORS.sensor, "pir", "Motion sensor");
8211
+ sub("smoke", "sensor", "sensor", "#ef4444", "smoke", "Smoke");
8212
+ sub("flood", "sensor", "sensor", "#3b82f6", "water", "Water leak");
8213
+ sub("gas", "sensor", "sensor", "#ef4444", "gas", "Gas");
8214
+ sub("carbon-monoxide", "sensor", "sensor", "#dc2626", "smoke", "Carbon monoxide");
8215
+ sub("vibration", "sensor", "sensor", "#eab308", "vibration", "Vibration");
8216
+ sub("tamper", "sensor", "sensor", "#f97316", "tamper", "Tamper");
8217
+ sub("presence", "sensor", "sensor", "#22c55e", "presence", "Presence");
8218
+ sub("enum-sensor", "sensor", "sensor", TAXONOMY_COLORS.sensor, "generic", "Sensor state");
8219
+ sub("device-event", "sensor", "sensor", "#10b981", "button", "Device event");
8220
+ sub("lock", "control", "control", "#0ea5e9", "lock", "Lock");
8221
+ sub("switch", "control", "control", TAXONOMY_COLORS.control, "switch", "Switch");
8222
+ sub("siren", "control", "control", "#dc2626", "siren", "Siren");
8223
+ sub("button", "control", "control", "#10b981", "button", "Button");
8224
+ sub("doorbell", "control", "control", "#a855f7", "doorbell", "Doorbell");
8225
+ for (const l of AUDIO_MACRO_LABELS) {
8226
+ const kind = `audio-${l.id}`;
8227
+ if (entries.has(kind)) continue;
8228
+ sub(kind, "audio", "audio", TAXONOMY_COLORS.audio, kind, l.name);
8229
+ }
8230
+ /** The complete taxonomy dictionary, keyed by kind. */
8231
+ var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
8232
+ /**
7960
8233
  * Error types for the safe expression engine. Two distinct classes so callers
7961
8234
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
7962
8235
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -15945,17 +16218,30 @@ var EventKindCategorySchema = _enum([
15945
16218
  "audio",
15946
16219
  "detection",
15947
16220
  "sensor",
16221
+ "control",
15948
16222
  "custom",
15949
16223
  "package"
15950
16224
  ]);
16225
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
16226
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
15951
16227
  var EventKindDescriptorSchema = object({
15952
- /** Stable kind id (e.g. 'motion', 'person', 'contact'). */
16228
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
15953
16229
  kind: string(),
16230
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
16231
+ labelKey: string(),
16232
+ /** English fallback label (kept for clients that don't translate). */
15954
16233
  label: string(),
15955
16234
  /** Hex color for timeline/legend rendering. */
15956
16235
  color: string(),
16236
+ /** Dictionary id → lucide component on the UI side. */
16237
+ iconId: string(),
16238
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
15957
16239
  icon: EventKindIconSchema,
15958
16240
  category: EventKindCategorySchema,
16241
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
16242
+ parentKind: string().nullable(),
16243
+ /** Derived from `parentKind`, explicit for the client tree. */
16244
+ level: EventKindLevelSchema,
15959
16245
  /** Which cap + device contributes this kind. For built-ins the camera
15960
16246
  * itself; for sensor kinds the LINKED source device. */
15961
16247
  source: object({
@@ -16028,11 +16314,21 @@ var TrackAudioLabelSchema = object({
16028
16314
  firstAt: number(),
16029
16315
  lastAt: number()
16030
16316
  });
16317
+ /**
16318
+ * How a track was produced. `pipeline` (default / absent) = the spatial
16319
+ * detection+tracking pipeline. `sensor` = a SYNTHETIC track projected from a
16320
+ * linked sensor/control state change (no positions; carries a snapshot). The
16321
+ * spatial subsystems (tracker association, occupancy count, re-id/embedding,
16322
+ * resurrection) MUST skip `sensor` tracks — they have no bbox trajectory.
16323
+ */
16324
+ var TrackSourceSchema = _enum(["pipeline", "sensor"]);
16031
16325
  var TrackSchema = object({
16032
16326
  trackId: string(),
16033
16327
  deviceId: number(),
16034
16328
  className: string(),
16035
16329
  label: string().optional(),
16330
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
16331
+ source: TrackSourceSchema.optional(),
16036
16332
  firstSeen: number(),
16037
16333
  lastSeen: number(),
16038
16334
  /** Frame-rate position history (subject to maxPositionHistory cap). */
@@ -16409,6 +16705,76 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
16409
16705
  eventId: string(),
16410
16706
  timestamp: number()
16411
16707
  });
16708
+ /**
16709
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
16710
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
16711
+ * caps into per-camera event-kind descriptors.
16712
+ *
16713
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
16714
+ * is NOT duplicated here — every entry is derived from the single
16715
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
16716
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
16717
+ * control cap means adding one line here (and a taxonomy entry); the anti-
16718
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
16719
+ * eventful cap is missing.
16720
+ */
16721
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
16722
+ var LEGACY_ICON = {
16723
+ motion: "motion",
16724
+ audio: "audio",
16725
+ person: "person",
16726
+ vehicle: "vehicle",
16727
+ animal: "animal",
16728
+ package: "package",
16729
+ door: "door",
16730
+ pir: "pir",
16731
+ smoke: "smoke",
16732
+ water: "water",
16733
+ button: "button",
16734
+ generic: "generic",
16735
+ gas: "smoke",
16736
+ vibration: "generic",
16737
+ tamper: "generic",
16738
+ presence: "person",
16739
+ lock: "generic",
16740
+ siren: "generic",
16741
+ switch: "generic",
16742
+ doorbell: "button"
16743
+ };
16744
+ function legacyIcon(iconId) {
16745
+ return LEGACY_ICON[iconId] ?? "generic";
16746
+ }
16747
+ /**
16748
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
16749
+ * The anti-drift guard cross-checks this against the eventful caps declared
16750
+ * in `packages/types/src/capabilities/*.cap.ts`.
16751
+ */
16752
+ var CAP_TO_KIND = {
16753
+ contact: "contact",
16754
+ motion: "motion-sensor",
16755
+ smoke: "smoke",
16756
+ flood: "flood",
16757
+ gas: "gas",
16758
+ "carbon-monoxide": "carbon-monoxide",
16759
+ vibration: "vibration",
16760
+ tamper: "tamper",
16761
+ presence: "presence",
16762
+ "enum-sensor": "enum-sensor",
16763
+ "event-emitter": "device-event",
16764
+ "lock-control": "lock",
16765
+ switch: "switch",
16766
+ button: "button",
16767
+ doorbell: "doorbell"
16768
+ };
16769
+ function buildDescriptor(capName, kind) {
16770
+ const t = EVENT_TAXONOMY[kind];
16771
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
16772
+ return {
16773
+ ...t,
16774
+ icon: legacyIcon(t.iconId)
16775
+ };
16776
+ }
16777
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
16412
16778
  var CameraPipelineConfigSchema = object({
16413
16779
  engine: PipelineEngineChoiceSchema.optional(),
16414
16780
  steps: array(PipelineStepInputSchema).readonly(),