@camstack/addon-provider-homeassistant 1.2.42 → 1.2.43

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.
@@ -6581,6 +6581,65 @@ var ProfileRtspEntrySchema = object({
6581
6581
  resolution: CamStreamResolutionSchema.optional()
6582
6582
  });
6583
6583
  /**
6584
+ * Per-call node pinning for `ctx.api` capability calls.
6585
+ *
6586
+ * A capability call normally resolves to its DEFAULT provider — a `singleton`
6587
+ * cap resolves to the hub, a device-scoped cap to the device's owning node. To
6588
+ * query a SPECIFIC node's provider instead (e.g. a remote agent's own
6589
+ * in-process `platform-probe` hardware, which the hub cannot probe), pin the
6590
+ * call to that node.
6591
+ *
6592
+ * The nodeId rides OUT-OF-BAND in the tRPC call context (NOT in the validated
6593
+ * method args), so capability method signatures stay `nodeId`-free — node
6594
+ * targeting is a property of the CALL, not of the method. The transport lifts
6595
+ * it from `op.context` onto the `CapCallInput.nodeId` field (`ipcParentLink`),
6596
+ * and the hub parent's `onUnownedCall` passes it to the `CapRouteResolver`,
6597
+ * which classifies a pinned agent node as `agent-child-forward`
6598
+ * (`$agent-cap-fwd.forward` → the agent's in-process provider).
6599
+ *
6600
+ * Usage at a call site:
6601
+ *
6602
+ * await api.platformProbe.getCapabilities.query(undefined, nodePin(nodeId))
6603
+ */
6604
+ /** tRPC `op.context` key carrying a per-call node pin. */
6605
+ var CAP_NODE_PIN_CONTEXT_KEY = "__camstackNodePin";
6606
+ /**
6607
+ * Build the tRPC request options that pin a single capability call to `nodeId`.
6608
+ * Pass as the second argument to `.query(input, …)` / `.mutate(input, …)`.
6609
+ *
6610
+ * ## The id is normalised here, and it has to be
6611
+ *
6612
+ * A forked addon reads its own node from `ctx.kernel.localNodeId`, and inside a
6613
+ * worker that value is a RUNNER id — `hub/export-hap`, not `hub`. Routing
6614
+ * compares a pin against real node ids, so such a pin matches nothing and the
6615
+ * call fails with `no provider registered for cap "…"`. The local-first
6616
+ * resolver already guarded against this (`localNodeId.split('/')[0]`), which
6617
+ * made the hazard invisible: unpinned calls worked, and only an explicit pin —
6618
+ * the thing you reach for when you specifically need THIS node — silently
6619
+ * addressed a node that does not exist.
6620
+ *
6621
+ * Cost of it being missing: `addon-export-hap` pinned `decoder.getInfo` to its
6622
+ * own node to read the host's hardware-decode backend. It never once answered,
6623
+ * so every HomeKit egress transcode decoded in SOFTWARE — including 4K H.265 —
6624
+ * while D67's whole premise was that the decoder addon is the authority on
6625
+ * hardware. The warn said `decoding in SOFTWARE` and read as "this node has no
6626
+ * hardware", which was false.
6627
+ *
6628
+ * Normalising in the ONE constructor fixes every caller at once, which is why
6629
+ * it is here and not at the call sites.
6630
+ */
6631
+ function nodePin(nodeId) {
6632
+ return { context: { [CAP_NODE_PIN_CONTEXT_KEY]: toNodeId(nodeId) } };
6633
+ }
6634
+ /**
6635
+ * A runner id is `<nodeId>/<addonId>`; a node id has no slash. Taking the head
6636
+ * is idempotent, so passing an already-clean id costs nothing.
6637
+ */
6638
+ function toNodeId(idOrRunnerId) {
6639
+ const head = idOrRunnerId.split("/")[0];
6640
+ return head === void 0 || head.length === 0 ? idOrRunnerId : head;
6641
+ }
6642
+ /**
6584
6643
  * Output schema shared by the contribution + live methods.
6585
6644
  *
6586
6645
  * Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
@@ -7522,6 +7581,32 @@ var CameraSwitchIdSchema = _enum([
7522
7581
  "notifications"
7523
7582
  ]);
7524
7583
  /**
7584
+ * Stable render order — broadest blast radius first, and a source before the
7585
+ * thing that consumes it. `device-audio` sits ABOVE `audio-analysis` because
7586
+ * turning the microphone off leaves the analyzer with nothing to analyse; the
7587
+ * reverse is not true.
7588
+ *
7589
+ * `privacy-mask` sits directly ABOVE `device-audio` because they are literal
7590
+ * siblings — one cap, one device plane, video then audio — and NOT above
7591
+ * `object-detection` despite feeding it: a mask blanks REGIONS, so its blast
7592
+ * radius is partial, and the "broadest first" rule does not rank a partial
7593
+ * control above a whole-function one.
7594
+ *
7595
+ * `broker-audio` sits directly BELOW `device-audio` by the same source-first
7596
+ * rule: the camera's microphone feeds the broker, so silencing the camera
7597
+ * leaves the broker's mute with nothing to suppress; the reverse is not true.
7598
+ */
7599
+ var CAMERA_SWITCH_ORDER = [
7600
+ "stream-broker",
7601
+ "object-detection",
7602
+ "privacy-mask",
7603
+ "device-audio",
7604
+ "broker-audio",
7605
+ "audio-analysis",
7606
+ "recording",
7607
+ "notifications"
7608
+ ];
7609
+ /**
7525
7610
  * WHERE the switch's state actually lives. A discriminated union rather than a
7526
7611
  * string so both the writer (the orchestrator's `setCameraSwitch`) and any
7527
7612
  * reader can exhaustively narrow — and so "the group added a parallel map" is
@@ -16652,1760 +16737,1996 @@ var oauthIntegrationCapability = {
16652
16737
  getDescriptor: method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" }) }
16653
16738
  };
16654
16739
  /**
16655
- * pipeline-analytics device-scoped wrapper cap. Refines raw
16656
- * per-frame detections emitted by the pipeline runner into tracked
16657
- * objects, per-kind event collections (motion / object / audio), and
16658
- * persisted media. Owns the post-detection domain end-to-end:
16659
- *
16660
- * runner emits PipelineInferenceResult
16661
- * ↓ (event bus)
16662
- * pipeline-analytics subscriber
16663
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
16664
- * → three DB collections (one per kind), one FS media tree, one
16665
- * unified event emitter (FrameTracked + TrackStarted/Ended +
16666
- * DetectionEvent on bus)
16667
- *
16668
- * Pure subscriber model. No `processFrame` cap method — the runner
16669
- * already publishes the raw frame on the bus. The cap surface is
16670
- * only QUERIES + per-device settings, bound on/off via
16671
- * `device-manager.setWrapperActive`. `defaultActive: true` because
16672
- * every camera with a detection pipeline wants its raw detections
16673
- * refined; operators opt out per-device via BindingsTab when needed.
16674
- *
16675
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
16676
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
16740
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
16741
+ * within the frame, so the executor can re-cut a leaf child ROI at native
16742
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
16677
16743
  */
16678
- var TrackStateSchema = _enum([
16679
- "new",
16680
- "entered",
16681
- "left",
16682
- "moving",
16683
- "idle"
16684
- ]);
16685
- var EventKindSchema = _enum([
16686
- "motion",
16687
- "object",
16688
- "audio"
16689
- ]);
16744
+ var NativeCropRefSchema = object({
16745
+ /** Handle keying the retained native surface (node-pinned to its owner). */
16746
+ handle: FrameHandleSchema,
16747
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
16748
+ cropFrameSpace: object({
16749
+ x: number(),
16750
+ y: number(),
16751
+ w: number(),
16752
+ h: number()
16753
+ })
16754
+ });
16755
+ object({
16756
+ crop: object({
16757
+ left: number(),
16758
+ top: number(),
16759
+ width: number().positive(),
16760
+ height: number().positive()
16761
+ }).optional(),
16762
+ content: object({
16763
+ width: number().int().positive(),
16764
+ height: number().int().positive()
16765
+ }),
16766
+ fit: _enum(["stretch", "contain"]),
16767
+ format: _enum([
16768
+ "rgb",
16769
+ "gray",
16770
+ "jpeg"
16771
+ ])
16772
+ });
16690
16773
  /**
16691
- * Spatial filter for `listTracks` the rect + polygon variants of the shared
16692
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
16693
- * of the camera frame (top-left origin), matching the drawing-plane editor.
16774
+ * Process-local frame identity. It is serializable so it can ride an in-process
16775
+ * capability call, but `registryId` deliberately prevents resolution in any
16776
+ * other process or execution group.
16694
16777
  */
16695
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
16696
- /** Closed icon vocabulary so clients render a known glyph per kind. */
16697
- var EventKindIconSchema = _enum([
16698
- "motion",
16699
- "audio",
16700
- "person",
16701
- "vehicle",
16702
- "animal",
16703
- "door",
16704
- "pir",
16705
- "smoke",
16706
- "water",
16707
- "button",
16708
- "package",
16709
- "generic"
16778
+ var FrameRefSchema = object({
16779
+ registryId: string().min(1),
16780
+ id: string().min(1),
16781
+ width: number().int().positive(),
16782
+ height: number().int().positive(),
16783
+ format: _enum(["rgb", "gray"]),
16784
+ timestamp: number(),
16785
+ capturedAt: number().optional()
16786
+ });
16787
+ var ModelFormatSchema$1 = _enum([
16788
+ "onnx",
16789
+ "coreml",
16790
+ "openvino",
16791
+ "tflite",
16792
+ "pt",
16793
+ "gguf"
16710
16794
  ]);
16711
- var EventKindCategorySchema = _enum([
16712
- "motion",
16713
- "audio",
16714
- "detection",
16715
- "sensor",
16716
- "control",
16717
- "custom",
16718
- "package"
16795
+ var PipelineSlotSchema = _enum([
16796
+ "detector",
16797
+ "cropper",
16798
+ "classifier",
16799
+ "refiner",
16800
+ "audio-classifier"
16719
16801
  ]);
16720
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
16721
- var EventKindLevelSchema = _enum(["macro", "sub"]);
16722
- var EventKindDescriptorSchema = object({
16723
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
16724
- kind: string(),
16725
- /** i18n key resolved on the UI side; `label` is the English fallback. */
16726
- labelKey: string(),
16727
- /** English fallback label (kept for clients that don't translate). */
16728
- label: string(),
16729
- /** Hex color for timeline/legend rendering. */
16730
- color: string(),
16731
- /** Dictionary id → lucide component on the UI side. */
16732
- iconId: string(),
16733
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
16734
- icon: EventKindIconSchema,
16735
- category: EventKindCategorySchema,
16736
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
16737
- parentKind: string().nullable(),
16738
- /** Derived from `parentKind`, explicit for the client tree. */
16739
- level: EventKindLevelSchema,
16740
- /** Which cap + device contributes this kind. For built-ins the camera
16741
- * itself; for sensor kinds the LINKED source device. */
16742
- source: object({
16743
- capName: string(),
16744
- deviceId: number()
16745
- })
16802
+ var PipelineEngineChoiceSchema = object({
16803
+ runtime: _enum(["node", "python"]),
16804
+ backend: string(),
16805
+ format: ModelFormatSchema$1,
16806
+ device: string().optional()
16746
16807
  });
16747
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
16748
- var EventKindsForDeviceSchema = object({
16749
- deviceId: number(),
16750
- kinds: array(EventKindDescriptorSchema).readonly()
16808
+ var AvailableEngineSchema = object({
16809
+ engine: PipelineEngineChoiceSchema,
16810
+ devices: array(object({
16811
+ id: string(),
16812
+ label: string(),
16813
+ description: string().optional()
16814
+ })).readonly(),
16815
+ defaultDevice: string()
16751
16816
  });
16752
- var SensorEventSchema = object({
16817
+ var PipelineDefaultStepSchema = lazy(() => object({
16818
+ addonId: string(),
16819
+ addonName: string(),
16820
+ slot: PipelineSlotSchema,
16821
+ inputClasses: array(string()).readonly(),
16822
+ outputClasses: array(string()).readonly(),
16823
+ enabled: boolean(),
16824
+ modelId: string(),
16825
+ children: array(PipelineDefaultStepSchema).readonly(),
16826
+ group: string().optional(),
16827
+ settings: record(string(), unknown()).optional()
16828
+ }));
16829
+ var PipelineTemplateStepSchema = lazy(() => object({
16830
+ addonId: string(),
16831
+ enabled: boolean(),
16832
+ modelId: string(),
16833
+ children: array(PipelineTemplateStepSchema).readonly(),
16834
+ settings: record(string(), unknown()).optional()
16835
+ }));
16836
+ var PipelineTemplateSchema$1 = object({
16753
16837
  id: string(),
16754
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
16755
- * yields N rows, one per camera). */
16756
- deviceId: number(),
16757
- /** The linked sensor device whose state changed. */
16758
- sourceDeviceId: number(),
16759
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
16760
- kind: string(),
16761
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
16762
- value: record(string(), unknown()).nullable(),
16763
- timestamp: number()
16838
+ name: string(),
16839
+ createdAt: string(),
16840
+ updatedAt: string(),
16841
+ engine: PipelineEngineChoiceSchema,
16842
+ steps: array(PipelineTemplateStepSchema).readonly()
16764
16843
  });
16765
- var TrackPositionSchema = object({
16766
- x: number(),
16767
- y: number(),
16768
- timestamp: number(),
16769
- bbox: BoundingBoxSchema
16844
+ var PipelineModelOptionSchema = object({
16845
+ id: string(),
16846
+ name: string(),
16847
+ formats: record(string(), object({
16848
+ downloaded: boolean(),
16849
+ sizeMB: number()
16850
+ })),
16851
+ group: ModelVariantGroupSchema.optional(),
16852
+ legacy: boolean().optional(),
16853
+ provider: ModelProviderIdSchema.optional()
16770
16854
  });
16771
- var TrackSnapshotSchema = object({
16772
- timestamp: number(),
16773
- position: TrackPositionSchema,
16774
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
16775
- mediaKey: string()
16855
+ var ConfigFieldBridge = custom();
16856
+ var PipelineAddonSchemaSchema = object({
16857
+ id: string(),
16858
+ name: string(),
16859
+ slot: PipelineSlotSchema,
16860
+ inputClasses: array(string()).readonly(),
16861
+ outputClasses: array(string()).readonly(),
16862
+ childSlots: array(PipelineSlotSchema).readonly(),
16863
+ models: array(PipelineModelOptionSchema).readonly(),
16864
+ defaultModelId: string(),
16865
+ defaultModelIdByFormat: record(string(), string()).optional(),
16866
+ enabledByDefault: boolean().optional(),
16867
+ backfillIntoExistingOverrides: boolean().optional(),
16868
+ defaultConfidence: number(),
16869
+ group: string().optional(),
16870
+ configSchema: array(ConfigFieldBridge).readonly().optional()
16776
16871
  });
16777
- /**
16778
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
16779
- * divided by the track's detection-frame dims), computed at persist time.
16780
- * Absent when the frame dims were unknown when the track was persisted
16781
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
16782
- */
16783
- var TrackEnvelopeSchema = object({
16784
- minX: number(),
16785
- minY: number(),
16786
- maxX: number(),
16787
- maxY: number()
16788
- });
16789
- /**
16790
- * Row projection for track list queries. `full` (default) returns the
16791
- * complete Track including the frame-rate `positions[]` history and the
16792
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
16793
- * keeps every scalar the list surfaces actually render (ids, class(es),
16794
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
16795
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
16796
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
16797
- * `getTrack`. Mirrors the event-store `projection` convention
16798
- * (`getObjectEvents` et al.).
16799
- */
16800
- var TrackProjectionSchema = _enum(["full", "slim"]);
16801
- /**
16802
- * One audio-classification label heard on the track's camera while the
16803
- * track was alive, aggregated per label. An "episode" is one persisted
16804
- * audio event (the confident-classification path: score ≥ the device's
16805
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
16806
- * one 32 ms inference chunk, so counts stay human-scaled.
16807
- */
16808
- var TrackAudioLabelSchema = object({
16872
+ var PipelineSlotSchemaSchema = object({
16873
+ id: PipelineSlotSchema,
16809
16874
  label: string(),
16810
- /** Highest classification score observed across the label's episodes. */
16811
- peakScore: number(),
16812
- /** Number of coalesced audio-event episodes carrying this label. */
16813
- count: number(),
16814
- firstAt: number(),
16815
- lastAt: number()
16875
+ priority: number(),
16876
+ parentSlot: PipelineSlotSchema.nullable(),
16877
+ addons: array(PipelineAddonSchemaSchema).readonly()
16816
16878
  });
16817
- /**
16818
- * How a track was produced. `pipeline` (default / absent) = the spatial
16819
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
16820
- * no positions, a single snapshot, and no bbox trajectory at all:
16821
- *
16822
- * - `sensor` — a linked sensor/control device state change.
16823
- * - `audio` — an audio event on the camera itself that was anomalous for
16824
- * THAT camera, loud, and heard while nothing visual was happening (D62).
16825
- *
16826
- * The spatial subsystems (tracker association, occupancy count, re-id /
16827
- * embedding, resurrection) MUST skip every synthetic source. Test for that
16828
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
16829
- * check silently readmits every source added after it was written.
16830
- */
16831
- var TrackSourceSchema = _enum([
16832
- "pipeline",
16833
- "sensor",
16834
- "audio"
16835
- ]);
16836
- /**
16837
- * Where a track sits in the RETRAIN lifecycle (D81).
16838
- *
16839
- * - `none` — never marked, or un-marked. Evictable.
16840
- * - `staging` — the operator wants this track as training material and has not
16841
- * finished with it. **This is the only state retention holds**: the track and
16842
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
16843
- * the device's age window.
16844
- * - `trained` — the retrain page has taken what it needed. The frames it chose
16845
- * were COPIED into the retrain dataset at selection time, so the dataset no
16846
- * longer depends on the track's media and the track becomes EVICTABLE again.
16847
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
16848
- * a deliberate action of the retrain page, not a side effect of a checkbox.
16849
- *
16850
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
16851
- * the store's filter language has only positive equality and `whereIn` — no
16852
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
16853
- * would make the entire pre-column history immortal in one deploy.
16854
- */
16855
- var RetrainStatusSchema = _enum([
16856
- "none",
16857
- "staging",
16858
- "trained"
16859
- ]);
16860
- /**
16861
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
16862
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
16863
- * so the two surfaces cannot drift.
16864
- *
16865
- * **Absent ≠ false.** A track that has never been touched omits the field; an
16866
- * explicitly un-flagged track carries `false`. Legacy rows written before the
16867
- * columns existed read as absent, and a consumer that needs a boolean should say
16868
- * `flag === true`, not `flag !== false`.
16869
- *
16870
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
16871
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
16872
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
16873
- * `trained` track reports `false` while refusing both writes. The boolean is
16874
- * kept because three surfaces drive a toggle off it; anything that needs to tell
16875
- * "never marked" from "already trained" must read `retrainStatus`.
16876
- *
16877
- * `debug` does NOT pin; it is attention, not durability.
16878
- *
16879
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16880
- * A favourited track is skipped by retention the same way `staging` is, but
16881
- * it does not enter `none|staging|trained` and has no staging budget.
16882
- */
16883
- var TrackFlagFields = {
16884
- /** Operator marked this track as training material — i.e. `retrainStatus` is
16885
- * `'staging'`. */
16886
- markForTrain: boolean().optional(),
16887
- /** Operator marked this track for diagnostic attention. */
16888
- debug: boolean().optional(),
16889
- /** Operator favourited this track. Pins it against pruning. */
16890
- favourited: boolean().optional()
16891
- };
16892
- /**
16893
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
16894
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
16895
- * write patch, and the status is not something the toggle sets — it is what the
16896
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
16897
- * always present on a persisted row (the column default materialises `'none'`).
16898
- */
16899
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
16900
- /**
16901
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
16902
- * one flag can never clear the other — the toggles are independent and are
16903
- * driven from three surfaces that do not know about each other.
16904
- */
16905
- var TrackFlagsPatchSchema = object(TrackFlagFields);
16906
- /**
16907
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
16908
- * collapses to `false`) so a caller can drive a toggle's checked state off the
16909
- * mutation result without a re-fetch.
16910
- */
16911
- var TrackFlagsSchema = object({
16912
- trackId: string(),
16913
- markForTrain: boolean(),
16914
- debug: boolean(),
16915
- favourited: boolean(),
16916
- /** The lifecycle state the boolean was derived from. Required here (unlike on
16917
- * a track row) because this shape is only ever produced by the write body,
16918
- * which always knows it — and a surface that has just written needs to render
16919
- * `trained` without a re-fetch. */
16920
- retrainStatus: RetrainStatusSchema
16879
+ var PipelineSchemaSchema = object({
16880
+ availableEngines: array(AvailableEngineSchema).readonly(),
16881
+ selectedEngine: PipelineEngineChoiceSchema,
16882
+ slots: array(PipelineSlotSchemaSchema).readonly()
16921
16883
  });
16922
- union([literal(1), literal(2)]);
16923
- /**
16924
- * WHO decided a label, and when. Carried per tier so a value can be traced to
16925
- * the step and model that produced it — which is what makes the write rule
16926
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
16927
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
16928
- *
16929
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
16930
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
16931
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
16932
- * that value has no provenance, and the write rule lets ANY properly-attributed
16933
- * write of the same tier replace it regardless of score.
16934
- */
16935
- var LabelAttributionSchema = object({
16936
- stepId: string(),
16937
- modelId: string().optional(),
16938
- decidedAt: number(),
16884
+ var EngineProvisioningSchema = object({
16885
+ runtimeId: _enum([
16886
+ "onnx",
16887
+ "openvino",
16888
+ "coreml",
16889
+ "edgetpu"
16890
+ ]).nullable(),
16891
+ device: string().nullable(),
16892
+ state: _enum([
16893
+ "idle",
16894
+ "installing",
16895
+ "verifying",
16896
+ "ready",
16897
+ "failed"
16898
+ ]),
16899
+ progress: number().optional(),
16900
+ error: string().optional(),
16901
+ nextRetryAt: number().optional(),
16939
16902
  /**
16940
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
16941
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
16942
- *
16943
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
16944
- * notification rule authored on "Gianluca" stopped matching the moment the
16945
- * operator fixed the spelling in the gallery, and nothing said so. The id is
16946
- * the thing that does not move, so it is what a rule matches on
16947
- * (`NcConditions.identities`) and the text is what a human is shown.
16948
- *
16949
- * Absent when the label names no gallery row — a plate the OCR read but no
16950
- * vehicle claims, a sub-class, a species, any tier-1 value.
16903
+ * Gate A (config-correctness gate at engine change): human-readable
16904
+ * config issues surfaced EAGERLY when the node's engine changes — model
16905
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
16906
+ * has a <format> build"). Additive/optional: informational only, never
16907
+ * enforced here `assertEngineReady` (readiness) still gates inference.
16908
+ * Absent/empty when the node-default tree resolves cleanly.
16951
16909
  */
16952
- identityId: string().optional()
16910
+ configIssues: array(string()).optional()
16953
16911
  });
16954
- /**
16955
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
16956
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
16957
- * track and its events always answer the same question the same way.
16958
- *
16959
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
16960
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
16961
- * is tier 2, and each carries its own score + attribution.
16962
- *
16963
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
16964
- * finest thing known. Before 4g the single `label` column held the finest
16965
- * value, so a consumer that has not been updated reads the tier-1 slot and
16966
- * shows nothing on a species-only row; that is why the migration puts every
16967
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
16968
- * and why the read surfaces were changed in the same train.
16969
- *
16970
- * **Writing it.** The slots are independent, which is the whole point: a
16971
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
16972
- * migratorius`), so fineness cannot regress by construction. Within a tier the
16973
- * higher score wins. One rule, one implementation — see
16974
- * `pipeline/label-tier.ts` in addon-post-analysis.
16975
- */
16976
- var TieredLabelFields = {
16977
- /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
16978
- label: string().optional(),
16979
- /** Confidence of the tier-1 value, as reported by the deciding step. */
16980
- labelScore: number().optional(),
16981
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
16982
- labelMeta: LabelAttributionSchema.optional(),
16983
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
16984
- subLabel: string().optional(),
16985
- /** Confidence of the tier-2 value, as reported by the deciding step. */
16986
- subLabelScore: number().optional(),
16987
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
16988
- subLabelMeta: LabelAttributionSchema.optional()
16989
- };
16990
- /** Per-camera slice of a training-export estimate. */
16991
- var TrainingExportDeviceTotalsSchema = object({
16992
- deviceId: number(),
16993
- tracks: number().int(),
16994
- files: number().int(),
16995
- bytes: number().int()
16912
+ var PipelineStepInputSchema = lazy(() => object({
16913
+ addonId: string(),
16914
+ modelId: string().optional(),
16915
+ enabled: boolean().default(true),
16916
+ children: array(PipelineStepInputSchema).optional(),
16917
+ settings: record(string(), unknown()).optional(),
16918
+ jumpDeviceKey: string().optional()
16919
+ }));
16920
+ var ModelSubstitutionSchema = object({
16921
+ addonId: string(),
16922
+ chosen: string(),
16923
+ running: string(),
16924
+ format: string()
16996
16925
  });
16997
- /**
16998
- * What a training export WOULD contain. Computed from media index rows only —
16999
- * no blob is read to produce this.
16926
+ var PipelineValidationIssueSchema = object({
16927
+ addonId: string(),
16928
+ kind: _enum(["unknown-addon", "no-format-build"]),
16929
+ detail: string()
16930
+ });
16931
+ var PipelineValidationResultSchema = object({
16932
+ ok: boolean(),
16933
+ issues: array(PipelineValidationIssueSchema).readonly(),
16934
+ substitutions: array(ModelSubstitutionSchema).readonly(),
16935
+ /** The node's `currentEngine.format` this validation ran against. */
16936
+ format: string()
16937
+ });
16938
+ var ReferenceImageEntrySchema = object({
16939
+ filename: string(),
16940
+ stepIds: array(string()).readonly().optional()
16941
+ });
16942
+ var ReferenceImageBodySchema = object({
16943
+ base64: string(),
16944
+ filename: string()
16945
+ });
16946
+ var ReferenceAudioEntrySchema = object({
16947
+ filename: string(),
16948
+ sizeKb: number()
16949
+ });
16950
+ var ReferenceAudioBodySchema = object({ base64: string() });
16951
+ var AudioBackendSchema = object({
16952
+ id: string(),
16953
+ name: string(),
16954
+ description: string(),
16955
+ available: boolean(),
16956
+ /**
16957
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
16958
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
16959
+ * the benchmark UI to populate the `enabledMicroClasses` filter
16960
+ * specific to the selected backend without a separate fetch.
16961
+ */
16962
+ rawLabels: array(string()).readonly().optional()
16963
+ });
16964
+ var AudioCapabilitiesSchema = object({
16965
+ activeBackend: string(),
16966
+ availableBackends: array(AudioBackendSchema).readonly(),
16967
+ sampleRate: number(),
16968
+ chunkDurationMs: number()
16969
+ });
16970
+ var DownloadModelResultSchema = object({
16971
+ filePath: string(),
16972
+ sizeMB: number(),
16973
+ durationMs: number()
16974
+ });
16975
+ /**
16976
+ * Wrapper carrying a single test run's result. Replaces the legacy
16977
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
16978
+ * canonical `AudioResult` from the Phase 6 output rework: one
16979
+ * `AudioDetection` per class above `minScore`, top-N candidates in
16980
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
16981
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
16982
+ * benchmark UI can still report a clean failure when the classifier
16983
+ * cap isn't available.
17000
16984
  */
17001
- var TrainingExportSummarySchema = object({
17002
- generatedAt: number(),
17003
- trackCount: number().int(),
17004
- fileCount: number().int(),
17005
- byteCount: number().int(),
17006
- /** More marked tracks exist than a single pass carries. */
17007
- truncated: boolean(),
17008
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
16985
+ var AudioTestResultSchema = object({
16986
+ success: boolean(),
16987
+ error: string().optional(),
16988
+ frame: custom().optional()
17009
16989
  });
17010
- var TrackSchema = object({
17011
- trackId: string(),
17012
- deviceId: number(),
17013
- className: string(),
17014
- ...TieredLabelFields,
17015
- producingDeviceName: string().optional(),
17016
- /** Track provenance. Absent `pipeline` (legacy rows). */
17017
- source: TrackSourceSchema.optional(),
17018
- firstSeen: number(),
17019
- lastSeen: number(),
17020
- /** Frame-rate position history (subject to maxPositionHistory cap). */
17021
- positions: array(TrackPositionSchema).readonly(),
17022
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17023
- * saveThumbnails policy). */
17024
- snapshots: array(TrackSnapshotSchema).readonly(),
17025
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
17026
- zonesVisited: array(string()).readonly(),
16990
+ var PipelineConfigBridge = custom();
16991
+ var ConfigUISchemaBridge = custom();
16992
+ var ConfigUISchemaNullableBridge = custom();
16993
+ var InferenceCapabilitiesBridge = custom();
16994
+ var ModelAvailabilityListBridge = custom();
16995
+ var PipelineRunResultBridge = custom();
16996
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
16997
+ modelId: string(),
16998
+ settings: record(string(), unknown()).readonly()
16999
+ }))), method(object({ steps: record(string(), object({
17000
+ modelId: string(),
17001
+ settings: record(string(), unknown()).readonly()
17002
+ })) }), object({ success: literal(true) }), {
17003
+ kind: "mutation",
17004
+ auth: "admin"
17005
+ }), method(object({ nodeId: string() }), object({
17006
+ success: literal(true),
17007
+ clearedDevices: number()
17008
+ }), {
17009
+ kind: "mutation",
17010
+ auth: "admin"
17011
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
17012
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
17013
+ deviceKey: string(),
17027
17014
  /**
17028
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17029
- * `zones` capability.
17030
- *
17031
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17032
- * and no card can render — so every free-text search surface was structurally
17033
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17034
- * just returned nothing. Resolving here rather than in each client keeps ONE
17035
- * derivation and costs the clients no extra call (the `zones` cap is
17036
- * per-device, so a client-side resolve would be a per-camera fan-out on a
17037
- * surface built to avoid exactly that).
17038
- *
17039
- * Resolved, never invented: a zone deleted since the track was written has no
17040
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17041
- * two are not positionally aligned. Absent when the track visited no zone, or
17042
- * when the zone catalogue could not be read.
17015
+ * `failed` the per-device restart budget is exhausted; no pool
17016
+ * will be spawned until an operator re-arms it or the runner
17017
+ * respawns. `backoff` — under budget, waiting out the backoff (or
17018
+ * a cached pool observed dead and not yet condemned).
17043
17019
  */
17044
- zoneNames: array(string()).readonly().optional(),
17045
- /** Deduplicated set of detector classes observed for this track over its
17046
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
17047
- * legacy rows written before class accumulation shipped. */
17048
- classes: array(string()).readonly().optional(),
17049
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17050
- totalDistance: number(),
17051
- state: TrackStateSchema,
17052
- active: boolean(),
17053
- /** Deterministic key-event importance score in [0,1] (server-computed at
17054
- * track expiry, recomputed on late label). Absent on legacy rows written
17055
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
17056
- importance: number().optional(),
17057
- /** Id of the track's highest-confidence ObjectEvent (its representative
17058
- * "best" frame). Absent when the track produced no object events. */
17059
- bestEventId: string().optional(),
17060
- /** Tag of the importance sub-signal that dominated the score
17061
- * (identity|dwell|proximity|class|confidence|travel|zone). */
17062
- importanceReason: string().optional(),
17063
- /** Audio-classification labels heard on the camera during the track's
17064
- * life (score ≥ device `classificationMinScore`), aggregated per label.
17065
- * Absent on legacy rows / tracks with no confident audio. */
17066
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17067
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17068
- * Populated from the persisted envelope columns on historical reads;
17069
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17070
- envelope: TrackEnvelopeSchema.optional(),
17020
+ state: _enum(["failed", "backoff"]),
17021
+ /** Epoch ms of the death that produced this state. */
17022
+ since: number(),
17023
+ /** Pool deaths inside the current window. */
17024
+ deaths: number(),
17025
+ /** The last death's message. */
17026
+ lastError: string()
17027
+ })).readonly() })), method(object({
17028
+ nodeId: string(),
17029
+ deviceKey: string()
17030
+ }), object({ rearmed: boolean() }), {
17031
+ kind: "mutation",
17032
+ auth: "admin"
17033
+ }), method(_void(), PipelineSchemaSchema), method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()), method(_void(), PipelineConfigBridge), method(_void(), ConfigUISchemaBridge), method(object({ steps: array(PipelineStepInputSchema) }), PipelineValidationResultSchema), method(_void(), array(PipelineTemplateSchema$1).readonly()), method(object({
17034
+ name: string(),
17035
+ steps: array(PipelineTemplateStepSchema).readonly(),
17036
+ engine: PipelineEngineChoiceSchema
17037
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
17038
+ id: string(),
17039
+ name: string().optional(),
17040
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
17041
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
17042
+ addonId: string(),
17043
+ modelId: string(),
17044
+ format: ModelFormatSchema$1
17045
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
17046
+ addonId: string(),
17047
+ modelId: string(),
17048
+ format: ModelFormatSchema$1
17049
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
17050
+ engine: PipelineEngineChoiceSchema.optional(),
17051
+ steps: array(PipelineStepInputSchema).min(1),
17052
+ frame: FrameInputSchema.optional(),
17071
17053
  /**
17072
- * A face DETECTOR found a face on this track — nothing more. It says the
17073
- * detail plane produced a `face` detail; it does NOT say the face was
17074
- * embedded, matched, above `minFacePx`, or that the recognizer was even
17075
- * enabled. Set once and never cleared.
17076
- *
17077
- * **This exists so "face present but not recognised" is expressible.** A
17078
- * recognised identity lands in `subLabel` (attributed to the face chain via
17079
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17080
- * and a track with no face at all were byte-identical on the wire and no
17081
- * surface could tell them apart. The read is `hasFace === true && subLabel
17082
- * === undefined`.
17083
- *
17084
- * **Absent ≠ false.** Every row written before the column existed omits it,
17085
- * and so does every server that predates the field — a consumer must test
17086
- * `=== true` and render nothing otherwise, never infer "no face".
17054
+ * Process-local lazy frame. Valid only when caller and provider resolve
17055
+ * in the same execution-group process; split/cross-node callers use
17056
+ * `frame`/`image` inline compatibility instead.
17087
17057
  */
17088
- hasFace: boolean().optional(),
17058
+ frameRef: FrameRefSchema.optional(),
17089
17059
  /**
17090
- * This track has a face row IN THE GALLERY: a crop **and** an embedding a
17091
- * face an operator could ASSIGN to an identity.
17092
- *
17093
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17094
- * because the two disagree. `hasFace` is stamped at the TOP of the face
17095
- * branch, before every gate, and means no more than "a face detector produced
17096
- * a face detail". This one is stamped at the single moment the gallery row
17097
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17098
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17099
- * candidate gate, the imageless-track drop (no crop was ever captured) and
17100
- * the crop-store drop. Everything between the detector and that insert can
17101
- * legitimately refuse the face, so a flag written any earlier promises the
17102
- * operator something to assign and delivers nothing.
17103
- *
17104
- * **Independent of recognition.** A face collected but never auto-matched is
17105
- * still assignable — it is in fact the face an operator most wants to reach —
17106
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17107
- * `subLabel`; this says only that the raw material exists.
17108
- *
17109
- * **Set once, never cleared.** A track that produced a gallery row produced
17110
- * one; deleting the row later is the gallery's business, not this flag's.
17111
- *
17112
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17113
- * before the column omits it, and so does every server that predates the
17114
- * field. A consumer must test `=== true` and render nothing otherwise —
17115
- * never infer "no assignable face".
17060
+ * CB5 shm passthrough a `FrameHandle` naming the same ring slot
17061
+ * the decoded pixels live in. One more member of the one-of
17062
+ * frame/frameHandle/image/imageBase64/referenceImage group.
17116
17063
  */
17117
- hasEmbeddedFace: boolean().optional(),
17064
+ frameHandle: FrameHandleSchema.optional(),
17065
+ imageBase64: string().optional(),
17118
17066
  /**
17119
- * This subject CONTAINS a folded rider a person the rider-pairing step
17120
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17121
- * so the passage is tracked once and as a VEHICLE.
17122
- *
17123
- * It exists because the fold's record was dishonest. D34 and the code both
17124
- * said "the person is not lost — it is reported so both entities stay on the
17125
- * record"; in fact the pair went into a per-processor RAM field behind an
17126
- * accessor nobody called, and every durable surface said `vehicle`, full
17127
- * stop. This is the composition note that makes the row true.
17128
- *
17129
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
17130
- * person" is not an answer to "what is this" — both label tiers would refuse
17131
- * a macro token anyway (D89), and correctly. Nothing here changes what the
17132
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17133
- * and a `person` rule still does not fire for someone cycling past.
17134
- *
17135
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17136
- * the column, and every hub that predates the field, omits it. Test
17137
- * `=== true` and render nothing otherwise — never infer "no rider".
17067
+ * Binary JPEG bytespreferred over `imageBase64` on internal
17068
+ * hops (hub forked worker via Moleculer MsgPack) because it
17069
+ * skips the 33% base64 overhead + the per-call base64 decode on
17070
+ * the detection-pipeline worker. Callers can pass either; exactly
17071
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
17138
17072
  */
17139
- hasRider: boolean().optional(),
17140
- ...TrackFlagFields,
17141
- ...TrackRetrainFields
17142
- });
17143
- var BaseEventFields = {
17144
- id: string(),
17145
- deviceId: number(),
17146
- timestamp: number()
17147
- };
17148
- var MotionEventSchema = object({
17149
- ...BaseEventFields,
17150
- kind: literal("motion"),
17151
- regionCount: number(),
17152
- /** Heavy JSON array omitted in slim projection. */
17153
- regions: array(object({
17154
- bbox: BoundingBoxSchema,
17155
- pixelCount: number(),
17156
- intensity: number()
17157
- })).readonly().optional(),
17158
- /** Omitted in slim projection. */
17159
- frameWidth: number().optional(),
17160
- /** Omitted in slim projection. */
17161
- frameHeight: number().optional(),
17162
- /** Populated by B5 (recording playback URL for this event). */
17163
- mediaUrl: string().optional()
17164
- });
17073
+ image: _instanceof(Uint8Array).optional(),
17074
+ referenceImage: string().optional(),
17075
+ deviceId: number().optional(),
17076
+ sessionId: string().optional(),
17077
+ /**
17078
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
17079
+ * reference-image, and detail-subtree calls. 'frame' is the live
17080
+ * per-frame dispatch: ONLY root-plane steps run; crop children
17081
+ * (inputClasses ≠ null) are skipped and served per-track via
17082
+ * pipelineRunner.runDetailSubtree (two-plane design).
17083
+ */
17084
+ plane: _enum(["full", "frame"]).optional(),
17085
+ /**
17086
+ * Inference-device selector (Phase 2 multi-device). Format
17087
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
17088
+ * Omitted ⇒ the runner's default device (current single-engine
17089
+ * behaviour). Selects WHICH device pool of the node runs the call.
17090
+ */
17091
+ deviceKey: string().optional(),
17092
+ /**
17093
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
17094
+ * when the parent crop was resolved from the frame's retained NATIVE
17095
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
17096
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
17097
+ * resolution from that surface — the SAME quality path faces already
17098
+ * had — instead of the downscaled parent tile. `handle` keys the native
17099
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
17100
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
17101
+ * the executor's crop-normalized child ROI back into frame-normalized
17102
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
17103
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
17104
+ * (today's behaviour on the fallback path).
17105
+ */
17106
+ nativeCropRef: NativeCropRefSchema.optional()
17107
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
17108
+ engine: PipelineEngineChoiceSchema.optional(),
17109
+ steps: array(PipelineStepInputSchema).min(1),
17110
+ frames: array(FrameInputSchema).min(1).max(255),
17111
+ deviceId: number().optional(),
17112
+ sessionId: string().optional(),
17113
+ /**
17114
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
17115
+ * the batch to the Python pool's bench preprocess cache
17116
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
17117
+ * preprocessed ONCE and every later inference is a pure-inference cache
17118
+ * hit — the sustained-throughput run measures inference, not
17119
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
17120
+ * full preprocess every call, correct). Fresh per sustained run;
17121
+ * released via `uncacheFrame`.
17122
+ */
17123
+ frameId: number().int().nonnegative().optional(),
17124
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
17125
+ deviceKey: string().optional()
17126
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
17127
+ data: _instanceof(Uint8Array),
17128
+ width: number().int().positive(),
17129
+ height: number().int().positive(),
17130
+ format: _enum([
17131
+ "rgb",
17132
+ "bgr",
17133
+ "gray"
17134
+ ])
17135
+ }), object({
17136
+ frameId: number(),
17137
+ width: number(),
17138
+ height: number()
17139
+ }), { kind: "mutation" }), method(object({
17140
+ stepId: string(),
17141
+ frameId: number().int()
17142
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
17143
+ batchMode: string(),
17144
+ windowMs: number(),
17145
+ maxBatchSize: number(),
17146
+ concurrency: number()
17147
+ })), method(_void(), array(object({
17148
+ engineKey: string(),
17149
+ engine: PipelineEngineChoiceSchema,
17150
+ modelsLoaded: array(string()).readonly(),
17151
+ inUseByCameras: array(number()).readonly(),
17152
+ /**
17153
+ * Origin of this resident factory.
17154
+ * - `runtime` — main camera-serving engine (no idle TTL).
17155
+ * - `warm-override` — benchmark/test override held in the warm
17156
+ * cache; auto-disposed after the idle TTL.
17157
+ * - `device-pool` — a concurrent per-device pool (Phase 2
17158
+ * multi-device, keyed by `deviceKey`) resolved
17159
+ * via `resolveDeviceFactory`. Runs alongside the
17160
+ * `runtime` engine on a DIFFERENT accelerator
17161
+ * (NPU / iGPU / Coral) — this is how the
17162
+ * Engines tab shows all pools running at once.
17163
+ */
17164
+ kind: _enum([
17165
+ "runtime",
17166
+ "warm-override",
17167
+ "device-pool"
17168
+ ]),
17169
+ /** Native pid of the underlying Python pool (null when no pool). */
17170
+ poolPid: number().nullable(),
17171
+ /** ms since this factory was last used (null when not warm-tracked). */
17172
+ idleMs: number().nullable(),
17173
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
17174
+ idleTtlMs: number().nullable()
17175
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
17176
+ kind: "mutation",
17177
+ auth: "admin"
17178
+ }), method(object({
17179
+ engine: PipelineEngineChoiceSchema,
17180
+ force: boolean().optional()
17181
+ }), object({
17182
+ success: boolean(),
17183
+ reason: string().optional()
17184
+ }), {
17185
+ kind: "mutation",
17186
+ auth: "admin"
17187
+ }), method(_void(), array(ReferenceImageEntrySchema).readonly()), method(object({ filename: string() }), ReferenceImageBodySchema.nullable()), method(_void(), array(ReferenceAudioEntrySchema).readonly()), method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()), method(_void(), AudioCapabilitiesSchema), method(object({
17188
+ addonId: string(),
17189
+ modelId: string(),
17190
+ filename: string().optional(),
17191
+ settings: record(string(), unknown()).optional()
17192
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
17165
17193
  /**
17166
- * Which detection SOURCE produced an object event. `pipeline` = the ML
17167
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
17168
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
17169
- * tracking, per-kind persistence) but stay distinguishable so consumers
17170
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17171
- * Absent on legacy rows treat as `pipeline`.
17194
+ * Per-stage gating mode applied to the zones a rule references.
17195
+ *
17196
+ * - `include`: the rule contributes to a **whitelist** for its stage.
17197
+ * When at least one `include` rule fires for a stage, only entities
17198
+ * inside one of those zones pass that stage.
17199
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
17200
+ * Entities inside one of those zones are dropped at that stage.
17201
+ *
17202
+ * `monitor`-style observation (count without filtering) is not a rule
17203
+ * mode — zones without any matching rule are observed naturally by
17204
+ * `zone-analytics` (live snapshot + history), so an "I just want to
17205
+ * count, not filter" use case needs no rule at all.
17172
17206
  */
17173
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17207
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
17174
17208
  /**
17175
- * The confirmed zone crossing that produced an object event. Present ONLY on
17176
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17177
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17178
- * appearance event carry none, so a rule asking for a direction fails closed
17179
- * on them.
17209
+ * Per-consumer rule that references existing zones (geometry) and
17210
+ * defines how a specific pipeline stage should treat them. Each
17211
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
17212
+ * settings:
17180
17213
  *
17181
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17182
- * into its own event, so a frame in which a track enters A while leaving B
17183
- * produces two events with two directions — never one ambiguous row.
17214
+ * - `addon-motion-wasm` `motionZoneRules: ZoneRule[]` (motion stage)
17215
+ * - `addon-detection-pipeline` `detectionZoneRules: ZoneRule[]` (detection stage)
17216
+ * - future: notification rules, audio gating, etc.
17184
17217
  *
17185
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17186
- * membership the box has NOW, and by definition it no longer contains the zone
17187
- * that was just left. Without the id here, a zone-scoped rule could never match
17188
- * the exit it asked for.
17218
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
17219
+ * express "ignore motion in ALL of {garden, street}" with a single
17220
+ * rule. `classFilter` narrows the rule to specific object classes
17221
+ * "drop person detections in the street, but keep cars" is one
17222
+ * `exclude` rule with `classFilter: ['person']`.
17223
+ *
17224
+ * `enabled` is a soft toggle — the operator can keep the rule
17225
+ * configured but inert without deleting it.
17189
17226
  */
17190
- var ZoneCrossingSchema = object({
17191
- direction: _enum(["enter", "exit"]),
17192
- /** Admin zone id crossed. */
17193
- zoneId: string(),
17194
- /** Zone display name at crossing time (falls back to the id). */
17195
- zoneName: string().optional()
17196
- });
17197
- var ObjectEventSchema = object({
17198
- ...BaseEventFields,
17199
- kind: literal("object"),
17200
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17201
- source: DetectionSourceSchema.optional(),
17227
+ var ZoneRuleSchema = object({
17228
+ /** Stable rule id — survives edits, used by the UI for diffing. */
17229
+ id: string(),
17230
+ /** Optional human-readable label rendered in the rule editor. */
17231
+ name: string().optional(),
17232
+ /** Zones this rule targets. The rule's `mode` applies to ALL
17233
+ * listed zones (OR-set: a detection in any one of them counts).
17234
+ * At least one zone id required — a rule with no targets is a
17235
+ * configuration mistake and the form validator rejects it. */
17236
+ zoneIds: array(string()).min(1).readonly(),
17237
+ mode: ZoneRuleModeEnum,
17202
17238
  /**
17203
- * Inference-frame id shared by every object event emitted from the SAME frame
17204
- * the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17205
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
17206
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
17207
- * Optional for backward-compat with pre-existing rows / the slim projection
17208
- * includes it (it is light). Absent on rows written before this field.
17239
+ * Class names this rule applies to. Empty / undefined rule
17240
+ * applies to every class. Class strings match the `macroClass`
17241
+ * field on detections (e.g. `person`, `car`, `dog`).
17209
17242
  */
17210
- frameId: string().optional(),
17211
- /** Omitted in slim projection. */
17212
- trackId: string().optional(),
17213
- className: string(),
17214
- ...TieredLabelFields,
17215
- /** Omitted in slim projection. */
17216
- confidence: number().optional(),
17217
- /** Heavy JSON — omitted in slim projection. */
17218
- bbox: BoundingBoxSchema.optional(),
17219
- /** Heavy JSON — omitted in slim projection. */
17220
- zones: array(string()).readonly().optional(),
17221
- /** Omitted in slim projection. */
17222
- state: TrackStateSchema.optional(),
17243
+ classFilter: array(string()).readonly().optional(),
17223
17244
  /**
17224
- * The zone crossing this event IS, when it is one. Absent on every other
17225
- * event kind (movement state, appearance, package) see
17226
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
17245
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
17246
+ * required to consider an entity "in the zone". Defaults to the
17247
+ * consumer's stage default when omitted. Kept for back-compat with
17248
+ * existing per-rule overrides; new operators pick the value via
17249
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
17250
+ * set, the lower-level engine reads it as a 0–1 fraction.
17227
17251
  */
17228
- zoneCrossing: ZoneCrossingSchema.optional(),
17229
- /** Detection-frame dimensions in pixels — let consumers normalize the
17230
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17231
- frameWidth: number().optional(),
17232
- frameHeight: number().optional(),
17233
- /** MediaStore key for the crop attached to this event (if any). */
17234
- mediaKey: string().optional(),
17235
- /** Design B: MediaStore key of the track's native-resolution key frame (the
17236
- * best-detection full frame). Resolve via the event-media data-plane
17237
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17238
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17239
- * sources — consumers fall back to `mediaKey` (the tight crop). */
17240
- keyFrameMediaKey: string().optional(),
17241
- /** Populated by B5 (recording playback URL for this event). */
17242
- mediaUrl: string().optional(),
17243
- /** The parent track's key-event importance [0,1], propagated to every object
17244
- * event of the track (so an event row can be sorted by importance without a
17245
- * track join). Absent on legacy rows / before the track was scored. */
17246
- importance: number().optional()
17252
+ overlapThreshold: number().min(0).max(1).optional(),
17253
+ /**
17254
+ * Operator-friendly version of `overlapThreshold` the percentage
17255
+ * of the detection's bbox that must lie inside the zone for the
17256
+ * rule to match. Documented default is 85%; the engine substitutes
17257
+ * that when the field is omitted (kept optional so existing rules
17258
+ * stored without it stay valid).
17259
+ *
17260
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
17261
+ * rule, the engine prefers `bboxInclusionPct` because it's the
17262
+ * field exposed in the UI. Internally both feed the same gate.
17263
+ */
17264
+ bboxInclusionPct: number().min(0).max(100).optional(),
17265
+ /**
17266
+ * When `true` and a detection has a segmentation mask, use the
17267
+ * mask for overlap instead of the bbox. Detection-stage only;
17268
+ * motion rules ignore this field.
17269
+ */
17270
+ preferMask: boolean().optional(),
17271
+ /**
17272
+ * Soft-toggle: `false` disables the rule without deleting it.
17273
+ * Defaults to `true` so operators creating a rule via the UI
17274
+ * see it active immediately.
17275
+ */
17276
+ enabled: boolean().default(true)
17247
17277
  });
17248
- var AudioEventSchema = object({
17249
- ...BaseEventFields,
17250
- kind: literal("audio"),
17251
- rms: number(),
17252
- dbfs: number(),
17253
- classification: object({
17254
- className: string(),
17255
- originalClass: string().optional(),
17256
- score: number()
17257
- }).optional(),
17258
- /** Populated by B5 (recording playback URL for this event). */
17259
- mediaUrl: string().optional()
17278
+ array(ZoneRuleSchema).readonly();
17279
+ /**
17280
+ * Zone — pure geometry + identity. NO filtering behaviour.
17281
+ *
17282
+ * Zones describe **where** in the frame the operator wants to flag
17283
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
17284
+ * each pipeline stage uses them. Splitting the two means a single
17285
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
17286
+ * a detection-include rule on `['car']`, and an occupancy aggregate
17287
+ * — without three duplicated polygons.
17288
+ *
17289
+ * Owned by the orchestrator addon (provider) and mirrored into the
17290
+ * `zones` device-state slice on every mutation. Consumers
17291
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
17292
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
17293
+ * mirror with `onChanged`).
17294
+ *
17295
+ * Coordinates are normalised fractions of the frame (0–1) so zones
17296
+ * survive resolution changes and stream profile switches.
17297
+ *
17298
+ * `kind` discriminates between full polygons (closed regions used
17299
+ * for intrusion / occupancy filters) and tripwires (open 2-point
17300
+ * line segments used for cross events). Onboard / firmware-reported
17301
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
17302
+ * task list.
17303
+ */
17304
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
17305
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
17306
+ var PolygonPointSchema = object({
17307
+ x: number(),
17308
+ y: number()
17260
17309
  });
17261
- var MediaFileKindEnum = _enum([
17262
- "crop",
17263
- "thumbnail",
17264
- "snapshot",
17265
- "firstFrame",
17266
- "lastFrame",
17267
- "fullFrame",
17268
- "fullFrameBoxed",
17269
- "faceCrop",
17270
- "plateCrop",
17271
- "keyFrame",
17272
- "keyFrameSmall",
17273
- "thumbnailSmall"
17274
- ]);
17275
- var MediaFileSchema = object({
17276
- key: string(),
17277
- kind: MediaFileKindEnum,
17278
- base64: string(),
17279
- sizeBytes: number(),
17280
- timestamp: number()
17310
+ /** A camera detection zone — pure geometry/identity. */
17311
+ var ZoneSchema = object({
17312
+ id: string(),
17313
+ name: string(),
17314
+ kind: ZoneKindEnum.default("polygon"),
17315
+ /** Polygon vertices, fraction of frame (0–1). */
17316
+ polygon: array(PolygonPointSchema).readonly(),
17317
+ /** Visual color for UI rendering. */
17318
+ color: string().default("#3b82f6")
17281
17319
  });
17282
17320
  /**
17283
- * One media row WITHOUT its bytes.
17321
+ * Zones capability per-camera CRUD over polygon detection zones.
17284
17322
  *
17285
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17286
- * 140 s track), and a client that renders tiles from the media data plane needs
17287
- * to know only WHAT EXISTS the bytes then arrive per tile, lazily, over HTTP
17288
- * with an immutable cache, instead of all at once inside a tRPC response that
17289
- * blocks the whole view.
17323
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
17324
+ * to per-device settings and mirrors into the `zones` device-state
17325
+ * slice on every mutation, so downstream consumers can subscribe via
17326
+ * `dev.state.zones.onChanged`.
17290
17327
  *
17291
- * `sizeBytes` is carried because it is what lets a client decide between the
17292
- * stored blob and a `?variant=thumb` rendering without fetching either.
17328
+ * The cap surface only handles geometry + identity; filtering
17329
+ * behaviour (per-class, include/exclude, threshold) lives in the
17330
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
17331
+ * `capabilities/schemas/zone-rule.js`.
17293
17332
  */
17294
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17333
+ var zonesCapability = {
17334
+ name: "zones",
17335
+ scope: "device",
17336
+ mode: "singleton",
17337
+ deviceTypes: [DeviceType.Camera],
17338
+ methods: {
17339
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
17340
+ addZone: method(object({
17341
+ deviceId: number(),
17342
+ zone: ZoneSchema
17343
+ }), _void(), {
17344
+ kind: "mutation",
17345
+ auth: "admin"
17346
+ }),
17347
+ removeZone: method(object({
17348
+ deviceId: number(),
17349
+ zoneId: string()
17350
+ }), _void(), {
17351
+ kind: "mutation",
17352
+ auth: "admin"
17353
+ }),
17354
+ updateZone: method(object({
17355
+ deviceId: number(),
17356
+ zone: ZoneSchema
17357
+ }), _void(), {
17358
+ kind: "mutation",
17359
+ auth: "admin"
17360
+ })
17361
+ },
17362
+ /**
17363
+ * Runtime-state slice — the live zone catalogue mirrored by the
17364
+ * orchestrator on every CRUD mutation. Consumers read via
17365
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
17366
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
17367
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
17368
+ * (e.g. zone groupings) can sit alongside the polygon list.
17369
+ */
17370
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
17371
+ /**
17372
+ * Runtime-state durability: **restored** — written only on operator mutation, so a camera that never had one has nothing to re-derive from. This is the slice `zone-mirror-hydration.ts` exists to paper over.
17373
+ *
17374
+ * See `RuntimeStateDurability`. Enforced by
17375
+ * `scripts/check-runtime-state-durability.ts`.
17376
+ */
17377
+ durability: "restored"
17378
+ };
17295
17379
  /**
17296
- * The MACRO tier of an annotation — a CLOSED set.
17380
+ * pipeline-analytics device-scoped wrapper cap. Refines raw
17381
+ * per-frame detections emitted by the pipeline runner into tracked
17382
+ * objects, per-kind event collections (motion / object / audio), and
17383
+ * persisted media. Owns the post-detection domain end-to-end:
17297
17384
  *
17298
- * This is what the exported detector predicts, so a typo here is a new class
17299
- * with one example in it. `label` and `subLabel` are open strings by contrast:
17300
- * the whole point of the page is teaching the model things it does not know
17301
- * yet, and constraining that vocabulary would make it useless.
17385
+ * runner emits PipelineInferenceResult
17386
+ * (event bus)
17387
+ * pipeline-analytics subscriber
17388
+ * SORT tracker + zone engine + state analyzer + event emitter
17389
+ * → three DB collections (one per kind), one FS media tree, one
17390
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
17391
+ * DetectionEvent on bus)
17302
17392
  *
17303
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
17304
- * `subLabel` is one of these values, in any casing, because once `person`
17305
- * exists in both tiers "every person box" stops being answerable without
17306
- * knowing every string anyone ever typed — and the damage is retroactive.
17393
+ * Pure subscriber model. No `processFrame` cap method the runner
17394
+ * already publishes the raw frame on the bus. The cap surface is
17395
+ * only QUERIES + per-device settings, bound on/off via
17396
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
17397
+ * every camera with a detection pipeline wants its raw detections
17398
+ * refined; operators opt out per-device via BindingsTab when needed.
17399
+ *
17400
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17401
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
17307
17402
  */
17308
- var RetrainMacroClassSchema = _enum([
17403
+ var TrackStateSchema = _enum([
17404
+ "new",
17405
+ "entered",
17406
+ "left",
17407
+ "moving",
17408
+ "idle"
17409
+ ]);
17410
+ var EventKindSchema = _enum([
17411
+ "motion",
17412
+ "object",
17413
+ "audio"
17414
+ ]);
17415
+ /**
17416
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
17417
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17418
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
17419
+ */
17420
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17421
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
17422
+ var EventKindIconSchema = _enum([
17423
+ "motion",
17424
+ "audio",
17309
17425
  "person",
17310
17426
  "vehicle",
17311
17427
  "animal",
17428
+ "door",
17429
+ "pir",
17430
+ "smoke",
17431
+ "water",
17432
+ "button",
17312
17433
  "package",
17313
- "face",
17314
- "plate"
17434
+ "generic"
17315
17435
  ]);
17316
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17317
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17318
- /** Did a human draw this box, or did the assist propose it? */
17319
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17320
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17321
- var RetrainBboxSchema = object({
17322
- x: number(),
17323
- y: number(),
17324
- w: number(),
17325
- h: number()
17326
- });
17327
- /**
17328
- * One annotated subject.
17329
- *
17330
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17331
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17332
- * derived from it at export and never stored storing them is how one feature
17333
- * space ends up holding two crops of the same subject (D52).
17334
- */
17335
- var RetrainAnnotationSchema = object({
17336
- id: string(),
17337
- trackId: string(),
17338
- deviceId: number(),
17339
- /** The COPY in retrain storage — never the source track's media key. */
17340
- mediaKey: string(),
17341
- bbox: RetrainBboxSchema,
17342
- macroClass: RetrainMacroClassSchema,
17343
- label: string().optional(),
17344
- subLabel: string().optional(),
17345
- kind: RetrainAnnotationKindSchema,
17346
- source: RetrainAnnotationSourceSchema,
17347
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17348
- assistModelId: string().optional(),
17349
- assistScore: number().optional(),
17350
- exportedInBatch: string().optional(),
17351
- createdAt: number()
17352
- });
17353
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17354
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17355
- id: true,
17356
- trackId: true,
17357
- deviceId: true,
17358
- mediaKey: true,
17359
- createdAt: true,
17360
- exportedInBatch: true
17436
+ var EventKindCategorySchema = _enum([
17437
+ "motion",
17438
+ "audio",
17439
+ "detection",
17440
+ "sensor",
17441
+ "control",
17442
+ "custom",
17443
+ "package"
17444
+ ]);
17445
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17446
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
17447
+ var EventKindDescriptorSchema = object({
17448
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17449
+ kind: string(),
17450
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
17451
+ labelKey: string(),
17452
+ /** English fallback label (kept for clients that don't translate). */
17453
+ label: string(),
17454
+ /** Hex color for timeline/legend rendering. */
17455
+ color: string(),
17456
+ /** Dictionary id → lucide component on the UI side. */
17457
+ iconId: string(),
17458
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
17459
+ icon: EventKindIconSchema,
17460
+ category: EventKindCategorySchema,
17461
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17462
+ parentKind: string().nullable(),
17463
+ /** Derived from `parentKind`, explicit for the client tree. */
17464
+ level: EventKindLevelSchema,
17465
+ /** Which cap + device contributes this kind. For built-ins the camera
17466
+ * itself; for sensor kinds the LINKED source device. */
17467
+ source: object({
17468
+ capName: string(),
17469
+ deviceId: number()
17470
+ })
17361
17471
  });
17362
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17363
- var RetrainTrackSchema = object({
17364
- trackId: string(),
17472
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17473
+ var EventKindsForDeviceSchema = object({
17365
17474
  deviceId: number(),
17366
- className: string(),
17367
- label: string().optional(),
17368
- firstSeen: number(),
17369
- lastSeen: number(),
17370
- /** How many frames the dataset already holds from this track. */
17371
- frameCount: number().int(),
17372
- /** How many subjects have been annotated on those frames. `0` with
17373
- * `frameCount: 0` is exactly "staging, still to work". */
17374
- annotationCount: number().int()
17375
- });
17376
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
17377
- var RetrainFrameCandidateSchema = object({
17378
- mediaKey: string(),
17379
- kind: MediaFileKindEnum,
17380
- timestamp: number(),
17381
- sizeBytes: number().int(),
17382
- /** A copy of this original already exists — selecting it is free and cannot
17383
- * fail, whatever became of the original. */
17384
- copied: boolean()
17475
+ kinds: array(EventKindDescriptorSchema).readonly()
17385
17476
  });
17386
- /** A frame the dataset OWNS: bytes copied at selection time. */
17387
- var RetrainFrameSchema = object({
17388
- frameId: string(),
17477
+ var SensorEventSchema = object({
17478
+ id: string(),
17479
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
17480
+ * yields N rows, one per camera). */
17389
17481
  deviceId: number(),
17390
- trackId: string(),
17391
- /** Provenance only. It may already point at nothing — that is expected. */
17392
- sourceMediaKey: string(),
17393
- sourceKind: MediaFileKindEnum,
17394
- sizeBytes: number().int(),
17395
- width: number().int(),
17396
- height: number().int(),
17397
- copiedAt: number()
17482
+ /** The linked sensor device whose state changed. */
17483
+ sourceDeviceId: number(),
17484
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
17485
+ kind: string(),
17486
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
17487
+ value: record(string(), unknown()).nullable(),
17488
+ timestamp: number()
17398
17489
  });
17399
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17400
- var RetrainCopyRefusalSchema = _enum([
17401
- "source-missing",
17402
- "unreadable-image",
17403
- "write-failed"
17404
- ]);
17405
- var RetrainFrameSelectionSchema = object({
17406
- copied: array(RetrainFrameSchema).readonly(),
17407
- refused: array(object({
17408
- sourceMediaKey: string(),
17409
- reason: RetrainCopyRefusalSchema
17410
- })).readonly()
17490
+ var TrackPositionSchema = object({
17491
+ x: number(),
17492
+ y: number(),
17493
+ timestamp: number(),
17494
+ bbox: BoundingBoxSchema
17411
17495
  });
17412
- var RetrainFrameListSchema = object({
17413
- candidates: array(RetrainFrameCandidateSchema).readonly(),
17414
- copies: array(RetrainFrameSchema).readonly(),
17415
- /** What the page pre-selects the native key frame when one survives. */
17416
- autoPickMediaKey: string().optional()
17496
+ var TrackSnapshotSchema = object({
17497
+ timestamp: number(),
17498
+ position: TrackPositionSchema,
17499
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17500
+ mediaKey: string()
17417
17501
  });
17418
- /** What the operator asked the assist to look for. */
17419
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17420
- kind: literal("package"),
17421
- zone: RetrainBboxSchema.optional()
17422
- }), object({
17423
- kind: literal("objects"),
17424
- modelId: string(),
17425
- minScore: number().optional()
17426
- })]);
17427
17502
  /**
17428
- * The assist's answer a discriminated union, because "the model saw nothing"
17429
- * and "this node cannot run that model" lead to different next moves and a
17430
- * nullable result cannot tell them apart.
17503
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17504
+ * divided by the track's detection-frame dims), computed at persist time.
17505
+ * Absent when the frame dims were unknown when the track was persisted
17506
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17431
17507
  */
17432
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17433
- kind: literal("proposed"),
17434
- modelId: string(),
17435
- stepId: string(),
17436
- minScore: number(),
17437
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17438
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
17439
- /** Returned by the runner but removed by the threshold. */
17440
- belowThreshold: number().int()
17441
- }), object({
17442
- kind: literal("refused"),
17443
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17444
- reason: string(),
17445
- detail: string().optional()
17446
- })]);
17447
- /** The outcome of a lifecycle move owned by the retrain page. */
17448
- var RetrainTransitionResultSchema = object({
17449
- trackId: string(),
17450
- /** Where the track ended up, whatever happened. */
17451
- retrainStatus: RetrainStatusSchema,
17452
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17453
- changed: boolean(),
17454
- reason: _enum([
17455
- "unknown-track",
17456
- "no-frames-copied",
17457
- "not-staging",
17458
- "not-trained",
17459
- "unchanged"
17460
- ]).optional()
17461
- });
17462
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17463
- var MAX_EVENT_QUERY_LIMIT = 5e3;
17464
- var DeviceEventQueryInput = object({
17465
- deviceId: number(),
17466
- since: number().optional(),
17467
- until: number().optional(),
17468
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17469
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17470
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17471
- * exact behaviour. Callers may omit this field — the store defaults to
17472
- * `full` when not provided. */
17473
- projection: _enum(["full", "slim"]).optional()
17474
- });
17475
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17476
- var RecentTracksQueryInput = object({
17477
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17478
- deviceIds: array(number()),
17479
- /** Window lower bound on `lastSeen` (inclusive). */
17480
- since: number().optional(),
17481
- /** Window upper bound on `lastSeen` (inclusive). */
17482
- until: number().optional(),
17483
- /** Page size. Default 200, max 1000. */
17484
- limit: number().int().min(1).max(1e3).default(200),
17485
- /** Opaque continuation cursor from a previous page's `nextCursor`.
17486
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17487
- cursor: string().optional(),
17488
- /** See {@link TrackProjectionSchema}. Default `full`. */
17489
- projection: TrackProjectionSchema.optional(),
17490
- /** Include stationary-promoted rows (parked objects). Default false: the
17491
- * feed lists passages; parking records live on the stationary registry. */
17492
- includeStationary: boolean().optional()
17508
+ var TrackEnvelopeSchema = object({
17509
+ minX: number(),
17510
+ minY: number(),
17511
+ maxX: number(),
17512
+ maxY: number()
17493
17513
  });
17494
- var RecentTracksPageSchema = object({
17495
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17496
- tracks: array(TrackSchema).readonly(),
17497
- /** Cursor for the next page, or null when this page is the last. */
17498
- nextCursor: string().nullable()
17499
- });
17500
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
17501
- var LIST_GROUPS_MAX_LIMIT = 100;
17502
- var AnalyticsGroupRecordSchema = object({
17503
- id: string(),
17504
- deviceId: number().int(),
17505
- openedAt: number().int(),
17506
- closedAt: number().int(),
17507
- timestamp: number().int(),
17508
- memberCount: number().int(),
17509
- memberTrackIds: array(string()).readonly(),
17510
- className: string(),
17511
- classes: array(string()).readonly(),
17512
- /** Relative event-media path, or null when the group has no picture yet. */
17513
- mediaUrl: string().nullable(),
17514
- singleton: boolean()
17515
- });
17516
- var AnalyticsGroupMemberSchema = object({
17517
- trackId: string(),
17518
- deviceId: number().int(),
17519
- className: string(),
17520
- firstSeen: number().int(),
17521
- lastSeen: number().int(),
17522
- mediaUrl: string().nullable()
17523
- });
17524
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17525
- var ListGroupsQueryInput = object({
17526
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17527
- deviceIds: array(number()),
17528
- /** Window lower bound on `closedAt` (inclusive). */
17529
- since: number().optional(),
17530
- /** Window upper bound on `openedAt` (inclusive). */
17531
- until: number().optional(),
17532
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17533
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
17534
- cursor: string().optional()
17535
- });
17536
- var ListGroupsPageSchema = object({
17537
- groups: array(AnalyticsGroupRecordSchema).readonly(),
17538
- nextCursor: string().nullable()
17539
- });
17540
- var KeyEventQueryInput = object({
17541
- deviceId: number(),
17542
- /** Window lower bound (track firstSeen ≥ since). */
17543
- since: number(),
17544
- /** Window upper bound (track firstSeen ≤ until). */
17545
- until: number(),
17546
- limit: number().int().min(1).max(200).default(50),
17547
- /** Drop tracks scoring below this importance. */
17548
- minImportance: number().min(0).max(1).optional(),
17549
- /** Restrict to a single class (e.g. 'person'). */
17550
- classFilter: string().optional()
17551
- });
17552
- var KeyEventSchema = object({
17553
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
17554
- id: string(),
17555
- trackId: string(),
17556
- /** Track start time (firstSeen). */
17557
- timestamp: number(),
17558
- className: string(),
17559
- ...TieredLabelFields,
17560
- importance: number(),
17561
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
17562
- bestEventId: string(),
17563
- /** Track lifetime in ms (lastSeen - firstSeen). */
17564
- windowMs: number().optional(),
17565
- ...TrackFlagFields,
17566
- ...TrackRetrainFields
17567
- });
17568
- object({
17569
- trackId: string(),
17570
- className: string(),
17571
- confidence: number(),
17572
- bbox: BoundingBoxSchema,
17573
- zones: array(string()).readonly(),
17574
- state: TrackStateSchema
17575
- });
17576
- var OverlayDetectionSchema = looseObject({
17577
- id: string(),
17578
- kind: _enum(["first-level", "detail"]),
17579
- macroClass: string(),
17580
- score: number(),
17581
- bbox: object({
17582
- x: number(),
17583
- y: number(),
17584
- width: number(),
17585
- height: number()
17586
- }),
17587
- labels: array(looseObject({
17588
- label: string(),
17589
- score: number()
17590
- })).readonly(),
17591
- parentId: string().optional()
17592
- });
17593
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
17594
- var SearchObjectEventsInput = object({
17595
- text: string(),
17596
- deviceId: number().optional(),
17597
- since: number().optional(),
17598
- until: number().optional(),
17599
- classFilter: string().optional(),
17600
- limit: number().default(50),
17601
- minScore: number().min(0).max(1).default(.2)
17602
- });
17603
- var TrackCascadeCountsSchema = object({
17604
- /** Persisted track roots deleted (authoritative). */
17605
- tracks: number().int(),
17606
- /** Object events removed with their tracks (best-effort; see note above). */
17607
- events: number().int(),
17608
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17609
- media: number().int(),
17610
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
17611
- faces: number().int(),
17612
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17613
- plates: number().int(),
17614
- /** Per-track CLIP search vectors removed (best-effort). */
17615
- embeddings: number().int(),
17616
- /** Group membership + group rows removed with their last member (best-effort). */
17617
- groups: number().int()
17618
- });
17619
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17620
- var DiskReconcileCountsSchema = object({
17621
- mediaDropped: number().int(),
17622
- tracks: number().int(),
17623
- events: number().int()
17624
- });
17625
- /** Event-store footprint for one camera. */
17626
- var EventStoreDeviceFootprintSchema = object({
17627
- deviceId: number(),
17628
- /** Persisted event rows (motion + object + audio) for the camera. */
17629
- rows: number().int(),
17630
- /** Event-owned media bytes on disk for the camera. */
17631
- bytes: number().int()
17632
- });
17633
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
17634
- var EventStoreFootprintSchema = object({
17635
- totalRows: number().int(),
17636
- totalBytes: number().int(),
17637
- devices: array(EventStoreDeviceFootprintSchema).readonly()
17638
- });
17639
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
17640
- var EventPruneCountsSchema = object({
17641
- motion: number().int(),
17642
- object: number().int(),
17643
- audio: number().int()
17514
+ /**
17515
+ * Row projection for track list queries. `full` (default) returns the
17516
+ * complete Track including the frame-rate `positions[]` history and the
17517
+ * `snapshots[]` references megabytes across a page of tracks. `slim`
17518
+ * keeps every scalar the list surfaces actually render (ids, class(es),
17519
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17520
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17521
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
17522
+ * `getTrack`. Mirrors the event-store `projection` convention
17523
+ * (`getObjectEvents` et al.).
17524
+ */
17525
+ var TrackProjectionSchema = _enum(["full", "slim"]);
17526
+ /**
17527
+ * One audio-classification label heard on the track's camera while the
17528
+ * track was alive, aggregated per label. An "episode" is one persisted
17529
+ * audio event (the confident-classification path: score ≥ the device's
17530
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17531
+ * one 32 ms inference chunk, so counts stay human-scaled.
17532
+ */
17533
+ var TrackAudioLabelSchema = object({
17534
+ label: string(),
17535
+ /** Highest classification score observed across the label's episodes. */
17536
+ peakScore: number(),
17537
+ /** Number of coalesced audio-event episodes carrying this label. */
17538
+ count: number(),
17539
+ firstAt: number(),
17540
+ lastAt: number()
17644
17541
  });
17645
17542
  /**
17646
- * Re-embed stored tracks from their key frames.
17543
+ * How a track was produced. `pipeline` (default / absent) = the spatial
17544
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17545
+ * no positions, a single snapshot, and no bbox trajectory at all:
17647
17546
  *
17648
- * The reason this is an operator-callable method and not a migration script:
17649
- * every knob that decides what a vector MEANS encoder model, crop margin,
17650
- * squaring is only changeable if the existing vectors can be regenerated.
17651
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
17652
- * symptom is a quality regression with no visible cause.
17547
+ * - `sensor` a linked sensor/control device state change.
17548
+ * - `audio` an audio event on the camera itself that was anomalous for
17549
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
17550
+ *
17551
+ * The spatial subsystems (tracker association, occupancy count, re-id /
17552
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
17553
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17554
+ * check silently readmits every source added after it was written.
17653
17555
  */
17654
- var RebuildObjectEmbeddingsInput = object({
17655
- /** Restrict to one camera. Omit for the whole fleet. */
17656
- deviceId: number().optional(),
17657
- since: number().optional(),
17658
- until: number().optional(),
17659
- /** Stop after this many tracks; the result reports whether more remain. */
17660
- maxTracks: number().int().positive().optional(),
17661
- /**
17662
- * Run every embedding on THIS node instead of round-robining the fleet.
17663
- *
17664
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
17665
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
17666
- * calling it that would pin the rebuild REQUEST itself to that node — the
17667
- * rebuild orchestration lives on the hub, and only the per-track step runs
17668
- * remotely. This field is data; the per-track pin is applied inside.
17669
- *
17670
- * Absent ⇒ round-robin over every online node whose runner can serve the
17671
- * pinned model.
17672
- */
17673
- executeOnNodeId: string().optional(),
17674
- /**
17675
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
17676
- * run flat out.
17677
- *
17678
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
17679
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
17680
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
17681
- * force is logged at start and finish so a deliberately slow pass reads
17682
- * differently from a stalled one.
17683
- */
17684
- pacingMs: number().int().nonnegative().optional()
17685
- });
17556
+ var TrackSourceSchema = _enum([
17557
+ "pipeline",
17558
+ "sensor",
17559
+ "audio"
17560
+ ]);
17686
17561
  /**
17687
- * Result of emptying the CLIP index.
17562
+ * Where a track sits in the RETRAIN lifecycle (D81).
17688
17563
  *
17689
- * The clean slate before a policy change: a new crop margin or encoder model
17690
- * leaves two feature spaces in one index whose cosine scores are not
17691
- * comparable, so wiping and rebuilding is the only way to be sure every vector
17692
- * means the same thing.
17564
+ * - `none` never marked, or un-marked. Evictable.
17565
+ * - `staging` the operator wants this track as training material and has not
17566
+ * finished with it. **This is the only state retention holds**: the track and
17567
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
17568
+ * the device's age window.
17569
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
17570
+ * were COPIED into the retrain dataset at selection time, so the dataset no
17571
+ * longer depends on the track's media and the track becomes EVICTABLE again.
17572
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17573
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
17574
+ *
17575
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17576
+ * the store's filter language has only positive equality and `whereIn` — no
17577
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17578
+ * would make the entire pre-column history immortal in one deploy.
17693
17579
  */
17694
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
17580
+ var RetrainStatusSchema = _enum([
17581
+ "none",
17582
+ "staging",
17583
+ "trained"
17584
+ ]);
17695
17585
  /**
17696
- * Acknowledgement that a rebuild STARTED.
17586
+ * Per-track OPERATOR flags set by hand from the admin UI or the viewer, never
17587
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17588
+ * so the two surfaces cannot drift.
17697
17589
  *
17698
- * The pass costs ~1s per track 45 minutes for a 2,600-track fleet so it
17699
- * runs detached and this returns immediately. Waiting for it made the client
17700
- * time out while the work carried on server-side, which is the worst of both:
17701
- * no result and no way to know it was still going. Poll
17702
- * `getObjectEmbeddingRebuildStatus` for progress.
17590
+ * **Absent false.** A track that has never been touched omits the field; an
17591
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
17592
+ * columns existed read as absent, and a consumer that needs a boolean should say
17593
+ * `flag === true`, not `flag !== false`.
17594
+ *
17595
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17596
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17597
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17598
+ * `trained` track reports `false` while refusing both writes. The boolean is
17599
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
17600
+ * "never marked" from "already trained" must read `retrainStatus`.
17601
+ *
17602
+ * `debug` does NOT pin; it is attention, not durability.
17603
+ *
17604
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17605
+ * A favourited track is skipped by retention the same way `staging` is, but
17606
+ * it does not enter `none|staging|trained` and has no staging budget.
17703
17607
  */
17704
- var RebuildObjectEmbeddingsResultSchema = object({
17705
- started: boolean(),
17706
- /** True when a pass was already running; the new request is ignored. */
17707
- alreadyRunning: boolean()
17708
- });
17709
- var RebuildStatusSchema = object({
17710
- running: boolean(),
17711
- scanned: number(),
17712
- rebuilt: number(),
17713
- /** Tracks whose key frame is gone — nothing to re-embed from. */
17714
- missingKeyFrame: number(),
17715
- /** Tracks with no usable detection box. */
17716
- missingBbox: number(),
17717
- /**
17718
- * Tracks an executing node REFUSED rather than broke on an unreadable key
17719
- * frame, a step that threw. Separate from `failed` because the remedy is
17720
- * different, and because a whole camera silently contributing zero vectors
17721
- * is the shape of failure a rebuild must never hide.
17722
- */
17723
- notRunnable: number(),
17608
+ var TrackFlagFields = {
17609
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
17610
+ * `'staging'`. */
17611
+ markForTrain: boolean().optional(),
17612
+ /** Operator marked this track for diagnostic attention. */
17613
+ debug: boolean().optional(),
17614
+ /** Operator favourited this track. Pins it against pruning. */
17615
+ favourited: boolean().optional()
17616
+ };
17617
+ /**
17618
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17619
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17620
+ * write patch, and the status is not something the toggle sets — it is what the
17621
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17622
+ * always present on a persisted row (the column default materialises `'none'`).
17623
+ */
17624
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17625
+ /**
17626
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17627
+ * one flag can never clear the other — the toggles are independent and are
17628
+ * driven from three surfaces that do not know about each other.
17629
+ */
17630
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
17631
+ /**
17632
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
17633
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
17634
+ * mutation result without a re-fetch.
17635
+ */
17636
+ var TrackFlagsSchema = object({
17637
+ trackId: string(),
17638
+ markForTrain: boolean(),
17639
+ debug: boolean(),
17640
+ favourited: boolean(),
17641
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
17642
+ * a track row) because this shape is only ever produced by the write body,
17643
+ * which always knows it — and a surface that has just written needs to render
17644
+ * `trained` without a re-fetch. */
17645
+ retrainStatus: RetrainStatusSchema
17646
+ });
17647
+ union([literal(1), literal(2)]);
17648
+ /**
17649
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
17650
+ * the step and model that produced it — which is what makes the write rule
17651
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17652
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17653
+ *
17654
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17655
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17656
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
17657
+ * that value has no provenance, and the write rule lets ANY properly-attributed
17658
+ * write of the same tier replace it regardless of score.
17659
+ */
17660
+ var LabelAttributionSchema = object({
17661
+ stepId: string(),
17662
+ modelId: string().optional(),
17663
+ decidedAt: number(),
17724
17664
  /**
17725
- * The pass stopped because NO node could serve the pinned model.
17665
+ * The GALLERY id behind a recognised tier-2 label a face-gallery
17666
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17726
17667
  *
17727
- * Distinct from `notRunnable` on purpose: that one says "this track was
17728
- * refused", this one says "the cluster cannot do this work at all" — every
17729
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
17730
- * pinned model for its engine format, or dropped out. The remedy is a model /
17731
- * engine change, not a per-camera one. Non-zero here always comes with
17732
- * `complete: false`.
17668
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
17669
+ * notification rule authored on "Gianluca" stopped matching the moment the
17670
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
17671
+ * the thing that does not move, so it is what a rule matches on
17672
+ * (`NcConditions.identities`) and the text is what a human is shown.
17673
+ *
17674
+ * Absent when the label names no gallery row — a plate the OCR read but no
17675
+ * vehicle claims, a sub-class, a species, any tier-1 value.
17733
17676
  */
17734
- noCapableNode: number(),
17735
- failed: number(),
17736
- /** Set once a pass ends: true only when EVERYTHING was covered. */
17737
- complete: boolean().nullable(),
17738
- startedAtMs: number().nullable(),
17739
- finishedAtMs: number().nullable(),
17740
- /** Present when the pass ended by throwing. */
17741
- error: string().nullable()
17677
+ identityId: string().optional()
17742
17678
  });
17743
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
17744
- deviceId: number(),
17745
- trackId: string()
17746
- }), TrackSchema.nullable()), method(object({
17747
- deviceId: number(),
17748
- since: number().optional(),
17749
- until: number().optional(),
17750
- limit: number().optional(),
17751
- /** Spatial filter — only tracks whose trajectory intersects the zone
17752
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
17753
- * envelope columns, then precisely tested per position. Tracks with
17754
- * an unknown envelope (no frame dims at persist time) always match. */
17755
- zone: TrackZoneFilterSchema.optional(),
17756
- /** See {@link TrackProjectionSchema}. Default `full` (backward
17757
- * compatible omitting the field keeps today's exact behaviour). */
17758
- projection: TrackProjectionSchema.optional(),
17759
- /** Include stationary-promoted rows (parked objects handed to the
17760
- * stationary registry). Default false: the timeline lists passages,
17761
- * not parking records (operator decision, 2026-08-15). */
17762
- includeStationary: boolean().optional()
17763
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
17764
- deviceId: number(),
17765
- groupId: string().min(1)
17766
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
17767
- kind: "mutation",
17768
- auth: "admin"
17769
- }), 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({
17770
- deviceId: number(),
17771
- since: number().optional(),
17772
- until: number().optional(),
17773
- kinds: array(string()).optional(),
17774
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
17775
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
17776
- deviceId: number(),
17777
- since: number(),
17778
- until: number(),
17779
- bucketMs: number().int().positive()
17780
- }), array(object({
17781
- bucketStart: number(),
17782
- motion: number().int(),
17783
- object: number().int(),
17784
- audio: number().int()
17785
- })).readonly()), method(object({
17786
- deviceId: number(),
17787
- cutoffMs: number()
17788
- }), object({
17789
- motion: number().int(),
17790
- object: number().int(),
17791
- audio: number().int()
17792
- }), {
17793
- kind: "mutation",
17794
- auth: "admin"
17795
- }), method(object({
17796
- deviceId: number(),
17797
- cutoffMs: number()
17798
- }), TrackCascadeCountsSchema, {
17799
- kind: "mutation",
17800
- auth: "admin"
17801
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17802
- kind: "mutation",
17803
- auth: "admin"
17804
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17805
- kind: "mutation",
17806
- auth: "admin"
17807
- }), method(object({
17808
- deviceId: number(),
17809
- trackIds: array(string()).min(1)
17810
- }), object({
17811
- deleted: number().int(),
17812
- failed: array(string()).readonly()
17813
- }), {
17814
- kind: "mutation",
17815
- auth: "admin"
17816
- }), method(object({
17817
- /** Log/audit scope only — the trackId is globally unique on its own. */
17679
+ /**
17680
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17681
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17682
+ * track and its events always answer the same question the same way.
17683
+ *
17684
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
17685
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17686
+ * is tier 2, and each carries its own score + attribution.
17687
+ *
17688
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17689
+ * finest thing known. Before 4g the single `label` column held the finest
17690
+ * value, so a consumer that has not been updated reads the tier-1 slot and
17691
+ * shows nothing on a species-only row; that is why the migration puts every
17692
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17693
+ * and why the read surfaces were changed in the same train.
17694
+ *
17695
+ * **Writing it.** The slots are independent, which is the whole point: a
17696
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17697
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
17698
+ * higher score wins. One rule, one implementation — see
17699
+ * `pipeline/label-tier.ts` in addon-post-analysis.
17700
+ */
17701
+ var TieredLabelFields = {
17702
+ /** Tier 1 the sub-class. See {@link LabelTierSchema}. */
17703
+ label: string().optional(),
17704
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
17705
+ labelScore: number().optional(),
17706
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17707
+ labelMeta: LabelAttributionSchema.optional(),
17708
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17709
+ subLabel: string().optional(),
17710
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
17711
+ subLabelScore: number().optional(),
17712
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17713
+ subLabelMeta: LabelAttributionSchema.optional()
17714
+ };
17715
+ /** Per-camera slice of a training-export estimate. */
17716
+ var TrainingExportDeviceTotalsSchema = object({
17818
17717
  deviceId: number(),
17718
+ tracks: number().int(),
17719
+ files: number().int(),
17720
+ bytes: number().int()
17721
+ });
17722
+ /**
17723
+ * What a training export WOULD contain. Computed from media index rows only —
17724
+ * no blob is read to produce this.
17725
+ */
17726
+ var TrainingExportSummarySchema = object({
17727
+ generatedAt: number(),
17728
+ trackCount: number().int(),
17729
+ fileCount: number().int(),
17730
+ byteCount: number().int(),
17731
+ /** More marked tracks exist than a single pass carries. */
17732
+ truncated: boolean(),
17733
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
17734
+ });
17735
+ var TrackSchema = object({
17819
17736
  trackId: string(),
17820
- flags: TrackFlagsPatchSchema
17821
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
17822
- kind: "query",
17823
- auth: "admin"
17824
- }), method(object({
17825
- olderThanMs: number(),
17826
- reason: OpsLogReasonSchema.optional()
17827
- }), EventPruneCountsSchema, {
17828
- kind: "mutation",
17829
- auth: "admin"
17830
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
17831
- kind: "mutation",
17832
- auth: "admin"
17833
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
17834
- kind: "mutation",
17835
- auth: "admin"
17836
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
17837
- kind: "mutation",
17838
- auth: "admin"
17839
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
17840
- kind: "mutation",
17841
- auth: "admin"
17842
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
17843
- kind: "mutation",
17844
- auth: "admin"
17845
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
17846
- kind: "mutation",
17847
- auth: "admin"
17848
- }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
17849
- kind: "mutation",
17850
- auth: "admin"
17851
- }), method(object({}), array(RelocateJobSchema).readonly(), {
17852
- kind: "query",
17853
- auth: "admin"
17854
- }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
17855
- kind: "mutation",
17856
- auth: "admin"
17857
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
17858
- kind: "query",
17859
- auth: "admin"
17860
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
17861
- kind: "query",
17862
- auth: "admin"
17863
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17864
- kind: "query",
17865
- auth: "admin"
17866
- }), method(object({
17867
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
17868
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
17869
- * route it at one camera's owner, and "every camera" would stop being
17870
- * expressible at all. */
17871
- deviceIds: array(number()).optional(),
17872
- limit: number().int().min(1).max(500).optional()
17873
- }), array(RetrainTrackSchema).readonly(), {
17874
- kind: "query",
17875
- auth: "admin"
17876
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
17877
- kind: "query",
17878
- auth: "admin"
17879
- }), method(object({
17880
17737
  deviceId: number(),
17881
- trackId: string(),
17882
- mediaKeys: array(string()).min(1)
17883
- }), RetrainFrameSelectionSchema, {
17884
- kind: "mutation",
17885
- auth: "admin"
17886
- }), method(object({
17738
+ className: string(),
17739
+ ...TieredLabelFields,
17740
+ producingDeviceName: string().optional(),
17741
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
17742
+ source: TrackSourceSchema.optional(),
17743
+ firstSeen: number(),
17744
+ lastSeen: number(),
17745
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
17746
+ positions: array(TrackPositionSchema).readonly(),
17747
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17748
+ * saveThumbnails policy). */
17749
+ snapshots: array(TrackSnapshotSchema).readonly(),
17750
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
17751
+ zonesVisited: array(string()).readonly(),
17752
+ /**
17753
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17754
+ * `zones` capability.
17755
+ *
17756
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17757
+ * and no card can render — so every free-text search surface was structurally
17758
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17759
+ * just returned nothing. Resolving here rather than in each client keeps ONE
17760
+ * derivation and costs the clients no extra call (the `zones` cap is
17761
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
17762
+ * surface built to avoid exactly that).
17763
+ *
17764
+ * Resolved, never invented: a zone deleted since the track was written has no
17765
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17766
+ * two are not positionally aligned. Absent when the track visited no zone, or
17767
+ * when the zone catalogue could not be read.
17768
+ */
17769
+ zoneNames: array(string()).readonly().optional(),
17770
+ /** Deduplicated set of detector classes observed for this track over its
17771
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
17772
+ * legacy rows written before class accumulation shipped. */
17773
+ classes: array(string()).readonly().optional(),
17774
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17775
+ totalDistance: number(),
17776
+ state: TrackStateSchema,
17777
+ active: boolean(),
17778
+ /** Deterministic key-event importance score in [0,1] (server-computed at
17779
+ * track expiry, recomputed on late label). Absent on legacy rows written
17780
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
17781
+ importance: number().optional(),
17782
+ /** Id of the track's highest-confidence ObjectEvent (its representative
17783
+ * "best" frame). Absent when the track produced no object events. */
17784
+ bestEventId: string().optional(),
17785
+ /** Tag of the importance sub-signal that dominated the score
17786
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
17787
+ importanceReason: string().optional(),
17788
+ /** Audio-classification labels heard on the camera during the track's
17789
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
17790
+ * Absent on legacy rows / tracks with no confident audio. */
17791
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17792
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17793
+ * Populated from the persisted envelope columns on historical reads;
17794
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17795
+ envelope: TrackEnvelopeSchema.optional(),
17796
+ /**
17797
+ * A face DETECTOR found a face on this track — nothing more. It says the
17798
+ * detail plane produced a `face` detail; it does NOT say the face was
17799
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
17800
+ * enabled. Set once and never cleared.
17801
+ *
17802
+ * **This exists so "face present but not recognised" is expressible.** A
17803
+ * recognised identity lands in `subLabel` (attributed to the face chain via
17804
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17805
+ * and a track with no face at all were byte-identical on the wire and no
17806
+ * surface could tell them apart. The read is `hasFace === true && subLabel
17807
+ * === undefined`.
17808
+ *
17809
+ * **Absent ≠ false.** Every row written before the column existed omits it,
17810
+ * and so does every server that predates the field — a consumer must test
17811
+ * `=== true` and render nothing otherwise, never infer "no face".
17812
+ */
17813
+ hasFace: boolean().optional(),
17814
+ /**
17815
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
17816
+ * face an operator could ASSIGN to an identity.
17817
+ *
17818
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17819
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
17820
+ * branch, before every gate, and means no more than "a face detector produced
17821
+ * a face detail". This one is stamped at the single moment the gallery row
17822
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17823
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17824
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
17825
+ * the crop-store drop. Everything between the detector and that insert can
17826
+ * legitimately refuse the face, so a flag written any earlier promises the
17827
+ * operator something to assign and delivers nothing.
17828
+ *
17829
+ * **Independent of recognition.** A face collected but never auto-matched is
17830
+ * still assignable — it is in fact the face an operator most wants to reach —
17831
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17832
+ * `subLabel`; this says only that the raw material exists.
17833
+ *
17834
+ * **Set once, never cleared.** A track that produced a gallery row produced
17835
+ * one; deleting the row later is the gallery's business, not this flag's.
17836
+ *
17837
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17838
+ * before the column omits it, and so does every server that predates the
17839
+ * field. A consumer must test `=== true` and render nothing otherwise —
17840
+ * never infer "no assignable face".
17841
+ */
17842
+ hasEmbeddedFace: boolean().optional(),
17843
+ /**
17844
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
17845
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17846
+ * so the passage is tracked once and as a VEHICLE.
17847
+ *
17848
+ * It exists because the fold's record was dishonest. D34 and the code both
17849
+ * said "the person is not lost — it is reported so both entities stay on the
17850
+ * record"; in fact the pair went into a per-processor RAM field behind an
17851
+ * accessor nobody called, and every durable surface said `vehicle`, full
17852
+ * stop. This is the composition note that makes the row true.
17853
+ *
17854
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
17855
+ * person" is not an answer to "what is this" — both label tiers would refuse
17856
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
17857
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17858
+ * and a `person` rule still does not fire for someone cycling past.
17859
+ *
17860
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17861
+ * the column, and every hub that predates the field, omits it. Test
17862
+ * `=== true` and render nothing otherwise — never infer "no rider".
17863
+ */
17864
+ hasRider: boolean().optional(),
17865
+ ...TrackFlagFields,
17866
+ ...TrackRetrainFields
17867
+ });
17868
+ var BaseEventFields = {
17869
+ id: string(),
17887
17870
  deviceId: number(),
17888
- trackId: string(),
17889
- frameId: string()
17890
- }), object({
17891
- removed: boolean(),
17892
- removedAnnotations: number().int()
17893
- }), {
17894
- kind: "mutation",
17895
- auth: "admin"
17896
- }), method(object({ frameId: string() }), object({
17871
+ timestamp: number()
17872
+ };
17873
+ var MotionEventSchema = object({
17874
+ ...BaseEventFields,
17875
+ kind: literal("motion"),
17876
+ regionCount: number(),
17877
+ /** Heavy JSON array — omitted in slim projection. */
17878
+ regions: array(object({
17879
+ bbox: BoundingBoxSchema,
17880
+ pixelCount: number(),
17881
+ intensity: number()
17882
+ })).readonly().optional(),
17883
+ /** Omitted in slim projection. */
17884
+ frameWidth: number().optional(),
17885
+ /** Omitted in slim projection. */
17886
+ frameHeight: number().optional(),
17887
+ /** Populated by B5 (recording playback URL for this event). */
17888
+ mediaUrl: string().optional()
17889
+ });
17890
+ /**
17891
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
17892
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
17893
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
17894
+ * tracking, per-kind persistence) but stay distinguishable so consumers
17895
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17896
+ * Absent on legacy rows ⇒ treat as `pipeline`.
17897
+ */
17898
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17899
+ /**
17900
+ * The confirmed zone crossing that produced an object event. Present ONLY on
17901
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17902
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17903
+ * appearance event carry none, so a rule asking for a direction fails closed
17904
+ * on them.
17905
+ *
17906
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17907
+ * into its own event, so a frame in which a track enters A while leaving B
17908
+ * produces two events with two directions — never one ambiguous row.
17909
+ *
17910
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17911
+ * membership the box has NOW, and by definition it no longer contains the zone
17912
+ * that was just left. Without the id here, a zone-scoped rule could never match
17913
+ * the exit it asked for.
17914
+ */
17915
+ var ZoneCrossingSchema = object({
17916
+ direction: _enum(["enter", "exit"]),
17917
+ /** Admin zone id crossed. */
17918
+ zoneId: string(),
17919
+ /** Zone display name at crossing time (falls back to the id). */
17920
+ zoneName: string().optional()
17921
+ });
17922
+ var ObjectEventSchema = object({
17923
+ ...BaseEventFields,
17924
+ kind: literal("object"),
17925
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17926
+ source: DetectionSourceSchema.optional(),
17927
+ /**
17928
+ * Inference-frame id shared by every object event emitted from the SAME frame
17929
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17930
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
17931
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
17932
+ * Optional for backward-compat with pre-existing rows / the slim projection
17933
+ * includes it (it is light). Absent on rows written before this field.
17934
+ */
17935
+ frameId: string().optional(),
17936
+ /** Omitted in slim projection. */
17937
+ trackId: string().optional(),
17938
+ className: string(),
17939
+ ...TieredLabelFields,
17940
+ /** Omitted in slim projection. */
17941
+ confidence: number().optional(),
17942
+ /** Heavy JSON — omitted in slim projection. */
17943
+ bbox: BoundingBoxSchema.optional(),
17944
+ /** Heavy JSON — omitted in slim projection. */
17945
+ zones: array(string()).readonly().optional(),
17946
+ /** Omitted in slim projection. */
17947
+ state: TrackStateSchema.optional(),
17948
+ /**
17949
+ * The zone crossing this event IS, when it is one. Absent on every other
17950
+ * event kind (movement state, appearance, package) — see
17951
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
17952
+ */
17953
+ zoneCrossing: ZoneCrossingSchema.optional(),
17954
+ /** Detection-frame dimensions in pixels — let consumers normalize the
17955
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17956
+ frameWidth: number().optional(),
17957
+ frameHeight: number().optional(),
17958
+ /** MediaStore key for the crop attached to this event (if any). */
17959
+ mediaKey: string().optional(),
17960
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
17961
+ * best-detection full frame). Resolve via the event-media data-plane
17962
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17963
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17964
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
17965
+ keyFrameMediaKey: string().optional(),
17966
+ /** Populated by B5 (recording playback URL for this event). */
17967
+ mediaUrl: string().optional(),
17968
+ /** The parent track's key-event importance [0,1], propagated to every object
17969
+ * event of the track (so an event row can be sorted by importance without a
17970
+ * track join). Absent on legacy rows / before the track was scored. */
17971
+ importance: number().optional()
17972
+ });
17973
+ var AudioEventSchema = object({
17974
+ ...BaseEventFields,
17975
+ kind: literal("audio"),
17976
+ rms: number(),
17977
+ dbfs: number(),
17978
+ classification: object({
17979
+ className: string(),
17980
+ originalClass: string().optional(),
17981
+ score: number()
17982
+ }).optional(),
17983
+ /** Populated by B5 (recording playback URL for this event). */
17984
+ mediaUrl: string().optional()
17985
+ });
17986
+ var MediaFileKindEnum = _enum([
17987
+ "crop",
17988
+ "thumbnail",
17989
+ "snapshot",
17990
+ "firstFrame",
17991
+ "lastFrame",
17992
+ "fullFrame",
17993
+ "fullFrameBoxed",
17994
+ "faceCrop",
17995
+ "plateCrop",
17996
+ "keyFrame",
17997
+ "keyFrameSmall",
17998
+ "thumbnailSmall"
17999
+ ]);
18000
+ var MediaFileSchema = object({
18001
+ key: string(),
18002
+ kind: MediaFileKindEnum,
17897
18003
  base64: string(),
17898
- width: number().int(),
17899
- height: number().int()
17900
- }), {
17901
- kind: "query",
17902
- auth: "admin"
17903
- }), method(object({
17904
- deviceId: number(),
17905
- trackId: string(),
17906
- frameId: string(),
17907
- subject: RetrainAssistSubjectSchema,
17908
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
17909
- nodeId: string().optional()
17910
- }), RetrainAssistResultSchema, {
17911
- kind: "mutation",
17912
- auth: "admin"
17913
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
17914
- kind: "query",
17915
- auth: "admin"
17916
- }), method(object({
17917
- deviceId: number(),
18004
+ sizeBytes: number(),
18005
+ timestamp: number()
18006
+ });
18007
+ /**
18008
+ * One media row WITHOUT its bytes.
18009
+ *
18010
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
18011
+ * 140 s track), and a client that renders tiles from the media data plane needs
18012
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
18013
+ * with an immutable cache, instead of all at once inside a tRPC response that
18014
+ * blocks the whole view.
18015
+ *
18016
+ * `sizeBytes` is carried because it is what lets a client decide between the
18017
+ * stored blob and a `?variant=thumb` rendering without fetching either.
18018
+ */
18019
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
18020
+ /**
18021
+ * The MACRO tier of an annotation — a CLOSED set.
18022
+ *
18023
+ * This is what the exported detector predicts, so a typo here is a new class
18024
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
18025
+ * the whole point of the page is teaching the model things it does not know
18026
+ * yet, and constraining that vocabulary would make it useless.
18027
+ *
18028
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
18029
+ * `subLabel` is one of these values, in any casing, because once `person`
18030
+ * exists in both tiers "every person box" stops being answerable without
18031
+ * knowing every string anyone ever typed — and the damage is retroactive.
18032
+ */
18033
+ var RetrainMacroClassSchema = _enum([
18034
+ "person",
18035
+ "vehicle",
18036
+ "animal",
18037
+ "package",
18038
+ "face",
18039
+ "plate"
18040
+ ]);
18041
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
18042
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
18043
+ /** Did a human draw this box, or did the assist propose it? */
18044
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
18045
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
18046
+ var RetrainBboxSchema = object({
18047
+ x: number(),
18048
+ y: number(),
18049
+ w: number(),
18050
+ h: number()
18051
+ });
18052
+ /**
18053
+ * One annotated subject.
18054
+ *
18055
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
18056
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
18057
+ * derived from it at export and never stored — storing them is how one feature
18058
+ * space ends up holding two crops of the same subject (D52).
18059
+ */
18060
+ var RetrainAnnotationSchema = object({
18061
+ id: string(),
17918
18062
  trackId: string(),
17919
- frameId: string(),
17920
- annotations: array(RetrainAnnotationDraftSchema)
17921
- }), array(RetrainAnnotationSchema).readonly(), {
17922
- kind: "mutation",
17923
- auth: "admin"
17924
- }), method(object({
17925
- deviceId: number(),
17926
- trackId: string()
17927
- }), RetrainTransitionResultSchema, {
17928
- kind: "mutation",
17929
- auth: "admin"
17930
- }), method(object({
17931
18063
  deviceId: number(),
17932
- trackId: string()
17933
- }), RetrainTransitionResultSchema, {
17934
- kind: "mutation",
17935
- auth: "admin"
17936
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17937
- kind: "query",
17938
- auth: "admin"
17939
- }), method(object({
17940
- eventId: string(),
17941
- kind: MediaFileKindEnum.optional(),
17942
- deviceId: number()
17943
- }), array(MediaFileSchema).readonly()), method(object({
17944
- trackId: string(),
17945
- kinds: array(MediaFileKindEnum).optional(),
17946
- deviceId: number()
17947
- }), array(MediaFileSchema).readonly()), method(object({
18064
+ /** The COPY in retrain storage — never the source track's media key. */
18065
+ mediaKey: string(),
18066
+ bbox: RetrainBboxSchema,
18067
+ macroClass: RetrainMacroClassSchema,
18068
+ label: string().optional(),
18069
+ subLabel: string().optional(),
18070
+ kind: RetrainAnnotationKindSchema,
18071
+ source: RetrainAnnotationSourceSchema,
18072
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
18073
+ assistModelId: string().optional(),
18074
+ assistScore: number().optional(),
18075
+ exportedInBatch: string().optional(),
18076
+ createdAt: number()
18077
+ });
18078
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
18079
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
18080
+ id: true,
18081
+ trackId: true,
18082
+ deviceId: true,
18083
+ mediaKey: true,
18084
+ createdAt: true,
18085
+ exportedInBatch: true
18086
+ });
18087
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
18088
+ var RetrainTrackSchema = object({
17948
18089
  trackId: string(),
17949
- deviceId: number()
17950
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
17951
- kind: "mutation",
17952
- auth: "admin"
17953
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
17954
- kind: "mutation",
17955
- auth: "admin"
17956
- }), method(object({}), RebuildStatusSchema), object({
17957
18090
  deviceId: number(),
18091
+ className: string(),
18092
+ label: string().optional(),
18093
+ firstSeen: number(),
18094
+ lastSeen: number(),
18095
+ /** How many frames the dataset already holds from this track. */
18096
+ frameCount: number().int(),
18097
+ /** How many subjects have been annotated on those frames. `0` with
18098
+ * `frameCount: 0` is exactly "staging, still to work". */
18099
+ annotationCount: number().int()
18100
+ });
18101
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
18102
+ var RetrainFrameCandidateSchema = object({
18103
+ mediaKey: string(),
18104
+ kind: MediaFileKindEnum,
17958
18105
  timestamp: number(),
17959
- frameWidth: number(),
17960
- frameHeight: number(),
17961
- detections: array(OverlayDetectionSchema).readonly()
17962
- }), object({
17963
- deviceId: number(),
17964
- trackId: string(),
17965
- className: string()
17966
- }), object({
18106
+ sizeBytes: number().int(),
18107
+ /** A copy of this original already exists — selecting it is free and cannot
18108
+ * fail, whatever became of the original. */
18109
+ copied: boolean()
18110
+ });
18111
+ /** A frame the dataset OWNS: bytes copied at selection time. */
18112
+ var RetrainFrameSchema = object({
18113
+ frameId: string(),
17967
18114
  deviceId: number(),
17968
18115
  trackId: string(),
17969
- className: string(),
17970
- durationMs: number()
17971
- }), object({
17972
- deviceId: number(),
17973
- kind: EventKindSchema,
17974
- eventId: string(),
17975
- timestamp: number()
18116
+ /** Provenance only. It may already point at nothing — that is expected. */
18117
+ sourceMediaKey: string(),
18118
+ sourceKind: MediaFileKindEnum,
18119
+ sizeBytes: number().int(),
18120
+ width: number().int(),
18121
+ height: number().int(),
18122
+ copiedAt: number()
17976
18123
  });
17977
- /**
17978
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
17979
- * within the frame, so the executor can re-cut a leaf child ROI at native
17980
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
17981
- */
17982
- var NativeCropRefSchema = object({
17983
- /** Handle keying the retained native surface (node-pinned to its owner). */
17984
- handle: FrameHandleSchema,
17985
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
17986
- cropFrameSpace: object({
17987
- x: number(),
17988
- y: number(),
17989
- w: number(),
17990
- h: number()
17991
- })
18124
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
18125
+ var RetrainCopyRefusalSchema = _enum([
18126
+ "source-missing",
18127
+ "unreadable-image",
18128
+ "write-failed"
18129
+ ]);
18130
+ var RetrainFrameSelectionSchema = object({
18131
+ copied: array(RetrainFrameSchema).readonly(),
18132
+ refused: array(object({
18133
+ sourceMediaKey: string(),
18134
+ reason: RetrainCopyRefusalSchema
18135
+ })).readonly()
17992
18136
  });
17993
- object({
17994
- crop: object({
17995
- left: number(),
17996
- top: number(),
17997
- width: number().positive(),
17998
- height: number().positive()
17999
- }).optional(),
18000
- content: object({
18001
- width: number().int().positive(),
18002
- height: number().int().positive()
18003
- }),
18004
- fit: _enum(["stretch", "contain"]),
18005
- format: _enum([
18006
- "rgb",
18007
- "gray",
18008
- "jpeg"
18009
- ])
18137
+ var RetrainFrameListSchema = object({
18138
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
18139
+ copies: array(RetrainFrameSchema).readonly(),
18140
+ /** What the page pre-selects — the native key frame when one survives. */
18141
+ autoPickMediaKey: string().optional()
18010
18142
  });
18143
+ /** What the operator asked the assist to look for. */
18144
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
18145
+ kind: literal("package"),
18146
+ zone: RetrainBboxSchema.optional()
18147
+ }), object({
18148
+ kind: literal("objects"),
18149
+ modelId: string(),
18150
+ minScore: number().optional()
18151
+ })]);
18011
18152
  /**
18012
- * Process-local frame identity. It is serializable so it can ride an in-process
18013
- * capability call, but `registryId` deliberately prevents resolution in any
18014
- * other process or execution group.
18153
+ * The assist's answer a discriminated union, because "the model saw nothing"
18154
+ * and "this node cannot run that model" lead to different next moves and a
18155
+ * nullable result cannot tell them apart.
18015
18156
  */
18016
- var FrameRefSchema = object({
18017
- registryId: string().min(1),
18018
- id: string().min(1),
18019
- width: number().int().positive(),
18020
- height: number().int().positive(),
18021
- format: _enum(["rgb", "gray"]),
18022
- timestamp: number(),
18023
- capturedAt: number().optional()
18157
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
18158
+ kind: literal("proposed"),
18159
+ modelId: string(),
18160
+ stepId: string(),
18161
+ minScore: number(),
18162
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
18163
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
18164
+ /** Returned by the runner but removed by the threshold. */
18165
+ belowThreshold: number().int()
18166
+ }), object({
18167
+ kind: literal("refused"),
18168
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
18169
+ reason: string(),
18170
+ detail: string().optional()
18171
+ })]);
18172
+ /** The outcome of a lifecycle move owned by the retrain page. */
18173
+ var RetrainTransitionResultSchema = object({
18174
+ trackId: string(),
18175
+ /** Where the track ended up, whatever happened. */
18176
+ retrainStatus: RetrainStatusSchema,
18177
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
18178
+ changed: boolean(),
18179
+ reason: _enum([
18180
+ "unknown-track",
18181
+ "no-frames-copied",
18182
+ "not-staging",
18183
+ "not-trained",
18184
+ "unchanged"
18185
+ ]).optional()
18024
18186
  });
18025
- var ModelFormatSchema$1 = _enum([
18026
- "onnx",
18027
- "coreml",
18028
- "openvino",
18029
- "tflite",
18030
- "pt",
18031
- "gguf"
18032
- ]);
18033
- var PipelineSlotSchema = _enum([
18034
- "detector",
18035
- "cropper",
18036
- "classifier",
18037
- "refiner",
18038
- "audio-classifier"
18039
- ]);
18040
- var PipelineEngineChoiceSchema = object({
18041
- runtime: _enum(["node", "python"]),
18042
- backend: string(),
18043
- format: ModelFormatSchema$1,
18044
- device: string().optional()
18187
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
18188
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
18189
+ var DeviceEventQueryInput = object({
18190
+ deviceId: number(),
18191
+ since: number().optional(),
18192
+ until: number().optional(),
18193
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
18194
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
18195
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
18196
+ * exact behaviour. Callers may omit this field — the store defaults to
18197
+ * `full` when not provided. */
18198
+ projection: _enum(["full", "slim"]).optional()
18199
+ });
18200
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
18201
+ var RecentTracksQueryInput = object({
18202
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
18203
+ deviceIds: array(number()),
18204
+ /** Window lower bound on `lastSeen` (inclusive). */
18205
+ since: number().optional(),
18206
+ /** Window upper bound on `lastSeen` (inclusive). */
18207
+ until: number().optional(),
18208
+ /** Page size. Default 200, max 1000. */
18209
+ limit: number().int().min(1).max(1e3).default(200),
18210
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
18211
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
18212
+ cursor: string().optional(),
18213
+ /** See {@link TrackProjectionSchema}. Default `full`. */
18214
+ projection: TrackProjectionSchema.optional(),
18215
+ /** Include stationary-promoted rows (parked objects). Default false: the
18216
+ * feed lists passages; parking records live on the stationary registry. */
18217
+ includeStationary: boolean().optional()
18045
18218
  });
18046
- var AvailableEngineSchema = object({
18047
- engine: PipelineEngineChoiceSchema,
18048
- devices: array(object({
18049
- id: string(),
18050
- label: string(),
18051
- description: string().optional()
18052
- })).readonly(),
18053
- defaultDevice: string()
18219
+ var RecentTracksPageSchema = object({
18220
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
18221
+ tracks: array(TrackSchema).readonly(),
18222
+ /** Cursor for the next page, or null when this page is the last. */
18223
+ nextCursor: string().nullable()
18054
18224
  });
18055
- var PipelineDefaultStepSchema = lazy(() => object({
18056
- addonId: string(),
18057
- addonName: string(),
18058
- slot: PipelineSlotSchema,
18059
- inputClasses: array(string()).readonly(),
18060
- outputClasses: array(string()).readonly(),
18061
- enabled: boolean(),
18062
- modelId: string(),
18063
- children: array(PipelineDefaultStepSchema).readonly(),
18064
- group: string().optional(),
18065
- settings: record(string(), unknown()).optional()
18066
- }));
18067
- var PipelineTemplateStepSchema = lazy(() => object({
18068
- addonId: string(),
18069
- enabled: boolean(),
18070
- modelId: string(),
18071
- children: array(PipelineTemplateStepSchema).readonly(),
18072
- settings: record(string(), unknown()).optional()
18073
- }));
18074
- var PipelineTemplateSchema$1 = object({
18225
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
18226
+ var LIST_GROUPS_MAX_LIMIT = 100;
18227
+ var AnalyticsGroupRecordSchema = object({
18075
18228
  id: string(),
18076
- name: string(),
18077
- createdAt: string(),
18078
- updatedAt: string(),
18079
- engine: PipelineEngineChoiceSchema,
18080
- steps: array(PipelineTemplateStepSchema).readonly()
18229
+ deviceId: number().int(),
18230
+ openedAt: number().int(),
18231
+ closedAt: number().int(),
18232
+ timestamp: number().int(),
18233
+ memberCount: number().int(),
18234
+ memberTrackIds: array(string()).readonly(),
18235
+ className: string(),
18236
+ classes: array(string()).readonly(),
18237
+ /** Relative event-media path, or null when the group has no picture yet. */
18238
+ mediaUrl: string().nullable(),
18239
+ singleton: boolean()
18081
18240
  });
18082
- var PipelineModelOptionSchema = object({
18083
- id: string(),
18084
- name: string(),
18085
- formats: record(string(), object({
18086
- downloaded: boolean(),
18087
- sizeMB: number()
18088
- })),
18089
- group: ModelVariantGroupSchema.optional(),
18090
- legacy: boolean().optional(),
18091
- provider: ModelProviderIdSchema.optional()
18241
+ var AnalyticsGroupMemberSchema = object({
18242
+ trackId: string(),
18243
+ deviceId: number().int(),
18244
+ className: string(),
18245
+ firstSeen: number().int(),
18246
+ lastSeen: number().int(),
18247
+ mediaUrl: string().nullable()
18092
18248
  });
18093
- var ConfigFieldBridge = custom();
18094
- var PipelineAddonSchemaSchema = object({
18095
- id: string(),
18096
- name: string(),
18097
- slot: PipelineSlotSchema,
18098
- inputClasses: array(string()).readonly(),
18099
- outputClasses: array(string()).readonly(),
18100
- childSlots: array(PipelineSlotSchema).readonly(),
18101
- models: array(PipelineModelOptionSchema).readonly(),
18102
- defaultModelId: string(),
18103
- defaultModelIdByFormat: record(string(), string()).optional(),
18104
- enabledByDefault: boolean().optional(),
18105
- backfillIntoExistingOverrides: boolean().optional(),
18106
- defaultConfidence: number(),
18107
- group: string().optional(),
18108
- configSchema: array(ConfigFieldBridge).readonly().optional()
18249
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
18250
+ var ListGroupsQueryInput = object({
18251
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
18252
+ deviceIds: array(number()),
18253
+ /** Window lower bound on `closedAt` (inclusive). */
18254
+ since: number().optional(),
18255
+ /** Window upper bound on `openedAt` (inclusive). */
18256
+ until: number().optional(),
18257
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
18258
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
18259
+ cursor: string().optional()
18109
18260
  });
18110
- var PipelineSlotSchemaSchema = object({
18111
- id: PipelineSlotSchema,
18112
- label: string(),
18113
- priority: number(),
18114
- parentSlot: PipelineSlotSchema.nullable(),
18115
- addons: array(PipelineAddonSchemaSchema).readonly()
18261
+ var ListGroupsPageSchema = object({
18262
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
18263
+ nextCursor: string().nullable()
18116
18264
  });
18117
- var PipelineSchemaSchema = object({
18118
- availableEngines: array(AvailableEngineSchema).readonly(),
18119
- selectedEngine: PipelineEngineChoiceSchema,
18120
- slots: array(PipelineSlotSchemaSchema).readonly()
18265
+ var KeyEventQueryInput = object({
18266
+ deviceId: number(),
18267
+ /** Window lower bound (track firstSeen ≥ since). */
18268
+ since: number(),
18269
+ /** Window upper bound (track firstSeen ≤ until). */
18270
+ until: number(),
18271
+ limit: number().int().min(1).max(200).default(50),
18272
+ /** Drop tracks scoring below this importance. */
18273
+ minImportance: number().min(0).max(1).optional(),
18274
+ /** Restrict to a single class (e.g. 'person'). */
18275
+ classFilter: string().optional()
18121
18276
  });
18122
- var EngineProvisioningSchema = object({
18123
- runtimeId: _enum([
18124
- "onnx",
18125
- "openvino",
18126
- "coreml",
18127
- "edgetpu"
18128
- ]).nullable(),
18129
- device: string().nullable(),
18130
- state: _enum([
18131
- "idle",
18132
- "installing",
18133
- "verifying",
18134
- "ready",
18135
- "failed"
18136
- ]),
18137
- progress: number().optional(),
18138
- error: string().optional(),
18139
- nextRetryAt: number().optional(),
18140
- /**
18141
- * Gate A (config-correctness gate at engine change): human-readable
18142
- * config issues surfaced EAGERLY when the node's engine changes — model
18143
- * substitutions ("chose X, running Y") and zero-build steps ("no model
18144
- * has a <format> build"). Additive/optional: informational only, never
18145
- * enforced here — `assertEngineReady` (readiness) still gates inference.
18146
- * Absent/empty when the node-default tree resolves cleanly.
18147
- */
18148
- configIssues: array(string()).optional()
18277
+ var KeyEventSchema = object({
18278
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
18279
+ id: string(),
18280
+ trackId: string(),
18281
+ /** Track start time (firstSeen). */
18282
+ timestamp: number(),
18283
+ className: string(),
18284
+ ...TieredLabelFields,
18285
+ importance: number(),
18286
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
18287
+ bestEventId: string(),
18288
+ /** Track lifetime in ms (lastSeen - firstSeen). */
18289
+ windowMs: number().optional(),
18290
+ ...TrackFlagFields,
18291
+ ...TrackRetrainFields
18149
18292
  });
18150
- var PipelineStepInputSchema = lazy(() => object({
18151
- addonId: string(),
18152
- modelId: string().optional(),
18153
- enabled: boolean().default(true),
18154
- children: array(PipelineStepInputSchema).optional(),
18155
- settings: record(string(), unknown()).optional(),
18156
- jumpDeviceKey: string().optional()
18157
- }));
18158
- var ModelSubstitutionSchema = object({
18159
- addonId: string(),
18160
- chosen: string(),
18161
- running: string(),
18162
- format: string()
18293
+ object({
18294
+ trackId: string(),
18295
+ className: string(),
18296
+ confidence: number(),
18297
+ bbox: BoundingBoxSchema,
18298
+ zones: array(string()).readonly(),
18299
+ state: TrackStateSchema
18163
18300
  });
18164
- var PipelineValidationIssueSchema = object({
18165
- addonId: string(),
18166
- kind: _enum(["unknown-addon", "no-format-build"]),
18167
- detail: string()
18301
+ var OverlayDetectionSchema = looseObject({
18302
+ id: string(),
18303
+ kind: _enum(["first-level", "detail"]),
18304
+ macroClass: string(),
18305
+ score: number(),
18306
+ bbox: object({
18307
+ x: number(),
18308
+ y: number(),
18309
+ width: number(),
18310
+ height: number()
18311
+ }),
18312
+ labels: array(looseObject({
18313
+ label: string(),
18314
+ score: number()
18315
+ })).readonly(),
18316
+ parentId: string().optional()
18168
18317
  });
18169
- var PipelineValidationResultSchema = object({
18170
- ok: boolean(),
18171
- issues: array(PipelineValidationIssueSchema).readonly(),
18172
- substitutions: array(ModelSubstitutionSchema).readonly(),
18173
- /** The node's `currentEngine.format` this validation ran against. */
18174
- format: string()
18318
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
18319
+ var SearchObjectEventsInput = object({
18320
+ text: string(),
18321
+ deviceId: number().optional(),
18322
+ since: number().optional(),
18323
+ until: number().optional(),
18324
+ classFilter: string().optional(),
18325
+ limit: number().default(50),
18326
+ minScore: number().min(0).max(1).default(.2)
18175
18327
  });
18176
- var ReferenceImageEntrySchema = object({
18177
- filename: string(),
18178
- stepIds: array(string()).readonly().optional()
18328
+ var TrackCascadeCountsSchema = object({
18329
+ /** Persisted track roots deleted (authoritative). */
18330
+ tracks: number().int(),
18331
+ /** Object events removed with their tracks (best-effort; see note above). */
18332
+ events: number().int(),
18333
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18334
+ media: number().int(),
18335
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
18336
+ faces: number().int(),
18337
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18338
+ plates: number().int(),
18339
+ /** Per-track CLIP search vectors removed (best-effort). */
18340
+ embeddings: number().int(),
18341
+ /** Group membership + group rows removed with their last member (best-effort). */
18342
+ groups: number().int()
18343
+ });
18344
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18345
+ var DiskReconcileCountsSchema = object({
18346
+ mediaDropped: number().int(),
18347
+ tracks: number().int(),
18348
+ events: number().int()
18349
+ });
18350
+ /** Event-store footprint for one camera. */
18351
+ var EventStoreDeviceFootprintSchema = object({
18352
+ deviceId: number(),
18353
+ /** Persisted event rows (motion + object + audio) for the camera. */
18354
+ rows: number().int(),
18355
+ /** Event-owned media bytes on disk for the camera. */
18356
+ bytes: number().int()
18179
18357
  });
18180
- var ReferenceImageBodySchema = object({
18181
- base64: string(),
18182
- filename: string()
18358
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18359
+ var EventStoreFootprintSchema = object({
18360
+ totalRows: number().int(),
18361
+ totalBytes: number().int(),
18362
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
18183
18363
  });
18184
- var ReferenceAudioEntrySchema = object({
18185
- filename: string(),
18186
- sizeKb: number()
18364
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
18365
+ var EventPruneCountsSchema = object({
18366
+ motion: number().int(),
18367
+ object: number().int(),
18368
+ audio: number().int()
18187
18369
  });
18188
- var ReferenceAudioBodySchema = object({ base64: string() });
18189
- var AudioBackendSchema = object({
18190
- id: string(),
18191
- name: string(),
18192
- description: string(),
18193
- available: boolean(),
18370
+ /**
18371
+ * Re-embed stored tracks from their key frames.
18372
+ *
18373
+ * The reason this is an operator-callable method and not a migration script:
18374
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
18375
+ * squaring — is only changeable if the existing vectors can be regenerated.
18376
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
18377
+ * symptom is a quality regression with no visible cause.
18378
+ */
18379
+ var RebuildObjectEmbeddingsInput = object({
18380
+ /** Restrict to one camera. Omit for the whole fleet. */
18381
+ deviceId: number().optional(),
18382
+ since: number().optional(),
18383
+ until: number().optional(),
18384
+ /** Stop after this many tracks; the result reports whether more remain. */
18385
+ maxTracks: number().int().positive().optional(),
18194
18386
  /**
18195
- * Raw classifier labels this backend can emit (e.g. YAMNet's
18196
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
18197
- * the benchmark UI to populate the `enabledMicroClasses` filter
18198
- * specific to the selected backend without a separate fetch.
18387
+ * Run every embedding on THIS node instead of round-robining the fleet.
18388
+ *
18389
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18390
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18391
+ * calling it that would pin the rebuild REQUEST itself to that node — the
18392
+ * rebuild orchestration lives on the hub, and only the per-track step runs
18393
+ * remotely. This field is data; the per-track pin is applied inside.
18394
+ *
18395
+ * Absent ⇒ round-robin over every online node whose runner can serve the
18396
+ * pinned model.
18199
18397
  */
18200
- rawLabels: array(string()).readonly().optional()
18201
- });
18202
- var AudioCapabilitiesSchema = object({
18203
- activeBackend: string(),
18204
- availableBackends: array(AudioBackendSchema).readonly(),
18205
- sampleRate: number(),
18206
- chunkDurationMs: number()
18207
- });
18208
- var DownloadModelResultSchema = object({
18209
- filePath: string(),
18210
- sizeMB: number(),
18211
- durationMs: number()
18398
+ executeOnNodeId: string().optional(),
18399
+ /**
18400
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18401
+ * run flat out.
18402
+ *
18403
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
18404
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18405
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18406
+ * force is logged at start and finish so a deliberately slow pass reads
18407
+ * differently from a stalled one.
18408
+ */
18409
+ pacingMs: number().int().nonnegative().optional()
18212
18410
  });
18213
18411
  /**
18214
- * Wrapper carrying a single test run's result. Replaces the legacy
18215
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
18216
- * canonical `AudioResult` from the Phase 6 output rework: one
18217
- * `AudioDetection` per class above `minScore`, top-N candidates in
18218
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
18219
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
18220
- * benchmark UI can still report a clean failure when the classifier
18221
- * cap isn't available.
18412
+ * Result of emptying the CLIP index.
18413
+ *
18414
+ * The clean slate before a policy change: a new crop margin or encoder model
18415
+ * leaves two feature spaces in one index whose cosine scores are not
18416
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
18417
+ * means the same thing.
18222
18418
  */
18223
- var AudioTestResultSchema = object({
18224
- success: boolean(),
18225
- error: string().optional(),
18226
- frame: custom().optional()
18419
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18420
+ /**
18421
+ * Acknowledgement that a rebuild STARTED.
18422
+ *
18423
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
18424
+ * runs detached and this returns immediately. Waiting for it made the client
18425
+ * time out while the work carried on server-side, which is the worst of both:
18426
+ * no result and no way to know it was still going. Poll
18427
+ * `getObjectEmbeddingRebuildStatus` for progress.
18428
+ */
18429
+ var RebuildObjectEmbeddingsResultSchema = object({
18430
+ started: boolean(),
18431
+ /** True when a pass was already running; the new request is ignored. */
18432
+ alreadyRunning: boolean()
18227
18433
  });
18228
- var PipelineConfigBridge = custom();
18229
- var ConfigUISchemaBridge = custom();
18230
- var ConfigUISchemaNullableBridge = custom();
18231
- var InferenceCapabilitiesBridge = custom();
18232
- var ModelAvailabilityListBridge = custom();
18233
- var PipelineRunResultBridge = custom();
18234
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
18235
- modelId: string(),
18236
- settings: record(string(), unknown()).readonly()
18237
- }))), method(object({ steps: record(string(), object({
18238
- modelId: string(),
18239
- settings: record(string(), unknown()).readonly()
18240
- })) }), object({ success: literal(true) }), {
18434
+ var RebuildStatusSchema = object({
18435
+ running: boolean(),
18436
+ scanned: number(),
18437
+ rebuilt: number(),
18438
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
18439
+ missingKeyFrame: number(),
18440
+ /** Tracks with no usable detection box. */
18441
+ missingBbox: number(),
18442
+ /**
18443
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
18444
+ * frame, a step that threw. Separate from `failed` because the remedy is
18445
+ * different, and because a whole camera silently contributing zero vectors
18446
+ * is the shape of failure a rebuild must never hide.
18447
+ */
18448
+ notRunnable: number(),
18449
+ /**
18450
+ * The pass stopped because NO node could serve the pinned model.
18451
+ *
18452
+ * Distinct from `notRunnable` on purpose: that one says "this track was
18453
+ * refused", this one says "the cluster cannot do this work at all" — every
18454
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
18455
+ * pinned model for its engine format, or dropped out. The remedy is a model /
18456
+ * engine change, not a per-camera one. Non-zero here always comes with
18457
+ * `complete: false`.
18458
+ */
18459
+ noCapableNode: number(),
18460
+ failed: number(),
18461
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
18462
+ complete: boolean().nullable(),
18463
+ startedAtMs: number().nullable(),
18464
+ finishedAtMs: number().nullable(),
18465
+ /** Present when the pass ended by throwing. */
18466
+ error: string().nullable()
18467
+ });
18468
+ var ReplayFrameInputSchema = object({
18469
+ timestamp: number(),
18470
+ frame: PipelineRunResultBridge
18471
+ });
18472
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
18473
+ className: string(),
18474
+ firstSeenMs: number(),
18475
+ lastSeenMs: number(),
18476
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
18477
+ * frame — a representative box for the diff's `(className, window, IoU)`
18478
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
18479
+ * trajectory production's `Track.positions` keeps. */
18480
+ bbox: BoundingBoxSchema,
18481
+ /** How many of the input frames this track matched a real detection on
18482
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
18483
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
18484
+ framesMatched: number().int()
18485
+ })).readonly() });
18486
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18487
+ deviceId: number(),
18488
+ trackId: string()
18489
+ }), TrackSchema.nullable()), method(object({
18490
+ deviceId: number(),
18491
+ since: number().optional(),
18492
+ until: number().optional(),
18493
+ limit: number().optional(),
18494
+ /** Spatial filter — only tracks whose trajectory intersects the zone
18495
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18496
+ * envelope columns, then precisely tested per position. Tracks with
18497
+ * an unknown envelope (no frame dims at persist time) always match. */
18498
+ zone: TrackZoneFilterSchema.optional(),
18499
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
18500
+ * compatible — omitting the field keeps today's exact behaviour). */
18501
+ projection: TrackProjectionSchema.optional(),
18502
+ /** Include stationary-promoted rows (parked objects handed to the
18503
+ * stationary registry). Default false: the timeline lists passages,
18504
+ * not parking records (operator decision, 2026-08-15). */
18505
+ includeStationary: boolean().optional()
18506
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18507
+ deviceId: number(),
18508
+ groupId: string().min(1)
18509
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18510
+ kind: "mutation",
18511
+ auth: "admin"
18512
+ }), 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({
18513
+ deviceId: number(),
18514
+ since: number().optional(),
18515
+ until: number().optional(),
18516
+ kinds: array(string()).optional(),
18517
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18518
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18519
+ deviceId: number(),
18520
+ since: number(),
18521
+ until: number(),
18522
+ bucketMs: number().int().positive()
18523
+ }), array(object({
18524
+ bucketStart: number(),
18525
+ motion: number().int(),
18526
+ object: number().int(),
18527
+ audio: number().int()
18528
+ })).readonly()), method(object({
18529
+ deviceId: number(),
18530
+ cutoffMs: number()
18531
+ }), object({
18532
+ motion: number().int(),
18533
+ object: number().int(),
18534
+ audio: number().int()
18535
+ }), {
18536
+ kind: "mutation",
18537
+ auth: "admin"
18538
+ }), method(object({
18539
+ deviceId: number(),
18540
+ cutoffMs: number()
18541
+ }), TrackCascadeCountsSchema, {
18542
+ kind: "mutation",
18543
+ auth: "admin"
18544
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18545
+ kind: "mutation",
18546
+ auth: "admin"
18547
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18548
+ kind: "mutation",
18549
+ auth: "admin"
18550
+ }), method(object({
18551
+ deviceId: number(),
18552
+ trackIds: array(string()).min(1)
18553
+ }), object({
18554
+ deleted: number().int(),
18555
+ failed: array(string()).readonly()
18556
+ }), {
18557
+ kind: "mutation",
18558
+ auth: "admin"
18559
+ }), method(object({
18560
+ /** Log/audit scope only — the trackId is globally unique on its own. */
18561
+ deviceId: number(),
18562
+ trackId: string(),
18563
+ flags: TrackFlagsPatchSchema
18564
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18565
+ kind: "query",
18566
+ auth: "admin"
18567
+ }), method(object({
18568
+ olderThanMs: number(),
18569
+ reason: OpsLogReasonSchema.optional()
18570
+ }), EventPruneCountsSchema, {
18571
+ kind: "mutation",
18572
+ auth: "admin"
18573
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
18574
+ kind: "mutation",
18575
+ auth: "admin"
18576
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18241
18577
  kind: "mutation",
18242
18578
  auth: "admin"
18243
- }), method(object({ nodeId: string() }), object({
18244
- success: literal(true),
18245
- clearedDevices: number()
18246
- }), {
18579
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18247
18580
  kind: "mutation",
18248
18581
  auth: "admin"
18249
- }), method(_void(), PipelineSchemaSchema), method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()), method(_void(), PipelineConfigBridge), method(_void(), ConfigUISchemaBridge), method(object({ steps: array(PipelineStepInputSchema) }), PipelineValidationResultSchema), method(_void(), array(PipelineTemplateSchema$1).readonly()), method(object({
18250
- name: string(),
18251
- steps: array(PipelineTemplateStepSchema).readonly(),
18252
- engine: PipelineEngineChoiceSchema
18253
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
18254
- id: string(),
18255
- name: string().optional(),
18256
- steps: array(PipelineTemplateStepSchema).readonly().optional()
18257
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
18258
- addonId: string(),
18259
- modelId: string(),
18260
- format: ModelFormatSchema$1
18261
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
18262
- addonId: string(),
18263
- modelId: string(),
18264
- format: ModelFormatSchema$1
18265
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
18266
- engine: PipelineEngineChoiceSchema.optional(),
18267
- steps: array(PipelineStepInputSchema).min(1),
18268
- frame: FrameInputSchema.optional(),
18269
- /**
18270
- * Process-local lazy frame. Valid only when caller and provider resolve
18271
- * in the same execution-group process; split/cross-node callers use
18272
- * `frame`/`image` inline compatibility instead.
18273
- */
18274
- frameRef: FrameRefSchema.optional(),
18275
- /**
18276
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
18277
- * the decoded pixels live in. One more member of the one-of
18278
- * frame/frameHandle/image/imageBase64/referenceImage group.
18279
- */
18280
- frameHandle: FrameHandleSchema.optional(),
18281
- imageBase64: string().optional(),
18282
- /**
18283
- * Binary JPEG bytes — preferred over `imageBase64` on internal
18284
- * hops (hub → forked worker via Moleculer MsgPack) because it
18285
- * skips the 33% base64 overhead + the per-call base64 decode on
18286
- * the detection-pipeline worker. Callers can pass either; exactly
18287
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
18288
- */
18289
- image: _instanceof(Uint8Array).optional(),
18290
- referenceImage: string().optional(),
18291
- deviceId: number().optional(),
18292
- sessionId: string().optional(),
18293
- /**
18294
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
18295
- * reference-image, and detail-subtree calls. 'frame' is the live
18296
- * per-frame dispatch: ONLY root-plane steps run; crop children
18297
- * (inputClasses ≠ null) are skipped and served per-track via
18298
- * pipelineRunner.runDetailSubtree (two-plane design).
18299
- */
18300
- plane: _enum(["full", "frame"]).optional(),
18301
- /**
18302
- * Inference-device selector (Phase 2 multi-device). Format
18303
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
18304
- * Omitted ⇒ the runner's default device (current single-engine
18305
- * behaviour). Selects WHICH device pool of the node runs the call.
18306
- */
18307
- deviceKey: string().optional(),
18308
- /**
18309
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
18310
- * when the parent crop was resolved from the frame's retained NATIVE
18311
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
18312
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
18313
- * resolution from that surface — the SAME quality path faces already
18314
- * had — instead of the downscaled parent tile. `handle` keys the native
18315
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
18316
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
18317
- * the executor's crop-normalized child ROI back into frame-normalized
18318
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
18319
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
18320
- * (today's behaviour on the fallback path).
18321
- */
18322
- nativeCropRef: NativeCropRefSchema.optional()
18323
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
18324
- engine: PipelineEngineChoiceSchema.optional(),
18325
- steps: array(PipelineStepInputSchema).min(1),
18326
- frames: array(FrameInputSchema).min(1).max(255),
18327
- deviceId: number().optional(),
18328
- sessionId: string().optional(),
18329
- /**
18330
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
18331
- * the batch to the Python pool's bench preprocess cache
18332
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
18333
- * preprocessed ONCE and every later inference is a pure-inference cache
18334
- * hit — the sustained-throughput run measures inference, not
18335
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
18336
- * full preprocess every call, correct). Fresh per sustained run;
18337
- * released via `uncacheFrame`.
18338
- */
18339
- frameId: number().int().nonnegative().optional(),
18340
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
18341
- deviceKey: string().optional()
18342
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
18343
- data: _instanceof(Uint8Array),
18344
- width: number().int().positive(),
18345
- height: number().int().positive(),
18346
- format: _enum([
18347
- "rgb",
18348
- "bgr",
18349
- "gray"
18350
- ])
18582
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18583
+ kind: "mutation",
18584
+ auth: "admin"
18585
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
18586
+ kind: "mutation",
18587
+ auth: "admin"
18588
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18589
+ kind: "mutation",
18590
+ auth: "admin"
18591
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18592
+ kind: "mutation",
18593
+ auth: "admin"
18594
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
18595
+ kind: "query",
18596
+ auth: "admin"
18597
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18598
+ kind: "mutation",
18599
+ auth: "admin"
18600
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18601
+ kind: "query",
18602
+ auth: "admin"
18603
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
18604
+ kind: "query",
18605
+ auth: "admin"
18606
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18607
+ kind: "query",
18608
+ auth: "admin"
18609
+ }), method(object({
18610
+ /** Empty every camera that has staging tracks. A LIST, not a single
18611
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
18612
+ * route it at one camera's owner, and "every camera" would stop being
18613
+ * expressible at all. */
18614
+ deviceIds: array(number()).optional(),
18615
+ limit: number().int().min(1).max(500).optional()
18616
+ }), array(RetrainTrackSchema).readonly(), {
18617
+ kind: "query",
18618
+ auth: "admin"
18619
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
18620
+ kind: "query",
18621
+ auth: "admin"
18622
+ }), method(object({
18623
+ deviceId: number(),
18624
+ trackId: string(),
18625
+ mediaKeys: array(string()).min(1)
18626
+ }), RetrainFrameSelectionSchema, {
18627
+ kind: "mutation",
18628
+ auth: "admin"
18629
+ }), method(object({
18630
+ deviceId: number(),
18631
+ trackId: string(),
18632
+ frameId: string()
18351
18633
  }), object({
18352
- frameId: number(),
18353
- width: number(),
18354
- height: number()
18355
- }), { kind: "mutation" }), method(object({
18356
- stepId: string(),
18357
- frameId: number().int()
18358
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
18359
- batchMode: string(),
18360
- windowMs: number(),
18361
- maxBatchSize: number(),
18362
- concurrency: number()
18363
- })), method(_void(), array(object({
18364
- engineKey: string(),
18365
- engine: PipelineEngineChoiceSchema,
18366
- modelsLoaded: array(string()).readonly(),
18367
- inUseByCameras: array(number()).readonly(),
18368
- /**
18369
- * Origin of this resident factory.
18370
- * - `runtime` — main camera-serving engine (no idle TTL).
18371
- * - `warm-override` — benchmark/test override held in the warm
18372
- * cache; auto-disposed after the idle TTL.
18373
- * - `device-pool` — a concurrent per-device pool (Phase 2
18374
- * multi-device, keyed by `deviceKey`) resolved
18375
- * via `resolveDeviceFactory`. Runs alongside the
18376
- * `runtime` engine on a DIFFERENT accelerator
18377
- * (NPU / iGPU / Coral) — this is how the
18378
- * Engines tab shows all pools running at once.
18379
- */
18380
- kind: _enum([
18381
- "runtime",
18382
- "warm-override",
18383
- "device-pool"
18384
- ]),
18385
- /** Native pid of the underlying Python pool (null when no pool). */
18386
- poolPid: number().nullable(),
18387
- /** ms since this factory was last used (null when not warm-tracked). */
18388
- idleMs: number().nullable(),
18389
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
18390
- idleTtlMs: number().nullable()
18391
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
18634
+ removed: boolean(),
18635
+ removedAnnotations: number().int()
18636
+ }), {
18637
+ kind: "mutation",
18638
+ auth: "admin"
18639
+ }), method(object({ frameId: string() }), object({
18640
+ base64: string(),
18641
+ width: number().int(),
18642
+ height: number().int()
18643
+ }), {
18644
+ kind: "query",
18645
+ auth: "admin"
18646
+ }), method(object({
18647
+ deviceId: number(),
18648
+ trackId: string(),
18649
+ frameId: string(),
18650
+ subject: RetrainAssistSubjectSchema,
18651
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18652
+ nodeId: string().optional()
18653
+ }), RetrainAssistResultSchema, {
18654
+ kind: "mutation",
18655
+ auth: "admin"
18656
+ }), method(object({
18657
+ deviceId: number(),
18658
+ source: DetectionSourceSchema,
18659
+ zones: array(ZoneSchema).readonly().optional(),
18660
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
18661
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
18662
+ frames: array(ReplayFrameInputSchema).min(1)
18663
+ }), RunReplayFrameProcessorResultSchema, {
18664
+ kind: "mutation",
18665
+ auth: "admin"
18666
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18667
+ kind: "query",
18668
+ auth: "admin"
18669
+ }), method(object({
18670
+ deviceId: number(),
18671
+ trackId: string(),
18672
+ frameId: string(),
18673
+ annotations: array(RetrainAnnotationDraftSchema)
18674
+ }), array(RetrainAnnotationSchema).readonly(), {
18675
+ kind: "mutation",
18676
+ auth: "admin"
18677
+ }), method(object({
18678
+ deviceId: number(),
18679
+ trackId: string()
18680
+ }), RetrainTransitionResultSchema, {
18681
+ kind: "mutation",
18682
+ auth: "admin"
18683
+ }), method(object({
18684
+ deviceId: number(),
18685
+ trackId: string()
18686
+ }), RetrainTransitionResultSchema, {
18687
+ kind: "mutation",
18688
+ auth: "admin"
18689
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18690
+ kind: "query",
18691
+ auth: "admin"
18692
+ }), method(object({
18693
+ eventId: string(),
18694
+ kind: MediaFileKindEnum.optional(),
18695
+ deviceId: number()
18696
+ }), array(MediaFileSchema).readonly()), method(object({
18697
+ trackId: string(),
18698
+ kinds: array(MediaFileKindEnum).optional(),
18699
+ deviceId: number()
18700
+ }), array(MediaFileSchema).readonly()), method(object({
18701
+ trackId: string(),
18702
+ deviceId: number()
18703
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18392
18704
  kind: "mutation",
18393
18705
  auth: "admin"
18394
- }), method(object({
18395
- engine: PipelineEngineChoiceSchema,
18396
- force: boolean().optional()
18397
- }), object({
18398
- success: boolean(),
18399
- reason: string().optional()
18400
- }), {
18706
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18401
18707
  kind: "mutation",
18402
18708
  auth: "admin"
18403
- }), method(_void(), array(ReferenceImageEntrySchema).readonly()), method(object({ filename: string() }), ReferenceImageBodySchema.nullable()), method(_void(), array(ReferenceAudioEntrySchema).readonly()), method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()), method(_void(), AudioCapabilitiesSchema), method(object({
18404
- addonId: string(),
18405
- modelId: string(),
18406
- filename: string().optional(),
18407
- settings: record(string(), unknown()).optional()
18408
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
18709
+ }), method(object({}), RebuildStatusSchema), object({
18710
+ deviceId: number(),
18711
+ timestamp: number(),
18712
+ frameWidth: number(),
18713
+ frameHeight: number(),
18714
+ detections: array(OverlayDetectionSchema).readonly()
18715
+ }), object({
18716
+ deviceId: number(),
18717
+ trackId: string(),
18718
+ className: string()
18719
+ }), object({
18720
+ deviceId: number(),
18721
+ trackId: string(),
18722
+ className: string(),
18723
+ durationMs: number()
18724
+ }), object({
18725
+ deviceId: number(),
18726
+ kind: EventKindSchema,
18727
+ eventId: string(),
18728
+ timestamp: number()
18729
+ });
18409
18730
  object({
18410
18731
  activeCameras: number(),
18411
18732
  throttledCameras: number(),
@@ -18431,106 +18752,6 @@ var CameraMetricsSchema = object({
18431
18752
  });
18432
18753
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18433
18754
  /**
18434
- * Zone — pure geometry + identity. NO filtering behaviour.
18435
- *
18436
- * Zones describe **where** in the frame the operator wants to flag
18437
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
18438
- * each pipeline stage uses them. Splitting the two means a single
18439
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
18440
- * a detection-include rule on `['car']`, and an occupancy aggregate
18441
- * — without three duplicated polygons.
18442
- *
18443
- * Owned by the orchestrator addon (provider) and mirrored into the
18444
- * `zones` device-state slice on every mutation. Consumers
18445
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18446
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18447
- * mirror with `onChanged`).
18448
- *
18449
- * Coordinates are normalised fractions of the frame (0–1) so zones
18450
- * survive resolution changes and stream profile switches.
18451
- *
18452
- * `kind` discriminates between full polygons (closed regions used
18453
- * for intrusion / occupancy filters) and tripwires (open 2-point
18454
- * line segments used for cross events). Onboard / firmware-reported
18455
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18456
- * task list.
18457
- */
18458
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18459
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18460
- var PolygonPointSchema = object({
18461
- x: number(),
18462
- y: number()
18463
- });
18464
- /** A camera detection zone — pure geometry/identity. */
18465
- var ZoneSchema = object({
18466
- id: string(),
18467
- name: string(),
18468
- kind: ZoneKindEnum.default("polygon"),
18469
- /** Polygon vertices, fraction of frame (0–1). */
18470
- polygon: array(PolygonPointSchema).readonly(),
18471
- /** Visual color for UI rendering. */
18472
- color: string().default("#3b82f6")
18473
- });
18474
- /**
18475
- * Zones capability — per-camera CRUD over polygon detection zones.
18476
- *
18477
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
18478
- * to per-device settings and mirrors into the `zones` device-state
18479
- * slice on every mutation, so downstream consumers can subscribe via
18480
- * `dev.state.zones.onChanged`.
18481
- *
18482
- * The cap surface only handles geometry + identity; filtering
18483
- * behaviour (per-class, include/exclude, threshold) lives in the
18484
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
18485
- * `capabilities/schemas/zone-rule.js`.
18486
- */
18487
- var zonesCapability = {
18488
- name: "zones",
18489
- scope: "device",
18490
- mode: "singleton",
18491
- deviceTypes: [DeviceType.Camera],
18492
- methods: {
18493
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
18494
- addZone: method(object({
18495
- deviceId: number(),
18496
- zone: ZoneSchema
18497
- }), _void(), {
18498
- kind: "mutation",
18499
- auth: "admin"
18500
- }),
18501
- removeZone: method(object({
18502
- deviceId: number(),
18503
- zoneId: string()
18504
- }), _void(), {
18505
- kind: "mutation",
18506
- auth: "admin"
18507
- }),
18508
- updateZone: method(object({
18509
- deviceId: number(),
18510
- zone: ZoneSchema
18511
- }), _void(), {
18512
- kind: "mutation",
18513
- auth: "admin"
18514
- })
18515
- },
18516
- /**
18517
- * Runtime-state slice — the live zone catalogue mirrored by the
18518
- * orchestrator on every CRUD mutation. Consumers read via
18519
- * `device.state.zones.value` / `.watch(...)` without round-tripping
18520
- * the cap, and the codegen DeviceProxy auto-wires the reactive
18521
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
18522
- * (e.g. zone groupings) can sit alongside the polygon list.
18523
- */
18524
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
18525
- /**
18526
- * Runtime-state durability: **restored** — written only on operator mutation, so a camera that never had one has nothing to re-derive from. This is the slice `zone-mirror-hydration.ts` exists to paper over.
18527
- *
18528
- * See `RuntimeStateDurability`. Enforced by
18529
- * `scripts/check-runtime-state-durability.ts`.
18530
- */
18531
- durability: "restored"
18532
- };
18533
- /**
18534
18755
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
18535
18756
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
18536
18757
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -27930,92 +28151,6 @@ var sceneMonitorCapability = {
27930
28151
  durability: "session"
27931
28152
  };
27932
28153
  /**
27933
- * Per-stage gating mode applied to the zones a rule references.
27934
- *
27935
- * - `include`: the rule contributes to a **whitelist** for its stage.
27936
- * When at least one `include` rule fires for a stage, only entities
27937
- * inside one of those zones pass that stage.
27938
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
27939
- * Entities inside one of those zones are dropped at that stage.
27940
- *
27941
- * `monitor`-style observation (count without filtering) is not a rule
27942
- * mode — zones without any matching rule are observed naturally by
27943
- * `zone-analytics` (live snapshot + history), so an "I just want to
27944
- * count, not filter" use case needs no rule at all.
27945
- */
27946
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
27947
- /**
27948
- * Per-consumer rule that references existing zones (geometry) and
27949
- * defines how a specific pipeline stage should treat them. Each
27950
- * consumer addon owns its own `ZoneRule[]` array in its per-device
27951
- * settings:
27952
- *
27953
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
27954
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
27955
- * - future: notification rules, audio gating, etc.
27956
- *
27957
- * One rule applies to N zones (`zoneIds[]`) so the operator can
27958
- * express "ignore motion in ALL of {garden, street}" with a single
27959
- * rule. `classFilter` narrows the rule to specific object classes —
27960
- * "drop person detections in the street, but keep cars" is one
27961
- * `exclude` rule with `classFilter: ['person']`.
27962
- *
27963
- * `enabled` is a soft toggle — the operator can keep the rule
27964
- * configured but inert without deleting it.
27965
- */
27966
- var ZoneRuleSchema = object({
27967
- /** Stable rule id — survives edits, used by the UI for diffing. */
27968
- id: string(),
27969
- /** Optional human-readable label rendered in the rule editor. */
27970
- name: string().optional(),
27971
- /** Zones this rule targets. The rule's `mode` applies to ALL
27972
- * listed zones (OR-set: a detection in any one of them counts).
27973
- * At least one zone id required — a rule with no targets is a
27974
- * configuration mistake and the form validator rejects it. */
27975
- zoneIds: array(string()).min(1).readonly(),
27976
- mode: ZoneRuleModeEnum,
27977
- /**
27978
- * Class names this rule applies to. Empty / undefined ⇒ rule
27979
- * applies to every class. Class strings match the `macroClass`
27980
- * field on detections (e.g. `person`, `car`, `dog`).
27981
- */
27982
- classFilter: array(string()).readonly().optional(),
27983
- /**
27984
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
27985
- * required to consider an entity "in the zone". Defaults to the
27986
- * consumer's stage default when omitted. Kept for back-compat with
27987
- * existing per-rule overrides; new operators pick the value via
27988
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
27989
- * set, the lower-level engine reads it as a 0–1 fraction.
27990
- */
27991
- overlapThreshold: number().min(0).max(1).optional(),
27992
- /**
27993
- * Operator-friendly version of `overlapThreshold` — the percentage
27994
- * of the detection's bbox that must lie inside the zone for the
27995
- * rule to match. Documented default is 85%; the engine substitutes
27996
- * that when the field is omitted (kept optional so existing rules
27997
- * stored without it stay valid).
27998
- *
27999
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
28000
- * rule, the engine prefers `bboxInclusionPct` because it's the
28001
- * field exposed in the UI. Internally both feed the same gate.
28002
- */
28003
- bboxInclusionPct: number().min(0).max(100).optional(),
28004
- /**
28005
- * When `true` and a detection has a segmentation mask, use the
28006
- * mask for overlap instead of the bbox. Detection-stage only;
28007
- * motion rules ignore this field.
28008
- */
28009
- preferMask: boolean().optional(),
28010
- /**
28011
- * Soft-toggle: `false` disables the rule without deleting it.
28012
- * Defaults to `true` so operators creating a rule via the UI
28013
- * see it active immediately.
28014
- */
28015
- enabled: boolean().default(true)
28016
- });
28017
- array(ZoneRuleSchema).readonly();
28018
- /**
28019
28154
  * Script-runner cap. Models HA `script.*` entities on
28020
28155
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
28021
28156
  * that can be invoked imperatively — optionally with a variables
@@ -33952,6 +34087,12 @@ Object.freeze({
33952
34087
  addonId: null,
33953
34088
  access: "create"
33954
34089
  },
34090
+ "pipelineAnalytics.runReplayFrameProcessor": {
34091
+ capName: "pipeline-analytics",
34092
+ capScope: "device",
34093
+ addonId: null,
34094
+ access: "create"
34095
+ },
33955
34096
  "pipelineAnalytics.saveRetrainAnnotations": {
33956
34097
  capName: "pipeline-analytics",
33957
34098
  capScope: "device",
@@ -34084,6 +34225,12 @@ Object.freeze({
34084
34225
  addonId: null,
34085
34226
  access: "view"
34086
34227
  },
34228
+ "pipelineExecutor.getInferenceDeviceHealth": {
34229
+ capName: "pipeline-executor",
34230
+ capScope: "system",
34231
+ addonId: null,
34232
+ access: "view"
34233
+ },
34087
34234
  "pipelineExecutor.getOrchestratorConfigSchema": {
34088
34235
  capName: "pipeline-executor",
34089
34236
  capScope: "system",
@@ -34156,6 +34303,12 @@ Object.freeze({
34156
34303
  addonId: null,
34157
34304
  access: "view"
34158
34305
  },
34306
+ "pipelineExecutor.rearmInferenceDevice": {
34307
+ capName: "pipeline-executor",
34308
+ capScope: "system",
34309
+ addonId: null,
34310
+ access: "create"
34311
+ },
34159
34312
  "pipelineExecutor.runAudioTest": {
34160
34313
  capName: "pipeline-executor",
34161
34314
  capScope: "system",
@@ -37404,6 +37557,11 @@ Object.freeze({
37404
37557
  form: "single",
37405
37558
  optional: false
37406
37559
  }],
37560
+ "pipelineAnalytics.runReplayFrameProcessor": [{
37561
+ name: "deviceId",
37562
+ form: "single",
37563
+ optional: false
37564
+ }],
37407
37565
  "pipelineAnalytics.saveRetrainAnnotations": [{
37408
37566
  name: "deviceId",
37409
37567
  form: "single",
@@ -38828,6 +38986,12 @@ Object.defineProperty(exports, "BaseDeviceProvider", {
38828
38986
  return BaseDeviceProvider;
38829
38987
  }
38830
38988
  });
38989
+ Object.defineProperty(exports, "CAMERA_SWITCH_ORDER", {
38990
+ enumerable: true,
38991
+ get: function() {
38992
+ return CAMERA_SWITCH_ORDER;
38993
+ }
38994
+ });
38831
38995
  Object.defineProperty(exports, "COCO_TO_MACRO", {
38832
38996
  enumerable: true,
38833
38997
  get: function() {
@@ -39134,6 +39298,12 @@ Object.defineProperty(exports, "motionCapability", {
39134
39298
  return motionCapability;
39135
39299
  }
39136
39300
  });
39301
+ Object.defineProperty(exports, "nodePin", {
39302
+ enumerable: true,
39303
+ get: function() {
39304
+ return nodePin;
39305
+ }
39306
+ });
39137
39307
  Object.defineProperty(exports, "normalizeUnit", {
39138
39308
  enumerable: true,
39139
39309
  get: function() {