@camstack/addon-provider-homeassistant 1.2.41 → 1.2.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6581,6 +6581,65 @@ var ProfileRtspEntrySchema = object({
6581
6581
  resolution: CamStreamResolutionSchema.optional()
6582
6582
  });
6583
6583
  /**
6584
+ * Per-call node pinning for `ctx.api` capability calls.
6585
+ *
6586
+ * A capability call normally resolves to its DEFAULT provider — a `singleton`
6587
+ * cap resolves to the hub, a device-scoped cap to the device's owning node. To
6588
+ * query a SPECIFIC node's provider instead (e.g. a remote agent's own
6589
+ * in-process `platform-probe` hardware, which the hub cannot probe), pin the
6590
+ * call to that node.
6591
+ *
6592
+ * The nodeId rides OUT-OF-BAND in the tRPC call context (NOT in the validated
6593
+ * method args), so capability method signatures stay `nodeId`-free — node
6594
+ * targeting is a property of the CALL, not of the method. The transport lifts
6595
+ * it from `op.context` onto the `CapCallInput.nodeId` field (`ipcParentLink`),
6596
+ * and the hub parent's `onUnownedCall` passes it to the `CapRouteResolver`,
6597
+ * which classifies a pinned agent node as `agent-child-forward`
6598
+ * (`$agent-cap-fwd.forward` → the agent's in-process provider).
6599
+ *
6600
+ * Usage at a call site:
6601
+ *
6602
+ * await api.platformProbe.getCapabilities.query(undefined, nodePin(nodeId))
6603
+ */
6604
+ /** tRPC `op.context` key carrying a per-call node pin. */
6605
+ var CAP_NODE_PIN_CONTEXT_KEY = "__camstackNodePin";
6606
+ /**
6607
+ * Build the tRPC request options that pin a single capability call to `nodeId`.
6608
+ * Pass as the second argument to `.query(input, …)` / `.mutate(input, …)`.
6609
+ *
6610
+ * ## The id is normalised here, and it has to be
6611
+ *
6612
+ * A forked addon reads its own node from `ctx.kernel.localNodeId`, and inside a
6613
+ * worker that value is a RUNNER id — `hub/export-hap`, not `hub`. Routing
6614
+ * compares a pin against real node ids, so such a pin matches nothing and the
6615
+ * call fails with `no provider registered for cap "…"`. The local-first
6616
+ * resolver already guarded against this (`localNodeId.split('/')[0]`), which
6617
+ * made the hazard invisible: unpinned calls worked, and only an explicit pin —
6618
+ * the thing you reach for when you specifically need THIS node — silently
6619
+ * addressed a node that does not exist.
6620
+ *
6621
+ * Cost of it being missing: `addon-export-hap` pinned `decoder.getInfo` to its
6622
+ * own node to read the host's hardware-decode backend. It never once answered,
6623
+ * so every HomeKit egress transcode decoded in SOFTWARE — including 4K H.265 —
6624
+ * while D67's whole premise was that the decoder addon is the authority on
6625
+ * hardware. The warn said `decoding in SOFTWARE` and read as "this node has no
6626
+ * hardware", which was false.
6627
+ *
6628
+ * Normalising in the ONE constructor fixes every caller at once, which is why
6629
+ * it is here and not at the call sites.
6630
+ */
6631
+ function nodePin(nodeId) {
6632
+ return { context: { [CAP_NODE_PIN_CONTEXT_KEY]: toNodeId(nodeId) } };
6633
+ }
6634
+ /**
6635
+ * A runner id is `<nodeId>/<addonId>`; a node id has no slash. Taking the head
6636
+ * is idempotent, so passing an already-clean id costs nothing.
6637
+ */
6638
+ function toNodeId(idOrRunnerId) {
6639
+ const head = idOrRunnerId.split("/")[0];
6640
+ return head === void 0 || head.length === 0 ? idOrRunnerId : head;
6641
+ }
6642
+ /**
6584
6643
  * Output schema shared by the contribution + live methods.
6585
6644
  *
6586
6645
  * Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
@@ -6629,7 +6688,7 @@ function method(input, output, options) {
6629
6688
  input,
6630
6689
  output,
6631
6690
  kind: options?.kind ?? "query",
6632
- auth: options?.auth ?? "protected",
6691
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
6633
6692
  ...options?.access !== void 0 ? { access: options.access } : {},
6634
6693
  ...options?.caller !== void 0 ? { caller: options.caller } : {},
6635
6694
  timeoutMs: options?.timeoutMs
@@ -6653,7 +6712,7 @@ function event(data) {
6653
6712
  }
6654
6713
  var StaticDirOutputSchema$1 = object({ staticDir: string() });
6655
6714
  var VersionOutputSchema$1 = object({ version: string() });
6656
- method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
6715
+ method(_void(), StaticDirOutputSchema$1, { auth: "admin" }), method(_void(), VersionOutputSchema$1, { auth: "admin" });
6657
6716
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
6658
6717
  DeviceType["Camera"] = "camera";
6659
6718
  DeviceType["Hub"] = "hub";
@@ -6974,7 +7033,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
6974
7033
  }({});
6975
7034
  var StaticDirOutputSchema = object({ staticDir: string() });
6976
7035
  var VersionOutputSchema = object({ version: string() });
6977
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
7036
+ method(_void(), StaticDirOutputSchema, { auth: "admin" }), method(_void(), VersionOutputSchema, { auth: "admin" });
6978
7037
  /**
6979
7038
  * device-ops — device-scoped cap that unifies the per-IDevice operations
6980
7039
  * previously routed through the `.device-ops` Moleculer bridge service.
@@ -7522,6 +7581,32 @@ var CameraSwitchIdSchema = _enum([
7522
7581
  "notifications"
7523
7582
  ]);
7524
7583
  /**
7584
+ * Stable render order — broadest blast radius first, and a source before the
7585
+ * thing that consumes it. `device-audio` sits ABOVE `audio-analysis` because
7586
+ * turning the microphone off leaves the analyzer with nothing to analyse; the
7587
+ * reverse is not true.
7588
+ *
7589
+ * `privacy-mask` sits directly ABOVE `device-audio` because they are literal
7590
+ * siblings — one cap, one device plane, video then audio — and NOT above
7591
+ * `object-detection` despite feeding it: a mask blanks REGIONS, so its blast
7592
+ * radius is partial, and the "broadest first" rule does not rank a partial
7593
+ * control above a whole-function one.
7594
+ *
7595
+ * `broker-audio` sits directly BELOW `device-audio` by the same source-first
7596
+ * rule: the camera's microphone feeds the broker, so silencing the camera
7597
+ * leaves the broker's mute with nothing to suppress; the reverse is not true.
7598
+ */
7599
+ var CAMERA_SWITCH_ORDER = [
7600
+ "stream-broker",
7601
+ "object-detection",
7602
+ "privacy-mask",
7603
+ "device-audio",
7604
+ "broker-audio",
7605
+ "audio-analysis",
7606
+ "recording",
7607
+ "notifications"
7608
+ ];
7609
+ /**
7525
7610
  * WHERE the switch's state actually lives. A discriminated union rather than a
7526
7611
  * string so both the writer (the orchestrator's `setCameraSwitch`) and any
7527
7612
  * reader can exhaustively narrow — and so "the group added a parallel map" is
@@ -7719,24 +7804,6 @@ var RecordingRetentionSchema = object({
7719
7804
  maxSizeGb: number().min(0).optional()
7720
7805
  });
7721
7806
  /**
7722
- * Scrub-thumbnail fidelity preset — the single per-camera selector bundling the
7723
- * sprite tile RESOLUTION + JPEG QUALITY the recorder packs timeline-scrub
7724
- * previews at. Five graduated steps; absent on a config = `standard` (the
7725
- * shipped default, matching `sheet-geometry`/`sheet-composer`).
7726
- *
7727
- * Existing sheets are IMMUTABLE — a changed preset applies to NEW windows only.
7728
- * Each window's index sidecar carries its own tile dims, so a camera whose
7729
- * preset changed over time renders every historical window at the dims it was
7730
- * written with.
7731
- */
7732
- var ScrubThumbnailPresetSchema = _enum([
7733
- "minimal",
7734
- "low",
7735
- "standard",
7736
- "high",
7737
- "max"
7738
- ]);
7739
- /**
7740
7807
  * The full per-camera recording intent — the wire shape of a RecordingTarget.
7741
7808
  *
7742
7809
  * `bands` is the ONLY authored recording intent: what to record, when, and on
@@ -7744,7 +7811,11 @@ var ScrubThumbnailPresetSchema = _enum([
7744
7811
  * other field is a storage knob (profiles, segment length, retention, scrub).
7745
7812
  *
7746
7813
  * STRICT on purpose: the legacy authoring surface (`schedule`/`schedules`/
7747
- * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30.
7814
+ * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30,
7815
+ * and `scrubThumbnails` — a five-step fidelity knob for a sprite tier that was
7816
+ * deleted on 2026-07-24 and had ZERO consumers in the recorder — on 2026-08-25
7817
+ * (D62: a switch that writes a store nobody reads is worse than no switch).
7818
+ * Stored rows keep loading: the READ schema is `.strip()` (config-store.ts).
7748
7819
  * A stale caller must fail loudly — silently stripping its legacy intent would
7749
7820
  * persist a band-less config, i.e. silently stop recording the camera.
7750
7821
  */
@@ -7767,14 +7838,7 @@ var RecordingConfigSchema = object({
7767
7838
  * "off" is the absence of a covering band, never a band value.
7768
7839
  */
7769
7840
  bands: array(RecordingBandSchema).default([]),
7770
- retention: RecordingRetentionSchema.optional(),
7771
- /**
7772
- * Per-camera scrub-thumbnail fidelity preset (resolution + JPEG quality for
7773
- * timeline-scrub sprite previews). Absent = `standard`. Applies to NEW
7774
- * windows only — existing sheets are immutable, and each window's index
7775
- * carries its own tile dims so mixed-preset history renders correctly.
7776
- */
7777
- scrubThumbnails: ScrubThumbnailPresetSchema.optional()
7841
+ retention: RecordingRetentionSchema.optional()
7778
7842
  }).strict();
7779
7843
  /**
7780
7844
  * Entity-relocation job state (storage entity-routing spec, Phase 4).
@@ -7850,10 +7914,11 @@ var RelocateFootageInputSchema = object({
7850
7914
  * `RecordingConfig.enabled` or camera wrapper bindings. */
7851
7915
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
7852
7916
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
7853
- var StorageMigrationMediaMoveInputSchema = object({
7917
+ var RelocateMediaInputSchema = object({
7854
7918
  toLocationId: string(),
7855
7919
  throttleMbps: number().min(1).max(1e3).optional()
7856
- }).extend({ leaseId: string().min(1) });
7920
+ });
7921
+ var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
7857
7922
  /** The independently selectable logical storage classes. `recordings`
7858
7923
  * encompasses the high and mid segment profiles; `recordingsLow` is low
7859
7924
  * segments; `eventMedia` is post-analysis blobs. */
@@ -8148,7 +8213,26 @@ var LabelDefinitionSchema = object({
8148
8213
  description: string().optional(),
8149
8214
  icon: string().optional()
8150
8215
  });
8151
- var ClassMapDefinitionSchema = object({
8216
+ /**
8217
+ * Wire schema for a per-model CATALOG classMap override
8218
+ * (`ModelCatalogEntry.classMap` / `ModelConvertMetadata.classMap`) —
8219
+ * restricted to {@link CLASS_MAP_MACRO_TARGETS}, the only macros the
8220
+ * detection pipeline executor actually routes.
8221
+ *
8222
+ * This is deliberately a DIFFERENT, narrower shape than the general-purpose
8223
+ * `ClassMapDefinition` interface above (e.g. `IDetectionAddon.getClassMap()`
8224
+ * and the audio `YAMNET_TO_MACRO` catalog both use macro targets outside this
8225
+ * enum) — the two used to share the name `ClassMapDefinition`/
8226
+ * `ClassMapDefinitionSchema`, which made the schema-type-twin guard
8227
+ * (`scripts/check-schema-type-twins.ts`) flag them as a duplicated shape. They
8228
+ * are not: it is two different concepts colliding on a name. Keep this type
8229
+ * under its own name rather than reusing `ClassMapDefinition` — reusing it
8230
+ * would either narrow every `ClassMapDefinition` consumer to the four
8231
+ * detection macros (breaking `YAMNET_TO_MACRO`) or drop the validation this
8232
+ * schema exists for (see the "rejects a classMap whose target is not a
8233
+ * detection macro" test in `model-catalog-schema.test.ts`).
8234
+ */
8235
+ var DetectionCatalogClassMapSchema = object({
8152
8236
  mapping: record(string(), _enum([
8153
8237
  "person",
8154
8238
  "vehicle",
@@ -8353,7 +8437,7 @@ var ModelCatalogEntrySchema = object({
8353
8437
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
8354
8438
  * labels already ARE the CamStack macros (Scrypted identity map).
8355
8439
  */
8356
- classMap: ClassMapDefinitionSchema.optional()
8440
+ classMap: DetectionCatalogClassMapSchema.optional()
8357
8441
  });
8358
8442
  var ConvertTargetSchema = discriminatedUnion("format", [object({
8359
8443
  format: literal("openvino"),
@@ -8383,7 +8467,7 @@ var ModelConvertMetadataSchema = object({
8383
8467
  "segmentation"
8384
8468
  ]),
8385
8469
  faceAlignment: boolean().optional(),
8386
- classMap: ClassMapDefinitionSchema.optional()
8470
+ classMap: DetectionCatalogClassMapSchema.optional()
8387
8471
  });
8388
8472
  var ConvertResultSchema = object({
8389
8473
  entry: ModelCatalogEntrySchema,
@@ -9246,7 +9330,7 @@ var AddonPageDeclarationSchema = object({
9246
9330
  /** Display label for a CUSTOM `section` id (ignored for well-known ids). */
9247
9331
  sectionLabel: string().optional()
9248
9332
  });
9249
- method(_void(), array(AddonPageDeclarationSchema).readonly());
9333
+ method(_void(), array(AddonPageDeclarationSchema).readonly(), { auth: "admin" });
9250
9334
  var AddonHttpRouteSchema = object({
9251
9335
  method: _enum([
9252
9336
  "GET",
@@ -9500,7 +9584,7 @@ var WidgetMetadataSchema = object({
9500
9584
  defaultColumns: number().int().min(1).max(12).default(6),
9501
9585
  defaultRows: number().int().min(1).max(12).default(1)
9502
9586
  });
9503
- method(_void(), array(WidgetMetadataSchema).readonly());
9587
+ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
9504
9588
  /**
9505
9589
  * `addon-widgets` — system-scoped singleton aggregator cap. Public-facing
9506
9590
  * surface that admin-ui consumes through `useAddonWidgetsListWidgets()`.
@@ -11173,7 +11257,7 @@ var CustomModelDescriptorSchema = object({
11173
11257
  stepId: string(),
11174
11258
  entry: ModelCatalogEntrySchema
11175
11259
  });
11176
- method(_void(), array(CustomModelDescriptorSchema).readonly());
11260
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
11177
11261
  /**
11178
11262
  * Query filter for settings-store collections.
11179
11263
  */
@@ -11260,7 +11344,8 @@ method(object({
11260
11344
  }), _void(), { kind: "mutation" }), method(object({
11261
11345
  namespace: string().optional(),
11262
11346
  collection: string(),
11263
- filter: QueryFilterSchema.optional()
11347
+ filter: QueryFilterSchema.optional(),
11348
+ columns: array(string()).readonly().optional()
11264
11349
  }), array(SettingsRecordSchema).readonly()), method(object({
11265
11350
  namespace: string().optional(),
11266
11351
  collection: string(),
@@ -11323,46 +11408,87 @@ var EngineInfoSchema = object({
11323
11408
  kind: _enum(["relational", "vector"]),
11324
11409
  displayName: string()
11325
11410
  });
11326
- method(_void(), EngineInfoSchema), method(object({
11411
+ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11327
11412
  namespace: string().optional(),
11328
11413
  collection: string(),
11329
11414
  key: string()
11330
- }), unknown()), method(object({
11415
+ }), unknown(), { auth: "admin" }), method(object({
11331
11416
  namespace: string().optional(),
11332
11417
  collection: string(),
11333
11418
  key: string(),
11334
11419
  value: unknown()
11335
- }), _void(), { kind: "mutation" }), method(object({
11420
+ }), _void(), {
11421
+ kind: "mutation",
11422
+ auth: "admin"
11423
+ }), method(object({
11336
11424
  namespace: string().optional(),
11337
11425
  collection: string(),
11338
- filter: QueryFilterSchema.optional()
11339
- }), array(SettingsRecordSchema).readonly()), method(object({
11426
+ filter: QueryFilterSchema.optional(),
11427
+ /**
11428
+ * SQL-level column projection — MUST mirror `settings-store.query`.
11429
+ *
11430
+ * ⚠ An earlier version of this comment blamed Zod stripping, and that
11431
+ * was wrong — corrected 2026-08-26 after the hop map
11432
+ * (`docs/design/2026-08-26-mappa-hop-argomenti.md`) traced the path.
11433
+ * There is **no Zod parse at all** between the door and the engine: the
11434
+ * dispatcher forwards the payload verbatim and UDS carries it whole. A
11435
+ * field declared here reaches `SqliteSettingsBackend` either way.
11436
+ *
11437
+ * What actually lost `columns` was the THIRD declaration of this shape:
11438
+ * `SettingsQueryInput` in `interfaces/storage.ts`, a hand-written TS
11439
+ * interface the engine destructures from. The field existed on both
11440
+ * schemas and the engine still never read it, because nothing checks a
11441
+ * registered provider against `InferProvider<cap>` —
11442
+ * `ProviderRegistration.provider` is typed `object`.
11443
+ *
11444
+ * It is declared here anyway, and must stay in step with
11445
+ * `settings-store.query`: a caller reading only the cap definitions has
11446
+ * to be able to see that this call carries a projection.
11447
+ * `data-door-schema-parity.spec.ts` keeps the two aligned.
11448
+ */
11449
+ columns: array(string()).readonly().optional()
11450
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
11340
11451
  namespace: string().optional(),
11341
11452
  collection: string(),
11342
11453
  record: SettingsRecordSchema
11343
- }), _void(), { kind: "mutation" }), method(object({
11454
+ }), _void(), {
11455
+ kind: "mutation",
11456
+ auth: "admin"
11457
+ }), method(object({
11344
11458
  namespace: string().optional(),
11345
11459
  collection: string(),
11346
11460
  id: string(),
11347
11461
  data: record(string(), unknown())
11348
- }), _void(), { kind: "mutation" }), method(object({
11462
+ }), _void(), {
11463
+ kind: "mutation",
11464
+ auth: "admin"
11465
+ }), method(object({
11349
11466
  namespace: string().optional(),
11350
11467
  collection: string(),
11351
11468
  key: string()
11352
- }), _void(), { kind: "mutation" }), method(object({
11469
+ }), _void(), {
11470
+ kind: "mutation",
11471
+ auth: "admin"
11472
+ }), method(object({
11353
11473
  namespace: string().optional(),
11354
11474
  collection: string(),
11355
11475
  filter: MutationFilterSchema
11356
- }), object({ deleted: number().int() }), { kind: "mutation" }), method(object({
11476
+ }), object({ deleted: number().int() }), {
11477
+ kind: "mutation",
11478
+ auth: "admin"
11479
+ }), method(object({
11357
11480
  namespace: string().optional(),
11358
11481
  collection: string(),
11359
11482
  filter: MutationFilterSchema,
11360
11483
  data: record(string(), unknown())
11361
- }), object({ updated: number().int() }), { kind: "mutation" }), method(object({
11484
+ }), object({ updated: number().int() }), {
11485
+ kind: "mutation",
11486
+ auth: "admin"
11487
+ }), method(object({
11362
11488
  namespace: string().optional(),
11363
11489
  collection: string(),
11364
11490
  filter: QueryFilterSchema.optional()
11365
- }), number()), method(object({
11491
+ }), number(), { auth: "admin" }), method(object({
11366
11492
  namespace: string().optional(),
11367
11493
  collection: string(),
11368
11494
  field: string(),
@@ -11372,15 +11498,18 @@ method(_void(), EngineInfoSchema), method(object({
11372
11498
  }), array(object({
11373
11499
  bucket: number().int(),
11374
11500
  count: number().int()
11375
- })).readonly()), method(object({
11501
+ })).readonly(), { auth: "admin" }), method(object({
11376
11502
  namespace: string().optional(),
11377
11503
  collection: string()
11378
- }), boolean()), method(object({
11504
+ }), boolean(), { auth: "admin" }), method(object({
11379
11505
  namespace: string().optional(),
11380
11506
  collection: string(),
11381
11507
  columns: array(CollectionColumnSchema).readonly(),
11382
11508
  indexes: array(CollectionIndexSchema).readonly().optional()
11383
- }), _void(), { kind: "mutation" });
11509
+ }), _void(), {
11510
+ kind: "mutation",
11511
+ auth: "admin"
11512
+ });
11384
11513
  /**
11385
11514
  * shm ring usage stats for a `frameSink: 'shm'` decoder session —
11386
11515
  * exposed via `decoder.getShmStats` so downstream consumers can
@@ -12757,7 +12886,7 @@ method(object({
12757
12886
  crop: _instanceof(Uint8Array),
12758
12887
  width: number(),
12759
12888
  height: number()
12760
- }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12889
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
12761
12890
  /**
12762
12891
  * filesystem-browse — per-node capability for browsing the node's local
12763
12892
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
@@ -13050,19 +13179,22 @@ method(LlmGenerateBaseInputSchema.extend({
13050
13179
  runtime: ManagedRuntimeConfigSchema,
13051
13180
  /** The managed profile's timeout, threaded by the hub provider. */
13052
13181
  timeoutMs: number().int().positive().optional()
13053
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
13182
+ }), LlmGenerateResultSchema, {
13183
+ kind: "mutation",
13184
+ auth: "admin"
13185
+ }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
13054
13186
  kind: "mutation",
13055
13187
  auth: "admin"
13056
13188
  }), method(object({}), _void(), {
13057
13189
  kind: "mutation",
13058
13190
  auth: "admin"
13059
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
13191
+ }), method(object({}), LlmRuntimeStatusSchema, { auth: "admin" }), method(object({ model: ManagedModelRefSchema }), _void(), {
13060
13192
  kind: "mutation",
13061
13193
  auth: "admin"
13062
13194
  }), method(object({ file: string() }), _void(), {
13063
13195
  kind: "mutation",
13064
13196
  auth: "admin"
13065
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
13197
+ }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" });
13066
13198
  /**
13067
13199
  * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
13068
13200
  * methods concat-fan across providers; single-row methods route to ONE
@@ -16592,1749 +16724,2009 @@ var oauthIntegrationCapability = {
16592
16724
  scope: "system",
16593
16725
  mode: "collection",
16594
16726
  internal: true,
16595
- methods: { getDescriptor: method(_void(), OauthIntegrationDescriptorSchema) }
16727
+ methods: {
16728
+ /**
16729
+ * `internal: true` did not gate the mount (see the 2026-08-26 note on
16730
+ * `data-store-provider`) — `getDescriptor` was reachable on the AppRouter
16731
+ * by ANY authenticated session at the default `auth: 'protected'`. The
16732
+ * real caller is `/api/oauth2/authorize` and `/api/oauth2/integrations`
16733
+ * (`oauth2-routes.ts`), which resolve the provider directly off the
16734
+ * capability registry — never through tRPC. `auth: 'admin'` closes the
16735
+ * tRPC surface without touching that path.
16736
+ */
16737
+ getDescriptor: method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" }) }
16596
16738
  };
16597
16739
  /**
16598
- * pipeline-analytics device-scoped wrapper cap. Refines raw
16599
- * per-frame detections emitted by the pipeline runner into tracked
16600
- * objects, per-kind event collections (motion / object / audio), and
16601
- * persisted media. Owns the post-detection domain end-to-end:
16602
- *
16603
- * runner emits PipelineInferenceResult
16604
- * ↓ (event bus)
16605
- * pipeline-analytics subscriber
16606
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
16607
- * → three DB collections (one per kind), one FS media tree, one
16608
- * unified event emitter (FrameTracked + TrackStarted/Ended +
16609
- * DetectionEvent on bus)
16610
- *
16611
- * Pure subscriber model. No `processFrame` cap method — the runner
16612
- * already publishes the raw frame on the bus. The cap surface is
16613
- * only QUERIES + per-device settings, bound on/off via
16614
- * `device-manager.setWrapperActive`. `defaultActive: true` because
16615
- * every camera with a detection pipeline wants its raw detections
16616
- * refined; operators opt out per-device via BindingsTab when needed.
16617
- *
16618
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
16619
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
16740
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
16741
+ * within the frame, so the executor can re-cut a leaf child ROI at native
16742
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
16620
16743
  */
16621
- var TrackStateSchema = _enum([
16622
- "new",
16623
- "entered",
16624
- "left",
16625
- "moving",
16626
- "idle"
16627
- ]);
16628
- var EventKindSchema = _enum([
16629
- "motion",
16630
- "object",
16631
- "audio"
16632
- ]);
16744
+ var NativeCropRefSchema = object({
16745
+ /** Handle keying the retained native surface (node-pinned to its owner). */
16746
+ handle: FrameHandleSchema,
16747
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
16748
+ cropFrameSpace: object({
16749
+ x: number(),
16750
+ y: number(),
16751
+ w: number(),
16752
+ h: number()
16753
+ })
16754
+ });
16755
+ object({
16756
+ crop: object({
16757
+ left: number(),
16758
+ top: number(),
16759
+ width: number().positive(),
16760
+ height: number().positive()
16761
+ }).optional(),
16762
+ content: object({
16763
+ width: number().int().positive(),
16764
+ height: number().int().positive()
16765
+ }),
16766
+ fit: _enum(["stretch", "contain"]),
16767
+ format: _enum([
16768
+ "rgb",
16769
+ "gray",
16770
+ "jpeg"
16771
+ ])
16772
+ });
16633
16773
  /**
16634
- * Spatial filter for `listTracks` the rect + polygon variants of the shared
16635
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
16636
- * of the camera frame (top-left origin), matching the drawing-plane editor.
16774
+ * Process-local frame identity. It is serializable so it can ride an in-process
16775
+ * capability call, but `registryId` deliberately prevents resolution in any
16776
+ * other process or execution group.
16637
16777
  */
16638
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
16639
- /** Closed icon vocabulary so clients render a known glyph per kind. */
16640
- var EventKindIconSchema = _enum([
16641
- "motion",
16642
- "audio",
16643
- "person",
16644
- "vehicle",
16645
- "animal",
16646
- "door",
16647
- "pir",
16648
- "smoke",
16649
- "water",
16650
- "button",
16651
- "package",
16652
- "generic"
16778
+ var FrameRefSchema = object({
16779
+ registryId: string().min(1),
16780
+ id: string().min(1),
16781
+ width: number().int().positive(),
16782
+ height: number().int().positive(),
16783
+ format: _enum(["rgb", "gray"]),
16784
+ timestamp: number(),
16785
+ capturedAt: number().optional()
16786
+ });
16787
+ var ModelFormatSchema$1 = _enum([
16788
+ "onnx",
16789
+ "coreml",
16790
+ "openvino",
16791
+ "tflite",
16792
+ "pt",
16793
+ "gguf"
16653
16794
  ]);
16654
- var EventKindCategorySchema = _enum([
16655
- "motion",
16656
- "audio",
16657
- "detection",
16658
- "sensor",
16659
- "control",
16660
- "custom",
16661
- "package"
16795
+ var PipelineSlotSchema = _enum([
16796
+ "detector",
16797
+ "cropper",
16798
+ "classifier",
16799
+ "refiner",
16800
+ "audio-classifier"
16662
16801
  ]);
16663
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
16664
- var EventKindLevelSchema = _enum(["macro", "sub"]);
16665
- var EventKindDescriptorSchema = object({
16666
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
16667
- kind: string(),
16668
- /** i18n key resolved on the UI side; `label` is the English fallback. */
16669
- labelKey: string(),
16670
- /** English fallback label (kept for clients that don't translate). */
16671
- label: string(),
16672
- /** Hex color for timeline/legend rendering. */
16673
- color: string(),
16674
- /** Dictionary id → lucide component on the UI side. */
16675
- iconId: string(),
16676
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
16677
- icon: EventKindIconSchema,
16678
- category: EventKindCategorySchema,
16679
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
16680
- parentKind: string().nullable(),
16681
- /** Derived from `parentKind`, explicit for the client tree. */
16682
- level: EventKindLevelSchema,
16683
- /** Which cap + device contributes this kind. For built-ins the camera
16684
- * itself; for sensor kinds the LINKED source device. */
16685
- source: object({
16686
- capName: string(),
16687
- deviceId: number()
16688
- })
16802
+ var PipelineEngineChoiceSchema = object({
16803
+ runtime: _enum(["node", "python"]),
16804
+ backend: string(),
16805
+ format: ModelFormatSchema$1,
16806
+ device: string().optional()
16689
16807
  });
16690
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
16691
- var EventKindsForDeviceSchema = object({
16692
- deviceId: number(),
16693
- kinds: array(EventKindDescriptorSchema).readonly()
16808
+ var AvailableEngineSchema = object({
16809
+ engine: PipelineEngineChoiceSchema,
16810
+ devices: array(object({
16811
+ id: string(),
16812
+ label: string(),
16813
+ description: string().optional()
16814
+ })).readonly(),
16815
+ defaultDevice: string()
16694
16816
  });
16695
- var SensorEventSchema = object({
16817
+ var PipelineDefaultStepSchema = lazy(() => object({
16818
+ addonId: string(),
16819
+ addonName: string(),
16820
+ slot: PipelineSlotSchema,
16821
+ inputClasses: array(string()).readonly(),
16822
+ outputClasses: array(string()).readonly(),
16823
+ enabled: boolean(),
16824
+ modelId: string(),
16825
+ children: array(PipelineDefaultStepSchema).readonly(),
16826
+ group: string().optional(),
16827
+ settings: record(string(), unknown()).optional()
16828
+ }));
16829
+ var PipelineTemplateStepSchema = lazy(() => object({
16830
+ addonId: string(),
16831
+ enabled: boolean(),
16832
+ modelId: string(),
16833
+ children: array(PipelineTemplateStepSchema).readonly(),
16834
+ settings: record(string(), unknown()).optional()
16835
+ }));
16836
+ var PipelineTemplateSchema$1 = object({
16696
16837
  id: string(),
16697
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
16698
- * yields N rows, one per camera). */
16699
- deviceId: number(),
16700
- /** The linked sensor device whose state changed. */
16701
- sourceDeviceId: number(),
16702
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
16703
- kind: string(),
16704
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
16705
- value: record(string(), unknown()).nullable(),
16706
- timestamp: number()
16707
- });
16708
- var TrackPositionSchema = object({
16709
- x: number(),
16710
- y: number(),
16711
- timestamp: number(),
16712
- bbox: BoundingBoxSchema
16838
+ name: string(),
16839
+ createdAt: string(),
16840
+ updatedAt: string(),
16841
+ engine: PipelineEngineChoiceSchema,
16842
+ steps: array(PipelineTemplateStepSchema).readonly()
16713
16843
  });
16714
- var TrackSnapshotSchema = object({
16715
- timestamp: number(),
16716
- position: TrackPositionSchema,
16717
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
16718
- mediaKey: string()
16844
+ var PipelineModelOptionSchema = object({
16845
+ id: string(),
16846
+ name: string(),
16847
+ formats: record(string(), object({
16848
+ downloaded: boolean(),
16849
+ sizeMB: number()
16850
+ })),
16851
+ group: ModelVariantGroupSchema.optional(),
16852
+ legacy: boolean().optional(),
16853
+ provider: ModelProviderIdSchema.optional()
16719
16854
  });
16720
- /**
16721
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
16722
- * divided by the track's detection-frame dims), computed at persist time.
16723
- * Absent when the frame dims were unknown when the track was persisted
16724
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
16725
- */
16726
- var TrackEnvelopeSchema = object({
16727
- minX: number(),
16728
- minY: number(),
16729
- maxX: number(),
16730
- maxY: number()
16855
+ var ConfigFieldBridge = custom();
16856
+ var PipelineAddonSchemaSchema = object({
16857
+ id: string(),
16858
+ name: string(),
16859
+ slot: PipelineSlotSchema,
16860
+ inputClasses: array(string()).readonly(),
16861
+ outputClasses: array(string()).readonly(),
16862
+ childSlots: array(PipelineSlotSchema).readonly(),
16863
+ models: array(PipelineModelOptionSchema).readonly(),
16864
+ defaultModelId: string(),
16865
+ defaultModelIdByFormat: record(string(), string()).optional(),
16866
+ enabledByDefault: boolean().optional(),
16867
+ backfillIntoExistingOverrides: boolean().optional(),
16868
+ defaultConfidence: number(),
16869
+ group: string().optional(),
16870
+ configSchema: array(ConfigFieldBridge).readonly().optional()
16731
16871
  });
16732
- /**
16733
- * Row projection for track list queries. `full` (default) returns the
16734
- * complete Track including the frame-rate `positions[]` history and the
16735
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
16736
- * keeps every scalar the list surfaces actually render (ids, class(es),
16737
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
16738
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
16739
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
16740
- * `getTrack`. Mirrors the event-store `projection` convention
16741
- * (`getObjectEvents` et al.).
16742
- */
16743
- var TrackProjectionSchema = _enum(["full", "slim"]);
16744
- /**
16745
- * One audio-classification label heard on the track's camera while the
16746
- * track was alive, aggregated per label. An "episode" is one persisted
16747
- * audio event (the confident-classification path: score ≥ the device's
16748
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
16749
- * one 32 ms inference chunk, so counts stay human-scaled.
16750
- */
16751
- var TrackAudioLabelSchema = object({
16872
+ var PipelineSlotSchemaSchema = object({
16873
+ id: PipelineSlotSchema,
16752
16874
  label: string(),
16753
- /** Highest classification score observed across the label's episodes. */
16754
- peakScore: number(),
16755
- /** Number of coalesced audio-event episodes carrying this label. */
16756
- count: number(),
16757
- firstAt: number(),
16758
- lastAt: number()
16875
+ priority: number(),
16876
+ parentSlot: PipelineSlotSchema.nullable(),
16877
+ addons: array(PipelineAddonSchemaSchema).readonly()
16759
16878
  });
16760
- /**
16761
- * How a track was produced. `pipeline` (default / absent) = the spatial
16762
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
16763
- * no positions, a single snapshot, and no bbox trajectory at all:
16764
- *
16765
- * - `sensor` — a linked sensor/control device state change.
16766
- * - `audio` — an audio event on the camera itself that was anomalous for
16767
- * THAT camera, loud, and heard while nothing visual was happening (D62).
16768
- *
16769
- * The spatial subsystems (tracker association, occupancy count, re-id /
16770
- * embedding, resurrection) MUST skip every synthetic source. Test for that
16771
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
16772
- * check silently readmits every source added after it was written.
16773
- */
16774
- var TrackSourceSchema = _enum([
16775
- "pipeline",
16776
- "sensor",
16777
- "audio"
16778
- ]);
16779
- /**
16780
- * Where a track sits in the RETRAIN lifecycle (D81).
16781
- *
16782
- * - `none` — never marked, or un-marked. Evictable.
16783
- * - `staging` — the operator wants this track as training material and has not
16784
- * finished with it. **This is the only state retention holds**: the track and
16785
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
16786
- * the device's age window.
16787
- * - `trained` — the retrain page has taken what it needed. The frames it chose
16788
- * were COPIED into the retrain dataset at selection time, so the dataset no
16789
- * longer depends on the track's media and the track becomes EVICTABLE again.
16790
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
16791
- * a deliberate action of the retrain page, not a side effect of a checkbox.
16792
- *
16793
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
16794
- * the store's filter language has only positive equality and `whereIn` — no
16795
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
16796
- * would make the entire pre-column history immortal in one deploy.
16797
- */
16798
- var RetrainStatusSchema = _enum([
16799
- "none",
16800
- "staging",
16801
- "trained"
16802
- ]);
16803
- /**
16804
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
16805
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
16806
- * so the two surfaces cannot drift.
16807
- *
16808
- * **Absent ≠ false.** A track that has never been touched omits the field; an
16809
- * explicitly un-flagged track carries `false`. Legacy rows written before the
16810
- * columns existed read as absent, and a consumer that needs a boolean should say
16811
- * `flag === true`, not `flag !== false`.
16812
- *
16813
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
16814
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
16815
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
16816
- * `trained` track reports `false` while refusing both writes. The boolean is
16817
- * kept because three surfaces drive a toggle off it; anything that needs to tell
16818
- * "never marked" from "already trained" must read `retrainStatus`.
16819
- *
16820
- * `debug` does NOT pin; it is attention, not durability.
16821
- *
16822
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16823
- * A favourited track is skipped by retention the same way `staging` is, but
16824
- * it does not enter `none|staging|trained` and has no staging budget.
16825
- */
16826
- var TrackFlagFields = {
16827
- /** Operator marked this track as training material — i.e. `retrainStatus` is
16828
- * `'staging'`. */
16829
- markForTrain: boolean().optional(),
16830
- /** Operator marked this track for diagnostic attention. */
16831
- debug: boolean().optional(),
16832
- /** Operator favourited this track. Pins it against pruning. */
16833
- favourited: boolean().optional()
16834
- };
16835
- /**
16836
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
16837
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
16838
- * write patch, and the status is not something the toggle sets — it is what the
16839
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
16840
- * always present on a persisted row (the column default materialises `'none'`).
16841
- */
16842
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
16843
- /**
16844
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
16845
- * one flag can never clear the other — the toggles are independent and are
16846
- * driven from three surfaces that do not know about each other.
16847
- */
16848
- var TrackFlagsPatchSchema = object(TrackFlagFields);
16849
- /**
16850
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
16851
- * collapses to `false`) so a caller can drive a toggle's checked state off the
16852
- * mutation result without a re-fetch.
16853
- */
16854
- var TrackFlagsSchema = object({
16855
- trackId: string(),
16856
- markForTrain: boolean(),
16857
- debug: boolean(),
16858
- favourited: boolean(),
16859
- /** The lifecycle state the boolean was derived from. Required here (unlike on
16860
- * a track row) because this shape is only ever produced by the write body,
16861
- * which always knows it — and a surface that has just written needs to render
16862
- * `trained` without a re-fetch. */
16863
- retrainStatus: RetrainStatusSchema
16879
+ var PipelineSchemaSchema = object({
16880
+ availableEngines: array(AvailableEngineSchema).readonly(),
16881
+ selectedEngine: PipelineEngineChoiceSchema,
16882
+ slots: array(PipelineSlotSchemaSchema).readonly()
16864
16883
  });
16865
- union([literal(1), literal(2)]);
16866
- /**
16867
- * WHO decided a label, and when. Carried per tier so a value can be traced to
16868
- * the step and model that produced it — which is what makes the write rule
16869
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
16870
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
16871
- *
16872
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
16873
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
16874
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
16875
- * that value has no provenance, and the write rule lets ANY properly-attributed
16876
- * write of the same tier replace it regardless of score.
16877
- */
16878
- var LabelAttributionSchema = object({
16879
- stepId: string(),
16880
- modelId: string().optional(),
16881
- decidedAt: number(),
16884
+ var EngineProvisioningSchema = object({
16885
+ runtimeId: _enum([
16886
+ "onnx",
16887
+ "openvino",
16888
+ "coreml",
16889
+ "edgetpu"
16890
+ ]).nullable(),
16891
+ device: string().nullable(),
16892
+ state: _enum([
16893
+ "idle",
16894
+ "installing",
16895
+ "verifying",
16896
+ "ready",
16897
+ "failed"
16898
+ ]),
16899
+ progress: number().optional(),
16900
+ error: string().optional(),
16901
+ nextRetryAt: number().optional(),
16882
16902
  /**
16883
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
16884
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
16885
- *
16886
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
16887
- * notification rule authored on "Gianluca" stopped matching the moment the
16888
- * operator fixed the spelling in the gallery, and nothing said so. The id is
16889
- * the thing that does not move, so it is what a rule matches on
16890
- * (`NcConditions.identities`) and the text is what a human is shown.
16891
- *
16892
- * Absent when the label names no gallery row — a plate the OCR read but no
16893
- * vehicle claims, a sub-class, a species, any tier-1 value.
16903
+ * Gate A (config-correctness gate at engine change): human-readable
16904
+ * config issues surfaced EAGERLY when the node's engine changes — model
16905
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
16906
+ * has a <format> build"). Additive/optional: informational only, never
16907
+ * enforced here `assertEngineReady` (readiness) still gates inference.
16908
+ * Absent/empty when the node-default tree resolves cleanly.
16894
16909
  */
16895
- identityId: string().optional()
16910
+ configIssues: array(string()).optional()
16896
16911
  });
16897
- /**
16898
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
16899
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
16900
- * track and its events always answer the same question the same way.
16901
- *
16902
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
16903
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
16904
- * is tier 2, and each carries its own score + attribution.
16905
- *
16906
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
16907
- * finest thing known. Before 4g the single `label` column held the finest
16908
- * value, so a consumer that has not been updated reads the tier-1 slot and
16909
- * shows nothing on a species-only row; that is why the migration puts every
16910
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
16911
- * and why the read surfaces were changed in the same train.
16912
- *
16913
- * **Writing it.** The slots are independent, which is the whole point: a
16914
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
16915
- * migratorius`), so fineness cannot regress by construction. Within a tier the
16916
- * higher score wins. One rule, one implementation — see
16917
- * `pipeline/label-tier.ts` in addon-post-analysis.
16918
- */
16919
- var TieredLabelFields = {
16920
- /** Tier 1 the sub-class. See {@link LabelTierSchema}. */
16921
- label: string().optional(),
16922
- /** Confidence of the tier-1 value, as reported by the deciding step. */
16923
- labelScore: number().optional(),
16924
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
16925
- labelMeta: LabelAttributionSchema.optional(),
16926
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
16927
- subLabel: string().optional(),
16928
- /** Confidence of the tier-2 value, as reported by the deciding step. */
16929
- subLabelScore: number().optional(),
16930
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
16931
- subLabelMeta: LabelAttributionSchema.optional()
16932
- };
16933
- /** Per-camera slice of a training-export estimate. */
16934
- var TrainingExportDeviceTotalsSchema = object({
16935
- deviceId: number(),
16936
- tracks: number().int(),
16937
- files: number().int(),
16938
- bytes: number().int()
16912
+ var PipelineStepInputSchema = lazy(() => object({
16913
+ addonId: string(),
16914
+ modelId: string().optional(),
16915
+ enabled: boolean().default(true),
16916
+ children: array(PipelineStepInputSchema).optional(),
16917
+ settings: record(string(), unknown()).optional(),
16918
+ jumpDeviceKey: string().optional()
16919
+ }));
16920
+ var ModelSubstitutionSchema = object({
16921
+ addonId: string(),
16922
+ chosen: string(),
16923
+ running: string(),
16924
+ format: string()
16925
+ });
16926
+ var PipelineValidationIssueSchema = object({
16927
+ addonId: string(),
16928
+ kind: _enum(["unknown-addon", "no-format-build"]),
16929
+ detail: string()
16930
+ });
16931
+ var PipelineValidationResultSchema = object({
16932
+ ok: boolean(),
16933
+ issues: array(PipelineValidationIssueSchema).readonly(),
16934
+ substitutions: array(ModelSubstitutionSchema).readonly(),
16935
+ /** The node's `currentEngine.format` this validation ran against. */
16936
+ format: string()
16937
+ });
16938
+ var ReferenceImageEntrySchema = object({
16939
+ filename: string(),
16940
+ stepIds: array(string()).readonly().optional()
16941
+ });
16942
+ var ReferenceImageBodySchema = object({
16943
+ base64: string(),
16944
+ filename: string()
16945
+ });
16946
+ var ReferenceAudioEntrySchema = object({
16947
+ filename: string(),
16948
+ sizeKb: number()
16949
+ });
16950
+ var ReferenceAudioBodySchema = object({ base64: string() });
16951
+ var AudioBackendSchema = object({
16952
+ id: string(),
16953
+ name: string(),
16954
+ description: string(),
16955
+ available: boolean(),
16956
+ /**
16957
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
16958
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
16959
+ * the benchmark UI to populate the `enabledMicroClasses` filter
16960
+ * specific to the selected backend without a separate fetch.
16961
+ */
16962
+ rawLabels: array(string()).readonly().optional()
16963
+ });
16964
+ var AudioCapabilitiesSchema = object({
16965
+ activeBackend: string(),
16966
+ availableBackends: array(AudioBackendSchema).readonly(),
16967
+ sampleRate: number(),
16968
+ chunkDurationMs: number()
16969
+ });
16970
+ var DownloadModelResultSchema = object({
16971
+ filePath: string(),
16972
+ sizeMB: number(),
16973
+ durationMs: number()
16939
16974
  });
16940
16975
  /**
16941
- * What a training export WOULD contain. Computed from media index rows only —
16942
- * no blob is read to produce this.
16976
+ * Wrapper carrying a single test run's result. Replaces the legacy
16977
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
16978
+ * canonical `AudioResult` from the Phase 6 output rework: one
16979
+ * `AudioDetection` per class above `minScore`, top-N candidates in
16980
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
16981
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
16982
+ * benchmark UI can still report a clean failure when the classifier
16983
+ * cap isn't available.
16943
16984
  */
16944
- var TrainingExportSummarySchema = object({
16945
- generatedAt: number(),
16946
- trackCount: number().int(),
16947
- fileCount: number().int(),
16948
- byteCount: number().int(),
16949
- /** More marked tracks exist than a single pass carries. */
16950
- truncated: boolean(),
16951
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
16985
+ var AudioTestResultSchema = object({
16986
+ success: boolean(),
16987
+ error: string().optional(),
16988
+ frame: custom().optional()
16952
16989
  });
16953
- var TrackSchema = object({
16954
- trackId: string(),
16955
- deviceId: number(),
16956
- className: string(),
16957
- ...TieredLabelFields,
16958
- producingDeviceName: string().optional(),
16959
- /** Track provenance. Absent `pipeline` (legacy rows). */
16960
- source: TrackSourceSchema.optional(),
16961
- firstSeen: number(),
16962
- lastSeen: number(),
16963
- /** Frame-rate position history (subject to maxPositionHistory cap). */
16964
- positions: array(TrackPositionSchema).readonly(),
16965
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
16966
- * saveThumbnails policy). */
16967
- snapshots: array(TrackSnapshotSchema).readonly(),
16968
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
16969
- zonesVisited: array(string()).readonly(),
16990
+ var PipelineConfigBridge = custom();
16991
+ var ConfigUISchemaBridge = custom();
16992
+ var ConfigUISchemaNullableBridge = custom();
16993
+ var InferenceCapabilitiesBridge = custom();
16994
+ var ModelAvailabilityListBridge = custom();
16995
+ var PipelineRunResultBridge = custom();
16996
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
16997
+ modelId: string(),
16998
+ settings: record(string(), unknown()).readonly()
16999
+ }))), method(object({ steps: record(string(), object({
17000
+ modelId: string(),
17001
+ settings: record(string(), unknown()).readonly()
17002
+ })) }), object({ success: literal(true) }), {
17003
+ kind: "mutation",
17004
+ auth: "admin"
17005
+ }), method(object({ nodeId: string() }), object({
17006
+ success: literal(true),
17007
+ clearedDevices: number()
17008
+ }), {
17009
+ kind: "mutation",
17010
+ auth: "admin"
17011
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
17012
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
17013
+ deviceKey: string(),
16970
17014
  /**
16971
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
16972
- * `zones` capability.
16973
- *
16974
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
16975
- * and no card can render — so every free-text search surface was structurally
16976
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
16977
- * just returned nothing. Resolving here rather than in each client keeps ONE
16978
- * derivation and costs the clients no extra call (the `zones` cap is
16979
- * per-device, so a client-side resolve would be a per-camera fan-out on a
16980
- * surface built to avoid exactly that).
16981
- *
16982
- * Resolved, never invented: a zone deleted since the track was written has no
16983
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
16984
- * two are not positionally aligned. Absent when the track visited no zone, or
16985
- * when the zone catalogue could not be read.
17015
+ * `failed` the per-device restart budget is exhausted; no pool
17016
+ * will be spawned until an operator re-arms it or the runner
17017
+ * respawns. `backoff` — under budget, waiting out the backoff (or
17018
+ * a cached pool observed dead and not yet condemned).
16986
17019
  */
16987
- zoneNames: array(string()).readonly().optional(),
16988
- /** Deduplicated set of detector classes observed for this track over its
16989
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
16990
- * legacy rows written before class accumulation shipped. */
16991
- classes: array(string()).readonly().optional(),
16992
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
16993
- totalDistance: number(),
16994
- state: TrackStateSchema,
16995
- active: boolean(),
16996
- /** Deterministic key-event importance score in [0,1] (server-computed at
16997
- * track expiry, recomputed on late label). Absent on legacy rows written
16998
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
16999
- importance: number().optional(),
17000
- /** Id of the track's highest-confidence ObjectEvent (its representative
17001
- * "best" frame). Absent when the track produced no object events. */
17002
- bestEventId: string().optional(),
17003
- /** Tag of the importance sub-signal that dominated the score
17004
- * (identity|dwell|proximity|class|confidence|travel|zone). */
17005
- importanceReason: string().optional(),
17006
- /** Audio-classification labels heard on the camera during the track's
17007
- * life (score ≥ device `classificationMinScore`), aggregated per label.
17008
- * Absent on legacy rows / tracks with no confident audio. */
17009
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17010
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17011
- * Populated from the persisted envelope columns on historical reads;
17012
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17013
- envelope: TrackEnvelopeSchema.optional(),
17020
+ state: _enum(["failed", "backoff"]),
17021
+ /** Epoch ms of the death that produced this state. */
17022
+ since: number(),
17023
+ /** Pool deaths inside the current window. */
17024
+ deaths: number(),
17025
+ /** The last death's message. */
17026
+ lastError: string()
17027
+ })).readonly() })), method(object({
17028
+ nodeId: string(),
17029
+ deviceKey: string()
17030
+ }), object({ rearmed: boolean() }), {
17031
+ kind: "mutation",
17032
+ auth: "admin"
17033
+ }), method(_void(), PipelineSchemaSchema), method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()), method(_void(), PipelineConfigBridge), method(_void(), ConfigUISchemaBridge), method(object({ steps: array(PipelineStepInputSchema) }), PipelineValidationResultSchema), method(_void(), array(PipelineTemplateSchema$1).readonly()), method(object({
17034
+ name: string(),
17035
+ steps: array(PipelineTemplateStepSchema).readonly(),
17036
+ engine: PipelineEngineChoiceSchema
17037
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
17038
+ id: string(),
17039
+ name: string().optional(),
17040
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
17041
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
17042
+ addonId: string(),
17043
+ modelId: string(),
17044
+ format: ModelFormatSchema$1
17045
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
17046
+ addonId: string(),
17047
+ modelId: string(),
17048
+ format: ModelFormatSchema$1
17049
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
17050
+ engine: PipelineEngineChoiceSchema.optional(),
17051
+ steps: array(PipelineStepInputSchema).min(1),
17052
+ frame: FrameInputSchema.optional(),
17014
17053
  /**
17015
- * A face DETECTOR found a face on this track — nothing more. It says the
17016
- * detail plane produced a `face` detail; it does NOT say the face was
17017
- * embedded, matched, above `minFacePx`, or that the recognizer was even
17018
- * enabled. Set once and never cleared.
17019
- *
17020
- * **This exists so "face present but not recognised" is expressible.** A
17021
- * recognised identity lands in `subLabel` (attributed to the face chain via
17022
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17023
- * and a track with no face at all were byte-identical on the wire and no
17024
- * surface could tell them apart. The read is `hasFace === true && subLabel
17025
- * === undefined`.
17026
- *
17027
- * **Absent ≠ false.** Every row written before the column existed omits it,
17028
- * and so does every server that predates the field — a consumer must test
17029
- * `=== true` and render nothing otherwise, never infer "no face".
17054
+ * Process-local lazy frame. Valid only when caller and provider resolve
17055
+ * in the same execution-group process; split/cross-node callers use
17056
+ * `frame`/`image` inline compatibility instead.
17030
17057
  */
17031
- hasFace: boolean().optional(),
17058
+ frameRef: FrameRefSchema.optional(),
17032
17059
  /**
17033
- * This track has a face row IN THE GALLERY: a crop **and** an embedding a
17034
- * face an operator could ASSIGN to an identity.
17035
- *
17036
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17037
- * because the two disagree. `hasFace` is stamped at the TOP of the face
17038
- * branch, before every gate, and means no more than "a face detector produced
17039
- * a face detail". This one is stamped at the single moment the gallery row
17040
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17041
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17042
- * candidate gate, the imageless-track drop (no crop was ever captured) and
17043
- * the crop-store drop. Everything between the detector and that insert can
17044
- * legitimately refuse the face, so a flag written any earlier promises the
17045
- * operator something to assign and delivers nothing.
17046
- *
17047
- * **Independent of recognition.** A face collected but never auto-matched is
17048
- * still assignable — it is in fact the face an operator most wants to reach —
17049
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17050
- * `subLabel`; this says only that the raw material exists.
17051
- *
17052
- * **Set once, never cleared.** A track that produced a gallery row produced
17053
- * one; deleting the row later is the gallery's business, not this flag's.
17054
- *
17055
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17056
- * before the column omits it, and so does every server that predates the
17057
- * field. A consumer must test `=== true` and render nothing otherwise —
17058
- * never infer "no assignable face".
17060
+ * CB5 shm passthrough a `FrameHandle` naming the same ring slot
17061
+ * the decoded pixels live in. One more member of the one-of
17062
+ * frame/frameHandle/image/imageBase64/referenceImage group.
17059
17063
  */
17060
- hasEmbeddedFace: boolean().optional(),
17064
+ frameHandle: FrameHandleSchema.optional(),
17065
+ imageBase64: string().optional(),
17061
17066
  /**
17062
- * This subject CONTAINS a folded rider a person the rider-pairing step
17063
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17064
- * so the passage is tracked once and as a VEHICLE.
17065
- *
17066
- * It exists because the fold's record was dishonest. D34 and the code both
17067
- * said "the person is not lost — it is reported so both entities stay on the
17068
- * record"; in fact the pair went into a per-processor RAM field behind an
17069
- * accessor nobody called, and every durable surface said `vehicle`, full
17070
- * stop. This is the composition note that makes the row true.
17071
- *
17072
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
17073
- * person" is not an answer to "what is this" — both label tiers would refuse
17074
- * a macro token anyway (D89), and correctly. Nothing here changes what the
17075
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17076
- * and a `person` rule still does not fire for someone cycling past.
17077
- *
17078
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17079
- * the column, and every hub that predates the field, omits it. Test
17080
- * `=== true` and render nothing otherwise — never infer "no rider".
17067
+ * Binary JPEG bytespreferred over `imageBase64` on internal
17068
+ * hops (hub forked worker via Moleculer MsgPack) because it
17069
+ * skips the 33% base64 overhead + the per-call base64 decode on
17070
+ * the detection-pipeline worker. Callers can pass either; exactly
17071
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
17081
17072
  */
17082
- hasRider: boolean().optional(),
17083
- ...TrackFlagFields,
17084
- ...TrackRetrainFields
17085
- });
17086
- var BaseEventFields = {
17087
- id: string(),
17088
- deviceId: number(),
17089
- timestamp: number()
17090
- };
17091
- var MotionEventSchema = object({
17092
- ...BaseEventFields,
17093
- kind: literal("motion"),
17094
- regionCount: number(),
17095
- /** Heavy JSON array omitted in slim projection. */
17096
- regions: array(object({
17097
- bbox: BoundingBoxSchema,
17098
- pixelCount: number(),
17099
- intensity: number()
17100
- })).readonly().optional(),
17101
- /** Omitted in slim projection. */
17102
- frameWidth: number().optional(),
17103
- /** Omitted in slim projection. */
17104
- frameHeight: number().optional(),
17105
- /** Populated by B5 (recording playback URL for this event). */
17106
- mediaUrl: string().optional()
17107
- });
17073
+ image: _instanceof(Uint8Array).optional(),
17074
+ referenceImage: string().optional(),
17075
+ deviceId: number().optional(),
17076
+ sessionId: string().optional(),
17077
+ /**
17078
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
17079
+ * reference-image, and detail-subtree calls. 'frame' is the live
17080
+ * per-frame dispatch: ONLY root-plane steps run; crop children
17081
+ * (inputClasses ≠ null) are skipped and served per-track via
17082
+ * pipelineRunner.runDetailSubtree (two-plane design).
17083
+ */
17084
+ plane: _enum(["full", "frame"]).optional(),
17085
+ /**
17086
+ * Inference-device selector (Phase 2 multi-device). Format
17087
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
17088
+ * Omitted ⇒ the runner's default device (current single-engine
17089
+ * behaviour). Selects WHICH device pool of the node runs the call.
17090
+ */
17091
+ deviceKey: string().optional(),
17092
+ /**
17093
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
17094
+ * when the parent crop was resolved from the frame's retained NATIVE
17095
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
17096
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
17097
+ * resolution from that surface — the SAME quality path faces already
17098
+ * had — instead of the downscaled parent tile. `handle` keys the native
17099
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
17100
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
17101
+ * the executor's crop-normalized child ROI back into frame-normalized
17102
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
17103
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
17104
+ * (today's behaviour on the fallback path).
17105
+ */
17106
+ nativeCropRef: NativeCropRefSchema.optional()
17107
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
17108
+ engine: PipelineEngineChoiceSchema.optional(),
17109
+ steps: array(PipelineStepInputSchema).min(1),
17110
+ frames: array(FrameInputSchema).min(1).max(255),
17111
+ deviceId: number().optional(),
17112
+ sessionId: string().optional(),
17113
+ /**
17114
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
17115
+ * the batch to the Python pool's bench preprocess cache
17116
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
17117
+ * preprocessed ONCE and every later inference is a pure-inference cache
17118
+ * hit — the sustained-throughput run measures inference, not
17119
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
17120
+ * full preprocess every call, correct). Fresh per sustained run;
17121
+ * released via `uncacheFrame`.
17122
+ */
17123
+ frameId: number().int().nonnegative().optional(),
17124
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
17125
+ deviceKey: string().optional()
17126
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
17127
+ data: _instanceof(Uint8Array),
17128
+ width: number().int().positive(),
17129
+ height: number().int().positive(),
17130
+ format: _enum([
17131
+ "rgb",
17132
+ "bgr",
17133
+ "gray"
17134
+ ])
17135
+ }), object({
17136
+ frameId: number(),
17137
+ width: number(),
17138
+ height: number()
17139
+ }), { kind: "mutation" }), method(object({
17140
+ stepId: string(),
17141
+ frameId: number().int()
17142
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
17143
+ batchMode: string(),
17144
+ windowMs: number(),
17145
+ maxBatchSize: number(),
17146
+ concurrency: number()
17147
+ })), method(_void(), array(object({
17148
+ engineKey: string(),
17149
+ engine: PipelineEngineChoiceSchema,
17150
+ modelsLoaded: array(string()).readonly(),
17151
+ inUseByCameras: array(number()).readonly(),
17152
+ /**
17153
+ * Origin of this resident factory.
17154
+ * - `runtime` — main camera-serving engine (no idle TTL).
17155
+ * - `warm-override` — benchmark/test override held in the warm
17156
+ * cache; auto-disposed after the idle TTL.
17157
+ * - `device-pool` — a concurrent per-device pool (Phase 2
17158
+ * multi-device, keyed by `deviceKey`) resolved
17159
+ * via `resolveDeviceFactory`. Runs alongside the
17160
+ * `runtime` engine on a DIFFERENT accelerator
17161
+ * (NPU / iGPU / Coral) — this is how the
17162
+ * Engines tab shows all pools running at once.
17163
+ */
17164
+ kind: _enum([
17165
+ "runtime",
17166
+ "warm-override",
17167
+ "device-pool"
17168
+ ]),
17169
+ /** Native pid of the underlying Python pool (null when no pool). */
17170
+ poolPid: number().nullable(),
17171
+ /** ms since this factory was last used (null when not warm-tracked). */
17172
+ idleMs: number().nullable(),
17173
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
17174
+ idleTtlMs: number().nullable()
17175
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
17176
+ kind: "mutation",
17177
+ auth: "admin"
17178
+ }), method(object({
17179
+ engine: PipelineEngineChoiceSchema,
17180
+ force: boolean().optional()
17181
+ }), object({
17182
+ success: boolean(),
17183
+ reason: string().optional()
17184
+ }), {
17185
+ kind: "mutation",
17186
+ auth: "admin"
17187
+ }), method(_void(), array(ReferenceImageEntrySchema).readonly()), method(object({ filename: string() }), ReferenceImageBodySchema.nullable()), method(_void(), array(ReferenceAudioEntrySchema).readonly()), method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()), method(_void(), AudioCapabilitiesSchema), method(object({
17188
+ addonId: string(),
17189
+ modelId: string(),
17190
+ filename: string().optional(),
17191
+ settings: record(string(), unknown()).optional()
17192
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
17108
17193
  /**
17109
- * Which detection SOURCE produced an object event. `pipeline` = the ML
17110
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
17111
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
17112
- * tracking, per-kind persistence) but stay distinguishable so consumers
17113
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17114
- * Absent on legacy rows treat as `pipeline`.
17194
+ * Per-stage gating mode applied to the zones a rule references.
17195
+ *
17196
+ * - `include`: the rule contributes to a **whitelist** for its stage.
17197
+ * When at least one `include` rule fires for a stage, only entities
17198
+ * inside one of those zones pass that stage.
17199
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
17200
+ * Entities inside one of those zones are dropped at that stage.
17201
+ *
17202
+ * `monitor`-style observation (count without filtering) is not a rule
17203
+ * mode — zones without any matching rule are observed naturally by
17204
+ * `zone-analytics` (live snapshot + history), so an "I just want to
17205
+ * count, not filter" use case needs no rule at all.
17115
17206
  */
17116
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17207
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
17117
17208
  /**
17118
- * The confirmed zone crossing that produced an object event. Present ONLY on
17119
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17120
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17121
- * appearance event carry none, so a rule asking for a direction fails closed
17122
- * on them.
17209
+ * Per-consumer rule that references existing zones (geometry) and
17210
+ * defines how a specific pipeline stage should treat them. Each
17211
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
17212
+ * settings:
17123
17213
  *
17124
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17125
- * into its own event, so a frame in which a track enters A while leaving B
17126
- * produces two events with two directions — never one ambiguous row.
17214
+ * - `addon-motion-wasm` `motionZoneRules: ZoneRule[]` (motion stage)
17215
+ * - `addon-detection-pipeline` `detectionZoneRules: ZoneRule[]` (detection stage)
17216
+ * - future: notification rules, audio gating, etc.
17127
17217
  *
17128
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17129
- * membership the box has NOW, and by definition it no longer contains the zone
17130
- * that was just left. Without the id here, a zone-scoped rule could never match
17131
- * the exit it asked for.
17218
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
17219
+ * express "ignore motion in ALL of {garden, street}" with a single
17220
+ * rule. `classFilter` narrows the rule to specific object classes
17221
+ * "drop person detections in the street, but keep cars" is one
17222
+ * `exclude` rule with `classFilter: ['person']`.
17223
+ *
17224
+ * `enabled` is a soft toggle — the operator can keep the rule
17225
+ * configured but inert without deleting it.
17132
17226
  */
17133
- var ZoneCrossingSchema = object({
17134
- direction: _enum(["enter", "exit"]),
17135
- /** Admin zone id crossed. */
17136
- zoneId: string(),
17137
- /** Zone display name at crossing time (falls back to the id). */
17138
- zoneName: string().optional()
17139
- });
17140
- var ObjectEventSchema = object({
17141
- ...BaseEventFields,
17142
- kind: literal("object"),
17143
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17144
- source: DetectionSourceSchema.optional(),
17145
- /**
17146
- * Inference-frame id shared by every object event emitted from the SAME frame
17147
- * the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17148
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
17149
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
17150
- * Optional for backward-compat with pre-existing rows / the slim projection
17151
- * includes it (it is light). Absent on rows written before this field.
17227
+ var ZoneRuleSchema = object({
17228
+ /** Stable rule id — survives edits, used by the UI for diffing. */
17229
+ id: string(),
17230
+ /** Optional human-readable label rendered in the rule editor. */
17231
+ name: string().optional(),
17232
+ /** Zones this rule targets. The rule's `mode` applies to ALL
17233
+ * listed zones (OR-set: a detection in any one of them counts).
17234
+ * At least one zone id required — a rule with no targets is a
17235
+ * configuration mistake and the form validator rejects it. */
17236
+ zoneIds: array(string()).min(1).readonly(),
17237
+ mode: ZoneRuleModeEnum,
17238
+ /**
17239
+ * Class names this rule applies to. Empty / undefined ⇒ rule
17240
+ * applies to every class. Class strings match the `macroClass`
17241
+ * field on detections (e.g. `person`, `car`, `dog`).
17152
17242
  */
17153
- frameId: string().optional(),
17154
- /** Omitted in slim projection. */
17155
- trackId: string().optional(),
17156
- className: string(),
17157
- ...TieredLabelFields,
17158
- /** Omitted in slim projection. */
17159
- confidence: number().optional(),
17160
- /** Heavy JSON — omitted in slim projection. */
17161
- bbox: BoundingBoxSchema.optional(),
17162
- /** Heavy JSON — omitted in slim projection. */
17163
- zones: array(string()).readonly().optional(),
17164
- /** Omitted in slim projection. */
17165
- state: TrackStateSchema.optional(),
17243
+ classFilter: array(string()).readonly().optional(),
17166
17244
  /**
17167
- * The zone crossing this event IS, when it is one. Absent on every other
17168
- * event kind (movement state, appearance, package) see
17169
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
17245
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
17246
+ * required to consider an entity "in the zone". Defaults to the
17247
+ * consumer's stage default when omitted. Kept for back-compat with
17248
+ * existing per-rule overrides; new operators pick the value via
17249
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
17250
+ * set, the lower-level engine reads it as a 0–1 fraction.
17170
17251
  */
17171
- zoneCrossing: ZoneCrossingSchema.optional(),
17172
- /** Detection-frame dimensions in pixels — let consumers normalize the
17173
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17174
- frameWidth: number().optional(),
17175
- frameHeight: number().optional(),
17176
- /** MediaStore key for the crop attached to this event (if any). */
17177
- mediaKey: string().optional(),
17178
- /** Design B: MediaStore key of the track's native-resolution key frame (the
17179
- * best-detection full frame). Resolve via the event-media data-plane
17180
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17181
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17182
- * sources — consumers fall back to `mediaKey` (the tight crop). */
17183
- keyFrameMediaKey: string().optional(),
17184
- /** Populated by B5 (recording playback URL for this event). */
17185
- mediaUrl: string().optional(),
17186
- /** The parent track's key-event importance [0,1], propagated to every object
17187
- * event of the track (so an event row can be sorted by importance without a
17188
- * track join). Absent on legacy rows / before the track was scored. */
17189
- importance: number().optional()
17190
- });
17191
- var AudioEventSchema = object({
17192
- ...BaseEventFields,
17193
- kind: literal("audio"),
17194
- rms: number(),
17195
- dbfs: number(),
17196
- classification: object({
17197
- className: string(),
17198
- originalClass: string().optional(),
17199
- score: number()
17200
- }).optional(),
17201
- /** Populated by B5 (recording playback URL for this event). */
17202
- mediaUrl: string().optional()
17203
- });
17204
- var MediaFileKindEnum = _enum([
17205
- "crop",
17206
- "thumbnail",
17207
- "snapshot",
17208
- "firstFrame",
17209
- "lastFrame",
17210
- "fullFrame",
17211
- "fullFrameBoxed",
17212
- "faceCrop",
17213
- "plateCrop",
17214
- "keyFrame",
17215
- "keyFrameSmall",
17216
- "thumbnailSmall"
17217
- ]);
17218
- var MediaFileSchema = object({
17219
- key: string(),
17220
- kind: MediaFileKindEnum,
17221
- base64: string(),
17222
- sizeBytes: number(),
17223
- timestamp: number()
17252
+ overlapThreshold: number().min(0).max(1).optional(),
17253
+ /**
17254
+ * Operator-friendly version of `overlapThreshold` the percentage
17255
+ * of the detection's bbox that must lie inside the zone for the
17256
+ * rule to match. Documented default is 85%; the engine substitutes
17257
+ * that when the field is omitted (kept optional so existing rules
17258
+ * stored without it stay valid).
17259
+ *
17260
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
17261
+ * rule, the engine prefers `bboxInclusionPct` because it's the
17262
+ * field exposed in the UI. Internally both feed the same gate.
17263
+ */
17264
+ bboxInclusionPct: number().min(0).max(100).optional(),
17265
+ /**
17266
+ * When `true` and a detection has a segmentation mask, use the
17267
+ * mask for overlap instead of the bbox. Detection-stage only;
17268
+ * motion rules ignore this field.
17269
+ */
17270
+ preferMask: boolean().optional(),
17271
+ /**
17272
+ * Soft-toggle: `false` disables the rule without deleting it.
17273
+ * Defaults to `true` so operators creating a rule via the UI
17274
+ * see it active immediately.
17275
+ */
17276
+ enabled: boolean().default(true)
17224
17277
  });
17278
+ array(ZoneRuleSchema).readonly();
17225
17279
  /**
17226
- * One media row WITHOUT its bytes.
17280
+ * Zone pure geometry + identity. NO filtering behaviour.
17227
17281
  *
17228
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17229
- * 140 s track), and a client that renders tiles from the media data plane needs
17230
- * to know only WHAT EXISTS the bytes then arrive per tile, lazily, over HTTP
17231
- * with an immutable cache, instead of all at once inside a tRPC response that
17232
- * blocks the whole view.
17282
+ * Zones describe **where** in the frame the operator wants to flag
17283
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
17284
+ * each pipeline stage uses them. Splitting the two means a single
17285
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
17286
+ * a detection-include rule on `['car']`, and an occupancy aggregate
17287
+ * — without three duplicated polygons.
17233
17288
  *
17234
- * `sizeBytes` is carried because it is what lets a client decide between the
17235
- * stored blob and a `?variant=thumb` rendering without fetching either.
17236
- */
17237
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17238
- /**
17239
- * The MACRO tier of an annotation — a CLOSED set.
17289
+ * Owned by the orchestrator addon (provider) and mirrored into the
17290
+ * `zones` device-state slice on every mutation. Consumers
17291
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
17292
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
17293
+ * mirror with `onChanged`).
17240
17294
  *
17241
- * This is what the exported detector predicts, so a typo here is a new class
17242
- * with one example in it. `label` and `subLabel` are open strings by contrast:
17243
- * the whole point of the page is teaching the model things it does not know
17244
- * yet, and constraining that vocabulary would make it useless.
17295
+ * Coordinates are normalised fractions of the frame (0–1) so zones
17296
+ * survive resolution changes and stream profile switches.
17245
17297
  *
17246
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
17247
- * `subLabel` is one of these values, in any casing, because once `person`
17248
- * exists in both tiers "every person box" stops being answerable without
17249
- * knowing every string anyone ever typedand the damage is retroactive.
17298
+ * `kind` discriminates between full polygons (closed regions used
17299
+ * for intrusion / occupancy filters) and tripwires (open 2-point
17300
+ * line segments used for cross events). Onboard / firmware-reported
17301
+ * zones (Reolink, ONVIF) are out of scope for now see the deferred
17302
+ * task list.
17250
17303
  */
17251
- var RetrainMacroClassSchema = _enum([
17252
- "person",
17253
- "vehicle",
17254
- "animal",
17255
- "package",
17256
- "face",
17257
- "plate"
17258
- ]);
17259
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17260
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17261
- /** Did a human draw this box, or did the assist propose it? */
17262
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17263
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17264
- var RetrainBboxSchema = object({
17304
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
17305
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
17306
+ var PolygonPointSchema = object({
17265
17307
  x: number(),
17266
- y: number(),
17267
- w: number(),
17268
- h: number()
17308
+ y: number()
17309
+ });
17310
+ /** A camera detection zone — pure geometry/identity. */
17311
+ var ZoneSchema = object({
17312
+ id: string(),
17313
+ name: string(),
17314
+ kind: ZoneKindEnum.default("polygon"),
17315
+ /** Polygon vertices, fraction of frame (0–1). */
17316
+ polygon: array(PolygonPointSchema).readonly(),
17317
+ /** Visual color for UI rendering. */
17318
+ color: string().default("#3b82f6")
17269
17319
  });
17270
17320
  /**
17271
- * One annotated subject.
17321
+ * Zones capability — per-camera CRUD over polygon detection zones.
17272
17322
  *
17273
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17274
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17275
- * derived from it at export and never stored storing them is how one feature
17276
- * space ends up holding two crops of the same subject (D52).
17323
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
17324
+ * to per-device settings and mirrors into the `zones` device-state
17325
+ * slice on every mutation, so downstream consumers can subscribe via
17326
+ * `dev.state.zones.onChanged`.
17327
+ *
17328
+ * The cap surface only handles geometry + identity; filtering
17329
+ * behaviour (per-class, include/exclude, threshold) lives in the
17330
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
17331
+ * `capabilities/schemas/zone-rule.js`.
17277
17332
  */
17278
- var RetrainAnnotationSchema = object({
17279
- id: string(),
17280
- trackId: string(),
17281
- deviceId: number(),
17282
- /** The COPY in retrain storage — never the source track's media key. */
17283
- mediaKey: string(),
17284
- bbox: RetrainBboxSchema,
17285
- macroClass: RetrainMacroClassSchema,
17286
- label: string().optional(),
17287
- subLabel: string().optional(),
17288
- kind: RetrainAnnotationKindSchema,
17289
- source: RetrainAnnotationSourceSchema,
17290
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17291
- assistModelId: string().optional(),
17292
- assistScore: number().optional(),
17293
- exportedInBatch: string().optional(),
17294
- createdAt: number()
17295
- });
17296
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17297
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17298
- id: true,
17299
- trackId: true,
17300
- deviceId: true,
17301
- mediaKey: true,
17302
- createdAt: true,
17303
- exportedInBatch: true
17304
- });
17305
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17306
- var RetrainTrackSchema = object({
17307
- trackId: string(),
17308
- deviceId: number(),
17309
- className: string(),
17310
- label: string().optional(),
17311
- firstSeen: number(),
17312
- lastSeen: number(),
17313
- /** How many frames the dataset already holds from this track. */
17314
- frameCount: number().int(),
17315
- /** How many subjects have been annotated on those frames. `0` with
17316
- * `frameCount: 0` is exactly "staging, still to work". */
17317
- annotationCount: number().int()
17318
- });
17319
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
17320
- var RetrainFrameCandidateSchema = object({
17321
- mediaKey: string(),
17322
- kind: MediaFileKindEnum,
17323
- timestamp: number(),
17324
- sizeBytes: number().int(),
17325
- /** A copy of this original already exists selecting it is free and cannot
17326
- * fail, whatever became of the original. */
17327
- copied: boolean()
17328
- });
17329
- /** A frame the dataset OWNS: bytes copied at selection time. */
17330
- var RetrainFrameSchema = object({
17331
- frameId: string(),
17332
- deviceId: number(),
17333
- trackId: string(),
17334
- /** Provenance only. It may already point at nothing that is expected. */
17335
- sourceMediaKey: string(),
17336
- sourceKind: MediaFileKindEnum,
17337
- sizeBytes: number().int(),
17338
- width: number().int(),
17339
- height: number().int(),
17340
- copiedAt: number()
17341
- });
17342
- /** Why a copy-on-select could not be honoured named, never a silent skip. */
17343
- var RetrainCopyRefusalSchema = _enum([
17344
- "source-missing",
17345
- "unreadable-image",
17346
- "write-failed"
17333
+ var zonesCapability = {
17334
+ name: "zones",
17335
+ scope: "device",
17336
+ mode: "singleton",
17337
+ deviceTypes: [DeviceType.Camera],
17338
+ methods: {
17339
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
17340
+ addZone: method(object({
17341
+ deviceId: number(),
17342
+ zone: ZoneSchema
17343
+ }), _void(), {
17344
+ kind: "mutation",
17345
+ auth: "admin"
17346
+ }),
17347
+ removeZone: method(object({
17348
+ deviceId: number(),
17349
+ zoneId: string()
17350
+ }), _void(), {
17351
+ kind: "mutation",
17352
+ auth: "admin"
17353
+ }),
17354
+ updateZone: method(object({
17355
+ deviceId: number(),
17356
+ zone: ZoneSchema
17357
+ }), _void(), {
17358
+ kind: "mutation",
17359
+ auth: "admin"
17360
+ })
17361
+ },
17362
+ /**
17363
+ * Runtime-state slice — the live zone catalogue mirrored by the
17364
+ * orchestrator on every CRUD mutation. Consumers read via
17365
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
17366
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
17367
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
17368
+ * (e.g. zone groupings) can sit alongside the polygon list.
17369
+ */
17370
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
17371
+ /**
17372
+ * Runtime-state durability: **restored** — written only on operator mutation, so a camera that never had one has nothing to re-derive from. This is the slice `zone-mirror-hydration.ts` exists to paper over.
17373
+ *
17374
+ * See `RuntimeStateDurability`. Enforced by
17375
+ * `scripts/check-runtime-state-durability.ts`.
17376
+ */
17377
+ durability: "restored"
17378
+ };
17379
+ /**
17380
+ * pipeline-analyticsdevice-scoped wrapper cap. Refines raw
17381
+ * per-frame detections emitted by the pipeline runner into tracked
17382
+ * objects, per-kind event collections (motion / object / audio), and
17383
+ * persisted media. Owns the post-detection domain end-to-end:
17384
+ *
17385
+ * runner emits PipelineInferenceResult
17386
+ * ↓ (event bus)
17387
+ * pipeline-analytics subscriber
17388
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
17389
+ * → three DB collections (one per kind), one FS media tree, one
17390
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
17391
+ * DetectionEvent on bus)
17392
+ *
17393
+ * Pure subscriber model. No `processFrame` cap method — the runner
17394
+ * already publishes the raw frame on the bus. The cap surface is
17395
+ * only QUERIES + per-device settings, bound on/off via
17396
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
17397
+ * every camera with a detection pipeline wants its raw detections
17398
+ * refined; operators opt out per-device via BindingsTab when needed.
17399
+ *
17400
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17401
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
17402
+ */
17403
+ var TrackStateSchema = _enum([
17404
+ "new",
17405
+ "entered",
17406
+ "left",
17407
+ "moving",
17408
+ "idle"
17409
+ ]);
17410
+ var EventKindSchema = _enum([
17411
+ "motion",
17412
+ "object",
17413
+ "audio"
17347
17414
  ]);
17348
- var RetrainFrameSelectionSchema = object({
17349
- copied: array(RetrainFrameSchema).readonly(),
17350
- refused: array(object({
17351
- sourceMediaKey: string(),
17352
- reason: RetrainCopyRefusalSchema
17353
- })).readonly()
17354
- });
17355
- var RetrainFrameListSchema = object({
17356
- candidates: array(RetrainFrameCandidateSchema).readonly(),
17357
- copies: array(RetrainFrameSchema).readonly(),
17358
- /** What the page pre-selects — the native key frame when one survives. */
17359
- autoPickMediaKey: string().optional()
17360
- });
17361
- /** What the operator asked the assist to look for. */
17362
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17363
- kind: literal("package"),
17364
- zone: RetrainBboxSchema.optional()
17365
- }), object({
17366
- kind: literal("objects"),
17367
- modelId: string(),
17368
- minScore: number().optional()
17369
- })]);
17370
17415
  /**
17371
- * The assist's answera discriminated union, because "the model saw nothing"
17372
- * and "this node cannot run that model" lead to different next moves and a
17373
- * nullable result cannot tell them apart.
17416
+ * Spatial filter for `listTracks` the rect + polygon variants of the shared
17417
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17418
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
17374
17419
  */
17375
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17376
- kind: literal("proposed"),
17377
- modelId: string(),
17378
- stepId: string(),
17379
- minScore: number(),
17380
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17381
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
17382
- /** Returned by the runner but removed by the threshold. */
17383
- belowThreshold: number().int()
17384
- }), object({
17385
- kind: literal("refused"),
17386
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17387
- reason: string(),
17388
- detail: string().optional()
17389
- })]);
17390
- /** The outcome of a lifecycle move owned by the retrain page. */
17391
- var RetrainTransitionResultSchema = object({
17392
- trackId: string(),
17393
- /** Where the track ended up, whatever happened. */
17394
- retrainStatus: RetrainStatusSchema,
17395
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17396
- changed: boolean(),
17397
- reason: _enum([
17398
- "unknown-track",
17399
- "no-frames-copied",
17400
- "not-staging",
17401
- "not-trained",
17402
- "unchanged"
17403
- ]).optional()
17420
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17421
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
17422
+ var EventKindIconSchema = _enum([
17423
+ "motion",
17424
+ "audio",
17425
+ "person",
17426
+ "vehicle",
17427
+ "animal",
17428
+ "door",
17429
+ "pir",
17430
+ "smoke",
17431
+ "water",
17432
+ "button",
17433
+ "package",
17434
+ "generic"
17435
+ ]);
17436
+ var EventKindCategorySchema = _enum([
17437
+ "motion",
17438
+ "audio",
17439
+ "detection",
17440
+ "sensor",
17441
+ "control",
17442
+ "custom",
17443
+ "package"
17444
+ ]);
17445
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17446
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
17447
+ var EventKindDescriptorSchema = object({
17448
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17449
+ kind: string(),
17450
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
17451
+ labelKey: string(),
17452
+ /** English fallback label (kept for clients that don't translate). */
17453
+ label: string(),
17454
+ /** Hex color for timeline/legend rendering. */
17455
+ color: string(),
17456
+ /** Dictionary id → lucide component on the UI side. */
17457
+ iconId: string(),
17458
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
17459
+ icon: EventKindIconSchema,
17460
+ category: EventKindCategorySchema,
17461
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17462
+ parentKind: string().nullable(),
17463
+ /** Derived from `parentKind`, explicit for the client tree. */
17464
+ level: EventKindLevelSchema,
17465
+ /** Which cap + device contributes this kind. For built-ins the camera
17466
+ * itself; for sensor kinds the LINKED source device. */
17467
+ source: object({
17468
+ capName: string(),
17469
+ deviceId: number()
17470
+ })
17404
17471
  });
17405
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17406
- var MAX_EVENT_QUERY_LIMIT = 5e3;
17407
- var DeviceEventQueryInput = object({
17472
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17473
+ var EventKindsForDeviceSchema = object({
17408
17474
  deviceId: number(),
17409
- since: number().optional(),
17410
- until: number().optional(),
17411
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17412
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17413
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17414
- * exact behaviour. Callers may omit this field — the store defaults to
17415
- * `full` when not provided. */
17416
- projection: _enum(["full", "slim"]).optional()
17417
- });
17418
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17419
- var RecentTracksQueryInput = object({
17420
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17421
- deviceIds: array(number()),
17422
- /** Window lower bound on `lastSeen` (inclusive). */
17423
- since: number().optional(),
17424
- /** Window upper bound on `lastSeen` (inclusive). */
17425
- until: number().optional(),
17426
- /** Page size. Default 200, max 1000. */
17427
- limit: number().int().min(1).max(1e3).default(200),
17428
- /** Opaque continuation cursor from a previous page's `nextCursor`.
17429
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17430
- cursor: string().optional(),
17431
- /** See {@link TrackProjectionSchema}. Default `full`. */
17432
- projection: TrackProjectionSchema.optional(),
17433
- /** Include stationary-promoted rows (parked objects). Default false: the
17434
- * feed lists passages; parking records live on the stationary registry. */
17435
- includeStationary: boolean().optional()
17436
- });
17437
- var RecentTracksPageSchema = object({
17438
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17439
- tracks: array(TrackSchema).readonly(),
17440
- /** Cursor for the next page, or null when this page is the last. */
17441
- nextCursor: string().nullable()
17475
+ kinds: array(EventKindDescriptorSchema).readonly()
17442
17476
  });
17443
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
17444
- var LIST_GROUPS_MAX_LIMIT = 100;
17445
- var AnalyticsGroupRecordSchema = object({
17477
+ var SensorEventSchema = object({
17446
17478
  id: string(),
17447
- deviceId: number().int(),
17448
- openedAt: number().int(),
17449
- closedAt: number().int(),
17450
- timestamp: number().int(),
17451
- memberCount: number().int(),
17452
- memberTrackIds: array(string()).readonly(),
17453
- className: string(),
17454
- classes: array(string()).readonly(),
17455
- /** Relative event-media path, or null when the group has no picture yet. */
17456
- mediaUrl: string().nullable(),
17457
- singleton: boolean()
17458
- });
17459
- var AnalyticsGroupMemberSchema = object({
17460
- trackId: string(),
17461
- deviceId: number().int(),
17462
- className: string(),
17463
- firstSeen: number().int(),
17464
- lastSeen: number().int(),
17465
- mediaUrl: string().nullable()
17466
- });
17467
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17468
- var ListGroupsQueryInput = object({
17469
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17470
- deviceIds: array(number()),
17471
- /** Window lower bound on `closedAt` (inclusive). */
17472
- since: number().optional(),
17473
- /** Window upper bound on `openedAt` (inclusive). */
17474
- until: number().optional(),
17475
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17476
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
17477
- cursor: string().optional()
17478
- });
17479
- var ListGroupsPageSchema = object({
17480
- groups: array(AnalyticsGroupRecordSchema).readonly(),
17481
- nextCursor: string().nullable()
17482
- });
17483
- var KeyEventQueryInput = object({
17479
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
17480
+ * yields N rows, one per camera). */
17484
17481
  deviceId: number(),
17485
- /** Window lower bound (track firstSeen since). */
17486
- since: number(),
17487
- /** Window upper bound (track firstSeen until). */
17488
- until: number(),
17489
- limit: number().int().min(1).max(200).default(50),
17490
- /** Drop tracks scoring below this importance. */
17491
- minImportance: number().min(0).max(1).optional(),
17492
- /** Restrict to a single class (e.g. 'person'). */
17493
- classFilter: string().optional()
17482
+ /** The linked sensor device whose state changed. */
17483
+ sourceDeviceId: number(),
17484
+ /** Event kind id matches an `EventKindDescriptor.kind`. */
17485
+ kind: string(),
17486
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
17487
+ value: record(string(), unknown()).nullable(),
17488
+ timestamp: number()
17494
17489
  });
17495
- var KeyEventSchema = object({
17496
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
17497
- id: string(),
17498
- trackId: string(),
17499
- /** Track start time (firstSeen). */
17490
+ var TrackPositionSchema = object({
17491
+ x: number(),
17492
+ y: number(),
17500
17493
  timestamp: number(),
17501
- className: string(),
17502
- ...TieredLabelFields,
17503
- importance: number(),
17504
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
17505
- bestEventId: string(),
17506
- /** Track lifetime in ms (lastSeen - firstSeen). */
17507
- windowMs: number().optional(),
17508
- ...TrackFlagFields,
17509
- ...TrackRetrainFields
17510
- });
17511
- object({
17512
- trackId: string(),
17513
- className: string(),
17514
- confidence: number(),
17515
- bbox: BoundingBoxSchema,
17516
- zones: array(string()).readonly(),
17517
- state: TrackStateSchema
17518
- });
17519
- var OverlayDetectionSchema = looseObject({
17520
- id: string(),
17521
- kind: _enum(["first-level", "detail"]),
17522
- macroClass: string(),
17523
- score: number(),
17524
- bbox: object({
17525
- x: number(),
17526
- y: number(),
17527
- width: number(),
17528
- height: number()
17529
- }),
17530
- labels: array(looseObject({
17531
- label: string(),
17532
- score: number()
17533
- })).readonly(),
17534
- parentId: string().optional()
17535
- });
17536
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
17537
- var SearchObjectEventsInput = object({
17538
- text: string(),
17539
- deviceId: number().optional(),
17540
- since: number().optional(),
17541
- until: number().optional(),
17542
- classFilter: string().optional(),
17543
- limit: number().default(50),
17544
- minScore: number().min(0).max(1).default(.2)
17545
- });
17546
- var TrackCascadeCountsSchema = object({
17547
- /** Persisted track roots deleted (authoritative). */
17548
- tracks: number().int(),
17549
- /** Object events removed with their tracks (best-effort; see note above). */
17550
- events: number().int(),
17551
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17552
- media: number().int(),
17553
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
17554
- faces: number().int(),
17555
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17556
- plates: number().int(),
17557
- /** Per-track CLIP search vectors removed (best-effort). */
17558
- embeddings: number().int(),
17559
- /** Group membership + group rows removed with their last member (best-effort). */
17560
- groups: number().int()
17561
- });
17562
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17563
- var DiskReconcileCountsSchema = object({
17564
- mediaDropped: number().int(),
17565
- tracks: number().int(),
17566
- events: number().int()
17567
- });
17568
- /** Event-store footprint for one camera. */
17569
- var EventStoreDeviceFootprintSchema = object({
17570
- deviceId: number(),
17571
- /** Persisted event rows (motion + object + audio) for the camera. */
17572
- rows: number().int(),
17573
- /** Event-owned media bytes on disk for the camera. */
17574
- bytes: number().int()
17494
+ bbox: BoundingBoxSchema
17575
17495
  });
17576
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
17577
- var EventStoreFootprintSchema = object({
17578
- totalRows: number().int(),
17579
- totalBytes: number().int(),
17580
- devices: array(EventStoreDeviceFootprintSchema).readonly()
17496
+ var TrackSnapshotSchema = object({
17497
+ timestamp: number(),
17498
+ position: TrackPositionSchema,
17499
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17500
+ mediaKey: string()
17581
17501
  });
17582
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
17583
- var EventPruneCountsSchema = object({
17584
- motion: number().int(),
17585
- object: number().int(),
17586
- audio: number().int()
17502
+ /**
17503
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17504
+ * divided by the track's detection-frame dims), computed at persist time.
17505
+ * Absent when the frame dims were unknown when the track was persisted
17506
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17507
+ */
17508
+ var TrackEnvelopeSchema = object({
17509
+ minX: number(),
17510
+ minY: number(),
17511
+ maxX: number(),
17512
+ maxY: number()
17587
17513
  });
17588
17514
  /**
17589
- * Re-embed stored tracks from their key frames.
17590
- *
17591
- * The reason this is an operator-callable method and not a migration script:
17592
- * every knob that decides what a vector MEANS — encoder model, crop margin,
17593
- * squaring is only changeable if the existing vectors can be regenerated.
17594
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
17595
- * symptom is a quality regression with no visible cause.
17515
+ * Row projection for track list queries. `full` (default) returns the
17516
+ * complete Track including the frame-rate `positions[]` history and the
17517
+ * `snapshots[]` references megabytes across a page of tracks. `slim`
17518
+ * keeps every scalar the list surfaces actually render (ids, class(es),
17519
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17520
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17521
+ * `snapshots` as EMPTY arrays detail views re-fetch the full row via
17522
+ * `getTrack`. Mirrors the event-store `projection` convention
17523
+ * (`getObjectEvents` et al.).
17596
17524
  */
17597
- var RebuildObjectEmbeddingsInput = object({
17598
- /** Restrict to one camera. Omit for the whole fleet. */
17599
- deviceId: number().optional(),
17600
- since: number().optional(),
17601
- until: number().optional(),
17602
- /** Stop after this many tracks; the result reports whether more remain. */
17603
- maxTracks: number().int().positive().optional(),
17604
- /**
17605
- * Run every embedding on THIS node instead of round-robining the fleet.
17606
- *
17607
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
17608
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
17609
- * calling it that would pin the rebuild REQUEST itself to that node — the
17610
- * rebuild orchestration lives on the hub, and only the per-track step runs
17611
- * remotely. This field is data; the per-track pin is applied inside.
17612
- *
17613
- * Absent ⇒ round-robin over every online node whose runner can serve the
17614
- * pinned model.
17615
- */
17616
- executeOnNodeId: string().optional(),
17617
- /**
17618
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
17619
- * run flat out.
17620
- *
17621
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
17622
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
17623
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
17624
- * force is logged at start and finish so a deliberately slow pass reads
17625
- * differently from a stalled one.
17626
- */
17627
- pacingMs: number().int().nonnegative().optional()
17525
+ var TrackProjectionSchema = _enum(["full", "slim"]);
17526
+ /**
17527
+ * One audio-classification label heard on the track's camera while the
17528
+ * track was alive, aggregated per label. An "episode" is one persisted
17529
+ * audio event (the confident-classification path: score ≥ the device's
17530
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) NOT
17531
+ * one 32 ms inference chunk, so counts stay human-scaled.
17532
+ */
17533
+ var TrackAudioLabelSchema = object({
17534
+ label: string(),
17535
+ /** Highest classification score observed across the label's episodes. */
17536
+ peakScore: number(),
17537
+ /** Number of coalesced audio-event episodes carrying this label. */
17538
+ count: number(),
17539
+ firstAt: number(),
17540
+ lastAt: number()
17628
17541
  });
17629
17542
  /**
17630
- * Result of emptying the CLIP index.
17543
+ * How a track was produced. `pipeline` (default / absent) = the spatial
17544
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17545
+ * no positions, a single snapshot, and no bbox trajectory at all:
17631
17546
  *
17632
- * The clean slate before a policy change: a new crop margin or encoder model
17633
- * leaves two feature spaces in one index whose cosine scores are not
17634
- * comparable, so wiping and rebuilding is the only way to be sure every vector
17635
- * means the same thing.
17547
+ * - `sensor` a linked sensor/control device state change.
17548
+ * - `audio` an audio event on the camera itself that was anomalous for
17549
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
17550
+ *
17551
+ * The spatial subsystems (tracker association, occupancy count, re-id /
17552
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
17553
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17554
+ * check silently readmits every source added after it was written.
17636
17555
  */
17637
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
17556
+ var TrackSourceSchema = _enum([
17557
+ "pipeline",
17558
+ "sensor",
17559
+ "audio"
17560
+ ]);
17638
17561
  /**
17639
- * Acknowledgement that a rebuild STARTED.
17562
+ * Where a track sits in the RETRAIN lifecycle (D81).
17640
17563
  *
17641
- * The pass costs ~1s per track 45 minutes for a 2,600-track fleet — so it
17642
- * runs detached and this returns immediately. Waiting for it made the client
17643
- * time out while the work carried on server-side, which is the worst of both:
17644
- * no result and no way to know it was still going. Poll
17645
- * `getObjectEmbeddingRebuildStatus` for progress.
17646
- */
17647
- var RebuildObjectEmbeddingsResultSchema = object({
17648
- started: boolean(),
17649
- /** True when a pass was already running; the new request is ignored. */
17650
- alreadyRunning: boolean()
17651
- });
17652
- var RebuildStatusSchema = object({
17653
- running: boolean(),
17654
- scanned: number(),
17655
- rebuilt: number(),
17656
- /** Tracks whose key frame is gone — nothing to re-embed from. */
17657
- missingKeyFrame: number(),
17658
- /** Tracks with no usable detection box. */
17659
- missingBbox: number(),
17660
- /**
17661
- * Tracks an executing node REFUSED rather than broke on — an unreadable key
17662
- * frame, a step that threw. Separate from `failed` because the remedy is
17663
- * different, and because a whole camera silently contributing zero vectors
17664
- * is the shape of failure a rebuild must never hide.
17665
- */
17666
- notRunnable: number(),
17564
+ * - `none`never marked, or un-marked. Evictable.
17565
+ * - `staging` the operator wants this track as training material and has not
17566
+ * finished with it. **This is the only state retention holds**: the track and
17567
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
17568
+ * the device's age window.
17569
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
17570
+ * were COPIED into the retrain dataset at selection time, so the dataset no
17571
+ * longer depends on the track's media and the track becomes EVICTABLE again.
17572
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17573
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
17574
+ *
17575
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17576
+ * the store's filter language has only positive equality and `whereIn` — no
17577
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17578
+ * would make the entire pre-column history immortal in one deploy.
17579
+ */
17580
+ var RetrainStatusSchema = _enum([
17581
+ "none",
17582
+ "staging",
17583
+ "trained"
17584
+ ]);
17585
+ /**
17586
+ * Per-track OPERATOR flags set by hand from the admin UI or the viewer, never
17587
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17588
+ * so the two surfaces cannot drift.
17589
+ *
17590
+ * **Absent ≠ false.** A track that has never been touched omits the field; an
17591
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
17592
+ * columns existed read as absent, and a consumer that needs a boolean should say
17593
+ * `flag === true`, not `flag !== false`.
17594
+ *
17595
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17596
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17597
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17598
+ * `trained` track reports `false` while refusing both writes. The boolean is
17599
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
17600
+ * "never marked" from "already trained" must read `retrainStatus`.
17601
+ *
17602
+ * `debug` does NOT pin; it is attention, not durability.
17603
+ *
17604
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17605
+ * A favourited track is skipped by retention the same way `staging` is, but
17606
+ * it does not enter `none|staging|trained` and has no staging budget.
17607
+ */
17608
+ var TrackFlagFields = {
17609
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
17610
+ * `'staging'`. */
17611
+ markForTrain: boolean().optional(),
17612
+ /** Operator marked this track for diagnostic attention. */
17613
+ debug: boolean().optional(),
17614
+ /** Operator favourited this track. Pins it against pruning. */
17615
+ favourited: boolean().optional()
17616
+ };
17617
+ /**
17618
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17619
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17620
+ * write patch, and the status is not something the toggle sets — it is what the
17621
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17622
+ * always present on a persisted row (the column default materialises `'none'`).
17623
+ */
17624
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17625
+ /**
17626
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17627
+ * one flag can never clear the other — the toggles are independent and are
17628
+ * driven from three surfaces that do not know about each other.
17629
+ */
17630
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
17631
+ /**
17632
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
17633
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
17634
+ * mutation result without a re-fetch.
17635
+ */
17636
+ var TrackFlagsSchema = object({
17637
+ trackId: string(),
17638
+ markForTrain: boolean(),
17639
+ debug: boolean(),
17640
+ favourited: boolean(),
17641
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
17642
+ * a track row) because this shape is only ever produced by the write body,
17643
+ * which always knows it — and a surface that has just written needs to render
17644
+ * `trained` without a re-fetch. */
17645
+ retrainStatus: RetrainStatusSchema
17646
+ });
17647
+ union([literal(1), literal(2)]);
17648
+ /**
17649
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
17650
+ * the step and model that produced it — which is what makes the write rule
17651
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17652
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17653
+ *
17654
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17655
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17656
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
17657
+ * that value has no provenance, and the write rule lets ANY properly-attributed
17658
+ * write of the same tier replace it regardless of score.
17659
+ */
17660
+ var LabelAttributionSchema = object({
17661
+ stepId: string(),
17662
+ modelId: string().optional(),
17663
+ decidedAt: number(),
17667
17664
  /**
17668
- * The pass stopped because NO node could serve the pinned model.
17665
+ * The GALLERY id behind a recognised tier-2 label a face-gallery
17666
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17669
17667
  *
17670
- * Distinct from `notRunnable` on purpose: that one says "this track was
17671
- * refused", this one says "the cluster cannot do this work at all" — every
17672
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
17673
- * pinned model for its engine format, or dropped out. The remedy is a model /
17674
- * engine change, not a per-camera one. Non-zero here always comes with
17675
- * `complete: false`.
17668
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
17669
+ * notification rule authored on "Gianluca" stopped matching the moment the
17670
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
17671
+ * the thing that does not move, so it is what a rule matches on
17672
+ * (`NcConditions.identities`) and the text is what a human is shown.
17673
+ *
17674
+ * Absent when the label names no gallery row — a plate the OCR read but no
17675
+ * vehicle claims, a sub-class, a species, any tier-1 value.
17676
17676
  */
17677
- noCapableNode: number(),
17678
- failed: number(),
17679
- /** Set once a pass ends: true only when EVERYTHING was covered. */
17680
- complete: boolean().nullable(),
17681
- startedAtMs: number().nullable(),
17682
- finishedAtMs: number().nullable(),
17683
- /** Present when the pass ended by throwing. */
17684
- error: string().nullable()
17677
+ identityId: string().optional()
17685
17678
  });
17686
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
17687
- deviceId: number(),
17688
- trackId: string()
17689
- }), TrackSchema.nullable()), method(object({
17690
- deviceId: number(),
17691
- since: number().optional(),
17692
- until: number().optional(),
17693
- limit: number().optional(),
17694
- /** Spatial filter — only tracks whose trajectory intersects the zone
17695
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
17696
- * envelope columns, then precisely tested per position. Tracks with
17697
- * an unknown envelope (no frame dims at persist time) always match. */
17698
- zone: TrackZoneFilterSchema.optional(),
17699
- /** See {@link TrackProjectionSchema}. Default `full` (backward
17700
- * compatible omitting the field keeps today's exact behaviour). */
17701
- projection: TrackProjectionSchema.optional(),
17702
- /** Include stationary-promoted rows (parked objects handed to the
17703
- * stationary registry). Default false: the timeline lists passages,
17704
- * not parking records (operator decision, 2026-08-15). */
17705
- includeStationary: boolean().optional()
17706
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
17707
- deviceId: number(),
17708
- groupId: string().min(1)
17709
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
17710
- kind: "mutation",
17711
- auth: "admin"
17712
- }), 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({
17713
- deviceId: number(),
17714
- since: number().optional(),
17715
- until: number().optional(),
17716
- kinds: array(string()).optional(),
17717
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
17718
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
17719
- deviceId: number(),
17720
- since: number(),
17721
- until: number(),
17722
- bucketMs: number().int().positive()
17723
- }), array(object({
17724
- bucketStart: number(),
17725
- motion: number().int(),
17726
- object: number().int(),
17727
- audio: number().int()
17728
- })).readonly()), method(object({
17679
+ /**
17680
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17681
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17682
+ * track and its events always answer the same question the same way.
17683
+ *
17684
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
17685
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17686
+ * is tier 2, and each carries its own score + attribution.
17687
+ *
17688
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17689
+ * finest thing known. Before 4g the single `label` column held the finest
17690
+ * value, so a consumer that has not been updated reads the tier-1 slot and
17691
+ * shows nothing on a species-only row; that is why the migration puts every
17692
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17693
+ * and why the read surfaces were changed in the same train.
17694
+ *
17695
+ * **Writing it.** The slots are independent, which is the whole point: a
17696
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17697
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
17698
+ * higher score wins. One rule, one implementation — see
17699
+ * `pipeline/label-tier.ts` in addon-post-analysis.
17700
+ */
17701
+ var TieredLabelFields = {
17702
+ /** Tier 1 the sub-class. See {@link LabelTierSchema}. */
17703
+ label: string().optional(),
17704
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
17705
+ labelScore: number().optional(),
17706
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17707
+ labelMeta: LabelAttributionSchema.optional(),
17708
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17709
+ subLabel: string().optional(),
17710
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
17711
+ subLabelScore: number().optional(),
17712
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17713
+ subLabelMeta: LabelAttributionSchema.optional()
17714
+ };
17715
+ /** Per-camera slice of a training-export estimate. */
17716
+ var TrainingExportDeviceTotalsSchema = object({
17729
17717
  deviceId: number(),
17730
- cutoffMs: number()
17731
- }), object({
17732
- motion: number().int(),
17733
- object: number().int(),
17734
- audio: number().int()
17735
- }), {
17736
- kind: "mutation",
17737
- auth: "admin"
17738
- }), method(object({
17718
+ tracks: number().int(),
17719
+ files: number().int(),
17720
+ bytes: number().int()
17721
+ });
17722
+ /**
17723
+ * What a training export WOULD contain. Computed from media index rows only —
17724
+ * no blob is read to produce this.
17725
+ */
17726
+ var TrainingExportSummarySchema = object({
17727
+ generatedAt: number(),
17728
+ trackCount: number().int(),
17729
+ fileCount: number().int(),
17730
+ byteCount: number().int(),
17731
+ /** More marked tracks exist than a single pass carries. */
17732
+ truncated: boolean(),
17733
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
17734
+ });
17735
+ var TrackSchema = object({
17736
+ trackId: string(),
17739
17737
  deviceId: number(),
17740
- cutoffMs: number()
17741
- }), TrackCascadeCountsSchema, {
17742
- kind: "mutation",
17743
- auth: "admin"
17744
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17745
- kind: "mutation",
17746
- auth: "admin"
17747
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17748
- kind: "mutation",
17749
- auth: "admin"
17750
- }), method(object({
17751
- deviceId: number(),
17752
- trackIds: array(string()).min(1)
17753
- }), object({
17754
- deleted: number().int(),
17755
- failed: array(string()).readonly()
17756
- }), {
17757
- kind: "mutation",
17758
- auth: "admin"
17759
- }), method(object({
17760
- /** Log/audit scope only the trackId is globally unique on its own. */
17761
- deviceId: number(),
17762
- trackId: string(),
17763
- flags: TrackFlagsPatchSchema
17764
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
17765
- kind: "query",
17766
- auth: "admin"
17767
- }), method(object({
17768
- olderThanMs: number(),
17769
- reason: OpsLogReasonSchema.optional()
17770
- }), EventPruneCountsSchema, {
17771
- kind: "mutation",
17772
- auth: "admin"
17773
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
17774
- kind: "mutation",
17775
- auth: "admin"
17776
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
17777
- kind: "mutation",
17778
- auth: "admin"
17779
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
17780
- kind: "mutation",
17781
- auth: "admin"
17782
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
17783
- kind: "mutation",
17784
- auth: "admin"
17785
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
17786
- kind: "mutation",
17787
- auth: "admin"
17788
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
17789
- kind: "mutation",
17790
- auth: "admin"
17791
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
17792
- kind: "query",
17793
- auth: "admin"
17794
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
17795
- kind: "query",
17796
- auth: "admin"
17797
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17798
- kind: "query",
17799
- auth: "admin"
17800
- }), method(object({
17801
- /** Empty every camera that has staging tracks. A LIST, not a single
17802
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
17803
- * route it at one camera's owner, and "every camera" would stop being
17804
- * expressible at all. */
17805
- deviceIds: array(number()).optional(),
17806
- limit: number().int().min(1).max(500).optional()
17807
- }), array(RetrainTrackSchema).readonly(), {
17808
- kind: "query",
17809
- auth: "admin"
17810
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
17811
- kind: "query",
17812
- auth: "admin"
17813
- }), method(object({
17814
- deviceId: number(),
17815
- trackId: string(),
17816
- mediaKeys: array(string()).min(1)
17817
- }), RetrainFrameSelectionSchema, {
17818
- kind: "mutation",
17819
- auth: "admin"
17820
- }), method(object({
17738
+ className: string(),
17739
+ ...TieredLabelFields,
17740
+ producingDeviceName: string().optional(),
17741
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
17742
+ source: TrackSourceSchema.optional(),
17743
+ firstSeen: number(),
17744
+ lastSeen: number(),
17745
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
17746
+ positions: array(TrackPositionSchema).readonly(),
17747
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17748
+ * saveThumbnails policy). */
17749
+ snapshots: array(TrackSnapshotSchema).readonly(),
17750
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
17751
+ zonesVisited: array(string()).readonly(),
17752
+ /**
17753
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17754
+ * `zones` capability.
17755
+ *
17756
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17757
+ * and no card can render — so every free-text search surface was structurally
17758
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17759
+ * just returned nothing. Resolving here rather than in each client keeps ONE
17760
+ * derivation and costs the clients no extra call (the `zones` cap is
17761
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
17762
+ * surface built to avoid exactly that).
17763
+ *
17764
+ * Resolved, never invented: a zone deleted since the track was written has no
17765
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17766
+ * two are not positionally aligned. Absent when the track visited no zone, or
17767
+ * when the zone catalogue could not be read.
17768
+ */
17769
+ zoneNames: array(string()).readonly().optional(),
17770
+ /** Deduplicated set of detector classes observed for this track over its
17771
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
17772
+ * legacy rows written before class accumulation shipped. */
17773
+ classes: array(string()).readonly().optional(),
17774
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17775
+ totalDistance: number(),
17776
+ state: TrackStateSchema,
17777
+ active: boolean(),
17778
+ /** Deterministic key-event importance score in [0,1] (server-computed at
17779
+ * track expiry, recomputed on late label). Absent on legacy rows written
17780
+ * before scoring shipped consumers degrade to absence / compute-on-read. */
17781
+ importance: number().optional(),
17782
+ /** Id of the track's highest-confidence ObjectEvent (its representative
17783
+ * "best" frame). Absent when the track produced no object events. */
17784
+ bestEventId: string().optional(),
17785
+ /** Tag of the importance sub-signal that dominated the score
17786
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
17787
+ importanceReason: string().optional(),
17788
+ /** Audio-classification labels heard on the camera during the track's
17789
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
17790
+ * Absent on legacy rows / tracks with no confident audio. */
17791
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17792
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17793
+ * Populated from the persisted envelope columns on historical reads;
17794
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17795
+ envelope: TrackEnvelopeSchema.optional(),
17796
+ /**
17797
+ * A face DETECTOR found a face on this track — nothing more. It says the
17798
+ * detail plane produced a `face` detail; it does NOT say the face was
17799
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
17800
+ * enabled. Set once and never cleared.
17801
+ *
17802
+ * **This exists so "face present but not recognised" is expressible.** A
17803
+ * recognised identity lands in `subLabel` (attributed to the face chain via
17804
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17805
+ * and a track with no face at all were byte-identical on the wire and no
17806
+ * surface could tell them apart. The read is `hasFace === true && subLabel
17807
+ * === undefined`.
17808
+ *
17809
+ * **Absent ≠ false.** Every row written before the column existed omits it,
17810
+ * and so does every server that predates the field — a consumer must test
17811
+ * `=== true` and render nothing otherwise, never infer "no face".
17812
+ */
17813
+ hasFace: boolean().optional(),
17814
+ /**
17815
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
17816
+ * face an operator could ASSIGN to an identity.
17817
+ *
17818
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17819
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
17820
+ * branch, before every gate, and means no more than "a face detector produced
17821
+ * a face detail". This one is stamped at the single moment the gallery row
17822
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17823
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17824
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
17825
+ * the crop-store drop. Everything between the detector and that insert can
17826
+ * legitimately refuse the face, so a flag written any earlier promises the
17827
+ * operator something to assign and delivers nothing.
17828
+ *
17829
+ * **Independent of recognition.** A face collected but never auto-matched is
17830
+ * still assignable — it is in fact the face an operator most wants to reach —
17831
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17832
+ * `subLabel`; this says only that the raw material exists.
17833
+ *
17834
+ * **Set once, never cleared.** A track that produced a gallery row produced
17835
+ * one; deleting the row later is the gallery's business, not this flag's.
17836
+ *
17837
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17838
+ * before the column omits it, and so does every server that predates the
17839
+ * field. A consumer must test `=== true` and render nothing otherwise —
17840
+ * never infer "no assignable face".
17841
+ */
17842
+ hasEmbeddedFace: boolean().optional(),
17843
+ /**
17844
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
17845
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17846
+ * so the passage is tracked once and as a VEHICLE.
17847
+ *
17848
+ * It exists because the fold's record was dishonest. D34 and the code both
17849
+ * said "the person is not lost — it is reported so both entities stay on the
17850
+ * record"; in fact the pair went into a per-processor RAM field behind an
17851
+ * accessor nobody called, and every durable surface said `vehicle`, full
17852
+ * stop. This is the composition note that makes the row true.
17853
+ *
17854
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
17855
+ * person" is not an answer to "what is this" — both label tiers would refuse
17856
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
17857
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17858
+ * and a `person` rule still does not fire for someone cycling past.
17859
+ *
17860
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17861
+ * the column, and every hub that predates the field, omits it. Test
17862
+ * `=== true` and render nothing otherwise — never infer "no rider".
17863
+ */
17864
+ hasRider: boolean().optional(),
17865
+ ...TrackFlagFields,
17866
+ ...TrackRetrainFields
17867
+ });
17868
+ var BaseEventFields = {
17869
+ id: string(),
17821
17870
  deviceId: number(),
17822
- trackId: string(),
17823
- frameId: string()
17824
- }), object({
17825
- removed: boolean(),
17826
- removedAnnotations: number().int()
17827
- }), {
17828
- kind: "mutation",
17829
- auth: "admin"
17830
- }), method(object({ frameId: string() }), object({
17871
+ timestamp: number()
17872
+ };
17873
+ var MotionEventSchema = object({
17874
+ ...BaseEventFields,
17875
+ kind: literal("motion"),
17876
+ regionCount: number(),
17877
+ /** Heavy JSON array — omitted in slim projection. */
17878
+ regions: array(object({
17879
+ bbox: BoundingBoxSchema,
17880
+ pixelCount: number(),
17881
+ intensity: number()
17882
+ })).readonly().optional(),
17883
+ /** Omitted in slim projection. */
17884
+ frameWidth: number().optional(),
17885
+ /** Omitted in slim projection. */
17886
+ frameHeight: number().optional(),
17887
+ /** Populated by B5 (recording playback URL for this event). */
17888
+ mediaUrl: string().optional()
17889
+ });
17890
+ /**
17891
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
17892
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
17893
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
17894
+ * tracking, per-kind persistence) but stay distinguishable so consumers
17895
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17896
+ * Absent on legacy rows ⇒ treat as `pipeline`.
17897
+ */
17898
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17899
+ /**
17900
+ * The confirmed zone crossing that produced an object event. Present ONLY on
17901
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17902
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17903
+ * appearance event carry none, so a rule asking for a direction fails closed
17904
+ * on them.
17905
+ *
17906
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17907
+ * into its own event, so a frame in which a track enters A while leaving B
17908
+ * produces two events with two directions — never one ambiguous row.
17909
+ *
17910
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17911
+ * membership the box has NOW, and by definition it no longer contains the zone
17912
+ * that was just left. Without the id here, a zone-scoped rule could never match
17913
+ * the exit it asked for.
17914
+ */
17915
+ var ZoneCrossingSchema = object({
17916
+ direction: _enum(["enter", "exit"]),
17917
+ /** Admin zone id crossed. */
17918
+ zoneId: string(),
17919
+ /** Zone display name at crossing time (falls back to the id). */
17920
+ zoneName: string().optional()
17921
+ });
17922
+ var ObjectEventSchema = object({
17923
+ ...BaseEventFields,
17924
+ kind: literal("object"),
17925
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17926
+ source: DetectionSourceSchema.optional(),
17927
+ /**
17928
+ * Inference-frame id shared by every object event emitted from the SAME frame
17929
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17930
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
17931
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
17932
+ * Optional for backward-compat with pre-existing rows / the slim projection
17933
+ * includes it (it is light). Absent on rows written before this field.
17934
+ */
17935
+ frameId: string().optional(),
17936
+ /** Omitted in slim projection. */
17937
+ trackId: string().optional(),
17938
+ className: string(),
17939
+ ...TieredLabelFields,
17940
+ /** Omitted in slim projection. */
17941
+ confidence: number().optional(),
17942
+ /** Heavy JSON — omitted in slim projection. */
17943
+ bbox: BoundingBoxSchema.optional(),
17944
+ /** Heavy JSON — omitted in slim projection. */
17945
+ zones: array(string()).readonly().optional(),
17946
+ /** Omitted in slim projection. */
17947
+ state: TrackStateSchema.optional(),
17948
+ /**
17949
+ * The zone crossing this event IS, when it is one. Absent on every other
17950
+ * event kind (movement state, appearance, package) — see
17951
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
17952
+ */
17953
+ zoneCrossing: ZoneCrossingSchema.optional(),
17954
+ /** Detection-frame dimensions in pixels — let consumers normalize the
17955
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17956
+ frameWidth: number().optional(),
17957
+ frameHeight: number().optional(),
17958
+ /** MediaStore key for the crop attached to this event (if any). */
17959
+ mediaKey: string().optional(),
17960
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
17961
+ * best-detection full frame). Resolve via the event-media data-plane
17962
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17963
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17964
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
17965
+ keyFrameMediaKey: string().optional(),
17966
+ /** Populated by B5 (recording playback URL for this event). */
17967
+ mediaUrl: string().optional(),
17968
+ /** The parent track's key-event importance [0,1], propagated to every object
17969
+ * event of the track (so an event row can be sorted by importance without a
17970
+ * track join). Absent on legacy rows / before the track was scored. */
17971
+ importance: number().optional()
17972
+ });
17973
+ var AudioEventSchema = object({
17974
+ ...BaseEventFields,
17975
+ kind: literal("audio"),
17976
+ rms: number(),
17977
+ dbfs: number(),
17978
+ classification: object({
17979
+ className: string(),
17980
+ originalClass: string().optional(),
17981
+ score: number()
17982
+ }).optional(),
17983
+ /** Populated by B5 (recording playback URL for this event). */
17984
+ mediaUrl: string().optional()
17985
+ });
17986
+ var MediaFileKindEnum = _enum([
17987
+ "crop",
17988
+ "thumbnail",
17989
+ "snapshot",
17990
+ "firstFrame",
17991
+ "lastFrame",
17992
+ "fullFrame",
17993
+ "fullFrameBoxed",
17994
+ "faceCrop",
17995
+ "plateCrop",
17996
+ "keyFrame",
17997
+ "keyFrameSmall",
17998
+ "thumbnailSmall"
17999
+ ]);
18000
+ var MediaFileSchema = object({
18001
+ key: string(),
18002
+ kind: MediaFileKindEnum,
17831
18003
  base64: string(),
17832
- width: number().int(),
17833
- height: number().int()
17834
- }), {
17835
- kind: "query",
17836
- auth: "admin"
17837
- }), method(object({
17838
- deviceId: number(),
17839
- trackId: string(),
17840
- frameId: string(),
17841
- subject: RetrainAssistSubjectSchema,
17842
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
17843
- nodeId: string().optional()
17844
- }), RetrainAssistResultSchema, {
17845
- kind: "mutation",
17846
- auth: "admin"
17847
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
17848
- kind: "query",
17849
- auth: "admin"
17850
- }), method(object({
17851
- deviceId: number(),
18004
+ sizeBytes: number(),
18005
+ timestamp: number()
18006
+ });
18007
+ /**
18008
+ * One media row WITHOUT its bytes.
18009
+ *
18010
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
18011
+ * 140 s track), and a client that renders tiles from the media data plane needs
18012
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
18013
+ * with an immutable cache, instead of all at once inside a tRPC response that
18014
+ * blocks the whole view.
18015
+ *
18016
+ * `sizeBytes` is carried because it is what lets a client decide between the
18017
+ * stored blob and a `?variant=thumb` rendering without fetching either.
18018
+ */
18019
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
18020
+ /**
18021
+ * The MACRO tier of an annotation — a CLOSED set.
18022
+ *
18023
+ * This is what the exported detector predicts, so a typo here is a new class
18024
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
18025
+ * the whole point of the page is teaching the model things it does not know
18026
+ * yet, and constraining that vocabulary would make it useless.
18027
+ *
18028
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
18029
+ * `subLabel` is one of these values, in any casing, because once `person`
18030
+ * exists in both tiers "every person box" stops being answerable without
18031
+ * knowing every string anyone ever typed — and the damage is retroactive.
18032
+ */
18033
+ var RetrainMacroClassSchema = _enum([
18034
+ "person",
18035
+ "vehicle",
18036
+ "animal",
18037
+ "package",
18038
+ "face",
18039
+ "plate"
18040
+ ]);
18041
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
18042
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
18043
+ /** Did a human draw this box, or did the assist propose it? */
18044
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
18045
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
18046
+ var RetrainBboxSchema = object({
18047
+ x: number(),
18048
+ y: number(),
18049
+ w: number(),
18050
+ h: number()
18051
+ });
18052
+ /**
18053
+ * One annotated subject.
18054
+ *
18055
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
18056
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
18057
+ * derived from it at export and never stored — storing them is how one feature
18058
+ * space ends up holding two crops of the same subject (D52).
18059
+ */
18060
+ var RetrainAnnotationSchema = object({
18061
+ id: string(),
17852
18062
  trackId: string(),
17853
- frameId: string(),
17854
- annotations: array(RetrainAnnotationDraftSchema)
17855
- }), array(RetrainAnnotationSchema).readonly(), {
17856
- kind: "mutation",
17857
- auth: "admin"
17858
- }), method(object({
17859
- deviceId: number(),
17860
- trackId: string()
17861
- }), RetrainTransitionResultSchema, {
17862
- kind: "mutation",
17863
- auth: "admin"
17864
- }), method(object({
17865
18063
  deviceId: number(),
17866
- trackId: string()
17867
- }), RetrainTransitionResultSchema, {
17868
- kind: "mutation",
17869
- auth: "admin"
17870
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17871
- kind: "query",
17872
- auth: "admin"
17873
- }), method(object({
17874
- eventId: string(),
17875
- kind: MediaFileKindEnum.optional(),
17876
- deviceId: number()
17877
- }), array(MediaFileSchema).readonly()), method(object({
17878
- trackId: string(),
17879
- kinds: array(MediaFileKindEnum).optional(),
17880
- deviceId: number()
17881
- }), array(MediaFileSchema).readonly()), method(object({
18064
+ /** The COPY in retrain storage — never the source track's media key. */
18065
+ mediaKey: string(),
18066
+ bbox: RetrainBboxSchema,
18067
+ macroClass: RetrainMacroClassSchema,
18068
+ label: string().optional(),
18069
+ subLabel: string().optional(),
18070
+ kind: RetrainAnnotationKindSchema,
18071
+ source: RetrainAnnotationSourceSchema,
18072
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
18073
+ assistModelId: string().optional(),
18074
+ assistScore: number().optional(),
18075
+ exportedInBatch: string().optional(),
18076
+ createdAt: number()
18077
+ });
18078
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
18079
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
18080
+ id: true,
18081
+ trackId: true,
18082
+ deviceId: true,
18083
+ mediaKey: true,
18084
+ createdAt: true,
18085
+ exportedInBatch: true
18086
+ });
18087
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
18088
+ var RetrainTrackSchema = object({
17882
18089
  trackId: string(),
17883
- deviceId: number()
17884
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
17885
- kind: "mutation",
17886
- auth: "admin"
17887
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
17888
- kind: "mutation",
17889
- auth: "admin"
17890
- }), method(object({}), RebuildStatusSchema), object({
17891
18090
  deviceId: number(),
18091
+ className: string(),
18092
+ label: string().optional(),
18093
+ firstSeen: number(),
18094
+ lastSeen: number(),
18095
+ /** How many frames the dataset already holds from this track. */
18096
+ frameCount: number().int(),
18097
+ /** How many subjects have been annotated on those frames. `0` with
18098
+ * `frameCount: 0` is exactly "staging, still to work". */
18099
+ annotationCount: number().int()
18100
+ });
18101
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
18102
+ var RetrainFrameCandidateSchema = object({
18103
+ mediaKey: string(),
18104
+ kind: MediaFileKindEnum,
17892
18105
  timestamp: number(),
17893
- frameWidth: number(),
17894
- frameHeight: number(),
17895
- detections: array(OverlayDetectionSchema).readonly()
17896
- }), object({
18106
+ sizeBytes: number().int(),
18107
+ /** A copy of this original already exists — selecting it is free and cannot
18108
+ * fail, whatever became of the original. */
18109
+ copied: boolean()
18110
+ });
18111
+ /** A frame the dataset OWNS: bytes copied at selection time. */
18112
+ var RetrainFrameSchema = object({
18113
+ frameId: string(),
17897
18114
  deviceId: number(),
17898
18115
  trackId: string(),
17899
- className: string()
18116
+ /** Provenance only. It may already point at nothing — that is expected. */
18117
+ sourceMediaKey: string(),
18118
+ sourceKind: MediaFileKindEnum,
18119
+ sizeBytes: number().int(),
18120
+ width: number().int(),
18121
+ height: number().int(),
18122
+ copiedAt: number()
18123
+ });
18124
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
18125
+ var RetrainCopyRefusalSchema = _enum([
18126
+ "source-missing",
18127
+ "unreadable-image",
18128
+ "write-failed"
18129
+ ]);
18130
+ var RetrainFrameSelectionSchema = object({
18131
+ copied: array(RetrainFrameSchema).readonly(),
18132
+ refused: array(object({
18133
+ sourceMediaKey: string(),
18134
+ reason: RetrainCopyRefusalSchema
18135
+ })).readonly()
18136
+ });
18137
+ var RetrainFrameListSchema = object({
18138
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
18139
+ copies: array(RetrainFrameSchema).readonly(),
18140
+ /** What the page pre-selects — the native key frame when one survives. */
18141
+ autoPickMediaKey: string().optional()
18142
+ });
18143
+ /** What the operator asked the assist to look for. */
18144
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
18145
+ kind: literal("package"),
18146
+ zone: RetrainBboxSchema.optional()
17900
18147
  }), object({
17901
- deviceId: number(),
17902
- trackId: string(),
17903
- className: string(),
17904
- durationMs: number()
18148
+ kind: literal("objects"),
18149
+ modelId: string(),
18150
+ minScore: number().optional()
18151
+ })]);
18152
+ /**
18153
+ * The assist's answer — a discriminated union, because "the model saw nothing"
18154
+ * and "this node cannot run that model" lead to different next moves and a
18155
+ * nullable result cannot tell them apart.
18156
+ */
18157
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
18158
+ kind: literal("proposed"),
18159
+ modelId: string(),
18160
+ stepId: string(),
18161
+ minScore: number(),
18162
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
18163
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
18164
+ /** Returned by the runner but removed by the threshold. */
18165
+ belowThreshold: number().int()
17905
18166
  }), object({
18167
+ kind: literal("refused"),
18168
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
18169
+ reason: string(),
18170
+ detail: string().optional()
18171
+ })]);
18172
+ /** The outcome of a lifecycle move owned by the retrain page. */
18173
+ var RetrainTransitionResultSchema = object({
18174
+ trackId: string(),
18175
+ /** Where the track ended up, whatever happened. */
18176
+ retrainStatus: RetrainStatusSchema,
18177
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
18178
+ changed: boolean(),
18179
+ reason: _enum([
18180
+ "unknown-track",
18181
+ "no-frames-copied",
18182
+ "not-staging",
18183
+ "not-trained",
18184
+ "unchanged"
18185
+ ]).optional()
18186
+ });
18187
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
18188
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
18189
+ var DeviceEventQueryInput = object({
17906
18190
  deviceId: number(),
17907
- kind: EventKindSchema,
17908
- eventId: string(),
17909
- timestamp: number()
18191
+ since: number().optional(),
18192
+ until: number().optional(),
18193
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
18194
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
18195
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
18196
+ * exact behaviour. Callers may omit this field — the store defaults to
18197
+ * `full` when not provided. */
18198
+ projection: _enum(["full", "slim"]).optional()
17910
18199
  });
17911
- /**
17912
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
17913
- * within the frame, so the executor can re-cut a leaf child ROI at native
17914
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
17915
- */
17916
- var NativeCropRefSchema = object({
17917
- /** Handle keying the retained native surface (node-pinned to its owner). */
17918
- handle: FrameHandleSchema,
17919
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
17920
- cropFrameSpace: object({
17921
- x: number(),
17922
- y: number(),
17923
- w: number(),
17924
- h: number()
17925
- })
18200
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
18201
+ var RecentTracksQueryInput = object({
18202
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
18203
+ deviceIds: array(number()),
18204
+ /** Window lower bound on `lastSeen` (inclusive). */
18205
+ since: number().optional(),
18206
+ /** Window upper bound on `lastSeen` (inclusive). */
18207
+ until: number().optional(),
18208
+ /** Page size. Default 200, max 1000. */
18209
+ limit: number().int().min(1).max(1e3).default(200),
18210
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
18211
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
18212
+ cursor: string().optional(),
18213
+ /** See {@link TrackProjectionSchema}. Default `full`. */
18214
+ projection: TrackProjectionSchema.optional(),
18215
+ /** Include stationary-promoted rows (parked objects). Default false: the
18216
+ * feed lists passages; parking records live on the stationary registry. */
18217
+ includeStationary: boolean().optional()
17926
18218
  });
17927
- object({
17928
- crop: object({
17929
- left: number(),
17930
- top: number(),
17931
- width: number().positive(),
17932
- height: number().positive()
17933
- }).optional(),
17934
- content: object({
17935
- width: number().int().positive(),
17936
- height: number().int().positive()
17937
- }),
17938
- fit: _enum(["stretch", "contain"]),
17939
- format: _enum([
17940
- "rgb",
17941
- "gray",
17942
- "jpeg"
17943
- ])
18219
+ var RecentTracksPageSchema = object({
18220
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
18221
+ tracks: array(TrackSchema).readonly(),
18222
+ /** Cursor for the next page, or null when this page is the last. */
18223
+ nextCursor: string().nullable()
17944
18224
  });
17945
- var FrameRefSchema = object({
17946
- registryId: string().min(1),
17947
- id: string().min(1),
17948
- width: number().int().positive(),
17949
- height: number().int().positive(),
17950
- format: _enum(["rgb", "gray"]),
17951
- timestamp: number(),
17952
- capturedAt: number().optional()
18225
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
18226
+ var LIST_GROUPS_MAX_LIMIT = 100;
18227
+ var AnalyticsGroupRecordSchema = object({
18228
+ id: string(),
18229
+ deviceId: number().int(),
18230
+ openedAt: number().int(),
18231
+ closedAt: number().int(),
18232
+ timestamp: number().int(),
18233
+ memberCount: number().int(),
18234
+ memberTrackIds: array(string()).readonly(),
18235
+ className: string(),
18236
+ classes: array(string()).readonly(),
18237
+ /** Relative event-media path, or null when the group has no picture yet. */
18238
+ mediaUrl: string().nullable(),
18239
+ singleton: boolean()
17953
18240
  });
17954
- var ModelFormatSchema$1 = _enum([
17955
- "onnx",
17956
- "coreml",
17957
- "openvino",
17958
- "tflite",
17959
- "pt",
17960
- "gguf"
17961
- ]);
17962
- var PipelineSlotSchema = _enum([
17963
- "detector",
17964
- "cropper",
17965
- "classifier",
17966
- "refiner",
17967
- "audio-classifier"
17968
- ]);
17969
- var PipelineEngineChoiceSchema = object({
17970
- runtime: _enum(["node", "python"]),
17971
- backend: string(),
17972
- format: ModelFormatSchema$1,
17973
- device: string().optional()
18241
+ var AnalyticsGroupMemberSchema = object({
18242
+ trackId: string(),
18243
+ deviceId: number().int(),
18244
+ className: string(),
18245
+ firstSeen: number().int(),
18246
+ lastSeen: number().int(),
18247
+ mediaUrl: string().nullable()
17974
18248
  });
17975
- var AvailableEngineSchema = object({
17976
- engine: PipelineEngineChoiceSchema,
17977
- devices: array(object({
17978
- id: string(),
17979
- label: string(),
17980
- description: string().optional()
17981
- })).readonly(),
17982
- defaultDevice: string()
18249
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
18250
+ var ListGroupsQueryInput = object({
18251
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
18252
+ deviceIds: array(number()),
18253
+ /** Window lower bound on `closedAt` (inclusive). */
18254
+ since: number().optional(),
18255
+ /** Window upper bound on `openedAt` (inclusive). */
18256
+ until: number().optional(),
18257
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
18258
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
18259
+ cursor: string().optional()
17983
18260
  });
17984
- var PipelineDefaultStepSchema = lazy(() => object({
17985
- addonId: string(),
17986
- addonName: string(),
17987
- slot: PipelineSlotSchema,
17988
- inputClasses: array(string()).readonly(),
17989
- outputClasses: array(string()).readonly(),
17990
- enabled: boolean(),
17991
- modelId: string(),
17992
- children: array(PipelineDefaultStepSchema).readonly(),
17993
- group: string().optional(),
17994
- settings: record(string(), unknown()).optional()
17995
- }));
17996
- var PipelineTemplateStepSchema = lazy(() => object({
17997
- addonId: string(),
17998
- enabled: boolean(),
17999
- modelId: string(),
18000
- children: array(PipelineTemplateStepSchema).readonly(),
18001
- settings: record(string(), unknown()).optional()
18002
- }));
18003
- var PipelineTemplateSchema$1 = object({
18004
- id: string(),
18005
- name: string(),
18006
- createdAt: string(),
18007
- updatedAt: string(),
18008
- engine: PipelineEngineChoiceSchema,
18009
- steps: array(PipelineTemplateStepSchema).readonly()
18261
+ var ListGroupsPageSchema = object({
18262
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
18263
+ nextCursor: string().nullable()
18264
+ });
18265
+ var KeyEventQueryInput = object({
18266
+ deviceId: number(),
18267
+ /** Window lower bound (track firstSeen ≥ since). */
18268
+ since: number(),
18269
+ /** Window upper bound (track firstSeen ≤ until). */
18270
+ until: number(),
18271
+ limit: number().int().min(1).max(200).default(50),
18272
+ /** Drop tracks scoring below this importance. */
18273
+ minImportance: number().min(0).max(1).optional(),
18274
+ /** Restrict to a single class (e.g. 'person'). */
18275
+ classFilter: string().optional()
18010
18276
  });
18011
- var PipelineModelOptionSchema = object({
18277
+ var KeyEventSchema = object({
18278
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
18012
18279
  id: string(),
18013
- name: string(),
18014
- formats: record(string(), object({
18015
- downloaded: boolean(),
18016
- sizeMB: number()
18017
- })),
18018
- group: ModelVariantGroupSchema.optional(),
18019
- legacy: boolean().optional(),
18020
- provider: ModelProviderIdSchema.optional()
18280
+ trackId: string(),
18281
+ /** Track start time (firstSeen). */
18282
+ timestamp: number(),
18283
+ className: string(),
18284
+ ...TieredLabelFields,
18285
+ importance: number(),
18286
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
18287
+ bestEventId: string(),
18288
+ /** Track lifetime in ms (lastSeen - firstSeen). */
18289
+ windowMs: number().optional(),
18290
+ ...TrackFlagFields,
18291
+ ...TrackRetrainFields
18021
18292
  });
18022
- var ConfigFieldBridge = custom();
18023
- var PipelineAddonSchemaSchema = object({
18024
- id: string(),
18025
- name: string(),
18026
- slot: PipelineSlotSchema,
18027
- inputClasses: array(string()).readonly(),
18028
- outputClasses: array(string()).readonly(),
18029
- childSlots: array(PipelineSlotSchema).readonly(),
18030
- models: array(PipelineModelOptionSchema).readonly(),
18031
- defaultModelId: string(),
18032
- defaultModelIdByFormat: record(string(), string()).optional(),
18033
- enabledByDefault: boolean().optional(),
18034
- backfillIntoExistingOverrides: boolean().optional(),
18035
- defaultConfidence: number(),
18036
- group: string().optional(),
18037
- configSchema: array(ConfigFieldBridge).readonly().optional()
18293
+ object({
18294
+ trackId: string(),
18295
+ className: string(),
18296
+ confidence: number(),
18297
+ bbox: BoundingBoxSchema,
18298
+ zones: array(string()).readonly(),
18299
+ state: TrackStateSchema
18038
18300
  });
18039
- var PipelineSlotSchemaSchema = object({
18040
- id: PipelineSlotSchema,
18041
- label: string(),
18042
- priority: number(),
18043
- parentSlot: PipelineSlotSchema.nullable(),
18044
- addons: array(PipelineAddonSchemaSchema).readonly()
18301
+ var OverlayDetectionSchema = looseObject({
18302
+ id: string(),
18303
+ kind: _enum(["first-level", "detail"]),
18304
+ macroClass: string(),
18305
+ score: number(),
18306
+ bbox: object({
18307
+ x: number(),
18308
+ y: number(),
18309
+ width: number(),
18310
+ height: number()
18311
+ }),
18312
+ labels: array(looseObject({
18313
+ label: string(),
18314
+ score: number()
18315
+ })).readonly(),
18316
+ parentId: string().optional()
18045
18317
  });
18046
- var PipelineSchemaSchema = object({
18047
- availableEngines: array(AvailableEngineSchema).readonly(),
18048
- selectedEngine: PipelineEngineChoiceSchema,
18049
- slots: array(PipelineSlotSchemaSchema).readonly()
18318
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
18319
+ var SearchObjectEventsInput = object({
18320
+ text: string(),
18321
+ deviceId: number().optional(),
18322
+ since: number().optional(),
18323
+ until: number().optional(),
18324
+ classFilter: string().optional(),
18325
+ limit: number().default(50),
18326
+ minScore: number().min(0).max(1).default(.2)
18050
18327
  });
18051
- var EngineProvisioningSchema = object({
18052
- runtimeId: _enum([
18053
- "onnx",
18054
- "openvino",
18055
- "coreml",
18056
- "edgetpu"
18057
- ]).nullable(),
18058
- device: string().nullable(),
18059
- state: _enum([
18060
- "idle",
18061
- "installing",
18062
- "verifying",
18063
- "ready",
18064
- "failed"
18065
- ]),
18066
- progress: number().optional(),
18067
- error: string().optional(),
18068
- nextRetryAt: number().optional(),
18069
- /**
18070
- * Gate A (config-correctness gate at engine change): human-readable
18071
- * config issues surfaced EAGERLY when the node's engine changes — model
18072
- * substitutions ("chose X, running Y") and zero-build steps ("no model
18073
- * has a <format> build"). Additive/optional: informational only, never
18074
- * enforced here — `assertEngineReady` (readiness) still gates inference.
18075
- * Absent/empty when the node-default tree resolves cleanly.
18076
- */
18077
- configIssues: array(string()).optional()
18328
+ var TrackCascadeCountsSchema = object({
18329
+ /** Persisted track roots deleted (authoritative). */
18330
+ tracks: number().int(),
18331
+ /** Object events removed with their tracks (best-effort; see note above). */
18332
+ events: number().int(),
18333
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18334
+ media: number().int(),
18335
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
18336
+ faces: number().int(),
18337
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18338
+ plates: number().int(),
18339
+ /** Per-track CLIP search vectors removed (best-effort). */
18340
+ embeddings: number().int(),
18341
+ /** Group membership + group rows removed with their last member (best-effort). */
18342
+ groups: number().int()
18078
18343
  });
18079
- var PipelineStepInputSchema = lazy(() => object({
18080
- addonId: string(),
18081
- modelId: string().optional(),
18082
- enabled: boolean().default(true),
18083
- children: array(PipelineStepInputSchema).optional(),
18084
- settings: record(string(), unknown()).optional(),
18085
- jumpDeviceKey: string().optional()
18086
- }));
18087
- var ModelSubstitutionSchema = object({
18088
- addonId: string(),
18089
- chosen: string(),
18090
- running: string(),
18091
- format: string()
18344
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18345
+ var DiskReconcileCountsSchema = object({
18346
+ mediaDropped: number().int(),
18347
+ tracks: number().int(),
18348
+ events: number().int()
18092
18349
  });
18093
- var PipelineValidationIssueSchema = object({
18094
- addonId: string(),
18095
- kind: _enum(["unknown-addon", "no-format-build"]),
18096
- detail: string()
18350
+ /** Event-store footprint for one camera. */
18351
+ var EventStoreDeviceFootprintSchema = object({
18352
+ deviceId: number(),
18353
+ /** Persisted event rows (motion + object + audio) for the camera. */
18354
+ rows: number().int(),
18355
+ /** Event-owned media bytes on disk for the camera. */
18356
+ bytes: number().int()
18097
18357
  });
18098
- var PipelineValidationResultSchema = object({
18099
- ok: boolean(),
18100
- issues: array(PipelineValidationIssueSchema).readonly(),
18101
- substitutions: array(ModelSubstitutionSchema).readonly(),
18102
- /** The node's `currentEngine.format` this validation ran against. */
18103
- format: string()
18358
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18359
+ var EventStoreFootprintSchema = object({
18360
+ totalRows: number().int(),
18361
+ totalBytes: number().int(),
18362
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
18104
18363
  });
18105
- var ReferenceImageEntrySchema = object({
18106
- filename: string(),
18107
- stepIds: array(string()).readonly().optional()
18364
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
18365
+ var EventPruneCountsSchema = object({
18366
+ motion: number().int(),
18367
+ object: number().int(),
18368
+ audio: number().int()
18108
18369
  });
18109
- var ReferenceImageBodySchema = object({
18110
- base64: string(),
18111
- filename: string()
18370
+ /**
18371
+ * Re-embed stored tracks from their key frames.
18372
+ *
18373
+ * The reason this is an operator-callable method and not a migration script:
18374
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
18375
+ * squaring — is only changeable if the existing vectors can be regenerated.
18376
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
18377
+ * symptom is a quality regression with no visible cause.
18378
+ */
18379
+ var RebuildObjectEmbeddingsInput = object({
18380
+ /** Restrict to one camera. Omit for the whole fleet. */
18381
+ deviceId: number().optional(),
18382
+ since: number().optional(),
18383
+ until: number().optional(),
18384
+ /** Stop after this many tracks; the result reports whether more remain. */
18385
+ maxTracks: number().int().positive().optional(),
18386
+ /**
18387
+ * Run every embedding on THIS node instead of round-robining the fleet.
18388
+ *
18389
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18390
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18391
+ * calling it that would pin the rebuild REQUEST itself to that node — the
18392
+ * rebuild orchestration lives on the hub, and only the per-track step runs
18393
+ * remotely. This field is data; the per-track pin is applied inside.
18394
+ *
18395
+ * Absent ⇒ round-robin over every online node whose runner can serve the
18396
+ * pinned model.
18397
+ */
18398
+ executeOnNodeId: string().optional(),
18399
+ /**
18400
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18401
+ * run flat out.
18402
+ *
18403
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
18404
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18405
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18406
+ * force is logged at start and finish so a deliberately slow pass reads
18407
+ * differently from a stalled one.
18408
+ */
18409
+ pacingMs: number().int().nonnegative().optional()
18112
18410
  });
18113
- var ReferenceAudioEntrySchema = object({
18114
- filename: string(),
18115
- sizeKb: number()
18411
+ /**
18412
+ * Result of emptying the CLIP index.
18413
+ *
18414
+ * The clean slate before a policy change: a new crop margin or encoder model
18415
+ * leaves two feature spaces in one index whose cosine scores are not
18416
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
18417
+ * means the same thing.
18418
+ */
18419
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18420
+ /**
18421
+ * Acknowledgement that a rebuild STARTED.
18422
+ *
18423
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
18424
+ * runs detached and this returns immediately. Waiting for it made the client
18425
+ * time out while the work carried on server-side, which is the worst of both:
18426
+ * no result and no way to know it was still going. Poll
18427
+ * `getObjectEmbeddingRebuildStatus` for progress.
18428
+ */
18429
+ var RebuildObjectEmbeddingsResultSchema = object({
18430
+ started: boolean(),
18431
+ /** True when a pass was already running; the new request is ignored. */
18432
+ alreadyRunning: boolean()
18116
18433
  });
18117
- var ReferenceAudioBodySchema = object({ base64: string() });
18118
- var AudioBackendSchema = object({
18119
- id: string(),
18120
- name: string(),
18121
- description: string(),
18122
- available: boolean(),
18434
+ var RebuildStatusSchema = object({
18435
+ running: boolean(),
18436
+ scanned: number(),
18437
+ rebuilt: number(),
18438
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
18439
+ missingKeyFrame: number(),
18440
+ /** Tracks with no usable detection box. */
18441
+ missingBbox: number(),
18442
+ /**
18443
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
18444
+ * frame, a step that threw. Separate from `failed` because the remedy is
18445
+ * different, and because a whole camera silently contributing zero vectors
18446
+ * is the shape of failure a rebuild must never hide.
18447
+ */
18448
+ notRunnable: number(),
18123
18449
  /**
18124
- * Raw classifier labels this backend can emit (e.g. YAMNet's
18125
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
18126
- * the benchmark UI to populate the `enabledMicroClasses` filter
18127
- * specific to the selected backend without a separate fetch.
18450
+ * The pass stopped because NO node could serve the pinned model.
18451
+ *
18452
+ * Distinct from `notRunnable` on purpose: that one says "this track was
18453
+ * refused", this one says "the cluster cannot do this work at all" — every
18454
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
18455
+ * pinned model for its engine format, or dropped out. The remedy is a model /
18456
+ * engine change, not a per-camera one. Non-zero here always comes with
18457
+ * `complete: false`.
18128
18458
  */
18129
- rawLabels: array(string()).readonly().optional()
18130
- });
18131
- var AudioCapabilitiesSchema = object({
18132
- activeBackend: string(),
18133
- availableBackends: array(AudioBackendSchema).readonly(),
18134
- sampleRate: number(),
18135
- chunkDurationMs: number()
18136
- });
18137
- var DownloadModelResultSchema = object({
18138
- filePath: string(),
18139
- sizeMB: number(),
18140
- durationMs: number()
18459
+ noCapableNode: number(),
18460
+ failed: number(),
18461
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
18462
+ complete: boolean().nullable(),
18463
+ startedAtMs: number().nullable(),
18464
+ finishedAtMs: number().nullable(),
18465
+ /** Present when the pass ended by throwing. */
18466
+ error: string().nullable()
18141
18467
  });
18142
- /**
18143
- * Wrapper carrying a single test run's result. Replaces the legacy
18144
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
18145
- * canonical `AudioResult` from the Phase 6 output rework: one
18146
- * `AudioDetection` per class above `minScore`, top-N candidates in
18147
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
18148
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
18149
- * benchmark UI can still report a clean failure when the classifier
18150
- * cap isn't available.
18151
- */
18152
- var AudioTestResultSchema = object({
18153
- success: boolean(),
18154
- error: string().optional(),
18155
- frame: custom().optional()
18468
+ var ReplayFrameInputSchema = object({
18469
+ timestamp: number(),
18470
+ frame: PipelineRunResultBridge
18156
18471
  });
18157
- var PipelineConfigBridge = custom();
18158
- var ConfigUISchemaBridge = custom();
18159
- var ConfigUISchemaNullableBridge = custom();
18160
- var InferenceCapabilitiesBridge = custom();
18161
- var ModelAvailabilityListBridge = custom();
18162
- var PipelineRunResultBridge = custom();
18163
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
18164
- modelId: string(),
18165
- settings: record(string(), unknown()).readonly()
18166
- }))), method(object({ steps: record(string(), object({
18167
- modelId: string(),
18168
- settings: record(string(), unknown()).readonly()
18169
- })) }), object({ success: literal(true) }), {
18472
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
18473
+ className: string(),
18474
+ firstSeenMs: number(),
18475
+ lastSeenMs: number(),
18476
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
18477
+ * frame a representative box for the diff's `(className, window, IoU)`
18478
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
18479
+ * trajectory production's `Track.positions` keeps. */
18480
+ bbox: BoundingBoxSchema,
18481
+ /** How many of the input frames this track matched a real detection on
18482
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
18483
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
18484
+ framesMatched: number().int()
18485
+ })).readonly() });
18486
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18487
+ deviceId: number(),
18488
+ trackId: string()
18489
+ }), TrackSchema.nullable()), method(object({
18490
+ deviceId: number(),
18491
+ since: number().optional(),
18492
+ until: number().optional(),
18493
+ limit: number().optional(),
18494
+ /** Spatial filter — only tracks whose trajectory intersects the zone
18495
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18496
+ * envelope columns, then precisely tested per position. Tracks with
18497
+ * an unknown envelope (no frame dims at persist time) always match. */
18498
+ zone: TrackZoneFilterSchema.optional(),
18499
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
18500
+ * compatible — omitting the field keeps today's exact behaviour). */
18501
+ projection: TrackProjectionSchema.optional(),
18502
+ /** Include stationary-promoted rows (parked objects handed to the
18503
+ * stationary registry). Default false: the timeline lists passages,
18504
+ * not parking records (operator decision, 2026-08-15). */
18505
+ includeStationary: boolean().optional()
18506
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18507
+ deviceId: number(),
18508
+ groupId: string().min(1)
18509
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18510
+ kind: "mutation",
18511
+ auth: "admin"
18512
+ }), method(DeviceEventQueryInput, array(MotionEventSchema).readonly()), method(ObjectEventQueryInput, array(ObjectEventSchema).readonly()), method(DeviceEventQueryInput, array(AudioEventSchema).readonly()), method(object({ deviceId: number() }), array(EventKindDescriptorSchema).readonly()), method(object({ deviceIds: array(number()).min(1).max(200) }), array(EventKindsForDeviceSchema).readonly()), method(object({
18513
+ deviceId: number(),
18514
+ since: number().optional(),
18515
+ until: number().optional(),
18516
+ kinds: array(string()).optional(),
18517
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18518
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18519
+ deviceId: number(),
18520
+ since: number(),
18521
+ until: number(),
18522
+ bucketMs: number().int().positive()
18523
+ }), array(object({
18524
+ bucketStart: number(),
18525
+ motion: number().int(),
18526
+ object: number().int(),
18527
+ audio: number().int()
18528
+ })).readonly()), method(object({
18529
+ deviceId: number(),
18530
+ cutoffMs: number()
18531
+ }), object({
18532
+ motion: number().int(),
18533
+ object: number().int(),
18534
+ audio: number().int()
18535
+ }), {
18536
+ kind: "mutation",
18537
+ auth: "admin"
18538
+ }), method(object({
18539
+ deviceId: number(),
18540
+ cutoffMs: number()
18541
+ }), TrackCascadeCountsSchema, {
18542
+ kind: "mutation",
18543
+ auth: "admin"
18544
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18545
+ kind: "mutation",
18546
+ auth: "admin"
18547
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18548
+ kind: "mutation",
18549
+ auth: "admin"
18550
+ }), method(object({
18551
+ deviceId: number(),
18552
+ trackIds: array(string()).min(1)
18553
+ }), object({
18554
+ deleted: number().int(),
18555
+ failed: array(string()).readonly()
18556
+ }), {
18557
+ kind: "mutation",
18558
+ auth: "admin"
18559
+ }), method(object({
18560
+ /** Log/audit scope only — the trackId is globally unique on its own. */
18561
+ deviceId: number(),
18562
+ trackId: string(),
18563
+ flags: TrackFlagsPatchSchema
18564
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18565
+ kind: "query",
18566
+ auth: "admin"
18567
+ }), method(object({
18568
+ olderThanMs: number(),
18569
+ reason: OpsLogReasonSchema.optional()
18570
+ }), EventPruneCountsSchema, {
18571
+ kind: "mutation",
18572
+ auth: "admin"
18573
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
18574
+ kind: "mutation",
18575
+ auth: "admin"
18576
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18577
+ kind: "mutation",
18578
+ auth: "admin"
18579
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18580
+ kind: "mutation",
18581
+ auth: "admin"
18582
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18583
+ kind: "mutation",
18584
+ auth: "admin"
18585
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
18586
+ kind: "mutation",
18587
+ auth: "admin"
18588
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18589
+ kind: "mutation",
18590
+ auth: "admin"
18591
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18592
+ kind: "mutation",
18593
+ auth: "admin"
18594
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
18595
+ kind: "query",
18596
+ auth: "admin"
18597
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18598
+ kind: "mutation",
18599
+ auth: "admin"
18600
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18601
+ kind: "query",
18602
+ auth: "admin"
18603
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
18604
+ kind: "query",
18605
+ auth: "admin"
18606
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18607
+ kind: "query",
18608
+ auth: "admin"
18609
+ }), method(object({
18610
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18611
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
18612
+ * route it at one camera's owner, and "every camera" would stop being
18613
+ * expressible at all. */
18614
+ deviceIds: array(number()).optional(),
18615
+ limit: number().int().min(1).max(500).optional()
18616
+ }), array(RetrainTrackSchema).readonly(), {
18617
+ kind: "query",
18618
+ auth: "admin"
18619
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
18620
+ kind: "query",
18621
+ auth: "admin"
18622
+ }), method(object({
18623
+ deviceId: number(),
18624
+ trackId: string(),
18625
+ mediaKeys: array(string()).min(1)
18626
+ }), RetrainFrameSelectionSchema, {
18627
+ kind: "mutation",
18628
+ auth: "admin"
18629
+ }), method(object({
18630
+ deviceId: number(),
18631
+ trackId: string(),
18632
+ frameId: string()
18633
+ }), object({
18634
+ removed: boolean(),
18635
+ removedAnnotations: number().int()
18636
+ }), {
18637
+ kind: "mutation",
18638
+ auth: "admin"
18639
+ }), method(object({ frameId: string() }), object({
18640
+ base64: string(),
18641
+ width: number().int(),
18642
+ height: number().int()
18643
+ }), {
18644
+ kind: "query",
18645
+ auth: "admin"
18646
+ }), method(object({
18647
+ deviceId: number(),
18648
+ trackId: string(),
18649
+ frameId: string(),
18650
+ subject: RetrainAssistSubjectSchema,
18651
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18652
+ nodeId: string().optional()
18653
+ }), RetrainAssistResultSchema, {
18654
+ kind: "mutation",
18655
+ auth: "admin"
18656
+ }), method(object({
18657
+ deviceId: number(),
18658
+ source: DetectionSourceSchema,
18659
+ zones: array(ZoneSchema).readonly().optional(),
18660
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
18661
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
18662
+ frames: array(ReplayFrameInputSchema).min(1)
18663
+ }), RunReplayFrameProcessorResultSchema, {
18664
+ kind: "mutation",
18665
+ auth: "admin"
18666
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18667
+ kind: "query",
18668
+ auth: "admin"
18669
+ }), method(object({
18670
+ deviceId: number(),
18671
+ trackId: string(),
18672
+ frameId: string(),
18673
+ annotations: array(RetrainAnnotationDraftSchema)
18674
+ }), array(RetrainAnnotationSchema).readonly(), {
18675
+ kind: "mutation",
18676
+ auth: "admin"
18677
+ }), method(object({
18678
+ deviceId: number(),
18679
+ trackId: string()
18680
+ }), RetrainTransitionResultSchema, {
18170
18681
  kind: "mutation",
18171
18682
  auth: "admin"
18172
- }), method(object({ nodeId: string() }), object({
18173
- success: literal(true),
18174
- clearedDevices: number()
18175
- }), {
18683
+ }), method(object({
18684
+ deviceId: number(),
18685
+ trackId: string()
18686
+ }), RetrainTransitionResultSchema, {
18176
18687
  kind: "mutation",
18177
18688
  auth: "admin"
18178
- }), 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({
18179
- name: string(),
18180
- steps: array(PipelineTemplateStepSchema).readonly(),
18181
- engine: PipelineEngineChoiceSchema
18182
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
18183
- id: string(),
18184
- name: string().optional(),
18185
- steps: array(PipelineTemplateStepSchema).readonly().optional()
18186
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
18187
- addonId: string(),
18188
- modelId: string(),
18189
- format: ModelFormatSchema$1
18190
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
18191
- addonId: string(),
18192
- modelId: string(),
18193
- format: ModelFormatSchema$1
18194
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
18195
- engine: PipelineEngineChoiceSchema.optional(),
18196
- steps: array(PipelineStepInputSchema).min(1),
18197
- frame: FrameInputSchema.optional(),
18198
- /**
18199
- * Process-local lazy frame. Valid only when caller and provider resolve
18200
- * in the same execution-group process; split/cross-node callers use
18201
- * `frame`/`image` inline compatibility instead.
18202
- */
18203
- frameRef: FrameRefSchema.optional(),
18204
- /**
18205
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
18206
- * the decoded pixels live in. One more member of the one-of
18207
- * frame/frameHandle/image/imageBase64/referenceImage group.
18208
- */
18209
- frameHandle: FrameHandleSchema.optional(),
18210
- imageBase64: string().optional(),
18211
- /**
18212
- * Binary JPEG bytes — preferred over `imageBase64` on internal
18213
- * hops (hub → forked worker via Moleculer MsgPack) because it
18214
- * skips the 33% base64 overhead + the per-call base64 decode on
18215
- * the detection-pipeline worker. Callers can pass either; exactly
18216
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
18217
- */
18218
- image: _instanceof(Uint8Array).optional(),
18219
- referenceImage: string().optional(),
18220
- deviceId: number().optional(),
18221
- sessionId: string().optional(),
18222
- /**
18223
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
18224
- * reference-image, and detail-subtree calls. 'frame' is the live
18225
- * per-frame dispatch: ONLY root-plane steps run; crop children
18226
- * (inputClasses ≠ null) are skipped and served per-track via
18227
- * pipelineRunner.runDetailSubtree (two-plane design).
18228
- */
18229
- plane: _enum(["full", "frame"]).optional(),
18230
- /**
18231
- * Inference-device selector (Phase 2 multi-device). Format
18232
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
18233
- * Omitted ⇒ the runner's default device (current single-engine
18234
- * behaviour). Selects WHICH device pool of the node runs the call.
18235
- */
18236
- deviceKey: string().optional(),
18237
- /**
18238
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
18239
- * when the parent crop was resolved from the frame's retained NATIVE
18240
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
18241
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
18242
- * resolution from that surface — the SAME quality path faces already
18243
- * had — instead of the downscaled parent tile. `handle` keys the native
18244
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
18245
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
18246
- * the executor's crop-normalized child ROI back into frame-normalized
18247
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
18248
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
18249
- * (today's behaviour on the fallback path).
18250
- */
18251
- nativeCropRef: NativeCropRefSchema.optional()
18252
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
18253
- engine: PipelineEngineChoiceSchema.optional(),
18254
- steps: array(PipelineStepInputSchema).min(1),
18255
- frames: array(FrameInputSchema).min(1).max(255),
18256
- deviceId: number().optional(),
18257
- sessionId: string().optional(),
18258
- /**
18259
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
18260
- * the batch to the Python pool's bench preprocess cache
18261
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
18262
- * preprocessed ONCE and every later inference is a pure-inference cache
18263
- * hit — the sustained-throughput run measures inference, not
18264
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
18265
- * full preprocess every call, correct). Fresh per sustained run;
18266
- * released via `uncacheFrame`.
18267
- */
18268
- frameId: number().int().nonnegative().optional(),
18269
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
18270
- deviceKey: string().optional()
18271
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
18272
- data: _instanceof(Uint8Array),
18273
- width: number().int().positive(),
18274
- height: number().int().positive(),
18275
- format: _enum([
18276
- "rgb",
18277
- "bgr",
18278
- "gray"
18279
- ])
18280
- }), object({
18281
- frameId: number(),
18282
- width: number(),
18283
- height: number()
18284
- }), { kind: "mutation" }), method(object({
18285
- stepId: string(),
18286
- frameId: number().int()
18287
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
18288
- batchMode: string(),
18289
- windowMs: number(),
18290
- maxBatchSize: number(),
18291
- concurrency: number()
18292
- })), method(_void(), array(object({
18293
- engineKey: string(),
18294
- engine: PipelineEngineChoiceSchema,
18295
- modelsLoaded: array(string()).readonly(),
18296
- inUseByCameras: array(number()).readonly(),
18297
- /**
18298
- * Origin of this resident factory.
18299
- * - `runtime` — main camera-serving engine (no idle TTL).
18300
- * - `warm-override` — benchmark/test override held in the warm
18301
- * cache; auto-disposed after the idle TTL.
18302
- * - `device-pool` — a concurrent per-device pool (Phase 2
18303
- * multi-device, keyed by `deviceKey`) resolved
18304
- * via `resolveDeviceFactory`. Runs alongside the
18305
- * `runtime` engine on a DIFFERENT accelerator
18306
- * (NPU / iGPU / Coral) — this is how the
18307
- * Engines tab shows all pools running at once.
18308
- */
18309
- kind: _enum([
18310
- "runtime",
18311
- "warm-override",
18312
- "device-pool"
18313
- ]),
18314
- /** Native pid of the underlying Python pool (null when no pool). */
18315
- poolPid: number().nullable(),
18316
- /** ms since this factory was last used (null when not warm-tracked). */
18317
- idleMs: number().nullable(),
18318
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
18319
- idleTtlMs: number().nullable()
18320
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
18321
- kind: "mutation",
18689
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18690
+ kind: "query",
18322
18691
  auth: "admin"
18323
18692
  }), method(object({
18324
- engine: PipelineEngineChoiceSchema,
18325
- force: boolean().optional()
18326
- }), object({
18327
- success: boolean(),
18328
- reason: string().optional()
18329
- }), {
18693
+ eventId: string(),
18694
+ kind: MediaFileKindEnum.optional(),
18695
+ deviceId: number()
18696
+ }), array(MediaFileSchema).readonly()), method(object({
18697
+ trackId: string(),
18698
+ kinds: array(MediaFileKindEnum).optional(),
18699
+ deviceId: number()
18700
+ }), array(MediaFileSchema).readonly()), method(object({
18701
+ trackId: string(),
18702
+ deviceId: number()
18703
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18330
18704
  kind: "mutation",
18331
18705
  auth: "admin"
18332
- }), method(_void(), array(ReferenceImageEntrySchema).readonly()), method(object({ filename: string() }), ReferenceImageBodySchema.nullable()), method(_void(), array(ReferenceAudioEntrySchema).readonly()), method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()), method(_void(), AudioCapabilitiesSchema), method(object({
18333
- addonId: string(),
18334
- modelId: string(),
18335
- filename: string().optional(),
18336
- settings: record(string(), unknown()).optional()
18337
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
18706
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18707
+ kind: "mutation",
18708
+ auth: "admin"
18709
+ }), method(object({}), RebuildStatusSchema), object({
18710
+ deviceId: number(),
18711
+ timestamp: number(),
18712
+ frameWidth: number(),
18713
+ frameHeight: number(),
18714
+ detections: array(OverlayDetectionSchema).readonly()
18715
+ }), object({
18716
+ deviceId: number(),
18717
+ trackId: string(),
18718
+ className: string()
18719
+ }), object({
18720
+ deviceId: number(),
18721
+ trackId: string(),
18722
+ className: string(),
18723
+ durationMs: number()
18724
+ }), object({
18725
+ deviceId: number(),
18726
+ kind: EventKindSchema,
18727
+ eventId: string(),
18728
+ timestamp: number()
18729
+ });
18338
18730
  object({
18339
18731
  activeCameras: number(),
18340
18732
  throttledCameras: number(),
@@ -18346,119 +18738,19 @@ var CameraMetricsSchema = object({
18346
18738
  "disabled",
18347
18739
  "always-on",
18348
18740
  "on-motion"
18349
- ]),
18350
- configuredFps: number(),
18351
- actualFps: number(),
18352
- queueDepth: number(),
18353
- avgInferenceTimeMs: number(),
18354
- droppedFrames: number(),
18355
- phase: _enum([
18356
- "idle",
18357
- "watching",
18358
- "active"
18359
- ])
18360
- });
18361
- var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18362
- /**
18363
- * Zone — pure geometry + identity. NO filtering behaviour.
18364
- *
18365
- * Zones describe **where** in the frame the operator wants to flag
18366
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
18367
- * each pipeline stage uses them. Splitting the two means a single
18368
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
18369
- * a detection-include rule on `['car']`, and an occupancy aggregate
18370
- * — without three duplicated polygons.
18371
- *
18372
- * Owned by the orchestrator addon (provider) and mirrored into the
18373
- * `zones` device-state slice on every mutation. Consumers
18374
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18375
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18376
- * mirror with `onChanged`).
18377
- *
18378
- * Coordinates are normalised fractions of the frame (0–1) so zones
18379
- * survive resolution changes and stream profile switches.
18380
- *
18381
- * `kind` discriminates between full polygons (closed regions used
18382
- * for intrusion / occupancy filters) and tripwires (open 2-point
18383
- * line segments used for cross events). Onboard / firmware-reported
18384
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18385
- * task list.
18386
- */
18387
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18388
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18389
- var PolygonPointSchema = object({
18390
- x: number(),
18391
- y: number()
18392
- });
18393
- /** A camera detection zone — pure geometry/identity. */
18394
- var ZoneSchema = object({
18395
- id: string(),
18396
- name: string(),
18397
- kind: ZoneKindEnum.default("polygon"),
18398
- /** Polygon vertices, fraction of frame (0–1). */
18399
- polygon: array(PolygonPointSchema).readonly(),
18400
- /** Visual color for UI rendering. */
18401
- color: string().default("#3b82f6")
18741
+ ]),
18742
+ configuredFps: number(),
18743
+ actualFps: number(),
18744
+ queueDepth: number(),
18745
+ avgInferenceTimeMs: number(),
18746
+ droppedFrames: number(),
18747
+ phase: _enum([
18748
+ "idle",
18749
+ "watching",
18750
+ "active"
18751
+ ])
18402
18752
  });
18403
- /**
18404
- * Zones capability — per-camera CRUD over polygon detection zones.
18405
- *
18406
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
18407
- * to per-device settings and mirrors into the `zones` device-state
18408
- * slice on every mutation, so downstream consumers can subscribe via
18409
- * `dev.state.zones.onChanged`.
18410
- *
18411
- * The cap surface only handles geometry + identity; filtering
18412
- * behaviour (per-class, include/exclude, threshold) lives in the
18413
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
18414
- * `capabilities/schemas/zone-rule.js`.
18415
- */
18416
- var zonesCapability = {
18417
- name: "zones",
18418
- scope: "device",
18419
- mode: "singleton",
18420
- deviceTypes: [DeviceType.Camera],
18421
- methods: {
18422
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
18423
- addZone: method(object({
18424
- deviceId: number(),
18425
- zone: ZoneSchema
18426
- }), _void(), {
18427
- kind: "mutation",
18428
- auth: "admin"
18429
- }),
18430
- removeZone: method(object({
18431
- deviceId: number(),
18432
- zoneId: string()
18433
- }), _void(), {
18434
- kind: "mutation",
18435
- auth: "admin"
18436
- }),
18437
- updateZone: method(object({
18438
- deviceId: number(),
18439
- zone: ZoneSchema
18440
- }), _void(), {
18441
- kind: "mutation",
18442
- auth: "admin"
18443
- })
18444
- },
18445
- /**
18446
- * Runtime-state slice — the live zone catalogue mirrored by the
18447
- * orchestrator on every CRUD mutation. Consumers read via
18448
- * `device.state.zones.value` / `.watch(...)` without round-tripping
18449
- * the cap, and the codegen DeviceProxy auto-wires the reactive
18450
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
18451
- * (e.g. zone groupings) can sit alongside the polygon list.
18452
- */
18453
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
18454
- /**
18455
- * 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.
18456
- *
18457
- * See `RuntimeStateDurability`. Enforced by
18458
- * `scripts/check-runtime-state-durability.ts`.
18459
- */
18460
- durability: "restored"
18461
- };
18753
+ var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18462
18754
  /**
18463
18755
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
18464
18756
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
@@ -20147,7 +20439,7 @@ method(object({
20147
20439
  * linking rather than produce an eternal token.
20148
20440
  */
20149
20441
  ttlSec: union([number().int().positive(), literal("never")]).optional()
20150
- }), object({ token: string() })), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable());
20442
+ }), object({ token: string() }), { auth: "admin" }), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
20151
20443
  var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
20152
20444
  providerId: string().min(1),
20153
20445
  displayName: string().min(1),
@@ -20242,10 +20534,13 @@ var EvictResultSchema = object({
20242
20534
  /** True when the provider has nothing left it is willing to drop on this location. */
20243
20535
  exhausted: boolean()
20244
20536
  });
20245
- method(object({ locationId: string() }), EvictableUsageSchema), method(object({
20537
+ method(object({ locationId: string() }), EvictableUsageSchema, { auth: "admin" }), method(object({
20246
20538
  locationId: string(),
20247
20539
  targetBytes: number().int().positive()
20248
- }), EvictResultSchema, { kind: "mutation" });
20540
+ }), EvictResultSchema, {
20541
+ kind: "mutation",
20542
+ auth: "admin"
20543
+ });
20249
20544
  method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin" }), method(StorageMigrationInputSchema, object({ jobId: string() }), {
20250
20545
  kind: "mutation",
20251
20546
  auth: "admin"
@@ -20305,26 +20600,50 @@ var ReadChunkInputSchema = object({
20305
20600
  length: number()
20306
20601
  });
20307
20602
  var EndDownloadInputSchema = object({ downloadId: string() });
20308
- method(_void(), ProviderInfoSchema), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20603
+ method(_void(), ProviderInfoSchema, { auth: "admin" }), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20309
20604
  location: StorageLocationSchema,
20310
20605
  relativePath: string()
20311
- }), string()), method(object({
20606
+ }), string(), { auth: "admin" }), method(object({
20312
20607
  location: StorageLocationSchema,
20313
20608
  relativePath: string(),
20314
20609
  data: _instanceof(Uint8Array)
20315
- }), _void(), { kind: "mutation" }), method(object({
20610
+ }), _void(), {
20611
+ kind: "mutation",
20612
+ auth: "admin"
20613
+ }), method(object({
20316
20614
  location: StorageLocationSchema,
20317
20615
  relativePath: string()
20318
- }), _instanceof(Uint8Array)), method(object({
20616
+ }), _instanceof(Uint8Array), { auth: "admin" }), method(object({
20319
20617
  location: StorageLocationSchema,
20320
20618
  relativePath: string()
20321
- }), boolean()), method(object({
20619
+ }), boolean(), { auth: "admin" }), method(object({
20322
20620
  location: StorageLocationSchema,
20323
20621
  prefix: string().optional()
20324
- }), array(string()).readonly()), method(object({
20622
+ }), array(string()).readonly(), { auth: "admin" }), method(object({
20325
20623
  location: StorageLocationSchema,
20326
20624
  relativePath: string()
20327
- }), _void(), { kind: "mutation" }), method(object({ location: StorageLocationSchema }), number().nullable()), method(BeginUploadInputSchema, BeginUploadResultSchema, { kind: "mutation" }), method(WriteChunkInputSchema, _void(), { kind: "mutation" }), method(FinalizeUploadInputSchema, _void(), { kind: "mutation" }), method(AbortUploadInputSchema, _void(), { kind: "mutation" }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, { kind: "mutation" }), method(ReadChunkInputSchema, _instanceof(Uint8Array)), method(EndDownloadInputSchema, _void(), { kind: "mutation" });
20625
+ }), _void(), {
20626
+ kind: "mutation",
20627
+ auth: "admin"
20628
+ }), method(object({ location: StorageLocationSchema }), number().nullable(), { auth: "admin" }), method(BeginUploadInputSchema, BeginUploadResultSchema, {
20629
+ kind: "mutation",
20630
+ auth: "admin"
20631
+ }), method(WriteChunkInputSchema, _void(), {
20632
+ kind: "mutation",
20633
+ auth: "admin"
20634
+ }), method(FinalizeUploadInputSchema, _void(), {
20635
+ kind: "mutation",
20636
+ auth: "admin"
20637
+ }), method(AbortUploadInputSchema, _void(), {
20638
+ kind: "mutation",
20639
+ auth: "admin"
20640
+ }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, {
20641
+ kind: "mutation",
20642
+ auth: "admin"
20643
+ }), method(ReadChunkInputSchema, _instanceof(Uint8Array), { auth: "admin" }), method(EndDownloadInputSchema, _void(), {
20644
+ kind: "mutation",
20645
+ auth: "admin"
20646
+ });
20328
20647
  /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
20329
20648
  var ProfileSettingsSchemaBridge = unknown().nullable();
20330
20649
  var ProfileSettingsBagSchema = record(string(), unknown());
@@ -20582,7 +20901,8 @@ method(object({
20582
20901
  access: "create"
20583
20902
  }), method(object({ userId: string().optional() }), object({ optionsJSON: record(string(), unknown()) }), {
20584
20903
  kind: "mutation",
20585
- access: "view"
20904
+ access: "view",
20905
+ auth: "admin"
20586
20906
  }), method(object({
20587
20907
  /** Required — the user the assertion belongs to (verified). */
20588
20908
  userId: string(),
@@ -20590,10 +20910,12 @@ method(object({
20590
20910
  response: record(string(), unknown())
20591
20911
  }), object({ verified: boolean() }), {
20592
20912
  kind: "mutation",
20593
- access: "view"
20913
+ access: "view",
20914
+ auth: "admin"
20594
20915
  }), method(object({}), object({ optionsJSON: record(string(), unknown()) }), {
20595
20916
  kind: "mutation",
20596
- access: "view"
20917
+ access: "view",
20918
+ auth: "admin"
20597
20919
  }), method(object({
20598
20920
  /** AuthenticationResponseJSON from the browser. */
20599
20921
  response: record(string(), unknown()) }), object({
@@ -20601,7 +20923,8 @@ response: record(string(), unknown()) }), object({
20601
20923
  userId: string().nullable()
20602
20924
  }), {
20603
20925
  kind: "mutation",
20604
- access: "view"
20926
+ access: "view",
20927
+ auth: "admin"
20605
20928
  }), method(object({ userId: string() }), array(PasskeySummarySchema), { auth: "admin" }), method(object({
20606
20929
  userId: string(),
20607
20930
  credentialId: string()
@@ -20773,7 +21096,19 @@ var VectorStatsResultSchema = object({
20773
21096
  /** False when the backend ranks approximately. */
20774
21097
  exact: boolean()
20775
21098
  });
20776
- method(VectorDeclareIndexInputSchema, _void(), { kind: "mutation" }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, { kind: "mutation" }), method(VectorQueryInputSchema, VectorQueryResultSchema), method(VectorGetInputSchema, VectorGetResultSchema), method(VectorDeleteInputSchema, VectorDeleteResultSchema, { kind: "mutation" }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, { kind: "mutation" }), method(VectorStatsInputSchema, VectorStatsResultSchema);
21099
+ method(VectorDeclareIndexInputSchema, _void(), {
21100
+ kind: "mutation",
21101
+ auth: "admin"
21102
+ }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21103
+ kind: "mutation",
21104
+ auth: "admin"
21105
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21106
+ kind: "mutation",
21107
+ auth: "admin"
21108
+ }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
21109
+ kind: "mutation",
21110
+ auth: "admin"
21111
+ }), method(VectorStatsInputSchema, VectorStatsResultSchema, { auth: "admin" });
20777
21112
  var ClipSchema = object({
20778
21113
  /** Opaque, provider-namespaced id. The default provider encodes the time
20779
21114
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -23315,7 +23650,27 @@ var MediaFileLiteSchema$1 = object({
23315
23650
  sizeBytes: number(),
23316
23651
  timestamp: number()
23317
23652
  });
23318
- method(_void(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
23653
+ method(object({
23654
+ /**
23655
+ * Inline {@link IdentitySchema.coverBase64} on every row.
23656
+ *
23657
+ * Default `false`, the same inversion `listRecentFaces` and
23658
+ * `listPlates` took on 2026-08-25 (see `include-crops-default.ts` for
23659
+ * why the burden belongs on the caller that WANTS the bytes). Measured
23660
+ * on the live hub the same day: four identities cost 40,979 B with the
23661
+ * covers inline, ~10 KB of base64 per row, on a query this UI mounts
23662
+ * four times and the viewer holds at `staleTime: 30_000`.
23663
+ *
23664
+ * Nothing loses its avatar: `coverMediaKey` is already on every row and
23665
+ * the `event-media` plane serves that key `immutable` with an ETag.
23666
+ *
23667
+ * **This is an INPUT field, so it does not reach the addon until the
23668
+ * next train** — the hub router validates cap inputs against its own
23669
+ * compiled Zod and strips a key it does not know. Until then the
23670
+ * provider sees `undefined`, which resolves to `false`: the cheap shape
23671
+ * is what ships, and the opt-in becomes reachable when the train lands.
23672
+ */
23673
+ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
23319
23674
  kind: "mutation",
23320
23675
  auth: "admin"
23321
23676
  }), method(object({
@@ -26205,8 +26560,10 @@ var PlateInfoSchema = object({
26205
26560
  keyFrameMediaKey: string().optional(),
26206
26561
  base64: string().optional(),
26207
26562
  /**
26208
- * Same crop as a data-plane URL. `getPlateByTrack` returns this and
26209
- * never inlines JPEG; `listPlates` still inlines for the admin-ui.
26563
+ * Same crop as a data-plane URL, always present when the plate has a stored
26564
+ * crop. `getPlateByTrack` returns this and never inlines JPEG; `listPlates`
26565
+ * and `searchPlates` inline the crop only when their `includeCrops` input is
26566
+ * left at its `true` default.
26210
26567
  */
26211
26568
  cropUrl: string().optional()
26212
26569
  });
@@ -26226,14 +26583,34 @@ var PlateClusterSchema = object({
26226
26583
  });
26227
26584
  method(object({
26228
26585
  deviceId: number().int().optional(),
26229
- limit: number().int().positive().optional()
26586
+ limit: number().int().positive().optional(),
26587
+ /**
26588
+ * Inline the base64 crop on every row. Default `true` — the existing
26589
+ * behaviour, kept so no caller breaks.
26590
+ *
26591
+ * Set `false` once the caller renders {@link PlateInfo.cropUrl}.
26592
+ * Measured on the live hub at the 500 rows the Plates view asks for:
26593
+ * 879,403 B and 27.7 s with the crops inline, against a few KiB of
26594
+ * metadata without them — and the browser then caches the images.
26595
+ *
26596
+ * This is the plate twin of `faceGallery.listRecentFaces`'s option;
26597
+ * plates were the one gallery list left without it.
26598
+ *
26599
+ * **This is an INPUT field, so it does not reach the addon until the
26600
+ * next train.** The hub router validates cap inputs against its own
26601
+ * compiled Zod and strips a key it does not know. Until the train
26602
+ * ships, sending `false` is harmless and keeps the crops inline.
26603
+ */
26604
+ includeCrops: boolean().optional()
26230
26605
  }).optional(), array(PlateInfoSchema).readonly()), method(object({
26231
26606
  deviceId: number().int(),
26232
26607
  trackId: string()
26233
26608
  }), PlateInfoSchema.nullable()), method(object({ plateId: string() }), array(MediaFileLiteSchema).readonly()), method(object({
26234
26609
  text: string().min(1),
26235
26610
  maxDistance: number().int().min(0).optional(),
26236
- limit: number().int().positive().optional()
26611
+ limit: number().int().positive().optional(),
26612
+ /** See `listPlates.includeCrops`. Default `true`. */
26613
+ includeCrops: boolean().optional()
26237
26614
  }), array(PlateInfoSchema).readonly()), method(object({
26238
26615
  maxDistance: number().int().min(0).optional(),
26239
26616
  minClusterSize: number().int().min(2).optional(),
@@ -26247,7 +26624,13 @@ method(object({
26247
26624
  }), method(object({ plateId: string() }), _void(), {
26248
26625
  kind: "mutation",
26249
26626
  auth: "admin"
26250
- }), method(_void(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
26627
+ }), method(object({
26628
+ /** Inline {@link VehicleSchema.coverBase64} on every row. Default
26629
+ * `false` — the vehicle twin of `faceGallery.listIdentities`'s
26630
+ * option; `coverMediaKey` + the `event-media` plane carry the picture.
26631
+ * INPUT field: stripped by the hub router until the train ships, which
26632
+ * resolves to `false` and is exactly the intended default. */
26633
+ includeCrops: boolean().optional() }).optional(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
26251
26634
  kind: "mutation",
26252
26635
  auth: "admin"
26253
26636
  }), method(object({
@@ -27768,92 +28151,6 @@ var sceneMonitorCapability = {
27768
28151
  durability: "session"
27769
28152
  };
27770
28153
  /**
27771
- * Per-stage gating mode applied to the zones a rule references.
27772
- *
27773
- * - `include`: the rule contributes to a **whitelist** for its stage.
27774
- * When at least one `include` rule fires for a stage, only entities
27775
- * inside one of those zones pass that stage.
27776
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
27777
- * Entities inside one of those zones are dropped at that stage.
27778
- *
27779
- * `monitor`-style observation (count without filtering) is not a rule
27780
- * mode — zones without any matching rule are observed naturally by
27781
- * `zone-analytics` (live snapshot + history), so an "I just want to
27782
- * count, not filter" use case needs no rule at all.
27783
- */
27784
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
27785
- /**
27786
- * Per-consumer rule that references existing zones (geometry) and
27787
- * defines how a specific pipeline stage should treat them. Each
27788
- * consumer addon owns its own `ZoneRule[]` array in its per-device
27789
- * settings:
27790
- *
27791
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
27792
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
27793
- * - future: notification rules, audio gating, etc.
27794
- *
27795
- * One rule applies to N zones (`zoneIds[]`) so the operator can
27796
- * express "ignore motion in ALL of {garden, street}" with a single
27797
- * rule. `classFilter` narrows the rule to specific object classes —
27798
- * "drop person detections in the street, but keep cars" is one
27799
- * `exclude` rule with `classFilter: ['person']`.
27800
- *
27801
- * `enabled` is a soft toggle — the operator can keep the rule
27802
- * configured but inert without deleting it.
27803
- */
27804
- var ZoneRuleSchema = object({
27805
- /** Stable rule id — survives edits, used by the UI for diffing. */
27806
- id: string(),
27807
- /** Optional human-readable label rendered in the rule editor. */
27808
- name: string().optional(),
27809
- /** Zones this rule targets. The rule's `mode` applies to ALL
27810
- * listed zones (OR-set: a detection in any one of them counts).
27811
- * At least one zone id required — a rule with no targets is a
27812
- * configuration mistake and the form validator rejects it. */
27813
- zoneIds: array(string()).min(1).readonly(),
27814
- mode: ZoneRuleModeEnum,
27815
- /**
27816
- * Class names this rule applies to. Empty / undefined ⇒ rule
27817
- * applies to every class. Class strings match the `macroClass`
27818
- * field on detections (e.g. `person`, `car`, `dog`).
27819
- */
27820
- classFilter: array(string()).readonly().optional(),
27821
- /**
27822
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
27823
- * required to consider an entity "in the zone". Defaults to the
27824
- * consumer's stage default when omitted. Kept for back-compat with
27825
- * existing per-rule overrides; new operators pick the value via
27826
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
27827
- * set, the lower-level engine reads it as a 0–1 fraction.
27828
- */
27829
- overlapThreshold: number().min(0).max(1).optional(),
27830
- /**
27831
- * Operator-friendly version of `overlapThreshold` — the percentage
27832
- * of the detection's bbox that must lie inside the zone for the
27833
- * rule to match. Documented default is 85%; the engine substitutes
27834
- * that when the field is omitted (kept optional so existing rules
27835
- * stored without it stay valid).
27836
- *
27837
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
27838
- * rule, the engine prefers `bboxInclusionPct` because it's the
27839
- * field exposed in the UI. Internally both feed the same gate.
27840
- */
27841
- bboxInclusionPct: number().min(0).max(100).optional(),
27842
- /**
27843
- * When `true` and a detection has a segmentation mask, use the
27844
- * mask for overlap instead of the bbox. Detection-stage only;
27845
- * motion rules ignore this field.
27846
- */
27847
- preferMask: boolean().optional(),
27848
- /**
27849
- * Soft-toggle: `false` disables the rule without deleting it.
27850
- * Defaults to `true` so operators creating a rule via the UI
27851
- * see it active immediately.
27852
- */
27853
- enabled: boolean().default(true)
27854
- });
27855
- array(ZoneRuleSchema).readonly();
27856
- /**
27857
28154
  * Script-runner cap. Models HA `script.*` entities on
27858
28155
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
27859
28156
  * that can be invoked imperatively — optionally with a variables
@@ -33508,6 +33805,12 @@ Object.freeze({
33508
33805
  addonId: null,
33509
33806
  access: "create"
33510
33807
  },
33808
+ "pipelineAnalytics.cancelRelocateMedia": {
33809
+ capName: "pipeline-analytics",
33810
+ capScope: "device",
33811
+ addonId: null,
33812
+ access: "create"
33813
+ },
33511
33814
  "pipelineAnalytics.cancelStorageMigrationMove": {
33512
33815
  capName: "pipeline-analytics",
33513
33816
  capScope: "device",
@@ -33682,6 +33985,12 @@ Object.freeze({
33682
33985
  addonId: null,
33683
33986
  access: "view"
33684
33987
  },
33988
+ "pipelineAnalytics.listRelocateMediaJobs": {
33989
+ capName: "pipeline-analytics",
33990
+ capScope: "device",
33991
+ addonId: null,
33992
+ access: "view"
33993
+ },
33685
33994
  "pipelineAnalytics.listRetrainAnnotations": {
33686
33995
  capName: "pipeline-analytics",
33687
33996
  capScope: "device",
@@ -33760,6 +34069,12 @@ Object.freeze({
33760
34069
  addonId: null,
33761
34070
  access: "create"
33762
34071
  },
34072
+ "pipelineAnalytics.relocateMedia": {
34073
+ capName: "pipeline-analytics",
34074
+ capScope: "device",
34075
+ addonId: null,
34076
+ access: "create"
34077
+ },
33763
34078
  "pipelineAnalytics.restageRetrainTrack": {
33764
34079
  capName: "pipeline-analytics",
33765
34080
  capScope: "device",
@@ -33772,6 +34087,12 @@ Object.freeze({
33772
34087
  addonId: null,
33773
34088
  access: "create"
33774
34089
  },
34090
+ "pipelineAnalytics.runReplayFrameProcessor": {
34091
+ capName: "pipeline-analytics",
34092
+ capScope: "device",
34093
+ addonId: null,
34094
+ access: "create"
34095
+ },
33775
34096
  "pipelineAnalytics.saveRetrainAnnotations": {
33776
34097
  capName: "pipeline-analytics",
33777
34098
  capScope: "device",
@@ -33904,6 +34225,12 @@ Object.freeze({
33904
34225
  addonId: null,
33905
34226
  access: "view"
33906
34227
  },
34228
+ "pipelineExecutor.getInferenceDeviceHealth": {
34229
+ capName: "pipeline-executor",
34230
+ capScope: "system",
34231
+ addonId: null,
34232
+ access: "view"
34233
+ },
33907
34234
  "pipelineExecutor.getOrchestratorConfigSchema": {
33908
34235
  capName: "pipeline-executor",
33909
34236
  capScope: "system",
@@ -33976,6 +34303,12 @@ Object.freeze({
33976
34303
  addonId: null,
33977
34304
  access: "view"
33978
34305
  },
34306
+ "pipelineExecutor.rearmInferenceDevice": {
34307
+ capName: "pipeline-executor",
34308
+ capScope: "system",
34309
+ addonId: null,
34310
+ access: "create"
34311
+ },
33979
34312
  "pipelineExecutor.runAudioTest": {
33980
34313
  capName: "pipeline-executor",
33981
34314
  capScope: "system",
@@ -37224,6 +37557,11 @@ Object.freeze({
37224
37557
  form: "single",
37225
37558
  optional: false
37226
37559
  }],
37560
+ "pipelineAnalytics.runReplayFrameProcessor": [{
37561
+ name: "deviceId",
37562
+ form: "single",
37563
+ optional: false
37564
+ }],
37227
37565
  "pipelineAnalytics.saveRetrainAnnotations": [{
37228
37566
  name: "deviceId",
37229
37567
  form: "single",
@@ -38624,4 +38962,4 @@ function bestLocationMatch(externalName, existing, threshold = .8) {
38624
38962
  var MB = 1024 * 1024;
38625
38963
  1024 * MB, 3072 * MB;
38626
38964
  //#endregion
38627
- export { pressureSensorCapability as $, coverCapability as A, imageCapability as B, buttonCapability as C, record as Ct, connectivityCapability as D, url as Dt, colorCapability as E, unknown as Et, fanControlCapability as F, normalizeUnit as G, lockControlCapability as H, floodCapability as I, numericSensorCapability as J, notificationOutputCapability as K, gasCapability as L, deviceExportCapability as M, enumSensorCapability as N, contactCapability as O, EventCategory as Ot, eventEmitterCapability as P, presenceCapability as Q, humidifierCapability as R, buildAddonRouteProvider as S, object as St, climateControlCapability as T, union as Tt, mediaPlayerCapability as U, lawnMowerControlCapability as V, motionCapability as W, powerMeterCapability as X, oauthIntegrationCapability as Y, prepareNotification as Z, batteryCapability as _, _enum as _t, CameraSwitchIdSchema as a, updateCapability as at, brightnessCapability as b, literal as bt, HvacModeSchema as c, vibrationCapability as ct, accessoriesCapability as d, errMsg as dt, scriptRunnerCapability as et, addonRoutesCapability as f, BaseAddon as ft, automationControlCapability as g, createEvent as gt, ambientLightSensorCapability as h, DeviceType as ht, COCO_TO_MACRO as i, temperatureSensorCapability as it, deviceAdoptionCapability as j, controlCapability as k, MediaPlayerRepeatSchema as l, waterHeaterCapability as lt, alarmPanelCapability as m, DeviceRole as mt, BaseDevice as n, switchCapability as nt, EnumSensorDateTimeFormatSchema as o, vacuumControlCapability as ot, airQualitySensorCapability as p, DeviceFeature as pt, notifierCapability as q, BaseDeviceProvider as r, tamperCapability as rt, FanDirectionSchema as s, valveCapability as st, AlarmArmModeSchema as t, smokeCapability as tt, TargetSchema as u, weatherCapability as ut, bestLocationMatch as v, array as vt, carbonMonoxideCapability as w, string as wt, brokerCapability as x, number as xt, binaryCapability as y, discriminatedUnion as yt, humiditySensorCapability as z };
38965
+ export { presenceCapability as $, controlCapability as A, EventCategory as At, humiditySensorCapability as B, buildAddonRouteProvider as C, number as Ct, colorCapability as D, union as Dt, climateControlCapability as E, string as Et, eventEmitterCapability as F, motionCapability as G, lawnMowerControlCapability as H, fanControlCapability as I, notifierCapability as J, normalizeUnit as K, floodCapability as L, deviceAdoptionCapability as M, deviceExportCapability as N, connectivityCapability as O, unknown as Ot, enumSensorCapability as P, prepareNotification as Q, gasCapability as R, brokerCapability as S, literal as St, carbonMonoxideCapability as T, record as Tt, lockControlCapability as U, imageCapability as V, mediaPlayerCapability as W, oauthIntegrationCapability as X, numericSensorCapability as Y, powerMeterCapability as Z, automationControlCapability as _, createEvent as _t, COCO_TO_MACRO as a, temperatureSensorCapability as at, binaryCapability as b, array as bt, FanDirectionSchema as c, valveCapability as ct, TargetSchema as d, weatherCapability as dt, pressureSensorCapability as et, accessoriesCapability as f, errMsg as ft, ambientLightSensorCapability as g, DeviceType as gt, alarmPanelCapability as h, DeviceRole as ht, CAMERA_SWITCH_ORDER as i, tamperCapability as it, coverCapability as j, contactCapability as k, url as kt, HvacModeSchema as l, vibrationCapability as lt, airQualitySensorCapability as m, DeviceFeature as mt, BaseDevice as n, smokeCapability as nt, CameraSwitchIdSchema as o, updateCapability as ot, addonRoutesCapability as p, BaseAddon as pt, notificationOutputCapability as q, BaseDeviceProvider as r, switchCapability as rt, EnumSensorDateTimeFormatSchema as s, vacuumControlCapability as st, AlarmArmModeSchema as t, scriptRunnerCapability as tt, MediaPlayerRepeatSchema as u, waterHeaterCapability as ut, batteryCapability as v, nodePin as vt, buttonCapability as w, object as wt, brightnessCapability as x, discriminatedUnion as xt, bestLocationMatch as y, _enum as yt, humidifierCapability as z };