@camstack/addon-pipeline-orchestrator 1.2.254 → 1.2.255

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.
package/dist/index.js CHANGED
@@ -5391,7 +5391,7 @@ var ZodIssueCode = {
5391
5391
  var ZodFirstPartyTypeKind;
5392
5392
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5393
5393
  //#endregion
5394
- //#region ../types/dist/sleep-DU7mu4wb.mjs
5394
+ //#region ../types/dist/sleep-BaRu0bS5.mjs
5395
5395
  /**
5396
5396
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5397
5397
  * window to float samples (D455).
@@ -10347,7 +10347,7 @@ var ModelFormatEntrySchema = object({
10347
10347
  /** Multi-file payload (directory members or sibling files). */
10348
10348
  files: array(string()).readonly().optional(),
10349
10349
  /** Runtime(s) that can use this format. If omitted, inferred from ModelFormat key */
10350
- runtimes: array(_enum(["node", "python"])).readonly().optional()
10350
+ runtimes: array(_enum(["python"])).readonly().optional()
10351
10351
  });
10352
10352
  /**
10353
10353
  * Extra file that must be downloaded alongside the model (e.g., labels JSON, dict.txt).
@@ -18016,6 +18016,29 @@ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
18016
18016
  ]);
18017
18017
  NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
18018
18018
  /**
18019
+ * The panel's transitions, as ONE list.
18020
+ *
18021
+ * Named here rather than spelled out at each of the four sites that need them
18022
+ * (the emitter, the intake, the editor group, the combined-notification gate),
18023
+ * because a transition added to the enum and forgotten at one of them is an
18024
+ * alarm state nobody can be notified about. That is exactly what this list
18025
+ * failed to prevent while it held three: `alarm-arming` was the fourth.
18026
+ *
18027
+ * In LIFECYCLE order, which is the order an editor lists them in and the order
18028
+ * a person experiences them — not the order they were added.
18029
+ */
18030
+ var NC_ALARM_SYSTEM_EVENT_KINDS = [
18031
+ "alarm-arm-refused",
18032
+ "alarm-check-failed",
18033
+ "alarm-arming",
18034
+ "alarm-armed",
18035
+ "alarm-pending",
18036
+ "alarm-triggered",
18037
+ "alarm-rearmed",
18038
+ "alarm-sensor-bypass",
18039
+ "alarm-disarmed"
18040
+ ];
18041
+ /**
18019
18042
  * One coherent system-event condition. `kinds` is the required opt-in safety
18020
18043
  * gate; the remaining lists are optional narrowing filters relevant to the
18021
18044
  * selected kinds.
@@ -18082,6 +18105,25 @@ var NcScheduleSchema = object({
18082
18105
  /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
18083
18106
  invert: boolean().optional()
18084
18107
  });
18108
+ /**
18109
+ * How a system-event rule of the `device-events` or `system` family speaks
18110
+ * (D647): at once, per event (`instant`, the only behaviour before D647), or
18111
+ * as a STATE SUMMARY at the end of each window of `schedule`.
18112
+ */
18113
+ var NcSystemEventDeliveryModeSchema = _enum(["instant", "summary"]);
18114
+ /**
18115
+ * `summary`: the rule sends NOTHING per event. When a window of `schedule`
18116
+ * CLOSES, it sends one notification with the current state of its kinds
18117
+ * (low batteries, consumables to replace, devices offline, updates
18118
+ * available, ...), after its own filters. Nothing to report sends nothing.
18119
+ * The schedule is the ordinary `NcSchedule` (weekly windows, IANA timezone,
18120
+ * midnight crossing); the send time is each window's END. Refused on the
18121
+ * `alarm` family, which stays instant (`systemEventDeliveryProblems`).
18122
+ */
18123
+ var NcSystemEventDeliverySchema = discriminatedUnion("mode", [object({ mode: literal("instant") }), object({
18124
+ mode: literal("summary"),
18125
+ schedule: NcScheduleSchema
18126
+ })]);
18085
18127
  /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
18086
18128
  var NcPlateMatcherSchema = object({
18087
18129
  /**
@@ -18817,6 +18859,16 @@ var NcRuleInputSchema = object({
18817
18859
  delivery: NcDeliverySchema,
18818
18860
  conditions: NcConditionsSchema.default({}),
18819
18861
  schedule: NcScheduleSchema.optional(),
18862
+ /**
18863
+ * A `device-events` / `system` rule's delivery (D647): absent or `instant`
18864
+ * is a notification per event; `summary` is one state summary per closed
18865
+ * window of its schedule. `.optional()` and never defaulted: absent must
18866
+ * keep meaning what every rule authored before D647 meant, with no
18867
+ * migration. Top-level rather than inside `conditions.systemEvent`, so a
18868
+ * client that does not know it (an older viewer re-sending `conditions`
18869
+ * whole) leaves it standing through the store's patch merge.
18870
+ */
18871
+ systemEventDelivery: NcSystemEventDeliverySchema.optional(),
18820
18872
  /** May be empty when `targetUsers` addresses at least one user — the
18821
18873
  * "at least one addressee" invariant is enforced by the provider, because
18822
18874
  * a cross-field refine here would break `NcRulePatchSchema.partial()`. */
@@ -19045,6 +19097,28 @@ var NcRuleSchema = NcRuleInputSchema.extend({
19045
19097
  */
19046
19098
  disabledTargetIds: array(string()).default([])
19047
19099
  });
19100
+ /** One section of a previewed state summary. `unavailable` = its state could not be read. */
19101
+ var NcStateSummaryPreviewSectionSchema = object({
19102
+ id: string(),
19103
+ status: _enum(["read", "unavailable"]),
19104
+ items: number().int().nonnegative(),
19105
+ reason: string().optional()
19106
+ });
19107
+ /**
19108
+ * The summary a rule would send now. `empty` = nothing to report and every
19109
+ * section read: such a summary is NOT sent. `dropped` counts the open states
19110
+ * the rule's own filters (or a camera mute) left out, by reason.
19111
+ * `excludedGroups` names the kind groups selected that have no state to report
19112
+ * (backups & exports).
19113
+ */
19114
+ var NcStateSummaryPreviewSchema = object({
19115
+ empty: boolean(),
19116
+ count: number().int().nonnegative(),
19117
+ text: string(),
19118
+ sections: array(NcStateSummaryPreviewSectionSchema),
19119
+ dropped: record(string(), number().int().nonnegative()),
19120
+ excludedGroups: array(string())
19121
+ });
19048
19122
  var NcTestResultSchema = object({
19049
19123
  recordId: string(),
19050
19124
  recordKind: _enum([
@@ -19136,6 +19210,13 @@ var NcTemplateVarDescriptorSchema = object({
19136
19210
  kinds: array(NcTemplateVarKindSchema).optional(),
19137
19211
  deliveries: array(NcDeliverySchema).optional(),
19138
19212
  systemEventKinds: array(NcSystemEventKindSchema).optional(),
19213
+ /**
19214
+ * Which system-event DELIVERY has a value for it (D647). Absent = an
19215
+ * instant row only when the descriptor names `systemEventKinds` (a
19216
+ * per-event fact: a summary row has no single device), and both otherwise.
19217
+ * `['summary']` marks the state-summary vocabulary (`{{summaryText}}`, ...).
19218
+ */
19219
+ systemEventDeliveries: array(NcSystemEventDeliveryModeSchema).optional(),
19139
19220
  dynamic: object({
19140
19221
  prefix: literal("count_"),
19141
19222
  from: literal("classes")
@@ -19148,7 +19229,9 @@ var NcTemplatePreviewInputSchema = object({
19148
19229
  field: NcTemplateFieldSchema,
19149
19230
  kind: NcRuleKindSchema.optional(),
19150
19231
  delivery: NcDeliverySchema.optional(),
19151
- systemEventKinds: array(NcSystemEventKindSchema).optional()
19232
+ systemEventKinds: array(NcSystemEventKindSchema).optional(),
19233
+ /** The rule's system-event delivery (D647); absent = instant. */
19234
+ systemEventDelivery: NcSystemEventDeliveryModeSchema.optional()
19152
19235
  }),
19153
19236
  template: object({
19154
19237
  title: string().max(500).optional(),
@@ -19682,6 +19765,10 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
19682
19765
  }), object({ results: array(NcTestResultSchema) }), {
19683
19766
  kind: "mutation",
19684
19767
  auth: "admin"
19768
+ }), method(object({ rule: NcRuleInputSchema }), NcStateSummaryPreviewSchema, {
19769
+ kind: "mutation",
19770
+ auth: "admin",
19771
+ access: "view"
19685
19772
  }), method(object({}), object({
19686
19773
  catalog: array(NcConditionDescriptorSchema),
19687
19774
  taxonomy: NcTaxonomySchema.optional()
@@ -20028,1191 +20115,367 @@ var OauthIntegrationDescriptorSchema = object({
20028
20115
  });
20029
20116
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
20030
20117
  /**
20031
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
20032
- * within the frame, so the executor can re-cut a leaf child ROI at native
20033
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
20118
+ * pipeline-analytics — device-scoped wrapper cap. Refines raw
20119
+ * per-frame detections emitted by the pipeline runner into tracked
20120
+ * objects, per-kind event collections (motion / object / audio), and
20121
+ * persisted media. Owns the post-detection domain end-to-end:
20122
+ *
20123
+ * runner emits PipelineInferenceResult
20124
+ * ↓ (event bus)
20125
+ * pipeline-analytics subscriber
20126
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
20127
+ * → three DB collections (one per kind), one FS media tree, one
20128
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
20129
+ * DetectionEvent on bus)
20130
+ *
20131
+ * Pure subscriber model. No `processFrame` cap method — the runner
20132
+ * already publishes the raw frame on the bus. The cap surface is
20133
+ * only QUERIES + per-device settings, bound on/off via
20134
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
20135
+ * every camera with a detection pipeline wants its raw detections
20136
+ * refined; operators opt out per-device via BindingsTab when needed.
20137
+ *
20138
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
20139
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
20034
20140
  */
20035
- var NativeCropRefSchema = object({
20036
- /** Handle keying the retained native surface (node-pinned to its owner). */
20037
- handle: FrameHandleSchema,
20038
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
20039
- cropFrameSpace: object({
20040
- x: number(),
20041
- y: number(),
20042
- w: number(),
20043
- h: number()
20044
- })
20045
- });
20046
- object({
20047
- crop: object({
20048
- left: number(),
20049
- top: number(),
20050
- width: number().positive(),
20051
- height: number().positive()
20052
- }).optional(),
20053
- content: object({
20054
- width: number().int().positive(),
20055
- height: number().int().positive()
20056
- }),
20057
- fit: _enum(["stretch", "contain"]),
20058
- format: _enum([
20059
- "rgb",
20060
- "gray",
20061
- "jpeg"
20062
- ])
20063
- });
20141
+ var TrackStateSchema = _enum([
20142
+ "new",
20143
+ "entered",
20144
+ "left",
20145
+ "moving",
20146
+ "idle"
20147
+ ]);
20148
+ var EventKindSchema = _enum([
20149
+ "motion",
20150
+ "object",
20151
+ "audio"
20152
+ ]);
20064
20153
  /**
20065
- * Process-local frame identity. It is serializable so it can ride an in-process
20066
- * capability call, but `registryId` deliberately prevents resolution in any
20067
- * other process or execution group.
20154
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
20155
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
20156
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
20068
20157
  */
20069
- var FrameRefSchema = object({
20070
- registryId: string().min(1),
20071
- id: string().min(1),
20072
- width: number().int().positive(),
20073
- height: number().int().positive(),
20074
- format: _enum(["rgb", "gray"]),
20075
- timestamp: number(),
20076
- capturedAt: number().optional()
20077
- });
20078
- var ModelFormatSchema$1 = _enum([
20079
- "onnx",
20080
- "coreml",
20081
- "openvino",
20082
- "tflite",
20083
- "pt",
20084
- "gguf"
20158
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
20159
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
20160
+ var EventKindIconSchema = _enum([
20161
+ "motion",
20162
+ "audio",
20163
+ "person",
20164
+ "vehicle",
20165
+ "animal",
20166
+ "door",
20167
+ "pir",
20168
+ "smoke",
20169
+ "water",
20170
+ "button",
20171
+ "package",
20172
+ "generic"
20085
20173
  ]);
20086
- var PipelineSlotSchema = _enum([
20087
- "detector",
20088
- "cropper",
20089
- "classifier",
20090
- "refiner",
20091
- "audio-classifier"
20174
+ var EventKindCategorySchema = _enum([
20175
+ "motion",
20176
+ "audio",
20177
+ "detection",
20178
+ "sensor",
20179
+ "control",
20180
+ "custom",
20181
+ "package"
20092
20182
  ]);
20093
- var PipelineEngineChoiceSchema = object({
20094
- runtime: _enum(["node", "python"]),
20095
- backend: string(),
20096
- format: ModelFormatSchema$1,
20097
- device: string().optional()
20098
- });
20099
- var AvailableEngineSchema = object({
20100
- engine: PipelineEngineChoiceSchema,
20101
- devices: array(object({
20102
- id: string(),
20103
- label: string(),
20104
- description: string().optional()
20105
- })).readonly(),
20106
- defaultDevice: string()
20107
- });
20108
- var PipelineDefaultStepSchema = lazy(() => object({
20109
- addonId: string(),
20110
- addonName: string(),
20111
- slot: PipelineSlotSchema,
20112
- inputClasses: array(string()).readonly(),
20113
- outputClasses: array(string()).readonly(),
20114
- enabled: boolean(),
20115
- modelId: string(),
20116
- children: array(PipelineDefaultStepSchema).readonly(),
20117
- group: string().optional(),
20118
- settings: record(string(), unknown()).optional()
20119
- }));
20120
- var PipelineTemplateStepSchema = lazy(() => object({
20121
- addonId: string(),
20122
- enabled: boolean(),
20123
- modelId: string(),
20124
- children: array(PipelineTemplateStepSchema).readonly(),
20125
- settings: record(string(), unknown()).optional()
20126
- }));
20127
- var PipelineTemplateSchema$1 = object({
20128
- id: string(),
20129
- name: string(),
20130
- createdAt: string(),
20131
- updatedAt: string(),
20132
- engine: PipelineEngineChoiceSchema,
20133
- steps: array(PipelineTemplateStepSchema).readonly()
20134
- });
20135
- var PipelineModelOptionSchema = object({
20136
- id: string(),
20137
- name: string(),
20138
- formats: record(string(), object({
20139
- downloaded: boolean(),
20140
- sizeMB: number()
20141
- })),
20142
- group: ModelVariantGroupSchema.optional(),
20143
- legacy: boolean().optional(),
20144
- provider: ModelProviderIdSchema.optional()
20145
- });
20146
- var ConfigFieldBridge = custom();
20147
- var PipelineAddonSchemaSchema = object({
20148
- id: string(),
20149
- name: string(),
20150
- slot: PipelineSlotSchema,
20151
- inputClasses: array(string()).readonly(),
20152
- outputClasses: array(string()).readonly(),
20153
- childSlots: array(PipelineSlotSchema).readonly(),
20154
- models: array(PipelineModelOptionSchema).readonly(),
20155
- defaultModelId: string(),
20156
- defaultModelIdByFormat: record(string(), string()).optional(),
20157
- enabledByDefault: boolean().optional(),
20158
- backfillIntoExistingOverrides: boolean().optional(),
20159
- defaultConfidence: number(),
20160
- group: string().optional(),
20161
- configSchema: array(ConfigFieldBridge).readonly().optional()
20162
- });
20163
- var PipelineSlotSchemaSchema = object({
20164
- id: PipelineSlotSchema,
20183
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
20184
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
20185
+ var EventKindDescriptorSchema = object({
20186
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
20187
+ kind: string(),
20188
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
20189
+ labelKey: string(),
20190
+ /** English fallback label (kept for clients that don't translate). */
20165
20191
  label: string(),
20166
- priority: number(),
20167
- parentSlot: PipelineSlotSchema.nullable(),
20168
- addons: array(PipelineAddonSchemaSchema).readonly()
20169
- });
20170
- var PipelineSchemaSchema = object({
20171
- availableEngines: array(AvailableEngineSchema).readonly(),
20172
- selectedEngine: PipelineEngineChoiceSchema,
20173
- slots: array(PipelineSlotSchemaSchema).readonly()
20174
- });
20175
- var EngineProvisioningSchema = object({
20176
- runtimeId: _enum([
20177
- "onnx",
20178
- "openvino",
20179
- "coreml",
20180
- "edgetpu"
20181
- ]).nullable(),
20182
- device: string().nullable(),
20183
- state: _enum([
20184
- "idle",
20185
- "installing",
20186
- "verifying",
20187
- "ready",
20188
- "failed"
20189
- ]),
20190
- progress: number().optional(),
20191
- error: string().optional(),
20192
- nextRetryAt: number().optional(),
20193
- /**
20194
- * Gate A (config-correctness gate at engine change): human-readable
20195
- * config issues surfaced EAGERLY when the node's engine changes — model
20196
- * substitutions ("chose X, running Y") and zero-build steps ("no model
20197
- * has a <format> build"). Additive/optional: informational only, never
20198
- * enforced here — `assertEngineReady` (readiness) still gates inference.
20199
- * Absent/empty when the node-default tree resolves cleanly.
20200
- */
20201
- configIssues: array(string()).optional()
20202
- });
20203
- var PipelineStepInputSchema = lazy(() => object({
20204
- addonId: string(),
20205
- modelId: string().optional(),
20206
- enabled: boolean().default(true),
20207
- children: array(PipelineStepInputSchema).optional(),
20208
- settings: record(string(), unknown()).optional(),
20209
- jumpDeviceKey: string().optional()
20210
- }));
20211
- var ModelSubstitutionSchema = object({
20212
- addonId: string(),
20213
- chosen: string(),
20214
- running: string(),
20215
- format: string()
20216
- });
20217
- var PipelineValidationIssueSchema = object({
20218
- addonId: string(),
20219
- kind: _enum(["unknown-addon", "no-format-build"]),
20220
- detail: string()
20221
- });
20222
- var PipelineValidationResultSchema = object({
20223
- ok: boolean(),
20224
- issues: array(PipelineValidationIssueSchema).readonly(),
20225
- substitutions: array(ModelSubstitutionSchema).readonly(),
20226
- /** The node's `currentEngine.format` this validation ran against. */
20227
- format: string()
20228
- });
20229
- var ReferenceImageEntrySchema = object({
20230
- filename: string(),
20231
- stepIds: array(string()).readonly().optional()
20232
- });
20233
- var ReferenceImageBodySchema = object({
20234
- base64: string(),
20235
- filename: string()
20192
+ /** Hex color for timeline/legend rendering. */
20193
+ color: string(),
20194
+ /** Dictionary id → lucide component on the UI side. */
20195
+ iconId: string(),
20196
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
20197
+ icon: EventKindIconSchema,
20198
+ category: EventKindCategorySchema,
20199
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
20200
+ parentKind: string().nullable(),
20201
+ /** Derived from `parentKind`, explicit for the client tree. */
20202
+ level: EventKindLevelSchema,
20203
+ /** Which cap + device contributes this kind. For built-ins the camera
20204
+ * itself; for sensor kinds the LINKED source device. */
20205
+ source: object({
20206
+ capName: string(),
20207
+ deviceId: number()
20208
+ })
20236
20209
  });
20237
- var ReferenceAudioEntrySchema = object({
20238
- filename: string(),
20239
- sizeKb: number()
20210
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
20211
+ var EventKindsForDeviceSchema = object({
20212
+ deviceId: number(),
20213
+ kinds: array(EventKindDescriptorSchema).readonly()
20240
20214
  });
20241
- var ReferenceAudioBodySchema = object({ base64: string() });
20242
- var AudioBackendSchema = object({
20215
+ var SensorEventSchema = object({
20243
20216
  id: string(),
20244
- name: string(),
20245
- description: string(),
20246
- available: boolean(),
20217
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
20218
+ * yields N rows, one per camera). */
20219
+ deviceId: number(),
20220
+ /** The linked sensor device whose state changed. */
20221
+ sourceDeviceId: number(),
20222
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
20223
+ kind: string(),
20224
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
20225
+ value: record(string(), unknown()).nullable(),
20226
+ timestamp: number()
20227
+ });
20228
+ /**
20229
+ * One stored sighting on a track's trajectory.
20230
+ *
20231
+ * The array these live in is returned in TIME order (D399) — it is APPENDED in
20232
+ * arrival order, and the two detector passes interleave, so a consumer must not
20233
+ * assume the two are the same on a row written by an older build.
20234
+ */
20235
+ var TrackPositionSchema = object({
20236
+ x: number(),
20237
+ y: number(),
20238
+ timestamp: number(),
20239
+ bbox: BoundingBoxSchema,
20247
20240
  /**
20248
- * Raw classifier labels this backend can emit (e.g. YAMNet's
20249
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
20250
- * the benchmark UI to populate the `enabledMicroClasses` filter
20251
- * specific to the selected backend without a separate fetch.
20241
+ * Which detector pass measured this box (D399): `frame` is the full-frame
20242
+ * pass on the analysis raster, `recovery` is the native-resolution
20243
+ * small-subject second pass (D377/D378). Both write into one array, and until
20244
+ * this field existed the only way to tell them apart was that full-frame boxes
20245
+ * are exact multiples of 1.2 while recovery boxes are full-precision floats.
20246
+ * Absent on rows written before D399.
20252
20247
  */
20253
- rawLabels: array(string()).readonly().optional()
20248
+ source: _enum(["frame", "recovery"]).optional(),
20249
+ /** Detection score of this box, so a position can be weighed and not only
20250
+ * plotted. Absent on rows written before D399. */
20251
+ score: number().optional()
20254
20252
  });
20255
- var AudioCapabilitiesSchema = object({
20256
- activeBackend: string(),
20257
- availableBackends: array(AudioBackendSchema).readonly(),
20258
- sampleRate: number(),
20259
- chunkDurationMs: number()
20253
+ var TrackSnapshotSchema = object({
20254
+ timestamp: number(),
20255
+ position: TrackPositionSchema,
20256
+ /** The snapshot's media row id (D482); resolve via `listTrackMedia({ trackId })`. */
20257
+ mediaId: number().int()
20260
20258
  });
20261
- var DownloadModelResultSchema = object({
20262
- filePath: string(),
20263
- sizeMB: number(),
20264
- durationMs: number()
20259
+ /**
20260
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
20261
+ * divided by the track's detection-frame dims), computed at persist time.
20262
+ * Absent when the frame dims were unknown when the track was persisted
20263
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
20264
+ */
20265
+ var TrackEnvelopeSchema = object({
20266
+ minX: number(),
20267
+ minY: number(),
20268
+ maxX: number(),
20269
+ maxY: number()
20265
20270
  });
20266
20271
  /**
20267
- * Wrapper carrying a single test run's result. Replaces the legacy
20268
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
20269
- * canonical `AudioResult` from the Phase 6 output rework: one
20270
- * `AudioDetection` per class above `minScore`, top-N candidates in
20271
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
20272
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
20273
- * benchmark UI can still report a clean failure when the classifier
20274
- * cap isn't available.
20272
+ * Row projection for track list queries. `full` (default) returns the
20273
+ * complete Track including the frame-rate `positions[]` history and the
20274
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
20275
+ * keeps every scalar the list surfaces actually render (ids, class(es),
20276
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
20277
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
20278
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
20279
+ * `getTrack`. Mirrors the event-store `projection` convention
20280
+ * (`getObjectEvents` et al.).
20275
20281
  */
20276
- var AudioTestResultSchema = object({
20277
- success: boolean(),
20278
- error: string().optional(),
20279
- frame: custom().optional()
20282
+ var TrackProjectionSchema = _enum(["full", "slim"]);
20283
+ /**
20284
+ * One audio-classification label heard on the track's camera while the
20285
+ * track was alive, aggregated per label. An "episode" is one persisted
20286
+ * audio event (the confident-classification path: score ≥ the device's
20287
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
20288
+ * one 32 ms inference chunk, so counts stay human-scaled.
20289
+ */
20290
+ var TrackAudioLabelSchema = object({
20291
+ label: string(),
20292
+ /** Highest classification score observed across the label's episodes. */
20293
+ peakScore: number(),
20294
+ /** Number of coalesced audio-event episodes carrying this label. */
20295
+ count: number(),
20296
+ firstAt: number(),
20297
+ lastAt: number()
20280
20298
  });
20281
- var PipelineConfigBridge = custom();
20282
- var ConfigUISchemaBridge = custom();
20283
- var ConfigUISchemaNullableBridge = custom();
20284
- var InferenceCapabilitiesBridge = custom();
20285
- var ModelAvailabilityListBridge = custom();
20286
- var PipelineRunResultBridge = custom();
20287
20299
  /**
20288
- * Pipeline executor — detection engine + configuration + inference API.
20300
+ * How a track was produced. `pipeline` (default / absent) = the spatial
20301
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
20302
+ * no positions, a single snapshot, and no bbox trajectory at all:
20289
20303
  *
20290
- * Merged from: pipeline-executor, pipeline-config, inference, detection-config.
20291
- * Implemented by the detection-pipeline addon.
20304
+ * - `sensor` — a linked sensor/control device state change.
20305
+ * - `audio` — an audio event on the camera itself that was anomalous for
20306
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
20292
20307
  *
20293
- * Per-device surface (DeviceSettingsContribution + the "is detection
20294
- * enabled for this camera?" toggle) lives on the paired
20295
- * `detection-pipeline` cap (device-scoped, singleton, wrapper
20296
- * defaultActive) — same split pattern used by stream-broker /
20297
- * camera-streams and audio-analyzer / audio-analysis.
20308
+ * - `onboard` — the CAMERA's own firmware, paired with a decoded frame in
20309
+ * that frame's pixel space. A real root detector and a SPATIAL one: its
20310
+ * boxes are the same kind of fact `pipeline`'s are, produced by a different
20311
+ * detector.
20312
+ *
20313
+ * `onboard` was missing here while `DetectionSourceSchema` already had it, so
20314
+ * a persisted onboard track failed `safeParse` on read and came back with NO
20315
+ * source at all — which `isSpatialTrack` then admitted by accident, through the
20316
+ * `undefined` arm rather than by anybody's decision, and which `excludeSources`
20317
+ * could not name.
20318
+ *
20319
+ * The spatial subsystems (tracker association, occupancy count, re-id /
20320
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
20321
+ * with `isSpatialTrack`, which allow-lists the spatial sources explicitly — a
20322
+ * `!== 'sensor'` check silently readmits every source added after it was
20323
+ * written.
20298
20324
  */
20299
- var pipelineExecutorCapability = {
20300
- name: "pipeline-executor",
20301
- scope: "system",
20302
- mode: "singleton",
20303
- methods: {
20304
- getAvailableEngines: method(_void(), array(PipelineEngineChoiceSchema)),
20305
- getSelectedEngine: method(_void(), PipelineEngineChoiceSchema),
20306
- getDefaultSteps: method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)),
20307
- /**
20308
- * Per-node detection-engine provisioning snapshot. Returns the live
20309
- * state of the lazy runtime-provisioning machine on `nodeId`
20310
- * (idle / installing / verifying / ready / failed). The UI pairs this
20311
- * one-shot query with the `pipeline.engine-provisioning` live event
20312
- * (emitted on every transition) to drive a per-node "engine ready?"
20313
- * indicator without polling. Phase 2.
20314
- */
20315
- getEngineProvisioning: method(object({ nodeId: string() }), EngineProvisioningSchema),
20316
- getVideoPipelineSteps: method(_void(), record(string(), object({
20317
- modelId: string(),
20318
- settings: record(string(), unknown()).readonly()
20319
- }))),
20320
- setVideoPipelineSteps: method(object({ steps: record(string(), object({
20321
- modelId: string(),
20322
- settings: record(string(), unknown()).readonly()
20323
- })) }), object({ success: literal(true) }), {
20324
- kind: "mutation",
20325
- auth: "admin"
20326
- }),
20327
- /**
20328
- * Clear THIS node's executor-side PER-DEVICE settings stores (the
20329
- * per-camera step overrides the object-detection root reads via
20330
- * `applyDeviceOverridesToTree`). `nodeId` is the ROUTING key — the
20331
- * generated cap-router strips it (default `nodeIdMode: 'routing'`) and
20332
- * dispatches to that node, so the provider method runs ON the target
20333
- * node and receives no `nodeId`.
20334
- *
20335
- * This is the slimmed executor leg of the orchestrator's
20336
- * `resetNodePipelineDefaults` flow (which owns the real reset: node
20337
- * addonDefaults pins + per-camera orchestrator overrides). The legacy
20338
- * `resetToDefault` — which reset a persisted global step-tree seed
20339
- * nothing in the live per-camera path read — was removed together with
20340
- * that seed.
20341
- */
20342
- clearDeviceOverrides: method(object({ nodeId: string() }), object({
20343
- success: literal(true),
20344
- clearedDevices: number()
20345
- }), {
20346
- kind: "mutation",
20347
- auth: "admin"
20348
- }),
20349
- /**
20350
- * Which of THIS node's inference devices the executor currently refuses,
20351
- * and why. `nodeId` is the ROUTING key (stripped by the generated router).
20352
- *
20353
- * The channel that did not exist. Pool health was known only inside the
20354
- * detection addon and was an input to no routing decision anywhere: the
20355
- * per-dispatch capability gate is keyed on model FORMAT and so can never
20356
- * separate `openvino:gpu` from `openvino:npu`, and the orchestrator's live
20357
- * eligibility probe (`platformProbe.getCapabilities`) answers about
20358
- * HARDWARE — which was present throughout. So when the hub's `openvino:gpu`
20359
- * Python worker was SIGABRT'd by the Intel GPU plugin on 2026-08-25, the
20360
- * balancer went on handing that dead pool cameras by rotation for 31 hours:
20361
- * ~370 000 `PoolWorker[w0]: not initialized` lines, every frame lost.
20362
- *
20363
- * Read semantics the caller depends on, and which the provider guarantees:
20364
- * this is a synchronous read of in-memory state. It never probes hardware,
20365
- * never spawns a pool and never throws — an EMPTY `unhealthy` means "asked,
20366
- * nothing is refused", which is what re-admits a device. A read that FAILS
20367
- * (node offline, version skew) must therefore be distinguishable from an
20368
- * empty answer, and it is: it rejects.
20369
- */
20370
- getInferenceDeviceHealth: method(object({ nodeId: string() }), object({ unhealthy: array(object({
20371
- /** `<backend>:<device>`, e.g. `openvino:gpu`. */
20372
- deviceKey: string(),
20373
- /**
20374
- * `failed` — the per-device restart budget is exhausted; no pool
20375
- * will be spawned until an operator re-arms it or the runner
20376
- * respawns. `backoff` — under budget, waiting out the backoff (or
20377
- * a cached pool observed dead and not yet condemned).
20378
- */
20379
- state: _enum(["failed", "backoff"]),
20380
- /** Epoch ms of the death that produced this state. */
20381
- since: number(),
20382
- /** Pool deaths inside the current window. */
20383
- deaths: number(),
20384
- /** The last death's message. */
20385
- lastError: string()
20386
- })).readonly() })),
20387
- /**
20388
- * Re-arm a terminally `failed` inference device on `nodeId`: forget its
20389
- * restart budget so the next dispatch builds a fresh pool.
20390
- *
20391
- * The terminal state is deliberate (the abort it bounds is deterministic —
20392
- * an automatic probation would just respawn Python forever, more slowly),
20393
- * and a terminal state an operator cannot leave is a silent fault. This is
20394
- * the way out. `rearmed:false` means there was nothing to forget.
20395
- */
20396
- rearmInferenceDevice: method(object({
20397
- nodeId: string(),
20398
- deviceKey: string()
20399
- }), object({ rearmed: boolean() }), {
20400
- kind: "mutation",
20401
- auth: "admin"
20402
- }),
20403
- getSchema: method(_void(), PipelineSchemaSchema),
20404
- getGlobalSteps: method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()),
20405
- getGlobalPipelineConfig: method(_void(), PipelineConfigBridge),
20406
- getOrchestratorConfigSchema: method(_void(), ConfigUISchemaBridge),
20407
- /**
20408
- * Gate B (pre-init config-correctness gate). PURE COMPUTE against this
20409
- * node's `currentEngine.format` — resolves `steps` the same way the
20410
- * runtime dispatch path would, and reports what WOULD happen without
20411
- * touching any node-global state. Called by the orchestrator at attach
20412
- * time (`attachOn`), node-pinned to the TARGET node, so config problems
20413
- * surface BEFORE `pipelineRunner.attachCamera` rather than at the first
20414
- * per-frame resolve. `ok` is false iff `issues` is non-empty (both
20415
- * `unknown-addon` and `no-format-build` are HARD issues); `substitutions`
20416
- * is informational (a degraded-but-loadable model swap) and never
20417
- * affects `ok`. Never throws.
20418
- */
20419
- validatePipeline: method(object({ steps: array(PipelineStepInputSchema) }), PipelineValidationResultSchema),
20420
- listTemplates: method(_void(), array(PipelineTemplateSchema$1).readonly()),
20421
- saveTemplate: method(object({
20422
- name: string(),
20423
- steps: array(PipelineTemplateStepSchema).readonly(),
20424
- engine: PipelineEngineChoiceSchema
20425
- }), PipelineTemplateSchema$1, { kind: "mutation" }),
20426
- updateTemplate: method(object({
20427
- id: string(),
20428
- name: string().optional(),
20429
- steps: array(PipelineTemplateStepSchema).readonly().optional()
20430
- }), PipelineTemplateSchema$1, { kind: "mutation" }),
20431
- deleteTemplate: method(object({ id: string() }), _void(), { kind: "mutation" }),
20432
- getCapabilities: method(_void(), InferenceCapabilitiesBridge),
20433
- getAddonModels: method(object({ addonId: string() }), ModelAvailabilityListBridge),
20434
- downloadModel: method(object({
20435
- addonId: string(),
20436
- modelId: string(),
20437
- format: ModelFormatSchema$1
20438
- }), DownloadModelResultSchema, { kind: "mutation" }),
20439
- deleteModel: method(object({
20440
- addonId: string(),
20441
- modelId: string(),
20442
- format: ModelFormatSchema$1
20443
- }), object({ success: literal(true) }), { kind: "mutation" }),
20444
- /**
20445
- * Stateless single-frame execution. Callers (runner, benchmark) pass
20446
- * the complete `engine` + `steps` tree; the executor holds no state
20447
- * about cameras or saved pipelines.
20448
- *
20449
- * `engine` is optional during the migration window to preserve the
20450
- * legacy call shape used by existing benchmark code; once all
20451
- * callers pass it explicitly we make it required.
20452
- *
20453
- * Exactly one of `frame`, `frameRef`, `frameHandle`, `imageBase64`,
20454
- * `referenceImage` must be provided:
20455
- * - `frame`: runtime dispatch path (runner → decoded broker frame).
20456
- * Carries the raw buffer, dimensions, and format; the executor
20457
- * uses it directly without base64 round-tripping.
20458
- * - `frameHandle` (CB5): a zero-pixel shm `FrameHandle` for the SAME
20459
- * decoded frame. Both runner and executor are hub-local processes
20460
- * sharing `/dev/shm`, so the executor maps the named segment and
20461
- * reads the pixels back zero-copy — eliminating the ~1.2MB
20462
- * re-serialisation over UDS/MsgPack the `frame` path pays per call.
20463
- * High-risk: the FrameRing is a latest-wins seqlock with no
20464
- * refcount, so a recycled slot yields a null read; the executor
20465
- * then degrades to an empty result and the runner ships pixels via
20466
- * `frame` as the fallback (queue-depth gated on the runner side).
20467
- * - `imageBase64`: one-shot test path (benchmark ImageTab).
20468
- * - `referenceImage`: named file from the reference-image store.
20469
- */
20470
- runPipeline: method(object({
20471
- engine: PipelineEngineChoiceSchema.optional(),
20472
- steps: array(PipelineStepInputSchema).min(1),
20473
- frame: FrameInputSchema.optional(),
20474
- /**
20475
- * Process-local lazy frame. Valid only when caller and provider resolve
20476
- * in the same execution-group process; split/cross-node callers use
20477
- * `frame`/`image` inline compatibility instead.
20478
- */
20479
- frameRef: FrameRefSchema.optional(),
20480
- /**
20481
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
20482
- * the decoded pixels live in. One more member of the one-of
20483
- * frame/frameHandle/image/imageBase64/referenceImage group.
20484
- */
20485
- frameHandle: FrameHandleSchema.optional(),
20486
- imageBase64: string().optional(),
20487
- /**
20488
- * Binary JPEG bytes — preferred over `imageBase64` on internal
20489
- * hops (hub → forked worker via Moleculer MsgPack) because it
20490
- * skips the 33% base64 overhead + the per-call base64 decode on
20491
- * the detection-pipeline worker. Callers can pass either; exactly
20492
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
20493
- */
20494
- image: _instanceof(Uint8Array).optional(),
20495
- referenceImage: string().optional(),
20496
- deviceId: number().optional(),
20497
- sessionId: string().optional(),
20498
- /**
20499
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
20500
- * reference-image, and detail-subtree calls. 'frame' is the live
20501
- * per-frame dispatch: ONLY root-plane steps run; crop children
20502
- * (inputClasses ≠ null) are skipped and served per-track via
20503
- * pipelineRunner.runDetailSubtree (two-plane design).
20504
- */
20505
- plane: _enum(["full", "frame"]).optional(),
20506
- /**
20507
- * Inference-device selector (Phase 2 multi-device). Format
20508
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
20509
- * Omitted ⇒ the runner's default device (current single-engine
20510
- * behaviour). Selects WHICH device pool of the node runs the call.
20511
- */
20512
- deviceKey: string().optional(),
20513
- /**
20514
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
20515
- * when the parent crop was resolved from the frame's retained NATIVE
20516
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
20517
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
20518
- * resolution from that surface — the SAME quality path faces already
20519
- * had — instead of the downscaled parent tile. `handle` keys the native
20520
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
20521
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
20522
- * the executor's crop-normalized child ROI back into frame-normalized
20523
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
20524
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
20525
- * (today's behaviour on the fallback path).
20526
- */
20527
- nativeCropRef: NativeCropRefSchema.optional()
20528
- }), PipelineRunResultBridge, { kind: "mutation" }),
20529
- /**
20530
- * Batched run — N raw frames packed into one cap call. The provider
20531
- * routes the batch through `SharedInferencePool.inferBatch`
20532
- * (`MSG_INFER_BATCH = 0x03`) so the IPC framing and JSON response
20533
- * envelope cost is amortised N:1 vs N concurrent `runPipeline`
20534
- * calls. Single root step + uniform model assumed; trees with crop
20535
- * children fall back to sequential execution.
20536
- *
20537
- * Used by `scripts/bench-batch-style.mts` for batch benchmarking —
20538
- * N frames in one call to amortise per-call IPC overhead.
20539
- */
20540
- runPipelineBatch: method(object({
20541
- engine: PipelineEngineChoiceSchema.optional(),
20542
- steps: array(PipelineStepInputSchema).min(1),
20543
- frames: array(FrameInputSchema).min(1).max(255),
20544
- deviceId: number().optional(),
20545
- sessionId: string().optional(),
20546
- /**
20547
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
20548
- * the batch to the Python pool's bench preprocess cache
20549
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
20550
- * preprocessed ONCE and every later inference is a pure-inference cache
20551
- * hit — the sustained-throughput run measures inference, not
20552
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
20553
- * full preprocess every call, correct). Fresh per sustained run;
20554
- * released via `uncacheFrame`.
20555
- */
20556
- frameId: number().int().nonnegative().optional(),
20557
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
20558
- deviceKey: string().optional()
20559
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }),
20560
- /**
20561
- * Cache a raw frame inside the Python inference pool's memory.
20562
- * Returns a numeric `frameId` that `inferCached` references —
20563
- * subsequent calls send only 5 bytes through the pipe instead of
20564
- * 1.2MB raw data, eliminating the pipe transfer bottleneck.
20565
- */
20566
- cacheFrameInPool: method(object({
20567
- data: _instanceof(Uint8Array),
20568
- width: number().int().positive(),
20569
- height: number().int().positive(),
20570
- format: _enum([
20571
- "rgb",
20572
- "bgr",
20573
- "gray"
20574
- ])
20575
- }), object({
20576
- frameId: number(),
20577
- width: number(),
20578
- height: number()
20579
- }), { kind: "mutation" }),
20580
- /**
20581
- * Run inference on a previously cached frame. Sends only 5 bytes
20582
- * (model_idx + frameId) through the IPC pipe — eliminates the
20583
- * ~35ms per-call overhead of transferring 1.2MB raw data.
20584
- */
20585
- inferCached: method(object({
20586
- stepId: string(),
20587
- frameId: number().int()
20588
- }), record(string(), unknown()), { kind: "mutation" }),
20589
- /**
20590
- * Release a cached frame from the Python pool's memory.
20591
- */
20592
- uncacheFrame: method(object({ frameId: number().int() }), _void(), { kind: "mutation" }),
20593
- /** Returns the effective pool tuning (resolved from user overrides + backend defaults). */
20594
- getEffectiveTuning: method(_void(), object({
20595
- batchMode: string(),
20596
- windowMs: number(),
20597
- maxBatchSize: number(),
20598
- concurrency: number()
20599
- })),
20600
- /**
20601
- * List every EngineFactory currently loaded in this executor's RAM,
20602
- * with the models resident and a coarse "in use" marker derived from
20603
- * ongoing inference activity. Used by the Pipeline page Engines tab.
20604
- */
20605
- listLoadedEngines: method(_void(), array(object({
20606
- engineKey: string(),
20607
- engine: PipelineEngineChoiceSchema,
20608
- modelsLoaded: array(string()).readonly(),
20609
- inUseByCameras: array(number()).readonly(),
20610
- /**
20611
- * Origin of this resident factory.
20612
- * - `runtime` — main camera-serving engine (no idle TTL).
20613
- * - `warm-override` — benchmark/test override held in the warm
20614
- * cache; auto-disposed after the idle TTL.
20615
- * - `device-pool` — a concurrent per-device pool (Phase 2
20616
- * multi-device, keyed by `deviceKey`) resolved
20617
- * via `resolveDeviceFactory`. Runs alongside the
20618
- * `runtime` engine on a DIFFERENT accelerator
20619
- * (NPU / iGPU / Coral) — this is how the
20620
- * Engines tab shows all pools running at once.
20621
- */
20622
- kind: _enum([
20623
- "runtime",
20624
- "warm-override",
20625
- "device-pool"
20626
- ]),
20627
- /** Native pid of the underlying Python pool (null when no pool). */
20628
- poolPid: number().nullable(),
20629
- /** ms since this factory was last used (null when not warm-tracked). */
20630
- idleMs: number().nullable(),
20631
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
20632
- idleTtlMs: number().nullable()
20633
- })).readonly()),
20634
- /** Warm up an engine without running a frame. No-op if already loaded. */
20635
- spinEngine: method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
20636
- kind: "mutation",
20637
- auth: "admin"
20638
- }),
20639
- /**
20640
- * Unload an engine from RAM. `force:true` unloads even when cameras
20641
- * are actively using it (they re-spin on next frame). Default is
20642
- * gated — returns `{success:false, reason}` when in use.
20643
- */
20644
- killEngine: method(object({
20645
- engine: PipelineEngineChoiceSchema,
20646
- force: boolean().optional()
20647
- }), object({
20648
- success: boolean(),
20649
- reason: string().optional()
20650
- }), {
20651
- kind: "mutation",
20652
- auth: "admin"
20653
- }),
20654
- listReferenceImages: method(_void(), array(ReferenceImageEntrySchema).readonly()),
20655
- getReferenceImage: method(object({ filename: string() }), ReferenceImageBodySchema.nullable()),
20656
- getReferenceAudioFiles: method(_void(), array(ReferenceAudioEntrySchema).readonly()),
20657
- getReferenceAudio: method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()),
20658
- getAudioCapabilities: method(_void(), AudioCapabilitiesSchema),
20659
- runAudioTest: method(object({
20660
- addonId: string(),
20661
- modelId: string(),
20662
- filename: string().optional(),
20663
- settings: record(string(), unknown()).optional()
20664
- }), AudioTestResultSchema, { kind: "mutation" }),
20665
- getDetectionConfigSchema: method(_void(), ConfigUISchemaNullableBridge)
20666
- }
20667
- };
20325
+ var TrackSourceSchema = _enum([
20326
+ "pipeline",
20327
+ "onboard",
20328
+ "sensor",
20329
+ "audio"
20330
+ ]);
20668
20331
  /**
20669
- * Per-stage gating mode applied to the zones a rule references.
20332
+ * Where a track sits in the RETRAIN lifecycle (D81).
20670
20333
  *
20671
- * - `include`: the rule contributes to a **whitelist** for its stage.
20672
- * When at least one `include` rule fires for a stage, only entities
20673
- * inside one of those zones pass that stage.
20674
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
20675
- * Entities inside one of those zones are dropped at that stage.
20334
+ * - `none` — never marked, or un-marked. Evictable.
20335
+ * - `staging` — the operator wants this track as training material and has not
20336
+ * finished with it. **This is the only state retention holds**: the track and
20337
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
20338
+ * the device's age window.
20339
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
20340
+ * were COPIED into the retrain dataset at selection time, so the dataset no
20341
+ * longer depends on the track's media and the track becomes EVICTABLE again.
20342
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
20343
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
20676
20344
  *
20677
- * `monitor`-style observation (count without filtering) is not a rule
20678
- * mode — zones without any matching rule are observed naturally by
20679
- * `zone-analytics` (live snapshot + history), so an "I just want to
20680
- * count, not filter" use case needs no rule at all.
20345
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` so that
20346
+ * every row is selectable by a positive predicate. (The filter language has
20347
+ * since grown the NULL-safe `whereNot` / `whereNotIn` and an `IS NULL` reading
20348
+ * of `where: { f: null }`, which is how {@link TrackSourceSchema} can be
20349
+ * filtered on a NULLABLE column — see `excludeSources`. It did not when this
20350
+ * column was designed, and a NOT NULL column is still the better shape.)
20681
20351
  */
20682
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
20352
+ var RetrainStatusSchema = _enum([
20353
+ "none",
20354
+ "staging",
20355
+ "trained"
20356
+ ]);
20683
20357
  /**
20684
- * Per-consumer rule that references existing zones (geometry) and
20685
- * defines how a specific pipeline stage should treat them. Each
20686
- * consumer addon owns its own `ZoneRule[]` array in its per-device
20687
- * settings:
20358
+ * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
20359
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
20360
+ * so the two surfaces cannot drift.
20688
20361
  *
20689
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
20690
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
20691
- * - future: notification rules, audio gating, etc.
20362
+ * **Absent ≠ false.** A track that has never been touched omits the field; an
20363
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
20364
+ * columns existed read as absent, and a consumer that needs a boolean should say
20365
+ * `flag === true`, not `flag !== false`.
20692
20366
  *
20693
- * One rule applies to N zones (`zoneIds[]`) so the operator can
20694
- * express "ignore motion in ALL of {garden, street}" with a single
20695
- * rule. `classFilter` narrows the rule to specific object classes —
20696
- * "drop person detections in the street, but keep cars" is one
20697
- * `exclude` rule with `classFilter: ['person']`.
20367
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
20368
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
20369
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
20370
+ * `trained` track reports `false` while refusing both writes. The boolean is
20371
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
20372
+ * "never marked" from "already trained" must read `retrainStatus`.
20698
20373
  *
20699
- * `enabled` is a soft toggle — the operator can keep the rule
20700
- * configured but inert without deleting it.
20374
+ * `debug` does NOT pin; it is attention, not durability.
20375
+ *
20376
+ * `debugNote` is the operator's own words about WHAT should be checked on this
20377
+ * track, and it lives and dies with `debug` — see {@link MAX_TRACK_DEBUG_NOTE_LEN}.
20378
+ *
20379
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
20380
+ * A favourited track is skipped by retention the same way `staging` is, but
20381
+ * it does not enter `none|staging|trained` and has no staging budget.
20701
20382
  */
20702
- var ZoneRuleSchema = object({
20703
- /** Stable rule id — survives edits, used by the UI for diffing. */
20704
- id: string(),
20705
- /** Optional human-readable label rendered in the rule editor. */
20706
- name: string().optional(),
20707
- /** Zones this rule targets. The rule's `mode` applies to ALL
20708
- * listed zones (OR-set: a detection in any one of them counts).
20709
- * At least one zone id required — a rule with no targets is a
20710
- * configuration mistake and the form validator rejects it. */
20711
- zoneIds: array(string()).min(1).readonly(),
20712
- mode: ZoneRuleModeEnum,
20713
- /**
20714
- * Class names this rule applies to. Empty / undefined ⇒ rule
20715
- * applies to every class. Class strings match the `macroClass`
20716
- * field on detections (e.g. `person`, `car`, `dog`).
20717
- */
20718
- classFilter: array(string()).readonly().optional(),
20719
- /**
20720
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
20721
- * required to consider an entity "in the zone". Defaults to the
20722
- * consumer's stage default when omitted. Kept for back-compat with
20723
- * existing per-rule overrides; new operators pick the value via
20724
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
20725
- * set, the lower-level engine reads it as a 0–1 fraction.
20726
- */
20727
- overlapThreshold: number().min(0).max(1).optional(),
20383
+ var TrackFlagFields = {
20384
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
20385
+ * `'staging'`. */
20386
+ markForTrain: boolean().optional(),
20387
+ /** Operator marked this track for diagnostic attention. */
20388
+ debug: boolean().optional(),
20728
20389
  /**
20729
- * Operator-friendly version of `overlapThreshold` — the percentage
20730
- * of the detection's bbox that must lie inside the zone for the
20731
- * rule to match. Documented default is 85%; the engine substitutes
20732
- * that when the field is omitted (kept optional so existing rules
20733
- * stored without it stay valid).
20390
+ * What the operator wants CHECKED on this track, in their own words.
20734
20391
  *
20735
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
20736
- * rule, the engine prefers `bboxInclusionPct` because it's the
20737
- * field exposed in the UI. Internally both feed the same gate.
20738
- */
20739
- bboxInclusionPct: number().min(0).max(100).optional(),
20740
- /**
20741
- * When `true` and a detection has a segmentation mask, use the
20742
- * mask for overlap instead of the bbox. Detection-stage only;
20743
- * motion rules ignore this field.
20392
+ * The flag alone says "look at this" and nothing about what for; a debug set
20393
+ * reviewed hours later is a list of tracks with no question attached. Bound
20394
+ * to `debug` on the WRITE side — the body clears it when `debug` goes off,
20395
+ * and refuses it on a track whose debug is off — so a note can never outlive
20396
+ * the attention it belongs to.
20397
+ *
20398
+ * `''` is a real value ("marked, nothing to add"); the ABSENT key means
20399
+ * "leave whatever is stored alone", which is what lets a surface turn debug
20400
+ * on without a note (a cancelled prompt) and what lets it edit the note
20401
+ * without touching the flag.
20744
20402
  */
20745
- preferMask: boolean().optional(),
20403
+ debugNote: string().max(500).optional(),
20404
+ /** Operator favourited this track. Pins it against pruning. */
20405
+ favourited: boolean().optional()
20406
+ };
20407
+ /**
20408
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
20409
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
20410
+ * write patch, and the status is not something the toggle sets — it is what the
20411
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
20412
+ * always present on a persisted row (the column default materialises `'none'`).
20413
+ */
20414
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
20415
+ /**
20416
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
20417
+ * one flag can never clear the other — the toggles are independent and are
20418
+ * driven from three surfaces that do not know about each other.
20419
+ */
20420
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
20421
+ /**
20422
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
20423
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
20424
+ * mutation result without a re-fetch.
20425
+ */
20426
+ var TrackFlagsSchema = object({
20427
+ trackId: string(),
20428
+ markForTrain: boolean(),
20429
+ debug: boolean(),
20430
+ /** The note as it STANDS after the write — never absent here (a track with no
20431
+ * note reports `''`), for the same reason the booleans are required: a
20432
+ * surface that has just written must be able to render the note it now owns
20433
+ * without a re-fetch, and an absent key would read as "unchanged" on a
20434
+ * screen that has no previous value to keep. */
20435
+ debugNote: string(),
20436
+ favourited: boolean(),
20437
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
20438
+ * a track row) because this shape is only ever produced by the write body,
20439
+ * which always knows it — and a surface that has just written needs to render
20440
+ * `trained` without a re-fetch. */
20441
+ retrainStatus: RetrainStatusSchema
20442
+ });
20443
+ union([literal(1), literal(2)]);
20444
+ /**
20445
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
20446
+ * the step and model that produced it — which is what makes the write rule
20447
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
20448
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
20449
+ *
20450
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
20451
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
20452
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
20453
+ * that value has no provenance, and the write rule lets ANY properly-attributed
20454
+ * write of the same tier replace it regardless of score.
20455
+ */
20456
+ var LabelAttributionSchema = object({
20457
+ stepId: string(),
20458
+ modelId: string().optional(),
20459
+ decidedAt: number(),
20746
20460
  /**
20747
- * Soft-toggle: `false` disables the rule without deleting it.
20748
- * Defaults to `true` so operators creating a rule via the UI
20749
- * see it active immediately.
20461
+ * The GALLERY id behind a recognised tier-2 label — a face-gallery
20462
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
20463
+ *
20464
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
20465
+ * notification rule authored on "Gianluca" stopped matching the moment the
20466
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
20467
+ * the thing that does not move, so it is what a rule matches on
20468
+ * (`NcConditions.identities`) and the text is what a human is shown.
20469
+ *
20470
+ * Absent when the label names no gallery row — a plate the OCR read but no
20471
+ * vehicle claims, a sub-class, a species, any tier-1 value.
20750
20472
  */
20751
- enabled: boolean().default(true)
20473
+ identityId: string().optional()
20752
20474
  });
20753
- array(ZoneRuleSchema).readonly();
20754
20475
  /**
20755
- * Zone — pure geometry + identity. NO filtering behaviour.
20756
- *
20757
- * Zones describe **where** in the frame the operator wants to flag
20758
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
20759
- * each pipeline stage uses them. Splitting the two means a single
20760
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
20761
- * a detection-include rule on `['car']`, and an occupancy aggregate
20762
- * — without three duplicated polygons.
20763
- *
20764
- * Owned by the orchestrator addon (provider) and mirrored into the
20765
- * `zones` device-state slice on every mutation. Consumers
20766
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
20767
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
20768
- * mirror with `onChanged`).
20769
- *
20770
- * Coordinates are normalised fractions of the frame (0–1) so zones
20771
- * survive resolution changes and stream profile switches.
20772
- *
20773
- * `kind` discriminates between full polygons (closed regions used
20774
- * for intrusion / occupancy filters) and tripwires (open 2-point
20775
- * line segments used for cross events). Onboard / firmware-reported
20776
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
20777
- * task list.
20778
- */
20779
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
20780
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
20781
- var PolygonPointSchema = object({
20782
- x: number(),
20783
- y: number()
20784
- });
20785
- /** A camera detection zone — pure geometry/identity. */
20786
- var ZoneSchema = object({
20787
- id: string(),
20788
- name: string(),
20789
- kind: ZoneKindEnum.default("polygon"),
20790
- /** Polygon vertices, fraction of frame (0–1). */
20791
- polygon: array(PolygonPointSchema).readonly(),
20792
- /** Visual color for UI rendering. */
20793
- color: string().default("#3b82f6")
20794
- });
20795
- /**
20796
- * Zones capability — per-camera CRUD over polygon detection zones.
20797
- *
20798
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
20799
- * to per-device settings and mirrors into the `zones` device-state
20800
- * slice on every mutation, so downstream consumers can subscribe via
20801
- * `dev.state.zones.onChanged`.
20802
- *
20803
- * The cap surface only handles geometry + identity; filtering
20804
- * behaviour (per-class, include/exclude, threshold) lives in the
20805
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
20806
- * `capabilities/schemas/zone-rule.js`.
20807
- */
20808
- var zonesCapability = {
20809
- name: "zones",
20810
- scope: "device",
20811
- mode: "singleton",
20812
- deviceTypes: [DeviceType.Camera],
20813
- methods: {
20814
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
20815
- addZone: method(object({
20816
- deviceId: number(),
20817
- zone: ZoneSchema
20818
- }), _void(), {
20819
- kind: "mutation",
20820
- auth: "admin"
20821
- }),
20822
- removeZone: method(object({
20823
- deviceId: number(),
20824
- zoneId: string()
20825
- }), _void(), {
20826
- kind: "mutation",
20827
- auth: "admin"
20828
- }),
20829
- updateZone: method(object({
20830
- deviceId: number(),
20831
- zone: ZoneSchema
20832
- }), _void(), {
20833
- kind: "mutation",
20834
- auth: "admin"
20835
- })
20836
- },
20837
- /**
20838
- * Runtime-state slice — the live zone catalogue mirrored by the
20839
- * orchestrator on every CRUD mutation. Consumers read via
20840
- * `device.state.zones.value` / `.watch(...)` without round-tripping
20841
- * the cap, and the codegen DeviceProxy auto-wires the reactive
20842
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
20843
- * (e.g. zone groupings) can sit alongside the polygon list.
20844
- */
20845
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
20846
- /**
20847
- * 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.
20848
- *
20849
- * See `RuntimeStateDurability`. Enforced by
20850
- * `scripts/check-runtime-state-durability.ts`.
20851
- */
20852
- durability: "restored"
20853
- };
20854
- /**
20855
- * pipeline-analytics — device-scoped wrapper cap. Refines raw
20856
- * per-frame detections emitted by the pipeline runner into tracked
20857
- * objects, per-kind event collections (motion / object / audio), and
20858
- * persisted media. Owns the post-detection domain end-to-end:
20859
- *
20860
- * runner emits PipelineInferenceResult
20861
- * ↓ (event bus)
20862
- * pipeline-analytics subscriber
20863
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
20864
- * → three DB collections (one per kind), one FS media tree, one
20865
- * unified event emitter (FrameTracked + TrackStarted/Ended +
20866
- * DetectionEvent on bus)
20867
- *
20868
- * Pure subscriber model. No `processFrame` cap method — the runner
20869
- * already publishes the raw frame on the bus. The cap surface is
20870
- * only QUERIES + per-device settings, bound on/off via
20871
- * `device-manager.setWrapperActive`. `defaultActive: true` because
20872
- * every camera with a detection pipeline wants its raw detections
20873
- * refined; operators opt out per-device via BindingsTab when needed.
20874
- *
20875
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
20876
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
20877
- */
20878
- var TrackStateSchema = _enum([
20879
- "new",
20880
- "entered",
20881
- "left",
20882
- "moving",
20883
- "idle"
20884
- ]);
20885
- var EventKindSchema = _enum([
20886
- "motion",
20887
- "object",
20888
- "audio"
20889
- ]);
20890
- /**
20891
- * Spatial filter for `listTracks` — the rect + polygon variants of the shared
20892
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
20893
- * of the camera frame (top-left origin), matching the drawing-plane editor.
20894
- */
20895
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
20896
- /** Closed icon vocabulary so clients render a known glyph per kind. */
20897
- var EventKindIconSchema = _enum([
20898
- "motion",
20899
- "audio",
20900
- "person",
20901
- "vehicle",
20902
- "animal",
20903
- "door",
20904
- "pir",
20905
- "smoke",
20906
- "water",
20907
- "button",
20908
- "package",
20909
- "generic"
20910
- ]);
20911
- var EventKindCategorySchema = _enum([
20912
- "motion",
20913
- "audio",
20914
- "detection",
20915
- "sensor",
20916
- "control",
20917
- "custom",
20918
- "package"
20919
- ]);
20920
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
20921
- var EventKindLevelSchema = _enum(["macro", "sub"]);
20922
- var EventKindDescriptorSchema = object({
20923
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
20924
- kind: string(),
20925
- /** i18n key resolved on the UI side; `label` is the English fallback. */
20926
- labelKey: string(),
20927
- /** English fallback label (kept for clients that don't translate). */
20928
- label: string(),
20929
- /** Hex color for timeline/legend rendering. */
20930
- color: string(),
20931
- /** Dictionary id → lucide component on the UI side. */
20932
- iconId: string(),
20933
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
20934
- icon: EventKindIconSchema,
20935
- category: EventKindCategorySchema,
20936
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
20937
- parentKind: string().nullable(),
20938
- /** Derived from `parentKind`, explicit for the client tree. */
20939
- level: EventKindLevelSchema,
20940
- /** Which cap + device contributes this kind. For built-ins the camera
20941
- * itself; for sensor kinds the LINKED source device. */
20942
- source: object({
20943
- capName: string(),
20944
- deviceId: number()
20945
- })
20946
- });
20947
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
20948
- var EventKindsForDeviceSchema = object({
20949
- deviceId: number(),
20950
- kinds: array(EventKindDescriptorSchema).readonly()
20951
- });
20952
- var SensorEventSchema = object({
20953
- id: string(),
20954
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
20955
- * yields N rows, one per camera). */
20956
- deviceId: number(),
20957
- /** The linked sensor device whose state changed. */
20958
- sourceDeviceId: number(),
20959
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
20960
- kind: string(),
20961
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
20962
- value: record(string(), unknown()).nullable(),
20963
- timestamp: number()
20964
- });
20965
- /**
20966
- * One stored sighting on a track's trajectory.
20967
- *
20968
- * The array these live in is returned in TIME order (D399) — it is APPENDED in
20969
- * arrival order, and the two detector passes interleave, so a consumer must not
20970
- * assume the two are the same on a row written by an older build.
20971
- */
20972
- var TrackPositionSchema = object({
20973
- x: number(),
20974
- y: number(),
20975
- timestamp: number(),
20976
- bbox: BoundingBoxSchema,
20977
- /**
20978
- * Which detector pass measured this box (D399): `frame` is the full-frame
20979
- * pass on the analysis raster, `recovery` is the native-resolution
20980
- * small-subject second pass (D377/D378). Both write into one array, and until
20981
- * this field existed the only way to tell them apart was that full-frame boxes
20982
- * are exact multiples of 1.2 while recovery boxes are full-precision floats.
20983
- * Absent on rows written before D399.
20984
- */
20985
- source: _enum(["frame", "recovery"]).optional(),
20986
- /** Detection score of this box, so a position can be weighed and not only
20987
- * plotted. Absent on rows written before D399. */
20988
- score: number().optional()
20989
- });
20990
- var TrackSnapshotSchema = object({
20991
- timestamp: number(),
20992
- position: TrackPositionSchema,
20993
- /** The snapshot's media row id (D482); resolve via `listTrackMedia({ trackId })`. */
20994
- mediaId: number().int()
20995
- });
20996
- /**
20997
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
20998
- * divided by the track's detection-frame dims), computed at persist time.
20999
- * Absent when the frame dims were unknown when the track was persisted
21000
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
21001
- */
21002
- var TrackEnvelopeSchema = object({
21003
- minX: number(),
21004
- minY: number(),
21005
- maxX: number(),
21006
- maxY: number()
21007
- });
21008
- /**
21009
- * Row projection for track list queries. `full` (default) returns the
21010
- * complete Track including the frame-rate `positions[]` history and the
21011
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
21012
- * keeps every scalar the list surfaces actually render (ids, class(es),
21013
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
21014
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
21015
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
21016
- * `getTrack`. Mirrors the event-store `projection` convention
21017
- * (`getObjectEvents` et al.).
21018
- */
21019
- var TrackProjectionSchema = _enum(["full", "slim"]);
21020
- /**
21021
- * One audio-classification label heard on the track's camera while the
21022
- * track was alive, aggregated per label. An "episode" is one persisted
21023
- * audio event (the confident-classification path: score ≥ the device's
21024
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
21025
- * one 32 ms inference chunk, so counts stay human-scaled.
21026
- */
21027
- var TrackAudioLabelSchema = object({
21028
- label: string(),
21029
- /** Highest classification score observed across the label's episodes. */
21030
- peakScore: number(),
21031
- /** Number of coalesced audio-event episodes carrying this label. */
21032
- count: number(),
21033
- firstAt: number(),
21034
- lastAt: number()
21035
- });
21036
- /**
21037
- * How a track was produced. `pipeline` (default / absent) = the spatial
21038
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
21039
- * no positions, a single snapshot, and no bbox trajectory at all:
21040
- *
21041
- * - `sensor` — a linked sensor/control device state change.
21042
- * - `audio` — an audio event on the camera itself that was anomalous for
21043
- * THAT camera, loud, and heard while nothing visual was happening (D62).
21044
- *
21045
- * - `onboard` — the CAMERA's own firmware, paired with a decoded frame in
21046
- * that frame's pixel space. A real root detector and a SPATIAL one: its
21047
- * boxes are the same kind of fact `pipeline`'s are, produced by a different
21048
- * detector.
21049
- *
21050
- * `onboard` was missing here while `DetectionSourceSchema` already had it, so
21051
- * a persisted onboard track failed `safeParse` on read and came back with NO
21052
- * source at all — which `isSpatialTrack` then admitted by accident, through the
21053
- * `undefined` arm rather than by anybody's decision, and which `excludeSources`
21054
- * could not name.
21055
- *
21056
- * The spatial subsystems (tracker association, occupancy count, re-id /
21057
- * embedding, resurrection) MUST skip every synthetic source. Test for that
21058
- * with `isSpatialTrack`, which allow-lists the spatial sources explicitly — a
21059
- * `!== 'sensor'` check silently readmits every source added after it was
21060
- * written.
21061
- */
21062
- var TrackSourceSchema = _enum([
21063
- "pipeline",
21064
- "onboard",
21065
- "sensor",
21066
- "audio"
21067
- ]);
21068
- /**
21069
- * Where a track sits in the RETRAIN lifecycle (D81).
21070
- *
21071
- * - `none` — never marked, or un-marked. Evictable.
21072
- * - `staging` — the operator wants this track as training material and has not
21073
- * finished with it. **This is the only state retention holds**: the track and
21074
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
21075
- * the device's age window.
21076
- * - `trained` — the retrain page has taken what it needed. The frames it chose
21077
- * were COPIED into the retrain dataset at selection time, so the dataset no
21078
- * longer depends on the track's media and the track becomes EVICTABLE again.
21079
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
21080
- * a deliberate action of the retrain page, not a side effect of a checkbox.
21081
- *
21082
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` so that
21083
- * every row is selectable by a positive predicate. (The filter language has
21084
- * since grown the NULL-safe `whereNot` / `whereNotIn` and an `IS NULL` reading
21085
- * of `where: { f: null }`, which is how {@link TrackSourceSchema} can be
21086
- * filtered on a NULLABLE column — see `excludeSources`. It did not when this
21087
- * column was designed, and a NOT NULL column is still the better shape.)
21088
- */
21089
- var RetrainStatusSchema = _enum([
21090
- "none",
21091
- "staging",
21092
- "trained"
21093
- ]);
21094
- /**
21095
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
21096
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
21097
- * so the two surfaces cannot drift.
21098
- *
21099
- * **Absent ≠ false.** A track that has never been touched omits the field; an
21100
- * explicitly un-flagged track carries `false`. Legacy rows written before the
21101
- * columns existed read as absent, and a consumer that needs a boolean should say
21102
- * `flag === true`, not `flag !== false`.
21103
- *
21104
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
21105
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
21106
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
21107
- * `trained` track reports `false` while refusing both writes. The boolean is
21108
- * kept because three surfaces drive a toggle off it; anything that needs to tell
21109
- * "never marked" from "already trained" must read `retrainStatus`.
21110
- *
21111
- * `debug` does NOT pin; it is attention, not durability.
21112
- *
21113
- * `debugNote` is the operator's own words about WHAT should be checked on this
21114
- * track, and it lives and dies with `debug` — see {@link MAX_TRACK_DEBUG_NOTE_LEN}.
21115
- *
21116
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
21117
- * A favourited track is skipped by retention the same way `staging` is, but
21118
- * it does not enter `none|staging|trained` and has no staging budget.
21119
- */
21120
- var TrackFlagFields = {
21121
- /** Operator marked this track as training material — i.e. `retrainStatus` is
21122
- * `'staging'`. */
21123
- markForTrain: boolean().optional(),
21124
- /** Operator marked this track for diagnostic attention. */
21125
- debug: boolean().optional(),
21126
- /**
21127
- * What the operator wants CHECKED on this track, in their own words.
21128
- *
21129
- * The flag alone says "look at this" and nothing about what for; a debug set
21130
- * reviewed hours later is a list of tracks with no question attached. Bound
21131
- * to `debug` on the WRITE side — the body clears it when `debug` goes off,
21132
- * and refuses it on a track whose debug is off — so a note can never outlive
21133
- * the attention it belongs to.
21134
- *
21135
- * `''` is a real value ("marked, nothing to add"); the ABSENT key means
21136
- * "leave whatever is stored alone", which is what lets a surface turn debug
21137
- * on without a note (a cancelled prompt) and what lets it edit the note
21138
- * without touching the flag.
21139
- */
21140
- debugNote: string().max(500).optional(),
21141
- /** Operator favourited this track. Pins it against pruning. */
21142
- favourited: boolean().optional()
21143
- };
21144
- /**
21145
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
21146
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
21147
- * write patch, and the status is not something the toggle sets — it is what the
21148
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
21149
- * always present on a persisted row (the column default materialises `'none'`).
21150
- */
21151
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
21152
- /**
21153
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
21154
- * one flag can never clear the other — the toggles are independent and are
21155
- * driven from three surfaces that do not know about each other.
21156
- */
21157
- var TrackFlagsPatchSchema = object(TrackFlagFields);
21158
- /**
21159
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
21160
- * collapses to `false`) so a caller can drive a toggle's checked state off the
21161
- * mutation result without a re-fetch.
21162
- */
21163
- var TrackFlagsSchema = object({
21164
- trackId: string(),
21165
- markForTrain: boolean(),
21166
- debug: boolean(),
21167
- /** The note as it STANDS after the write — never absent here (a track with no
21168
- * note reports `''`), for the same reason the booleans are required: a
21169
- * surface that has just written must be able to render the note it now owns
21170
- * without a re-fetch, and an absent key would read as "unchanged" on a
21171
- * screen that has no previous value to keep. */
21172
- debugNote: string(),
21173
- favourited: boolean(),
21174
- /** The lifecycle state the boolean was derived from. Required here (unlike on
21175
- * a track row) because this shape is only ever produced by the write body,
21176
- * which always knows it — and a surface that has just written needs to render
21177
- * `trained` without a re-fetch. */
21178
- retrainStatus: RetrainStatusSchema
21179
- });
21180
- union([literal(1), literal(2)]);
21181
- /**
21182
- * WHO decided a label, and when. Carried per tier so a value can be traced to
21183
- * the step and model that produced it — which is what makes the write rule
21184
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
21185
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
21186
- *
21187
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
21188
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
21189
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
21190
- * that value has no provenance, and the write rule lets ANY properly-attributed
21191
- * write of the same tier replace it regardless of score.
21192
- */
21193
- var LabelAttributionSchema = object({
21194
- stepId: string(),
21195
- modelId: string().optional(),
21196
- decidedAt: number(),
21197
- /**
21198
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
21199
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
21200
- *
21201
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
21202
- * notification rule authored on "Gianluca" stopped matching the moment the
21203
- * operator fixed the spelling in the gallery, and nothing said so. The id is
21204
- * the thing that does not move, so it is what a rule matches on
21205
- * (`NcConditions.identities`) and the text is what a human is shown.
21206
- *
21207
- * Absent when the label names no gallery row — a plate the OCR read but no
21208
- * vehicle claims, a sub-class, a species, any tier-1 value.
21209
- */
21210
- identityId: string().optional()
21211
- });
21212
- /**
21213
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
21214
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
21215
- * track and its events always answer the same question the same way.
20476
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
20477
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
20478
+ * track and its events always answer the same question the same way.
21216
20479
  *
21217
20480
  * Two scalar columns, not an array: every consumer wants "the coarse one" or
21218
20481
  * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
@@ -21422,6 +20685,22 @@ var TrackSchema = object({
21422
20685
  * omit it. Render nothing when absent.
21423
20686
  */
21424
20687
  previewMissReason: string().optional(),
20688
+ /**
20689
+ * The ROOT model that produced this track — the `FrameResult.rootModelId` of
20690
+ * the frame it was BORN on (D646). What a later replay compares against, so
20691
+ * "the original model" is named rather than assumed. A birth fact: never
20692
+ * rewritten by a later frame. **Absent ≠ unknown-model**: a row from before
20693
+ * the column, and a track the camera's own detector produced, carry none.
20694
+ */
20695
+ modelId: string().optional(),
20696
+ /**
20697
+ * Size (px) of the detection frame this track's `positions[].bbox` live in —
20698
+ * the frame it was born on, else the camera's latest analysis frame at
20699
+ * persist time. Divide a position by these to normalise it. Absent when the
20700
+ * size was never known.
20701
+ */
20702
+ frameWidth: number().optional(),
20703
+ frameHeight: number().optional(),
21425
20704
  ...TrackFlagFields,
21426
20705
  ...TrackRetrainFields
21427
20706
  });
@@ -22428,24 +21707,6 @@ var MediaReclaimStatusSchema = object({
22428
21707
  finishedAtMs: number().nullable(),
22429
21708
  error: string().nullable()
22430
21709
  });
22431
- var ReplayFrameInputSchema = object({
22432
- timestamp: number(),
22433
- frame: PipelineRunResultBridge
22434
- });
22435
- var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
22436
- className: string(),
22437
- firstSeenMs: number(),
22438
- lastSeenMs: number(),
22439
- /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
22440
- * frame — a representative box for the diff's `(className, window, IoU)`
22441
- * pairing (`replay-diff.ts`). A replay does not need the full per-frame
22442
- * trajectory production's `Track.positions` keeps. */
22443
- bbox: BoundingBoxSchema,
22444
- /** How many of the input frames this track matched a real detection on
22445
- * (never a coasted/extrapolated frame) — the replay's own signal for "how
22446
- * solid is this track", cheaper than re-deriving it from a trajectory. */
22447
- framesMatched: number().int()
22448
- })).readonly() });
22449
21710
  /**
22450
21711
  * The long-term series a camera produces. A closed union so a typo cannot
22451
21712
  * invent one, and the ONE declaration of it — the addon's `AnalyticsLtsSeries`
@@ -22676,16 +21937,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22676
21937
  }), RetrainAssistResultSchema, {
22677
21938
  kind: "mutation",
22678
21939
  auth: "admin"
22679
- }), method(object({
22680
- deviceId: number(),
22681
- source: DetectionSourceSchema,
22682
- zones: array(ZoneSchema).readonly().optional(),
22683
- detectionRules: array(ZoneRuleSchema).readonly().optional(),
22684
- zoneMembershipMinOverlap: number().min(0).max(1).optional(),
22685
- frames: array(ReplayFrameInputSchema).min(1)
22686
- }), RunReplayFrameProcessorResultSchema, {
22687
- kind: "mutation",
22688
- auth: "admin"
22689
21940
  }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
22690
21941
  kind: "query",
22691
21942
  auth: "admin"
@@ -22761,6 +22012,674 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22761
22012
  eventId: string(),
22762
22013
  timestamp: number()
22763
22014
  });
22015
+ /**
22016
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
22017
+ * within the frame, so the executor can re-cut a leaf child ROI at native
22018
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
22019
+ */
22020
+ var NativeCropRefSchema = object({
22021
+ /** Handle keying the retained native surface (node-pinned to its owner). */
22022
+ handle: FrameHandleSchema,
22023
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
22024
+ cropFrameSpace: object({
22025
+ x: number(),
22026
+ y: number(),
22027
+ w: number(),
22028
+ h: number()
22029
+ })
22030
+ });
22031
+ object({
22032
+ crop: object({
22033
+ left: number(),
22034
+ top: number(),
22035
+ width: number().positive(),
22036
+ height: number().positive()
22037
+ }).optional(),
22038
+ content: object({
22039
+ width: number().int().positive(),
22040
+ height: number().int().positive()
22041
+ }),
22042
+ fit: _enum(["stretch", "contain"]),
22043
+ format: _enum([
22044
+ "rgb",
22045
+ "gray",
22046
+ "jpeg"
22047
+ ])
22048
+ });
22049
+ /**
22050
+ * Process-local frame identity. It is serializable so it can ride an in-process
22051
+ * capability call, but `registryId` deliberately prevents resolution in any
22052
+ * other process or execution group.
22053
+ */
22054
+ var FrameRefSchema = object({
22055
+ registryId: string().min(1),
22056
+ id: string().min(1),
22057
+ width: number().int().positive(),
22058
+ height: number().int().positive(),
22059
+ format: _enum(["rgb", "gray"]),
22060
+ timestamp: number(),
22061
+ capturedAt: number().optional()
22062
+ });
22063
+ var ModelFormatSchema$1 = _enum([
22064
+ "onnx",
22065
+ "coreml",
22066
+ "openvino",
22067
+ "tflite",
22068
+ "pt",
22069
+ "gguf"
22070
+ ]);
22071
+ var PipelineSlotSchema = _enum([
22072
+ "detector",
22073
+ "cropper",
22074
+ "classifier",
22075
+ "refiner",
22076
+ "audio-classifier"
22077
+ ]);
22078
+ var PipelineEngineChoiceSchema = object({
22079
+ runtime: literal("python"),
22080
+ backend: string(),
22081
+ format: ModelFormatSchema$1,
22082
+ device: string().optional()
22083
+ });
22084
+ /**
22085
+ * One pool's resolved provisioning (`getEffectiveTuning`). `numWorkers` is the
22086
+ * knob that lifts a saturated pool (`inference-devices.md`); `concurrency` is
22087
+ * per-worker in-flight requests. `deviceKey` echoes the pool asked about —
22088
+ * `null` for the node-default pool.
22089
+ */
22090
+ var EffectiveTuningSchema = object({
22091
+ deviceKey: string().nullable(),
22092
+ runtime: string(),
22093
+ batchMode: string(),
22094
+ windowMs: number(),
22095
+ maxBatchSize: number(),
22096
+ concurrency: number(),
22097
+ numWorkers: number()
22098
+ });
22099
+ var AvailableEngineSchema = object({
22100
+ engine: PipelineEngineChoiceSchema,
22101
+ devices: array(object({
22102
+ id: string(),
22103
+ label: string(),
22104
+ description: string().optional()
22105
+ })).readonly(),
22106
+ defaultDevice: string()
22107
+ });
22108
+ var PipelineDefaultStepSchema = lazy(() => object({
22109
+ addonId: string(),
22110
+ addonName: string(),
22111
+ slot: PipelineSlotSchema,
22112
+ inputClasses: array(string()).readonly(),
22113
+ outputClasses: array(string()).readonly(),
22114
+ enabled: boolean(),
22115
+ modelId: string(),
22116
+ children: array(PipelineDefaultStepSchema).readonly(),
22117
+ group: string().optional(),
22118
+ settings: record(string(), unknown()).optional()
22119
+ }));
22120
+ var PipelineTemplateStepSchema = lazy(() => object({
22121
+ addonId: string(),
22122
+ enabled: boolean(),
22123
+ modelId: string(),
22124
+ children: array(PipelineTemplateStepSchema).readonly(),
22125
+ settings: record(string(), unknown()).optional()
22126
+ }));
22127
+ var PipelineTemplateSchema$1 = object({
22128
+ id: string(),
22129
+ name: string(),
22130
+ createdAt: string(),
22131
+ updatedAt: string(),
22132
+ engine: PipelineEngineChoiceSchema,
22133
+ steps: array(PipelineTemplateStepSchema).readonly()
22134
+ });
22135
+ var PipelineModelOptionSchema = object({
22136
+ id: string(),
22137
+ name: string(),
22138
+ formats: record(string(), object({
22139
+ downloaded: boolean(),
22140
+ sizeMB: number()
22141
+ })),
22142
+ group: ModelVariantGroupSchema.optional(),
22143
+ legacy: boolean().optional(),
22144
+ provider: ModelProviderIdSchema.optional()
22145
+ });
22146
+ var ConfigFieldBridge = custom();
22147
+ var PipelineAddonSchemaSchema = object({
22148
+ id: string(),
22149
+ name: string(),
22150
+ slot: PipelineSlotSchema,
22151
+ inputClasses: array(string()).readonly(),
22152
+ outputClasses: array(string()).readonly(),
22153
+ childSlots: array(PipelineSlotSchema).readonly(),
22154
+ models: array(PipelineModelOptionSchema).readonly(),
22155
+ defaultModelId: string(),
22156
+ defaultModelIdByFormat: record(string(), string()).optional(),
22157
+ enabledByDefault: boolean().optional(),
22158
+ backfillIntoExistingOverrides: boolean().optional(),
22159
+ defaultConfidence: number(),
22160
+ group: string().optional(),
22161
+ configSchema: array(ConfigFieldBridge).readonly().optional()
22162
+ });
22163
+ var PipelineSlotSchemaSchema = object({
22164
+ id: PipelineSlotSchema,
22165
+ label: string(),
22166
+ priority: number(),
22167
+ parentSlot: PipelineSlotSchema.nullable(),
22168
+ addons: array(PipelineAddonSchemaSchema).readonly()
22169
+ });
22170
+ var PipelineSchemaSchema = object({
22171
+ availableEngines: array(AvailableEngineSchema).readonly(),
22172
+ selectedEngine: PipelineEngineChoiceSchema,
22173
+ slots: array(PipelineSlotSchemaSchema).readonly()
22174
+ });
22175
+ var EngineProvisioningSchema = object({
22176
+ runtimeId: _enum([
22177
+ "onnx",
22178
+ "openvino",
22179
+ "coreml",
22180
+ "edgetpu"
22181
+ ]).nullable(),
22182
+ device: string().nullable(),
22183
+ state: _enum([
22184
+ "idle",
22185
+ "installing",
22186
+ "verifying",
22187
+ "ready",
22188
+ "failed"
22189
+ ]),
22190
+ progress: number().optional(),
22191
+ error: string().optional(),
22192
+ nextRetryAt: number().optional(),
22193
+ /**
22194
+ * Gate A (config-correctness gate at engine change): human-readable
22195
+ * config issues surfaced EAGERLY when the node's engine changes — model
22196
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
22197
+ * has a <format> build"). Additive/optional: informational only, never
22198
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
22199
+ * Absent/empty when the node-default tree resolves cleanly.
22200
+ */
22201
+ configIssues: array(string()).optional()
22202
+ });
22203
+ var PipelineStepInputSchema = lazy(() => object({
22204
+ addonId: string(),
22205
+ modelId: string().optional(),
22206
+ enabled: boolean().default(true),
22207
+ children: array(PipelineStepInputSchema).optional(),
22208
+ settings: record(string(), unknown()).optional(),
22209
+ jumpDeviceKey: string().optional()
22210
+ }));
22211
+ var ModelSubstitutionSchema = object({
22212
+ addonId: string(),
22213
+ chosen: string(),
22214
+ running: string(),
22215
+ format: string()
22216
+ });
22217
+ var PipelineValidationIssueSchema = object({
22218
+ addonId: string(),
22219
+ kind: _enum([
22220
+ "unknown-addon",
22221
+ "no-format-build",
22222
+ "unknown-device"
22223
+ ]),
22224
+ detail: string()
22225
+ });
22226
+ var PipelineValidationResultSchema = object({
22227
+ ok: boolean(),
22228
+ issues: array(PipelineValidationIssueSchema).readonly(),
22229
+ substitutions: array(ModelSubstitutionSchema).readonly(),
22230
+ /** The node's `currentEngine.format` this validation ran against. */
22231
+ format: string()
22232
+ });
22233
+ var ReferenceImageEntrySchema = object({
22234
+ filename: string(),
22235
+ stepIds: array(string()).readonly().optional()
22236
+ });
22237
+ var ReferenceImageBodySchema = object({
22238
+ base64: string(),
22239
+ filename: string()
22240
+ });
22241
+ var ReferenceAudioEntrySchema = object({
22242
+ filename: string(),
22243
+ sizeKb: number()
22244
+ });
22245
+ var ReferenceAudioBodySchema = object({ base64: string() });
22246
+ var AudioBackendSchema = object({
22247
+ id: string(),
22248
+ name: string(),
22249
+ description: string(),
22250
+ available: boolean(),
22251
+ /**
22252
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
22253
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
22254
+ * the benchmark UI to populate the `enabledMicroClasses` filter
22255
+ * specific to the selected backend without a separate fetch.
22256
+ */
22257
+ rawLabels: array(string()).readonly().optional()
22258
+ });
22259
+ var AudioCapabilitiesSchema = object({
22260
+ activeBackend: string(),
22261
+ availableBackends: array(AudioBackendSchema).readonly(),
22262
+ sampleRate: number(),
22263
+ chunkDurationMs: number()
22264
+ });
22265
+ var DownloadModelResultSchema = object({
22266
+ filePath: string(),
22267
+ sizeMB: number(),
22268
+ durationMs: number()
22269
+ });
22270
+ /**
22271
+ * Wrapper carrying a single test run's result. Replaces the legacy
22272
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
22273
+ * canonical `AudioResult` from the Phase 6 output rework: one
22274
+ * `AudioDetection` per class above `minScore`, top-N candidates in
22275
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
22276
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
22277
+ * benchmark UI can still report a clean failure when the classifier
22278
+ * cap isn't available.
22279
+ */
22280
+ var AudioTestResultSchema = object({
22281
+ success: boolean(),
22282
+ error: string().optional(),
22283
+ frame: custom().optional()
22284
+ });
22285
+ var PipelineConfigBridge = custom();
22286
+ var ConfigUISchemaBridge = custom();
22287
+ var ConfigUISchemaNullableBridge = custom();
22288
+ var InferenceCapabilitiesBridge = custom();
22289
+ var ModelAvailabilityListBridge = custom();
22290
+ var PipelineRunResultBridge = custom();
22291
+ /**
22292
+ * Pipeline executor — detection engine + configuration + inference API.
22293
+ *
22294
+ * Merged from: pipeline-executor, pipeline-config, inference, detection-config.
22295
+ * Implemented by the detection-pipeline addon.
22296
+ *
22297
+ * Per-device surface (DeviceSettingsContribution + the "is detection
22298
+ * enabled for this camera?" toggle) lives on the paired
22299
+ * `detection-pipeline` cap (device-scoped, singleton, wrapper
22300
+ * defaultActive) — same split pattern used by stream-broker /
22301
+ * camera-streams and audio-analyzer / audio-analysis.
22302
+ */
22303
+ var pipelineExecutorCapability = {
22304
+ name: "pipeline-executor",
22305
+ scope: "system",
22306
+ mode: "singleton",
22307
+ methods: {
22308
+ getAvailableEngines: method(_void(), array(PipelineEngineChoiceSchema)),
22309
+ getSelectedEngine: method(_void(), PipelineEngineChoiceSchema),
22310
+ getDefaultSteps: method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)),
22311
+ /**
22312
+ * Per-node detection-engine provisioning snapshot. Returns the live
22313
+ * state of the lazy runtime-provisioning machine on `nodeId`
22314
+ * (idle / installing / verifying / ready / failed). The UI pairs this
22315
+ * one-shot query with the `pipeline.engine-provisioning` live event
22316
+ * (emitted on every transition) to drive a per-node "engine ready?"
22317
+ * indicator without polling. Phase 2.
22318
+ */
22319
+ getEngineProvisioning: method(object({ nodeId: string() }), EngineProvisioningSchema),
22320
+ getVideoPipelineSteps: method(_void(), record(string(), object({
22321
+ modelId: string(),
22322
+ settings: record(string(), unknown()).readonly()
22323
+ }))),
22324
+ setVideoPipelineSteps: method(object({ steps: record(string(), object({
22325
+ modelId: string(),
22326
+ settings: record(string(), unknown()).readonly()
22327
+ })) }), object({ success: literal(true) }), {
22328
+ kind: "mutation",
22329
+ auth: "admin"
22330
+ }),
22331
+ /**
22332
+ * Clear THIS node's executor-side PER-DEVICE settings stores (the
22333
+ * per-camera step overrides the object-detection root reads via
22334
+ * `applyDeviceOverridesToTree`). `nodeId` is the ROUTING key — the
22335
+ * generated cap-router strips it (default `nodeIdMode: 'routing'`) and
22336
+ * dispatches to that node, so the provider method runs ON the target
22337
+ * node and receives no `nodeId`.
22338
+ *
22339
+ * This is the slimmed executor leg of the orchestrator's
22340
+ * `resetNodePipelineDefaults` flow (which owns the real reset: node
22341
+ * addonDefaults pins + per-camera orchestrator overrides). The legacy
22342
+ * `resetToDefault` — which reset a persisted global step-tree seed
22343
+ * nothing in the live per-camera path read — was removed together with
22344
+ * that seed.
22345
+ */
22346
+ clearDeviceOverrides: method(object({ nodeId: string() }), object({
22347
+ success: literal(true),
22348
+ clearedDevices: number()
22349
+ }), {
22350
+ kind: "mutation",
22351
+ auth: "admin"
22352
+ }),
22353
+ /**
22354
+ * Which of THIS node's inference devices the executor currently refuses,
22355
+ * and why. `nodeId` is the ROUTING key (stripped by the generated router).
22356
+ *
22357
+ * The channel that did not exist. Pool health was known only inside the
22358
+ * detection addon and was an input to no routing decision anywhere: the
22359
+ * per-dispatch capability gate is keyed on model FORMAT and so can never
22360
+ * separate `openvino:gpu` from `openvino:npu`, and the orchestrator's live
22361
+ * eligibility probe (`platformProbe.getCapabilities`) answers about
22362
+ * HARDWARE — which was present throughout. So when the hub's `openvino:gpu`
22363
+ * Python worker was SIGABRT'd by the Intel GPU plugin on 2026-08-25, the
22364
+ * balancer went on handing that dead pool cameras by rotation for 31 hours:
22365
+ * ~370 000 `PoolWorker[w0]: not initialized` lines, every frame lost.
22366
+ *
22367
+ * Read semantics the caller depends on, and which the provider guarantees:
22368
+ * this is a synchronous read of in-memory state. It never probes hardware,
22369
+ * never spawns a pool and never throws — an EMPTY `unhealthy` means "asked,
22370
+ * nothing is refused", which is what re-admits a device. A read that FAILS
22371
+ * (node offline, version skew) must therefore be distinguishable from an
22372
+ * empty answer, and it is: it rejects.
22373
+ */
22374
+ getInferenceDeviceHealth: method(object({ nodeId: string() }), object({ unhealthy: array(object({
22375
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
22376
+ deviceKey: string(),
22377
+ /**
22378
+ * `failed` — the per-device restart budget is exhausted; no pool
22379
+ * will be spawned until an operator re-arms it or the runner
22380
+ * respawns. `backoff` — under budget, waiting out the backoff (or
22381
+ * a cached pool observed dead and not yet condemned).
22382
+ */
22383
+ state: _enum(["failed", "backoff"]),
22384
+ /** Epoch ms of the death that produced this state. */
22385
+ since: number(),
22386
+ /** Pool deaths inside the current window. */
22387
+ deaths: number(),
22388
+ /** The last death's message. */
22389
+ lastError: string()
22390
+ })).readonly() })),
22391
+ /**
22392
+ * Re-arm a terminally `failed` inference device on `nodeId`: forget its
22393
+ * restart budget so the next dispatch builds a fresh pool.
22394
+ *
22395
+ * The terminal state is deliberate (the abort it bounds is deterministic —
22396
+ * an automatic probation would just respawn Python forever, more slowly),
22397
+ * and a terminal state an operator cannot leave is a silent fault. This is
22398
+ * the way out. `rearmed:false` means there was nothing to forget.
22399
+ */
22400
+ rearmInferenceDevice: method(object({
22401
+ nodeId: string(),
22402
+ deviceKey: string()
22403
+ }), object({ rearmed: boolean() }), {
22404
+ kind: "mutation",
22405
+ auth: "admin"
22406
+ }),
22407
+ getSchema: method(_void(), PipelineSchemaSchema),
22408
+ getGlobalSteps: method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()),
22409
+ getGlobalPipelineConfig: method(_void(), PipelineConfigBridge),
22410
+ getOrchestratorConfigSchema: method(_void(), ConfigUISchemaBridge),
22411
+ /**
22412
+ * Gate B (pre-init config-correctness gate). PURE COMPUTE against this
22413
+ * node's `currentEngine.format` — resolves `steps` the same way the
22414
+ * runtime dispatch path would, and reports what WOULD happen without
22415
+ * touching any node-global state. Called by the orchestrator at attach
22416
+ * time (`attachOn`), node-pinned to the TARGET node, so config problems
22417
+ * surface BEFORE `pipelineRunner.attachCamera` rather than at the first
22418
+ * per-frame resolve. `ok` is false iff `issues` is non-empty (both
22419
+ * `unknown-addon` and `no-format-build` are HARD issues); `substitutions`
22420
+ * is informational (a degraded-but-loadable model swap) and never
22421
+ * affects `ok`. Never throws.
22422
+ *
22423
+ * `deviceKey` validates against THAT device pool's format instead of the
22424
+ * node default (D646) — the cheap question a pinned replay asks before it
22425
+ * reads any media: can this (node, deviceKey) run exactly this model?
22426
+ */
22427
+ validatePipeline: method(object({
22428
+ steps: array(PipelineStepInputSchema),
22429
+ deviceKey: string().optional()
22430
+ }), PipelineValidationResultSchema),
22431
+ listTemplates: method(_void(), array(PipelineTemplateSchema$1).readonly()),
22432
+ saveTemplate: method(object({
22433
+ name: string(),
22434
+ steps: array(PipelineTemplateStepSchema).readonly(),
22435
+ engine: PipelineEngineChoiceSchema
22436
+ }), PipelineTemplateSchema$1, { kind: "mutation" }),
22437
+ updateTemplate: method(object({
22438
+ id: string(),
22439
+ name: string().optional(),
22440
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
22441
+ }), PipelineTemplateSchema$1, { kind: "mutation" }),
22442
+ deleteTemplate: method(object({ id: string() }), _void(), { kind: "mutation" }),
22443
+ getCapabilities: method(_void(), InferenceCapabilitiesBridge),
22444
+ getAddonModels: method(object({ addonId: string() }), ModelAvailabilityListBridge),
22445
+ downloadModel: method(object({
22446
+ addonId: string(),
22447
+ modelId: string(),
22448
+ format: ModelFormatSchema$1
22449
+ }), DownloadModelResultSchema, { kind: "mutation" }),
22450
+ deleteModel: method(object({
22451
+ addonId: string(),
22452
+ modelId: string(),
22453
+ format: ModelFormatSchema$1
22454
+ }), object({ success: literal(true) }), { kind: "mutation" }),
22455
+ /**
22456
+ * Stateless single-frame execution. Callers (runner, benchmark) pass
22457
+ * the complete `steps` tree; the executor holds no state about cameras
22458
+ * or saved pipelines. WHICH pool answers is the node's own engine, or the
22459
+ * `deviceKey` pool when one is named.
22460
+ *
22461
+ * There is no `engine` field (D646). It existed for the benchmark and was
22462
+ * honoured by swapping the SHARED provider's engine, factory and executor
22463
+ * for the duration of the call, on a node serving live cameras. A caller
22464
+ * that still sends the key has it stripped here and changes nothing.
22465
+ *
22466
+ * Exactly one of `frame`, `frameRef`, `frameHandle`, `imageBase64`,
22467
+ * `referenceImage` must be provided:
22468
+ * - `frame`: runtime dispatch path (runner → decoded broker frame).
22469
+ * Carries the raw buffer, dimensions, and format; the executor
22470
+ * uses it directly without base64 round-tripping.
22471
+ * - `frameHandle` (CB5): a zero-pixel shm `FrameHandle` for the SAME
22472
+ * decoded frame. Both runner and executor are hub-local processes
22473
+ * sharing `/dev/shm`, so the executor maps the named segment and
22474
+ * reads the pixels back zero-copy — eliminating the ~1.2MB
22475
+ * re-serialisation over UDS/MsgPack the `frame` path pays per call.
22476
+ * High-risk: the FrameRing is a latest-wins seqlock with no
22477
+ * refcount, so a recycled slot yields a null read; the executor
22478
+ * then degrades to an empty result and the runner ships pixels via
22479
+ * `frame` as the fallback (queue-depth gated on the runner side).
22480
+ * - `imageBase64`: one-shot test path (benchmark ImageTab).
22481
+ * - `referenceImage`: named file from the reference-image store.
22482
+ */
22483
+ runPipeline: method(object({
22484
+ steps: array(PipelineStepInputSchema).min(1),
22485
+ frame: FrameInputSchema.optional(),
22486
+ /**
22487
+ * Process-local lazy frame. Valid only when caller and provider resolve
22488
+ * in the same execution-group process; split/cross-node callers use
22489
+ * `frame`/`image` inline compatibility instead.
22490
+ */
22491
+ frameRef: FrameRefSchema.optional(),
22492
+ /**
22493
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
22494
+ * the decoded pixels live in. One more member of the one-of
22495
+ * frame/frameHandle/image/imageBase64/referenceImage group.
22496
+ */
22497
+ frameHandle: FrameHandleSchema.optional(),
22498
+ imageBase64: string().optional(),
22499
+ /**
22500
+ * Binary JPEG bytes — preferred over `imageBase64` on internal
22501
+ * hops (hub → forked worker via Moleculer MsgPack) because it
22502
+ * skips the 33% base64 overhead + the per-call base64 decode on
22503
+ * the detection-pipeline worker. Callers can pass either; exactly
22504
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
22505
+ */
22506
+ image: _instanceof(Uint8Array).optional(),
22507
+ referenceImage: string().optional(),
22508
+ deviceId: number().optional(),
22509
+ sessionId: string().optional(),
22510
+ /**
22511
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
22512
+ * reference-image, and detail-subtree calls. 'frame' is the live
22513
+ * per-frame dispatch: ONLY root-plane steps run; crop children
22514
+ * (inputClasses ≠ null) are skipped and served per-track via
22515
+ * pipelineRunner.runDetailSubtree (two-plane design).
22516
+ */
22517
+ plane: _enum(["full", "frame"]).optional(),
22518
+ /**
22519
+ * Inference-device selector (Phase 2 multi-device). Format
22520
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
22521
+ * Omitted ⇒ the runner's default device (current single-engine
22522
+ * behaviour). Selects WHICH device pool of the node runs the call.
22523
+ */
22524
+ deviceKey: string().optional(),
22525
+ /**
22526
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
22527
+ * when the parent crop was resolved from the frame's retained NATIVE
22528
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
22529
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
22530
+ * resolution from that surface — the SAME quality path faces already
22531
+ * had — instead of the downscaled parent tile. `handle` keys the native
22532
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
22533
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
22534
+ * the executor's crop-normalized child ROI back into frame-normalized
22535
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
22536
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
22537
+ * (today's behaviour on the fallback path).
22538
+ */
22539
+ nativeCropRef: NativeCropRefSchema.optional(),
22540
+ /**
22541
+ * Offline REPLAY of stored media for `deviceId` (D56, D646): the
22542
+ * camera's zone gate and overrides apply as live, every executing
22543
+ * step runs EXACTLY the model it names on the `deviceKey` pool it
22544
+ * names or the call refuses (`model-not-servable` /
22545
+ * `device-not-servable`), and nothing reaches the camera's live
22546
+ * trace stream. Absent ⇒ unchanged behaviour.
22547
+ */
22548
+ replay: literal(true).optional()
22549
+ }), PipelineRunResultBridge, { kind: "mutation" }),
22550
+ /**
22551
+ * Batched run — N raw frames packed into one cap call. The provider
22552
+ * routes the batch through `SharedInferencePool.inferBatch`
22553
+ * (`MSG_INFER_BATCH = 0x03`) so the IPC framing and JSON response
22554
+ * envelope cost is amortised N:1 vs N concurrent `runPipeline`
22555
+ * calls. Single root step + uniform model assumed; trees with crop
22556
+ * children fall back to sequential execution.
22557
+ *
22558
+ * Used by `scripts/bench-batch-style.mts` for batch benchmarking —
22559
+ * N frames in one call to amortise per-call IPC overhead.
22560
+ */
22561
+ runPipelineBatch: method(object({
22562
+ steps: array(PipelineStepInputSchema).min(1),
22563
+ frames: array(FrameInputSchema).min(1).max(255),
22564
+ deviceId: number().optional(),
22565
+ sessionId: string().optional(),
22566
+ /**
22567
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
22568
+ * the batch to the Python pool's bench preprocess cache
22569
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
22570
+ * preprocessed ONCE and every later inference is a pure-inference cache
22571
+ * hit — the sustained-throughput run measures inference, not
22572
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
22573
+ * full preprocess every call, correct). Fresh per sustained run;
22574
+ * released via `uncacheFrame`.
22575
+ */
22576
+ frameId: number().int().nonnegative().optional(),
22577
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
22578
+ deviceKey: string().optional()
22579
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }),
22580
+ /**
22581
+ * Cache a raw frame inside the Python inference pool's memory.
22582
+ * Returns a numeric `frameId` that `inferCached` references —
22583
+ * subsequent calls send only 5 bytes through the pipe instead of
22584
+ * 1.2MB raw data, eliminating the pipe transfer bottleneck.
22585
+ */
22586
+ cacheFrameInPool: method(object({
22587
+ data: _instanceof(Uint8Array),
22588
+ width: number().int().positive(),
22589
+ height: number().int().positive(),
22590
+ format: _enum([
22591
+ "rgb",
22592
+ "bgr",
22593
+ "gray"
22594
+ ])
22595
+ }), object({
22596
+ frameId: number(),
22597
+ width: number(),
22598
+ height: number()
22599
+ }), { kind: "mutation" }),
22600
+ /**
22601
+ * Run inference on a previously cached frame. Sends only 5 bytes
22602
+ * (model_idx + frameId) through the IPC pipe — eliminates the
22603
+ * ~35ms per-call overhead of transferring 1.2MB raw data.
22604
+ */
22605
+ inferCached: method(object({
22606
+ stepId: string(),
22607
+ frameId: number().int()
22608
+ }), record(string(), unknown()), { kind: "mutation" }),
22609
+ /**
22610
+ * Release a cached frame from the Python pool's memory.
22611
+ */
22612
+ uncacheFrame: method(object({ frameId: number().int() }), _void(), { kind: "mutation" }),
22613
+ /**
22614
+ * The effective provisioning of ONE pool of this node (operator override →
22615
+ * the pool's own runtime row). `deviceKey` names the device pool; absent is
22616
+ * the node-default pool. It answered only for the node default until
22617
+ * D646, so a benchmark on `openvino:npu` recorded the onnx pool's tuning
22618
+ * beside an NPU measurement.
22619
+ */
22620
+ getEffectiveTuning: method(object({ deviceKey: string().optional() }), EffectiveTuningSchema),
22621
+ /**
22622
+ * List every EngineFactory currently loaded in this executor's RAM,
22623
+ * with the models resident and a coarse "in use" marker derived from
22624
+ * ongoing inference activity. Used by the Pipeline page Engines tab.
22625
+ */
22626
+ listLoadedEngines: method(_void(), array(object({
22627
+ engineKey: string(),
22628
+ engine: PipelineEngineChoiceSchema,
22629
+ modelsLoaded: array(string()).readonly(),
22630
+ inUseByCameras: array(number()).readonly(),
22631
+ /**
22632
+ * Origin of this resident factory.
22633
+ * - `runtime` — main camera-serving engine (no idle TTL).
22634
+ * - `device-pool` — a concurrent per-device pool (Phase 2
22635
+ * multi-device, keyed by `deviceKey`) resolved
22636
+ * via `resolveDeviceFactory`. Runs alongside the
22637
+ * `runtime` engine on a DIFFERENT accelerator
22638
+ * (NPU / iGPU / Coral) — this is how the
22639
+ * Engines tab shows all pools running at once.
22640
+ */
22641
+ kind: _enum(["runtime", "device-pool"]),
22642
+ /** Native pid of the underlying Python pool (null when no pool). */
22643
+ poolPid: number().nullable(),
22644
+ /** ms since this factory was last used (null when not warm-tracked). */
22645
+ idleMs: number().nullable(),
22646
+ /** Idle TTL after which the factory self-evicts (null when not applicable). */
22647
+ idleTtlMs: number().nullable()
22648
+ })).readonly()),
22649
+ /** Warm up an engine without running a frame. No-op if already loaded. */
22650
+ spinEngine: method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
22651
+ kind: "mutation",
22652
+ auth: "admin"
22653
+ }),
22654
+ /**
22655
+ * Unload an engine from RAM. `force:true` unloads even when cameras
22656
+ * are actively using it (they re-spin on next frame). Default is
22657
+ * gated — returns `{success:false, reason}` when in use.
22658
+ */
22659
+ killEngine: method(object({
22660
+ engine: PipelineEngineChoiceSchema,
22661
+ force: boolean().optional()
22662
+ }), object({
22663
+ success: boolean(),
22664
+ reason: string().optional()
22665
+ }), {
22666
+ kind: "mutation",
22667
+ auth: "admin"
22668
+ }),
22669
+ listReferenceImages: method(_void(), array(ReferenceImageEntrySchema).readonly()),
22670
+ getReferenceImage: method(object({ filename: string() }), ReferenceImageBodySchema.nullable()),
22671
+ getReferenceAudioFiles: method(_void(), array(ReferenceAudioEntrySchema).readonly()),
22672
+ getReferenceAudio: method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()),
22673
+ getAudioCapabilities: method(_void(), AudioCapabilitiesSchema),
22674
+ runAudioTest: method(object({
22675
+ addonId: string(),
22676
+ modelId: string(),
22677
+ filename: string().optional(),
22678
+ settings: record(string(), unknown()).optional()
22679
+ }), AudioTestResultSchema, { kind: "mutation" }),
22680
+ getDetectionConfigSchema: method(_void(), ConfigUISchemaNullableBridge)
22681
+ }
22682
+ };
22764
22683
  object({
22765
22684
  activeCameras: number(),
22766
22685
  throttledCameras: number(),
@@ -22786,6 +22705,106 @@ var CameraMetricsSchema = object({
22786
22705
  });
22787
22706
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
22788
22707
  /**
22708
+ * Zone — pure geometry + identity. NO filtering behaviour.
22709
+ *
22710
+ * Zones describe **where** in the frame the operator wants to flag
22711
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
22712
+ * each pipeline stage uses them. Splitting the two means a single
22713
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
22714
+ * a detection-include rule on `['car']`, and an occupancy aggregate
22715
+ * — without three duplicated polygons.
22716
+ *
22717
+ * Owned by the orchestrator addon (provider) and mirrored into the
22718
+ * `zones` device-state slice on every mutation. Consumers
22719
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
22720
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
22721
+ * mirror with `onChanged`).
22722
+ *
22723
+ * Coordinates are normalised fractions of the frame (0–1) so zones
22724
+ * survive resolution changes and stream profile switches.
22725
+ *
22726
+ * `kind` discriminates between full polygons (closed regions used
22727
+ * for intrusion / occupancy filters) and tripwires (open 2-point
22728
+ * line segments used for cross events). Onboard / firmware-reported
22729
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
22730
+ * task list.
22731
+ */
22732
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
22733
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
22734
+ var PolygonPointSchema = object({
22735
+ x: number(),
22736
+ y: number()
22737
+ });
22738
+ /** A camera detection zone — pure geometry/identity. */
22739
+ var ZoneSchema = object({
22740
+ id: string(),
22741
+ name: string(),
22742
+ kind: ZoneKindEnum.default("polygon"),
22743
+ /** Polygon vertices, fraction of frame (0–1). */
22744
+ polygon: array(PolygonPointSchema).readonly(),
22745
+ /** Visual color for UI rendering. */
22746
+ color: string().default("#3b82f6")
22747
+ });
22748
+ /**
22749
+ * Zones capability — per-camera CRUD over polygon detection zones.
22750
+ *
22751
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
22752
+ * to per-device settings and mirrors into the `zones` device-state
22753
+ * slice on every mutation, so downstream consumers can subscribe via
22754
+ * `dev.state.zones.onChanged`.
22755
+ *
22756
+ * The cap surface only handles geometry + identity; filtering
22757
+ * behaviour (per-class, include/exclude, threshold) lives in the
22758
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
22759
+ * `capabilities/schemas/zone-rule.js`.
22760
+ */
22761
+ var zonesCapability = {
22762
+ name: "zones",
22763
+ scope: "device",
22764
+ mode: "singleton",
22765
+ deviceTypes: [DeviceType.Camera],
22766
+ methods: {
22767
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
22768
+ addZone: method(object({
22769
+ deviceId: number(),
22770
+ zone: ZoneSchema
22771
+ }), _void(), {
22772
+ kind: "mutation",
22773
+ auth: "admin"
22774
+ }),
22775
+ removeZone: method(object({
22776
+ deviceId: number(),
22777
+ zoneId: string()
22778
+ }), _void(), {
22779
+ kind: "mutation",
22780
+ auth: "admin"
22781
+ }),
22782
+ updateZone: method(object({
22783
+ deviceId: number(),
22784
+ zone: ZoneSchema
22785
+ }), _void(), {
22786
+ kind: "mutation",
22787
+ auth: "admin"
22788
+ })
22789
+ },
22790
+ /**
22791
+ * Runtime-state slice — the live zone catalogue mirrored by the
22792
+ * orchestrator on every CRUD mutation. Consumers read via
22793
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
22794
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
22795
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
22796
+ * (e.g. zone groupings) can sit alongside the polygon list.
22797
+ */
22798
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
22799
+ /**
22800
+ * 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.
22801
+ *
22802
+ * See `RuntimeStateDurability`. Enforced by
22803
+ * `scripts/check-runtime-state-durability.ts`.
22804
+ */
22805
+ durability: "restored"
22806
+ };
22807
+ /**
22789
22808
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
22790
22809
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
22791
22810
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -22972,7 +22991,17 @@ var DetailResultSchema = object({
22972
22991
  /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
22973
22992
  * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
22974
22993
  * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
22975
- nativeFaceShortSidePx: number().optional()
22994
+ nativeFaceShortSidePx: number().optional(),
22995
+ /**
22996
+ * The five facial landmarks of a `face` detail, in the SAME frame space as
22997
+ * `bbox` (D644). Additive and optional: post-analysis stores them beside the
22998
+ * face's source frame so a future alignment can be re-derived exactly; a
22999
+ * runner that predates the field sends none and the face is stored without.
23000
+ */
23001
+ landmarks: array(object({
23002
+ x: number(),
23003
+ y: number()
23004
+ })).optional()
22976
23005
  });
22977
23006
  /**
22978
23007
  * Why an executing node REFUSED a stateless step run (`runStatelessStep`).
@@ -31828,7 +31857,7 @@ var HardwareInfoSchema = object({
31828
31857
  coral: CoralInfoSchema.nullable().optional()
31829
31858
  });
31830
31859
  var PlatformScoreSchema = object({
31831
- runtime: _enum(["node", "python"]),
31860
+ runtime: literal("python"),
31832
31861
  backend: string(),
31833
31862
  format: _enum([
31834
31863
  "onnx",
@@ -31865,7 +31894,7 @@ var ModelRequirementSchema = object({
31865
31894
  });
31866
31895
  var ResolvedInferenceConfigSchema = object({
31867
31896
  modelId: string(),
31868
- runtime: _enum(["node", "python"]),
31897
+ runtime: literal("python"),
31869
31898
  backend: string(),
31870
31899
  format: ModelFormatSchema,
31871
31900
  reason: string()
@@ -34102,6 +34131,92 @@ DeviceType.Camera, method(object({ deviceId: number() }), SceneMonitorStatusSche
34102
34131
  kind: "mutation",
34103
34132
  auth: "admin"
34104
34133
  });
34134
+ /**
34135
+ * Per-stage gating mode applied to the zones a rule references.
34136
+ *
34137
+ * - `include`: the rule contributes to a **whitelist** for its stage.
34138
+ * When at least one `include` rule fires for a stage, only entities
34139
+ * inside one of those zones pass that stage.
34140
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
34141
+ * Entities inside one of those zones are dropped at that stage.
34142
+ *
34143
+ * `monitor`-style observation (count without filtering) is not a rule
34144
+ * mode — zones without any matching rule are observed naturally by
34145
+ * `zone-analytics` (live snapshot + history), so an "I just want to
34146
+ * count, not filter" use case needs no rule at all.
34147
+ */
34148
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
34149
+ /**
34150
+ * Per-consumer rule that references existing zones (geometry) and
34151
+ * defines how a specific pipeline stage should treat them. Each
34152
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
34153
+ * settings:
34154
+ *
34155
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
34156
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
34157
+ * - future: notification rules, audio gating, etc.
34158
+ *
34159
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
34160
+ * express "ignore motion in ALL of {garden, street}" with a single
34161
+ * rule. `classFilter` narrows the rule to specific object classes —
34162
+ * "drop person detections in the street, but keep cars" is one
34163
+ * `exclude` rule with `classFilter: ['person']`.
34164
+ *
34165
+ * `enabled` is a soft toggle — the operator can keep the rule
34166
+ * configured but inert without deleting it.
34167
+ */
34168
+ var ZoneRuleSchema = object({
34169
+ /** Stable rule id — survives edits, used by the UI for diffing. */
34170
+ id: string(),
34171
+ /** Optional human-readable label rendered in the rule editor. */
34172
+ name: string().optional(),
34173
+ /** Zones this rule targets. The rule's `mode` applies to ALL
34174
+ * listed zones (OR-set: a detection in any one of them counts).
34175
+ * At least one zone id required — a rule with no targets is a
34176
+ * configuration mistake and the form validator rejects it. */
34177
+ zoneIds: array(string()).min(1).readonly(),
34178
+ mode: ZoneRuleModeEnum,
34179
+ /**
34180
+ * Class names this rule applies to. Empty / undefined ⇒ rule
34181
+ * applies to every class. Class strings match the `macroClass`
34182
+ * field on detections (e.g. `person`, `car`, `dog`).
34183
+ */
34184
+ classFilter: array(string()).readonly().optional(),
34185
+ /**
34186
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
34187
+ * required to consider an entity "in the zone". Defaults to the
34188
+ * consumer's stage default when omitted. Kept for back-compat with
34189
+ * existing per-rule overrides; new operators pick the value via
34190
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
34191
+ * set, the lower-level engine reads it as a 0–1 fraction.
34192
+ */
34193
+ overlapThreshold: number().min(0).max(1).optional(),
34194
+ /**
34195
+ * Operator-friendly version of `overlapThreshold` — the percentage
34196
+ * of the detection's bbox that must lie inside the zone for the
34197
+ * rule to match. Documented default is 85%; the engine substitutes
34198
+ * that when the field is omitted (kept optional so existing rules
34199
+ * stored without it stay valid).
34200
+ *
34201
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
34202
+ * rule, the engine prefers `bboxInclusionPct` because it's the
34203
+ * field exposed in the UI. Internally both feed the same gate.
34204
+ */
34205
+ bboxInclusionPct: number().min(0).max(100).optional(),
34206
+ /**
34207
+ * When `true` and a detection has a segmentation mask, use the
34208
+ * mask for overlap instead of the bbox. Detection-stage only;
34209
+ * motion rules ignore this field.
34210
+ */
34211
+ preferMask: boolean().optional(),
34212
+ /**
34213
+ * Soft-toggle: `false` disables the rule without deleting it.
34214
+ * Defaults to `true` so operators creating a rule via the UI
34215
+ * see it active immediately.
34216
+ */
34217
+ enabled: boolean().default(true)
34218
+ });
34219
+ array(ZoneRuleSchema).readonly();
34105
34220
  object({
34106
34221
  /** Whether the script is currently executing. */
34107
34222
  isRunning: boolean(),
@@ -40538,6 +40653,12 @@ Object.freeze({
40538
40653
  addonId: null,
40539
40654
  access: "view"
40540
40655
  },
40656
+ "notificationRules.previewStateSummary": {
40657
+ capName: "notification-rules",
40658
+ capScope: "system",
40659
+ addonId: null,
40660
+ access: "view"
40661
+ },
40541
40662
  "notificationRules.previewTemplate": {
40542
40663
  capName: "notification-rules",
40543
40664
  capScope: "system",
@@ -41114,12 +41235,6 @@ Object.freeze({
41114
41235
  addonId: null,
41115
41236
  access: "create"
41116
41237
  },
41117
- "pipelineAnalytics.runReplayFrameProcessor": {
41118
- capName: "pipeline-analytics",
41119
- capScope: "device",
41120
- addonId: null,
41121
- access: "create"
41122
- },
41123
41238
  "pipelineAnalytics.saveRetrainAnnotations": {
41124
41239
  capName: "pipeline-analytics",
41125
41240
  capScope: "device",
@@ -45217,11 +45332,6 @@ Object.freeze({
45217
45332
  form: "single",
45218
45333
  optional: false
45219
45334
  }],
45220
- "pipelineAnalytics.runReplayFrameProcessor": [{
45221
- name: "deviceId",
45222
- form: "single",
45223
- optional: false
45224
- }],
45225
45335
  "pipelineAnalytics.saveRetrainAnnotations": [{
45226
45336
  name: "deviceId",
45227
45337
  form: "single",
@@ -46201,6 +46311,98 @@ new Map(Object.entries({
46201
46311
  "camera-enabled": null
46202
46312
  }));
46203
46313
  [...NC_SYSTEM_EVENT_FILTER_KEYS];
46314
+ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
46315
+ {
46316
+ id: "device-state",
46317
+ family: "device-events",
46318
+ label: "Device state",
46319
+ kinds: [
46320
+ "device-offline",
46321
+ "device-online",
46322
+ "device-disabled",
46323
+ "device-enabled"
46324
+ ]
46325
+ },
46326
+ {
46327
+ id: "streams",
46328
+ family: "device-events",
46329
+ label: "Streams",
46330
+ kinds: ["stream-offline", "stream-online"]
46331
+ },
46332
+ {
46333
+ id: "battery",
46334
+ family: "device-events",
46335
+ label: "Battery",
46336
+ kinds: ["device-battery-low", "device-battery-normal"]
46337
+ },
46338
+ {
46339
+ id: "consumables",
46340
+ family: "device-events",
46341
+ label: "Consumables",
46342
+ kinds: ["device-consumable-low", "device-consumable-normal"]
46343
+ },
46344
+ {
46345
+ id: "tanks",
46346
+ family: "device-events",
46347
+ label: "Tanks",
46348
+ kinds: [
46349
+ "device-tank-low",
46350
+ "device-tank-full",
46351
+ "device-tank-normal"
46352
+ ]
46353
+ },
46354
+ {
46355
+ id: "detection-blind",
46356
+ family: "device-events",
46357
+ label: "Detecting nothing",
46358
+ kinds: ["detection-blind"]
46359
+ },
46360
+ {
46361
+ id: "nodes",
46362
+ family: "system",
46363
+ label: "Nodes",
46364
+ kinds: [
46365
+ "node-offline",
46366
+ "node-online",
46367
+ "node-inference-unavailable"
46368
+ ]
46369
+ },
46370
+ {
46371
+ id: "addons",
46372
+ family: "system",
46373
+ label: "Addons",
46374
+ kinds: [
46375
+ "addon-crash-loop",
46376
+ "addon-update-available",
46377
+ "addon-updated"
46378
+ ]
46379
+ },
46380
+ {
46381
+ id: "updates",
46382
+ family: "system",
46383
+ label: "Server & container updates",
46384
+ kinds: [
46385
+ "server-update-available",
46386
+ "server-updated",
46387
+ "wrapper-update-available"
46388
+ ]
46389
+ },
46390
+ {
46391
+ id: "backups-exports",
46392
+ family: "system",
46393
+ label: "Backups & exports",
46394
+ kinds: ["backup-completed", "export-completed"]
46395
+ },
46396
+ {
46397
+ id: "alarm",
46398
+ family: "alarm",
46399
+ label: "Alarm",
46400
+ kinds: NC_ALARM_SYSTEM_EVENT_KINDS
46401
+ }
46402
+ ];
46403
+ function systemEventKindsOfFamily(family) {
46404
+ return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
46405
+ }
46204
46406
  NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
46205
46407
  /**
46206
46408
  * WHICH WAY A BOOLEAN SENSOR MOVED — read off the one slice a sensor event
@@ -46275,7 +46477,183 @@ var DEVICE_EVENTS = [
46275
46477
  "detection-blind",
46276
46478
  ...ALARM
46277
46479
  ];
46278
- [...DEVICE_EVENTS], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_BODY_ONLY], [...RULE_TEXT], [...RULE_TEXT], [...DEVICE_EVENTS], [...RULE_TEXT], [...DEVICE_EVENTS], [...RULE_TEXT], [...BATTERY, ...CONSUMABLE], [...RULE_TEXT], [...CONSUMABLE], [...RULE_TEXT], [...TANK], [...RULE_TEXT], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT];
46480
+ /** Every kind a summary may speak about — the two summarisable families. */
46481
+ var SUMMARISABLE = [...systemEventKindsOfFamily("device-events"), ...systemEventKindsOfFamily("system")];
46482
+ /** One per summary SECTION (`NC_STATE_SUMMARY_SECTIONS` in the notification
46483
+ * centre): the section's lines, offered when one of its kinds is selected. */
46484
+ var STATE_SUMMARY_SECTION_VARS = [
46485
+ {
46486
+ name: "summaryDevices",
46487
+ label: "Summary: devices offline / switched off",
46488
+ example: "Garage — offline since 07:12",
46489
+ kinds: [
46490
+ "device-offline",
46491
+ "device-online",
46492
+ "device-disabled",
46493
+ "device-enabled"
46494
+ ]
46495
+ },
46496
+ {
46497
+ name: "summaryStreams",
46498
+ label: "Summary: streams offline",
46499
+ example: "Ingresso (high) — since 06:40",
46500
+ kinds: ["stream-offline", "stream-online"]
46501
+ },
46502
+ {
46503
+ name: "summaryBattery",
46504
+ label: "Summary: low batteries",
46505
+ example: "Sensore porta — 8 %",
46506
+ kinds: BATTERY
46507
+ },
46508
+ {
46509
+ name: "summaryConsumables",
46510
+ label: "Summary: consumables",
46511
+ example: "Robot — filter 10 %",
46512
+ kinds: CONSUMABLE
46513
+ },
46514
+ {
46515
+ name: "summaryTanks",
46516
+ label: "Summary: tanks",
46517
+ example: "Robot — clean water low",
46518
+ kinds: TANK
46519
+ },
46520
+ {
46521
+ name: "summaryDetection",
46522
+ label: "Summary: cameras detecting nothing",
46523
+ example: "Ingresso — since 05:10",
46524
+ kinds: ["detection-blind"]
46525
+ },
46526
+ {
46527
+ name: "summaryNodes",
46528
+ label: "Summary: nodes",
46529
+ example: "little-unraid — offline since 03:00",
46530
+ kinds: [
46531
+ "node-offline",
46532
+ "node-online",
46533
+ "node-inference-unavailable"
46534
+ ]
46535
+ },
46536
+ {
46537
+ name: "summaryAddons",
46538
+ label: "Summary: addons",
46539
+ example: "@camstack/addon-recorder 1.2.3 → 1.2.4",
46540
+ kinds: [
46541
+ "addon-crash-loop",
46542
+ "addon-update-available",
46543
+ "addon-updated"
46544
+ ]
46545
+ },
46546
+ {
46547
+ name: "summaryUpdates",
46548
+ label: "Summary: server & container updates",
46549
+ example: "server 1.2.377 → 1.2.378",
46550
+ kinds: [
46551
+ "server-update-available",
46552
+ "server-updated",
46553
+ "wrapper-update-available"
46554
+ ]
46555
+ }
46556
+ ];
46557
+ var STATE_SUMMARY_VARS = [
46558
+ {
46559
+ name: "summaryText",
46560
+ label: "Summary: every section",
46561
+ description: "One block per section with something to report, one line per item.",
46562
+ example: "Batterie scariche: Sensore porta — 8 %",
46563
+ group: "system",
46564
+ families: ["rule"],
46565
+ fields: [...RULE_TEXT],
46566
+ kinds: ["system"],
46567
+ systemEventKinds: [...SUMMARISABLE],
46568
+ systemEventDeliveries: ["summary"]
46569
+ },
46570
+ {
46571
+ name: "summaryCount",
46572
+ label: "Summary: items reported",
46573
+ example: "3",
46574
+ group: "system",
46575
+ families: ["rule"],
46576
+ fields: [...RULE_TEXT],
46577
+ kinds: ["system"],
46578
+ systemEventKinds: [...SUMMARISABLE],
46579
+ systemEventDeliveries: ["summary"]
46580
+ },
46581
+ ...STATE_SUMMARY_SECTION_VARS.map((v) => ({
46582
+ name: v.name,
46583
+ label: v.label,
46584
+ example: v.example,
46585
+ group: "system",
46586
+ families: ["rule"],
46587
+ fields: [...RULE_TEXT],
46588
+ kinds: ["system"],
46589
+ systemEventKinds: [...v.kinds],
46590
+ systemEventDeliveries: ["summary"]
46591
+ }))
46592
+ ];
46593
+ [
46594
+ [...DEVICE_EVENTS],
46595
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
46596
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
46597
+ [...RULE_TEXT],
46598
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
46599
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
46600
+ [...RULE_TEXT],
46601
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
46602
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
46603
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
46604
+ [...RULE_TEXT],
46605
+ [...RULE_TEXT],
46606
+ [...RULE_TEXT],
46607
+ [...RULE_TEXT],
46608
+ [...RULE_TEXT],
46609
+ [...RULE_TEXT],
46610
+ [...RULE_TEXT],
46611
+ [...RULE_TEXT],
46612
+ [...RULE_BODY_ONLY],
46613
+ [...RULE_TEXT],
46614
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
46615
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
46616
+ ([...RULE_TEXT], [...BATTERY, ...CONSUMABLE]),
46617
+ ([...RULE_TEXT], [...CONSUMABLE]),
46618
+ ([...RULE_TEXT], [...TANK]),
46619
+ [...RULE_TEXT],
46620
+ ([...RULE_TEXT], [...UPDATES]),
46621
+ ([...RULE_TEXT], [...UPDATES]),
46622
+ [...RULE_TEXT],
46623
+ [...RULE_TEXT],
46624
+ [...RULE_TEXT],
46625
+ ([...RULE_TEXT], [...UPDATES]),
46626
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
46627
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
46628
+ ([...RULE_TEXT], [...UPDATES]),
46629
+ ([...RULE_TEXT], [...UPDATES]),
46630
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
46631
+ [...RULE_TEXT],
46632
+ [...RULE_TEXT],
46633
+ [...RULE_TEXT],
46634
+ [...RULE_TEXT],
46635
+ [...RULE_TEXT],
46636
+ [...RULE_TEXT],
46637
+ [...RULE_TEXT],
46638
+ [...RULE_TEXT],
46639
+ [...RULE_TEXT],
46640
+ [...RULE_TEXT],
46641
+ [...RULE_TEXT],
46642
+ [...RULE_TEXT],
46643
+ [...RULE_TEXT],
46644
+ [...RULE_TEXT],
46645
+ [...RULE_TEXT],
46646
+ [...RULE_TEXT],
46647
+ [...RULE_TEXT],
46648
+ [...RULE_TEXT],
46649
+ [...RULE_TEXT],
46650
+ [...RULE_TEXT],
46651
+ [...RULE_TEXT],
46652
+ [...RULE_TEXT],
46653
+ [...RULE_TEXT],
46654
+ [...RULE_TEXT],
46655
+ ...STATE_SUMMARY_VARS
46656
+ ];
46279
46657
  /**
46280
46658
  * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
46281
46659
  *
@@ -46956,9 +47334,9 @@ var MB = 1024 * 1024;
46956
47334
  1024 * MB, 3072 * MB;
46957
47335
  /**
46958
47336
  * DEVICE-POOL backend → model format — the SSOT for the multi-device inference
46959
- * DESCRIPTOR path (Python per-device pools), distinct from {@link BACKEND_TO_FORMAT}
46960
- * above which is the legacy NODE runtime map (where `coreml → onnx` because
46961
- * onnxruntime-node's CoreML EP loads `.onnx`). Here a device pool runs the
47337
+ * DESCRIPTOR path (Python per-device pools), distinct from the former BACKEND_TO_FORMAT,
47338
+ * which was the removed NODE runtime map (where `coreml → onnx` because
47339
+ * onnxruntime-node's CoreML EP loaded `.onnx`). A device pool runs the
46962
47340
  * backend NATIVELY, so `coreml → coreml` and `edgetpu → tflite`. Consumed by
46963
47341
  * `resolveDeviceEngine` (addon-pipeline) and the orchestrator's
46964
47342
  * `parseDeviceKey`/`getNodeInferenceDevices` — the previously-duplicated
@@ -55595,7 +55973,7 @@ function migrateCameraSettings(cameraMap) {
55595
55973
  * schema is kept faithful to the on-disk shape rather than overly strict.
55596
55974
  */
55597
55975
  var EngineChoiceSchema = object({
55598
- runtime: _enum(["node", "python"]),
55976
+ runtime: _enum(["python", "node"]).transform(() => "python"),
55599
55977
  backend: string(),
55600
55978
  format: string(),
55601
55979
  device: string().optional()