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