@camstack/addon-model-studio 1.1.43 → 1.1.45

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.
Files changed (17) hide show
  1. package/dist/{MotionZonesSettings-BQmeOC6s.mjs → MotionZonesSettings-BA2jeOR6.mjs} +2 -2
  2. package/dist/{PrivacyMaskSettings-MznS24IR.mjs → PrivacyMaskSettings-Bf1hFhGN.mjs} +4 -4
  3. package/dist/{SceneMonitorEditor-slpx5RVW.mjs → SceneMonitorEditor-DcKcwKsJ.mjs} +3 -3
  4. package/dist/_stub.js +10 -10
  5. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_model_studio_page-Dvg3AwY0.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_model_studio_page-B-ZMvrf0.mjs} +4 -4
  6. package/dist/{_virtual_mf___mfe_internal__addon_model_studio_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-Dz7eB41h.mjs → _virtual_mf___mfe_internal__addon_model_studio_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-C3sZIjJ6.mjs} +1 -1
  7. package/dist/{hostInit-9uaH_tWZ.mjs → hostInit-BZM9cD30.mjs} +3 -3
  8. package/dist/model-studio.addon.js +1585 -1437
  9. package/dist/model-studio.addon.mjs +1585 -1437
  10. package/dist/{player-overlays-ZV106hch.mjs → player-overlays-CUJ2regU.mjs} +1 -1
  11. package/dist/remoteEntry.js +1 -1
  12. package/dist/{responsive-BWcJ76VI.mjs → responsive-pq6YOPGN.mjs} +1 -1
  13. package/dist/{square-DK5dno3H.mjs → square-BFrlalUj.mjs} +1 -1
  14. package/dist/{trash-2-B9ZCrm5O.mjs → trash-2-KCXgMJqK.mjs} +1 -1
  15. package/dist/{use-device-snapshot-_PNv-X_c.mjs → use-device-snapshot-C9mtUHIM.mjs} +1 -1
  16. package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_model_studio_page__remoteEntry_js-DQmO25Hm.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_model_studio_page__remoteEntry_js-DlP1RQa1.mjs} +1 -1
  17. package/package.json +1 -1
@@ -16181,7 +16181,23 @@ var NcHistoryEntrySchema = object({
16181
16181
  updatedAt: number(),
16182
16182
  /** Failure detail — present on a `dead` row. */
16183
16183
  error: string().optional(),
16184
- subject: NcHistorySubjectSchema
16184
+ subject: NcHistorySubjectSchema,
16185
+ /**
16186
+ * Ids of the artefacts (still, then gif, then clip) this row's successful
16187
+ * delivery indexed in the artefact library — a REFERENCE, never the bytes
16188
+ * (an artefact is often megabytes; this row is durable JSON rewritten on
16189
+ * every delivery attempt). Absent on a row still pending/dead, a row
16190
+ * delivered before this field shipped, or a wiring with no artefact index.
16191
+ *
16192
+ * Resolve one to a fetchable URL with `resolveArtifactUrl` — an id
16193
+ * outlives any one URL's TTL, so a caller mints a fresh link on demand
16194
+ * rather than trusting one frozen at delivery time. `resolveArtifactUrl`
16195
+ * also answers `null` for an id whose artefact has since expired past the
16196
+ * retained shelf's own age bound — the degrade a caller (the Home
16197
+ * Assistant export) must render as "no image right now", never as a
16198
+ * broken link.
16199
+ */
16200
+ artifactIds: array(string().min(1)).optional()
16185
16201
  });
16186
16202
  /**
16187
16203
  * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
@@ -16408,7 +16424,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
16408
16424
  }), method(object({}), object({
16409
16425
  catalog: array(NcConditionDescriptorSchema),
16410
16426
  taxonomy: NcTaxonomySchema.optional()
16411
- })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" }), method(object({}), object({ snoozes: array(NcSnoozeSchema) }), { caller: "required" }), method(object({ snooze: NcSnoozeInputSchema }), object({ snooze: NcSnoozeSchema }), {
16427
+ })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" }), method(object({ artifactId: string().min(1) }), object({ url: string().nullable() }), { auth: "admin" }), method(object({}), object({ snoozes: array(NcSnoozeSchema) }), { caller: "required" }), method(object({ snooze: NcSnoozeInputSchema }), object({ snooze: NcSnoozeSchema }), {
16412
16428
  kind: "mutation",
16413
16429
  caller: "required"
16414
16430
  }), method(object({ snoozeId: string() }), object({ success: literal(true) }), {
@@ -16748,896 +16764,1496 @@ var OauthIntegrationDescriptorSchema = object({
16748
16764
  });
16749
16765
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
16750
16766
  /**
16751
- * pipeline-analytics device-scoped wrapper cap. Refines raw
16752
- * per-frame detections emitted by the pipeline runner into tracked
16753
- * objects, per-kind event collections (motion / object / audio), and
16754
- * persisted media. Owns the post-detection domain end-to-end:
16755
- *
16756
- * runner emits PipelineInferenceResult
16757
- * ↓ (event bus)
16758
- * pipeline-analytics subscriber
16759
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
16760
- * → three DB collections (one per kind), one FS media tree, one
16761
- * unified event emitter (FrameTracked + TrackStarted/Ended +
16762
- * DetectionEvent on bus)
16763
- *
16764
- * Pure subscriber model. No `processFrame` cap method — the runner
16765
- * already publishes the raw frame on the bus. The cap surface is
16766
- * only QUERIES + per-device settings, bound on/off via
16767
- * `device-manager.setWrapperActive`. `defaultActive: true` because
16768
- * every camera with a detection pipeline wants its raw detections
16769
- * refined; operators opt out per-device via BindingsTab when needed.
16770
- *
16771
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
16772
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
16767
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
16768
+ * within the frame, so the executor can re-cut a leaf child ROI at native
16769
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
16773
16770
  */
16774
- var TrackStateSchema = _enum([
16775
- "new",
16776
- "entered",
16777
- "left",
16778
- "moving",
16779
- "idle"
16780
- ]);
16781
- var EventKindSchema = _enum([
16782
- "motion",
16783
- "object",
16784
- "audio"
16785
- ]);
16771
+ var NativeCropRefSchema = object({
16772
+ /** Handle keying the retained native surface (node-pinned to its owner). */
16773
+ handle: FrameHandleSchema,
16774
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
16775
+ cropFrameSpace: object({
16776
+ x: number(),
16777
+ y: number(),
16778
+ w: number(),
16779
+ h: number()
16780
+ })
16781
+ });
16782
+ object({
16783
+ crop: object({
16784
+ left: number(),
16785
+ top: number(),
16786
+ width: number().positive(),
16787
+ height: number().positive()
16788
+ }).optional(),
16789
+ content: object({
16790
+ width: number().int().positive(),
16791
+ height: number().int().positive()
16792
+ }),
16793
+ fit: _enum(["stretch", "contain"]),
16794
+ format: _enum([
16795
+ "rgb",
16796
+ "gray",
16797
+ "jpeg"
16798
+ ])
16799
+ });
16786
16800
  /**
16787
- * Spatial filter for `listTracks` the rect + polygon variants of the shared
16788
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
16789
- * of the camera frame (top-left origin), matching the drawing-plane editor.
16801
+ * Process-local frame identity. It is serializable so it can ride an in-process
16802
+ * capability call, but `registryId` deliberately prevents resolution in any
16803
+ * other process or execution group.
16790
16804
  */
16791
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
16792
- /** Closed icon vocabulary so clients render a known glyph per kind. */
16793
- var EventKindIconSchema = _enum([
16794
- "motion",
16795
- "audio",
16796
- "person",
16797
- "vehicle",
16798
- "animal",
16799
- "door",
16800
- "pir",
16801
- "smoke",
16802
- "water",
16803
- "button",
16804
- "package",
16805
- "generic"
16805
+ var FrameRefSchema = object({
16806
+ registryId: string().min(1),
16807
+ id: string().min(1),
16808
+ width: number().int().positive(),
16809
+ height: number().int().positive(),
16810
+ format: _enum(["rgb", "gray"]),
16811
+ timestamp: number(),
16812
+ capturedAt: number().optional()
16813
+ });
16814
+ var ModelFormatSchema$1 = _enum([
16815
+ "onnx",
16816
+ "coreml",
16817
+ "openvino",
16818
+ "tflite",
16819
+ "pt",
16820
+ "gguf"
16806
16821
  ]);
16807
- var EventKindCategorySchema = _enum([
16808
- "motion",
16809
- "audio",
16810
- "detection",
16811
- "sensor",
16812
- "control",
16813
- "custom",
16814
- "package"
16822
+ var PipelineSlotSchema = _enum([
16823
+ "detector",
16824
+ "cropper",
16825
+ "classifier",
16826
+ "refiner",
16827
+ "audio-classifier"
16815
16828
  ]);
16816
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
16817
- var EventKindLevelSchema = _enum(["macro", "sub"]);
16818
- var EventKindDescriptorSchema = object({
16819
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
16820
- kind: string(),
16821
- /** i18n key resolved on the UI side; `label` is the English fallback. */
16822
- labelKey: string(),
16823
- /** English fallback label (kept for clients that don't translate). */
16824
- label: string(),
16825
- /** Hex color for timeline/legend rendering. */
16826
- color: string(),
16827
- /** Dictionary id → lucide component on the UI side. */
16828
- iconId: string(),
16829
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
16830
- icon: EventKindIconSchema,
16831
- category: EventKindCategorySchema,
16832
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
16833
- parentKind: string().nullable(),
16834
- /** Derived from `parentKind`, explicit for the client tree. */
16835
- level: EventKindLevelSchema,
16836
- /** Which cap + device contributes this kind. For built-ins the camera
16837
- * itself; for sensor kinds the LINKED source device. */
16838
- source: object({
16839
- capName: string(),
16840
- deviceId: number()
16841
- })
16829
+ var PipelineEngineChoiceSchema = object({
16830
+ runtime: _enum(["node", "python"]),
16831
+ backend: string(),
16832
+ format: ModelFormatSchema$1,
16833
+ device: string().optional()
16842
16834
  });
16843
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
16844
- var EventKindsForDeviceSchema = object({
16845
- deviceId: number(),
16846
- kinds: array(EventKindDescriptorSchema).readonly()
16835
+ var AvailableEngineSchema = object({
16836
+ engine: PipelineEngineChoiceSchema,
16837
+ devices: array(object({
16838
+ id: string(),
16839
+ label: string(),
16840
+ description: string().optional()
16841
+ })).readonly(),
16842
+ defaultDevice: string()
16847
16843
  });
16848
- var SensorEventSchema = object({
16844
+ var PipelineDefaultStepSchema = lazy(() => object({
16845
+ addonId: string(),
16846
+ addonName: string(),
16847
+ slot: PipelineSlotSchema,
16848
+ inputClasses: array(string()).readonly(),
16849
+ outputClasses: array(string()).readonly(),
16850
+ enabled: boolean(),
16851
+ modelId: string(),
16852
+ children: array(PipelineDefaultStepSchema).readonly(),
16853
+ group: string().optional(),
16854
+ settings: record(string(), unknown()).optional()
16855
+ }));
16856
+ var PipelineTemplateStepSchema = lazy(() => object({
16857
+ addonId: string(),
16858
+ enabled: boolean(),
16859
+ modelId: string(),
16860
+ children: array(PipelineTemplateStepSchema).readonly(),
16861
+ settings: record(string(), unknown()).optional()
16862
+ }));
16863
+ var PipelineTemplateSchema$1 = object({
16849
16864
  id: string(),
16850
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
16851
- * yields N rows, one per camera). */
16852
- deviceId: number(),
16853
- /** The linked sensor device whose state changed. */
16854
- sourceDeviceId: number(),
16855
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
16856
- kind: string(),
16857
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
16858
- value: record(string(), unknown()).nullable(),
16859
- timestamp: number()
16865
+ name: string(),
16866
+ createdAt: string(),
16867
+ updatedAt: string(),
16868
+ engine: PipelineEngineChoiceSchema,
16869
+ steps: array(PipelineTemplateStepSchema).readonly()
16860
16870
  });
16861
- var TrackPositionSchema = object({
16862
- x: number(),
16863
- y: number(),
16864
- timestamp: number(),
16865
- bbox: BoundingBoxSchema
16871
+ var PipelineModelOptionSchema = object({
16872
+ id: string(),
16873
+ name: string(),
16874
+ formats: record(string(), object({
16875
+ downloaded: boolean(),
16876
+ sizeMB: number()
16877
+ })),
16878
+ group: ModelVariantGroupSchema.optional(),
16879
+ legacy: boolean().optional(),
16880
+ provider: ModelProviderIdSchema.optional()
16866
16881
  });
16867
- var TrackSnapshotSchema = object({
16868
- timestamp: number(),
16869
- position: TrackPositionSchema,
16870
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
16871
- mediaKey: string()
16882
+ var ConfigFieldBridge = custom();
16883
+ var PipelineAddonSchemaSchema = object({
16884
+ id: string(),
16885
+ name: string(),
16886
+ slot: PipelineSlotSchema,
16887
+ inputClasses: array(string()).readonly(),
16888
+ outputClasses: array(string()).readonly(),
16889
+ childSlots: array(PipelineSlotSchema).readonly(),
16890
+ models: array(PipelineModelOptionSchema).readonly(),
16891
+ defaultModelId: string(),
16892
+ defaultModelIdByFormat: record(string(), string()).optional(),
16893
+ enabledByDefault: boolean().optional(),
16894
+ backfillIntoExistingOverrides: boolean().optional(),
16895
+ defaultConfidence: number(),
16896
+ group: string().optional(),
16897
+ configSchema: array(ConfigFieldBridge).readonly().optional()
16872
16898
  });
16873
- /**
16874
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
16875
- * divided by the track's detection-frame dims), computed at persist time.
16876
- * Absent when the frame dims were unknown when the track was persisted
16877
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
16878
- */
16879
- var TrackEnvelopeSchema = object({
16880
- minX: number(),
16881
- minY: number(),
16882
- maxX: number(),
16883
- maxY: number()
16899
+ var PipelineSlotSchemaSchema = object({
16900
+ id: PipelineSlotSchema,
16901
+ label: string(),
16902
+ priority: number(),
16903
+ parentSlot: PipelineSlotSchema.nullable(),
16904
+ addons: array(PipelineAddonSchemaSchema).readonly()
16884
16905
  });
16885
- /**
16886
- * Row projection for track list queries. `full` (default) returns the
16887
- * complete Track including the frame-rate `positions[]` history and the
16888
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
16889
- * keeps every scalar the list surfaces actually render (ids, class(es),
16890
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
16891
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
16892
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
16893
- * `getTrack`. Mirrors the event-store `projection` convention
16894
- * (`getObjectEvents` et al.).
16895
- */
16896
- var TrackProjectionSchema = _enum(["full", "slim"]);
16897
- /**
16898
- * One audio-classification label heard on the track's camera while the
16899
- * track was alive, aggregated per label. An "episode" is one persisted
16900
- * audio event (the confident-classification path: score ≥ the device's
16901
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
16902
- * one 32 ms inference chunk, so counts stay human-scaled.
16903
- */
16904
- var TrackAudioLabelSchema = object({
16905
- label: string(),
16906
- /** Highest classification score observed across the label's episodes. */
16907
- peakScore: number(),
16908
- /** Number of coalesced audio-event episodes carrying this label. */
16909
- count: number(),
16910
- firstAt: number(),
16911
- lastAt: number()
16906
+ var PipelineSchemaSchema = object({
16907
+ availableEngines: array(AvailableEngineSchema).readonly(),
16908
+ selectedEngine: PipelineEngineChoiceSchema,
16909
+ slots: array(PipelineSlotSchemaSchema).readonly()
16912
16910
  });
16913
- /**
16914
- * How a track was produced. `pipeline` (default / absent) = the spatial
16915
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
16916
- * no positions, a single snapshot, and no bbox trajectory at all:
16917
- *
16918
- * - `sensor` — a linked sensor/control device state change.
16919
- * - `audio` — an audio event on the camera itself that was anomalous for
16920
- * THAT camera, loud, and heard while nothing visual was happening (D62).
16921
- *
16922
- * The spatial subsystems (tracker association, occupancy count, re-id /
16923
- * embedding, resurrection) MUST skip every synthetic source. Test for that
16924
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
16925
- * check silently readmits every source added after it was written.
16926
- */
16927
- var TrackSourceSchema = _enum([
16928
- "pipeline",
16929
- "sensor",
16930
- "audio"
16931
- ]);
16932
- /**
16933
- * Where a track sits in the RETRAIN lifecycle (D81).
16934
- *
16935
- * - `none` never marked, or un-marked. Evictable.
16936
- * - `staging`the operator wants this track as training material and has not
16937
- * finished with it. **This is the only state retention holds**: the track and
16938
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
16939
- * the device's age window.
16940
- * - `trained` — the retrain page has taken what it needed. The frames it chose
16941
- * were COPIED into the retrain dataset at selection time, so the dataset no
16942
- * longer depends on the track's media and the track becomes EVICTABLE again.
16943
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
16944
- * a deliberate action of the retrain page, not a side effect of a checkbox.
16945
- *
16946
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
16947
- * the store's filter language has only positive equality and `whereIn` — no
16948
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
16949
- * would make the entire pre-column history immortal in one deploy.
16950
- */
16951
- var RetrainStatusSchema = _enum([
16952
- "none",
16953
- "staging",
16954
- "trained"
16955
- ]);
16956
- /**
16957
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
16958
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
16959
- * so the two surfaces cannot drift.
16960
- *
16961
- * **Absent ≠ false.** A track that has never been touched omits the field; an
16962
- * explicitly un-flagged track carries `false`. Legacy rows written before the
16963
- * columns existed read as absent, and a consumer that needs a boolean should say
16964
- * `flag === true`, not `flag !== false`.
16965
- *
16966
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
16967
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
16968
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
16969
- * `trained` track reports `false` while refusing both writes. The boolean is
16970
- * kept because three surfaces drive a toggle off it; anything that needs to tell
16971
- * "never marked" from "already trained" must read `retrainStatus`.
16972
- *
16973
- * `debug` does NOT pin; it is attention, not durability.
16974
- *
16975
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16976
- * A favourited track is skipped by retention the same way `staging` is, but
16977
- * it does not enter `none|staging|trained` and has no staging budget.
16978
- */
16979
- var TrackFlagFields = {
16980
- /** Operator marked this track as training material — i.e. `retrainStatus` is
16981
- * `'staging'`. */
16982
- markForTrain: boolean().optional(),
16983
- /** Operator marked this track for diagnostic attention. */
16984
- debug: boolean().optional(),
16985
- /** Operator favourited this track. Pins it against pruning. */
16986
- favourited: boolean().optional()
16987
- };
16988
- /**
16989
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
16990
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
16991
- * write patch, and the status is not something the toggle sets — it is what the
16992
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
16993
- * always present on a persisted row (the column default materialises `'none'`).
16994
- */
16995
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
16996
- /**
16997
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
16998
- * one flag can never clear the other — the toggles are independent and are
16999
- * driven from three surfaces that do not know about each other.
17000
- */
17001
- var TrackFlagsPatchSchema = object(TrackFlagFields);
17002
- /**
17003
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
17004
- * collapses to `false`) so a caller can drive a toggle's checked state off the
17005
- * mutation result without a re-fetch.
17006
- */
17007
- var TrackFlagsSchema = object({
17008
- trackId: string(),
17009
- markForTrain: boolean(),
17010
- debug: boolean(),
17011
- favourited: boolean(),
17012
- /** The lifecycle state the boolean was derived from. Required here (unlike on
17013
- * a track row) because this shape is only ever produced by the write body,
17014
- * which always knows it — and a surface that has just written needs to render
17015
- * `trained` without a re-fetch. */
17016
- retrainStatus: RetrainStatusSchema
16911
+ var EngineProvisioningSchema = object({
16912
+ runtimeId: _enum([
16913
+ "onnx",
16914
+ "openvino",
16915
+ "coreml",
16916
+ "edgetpu"
16917
+ ]).nullable(),
16918
+ device: string().nullable(),
16919
+ state: _enum([
16920
+ "idle",
16921
+ "installing",
16922
+ "verifying",
16923
+ "ready",
16924
+ "failed"
16925
+ ]),
16926
+ progress: number().optional(),
16927
+ error: string().optional(),
16928
+ nextRetryAt: number().optional(),
16929
+ /**
16930
+ * Gate A (config-correctness gate at engine change): human-readable
16931
+ * config issues surfaced EAGERLY when the node's engine changes — model
16932
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
16933
+ * has a <format> build"). Additive/optional: informational only, never
16934
+ * enforced here `assertEngineReady` (readiness) still gates inference.
16935
+ * Absent/empty when the node-default tree resolves cleanly.
16936
+ */
16937
+ configIssues: array(string()).optional()
17017
16938
  });
17018
- union([literal(1), literal(2)]);
17019
- /**
17020
- * WHO decided a label, and when. Carried per tier so a value can be traced to
17021
- * the step and model that produced it — which is what makes the write rule
17022
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17023
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17024
- *
17025
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17026
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17027
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
17028
- * that value has no provenance, and the write rule lets ANY properly-attributed
17029
- * write of the same tier replace it regardless of score.
17030
- */
17031
- var LabelAttributionSchema = object({
17032
- stepId: string(),
16939
+ var PipelineStepInputSchema = lazy(() => object({
16940
+ addonId: string(),
17033
16941
  modelId: string().optional(),
17034
- decidedAt: number(),
16942
+ enabled: boolean().default(true),
16943
+ children: array(PipelineStepInputSchema).optional(),
16944
+ settings: record(string(), unknown()).optional(),
16945
+ jumpDeviceKey: string().optional()
16946
+ }));
16947
+ var ModelSubstitutionSchema = object({
16948
+ addonId: string(),
16949
+ chosen: string(),
16950
+ running: string(),
16951
+ format: string()
16952
+ });
16953
+ var PipelineValidationIssueSchema = object({
16954
+ addonId: string(),
16955
+ kind: _enum(["unknown-addon", "no-format-build"]),
16956
+ detail: string()
16957
+ });
16958
+ var PipelineValidationResultSchema = object({
16959
+ ok: boolean(),
16960
+ issues: array(PipelineValidationIssueSchema).readonly(),
16961
+ substitutions: array(ModelSubstitutionSchema).readonly(),
16962
+ /** The node's `currentEngine.format` this validation ran against. */
16963
+ format: string()
16964
+ });
16965
+ var ReferenceImageEntrySchema = object({
16966
+ filename: string(),
16967
+ stepIds: array(string()).readonly().optional()
16968
+ });
16969
+ var ReferenceImageBodySchema = object({
16970
+ base64: string(),
16971
+ filename: string()
16972
+ });
16973
+ var ReferenceAudioEntrySchema = object({
16974
+ filename: string(),
16975
+ sizeKb: number()
16976
+ });
16977
+ var ReferenceAudioBodySchema = object({ base64: string() });
16978
+ var AudioBackendSchema = object({
16979
+ id: string(),
16980
+ name: string(),
16981
+ description: string(),
16982
+ available: boolean(),
17035
16983
  /**
17036
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
17037
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17038
- *
17039
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
17040
- * notification rule authored on "Gianluca" stopped matching the moment the
17041
- * operator fixed the spelling in the gallery, and nothing said so. The id is
17042
- * the thing that does not move, so it is what a rule matches on
17043
- * (`NcConditions.identities`) and the text is what a human is shown.
17044
- *
17045
- * Absent when the label names no gallery row — a plate the OCR read but no
17046
- * vehicle claims, a sub-class, a species, any tier-1 value.
16984
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
16985
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
16986
+ * the benchmark UI to populate the `enabledMicroClasses` filter
16987
+ * specific to the selected backend without a separate fetch.
17047
16988
  */
17048
- identityId: string().optional()
16989
+ rawLabels: array(string()).readonly().optional()
16990
+ });
16991
+ var AudioCapabilitiesSchema = object({
16992
+ activeBackend: string(),
16993
+ availableBackends: array(AudioBackendSchema).readonly(),
16994
+ sampleRate: number(),
16995
+ chunkDurationMs: number()
16996
+ });
16997
+ var DownloadModelResultSchema = object({
16998
+ filePath: string(),
16999
+ sizeMB: number(),
17000
+ durationMs: number()
17049
17001
  });
17050
17002
  /**
17051
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17052
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17053
- * track and its events always answer the same question the same way.
17054
- *
17055
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
17056
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17057
- * is tier 2, and each carries its own score + attribution.
17058
- *
17059
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17060
- * finest thing known. Before 4g the single `label` column held the finest
17061
- * value, so a consumer that has not been updated reads the tier-1 slot and
17062
- * shows nothing on a species-only row; that is why the migration puts every
17063
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17064
- * and why the read surfaces were changed in the same train.
17065
- *
17066
- * **Writing it.** The slots are independent, which is the whole point: a
17067
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17068
- * migratorius`), so fineness cannot regress by construction. Within a tier the
17069
- * higher score wins. One rule, one implementation — see
17070
- * `pipeline/label-tier.ts` in addon-post-analysis.
17071
- */
17072
- var TieredLabelFields = {
17073
- /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
17074
- label: string().optional(),
17075
- /** Confidence of the tier-1 value, as reported by the deciding step. */
17076
- labelScore: number().optional(),
17077
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17078
- labelMeta: LabelAttributionSchema.optional(),
17079
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17080
- subLabel: string().optional(),
17081
- /** Confidence of the tier-2 value, as reported by the deciding step. */
17082
- subLabelScore: number().optional(),
17083
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17084
- subLabelMeta: LabelAttributionSchema.optional()
17085
- };
17086
- /** Per-camera slice of a training-export estimate. */
17087
- var TrainingExportDeviceTotalsSchema = object({
17088
- deviceId: number(),
17089
- tracks: number().int(),
17090
- files: number().int(),
17091
- bytes: number().int()
17092
- });
17093
- /**
17094
- * What a training export WOULD contain. Computed from media index rows only —
17095
- * no blob is read to produce this.
17003
+ * Wrapper carrying a single test run's result. Replaces the legacy
17004
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
17005
+ * canonical `AudioResult` from the Phase 6 output rework: one
17006
+ * `AudioDetection` per class above `minScore`, top-N candidates in
17007
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
17008
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
17009
+ * benchmark UI can still report a clean failure when the classifier
17010
+ * cap isn't available.
17096
17011
  */
17097
- var TrainingExportSummarySchema = object({
17098
- generatedAt: number(),
17099
- trackCount: number().int(),
17100
- fileCount: number().int(),
17101
- byteCount: number().int(),
17102
- /** More marked tracks exist than a single pass carries. */
17103
- truncated: boolean(),
17104
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
17012
+ var AudioTestResultSchema = object({
17013
+ success: boolean(),
17014
+ error: string().optional(),
17015
+ frame: custom().optional()
17105
17016
  });
17106
- var TrackSchema = object({
17107
- trackId: string(),
17108
- deviceId: number(),
17109
- className: string(),
17110
- ...TieredLabelFields,
17111
- producingDeviceName: string().optional(),
17112
- /** Track provenance. Absent `pipeline` (legacy rows). */
17113
- source: TrackSourceSchema.optional(),
17114
- firstSeen: number(),
17115
- lastSeen: number(),
17116
- /** Frame-rate position history (subject to maxPositionHistory cap). */
17117
- positions: array(TrackPositionSchema).readonly(),
17118
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17119
- * saveThumbnails policy). */
17120
- snapshots: array(TrackSnapshotSchema).readonly(),
17121
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
17122
- zonesVisited: array(string()).readonly(),
17017
+ var PipelineConfigBridge = custom();
17018
+ var ConfigUISchemaBridge = custom();
17019
+ var ConfigUISchemaNullableBridge = custom();
17020
+ var InferenceCapabilitiesBridge = custom();
17021
+ var ModelAvailabilityListBridge = custom();
17022
+ var PipelineRunResultBridge = custom();
17023
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
17024
+ modelId: string(),
17025
+ settings: record(string(), unknown()).readonly()
17026
+ }))), method(object({ steps: record(string(), object({
17027
+ modelId: string(),
17028
+ settings: record(string(), unknown()).readonly()
17029
+ })) }), object({ success: literal(true) }), {
17030
+ kind: "mutation",
17031
+ auth: "admin"
17032
+ }), method(object({ nodeId: string() }), object({
17033
+ success: literal(true),
17034
+ clearedDevices: number()
17035
+ }), {
17036
+ kind: "mutation",
17037
+ auth: "admin"
17038
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
17039
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
17040
+ deviceKey: string(),
17123
17041
  /**
17124
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17125
- * `zones` capability.
17126
- *
17127
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17128
- * and no card can render — so every free-text search surface was structurally
17129
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17130
- * just returned nothing. Resolving here rather than in each client keeps ONE
17131
- * derivation and costs the clients no extra call (the `zones` cap is
17132
- * per-device, so a client-side resolve would be a per-camera fan-out on a
17133
- * surface built to avoid exactly that).
17134
- *
17135
- * Resolved, never invented: a zone deleted since the track was written has no
17136
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17137
- * two are not positionally aligned. Absent when the track visited no zone, or
17138
- * when the zone catalogue could not be read.
17042
+ * `failed` the per-device restart budget is exhausted; no pool
17043
+ * will be spawned until an operator re-arms it or the runner
17044
+ * respawns. `backoff` — under budget, waiting out the backoff (or
17045
+ * a cached pool observed dead and not yet condemned).
17139
17046
  */
17140
- zoneNames: array(string()).readonly().optional(),
17141
- /** Deduplicated set of detector classes observed for this track over its
17142
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
17143
- * legacy rows written before class accumulation shipped. */
17144
- classes: array(string()).readonly().optional(),
17145
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17146
- totalDistance: number(),
17147
- state: TrackStateSchema,
17148
- active: boolean(),
17149
- /** Deterministic key-event importance score in [0,1] (server-computed at
17150
- * track expiry, recomputed on late label). Absent on legacy rows written
17151
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
17152
- importance: number().optional(),
17153
- /** Id of the track's highest-confidence ObjectEvent (its representative
17154
- * "best" frame). Absent when the track produced no object events. */
17155
- bestEventId: string().optional(),
17156
- /** Tag of the importance sub-signal that dominated the score
17157
- * (identity|dwell|proximity|class|confidence|travel|zone). */
17158
- importanceReason: string().optional(),
17159
- /** Audio-classification labels heard on the camera during the track's
17160
- * life (score ≥ device `classificationMinScore`), aggregated per label.
17161
- * Absent on legacy rows / tracks with no confident audio. */
17162
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17163
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17164
- * Populated from the persisted envelope columns on historical reads;
17165
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17166
- envelope: TrackEnvelopeSchema.optional(),
17047
+ state: _enum(["failed", "backoff"]),
17048
+ /** Epoch ms of the death that produced this state. */
17049
+ since: number(),
17050
+ /** Pool deaths inside the current window. */
17051
+ deaths: number(),
17052
+ /** The last death's message. */
17053
+ lastError: string()
17054
+ })).readonly() })), method(object({
17055
+ nodeId: string(),
17056
+ deviceKey: string()
17057
+ }), object({ rearmed: boolean() }), {
17058
+ kind: "mutation",
17059
+ auth: "admin"
17060
+ }), method(_void(), PipelineSchemaSchema), method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()), method(_void(), PipelineConfigBridge), method(_void(), ConfigUISchemaBridge), method(object({ steps: array(PipelineStepInputSchema) }), PipelineValidationResultSchema), method(_void(), array(PipelineTemplateSchema$1).readonly()), method(object({
17061
+ name: string(),
17062
+ steps: array(PipelineTemplateStepSchema).readonly(),
17063
+ engine: PipelineEngineChoiceSchema
17064
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
17065
+ id: string(),
17066
+ name: string().optional(),
17067
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
17068
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
17069
+ addonId: string(),
17070
+ modelId: string(),
17071
+ format: ModelFormatSchema$1
17072
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
17073
+ addonId: string(),
17074
+ modelId: string(),
17075
+ format: ModelFormatSchema$1
17076
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
17077
+ engine: PipelineEngineChoiceSchema.optional(),
17078
+ steps: array(PipelineStepInputSchema).min(1),
17079
+ frame: FrameInputSchema.optional(),
17167
17080
  /**
17168
- * A face DETECTOR found a face on this track — nothing more. It says the
17169
- * detail plane produced a `face` detail; it does NOT say the face was
17170
- * embedded, matched, above `minFacePx`, or that the recognizer was even
17171
- * enabled. Set once and never cleared.
17172
- *
17173
- * **This exists so "face present but not recognised" is expressible.** A
17174
- * recognised identity lands in `subLabel` (attributed to the face chain via
17175
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17176
- * and a track with no face at all were byte-identical on the wire and no
17177
- * surface could tell them apart. The read is `hasFace === true && subLabel
17178
- * === undefined`.
17179
- *
17180
- * **Absent ≠ false.** Every row written before the column existed omits it,
17181
- * and so does every server that predates the field — a consumer must test
17182
- * `=== true` and render nothing otherwise, never infer "no face".
17081
+ * Process-local lazy frame. Valid only when caller and provider resolve
17082
+ * in the same execution-group process; split/cross-node callers use
17083
+ * `frame`/`image` inline compatibility instead.
17183
17084
  */
17184
- hasFace: boolean().optional(),
17085
+ frameRef: FrameRefSchema.optional(),
17185
17086
  /**
17186
- * This track has a face row IN THE GALLERY: a crop **and** an embedding a
17187
- * face an operator could ASSIGN to an identity.
17188
- *
17189
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17190
- * because the two disagree. `hasFace` is stamped at the TOP of the face
17191
- * branch, before every gate, and means no more than "a face detector produced
17192
- * a face detail". This one is stamped at the single moment the gallery row
17193
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17194
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17195
- * candidate gate, the imageless-track drop (no crop was ever captured) and
17196
- * the crop-store drop. Everything between the detector and that insert can
17197
- * legitimately refuse the face, so a flag written any earlier promises the
17198
- * operator something to assign and delivers nothing.
17199
- *
17200
- * **Independent of recognition.** A face collected but never auto-matched is
17201
- * still assignable — it is in fact the face an operator most wants to reach —
17202
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17203
- * `subLabel`; this says only that the raw material exists.
17204
- *
17205
- * **Set once, never cleared.** A track that produced a gallery row produced
17206
- * one; deleting the row later is the gallery's business, not this flag's.
17207
- *
17208
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17209
- * before the column omits it, and so does every server that predates the
17210
- * field. A consumer must test `=== true` and render nothing otherwise —
17211
- * never infer "no assignable face".
17087
+ * CB5 shm passthrough a `FrameHandle` naming the same ring slot
17088
+ * the decoded pixels live in. One more member of the one-of
17089
+ * frame/frameHandle/image/imageBase64/referenceImage group.
17212
17090
  */
17213
- hasEmbeddedFace: boolean().optional(),
17091
+ frameHandle: FrameHandleSchema.optional(),
17092
+ imageBase64: string().optional(),
17214
17093
  /**
17215
- * This subject CONTAINS a folded rider a person the rider-pairing step
17216
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17217
- * so the passage is tracked once and as a VEHICLE.
17218
- *
17219
- * It exists because the fold's record was dishonest. D34 and the code both
17220
- * said "the person is not lost — it is reported so both entities stay on the
17221
- * record"; in fact the pair went into a per-processor RAM field behind an
17222
- * accessor nobody called, and every durable surface said `vehicle`, full
17223
- * stop. This is the composition note that makes the row true.
17224
- *
17225
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
17226
- * person" is not an answer to "what is this" — both label tiers would refuse
17227
- * a macro token anyway (D89), and correctly. Nothing here changes what the
17228
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17229
- * and a `person` rule still does not fire for someone cycling past.
17230
- *
17231
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17232
- * the column, and every hub that predates the field, omits it. Test
17233
- * `=== true` and render nothing otherwise — never infer "no rider".
17094
+ * Binary JPEG bytespreferred over `imageBase64` on internal
17095
+ * hops (hub forked worker via Moleculer MsgPack) because it
17096
+ * skips the 33% base64 overhead + the per-call base64 decode on
17097
+ * the detection-pipeline worker. Callers can pass either; exactly
17098
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
17234
17099
  */
17235
- hasRider: boolean().optional(),
17236
- ...TrackFlagFields,
17237
- ...TrackRetrainFields
17238
- });
17239
- var BaseEventFields = {
17240
- id: string(),
17241
- deviceId: number(),
17242
- timestamp: number()
17243
- };
17244
- var MotionEventSchema = object({
17245
- ...BaseEventFields,
17246
- kind: literal("motion"),
17247
- regionCount: number(),
17248
- /** Heavy JSON array omitted in slim projection. */
17249
- regions: array(object({
17250
- bbox: BoundingBoxSchema,
17251
- pixelCount: number(),
17252
- intensity: number()
17253
- })).readonly().optional(),
17254
- /** Omitted in slim projection. */
17255
- frameWidth: number().optional(),
17256
- /** Omitted in slim projection. */
17257
- frameHeight: number().optional(),
17258
- /** Populated by B5 (recording playback URL for this event). */
17259
- mediaUrl: string().optional()
17260
- });
17100
+ image: _instanceof(Uint8Array).optional(),
17101
+ referenceImage: string().optional(),
17102
+ deviceId: number().optional(),
17103
+ sessionId: string().optional(),
17104
+ /**
17105
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
17106
+ * reference-image, and detail-subtree calls. 'frame' is the live
17107
+ * per-frame dispatch: ONLY root-plane steps run; crop children
17108
+ * (inputClasses ≠ null) are skipped and served per-track via
17109
+ * pipelineRunner.runDetailSubtree (two-plane design).
17110
+ */
17111
+ plane: _enum(["full", "frame"]).optional(),
17112
+ /**
17113
+ * Inference-device selector (Phase 2 multi-device). Format
17114
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
17115
+ * Omitted ⇒ the runner's default device (current single-engine
17116
+ * behaviour). Selects WHICH device pool of the node runs the call.
17117
+ */
17118
+ deviceKey: string().optional(),
17119
+ /**
17120
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
17121
+ * when the parent crop was resolved from the frame's retained NATIVE
17122
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
17123
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
17124
+ * resolution from that surface — the SAME quality path faces already
17125
+ * had — instead of the downscaled parent tile. `handle` keys the native
17126
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
17127
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
17128
+ * the executor's crop-normalized child ROI back into frame-normalized
17129
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
17130
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
17131
+ * (today's behaviour on the fallback path).
17132
+ */
17133
+ nativeCropRef: NativeCropRefSchema.optional()
17134
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
17135
+ engine: PipelineEngineChoiceSchema.optional(),
17136
+ steps: array(PipelineStepInputSchema).min(1),
17137
+ frames: array(FrameInputSchema).min(1).max(255),
17138
+ deviceId: number().optional(),
17139
+ sessionId: string().optional(),
17140
+ /**
17141
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
17142
+ * the batch to the Python pool's bench preprocess cache
17143
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
17144
+ * preprocessed ONCE and every later inference is a pure-inference cache
17145
+ * hit — the sustained-throughput run measures inference, not
17146
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
17147
+ * full preprocess every call, correct). Fresh per sustained run;
17148
+ * released via `uncacheFrame`.
17149
+ */
17150
+ frameId: number().int().nonnegative().optional(),
17151
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
17152
+ deviceKey: string().optional()
17153
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
17154
+ data: _instanceof(Uint8Array),
17155
+ width: number().int().positive(),
17156
+ height: number().int().positive(),
17157
+ format: _enum([
17158
+ "rgb",
17159
+ "bgr",
17160
+ "gray"
17161
+ ])
17162
+ }), object({
17163
+ frameId: number(),
17164
+ width: number(),
17165
+ height: number()
17166
+ }), { kind: "mutation" }), method(object({
17167
+ stepId: string(),
17168
+ frameId: number().int()
17169
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
17170
+ batchMode: string(),
17171
+ windowMs: number(),
17172
+ maxBatchSize: number(),
17173
+ concurrency: number()
17174
+ })), method(_void(), array(object({
17175
+ engineKey: string(),
17176
+ engine: PipelineEngineChoiceSchema,
17177
+ modelsLoaded: array(string()).readonly(),
17178
+ inUseByCameras: array(number()).readonly(),
17179
+ /**
17180
+ * Origin of this resident factory.
17181
+ * - `runtime` — main camera-serving engine (no idle TTL).
17182
+ * - `warm-override` — benchmark/test override held in the warm
17183
+ * cache; auto-disposed after the idle TTL.
17184
+ * - `device-pool` — a concurrent per-device pool (Phase 2
17185
+ * multi-device, keyed by `deviceKey`) resolved
17186
+ * via `resolveDeviceFactory`. Runs alongside the
17187
+ * `runtime` engine on a DIFFERENT accelerator
17188
+ * (NPU / iGPU / Coral) — this is how the
17189
+ * Engines tab shows all pools running at once.
17190
+ */
17191
+ kind: _enum([
17192
+ "runtime",
17193
+ "warm-override",
17194
+ "device-pool"
17195
+ ]),
17196
+ /** Native pid of the underlying Python pool (null when no pool). */
17197
+ poolPid: number().nullable(),
17198
+ /** ms since this factory was last used (null when not warm-tracked). */
17199
+ idleMs: number().nullable(),
17200
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
17201
+ idleTtlMs: number().nullable()
17202
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
17203
+ kind: "mutation",
17204
+ auth: "admin"
17205
+ }), method(object({
17206
+ engine: PipelineEngineChoiceSchema,
17207
+ force: boolean().optional()
17208
+ }), object({
17209
+ success: boolean(),
17210
+ reason: string().optional()
17211
+ }), {
17212
+ kind: "mutation",
17213
+ auth: "admin"
17214
+ }), method(_void(), array(ReferenceImageEntrySchema).readonly()), method(object({ filename: string() }), ReferenceImageBodySchema.nullable()), method(_void(), array(ReferenceAudioEntrySchema).readonly()), method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()), method(_void(), AudioCapabilitiesSchema), method(object({
17215
+ addonId: string(),
17216
+ modelId: string(),
17217
+ filename: string().optional(),
17218
+ settings: record(string(), unknown()).optional()
17219
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
17261
17220
  /**
17262
- * Which detection SOURCE produced an object event. `pipeline` = the ML
17263
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
17264
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
17265
- * tracking, per-kind persistence) but stay distinguishable so consumers
17266
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17267
- * Absent on legacy rows treat as `pipeline`.
17221
+ * Per-stage gating mode applied to the zones a rule references.
17222
+ *
17223
+ * - `include`: the rule contributes to a **whitelist** for its stage.
17224
+ * When at least one `include` rule fires for a stage, only entities
17225
+ * inside one of those zones pass that stage.
17226
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
17227
+ * Entities inside one of those zones are dropped at that stage.
17228
+ *
17229
+ * `monitor`-style observation (count without filtering) is not a rule
17230
+ * mode — zones without any matching rule are observed naturally by
17231
+ * `zone-analytics` (live snapshot + history), so an "I just want to
17232
+ * count, not filter" use case needs no rule at all.
17268
17233
  */
17269
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17234
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
17270
17235
  /**
17271
- * The confirmed zone crossing that produced an object event. Present ONLY on
17272
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17273
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17274
- * appearance event carry none, so a rule asking for a direction fails closed
17275
- * on them.
17236
+ * Per-consumer rule that references existing zones (geometry) and
17237
+ * defines how a specific pipeline stage should treat them. Each
17238
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
17239
+ * settings:
17276
17240
  *
17277
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17278
- * into its own event, so a frame in which a track enters A while leaving B
17279
- * produces two events with two directions — never one ambiguous row.
17241
+ * - `addon-motion-wasm` `motionZoneRules: ZoneRule[]` (motion stage)
17242
+ * - `addon-detection-pipeline` `detectionZoneRules: ZoneRule[]` (detection stage)
17243
+ * - future: notification rules, audio gating, etc.
17280
17244
  *
17281
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17282
- * membership the box has NOW, and by definition it no longer contains the zone
17283
- * that was just left. Without the id here, a zone-scoped rule could never match
17284
- * the exit it asked for.
17245
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
17246
+ * express "ignore motion in ALL of {garden, street}" with a single
17247
+ * rule. `classFilter` narrows the rule to specific object classes
17248
+ * "drop person detections in the street, but keep cars" is one
17249
+ * `exclude` rule with `classFilter: ['person']`.
17250
+ *
17251
+ * `enabled` is a soft toggle — the operator can keep the rule
17252
+ * configured but inert without deleting it.
17285
17253
  */
17286
- var ZoneCrossingSchema = object({
17287
- direction: _enum(["enter", "exit"]),
17288
- /** Admin zone id crossed. */
17289
- zoneId: string(),
17290
- /** Zone display name at crossing time (falls back to the id). */
17291
- zoneName: string().optional()
17292
- });
17293
- var ObjectEventSchema = object({
17294
- ...BaseEventFields,
17295
- kind: literal("object"),
17296
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17297
- source: DetectionSourceSchema.optional(),
17254
+ var ZoneRuleSchema = object({
17255
+ /** Stable rule id — survives edits, used by the UI for diffing. */
17256
+ id: string(),
17257
+ /** Optional human-readable label rendered in the rule editor. */
17258
+ name: string().optional(),
17259
+ /** Zones this rule targets. The rule's `mode` applies to ALL
17260
+ * listed zones (OR-set: a detection in any one of them counts).
17261
+ * At least one zone id required — a rule with no targets is a
17262
+ * configuration mistake and the form validator rejects it. */
17263
+ zoneIds: array(string()).min(1).readonly(),
17264
+ mode: ZoneRuleModeEnum,
17298
17265
  /**
17299
- * Inference-frame id shared by every object event emitted from the SAME frame
17300
- * the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17301
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
17302
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
17303
- * Optional for backward-compat with pre-existing rows / the slim projection
17304
- * includes it (it is light). Absent on rows written before this field.
17266
+ * Class names this rule applies to. Empty / undefined rule
17267
+ * applies to every class. Class strings match the `macroClass`
17268
+ * field on detections (e.g. `person`, `car`, `dog`).
17305
17269
  */
17306
- frameId: string().optional(),
17307
- /** Omitted in slim projection. */
17308
- trackId: string().optional(),
17309
- className: string(),
17310
- ...TieredLabelFields,
17311
- /** Omitted in slim projection. */
17312
- confidence: number().optional(),
17313
- /** Heavy JSON — omitted in slim projection. */
17314
- bbox: BoundingBoxSchema.optional(),
17315
- /** Heavy JSON — omitted in slim projection. */
17316
- zones: array(string()).readonly().optional(),
17317
- /** Omitted in slim projection. */
17318
- state: TrackStateSchema.optional(),
17270
+ classFilter: array(string()).readonly().optional(),
17319
17271
  /**
17320
- * The zone crossing this event IS, when it is one. Absent on every other
17321
- * event kind (movement state, appearance, package) see
17322
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
17272
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
17273
+ * required to consider an entity "in the zone". Defaults to the
17274
+ * consumer's stage default when omitted. Kept for back-compat with
17275
+ * existing per-rule overrides; new operators pick the value via
17276
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
17277
+ * set, the lower-level engine reads it as a 0–1 fraction.
17323
17278
  */
17324
- zoneCrossing: ZoneCrossingSchema.optional(),
17325
- /** Detection-frame dimensions in pixels — let consumers normalize the
17326
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17327
- frameWidth: number().optional(),
17328
- frameHeight: number().optional(),
17329
- /** MediaStore key for the crop attached to this event (if any). */
17330
- mediaKey: string().optional(),
17331
- /** Design B: MediaStore key of the track's native-resolution key frame (the
17332
- * best-detection full frame). Resolve via the event-media data-plane
17333
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17334
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17335
- * sources — consumers fall back to `mediaKey` (the tight crop). */
17336
- keyFrameMediaKey: string().optional(),
17337
- /** Populated by B5 (recording playback URL for this event). */
17338
- mediaUrl: string().optional(),
17339
- /** The parent track's key-event importance [0,1], propagated to every object
17340
- * event of the track (so an event row can be sorted by importance without a
17341
- * track join). Absent on legacy rows / before the track was scored. */
17342
- importance: number().optional()
17343
- });
17344
- var AudioEventSchema = object({
17345
- ...BaseEventFields,
17346
- kind: literal("audio"),
17347
- rms: number(),
17348
- dbfs: number(),
17349
- classification: object({
17350
- className: string(),
17351
- originalClass: string().optional(),
17352
- score: number()
17353
- }).optional(),
17354
- /** Populated by B5 (recording playback URL for this event). */
17355
- mediaUrl: string().optional()
17356
- });
17357
- var MediaFileKindEnum = _enum([
17358
- "crop",
17359
- "thumbnail",
17360
- "snapshot",
17361
- "firstFrame",
17362
- "lastFrame",
17363
- "fullFrame",
17364
- "fullFrameBoxed",
17365
- "faceCrop",
17366
- "plateCrop",
17367
- "keyFrame",
17368
- "keyFrameSmall",
17369
- "thumbnailSmall"
17370
- ]);
17371
- var MediaFileSchema = object({
17372
- key: string(),
17373
- kind: MediaFileKindEnum,
17374
- base64: string(),
17375
- sizeBytes: number(),
17376
- timestamp: number()
17279
+ overlapThreshold: number().min(0).max(1).optional(),
17280
+ /**
17281
+ * Operator-friendly version of `overlapThreshold` the percentage
17282
+ * of the detection's bbox that must lie inside the zone for the
17283
+ * rule to match. Documented default is 85%; the engine substitutes
17284
+ * that when the field is omitted (kept optional so existing rules
17285
+ * stored without it stay valid).
17286
+ *
17287
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
17288
+ * rule, the engine prefers `bboxInclusionPct` because it's the
17289
+ * field exposed in the UI. Internally both feed the same gate.
17290
+ */
17291
+ bboxInclusionPct: number().min(0).max(100).optional(),
17292
+ /**
17293
+ * When `true` and a detection has a segmentation mask, use the
17294
+ * mask for overlap instead of the bbox. Detection-stage only;
17295
+ * motion rules ignore this field.
17296
+ */
17297
+ preferMask: boolean().optional(),
17298
+ /**
17299
+ * Soft-toggle: `false` disables the rule without deleting it.
17300
+ * Defaults to `true` so operators creating a rule via the UI
17301
+ * see it active immediately.
17302
+ */
17303
+ enabled: boolean().default(true)
17377
17304
  });
17305
+ array(ZoneRuleSchema).readonly();
17378
17306
  /**
17379
- * One media row WITHOUT its bytes.
17307
+ * Zone pure geometry + identity. NO filtering behaviour.
17380
17308
  *
17381
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17382
- * 140 s track), and a client that renders tiles from the media data plane needs
17383
- * to know only WHAT EXISTS the bytes then arrive per tile, lazily, over HTTP
17384
- * with an immutable cache, instead of all at once inside a tRPC response that
17385
- * blocks the whole view.
17309
+ * Zones describe **where** in the frame the operator wants to flag
17310
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
17311
+ * each pipeline stage uses them. Splitting the two means a single
17312
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
17313
+ * a detection-include rule on `['car']`, and an occupancy aggregate
17314
+ * — without three duplicated polygons.
17386
17315
  *
17387
- * `sizeBytes` is carried because it is what lets a client decide between the
17388
- * stored blob and a `?variant=thumb` rendering without fetching either.
17316
+ * Owned by the orchestrator addon (provider) and mirrored into the
17317
+ * `zones` device-state slice on every mutation. Consumers
17318
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
17319
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
17320
+ * mirror with `onChanged`).
17321
+ *
17322
+ * Coordinates are normalised fractions of the frame (0–1) so zones
17323
+ * survive resolution changes and stream profile switches.
17324
+ *
17325
+ * `kind` discriminates between full polygons (closed regions used
17326
+ * for intrusion / occupancy filters) and tripwires (open 2-point
17327
+ * line segments used for cross events). Onboard / firmware-reported
17328
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
17329
+ * task list.
17389
17330
  */
17390
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17331
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
17332
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
17333
+ var PolygonPointSchema = object({
17334
+ x: number(),
17335
+ y: number()
17336
+ });
17337
+ /** A camera detection zone — pure geometry/identity. */
17338
+ var ZoneSchema = object({
17339
+ id: string(),
17340
+ name: string(),
17341
+ kind: ZoneKindEnum.default("polygon"),
17342
+ /** Polygon vertices, fraction of frame (0–1). */
17343
+ polygon: array(PolygonPointSchema).readonly(),
17344
+ /** Visual color for UI rendering. */
17345
+ color: string().default("#3b82f6")
17346
+ });
17347
+ DeviceType.Camera, method(object({ deviceId: number() }), array(ZoneSchema).readonly()), method(object({
17348
+ deviceId: number(),
17349
+ zone: ZoneSchema
17350
+ }), _void(), {
17351
+ kind: "mutation",
17352
+ auth: "admin"
17353
+ }), method(object({
17354
+ deviceId: number(),
17355
+ zoneId: string()
17356
+ }), _void(), {
17357
+ kind: "mutation",
17358
+ auth: "admin"
17359
+ }), method(object({
17360
+ deviceId: number(),
17361
+ zone: ZoneSchema
17362
+ }), _void(), {
17363
+ kind: "mutation",
17364
+ auth: "admin"
17365
+ }), object({ zones: array(ZoneSchema).readonly() });
17391
17366
  /**
17392
- * The MACRO tier of an annotation — a CLOSED set.
17367
+ * pipeline-analytics device-scoped wrapper cap. Refines raw
17368
+ * per-frame detections emitted by the pipeline runner into tracked
17369
+ * objects, per-kind event collections (motion / object / audio), and
17370
+ * persisted media. Owns the post-detection domain end-to-end:
17393
17371
  *
17394
- * This is what the exported detector predicts, so a typo here is a new class
17395
- * with one example in it. `label` and `subLabel` are open strings by contrast:
17396
- * the whole point of the page is teaching the model things it does not know
17397
- * yet, and constraining that vocabulary would make it useless.
17372
+ * runner emits PipelineInferenceResult
17373
+ * (event bus)
17374
+ * pipeline-analytics subscriber
17375
+ * SORT tracker + zone engine + state analyzer + event emitter
17376
+ * → three DB collections (one per kind), one FS media tree, one
17377
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
17378
+ * DetectionEvent on bus)
17398
17379
  *
17399
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
17400
- * `subLabel` is one of these values, in any casing, because once `person`
17401
- * exists in both tiers "every person box" stops being answerable without
17402
- * knowing every string anyone ever typed — and the damage is retroactive.
17380
+ * Pure subscriber model. No `processFrame` cap method the runner
17381
+ * already publishes the raw frame on the bus. The cap surface is
17382
+ * only QUERIES + per-device settings, bound on/off via
17383
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
17384
+ * every camera with a detection pipeline wants its raw detections
17385
+ * refined; operators opt out per-device via BindingsTab when needed.
17386
+ *
17387
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17388
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
17403
17389
  */
17404
- var RetrainMacroClassSchema = _enum([
17390
+ var TrackStateSchema = _enum([
17391
+ "new",
17392
+ "entered",
17393
+ "left",
17394
+ "moving",
17395
+ "idle"
17396
+ ]);
17397
+ var EventKindSchema = _enum([
17398
+ "motion",
17399
+ "object",
17400
+ "audio"
17401
+ ]);
17402
+ /**
17403
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
17404
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17405
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
17406
+ */
17407
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17408
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
17409
+ var EventKindIconSchema = _enum([
17410
+ "motion",
17411
+ "audio",
17405
17412
  "person",
17406
17413
  "vehicle",
17407
17414
  "animal",
17415
+ "door",
17416
+ "pir",
17417
+ "smoke",
17418
+ "water",
17419
+ "button",
17408
17420
  "package",
17409
- "face",
17410
- "plate"
17421
+ "generic"
17411
17422
  ]);
17412
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17413
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17414
- /** Did a human draw this box, or did the assist propose it? */
17415
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17416
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17417
- var RetrainBboxSchema = object({
17423
+ var EventKindCategorySchema = _enum([
17424
+ "motion",
17425
+ "audio",
17426
+ "detection",
17427
+ "sensor",
17428
+ "control",
17429
+ "custom",
17430
+ "package"
17431
+ ]);
17432
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17433
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
17434
+ var EventKindDescriptorSchema = object({
17435
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17436
+ kind: string(),
17437
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
17438
+ labelKey: string(),
17439
+ /** English fallback label (kept for clients that don't translate). */
17440
+ label: string(),
17441
+ /** Hex color for timeline/legend rendering. */
17442
+ color: string(),
17443
+ /** Dictionary id → lucide component on the UI side. */
17444
+ iconId: string(),
17445
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
17446
+ icon: EventKindIconSchema,
17447
+ category: EventKindCategorySchema,
17448
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17449
+ parentKind: string().nullable(),
17450
+ /** Derived from `parentKind`, explicit for the client tree. */
17451
+ level: EventKindLevelSchema,
17452
+ /** Which cap + device contributes this kind. For built-ins the camera
17453
+ * itself; for sensor kinds the LINKED source device. */
17454
+ source: object({
17455
+ capName: string(),
17456
+ deviceId: number()
17457
+ })
17458
+ });
17459
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17460
+ var EventKindsForDeviceSchema = object({
17461
+ deviceId: number(),
17462
+ kinds: array(EventKindDescriptorSchema).readonly()
17463
+ });
17464
+ var SensorEventSchema = object({
17465
+ id: string(),
17466
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
17467
+ * yields N rows, one per camera). */
17468
+ deviceId: number(),
17469
+ /** The linked sensor device whose state changed. */
17470
+ sourceDeviceId: number(),
17471
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
17472
+ kind: string(),
17473
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
17474
+ value: record(string(), unknown()).nullable(),
17475
+ timestamp: number()
17476
+ });
17477
+ var TrackPositionSchema = object({
17418
17478
  x: number(),
17419
17479
  y: number(),
17420
- w: number(),
17421
- h: number()
17480
+ timestamp: number(),
17481
+ bbox: BoundingBoxSchema
17482
+ });
17483
+ var TrackSnapshotSchema = object({
17484
+ timestamp: number(),
17485
+ position: TrackPositionSchema,
17486
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17487
+ mediaKey: string()
17422
17488
  });
17423
17489
  /**
17424
- * One annotated subject.
17425
- *
17426
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17427
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17428
- * derived from it at export and never stored — storing them is how one feature
17429
- * space ends up holding two crops of the same subject (D52).
17430
- */
17431
- var RetrainAnnotationSchema = object({
17432
- id: string(),
17490
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17491
+ * divided by the track's detection-frame dims), computed at persist time.
17492
+ * Absent when the frame dims were unknown when the track was persisted
17493
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17494
+ */
17495
+ var TrackEnvelopeSchema = object({
17496
+ minX: number(),
17497
+ minY: number(),
17498
+ maxX: number(),
17499
+ maxY: number()
17500
+ });
17501
+ /**
17502
+ * Row projection for track list queries. `full` (default) returns the
17503
+ * complete Track including the frame-rate `positions[]` history and the
17504
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
17505
+ * keeps every scalar the list surfaces actually render (ids, class(es),
17506
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17507
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17508
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
17509
+ * `getTrack`. Mirrors the event-store `projection` convention
17510
+ * (`getObjectEvents` et al.).
17511
+ */
17512
+ var TrackProjectionSchema = _enum(["full", "slim"]);
17513
+ /**
17514
+ * One audio-classification label heard on the track's camera while the
17515
+ * track was alive, aggregated per label. An "episode" is one persisted
17516
+ * audio event (the confident-classification path: score ≥ the device's
17517
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17518
+ * one 32 ms inference chunk, so counts stay human-scaled.
17519
+ */
17520
+ var TrackAudioLabelSchema = object({
17521
+ label: string(),
17522
+ /** Highest classification score observed across the label's episodes. */
17523
+ peakScore: number(),
17524
+ /** Number of coalesced audio-event episodes carrying this label. */
17525
+ count: number(),
17526
+ firstAt: number(),
17527
+ lastAt: number()
17528
+ });
17529
+ /**
17530
+ * How a track was produced. `pipeline` (default / absent) = the spatial
17531
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17532
+ * no positions, a single snapshot, and no bbox trajectory at all:
17533
+ *
17534
+ * - `sensor` — a linked sensor/control device state change.
17535
+ * - `audio` — an audio event on the camera itself that was anomalous for
17536
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
17537
+ *
17538
+ * The spatial subsystems (tracker association, occupancy count, re-id /
17539
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
17540
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17541
+ * check silently readmits every source added after it was written.
17542
+ */
17543
+ var TrackSourceSchema = _enum([
17544
+ "pipeline",
17545
+ "sensor",
17546
+ "audio"
17547
+ ]);
17548
+ /**
17549
+ * Where a track sits in the RETRAIN lifecycle (D81).
17550
+ *
17551
+ * - `none` — never marked, or un-marked. Evictable.
17552
+ * - `staging` — the operator wants this track as training material and has not
17553
+ * finished with it. **This is the only state retention holds**: the track and
17554
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
17555
+ * the device's age window.
17556
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
17557
+ * were COPIED into the retrain dataset at selection time, so the dataset no
17558
+ * longer depends on the track's media and the track becomes EVICTABLE again.
17559
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17560
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
17561
+ *
17562
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17563
+ * the store's filter language has only positive equality and `whereIn` — no
17564
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17565
+ * would make the entire pre-column history immortal in one deploy.
17566
+ */
17567
+ var RetrainStatusSchema = _enum([
17568
+ "none",
17569
+ "staging",
17570
+ "trained"
17571
+ ]);
17572
+ /**
17573
+ * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
17574
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17575
+ * so the two surfaces cannot drift.
17576
+ *
17577
+ * **Absent ≠ false.** A track that has never been touched omits the field; an
17578
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
17579
+ * columns existed read as absent, and a consumer that needs a boolean should say
17580
+ * `flag === true`, not `flag !== false`.
17581
+ *
17582
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17583
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17584
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17585
+ * `trained` track reports `false` while refusing both writes. The boolean is
17586
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
17587
+ * "never marked" from "already trained" must read `retrainStatus`.
17588
+ *
17589
+ * `debug` does NOT pin; it is attention, not durability.
17590
+ *
17591
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17592
+ * A favourited track is skipped by retention the same way `staging` is, but
17593
+ * it does not enter `none|staging|trained` and has no staging budget.
17594
+ */
17595
+ var TrackFlagFields = {
17596
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
17597
+ * `'staging'`. */
17598
+ markForTrain: boolean().optional(),
17599
+ /** Operator marked this track for diagnostic attention. */
17600
+ debug: boolean().optional(),
17601
+ /** Operator favourited this track. Pins it against pruning. */
17602
+ favourited: boolean().optional()
17603
+ };
17604
+ /**
17605
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17606
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17607
+ * write patch, and the status is not something the toggle sets — it is what the
17608
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17609
+ * always present on a persisted row (the column default materialises `'none'`).
17610
+ */
17611
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17612
+ /**
17613
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17614
+ * one flag can never clear the other — the toggles are independent and are
17615
+ * driven from three surfaces that do not know about each other.
17616
+ */
17617
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
17618
+ /**
17619
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
17620
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
17621
+ * mutation result without a re-fetch.
17622
+ */
17623
+ var TrackFlagsSchema = object({
17433
17624
  trackId: string(),
17434
- deviceId: number(),
17435
- /** The COPY in retrain storage — never the source track's media key. */
17436
- mediaKey: string(),
17437
- bbox: RetrainBboxSchema,
17438
- macroClass: RetrainMacroClassSchema,
17625
+ markForTrain: boolean(),
17626
+ debug: boolean(),
17627
+ favourited: boolean(),
17628
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
17629
+ * a track row) because this shape is only ever produced by the write body,
17630
+ * which always knows it — and a surface that has just written needs to render
17631
+ * `trained` without a re-fetch. */
17632
+ retrainStatus: RetrainStatusSchema
17633
+ });
17634
+ union([literal(1), literal(2)]);
17635
+ /**
17636
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
17637
+ * the step and model that produced it — which is what makes the write rule
17638
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17639
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17640
+ *
17641
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17642
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17643
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
17644
+ * that value has no provenance, and the write rule lets ANY properly-attributed
17645
+ * write of the same tier replace it regardless of score.
17646
+ */
17647
+ var LabelAttributionSchema = object({
17648
+ stepId: string(),
17649
+ modelId: string().optional(),
17650
+ decidedAt: number(),
17651
+ /**
17652
+ * The GALLERY id behind a recognised tier-2 label — a face-gallery
17653
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17654
+ *
17655
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
17656
+ * notification rule authored on "Gianluca" stopped matching the moment the
17657
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
17658
+ * the thing that does not move, so it is what a rule matches on
17659
+ * (`NcConditions.identities`) and the text is what a human is shown.
17660
+ *
17661
+ * Absent when the label names no gallery row — a plate the OCR read but no
17662
+ * vehicle claims, a sub-class, a species, any tier-1 value.
17663
+ */
17664
+ identityId: string().optional()
17665
+ });
17666
+ /**
17667
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17668
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17669
+ * track and its events always answer the same question the same way.
17670
+ *
17671
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
17672
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17673
+ * is tier 2, and each carries its own score + attribution.
17674
+ *
17675
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17676
+ * finest thing known. Before 4g the single `label` column held the finest
17677
+ * value, so a consumer that has not been updated reads the tier-1 slot and
17678
+ * shows nothing on a species-only row; that is why the migration puts every
17679
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17680
+ * and why the read surfaces were changed in the same train.
17681
+ *
17682
+ * **Writing it.** The slots are independent, which is the whole point: a
17683
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17684
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
17685
+ * higher score wins. One rule, one implementation — see
17686
+ * `pipeline/label-tier.ts` in addon-post-analysis.
17687
+ */
17688
+ var TieredLabelFields = {
17689
+ /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
17439
17690
  label: string().optional(),
17691
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
17692
+ labelScore: number().optional(),
17693
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17694
+ labelMeta: LabelAttributionSchema.optional(),
17695
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17440
17696
  subLabel: string().optional(),
17441
- kind: RetrainAnnotationKindSchema,
17442
- source: RetrainAnnotationSourceSchema,
17443
- /** Which model proposed this box or, on a `model_error`, drew the phantom. */
17444
- assistModelId: string().optional(),
17445
- assistScore: number().optional(),
17446
- exportedInBatch: string().optional(),
17447
- createdAt: number()
17697
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
17698
+ subLabelScore: number().optional(),
17699
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17700
+ subLabelMeta: LabelAttributionSchema.optional()
17701
+ };
17702
+ /** Per-camera slice of a training-export estimate. */
17703
+ var TrainingExportDeviceTotalsSchema = object({
17704
+ deviceId: number(),
17705
+ tracks: number().int(),
17706
+ files: number().int(),
17707
+ bytes: number().int()
17448
17708
  });
17449
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17450
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17451
- id: true,
17452
- trackId: true,
17453
- deviceId: true,
17454
- mediaKey: true,
17455
- createdAt: true,
17456
- exportedInBatch: true
17709
+ /**
17710
+ * What a training export WOULD contain. Computed from media index rows only —
17711
+ * no blob is read to produce this.
17712
+ */
17713
+ var TrainingExportSummarySchema = object({
17714
+ generatedAt: number(),
17715
+ trackCount: number().int(),
17716
+ fileCount: number().int(),
17717
+ byteCount: number().int(),
17718
+ /** More marked tracks exist than a single pass carries. */
17719
+ truncated: boolean(),
17720
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
17457
17721
  });
17458
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17459
- var RetrainTrackSchema = object({
17722
+ var TrackSchema = object({
17460
17723
  trackId: string(),
17461
17724
  deviceId: number(),
17462
17725
  className: string(),
17463
- label: string().optional(),
17726
+ ...TieredLabelFields,
17727
+ producingDeviceName: string().optional(),
17728
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
17729
+ source: TrackSourceSchema.optional(),
17464
17730
  firstSeen: number(),
17465
17731
  lastSeen: number(),
17466
- /** How many frames the dataset already holds from this track. */
17467
- frameCount: number().int(),
17468
- /** How many subjects have been annotated on those frames. `0` with
17469
- * `frameCount: 0` is exactly "staging, still to work". */
17470
- annotationCount: number().int()
17471
- });
17472
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
17473
- var RetrainFrameCandidateSchema = object({
17474
- mediaKey: string(),
17475
- kind: MediaFileKindEnum,
17476
- timestamp: number(),
17477
- sizeBytes: number().int(),
17478
- /** A copy of this original already exists selecting it is free and cannot
17479
- * fail, whatever became of the original. */
17480
- copied: boolean()
17732
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
17733
+ positions: array(TrackPositionSchema).readonly(),
17734
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17735
+ * saveThumbnails policy). */
17736
+ snapshots: array(TrackSnapshotSchema).readonly(),
17737
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
17738
+ zonesVisited: array(string()).readonly(),
17739
+ /**
17740
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17741
+ * `zones` capability.
17742
+ *
17743
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17744
+ * and no card can render so every free-text search surface was structurally
17745
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17746
+ * just returned nothing. Resolving here rather than in each client keeps ONE
17747
+ * derivation and costs the clients no extra call (the `zones` cap is
17748
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
17749
+ * surface built to avoid exactly that).
17750
+ *
17751
+ * Resolved, never invented: a zone deleted since the track was written has no
17752
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17753
+ * two are not positionally aligned. Absent when the track visited no zone, or
17754
+ * when the zone catalogue could not be read.
17755
+ */
17756
+ zoneNames: array(string()).readonly().optional(),
17757
+ /** Deduplicated set of detector classes observed for this track over its
17758
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
17759
+ * legacy rows written before class accumulation shipped. */
17760
+ classes: array(string()).readonly().optional(),
17761
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17762
+ totalDistance: number(),
17763
+ state: TrackStateSchema,
17764
+ active: boolean(),
17765
+ /** Deterministic key-event importance score in [0,1] (server-computed at
17766
+ * track expiry, recomputed on late label). Absent on legacy rows written
17767
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
17768
+ importance: number().optional(),
17769
+ /** Id of the track's highest-confidence ObjectEvent (its representative
17770
+ * "best" frame). Absent when the track produced no object events. */
17771
+ bestEventId: string().optional(),
17772
+ /** Tag of the importance sub-signal that dominated the score
17773
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
17774
+ importanceReason: string().optional(),
17775
+ /** Audio-classification labels heard on the camera during the track's
17776
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
17777
+ * Absent on legacy rows / tracks with no confident audio. */
17778
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17779
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17780
+ * Populated from the persisted envelope columns on historical reads;
17781
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17782
+ envelope: TrackEnvelopeSchema.optional(),
17783
+ /**
17784
+ * A face DETECTOR found a face on this track — nothing more. It says the
17785
+ * detail plane produced a `face` detail; it does NOT say the face was
17786
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
17787
+ * enabled. Set once and never cleared.
17788
+ *
17789
+ * **This exists so "face present but not recognised" is expressible.** A
17790
+ * recognised identity lands in `subLabel` (attributed to the face chain via
17791
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17792
+ * and a track with no face at all were byte-identical on the wire and no
17793
+ * surface could tell them apart. The read is `hasFace === true && subLabel
17794
+ * === undefined`.
17795
+ *
17796
+ * **Absent ≠ false.** Every row written before the column existed omits it,
17797
+ * and so does every server that predates the field — a consumer must test
17798
+ * `=== true` and render nothing otherwise, never infer "no face".
17799
+ */
17800
+ hasFace: boolean().optional(),
17801
+ /**
17802
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
17803
+ * face an operator could ASSIGN to an identity.
17804
+ *
17805
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17806
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
17807
+ * branch, before every gate, and means no more than "a face detector produced
17808
+ * a face detail". This one is stamped at the single moment the gallery row
17809
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17810
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17811
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
17812
+ * the crop-store drop. Everything between the detector and that insert can
17813
+ * legitimately refuse the face, so a flag written any earlier promises the
17814
+ * operator something to assign and delivers nothing.
17815
+ *
17816
+ * **Independent of recognition.** A face collected but never auto-matched is
17817
+ * still assignable — it is in fact the face an operator most wants to reach —
17818
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17819
+ * `subLabel`; this says only that the raw material exists.
17820
+ *
17821
+ * **Set once, never cleared.** A track that produced a gallery row produced
17822
+ * one; deleting the row later is the gallery's business, not this flag's.
17823
+ *
17824
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17825
+ * before the column omits it, and so does every server that predates the
17826
+ * field. A consumer must test `=== true` and render nothing otherwise —
17827
+ * never infer "no assignable face".
17828
+ */
17829
+ hasEmbeddedFace: boolean().optional(),
17830
+ /**
17831
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
17832
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17833
+ * so the passage is tracked once and as a VEHICLE.
17834
+ *
17835
+ * It exists because the fold's record was dishonest. D34 and the code both
17836
+ * said "the person is not lost — it is reported so both entities stay on the
17837
+ * record"; in fact the pair went into a per-processor RAM field behind an
17838
+ * accessor nobody called, and every durable surface said `vehicle`, full
17839
+ * stop. This is the composition note that makes the row true.
17840
+ *
17841
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
17842
+ * person" is not an answer to "what is this" — both label tiers would refuse
17843
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
17844
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17845
+ * and a `person` rule still does not fire for someone cycling past.
17846
+ *
17847
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17848
+ * the column, and every hub that predates the field, omits it. Test
17849
+ * `=== true` and render nothing otherwise — never infer "no rider".
17850
+ */
17851
+ hasRider: boolean().optional(),
17852
+ ...TrackFlagFields,
17853
+ ...TrackRetrainFields
17481
17854
  });
17482
- /** A frame the dataset OWNS: bytes copied at selection time. */
17483
- var RetrainFrameSchema = object({
17484
- frameId: string(),
17855
+ var BaseEventFields = {
17856
+ id: string(),
17485
17857
  deviceId: number(),
17486
- trackId: string(),
17487
- /** Provenance only. It may already point at nothing — that is expected. */
17488
- sourceMediaKey: string(),
17489
- sourceKind: MediaFileKindEnum,
17490
- sizeBytes: number().int(),
17491
- width: number().int(),
17492
- height: number().int(),
17493
- copiedAt: number()
17494
- });
17495
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17496
- var RetrainCopyRefusalSchema = _enum([
17497
- "source-missing",
17498
- "unreadable-image",
17499
- "write-failed"
17500
- ]);
17501
- var RetrainFrameSelectionSchema = object({
17502
- copied: array(RetrainFrameSchema).readonly(),
17503
- refused: array(object({
17504
- sourceMediaKey: string(),
17505
- reason: RetrainCopyRefusalSchema
17506
- })).readonly()
17507
- });
17508
- var RetrainFrameListSchema = object({
17509
- candidates: array(RetrainFrameCandidateSchema).readonly(),
17510
- copies: array(RetrainFrameSchema).readonly(),
17511
- /** What the page pre-selects — the native key frame when one survives. */
17512
- autoPickMediaKey: string().optional()
17858
+ timestamp: number()
17859
+ };
17860
+ var MotionEventSchema = object({
17861
+ ...BaseEventFields,
17862
+ kind: literal("motion"),
17863
+ regionCount: number(),
17864
+ /** Heavy JSON array — omitted in slim projection. */
17865
+ regions: array(object({
17866
+ bbox: BoundingBoxSchema,
17867
+ pixelCount: number(),
17868
+ intensity: number()
17869
+ })).readonly().optional(),
17870
+ /** Omitted in slim projection. */
17871
+ frameWidth: number().optional(),
17872
+ /** Omitted in slim projection. */
17873
+ frameHeight: number().optional(),
17874
+ /** Populated by B5 (recording playback URL for this event). */
17875
+ mediaUrl: string().optional()
17513
17876
  });
17514
- /** What the operator asked the assist to look for. */
17515
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17516
- kind: literal("package"),
17517
- zone: RetrainBboxSchema.optional()
17518
- }), object({
17519
- kind: literal("objects"),
17520
- modelId: string(),
17521
- minScore: number().optional()
17522
- })]);
17523
17877
  /**
17524
- * The assist's answer a discriminated union, because "the model saw nothing"
17525
- * and "this node cannot run that model" lead to different next moves and a
17526
- * nullable result cannot tell them apart.
17878
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
17879
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
17880
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
17881
+ * tracking, per-kind persistence) but stay distinguishable so consumers
17882
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17883
+ * Absent on legacy rows ⇒ treat as `pipeline`.
17527
17884
  */
17528
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17529
- kind: literal("proposed"),
17530
- modelId: string(),
17531
- stepId: string(),
17532
- minScore: number(),
17533
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17534
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
17535
- /** Returned by the runner but removed by the threshold. */
17536
- belowThreshold: number().int()
17537
- }), object({
17538
- kind: literal("refused"),
17539
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17540
- reason: string(),
17541
- detail: string().optional()
17542
- })]);
17543
- /** The outcome of a lifecycle move owned by the retrain page. */
17544
- var RetrainTransitionResultSchema = object({
17545
- trackId: string(),
17546
- /** Where the track ended up, whatever happened. */
17547
- retrainStatus: RetrainStatusSchema,
17548
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17549
- changed: boolean(),
17550
- reason: _enum([
17551
- "unknown-track",
17552
- "no-frames-copied",
17553
- "not-staging",
17554
- "not-trained",
17555
- "unchanged"
17556
- ]).optional()
17885
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17886
+ /**
17887
+ * The confirmed zone crossing that produced an object event. Present ONLY on
17888
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17889
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17890
+ * appearance event carry none, so a rule asking for a direction fails closed
17891
+ * on them.
17892
+ *
17893
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17894
+ * into its own event, so a frame in which a track enters A while leaving B
17895
+ * produces two events with two directions — never one ambiguous row.
17896
+ *
17897
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17898
+ * membership the box has NOW, and by definition it no longer contains the zone
17899
+ * that was just left. Without the id here, a zone-scoped rule could never match
17900
+ * the exit it asked for.
17901
+ */
17902
+ var ZoneCrossingSchema = object({
17903
+ direction: _enum(["enter", "exit"]),
17904
+ /** Admin zone id crossed. */
17905
+ zoneId: string(),
17906
+ /** Zone display name at crossing time (falls back to the id). */
17907
+ zoneName: string().optional()
17557
17908
  });
17558
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17559
- var MAX_EVENT_QUERY_LIMIT = 5e3;
17560
- var DeviceEventQueryInput = object({
17561
- deviceId: number(),
17562
- since: number().optional(),
17563
- until: number().optional(),
17564
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17565
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17566
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17567
- * exact behaviour. Callers may omit this field the store defaults to
17568
- * `full` when not provided. */
17569
- projection: _enum(["full", "slim"]).optional()
17909
+ var ObjectEventSchema = object({
17910
+ ...BaseEventFields,
17911
+ kind: literal("object"),
17912
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17913
+ source: DetectionSourceSchema.optional(),
17914
+ /**
17915
+ * Inference-frame id shared by every object event emitted from the SAME frame
17916
+ * the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17917
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
17918
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
17919
+ * Optional for backward-compat with pre-existing rows / the slim projection
17920
+ * includes it (it is light). Absent on rows written before this field.
17921
+ */
17922
+ frameId: string().optional(),
17923
+ /** Omitted in slim projection. */
17924
+ trackId: string().optional(),
17925
+ className: string(),
17926
+ ...TieredLabelFields,
17927
+ /** Omitted in slim projection. */
17928
+ confidence: number().optional(),
17929
+ /** Heavy JSON — omitted in slim projection. */
17930
+ bbox: BoundingBoxSchema.optional(),
17931
+ /** Heavy JSON — omitted in slim projection. */
17932
+ zones: array(string()).readonly().optional(),
17933
+ /** Omitted in slim projection. */
17934
+ state: TrackStateSchema.optional(),
17935
+ /**
17936
+ * The zone crossing this event IS, when it is one. Absent on every other
17937
+ * event kind (movement state, appearance, package) — see
17938
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
17939
+ */
17940
+ zoneCrossing: ZoneCrossingSchema.optional(),
17941
+ /** Detection-frame dimensions in pixels — let consumers normalize the
17942
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17943
+ frameWidth: number().optional(),
17944
+ frameHeight: number().optional(),
17945
+ /** MediaStore key for the crop attached to this event (if any). */
17946
+ mediaKey: string().optional(),
17947
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
17948
+ * best-detection full frame). Resolve via the event-media data-plane
17949
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17950
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17951
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
17952
+ keyFrameMediaKey: string().optional(),
17953
+ /** Populated by B5 (recording playback URL for this event). */
17954
+ mediaUrl: string().optional(),
17955
+ /** The parent track's key-event importance [0,1], propagated to every object
17956
+ * event of the track (so an event row can be sorted by importance without a
17957
+ * track join). Absent on legacy rows / before the track was scored. */
17958
+ importance: number().optional()
17570
17959
  });
17571
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17572
- var RecentTracksQueryInput = object({
17573
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17574
- deviceIds: array(number()),
17575
- /** Window lower bound on `lastSeen` (inclusive). */
17576
- since: number().optional(),
17577
- /** Window upper bound on `lastSeen` (inclusive). */
17578
- until: number().optional(),
17579
- /** Page size. Default 200, max 1000. */
17580
- limit: number().int().min(1).max(1e3).default(200),
17581
- /** Opaque continuation cursor from a previous page's `nextCursor`.
17582
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17583
- cursor: string().optional(),
17584
- /** See {@link TrackProjectionSchema}. Default `full`. */
17585
- projection: TrackProjectionSchema.optional(),
17586
- /** Include stationary-promoted rows (parked objects). Default false: the
17587
- * feed lists passages; parking records live on the stationary registry. */
17588
- includeStationary: boolean().optional()
17960
+ var AudioEventSchema = object({
17961
+ ...BaseEventFields,
17962
+ kind: literal("audio"),
17963
+ rms: number(),
17964
+ dbfs: number(),
17965
+ classification: object({
17966
+ className: string(),
17967
+ originalClass: string().optional(),
17968
+ score: number()
17969
+ }).optional(),
17970
+ /** Populated by B5 (recording playback URL for this event). */
17971
+ mediaUrl: string().optional()
17589
17972
  });
17590
- var RecentTracksPageSchema = object({
17591
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17592
- tracks: array(TrackSchema).readonly(),
17593
- /** Cursor for the next page, or null when this page is the last. */
17594
- nextCursor: string().nullable()
17973
+ var MediaFileKindEnum = _enum([
17974
+ "crop",
17975
+ "thumbnail",
17976
+ "snapshot",
17977
+ "firstFrame",
17978
+ "lastFrame",
17979
+ "fullFrame",
17980
+ "fullFrameBoxed",
17981
+ "faceCrop",
17982
+ "plateCrop",
17983
+ "keyFrame",
17984
+ "keyFrameSmall",
17985
+ "thumbnailSmall"
17986
+ ]);
17987
+ var MediaFileSchema = object({
17988
+ key: string(),
17989
+ kind: MediaFileKindEnum,
17990
+ base64: string(),
17991
+ sizeBytes: number(),
17992
+ timestamp: number()
17595
17993
  });
17596
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
17597
- var LIST_GROUPS_MAX_LIMIT = 100;
17598
- var AnalyticsGroupRecordSchema = object({
17994
+ /**
17995
+ * One media row WITHOUT its bytes.
17996
+ *
17997
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17998
+ * 140 s track), and a client that renders tiles from the media data plane needs
17999
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
18000
+ * with an immutable cache, instead of all at once inside a tRPC response that
18001
+ * blocks the whole view.
18002
+ *
18003
+ * `sizeBytes` is carried because it is what lets a client decide between the
18004
+ * stored blob and a `?variant=thumb` rendering without fetching either.
18005
+ */
18006
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
18007
+ /**
18008
+ * The MACRO tier of an annotation — a CLOSED set.
18009
+ *
18010
+ * This is what the exported detector predicts, so a typo here is a new class
18011
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
18012
+ * the whole point of the page is teaching the model things it does not know
18013
+ * yet, and constraining that vocabulary would make it useless.
18014
+ *
18015
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
18016
+ * `subLabel` is one of these values, in any casing, because once `person`
18017
+ * exists in both tiers "every person box" stops being answerable without
18018
+ * knowing every string anyone ever typed — and the damage is retroactive.
18019
+ */
18020
+ var RetrainMacroClassSchema = _enum([
18021
+ "person",
18022
+ "vehicle",
18023
+ "animal",
18024
+ "package",
18025
+ "face",
18026
+ "plate"
18027
+ ]);
18028
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
18029
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
18030
+ /** Did a human draw this box, or did the assist propose it? */
18031
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
18032
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
18033
+ var RetrainBboxSchema = object({
18034
+ x: number(),
18035
+ y: number(),
18036
+ w: number(),
18037
+ h: number()
18038
+ });
18039
+ /**
18040
+ * One annotated subject.
18041
+ *
18042
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
18043
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
18044
+ * derived from it at export and never stored — storing them is how one feature
18045
+ * space ends up holding two crops of the same subject (D52).
18046
+ */
18047
+ var RetrainAnnotationSchema = object({
17599
18048
  id: string(),
17600
- deviceId: number().int(),
17601
- openedAt: number().int(),
17602
- closedAt: number().int(),
17603
- timestamp: number().int(),
17604
- memberCount: number().int(),
17605
- memberTrackIds: array(string()).readonly(),
17606
- className: string(),
17607
- classes: array(string()).readonly(),
17608
- /** Relative event-media path, or null when the group has no picture yet. */
17609
- mediaUrl: string().nullable(),
17610
- singleton: boolean()
18049
+ trackId: string(),
18050
+ deviceId: number(),
18051
+ /** The COPY in retrain storage — never the source track's media key. */
18052
+ mediaKey: string(),
18053
+ bbox: RetrainBboxSchema,
18054
+ macroClass: RetrainMacroClassSchema,
18055
+ label: string().optional(),
18056
+ subLabel: string().optional(),
18057
+ kind: RetrainAnnotationKindSchema,
18058
+ source: RetrainAnnotationSourceSchema,
18059
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
18060
+ assistModelId: string().optional(),
18061
+ assistScore: number().optional(),
18062
+ exportedInBatch: string().optional(),
18063
+ createdAt: number()
17611
18064
  });
17612
- var AnalyticsGroupMemberSchema = object({
18065
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
18066
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
18067
+ id: true,
18068
+ trackId: true,
18069
+ deviceId: true,
18070
+ mediaKey: true,
18071
+ createdAt: true,
18072
+ exportedInBatch: true
18073
+ });
18074
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
18075
+ var RetrainTrackSchema = object({
17613
18076
  trackId: string(),
17614
- deviceId: number().int(),
18077
+ deviceId: number(),
17615
18078
  className: string(),
17616
- firstSeen: number().int(),
17617
- lastSeen: number().int(),
17618
- mediaUrl: string().nullable()
17619
- });
17620
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17621
- var ListGroupsQueryInput = object({
17622
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17623
- deviceIds: array(number()),
17624
- /** Window lower bound on `closedAt` (inclusive). */
17625
- since: number().optional(),
17626
- /** Window upper bound on `openedAt` (inclusive). */
17627
- until: number().optional(),
17628
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17629
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
17630
- cursor: string().optional()
18079
+ label: string().optional(),
18080
+ firstSeen: number(),
18081
+ lastSeen: number(),
18082
+ /** How many frames the dataset already holds from this track. */
18083
+ frameCount: number().int(),
18084
+ /** How many subjects have been annotated on those frames. `0` with
18085
+ * `frameCount: 0` is exactly "staging, still to work". */
18086
+ annotationCount: number().int()
17631
18087
  });
17632
- var ListGroupsPageSchema = object({
17633
- groups: array(AnalyticsGroupRecordSchema).readonly(),
17634
- nextCursor: string().nullable()
18088
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
18089
+ var RetrainFrameCandidateSchema = object({
18090
+ mediaKey: string(),
18091
+ kind: MediaFileKindEnum,
18092
+ timestamp: number(),
18093
+ sizeBytes: number().int(),
18094
+ /** A copy of this original already exists — selecting it is free and cannot
18095
+ * fail, whatever became of the original. */
18096
+ copied: boolean()
17635
18097
  });
17636
- var KeyEventQueryInput = object({
18098
+ /** A frame the dataset OWNS: bytes copied at selection time. */
18099
+ var RetrainFrameSchema = object({
18100
+ frameId: string(),
17637
18101
  deviceId: number(),
17638
- /** Window lower bound (track firstSeen ≥ since). */
17639
- since: number(),
17640
- /** Window upper bound (track firstSeen ≤ until). */
18102
+ trackId: string(),
18103
+ /** Provenance only. It may already point at nothing — that is expected. */
18104
+ sourceMediaKey: string(),
18105
+ sourceKind: MediaFileKindEnum,
18106
+ sizeBytes: number().int(),
18107
+ width: number().int(),
18108
+ height: number().int(),
18109
+ copiedAt: number()
18110
+ });
18111
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
18112
+ var RetrainCopyRefusalSchema = _enum([
18113
+ "source-missing",
18114
+ "unreadable-image",
18115
+ "write-failed"
18116
+ ]);
18117
+ var RetrainFrameSelectionSchema = object({
18118
+ copied: array(RetrainFrameSchema).readonly(),
18119
+ refused: array(object({
18120
+ sourceMediaKey: string(),
18121
+ reason: RetrainCopyRefusalSchema
18122
+ })).readonly()
18123
+ });
18124
+ var RetrainFrameListSchema = object({
18125
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
18126
+ copies: array(RetrainFrameSchema).readonly(),
18127
+ /** What the page pre-selects — the native key frame when one survives. */
18128
+ autoPickMediaKey: string().optional()
18129
+ });
18130
+ /** What the operator asked the assist to look for. */
18131
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
18132
+ kind: literal("package"),
18133
+ zone: RetrainBboxSchema.optional()
18134
+ }), object({
18135
+ kind: literal("objects"),
18136
+ modelId: string(),
18137
+ minScore: number().optional()
18138
+ })]);
18139
+ /**
18140
+ * The assist's answer — a discriminated union, because "the model saw nothing"
18141
+ * and "this node cannot run that model" lead to different next moves and a
18142
+ * nullable result cannot tell them apart.
18143
+ */
18144
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
18145
+ kind: literal("proposed"),
18146
+ modelId: string(),
18147
+ stepId: string(),
18148
+ minScore: number(),
18149
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
18150
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
18151
+ /** Returned by the runner but removed by the threshold. */
18152
+ belowThreshold: number().int()
18153
+ }), object({
18154
+ kind: literal("refused"),
18155
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
18156
+ reason: string(),
18157
+ detail: string().optional()
18158
+ })]);
18159
+ /** The outcome of a lifecycle move owned by the retrain page. */
18160
+ var RetrainTransitionResultSchema = object({
18161
+ trackId: string(),
18162
+ /** Where the track ended up, whatever happened. */
18163
+ retrainStatus: RetrainStatusSchema,
18164
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
18165
+ changed: boolean(),
18166
+ reason: _enum([
18167
+ "unknown-track",
18168
+ "no-frames-copied",
18169
+ "not-staging",
18170
+ "not-trained",
18171
+ "unchanged"
18172
+ ]).optional()
18173
+ });
18174
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
18175
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
18176
+ var DeviceEventQueryInput = object({
18177
+ deviceId: number(),
18178
+ since: number().optional(),
18179
+ until: number().optional(),
18180
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
18181
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
18182
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
18183
+ * exact behaviour. Callers may omit this field — the store defaults to
18184
+ * `full` when not provided. */
18185
+ projection: _enum(["full", "slim"]).optional()
18186
+ });
18187
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
18188
+ var RecentTracksQueryInput = object({
18189
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
18190
+ deviceIds: array(number()),
18191
+ /** Window lower bound on `lastSeen` (inclusive). */
18192
+ since: number().optional(),
18193
+ /** Window upper bound on `lastSeen` (inclusive). */
18194
+ until: number().optional(),
18195
+ /** Page size. Default 200, max 1000. */
18196
+ limit: number().int().min(1).max(1e3).default(200),
18197
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
18198
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
18199
+ cursor: string().optional(),
18200
+ /** See {@link TrackProjectionSchema}. Default `full`. */
18201
+ projection: TrackProjectionSchema.optional(),
18202
+ /** Include stationary-promoted rows (parked objects). Default false: the
18203
+ * feed lists passages; parking records live on the stationary registry. */
18204
+ includeStationary: boolean().optional()
18205
+ });
18206
+ var RecentTracksPageSchema = object({
18207
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
18208
+ tracks: array(TrackSchema).readonly(),
18209
+ /** Cursor for the next page, or null when this page is the last. */
18210
+ nextCursor: string().nullable()
18211
+ });
18212
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
18213
+ var LIST_GROUPS_MAX_LIMIT = 100;
18214
+ var AnalyticsGroupRecordSchema = object({
18215
+ id: string(),
18216
+ deviceId: number().int(),
18217
+ openedAt: number().int(),
18218
+ closedAt: number().int(),
18219
+ timestamp: number().int(),
18220
+ memberCount: number().int(),
18221
+ memberTrackIds: array(string()).readonly(),
18222
+ className: string(),
18223
+ classes: array(string()).readonly(),
18224
+ /** Relative event-media path, or null when the group has no picture yet. */
18225
+ mediaUrl: string().nullable(),
18226
+ singleton: boolean()
18227
+ });
18228
+ var AnalyticsGroupMemberSchema = object({
18229
+ trackId: string(),
18230
+ deviceId: number().int(),
18231
+ className: string(),
18232
+ firstSeen: number().int(),
18233
+ lastSeen: number().int(),
18234
+ mediaUrl: string().nullable()
18235
+ });
18236
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
18237
+ var ListGroupsQueryInput = object({
18238
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
18239
+ deviceIds: array(number()),
18240
+ /** Window lower bound on `closedAt` (inclusive). */
18241
+ since: number().optional(),
18242
+ /** Window upper bound on `openedAt` (inclusive). */
18243
+ until: number().optional(),
18244
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
18245
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
18246
+ cursor: string().optional()
18247
+ });
18248
+ var ListGroupsPageSchema = object({
18249
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
18250
+ nextCursor: string().nullable()
18251
+ });
18252
+ var KeyEventQueryInput = object({
18253
+ deviceId: number(),
18254
+ /** Window lower bound (track firstSeen ≥ since). */
18255
+ since: number(),
18256
+ /** Window upper bound (track firstSeen ≤ until). */
17641
18257
  until: number(),
17642
18258
  limit: number().int().min(1).max(200).default(50),
17643
18259
  /** Drop tracks scoring below this importance. */
@@ -17836,6 +18452,24 @@ var RebuildStatusSchema = object({
17836
18452
  /** Present when the pass ended by throwing. */
17837
18453
  error: string().nullable()
17838
18454
  });
18455
+ var ReplayFrameInputSchema = object({
18456
+ timestamp: number(),
18457
+ frame: PipelineRunResultBridge
18458
+ });
18459
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
18460
+ className: string(),
18461
+ firstSeenMs: number(),
18462
+ lastSeenMs: number(),
18463
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
18464
+ * frame — a representative box for the diff's `(className, window, IoU)`
18465
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
18466
+ * trajectory production's `Track.positions` keeps. */
18467
+ bbox: BoundingBoxSchema,
18468
+ /** How many of the input frames this track matched a real detection on
18469
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
18470
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
18471
+ framesMatched: number().int()
18472
+ })).readonly() });
17839
18473
  DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
17840
18474
  deviceId: number(),
17841
18475
  trackId: string()
@@ -18006,502 +18640,80 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
18006
18640
  }), RetrainAssistResultSchema, {
18007
18641
  kind: "mutation",
18008
18642
  auth: "admin"
18009
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18010
- kind: "query",
18011
- auth: "admin"
18012
- }), method(object({
18013
- deviceId: number(),
18014
- trackId: string(),
18015
- frameId: string(),
18016
- annotations: array(RetrainAnnotationDraftSchema)
18017
- }), array(RetrainAnnotationSchema).readonly(), {
18018
- kind: "mutation",
18019
- auth: "admin"
18020
- }), method(object({
18021
- deviceId: number(),
18022
- trackId: string()
18023
- }), RetrainTransitionResultSchema, {
18024
- kind: "mutation",
18025
- auth: "admin"
18026
18643
  }), method(object({
18027
18644
  deviceId: number(),
18028
- trackId: string()
18029
- }), RetrainTransitionResultSchema, {
18645
+ source: DetectionSourceSchema,
18646
+ zones: array(ZoneSchema).readonly().optional(),
18647
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
18648
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
18649
+ frames: array(ReplayFrameInputSchema).min(1)
18650
+ }), RunReplayFrameProcessorResultSchema, {
18030
18651
  kind: "mutation",
18031
18652
  auth: "admin"
18032
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18653
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18033
18654
  kind: "query",
18034
18655
  auth: "admin"
18035
18656
  }), method(object({
18036
- eventId: string(),
18037
- kind: MediaFileKindEnum.optional(),
18038
- deviceId: number()
18039
- }), array(MediaFileSchema).readonly()), method(object({
18040
- trackId: string(),
18041
- kinds: array(MediaFileKindEnum).optional(),
18042
- deviceId: number()
18043
- }), array(MediaFileSchema).readonly()), method(object({
18044
- trackId: string(),
18045
- deviceId: number()
18046
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18047
- kind: "mutation",
18048
- auth: "admin"
18049
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18050
- kind: "mutation",
18051
- auth: "admin"
18052
- }), method(object({}), RebuildStatusSchema), object({
18053
- deviceId: number(),
18054
- timestamp: number(),
18055
- frameWidth: number(),
18056
- frameHeight: number(),
18057
- detections: array(OverlayDetectionSchema).readonly()
18058
- }), object({
18059
- deviceId: number(),
18060
- trackId: string(),
18061
- className: string()
18062
- }), object({
18063
18657
  deviceId: number(),
18064
18658
  trackId: string(),
18065
- className: string(),
18066
- durationMs: number()
18067
- }), object({
18068
- deviceId: number(),
18069
- kind: EventKindSchema,
18070
- eventId: string(),
18071
- timestamp: number()
18072
- });
18073
- /**
18074
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
18075
- * within the frame, so the executor can re-cut a leaf child ROI at native
18076
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
18077
- */
18078
- var NativeCropRefSchema = object({
18079
- /** Handle keying the retained native surface (node-pinned to its owner). */
18080
- handle: FrameHandleSchema,
18081
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
18082
- cropFrameSpace: object({
18083
- x: number(),
18084
- y: number(),
18085
- w: number(),
18086
- h: number()
18087
- })
18088
- });
18089
- object({
18090
- crop: object({
18091
- left: number(),
18092
- top: number(),
18093
- width: number().positive(),
18094
- height: number().positive()
18095
- }).optional(),
18096
- content: object({
18097
- width: number().int().positive(),
18098
- height: number().int().positive()
18099
- }),
18100
- fit: _enum(["stretch", "contain"]),
18101
- format: _enum([
18102
- "rgb",
18103
- "gray",
18104
- "jpeg"
18105
- ])
18106
- });
18107
- /**
18108
- * Process-local frame identity. It is serializable so it can ride an in-process
18109
- * capability call, but `registryId` deliberately prevents resolution in any
18110
- * other process or execution group.
18111
- */
18112
- var FrameRefSchema = object({
18113
- registryId: string().min(1),
18114
- id: string().min(1),
18115
- width: number().int().positive(),
18116
- height: number().int().positive(),
18117
- format: _enum(["rgb", "gray"]),
18118
- timestamp: number(),
18119
- capturedAt: number().optional()
18120
- });
18121
- var ModelFormatSchema$1 = _enum([
18122
- "onnx",
18123
- "coreml",
18124
- "openvino",
18125
- "tflite",
18126
- "pt",
18127
- "gguf"
18128
- ]);
18129
- var PipelineSlotSchema = _enum([
18130
- "detector",
18131
- "cropper",
18132
- "classifier",
18133
- "refiner",
18134
- "audio-classifier"
18135
- ]);
18136
- var PipelineEngineChoiceSchema = object({
18137
- runtime: _enum(["node", "python"]),
18138
- backend: string(),
18139
- format: ModelFormatSchema$1,
18140
- device: string().optional()
18141
- });
18142
- var AvailableEngineSchema = object({
18143
- engine: PipelineEngineChoiceSchema,
18144
- devices: array(object({
18145
- id: string(),
18146
- label: string(),
18147
- description: string().optional()
18148
- })).readonly(),
18149
- defaultDevice: string()
18150
- });
18151
- var PipelineDefaultStepSchema = lazy(() => object({
18152
- addonId: string(),
18153
- addonName: string(),
18154
- slot: PipelineSlotSchema,
18155
- inputClasses: array(string()).readonly(),
18156
- outputClasses: array(string()).readonly(),
18157
- enabled: boolean(),
18158
- modelId: string(),
18159
- children: array(PipelineDefaultStepSchema).readonly(),
18160
- group: string().optional(),
18161
- settings: record(string(), unknown()).optional()
18162
- }));
18163
- var PipelineTemplateStepSchema = lazy(() => object({
18164
- addonId: string(),
18165
- enabled: boolean(),
18166
- modelId: string(),
18167
- children: array(PipelineTemplateStepSchema).readonly(),
18168
- settings: record(string(), unknown()).optional()
18169
- }));
18170
- var PipelineTemplateSchema$1 = object({
18171
- id: string(),
18172
- name: string(),
18173
- createdAt: string(),
18174
- updatedAt: string(),
18175
- engine: PipelineEngineChoiceSchema,
18176
- steps: array(PipelineTemplateStepSchema).readonly()
18177
- });
18178
- var PipelineModelOptionSchema = object({
18179
- id: string(),
18180
- name: string(),
18181
- formats: record(string(), object({
18182
- downloaded: boolean(),
18183
- sizeMB: number()
18184
- })),
18185
- group: ModelVariantGroupSchema.optional(),
18186
- legacy: boolean().optional(),
18187
- provider: ModelProviderIdSchema.optional()
18188
- });
18189
- var ConfigFieldBridge = custom();
18190
- var PipelineAddonSchemaSchema = object({
18191
- id: string(),
18192
- name: string(),
18193
- slot: PipelineSlotSchema,
18194
- inputClasses: array(string()).readonly(),
18195
- outputClasses: array(string()).readonly(),
18196
- childSlots: array(PipelineSlotSchema).readonly(),
18197
- models: array(PipelineModelOptionSchema).readonly(),
18198
- defaultModelId: string(),
18199
- defaultModelIdByFormat: record(string(), string()).optional(),
18200
- enabledByDefault: boolean().optional(),
18201
- backfillIntoExistingOverrides: boolean().optional(),
18202
- defaultConfidence: number(),
18203
- group: string().optional(),
18204
- configSchema: array(ConfigFieldBridge).readonly().optional()
18205
- });
18206
- var PipelineSlotSchemaSchema = object({
18207
- id: PipelineSlotSchema,
18208
- label: string(),
18209
- priority: number(),
18210
- parentSlot: PipelineSlotSchema.nullable(),
18211
- addons: array(PipelineAddonSchemaSchema).readonly()
18212
- });
18213
- var PipelineSchemaSchema = object({
18214
- availableEngines: array(AvailableEngineSchema).readonly(),
18215
- selectedEngine: PipelineEngineChoiceSchema,
18216
- slots: array(PipelineSlotSchemaSchema).readonly()
18217
- });
18218
- var EngineProvisioningSchema = object({
18219
- runtimeId: _enum([
18220
- "onnx",
18221
- "openvino",
18222
- "coreml",
18223
- "edgetpu"
18224
- ]).nullable(),
18225
- device: string().nullable(),
18226
- state: _enum([
18227
- "idle",
18228
- "installing",
18229
- "verifying",
18230
- "ready",
18231
- "failed"
18232
- ]),
18233
- progress: number().optional(),
18234
- error: string().optional(),
18235
- nextRetryAt: number().optional(),
18236
- /**
18237
- * Gate A (config-correctness gate at engine change): human-readable
18238
- * config issues surfaced EAGERLY when the node's engine changes — model
18239
- * substitutions ("chose X, running Y") and zero-build steps ("no model
18240
- * has a <format> build"). Additive/optional: informational only, never
18241
- * enforced here — `assertEngineReady` (readiness) still gates inference.
18242
- * Absent/empty when the node-default tree resolves cleanly.
18243
- */
18244
- configIssues: array(string()).optional()
18245
- });
18246
- var PipelineStepInputSchema = lazy(() => object({
18247
- addonId: string(),
18248
- modelId: string().optional(),
18249
- enabled: boolean().default(true),
18250
- children: array(PipelineStepInputSchema).optional(),
18251
- settings: record(string(), unknown()).optional(),
18252
- jumpDeviceKey: string().optional()
18253
- }));
18254
- var ModelSubstitutionSchema = object({
18255
- addonId: string(),
18256
- chosen: string(),
18257
- running: string(),
18258
- format: string()
18259
- });
18260
- var PipelineValidationIssueSchema = object({
18261
- addonId: string(),
18262
- kind: _enum(["unknown-addon", "no-format-build"]),
18263
- detail: string()
18264
- });
18265
- var PipelineValidationResultSchema = object({
18266
- ok: boolean(),
18267
- issues: array(PipelineValidationIssueSchema).readonly(),
18268
- substitutions: array(ModelSubstitutionSchema).readonly(),
18269
- /** The node's `currentEngine.format` this validation ran against. */
18270
- format: string()
18271
- });
18272
- var ReferenceImageEntrySchema = object({
18273
- filename: string(),
18274
- stepIds: array(string()).readonly().optional()
18275
- });
18276
- var ReferenceImageBodySchema = object({
18277
- base64: string(),
18278
- filename: string()
18279
- });
18280
- var ReferenceAudioEntrySchema = object({
18281
- filename: string(),
18282
- sizeKb: number()
18283
- });
18284
- var ReferenceAudioBodySchema = object({ base64: string() });
18285
- var AudioBackendSchema = object({
18286
- id: string(),
18287
- name: string(),
18288
- description: string(),
18289
- available: boolean(),
18290
- /**
18291
- * Raw classifier labels this backend can emit (e.g. YAMNet's
18292
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
18293
- * the benchmark UI to populate the `enabledMicroClasses` filter
18294
- * specific to the selected backend without a separate fetch.
18295
- */
18296
- rawLabels: array(string()).readonly().optional()
18297
- });
18298
- var AudioCapabilitiesSchema = object({
18299
- activeBackend: string(),
18300
- availableBackends: array(AudioBackendSchema).readonly(),
18301
- sampleRate: number(),
18302
- chunkDurationMs: number()
18303
- });
18304
- var DownloadModelResultSchema = object({
18305
- filePath: string(),
18306
- sizeMB: number(),
18307
- durationMs: number()
18308
- });
18309
- /**
18310
- * Wrapper carrying a single test run's result. Replaces the legacy
18311
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
18312
- * canonical `AudioResult` from the Phase 6 output rework: one
18313
- * `AudioDetection` per class above `minScore`, top-N candidates in
18314
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
18315
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
18316
- * benchmark UI can still report a clean failure when the classifier
18317
- * cap isn't available.
18318
- */
18319
- var AudioTestResultSchema = object({
18320
- success: boolean(),
18321
- error: string().optional(),
18322
- frame: custom().optional()
18323
- });
18324
- var PipelineConfigBridge = custom();
18325
- var ConfigUISchemaBridge = custom();
18326
- var ConfigUISchemaNullableBridge = custom();
18327
- var InferenceCapabilitiesBridge = custom();
18328
- var ModelAvailabilityListBridge = custom();
18329
- var PipelineRunResultBridge = custom();
18330
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
18331
- modelId: string(),
18332
- settings: record(string(), unknown()).readonly()
18333
- }))), method(object({ steps: record(string(), object({
18334
- modelId: string(),
18335
- settings: record(string(), unknown()).readonly()
18336
- })) }), object({ success: literal(true) }), {
18337
- kind: "mutation",
18338
- auth: "admin"
18339
- }), method(object({ nodeId: string() }), object({
18340
- success: literal(true),
18341
- clearedDevices: number()
18342
- }), {
18343
- kind: "mutation",
18344
- auth: "admin"
18345
- }), method(_void(), PipelineSchemaSchema), method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()), method(_void(), PipelineConfigBridge), method(_void(), ConfigUISchemaBridge), method(object({ steps: array(PipelineStepInputSchema) }), PipelineValidationResultSchema), method(_void(), array(PipelineTemplateSchema$1).readonly()), method(object({
18346
- name: string(),
18347
- steps: array(PipelineTemplateStepSchema).readonly(),
18348
- engine: PipelineEngineChoiceSchema
18349
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
18350
- id: string(),
18351
- name: string().optional(),
18352
- steps: array(PipelineTemplateStepSchema).readonly().optional()
18353
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
18354
- addonId: string(),
18355
- modelId: string(),
18356
- format: ModelFormatSchema$1
18357
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
18358
- addonId: string(),
18359
- modelId: string(),
18360
- format: ModelFormatSchema$1
18361
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
18362
- engine: PipelineEngineChoiceSchema.optional(),
18363
- steps: array(PipelineStepInputSchema).min(1),
18364
- frame: FrameInputSchema.optional(),
18365
- /**
18366
- * Process-local lazy frame. Valid only when caller and provider resolve
18367
- * in the same execution-group process; split/cross-node callers use
18368
- * `frame`/`image` inline compatibility instead.
18369
- */
18370
- frameRef: FrameRefSchema.optional(),
18371
- /**
18372
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
18373
- * the decoded pixels live in. One more member of the one-of
18374
- * frame/frameHandle/image/imageBase64/referenceImage group.
18375
- */
18376
- frameHandle: FrameHandleSchema.optional(),
18377
- imageBase64: string().optional(),
18378
- /**
18379
- * Binary JPEG bytes — preferred over `imageBase64` on internal
18380
- * hops (hub → forked worker via Moleculer MsgPack) because it
18381
- * skips the 33% base64 overhead + the per-call base64 decode on
18382
- * the detection-pipeline worker. Callers can pass either; exactly
18383
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
18384
- */
18385
- image: _instanceof(Uint8Array).optional(),
18386
- referenceImage: string().optional(),
18387
- deviceId: number().optional(),
18388
- sessionId: string().optional(),
18389
- /**
18390
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
18391
- * reference-image, and detail-subtree calls. 'frame' is the live
18392
- * per-frame dispatch: ONLY root-plane steps run; crop children
18393
- * (inputClasses ≠ null) are skipped and served per-track via
18394
- * pipelineRunner.runDetailSubtree (two-plane design).
18395
- */
18396
- plane: _enum(["full", "frame"]).optional(),
18397
- /**
18398
- * Inference-device selector (Phase 2 multi-device). Format
18399
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
18400
- * Omitted ⇒ the runner's default device (current single-engine
18401
- * behaviour). Selects WHICH device pool of the node runs the call.
18402
- */
18403
- deviceKey: string().optional(),
18404
- /**
18405
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
18406
- * when the parent crop was resolved from the frame's retained NATIVE
18407
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
18408
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
18409
- * resolution from that surface — the SAME quality path faces already
18410
- * had — instead of the downscaled parent tile. `handle` keys the native
18411
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
18412
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
18413
- * the executor's crop-normalized child ROI back into frame-normalized
18414
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
18415
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
18416
- * (today's behaviour on the fallback path).
18417
- */
18418
- nativeCropRef: NativeCropRefSchema.optional()
18419
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
18420
- engine: PipelineEngineChoiceSchema.optional(),
18421
- steps: array(PipelineStepInputSchema).min(1),
18422
- frames: array(FrameInputSchema).min(1).max(255),
18423
- deviceId: number().optional(),
18424
- sessionId: string().optional(),
18425
- /**
18426
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
18427
- * the batch to the Python pool's bench preprocess cache
18428
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
18429
- * preprocessed ONCE and every later inference is a pure-inference cache
18430
- * hit — the sustained-throughput run measures inference, not
18431
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
18432
- * full preprocess every call, correct). Fresh per sustained run;
18433
- * released via `uncacheFrame`.
18434
- */
18435
- frameId: number().int().nonnegative().optional(),
18436
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
18437
- deviceKey: string().optional()
18438
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
18439
- data: _instanceof(Uint8Array),
18440
- width: number().int().positive(),
18441
- height: number().int().positive(),
18442
- format: _enum([
18443
- "rgb",
18444
- "bgr",
18445
- "gray"
18446
- ])
18447
- }), object({
18448
- frameId: number(),
18449
- width: number(),
18450
- height: number()
18451
- }), { kind: "mutation" }), method(object({
18452
- stepId: string(),
18453
- frameId: number().int()
18454
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
18455
- batchMode: string(),
18456
- windowMs: number(),
18457
- maxBatchSize: number(),
18458
- concurrency: number()
18459
- })), method(_void(), array(object({
18460
- engineKey: string(),
18461
- engine: PipelineEngineChoiceSchema,
18462
- modelsLoaded: array(string()).readonly(),
18463
- inUseByCameras: array(number()).readonly(),
18464
- /**
18465
- * Origin of this resident factory.
18466
- * - `runtime` — main camera-serving engine (no idle TTL).
18467
- * - `warm-override` — benchmark/test override held in the warm
18468
- * cache; auto-disposed after the idle TTL.
18469
- * - `device-pool` — a concurrent per-device pool (Phase 2
18470
- * multi-device, keyed by `deviceKey`) resolved
18471
- * via `resolveDeviceFactory`. Runs alongside the
18472
- * `runtime` engine on a DIFFERENT accelerator
18473
- * (NPU / iGPU / Coral) — this is how the
18474
- * Engines tab shows all pools running at once.
18475
- */
18476
- kind: _enum([
18477
- "runtime",
18478
- "warm-override",
18479
- "device-pool"
18480
- ]),
18481
- /** Native pid of the underlying Python pool (null when no pool). */
18482
- poolPid: number().nullable(),
18483
- /** ms since this factory was last used (null when not warm-tracked). */
18484
- idleMs: number().nullable(),
18485
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
18486
- idleTtlMs: number().nullable()
18487
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
18659
+ frameId: string(),
18660
+ annotations: array(RetrainAnnotationDraftSchema)
18661
+ }), array(RetrainAnnotationSchema).readonly(), {
18488
18662
  kind: "mutation",
18489
18663
  auth: "admin"
18490
18664
  }), method(object({
18491
- engine: PipelineEngineChoiceSchema,
18492
- force: boolean().optional()
18493
- }), object({
18494
- success: boolean(),
18495
- reason: string().optional()
18496
- }), {
18665
+ deviceId: number(),
18666
+ trackId: string()
18667
+ }), RetrainTransitionResultSchema, {
18497
18668
  kind: "mutation",
18498
18669
  auth: "admin"
18499
- }), method(_void(), array(ReferenceImageEntrySchema).readonly()), method(object({ filename: string() }), ReferenceImageBodySchema.nullable()), method(_void(), array(ReferenceAudioEntrySchema).readonly()), method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()), method(_void(), AudioCapabilitiesSchema), method(object({
18500
- addonId: string(),
18501
- modelId: string(),
18502
- filename: string().optional(),
18503
- settings: record(string(), unknown()).optional()
18504
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
18670
+ }), method(object({
18671
+ deviceId: number(),
18672
+ trackId: string()
18673
+ }), RetrainTransitionResultSchema, {
18674
+ kind: "mutation",
18675
+ auth: "admin"
18676
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18677
+ kind: "query",
18678
+ auth: "admin"
18679
+ }), method(object({
18680
+ eventId: string(),
18681
+ kind: MediaFileKindEnum.optional(),
18682
+ deviceId: number()
18683
+ }), array(MediaFileSchema).readonly()), method(object({
18684
+ trackId: string(),
18685
+ kinds: array(MediaFileKindEnum).optional(),
18686
+ deviceId: number()
18687
+ }), array(MediaFileSchema).readonly()), method(object({
18688
+ trackId: string(),
18689
+ deviceId: number()
18690
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18691
+ kind: "mutation",
18692
+ auth: "admin"
18693
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18694
+ kind: "mutation",
18695
+ auth: "admin"
18696
+ }), method(object({}), RebuildStatusSchema), object({
18697
+ deviceId: number(),
18698
+ timestamp: number(),
18699
+ frameWidth: number(),
18700
+ frameHeight: number(),
18701
+ detections: array(OverlayDetectionSchema).readonly()
18702
+ }), object({
18703
+ deviceId: number(),
18704
+ trackId: string(),
18705
+ className: string()
18706
+ }), object({
18707
+ deviceId: number(),
18708
+ trackId: string(),
18709
+ className: string(),
18710
+ durationMs: number()
18711
+ }), object({
18712
+ deviceId: number(),
18713
+ kind: EventKindSchema,
18714
+ eventId: string(),
18715
+ timestamp: number()
18716
+ });
18505
18717
  object({
18506
18718
  activeCameras: number(),
18507
18719
  throttledCameras: number(),
@@ -18527,66 +18739,6 @@ var CameraMetricsSchema = object({
18527
18739
  });
18528
18740
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18529
18741
  /**
18530
- * Zone — pure geometry + identity. NO filtering behaviour.
18531
- *
18532
- * Zones describe **where** in the frame the operator wants to flag
18533
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
18534
- * each pipeline stage uses them. Splitting the two means a single
18535
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
18536
- * a detection-include rule on `['car']`, and an occupancy aggregate
18537
- * — without three duplicated polygons.
18538
- *
18539
- * Owned by the orchestrator addon (provider) and mirrored into the
18540
- * `zones` device-state slice on every mutation. Consumers
18541
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18542
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18543
- * mirror with `onChanged`).
18544
- *
18545
- * Coordinates are normalised fractions of the frame (0–1) so zones
18546
- * survive resolution changes and stream profile switches.
18547
- *
18548
- * `kind` discriminates between full polygons (closed regions used
18549
- * for intrusion / occupancy filters) and tripwires (open 2-point
18550
- * line segments used for cross events). Onboard / firmware-reported
18551
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18552
- * task list.
18553
- */
18554
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18555
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18556
- var PolygonPointSchema = object({
18557
- x: number(),
18558
- y: number()
18559
- });
18560
- /** A camera detection zone — pure geometry/identity. */
18561
- var ZoneSchema = object({
18562
- id: string(),
18563
- name: string(),
18564
- kind: ZoneKindEnum.default("polygon"),
18565
- /** Polygon vertices, fraction of frame (0–1). */
18566
- polygon: array(PolygonPointSchema).readonly(),
18567
- /** Visual color for UI rendering. */
18568
- color: string().default("#3b82f6")
18569
- });
18570
- DeviceType.Camera, method(object({ deviceId: number() }), array(ZoneSchema).readonly()), method(object({
18571
- deviceId: number(),
18572
- zone: ZoneSchema
18573
- }), _void(), {
18574
- kind: "mutation",
18575
- auth: "admin"
18576
- }), method(object({
18577
- deviceId: number(),
18578
- zoneId: string()
18579
- }), _void(), {
18580
- kind: "mutation",
18581
- auth: "admin"
18582
- }), method(object({
18583
- deviceId: number(),
18584
- zone: ZoneSchema
18585
- }), _void(), {
18586
- kind: "mutation",
18587
- auth: "admin"
18588
- }), object({ zones: array(ZoneSchema).readonly() });
18589
- /**
18590
18742
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
18591
18743
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
18592
18744
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -25564,6 +25716,39 @@ var ReadGopBytesResultSchema = object({
25564
25716
  /** Media ms the returned fragment covers. */
25565
25717
  gopDurMs: number()
25566
25718
  });
25719
+ /**
25720
+ * A time WINDOW of one finalized segment, cut by byte range — the multi-GOP
25721
+ * twin of {@link ReadGopBytesResultSchema}'s single instant. Built for the
25722
+ * replay clip's `recording` source (`docs/design/plans/2026-08-26-replay-clip-su-pipeline.md`):
25723
+ * a replay needs several seconds of native pixels, not one frame.
25724
+ *
25725
+ * `ok.data` is standalone-demuxable, same as a GOP read. `ok.reachesRequestedEnd`
25726
+ * is `false` when the returned bytes were cut short by the read's own safety
25727
+ * byte cap before covering `[fromMs, toMs)` — a truncation, reported, not a
25728
+ * silently shorter answer. `spans-multiple-segments` is a REFUSAL, not a
25729
+ * degradation: a window whose end falls past the covering segment would need
25730
+ * bytes stitched from a second segment file (its own `ftyp`+`moov`), which is
25731
+ * not one standalone-demuxable stream — the caller's answer is to request a
25732
+ * shorter window or one aligned to a single segment, not to receive spliced
25733
+ * bytes nothing has proven decodable.
25734
+ */
25735
+ var ReadWindowBytesResultSchema = discriminatedUnion("kind", [object({
25736
+ kind: literal("ok"),
25737
+ data: _instanceof(Uint8Array),
25738
+ /** Absolute epoch ms of the returned bytes' first sample — at or before
25739
+ * the requested `fromMs` (anchored on the nearest keyframe). */
25740
+ gopStartMs: number(),
25741
+ /** Media ms the returned bytes cover, from `gopStartMs`. */
25742
+ gopDurMs: number(),
25743
+ /** `false` ⇒ the safety byte cap cut the read short before it reached
25744
+ * the requested `toMs`; the caller got fewer frames than asked for. */
25745
+ reachesRequestedEnd: boolean()
25746
+ }), object({
25747
+ kind: literal("spans-multiple-segments"),
25748
+ /** Where the covering segment's own footage runs out — informational,
25749
+ * not a retry hint (retrying the same window would refuse again). */
25750
+ segmentEndMs: number()
25751
+ })]);
25567
25752
  method(object({
25568
25753
  deviceId: number(),
25569
25754
  fromMs: number(),
@@ -25614,6 +25799,15 @@ method(object({
25614
25799
  }), ReadGopBytesResultSchema, {
25615
25800
  kind: "query",
25616
25801
  auth: "admin"
25802
+ }), method(object({
25803
+ deviceId: number(),
25804
+ profile: string(),
25805
+ startMs: number(),
25806
+ fromMs: number(),
25807
+ toMs: number()
25808
+ }), ReadWindowBytesResultSchema, {
25809
+ kind: "query",
25810
+ auth: "admin"
25617
25811
  }), method(object({
25618
25812
  deviceId: number(),
25619
25813
  config: RecordingConfigSchema
@@ -26168,92 +26362,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), SceneMonitorStatusSche
26168
26362
  kind: "mutation",
26169
26363
  auth: "admin"
26170
26364
  });
26171
- /**
26172
- * Per-stage gating mode applied to the zones a rule references.
26173
- *
26174
- * - `include`: the rule contributes to a **whitelist** for its stage.
26175
- * When at least one `include` rule fires for a stage, only entities
26176
- * inside one of those zones pass that stage.
26177
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
26178
- * Entities inside one of those zones are dropped at that stage.
26179
- *
26180
- * `monitor`-style observation (count without filtering) is not a rule
26181
- * mode — zones without any matching rule are observed naturally by
26182
- * `zone-analytics` (live snapshot + history), so an "I just want to
26183
- * count, not filter" use case needs no rule at all.
26184
- */
26185
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
26186
- /**
26187
- * Per-consumer rule that references existing zones (geometry) and
26188
- * defines how a specific pipeline stage should treat them. Each
26189
- * consumer addon owns its own `ZoneRule[]` array in its per-device
26190
- * settings:
26191
- *
26192
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
26193
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
26194
- * - future: notification rules, audio gating, etc.
26195
- *
26196
- * One rule applies to N zones (`zoneIds[]`) so the operator can
26197
- * express "ignore motion in ALL of {garden, street}" with a single
26198
- * rule. `classFilter` narrows the rule to specific object classes —
26199
- * "drop person detections in the street, but keep cars" is one
26200
- * `exclude` rule with `classFilter: ['person']`.
26201
- *
26202
- * `enabled` is a soft toggle — the operator can keep the rule
26203
- * configured but inert without deleting it.
26204
- */
26205
- var ZoneRuleSchema = object({
26206
- /** Stable rule id — survives edits, used by the UI for diffing. */
26207
- id: string(),
26208
- /** Optional human-readable label rendered in the rule editor. */
26209
- name: string().optional(),
26210
- /** Zones this rule targets. The rule's `mode` applies to ALL
26211
- * listed zones (OR-set: a detection in any one of them counts).
26212
- * At least one zone id required — a rule with no targets is a
26213
- * configuration mistake and the form validator rejects it. */
26214
- zoneIds: array(string()).min(1).readonly(),
26215
- mode: ZoneRuleModeEnum,
26216
- /**
26217
- * Class names this rule applies to. Empty / undefined ⇒ rule
26218
- * applies to every class. Class strings match the `macroClass`
26219
- * field on detections (e.g. `person`, `car`, `dog`).
26220
- */
26221
- classFilter: array(string()).readonly().optional(),
26222
- /**
26223
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
26224
- * required to consider an entity "in the zone". Defaults to the
26225
- * consumer's stage default when omitted. Kept for back-compat with
26226
- * existing per-rule overrides; new operators pick the value via
26227
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
26228
- * set, the lower-level engine reads it as a 0–1 fraction.
26229
- */
26230
- overlapThreshold: number().min(0).max(1).optional(),
26231
- /**
26232
- * Operator-friendly version of `overlapThreshold` — the percentage
26233
- * of the detection's bbox that must lie inside the zone for the
26234
- * rule to match. Documented default is 85%; the engine substitutes
26235
- * that when the field is omitted (kept optional so existing rules
26236
- * stored without it stay valid).
26237
- *
26238
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
26239
- * rule, the engine prefers `bboxInclusionPct` because it's the
26240
- * field exposed in the UI. Internally both feed the same gate.
26241
- */
26242
- bboxInclusionPct: number().min(0).max(100).optional(),
26243
- /**
26244
- * When `true` and a detection has a segmentation mask, use the
26245
- * mask for overlap instead of the bbox. Detection-stage only;
26246
- * motion rules ignore this field.
26247
- */
26248
- preferMask: boolean().optional(),
26249
- /**
26250
- * Soft-toggle: `false` disables the rule without deleting it.
26251
- * Defaults to `true` so operators creating a rule via the UI
26252
- * see it active immediately.
26253
- */
26254
- enabled: boolean().default(true)
26255
- });
26256
- array(ZoneRuleSchema).readonly();
26257
26365
  object({
26258
26366
  /** Whether the script is currently executing. */
26259
26367
  isRunning: boolean(),
@@ -30118,6 +30226,12 @@ Object.freeze({
30118
30226
  addonId: null,
30119
30227
  access: "view"
30120
30228
  },
30229
+ "notificationRules.resolveArtifactUrl": {
30230
+ capName: "notification-rules",
30231
+ capScope: "system",
30232
+ addonId: null,
30233
+ access: "view"
30234
+ },
30121
30235
  "notificationRules.setAlarmConfig": {
30122
30236
  capName: "notification-rules",
30123
30237
  capScope: "system",
@@ -30562,6 +30676,12 @@ Object.freeze({
30562
30676
  addonId: null,
30563
30677
  access: "create"
30564
30678
  },
30679
+ "pipelineAnalytics.runReplayFrameProcessor": {
30680
+ capName: "pipeline-analytics",
30681
+ capScope: "device",
30682
+ addonId: null,
30683
+ access: "create"
30684
+ },
30565
30685
  "pipelineAnalytics.saveRetrainAnnotations": {
30566
30686
  capName: "pipeline-analytics",
30567
30687
  capScope: "device",
@@ -30694,6 +30814,12 @@ Object.freeze({
30694
30814
  addonId: null,
30695
30815
  access: "view"
30696
30816
  },
30817
+ "pipelineExecutor.getInferenceDeviceHealth": {
30818
+ capName: "pipeline-executor",
30819
+ capScope: "system",
30820
+ addonId: null,
30821
+ access: "view"
30822
+ },
30697
30823
  "pipelineExecutor.getOrchestratorConfigSchema": {
30698
30824
  capName: "pipeline-executor",
30699
30825
  capScope: "system",
@@ -30766,6 +30892,12 @@ Object.freeze({
30766
30892
  addonId: null,
30767
30893
  access: "view"
30768
30894
  },
30895
+ "pipelineExecutor.rearmInferenceDevice": {
30896
+ capName: "pipeline-executor",
30897
+ capScope: "system",
30898
+ addonId: null,
30899
+ access: "create"
30900
+ },
30769
30901
  "pipelineExecutor.runAudioTest": {
30770
30902
  capName: "pipeline-executor",
30771
30903
  capScope: "system",
@@ -31504,6 +31636,12 @@ Object.freeze({
31504
31636
  addonId: null,
31505
31637
  access: "view"
31506
31638
  },
31639
+ "recording.readWindowBytes": {
31640
+ capName: "recording",
31641
+ capScope: "system",
31642
+ addonId: null,
31643
+ access: "view"
31644
+ },
31507
31645
  "recording.refreshStorageLocationsForMigration": {
31508
31646
  capName: "recording",
31509
31647
  capScope: "system",
@@ -34014,6 +34152,11 @@ Object.freeze({
34014
34152
  form: "single",
34015
34153
  optional: false
34016
34154
  }],
34155
+ "pipelineAnalytics.runReplayFrameProcessor": [{
34156
+ name: "deviceId",
34157
+ form: "single",
34158
+ optional: false
34159
+ }],
34017
34160
  "pipelineAnalytics.saveRetrainAnnotations": [{
34018
34161
  name: "deviceId",
34019
34162
  form: "single",
@@ -34329,6 +34472,11 @@ Object.freeze({
34329
34472
  form: "single",
34330
34473
  optional: false
34331
34474
  }],
34475
+ "recording.readWindowBytes": [{
34476
+ name: "deviceId",
34477
+ form: "single",
34478
+ optional: false
34479
+ }],
34332
34480
  "recording.relocateFootage": [{
34333
34481
  name: "deviceId",
34334
34482
  form: "single",