@camstack/addon-pipeline 1.2.130 → 1.2.131

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 (34) hide show
  1. package/dist/{addon-utils-DH78p79i.js → addon-utils-DCQ5AP_v.js} +1 -1
  2. package/dist/audio-analyzer/index.js +3 -3
  3. package/dist/audio-analyzer/index.mjs +2 -2
  4. package/dist/detection-pipeline/index.js +332 -20
  5. package/dist/detection-pipeline/index.mjs +330 -18
  6. package/dist/{dist-DOw-izoI.js → dist-CqoMNE1e.js} +1817 -1712
  7. package/dist/{dist-Wt81pN5Y.mjs → dist-DO0UVhOk.mjs} +1817 -1712
  8. package/dist/{event-loop-stall-monitor-CtQCOZqm.mjs → event-loop-stall-monitor-D0Juf7Dn.mjs} +1 -1
  9. package/dist/{event-loop-stall-monitor-Bld7jNCb.js → event-loop-stall-monitor-eM7_yYfn.js} +1 -1
  10. package/dist/{lazy-sharp-BbNI2ZD-.js → lazy-sharp-BGrpS8yi.js} +1 -1
  11. package/dist/motion-wasm/index.js +2 -2
  12. package/dist/motion-wasm/index.mjs +1 -1
  13. package/dist/pipeline-runner/index.js +4 -4
  14. package/dist/pipeline-runner/index.mjs +3 -3
  15. package/dist/{process-memory-1_D3EZT9.mjs → process-memory-Bac3FuG6.mjs} +1 -1
  16. package/dist/{process-memory-D9H5qjDl.js → process-memory-xAPjvSw9.js} +1 -1
  17. package/dist/recorder/index.js +95 -4
  18. package/dist/recorder/index.mjs +94 -3
  19. package/dist/{segment-demux-js-C2jBBqGW.js → segment-demux-js-Cu0oDMUL.js} +1 -1
  20. package/dist/{segment-demux-js-BW-Q-j2A.mjs → segment-demux-js-skhsAZx6.mjs} +1 -1
  21. package/dist/session-decode/decode-worker-child.js +2 -2
  22. package/dist/session-decode/decode-worker-child.mjs +1 -1
  23. package/dist/stream-broker/_stub.js +1 -1
  24. package/dist/stream-broker/{_virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-Dw-iwP4y.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-DGQkDEYw.mjs} +3 -3
  25. package/dist/stream-broker/{_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-D36MoVV1.mjs → _virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-CQKwHIHI.mjs} +1 -1
  26. package/dist/stream-broker/demux-worker-child.js +1 -1
  27. package/dist/stream-broker/demux-worker-child.mjs +1 -1
  28. package/dist/stream-broker/{hostInit-DEVCEYgu.mjs → hostInit-D7FwwZgj.mjs} +3 -3
  29. package/dist/stream-broker/index.js +2 -2
  30. package/dist/stream-broker/index.mjs +2 -2
  31. package/dist/stream-broker/remoteEntry.js +1 -1
  32. package/dist/{worker-protocol-nAZl_Rsv.js → worker-protocol-G3HXTY8z.js} +1 -1
  33. package/dist/{worker-protocol-rpnr7Ldd.mjs → worker-protocol-_Ujvj1hl.mjs} +1 -1
  34. package/package.json +1 -1
@@ -17904,1596 +17904,273 @@ var OauthIntegrationDescriptorSchema = object({
17904
17904
  });
17905
17905
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
17906
17906
  /**
17907
- * pipeline-analytics device-scoped wrapper cap. Refines raw
17908
- * per-frame detections emitted by the pipeline runner into tracked
17909
- * objects, per-kind event collections (motion / object / audio), and
17910
- * persisted media. Owns the post-detection domain end-to-end:
17911
- *
17912
- * runner emits PipelineInferenceResult
17913
- * ↓ (event bus)
17914
- * pipeline-analytics subscriber
17915
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
17916
- * → three DB collections (one per kind), one FS media tree, one
17917
- * unified event emitter (FrameTracked + TrackStarted/Ended +
17918
- * DetectionEvent on bus)
17919
- *
17920
- * Pure subscriber model. No `processFrame` cap method — the runner
17921
- * already publishes the raw frame on the bus. The cap surface is
17922
- * only QUERIES + per-device settings, bound on/off via
17923
- * `device-manager.setWrapperActive`. `defaultActive: true` because
17924
- * every camera with a detection pipeline wants its raw detections
17925
- * refined; operators opt out per-device via BindingsTab when needed.
17926
- *
17927
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17928
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
17907
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
17908
+ * within the frame, so the executor can re-cut a leaf child ROI at native
17909
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
17929
17910
  */
17930
- var TrackStateSchema = _enum([
17931
- "new",
17932
- "entered",
17933
- "left",
17934
- "moving",
17935
- "idle"
17936
- ]);
17937
- var EventKindSchema = _enum([
17938
- "motion",
17939
- "object",
17940
- "audio"
17941
- ]);
17911
+ var NativeCropRefSchema = object({
17912
+ /** Handle keying the retained native surface (node-pinned to its owner). */
17913
+ handle: FrameHandleSchema,
17914
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
17915
+ cropFrameSpace: object({
17916
+ x: number(),
17917
+ y: number(),
17918
+ w: number(),
17919
+ h: number()
17920
+ })
17921
+ });
17922
+ object({
17923
+ crop: object({
17924
+ left: number(),
17925
+ top: number(),
17926
+ width: number().positive(),
17927
+ height: number().positive()
17928
+ }).optional(),
17929
+ content: object({
17930
+ width: number().int().positive(),
17931
+ height: number().int().positive()
17932
+ }),
17933
+ fit: _enum(["stretch", "contain"]),
17934
+ format: _enum([
17935
+ "rgb",
17936
+ "gray",
17937
+ "jpeg"
17938
+ ])
17939
+ });
17942
17940
  /**
17943
- * Spatial filter for `listTracks` the rect + polygon variants of the shared
17944
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17945
- * of the camera frame (top-left origin), matching the drawing-plane editor.
17941
+ * Process-local frame identity. It is serializable so it can ride an in-process
17942
+ * capability call, but `registryId` deliberately prevents resolution in any
17943
+ * other process or execution group.
17946
17944
  */
17947
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17948
- /** Closed icon vocabulary so clients render a known glyph per kind. */
17949
- var EventKindIconSchema = _enum([
17950
- "motion",
17951
- "audio",
17952
- "person",
17953
- "vehicle",
17954
- "animal",
17955
- "door",
17956
- "pir",
17957
- "smoke",
17958
- "water",
17959
- "button",
17960
- "package",
17961
- "generic"
17945
+ var FrameRefSchema = object({
17946
+ registryId: string().min(1),
17947
+ id: string().min(1),
17948
+ width: number().int().positive(),
17949
+ height: number().int().positive(),
17950
+ format: _enum(["rgb", "gray"]),
17951
+ timestamp: number(),
17952
+ capturedAt: number().optional()
17953
+ });
17954
+ var ModelFormatSchema$1 = _enum([
17955
+ "onnx",
17956
+ "coreml",
17957
+ "openvino",
17958
+ "tflite",
17959
+ "pt",
17960
+ "gguf"
17962
17961
  ]);
17963
- var EventKindCategorySchema = _enum([
17964
- "motion",
17965
- "audio",
17966
- "detection",
17967
- "sensor",
17968
- "control",
17969
- "custom",
17970
- "package"
17962
+ var PipelineSlotSchema = _enum([
17963
+ "detector",
17964
+ "cropper",
17965
+ "classifier",
17966
+ "refiner",
17967
+ "audio-classifier"
17971
17968
  ]);
17972
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17973
- var EventKindLevelSchema = _enum(["macro", "sub"]);
17974
- var EventKindDescriptorSchema = object({
17975
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17976
- kind: string(),
17977
- /** i18n key resolved on the UI side; `label` is the English fallback. */
17978
- labelKey: string(),
17979
- /** English fallback label (kept for clients that don't translate). */
17980
- label: string(),
17981
- /** Hex color for timeline/legend rendering. */
17982
- color: string(),
17983
- /** Dictionary id → lucide component on the UI side. */
17984
- iconId: string(),
17985
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
17986
- icon: EventKindIconSchema,
17987
- category: EventKindCategorySchema,
17988
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17989
- parentKind: string().nullable(),
17990
- /** Derived from `parentKind`, explicit for the client tree. */
17991
- level: EventKindLevelSchema,
17992
- /** Which cap + device contributes this kind. For built-ins the camera
17993
- * itself; for sensor kinds the LINKED source device. */
17994
- source: object({
17995
- capName: string(),
17996
- deviceId: number()
17997
- })
17969
+ var PipelineEngineChoiceSchema = object({
17970
+ runtime: _enum(["node", "python"]),
17971
+ backend: string(),
17972
+ format: ModelFormatSchema$1,
17973
+ device: string().optional()
17998
17974
  });
17999
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
18000
- var EventKindsForDeviceSchema = object({
18001
- deviceId: number(),
18002
- kinds: array(EventKindDescriptorSchema).readonly()
17975
+ var AvailableEngineSchema = object({
17976
+ engine: PipelineEngineChoiceSchema,
17977
+ devices: array(object({
17978
+ id: string(),
17979
+ label: string(),
17980
+ description: string().optional()
17981
+ })).readonly(),
17982
+ defaultDevice: string()
18003
17983
  });
18004
- var SensorEventSchema = object({
17984
+ var PipelineDefaultStepSchema = lazy(() => object({
17985
+ addonId: string(),
17986
+ addonName: string(),
17987
+ slot: PipelineSlotSchema,
17988
+ inputClasses: array(string()).readonly(),
17989
+ outputClasses: array(string()).readonly(),
17990
+ enabled: boolean(),
17991
+ modelId: string(),
17992
+ children: array(PipelineDefaultStepSchema).readonly(),
17993
+ group: string().optional(),
17994
+ settings: record(string(), unknown()).optional()
17995
+ }));
17996
+ var PipelineTemplateStepSchema = lazy(() => object({
17997
+ addonId: string(),
17998
+ enabled: boolean(),
17999
+ modelId: string(),
18000
+ children: array(PipelineTemplateStepSchema).readonly(),
18001
+ settings: record(string(), unknown()).optional()
18002
+ }));
18003
+ var PipelineTemplateSchema$1 = object({
18005
18004
  id: string(),
18006
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
18007
- * yields N rows, one per camera). */
18008
- deviceId: number(),
18009
- /** The linked sensor device whose state changed. */
18010
- sourceDeviceId: number(),
18011
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
18012
- kind: string(),
18013
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
18014
- value: record(string(), unknown()).nullable(),
18015
- timestamp: number()
18005
+ name: string(),
18006
+ createdAt: string(),
18007
+ updatedAt: string(),
18008
+ engine: PipelineEngineChoiceSchema,
18009
+ steps: array(PipelineTemplateStepSchema).readonly()
18016
18010
  });
18017
- var TrackPositionSchema = object({
18018
- x: number(),
18019
- y: number(),
18020
- timestamp: number(),
18021
- bbox: BoundingBoxSchema
18011
+ var PipelineModelOptionSchema = object({
18012
+ id: string(),
18013
+ name: string(),
18014
+ formats: record(string(), object({
18015
+ downloaded: boolean(),
18016
+ sizeMB: number()
18017
+ })),
18018
+ group: ModelVariantGroupSchema.optional(),
18019
+ legacy: boolean().optional(),
18020
+ provider: ModelProviderIdSchema.optional()
18022
18021
  });
18023
- var TrackSnapshotSchema = object({
18024
- timestamp: number(),
18025
- position: TrackPositionSchema,
18026
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
18027
- mediaKey: string()
18022
+ var ConfigFieldBridge = custom();
18023
+ var PipelineAddonSchemaSchema = object({
18024
+ id: string(),
18025
+ name: string(),
18026
+ slot: PipelineSlotSchema,
18027
+ inputClasses: array(string()).readonly(),
18028
+ outputClasses: array(string()).readonly(),
18029
+ childSlots: array(PipelineSlotSchema).readonly(),
18030
+ models: array(PipelineModelOptionSchema).readonly(),
18031
+ defaultModelId: string(),
18032
+ defaultModelIdByFormat: record(string(), string()).optional(),
18033
+ enabledByDefault: boolean().optional(),
18034
+ backfillIntoExistingOverrides: boolean().optional(),
18035
+ defaultConfidence: number(),
18036
+ group: string().optional(),
18037
+ configSchema: array(ConfigFieldBridge).readonly().optional()
18028
18038
  });
18029
- /**
18030
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
18031
- * divided by the track's detection-frame dims), computed at persist time.
18032
- * Absent when the frame dims were unknown when the track was persisted
18033
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
18034
- */
18035
- var TrackEnvelopeSchema = object({
18036
- minX: number(),
18037
- minY: number(),
18038
- maxX: number(),
18039
- maxY: number()
18039
+ var PipelineSlotSchemaSchema = object({
18040
+ id: PipelineSlotSchema,
18041
+ label: string(),
18042
+ priority: number(),
18043
+ parentSlot: PipelineSlotSchema.nullable(),
18044
+ addons: array(PipelineAddonSchemaSchema).readonly()
18040
18045
  });
18041
- /**
18042
- * Row projection for track list queries. `full` (default) returns the
18043
- * complete Track including the frame-rate `positions[]` history and the
18044
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
18045
- * keeps every scalar the list surfaces actually render (ids, class(es),
18046
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
18047
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
18048
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
18049
- * `getTrack`. Mirrors the event-store `projection` convention
18050
- * (`getObjectEvents` et al.).
18051
- */
18052
- var TrackProjectionSchema = _enum(["full", "slim"]);
18053
- /**
18054
- * One audio-classification label heard on the track's camera while the
18055
- * track was alive, aggregated per label. An "episode" is one persisted
18056
- * audio event (the confident-classification path: score ≥ the device's
18057
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
18058
- * one 32 ms inference chunk, so counts stay human-scaled.
18059
- */
18060
- var TrackAudioLabelSchema = object({
18061
- label: string(),
18062
- /** Highest classification score observed across the label's episodes. */
18063
- peakScore: number(),
18064
- /** Number of coalesced audio-event episodes carrying this label. */
18065
- count: number(),
18066
- firstAt: number(),
18067
- lastAt: number()
18046
+ var PipelineSchemaSchema = object({
18047
+ availableEngines: array(AvailableEngineSchema).readonly(),
18048
+ selectedEngine: PipelineEngineChoiceSchema,
18049
+ slots: array(PipelineSlotSchemaSchema).readonly()
18068
18050
  });
18069
- /**
18070
- * How a track was produced. `pipeline` (default / absent) = the spatial
18071
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
18072
- * no positions, a single snapshot, and no bbox trajectory at all:
18073
- *
18074
- * - `sensor` — a linked sensor/control device state change.
18075
- * - `audio` — an audio event on the camera itself that was anomalous for
18076
- * THAT camera, loud, and heard while nothing visual was happening (D62).
18077
- *
18078
- * The spatial subsystems (tracker association, occupancy count, re-id /
18079
- * embedding, resurrection) MUST skip every synthetic source. Test for that
18080
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
18081
- * check silently readmits every source added after it was written.
18082
- */
18083
- var TrackSourceSchema = _enum([
18084
- "pipeline",
18085
- "sensor",
18086
- "audio"
18087
- ]);
18088
- /**
18089
- * Where a track sits in the RETRAIN lifecycle (D81).
18090
- *
18091
- * - `none` never marked, or un-marked. Evictable.
18092
- * - `staging`the operator wants this track as training material and has not
18093
- * finished with it. **This is the only state retention holds**: the track and
18094
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
18095
- * the device's age window.
18096
- * - `trained` — the retrain page has taken what it needed. The frames it chose
18097
- * were COPIED into the retrain dataset at selection time, so the dataset no
18098
- * longer depends on the track's media and the track becomes EVICTABLE again.
18099
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
18100
- * a deliberate action of the retrain page, not a side effect of a checkbox.
18101
- *
18102
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
18103
- * the store's filter language has only positive equality and `whereIn` — no
18104
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
18105
- * would make the entire pre-column history immortal in one deploy.
18106
- */
18107
- var RetrainStatusSchema = _enum([
18108
- "none",
18109
- "staging",
18110
- "trained"
18111
- ]);
18112
- /**
18113
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
18114
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
18115
- * so the two surfaces cannot drift.
18116
- *
18117
- * **Absent ≠ false.** A track that has never been touched omits the field; an
18118
- * explicitly un-flagged track carries `false`. Legacy rows written before the
18119
- * columns existed read as absent, and a consumer that needs a boolean should say
18120
- * `flag === true`, not `flag !== false`.
18121
- *
18122
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
18123
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
18124
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
18125
- * `trained` track reports `false` while refusing both writes. The boolean is
18126
- * kept because three surfaces drive a toggle off it; anything that needs to tell
18127
- * "never marked" from "already trained" must read `retrainStatus`.
18128
- *
18129
- * `debug` does NOT pin; it is attention, not durability.
18130
- *
18131
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
18132
- * A favourited track is skipped by retention the same way `staging` is, but
18133
- * it does not enter `none|staging|trained` and has no staging budget.
18134
- */
18135
- var TrackFlagFields = {
18136
- /** Operator marked this track as training material — i.e. `retrainStatus` is
18137
- * `'staging'`. */
18138
- markForTrain: boolean().optional(),
18139
- /** Operator marked this track for diagnostic attention. */
18140
- debug: boolean().optional(),
18141
- /** Operator favourited this track. Pins it against pruning. */
18142
- favourited: boolean().optional()
18143
- };
18144
- /**
18145
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
18146
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
18147
- * write patch, and the status is not something the toggle sets — it is what the
18148
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
18149
- * always present on a persisted row (the column default materialises `'none'`).
18150
- */
18151
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
18152
- /**
18153
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
18154
- * one flag can never clear the other — the toggles are independent and are
18155
- * driven from three surfaces that do not know about each other.
18156
- */
18157
- var TrackFlagsPatchSchema = object(TrackFlagFields);
18158
- /**
18159
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
18160
- * collapses to `false`) so a caller can drive a toggle's checked state off the
18161
- * mutation result without a re-fetch.
18162
- */
18163
- var TrackFlagsSchema = object({
18164
- trackId: string(),
18165
- markForTrain: boolean(),
18166
- debug: boolean(),
18167
- favourited: boolean(),
18168
- /** The lifecycle state the boolean was derived from. Required here (unlike on
18169
- * a track row) because this shape is only ever produced by the write body,
18170
- * which always knows it — and a surface that has just written needs to render
18171
- * `trained` without a re-fetch. */
18172
- retrainStatus: RetrainStatusSchema
18051
+ var EngineProvisioningSchema = object({
18052
+ runtimeId: _enum([
18053
+ "onnx",
18054
+ "openvino",
18055
+ "coreml",
18056
+ "edgetpu"
18057
+ ]).nullable(),
18058
+ device: string().nullable(),
18059
+ state: _enum([
18060
+ "idle",
18061
+ "installing",
18062
+ "verifying",
18063
+ "ready",
18064
+ "failed"
18065
+ ]),
18066
+ progress: number().optional(),
18067
+ error: string().optional(),
18068
+ nextRetryAt: number().optional(),
18069
+ /**
18070
+ * Gate A (config-correctness gate at engine change): human-readable
18071
+ * config issues surfaced EAGERLY when the node's engine changes — model
18072
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
18073
+ * has a <format> build"). Additive/optional: informational only, never
18074
+ * enforced here `assertEngineReady` (readiness) still gates inference.
18075
+ * Absent/empty when the node-default tree resolves cleanly.
18076
+ */
18077
+ configIssues: array(string()).optional()
18173
18078
  });
18174
- union([literal(1), literal(2)]);
18175
- /**
18176
- * WHO decided a label, and when. Carried per tier so a value can be traced to
18177
- * the step and model that produced it — which is what makes the write rule
18178
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
18179
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
18180
- *
18181
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
18182
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
18183
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
18184
- * that value has no provenance, and the write rule lets ANY properly-attributed
18185
- * write of the same tier replace it regardless of score.
18186
- */
18187
- var LabelAttributionSchema = object({
18188
- stepId: string(),
18079
+ var PipelineStepInputSchema = lazy(() => object({
18080
+ addonId: string(),
18189
18081
  modelId: string().optional(),
18190
- decidedAt: number(),
18082
+ enabled: boolean().default(true),
18083
+ children: array(PipelineStepInputSchema).optional(),
18084
+ settings: record(string(), unknown()).optional(),
18085
+ jumpDeviceKey: string().optional()
18086
+ }));
18087
+ var ModelSubstitutionSchema = object({
18088
+ addonId: string(),
18089
+ chosen: string(),
18090
+ running: string(),
18091
+ format: string()
18092
+ });
18093
+ var PipelineValidationIssueSchema = object({
18094
+ addonId: string(),
18095
+ kind: _enum(["unknown-addon", "no-format-build"]),
18096
+ detail: string()
18097
+ });
18098
+ var PipelineValidationResultSchema = object({
18099
+ ok: boolean(),
18100
+ issues: array(PipelineValidationIssueSchema).readonly(),
18101
+ substitutions: array(ModelSubstitutionSchema).readonly(),
18102
+ /** The node's `currentEngine.format` this validation ran against. */
18103
+ format: string()
18104
+ });
18105
+ var ReferenceImageEntrySchema = object({
18106
+ filename: string(),
18107
+ stepIds: array(string()).readonly().optional()
18108
+ });
18109
+ var ReferenceImageBodySchema = object({
18110
+ base64: string(),
18111
+ filename: string()
18112
+ });
18113
+ var ReferenceAudioEntrySchema = object({
18114
+ filename: string(),
18115
+ sizeKb: number()
18116
+ });
18117
+ var ReferenceAudioBodySchema = object({ base64: string() });
18118
+ var AudioBackendSchema = object({
18119
+ id: string(),
18120
+ name: string(),
18121
+ description: string(),
18122
+ available: boolean(),
18191
18123
  /**
18192
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
18193
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
18194
- *
18195
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
18196
- * notification rule authored on "Gianluca" stopped matching the moment the
18197
- * operator fixed the spelling in the gallery, and nothing said so. The id is
18198
- * the thing that does not move, so it is what a rule matches on
18199
- * (`NcConditions.identities`) and the text is what a human is shown.
18200
- *
18201
- * Absent when the label names no gallery row — a plate the OCR read but no
18202
- * vehicle claims, a sub-class, a species, any tier-1 value.
18124
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
18125
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
18126
+ * the benchmark UI to populate the `enabledMicroClasses` filter
18127
+ * specific to the selected backend without a separate fetch.
18203
18128
  */
18204
- identityId: string().optional()
18129
+ rawLabels: array(string()).readonly().optional()
18130
+ });
18131
+ var AudioCapabilitiesSchema = object({
18132
+ activeBackend: string(),
18133
+ availableBackends: array(AudioBackendSchema).readonly(),
18134
+ sampleRate: number(),
18135
+ chunkDurationMs: number()
18136
+ });
18137
+ var DownloadModelResultSchema = object({
18138
+ filePath: string(),
18139
+ sizeMB: number(),
18140
+ durationMs: number()
18205
18141
  });
18206
18142
  /**
18207
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
18208
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
18209
- * track and its events always answer the same question the same way.
18210
- *
18211
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
18212
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
18213
- * is tier 2, and each carries its own score + attribution.
18214
- *
18215
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
18216
- * finest thing known. Before 4g the single `label` column held the finest
18217
- * value, so a consumer that has not been updated reads the tier-1 slot and
18218
- * shows nothing on a species-only row; that is why the migration puts every
18219
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
18220
- * and why the read surfaces were changed in the same train.
18221
- *
18222
- * **Writing it.** The slots are independent, which is the whole point: a
18223
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
18224
- * migratorius`), so fineness cannot regress by construction. Within a tier the
18225
- * higher score wins. One rule, one implementation — see
18226
- * `pipeline/label-tier.ts` in addon-post-analysis.
18227
- */
18228
- var TieredLabelFields = {
18229
- /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
18230
- label: string().optional(),
18231
- /** Confidence of the tier-1 value, as reported by the deciding step. */
18232
- labelScore: number().optional(),
18233
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
18234
- labelMeta: LabelAttributionSchema.optional(),
18235
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
18236
- subLabel: string().optional(),
18237
- /** Confidence of the tier-2 value, as reported by the deciding step. */
18238
- subLabelScore: number().optional(),
18239
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
18240
- subLabelMeta: LabelAttributionSchema.optional()
18241
- };
18242
- /** Per-camera slice of a training-export estimate. */
18243
- var TrainingExportDeviceTotalsSchema = object({
18244
- deviceId: number(),
18245
- tracks: number().int(),
18246
- files: number().int(),
18247
- bytes: number().int()
18248
- });
18249
- /**
18250
- * What a training export WOULD contain. Computed from media index rows only —
18251
- * no blob is read to produce this.
18143
+ * Wrapper carrying a single test run's result. Replaces the legacy
18144
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
18145
+ * canonical `AudioResult` from the Phase 6 output rework: one
18146
+ * `AudioDetection` per class above `minScore`, top-N candidates in
18147
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
18148
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
18149
+ * benchmark UI can still report a clean failure when the classifier
18150
+ * cap isn't available.
18252
18151
  */
18253
- var TrainingExportSummarySchema = object({
18254
- generatedAt: number(),
18255
- trackCount: number().int(),
18256
- fileCount: number().int(),
18257
- byteCount: number().int(),
18258
- /** More marked tracks exist than a single pass carries. */
18259
- truncated: boolean(),
18260
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
18261
- });
18262
- var TrackSchema = object({
18263
- trackId: string(),
18264
- deviceId: number(),
18265
- className: string(),
18266
- ...TieredLabelFields,
18267
- producingDeviceName: string().optional(),
18268
- /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
18269
- source: TrackSourceSchema.optional(),
18270
- firstSeen: number(),
18271
- lastSeen: number(),
18272
- /** Frame-rate position history (subject to maxPositionHistory cap). */
18273
- positions: array(TrackPositionSchema).readonly(),
18274
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18275
- * saveThumbnails policy). */
18276
- snapshots: array(TrackSnapshotSchema).readonly(),
18277
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
18278
- zonesVisited: array(string()).readonly(),
18279
- /**
18280
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
18281
- * `zones` capability.
18282
- *
18283
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
18284
- * and no card can render — so every free-text search surface was structurally
18285
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
18286
- * just returned nothing. Resolving here rather than in each client keeps ONE
18287
- * derivation and costs the clients no extra call (the `zones` cap is
18288
- * per-device, so a client-side resolve would be a per-camera fan-out on a
18289
- * surface built to avoid exactly that).
18290
- *
18291
- * Resolved, never invented: a zone deleted since the track was written has no
18292
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
18293
- * two are not positionally aligned. Absent when the track visited no zone, or
18294
- * when the zone catalogue could not be read.
18295
- */
18296
- zoneNames: array(string()).readonly().optional(),
18297
- /** Deduplicated set of detector classes observed for this track over its
18298
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
18299
- * legacy rows written before class accumulation shipped. */
18300
- classes: array(string()).readonly().optional(),
18301
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
18302
- totalDistance: number(),
18303
- state: TrackStateSchema,
18304
- active: boolean(),
18305
- /** Deterministic key-event importance score in [0,1] (server-computed at
18306
- * track expiry, recomputed on late label). Absent on legacy rows written
18307
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
18308
- importance: number().optional(),
18309
- /** Id of the track's highest-confidence ObjectEvent (its representative
18310
- * "best" frame). Absent when the track produced no object events. */
18311
- bestEventId: string().optional(),
18312
- /** Tag of the importance sub-signal that dominated the score
18313
- * (identity|dwell|proximity|class|confidence|travel|zone). */
18314
- importanceReason: string().optional(),
18315
- /** Audio-classification labels heard on the camera during the track's
18316
- * life (score ≥ device `classificationMinScore`), aggregated per label.
18317
- * Absent on legacy rows / tracks with no confident audio. */
18318
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
18319
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
18320
- * Populated from the persisted envelope columns on historical reads;
18321
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
18322
- envelope: TrackEnvelopeSchema.optional(),
18323
- /**
18324
- * A face DETECTOR found a face on this track — nothing more. It says the
18325
- * detail plane produced a `face` detail; it does NOT say the face was
18326
- * embedded, matched, above `minFacePx`, or that the recognizer was even
18327
- * enabled. Set once and never cleared.
18328
- *
18329
- * **This exists so "face present but not recognised" is expressible.** A
18330
- * recognised identity lands in `subLabel` (attributed to the face chain via
18331
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
18332
- * and a track with no face at all were byte-identical on the wire and no
18333
- * surface could tell them apart. The read is `hasFace === true && subLabel
18334
- * === undefined`.
18335
- *
18336
- * **Absent ≠ false.** Every row written before the column existed omits it,
18337
- * and so does every server that predates the field — a consumer must test
18338
- * `=== true` and render nothing otherwise, never infer "no face".
18339
- */
18340
- hasFace: boolean().optional(),
18341
- /**
18342
- * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
18343
- * face an operator could ASSIGN to an identity.
18344
- *
18345
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
18346
- * because the two disagree. `hasFace` is stamped at the TOP of the face
18347
- * branch, before every gate, and means no more than "a face detector produced
18348
- * a face detail". This one is stamped at the single moment the gallery row
18349
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
18350
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
18351
- * candidate gate, the imageless-track drop (no crop was ever captured) and
18352
- * the crop-store drop. Everything between the detector and that insert can
18353
- * legitimately refuse the face, so a flag written any earlier promises the
18354
- * operator something to assign and delivers nothing.
18355
- *
18356
- * **Independent of recognition.** A face collected but never auto-matched is
18357
- * still assignable — it is in fact the face an operator most wants to reach —
18358
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
18359
- * `subLabel`; this says only that the raw material exists.
18360
- *
18361
- * **Set once, never cleared.** A track that produced a gallery row produced
18362
- * one; deleting the row later is the gallery's business, not this flag's.
18363
- *
18364
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
18365
- * before the column omits it, and so does every server that predates the
18366
- * field. A consumer must test `=== true` and render nothing otherwise —
18367
- * never infer "no assignable face".
18368
- */
18369
- hasEmbeddedFace: boolean().optional(),
18370
- /**
18371
- * This subject CONTAINS a folded rider — a person the rider-pairing step
18372
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
18373
- * so the passage is tracked once and as a VEHICLE.
18374
- *
18375
- * It exists because the fold's record was dishonest. D34 and the code both
18376
- * said "the person is not lost — it is reported so both entities stay on the
18377
- * record"; in fact the pair went into a per-processor RAM field behind an
18378
- * accessor nobody called, and every durable surface said `vehicle`, full
18379
- * stop. This is the composition note that makes the row true.
18380
- *
18381
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
18382
- * person" is not an answer to "what is this" — both label tiers would refuse
18383
- * a macro token anyway (D89), and correctly. Nothing here changes what the
18384
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
18385
- * and a `person` rule still does not fire for someone cycling past.
18386
- *
18387
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
18388
- * the column, and every hub that predates the field, omits it. Test
18389
- * `=== true` and render nothing otherwise — never infer "no rider".
18390
- */
18391
- hasRider: boolean().optional(),
18392
- ...TrackFlagFields,
18393
- ...TrackRetrainFields
18394
- });
18395
- var BaseEventFields = {
18396
- id: string(),
18397
- deviceId: number(),
18398
- timestamp: number()
18399
- };
18400
- var MotionEventSchema = object({
18401
- ...BaseEventFields,
18402
- kind: literal("motion"),
18403
- regionCount: number(),
18404
- /** Heavy JSON array — omitted in slim projection. */
18405
- regions: array(object({
18406
- bbox: BoundingBoxSchema,
18407
- pixelCount: number(),
18408
- intensity: number()
18409
- })).readonly().optional(),
18410
- /** Omitted in slim projection. */
18411
- frameWidth: number().optional(),
18412
- /** Omitted in slim projection. */
18413
- frameHeight: number().optional(),
18414
- /** Populated by B5 (recording playback URL for this event). */
18415
- mediaUrl: string().optional()
18152
+ var AudioTestResultSchema = object({
18153
+ success: boolean(),
18154
+ error: string().optional(),
18155
+ frame: custom().optional()
18416
18156
  });
18157
+ var PipelineConfigBridge = custom();
18158
+ var ConfigUISchemaBridge = custom();
18159
+ var ConfigUISchemaNullableBridge = custom();
18160
+ var InferenceCapabilitiesBridge = custom();
18161
+ var ModelAvailabilityListBridge = custom();
18162
+ var PipelineRunResultBridge = custom();
18417
18163
  /**
18418
- * Which detection SOURCE produced an object event. `pipeline` = the ML
18419
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
18420
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
18421
- * tracking, per-kind persistence) but stay distinguishable so consumers
18422
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
18423
- * Absent on legacy rows ⇒ treat as `pipeline`.
18424
- */
18425
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
18426
- /**
18427
- * The confirmed zone crossing that produced an object event. Present ONLY on
18428
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
18429
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
18430
- * appearance event carry none, so a rule asking for a direction fails closed
18431
- * on them.
18164
+ * Pipeline executor detection engine + configuration + inference API.
18432
18165
  *
18433
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
18434
- * into its own event, so a frame in which a track enters A while leaving B
18435
- * produces two events with two directions — never one ambiguous row.
18166
+ * Merged from: pipeline-executor, pipeline-config, inference, detection-config.
18167
+ * Implemented by the detection-pipeline addon.
18436
18168
  *
18437
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
18438
- * membership the box has NOW, and by definition it no longer contains the zone
18439
- * that was just left. Without the id here, a zone-scoped rule could never match
18440
- * the exit it asked for.
18441
- */
18442
- var ZoneCrossingSchema = object({
18443
- direction: _enum(["enter", "exit"]),
18444
- /** Admin zone id crossed. */
18445
- zoneId: string(),
18446
- /** Zone display name at crossing time (falls back to the id). */
18447
- zoneName: string().optional()
18448
- });
18449
- var ObjectEventSchema = object({
18450
- ...BaseEventFields,
18451
- kind: literal("object"),
18452
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
18453
- source: DetectionSourceSchema.optional(),
18454
- /**
18455
- * Inference-frame id shared by every object event emitted from the SAME frame
18456
- * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
18457
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
18458
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
18459
- * Optional for backward-compat with pre-existing rows / the slim projection
18460
- * includes it (it is light). Absent on rows written before this field.
18461
- */
18462
- frameId: string().optional(),
18463
- /** Omitted in slim projection. */
18464
- trackId: string().optional(),
18465
- className: string(),
18466
- ...TieredLabelFields,
18467
- /** Omitted in slim projection. */
18468
- confidence: number().optional(),
18469
- /** Heavy JSON — omitted in slim projection. */
18470
- bbox: BoundingBoxSchema.optional(),
18471
- /** Heavy JSON — omitted in slim projection. */
18472
- zones: array(string()).readonly().optional(),
18473
- /** Omitted in slim projection. */
18474
- state: TrackStateSchema.optional(),
18475
- /**
18476
- * The zone crossing this event IS, when it is one. Absent on every other
18477
- * event kind (movement state, appearance, package) — see
18478
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
18479
- */
18480
- zoneCrossing: ZoneCrossingSchema.optional(),
18481
- /** Detection-frame dimensions in pixels — let consumers normalize the
18482
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
18483
- frameWidth: number().optional(),
18484
- frameHeight: number().optional(),
18485
- /** MediaStore key for the crop attached to this event (if any). */
18486
- mediaKey: string().optional(),
18487
- /** Design B: MediaStore key of the track's native-resolution key frame (the
18488
- * best-detection full frame). Resolve via the event-media data-plane
18489
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
18490
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
18491
- * sources — consumers fall back to `mediaKey` (the tight crop). */
18492
- keyFrameMediaKey: string().optional(),
18493
- /** Populated by B5 (recording playback URL for this event). */
18494
- mediaUrl: string().optional(),
18495
- /** The parent track's key-event importance [0,1], propagated to every object
18496
- * event of the track (so an event row can be sorted by importance without a
18497
- * track join). Absent on legacy rows / before the track was scored. */
18498
- importance: number().optional()
18499
- });
18500
- var AudioEventSchema = object({
18501
- ...BaseEventFields,
18502
- kind: literal("audio"),
18503
- rms: number(),
18504
- dbfs: number(),
18505
- classification: object({
18506
- className: string(),
18507
- originalClass: string().optional(),
18508
- score: number()
18509
- }).optional(),
18510
- /** Populated by B5 (recording playback URL for this event). */
18511
- mediaUrl: string().optional()
18512
- });
18513
- var MediaFileKindEnum = _enum([
18514
- "crop",
18515
- "thumbnail",
18516
- "snapshot",
18517
- "firstFrame",
18518
- "lastFrame",
18519
- "fullFrame",
18520
- "fullFrameBoxed",
18521
- "faceCrop",
18522
- "plateCrop",
18523
- "keyFrame",
18524
- "keyFrameSmall",
18525
- "thumbnailSmall"
18526
- ]);
18527
- var MediaFileSchema = object({
18528
- key: string(),
18529
- kind: MediaFileKindEnum,
18530
- base64: string(),
18531
- sizeBytes: number(),
18532
- timestamp: number()
18533
- });
18534
- /**
18535
- * One media row WITHOUT its bytes.
18536
- *
18537
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
18538
- * 140 s track), and a client that renders tiles from the media data plane needs
18539
- * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
18540
- * with an immutable cache, instead of all at once inside a tRPC response that
18541
- * blocks the whole view.
18542
- *
18543
- * `sizeBytes` is carried because it is what lets a client decide between the
18544
- * stored blob and a `?variant=thumb` rendering without fetching either.
18545
- */
18546
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
18547
- /**
18548
- * The MACRO tier of an annotation — a CLOSED set.
18549
- *
18550
- * This is what the exported detector predicts, so a typo here is a new class
18551
- * with one example in it. `label` and `subLabel` are open strings by contrast:
18552
- * the whole point of the page is teaching the model things it does not know
18553
- * yet, and constraining that vocabulary would make it useless.
18554
- *
18555
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
18556
- * `subLabel` is one of these values, in any casing, because once `person`
18557
- * exists in both tiers "every person box" stops being answerable without
18558
- * knowing every string anyone ever typed — and the damage is retroactive.
18559
- */
18560
- var RetrainMacroClassSchema = _enum([
18561
- "person",
18562
- "vehicle",
18563
- "animal",
18564
- "package",
18565
- "face",
18566
- "plate"
18567
- ]);
18568
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
18569
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
18570
- /** Did a human draw this box, or did the assist propose it? */
18571
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
18572
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
18573
- var RetrainBboxSchema = object({
18574
- x: number(),
18575
- y: number(),
18576
- w: number(),
18577
- h: number()
18578
- });
18579
- /**
18580
- * One annotated subject.
18581
- *
18582
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
18583
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
18584
- * derived from it at export and never stored — storing them is how one feature
18585
- * space ends up holding two crops of the same subject (D52).
18586
- */
18587
- var RetrainAnnotationSchema = object({
18588
- id: string(),
18589
- trackId: string(),
18590
- deviceId: number(),
18591
- /** The COPY in retrain storage — never the source track's media key. */
18592
- mediaKey: string(),
18593
- bbox: RetrainBboxSchema,
18594
- macroClass: RetrainMacroClassSchema,
18595
- label: string().optional(),
18596
- subLabel: string().optional(),
18597
- kind: RetrainAnnotationKindSchema,
18598
- source: RetrainAnnotationSourceSchema,
18599
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
18600
- assistModelId: string().optional(),
18601
- assistScore: number().optional(),
18602
- exportedInBatch: string().optional(),
18603
- createdAt: number()
18604
- });
18605
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
18606
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
18607
- id: true,
18608
- trackId: true,
18609
- deviceId: true,
18610
- mediaKey: true,
18611
- createdAt: true,
18612
- exportedInBatch: true
18613
- });
18614
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
18615
- var RetrainTrackSchema = object({
18616
- trackId: string(),
18617
- deviceId: number(),
18618
- className: string(),
18619
- label: string().optional(),
18620
- firstSeen: number(),
18621
- lastSeen: number(),
18622
- /** How many frames the dataset already holds from this track. */
18623
- frameCount: number().int(),
18624
- /** How many subjects have been annotated on those frames. `0` with
18625
- * `frameCount: 0` is exactly "staging, still to work". */
18626
- annotationCount: number().int()
18627
- });
18628
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
18629
- var RetrainFrameCandidateSchema = object({
18630
- mediaKey: string(),
18631
- kind: MediaFileKindEnum,
18632
- timestamp: number(),
18633
- sizeBytes: number().int(),
18634
- /** A copy of this original already exists — selecting it is free and cannot
18635
- * fail, whatever became of the original. */
18636
- copied: boolean()
18637
- });
18638
- /** A frame the dataset OWNS: bytes copied at selection time. */
18639
- var RetrainFrameSchema = object({
18640
- frameId: string(),
18641
- deviceId: number(),
18642
- trackId: string(),
18643
- /** Provenance only. It may already point at nothing — that is expected. */
18644
- sourceMediaKey: string(),
18645
- sourceKind: MediaFileKindEnum,
18646
- sizeBytes: number().int(),
18647
- width: number().int(),
18648
- height: number().int(),
18649
- copiedAt: number()
18650
- });
18651
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
18652
- var RetrainCopyRefusalSchema = _enum([
18653
- "source-missing",
18654
- "unreadable-image",
18655
- "write-failed"
18656
- ]);
18657
- var RetrainFrameSelectionSchema = object({
18658
- copied: array(RetrainFrameSchema).readonly(),
18659
- refused: array(object({
18660
- sourceMediaKey: string(),
18661
- reason: RetrainCopyRefusalSchema
18662
- })).readonly()
18663
- });
18664
- var RetrainFrameListSchema = object({
18665
- candidates: array(RetrainFrameCandidateSchema).readonly(),
18666
- copies: array(RetrainFrameSchema).readonly(),
18667
- /** What the page pre-selects — the native key frame when one survives. */
18668
- autoPickMediaKey: string().optional()
18669
- });
18670
- /** What the operator asked the assist to look for. */
18671
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
18672
- kind: literal("package"),
18673
- zone: RetrainBboxSchema.optional()
18674
- }), object({
18675
- kind: literal("objects"),
18676
- modelId: string(),
18677
- minScore: number().optional()
18678
- })]);
18679
- /**
18680
- * The assist's answer — a discriminated union, because "the model saw nothing"
18681
- * and "this node cannot run that model" lead to different next moves and a
18682
- * nullable result cannot tell them apart.
18683
- */
18684
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
18685
- kind: literal("proposed"),
18686
- modelId: string(),
18687
- stepId: string(),
18688
- minScore: number(),
18689
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
18690
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
18691
- /** Returned by the runner but removed by the threshold. */
18692
- belowThreshold: number().int()
18693
- }), object({
18694
- kind: literal("refused"),
18695
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
18696
- reason: string(),
18697
- detail: string().optional()
18698
- })]);
18699
- /** The outcome of a lifecycle move owned by the retrain page. */
18700
- var RetrainTransitionResultSchema = object({
18701
- trackId: string(),
18702
- /** Where the track ended up, whatever happened. */
18703
- retrainStatus: RetrainStatusSchema,
18704
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
18705
- changed: boolean(),
18706
- reason: _enum([
18707
- "unknown-track",
18708
- "no-frames-copied",
18709
- "not-staging",
18710
- "not-trained",
18711
- "unchanged"
18712
- ]).optional()
18713
- });
18714
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
18715
- var MAX_EVENT_QUERY_LIMIT = 5e3;
18716
- var DeviceEventQueryInput = object({
18717
- deviceId: number(),
18718
- since: number().optional(),
18719
- until: number().optional(),
18720
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
18721
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
18722
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
18723
- * exact behaviour. Callers may omit this field — the store defaults to
18724
- * `full` when not provided. */
18725
- projection: _enum(["full", "slim"]).optional()
18726
- });
18727
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
18728
- var RecentTracksQueryInput = object({
18729
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
18730
- deviceIds: array(number()),
18731
- /** Window lower bound on `lastSeen` (inclusive). */
18732
- since: number().optional(),
18733
- /** Window upper bound on `lastSeen` (inclusive). */
18734
- until: number().optional(),
18735
- /** Page size. Default 200, max 1000. */
18736
- limit: number().int().min(1).max(1e3).default(200),
18737
- /** Opaque continuation cursor from a previous page's `nextCursor`.
18738
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
18739
- cursor: string().optional(),
18740
- /** See {@link TrackProjectionSchema}. Default `full`. */
18741
- projection: TrackProjectionSchema.optional(),
18742
- /** Include stationary-promoted rows (parked objects). Default false: the
18743
- * feed lists passages; parking records live on the stationary registry. */
18744
- includeStationary: boolean().optional()
18745
- });
18746
- var RecentTracksPageSchema = object({
18747
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
18748
- tracks: array(TrackSchema).readonly(),
18749
- /** Cursor for the next page, or null when this page is the last. */
18750
- nextCursor: string().nullable()
18751
- });
18752
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
18753
- var LIST_GROUPS_MAX_LIMIT = 100;
18754
- var AnalyticsGroupRecordSchema = object({
18755
- id: string(),
18756
- deviceId: number().int(),
18757
- openedAt: number().int(),
18758
- closedAt: number().int(),
18759
- timestamp: number().int(),
18760
- memberCount: number().int(),
18761
- memberTrackIds: array(string()).readonly(),
18762
- className: string(),
18763
- classes: array(string()).readonly(),
18764
- /** Relative event-media path, or null when the group has no picture yet. */
18765
- mediaUrl: string().nullable(),
18766
- singleton: boolean()
18767
- });
18768
- var AnalyticsGroupMemberSchema = object({
18769
- trackId: string(),
18770
- deviceId: number().int(),
18771
- className: string(),
18772
- firstSeen: number().int(),
18773
- lastSeen: number().int(),
18774
- mediaUrl: string().nullable()
18775
- });
18776
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
18777
- var ListGroupsQueryInput = object({
18778
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
18779
- deviceIds: array(number()),
18780
- /** Window lower bound on `closedAt` (inclusive). */
18781
- since: number().optional(),
18782
- /** Window upper bound on `openedAt` (inclusive). */
18783
- until: number().optional(),
18784
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
18785
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
18786
- cursor: string().optional()
18787
- });
18788
- var ListGroupsPageSchema = object({
18789
- groups: array(AnalyticsGroupRecordSchema).readonly(),
18790
- nextCursor: string().nullable()
18791
- });
18792
- var KeyEventQueryInput = object({
18793
- deviceId: number(),
18794
- /** Window lower bound (track firstSeen ≥ since). */
18795
- since: number(),
18796
- /** Window upper bound (track firstSeen ≤ until). */
18797
- until: number(),
18798
- limit: number().int().min(1).max(200).default(50),
18799
- /** Drop tracks scoring below this importance. */
18800
- minImportance: number().min(0).max(1).optional(),
18801
- /** Restrict to a single class (e.g. 'person'). */
18802
- classFilter: string().optional()
18803
- });
18804
- var KeyEventSchema = object({
18805
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
18806
- id: string(),
18807
- trackId: string(),
18808
- /** Track start time (firstSeen). */
18809
- timestamp: number(),
18810
- className: string(),
18811
- ...TieredLabelFields,
18812
- importance: number(),
18813
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
18814
- bestEventId: string(),
18815
- /** Track lifetime in ms (lastSeen - firstSeen). */
18816
- windowMs: number().optional(),
18817
- ...TrackFlagFields,
18818
- ...TrackRetrainFields
18819
- });
18820
- object({
18821
- trackId: string(),
18822
- className: string(),
18823
- confidence: number(),
18824
- bbox: BoundingBoxSchema,
18825
- zones: array(string()).readonly(),
18826
- state: TrackStateSchema
18827
- });
18828
- var OverlayDetectionSchema = looseObject({
18829
- id: string(),
18830
- kind: _enum(["first-level", "detail"]),
18831
- macroClass: string(),
18832
- score: number(),
18833
- bbox: object({
18834
- x: number(),
18835
- y: number(),
18836
- width: number(),
18837
- height: number()
18838
- }),
18839
- labels: array(looseObject({
18840
- label: string(),
18841
- score: number()
18842
- })).readonly(),
18843
- parentId: string().optional()
18844
- });
18845
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
18846
- var SearchObjectEventsInput = object({
18847
- text: string(),
18848
- deviceId: number().optional(),
18849
- since: number().optional(),
18850
- until: number().optional(),
18851
- classFilter: string().optional(),
18852
- limit: number().default(50),
18853
- minScore: number().min(0).max(1).default(.2)
18854
- });
18855
- var TrackCascadeCountsSchema = object({
18856
- /** Persisted track roots deleted (authoritative). */
18857
- tracks: number().int(),
18858
- /** Object events removed with their tracks (best-effort; see note above). */
18859
- events: number().int(),
18860
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18861
- media: number().int(),
18862
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
18863
- faces: number().int(),
18864
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18865
- plates: number().int(),
18866
- /** Per-track CLIP search vectors removed (best-effort). */
18867
- embeddings: number().int(),
18868
- /** Group membership + group rows removed with their last member (best-effort). */
18869
- groups: number().int()
18870
- });
18871
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18872
- var DiskReconcileCountsSchema = object({
18873
- mediaDropped: number().int(),
18874
- tracks: number().int(),
18875
- events: number().int()
18876
- });
18877
- /** Event-store footprint for one camera. */
18878
- var EventStoreDeviceFootprintSchema = object({
18879
- deviceId: number(),
18880
- /** Persisted event rows (motion + object + audio) for the camera. */
18881
- rows: number().int(),
18882
- /** Event-owned media bytes on disk for the camera. */
18883
- bytes: number().int()
18884
- });
18885
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18886
- var EventStoreFootprintSchema = object({
18887
- totalRows: number().int(),
18888
- totalBytes: number().int(),
18889
- devices: array(EventStoreDeviceFootprintSchema).readonly()
18890
- });
18891
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
18892
- var EventPruneCountsSchema = object({
18893
- motion: number().int(),
18894
- object: number().int(),
18895
- audio: number().int()
18896
- });
18897
- /**
18898
- * Re-embed stored tracks from their key frames.
18899
- *
18900
- * The reason this is an operator-callable method and not a migration script:
18901
- * every knob that decides what a vector MEANS — encoder model, crop margin,
18902
- * squaring — is only changeable if the existing vectors can be regenerated.
18903
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
18904
- * symptom is a quality regression with no visible cause.
18905
- */
18906
- var RebuildObjectEmbeddingsInput = object({
18907
- /** Restrict to one camera. Omit for the whole fleet. */
18908
- deviceId: number().optional(),
18909
- since: number().optional(),
18910
- until: number().optional(),
18911
- /** Stop after this many tracks; the result reports whether more remain. */
18912
- maxTracks: number().int().positive().optional(),
18913
- /**
18914
- * Run every embedding on THIS node instead of round-robining the fleet.
18915
- *
18916
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18917
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18918
- * calling it that would pin the rebuild REQUEST itself to that node — the
18919
- * rebuild orchestration lives on the hub, and only the per-track step runs
18920
- * remotely. This field is data; the per-track pin is applied inside.
18921
- *
18922
- * Absent ⇒ round-robin over every online node whose runner can serve the
18923
- * pinned model.
18924
- */
18925
- executeOnNodeId: string().optional(),
18926
- /**
18927
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18928
- * run flat out.
18929
- *
18930
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
18931
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18932
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18933
- * force is logged at start and finish so a deliberately slow pass reads
18934
- * differently from a stalled one.
18935
- */
18936
- pacingMs: number().int().nonnegative().optional()
18937
- });
18938
- /**
18939
- * Result of emptying the CLIP index.
18940
- *
18941
- * The clean slate before a policy change: a new crop margin or encoder model
18942
- * leaves two feature spaces in one index whose cosine scores are not
18943
- * comparable, so wiping and rebuilding is the only way to be sure every vector
18944
- * means the same thing.
18945
- */
18946
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18947
- /**
18948
- * Acknowledgement that a rebuild STARTED.
18949
- *
18950
- * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
18951
- * runs detached and this returns immediately. Waiting for it made the client
18952
- * time out while the work carried on server-side, which is the worst of both:
18953
- * no result and no way to know it was still going. Poll
18954
- * `getObjectEmbeddingRebuildStatus` for progress.
18955
- */
18956
- var RebuildObjectEmbeddingsResultSchema = object({
18957
- started: boolean(),
18958
- /** True when a pass was already running; the new request is ignored. */
18959
- alreadyRunning: boolean()
18960
- });
18961
- var RebuildStatusSchema = object({
18962
- running: boolean(),
18963
- scanned: number(),
18964
- rebuilt: number(),
18965
- /** Tracks whose key frame is gone — nothing to re-embed from. */
18966
- missingKeyFrame: number(),
18967
- /** Tracks with no usable detection box. */
18968
- missingBbox: number(),
18969
- /**
18970
- * Tracks an executing node REFUSED rather than broke on — an unreadable key
18971
- * frame, a step that threw. Separate from `failed` because the remedy is
18972
- * different, and because a whole camera silently contributing zero vectors
18973
- * is the shape of failure a rebuild must never hide.
18974
- */
18975
- notRunnable: number(),
18976
- /**
18977
- * The pass stopped because NO node could serve the pinned model.
18978
- *
18979
- * Distinct from `notRunnable` on purpose: that one says "this track was
18980
- * refused", this one says "the cluster cannot do this work at all" — every
18981
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
18982
- * pinned model for its engine format, or dropped out. The remedy is a model /
18983
- * engine change, not a per-camera one. Non-zero here always comes with
18984
- * `complete: false`.
18985
- */
18986
- noCapableNode: number(),
18987
- failed: number(),
18988
- /** Set once a pass ends: true only when EVERYTHING was covered. */
18989
- complete: boolean().nullable(),
18990
- startedAtMs: number().nullable(),
18991
- finishedAtMs: number().nullable(),
18992
- /** Present when the pass ended by throwing. */
18993
- error: string().nullable()
18994
- });
18995
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18996
- deviceId: number(),
18997
- trackId: string()
18998
- }), TrackSchema.nullable()), method(object({
18999
- deviceId: number(),
19000
- since: number().optional(),
19001
- until: number().optional(),
19002
- limit: number().optional(),
19003
- /** Spatial filter — only tracks whose trajectory intersects the zone
19004
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
19005
- * envelope columns, then precisely tested per position. Tracks with
19006
- * an unknown envelope (no frame dims at persist time) always match. */
19007
- zone: TrackZoneFilterSchema.optional(),
19008
- /** See {@link TrackProjectionSchema}. Default `full` (backward
19009
- * compatible — omitting the field keeps today's exact behaviour). */
19010
- projection: TrackProjectionSchema.optional(),
19011
- /** Include stationary-promoted rows (parked objects handed to the
19012
- * stationary registry). Default false: the timeline lists passages,
19013
- * not parking records (operator decision, 2026-08-15). */
19014
- includeStationary: boolean().optional()
19015
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
19016
- deviceId: number(),
19017
- groupId: string().min(1)
19018
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
19019
- kind: "mutation",
19020
- auth: "admin"
19021
- }), method(DeviceEventQueryInput, array(MotionEventSchema).readonly()), method(ObjectEventQueryInput, array(ObjectEventSchema).readonly()), method(DeviceEventQueryInput, array(AudioEventSchema).readonly()), method(object({ deviceId: number() }), array(EventKindDescriptorSchema).readonly()), method(object({ deviceIds: array(number()).min(1).max(200) }), array(EventKindsForDeviceSchema).readonly()), method(object({
19022
- deviceId: number(),
19023
- since: number().optional(),
19024
- until: number().optional(),
19025
- kinds: array(string()).optional(),
19026
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
19027
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
19028
- deviceId: number(),
19029
- since: number(),
19030
- until: number(),
19031
- bucketMs: number().int().positive()
19032
- }), array(object({
19033
- bucketStart: number(),
19034
- motion: number().int(),
19035
- object: number().int(),
19036
- audio: number().int()
19037
- })).readonly()), method(object({
19038
- deviceId: number(),
19039
- cutoffMs: number()
19040
- }), object({
19041
- motion: number().int(),
19042
- object: number().int(),
19043
- audio: number().int()
19044
- }), {
19045
- kind: "mutation",
19046
- auth: "admin"
19047
- }), method(object({
19048
- deviceId: number(),
19049
- cutoffMs: number()
19050
- }), TrackCascadeCountsSchema, {
19051
- kind: "mutation",
19052
- auth: "admin"
19053
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
19054
- kind: "mutation",
19055
- auth: "admin"
19056
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
19057
- kind: "mutation",
19058
- auth: "admin"
19059
- }), method(object({
19060
- deviceId: number(),
19061
- trackIds: array(string()).min(1)
19062
- }), object({
19063
- deleted: number().int(),
19064
- failed: array(string()).readonly()
19065
- }), {
19066
- kind: "mutation",
19067
- auth: "admin"
19068
- }), method(object({
19069
- /** Log/audit scope only — the trackId is globally unique on its own. */
19070
- deviceId: number(),
19071
- trackId: string(),
19072
- flags: TrackFlagsPatchSchema
19073
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
19074
- kind: "query",
19075
- auth: "admin"
19076
- }), method(object({
19077
- olderThanMs: number(),
19078
- reason: OpsLogReasonSchema.optional()
19079
- }), EventPruneCountsSchema, {
19080
- kind: "mutation",
19081
- auth: "admin"
19082
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
19083
- kind: "mutation",
19084
- auth: "admin"
19085
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
19086
- kind: "mutation",
19087
- auth: "admin"
19088
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
19089
- kind: "mutation",
19090
- auth: "admin"
19091
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
19092
- kind: "mutation",
19093
- auth: "admin"
19094
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
19095
- kind: "mutation",
19096
- auth: "admin"
19097
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
19098
- kind: "mutation",
19099
- auth: "admin"
19100
- }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
19101
- kind: "mutation",
19102
- auth: "admin"
19103
- }), method(object({}), array(RelocateJobSchema).readonly(), {
19104
- kind: "query",
19105
- auth: "admin"
19106
- }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
19107
- kind: "mutation",
19108
- auth: "admin"
19109
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
19110
- kind: "query",
19111
- auth: "admin"
19112
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
19113
- kind: "query",
19114
- auth: "admin"
19115
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
19116
- kind: "query",
19117
- auth: "admin"
19118
- }), method(object({
19119
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
19120
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
19121
- * route it at one camera's owner, and "every camera" would stop being
19122
- * expressible at all. */
19123
- deviceIds: array(number()).optional(),
19124
- limit: number().int().min(1).max(500).optional()
19125
- }), array(RetrainTrackSchema).readonly(), {
19126
- kind: "query",
19127
- auth: "admin"
19128
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
19129
- kind: "query",
19130
- auth: "admin"
19131
- }), method(object({
19132
- deviceId: number(),
19133
- trackId: string(),
19134
- mediaKeys: array(string()).min(1)
19135
- }), RetrainFrameSelectionSchema, {
19136
- kind: "mutation",
19137
- auth: "admin"
19138
- }), method(object({
19139
- deviceId: number(),
19140
- trackId: string(),
19141
- frameId: string()
19142
- }), object({
19143
- removed: boolean(),
19144
- removedAnnotations: number().int()
19145
- }), {
19146
- kind: "mutation",
19147
- auth: "admin"
19148
- }), method(object({ frameId: string() }), object({
19149
- base64: string(),
19150
- width: number().int(),
19151
- height: number().int()
19152
- }), {
19153
- kind: "query",
19154
- auth: "admin"
19155
- }), method(object({
19156
- deviceId: number(),
19157
- trackId: string(),
19158
- frameId: string(),
19159
- subject: RetrainAssistSubjectSchema,
19160
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
19161
- nodeId: string().optional()
19162
- }), RetrainAssistResultSchema, {
19163
- kind: "mutation",
19164
- auth: "admin"
19165
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
19166
- kind: "query",
19167
- auth: "admin"
19168
- }), method(object({
19169
- deviceId: number(),
19170
- trackId: string(),
19171
- frameId: string(),
19172
- annotations: array(RetrainAnnotationDraftSchema)
19173
- }), array(RetrainAnnotationSchema).readonly(), {
19174
- kind: "mutation",
19175
- auth: "admin"
19176
- }), method(object({
19177
- deviceId: number(),
19178
- trackId: string()
19179
- }), RetrainTransitionResultSchema, {
19180
- kind: "mutation",
19181
- auth: "admin"
19182
- }), method(object({
19183
- deviceId: number(),
19184
- trackId: string()
19185
- }), RetrainTransitionResultSchema, {
19186
- kind: "mutation",
19187
- auth: "admin"
19188
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
19189
- kind: "query",
19190
- auth: "admin"
19191
- }), method(object({
19192
- eventId: string(),
19193
- kind: MediaFileKindEnum.optional(),
19194
- deviceId: number()
19195
- }), array(MediaFileSchema).readonly()), method(object({
19196
- trackId: string(),
19197
- kinds: array(MediaFileKindEnum).optional(),
19198
- deviceId: number()
19199
- }), array(MediaFileSchema).readonly()), method(object({
19200
- trackId: string(),
19201
- deviceId: number()
19202
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
19203
- kind: "mutation",
19204
- auth: "admin"
19205
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
19206
- kind: "mutation",
19207
- auth: "admin"
19208
- }), method(object({}), RebuildStatusSchema), object({
19209
- deviceId: number(),
19210
- timestamp: number(),
19211
- frameWidth: number(),
19212
- frameHeight: number(),
19213
- detections: array(OverlayDetectionSchema).readonly()
19214
- }), object({
19215
- deviceId: number(),
19216
- trackId: string(),
19217
- className: string()
19218
- }), object({
19219
- deviceId: number(),
19220
- trackId: string(),
19221
- className: string(),
19222
- durationMs: number()
19223
- }), object({
19224
- deviceId: number(),
19225
- kind: EventKindSchema,
19226
- eventId: string(),
19227
- timestamp: number()
19228
- });
19229
- /**
19230
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
19231
- * within the frame, so the executor can re-cut a leaf child ROI at native
19232
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
19233
- */
19234
- var NativeCropRefSchema = object({
19235
- /** Handle keying the retained native surface (node-pinned to its owner). */
19236
- handle: FrameHandleSchema,
19237
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
19238
- cropFrameSpace: object({
19239
- x: number(),
19240
- y: number(),
19241
- w: number(),
19242
- h: number()
19243
- })
19244
- });
19245
- object({
19246
- crop: object({
19247
- left: number(),
19248
- top: number(),
19249
- width: number().positive(),
19250
- height: number().positive()
19251
- }).optional(),
19252
- content: object({
19253
- width: number().int().positive(),
19254
- height: number().int().positive()
19255
- }),
19256
- fit: _enum(["stretch", "contain"]),
19257
- format: _enum([
19258
- "rgb",
19259
- "gray",
19260
- "jpeg"
19261
- ])
19262
- });
19263
- /**
19264
- * Process-local frame identity. It is serializable so it can ride an in-process
19265
- * capability call, but `registryId` deliberately prevents resolution in any
19266
- * other process or execution group.
19267
- */
19268
- var FrameRefSchema = object({
19269
- registryId: string().min(1),
19270
- id: string().min(1),
19271
- width: number().int().positive(),
19272
- height: number().int().positive(),
19273
- format: _enum(["rgb", "gray"]),
19274
- timestamp: number(),
19275
- capturedAt: number().optional()
19276
- });
19277
- var ModelFormatSchema$1 = _enum([
19278
- "onnx",
19279
- "coreml",
19280
- "openvino",
19281
- "tflite",
19282
- "pt",
19283
- "gguf"
19284
- ]);
19285
- var PipelineSlotSchema = _enum([
19286
- "detector",
19287
- "cropper",
19288
- "classifier",
19289
- "refiner",
19290
- "audio-classifier"
19291
- ]);
19292
- var PipelineEngineChoiceSchema = object({
19293
- runtime: _enum(["node", "python"]),
19294
- backend: string(),
19295
- format: ModelFormatSchema$1,
19296
- device: string().optional()
19297
- });
19298
- var AvailableEngineSchema = object({
19299
- engine: PipelineEngineChoiceSchema,
19300
- devices: array(object({
19301
- id: string(),
19302
- label: string(),
19303
- description: string().optional()
19304
- })).readonly(),
19305
- defaultDevice: string()
19306
- });
19307
- var PipelineDefaultStepSchema = lazy(() => object({
19308
- addonId: string(),
19309
- addonName: string(),
19310
- slot: PipelineSlotSchema,
19311
- inputClasses: array(string()).readonly(),
19312
- outputClasses: array(string()).readonly(),
19313
- enabled: boolean(),
19314
- modelId: string(),
19315
- children: array(PipelineDefaultStepSchema).readonly(),
19316
- group: string().optional(),
19317
- settings: record(string(), unknown()).optional()
19318
- }));
19319
- var PipelineTemplateStepSchema = lazy(() => object({
19320
- addonId: string(),
19321
- enabled: boolean(),
19322
- modelId: string(),
19323
- children: array(PipelineTemplateStepSchema).readonly(),
19324
- settings: record(string(), unknown()).optional()
19325
- }));
19326
- var PipelineTemplateSchema$1 = object({
19327
- id: string(),
19328
- name: string(),
19329
- createdAt: string(),
19330
- updatedAt: string(),
19331
- engine: PipelineEngineChoiceSchema,
19332
- steps: array(PipelineTemplateStepSchema).readonly()
19333
- });
19334
- var PipelineModelOptionSchema = object({
19335
- id: string(),
19336
- name: string(),
19337
- formats: record(string(), object({
19338
- downloaded: boolean(),
19339
- sizeMB: number()
19340
- })),
19341
- group: ModelVariantGroupSchema.optional(),
19342
- legacy: boolean().optional(),
19343
- provider: ModelProviderIdSchema.optional()
19344
- });
19345
- var ConfigFieldBridge = custom();
19346
- var PipelineAddonSchemaSchema = object({
19347
- id: string(),
19348
- name: string(),
19349
- slot: PipelineSlotSchema,
19350
- inputClasses: array(string()).readonly(),
19351
- outputClasses: array(string()).readonly(),
19352
- childSlots: array(PipelineSlotSchema).readonly(),
19353
- models: array(PipelineModelOptionSchema).readonly(),
19354
- defaultModelId: string(),
19355
- defaultModelIdByFormat: record(string(), string()).optional(),
19356
- enabledByDefault: boolean().optional(),
19357
- backfillIntoExistingOverrides: boolean().optional(),
19358
- defaultConfidence: number(),
19359
- group: string().optional(),
19360
- configSchema: array(ConfigFieldBridge).readonly().optional()
19361
- });
19362
- var PipelineSlotSchemaSchema = object({
19363
- id: PipelineSlotSchema,
19364
- label: string(),
19365
- priority: number(),
19366
- parentSlot: PipelineSlotSchema.nullable(),
19367
- addons: array(PipelineAddonSchemaSchema).readonly()
19368
- });
19369
- var PipelineSchemaSchema = object({
19370
- availableEngines: array(AvailableEngineSchema).readonly(),
19371
- selectedEngine: PipelineEngineChoiceSchema,
19372
- slots: array(PipelineSlotSchemaSchema).readonly()
19373
- });
19374
- var EngineProvisioningSchema = object({
19375
- runtimeId: _enum([
19376
- "onnx",
19377
- "openvino",
19378
- "coreml",
19379
- "edgetpu"
19380
- ]).nullable(),
19381
- device: string().nullable(),
19382
- state: _enum([
19383
- "idle",
19384
- "installing",
19385
- "verifying",
19386
- "ready",
19387
- "failed"
19388
- ]),
19389
- progress: number().optional(),
19390
- error: string().optional(),
19391
- nextRetryAt: number().optional(),
19392
- /**
19393
- * Gate A (config-correctness gate at engine change): human-readable
19394
- * config issues surfaced EAGERLY when the node's engine changes — model
19395
- * substitutions ("chose X, running Y") and zero-build steps ("no model
19396
- * has a <format> build"). Additive/optional: informational only, never
19397
- * enforced here — `assertEngineReady` (readiness) still gates inference.
19398
- * Absent/empty when the node-default tree resolves cleanly.
19399
- */
19400
- configIssues: array(string()).optional()
19401
- });
19402
- var PipelineStepInputSchema = lazy(() => object({
19403
- addonId: string(),
19404
- modelId: string().optional(),
19405
- enabled: boolean().default(true),
19406
- children: array(PipelineStepInputSchema).optional(),
19407
- settings: record(string(), unknown()).optional(),
19408
- jumpDeviceKey: string().optional()
19409
- }));
19410
- var ModelSubstitutionSchema = object({
19411
- addonId: string(),
19412
- chosen: string(),
19413
- running: string(),
19414
- format: string()
19415
- });
19416
- var PipelineValidationIssueSchema = object({
19417
- addonId: string(),
19418
- kind: _enum(["unknown-addon", "no-format-build"]),
19419
- detail: string()
19420
- });
19421
- var PipelineValidationResultSchema = object({
19422
- ok: boolean(),
19423
- issues: array(PipelineValidationIssueSchema).readonly(),
19424
- substitutions: array(ModelSubstitutionSchema).readonly(),
19425
- /** The node's `currentEngine.format` this validation ran against. */
19426
- format: string()
19427
- });
19428
- var ReferenceImageEntrySchema = object({
19429
- filename: string(),
19430
- stepIds: array(string()).readonly().optional()
19431
- });
19432
- var ReferenceImageBodySchema = object({
19433
- base64: string(),
19434
- filename: string()
19435
- });
19436
- var ReferenceAudioEntrySchema = object({
19437
- filename: string(),
19438
- sizeKb: number()
19439
- });
19440
- var ReferenceAudioBodySchema = object({ base64: string() });
19441
- var AudioBackendSchema = object({
19442
- id: string(),
19443
- name: string(),
19444
- description: string(),
19445
- available: boolean(),
19446
- /**
19447
- * Raw classifier labels this backend can emit (e.g. YAMNet's
19448
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
19449
- * the benchmark UI to populate the `enabledMicroClasses` filter
19450
- * specific to the selected backend without a separate fetch.
19451
- */
19452
- rawLabels: array(string()).readonly().optional()
19453
- });
19454
- var AudioCapabilitiesSchema = object({
19455
- activeBackend: string(),
19456
- availableBackends: array(AudioBackendSchema).readonly(),
19457
- sampleRate: number(),
19458
- chunkDurationMs: number()
19459
- });
19460
- var DownloadModelResultSchema = object({
19461
- filePath: string(),
19462
- sizeMB: number(),
19463
- durationMs: number()
19464
- });
19465
- /**
19466
- * Wrapper carrying a single test run's result. Replaces the legacy
19467
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
19468
- * canonical `AudioResult` from the Phase 6 output rework: one
19469
- * `AudioDetection` per class above `minScore`, top-N candidates in
19470
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
19471
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
19472
- * benchmark UI can still report a clean failure when the classifier
19473
- * cap isn't available.
19474
- */
19475
- var AudioTestResultSchema = object({
19476
- success: boolean(),
19477
- error: string().optional(),
19478
- frame: custom().optional()
19479
- });
19480
- var PipelineConfigBridge = custom();
19481
- var ConfigUISchemaBridge = custom();
19482
- var ConfigUISchemaNullableBridge = custom();
19483
- var InferenceCapabilitiesBridge = custom();
19484
- var ModelAvailabilityListBridge = custom();
19485
- var PipelineRunResultBridge = custom();
19486
- /**
19487
- * Pipeline executor — detection engine + configuration + inference API.
19488
- *
19489
- * Merged from: pipeline-executor, pipeline-config, inference, detection-config.
19490
- * Implemented by the detection-pipeline addon.
19491
- *
19492
- * Per-device surface (DeviceSettingsContribution + the "is detection
19493
- * enabled for this camera?" toggle) lives on the paired
19494
- * `detection-pipeline` cap (device-scoped, singleton, wrapper
19495
- * defaultActive) — same split pattern used by stream-broker /
19496
- * camera-streams and audio-analyzer / audio-analysis.
18169
+ * Per-device surface (DeviceSettingsContribution + the "is detection
18170
+ * enabled for this camera?" toggle) lives on the paired
18171
+ * `detection-pipeline` cap (device-scoped, singleton, wrapper
18172
+ * defaultActive) same split pattern used by stream-broker /
18173
+ * camera-streams and audio-analyzer / audio-analysis.
19497
18174
  */
19498
18175
  var pipelineExecutorCapability = {
19499
18176
  name: "pipeline-executor",
@@ -19545,6 +18222,60 @@ var pipelineExecutorCapability = {
19545
18222
  kind: "mutation",
19546
18223
  auth: "admin"
19547
18224
  }),
18225
+ /**
18226
+ * Which of THIS node's inference devices the executor currently refuses,
18227
+ * and why. `nodeId` is the ROUTING key (stripped by the generated router).
18228
+ *
18229
+ * The channel that did not exist. Pool health was known only inside the
18230
+ * detection addon and was an input to no routing decision anywhere: the
18231
+ * per-dispatch capability gate is keyed on model FORMAT and so can never
18232
+ * separate `openvino:gpu` from `openvino:npu`, and the orchestrator's live
18233
+ * eligibility probe (`platformProbe.getCapabilities`) answers about
18234
+ * HARDWARE — which was present throughout. So when the hub's `openvino:gpu`
18235
+ * Python worker was SIGABRT'd by the Intel GPU plugin on 2026-08-25, the
18236
+ * balancer went on handing that dead pool cameras by rotation for 31 hours:
18237
+ * ~370 000 `PoolWorker[w0]: not initialized` lines, every frame lost.
18238
+ *
18239
+ * Read semantics the caller depends on, and which the provider guarantees:
18240
+ * this is a synchronous read of in-memory state. It never probes hardware,
18241
+ * never spawns a pool and never throws — an EMPTY `unhealthy` means "asked,
18242
+ * nothing is refused", which is what re-admits a device. A read that FAILS
18243
+ * (node offline, version skew) must therefore be distinguishable from an
18244
+ * empty answer, and it is: it rejects.
18245
+ */
18246
+ getInferenceDeviceHealth: method(object({ nodeId: string() }), object({ unhealthy: array(object({
18247
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
18248
+ deviceKey: string(),
18249
+ /**
18250
+ * `failed` — the per-device restart budget is exhausted; no pool
18251
+ * will be spawned until an operator re-arms it or the runner
18252
+ * respawns. `backoff` — under budget, waiting out the backoff (or
18253
+ * a cached pool observed dead and not yet condemned).
18254
+ */
18255
+ state: _enum(["failed", "backoff"]),
18256
+ /** Epoch ms of the death that produced this state. */
18257
+ since: number(),
18258
+ /** Pool deaths inside the current window. */
18259
+ deaths: number(),
18260
+ /** The last death's message. */
18261
+ lastError: string()
18262
+ })).readonly() })),
18263
+ /**
18264
+ * Re-arm a terminally `failed` inference device on `nodeId`: forget its
18265
+ * restart budget so the next dispatch builds a fresh pool.
18266
+ *
18267
+ * The terminal state is deliberate (the abort it bounds is deterministic —
18268
+ * an automatic probation would just respawn Python forever, more slowly),
18269
+ * and a terminal state an operator cannot leave is a silent fault. This is
18270
+ * the way out. `rearmed:false` means there was nothing to forget.
18271
+ */
18272
+ rearmInferenceDevice: method(object({
18273
+ nodeId: string(),
18274
+ deviceKey: string()
18275
+ }), object({ rearmed: boolean() }), {
18276
+ kind: "mutation",
18277
+ auth: "admin"
18278
+ }),
19548
18279
  getSchema: method(_void(), PipelineSchemaSchema),
19549
18280
  getGlobalSteps: method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()),
19550
18281
  getGlobalPipelineConfig: method(_void(), PipelineConfigBridge),
@@ -19810,6 +18541,1503 @@ var pipelineExecutorCapability = {
19810
18541
  getDetectionConfigSchema: method(_void(), ConfigUISchemaNullableBridge)
19811
18542
  }
19812
18543
  };
18544
+ /**
18545
+ * Per-stage gating mode applied to the zones a rule references.
18546
+ *
18547
+ * - `include`: the rule contributes to a **whitelist** for its stage.
18548
+ * When at least one `include` rule fires for a stage, only entities
18549
+ * inside one of those zones pass that stage.
18550
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
18551
+ * Entities inside one of those zones are dropped at that stage.
18552
+ *
18553
+ * `monitor`-style observation (count without filtering) is not a rule
18554
+ * mode — zones without any matching rule are observed naturally by
18555
+ * `zone-analytics` (live snapshot + history), so an "I just want to
18556
+ * count, not filter" use case needs no rule at all.
18557
+ */
18558
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
18559
+ /**
18560
+ * Per-consumer rule that references existing zones (geometry) and
18561
+ * defines how a specific pipeline stage should treat them. Each
18562
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
18563
+ * settings:
18564
+ *
18565
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
18566
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
18567
+ * - future: notification rules, audio gating, etc.
18568
+ *
18569
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
18570
+ * express "ignore motion in ALL of {garden, street}" with a single
18571
+ * rule. `classFilter` narrows the rule to specific object classes —
18572
+ * "drop person detections in the street, but keep cars" is one
18573
+ * `exclude` rule with `classFilter: ['person']`.
18574
+ *
18575
+ * `enabled` is a soft toggle — the operator can keep the rule
18576
+ * configured but inert without deleting it.
18577
+ */
18578
+ var ZoneRuleSchema = object({
18579
+ /** Stable rule id — survives edits, used by the UI for diffing. */
18580
+ id: string(),
18581
+ /** Optional human-readable label rendered in the rule editor. */
18582
+ name: string().optional(),
18583
+ /** Zones this rule targets. The rule's `mode` applies to ALL
18584
+ * listed zones (OR-set: a detection in any one of them counts).
18585
+ * At least one zone id required — a rule with no targets is a
18586
+ * configuration mistake and the form validator rejects it. */
18587
+ zoneIds: array(string()).min(1).readonly(),
18588
+ mode: ZoneRuleModeEnum,
18589
+ /**
18590
+ * Class names this rule applies to. Empty / undefined ⇒ rule
18591
+ * applies to every class. Class strings match the `macroClass`
18592
+ * field on detections (e.g. `person`, `car`, `dog`).
18593
+ */
18594
+ classFilter: array(string()).readonly().optional(),
18595
+ /**
18596
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
18597
+ * required to consider an entity "in the zone". Defaults to the
18598
+ * consumer's stage default when omitted. Kept for back-compat with
18599
+ * existing per-rule overrides; new operators pick the value via
18600
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
18601
+ * set, the lower-level engine reads it as a 0–1 fraction.
18602
+ */
18603
+ overlapThreshold: number().min(0).max(1).optional(),
18604
+ /**
18605
+ * Operator-friendly version of `overlapThreshold` — the percentage
18606
+ * of the detection's bbox that must lie inside the zone for the
18607
+ * rule to match. Documented default is 85%; the engine substitutes
18608
+ * that when the field is omitted (kept optional so existing rules
18609
+ * stored without it stay valid).
18610
+ *
18611
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
18612
+ * rule, the engine prefers `bboxInclusionPct` because it's the
18613
+ * field exposed in the UI. Internally both feed the same gate.
18614
+ */
18615
+ bboxInclusionPct: number().min(0).max(100).optional(),
18616
+ /**
18617
+ * When `true` and a detection has a segmentation mask, use the
18618
+ * mask for overlap instead of the bbox. Detection-stage only;
18619
+ * motion rules ignore this field.
18620
+ */
18621
+ preferMask: boolean().optional(),
18622
+ /**
18623
+ * Soft-toggle: `false` disables the rule without deleting it.
18624
+ * Defaults to `true` so operators creating a rule via the UI
18625
+ * see it active immediately.
18626
+ */
18627
+ enabled: boolean().default(true)
18628
+ });
18629
+ array(ZoneRuleSchema).readonly();
18630
+ /**
18631
+ * Zone — pure geometry + identity. NO filtering behaviour.
18632
+ *
18633
+ * Zones describe **where** in the frame the operator wants to flag
18634
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
18635
+ * each pipeline stage uses them. Splitting the two means a single
18636
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
18637
+ * a detection-include rule on `['car']`, and an occupancy aggregate
18638
+ * — without three duplicated polygons.
18639
+ *
18640
+ * Owned by the orchestrator addon (provider) and mirrored into the
18641
+ * `zones` device-state slice on every mutation. Consumers
18642
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18643
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18644
+ * mirror with `onChanged`).
18645
+ *
18646
+ * Coordinates are normalised fractions of the frame (0–1) so zones
18647
+ * survive resolution changes and stream profile switches.
18648
+ *
18649
+ * `kind` discriminates between full polygons (closed regions used
18650
+ * for intrusion / occupancy filters) and tripwires (open 2-point
18651
+ * line segments used for cross events). Onboard / firmware-reported
18652
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18653
+ * task list.
18654
+ */
18655
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18656
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18657
+ var PolygonPointSchema = object({
18658
+ x: number(),
18659
+ y: number()
18660
+ });
18661
+ /** A camera detection zone — pure geometry/identity. */
18662
+ var ZoneSchema = object({
18663
+ id: string(),
18664
+ name: string(),
18665
+ kind: ZoneKindEnum.default("polygon"),
18666
+ /** Polygon vertices, fraction of frame (0–1). */
18667
+ polygon: array(PolygonPointSchema).readonly(),
18668
+ /** Visual color for UI rendering. */
18669
+ color: string().default("#3b82f6")
18670
+ });
18671
+ DeviceType.Camera, method(object({ deviceId: number() }), array(ZoneSchema).readonly()), method(object({
18672
+ deviceId: number(),
18673
+ zone: ZoneSchema
18674
+ }), _void(), {
18675
+ kind: "mutation",
18676
+ auth: "admin"
18677
+ }), method(object({
18678
+ deviceId: number(),
18679
+ zoneId: string()
18680
+ }), _void(), {
18681
+ kind: "mutation",
18682
+ auth: "admin"
18683
+ }), method(object({
18684
+ deviceId: number(),
18685
+ zone: ZoneSchema
18686
+ }), _void(), {
18687
+ kind: "mutation",
18688
+ auth: "admin"
18689
+ }), object({ zones: array(ZoneSchema).readonly() });
18690
+ /**
18691
+ * pipeline-analytics — device-scoped wrapper cap. Refines raw
18692
+ * per-frame detections emitted by the pipeline runner into tracked
18693
+ * objects, per-kind event collections (motion / object / audio), and
18694
+ * persisted media. Owns the post-detection domain end-to-end:
18695
+ *
18696
+ * runner emits PipelineInferenceResult
18697
+ * ↓ (event bus)
18698
+ * pipeline-analytics subscriber
18699
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
18700
+ * → three DB collections (one per kind), one FS media tree, one
18701
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
18702
+ * DetectionEvent on bus)
18703
+ *
18704
+ * Pure subscriber model. No `processFrame` cap method — the runner
18705
+ * already publishes the raw frame on the bus. The cap surface is
18706
+ * only QUERIES + per-device settings, bound on/off via
18707
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
18708
+ * every camera with a detection pipeline wants its raw detections
18709
+ * refined; operators opt out per-device via BindingsTab when needed.
18710
+ *
18711
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
18712
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
18713
+ */
18714
+ var TrackStateSchema = _enum([
18715
+ "new",
18716
+ "entered",
18717
+ "left",
18718
+ "moving",
18719
+ "idle"
18720
+ ]);
18721
+ var EventKindSchema = _enum([
18722
+ "motion",
18723
+ "object",
18724
+ "audio"
18725
+ ]);
18726
+ /**
18727
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
18728
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
18729
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
18730
+ */
18731
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
18732
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
18733
+ var EventKindIconSchema = _enum([
18734
+ "motion",
18735
+ "audio",
18736
+ "person",
18737
+ "vehicle",
18738
+ "animal",
18739
+ "door",
18740
+ "pir",
18741
+ "smoke",
18742
+ "water",
18743
+ "button",
18744
+ "package",
18745
+ "generic"
18746
+ ]);
18747
+ var EventKindCategorySchema = _enum([
18748
+ "motion",
18749
+ "audio",
18750
+ "detection",
18751
+ "sensor",
18752
+ "control",
18753
+ "custom",
18754
+ "package"
18755
+ ]);
18756
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
18757
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
18758
+ var EventKindDescriptorSchema = object({
18759
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
18760
+ kind: string(),
18761
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
18762
+ labelKey: string(),
18763
+ /** English fallback label (kept for clients that don't translate). */
18764
+ label: string(),
18765
+ /** Hex color for timeline/legend rendering. */
18766
+ color: string(),
18767
+ /** Dictionary id → lucide component on the UI side. */
18768
+ iconId: string(),
18769
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
18770
+ icon: EventKindIconSchema,
18771
+ category: EventKindCategorySchema,
18772
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
18773
+ parentKind: string().nullable(),
18774
+ /** Derived from `parentKind`, explicit for the client tree. */
18775
+ level: EventKindLevelSchema,
18776
+ /** Which cap + device contributes this kind. For built-ins the camera
18777
+ * itself; for sensor kinds the LINKED source device. */
18778
+ source: object({
18779
+ capName: string(),
18780
+ deviceId: number()
18781
+ })
18782
+ });
18783
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
18784
+ var EventKindsForDeviceSchema = object({
18785
+ deviceId: number(),
18786
+ kinds: array(EventKindDescriptorSchema).readonly()
18787
+ });
18788
+ var SensorEventSchema = object({
18789
+ id: string(),
18790
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
18791
+ * yields N rows, one per camera). */
18792
+ deviceId: number(),
18793
+ /** The linked sensor device whose state changed. */
18794
+ sourceDeviceId: number(),
18795
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
18796
+ kind: string(),
18797
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
18798
+ value: record(string(), unknown()).nullable(),
18799
+ timestamp: number()
18800
+ });
18801
+ var TrackPositionSchema = object({
18802
+ x: number(),
18803
+ y: number(),
18804
+ timestamp: number(),
18805
+ bbox: BoundingBoxSchema
18806
+ });
18807
+ var TrackSnapshotSchema = object({
18808
+ timestamp: number(),
18809
+ position: TrackPositionSchema,
18810
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
18811
+ mediaKey: string()
18812
+ });
18813
+ /**
18814
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
18815
+ * divided by the track's detection-frame dims), computed at persist time.
18816
+ * Absent when the frame dims were unknown when the track was persisted
18817
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
18818
+ */
18819
+ var TrackEnvelopeSchema = object({
18820
+ minX: number(),
18821
+ minY: number(),
18822
+ maxX: number(),
18823
+ maxY: number()
18824
+ });
18825
+ /**
18826
+ * Row projection for track list queries. `full` (default) returns the
18827
+ * complete Track including the frame-rate `positions[]` history and the
18828
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
18829
+ * keeps every scalar the list surfaces actually render (ids, class(es),
18830
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
18831
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
18832
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
18833
+ * `getTrack`. Mirrors the event-store `projection` convention
18834
+ * (`getObjectEvents` et al.).
18835
+ */
18836
+ var TrackProjectionSchema = _enum(["full", "slim"]);
18837
+ /**
18838
+ * One audio-classification label heard on the track's camera while the
18839
+ * track was alive, aggregated per label. An "episode" is one persisted
18840
+ * audio event (the confident-classification path: score ≥ the device's
18841
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
18842
+ * one 32 ms inference chunk, so counts stay human-scaled.
18843
+ */
18844
+ var TrackAudioLabelSchema = object({
18845
+ label: string(),
18846
+ /** Highest classification score observed across the label's episodes. */
18847
+ peakScore: number(),
18848
+ /** Number of coalesced audio-event episodes carrying this label. */
18849
+ count: number(),
18850
+ firstAt: number(),
18851
+ lastAt: number()
18852
+ });
18853
+ /**
18854
+ * How a track was produced. `pipeline` (default / absent) = the spatial
18855
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
18856
+ * no positions, a single snapshot, and no bbox trajectory at all:
18857
+ *
18858
+ * - `sensor` — a linked sensor/control device state change.
18859
+ * - `audio` — an audio event on the camera itself that was anomalous for
18860
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
18861
+ *
18862
+ * The spatial subsystems (tracker association, occupancy count, re-id /
18863
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
18864
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
18865
+ * check silently readmits every source added after it was written.
18866
+ */
18867
+ var TrackSourceSchema = _enum([
18868
+ "pipeline",
18869
+ "sensor",
18870
+ "audio"
18871
+ ]);
18872
+ /**
18873
+ * Where a track sits in the RETRAIN lifecycle (D81).
18874
+ *
18875
+ * - `none` — never marked, or un-marked. Evictable.
18876
+ * - `staging` — the operator wants this track as training material and has not
18877
+ * finished with it. **This is the only state retention holds**: the track and
18878
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
18879
+ * the device's age window.
18880
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
18881
+ * were COPIED into the retrain dataset at selection time, so the dataset no
18882
+ * longer depends on the track's media and the track becomes EVICTABLE again.
18883
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
18884
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
18885
+ *
18886
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
18887
+ * the store's filter language has only positive equality and `whereIn` — no
18888
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
18889
+ * would make the entire pre-column history immortal in one deploy.
18890
+ */
18891
+ var RetrainStatusSchema = _enum([
18892
+ "none",
18893
+ "staging",
18894
+ "trained"
18895
+ ]);
18896
+ /**
18897
+ * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
18898
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
18899
+ * so the two surfaces cannot drift.
18900
+ *
18901
+ * **Absent ≠ false.** A track that has never been touched omits the field; an
18902
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
18903
+ * columns existed read as absent, and a consumer that needs a boolean should say
18904
+ * `flag === true`, not `flag !== false`.
18905
+ *
18906
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
18907
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
18908
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
18909
+ * `trained` track reports `false` while refusing both writes. The boolean is
18910
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
18911
+ * "never marked" from "already trained" must read `retrainStatus`.
18912
+ *
18913
+ * `debug` does NOT pin; it is attention, not durability.
18914
+ *
18915
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
18916
+ * A favourited track is skipped by retention the same way `staging` is, but
18917
+ * it does not enter `none|staging|trained` and has no staging budget.
18918
+ */
18919
+ var TrackFlagFields = {
18920
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
18921
+ * `'staging'`. */
18922
+ markForTrain: boolean().optional(),
18923
+ /** Operator marked this track for diagnostic attention. */
18924
+ debug: boolean().optional(),
18925
+ /** Operator favourited this track. Pins it against pruning. */
18926
+ favourited: boolean().optional()
18927
+ };
18928
+ /**
18929
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
18930
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
18931
+ * write patch, and the status is not something the toggle sets — it is what the
18932
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
18933
+ * always present on a persisted row (the column default materialises `'none'`).
18934
+ */
18935
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
18936
+ /**
18937
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
18938
+ * one flag can never clear the other — the toggles are independent and are
18939
+ * driven from three surfaces that do not know about each other.
18940
+ */
18941
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
18942
+ /**
18943
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
18944
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
18945
+ * mutation result without a re-fetch.
18946
+ */
18947
+ var TrackFlagsSchema = object({
18948
+ trackId: string(),
18949
+ markForTrain: boolean(),
18950
+ debug: boolean(),
18951
+ favourited: boolean(),
18952
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
18953
+ * a track row) because this shape is only ever produced by the write body,
18954
+ * which always knows it — and a surface that has just written needs to render
18955
+ * `trained` without a re-fetch. */
18956
+ retrainStatus: RetrainStatusSchema
18957
+ });
18958
+ union([literal(1), literal(2)]);
18959
+ /**
18960
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
18961
+ * the step and model that produced it — which is what makes the write rule
18962
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
18963
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
18964
+ *
18965
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
18966
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
18967
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
18968
+ * that value has no provenance, and the write rule lets ANY properly-attributed
18969
+ * write of the same tier replace it regardless of score.
18970
+ */
18971
+ var LabelAttributionSchema = object({
18972
+ stepId: string(),
18973
+ modelId: string().optional(),
18974
+ decidedAt: number(),
18975
+ /**
18976
+ * The GALLERY id behind a recognised tier-2 label — a face-gallery
18977
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
18978
+ *
18979
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
18980
+ * notification rule authored on "Gianluca" stopped matching the moment the
18981
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
18982
+ * the thing that does not move, so it is what a rule matches on
18983
+ * (`NcConditions.identities`) and the text is what a human is shown.
18984
+ *
18985
+ * Absent when the label names no gallery row — a plate the OCR read but no
18986
+ * vehicle claims, a sub-class, a species, any tier-1 value.
18987
+ */
18988
+ identityId: string().optional()
18989
+ });
18990
+ /**
18991
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
18992
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
18993
+ * track and its events always answer the same question the same way.
18994
+ *
18995
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
18996
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
18997
+ * is tier 2, and each carries its own score + attribution.
18998
+ *
18999
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
19000
+ * finest thing known. Before 4g the single `label` column held the finest
19001
+ * value, so a consumer that has not been updated reads the tier-1 slot and
19002
+ * shows nothing on a species-only row; that is why the migration puts every
19003
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
19004
+ * and why the read surfaces were changed in the same train.
19005
+ *
19006
+ * **Writing it.** The slots are independent, which is the whole point: a
19007
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
19008
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
19009
+ * higher score wins. One rule, one implementation — see
19010
+ * `pipeline/label-tier.ts` in addon-post-analysis.
19011
+ */
19012
+ var TieredLabelFields = {
19013
+ /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
19014
+ label: string().optional(),
19015
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
19016
+ labelScore: number().optional(),
19017
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
19018
+ labelMeta: LabelAttributionSchema.optional(),
19019
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
19020
+ subLabel: string().optional(),
19021
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
19022
+ subLabelScore: number().optional(),
19023
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
19024
+ subLabelMeta: LabelAttributionSchema.optional()
19025
+ };
19026
+ /** Per-camera slice of a training-export estimate. */
19027
+ var TrainingExportDeviceTotalsSchema = object({
19028
+ deviceId: number(),
19029
+ tracks: number().int(),
19030
+ files: number().int(),
19031
+ bytes: number().int()
19032
+ });
19033
+ /**
19034
+ * What a training export WOULD contain. Computed from media index rows only —
19035
+ * no blob is read to produce this.
19036
+ */
19037
+ var TrainingExportSummarySchema = object({
19038
+ generatedAt: number(),
19039
+ trackCount: number().int(),
19040
+ fileCount: number().int(),
19041
+ byteCount: number().int(),
19042
+ /** More marked tracks exist than a single pass carries. */
19043
+ truncated: boolean(),
19044
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
19045
+ });
19046
+ var TrackSchema = object({
19047
+ trackId: string(),
19048
+ deviceId: number(),
19049
+ className: string(),
19050
+ ...TieredLabelFields,
19051
+ producingDeviceName: string().optional(),
19052
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
19053
+ source: TrackSourceSchema.optional(),
19054
+ firstSeen: number(),
19055
+ lastSeen: number(),
19056
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
19057
+ positions: array(TrackPositionSchema).readonly(),
19058
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
19059
+ * saveThumbnails policy). */
19060
+ snapshots: array(TrackSnapshotSchema).readonly(),
19061
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
19062
+ zonesVisited: array(string()).readonly(),
19063
+ /**
19064
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
19065
+ * `zones` capability.
19066
+ *
19067
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
19068
+ * and no card can render — so every free-text search surface was structurally
19069
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
19070
+ * just returned nothing. Resolving here rather than in each client keeps ONE
19071
+ * derivation and costs the clients no extra call (the `zones` cap is
19072
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
19073
+ * surface built to avoid exactly that).
19074
+ *
19075
+ * Resolved, never invented: a zone deleted since the track was written has no
19076
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
19077
+ * two are not positionally aligned. Absent when the track visited no zone, or
19078
+ * when the zone catalogue could not be read.
19079
+ */
19080
+ zoneNames: array(string()).readonly().optional(),
19081
+ /** Deduplicated set of detector classes observed for this track over its
19082
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
19083
+ * legacy rows written before class accumulation shipped. */
19084
+ classes: array(string()).readonly().optional(),
19085
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
19086
+ totalDistance: number(),
19087
+ state: TrackStateSchema,
19088
+ active: boolean(),
19089
+ /** Deterministic key-event importance score in [0,1] (server-computed at
19090
+ * track expiry, recomputed on late label). Absent on legacy rows written
19091
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
19092
+ importance: number().optional(),
19093
+ /** Id of the track's highest-confidence ObjectEvent (its representative
19094
+ * "best" frame). Absent when the track produced no object events. */
19095
+ bestEventId: string().optional(),
19096
+ /** Tag of the importance sub-signal that dominated the score
19097
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
19098
+ importanceReason: string().optional(),
19099
+ /** Audio-classification labels heard on the camera during the track's
19100
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
19101
+ * Absent on legacy rows / tracks with no confident audio. */
19102
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
19103
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
19104
+ * Populated from the persisted envelope columns on historical reads;
19105
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
19106
+ envelope: TrackEnvelopeSchema.optional(),
19107
+ /**
19108
+ * A face DETECTOR found a face on this track — nothing more. It says the
19109
+ * detail plane produced a `face` detail; it does NOT say the face was
19110
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
19111
+ * enabled. Set once and never cleared.
19112
+ *
19113
+ * **This exists so "face present but not recognised" is expressible.** A
19114
+ * recognised identity lands in `subLabel` (attributed to the face chain via
19115
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
19116
+ * and a track with no face at all were byte-identical on the wire and no
19117
+ * surface could tell them apart. The read is `hasFace === true && subLabel
19118
+ * === undefined`.
19119
+ *
19120
+ * **Absent ≠ false.** Every row written before the column existed omits it,
19121
+ * and so does every server that predates the field — a consumer must test
19122
+ * `=== true` and render nothing otherwise, never infer "no face".
19123
+ */
19124
+ hasFace: boolean().optional(),
19125
+ /**
19126
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
19127
+ * face an operator could ASSIGN to an identity.
19128
+ *
19129
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
19130
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
19131
+ * branch, before every gate, and means no more than "a face detector produced
19132
+ * a face detail". This one is stamped at the single moment the gallery row
19133
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
19134
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
19135
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
19136
+ * the crop-store drop. Everything between the detector and that insert can
19137
+ * legitimately refuse the face, so a flag written any earlier promises the
19138
+ * operator something to assign and delivers nothing.
19139
+ *
19140
+ * **Independent of recognition.** A face collected but never auto-matched is
19141
+ * still assignable — it is in fact the face an operator most wants to reach —
19142
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
19143
+ * `subLabel`; this says only that the raw material exists.
19144
+ *
19145
+ * **Set once, never cleared.** A track that produced a gallery row produced
19146
+ * one; deleting the row later is the gallery's business, not this flag's.
19147
+ *
19148
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
19149
+ * before the column omits it, and so does every server that predates the
19150
+ * field. A consumer must test `=== true` and render nothing otherwise —
19151
+ * never infer "no assignable face".
19152
+ */
19153
+ hasEmbeddedFace: boolean().optional(),
19154
+ /**
19155
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
19156
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
19157
+ * so the passage is tracked once and as a VEHICLE.
19158
+ *
19159
+ * It exists because the fold's record was dishonest. D34 and the code both
19160
+ * said "the person is not lost — it is reported so both entities stay on the
19161
+ * record"; in fact the pair went into a per-processor RAM field behind an
19162
+ * accessor nobody called, and every durable surface said `vehicle`, full
19163
+ * stop. This is the composition note that makes the row true.
19164
+ *
19165
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
19166
+ * person" is not an answer to "what is this" — both label tiers would refuse
19167
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
19168
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
19169
+ * and a `person` rule still does not fire for someone cycling past.
19170
+ *
19171
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
19172
+ * the column, and every hub that predates the field, omits it. Test
19173
+ * `=== true` and render nothing otherwise — never infer "no rider".
19174
+ */
19175
+ hasRider: boolean().optional(),
19176
+ ...TrackFlagFields,
19177
+ ...TrackRetrainFields
19178
+ });
19179
+ var BaseEventFields = {
19180
+ id: string(),
19181
+ deviceId: number(),
19182
+ timestamp: number()
19183
+ };
19184
+ var MotionEventSchema = object({
19185
+ ...BaseEventFields,
19186
+ kind: literal("motion"),
19187
+ regionCount: number(),
19188
+ /** Heavy JSON array — omitted in slim projection. */
19189
+ regions: array(object({
19190
+ bbox: BoundingBoxSchema,
19191
+ pixelCount: number(),
19192
+ intensity: number()
19193
+ })).readonly().optional(),
19194
+ /** Omitted in slim projection. */
19195
+ frameWidth: number().optional(),
19196
+ /** Omitted in slim projection. */
19197
+ frameHeight: number().optional(),
19198
+ /** Populated by B5 (recording playback URL for this event). */
19199
+ mediaUrl: string().optional()
19200
+ });
19201
+ /**
19202
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
19203
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
19204
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
19205
+ * tracking, per-kind persistence) but stay distinguishable so consumers
19206
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
19207
+ * Absent on legacy rows ⇒ treat as `pipeline`.
19208
+ */
19209
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
19210
+ /**
19211
+ * The confirmed zone crossing that produced an object event. Present ONLY on
19212
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
19213
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
19214
+ * appearance event carry none, so a rule asking for a direction fails closed
19215
+ * on them.
19216
+ *
19217
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
19218
+ * into its own event, so a frame in which a track enters A while leaving B
19219
+ * produces two events with two directions — never one ambiguous row.
19220
+ *
19221
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
19222
+ * membership the box has NOW, and by definition it no longer contains the zone
19223
+ * that was just left. Without the id here, a zone-scoped rule could never match
19224
+ * the exit it asked for.
19225
+ */
19226
+ var ZoneCrossingSchema = object({
19227
+ direction: _enum(["enter", "exit"]),
19228
+ /** Admin zone id crossed. */
19229
+ zoneId: string(),
19230
+ /** Zone display name at crossing time (falls back to the id). */
19231
+ zoneName: string().optional()
19232
+ });
19233
+ var ObjectEventSchema = object({
19234
+ ...BaseEventFields,
19235
+ kind: literal("object"),
19236
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
19237
+ source: DetectionSourceSchema.optional(),
19238
+ /**
19239
+ * Inference-frame id shared by every object event emitted from the SAME frame
19240
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
19241
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
19242
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
19243
+ * Optional for backward-compat with pre-existing rows / the slim projection
19244
+ * includes it (it is light). Absent on rows written before this field.
19245
+ */
19246
+ frameId: string().optional(),
19247
+ /** Omitted in slim projection. */
19248
+ trackId: string().optional(),
19249
+ className: string(),
19250
+ ...TieredLabelFields,
19251
+ /** Omitted in slim projection. */
19252
+ confidence: number().optional(),
19253
+ /** Heavy JSON — omitted in slim projection. */
19254
+ bbox: BoundingBoxSchema.optional(),
19255
+ /** Heavy JSON — omitted in slim projection. */
19256
+ zones: array(string()).readonly().optional(),
19257
+ /** Omitted in slim projection. */
19258
+ state: TrackStateSchema.optional(),
19259
+ /**
19260
+ * The zone crossing this event IS, when it is one. Absent on every other
19261
+ * event kind (movement state, appearance, package) — see
19262
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
19263
+ */
19264
+ zoneCrossing: ZoneCrossingSchema.optional(),
19265
+ /** Detection-frame dimensions in pixels — let consumers normalize the
19266
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
19267
+ frameWidth: number().optional(),
19268
+ frameHeight: number().optional(),
19269
+ /** MediaStore key for the crop attached to this event (if any). */
19270
+ mediaKey: string().optional(),
19271
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
19272
+ * best-detection full frame). Resolve via the event-media data-plane
19273
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
19274
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
19275
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
19276
+ keyFrameMediaKey: string().optional(),
19277
+ /** Populated by B5 (recording playback URL for this event). */
19278
+ mediaUrl: string().optional(),
19279
+ /** The parent track's key-event importance [0,1], propagated to every object
19280
+ * event of the track (so an event row can be sorted by importance without a
19281
+ * track join). Absent on legacy rows / before the track was scored. */
19282
+ importance: number().optional()
19283
+ });
19284
+ var AudioEventSchema = object({
19285
+ ...BaseEventFields,
19286
+ kind: literal("audio"),
19287
+ rms: number(),
19288
+ dbfs: number(),
19289
+ classification: object({
19290
+ className: string(),
19291
+ originalClass: string().optional(),
19292
+ score: number()
19293
+ }).optional(),
19294
+ /** Populated by B5 (recording playback URL for this event). */
19295
+ mediaUrl: string().optional()
19296
+ });
19297
+ var MediaFileKindEnum = _enum([
19298
+ "crop",
19299
+ "thumbnail",
19300
+ "snapshot",
19301
+ "firstFrame",
19302
+ "lastFrame",
19303
+ "fullFrame",
19304
+ "fullFrameBoxed",
19305
+ "faceCrop",
19306
+ "plateCrop",
19307
+ "keyFrame",
19308
+ "keyFrameSmall",
19309
+ "thumbnailSmall"
19310
+ ]);
19311
+ var MediaFileSchema = object({
19312
+ key: string(),
19313
+ kind: MediaFileKindEnum,
19314
+ base64: string(),
19315
+ sizeBytes: number(),
19316
+ timestamp: number()
19317
+ });
19318
+ /**
19319
+ * One media row WITHOUT its bytes.
19320
+ *
19321
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
19322
+ * 140 s track), and a client that renders tiles from the media data plane needs
19323
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
19324
+ * with an immutable cache, instead of all at once inside a tRPC response that
19325
+ * blocks the whole view.
19326
+ *
19327
+ * `sizeBytes` is carried because it is what lets a client decide between the
19328
+ * stored blob and a `?variant=thumb` rendering without fetching either.
19329
+ */
19330
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
19331
+ /**
19332
+ * The MACRO tier of an annotation — a CLOSED set.
19333
+ *
19334
+ * This is what the exported detector predicts, so a typo here is a new class
19335
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
19336
+ * the whole point of the page is teaching the model things it does not know
19337
+ * yet, and constraining that vocabulary would make it useless.
19338
+ *
19339
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
19340
+ * `subLabel` is one of these values, in any casing, because once `person`
19341
+ * exists in both tiers "every person box" stops being answerable without
19342
+ * knowing every string anyone ever typed — and the damage is retroactive.
19343
+ */
19344
+ var RetrainMacroClassSchema = _enum([
19345
+ "person",
19346
+ "vehicle",
19347
+ "animal",
19348
+ "package",
19349
+ "face",
19350
+ "plate"
19351
+ ]);
19352
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
19353
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
19354
+ /** Did a human draw this box, or did the assist propose it? */
19355
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
19356
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
19357
+ var RetrainBboxSchema = object({
19358
+ x: number(),
19359
+ y: number(),
19360
+ w: number(),
19361
+ h: number()
19362
+ });
19363
+ /**
19364
+ * One annotated subject.
19365
+ *
19366
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
19367
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
19368
+ * derived from it at export and never stored — storing them is how one feature
19369
+ * space ends up holding two crops of the same subject (D52).
19370
+ */
19371
+ var RetrainAnnotationSchema = object({
19372
+ id: string(),
19373
+ trackId: string(),
19374
+ deviceId: number(),
19375
+ /** The COPY in retrain storage — never the source track's media key. */
19376
+ mediaKey: string(),
19377
+ bbox: RetrainBboxSchema,
19378
+ macroClass: RetrainMacroClassSchema,
19379
+ label: string().optional(),
19380
+ subLabel: string().optional(),
19381
+ kind: RetrainAnnotationKindSchema,
19382
+ source: RetrainAnnotationSourceSchema,
19383
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
19384
+ assistModelId: string().optional(),
19385
+ assistScore: number().optional(),
19386
+ exportedInBatch: string().optional(),
19387
+ createdAt: number()
19388
+ });
19389
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
19390
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
19391
+ id: true,
19392
+ trackId: true,
19393
+ deviceId: true,
19394
+ mediaKey: true,
19395
+ createdAt: true,
19396
+ exportedInBatch: true
19397
+ });
19398
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
19399
+ var RetrainTrackSchema = object({
19400
+ trackId: string(),
19401
+ deviceId: number(),
19402
+ className: string(),
19403
+ label: string().optional(),
19404
+ firstSeen: number(),
19405
+ lastSeen: number(),
19406
+ /** How many frames the dataset already holds from this track. */
19407
+ frameCount: number().int(),
19408
+ /** How many subjects have been annotated on those frames. `0` with
19409
+ * `frameCount: 0` is exactly "staging, still to work". */
19410
+ annotationCount: number().int()
19411
+ });
19412
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
19413
+ var RetrainFrameCandidateSchema = object({
19414
+ mediaKey: string(),
19415
+ kind: MediaFileKindEnum,
19416
+ timestamp: number(),
19417
+ sizeBytes: number().int(),
19418
+ /** A copy of this original already exists — selecting it is free and cannot
19419
+ * fail, whatever became of the original. */
19420
+ copied: boolean()
19421
+ });
19422
+ /** A frame the dataset OWNS: bytes copied at selection time. */
19423
+ var RetrainFrameSchema = object({
19424
+ frameId: string(),
19425
+ deviceId: number(),
19426
+ trackId: string(),
19427
+ /** Provenance only. It may already point at nothing — that is expected. */
19428
+ sourceMediaKey: string(),
19429
+ sourceKind: MediaFileKindEnum,
19430
+ sizeBytes: number().int(),
19431
+ width: number().int(),
19432
+ height: number().int(),
19433
+ copiedAt: number()
19434
+ });
19435
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
19436
+ var RetrainCopyRefusalSchema = _enum([
19437
+ "source-missing",
19438
+ "unreadable-image",
19439
+ "write-failed"
19440
+ ]);
19441
+ var RetrainFrameSelectionSchema = object({
19442
+ copied: array(RetrainFrameSchema).readonly(),
19443
+ refused: array(object({
19444
+ sourceMediaKey: string(),
19445
+ reason: RetrainCopyRefusalSchema
19446
+ })).readonly()
19447
+ });
19448
+ var RetrainFrameListSchema = object({
19449
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
19450
+ copies: array(RetrainFrameSchema).readonly(),
19451
+ /** What the page pre-selects — the native key frame when one survives. */
19452
+ autoPickMediaKey: string().optional()
19453
+ });
19454
+ /** What the operator asked the assist to look for. */
19455
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
19456
+ kind: literal("package"),
19457
+ zone: RetrainBboxSchema.optional()
19458
+ }), object({
19459
+ kind: literal("objects"),
19460
+ modelId: string(),
19461
+ minScore: number().optional()
19462
+ })]);
19463
+ /**
19464
+ * The assist's answer — a discriminated union, because "the model saw nothing"
19465
+ * and "this node cannot run that model" lead to different next moves and a
19466
+ * nullable result cannot tell them apart.
19467
+ */
19468
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
19469
+ kind: literal("proposed"),
19470
+ modelId: string(),
19471
+ stepId: string(),
19472
+ minScore: number(),
19473
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
19474
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
19475
+ /** Returned by the runner but removed by the threshold. */
19476
+ belowThreshold: number().int()
19477
+ }), object({
19478
+ kind: literal("refused"),
19479
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
19480
+ reason: string(),
19481
+ detail: string().optional()
19482
+ })]);
19483
+ /** The outcome of a lifecycle move owned by the retrain page. */
19484
+ var RetrainTransitionResultSchema = object({
19485
+ trackId: string(),
19486
+ /** Where the track ended up, whatever happened. */
19487
+ retrainStatus: RetrainStatusSchema,
19488
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
19489
+ changed: boolean(),
19490
+ reason: _enum([
19491
+ "unknown-track",
19492
+ "no-frames-copied",
19493
+ "not-staging",
19494
+ "not-trained",
19495
+ "unchanged"
19496
+ ]).optional()
19497
+ });
19498
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
19499
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
19500
+ var DeviceEventQueryInput = object({
19501
+ deviceId: number(),
19502
+ since: number().optional(),
19503
+ until: number().optional(),
19504
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
19505
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
19506
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
19507
+ * exact behaviour. Callers may omit this field — the store defaults to
19508
+ * `full` when not provided. */
19509
+ projection: _enum(["full", "slim"]).optional()
19510
+ });
19511
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
19512
+ var RecentTracksQueryInput = object({
19513
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
19514
+ deviceIds: array(number()),
19515
+ /** Window lower bound on `lastSeen` (inclusive). */
19516
+ since: number().optional(),
19517
+ /** Window upper bound on `lastSeen` (inclusive). */
19518
+ until: number().optional(),
19519
+ /** Page size. Default 200, max 1000. */
19520
+ limit: number().int().min(1).max(1e3).default(200),
19521
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
19522
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
19523
+ cursor: string().optional(),
19524
+ /** See {@link TrackProjectionSchema}. Default `full`. */
19525
+ projection: TrackProjectionSchema.optional(),
19526
+ /** Include stationary-promoted rows (parked objects). Default false: the
19527
+ * feed lists passages; parking records live on the stationary registry. */
19528
+ includeStationary: boolean().optional()
19529
+ });
19530
+ var RecentTracksPageSchema = object({
19531
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
19532
+ tracks: array(TrackSchema).readonly(),
19533
+ /** Cursor for the next page, or null when this page is the last. */
19534
+ nextCursor: string().nullable()
19535
+ });
19536
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
19537
+ var LIST_GROUPS_MAX_LIMIT = 100;
19538
+ var AnalyticsGroupRecordSchema = object({
19539
+ id: string(),
19540
+ deviceId: number().int(),
19541
+ openedAt: number().int(),
19542
+ closedAt: number().int(),
19543
+ timestamp: number().int(),
19544
+ memberCount: number().int(),
19545
+ memberTrackIds: array(string()).readonly(),
19546
+ className: string(),
19547
+ classes: array(string()).readonly(),
19548
+ /** Relative event-media path, or null when the group has no picture yet. */
19549
+ mediaUrl: string().nullable(),
19550
+ singleton: boolean()
19551
+ });
19552
+ var AnalyticsGroupMemberSchema = object({
19553
+ trackId: string(),
19554
+ deviceId: number().int(),
19555
+ className: string(),
19556
+ firstSeen: number().int(),
19557
+ lastSeen: number().int(),
19558
+ mediaUrl: string().nullable()
19559
+ });
19560
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
19561
+ var ListGroupsQueryInput = object({
19562
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
19563
+ deviceIds: array(number()),
19564
+ /** Window lower bound on `closedAt` (inclusive). */
19565
+ since: number().optional(),
19566
+ /** Window upper bound on `openedAt` (inclusive). */
19567
+ until: number().optional(),
19568
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
19569
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
19570
+ cursor: string().optional()
19571
+ });
19572
+ var ListGroupsPageSchema = object({
19573
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
19574
+ nextCursor: string().nullable()
19575
+ });
19576
+ var KeyEventQueryInput = object({
19577
+ deviceId: number(),
19578
+ /** Window lower bound (track firstSeen ≥ since). */
19579
+ since: number(),
19580
+ /** Window upper bound (track firstSeen ≤ until). */
19581
+ until: number(),
19582
+ limit: number().int().min(1).max(200).default(50),
19583
+ /** Drop tracks scoring below this importance. */
19584
+ minImportance: number().min(0).max(1).optional(),
19585
+ /** Restrict to a single class (e.g. 'person'). */
19586
+ classFilter: string().optional()
19587
+ });
19588
+ var KeyEventSchema = object({
19589
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
19590
+ id: string(),
19591
+ trackId: string(),
19592
+ /** Track start time (firstSeen). */
19593
+ timestamp: number(),
19594
+ className: string(),
19595
+ ...TieredLabelFields,
19596
+ importance: number(),
19597
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
19598
+ bestEventId: string(),
19599
+ /** Track lifetime in ms (lastSeen - firstSeen). */
19600
+ windowMs: number().optional(),
19601
+ ...TrackFlagFields,
19602
+ ...TrackRetrainFields
19603
+ });
19604
+ object({
19605
+ trackId: string(),
19606
+ className: string(),
19607
+ confidence: number(),
19608
+ bbox: BoundingBoxSchema,
19609
+ zones: array(string()).readonly(),
19610
+ state: TrackStateSchema
19611
+ });
19612
+ var OverlayDetectionSchema = looseObject({
19613
+ id: string(),
19614
+ kind: _enum(["first-level", "detail"]),
19615
+ macroClass: string(),
19616
+ score: number(),
19617
+ bbox: object({
19618
+ x: number(),
19619
+ y: number(),
19620
+ width: number(),
19621
+ height: number()
19622
+ }),
19623
+ labels: array(looseObject({
19624
+ label: string(),
19625
+ score: number()
19626
+ })).readonly(),
19627
+ parentId: string().optional()
19628
+ });
19629
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
19630
+ var SearchObjectEventsInput = object({
19631
+ text: string(),
19632
+ deviceId: number().optional(),
19633
+ since: number().optional(),
19634
+ until: number().optional(),
19635
+ classFilter: string().optional(),
19636
+ limit: number().default(50),
19637
+ minScore: number().min(0).max(1).default(.2)
19638
+ });
19639
+ var TrackCascadeCountsSchema = object({
19640
+ /** Persisted track roots deleted (authoritative). */
19641
+ tracks: number().int(),
19642
+ /** Object events removed with their tracks (best-effort; see note above). */
19643
+ events: number().int(),
19644
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
19645
+ media: number().int(),
19646
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
19647
+ faces: number().int(),
19648
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
19649
+ plates: number().int(),
19650
+ /** Per-track CLIP search vectors removed (best-effort). */
19651
+ embeddings: number().int(),
19652
+ /** Group membership + group rows removed with their last member (best-effort). */
19653
+ groups: number().int()
19654
+ });
19655
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
19656
+ var DiskReconcileCountsSchema = object({
19657
+ mediaDropped: number().int(),
19658
+ tracks: number().int(),
19659
+ events: number().int()
19660
+ });
19661
+ /** Event-store footprint for one camera. */
19662
+ var EventStoreDeviceFootprintSchema = object({
19663
+ deviceId: number(),
19664
+ /** Persisted event rows (motion + object + audio) for the camera. */
19665
+ rows: number().int(),
19666
+ /** Event-owned media bytes on disk for the camera. */
19667
+ bytes: number().int()
19668
+ });
19669
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
19670
+ var EventStoreFootprintSchema = object({
19671
+ totalRows: number().int(),
19672
+ totalBytes: number().int(),
19673
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
19674
+ });
19675
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
19676
+ var EventPruneCountsSchema = object({
19677
+ motion: number().int(),
19678
+ object: number().int(),
19679
+ audio: number().int()
19680
+ });
19681
+ /**
19682
+ * Re-embed stored tracks from their key frames.
19683
+ *
19684
+ * The reason this is an operator-callable method and not a migration script:
19685
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
19686
+ * squaring — is only changeable if the existing vectors can be regenerated.
19687
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
19688
+ * symptom is a quality regression with no visible cause.
19689
+ */
19690
+ var RebuildObjectEmbeddingsInput = object({
19691
+ /** Restrict to one camera. Omit for the whole fleet. */
19692
+ deviceId: number().optional(),
19693
+ since: number().optional(),
19694
+ until: number().optional(),
19695
+ /** Stop after this many tracks; the result reports whether more remain. */
19696
+ maxTracks: number().int().positive().optional(),
19697
+ /**
19698
+ * Run every embedding on THIS node instead of round-robining the fleet.
19699
+ *
19700
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
19701
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
19702
+ * calling it that would pin the rebuild REQUEST itself to that node — the
19703
+ * rebuild orchestration lives on the hub, and only the per-track step runs
19704
+ * remotely. This field is data; the per-track pin is applied inside.
19705
+ *
19706
+ * Absent ⇒ round-robin over every online node whose runner can serve the
19707
+ * pinned model.
19708
+ */
19709
+ executeOnNodeId: string().optional(),
19710
+ /**
19711
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
19712
+ * run flat out.
19713
+ *
19714
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
19715
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
19716
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
19717
+ * force is logged at start and finish so a deliberately slow pass reads
19718
+ * differently from a stalled one.
19719
+ */
19720
+ pacingMs: number().int().nonnegative().optional()
19721
+ });
19722
+ /**
19723
+ * Result of emptying the CLIP index.
19724
+ *
19725
+ * The clean slate before a policy change: a new crop margin or encoder model
19726
+ * leaves two feature spaces in one index whose cosine scores are not
19727
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
19728
+ * means the same thing.
19729
+ */
19730
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
19731
+ /**
19732
+ * Acknowledgement that a rebuild STARTED.
19733
+ *
19734
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
19735
+ * runs detached and this returns immediately. Waiting for it made the client
19736
+ * time out while the work carried on server-side, which is the worst of both:
19737
+ * no result and no way to know it was still going. Poll
19738
+ * `getObjectEmbeddingRebuildStatus` for progress.
19739
+ */
19740
+ var RebuildObjectEmbeddingsResultSchema = object({
19741
+ started: boolean(),
19742
+ /** True when a pass was already running; the new request is ignored. */
19743
+ alreadyRunning: boolean()
19744
+ });
19745
+ var RebuildStatusSchema = object({
19746
+ running: boolean(),
19747
+ scanned: number(),
19748
+ rebuilt: number(),
19749
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
19750
+ missingKeyFrame: number(),
19751
+ /** Tracks with no usable detection box. */
19752
+ missingBbox: number(),
19753
+ /**
19754
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
19755
+ * frame, a step that threw. Separate from `failed` because the remedy is
19756
+ * different, and because a whole camera silently contributing zero vectors
19757
+ * is the shape of failure a rebuild must never hide.
19758
+ */
19759
+ notRunnable: number(),
19760
+ /**
19761
+ * The pass stopped because NO node could serve the pinned model.
19762
+ *
19763
+ * Distinct from `notRunnable` on purpose: that one says "this track was
19764
+ * refused", this one says "the cluster cannot do this work at all" — every
19765
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
19766
+ * pinned model for its engine format, or dropped out. The remedy is a model /
19767
+ * engine change, not a per-camera one. Non-zero here always comes with
19768
+ * `complete: false`.
19769
+ */
19770
+ noCapableNode: number(),
19771
+ failed: number(),
19772
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
19773
+ complete: boolean().nullable(),
19774
+ startedAtMs: number().nullable(),
19775
+ finishedAtMs: number().nullable(),
19776
+ /** Present when the pass ended by throwing. */
19777
+ error: string().nullable()
19778
+ });
19779
+ var ReplayFrameInputSchema = object({
19780
+ timestamp: number(),
19781
+ frame: PipelineRunResultBridge
19782
+ });
19783
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
19784
+ className: string(),
19785
+ firstSeenMs: number(),
19786
+ lastSeenMs: number(),
19787
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
19788
+ * frame — a representative box for the diff's `(className, window, IoU)`
19789
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
19790
+ * trajectory production's `Track.positions` keeps. */
19791
+ bbox: BoundingBoxSchema,
19792
+ /** How many of the input frames this track matched a real detection on
19793
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
19794
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
19795
+ framesMatched: number().int()
19796
+ })).readonly() });
19797
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
19798
+ deviceId: number(),
19799
+ trackId: string()
19800
+ }), TrackSchema.nullable()), method(object({
19801
+ deviceId: number(),
19802
+ since: number().optional(),
19803
+ until: number().optional(),
19804
+ limit: number().optional(),
19805
+ /** Spatial filter — only tracks whose trajectory intersects the zone
19806
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
19807
+ * envelope columns, then precisely tested per position. Tracks with
19808
+ * an unknown envelope (no frame dims at persist time) always match. */
19809
+ zone: TrackZoneFilterSchema.optional(),
19810
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
19811
+ * compatible — omitting the field keeps today's exact behaviour). */
19812
+ projection: TrackProjectionSchema.optional(),
19813
+ /** Include stationary-promoted rows (parked objects handed to the
19814
+ * stationary registry). Default false: the timeline lists passages,
19815
+ * not parking records (operator decision, 2026-08-15). */
19816
+ includeStationary: boolean().optional()
19817
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
19818
+ deviceId: number(),
19819
+ groupId: string().min(1)
19820
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
19821
+ kind: "mutation",
19822
+ auth: "admin"
19823
+ }), method(DeviceEventQueryInput, array(MotionEventSchema).readonly()), method(ObjectEventQueryInput, array(ObjectEventSchema).readonly()), method(DeviceEventQueryInput, array(AudioEventSchema).readonly()), method(object({ deviceId: number() }), array(EventKindDescriptorSchema).readonly()), method(object({ deviceIds: array(number()).min(1).max(200) }), array(EventKindsForDeviceSchema).readonly()), method(object({
19824
+ deviceId: number(),
19825
+ since: number().optional(),
19826
+ until: number().optional(),
19827
+ kinds: array(string()).optional(),
19828
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
19829
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
19830
+ deviceId: number(),
19831
+ since: number(),
19832
+ until: number(),
19833
+ bucketMs: number().int().positive()
19834
+ }), array(object({
19835
+ bucketStart: number(),
19836
+ motion: number().int(),
19837
+ object: number().int(),
19838
+ audio: number().int()
19839
+ })).readonly()), method(object({
19840
+ deviceId: number(),
19841
+ cutoffMs: number()
19842
+ }), object({
19843
+ motion: number().int(),
19844
+ object: number().int(),
19845
+ audio: number().int()
19846
+ }), {
19847
+ kind: "mutation",
19848
+ auth: "admin"
19849
+ }), method(object({
19850
+ deviceId: number(),
19851
+ cutoffMs: number()
19852
+ }), TrackCascadeCountsSchema, {
19853
+ kind: "mutation",
19854
+ auth: "admin"
19855
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
19856
+ kind: "mutation",
19857
+ auth: "admin"
19858
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
19859
+ kind: "mutation",
19860
+ auth: "admin"
19861
+ }), method(object({
19862
+ deviceId: number(),
19863
+ trackIds: array(string()).min(1)
19864
+ }), object({
19865
+ deleted: number().int(),
19866
+ failed: array(string()).readonly()
19867
+ }), {
19868
+ kind: "mutation",
19869
+ auth: "admin"
19870
+ }), method(object({
19871
+ /** Log/audit scope only — the trackId is globally unique on its own. */
19872
+ deviceId: number(),
19873
+ trackId: string(),
19874
+ flags: TrackFlagsPatchSchema
19875
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
19876
+ kind: "query",
19877
+ auth: "admin"
19878
+ }), method(object({
19879
+ olderThanMs: number(),
19880
+ reason: OpsLogReasonSchema.optional()
19881
+ }), EventPruneCountsSchema, {
19882
+ kind: "mutation",
19883
+ auth: "admin"
19884
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
19885
+ kind: "mutation",
19886
+ auth: "admin"
19887
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
19888
+ kind: "mutation",
19889
+ auth: "admin"
19890
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
19891
+ kind: "mutation",
19892
+ auth: "admin"
19893
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
19894
+ kind: "mutation",
19895
+ auth: "admin"
19896
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
19897
+ kind: "mutation",
19898
+ auth: "admin"
19899
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
19900
+ kind: "mutation",
19901
+ auth: "admin"
19902
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
19903
+ kind: "mutation",
19904
+ auth: "admin"
19905
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
19906
+ kind: "query",
19907
+ auth: "admin"
19908
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
19909
+ kind: "mutation",
19910
+ auth: "admin"
19911
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
19912
+ kind: "query",
19913
+ auth: "admin"
19914
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
19915
+ kind: "query",
19916
+ auth: "admin"
19917
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
19918
+ kind: "query",
19919
+ auth: "admin"
19920
+ }), method(object({
19921
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
19922
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
19923
+ * route it at one camera's owner, and "every camera" would stop being
19924
+ * expressible at all. */
19925
+ deviceIds: array(number()).optional(),
19926
+ limit: number().int().min(1).max(500).optional()
19927
+ }), array(RetrainTrackSchema).readonly(), {
19928
+ kind: "query",
19929
+ auth: "admin"
19930
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
19931
+ kind: "query",
19932
+ auth: "admin"
19933
+ }), method(object({
19934
+ deviceId: number(),
19935
+ trackId: string(),
19936
+ mediaKeys: array(string()).min(1)
19937
+ }), RetrainFrameSelectionSchema, {
19938
+ kind: "mutation",
19939
+ auth: "admin"
19940
+ }), method(object({
19941
+ deviceId: number(),
19942
+ trackId: string(),
19943
+ frameId: string()
19944
+ }), object({
19945
+ removed: boolean(),
19946
+ removedAnnotations: number().int()
19947
+ }), {
19948
+ kind: "mutation",
19949
+ auth: "admin"
19950
+ }), method(object({ frameId: string() }), object({
19951
+ base64: string(),
19952
+ width: number().int(),
19953
+ height: number().int()
19954
+ }), {
19955
+ kind: "query",
19956
+ auth: "admin"
19957
+ }), method(object({
19958
+ deviceId: number(),
19959
+ trackId: string(),
19960
+ frameId: string(),
19961
+ subject: RetrainAssistSubjectSchema,
19962
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
19963
+ nodeId: string().optional()
19964
+ }), RetrainAssistResultSchema, {
19965
+ kind: "mutation",
19966
+ auth: "admin"
19967
+ }), method(object({
19968
+ deviceId: number(),
19969
+ source: DetectionSourceSchema,
19970
+ zones: array(ZoneSchema).readonly().optional(),
19971
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
19972
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
19973
+ frames: array(ReplayFrameInputSchema).min(1)
19974
+ }), RunReplayFrameProcessorResultSchema, {
19975
+ kind: "mutation",
19976
+ auth: "admin"
19977
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
19978
+ kind: "query",
19979
+ auth: "admin"
19980
+ }), method(object({
19981
+ deviceId: number(),
19982
+ trackId: string(),
19983
+ frameId: string(),
19984
+ annotations: array(RetrainAnnotationDraftSchema)
19985
+ }), array(RetrainAnnotationSchema).readonly(), {
19986
+ kind: "mutation",
19987
+ auth: "admin"
19988
+ }), method(object({
19989
+ deviceId: number(),
19990
+ trackId: string()
19991
+ }), RetrainTransitionResultSchema, {
19992
+ kind: "mutation",
19993
+ auth: "admin"
19994
+ }), method(object({
19995
+ deviceId: number(),
19996
+ trackId: string()
19997
+ }), RetrainTransitionResultSchema, {
19998
+ kind: "mutation",
19999
+ auth: "admin"
20000
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
20001
+ kind: "query",
20002
+ auth: "admin"
20003
+ }), method(object({
20004
+ eventId: string(),
20005
+ kind: MediaFileKindEnum.optional(),
20006
+ deviceId: number()
20007
+ }), array(MediaFileSchema).readonly()), method(object({
20008
+ trackId: string(),
20009
+ kinds: array(MediaFileKindEnum).optional(),
20010
+ deviceId: number()
20011
+ }), array(MediaFileSchema).readonly()), method(object({
20012
+ trackId: string(),
20013
+ deviceId: number()
20014
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
20015
+ kind: "mutation",
20016
+ auth: "admin"
20017
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
20018
+ kind: "mutation",
20019
+ auth: "admin"
20020
+ }), method(object({}), RebuildStatusSchema), object({
20021
+ deviceId: number(),
20022
+ timestamp: number(),
20023
+ frameWidth: number(),
20024
+ frameHeight: number(),
20025
+ detections: array(OverlayDetectionSchema).readonly()
20026
+ }), object({
20027
+ deviceId: number(),
20028
+ trackId: string(),
20029
+ className: string()
20030
+ }), object({
20031
+ deviceId: number(),
20032
+ trackId: string(),
20033
+ className: string(),
20034
+ durationMs: number()
20035
+ }), object({
20036
+ deviceId: number(),
20037
+ kind: EventKindSchema,
20038
+ eventId: string(),
20039
+ timestamp: number()
20040
+ });
19813
20041
  object({
19814
20042
  activeCameras: number(),
19815
20043
  throttledCameras: number(),
@@ -19835,66 +20063,6 @@ var CameraMetricsSchema = object({
19835
20063
  });
19836
20064
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
19837
20065
  /**
19838
- * Zone — pure geometry + identity. NO filtering behaviour.
19839
- *
19840
- * Zones describe **where** in the frame the operator wants to flag
19841
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
19842
- * each pipeline stage uses them. Splitting the two means a single
19843
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
19844
- * a detection-include rule on `['car']`, and an occupancy aggregate
19845
- * — without three duplicated polygons.
19846
- *
19847
- * Owned by the orchestrator addon (provider) and mirrored into the
19848
- * `zones` device-state slice on every mutation. Consumers
19849
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
19850
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
19851
- * mirror with `onChanged`).
19852
- *
19853
- * Coordinates are normalised fractions of the frame (0–1) so zones
19854
- * survive resolution changes and stream profile switches.
19855
- *
19856
- * `kind` discriminates between full polygons (closed regions used
19857
- * for intrusion / occupancy filters) and tripwires (open 2-point
19858
- * line segments used for cross events). Onboard / firmware-reported
19859
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
19860
- * task list.
19861
- */
19862
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
19863
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
19864
- var PolygonPointSchema = object({
19865
- x: number(),
19866
- y: number()
19867
- });
19868
- /** A camera detection zone — pure geometry/identity. */
19869
- var ZoneSchema = object({
19870
- id: string(),
19871
- name: string(),
19872
- kind: ZoneKindEnum.default("polygon"),
19873
- /** Polygon vertices, fraction of frame (0–1). */
19874
- polygon: array(PolygonPointSchema).readonly(),
19875
- /** Visual color for UI rendering. */
19876
- color: string().default("#3b82f6")
19877
- });
19878
- DeviceType.Camera, method(object({ deviceId: number() }), array(ZoneSchema).readonly()), method(object({
19879
- deviceId: number(),
19880
- zone: ZoneSchema
19881
- }), _void(), {
19882
- kind: "mutation",
19883
- auth: "admin"
19884
- }), method(object({
19885
- deviceId: number(),
19886
- zoneId: string()
19887
- }), _void(), {
19888
- kind: "mutation",
19889
- auth: "admin"
19890
- }), method(object({
19891
- deviceId: number(),
19892
- zone: ZoneSchema
19893
- }), _void(), {
19894
- kind: "mutation",
19895
- auth: "admin"
19896
- }), object({ zones: array(ZoneSchema).readonly() });
19897
- /**
19898
20066
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
19899
20067
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
19900
20068
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -27940,92 +28108,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), SceneMonitorStatusSche
27940
28108
  kind: "mutation",
27941
28109
  auth: "admin"
27942
28110
  });
27943
- /**
27944
- * Per-stage gating mode applied to the zones a rule references.
27945
- *
27946
- * - `include`: the rule contributes to a **whitelist** for its stage.
27947
- * When at least one `include` rule fires for a stage, only entities
27948
- * inside one of those zones pass that stage.
27949
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
27950
- * Entities inside one of those zones are dropped at that stage.
27951
- *
27952
- * `monitor`-style observation (count without filtering) is not a rule
27953
- * mode — zones without any matching rule are observed naturally by
27954
- * `zone-analytics` (live snapshot + history), so an "I just want to
27955
- * count, not filter" use case needs no rule at all.
27956
- */
27957
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
27958
- /**
27959
- * Per-consumer rule that references existing zones (geometry) and
27960
- * defines how a specific pipeline stage should treat them. Each
27961
- * consumer addon owns its own `ZoneRule[]` array in its per-device
27962
- * settings:
27963
- *
27964
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
27965
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
27966
- * - future: notification rules, audio gating, etc.
27967
- *
27968
- * One rule applies to N zones (`zoneIds[]`) so the operator can
27969
- * express "ignore motion in ALL of {garden, street}" with a single
27970
- * rule. `classFilter` narrows the rule to specific object classes —
27971
- * "drop person detections in the street, but keep cars" is one
27972
- * `exclude` rule with `classFilter: ['person']`.
27973
- *
27974
- * `enabled` is a soft toggle — the operator can keep the rule
27975
- * configured but inert without deleting it.
27976
- */
27977
- var ZoneRuleSchema = object({
27978
- /** Stable rule id — survives edits, used by the UI for diffing. */
27979
- id: string(),
27980
- /** Optional human-readable label rendered in the rule editor. */
27981
- name: string().optional(),
27982
- /** Zones this rule targets. The rule's `mode` applies to ALL
27983
- * listed zones (OR-set: a detection in any one of them counts).
27984
- * At least one zone id required — a rule with no targets is a
27985
- * configuration mistake and the form validator rejects it. */
27986
- zoneIds: array(string()).min(1).readonly(),
27987
- mode: ZoneRuleModeEnum,
27988
- /**
27989
- * Class names this rule applies to. Empty / undefined ⇒ rule
27990
- * applies to every class. Class strings match the `macroClass`
27991
- * field on detections (e.g. `person`, `car`, `dog`).
27992
- */
27993
- classFilter: array(string()).readonly().optional(),
27994
- /**
27995
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
27996
- * required to consider an entity "in the zone". Defaults to the
27997
- * consumer's stage default when omitted. Kept for back-compat with
27998
- * existing per-rule overrides; new operators pick the value via
27999
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
28000
- * set, the lower-level engine reads it as a 0–1 fraction.
28001
- */
28002
- overlapThreshold: number().min(0).max(1).optional(),
28003
- /**
28004
- * Operator-friendly version of `overlapThreshold` — the percentage
28005
- * of the detection's bbox that must lie inside the zone for the
28006
- * rule to match. Documented default is 85%; the engine substitutes
28007
- * that when the field is omitted (kept optional so existing rules
28008
- * stored without it stay valid).
28009
- *
28010
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
28011
- * rule, the engine prefers `bboxInclusionPct` because it's the
28012
- * field exposed in the UI. Internally both feed the same gate.
28013
- */
28014
- bboxInclusionPct: number().min(0).max(100).optional(),
28015
- /**
28016
- * When `true` and a detection has a segmentation mask, use the
28017
- * mask for overlap instead of the bbox. Detection-stage only;
28018
- * motion rules ignore this field.
28019
- */
28020
- preferMask: boolean().optional(),
28021
- /**
28022
- * Soft-toggle: `false` disables the rule without deleting it.
28023
- * Defaults to `true` so operators creating a rule via the UI
28024
- * see it active immediately.
28025
- */
28026
- enabled: boolean().default(true)
28027
- });
28028
- array(ZoneRuleSchema).readonly();
28029
28111
  object({
28030
28112
  /** Whether the script is currently executing. */
28031
28113
  isRunning: boolean(),
@@ -32353,6 +32435,12 @@ Object.freeze({
32353
32435
  addonId: null,
32354
32436
  access: "create"
32355
32437
  },
32438
+ "pipelineAnalytics.runReplayFrameProcessor": {
32439
+ capName: "pipeline-analytics",
32440
+ capScope: "device",
32441
+ addonId: null,
32442
+ access: "create"
32443
+ },
32356
32444
  "pipelineAnalytics.saveRetrainAnnotations": {
32357
32445
  capName: "pipeline-analytics",
32358
32446
  capScope: "device",
@@ -32485,6 +32573,12 @@ Object.freeze({
32485
32573
  addonId: null,
32486
32574
  access: "view"
32487
32575
  },
32576
+ "pipelineExecutor.getInferenceDeviceHealth": {
32577
+ capName: "pipeline-executor",
32578
+ capScope: "system",
32579
+ addonId: null,
32580
+ access: "view"
32581
+ },
32488
32582
  "pipelineExecutor.getOrchestratorConfigSchema": {
32489
32583
  capName: "pipeline-executor",
32490
32584
  capScope: "system",
@@ -32557,6 +32651,12 @@ Object.freeze({
32557
32651
  addonId: null,
32558
32652
  access: "view"
32559
32653
  },
32654
+ "pipelineExecutor.rearmInferenceDevice": {
32655
+ capName: "pipeline-executor",
32656
+ capScope: "system",
32657
+ addonId: null,
32658
+ access: "create"
32659
+ },
32560
32660
  "pipelineExecutor.runAudioTest": {
32561
32661
  capName: "pipeline-executor",
32562
32662
  capScope: "system",
@@ -35805,6 +35905,11 @@ Object.freeze({
35805
35905
  form: "single",
35806
35906
  optional: false
35807
35907
  }],
35908
+ "pipelineAnalytics.runReplayFrameProcessor": [{
35909
+ name: "deviceId",
35910
+ form: "single",
35911
+ optional: false
35912
+ }],
35808
35913
  "pipelineAnalytics.saveRetrainAnnotations": [{
35809
35914
  name: "deviceId",
35810
35915
  form: "single",