@camstack/addon-matter-broker 0.2.28 → 0.2.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +1968 -1820
  2. package/dist/addon.mjs +1968 -1820
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -15862,7 +15862,23 @@ var NcHistoryEntrySchema = object({
15862
15862
  updatedAt: number(),
15863
15863
  /** Failure detail — present on a `dead` row. */
15864
15864
  error: string$2().optional(),
15865
- subject: NcHistorySubjectSchema
15865
+ subject: NcHistorySubjectSchema,
15866
+ /**
15867
+ * Ids of the artefacts (still, then gif, then clip) this row's successful
15868
+ * delivery indexed in the artefact library — a REFERENCE, never the bytes
15869
+ * (an artefact is often megabytes; this row is durable JSON rewritten on
15870
+ * every delivery attempt). Absent on a row still pending/dead, a row
15871
+ * delivered before this field shipped, or a wiring with no artefact index.
15872
+ *
15873
+ * Resolve one to a fetchable URL with `resolveArtifactUrl` — an id
15874
+ * outlives any one URL's TTL, so a caller mints a fresh link on demand
15875
+ * rather than trusting one frozen at delivery time. `resolveArtifactUrl`
15876
+ * also answers `null` for an id whose artefact has since expired past the
15877
+ * retained shelf's own age bound — the degrade a caller (the Home
15878
+ * Assistant export) must render as "no image right now", never as a
15879
+ * broken link.
15880
+ */
15881
+ artifactIds: array(string$2().min(1)).optional()
15866
15882
  });
15867
15883
  /**
15868
15884
  * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
@@ -16089,7 +16105,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
16089
16105
  }), method(object({}), object({
16090
16106
  catalog: array(NcConditionDescriptorSchema),
16091
16107
  taxonomy: NcTaxonomySchema.optional()
16092
- })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" }), method(object({}), object({ snoozes: array(NcSnoozeSchema) }), { caller: "required" }), method(object({ snooze: NcSnoozeInputSchema }), object({ snooze: NcSnoozeSchema }), {
16108
+ })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" }), method(object({ artifactId: string$2().min(1) }), object({ url: string$2().nullable() }), { auth: "admin" }), method(object({}), object({ snoozes: array(NcSnoozeSchema) }), { caller: "required" }), method(object({ snooze: NcSnoozeInputSchema }), object({ snooze: NcSnoozeSchema }), {
16093
16109
  kind: "mutation",
16094
16110
  caller: "required"
16095
16111
  }), method(object({ snoozeId: string$2() }), object({ success: literal(true) }), {
@@ -16429,1760 +16445,1996 @@ var OauthIntegrationDescriptorSchema = object({
16429
16445
  });
16430
16446
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
16431
16447
  /**
16432
- * pipeline-analytics device-scoped wrapper cap. Refines raw
16433
- * per-frame detections emitted by the pipeline runner into tracked
16434
- * objects, per-kind event collections (motion / object / audio), and
16435
- * persisted media. Owns the post-detection domain end-to-end:
16436
- *
16437
- * runner emits PipelineInferenceResult
16438
- * ↓ (event bus)
16439
- * pipeline-analytics subscriber
16440
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
16441
- * → three DB collections (one per kind), one FS media tree, one
16442
- * unified event emitter (FrameTracked + TrackStarted/Ended +
16443
- * DetectionEvent on bus)
16444
- *
16445
- * Pure subscriber model. No `processFrame` cap method — the runner
16446
- * already publishes the raw frame on the bus. The cap surface is
16447
- * only QUERIES + per-device settings, bound on/off via
16448
- * `device-manager.setWrapperActive`. `defaultActive: true` because
16449
- * every camera with a detection pipeline wants its raw detections
16450
- * refined; operators opt out per-device via BindingsTab when needed.
16451
- *
16452
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
16453
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
16448
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
16449
+ * within the frame, so the executor can re-cut a leaf child ROI at native
16450
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
16454
16451
  */
16455
- var TrackStateSchema = _enum([
16456
- "new",
16457
- "entered",
16458
- "left",
16459
- "moving",
16460
- "idle"
16461
- ]);
16462
- var EventKindSchema = _enum([
16463
- "motion",
16464
- "object",
16465
- "audio"
16466
- ]);
16452
+ var NativeCropRefSchema = object({
16453
+ /** Handle keying the retained native surface (node-pinned to its owner). */
16454
+ handle: FrameHandleSchema,
16455
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
16456
+ cropFrameSpace: object({
16457
+ x: number(),
16458
+ y: number(),
16459
+ w: number(),
16460
+ h: number()
16461
+ })
16462
+ });
16463
+ object({
16464
+ crop: object({
16465
+ left: number(),
16466
+ top: number(),
16467
+ width: number().positive(),
16468
+ height: number().positive()
16469
+ }).optional(),
16470
+ content: object({
16471
+ width: number().int().positive(),
16472
+ height: number().int().positive()
16473
+ }),
16474
+ fit: _enum(["stretch", "contain"]),
16475
+ format: _enum([
16476
+ "rgb",
16477
+ "gray",
16478
+ "jpeg"
16479
+ ])
16480
+ });
16467
16481
  /**
16468
- * Spatial filter for `listTracks` the rect + polygon variants of the shared
16469
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
16470
- * of the camera frame (top-left origin), matching the drawing-plane editor.
16482
+ * Process-local frame identity. It is serializable so it can ride an in-process
16483
+ * capability call, but `registryId` deliberately prevents resolution in any
16484
+ * other process or execution group.
16471
16485
  */
16472
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
16473
- /** Closed icon vocabulary so clients render a known glyph per kind. */
16474
- var EventKindIconSchema = _enum([
16475
- "motion",
16476
- "audio",
16477
- "person",
16478
- "vehicle",
16479
- "animal",
16480
- "door",
16481
- "pir",
16482
- "smoke",
16483
- "water",
16484
- "button",
16485
- "package",
16486
- "generic"
16486
+ var FrameRefSchema = object({
16487
+ registryId: string$2().min(1),
16488
+ id: string$2().min(1),
16489
+ width: number().int().positive(),
16490
+ height: number().int().positive(),
16491
+ format: _enum(["rgb", "gray"]),
16492
+ timestamp: number(),
16493
+ capturedAt: number().optional()
16494
+ });
16495
+ var ModelFormatSchema$1 = _enum([
16496
+ "onnx",
16497
+ "coreml",
16498
+ "openvino",
16499
+ "tflite",
16500
+ "pt",
16501
+ "gguf"
16487
16502
  ]);
16488
- var EventKindCategorySchema = _enum([
16489
- "motion",
16490
- "audio",
16491
- "detection",
16492
- "sensor",
16493
- "control",
16494
- "custom",
16495
- "package"
16503
+ var PipelineSlotSchema = _enum([
16504
+ "detector",
16505
+ "cropper",
16506
+ "classifier",
16507
+ "refiner",
16508
+ "audio-classifier"
16496
16509
  ]);
16497
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
16498
- var EventKindLevelSchema = _enum(["macro", "sub"]);
16499
- var EventKindDescriptorSchema = object({
16500
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
16501
- kind: string$2(),
16502
- /** i18n key resolved on the UI side; `label` is the English fallback. */
16503
- labelKey: string$2(),
16504
- /** English fallback label (kept for clients that don't translate). */
16505
- label: string$2(),
16506
- /** Hex color for timeline/legend rendering. */
16507
- color: string$2(),
16508
- /** Dictionary id → lucide component on the UI side. */
16509
- iconId: string$2(),
16510
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
16511
- icon: EventKindIconSchema,
16512
- category: EventKindCategorySchema,
16513
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
16514
- parentKind: string$2().nullable(),
16515
- /** Derived from `parentKind`, explicit for the client tree. */
16516
- level: EventKindLevelSchema,
16517
- /** Which cap + device contributes this kind. For built-ins the camera
16518
- * itself; for sensor kinds the LINKED source device. */
16519
- source: object({
16520
- capName: string$2(),
16521
- deviceId: number()
16522
- })
16510
+ var PipelineEngineChoiceSchema = object({
16511
+ runtime: _enum(["node", "python"]),
16512
+ backend: string$2(),
16513
+ format: ModelFormatSchema$1,
16514
+ device: string$2().optional()
16523
16515
  });
16524
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
16525
- var EventKindsForDeviceSchema = object({
16526
- deviceId: number(),
16527
- kinds: array(EventKindDescriptorSchema).readonly()
16516
+ var AvailableEngineSchema = object({
16517
+ engine: PipelineEngineChoiceSchema,
16518
+ devices: array(object({
16519
+ id: string$2(),
16520
+ label: string$2(),
16521
+ description: string$2().optional()
16522
+ })).readonly(),
16523
+ defaultDevice: string$2()
16528
16524
  });
16529
- var SensorEventSchema = object({
16525
+ var PipelineDefaultStepSchema = lazy(() => object({
16526
+ addonId: string$2(),
16527
+ addonName: string$2(),
16528
+ slot: PipelineSlotSchema,
16529
+ inputClasses: array(string$2()).readonly(),
16530
+ outputClasses: array(string$2()).readonly(),
16531
+ enabled: boolean(),
16532
+ modelId: string$2(),
16533
+ children: array(PipelineDefaultStepSchema).readonly(),
16534
+ group: string$2().optional(),
16535
+ settings: record(string$2(), unknown()).optional()
16536
+ }));
16537
+ var PipelineTemplateStepSchema = lazy(() => object({
16538
+ addonId: string$2(),
16539
+ enabled: boolean(),
16540
+ modelId: string$2(),
16541
+ children: array(PipelineTemplateStepSchema).readonly(),
16542
+ settings: record(string$2(), unknown()).optional()
16543
+ }));
16544
+ var PipelineTemplateSchema$1 = object({
16530
16545
  id: string$2(),
16531
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
16532
- * yields N rows, one per camera). */
16533
- deviceId: number(),
16534
- /** The linked sensor device whose state changed. */
16535
- sourceDeviceId: number(),
16536
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
16537
- kind: string$2(),
16538
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
16539
- value: record(string$2(), unknown()).nullable(),
16540
- timestamp: number()
16546
+ name: string$2(),
16547
+ createdAt: string$2(),
16548
+ updatedAt: string$2(),
16549
+ engine: PipelineEngineChoiceSchema,
16550
+ steps: array(PipelineTemplateStepSchema).readonly()
16541
16551
  });
16542
- var TrackPositionSchema = object({
16543
- x: number(),
16544
- y: number(),
16545
- timestamp: number(),
16546
- bbox: BoundingBoxSchema
16552
+ var PipelineModelOptionSchema = object({
16553
+ id: string$2(),
16554
+ name: string$2(),
16555
+ formats: record(string$2(), object({
16556
+ downloaded: boolean(),
16557
+ sizeMB: number()
16558
+ })),
16559
+ group: ModelVariantGroupSchema.optional(),
16560
+ legacy: boolean().optional(),
16561
+ provider: ModelProviderIdSchema.optional()
16547
16562
  });
16548
- var TrackSnapshotSchema = object({
16549
- timestamp: number(),
16550
- position: TrackPositionSchema,
16551
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
16552
- mediaKey: string$2()
16563
+ var ConfigFieldBridge = custom();
16564
+ var PipelineAddonSchemaSchema = object({
16565
+ id: string$2(),
16566
+ name: string$2(),
16567
+ slot: PipelineSlotSchema,
16568
+ inputClasses: array(string$2()).readonly(),
16569
+ outputClasses: array(string$2()).readonly(),
16570
+ childSlots: array(PipelineSlotSchema).readonly(),
16571
+ models: array(PipelineModelOptionSchema).readonly(),
16572
+ defaultModelId: string$2(),
16573
+ defaultModelIdByFormat: record(string$2(), string$2()).optional(),
16574
+ enabledByDefault: boolean().optional(),
16575
+ backfillIntoExistingOverrides: boolean().optional(),
16576
+ defaultConfidence: number(),
16577
+ group: string$2().optional(),
16578
+ configSchema: array(ConfigFieldBridge).readonly().optional()
16553
16579
  });
16554
- /**
16555
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
16556
- * divided by the track's detection-frame dims), computed at persist time.
16557
- * Absent when the frame dims were unknown when the track was persisted
16558
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
16559
- */
16560
- var TrackEnvelopeSchema = object({
16561
- minX: number(),
16562
- minY: number(),
16563
- maxX: number(),
16564
- maxY: number()
16580
+ var PipelineSlotSchemaSchema = object({
16581
+ id: PipelineSlotSchema,
16582
+ label: string$2(),
16583
+ priority: number(),
16584
+ parentSlot: PipelineSlotSchema.nullable(),
16585
+ addons: array(PipelineAddonSchemaSchema).readonly()
16565
16586
  });
16566
- /**
16567
- * Row projection for track list queries. `full` (default) returns the
16568
- * complete Track including the frame-rate `positions[]` history and the
16569
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
16570
- * keeps every scalar the list surfaces actually render (ids, class(es),
16571
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
16572
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
16573
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
16574
- * `getTrack`. Mirrors the event-store `projection` convention
16575
- * (`getObjectEvents` et al.).
16576
- */
16577
- var TrackProjectionSchema = _enum(["full", "slim"]);
16578
- /**
16579
- * One audio-classification label heard on the track's camera while the
16580
- * track was alive, aggregated per label. An "episode" is one persisted
16581
- * audio event (the confident-classification path: score ≥ the device's
16582
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
16583
- * one 32 ms inference chunk, so counts stay human-scaled.
16584
- */
16585
- var TrackAudioLabelSchema = object({
16586
- label: string$2(),
16587
- /** Highest classification score observed across the label's episodes. */
16588
- peakScore: number(),
16589
- /** Number of coalesced audio-event episodes carrying this label. */
16590
- count: number(),
16591
- firstAt: number(),
16592
- lastAt: number()
16587
+ var PipelineSchemaSchema = object({
16588
+ availableEngines: array(AvailableEngineSchema).readonly(),
16589
+ selectedEngine: PipelineEngineChoiceSchema,
16590
+ slots: array(PipelineSlotSchemaSchema).readonly()
16593
16591
  });
16594
- /**
16595
- * How a track was produced. `pipeline` (default / absent) = the spatial
16596
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
16597
- * no positions, a single snapshot, and no bbox trajectory at all:
16598
- *
16599
- * - `sensor` — a linked sensor/control device state change.
16600
- * - `audio` — an audio event on the camera itself that was anomalous for
16601
- * THAT camera, loud, and heard while nothing visual was happening (D62).
16602
- *
16603
- * The spatial subsystems (tracker association, occupancy count, re-id /
16604
- * embedding, resurrection) MUST skip every synthetic source. Test for that
16605
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
16606
- * check silently readmits every source added after it was written.
16607
- */
16608
- var TrackSourceSchema = _enum([
16609
- "pipeline",
16610
- "sensor",
16611
- "audio"
16612
- ]);
16613
- /**
16614
- * Where a track sits in the RETRAIN lifecycle (D81).
16615
- *
16616
- * - `none` never marked, or un-marked. Evictable.
16617
- * - `staging`the operator wants this track as training material and has not
16618
- * finished with it. **This is the only state retention holds**: the track and
16619
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
16620
- * the device's age window.
16621
- * - `trained` — the retrain page has taken what it needed. The frames it chose
16622
- * were COPIED into the retrain dataset at selection time, so the dataset no
16623
- * longer depends on the track's media and the track becomes EVICTABLE again.
16624
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
16625
- * a deliberate action of the retrain page, not a side effect of a checkbox.
16626
- *
16627
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
16628
- * the store's filter language has only positive equality and `whereIn` — no
16629
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
16630
- * would make the entire pre-column history immortal in one deploy.
16631
- */
16632
- var RetrainStatusSchema = _enum([
16633
- "none",
16634
- "staging",
16635
- "trained"
16636
- ]);
16637
- /**
16638
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
16639
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
16640
- * so the two surfaces cannot drift.
16641
- *
16642
- * **Absent ≠ false.** A track that has never been touched omits the field; an
16643
- * explicitly un-flagged track carries `false`. Legacy rows written before the
16644
- * columns existed read as absent, and a consumer that needs a boolean should say
16645
- * `flag === true`, not `flag !== false`.
16646
- *
16647
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
16648
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
16649
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
16650
- * `trained` track reports `false` while refusing both writes. The boolean is
16651
- * kept because three surfaces drive a toggle off it; anything that needs to tell
16652
- * "never marked" from "already trained" must read `retrainStatus`.
16653
- *
16654
- * `debug` does NOT pin; it is attention, not durability.
16655
- *
16656
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16657
- * A favourited track is skipped by retention the same way `staging` is, but
16658
- * it does not enter `none|staging|trained` and has no staging budget.
16659
- */
16660
- var TrackFlagFields = {
16661
- /** Operator marked this track as training material — i.e. `retrainStatus` is
16662
- * `'staging'`. */
16663
- markForTrain: boolean().optional(),
16664
- /** Operator marked this track for diagnostic attention. */
16665
- debug: boolean().optional(),
16666
- /** Operator favourited this track. Pins it against pruning. */
16667
- favourited: boolean().optional()
16668
- };
16669
- /**
16670
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
16671
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
16672
- * write patch, and the status is not something the toggle sets — it is what the
16673
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
16674
- * always present on a persisted row (the column default materialises `'none'`).
16675
- */
16676
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
16677
- /**
16678
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
16679
- * one flag can never clear the other — the toggles are independent and are
16680
- * driven from three surfaces that do not know about each other.
16681
- */
16682
- var TrackFlagsPatchSchema = object(TrackFlagFields);
16683
- /**
16684
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
16685
- * collapses to `false`) so a caller can drive a toggle's checked state off the
16686
- * mutation result without a re-fetch.
16687
- */
16688
- var TrackFlagsSchema = object({
16689
- trackId: string$2(),
16690
- markForTrain: boolean(),
16691
- debug: boolean(),
16692
- favourited: boolean(),
16693
- /** The lifecycle state the boolean was derived from. Required here (unlike on
16694
- * a track row) because this shape is only ever produced by the write body,
16695
- * which always knows it — and a surface that has just written needs to render
16696
- * `trained` without a re-fetch. */
16697
- retrainStatus: RetrainStatusSchema
16592
+ var EngineProvisioningSchema = object({
16593
+ runtimeId: _enum([
16594
+ "onnx",
16595
+ "openvino",
16596
+ "coreml",
16597
+ "edgetpu"
16598
+ ]).nullable(),
16599
+ device: string$2().nullable(),
16600
+ state: _enum([
16601
+ "idle",
16602
+ "installing",
16603
+ "verifying",
16604
+ "ready",
16605
+ "failed"
16606
+ ]),
16607
+ progress: number().optional(),
16608
+ error: string$2().optional(),
16609
+ nextRetryAt: number().optional(),
16610
+ /**
16611
+ * Gate A (config-correctness gate at engine change): human-readable
16612
+ * config issues surfaced EAGERLY when the node's engine changes — model
16613
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
16614
+ * has a <format> build"). Additive/optional: informational only, never
16615
+ * enforced here `assertEngineReady` (readiness) still gates inference.
16616
+ * Absent/empty when the node-default tree resolves cleanly.
16617
+ */
16618
+ configIssues: array(string$2()).optional()
16698
16619
  });
16699
- union([literal(1), literal(2)]);
16700
- /**
16701
- * WHO decided a label, and when. Carried per tier so a value can be traced to
16702
- * the step and model that produced it — which is what makes the write rule
16703
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
16704
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
16705
- *
16706
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
16707
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
16708
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
16709
- * that value has no provenance, and the write rule lets ANY properly-attributed
16710
- * write of the same tier replace it regardless of score.
16711
- */
16712
- var LabelAttributionSchema = object({
16713
- stepId: string$2(),
16620
+ var PipelineStepInputSchema = lazy(() => object({
16621
+ addonId: string$2(),
16714
16622
  modelId: string$2().optional(),
16715
- decidedAt: number(),
16623
+ enabled: boolean().default(true),
16624
+ children: array(PipelineStepInputSchema).optional(),
16625
+ settings: record(string$2(), unknown()).optional(),
16626
+ jumpDeviceKey: string$2().optional()
16627
+ }));
16628
+ var ModelSubstitutionSchema = object({
16629
+ addonId: string$2(),
16630
+ chosen: string$2(),
16631
+ running: string$2(),
16632
+ format: string$2()
16633
+ });
16634
+ var PipelineValidationIssueSchema = object({
16635
+ addonId: string$2(),
16636
+ kind: _enum(["unknown-addon", "no-format-build"]),
16637
+ detail: string$2()
16638
+ });
16639
+ var PipelineValidationResultSchema = object({
16640
+ ok: boolean(),
16641
+ issues: array(PipelineValidationIssueSchema).readonly(),
16642
+ substitutions: array(ModelSubstitutionSchema).readonly(),
16643
+ /** The node's `currentEngine.format` this validation ran against. */
16644
+ format: string$2()
16645
+ });
16646
+ var ReferenceImageEntrySchema = object({
16647
+ filename: string$2(),
16648
+ stepIds: array(string$2()).readonly().optional()
16649
+ });
16650
+ var ReferenceImageBodySchema = object({
16651
+ base64: string$2(),
16652
+ filename: string$2()
16653
+ });
16654
+ var ReferenceAudioEntrySchema = object({
16655
+ filename: string$2(),
16656
+ sizeKb: number()
16657
+ });
16658
+ var ReferenceAudioBodySchema = object({ base64: string$2() });
16659
+ var AudioBackendSchema = object({
16660
+ id: string$2(),
16661
+ name: string$2(),
16662
+ description: string$2(),
16663
+ available: boolean(),
16716
16664
  /**
16717
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
16718
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
16719
- *
16720
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
16721
- * notification rule authored on "Gianluca" stopped matching the moment the
16722
- * operator fixed the spelling in the gallery, and nothing said so. The id is
16723
- * the thing that does not move, so it is what a rule matches on
16724
- * (`NcConditions.identities`) and the text is what a human is shown.
16725
- *
16726
- * Absent when the label names no gallery row — a plate the OCR read but no
16727
- * vehicle claims, a sub-class, a species, any tier-1 value.
16665
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
16666
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
16667
+ * the benchmark UI to populate the `enabledMicroClasses` filter
16668
+ * specific to the selected backend without a separate fetch.
16728
16669
  */
16729
- identityId: string$2().optional()
16670
+ rawLabels: array(string$2()).readonly().optional()
16671
+ });
16672
+ var AudioCapabilitiesSchema = object({
16673
+ activeBackend: string$2(),
16674
+ availableBackends: array(AudioBackendSchema).readonly(),
16675
+ sampleRate: number(),
16676
+ chunkDurationMs: number()
16677
+ });
16678
+ var DownloadModelResultSchema = object({
16679
+ filePath: string$2(),
16680
+ sizeMB: number(),
16681
+ durationMs: number()
16730
16682
  });
16731
16683
  /**
16732
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
16733
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
16734
- * track and its events always answer the same question the same way.
16735
- *
16736
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
16737
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
16738
- * is tier 2, and each carries its own score + attribution.
16739
- *
16740
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
16741
- * finest thing known. Before 4g the single `label` column held the finest
16742
- * value, so a consumer that has not been updated reads the tier-1 slot and
16743
- * shows nothing on a species-only row; that is why the migration puts every
16744
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
16745
- * and why the read surfaces were changed in the same train.
16746
- *
16747
- * **Writing it.** The slots are independent, which is the whole point: a
16748
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
16749
- * migratorius`), so fineness cannot regress by construction. Within a tier the
16750
- * higher score wins. One rule, one implementation — see
16751
- * `pipeline/label-tier.ts` in addon-post-analysis.
16752
- */
16753
- var TieredLabelFields = {
16754
- /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
16755
- label: string$2().optional(),
16756
- /** Confidence of the tier-1 value, as reported by the deciding step. */
16757
- labelScore: number().optional(),
16758
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
16759
- labelMeta: LabelAttributionSchema.optional(),
16760
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
16761
- subLabel: string$2().optional(),
16762
- /** Confidence of the tier-2 value, as reported by the deciding step. */
16763
- subLabelScore: number().optional(),
16764
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
16765
- subLabelMeta: LabelAttributionSchema.optional()
16766
- };
16767
- /** Per-camera slice of a training-export estimate. */
16768
- var TrainingExportDeviceTotalsSchema = object({
16769
- deviceId: number(),
16770
- tracks: number().int(),
16771
- files: number().int(),
16772
- bytes: number().int()
16773
- });
16774
- /**
16775
- * What a training export WOULD contain. Computed from media index rows only —
16776
- * no blob is read to produce this.
16684
+ * Wrapper carrying a single test run's result. Replaces the legacy
16685
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
16686
+ * canonical `AudioResult` from the Phase 6 output rework: one
16687
+ * `AudioDetection` per class above `minScore`, top-N candidates in
16688
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
16689
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
16690
+ * benchmark UI can still report a clean failure when the classifier
16691
+ * cap isn't available.
16777
16692
  */
16778
- var TrainingExportSummarySchema = object({
16779
- generatedAt: number(),
16780
- trackCount: number().int(),
16781
- fileCount: number().int(),
16782
- byteCount: number().int(),
16783
- /** More marked tracks exist than a single pass carries. */
16784
- truncated: boolean(),
16785
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
16693
+ var AudioTestResultSchema = object({
16694
+ success: boolean(),
16695
+ error: string$2().optional(),
16696
+ frame: custom().optional()
16786
16697
  });
16787
- var TrackSchema = object({
16788
- trackId: string$2(),
16789
- deviceId: number(),
16790
- className: string$2(),
16791
- ...TieredLabelFields,
16792
- producingDeviceName: string$2().optional(),
16793
- /** Track provenance. Absent `pipeline` (legacy rows). */
16794
- source: TrackSourceSchema.optional(),
16795
- firstSeen: number(),
16796
- lastSeen: number(),
16797
- /** Frame-rate position history (subject to maxPositionHistory cap). */
16798
- positions: array(TrackPositionSchema).readonly(),
16799
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
16800
- * saveThumbnails policy). */
16801
- snapshots: array(TrackSnapshotSchema).readonly(),
16802
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
16803
- zonesVisited: array(string$2()).readonly(),
16698
+ var PipelineConfigBridge = custom();
16699
+ var ConfigUISchemaBridge = custom();
16700
+ var ConfigUISchemaNullableBridge = custom();
16701
+ var InferenceCapabilitiesBridge = custom();
16702
+ var ModelAvailabilityListBridge = custom();
16703
+ var PipelineRunResultBridge = custom();
16704
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string$2() }), EngineProvisioningSchema), method(_void(), record(string$2(), object({
16705
+ modelId: string$2(),
16706
+ settings: record(string$2(), unknown()).readonly()
16707
+ }))), method(object({ steps: record(string$2(), object({
16708
+ modelId: string$2(),
16709
+ settings: record(string$2(), unknown()).readonly()
16710
+ })) }), object({ success: literal(true) }), {
16711
+ kind: "mutation",
16712
+ auth: "admin"
16713
+ }), method(object({ nodeId: string$2() }), object({
16714
+ success: literal(true),
16715
+ clearedDevices: number()
16716
+ }), {
16717
+ kind: "mutation",
16718
+ auth: "admin"
16719
+ }), method(object({ nodeId: string$2() }), object({ unhealthy: array(object({
16720
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
16721
+ deviceKey: string$2(),
16804
16722
  /**
16805
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
16806
- * `zones` capability.
16807
- *
16808
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
16809
- * and no card can render — so every free-text search surface was structurally
16810
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
16811
- * just returned nothing. Resolving here rather than in each client keeps ONE
16812
- * derivation and costs the clients no extra call (the `zones` cap is
16813
- * per-device, so a client-side resolve would be a per-camera fan-out on a
16814
- * surface built to avoid exactly that).
16815
- *
16816
- * Resolved, never invented: a zone deleted since the track was written has no
16817
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
16818
- * two are not positionally aligned. Absent when the track visited no zone, or
16819
- * when the zone catalogue could not be read.
16723
+ * `failed` the per-device restart budget is exhausted; no pool
16724
+ * will be spawned until an operator re-arms it or the runner
16725
+ * respawns. `backoff` — under budget, waiting out the backoff (or
16726
+ * a cached pool observed dead and not yet condemned).
16820
16727
  */
16821
- zoneNames: array(string$2()).readonly().optional(),
16822
- /** Deduplicated set of detector classes observed for this track over its
16823
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
16824
- * legacy rows written before class accumulation shipped. */
16825
- classes: array(string$2()).readonly().optional(),
16826
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
16827
- totalDistance: number(),
16828
- state: TrackStateSchema,
16829
- active: boolean(),
16830
- /** Deterministic key-event importance score in [0,1] (server-computed at
16831
- * track expiry, recomputed on late label). Absent on legacy rows written
16832
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
16833
- importance: number().optional(),
16834
- /** Id of the track's highest-confidence ObjectEvent (its representative
16835
- * "best" frame). Absent when the track produced no object events. */
16836
- bestEventId: string$2().optional(),
16837
- /** Tag of the importance sub-signal that dominated the score
16838
- * (identity|dwell|proximity|class|confidence|travel|zone). */
16839
- importanceReason: string$2().optional(),
16840
- /** Audio-classification labels heard on the camera during the track's
16841
- * life (score ≥ device `classificationMinScore`), aggregated per label.
16842
- * Absent on legacy rows / tracks with no confident audio. */
16843
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
16844
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
16845
- * Populated from the persisted envelope columns on historical reads;
16846
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
16847
- envelope: TrackEnvelopeSchema.optional(),
16728
+ state: _enum(["failed", "backoff"]),
16729
+ /** Epoch ms of the death that produced this state. */
16730
+ since: number(),
16731
+ /** Pool deaths inside the current window. */
16732
+ deaths: number(),
16733
+ /** The last death's message. */
16734
+ lastError: string$2()
16735
+ })).readonly() })), method(object({
16736
+ nodeId: string$2(),
16737
+ deviceKey: string$2()
16738
+ }), object({ rearmed: boolean() }), {
16739
+ kind: "mutation",
16740
+ auth: "admin"
16741
+ }), 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({
16742
+ name: string$2(),
16743
+ steps: array(PipelineTemplateStepSchema).readonly(),
16744
+ engine: PipelineEngineChoiceSchema
16745
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
16746
+ id: string$2(),
16747
+ name: string$2().optional(),
16748
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
16749
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string$2() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string$2() }), ModelAvailabilityListBridge), method(object({
16750
+ addonId: string$2(),
16751
+ modelId: string$2(),
16752
+ format: ModelFormatSchema$1
16753
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
16754
+ addonId: string$2(),
16755
+ modelId: string$2(),
16756
+ format: ModelFormatSchema$1
16757
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
16758
+ engine: PipelineEngineChoiceSchema.optional(),
16759
+ steps: array(PipelineStepInputSchema).min(1),
16760
+ frame: FrameInputSchema.optional(),
16848
16761
  /**
16849
- * A face DETECTOR found a face on this track — nothing more. It says the
16850
- * detail plane produced a `face` detail; it does NOT say the face was
16851
- * embedded, matched, above `minFacePx`, or that the recognizer was even
16852
- * enabled. Set once and never cleared.
16853
- *
16854
- * **This exists so "face present but not recognised" is expressible.** A
16855
- * recognised identity lands in `subLabel` (attributed to the face chain via
16856
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
16857
- * and a track with no face at all were byte-identical on the wire and no
16858
- * surface could tell them apart. The read is `hasFace === true && subLabel
16859
- * === undefined`.
16860
- *
16861
- * **Absent ≠ false.** Every row written before the column existed omits it,
16862
- * and so does every server that predates the field — a consumer must test
16863
- * `=== true` and render nothing otherwise, never infer "no face".
16762
+ * Process-local lazy frame. Valid only when caller and provider resolve
16763
+ * in the same execution-group process; split/cross-node callers use
16764
+ * `frame`/`image` inline compatibility instead.
16864
16765
  */
16865
- hasFace: boolean().optional(),
16766
+ frameRef: FrameRefSchema.optional(),
16866
16767
  /**
16867
- * This track has a face row IN THE GALLERY: a crop **and** an embedding a
16868
- * face an operator could ASSIGN to an identity.
16869
- *
16870
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
16871
- * because the two disagree. `hasFace` is stamped at the TOP of the face
16872
- * branch, before every gate, and means no more than "a face detector produced
16873
- * a face detail". This one is stamped at the single moment the gallery row
16874
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
16875
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
16876
- * candidate gate, the imageless-track drop (no crop was ever captured) and
16877
- * the crop-store drop. Everything between the detector and that insert can
16878
- * legitimately refuse the face, so a flag written any earlier promises the
16879
- * operator something to assign and delivers nothing.
16880
- *
16881
- * **Independent of recognition.** A face collected but never auto-matched is
16882
- * still assignable — it is in fact the face an operator most wants to reach —
16883
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
16884
- * `subLabel`; this says only that the raw material exists.
16885
- *
16886
- * **Set once, never cleared.** A track that produced a gallery row produced
16887
- * one; deleting the row later is the gallery's business, not this flag's.
16888
- *
16889
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
16890
- * before the column omits it, and so does every server that predates the
16891
- * field. A consumer must test `=== true` and render nothing otherwise —
16892
- * never infer "no assignable face".
16768
+ * CB5 shm passthrough a `FrameHandle` naming the same ring slot
16769
+ * the decoded pixels live in. One more member of the one-of
16770
+ * frame/frameHandle/image/imageBase64/referenceImage group.
16893
16771
  */
16894
- hasEmbeddedFace: boolean().optional(),
16772
+ frameHandle: FrameHandleSchema.optional(),
16773
+ imageBase64: string$2().optional(),
16895
16774
  /**
16896
- * This subject CONTAINS a folded rider a person the rider-pairing step
16897
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
16898
- * so the passage is tracked once and as a VEHICLE.
16899
- *
16900
- * It exists because the fold's record was dishonest. D34 and the code both
16901
- * said "the person is not lost — it is reported so both entities stay on the
16902
- * record"; in fact the pair went into a per-processor RAM field behind an
16903
- * accessor nobody called, and every durable surface said `vehicle`, full
16904
- * stop. This is the composition note that makes the row true.
16905
- *
16906
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
16907
- * person" is not an answer to "what is this" — both label tiers would refuse
16908
- * a macro token anyway (D89), and correctly. Nothing here changes what the
16909
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
16910
- * and a `person` rule still does not fire for someone cycling past.
16911
- *
16912
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
16913
- * the column, and every hub that predates the field, omits it. Test
16914
- * `=== true` and render nothing otherwise — never infer "no rider".
16775
+ * Binary JPEG bytespreferred over `imageBase64` on internal
16776
+ * hops (hub forked worker via Moleculer MsgPack) because it
16777
+ * skips the 33% base64 overhead + the per-call base64 decode on
16778
+ * the detection-pipeline worker. Callers can pass either; exactly
16779
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
16915
16780
  */
16916
- hasRider: boolean().optional(),
16917
- ...TrackFlagFields,
16918
- ...TrackRetrainFields
16919
- });
16920
- var BaseEventFields = {
16921
- id: string$2(),
16922
- deviceId: number(),
16923
- timestamp: number()
16924
- };
16925
- var MotionEventSchema = object({
16926
- ...BaseEventFields,
16927
- kind: literal("motion"),
16928
- regionCount: number(),
16929
- /** Heavy JSON array omitted in slim projection. */
16930
- regions: array(object({
16931
- bbox: BoundingBoxSchema,
16932
- pixelCount: number(),
16933
- intensity: number()
16934
- })).readonly().optional(),
16935
- /** Omitted in slim projection. */
16936
- frameWidth: number().optional(),
16937
- /** Omitted in slim projection. */
16938
- frameHeight: number().optional(),
16939
- /** Populated by B5 (recording playback URL for this event). */
16940
- mediaUrl: string$2().optional()
16941
- });
16781
+ image: _instanceof(Uint8Array).optional(),
16782
+ referenceImage: string$2().optional(),
16783
+ deviceId: number().optional(),
16784
+ sessionId: string$2().optional(),
16785
+ /**
16786
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
16787
+ * reference-image, and detail-subtree calls. 'frame' is the live
16788
+ * per-frame dispatch: ONLY root-plane steps run; crop children
16789
+ * (inputClasses ≠ null) are skipped and served per-track via
16790
+ * pipelineRunner.runDetailSubtree (two-plane design).
16791
+ */
16792
+ plane: _enum(["full", "frame"]).optional(),
16793
+ /**
16794
+ * Inference-device selector (Phase 2 multi-device). Format
16795
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
16796
+ * Omitted ⇒ the runner's default device (current single-engine
16797
+ * behaviour). Selects WHICH device pool of the node runs the call.
16798
+ */
16799
+ deviceKey: string$2().optional(),
16800
+ /**
16801
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
16802
+ * when the parent crop was resolved from the frame's retained NATIVE
16803
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
16804
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
16805
+ * resolution from that surface — the SAME quality path faces already
16806
+ * had — instead of the downscaled parent tile. `handle` keys the native
16807
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
16808
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
16809
+ * the executor's crop-normalized child ROI back into frame-normalized
16810
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
16811
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
16812
+ * (today's behaviour on the fallback path).
16813
+ */
16814
+ nativeCropRef: NativeCropRefSchema.optional()
16815
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
16816
+ engine: PipelineEngineChoiceSchema.optional(),
16817
+ steps: array(PipelineStepInputSchema).min(1),
16818
+ frames: array(FrameInputSchema).min(1).max(255),
16819
+ deviceId: number().optional(),
16820
+ sessionId: string$2().optional(),
16821
+ /**
16822
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
16823
+ * the batch to the Python pool's bench preprocess cache
16824
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
16825
+ * preprocessed ONCE and every later inference is a pure-inference cache
16826
+ * hit — the sustained-throughput run measures inference, not
16827
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
16828
+ * full preprocess every call, correct). Fresh per sustained run;
16829
+ * released via `uncacheFrame`.
16830
+ */
16831
+ frameId: number().int().nonnegative().optional(),
16832
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
16833
+ deviceKey: string$2().optional()
16834
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
16835
+ data: _instanceof(Uint8Array),
16836
+ width: number().int().positive(),
16837
+ height: number().int().positive(),
16838
+ format: _enum([
16839
+ "rgb",
16840
+ "bgr",
16841
+ "gray"
16842
+ ])
16843
+ }), object({
16844
+ frameId: number(),
16845
+ width: number(),
16846
+ height: number()
16847
+ }), { kind: "mutation" }), method(object({
16848
+ stepId: string$2(),
16849
+ frameId: number().int()
16850
+ }), record(string$2(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
16851
+ batchMode: string$2(),
16852
+ windowMs: number(),
16853
+ maxBatchSize: number(),
16854
+ concurrency: number()
16855
+ })), method(_void(), array(object({
16856
+ engineKey: string$2(),
16857
+ engine: PipelineEngineChoiceSchema,
16858
+ modelsLoaded: array(string$2()).readonly(),
16859
+ inUseByCameras: array(number()).readonly(),
16860
+ /**
16861
+ * Origin of this resident factory.
16862
+ * - `runtime` — main camera-serving engine (no idle TTL).
16863
+ * - `warm-override` — benchmark/test override held in the warm
16864
+ * cache; auto-disposed after the idle TTL.
16865
+ * - `device-pool` — a concurrent per-device pool (Phase 2
16866
+ * multi-device, keyed by `deviceKey`) resolved
16867
+ * via `resolveDeviceFactory`. Runs alongside the
16868
+ * `runtime` engine on a DIFFERENT accelerator
16869
+ * (NPU / iGPU / Coral) — this is how the
16870
+ * Engines tab shows all pools running at once.
16871
+ */
16872
+ kind: _enum([
16873
+ "runtime",
16874
+ "warm-override",
16875
+ "device-pool"
16876
+ ]),
16877
+ /** Native pid of the underlying Python pool (null when no pool). */
16878
+ poolPid: number().nullable(),
16879
+ /** ms since this factory was last used (null when not warm-tracked). */
16880
+ idleMs: number().nullable(),
16881
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
16882
+ idleTtlMs: number().nullable()
16883
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
16884
+ kind: "mutation",
16885
+ auth: "admin"
16886
+ }), method(object({
16887
+ engine: PipelineEngineChoiceSchema,
16888
+ force: boolean().optional()
16889
+ }), object({
16890
+ success: boolean(),
16891
+ reason: string$2().optional()
16892
+ }), {
16893
+ kind: "mutation",
16894
+ auth: "admin"
16895
+ }), method(_void(), array(ReferenceImageEntrySchema).readonly()), method(object({ filename: string$2() }), ReferenceImageBodySchema.nullable()), method(_void(), array(ReferenceAudioEntrySchema).readonly()), method(object({ filename: string$2() }), ReferenceAudioBodySchema.nullable()), method(_void(), AudioCapabilitiesSchema), method(object({
16896
+ addonId: string$2(),
16897
+ modelId: string$2(),
16898
+ filename: string$2().optional(),
16899
+ settings: record(string$2(), unknown()).optional()
16900
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
16942
16901
  /**
16943
- * Which detection SOURCE produced an object event. `pipeline` = the ML
16944
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
16945
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
16946
- * tracking, per-kind persistence) but stay distinguishable so consumers
16947
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
16948
- * Absent on legacy rows treat as `pipeline`.
16902
+ * Per-stage gating mode applied to the zones a rule references.
16903
+ *
16904
+ * - `include`: the rule contributes to a **whitelist** for its stage.
16905
+ * When at least one `include` rule fires for a stage, only entities
16906
+ * inside one of those zones pass that stage.
16907
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
16908
+ * Entities inside one of those zones are dropped at that stage.
16909
+ *
16910
+ * `monitor`-style observation (count without filtering) is not a rule
16911
+ * mode — zones without any matching rule are observed naturally by
16912
+ * `zone-analytics` (live snapshot + history), so an "I just want to
16913
+ * count, not filter" use case needs no rule at all.
16949
16914
  */
16950
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
16915
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
16951
16916
  /**
16952
- * The confirmed zone crossing that produced an object event. Present ONLY on
16953
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
16954
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
16955
- * appearance event carry none, so a rule asking for a direction fails closed
16956
- * on them.
16917
+ * Per-consumer rule that references existing zones (geometry) and
16918
+ * defines how a specific pipeline stage should treat them. Each
16919
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
16920
+ * settings:
16957
16921
  *
16958
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
16959
- * into its own event, so a frame in which a track enters A while leaving B
16960
- * produces two events with two directions — never one ambiguous row.
16922
+ * - `addon-motion-wasm` `motionZoneRules: ZoneRule[]` (motion stage)
16923
+ * - `addon-detection-pipeline` `detectionZoneRules: ZoneRule[]` (detection stage)
16924
+ * - future: notification rules, audio gating, etc.
16961
16925
  *
16962
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
16963
- * membership the box has NOW, and by definition it no longer contains the zone
16964
- * that was just left. Without the id here, a zone-scoped rule could never match
16965
- * the exit it asked for.
16926
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
16927
+ * express "ignore motion in ALL of {garden, street}" with a single
16928
+ * rule. `classFilter` narrows the rule to specific object classes
16929
+ * "drop person detections in the street, but keep cars" is one
16930
+ * `exclude` rule with `classFilter: ['person']`.
16931
+ *
16932
+ * `enabled` is a soft toggle — the operator can keep the rule
16933
+ * configured but inert without deleting it.
16966
16934
  */
16967
- var ZoneCrossingSchema = object({
16968
- direction: _enum(["enter", "exit"]),
16969
- /** Admin zone id crossed. */
16970
- zoneId: string$2(),
16971
- /** Zone display name at crossing time (falls back to the id). */
16972
- zoneName: string$2().optional()
16973
- });
16974
- var ObjectEventSchema = object({
16975
- ...BaseEventFields,
16976
- kind: literal("object"),
16977
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
16978
- source: DetectionSourceSchema.optional(),
16935
+ var ZoneRuleSchema = object({
16936
+ /** Stable rule id — survives edits, used by the UI for diffing. */
16937
+ id: string$2(),
16938
+ /** Optional human-readable label rendered in the rule editor. */
16939
+ name: string$2().optional(),
16940
+ /** Zones this rule targets. The rule's `mode` applies to ALL
16941
+ * listed zones (OR-set: a detection in any one of them counts).
16942
+ * At least one zone id required — a rule with no targets is a
16943
+ * configuration mistake and the form validator rejects it. */
16944
+ zoneIds: array(string$2()).min(1).readonly(),
16945
+ mode: ZoneRuleModeEnum,
16979
16946
  /**
16980
- * Inference-frame id shared by every object event emitted from the SAME frame
16981
- * the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
16982
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
16983
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
16984
- * Optional for backward-compat with pre-existing rows / the slim projection
16985
- * includes it (it is light). Absent on rows written before this field.
16947
+ * Class names this rule applies to. Empty / undefined rule
16948
+ * applies to every class. Class strings match the `macroClass`
16949
+ * field on detections (e.g. `person`, `car`, `dog`).
16986
16950
  */
16987
- frameId: string$2().optional(),
16988
- /** Omitted in slim projection. */
16989
- trackId: string$2().optional(),
16990
- className: string$2(),
16991
- ...TieredLabelFields,
16992
- /** Omitted in slim projection. */
16993
- confidence: number().optional(),
16994
- /** Heavy JSON — omitted in slim projection. */
16995
- bbox: BoundingBoxSchema.optional(),
16996
- /** Heavy JSON — omitted in slim projection. */
16997
- zones: array(string$2()).readonly().optional(),
16998
- /** Omitted in slim projection. */
16999
- state: TrackStateSchema.optional(),
16951
+ classFilter: array(string$2()).readonly().optional(),
17000
16952
  /**
17001
- * The zone crossing this event IS, when it is one. Absent on every other
17002
- * event kind (movement state, appearance, package) see
17003
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
16953
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
16954
+ * required to consider an entity "in the zone". Defaults to the
16955
+ * consumer's stage default when omitted. Kept for back-compat with
16956
+ * existing per-rule overrides; new operators pick the value via
16957
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
16958
+ * set, the lower-level engine reads it as a 0–1 fraction.
17004
16959
  */
17005
- zoneCrossing: ZoneCrossingSchema.optional(),
17006
- /** Detection-frame dimensions in pixels — let consumers normalize the
17007
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17008
- frameWidth: number().optional(),
17009
- frameHeight: number().optional(),
17010
- /** MediaStore key for the crop attached to this event (if any). */
17011
- mediaKey: string$2().optional(),
17012
- /** Design B: MediaStore key of the track's native-resolution key frame (the
17013
- * best-detection full frame). Resolve via the event-media data-plane
17014
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17015
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17016
- * sources — consumers fall back to `mediaKey` (the tight crop). */
17017
- keyFrameMediaKey: string$2().optional(),
17018
- /** Populated by B5 (recording playback URL for this event). */
17019
- mediaUrl: string$2().optional(),
17020
- /** The parent track's key-event importance [0,1], propagated to every object
17021
- * event of the track (so an event row can be sorted by importance without a
17022
- * track join). Absent on legacy rows / before the track was scored. */
17023
- importance: number().optional()
17024
- });
17025
- var AudioEventSchema = object({
17026
- ...BaseEventFields,
17027
- kind: literal("audio"),
17028
- rms: number(),
17029
- dbfs: number(),
17030
- classification: object({
17031
- className: string$2(),
17032
- originalClass: string$2().optional(),
17033
- score: number()
17034
- }).optional(),
17035
- /** Populated by B5 (recording playback URL for this event). */
17036
- mediaUrl: string$2().optional()
16960
+ overlapThreshold: number().min(0).max(1).optional(),
16961
+ /**
16962
+ * Operator-friendly version of `overlapThreshold` the percentage
16963
+ * of the detection's bbox that must lie inside the zone for the
16964
+ * rule to match. Documented default is 85%; the engine substitutes
16965
+ * that when the field is omitted (kept optional so existing rules
16966
+ * stored without it stay valid).
16967
+ *
16968
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
16969
+ * rule, the engine prefers `bboxInclusionPct` because it's the
16970
+ * field exposed in the UI. Internally both feed the same gate.
16971
+ */
16972
+ bboxInclusionPct: number().min(0).max(100).optional(),
16973
+ /**
16974
+ * When `true` and a detection has a segmentation mask, use the
16975
+ * mask for overlap instead of the bbox. Detection-stage only;
16976
+ * motion rules ignore this field.
16977
+ */
16978
+ preferMask: boolean().optional(),
16979
+ /**
16980
+ * Soft-toggle: `false` disables the rule without deleting it.
16981
+ * Defaults to `true` so operators creating a rule via the UI
16982
+ * see it active immediately.
16983
+ */
16984
+ enabled: boolean().default(true)
17037
16985
  });
17038
- var MediaFileKindEnum = _enum([
17039
- "crop",
17040
- "thumbnail",
17041
- "snapshot",
17042
- "firstFrame",
17043
- "lastFrame",
17044
- "fullFrame",
17045
- "fullFrameBoxed",
17046
- "faceCrop",
17047
- "plateCrop",
17048
- "keyFrame",
17049
- "keyFrameSmall",
17050
- "thumbnailSmall"
17051
- ]);
17052
- var MediaFileSchema = object({
17053
- key: string$2(),
17054
- kind: MediaFileKindEnum,
17055
- base64: string$2(),
17056
- sizeBytes: number(),
17057
- timestamp: number()
16986
+ array(ZoneRuleSchema).readonly();
16987
+ /**
16988
+ * Zone — pure geometry + identity. NO filtering behaviour.
16989
+ *
16990
+ * Zones describe **where** in the frame the operator wants to flag
16991
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
16992
+ * each pipeline stage uses them. Splitting the two means a single
16993
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
16994
+ * a detection-include rule on `['car']`, and an occupancy aggregate
16995
+ * — without three duplicated polygons.
16996
+ *
16997
+ * Owned by the orchestrator addon (provider) and mirrored into the
16998
+ * `zones` device-state slice on every mutation. Consumers
16999
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
17000
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
17001
+ * mirror with `onChanged`).
17002
+ *
17003
+ * Coordinates are normalised fractions of the frame (0–1) so zones
17004
+ * survive resolution changes and stream profile switches.
17005
+ *
17006
+ * `kind` discriminates between full polygons (closed regions used
17007
+ * for intrusion / occupancy filters) and tripwires (open 2-point
17008
+ * line segments used for cross events). Onboard / firmware-reported
17009
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
17010
+ * task list.
17011
+ */
17012
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
17013
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
17014
+ var PolygonPointSchema = object({
17015
+ x: number(),
17016
+ y: number()
17017
+ });
17018
+ /** A camera detection zone — pure geometry/identity. */
17019
+ var ZoneSchema = object({
17020
+ id: string$2(),
17021
+ name: string$2(),
17022
+ kind: ZoneKindEnum.default("polygon"),
17023
+ /** Polygon vertices, fraction of frame (0–1). */
17024
+ polygon: array(PolygonPointSchema).readonly(),
17025
+ /** Visual color for UI rendering. */
17026
+ color: string$2().default("#3b82f6")
17058
17027
  });
17059
17028
  /**
17060
- * One media row WITHOUT its bytes.
17029
+ * Zones capability per-camera CRUD over polygon detection zones.
17061
17030
  *
17062
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17063
- * 140 s track), and a client that renders tiles from the media data plane needs
17064
- * to know only WHAT EXISTS the bytes then arrive per tile, lazily, over HTTP
17065
- * with an immutable cache, instead of all at once inside a tRPC response that
17066
- * blocks the whole view.
17031
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
17032
+ * to per-device settings and mirrors into the `zones` device-state
17033
+ * slice on every mutation, so downstream consumers can subscribe via
17034
+ * `dev.state.zones.onChanged`.
17067
17035
  *
17068
- * `sizeBytes` is carried because it is what lets a client decide between the
17069
- * stored blob and a `?variant=thumb` rendering without fetching either.
17036
+ * The cap surface only handles geometry + identity; filtering
17037
+ * behaviour (per-class, include/exclude, threshold) lives in the
17038
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
17039
+ * `capabilities/schemas/zone-rule.js`.
17070
17040
  */
17071
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17041
+ var zonesCapability = {
17042
+ name: "zones",
17043
+ scope: "device",
17044
+ mode: "singleton",
17045
+ deviceTypes: [DeviceType.Camera],
17046
+ methods: {
17047
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
17048
+ addZone: method(object({
17049
+ deviceId: number(),
17050
+ zone: ZoneSchema
17051
+ }), _void(), {
17052
+ kind: "mutation",
17053
+ auth: "admin"
17054
+ }),
17055
+ removeZone: method(object({
17056
+ deviceId: number(),
17057
+ zoneId: string$2()
17058
+ }), _void(), {
17059
+ kind: "mutation",
17060
+ auth: "admin"
17061
+ }),
17062
+ updateZone: method(object({
17063
+ deviceId: number(),
17064
+ zone: ZoneSchema
17065
+ }), _void(), {
17066
+ kind: "mutation",
17067
+ auth: "admin"
17068
+ })
17069
+ },
17070
+ /**
17071
+ * Runtime-state slice — the live zone catalogue mirrored by the
17072
+ * orchestrator on every CRUD mutation. Consumers read via
17073
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
17074
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
17075
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
17076
+ * (e.g. zone groupings) can sit alongside the polygon list.
17077
+ */
17078
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
17079
+ /**
17080
+ * 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.
17081
+ *
17082
+ * See `RuntimeStateDurability`. Enforced by
17083
+ * `scripts/check-runtime-state-durability.ts`.
17084
+ */
17085
+ durability: "restored"
17086
+ };
17072
17087
  /**
17073
- * The MACRO tier of an annotation — a CLOSED set.
17088
+ * pipeline-analytics device-scoped wrapper cap. Refines raw
17089
+ * per-frame detections emitted by the pipeline runner into tracked
17090
+ * objects, per-kind event collections (motion / object / audio), and
17091
+ * persisted media. Owns the post-detection domain end-to-end:
17074
17092
  *
17075
- * This is what the exported detector predicts, so a typo here is a new class
17076
- * with one example in it. `label` and `subLabel` are open strings by contrast:
17077
- * the whole point of the page is teaching the model things it does not know
17078
- * yet, and constraining that vocabulary would make it useless.
17093
+ * runner emits PipelineInferenceResult
17094
+ * (event bus)
17095
+ * pipeline-analytics subscriber
17096
+ * SORT tracker + zone engine + state analyzer + event emitter
17097
+ * → three DB collections (one per kind), one FS media tree, one
17098
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
17099
+ * DetectionEvent on bus)
17079
17100
  *
17080
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
17081
- * `subLabel` is one of these values, in any casing, because once `person`
17082
- * exists in both tiers "every person box" stops being answerable without
17083
- * knowing every string anyone ever typed — and the damage is retroactive.
17101
+ * Pure subscriber model. No `processFrame` cap method the runner
17102
+ * already publishes the raw frame on the bus. The cap surface is
17103
+ * only QUERIES + per-device settings, bound on/off via
17104
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
17105
+ * every camera with a detection pipeline wants its raw detections
17106
+ * refined; operators opt out per-device via BindingsTab when needed.
17107
+ *
17108
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17109
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
17084
17110
  */
17085
- var RetrainMacroClassSchema = _enum([
17111
+ var TrackStateSchema = _enum([
17112
+ "new",
17113
+ "entered",
17114
+ "left",
17115
+ "moving",
17116
+ "idle"
17117
+ ]);
17118
+ var EventKindSchema = _enum([
17119
+ "motion",
17120
+ "object",
17121
+ "audio"
17122
+ ]);
17123
+ /**
17124
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
17125
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17126
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
17127
+ */
17128
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17129
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
17130
+ var EventKindIconSchema = _enum([
17131
+ "motion",
17132
+ "audio",
17086
17133
  "person",
17087
17134
  "vehicle",
17088
17135
  "animal",
17136
+ "door",
17137
+ "pir",
17138
+ "smoke",
17139
+ "water",
17140
+ "button",
17089
17141
  "package",
17090
- "face",
17091
- "plate"
17142
+ "generic"
17092
17143
  ]);
17093
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17094
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17095
- /** Did a human draw this box, or did the assist propose it? */
17096
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17097
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17098
- var RetrainBboxSchema = object({
17099
- x: number(),
17100
- y: number(),
17101
- w: number(),
17102
- h: number()
17103
- });
17104
- /**
17105
- * One annotated subject.
17106
- *
17107
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17108
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17109
- * derived from it at export and never stored storing them is how one feature
17110
- * space ends up holding two crops of the same subject (D52).
17111
- */
17112
- var RetrainAnnotationSchema = object({
17113
- id: string$2(),
17114
- trackId: string$2(),
17115
- deviceId: number(),
17116
- /** The COPY in retrain storage — never the source track's media key. */
17117
- mediaKey: string$2(),
17118
- bbox: RetrainBboxSchema,
17119
- macroClass: RetrainMacroClassSchema,
17120
- label: string$2().optional(),
17121
- subLabel: string$2().optional(),
17122
- kind: RetrainAnnotationKindSchema,
17123
- source: RetrainAnnotationSourceSchema,
17124
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17125
- assistModelId: string$2().optional(),
17126
- assistScore: number().optional(),
17127
- exportedInBatch: string$2().optional(),
17128
- createdAt: number()
17129
- });
17130
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17131
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17132
- id: true,
17133
- trackId: true,
17134
- deviceId: true,
17135
- mediaKey: true,
17136
- createdAt: true,
17137
- exportedInBatch: true
17144
+ var EventKindCategorySchema = _enum([
17145
+ "motion",
17146
+ "audio",
17147
+ "detection",
17148
+ "sensor",
17149
+ "control",
17150
+ "custom",
17151
+ "package"
17152
+ ]);
17153
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17154
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
17155
+ var EventKindDescriptorSchema = object({
17156
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17157
+ kind: string$2(),
17158
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
17159
+ labelKey: string$2(),
17160
+ /** English fallback label (kept for clients that don't translate). */
17161
+ label: string$2(),
17162
+ /** Hex color for timeline/legend rendering. */
17163
+ color: string$2(),
17164
+ /** Dictionary id → lucide component on the UI side. */
17165
+ iconId: string$2(),
17166
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
17167
+ icon: EventKindIconSchema,
17168
+ category: EventKindCategorySchema,
17169
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17170
+ parentKind: string$2().nullable(),
17171
+ /** Derived from `parentKind`, explicit for the client tree. */
17172
+ level: EventKindLevelSchema,
17173
+ /** Which cap + device contributes this kind. For built-ins the camera
17174
+ * itself; for sensor kinds the LINKED source device. */
17175
+ source: object({
17176
+ capName: string$2(),
17177
+ deviceId: number()
17178
+ })
17138
17179
  });
17139
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17140
- var RetrainTrackSchema = object({
17141
- trackId: string$2(),
17180
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17181
+ var EventKindsForDeviceSchema = object({
17142
17182
  deviceId: number(),
17143
- className: string$2(),
17144
- label: string$2().optional(),
17145
- firstSeen: number(),
17146
- lastSeen: number(),
17147
- /** How many frames the dataset already holds from this track. */
17148
- frameCount: number().int(),
17149
- /** How many subjects have been annotated on those frames. `0` with
17150
- * `frameCount: 0` is exactly "staging, still to work". */
17151
- annotationCount: number().int()
17152
- });
17153
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
17154
- var RetrainFrameCandidateSchema = object({
17155
- mediaKey: string$2(),
17156
- kind: MediaFileKindEnum,
17157
- timestamp: number(),
17158
- sizeBytes: number().int(),
17159
- /** A copy of this original already exists — selecting it is free and cannot
17160
- * fail, whatever became of the original. */
17161
- copied: boolean()
17183
+ kinds: array(EventKindDescriptorSchema).readonly()
17162
17184
  });
17163
- /** A frame the dataset OWNS: bytes copied at selection time. */
17164
- var RetrainFrameSchema = object({
17165
- frameId: string$2(),
17185
+ var SensorEventSchema = object({
17186
+ id: string$2(),
17187
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
17188
+ * yields N rows, one per camera). */
17166
17189
  deviceId: number(),
17167
- trackId: string$2(),
17168
- /** Provenance only. It may already point at nothing — that is expected. */
17169
- sourceMediaKey: string$2(),
17170
- sourceKind: MediaFileKindEnum,
17171
- sizeBytes: number().int(),
17172
- width: number().int(),
17173
- height: number().int(),
17174
- copiedAt: number()
17190
+ /** The linked sensor device whose state changed. */
17191
+ sourceDeviceId: number(),
17192
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
17193
+ kind: string$2(),
17194
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
17195
+ value: record(string$2(), unknown()).nullable(),
17196
+ timestamp: number()
17175
17197
  });
17176
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17177
- var RetrainCopyRefusalSchema = _enum([
17178
- "source-missing",
17179
- "unreadable-image",
17180
- "write-failed"
17181
- ]);
17182
- var RetrainFrameSelectionSchema = object({
17183
- copied: array(RetrainFrameSchema).readonly(),
17184
- refused: array(object({
17185
- sourceMediaKey: string$2(),
17186
- reason: RetrainCopyRefusalSchema
17187
- })).readonly()
17198
+ var TrackPositionSchema = object({
17199
+ x: number(),
17200
+ y: number(),
17201
+ timestamp: number(),
17202
+ bbox: BoundingBoxSchema
17188
17203
  });
17189
- var RetrainFrameListSchema = object({
17190
- candidates: array(RetrainFrameCandidateSchema).readonly(),
17191
- copies: array(RetrainFrameSchema).readonly(),
17192
- /** What the page pre-selects the native key frame when one survives. */
17193
- autoPickMediaKey: string$2().optional()
17204
+ var TrackSnapshotSchema = object({
17205
+ timestamp: number(),
17206
+ position: TrackPositionSchema,
17207
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17208
+ mediaKey: string$2()
17194
17209
  });
17195
- /** What the operator asked the assist to look for. */
17196
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17197
- kind: literal("package"),
17198
- zone: RetrainBboxSchema.optional()
17199
- }), object({
17200
- kind: literal("objects"),
17201
- modelId: string$2(),
17202
- minScore: number().optional()
17203
- })]);
17204
17210
  /**
17205
- * The assist's answer a discriminated union, because "the model saw nothing"
17206
- * and "this node cannot run that model" lead to different next moves and a
17207
- * nullable result cannot tell them apart.
17211
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17212
+ * divided by the track's detection-frame dims), computed at persist time.
17213
+ * Absent when the frame dims were unknown when the track was persisted
17214
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17208
17215
  */
17209
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17210
- kind: literal("proposed"),
17211
- modelId: string$2(),
17212
- stepId: string$2(),
17213
- minScore: number(),
17214
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17215
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
17216
- /** Returned by the runner but removed by the threshold. */
17217
- belowThreshold: number().int()
17218
- }), object({
17219
- kind: literal("refused"),
17220
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17221
- reason: string$2(),
17222
- detail: string$2().optional()
17223
- })]);
17224
- /** The outcome of a lifecycle move owned by the retrain page. */
17225
- var RetrainTransitionResultSchema = object({
17226
- trackId: string$2(),
17227
- /** Where the track ended up, whatever happened. */
17228
- retrainStatus: RetrainStatusSchema,
17229
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17230
- changed: boolean(),
17231
- reason: _enum([
17232
- "unknown-track",
17233
- "no-frames-copied",
17234
- "not-staging",
17235
- "not-trained",
17236
- "unchanged"
17237
- ]).optional()
17238
- });
17239
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17240
- var MAX_EVENT_QUERY_LIMIT = 5e3;
17241
- var DeviceEventQueryInput = object({
17242
- deviceId: number(),
17243
- since: number().optional(),
17244
- until: number().optional(),
17245
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17246
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17247
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17248
- * exact behaviour. Callers may omit this field — the store defaults to
17249
- * `full` when not provided. */
17250
- projection: _enum(["full", "slim"]).optional()
17251
- });
17252
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string$2().optional() });
17253
- var RecentTracksQueryInput = object({
17254
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17255
- deviceIds: array(number()),
17256
- /** Window lower bound on `lastSeen` (inclusive). */
17257
- since: number().optional(),
17258
- /** Window upper bound on `lastSeen` (inclusive). */
17259
- until: number().optional(),
17260
- /** Page size. Default 200, max 1000. */
17261
- limit: number().int().min(1).max(1e3).default(200),
17262
- /** Opaque continuation cursor from a previous page's `nextCursor`.
17263
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17264
- cursor: string$2().optional(),
17265
- /** See {@link TrackProjectionSchema}. Default `full`. */
17266
- projection: TrackProjectionSchema.optional(),
17267
- /** Include stationary-promoted rows (parked objects). Default false: the
17268
- * feed lists passages; parking records live on the stationary registry. */
17269
- includeStationary: boolean().optional()
17270
- });
17271
- var RecentTracksPageSchema = object({
17272
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17273
- tracks: array(TrackSchema).readonly(),
17274
- /** Cursor for the next page, or null when this page is the last. */
17275
- nextCursor: string$2().nullable()
17276
- });
17277
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
17278
- var LIST_GROUPS_MAX_LIMIT = 100;
17279
- var AnalyticsGroupRecordSchema = object({
17280
- id: string$2(),
17281
- deviceId: number().int(),
17282
- openedAt: number().int(),
17283
- closedAt: number().int(),
17284
- timestamp: number().int(),
17285
- memberCount: number().int(),
17286
- memberTrackIds: array(string$2()).readonly(),
17287
- className: string$2(),
17288
- classes: array(string$2()).readonly(),
17289
- /** Relative event-media path, or null when the group has no picture yet. */
17290
- mediaUrl: string$2().nullable(),
17291
- singleton: boolean()
17216
+ var TrackEnvelopeSchema = object({
17217
+ minX: number(),
17218
+ minY: number(),
17219
+ maxX: number(),
17220
+ maxY: number()
17292
17221
  });
17293
- var AnalyticsGroupMemberSchema = object({
17294
- trackId: string$2(),
17295
- deviceId: number().int(),
17296
- className: string$2(),
17297
- firstSeen: number().int(),
17298
- lastSeen: number().int(),
17299
- mediaUrl: string$2().nullable()
17300
- });
17301
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17302
- var ListGroupsQueryInput = object({
17303
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17304
- deviceIds: array(number()),
17305
- /** Window lower bound on `closedAt` (inclusive). */
17306
- since: number().optional(),
17307
- /** Window upper bound on `openedAt` (inclusive). */
17308
- until: number().optional(),
17309
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17310
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
17311
- cursor: string$2().optional()
17312
- });
17313
- var ListGroupsPageSchema = object({
17314
- groups: array(AnalyticsGroupRecordSchema).readonly(),
17315
- nextCursor: string$2().nullable()
17316
- });
17317
- var KeyEventQueryInput = object({
17318
- deviceId: number(),
17319
- /** Window lower bound (track firstSeen ≥ since). */
17320
- since: number(),
17321
- /** Window upper bound (track firstSeen ≤ until). */
17322
- until: number(),
17323
- limit: number().int().min(1).max(200).default(50),
17324
- /** Drop tracks scoring below this importance. */
17325
- minImportance: number().min(0).max(1).optional(),
17326
- /** Restrict to a single class (e.g. 'person'). */
17327
- classFilter: string$2().optional()
17328
- });
17329
- var KeyEventSchema = object({
17330
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
17331
- id: string$2(),
17332
- trackId: string$2(),
17333
- /** Track start time (firstSeen). */
17334
- timestamp: number(),
17335
- className: string$2(),
17336
- ...TieredLabelFields,
17337
- importance: number(),
17338
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
17339
- bestEventId: string$2(),
17340
- /** Track lifetime in ms (lastSeen - firstSeen). */
17341
- windowMs: number().optional(),
17342
- ...TrackFlagFields,
17343
- ...TrackRetrainFields
17344
- });
17345
- object({
17346
- trackId: string$2(),
17347
- className: string$2(),
17348
- confidence: number(),
17349
- bbox: BoundingBoxSchema,
17350
- zones: array(string$2()).readonly(),
17351
- state: TrackStateSchema
17352
- });
17353
- var OverlayDetectionSchema = looseObject({
17354
- id: string$2(),
17355
- kind: _enum(["first-level", "detail"]),
17356
- macroClass: string$2(),
17357
- score: number(),
17358
- bbox: object({
17359
- x: number(),
17360
- y: number(),
17361
- width: number(),
17362
- height: number()
17363
- }),
17364
- labels: array(looseObject({
17365
- label: string$2(),
17366
- score: number()
17367
- })).readonly(),
17368
- parentId: string$2().optional()
17369
- });
17370
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
17371
- var SearchObjectEventsInput = object({
17372
- text: string$2(),
17373
- deviceId: number().optional(),
17374
- since: number().optional(),
17375
- until: number().optional(),
17376
- classFilter: string$2().optional(),
17377
- limit: number().default(50),
17378
- minScore: number().min(0).max(1).default(.2)
17379
- });
17380
- var TrackCascadeCountsSchema = object({
17381
- /** Persisted track roots deleted (authoritative). */
17382
- tracks: number().int(),
17383
- /** Object events removed with their tracks (best-effort; see note above). */
17384
- events: number().int(),
17385
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17386
- media: number().int(),
17387
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
17388
- faces: number().int(),
17389
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17390
- plates: number().int(),
17391
- /** Per-track CLIP search vectors removed (best-effort). */
17392
- embeddings: number().int(),
17393
- /** Group membership + group rows removed with their last member (best-effort). */
17394
- groups: number().int()
17395
- });
17396
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17397
- var DiskReconcileCountsSchema = object({
17398
- mediaDropped: number().int(),
17399
- tracks: number().int(),
17400
- events: number().int()
17401
- });
17402
- /** Event-store footprint for one camera. */
17403
- var EventStoreDeviceFootprintSchema = object({
17404
- deviceId: number(),
17405
- /** Persisted event rows (motion + object + audio) for the camera. */
17406
- rows: number().int(),
17407
- /** Event-owned media bytes on disk for the camera. */
17408
- bytes: number().int()
17409
- });
17410
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
17411
- var EventStoreFootprintSchema = object({
17412
- totalRows: number().int(),
17413
- totalBytes: number().int(),
17414
- devices: array(EventStoreDeviceFootprintSchema).readonly()
17415
- });
17416
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
17417
- var EventPruneCountsSchema = object({
17418
- motion: number().int(),
17419
- object: number().int(),
17420
- audio: number().int()
17222
+ /**
17223
+ * Row projection for track list queries. `full` (default) returns the
17224
+ * complete Track including the frame-rate `positions[]` history and the
17225
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
17226
+ * keeps every scalar the list surfaces actually render (ids, class(es),
17227
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17228
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17229
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
17230
+ * `getTrack`. Mirrors the event-store `projection` convention
17231
+ * (`getObjectEvents` et al.).
17232
+ */
17233
+ var TrackProjectionSchema = _enum(["full", "slim"]);
17234
+ /**
17235
+ * One audio-classification label heard on the track's camera while the
17236
+ * track was alive, aggregated per label. An "episode" is one persisted
17237
+ * audio event (the confident-classification path: score ≥ the device's
17238
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17239
+ * one 32 ms inference chunk, so counts stay human-scaled.
17240
+ */
17241
+ var TrackAudioLabelSchema = object({
17242
+ label: string$2(),
17243
+ /** Highest classification score observed across the label's episodes. */
17244
+ peakScore: number(),
17245
+ /** Number of coalesced audio-event episodes carrying this label. */
17246
+ count: number(),
17247
+ firstAt: number(),
17248
+ lastAt: number()
17421
17249
  });
17422
17250
  /**
17423
- * Re-embed stored tracks from their key frames.
17251
+ * How a track was produced. `pipeline` (default / absent) = the spatial
17252
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17253
+ * no positions, a single snapshot, and no bbox trajectory at all:
17424
17254
  *
17425
- * The reason this is an operator-callable method and not a migration script:
17426
- * every knob that decides what a vector MEANS encoder model, crop margin,
17427
- * squaring is only changeable if the existing vectors can be regenerated.
17428
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
17429
- * symptom is a quality regression with no visible cause.
17255
+ * - `sensor` a linked sensor/control device state change.
17256
+ * - `audio` an audio event on the camera itself that was anomalous for
17257
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
17258
+ *
17259
+ * The spatial subsystems (tracker association, occupancy count, re-id /
17260
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
17261
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17262
+ * check silently readmits every source added after it was written.
17430
17263
  */
17431
- var RebuildObjectEmbeddingsInput = object({
17432
- /** Restrict to one camera. Omit for the whole fleet. */
17433
- deviceId: number().optional(),
17434
- since: number().optional(),
17435
- until: number().optional(),
17436
- /** Stop after this many tracks; the result reports whether more remain. */
17437
- maxTracks: number().int().positive().optional(),
17438
- /**
17439
- * Run every embedding on THIS node instead of round-robining the fleet.
17440
- *
17441
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
17442
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
17443
- * calling it that would pin the rebuild REQUEST itself to that node — the
17444
- * rebuild orchestration lives on the hub, and only the per-track step runs
17445
- * remotely. This field is data; the per-track pin is applied inside.
17446
- *
17447
- * Absent ⇒ round-robin over every online node whose runner can serve the
17448
- * pinned model.
17449
- */
17450
- executeOnNodeId: string$2().optional(),
17451
- /**
17452
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
17453
- * run flat out.
17454
- *
17455
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
17456
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
17457
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
17458
- * force is logged at start and finish so a deliberately slow pass reads
17459
- * differently from a stalled one.
17460
- */
17461
- pacingMs: number().int().nonnegative().optional()
17462
- });
17264
+ var TrackSourceSchema = _enum([
17265
+ "pipeline",
17266
+ "sensor",
17267
+ "audio"
17268
+ ]);
17463
17269
  /**
17464
- * Result of emptying the CLIP index.
17270
+ * Where a track sits in the RETRAIN lifecycle (D81).
17465
17271
  *
17466
- * The clean slate before a policy change: a new crop margin or encoder model
17467
- * leaves two feature spaces in one index whose cosine scores are not
17468
- * comparable, so wiping and rebuilding is the only way to be sure every vector
17469
- * means the same thing.
17272
+ * - `none` never marked, or un-marked. Evictable.
17273
+ * - `staging` the operator wants this track as training material and has not
17274
+ * finished with it. **This is the only state retention holds**: the track and
17275
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
17276
+ * the device's age window.
17277
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
17278
+ * were COPIED into the retrain dataset at selection time, so the dataset no
17279
+ * longer depends on the track's media and the track becomes EVICTABLE again.
17280
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17281
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
17282
+ *
17283
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17284
+ * the store's filter language has only positive equality and `whereIn` — no
17285
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17286
+ * would make the entire pre-column history immortal in one deploy.
17470
17287
  */
17471
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
17288
+ var RetrainStatusSchema = _enum([
17289
+ "none",
17290
+ "staging",
17291
+ "trained"
17292
+ ]);
17472
17293
  /**
17473
- * Acknowledgement that a rebuild STARTED.
17294
+ * Per-track OPERATOR flags set by hand from the admin UI or the viewer, never
17295
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17296
+ * so the two surfaces cannot drift.
17474
17297
  *
17475
- * The pass costs ~1s per track 45 minutes for a 2,600-track fleet so it
17476
- * runs detached and this returns immediately. Waiting for it made the client
17477
- * time out while the work carried on server-side, which is the worst of both:
17478
- * no result and no way to know it was still going. Poll
17479
- * `getObjectEmbeddingRebuildStatus` for progress.
17298
+ * **Absent false.** A track that has never been touched omits the field; an
17299
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
17300
+ * columns existed read as absent, and a consumer that needs a boolean should say
17301
+ * `flag === true`, not `flag !== false`.
17302
+ *
17303
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17304
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17305
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17306
+ * `trained` track reports `false` while refusing both writes. The boolean is
17307
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
17308
+ * "never marked" from "already trained" must read `retrainStatus`.
17309
+ *
17310
+ * `debug` does NOT pin; it is attention, not durability.
17311
+ *
17312
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17313
+ * A favourited track is skipped by retention the same way `staging` is, but
17314
+ * it does not enter `none|staging|trained` and has no staging budget.
17480
17315
  */
17481
- var RebuildObjectEmbeddingsResultSchema = object({
17482
- started: boolean(),
17483
- /** True when a pass was already running; the new request is ignored. */
17484
- alreadyRunning: boolean()
17485
- });
17486
- var RebuildStatusSchema = object({
17487
- running: boolean(),
17488
- scanned: number(),
17489
- rebuilt: number(),
17490
- /** Tracks whose key frame is gone — nothing to re-embed from. */
17491
- missingKeyFrame: number(),
17492
- /** Tracks with no usable detection box. */
17493
- missingBbox: number(),
17494
- /**
17495
- * Tracks an executing node REFUSED rather than broke on an unreadable key
17496
- * frame, a step that threw. Separate from `failed` because the remedy is
17497
- * different, and because a whole camera silently contributing zero vectors
17498
- * is the shape of failure a rebuild must never hide.
17499
- */
17500
- notRunnable: number(),
17501
- /**
17502
- * The pass stopped because NO node could serve the pinned model.
17503
- *
17504
- * Distinct from `notRunnable` on purpose: that one says "this track was
17505
- * refused", this one says "the cluster cannot do this work at all" — every
17506
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
17507
- * pinned model for its engine format, or dropped out. The remedy is a model /
17508
- * engine change, not a per-camera one. Non-zero here always comes with
17509
- * `complete: false`.
17510
- */
17511
- noCapableNode: number(),
17512
- failed: number(),
17513
- /** Set once a pass ends: true only when EVERYTHING was covered. */
17514
- complete: boolean().nullable(),
17515
- startedAtMs: number().nullable(),
17516
- finishedAtMs: number().nullable(),
17517
- /** Present when the pass ended by throwing. */
17518
- error: string$2().nullable()
17316
+ var TrackFlagFields = {
17317
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
17318
+ * `'staging'`. */
17319
+ markForTrain: boolean().optional(),
17320
+ /** Operator marked this track for diagnostic attention. */
17321
+ debug: boolean().optional(),
17322
+ /** Operator favourited this track. Pins it against pruning. */
17323
+ favourited: boolean().optional()
17324
+ };
17325
+ /**
17326
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17327
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17328
+ * write patch, and the status is not something the toggle sets — it is what the
17329
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17330
+ * always present on a persisted row (the column default materialises `'none'`).
17331
+ */
17332
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17333
+ /**
17334
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17335
+ * one flag can never clear the other — the toggles are independent and are
17336
+ * driven from three surfaces that do not know about each other.
17337
+ */
17338
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
17339
+ /**
17340
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
17341
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
17342
+ * mutation result without a re-fetch.
17343
+ */
17344
+ var TrackFlagsSchema = object({
17345
+ trackId: string$2(),
17346
+ markForTrain: boolean(),
17347
+ debug: boolean(),
17348
+ favourited: boolean(),
17349
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
17350
+ * a track row) because this shape is only ever produced by the write body,
17351
+ * which always knows it — and a surface that has just written needs to render
17352
+ * `trained` without a re-fetch. */
17353
+ retrainStatus: RetrainStatusSchema
17519
17354
  });
17520
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
17521
- deviceId: number(),
17522
- trackId: string$2()
17523
- }), TrackSchema.nullable()), method(object({
17524
- deviceId: number(),
17525
- since: number().optional(),
17526
- until: number().optional(),
17527
- limit: number().optional(),
17528
- /** Spatial filter only tracks whose trajectory intersects the zone
17529
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
17530
- * envelope columns, then precisely tested per position. Tracks with
17531
- * an unknown envelope (no frame dims at persist time) always match. */
17532
- zone: TrackZoneFilterSchema.optional(),
17533
- /** See {@link TrackProjectionSchema}. Default `full` (backward
17534
- * compatible — omitting the field keeps today's exact behaviour). */
17535
- projection: TrackProjectionSchema.optional(),
17536
- /** Include stationary-promoted rows (parked objects handed to the
17537
- * stationary registry). Default false: the timeline lists passages,
17538
- * not parking records (operator decision, 2026-08-15). */
17539
- includeStationary: boolean().optional()
17540
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
17541
- deviceId: number(),
17542
- groupId: string$2().min(1)
17543
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
17544
- kind: "mutation",
17545
- auth: "admin"
17546
- }), 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({
17547
- deviceId: number(),
17548
- since: number().optional(),
17549
- until: number().optional(),
17550
- kinds: array(string$2()).optional(),
17551
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
17552
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
17553
- deviceId: number(),
17554
- since: number(),
17555
- until: number(),
17556
- bucketMs: number().int().positive()
17557
- }), array(object({
17558
- bucketStart: number(),
17559
- motion: number().int(),
17560
- object: number().int(),
17561
- audio: number().int()
17562
- })).readonly()), method(object({
17563
- deviceId: number(),
17564
- cutoffMs: number()
17565
- }), object({
17566
- motion: number().int(),
17567
- object: number().int(),
17568
- audio: number().int()
17569
- }), {
17570
- kind: "mutation",
17571
- auth: "admin"
17572
- }), method(object({
17573
- deviceId: number(),
17574
- cutoffMs: number()
17575
- }), TrackCascadeCountsSchema, {
17576
- kind: "mutation",
17577
- auth: "admin"
17578
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17579
- kind: "mutation",
17580
- auth: "admin"
17581
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17582
- kind: "mutation",
17583
- auth: "admin"
17584
- }), method(object({
17585
- deviceId: number(),
17586
- trackIds: array(string$2()).min(1)
17587
- }), object({
17588
- deleted: number().int(),
17589
- failed: array(string$2()).readonly()
17590
- }), {
17591
- kind: "mutation",
17592
- auth: "admin"
17593
- }), method(object({
17594
- /** Log/audit scope only — the trackId is globally unique on its own. */
17355
+ union([literal(1), literal(2)]);
17356
+ /**
17357
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
17358
+ * the step and model that produced it — which is what makes the write rule
17359
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17360
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17361
+ *
17362
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17363
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17364
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
17365
+ * that value has no provenance, and the write rule lets ANY properly-attributed
17366
+ * write of the same tier replace it regardless of score.
17367
+ */
17368
+ var LabelAttributionSchema = object({
17369
+ stepId: string$2(),
17370
+ modelId: string$2().optional(),
17371
+ decidedAt: number(),
17372
+ /**
17373
+ * The GALLERY id behind a recognised tier-2 label — a face-gallery
17374
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17375
+ *
17376
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
17377
+ * notification rule authored on "Gianluca" stopped matching the moment the
17378
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
17379
+ * the thing that does not move, so it is what a rule matches on
17380
+ * (`NcConditions.identities`) and the text is what a human is shown.
17381
+ *
17382
+ * Absent when the label names no gallery row — a plate the OCR read but no
17383
+ * vehicle claims, a sub-class, a species, any tier-1 value.
17384
+ */
17385
+ identityId: string$2().optional()
17386
+ });
17387
+ /**
17388
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17389
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17390
+ * track and its events always answer the same question the same way.
17391
+ *
17392
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
17393
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17394
+ * is tier 2, and each carries its own score + attribution.
17395
+ *
17396
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17397
+ * finest thing known. Before 4g the single `label` column held the finest
17398
+ * value, so a consumer that has not been updated reads the tier-1 slot and
17399
+ * shows nothing on a species-only row; that is why the migration puts every
17400
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17401
+ * and why the read surfaces were changed in the same train.
17402
+ *
17403
+ * **Writing it.** The slots are independent, which is the whole point: a
17404
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17405
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
17406
+ * higher score wins. One rule, one implementation — see
17407
+ * `pipeline/label-tier.ts` in addon-post-analysis.
17408
+ */
17409
+ var TieredLabelFields = {
17410
+ /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
17411
+ label: string$2().optional(),
17412
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
17413
+ labelScore: number().optional(),
17414
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17415
+ labelMeta: LabelAttributionSchema.optional(),
17416
+ /** Tier 2 the instance. See {@link LabelTierSchema}. */
17417
+ subLabel: string$2().optional(),
17418
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
17419
+ subLabelScore: number().optional(),
17420
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17421
+ subLabelMeta: LabelAttributionSchema.optional()
17422
+ };
17423
+ /** Per-camera slice of a training-export estimate. */
17424
+ var TrainingExportDeviceTotalsSchema = object({
17595
17425
  deviceId: number(),
17426
+ tracks: number().int(),
17427
+ files: number().int(),
17428
+ bytes: number().int()
17429
+ });
17430
+ /**
17431
+ * What a training export WOULD contain. Computed from media index rows only —
17432
+ * no blob is read to produce this.
17433
+ */
17434
+ var TrainingExportSummarySchema = object({
17435
+ generatedAt: number(),
17436
+ trackCount: number().int(),
17437
+ fileCount: number().int(),
17438
+ byteCount: number().int(),
17439
+ /** More marked tracks exist than a single pass carries. */
17440
+ truncated: boolean(),
17441
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
17442
+ });
17443
+ var TrackSchema = object({
17596
17444
  trackId: string$2(),
17597
- flags: TrackFlagsPatchSchema
17598
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
17599
- kind: "query",
17600
- auth: "admin"
17601
- }), method(object({
17602
- olderThanMs: number(),
17603
- reason: OpsLogReasonSchema.optional()
17604
- }), EventPruneCountsSchema, {
17605
- kind: "mutation",
17606
- auth: "admin"
17607
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
17608
- kind: "mutation",
17609
- auth: "admin"
17610
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
17611
- kind: "mutation",
17612
- auth: "admin"
17613
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
17614
- kind: "mutation",
17615
- auth: "admin"
17616
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
17617
- kind: "mutation",
17618
- auth: "admin"
17619
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string$2() }), {
17620
- kind: "mutation",
17621
- auth: "admin"
17622
- }), method(object({ jobId: string$2() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string$2() }), object({ cancelled: boolean() }), {
17623
- kind: "mutation",
17624
- auth: "admin"
17625
- }), method(RelocateMediaInputSchema, object({ jobId: string$2() }), {
17626
- kind: "mutation",
17627
- auth: "admin"
17628
- }), method(object({}), array(RelocateJobSchema).readonly(), {
17629
- kind: "query",
17630
- auth: "admin"
17631
- }), method(object({ jobId: string$2() }), object({ cancelled: boolean() }), {
17632
- kind: "mutation",
17633
- auth: "admin"
17634
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
17635
- kind: "query",
17636
- auth: "admin"
17637
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
17638
- kind: "query",
17639
- auth: "admin"
17640
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string$2() }), {
17641
- kind: "query",
17642
- auth: "admin"
17643
- }), method(object({
17644
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
17645
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
17646
- * route it at one camera's owner, and "every camera" would stop being
17647
- * expressible at all. */
17648
- deviceIds: array(number()).optional(),
17649
- limit: number().int().min(1).max(500).optional()
17650
- }), array(RetrainTrackSchema).readonly(), {
17651
- kind: "query",
17652
- auth: "admin"
17653
- }), method(object({ trackId: string$2() }), RetrainFrameListSchema, {
17654
- kind: "query",
17655
- auth: "admin"
17656
- }), method(object({
17657
17445
  deviceId: number(),
17658
- trackId: string$2(),
17659
- mediaKeys: array(string$2()).min(1)
17660
- }), RetrainFrameSelectionSchema, {
17661
- kind: "mutation",
17662
- auth: "admin"
17663
- }), method(object({
17446
+ className: string$2(),
17447
+ ...TieredLabelFields,
17448
+ producingDeviceName: string$2().optional(),
17449
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
17450
+ source: TrackSourceSchema.optional(),
17451
+ firstSeen: number(),
17452
+ lastSeen: number(),
17453
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
17454
+ positions: array(TrackPositionSchema).readonly(),
17455
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17456
+ * saveThumbnails policy). */
17457
+ snapshots: array(TrackSnapshotSchema).readonly(),
17458
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
17459
+ zonesVisited: array(string$2()).readonly(),
17460
+ /**
17461
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17462
+ * `zones` capability.
17463
+ *
17464
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17465
+ * and no card can render — so every free-text search surface was structurally
17466
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17467
+ * just returned nothing. Resolving here rather than in each client keeps ONE
17468
+ * derivation and costs the clients no extra call (the `zones` cap is
17469
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
17470
+ * surface built to avoid exactly that).
17471
+ *
17472
+ * Resolved, never invented: a zone deleted since the track was written has no
17473
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17474
+ * two are not positionally aligned. Absent when the track visited no zone, or
17475
+ * when the zone catalogue could not be read.
17476
+ */
17477
+ zoneNames: array(string$2()).readonly().optional(),
17478
+ /** Deduplicated set of detector classes observed for this track over its
17479
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
17480
+ * legacy rows written before class accumulation shipped. */
17481
+ classes: array(string$2()).readonly().optional(),
17482
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17483
+ totalDistance: number(),
17484
+ state: TrackStateSchema,
17485
+ active: boolean(),
17486
+ /** Deterministic key-event importance score in [0,1] (server-computed at
17487
+ * track expiry, recomputed on late label). Absent on legacy rows written
17488
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
17489
+ importance: number().optional(),
17490
+ /** Id of the track's highest-confidence ObjectEvent (its representative
17491
+ * "best" frame). Absent when the track produced no object events. */
17492
+ bestEventId: string$2().optional(),
17493
+ /** Tag of the importance sub-signal that dominated the score
17494
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
17495
+ importanceReason: string$2().optional(),
17496
+ /** Audio-classification labels heard on the camera during the track's
17497
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
17498
+ * Absent on legacy rows / tracks with no confident audio. */
17499
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17500
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17501
+ * Populated from the persisted envelope columns on historical reads;
17502
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17503
+ envelope: TrackEnvelopeSchema.optional(),
17504
+ /**
17505
+ * A face DETECTOR found a face on this track — nothing more. It says the
17506
+ * detail plane produced a `face` detail; it does NOT say the face was
17507
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
17508
+ * enabled. Set once and never cleared.
17509
+ *
17510
+ * **This exists so "face present but not recognised" is expressible.** A
17511
+ * recognised identity lands in `subLabel` (attributed to the face chain via
17512
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17513
+ * and a track with no face at all were byte-identical on the wire and no
17514
+ * surface could tell them apart. The read is `hasFace === true && subLabel
17515
+ * === undefined`.
17516
+ *
17517
+ * **Absent ≠ false.** Every row written before the column existed omits it,
17518
+ * and so does every server that predates the field — a consumer must test
17519
+ * `=== true` and render nothing otherwise, never infer "no face".
17520
+ */
17521
+ hasFace: boolean().optional(),
17522
+ /**
17523
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
17524
+ * face an operator could ASSIGN to an identity.
17525
+ *
17526
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17527
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
17528
+ * branch, before every gate, and means no more than "a face detector produced
17529
+ * a face detail". This one is stamped at the single moment the gallery row
17530
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17531
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17532
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
17533
+ * the crop-store drop. Everything between the detector and that insert can
17534
+ * legitimately refuse the face, so a flag written any earlier promises the
17535
+ * operator something to assign and delivers nothing.
17536
+ *
17537
+ * **Independent of recognition.** A face collected but never auto-matched is
17538
+ * still assignable — it is in fact the face an operator most wants to reach —
17539
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17540
+ * `subLabel`; this says only that the raw material exists.
17541
+ *
17542
+ * **Set once, never cleared.** A track that produced a gallery row produced
17543
+ * one; deleting the row later is the gallery's business, not this flag's.
17544
+ *
17545
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17546
+ * before the column omits it, and so does every server that predates the
17547
+ * field. A consumer must test `=== true` and render nothing otherwise —
17548
+ * never infer "no assignable face".
17549
+ */
17550
+ hasEmbeddedFace: boolean().optional(),
17551
+ /**
17552
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
17553
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17554
+ * so the passage is tracked once and as a VEHICLE.
17555
+ *
17556
+ * It exists because the fold's record was dishonest. D34 and the code both
17557
+ * said "the person is not lost — it is reported so both entities stay on the
17558
+ * record"; in fact the pair went into a per-processor RAM field behind an
17559
+ * accessor nobody called, and every durable surface said `vehicle`, full
17560
+ * stop. This is the composition note that makes the row true.
17561
+ *
17562
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
17563
+ * person" is not an answer to "what is this" — both label tiers would refuse
17564
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
17565
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17566
+ * and a `person` rule still does not fire for someone cycling past.
17567
+ *
17568
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17569
+ * the column, and every hub that predates the field, omits it. Test
17570
+ * `=== true` and render nothing otherwise — never infer "no rider".
17571
+ */
17572
+ hasRider: boolean().optional(),
17573
+ ...TrackFlagFields,
17574
+ ...TrackRetrainFields
17575
+ });
17576
+ var BaseEventFields = {
17577
+ id: string$2(),
17664
17578
  deviceId: number(),
17665
- trackId: string$2(),
17666
- frameId: string$2()
17667
- }), object({
17668
- removed: boolean(),
17669
- removedAnnotations: number().int()
17670
- }), {
17671
- kind: "mutation",
17672
- auth: "admin"
17673
- }), method(object({ frameId: string$2() }), object({
17579
+ timestamp: number()
17580
+ };
17581
+ var MotionEventSchema = object({
17582
+ ...BaseEventFields,
17583
+ kind: literal("motion"),
17584
+ regionCount: number(),
17585
+ /** Heavy JSON array — omitted in slim projection. */
17586
+ regions: array(object({
17587
+ bbox: BoundingBoxSchema,
17588
+ pixelCount: number(),
17589
+ intensity: number()
17590
+ })).readonly().optional(),
17591
+ /** Omitted in slim projection. */
17592
+ frameWidth: number().optional(),
17593
+ /** Omitted in slim projection. */
17594
+ frameHeight: number().optional(),
17595
+ /** Populated by B5 (recording playback URL for this event). */
17596
+ mediaUrl: string$2().optional()
17597
+ });
17598
+ /**
17599
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
17600
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
17601
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
17602
+ * tracking, per-kind persistence) but stay distinguishable so consumers
17603
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17604
+ * Absent on legacy rows ⇒ treat as `pipeline`.
17605
+ */
17606
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17607
+ /**
17608
+ * The confirmed zone crossing that produced an object event. Present ONLY on
17609
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17610
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17611
+ * appearance event carry none, so a rule asking for a direction fails closed
17612
+ * on them.
17613
+ *
17614
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17615
+ * into its own event, so a frame in which a track enters A while leaving B
17616
+ * produces two events with two directions — never one ambiguous row.
17617
+ *
17618
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17619
+ * membership the box has NOW, and by definition it no longer contains the zone
17620
+ * that was just left. Without the id here, a zone-scoped rule could never match
17621
+ * the exit it asked for.
17622
+ */
17623
+ var ZoneCrossingSchema = object({
17624
+ direction: _enum(["enter", "exit"]),
17625
+ /** Admin zone id crossed. */
17626
+ zoneId: string$2(),
17627
+ /** Zone display name at crossing time (falls back to the id). */
17628
+ zoneName: string$2().optional()
17629
+ });
17630
+ var ObjectEventSchema = object({
17631
+ ...BaseEventFields,
17632
+ kind: literal("object"),
17633
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17634
+ source: DetectionSourceSchema.optional(),
17635
+ /**
17636
+ * Inference-frame id shared by every object event emitted from the SAME frame
17637
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17638
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
17639
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
17640
+ * Optional for backward-compat with pre-existing rows / the slim projection
17641
+ * includes it (it is light). Absent on rows written before this field.
17642
+ */
17643
+ frameId: string$2().optional(),
17644
+ /** Omitted in slim projection. */
17645
+ trackId: string$2().optional(),
17646
+ className: string$2(),
17647
+ ...TieredLabelFields,
17648
+ /** Omitted in slim projection. */
17649
+ confidence: number().optional(),
17650
+ /** Heavy JSON — omitted in slim projection. */
17651
+ bbox: BoundingBoxSchema.optional(),
17652
+ /** Heavy JSON — omitted in slim projection. */
17653
+ zones: array(string$2()).readonly().optional(),
17654
+ /** Omitted in slim projection. */
17655
+ state: TrackStateSchema.optional(),
17656
+ /**
17657
+ * The zone crossing this event IS, when it is one. Absent on every other
17658
+ * event kind (movement state, appearance, package) — see
17659
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
17660
+ */
17661
+ zoneCrossing: ZoneCrossingSchema.optional(),
17662
+ /** Detection-frame dimensions in pixels — let consumers normalize the
17663
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17664
+ frameWidth: number().optional(),
17665
+ frameHeight: number().optional(),
17666
+ /** MediaStore key for the crop attached to this event (if any). */
17667
+ mediaKey: string$2().optional(),
17668
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
17669
+ * best-detection full frame). Resolve via the event-media data-plane
17670
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17671
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17672
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
17673
+ keyFrameMediaKey: string$2().optional(),
17674
+ /** Populated by B5 (recording playback URL for this event). */
17675
+ mediaUrl: string$2().optional(),
17676
+ /** The parent track's key-event importance [0,1], propagated to every object
17677
+ * event of the track (so an event row can be sorted by importance without a
17678
+ * track join). Absent on legacy rows / before the track was scored. */
17679
+ importance: number().optional()
17680
+ });
17681
+ var AudioEventSchema = object({
17682
+ ...BaseEventFields,
17683
+ kind: literal("audio"),
17684
+ rms: number(),
17685
+ dbfs: number(),
17686
+ classification: object({
17687
+ className: string$2(),
17688
+ originalClass: string$2().optional(),
17689
+ score: number()
17690
+ }).optional(),
17691
+ /** Populated by B5 (recording playback URL for this event). */
17692
+ mediaUrl: string$2().optional()
17693
+ });
17694
+ var MediaFileKindEnum = _enum([
17695
+ "crop",
17696
+ "thumbnail",
17697
+ "snapshot",
17698
+ "firstFrame",
17699
+ "lastFrame",
17700
+ "fullFrame",
17701
+ "fullFrameBoxed",
17702
+ "faceCrop",
17703
+ "plateCrop",
17704
+ "keyFrame",
17705
+ "keyFrameSmall",
17706
+ "thumbnailSmall"
17707
+ ]);
17708
+ var MediaFileSchema = object({
17709
+ key: string$2(),
17710
+ kind: MediaFileKindEnum,
17674
17711
  base64: string$2(),
17675
- width: number().int(),
17676
- height: number().int()
17677
- }), {
17678
- kind: "query",
17679
- auth: "admin"
17680
- }), method(object({
17681
- deviceId: number(),
17682
- trackId: string$2(),
17683
- frameId: string$2(),
17684
- subject: RetrainAssistSubjectSchema,
17685
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
17686
- nodeId: string$2().optional()
17687
- }), RetrainAssistResultSchema, {
17688
- kind: "mutation",
17689
- auth: "admin"
17690
- }), method(object({ trackId: string$2() }), array(RetrainAnnotationSchema).readonly(), {
17691
- kind: "query",
17692
- auth: "admin"
17693
- }), method(object({
17694
- deviceId: number(),
17695
- trackId: string$2(),
17696
- frameId: string$2(),
17697
- annotations: array(RetrainAnnotationDraftSchema)
17698
- }), array(RetrainAnnotationSchema).readonly(), {
17699
- kind: "mutation",
17700
- auth: "admin"
17701
- }), method(object({
17702
- deviceId: number(),
17703
- trackId: string$2()
17704
- }), RetrainTransitionResultSchema, {
17705
- kind: "mutation",
17706
- auth: "admin"
17707
- }), method(object({
17708
- deviceId: number(),
17709
- trackId: string$2()
17710
- }), RetrainTransitionResultSchema, {
17711
- kind: "mutation",
17712
- auth: "admin"
17713
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string$2() }), {
17714
- kind: "query",
17715
- auth: "admin"
17716
- }), method(object({
17717
- eventId: string$2(),
17718
- kind: MediaFileKindEnum.optional(),
17719
- deviceId: number()
17720
- }), array(MediaFileSchema).readonly()), method(object({
17721
- trackId: string$2(),
17722
- kinds: array(MediaFileKindEnum).optional(),
17723
- deviceId: number()
17724
- }), array(MediaFileSchema).readonly()), method(object({
17712
+ sizeBytes: number(),
17713
+ timestamp: number()
17714
+ });
17715
+ /**
17716
+ * One media row WITHOUT its bytes.
17717
+ *
17718
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17719
+ * 140 s track), and a client that renders tiles from the media data plane needs
17720
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
17721
+ * with an immutable cache, instead of all at once inside a tRPC response that
17722
+ * blocks the whole view.
17723
+ *
17724
+ * `sizeBytes` is carried because it is what lets a client decide between the
17725
+ * stored blob and a `?variant=thumb` rendering without fetching either.
17726
+ */
17727
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17728
+ /**
17729
+ * The MACRO tier of an annotation — a CLOSED set.
17730
+ *
17731
+ * This is what the exported detector predicts, so a typo here is a new class
17732
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
17733
+ * the whole point of the page is teaching the model things it does not know
17734
+ * yet, and constraining that vocabulary would make it useless.
17735
+ *
17736
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
17737
+ * `subLabel` is one of these values, in any casing, because once `person`
17738
+ * exists in both tiers "every person box" stops being answerable without
17739
+ * knowing every string anyone ever typed — and the damage is retroactive.
17740
+ */
17741
+ var RetrainMacroClassSchema = _enum([
17742
+ "person",
17743
+ "vehicle",
17744
+ "animal",
17745
+ "package",
17746
+ "face",
17747
+ "plate"
17748
+ ]);
17749
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17750
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17751
+ /** Did a human draw this box, or did the assist propose it? */
17752
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17753
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17754
+ var RetrainBboxSchema = object({
17755
+ x: number(),
17756
+ y: number(),
17757
+ w: number(),
17758
+ h: number()
17759
+ });
17760
+ /**
17761
+ * One annotated subject.
17762
+ *
17763
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17764
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17765
+ * derived from it at export and never stored — storing them is how one feature
17766
+ * space ends up holding two crops of the same subject (D52).
17767
+ */
17768
+ var RetrainAnnotationSchema = object({
17769
+ id: string$2(),
17725
17770
  trackId: string$2(),
17726
- deviceId: number()
17727
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
17728
- kind: "mutation",
17729
- auth: "admin"
17730
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
17731
- kind: "mutation",
17732
- auth: "admin"
17733
- }), method(object({}), RebuildStatusSchema), object({
17734
- deviceId: number(),
17735
- timestamp: number(),
17736
- frameWidth: number(),
17737
- frameHeight: number(),
17738
- detections: array(OverlayDetectionSchema).readonly()
17739
- }), object({
17740
17771
  deviceId: number(),
17772
+ /** The COPY in retrain storage — never the source track's media key. */
17773
+ mediaKey: string$2(),
17774
+ bbox: RetrainBboxSchema,
17775
+ macroClass: RetrainMacroClassSchema,
17776
+ label: string$2().optional(),
17777
+ subLabel: string$2().optional(),
17778
+ kind: RetrainAnnotationKindSchema,
17779
+ source: RetrainAnnotationSourceSchema,
17780
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17781
+ assistModelId: string$2().optional(),
17782
+ assistScore: number().optional(),
17783
+ exportedInBatch: string$2().optional(),
17784
+ createdAt: number()
17785
+ });
17786
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17787
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17788
+ id: true,
17789
+ trackId: true,
17790
+ deviceId: true,
17791
+ mediaKey: true,
17792
+ createdAt: true,
17793
+ exportedInBatch: true
17794
+ });
17795
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17796
+ var RetrainTrackSchema = object({
17741
17797
  trackId: string$2(),
17742
- className: string$2()
17743
- }), object({
17744
17798
  deviceId: number(),
17745
- trackId: string$2(),
17746
17799
  className: string$2(),
17747
- durationMs: number()
17748
- }), object({
17800
+ label: string$2().optional(),
17801
+ firstSeen: number(),
17802
+ lastSeen: number(),
17803
+ /** How many frames the dataset already holds from this track. */
17804
+ frameCount: number().int(),
17805
+ /** How many subjects have been annotated on those frames. `0` with
17806
+ * `frameCount: 0` is exactly "staging, still to work". */
17807
+ annotationCount: number().int()
17808
+ });
17809
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
17810
+ var RetrainFrameCandidateSchema = object({
17811
+ mediaKey: string$2(),
17812
+ kind: MediaFileKindEnum,
17813
+ timestamp: number(),
17814
+ sizeBytes: number().int(),
17815
+ /** A copy of this original already exists — selecting it is free and cannot
17816
+ * fail, whatever became of the original. */
17817
+ copied: boolean()
17818
+ });
17819
+ /** A frame the dataset OWNS: bytes copied at selection time. */
17820
+ var RetrainFrameSchema = object({
17821
+ frameId: string$2(),
17749
17822
  deviceId: number(),
17750
- kind: EventKindSchema,
17751
- eventId: string$2(),
17752
- timestamp: number()
17823
+ trackId: string$2(),
17824
+ /** Provenance only. It may already point at nothing — that is expected. */
17825
+ sourceMediaKey: string$2(),
17826
+ sourceKind: MediaFileKindEnum,
17827
+ sizeBytes: number().int(),
17828
+ width: number().int(),
17829
+ height: number().int(),
17830
+ copiedAt: number()
17753
17831
  });
17754
- /**
17755
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
17756
- * within the frame, so the executor can re-cut a leaf child ROI at native
17757
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
17758
- */
17759
- var NativeCropRefSchema = object({
17760
- /** Handle keying the retained native surface (node-pinned to its owner). */
17761
- handle: FrameHandleSchema,
17762
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
17763
- cropFrameSpace: object({
17764
- x: number(),
17765
- y: number(),
17766
- w: number(),
17767
- h: number()
17768
- })
17832
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17833
+ var RetrainCopyRefusalSchema = _enum([
17834
+ "source-missing",
17835
+ "unreadable-image",
17836
+ "write-failed"
17837
+ ]);
17838
+ var RetrainFrameSelectionSchema = object({
17839
+ copied: array(RetrainFrameSchema).readonly(),
17840
+ refused: array(object({
17841
+ sourceMediaKey: string$2(),
17842
+ reason: RetrainCopyRefusalSchema
17843
+ })).readonly()
17769
17844
  });
17770
- object({
17771
- crop: object({
17772
- left: number(),
17773
- top: number(),
17774
- width: number().positive(),
17775
- height: number().positive()
17776
- }).optional(),
17777
- content: object({
17778
- width: number().int().positive(),
17779
- height: number().int().positive()
17780
- }),
17781
- fit: _enum(["stretch", "contain"]),
17782
- format: _enum([
17783
- "rgb",
17784
- "gray",
17785
- "jpeg"
17786
- ])
17845
+ var RetrainFrameListSchema = object({
17846
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
17847
+ copies: array(RetrainFrameSchema).readonly(),
17848
+ /** What the page pre-selects — the native key frame when one survives. */
17849
+ autoPickMediaKey: string$2().optional()
17787
17850
  });
17851
+ /** What the operator asked the assist to look for. */
17852
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17853
+ kind: literal("package"),
17854
+ zone: RetrainBboxSchema.optional()
17855
+ }), object({
17856
+ kind: literal("objects"),
17857
+ modelId: string$2(),
17858
+ minScore: number().optional()
17859
+ })]);
17788
17860
  /**
17789
- * Process-local frame identity. It is serializable so it can ride an in-process
17790
- * capability call, but `registryId` deliberately prevents resolution in any
17791
- * other process or execution group.
17861
+ * The assist's answer a discriminated union, because "the model saw nothing"
17862
+ * and "this node cannot run that model" lead to different next moves and a
17863
+ * nullable result cannot tell them apart.
17792
17864
  */
17793
- var FrameRefSchema = object({
17794
- registryId: string$2().min(1),
17795
- id: string$2().min(1),
17796
- width: number().int().positive(),
17797
- height: number().int().positive(),
17798
- format: _enum(["rgb", "gray"]),
17799
- timestamp: number(),
17800
- capturedAt: number().optional()
17865
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17866
+ kind: literal("proposed"),
17867
+ modelId: string$2(),
17868
+ stepId: string$2(),
17869
+ minScore: number(),
17870
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17871
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
17872
+ /** Returned by the runner but removed by the threshold. */
17873
+ belowThreshold: number().int()
17874
+ }), object({
17875
+ kind: literal("refused"),
17876
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17877
+ reason: string$2(),
17878
+ detail: string$2().optional()
17879
+ })]);
17880
+ /** The outcome of a lifecycle move owned by the retrain page. */
17881
+ var RetrainTransitionResultSchema = object({
17882
+ trackId: string$2(),
17883
+ /** Where the track ended up, whatever happened. */
17884
+ retrainStatus: RetrainStatusSchema,
17885
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17886
+ changed: boolean(),
17887
+ reason: _enum([
17888
+ "unknown-track",
17889
+ "no-frames-copied",
17890
+ "not-staging",
17891
+ "not-trained",
17892
+ "unchanged"
17893
+ ]).optional()
17801
17894
  });
17802
- var ModelFormatSchema$1 = _enum([
17803
- "onnx",
17804
- "coreml",
17805
- "openvino",
17806
- "tflite",
17807
- "pt",
17808
- "gguf"
17809
- ]);
17810
- var PipelineSlotSchema = _enum([
17811
- "detector",
17812
- "cropper",
17813
- "classifier",
17814
- "refiner",
17815
- "audio-classifier"
17816
- ]);
17817
- var PipelineEngineChoiceSchema = object({
17818
- runtime: _enum(["node", "python"]),
17819
- backend: string$2(),
17820
- format: ModelFormatSchema$1,
17821
- device: string$2().optional()
17895
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17896
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
17897
+ var DeviceEventQueryInput = object({
17898
+ deviceId: number(),
17899
+ since: number().optional(),
17900
+ until: number().optional(),
17901
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17902
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17903
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17904
+ * exact behaviour. Callers may omit this field — the store defaults to
17905
+ * `full` when not provided. */
17906
+ projection: _enum(["full", "slim"]).optional()
17822
17907
  });
17823
- var AvailableEngineSchema = object({
17824
- engine: PipelineEngineChoiceSchema,
17825
- devices: array(object({
17826
- id: string$2(),
17827
- label: string$2(),
17828
- description: string$2().optional()
17829
- })).readonly(),
17830
- defaultDevice: string$2()
17908
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string$2().optional() });
17909
+ var RecentTracksQueryInput = object({
17910
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17911
+ deviceIds: array(number()),
17912
+ /** Window lower bound on `lastSeen` (inclusive). */
17913
+ since: number().optional(),
17914
+ /** Window upper bound on `lastSeen` (inclusive). */
17915
+ until: number().optional(),
17916
+ /** Page size. Default 200, max 1000. */
17917
+ limit: number().int().min(1).max(1e3).default(200),
17918
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
17919
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17920
+ cursor: string$2().optional(),
17921
+ /** See {@link TrackProjectionSchema}. Default `full`. */
17922
+ projection: TrackProjectionSchema.optional(),
17923
+ /** Include stationary-promoted rows (parked objects). Default false: the
17924
+ * feed lists passages; parking records live on the stationary registry. */
17925
+ includeStationary: boolean().optional()
17831
17926
  });
17832
- var PipelineDefaultStepSchema = lazy(() => object({
17833
- addonId: string$2(),
17834
- addonName: string$2(),
17835
- slot: PipelineSlotSchema,
17836
- inputClasses: array(string$2()).readonly(),
17837
- outputClasses: array(string$2()).readonly(),
17838
- enabled: boolean(),
17839
- modelId: string$2(),
17840
- children: array(PipelineDefaultStepSchema).readonly(),
17841
- group: string$2().optional(),
17842
- settings: record(string$2(), unknown()).optional()
17843
- }));
17844
- var PipelineTemplateStepSchema = lazy(() => object({
17845
- addonId: string$2(),
17846
- enabled: boolean(),
17847
- modelId: string$2(),
17848
- children: array(PipelineTemplateStepSchema).readonly(),
17849
- settings: record(string$2(), unknown()).optional()
17850
- }));
17851
- var PipelineTemplateSchema$1 = object({
17852
- id: string$2(),
17853
- name: string$2(),
17854
- createdAt: string$2(),
17855
- updatedAt: string$2(),
17856
- engine: PipelineEngineChoiceSchema,
17857
- steps: array(PipelineTemplateStepSchema).readonly()
17927
+ var RecentTracksPageSchema = object({
17928
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17929
+ tracks: array(TrackSchema).readonly(),
17930
+ /** Cursor for the next page, or null when this page is the last. */
17931
+ nextCursor: string$2().nullable()
17858
17932
  });
17859
- var PipelineModelOptionSchema = object({
17933
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
17934
+ var LIST_GROUPS_MAX_LIMIT = 100;
17935
+ var AnalyticsGroupRecordSchema = object({
17860
17936
  id: string$2(),
17861
- name: string$2(),
17862
- formats: record(string$2(), object({
17863
- downloaded: boolean(),
17864
- sizeMB: number()
17865
- })),
17866
- group: ModelVariantGroupSchema.optional(),
17867
- legacy: boolean().optional(),
17868
- provider: ModelProviderIdSchema.optional()
17937
+ deviceId: number().int(),
17938
+ openedAt: number().int(),
17939
+ closedAt: number().int(),
17940
+ timestamp: number().int(),
17941
+ memberCount: number().int(),
17942
+ memberTrackIds: array(string$2()).readonly(),
17943
+ className: string$2(),
17944
+ classes: array(string$2()).readonly(),
17945
+ /** Relative event-media path, or null when the group has no picture yet. */
17946
+ mediaUrl: string$2().nullable(),
17947
+ singleton: boolean()
17869
17948
  });
17870
- var ConfigFieldBridge = custom();
17871
- var PipelineAddonSchemaSchema = object({
17872
- id: string$2(),
17873
- name: string$2(),
17874
- slot: PipelineSlotSchema,
17875
- inputClasses: array(string$2()).readonly(),
17876
- outputClasses: array(string$2()).readonly(),
17877
- childSlots: array(PipelineSlotSchema).readonly(),
17878
- models: array(PipelineModelOptionSchema).readonly(),
17879
- defaultModelId: string$2(),
17880
- defaultModelIdByFormat: record(string$2(), string$2()).optional(),
17881
- enabledByDefault: boolean().optional(),
17882
- backfillIntoExistingOverrides: boolean().optional(),
17883
- defaultConfidence: number(),
17884
- group: string$2().optional(),
17885
- configSchema: array(ConfigFieldBridge).readonly().optional()
17949
+ var AnalyticsGroupMemberSchema = object({
17950
+ trackId: string$2(),
17951
+ deviceId: number().int(),
17952
+ className: string$2(),
17953
+ firstSeen: number().int(),
17954
+ lastSeen: number().int(),
17955
+ mediaUrl: string$2().nullable()
17886
17956
  });
17887
- var PipelineSlotSchemaSchema = object({
17888
- id: PipelineSlotSchema,
17889
- label: string$2(),
17890
- priority: number(),
17891
- parentSlot: PipelineSlotSchema.nullable(),
17892
- addons: array(PipelineAddonSchemaSchema).readonly()
17957
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17958
+ var ListGroupsQueryInput = object({
17959
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17960
+ deviceIds: array(number()),
17961
+ /** Window lower bound on `closedAt` (inclusive). */
17962
+ since: number().optional(),
17963
+ /** Window upper bound on `openedAt` (inclusive). */
17964
+ until: number().optional(),
17965
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17966
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
17967
+ cursor: string$2().optional()
17893
17968
  });
17894
- var PipelineSchemaSchema = object({
17895
- availableEngines: array(AvailableEngineSchema).readonly(),
17896
- selectedEngine: PipelineEngineChoiceSchema,
17897
- slots: array(PipelineSlotSchemaSchema).readonly()
17969
+ var ListGroupsPageSchema = object({
17970
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
17971
+ nextCursor: string$2().nullable()
17898
17972
  });
17899
- var EngineProvisioningSchema = object({
17900
- runtimeId: _enum([
17901
- "onnx",
17902
- "openvino",
17903
- "coreml",
17904
- "edgetpu"
17905
- ]).nullable(),
17906
- device: string$2().nullable(),
17907
- state: _enum([
17908
- "idle",
17909
- "installing",
17910
- "verifying",
17911
- "ready",
17912
- "failed"
17913
- ]),
17914
- progress: number().optional(),
17915
- error: string$2().optional(),
17916
- nextRetryAt: number().optional(),
17917
- /**
17918
- * Gate A (config-correctness gate at engine change): human-readable
17919
- * config issues surfaced EAGERLY when the node's engine changes — model
17920
- * substitutions ("chose X, running Y") and zero-build steps ("no model
17921
- * has a <format> build"). Additive/optional: informational only, never
17922
- * enforced here — `assertEngineReady` (readiness) still gates inference.
17923
- * Absent/empty when the node-default tree resolves cleanly.
17924
- */
17925
- configIssues: array(string$2()).optional()
17973
+ var KeyEventQueryInput = object({
17974
+ deviceId: number(),
17975
+ /** Window lower bound (track firstSeen ≥ since). */
17976
+ since: number(),
17977
+ /** Window upper bound (track firstSeen ≤ until). */
17978
+ until: number(),
17979
+ limit: number().int().min(1).max(200).default(50),
17980
+ /** Drop tracks scoring below this importance. */
17981
+ minImportance: number().min(0).max(1).optional(),
17982
+ /** Restrict to a single class (e.g. 'person'). */
17983
+ classFilter: string$2().optional()
17926
17984
  });
17927
- var PipelineStepInputSchema = lazy(() => object({
17928
- addonId: string$2(),
17929
- modelId: string$2().optional(),
17930
- enabled: boolean().default(true),
17931
- children: array(PipelineStepInputSchema).optional(),
17932
- settings: record(string$2(), unknown()).optional(),
17933
- jumpDeviceKey: string$2().optional()
17934
- }));
17935
- var ModelSubstitutionSchema = object({
17936
- addonId: string$2(),
17937
- chosen: string$2(),
17938
- running: string$2(),
17939
- format: string$2()
17985
+ var KeyEventSchema = object({
17986
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
17987
+ id: string$2(),
17988
+ trackId: string$2(),
17989
+ /** Track start time (firstSeen). */
17990
+ timestamp: number(),
17991
+ className: string$2(),
17992
+ ...TieredLabelFields,
17993
+ importance: number(),
17994
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
17995
+ bestEventId: string$2(),
17996
+ /** Track lifetime in ms (lastSeen - firstSeen). */
17997
+ windowMs: number().optional(),
17998
+ ...TrackFlagFields,
17999
+ ...TrackRetrainFields
17940
18000
  });
17941
- var PipelineValidationIssueSchema = object({
17942
- addonId: string$2(),
17943
- kind: _enum(["unknown-addon", "no-format-build"]),
17944
- detail: string$2()
18001
+ object({
18002
+ trackId: string$2(),
18003
+ className: string$2(),
18004
+ confidence: number(),
18005
+ bbox: BoundingBoxSchema,
18006
+ zones: array(string$2()).readonly(),
18007
+ state: TrackStateSchema
17945
18008
  });
17946
- var PipelineValidationResultSchema = object({
17947
- ok: boolean(),
17948
- issues: array(PipelineValidationIssueSchema).readonly(),
17949
- substitutions: array(ModelSubstitutionSchema).readonly(),
17950
- /** The node's `currentEngine.format` this validation ran against. */
17951
- format: string$2()
18009
+ var OverlayDetectionSchema = looseObject({
18010
+ id: string$2(),
18011
+ kind: _enum(["first-level", "detail"]),
18012
+ macroClass: string$2(),
18013
+ score: number(),
18014
+ bbox: object({
18015
+ x: number(),
18016
+ y: number(),
18017
+ width: number(),
18018
+ height: number()
18019
+ }),
18020
+ labels: array(looseObject({
18021
+ label: string$2(),
18022
+ score: number()
18023
+ })).readonly(),
18024
+ parentId: string$2().optional()
17952
18025
  });
17953
- var ReferenceImageEntrySchema = object({
17954
- filename: string$2(),
17955
- stepIds: array(string$2()).readonly().optional()
18026
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
18027
+ var SearchObjectEventsInput = object({
18028
+ text: string$2(),
18029
+ deviceId: number().optional(),
18030
+ since: number().optional(),
18031
+ until: number().optional(),
18032
+ classFilter: string$2().optional(),
18033
+ limit: number().default(50),
18034
+ minScore: number().min(0).max(1).default(.2)
17956
18035
  });
17957
- var ReferenceImageBodySchema = object({
17958
- base64: string$2(),
17959
- filename: string$2()
18036
+ var TrackCascadeCountsSchema = object({
18037
+ /** Persisted track roots deleted (authoritative). */
18038
+ tracks: number().int(),
18039
+ /** Object events removed with their tracks (best-effort; see note above). */
18040
+ events: number().int(),
18041
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18042
+ media: number().int(),
18043
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
18044
+ faces: number().int(),
18045
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18046
+ plates: number().int(),
18047
+ /** Per-track CLIP search vectors removed (best-effort). */
18048
+ embeddings: number().int(),
18049
+ /** Group membership + group rows removed with their last member (best-effort). */
18050
+ groups: number().int()
17960
18051
  });
17961
- var ReferenceAudioEntrySchema = object({
17962
- filename: string$2(),
17963
- sizeKb: number()
18052
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18053
+ var DiskReconcileCountsSchema = object({
18054
+ mediaDropped: number().int(),
18055
+ tracks: number().int(),
18056
+ events: number().int()
18057
+ });
18058
+ /** Event-store footprint for one camera. */
18059
+ var EventStoreDeviceFootprintSchema = object({
18060
+ deviceId: number(),
18061
+ /** Persisted event rows (motion + object + audio) for the camera. */
18062
+ rows: number().int(),
18063
+ /** Event-owned media bytes on disk for the camera. */
18064
+ bytes: number().int()
18065
+ });
18066
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18067
+ var EventStoreFootprintSchema = object({
18068
+ totalRows: number().int(),
18069
+ totalBytes: number().int(),
18070
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
18071
+ });
18072
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
18073
+ var EventPruneCountsSchema = object({
18074
+ motion: number().int(),
18075
+ object: number().int(),
18076
+ audio: number().int()
17964
18077
  });
17965
- var ReferenceAudioBodySchema = object({ base64: string$2() });
17966
- var AudioBackendSchema = object({
17967
- id: string$2(),
17968
- name: string$2(),
17969
- description: string$2(),
17970
- available: boolean(),
18078
+ /**
18079
+ * Re-embed stored tracks from their key frames.
18080
+ *
18081
+ * The reason this is an operator-callable method and not a migration script:
18082
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
18083
+ * squaring — is only changeable if the existing vectors can be regenerated.
18084
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
18085
+ * symptom is a quality regression with no visible cause.
18086
+ */
18087
+ var RebuildObjectEmbeddingsInput = object({
18088
+ /** Restrict to one camera. Omit for the whole fleet. */
18089
+ deviceId: number().optional(),
18090
+ since: number().optional(),
18091
+ until: number().optional(),
18092
+ /** Stop after this many tracks; the result reports whether more remain. */
18093
+ maxTracks: number().int().positive().optional(),
17971
18094
  /**
17972
- * Raw classifier labels this backend can emit (e.g. YAMNet's
17973
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
17974
- * the benchmark UI to populate the `enabledMicroClasses` filter
17975
- * specific to the selected backend without a separate fetch.
18095
+ * Run every embedding on THIS node instead of round-robining the fleet.
18096
+ *
18097
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18098
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18099
+ * calling it that would pin the rebuild REQUEST itself to that node — the
18100
+ * rebuild orchestration lives on the hub, and only the per-track step runs
18101
+ * remotely. This field is data; the per-track pin is applied inside.
18102
+ *
18103
+ * Absent ⇒ round-robin over every online node whose runner can serve the
18104
+ * pinned model.
17976
18105
  */
17977
- rawLabels: array(string$2()).readonly().optional()
17978
- });
17979
- var AudioCapabilitiesSchema = object({
17980
- activeBackend: string$2(),
17981
- availableBackends: array(AudioBackendSchema).readonly(),
17982
- sampleRate: number(),
17983
- chunkDurationMs: number()
17984
- });
17985
- var DownloadModelResultSchema = object({
17986
- filePath: string$2(),
17987
- sizeMB: number(),
17988
- durationMs: number()
18106
+ executeOnNodeId: string$2().optional(),
18107
+ /**
18108
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18109
+ * run flat out.
18110
+ *
18111
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
18112
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18113
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18114
+ * force is logged at start and finish so a deliberately slow pass reads
18115
+ * differently from a stalled one.
18116
+ */
18117
+ pacingMs: number().int().nonnegative().optional()
17989
18118
  });
17990
18119
  /**
17991
- * Wrapper carrying a single test run's result. Replaces the legacy
17992
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
17993
- * canonical `AudioResult` from the Phase 6 output rework: one
17994
- * `AudioDetection` per class above `minScore`, top-N candidates in
17995
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
17996
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
17997
- * benchmark UI can still report a clean failure when the classifier
17998
- * cap isn't available.
18120
+ * Result of emptying the CLIP index.
18121
+ *
18122
+ * The clean slate before a policy change: a new crop margin or encoder model
18123
+ * leaves two feature spaces in one index whose cosine scores are not
18124
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
18125
+ * means the same thing.
17999
18126
  */
18000
- var AudioTestResultSchema = object({
18001
- success: boolean(),
18002
- error: string$2().optional(),
18003
- frame: custom().optional()
18127
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18128
+ /**
18129
+ * Acknowledgement that a rebuild STARTED.
18130
+ *
18131
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
18132
+ * runs detached and this returns immediately. Waiting for it made the client
18133
+ * time out while the work carried on server-side, which is the worst of both:
18134
+ * no result and no way to know it was still going. Poll
18135
+ * `getObjectEmbeddingRebuildStatus` for progress.
18136
+ */
18137
+ var RebuildObjectEmbeddingsResultSchema = object({
18138
+ started: boolean(),
18139
+ /** True when a pass was already running; the new request is ignored. */
18140
+ alreadyRunning: boolean()
18004
18141
  });
18005
- var PipelineConfigBridge = custom();
18006
- var ConfigUISchemaBridge = custom();
18007
- var ConfigUISchemaNullableBridge = custom();
18008
- var InferenceCapabilitiesBridge = custom();
18009
- var ModelAvailabilityListBridge = custom();
18010
- var PipelineRunResultBridge = custom();
18011
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string$2() }), EngineProvisioningSchema), method(_void(), record(string$2(), object({
18012
- modelId: string$2(),
18013
- settings: record(string$2(), unknown()).readonly()
18014
- }))), method(object({ steps: record(string$2(), object({
18015
- modelId: string$2(),
18016
- settings: record(string$2(), unknown()).readonly()
18017
- })) }), object({ success: literal(true) }), {
18142
+ var RebuildStatusSchema = object({
18143
+ running: boolean(),
18144
+ scanned: number(),
18145
+ rebuilt: number(),
18146
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
18147
+ missingKeyFrame: number(),
18148
+ /** Tracks with no usable detection box. */
18149
+ missingBbox: number(),
18150
+ /**
18151
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
18152
+ * frame, a step that threw. Separate from `failed` because the remedy is
18153
+ * different, and because a whole camera silently contributing zero vectors
18154
+ * is the shape of failure a rebuild must never hide.
18155
+ */
18156
+ notRunnable: number(),
18157
+ /**
18158
+ * The pass stopped because NO node could serve the pinned model.
18159
+ *
18160
+ * Distinct from `notRunnable` on purpose: that one says "this track was
18161
+ * refused", this one says "the cluster cannot do this work at all" — every
18162
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
18163
+ * pinned model for its engine format, or dropped out. The remedy is a model /
18164
+ * engine change, not a per-camera one. Non-zero here always comes with
18165
+ * `complete: false`.
18166
+ */
18167
+ noCapableNode: number(),
18168
+ failed: number(),
18169
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
18170
+ complete: boolean().nullable(),
18171
+ startedAtMs: number().nullable(),
18172
+ finishedAtMs: number().nullable(),
18173
+ /** Present when the pass ended by throwing. */
18174
+ error: string$2().nullable()
18175
+ });
18176
+ var ReplayFrameInputSchema = object({
18177
+ timestamp: number(),
18178
+ frame: PipelineRunResultBridge
18179
+ });
18180
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
18181
+ className: string$2(),
18182
+ firstSeenMs: number(),
18183
+ lastSeenMs: number(),
18184
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
18185
+ * frame — a representative box for the diff's `(className, window, IoU)`
18186
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
18187
+ * trajectory production's `Track.positions` keeps. */
18188
+ bbox: BoundingBoxSchema,
18189
+ /** How many of the input frames this track matched a real detection on
18190
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
18191
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
18192
+ framesMatched: number().int()
18193
+ })).readonly() });
18194
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18195
+ deviceId: number(),
18196
+ trackId: string$2()
18197
+ }), TrackSchema.nullable()), method(object({
18198
+ deviceId: number(),
18199
+ since: number().optional(),
18200
+ until: number().optional(),
18201
+ limit: number().optional(),
18202
+ /** Spatial filter — only tracks whose trajectory intersects the zone
18203
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18204
+ * envelope columns, then precisely tested per position. Tracks with
18205
+ * an unknown envelope (no frame dims at persist time) always match. */
18206
+ zone: TrackZoneFilterSchema.optional(),
18207
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
18208
+ * compatible — omitting the field keeps today's exact behaviour). */
18209
+ projection: TrackProjectionSchema.optional(),
18210
+ /** Include stationary-promoted rows (parked objects handed to the
18211
+ * stationary registry). Default false: the timeline lists passages,
18212
+ * not parking records (operator decision, 2026-08-15). */
18213
+ includeStationary: boolean().optional()
18214
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18215
+ deviceId: number(),
18216
+ groupId: string$2().min(1)
18217
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18218
+ kind: "mutation",
18219
+ auth: "admin"
18220
+ }), 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({
18221
+ deviceId: number(),
18222
+ since: number().optional(),
18223
+ until: number().optional(),
18224
+ kinds: array(string$2()).optional(),
18225
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18226
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18227
+ deviceId: number(),
18228
+ since: number(),
18229
+ until: number(),
18230
+ bucketMs: number().int().positive()
18231
+ }), array(object({
18232
+ bucketStart: number(),
18233
+ motion: number().int(),
18234
+ object: number().int(),
18235
+ audio: number().int()
18236
+ })).readonly()), method(object({
18237
+ deviceId: number(),
18238
+ cutoffMs: number()
18239
+ }), object({
18240
+ motion: number().int(),
18241
+ object: number().int(),
18242
+ audio: number().int()
18243
+ }), {
18244
+ kind: "mutation",
18245
+ auth: "admin"
18246
+ }), method(object({
18247
+ deviceId: number(),
18248
+ cutoffMs: number()
18249
+ }), TrackCascadeCountsSchema, {
18250
+ kind: "mutation",
18251
+ auth: "admin"
18252
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18253
+ kind: "mutation",
18254
+ auth: "admin"
18255
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18256
+ kind: "mutation",
18257
+ auth: "admin"
18258
+ }), method(object({
18259
+ deviceId: number(),
18260
+ trackIds: array(string$2()).min(1)
18261
+ }), object({
18262
+ deleted: number().int(),
18263
+ failed: array(string$2()).readonly()
18264
+ }), {
18265
+ kind: "mutation",
18266
+ auth: "admin"
18267
+ }), method(object({
18268
+ /** Log/audit scope only — the trackId is globally unique on its own. */
18269
+ deviceId: number(),
18270
+ trackId: string$2(),
18271
+ flags: TrackFlagsPatchSchema
18272
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18273
+ kind: "query",
18274
+ auth: "admin"
18275
+ }), method(object({
18276
+ olderThanMs: number(),
18277
+ reason: OpsLogReasonSchema.optional()
18278
+ }), EventPruneCountsSchema, {
18279
+ kind: "mutation",
18280
+ auth: "admin"
18281
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
18282
+ kind: "mutation",
18283
+ auth: "admin"
18284
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18285
+ kind: "mutation",
18286
+ auth: "admin"
18287
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18288
+ kind: "mutation",
18289
+ auth: "admin"
18290
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18291
+ kind: "mutation",
18292
+ auth: "admin"
18293
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string$2() }), {
18294
+ kind: "mutation",
18295
+ auth: "admin"
18296
+ }), method(object({ jobId: string$2() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string$2() }), object({ cancelled: boolean() }), {
18297
+ kind: "mutation",
18298
+ auth: "admin"
18299
+ }), method(RelocateMediaInputSchema, object({ jobId: string$2() }), {
18300
+ kind: "mutation",
18301
+ auth: "admin"
18302
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
18303
+ kind: "query",
18304
+ auth: "admin"
18305
+ }), method(object({ jobId: string$2() }), object({ cancelled: boolean() }), {
18018
18306
  kind: "mutation",
18019
18307
  auth: "admin"
18020
- }), method(object({ nodeId: string$2() }), object({
18021
- success: literal(true),
18022
- clearedDevices: number()
18023
- }), {
18308
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18309
+ kind: "query",
18310
+ auth: "admin"
18311
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
18312
+ kind: "query",
18313
+ auth: "admin"
18314
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string$2() }), {
18315
+ kind: "query",
18316
+ auth: "admin"
18317
+ }), method(object({
18318
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18319
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
18320
+ * route it at one camera's owner, and "every camera" would stop being
18321
+ * expressible at all. */
18322
+ deviceIds: array(number()).optional(),
18323
+ limit: number().int().min(1).max(500).optional()
18324
+ }), array(RetrainTrackSchema).readonly(), {
18325
+ kind: "query",
18326
+ auth: "admin"
18327
+ }), method(object({ trackId: string$2() }), RetrainFrameListSchema, {
18328
+ kind: "query",
18329
+ auth: "admin"
18330
+ }), method(object({
18331
+ deviceId: number(),
18332
+ trackId: string$2(),
18333
+ mediaKeys: array(string$2()).min(1)
18334
+ }), RetrainFrameSelectionSchema, {
18024
18335
  kind: "mutation",
18025
18336
  auth: "admin"
18026
- }), 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({
18027
- name: string$2(),
18028
- steps: array(PipelineTemplateStepSchema).readonly(),
18029
- engine: PipelineEngineChoiceSchema
18030
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
18031
- id: string$2(),
18032
- name: string$2().optional(),
18033
- steps: array(PipelineTemplateStepSchema).readonly().optional()
18034
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string$2() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string$2() }), ModelAvailabilityListBridge), method(object({
18035
- addonId: string$2(),
18036
- modelId: string$2(),
18037
- format: ModelFormatSchema$1
18038
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
18039
- addonId: string$2(),
18040
- modelId: string$2(),
18041
- format: ModelFormatSchema$1
18042
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
18043
- engine: PipelineEngineChoiceSchema.optional(),
18044
- steps: array(PipelineStepInputSchema).min(1),
18045
- frame: FrameInputSchema.optional(),
18046
- /**
18047
- * Process-local lazy frame. Valid only when caller and provider resolve
18048
- * in the same execution-group process; split/cross-node callers use
18049
- * `frame`/`image` inline compatibility instead.
18050
- */
18051
- frameRef: FrameRefSchema.optional(),
18052
- /**
18053
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
18054
- * the decoded pixels live in. One more member of the one-of
18055
- * frame/frameHandle/image/imageBase64/referenceImage group.
18056
- */
18057
- frameHandle: FrameHandleSchema.optional(),
18058
- imageBase64: string$2().optional(),
18059
- /**
18060
- * Binary JPEG bytes — preferred over `imageBase64` on internal
18061
- * hops (hub → forked worker via Moleculer MsgPack) because it
18062
- * skips the 33% base64 overhead + the per-call base64 decode on
18063
- * the detection-pipeline worker. Callers can pass either; exactly
18064
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
18065
- */
18066
- image: _instanceof(Uint8Array).optional(),
18067
- referenceImage: string$2().optional(),
18068
- deviceId: number().optional(),
18069
- sessionId: string$2().optional(),
18070
- /**
18071
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
18072
- * reference-image, and detail-subtree calls. 'frame' is the live
18073
- * per-frame dispatch: ONLY root-plane steps run; crop children
18074
- * (inputClasses ≠ null) are skipped and served per-track via
18075
- * pipelineRunner.runDetailSubtree (two-plane design).
18076
- */
18077
- plane: _enum(["full", "frame"]).optional(),
18078
- /**
18079
- * Inference-device selector (Phase 2 multi-device). Format
18080
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
18081
- * Omitted ⇒ the runner's default device (current single-engine
18082
- * behaviour). Selects WHICH device pool of the node runs the call.
18083
- */
18084
- deviceKey: string$2().optional(),
18085
- /**
18086
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
18087
- * when the parent crop was resolved from the frame's retained NATIVE
18088
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
18089
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
18090
- * resolution from that surface — the SAME quality path faces already
18091
- * had — instead of the downscaled parent tile. `handle` keys the native
18092
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
18093
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
18094
- * the executor's crop-normalized child ROI back into frame-normalized
18095
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
18096
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
18097
- * (today's behaviour on the fallback path).
18098
- */
18099
- nativeCropRef: NativeCropRefSchema.optional()
18100
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
18101
- engine: PipelineEngineChoiceSchema.optional(),
18102
- steps: array(PipelineStepInputSchema).min(1),
18103
- frames: array(FrameInputSchema).min(1).max(255),
18104
- deviceId: number().optional(),
18105
- sessionId: string$2().optional(),
18106
- /**
18107
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
18108
- * the batch to the Python pool's bench preprocess cache
18109
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
18110
- * preprocessed ONCE and every later inference is a pure-inference cache
18111
- * hit — the sustained-throughput run measures inference, not
18112
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
18113
- * full preprocess every call, correct). Fresh per sustained run;
18114
- * released via `uncacheFrame`.
18115
- */
18116
- frameId: number().int().nonnegative().optional(),
18117
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
18118
- deviceKey: string$2().optional()
18119
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
18120
- data: _instanceof(Uint8Array),
18121
- width: number().int().positive(),
18122
- height: number().int().positive(),
18123
- format: _enum([
18124
- "rgb",
18125
- "bgr",
18126
- "gray"
18127
- ])
18337
+ }), method(object({
18338
+ deviceId: number(),
18339
+ trackId: string$2(),
18340
+ frameId: string$2()
18128
18341
  }), object({
18129
- frameId: number(),
18130
- width: number(),
18131
- height: number()
18132
- }), { kind: "mutation" }), method(object({
18133
- stepId: string$2(),
18134
- frameId: number().int()
18135
- }), record(string$2(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
18136
- batchMode: string$2(),
18137
- windowMs: number(),
18138
- maxBatchSize: number(),
18139
- concurrency: number()
18140
- })), method(_void(), array(object({
18141
- engineKey: string$2(),
18142
- engine: PipelineEngineChoiceSchema,
18143
- modelsLoaded: array(string$2()).readonly(),
18144
- inUseByCameras: array(number()).readonly(),
18145
- /**
18146
- * Origin of this resident factory.
18147
- * - `runtime` — main camera-serving engine (no idle TTL).
18148
- * - `warm-override` — benchmark/test override held in the warm
18149
- * cache; auto-disposed after the idle TTL.
18150
- * - `device-pool` — a concurrent per-device pool (Phase 2
18151
- * multi-device, keyed by `deviceKey`) resolved
18152
- * via `resolveDeviceFactory`. Runs alongside the
18153
- * `runtime` engine on a DIFFERENT accelerator
18154
- * (NPU / iGPU / Coral) — this is how the
18155
- * Engines tab shows all pools running at once.
18156
- */
18157
- kind: _enum([
18158
- "runtime",
18159
- "warm-override",
18160
- "device-pool"
18161
- ]),
18162
- /** Native pid of the underlying Python pool (null when no pool). */
18163
- poolPid: number().nullable(),
18164
- /** ms since this factory was last used (null when not warm-tracked). */
18165
- idleMs: number().nullable(),
18166
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
18167
- idleTtlMs: number().nullable()
18168
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
18342
+ removed: boolean(),
18343
+ removedAnnotations: number().int()
18344
+ }), {
18169
18345
  kind: "mutation",
18170
18346
  auth: "admin"
18347
+ }), method(object({ frameId: string$2() }), object({
18348
+ base64: string$2(),
18349
+ width: number().int(),
18350
+ height: number().int()
18351
+ }), {
18352
+ kind: "query",
18353
+ auth: "admin"
18171
18354
  }), method(object({
18172
- engine: PipelineEngineChoiceSchema,
18173
- force: boolean().optional()
18355
+ deviceId: number(),
18356
+ trackId: string$2(),
18357
+ frameId: string$2(),
18358
+ subject: RetrainAssistSubjectSchema,
18359
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18360
+ nodeId: string$2().optional()
18361
+ }), RetrainAssistResultSchema, {
18362
+ kind: "mutation",
18363
+ auth: "admin"
18364
+ }), method(object({
18365
+ deviceId: number(),
18366
+ source: DetectionSourceSchema,
18367
+ zones: array(ZoneSchema).readonly().optional(),
18368
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
18369
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
18370
+ frames: array(ReplayFrameInputSchema).min(1)
18371
+ }), RunReplayFrameProcessorResultSchema, {
18372
+ kind: "mutation",
18373
+ auth: "admin"
18374
+ }), method(object({ trackId: string$2() }), array(RetrainAnnotationSchema).readonly(), {
18375
+ kind: "query",
18376
+ auth: "admin"
18377
+ }), method(object({
18378
+ deviceId: number(),
18379
+ trackId: string$2(),
18380
+ frameId: string$2(),
18381
+ annotations: array(RetrainAnnotationDraftSchema)
18382
+ }), array(RetrainAnnotationSchema).readonly(), {
18383
+ kind: "mutation",
18384
+ auth: "admin"
18385
+ }), method(object({
18386
+ deviceId: number(),
18387
+ trackId: string$2()
18388
+ }), RetrainTransitionResultSchema, {
18389
+ kind: "mutation",
18390
+ auth: "admin"
18391
+ }), method(object({
18392
+ deviceId: number(),
18393
+ trackId: string$2()
18394
+ }), RetrainTransitionResultSchema, {
18395
+ kind: "mutation",
18396
+ auth: "admin"
18397
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string$2() }), {
18398
+ kind: "query",
18399
+ auth: "admin"
18400
+ }), method(object({
18401
+ eventId: string$2(),
18402
+ kind: MediaFileKindEnum.optional(),
18403
+ deviceId: number()
18404
+ }), array(MediaFileSchema).readonly()), method(object({
18405
+ trackId: string$2(),
18406
+ kinds: array(MediaFileKindEnum).optional(),
18407
+ deviceId: number()
18408
+ }), array(MediaFileSchema).readonly()), method(object({
18409
+ trackId: string$2(),
18410
+ deviceId: number()
18411
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18412
+ kind: "mutation",
18413
+ auth: "admin"
18414
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18415
+ kind: "mutation",
18416
+ auth: "admin"
18417
+ }), method(object({}), RebuildStatusSchema), object({
18418
+ deviceId: number(),
18419
+ timestamp: number(),
18420
+ frameWidth: number(),
18421
+ frameHeight: number(),
18422
+ detections: array(OverlayDetectionSchema).readonly()
18423
+ }), object({
18424
+ deviceId: number(),
18425
+ trackId: string$2(),
18426
+ className: string$2()
18174
18427
  }), object({
18175
- success: boolean(),
18176
- reason: string$2().optional()
18177
- }), {
18178
- kind: "mutation",
18179
- auth: "admin"
18180
- }), method(_void(), array(ReferenceImageEntrySchema).readonly()), method(object({ filename: string$2() }), ReferenceImageBodySchema.nullable()), method(_void(), array(ReferenceAudioEntrySchema).readonly()), method(object({ filename: string$2() }), ReferenceAudioBodySchema.nullable()), method(_void(), AudioCapabilitiesSchema), method(object({
18181
- addonId: string$2(),
18182
- modelId: string$2(),
18183
- filename: string$2().optional(),
18184
- settings: record(string$2(), unknown()).optional()
18185
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
18428
+ deviceId: number(),
18429
+ trackId: string$2(),
18430
+ className: string$2(),
18431
+ durationMs: number()
18432
+ }), object({
18433
+ deviceId: number(),
18434
+ kind: EventKindSchema,
18435
+ eventId: string$2(),
18436
+ timestamp: number()
18437
+ });
18186
18438
  object({
18187
18439
  activeCameras: number(),
18188
18440
  throttledCameras: number(),
@@ -18208,106 +18460,6 @@ var CameraMetricsSchema = object({
18208
18460
  });
18209
18461
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18210
18462
  /**
18211
- * Zone — pure geometry + identity. NO filtering behaviour.
18212
- *
18213
- * Zones describe **where** in the frame the operator wants to flag
18214
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
18215
- * each pipeline stage uses them. Splitting the two means a single
18216
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
18217
- * a detection-include rule on `['car']`, and an occupancy aggregate
18218
- * — without three duplicated polygons.
18219
- *
18220
- * Owned by the orchestrator addon (provider) and mirrored into the
18221
- * `zones` device-state slice on every mutation. Consumers
18222
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18223
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18224
- * mirror with `onChanged`).
18225
- *
18226
- * Coordinates are normalised fractions of the frame (0–1) so zones
18227
- * survive resolution changes and stream profile switches.
18228
- *
18229
- * `kind` discriminates between full polygons (closed regions used
18230
- * for intrusion / occupancy filters) and tripwires (open 2-point
18231
- * line segments used for cross events). Onboard / firmware-reported
18232
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18233
- * task list.
18234
- */
18235
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18236
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18237
- var PolygonPointSchema = object({
18238
- x: number(),
18239
- y: number()
18240
- });
18241
- /** A camera detection zone — pure geometry/identity. */
18242
- var ZoneSchema = object({
18243
- id: string$2(),
18244
- name: string$2(),
18245
- kind: ZoneKindEnum.default("polygon"),
18246
- /** Polygon vertices, fraction of frame (0–1). */
18247
- polygon: array(PolygonPointSchema).readonly(),
18248
- /** Visual color for UI rendering. */
18249
- color: string$2().default("#3b82f6")
18250
- });
18251
- /**
18252
- * Zones capability — per-camera CRUD over polygon detection zones.
18253
- *
18254
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
18255
- * to per-device settings and mirrors into the `zones` device-state
18256
- * slice on every mutation, so downstream consumers can subscribe via
18257
- * `dev.state.zones.onChanged`.
18258
- *
18259
- * The cap surface only handles geometry + identity; filtering
18260
- * behaviour (per-class, include/exclude, threshold) lives in the
18261
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
18262
- * `capabilities/schemas/zone-rule.js`.
18263
- */
18264
- var zonesCapability = {
18265
- name: "zones",
18266
- scope: "device",
18267
- mode: "singleton",
18268
- deviceTypes: [DeviceType.Camera],
18269
- methods: {
18270
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
18271
- addZone: method(object({
18272
- deviceId: number(),
18273
- zone: ZoneSchema
18274
- }), _void(), {
18275
- kind: "mutation",
18276
- auth: "admin"
18277
- }),
18278
- removeZone: method(object({
18279
- deviceId: number(),
18280
- zoneId: string$2()
18281
- }), _void(), {
18282
- kind: "mutation",
18283
- auth: "admin"
18284
- }),
18285
- updateZone: method(object({
18286
- deviceId: number(),
18287
- zone: ZoneSchema
18288
- }), _void(), {
18289
- kind: "mutation",
18290
- auth: "admin"
18291
- })
18292
- },
18293
- /**
18294
- * Runtime-state slice — the live zone catalogue mirrored by the
18295
- * orchestrator on every CRUD mutation. Consumers read via
18296
- * `device.state.zones.value` / `.watch(...)` without round-tripping
18297
- * the cap, and the codegen DeviceProxy auto-wires the reactive
18298
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
18299
- * (e.g. zone groupings) can sit alongside the polygon list.
18300
- */
18301
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
18302
- /**
18303
- * 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.
18304
- *
18305
- * See `RuntimeStateDurability`. Enforced by
18306
- * `scripts/check-runtime-state-durability.ts`.
18307
- */
18308
- durability: "restored"
18309
- };
18310
- /**
18311
18463
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
18312
18464
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
18313
18465
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -26990,6 +27142,39 @@ var ReadGopBytesResultSchema = object({
26990
27142
  /** Media ms the returned fragment covers. */
26991
27143
  gopDurMs: number()
26992
27144
  });
27145
+ /**
27146
+ * A time WINDOW of one finalized segment, cut by byte range — the multi-GOP
27147
+ * twin of {@link ReadGopBytesResultSchema}'s single instant. Built for the
27148
+ * replay clip's `recording` source (`docs/design/plans/2026-08-26-replay-clip-su-pipeline.md`):
27149
+ * a replay needs several seconds of native pixels, not one frame.
27150
+ *
27151
+ * `ok.data` is standalone-demuxable, same as a GOP read. `ok.reachesRequestedEnd`
27152
+ * is `false` when the returned bytes were cut short by the read's own safety
27153
+ * byte cap before covering `[fromMs, toMs)` — a truncation, reported, not a
27154
+ * silently shorter answer. `spans-multiple-segments` is a REFUSAL, not a
27155
+ * degradation: a window whose end falls past the covering segment would need
27156
+ * bytes stitched from a second segment file (its own `ftyp`+`moov`), which is
27157
+ * not one standalone-demuxable stream — the caller's answer is to request a
27158
+ * shorter window or one aligned to a single segment, not to receive spliced
27159
+ * bytes nothing has proven decodable.
27160
+ */
27161
+ var ReadWindowBytesResultSchema = discriminatedUnion("kind", [object({
27162
+ kind: literal("ok"),
27163
+ data: _instanceof(Uint8Array),
27164
+ /** Absolute epoch ms of the returned bytes' first sample — at or before
27165
+ * the requested `fromMs` (anchored on the nearest keyframe). */
27166
+ gopStartMs: number(),
27167
+ /** Media ms the returned bytes cover, from `gopStartMs`. */
27168
+ gopDurMs: number(),
27169
+ /** `false` ⇒ the safety byte cap cut the read short before it reached
27170
+ * the requested `toMs`; the caller got fewer frames than asked for. */
27171
+ reachesRequestedEnd: boolean()
27172
+ }), object({
27173
+ kind: literal("spans-multiple-segments"),
27174
+ /** Where the covering segment's own footage runs out — informational,
27175
+ * not a retry hint (retrying the same window would refuse again). */
27176
+ segmentEndMs: number()
27177
+ })]);
26993
27178
  method(object({
26994
27179
  deviceId: number(),
26995
27180
  fromMs: number(),
@@ -27040,6 +27225,15 @@ method(object({
27040
27225
  }), ReadGopBytesResultSchema, {
27041
27226
  kind: "query",
27042
27227
  auth: "admin"
27228
+ }), method(object({
27229
+ deviceId: number(),
27230
+ profile: string$2(),
27231
+ startMs: number(),
27232
+ fromMs: number(),
27233
+ toMs: number()
27234
+ }), ReadWindowBytesResultSchema, {
27235
+ kind: "query",
27236
+ auth: "admin"
27043
27237
  }), method(object({
27044
27238
  deviceId: number(),
27045
27239
  config: RecordingConfigSchema
@@ -27635,92 +27829,6 @@ var sceneMonitorCapability = {
27635
27829
  durability: "session"
27636
27830
  };
27637
27831
  /**
27638
- * Per-stage gating mode applied to the zones a rule references.
27639
- *
27640
- * - `include`: the rule contributes to a **whitelist** for its stage.
27641
- * When at least one `include` rule fires for a stage, only entities
27642
- * inside one of those zones pass that stage.
27643
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
27644
- * Entities inside one of those zones are dropped at that stage.
27645
- *
27646
- * `monitor`-style observation (count without filtering) is not a rule
27647
- * mode — zones without any matching rule are observed naturally by
27648
- * `zone-analytics` (live snapshot + history), so an "I just want to
27649
- * count, not filter" use case needs no rule at all.
27650
- */
27651
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
27652
- /**
27653
- * Per-consumer rule that references existing zones (geometry) and
27654
- * defines how a specific pipeline stage should treat them. Each
27655
- * consumer addon owns its own `ZoneRule[]` array in its per-device
27656
- * settings:
27657
- *
27658
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
27659
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
27660
- * - future: notification rules, audio gating, etc.
27661
- *
27662
- * One rule applies to N zones (`zoneIds[]`) so the operator can
27663
- * express "ignore motion in ALL of {garden, street}" with a single
27664
- * rule. `classFilter` narrows the rule to specific object classes —
27665
- * "drop person detections in the street, but keep cars" is one
27666
- * `exclude` rule with `classFilter: ['person']`.
27667
- *
27668
- * `enabled` is a soft toggle — the operator can keep the rule
27669
- * configured but inert without deleting it.
27670
- */
27671
- var ZoneRuleSchema = object({
27672
- /** Stable rule id — survives edits, used by the UI for diffing. */
27673
- id: string$2(),
27674
- /** Optional human-readable label rendered in the rule editor. */
27675
- name: string$2().optional(),
27676
- /** Zones this rule targets. The rule's `mode` applies to ALL
27677
- * listed zones (OR-set: a detection in any one of them counts).
27678
- * At least one zone id required — a rule with no targets is a
27679
- * configuration mistake and the form validator rejects it. */
27680
- zoneIds: array(string$2()).min(1).readonly(),
27681
- mode: ZoneRuleModeEnum,
27682
- /**
27683
- * Class names this rule applies to. Empty / undefined ⇒ rule
27684
- * applies to every class. Class strings match the `macroClass`
27685
- * field on detections (e.g. `person`, `car`, `dog`).
27686
- */
27687
- classFilter: array(string$2()).readonly().optional(),
27688
- /**
27689
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
27690
- * required to consider an entity "in the zone". Defaults to the
27691
- * consumer's stage default when omitted. Kept for back-compat with
27692
- * existing per-rule overrides; new operators pick the value via
27693
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
27694
- * set, the lower-level engine reads it as a 0–1 fraction.
27695
- */
27696
- overlapThreshold: number().min(0).max(1).optional(),
27697
- /**
27698
- * Operator-friendly version of `overlapThreshold` — the percentage
27699
- * of the detection's bbox that must lie inside the zone for the
27700
- * rule to match. Documented default is 85%; the engine substitutes
27701
- * that when the field is omitted (kept optional so existing rules
27702
- * stored without it stay valid).
27703
- *
27704
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
27705
- * rule, the engine prefers `bboxInclusionPct` because it's the
27706
- * field exposed in the UI. Internally both feed the same gate.
27707
- */
27708
- bboxInclusionPct: number().min(0).max(100).optional(),
27709
- /**
27710
- * When `true` and a detection has a segmentation mask, use the
27711
- * mask for overlap instead of the bbox. Detection-stage only;
27712
- * motion rules ignore this field.
27713
- */
27714
- preferMask: boolean().optional(),
27715
- /**
27716
- * Soft-toggle: `false` disables the rule without deleting it.
27717
- * Defaults to `true` so operators creating a rule via the UI
27718
- * see it active immediately.
27719
- */
27720
- enabled: boolean().default(true)
27721
- });
27722
- array(ZoneRuleSchema).readonly();
27723
- /**
27724
27832
  * Script-runner cap. Models HA `script.*` entities on
27725
27833
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
27726
27834
  * that can be invoked imperatively — optionally with a variables
@@ -33213,6 +33321,12 @@ Object.freeze({
33213
33321
  addonId: null,
33214
33322
  access: "view"
33215
33323
  },
33324
+ "notificationRules.resolveArtifactUrl": {
33325
+ capName: "notification-rules",
33326
+ capScope: "system",
33327
+ addonId: null,
33328
+ access: "view"
33329
+ },
33216
33330
  "notificationRules.setAlarmConfig": {
33217
33331
  capName: "notification-rules",
33218
33332
  capScope: "system",
@@ -33657,6 +33771,12 @@ Object.freeze({
33657
33771
  addonId: null,
33658
33772
  access: "create"
33659
33773
  },
33774
+ "pipelineAnalytics.runReplayFrameProcessor": {
33775
+ capName: "pipeline-analytics",
33776
+ capScope: "device",
33777
+ addonId: null,
33778
+ access: "create"
33779
+ },
33660
33780
  "pipelineAnalytics.saveRetrainAnnotations": {
33661
33781
  capName: "pipeline-analytics",
33662
33782
  capScope: "device",
@@ -33789,6 +33909,12 @@ Object.freeze({
33789
33909
  addonId: null,
33790
33910
  access: "view"
33791
33911
  },
33912
+ "pipelineExecutor.getInferenceDeviceHealth": {
33913
+ capName: "pipeline-executor",
33914
+ capScope: "system",
33915
+ addonId: null,
33916
+ access: "view"
33917
+ },
33792
33918
  "pipelineExecutor.getOrchestratorConfigSchema": {
33793
33919
  capName: "pipeline-executor",
33794
33920
  capScope: "system",
@@ -33861,6 +33987,12 @@ Object.freeze({
33861
33987
  addonId: null,
33862
33988
  access: "view"
33863
33989
  },
33990
+ "pipelineExecutor.rearmInferenceDevice": {
33991
+ capName: "pipeline-executor",
33992
+ capScope: "system",
33993
+ addonId: null,
33994
+ access: "create"
33995
+ },
33864
33996
  "pipelineExecutor.runAudioTest": {
33865
33997
  capName: "pipeline-executor",
33866
33998
  capScope: "system",
@@ -34599,6 +34731,12 @@ Object.freeze({
34599
34731
  addonId: null,
34600
34732
  access: "view"
34601
34733
  },
34734
+ "recording.readWindowBytes": {
34735
+ capName: "recording",
34736
+ capScope: "system",
34737
+ addonId: null,
34738
+ access: "view"
34739
+ },
34602
34740
  "recording.refreshStorageLocationsForMigration": {
34603
34741
  capName: "recording",
34604
34742
  capScope: "system",
@@ -37109,6 +37247,11 @@ Object.freeze({
37109
37247
  form: "single",
37110
37248
  optional: false
37111
37249
  }],
37250
+ "pipelineAnalytics.runReplayFrameProcessor": [{
37251
+ name: "deviceId",
37252
+ form: "single",
37253
+ optional: false
37254
+ }],
37112
37255
  "pipelineAnalytics.saveRetrainAnnotations": [{
37113
37256
  name: "deviceId",
37114
37257
  form: "single",
@@ -37424,6 +37567,11 @@ Object.freeze({
37424
37567
  form: "single",
37425
37568
  optional: false
37426
37569
  }],
37570
+ "recording.readWindowBytes": [{
37571
+ name: "deviceId",
37572
+ form: "single",
37573
+ optional: false
37574
+ }],
37427
37575
  "recording.relocateFootage": [{
37428
37576
  name: "deviceId",
37429
37577
  form: "single",