@camstack/types 1.2.258 → 1.2.260
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/addon.js +12 -2
- package/dist/addon.mjs +12 -2
- package/dist/capabilities/camera-streams.cap.d.ts +5 -5
- package/dist/capabilities/custom-model-registry.cap.d.ts +0 -12
- package/dist/capabilities/decoder.cap.d.ts +12 -12
- package/dist/capabilities/index.d.ts +3 -3
- package/dist/capabilities/load-contribution.cap.d.ts +2 -2
- package/dist/capabilities/model-convert.cap.d.ts +0 -6
- package/dist/capabilities/model-distributor.cap.d.ts +0 -12
- package/dist/capabilities/motion-detection.cap.d.ts +4 -4
- package/dist/capabilities/notification-rules.cap.d.ts +572 -18
- package/dist/capabilities/osd-manager.cap.d.ts +1 -1
- package/dist/capabilities/pipeline-analytics.cap.d.ts +50 -127
- package/dist/capabilities/pipeline-executor.cap.d.ts +78 -120
- package/dist/capabilities/pipeline-orchestrator.cap.d.ts +16 -64
- package/dist/capabilities/pipeline-runner.cap.d.ts +18 -6
- package/dist/capabilities/platform-probe.cap.d.ts +4 -13
- package/dist/capabilities/recording-export.cap.d.ts +7 -7
- package/dist/capabilities/schemas/detection-shared.d.ts +4 -4
- package/dist/capabilities/schemas/streaming-shared.d.ts +8 -8
- package/dist/capabilities/stream-broker.cap.d.ts +9 -9
- package/dist/capabilities/system.cap.d.ts +2 -2
- package/dist/capabilities/vacuum-control.cap.d.ts +13 -13
- package/dist/capabilities/videoclips.cap.d.ts +5 -5
- package/dist/capabilities/webrtc-session.cap.d.ts +2 -2
- package/dist/generated/addon-api.d.ts +9 -9
- package/dist/generated/cap-input-defaults.d.ts +1 -1
- package/dist/generated/method-device-selectors.d.ts +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1785 -1406
- package/dist/index.mjs +1770 -1402
- package/dist/interfaces/event-bus.d.ts +1 -1
- package/dist/interfaces/pipeline-executor-capability.d.ts +15 -6
- package/dist/interfaces/platform.d.ts +2 -2
- package/dist/interfaces/stream-broker.d.ts +2 -2
- package/dist/notification/system-event-summary.d.ts +83 -0
- package/dist/notification/template-vars.d.ts +15 -0
- package/dist/{sleep-DtomDrRW.js → sleep-BDYxE1ax.js} +1 -1
- package/dist/{sleep-DU7mu4wb.mjs → sleep-BaRu0bS5.mjs} +1 -1
- package/dist/types/detection.d.ts +18 -0
- package/dist/types/models.d.ts +0 -19
- package/dist/types/pipeline-step.d.ts +9 -1
- package/dist/types/pipeline.d.ts +2 -1
- package/dist/utils/background-run-registry.d.ts +69 -0
- package/dist/utils/runtime-mapping.d.ts +9 -54
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_sleep = require("./sleep-
|
|
2
|
+
const require_sleep = require("./sleep-BDYxE1ax.js");
|
|
3
3
|
const require_event_category = require("./event-category-BVfsrBYA.js");
|
|
4
4
|
const require_canonical_hash = require("./canonical-hash-CSE4ioRi.js");
|
|
5
5
|
const require_enums = require("./enums.js");
|
|
@@ -5046,7 +5046,7 @@ var ModelFormatEntrySchema = zod.z.object({
|
|
|
5046
5046
|
/** Multi-file payload (directory members or sibling files). */
|
|
5047
5047
|
files: zod.z.array(zod.z.string()).readonly().optional(),
|
|
5048
5048
|
/** Runtime(s) that can use this format. If omitted, inferred from ModelFormat key */
|
|
5049
|
-
runtimes: zod.z.array(zod.z.enum(["
|
|
5049
|
+
runtimes: zod.z.array(zod.z.enum(["python"])).readonly().optional()
|
|
5050
5050
|
});
|
|
5051
5051
|
/**
|
|
5052
5052
|
* Extra file that must be downloaded alongside the model (e.g., labels JSON, dict.txt).
|
|
@@ -17407,6 +17407,25 @@ var NcScheduleSchema = zod.z.object({
|
|
|
17407
17407
|
/** Active OUTSIDE the windows (e.g. "only outside business hours"). */
|
|
17408
17408
|
invert: zod.z.boolean().optional()
|
|
17409
17409
|
});
|
|
17410
|
+
/**
|
|
17411
|
+
* How a system-event rule of the `device-events` or `system` family speaks
|
|
17412
|
+
* (D647): at once, per event (`instant`, the only behaviour before D647), or
|
|
17413
|
+
* as a STATE SUMMARY at the end of each window of `schedule`.
|
|
17414
|
+
*/
|
|
17415
|
+
var NcSystemEventDeliveryModeSchema = zod.z.enum(["instant", "summary"]);
|
|
17416
|
+
/**
|
|
17417
|
+
* `summary`: the rule sends NOTHING per event. When a window of `schedule`
|
|
17418
|
+
* CLOSES, it sends one notification with the current state of its kinds
|
|
17419
|
+
* (low batteries, consumables to replace, devices offline, updates
|
|
17420
|
+
* available, ...), after its own filters. Nothing to report sends nothing.
|
|
17421
|
+
* The schedule is the ordinary `NcSchedule` (weekly windows, IANA timezone,
|
|
17422
|
+
* midnight crossing); the send time is each window's END. Refused on the
|
|
17423
|
+
* `alarm` family, which stays instant (`systemEventDeliveryProblems`).
|
|
17424
|
+
*/
|
|
17425
|
+
var NcSystemEventDeliverySchema = zod.z.discriminatedUnion("mode", [zod.z.object({ mode: zod.z.literal("instant") }), zod.z.object({
|
|
17426
|
+
mode: zod.z.literal("summary"),
|
|
17427
|
+
schedule: NcScheduleSchema
|
|
17428
|
+
})]);
|
|
17410
17429
|
/** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
|
|
17411
17430
|
var NcPlateMatcherSchema = zod.z.object({
|
|
17412
17431
|
/**
|
|
@@ -18161,6 +18180,16 @@ var NcRuleInputSchema = zod.z.object({
|
|
|
18161
18180
|
delivery: NcDeliverySchema,
|
|
18162
18181
|
conditions: NcConditionsSchema.default({}),
|
|
18163
18182
|
schedule: NcScheduleSchema.optional(),
|
|
18183
|
+
/**
|
|
18184
|
+
* A `device-events` / `system` rule's delivery (D647): absent or `instant`
|
|
18185
|
+
* is a notification per event; `summary` is one state summary per closed
|
|
18186
|
+
* window of its schedule. `.optional()` and never defaulted: absent must
|
|
18187
|
+
* keep meaning what every rule authored before D647 meant, with no
|
|
18188
|
+
* migration. Top-level rather than inside `conditions.systemEvent`, so a
|
|
18189
|
+
* client that does not know it (an older viewer re-sending `conditions`
|
|
18190
|
+
* whole) leaves it standing through the store's patch merge.
|
|
18191
|
+
*/
|
|
18192
|
+
systemEventDelivery: NcSystemEventDeliverySchema.optional(),
|
|
18164
18193
|
/** May be empty when `targetUsers` addresses at least one user — the
|
|
18165
18194
|
* "at least one addressee" invariant is enforced by the provider, because
|
|
18166
18195
|
* a cross-field refine here would break `NcRulePatchSchema.partial()`. */
|
|
@@ -18400,6 +18429,28 @@ var NcRuleSchema = NcRuleInputSchema.extend({
|
|
|
18400
18429
|
*/
|
|
18401
18430
|
disabledTargetIds: zod.z.array(zod.z.string()).default([])
|
|
18402
18431
|
});
|
|
18432
|
+
/** One section of a previewed state summary. `unavailable` = its state could not be read. */
|
|
18433
|
+
var NcStateSummaryPreviewSectionSchema = zod.z.object({
|
|
18434
|
+
id: zod.z.string(),
|
|
18435
|
+
status: zod.z.enum(["read", "unavailable"]),
|
|
18436
|
+
items: zod.z.number().int().nonnegative(),
|
|
18437
|
+
reason: zod.z.string().optional()
|
|
18438
|
+
});
|
|
18439
|
+
/**
|
|
18440
|
+
* The summary a rule would send now. `empty` = nothing to report and every
|
|
18441
|
+
* section read: such a summary is NOT sent. `dropped` counts the open states
|
|
18442
|
+
* the rule's own filters (or a camera mute) left out, by reason.
|
|
18443
|
+
* `excludedGroups` names the kind groups selected that have no state to report
|
|
18444
|
+
* (backups & exports).
|
|
18445
|
+
*/
|
|
18446
|
+
var NcStateSummaryPreviewSchema = zod.z.object({
|
|
18447
|
+
empty: zod.z.boolean(),
|
|
18448
|
+
count: zod.z.number().int().nonnegative(),
|
|
18449
|
+
text: zod.z.string(),
|
|
18450
|
+
sections: zod.z.array(NcStateSummaryPreviewSectionSchema),
|
|
18451
|
+
dropped: zod.z.record(zod.z.string(), zod.z.number().int().nonnegative()),
|
|
18452
|
+
excludedGroups: zod.z.array(zod.z.string())
|
|
18453
|
+
});
|
|
18403
18454
|
var NcTestResultSchema = zod.z.object({
|
|
18404
18455
|
recordId: zod.z.string(),
|
|
18405
18456
|
recordKind: zod.z.enum([
|
|
@@ -18491,6 +18542,13 @@ var NcTemplateVarDescriptorSchema = zod.z.object({
|
|
|
18491
18542
|
kinds: zod.z.array(NcTemplateVarKindSchema).optional(),
|
|
18492
18543
|
deliveries: zod.z.array(NcDeliverySchema).optional(),
|
|
18493
18544
|
systemEventKinds: zod.z.array(NcSystemEventKindSchema).optional(),
|
|
18545
|
+
/**
|
|
18546
|
+
* Which system-event DELIVERY has a value for it (D647). Absent = an
|
|
18547
|
+
* instant row only when the descriptor names `systemEventKinds` (a
|
|
18548
|
+
* per-event fact: a summary row has no single device), and both otherwise.
|
|
18549
|
+
* `['summary']` marks the state-summary vocabulary (`{{summaryText}}`, ...).
|
|
18550
|
+
*/
|
|
18551
|
+
systemEventDeliveries: zod.z.array(NcSystemEventDeliveryModeSchema).optional(),
|
|
18494
18552
|
dynamic: zod.z.object({
|
|
18495
18553
|
prefix: zod.z.literal("count_"),
|
|
18496
18554
|
from: zod.z.literal("classes")
|
|
@@ -18502,7 +18560,9 @@ var NcTemplateVarContextSchema = zod.z.object({
|
|
|
18502
18560
|
field: NcTemplateFieldSchema,
|
|
18503
18561
|
kind: NcRuleKindSchema.optional(),
|
|
18504
18562
|
delivery: NcDeliverySchema.optional(),
|
|
18505
|
-
systemEventKinds: zod.z.array(NcSystemEventKindSchema).optional()
|
|
18563
|
+
systemEventKinds: zod.z.array(NcSystemEventKindSchema).optional(),
|
|
18564
|
+
/** The rule's system-event delivery (D647); absent = instant. */
|
|
18565
|
+
systemEventDelivery: NcSystemEventDeliveryModeSchema.optional()
|
|
18506
18566
|
});
|
|
18507
18567
|
/** Input to `previewTemplate` — the editor's own context, plus the draft text. */
|
|
18508
18568
|
var NcTemplatePreviewInputSchema = zod.z.object({
|
|
@@ -19676,6 +19736,17 @@ var notificationRulesCapability = {
|
|
|
19676
19736
|
auth: "admin"
|
|
19677
19737
|
}),
|
|
19678
19738
|
/**
|
|
19739
|
+
* The STATE SUMMARY a system rule would send now (D647) — for a saved rule
|
|
19740
|
+
* or an unsaved draft. Pure: sends nothing, stamps nothing. A MUTATION
|
|
19741
|
+
* only for transport (a whole rule does not belong in a GET URL). Admin,
|
|
19742
|
+
* like `testRule`: it names devices and nodes across the installation.
|
|
19743
|
+
*/
|
|
19744
|
+
previewStateSummary: require_sleep.method(zod.z.object({ rule: NcRuleInputSchema }), NcStateSummaryPreviewSchema, {
|
|
19745
|
+
kind: "mutation",
|
|
19746
|
+
auth: "admin",
|
|
19747
|
+
access: "view"
|
|
19748
|
+
}),
|
|
19749
|
+
/**
|
|
19679
19750
|
* The machine-readable condition surface a rule editor renders from, plus
|
|
19680
19751
|
* the picker VOCABULARY those conditions draw on.
|
|
19681
19752
|
*
|
|
@@ -20140,1049 +20211,214 @@ var oauthIntegrationCapability = {
|
|
|
20140
20211
|
getDescriptor: require_sleep.method(zod.z.void(), OauthIntegrationDescriptorSchema, { auth: "admin" }) }
|
|
20141
20212
|
};
|
|
20142
20213
|
//#endregion
|
|
20143
|
-
//#region src/capabilities/pipeline-
|
|
20214
|
+
//#region src/capabilities/pipeline-analytics.cap.ts
|
|
20144
20215
|
/**
|
|
20145
|
-
*
|
|
20146
|
-
*
|
|
20147
|
-
*
|
|
20216
|
+
* pipeline-analytics — device-scoped wrapper cap. Refines raw
|
|
20217
|
+
* per-frame detections emitted by the pipeline runner into tracked
|
|
20218
|
+
* objects, per-kind event collections (motion / object / audio), and
|
|
20219
|
+
* persisted media. Owns the post-detection domain end-to-end:
|
|
20220
|
+
*
|
|
20221
|
+
* runner emits PipelineInferenceResult
|
|
20222
|
+
* ↓ (event bus)
|
|
20223
|
+
* pipeline-analytics subscriber
|
|
20224
|
+
* ↓ SORT tracker + zone engine + state analyzer + event emitter
|
|
20225
|
+
* → three DB collections (one per kind), one FS media tree, one
|
|
20226
|
+
* unified event emitter (FrameTracked + TrackStarted/Ended +
|
|
20227
|
+
* DetectionEvent on bus)
|
|
20228
|
+
*
|
|
20229
|
+
* Pure subscriber model. No `processFrame` cap method — the runner
|
|
20230
|
+
* already publishes the raw frame on the bus. The cap surface is
|
|
20231
|
+
* only QUERIES + per-device settings, bound on/off via
|
|
20232
|
+
* `device-manager.setWrapperActive`. `defaultActive: true` because
|
|
20233
|
+
* every camera with a detection pipeline wants its raw detections
|
|
20234
|
+
* refined; operators opt out per-device via BindingsTab when needed.
|
|
20235
|
+
*
|
|
20236
|
+
* Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
|
|
20237
|
+
* (per-device surface) and `track-trail` caps — see P11 cleanup.
|
|
20148
20238
|
*/
|
|
20149
|
-
var
|
|
20150
|
-
|
|
20151
|
-
|
|
20152
|
-
|
|
20153
|
-
|
|
20154
|
-
|
|
20155
|
-
|
|
20156
|
-
|
|
20157
|
-
|
|
20158
|
-
|
|
20159
|
-
|
|
20160
|
-
|
|
20161
|
-
crop: zod.z.object({
|
|
20162
|
-
left: zod.z.number(),
|
|
20163
|
-
top: zod.z.number(),
|
|
20164
|
-
width: zod.z.number().positive(),
|
|
20165
|
-
height: zod.z.number().positive()
|
|
20166
|
-
}).optional(),
|
|
20167
|
-
content: zod.z.object({
|
|
20168
|
-
width: zod.z.number().int().positive(),
|
|
20169
|
-
height: zod.z.number().int().positive()
|
|
20170
|
-
}),
|
|
20171
|
-
fit: zod.z.enum(["stretch", "contain"]),
|
|
20172
|
-
format: zod.z.enum([
|
|
20173
|
-
"rgb",
|
|
20174
|
-
"gray",
|
|
20175
|
-
"jpeg"
|
|
20176
|
-
])
|
|
20177
|
-
});
|
|
20239
|
+
var TrackStateSchema = zod.z.enum([
|
|
20240
|
+
"new",
|
|
20241
|
+
"entered",
|
|
20242
|
+
"left",
|
|
20243
|
+
"moving",
|
|
20244
|
+
"idle"
|
|
20245
|
+
]);
|
|
20246
|
+
var EventKindSchema = zod.z.enum([
|
|
20247
|
+
"motion",
|
|
20248
|
+
"object",
|
|
20249
|
+
"audio"
|
|
20250
|
+
]);
|
|
20178
20251
|
/**
|
|
20179
|
-
*
|
|
20180
|
-
*
|
|
20181
|
-
*
|
|
20252
|
+
* Spatial filter for `listTracks` — the rect + polygon variants of the shared
|
|
20253
|
+
* MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
|
|
20254
|
+
* of the camera frame (top-left origin), matching the drawing-plane editor.
|
|
20182
20255
|
*/
|
|
20183
|
-
var
|
|
20184
|
-
|
|
20185
|
-
|
|
20186
|
-
|
|
20187
|
-
|
|
20188
|
-
|
|
20189
|
-
|
|
20190
|
-
|
|
20191
|
-
|
|
20192
|
-
|
|
20193
|
-
"
|
|
20194
|
-
"
|
|
20195
|
-
"
|
|
20196
|
-
"
|
|
20197
|
-
"
|
|
20198
|
-
"gguf"
|
|
20256
|
+
var TrackZoneFilterSchema = zod.z.discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
|
|
20257
|
+
/** Closed icon vocabulary so clients render a known glyph per kind. */
|
|
20258
|
+
var EventKindIconSchema = zod.z.enum([
|
|
20259
|
+
"motion",
|
|
20260
|
+
"audio",
|
|
20261
|
+
"person",
|
|
20262
|
+
"vehicle",
|
|
20263
|
+
"animal",
|
|
20264
|
+
"door",
|
|
20265
|
+
"pir",
|
|
20266
|
+
"smoke",
|
|
20267
|
+
"water",
|
|
20268
|
+
"button",
|
|
20269
|
+
"package",
|
|
20270
|
+
"generic"
|
|
20199
20271
|
]);
|
|
20200
|
-
var
|
|
20201
|
-
"
|
|
20202
|
-
"
|
|
20203
|
-
"
|
|
20204
|
-
"
|
|
20205
|
-
"
|
|
20272
|
+
var EventKindCategorySchema = zod.z.enum([
|
|
20273
|
+
"motion",
|
|
20274
|
+
"audio",
|
|
20275
|
+
"detection",
|
|
20276
|
+
"sensor",
|
|
20277
|
+
"control",
|
|
20278
|
+
"custom",
|
|
20279
|
+
"package"
|
|
20206
20280
|
]);
|
|
20207
|
-
|
|
20208
|
-
|
|
20209
|
-
|
|
20210
|
-
|
|
20211
|
-
|
|
20212
|
-
|
|
20213
|
-
|
|
20214
|
-
|
|
20281
|
+
/** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
|
|
20282
|
+
var EventKindLevelSchema = zod.z.enum(["macro", "sub"]);
|
|
20283
|
+
var EventKindDescriptorSchema = zod.z.object({
|
|
20284
|
+
/** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
|
|
20285
|
+
kind: zod.z.string(),
|
|
20286
|
+
/** i18n key resolved on the UI side; `label` is the English fallback. */
|
|
20287
|
+
labelKey: zod.z.string(),
|
|
20288
|
+
/** English fallback label (kept for clients that don't translate). */
|
|
20215
20289
|
label: zod.z.string(),
|
|
20216
|
-
|
|
20217
|
-
|
|
20218
|
-
|
|
20219
|
-
|
|
20220
|
-
|
|
20221
|
-
|
|
20222
|
-
|
|
20223
|
-
|
|
20224
|
-
|
|
20225
|
-
|
|
20226
|
-
|
|
20227
|
-
|
|
20228
|
-
|
|
20229
|
-
|
|
20230
|
-
|
|
20231
|
-
|
|
20232
|
-
|
|
20233
|
-
settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
20234
|
-
}));
|
|
20235
|
-
var PipelineTemplateStepSchema = zod.z.lazy(() => zod.z.object({
|
|
20236
|
-
addonId: zod.z.string(),
|
|
20237
|
-
enabled: zod.z.boolean(),
|
|
20238
|
-
modelId: zod.z.string(),
|
|
20239
|
-
children: zod.z.array(PipelineTemplateStepSchema).readonly(),
|
|
20240
|
-
settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
20241
|
-
}));
|
|
20242
|
-
var PipelineTemplateSchema$1 = zod.z.object({
|
|
20243
|
-
id: zod.z.string(),
|
|
20244
|
-
name: zod.z.string(),
|
|
20245
|
-
createdAt: zod.z.string(),
|
|
20246
|
-
updatedAt: zod.z.string(),
|
|
20247
|
-
engine: PipelineEngineChoiceSchema,
|
|
20248
|
-
steps: zod.z.array(PipelineTemplateStepSchema).readonly()
|
|
20290
|
+
/** Hex color for timeline/legend rendering. */
|
|
20291
|
+
color: zod.z.string(),
|
|
20292
|
+
/** Dictionary id → lucide component on the UI side. */
|
|
20293
|
+
iconId: zod.z.string(),
|
|
20294
|
+
/** Legacy closed-vocab glyph — fallback for `iconId`. */
|
|
20295
|
+
icon: EventKindIconSchema,
|
|
20296
|
+
category: EventKindCategorySchema,
|
|
20297
|
+
/** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
|
|
20298
|
+
parentKind: zod.z.string().nullable(),
|
|
20299
|
+
/** Derived from `parentKind`, explicit for the client tree. */
|
|
20300
|
+
level: EventKindLevelSchema,
|
|
20301
|
+
/** Which cap + device contributes this kind. For built-ins the camera
|
|
20302
|
+
* itself; for sensor kinds the LINKED source device. */
|
|
20303
|
+
source: zod.z.object({
|
|
20304
|
+
capName: zod.z.string(),
|
|
20305
|
+
deviceId: zod.z.number()
|
|
20306
|
+
})
|
|
20249
20307
|
});
|
|
20250
|
-
|
|
20251
|
-
|
|
20252
|
-
|
|
20253
|
-
|
|
20254
|
-
downloaded: zod.z.boolean(),
|
|
20255
|
-
sizeMB: zod.z.number()
|
|
20256
|
-
})),
|
|
20257
|
-
group: ModelVariantGroupSchema.optional(),
|
|
20258
|
-
legacy: zod.z.boolean().optional(),
|
|
20259
|
-
provider: ModelProviderIdSchema.optional()
|
|
20308
|
+
/** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
|
|
20309
|
+
var EventKindsForDeviceSchema = zod.z.object({
|
|
20310
|
+
deviceId: zod.z.number(),
|
|
20311
|
+
kinds: zod.z.array(EventKindDescriptorSchema).readonly()
|
|
20260
20312
|
});
|
|
20261
|
-
var
|
|
20262
|
-
var PipelineAddonSchemaSchema = zod.z.object({
|
|
20313
|
+
var SensorEventSchema = zod.z.object({
|
|
20263
20314
|
id: zod.z.string(),
|
|
20264
|
-
|
|
20265
|
-
|
|
20266
|
-
|
|
20267
|
-
|
|
20268
|
-
|
|
20269
|
-
|
|
20270
|
-
|
|
20271
|
-
|
|
20272
|
-
|
|
20273
|
-
|
|
20274
|
-
defaultConfidence: zod.z.number(),
|
|
20275
|
-
group: zod.z.string().optional(),
|
|
20276
|
-
configSchema: zod.z.array(ConfigFieldBridge).readonly().optional()
|
|
20277
|
-
});
|
|
20278
|
-
var PipelineSlotSchemaSchema = zod.z.object({
|
|
20279
|
-
id: PipelineSlotSchema,
|
|
20280
|
-
label: zod.z.string(),
|
|
20281
|
-
priority: zod.z.number(),
|
|
20282
|
-
parentSlot: PipelineSlotSchema.nullable(),
|
|
20283
|
-
addons: zod.z.array(PipelineAddonSchemaSchema).readonly()
|
|
20284
|
-
});
|
|
20285
|
-
var PipelineSchemaSchema = zod.z.object({
|
|
20286
|
-
availableEngines: zod.z.array(AvailableEngineSchema).readonly(),
|
|
20287
|
-
selectedEngine: PipelineEngineChoiceSchema,
|
|
20288
|
-
slots: zod.z.array(PipelineSlotSchemaSchema).readonly()
|
|
20289
|
-
});
|
|
20290
|
-
var EngineProvisioningSchema = zod.z.object({
|
|
20291
|
-
runtimeId: zod.z.enum([
|
|
20292
|
-
"onnx",
|
|
20293
|
-
"openvino",
|
|
20294
|
-
"coreml",
|
|
20295
|
-
"edgetpu"
|
|
20296
|
-
]).nullable(),
|
|
20297
|
-
device: zod.z.string().nullable(),
|
|
20298
|
-
state: zod.z.enum([
|
|
20299
|
-
"idle",
|
|
20300
|
-
"installing",
|
|
20301
|
-
"verifying",
|
|
20302
|
-
"ready",
|
|
20303
|
-
"failed"
|
|
20304
|
-
]),
|
|
20305
|
-
progress: zod.z.number().optional(),
|
|
20306
|
-
error: zod.z.string().optional(),
|
|
20307
|
-
nextRetryAt: zod.z.number().optional(),
|
|
20308
|
-
/**
|
|
20309
|
-
* Gate A (config-correctness gate at engine change): human-readable
|
|
20310
|
-
* config issues surfaced EAGERLY when the node's engine changes — model
|
|
20311
|
-
* substitutions ("chose X, running Y") and zero-build steps ("no model
|
|
20312
|
-
* has a <format> build"). Additive/optional: informational only, never
|
|
20313
|
-
* enforced here — `assertEngineReady` (readiness) still gates inference.
|
|
20314
|
-
* Absent/empty when the node-default tree resolves cleanly.
|
|
20315
|
-
*/
|
|
20316
|
-
configIssues: zod.z.array(zod.z.string()).optional()
|
|
20317
|
-
});
|
|
20318
|
-
var PipelineStepInputSchema = zod.z.lazy(() => zod.z.object({
|
|
20319
|
-
addonId: zod.z.string(),
|
|
20320
|
-
modelId: zod.z.string().optional(),
|
|
20321
|
-
enabled: zod.z.boolean().default(true),
|
|
20322
|
-
children: zod.z.array(PipelineStepInputSchema).optional(),
|
|
20323
|
-
settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
20324
|
-
jumpDeviceKey: zod.z.string().optional()
|
|
20325
|
-
}));
|
|
20326
|
-
var ModelSubstitutionSchema = zod.z.object({
|
|
20327
|
-
addonId: zod.z.string(),
|
|
20328
|
-
chosen: zod.z.string(),
|
|
20329
|
-
running: zod.z.string(),
|
|
20330
|
-
format: zod.z.string()
|
|
20331
|
-
});
|
|
20332
|
-
var PipelineValidationIssueSchema = zod.z.object({
|
|
20333
|
-
addonId: zod.z.string(),
|
|
20334
|
-
kind: zod.z.enum(["unknown-addon", "no-format-build"]),
|
|
20335
|
-
detail: zod.z.string()
|
|
20336
|
-
});
|
|
20337
|
-
var PipelineValidationResultSchema = zod.z.object({
|
|
20338
|
-
ok: zod.z.boolean(),
|
|
20339
|
-
issues: zod.z.array(PipelineValidationIssueSchema).readonly(),
|
|
20340
|
-
substitutions: zod.z.array(ModelSubstitutionSchema).readonly(),
|
|
20341
|
-
/** The node's `currentEngine.format` this validation ran against. */
|
|
20342
|
-
format: zod.z.string()
|
|
20343
|
-
});
|
|
20344
|
-
var ReferenceImageEntrySchema = zod.z.object({
|
|
20345
|
-
filename: zod.z.string(),
|
|
20346
|
-
stepIds: zod.z.array(zod.z.string()).readonly().optional()
|
|
20347
|
-
});
|
|
20348
|
-
var ReferenceImageBodySchema = zod.z.object({
|
|
20349
|
-
base64: zod.z.string(),
|
|
20350
|
-
filename: zod.z.string()
|
|
20351
|
-
});
|
|
20352
|
-
var ReferenceAudioEntrySchema = zod.z.object({
|
|
20353
|
-
filename: zod.z.string(),
|
|
20354
|
-
sizeKb: zod.z.number()
|
|
20315
|
+
/** The CAMERA the event is attributed to (a sensor linked to N cameras
|
|
20316
|
+
* yields N rows, one per camera). */
|
|
20317
|
+
deviceId: zod.z.number(),
|
|
20318
|
+
/** The linked sensor device whose state changed. */
|
|
20319
|
+
sourceDeviceId: zod.z.number(),
|
|
20320
|
+
/** Event kind id — matches an `EventKindDescriptor.kind`. */
|
|
20321
|
+
kind: zod.z.string(),
|
|
20322
|
+
/** Snapshot of the sensor cap's runtime-state slice at the change. */
|
|
20323
|
+
value: zod.z.record(zod.z.string(), zod.z.unknown()).nullable(),
|
|
20324
|
+
timestamp: zod.z.number()
|
|
20355
20325
|
});
|
|
20356
|
-
|
|
20357
|
-
|
|
20358
|
-
|
|
20359
|
-
|
|
20360
|
-
|
|
20361
|
-
|
|
20326
|
+
/**
|
|
20327
|
+
* One stored sighting on a track's trajectory.
|
|
20328
|
+
*
|
|
20329
|
+
* The array these live in is returned in TIME order (D399) — it is APPENDED in
|
|
20330
|
+
* arrival order, and the two detector passes interleave, so a consumer must not
|
|
20331
|
+
* assume the two are the same on a row written by an older build.
|
|
20332
|
+
*/
|
|
20333
|
+
var TrackPositionSchema = zod.z.object({
|
|
20334
|
+
x: zod.z.number(),
|
|
20335
|
+
y: zod.z.number(),
|
|
20336
|
+
timestamp: zod.z.number(),
|
|
20337
|
+
bbox: BoundingBoxSchema,
|
|
20362
20338
|
/**
|
|
20363
|
-
*
|
|
20364
|
-
*
|
|
20365
|
-
*
|
|
20366
|
-
*
|
|
20339
|
+
* Which detector pass measured this box (D399): `frame` is the full-frame
|
|
20340
|
+
* pass on the analysis raster, `recovery` is the native-resolution
|
|
20341
|
+
* small-subject second pass (D377/D378). Both write into one array, and until
|
|
20342
|
+
* this field existed the only way to tell them apart was that full-frame boxes
|
|
20343
|
+
* are exact multiples of 1.2 while recovery boxes are full-precision floats.
|
|
20344
|
+
* Absent on rows written before D399.
|
|
20367
20345
|
*/
|
|
20368
|
-
|
|
20346
|
+
source: zod.z.enum(["frame", "recovery"]).optional(),
|
|
20347
|
+
/** Detection score of this box, so a position can be weighed and not only
|
|
20348
|
+
* plotted. Absent on rows written before D399. */
|
|
20349
|
+
score: zod.z.number().optional()
|
|
20369
20350
|
});
|
|
20370
|
-
var
|
|
20371
|
-
|
|
20372
|
-
|
|
20373
|
-
|
|
20374
|
-
|
|
20351
|
+
var TrackSnapshotSchema = zod.z.object({
|
|
20352
|
+
timestamp: zod.z.number(),
|
|
20353
|
+
position: TrackPositionSchema,
|
|
20354
|
+
/** The snapshot's media row id (D482); resolve via `listTrackMedia({ trackId })`. */
|
|
20355
|
+
mediaId: zod.z.number().int()
|
|
20375
20356
|
});
|
|
20376
|
-
|
|
20377
|
-
|
|
20378
|
-
|
|
20379
|
-
|
|
20357
|
+
/**
|
|
20358
|
+
* Normalized 0..1 trajectory envelope (min/max over every position bbox,
|
|
20359
|
+
* divided by the track's detection-frame dims), computed at persist time.
|
|
20360
|
+
* Absent when the frame dims were unknown when the track was persisted
|
|
20361
|
+
* (legacy rows / dims-less sources) and on active (in-RAM) tracks.
|
|
20362
|
+
*/
|
|
20363
|
+
var TrackEnvelopeSchema = zod.z.object({
|
|
20364
|
+
minX: zod.z.number(),
|
|
20365
|
+
minY: zod.z.number(),
|
|
20366
|
+
maxX: zod.z.number(),
|
|
20367
|
+
maxY: zod.z.number()
|
|
20380
20368
|
});
|
|
20381
20369
|
/**
|
|
20382
|
-
*
|
|
20383
|
-
*
|
|
20384
|
-
*
|
|
20385
|
-
*
|
|
20386
|
-
*
|
|
20387
|
-
*
|
|
20388
|
-
*
|
|
20389
|
-
*
|
|
20370
|
+
* Row projection for track list queries. `full` (default) returns the
|
|
20371
|
+
* complete Track including the frame-rate `positions[]` history and the
|
|
20372
|
+
* `snapshots[]` references — megabytes across a page of tracks. `slim`
|
|
20373
|
+
* keeps every scalar the list surfaces actually render (ids, class(es),
|
|
20374
|
+
* label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
|
|
20375
|
+
* zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
|
|
20376
|
+
* `snapshots` as EMPTY arrays — detail views re-fetch the full row via
|
|
20377
|
+
* `getTrack`. Mirrors the event-store `projection` convention
|
|
20378
|
+
* (`getObjectEvents` et al.).
|
|
20390
20379
|
*/
|
|
20391
|
-
var
|
|
20392
|
-
|
|
20393
|
-
|
|
20394
|
-
|
|
20380
|
+
var TrackProjectionSchema = zod.z.enum(["full", "slim"]);
|
|
20381
|
+
/**
|
|
20382
|
+
* One audio-classification label heard on the track's camera while the
|
|
20383
|
+
* track was alive, aggregated per label. An "episode" is one persisted
|
|
20384
|
+
* audio event (the confident-classification path: score ≥ the device's
|
|
20385
|
+
* `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
|
|
20386
|
+
* one 32 ms inference chunk, so counts stay human-scaled.
|
|
20387
|
+
*/
|
|
20388
|
+
var TrackAudioLabelSchema = zod.z.object({
|
|
20389
|
+
label: zod.z.string(),
|
|
20390
|
+
/** Highest classification score observed across the label's episodes. */
|
|
20391
|
+
peakScore: zod.z.number(),
|
|
20392
|
+
/** Number of coalesced audio-event episodes carrying this label. */
|
|
20393
|
+
count: zod.z.number(),
|
|
20394
|
+
firstAt: zod.z.number(),
|
|
20395
|
+
lastAt: zod.z.number()
|
|
20395
20396
|
});
|
|
20396
|
-
var PipelineConfigBridge = zod.z.custom();
|
|
20397
|
-
var ConfigUISchemaBridge = zod.z.custom();
|
|
20398
|
-
var ConfigUISchemaNullableBridge = zod.z.custom();
|
|
20399
|
-
var InferenceCapabilitiesBridge = zod.z.custom();
|
|
20400
|
-
var ModelAvailabilityListBridge = zod.z.custom();
|
|
20401
|
-
var PipelineRunResultBridge = zod.z.custom();
|
|
20402
20397
|
/**
|
|
20403
|
-
*
|
|
20398
|
+
* How a track was produced. `pipeline` (default / absent) = the spatial
|
|
20399
|
+
* detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
|
|
20400
|
+
* no positions, a single snapshot, and no bbox trajectory at all:
|
|
20404
20401
|
*
|
|
20405
|
-
*
|
|
20406
|
-
*
|
|
20402
|
+
* - `sensor` — a linked sensor/control device state change.
|
|
20403
|
+
* - `audio` — an audio event on the camera itself that was anomalous for
|
|
20404
|
+
* THAT camera, loud, and heard while nothing visual was happening (D62).
|
|
20407
20405
|
*
|
|
20408
|
-
*
|
|
20409
|
-
*
|
|
20410
|
-
* `
|
|
20411
|
-
*
|
|
20412
|
-
*
|
|
20413
|
-
|
|
20414
|
-
|
|
20415
|
-
|
|
20416
|
-
|
|
20417
|
-
|
|
20418
|
-
|
|
20419
|
-
|
|
20420
|
-
|
|
20421
|
-
|
|
20422
|
-
|
|
20423
|
-
|
|
20424
|
-
* state of the lazy runtime-provisioning machine on `nodeId`
|
|
20425
|
-
* (idle / installing / verifying / ready / failed). The UI pairs this
|
|
20426
|
-
* one-shot query with the `pipeline.engine-provisioning` live event
|
|
20427
|
-
* (emitted on every transition) to drive a per-node "engine ready?"
|
|
20428
|
-
* indicator without polling. Phase 2.
|
|
20429
|
-
*/
|
|
20430
|
-
getEngineProvisioning: require_sleep.method(zod.z.object({ nodeId: zod.z.string() }), EngineProvisioningSchema),
|
|
20431
|
-
getVideoPipelineSteps: require_sleep.method(zod.z.void(), zod.z.record(zod.z.string(), zod.z.object({
|
|
20432
|
-
modelId: zod.z.string(),
|
|
20433
|
-
settings: zod.z.record(zod.z.string(), zod.z.unknown()).readonly()
|
|
20434
|
-
}))),
|
|
20435
|
-
setVideoPipelineSteps: require_sleep.method(zod.z.object({ steps: zod.z.record(zod.z.string(), zod.z.object({
|
|
20436
|
-
modelId: zod.z.string(),
|
|
20437
|
-
settings: zod.z.record(zod.z.string(), zod.z.unknown()).readonly()
|
|
20438
|
-
})) }), zod.z.object({ success: zod.z.literal(true) }), {
|
|
20439
|
-
kind: "mutation",
|
|
20440
|
-
auth: "admin"
|
|
20441
|
-
}),
|
|
20442
|
-
/**
|
|
20443
|
-
* Clear THIS node's executor-side PER-DEVICE settings stores (the
|
|
20444
|
-
* per-camera step overrides the object-detection root reads via
|
|
20445
|
-
* `applyDeviceOverridesToTree`). `nodeId` is the ROUTING key — the
|
|
20446
|
-
* generated cap-router strips it (default `nodeIdMode: 'routing'`) and
|
|
20447
|
-
* dispatches to that node, so the provider method runs ON the target
|
|
20448
|
-
* node and receives no `nodeId`.
|
|
20449
|
-
*
|
|
20450
|
-
* This is the slimmed executor leg of the orchestrator's
|
|
20451
|
-
* `resetNodePipelineDefaults` flow (which owns the real reset: node
|
|
20452
|
-
* addonDefaults pins + per-camera orchestrator overrides). The legacy
|
|
20453
|
-
* `resetToDefault` — which reset a persisted global step-tree seed
|
|
20454
|
-
* nothing in the live per-camera path read — was removed together with
|
|
20455
|
-
* that seed.
|
|
20456
|
-
*/
|
|
20457
|
-
clearDeviceOverrides: require_sleep.method(zod.z.object({ nodeId: zod.z.string() }), zod.z.object({
|
|
20458
|
-
success: zod.z.literal(true),
|
|
20459
|
-
clearedDevices: zod.z.number()
|
|
20460
|
-
}), {
|
|
20461
|
-
kind: "mutation",
|
|
20462
|
-
auth: "admin"
|
|
20463
|
-
}),
|
|
20464
|
-
/**
|
|
20465
|
-
* Which of THIS node's inference devices the executor currently refuses,
|
|
20466
|
-
* and why. `nodeId` is the ROUTING key (stripped by the generated router).
|
|
20467
|
-
*
|
|
20468
|
-
* The channel that did not exist. Pool health was known only inside the
|
|
20469
|
-
* detection addon and was an input to no routing decision anywhere: the
|
|
20470
|
-
* per-dispatch capability gate is keyed on model FORMAT and so can never
|
|
20471
|
-
* separate `openvino:gpu` from `openvino:npu`, and the orchestrator's live
|
|
20472
|
-
* eligibility probe (`platformProbe.getCapabilities`) answers about
|
|
20473
|
-
* HARDWARE — which was present throughout. So when the hub's `openvino:gpu`
|
|
20474
|
-
* Python worker was SIGABRT'd by the Intel GPU plugin on 2026-08-25, the
|
|
20475
|
-
* balancer went on handing that dead pool cameras by rotation for 31 hours:
|
|
20476
|
-
* ~370 000 `PoolWorker[w0]: not initialized` lines, every frame lost.
|
|
20477
|
-
*
|
|
20478
|
-
* Read semantics the caller depends on, and which the provider guarantees:
|
|
20479
|
-
* this is a synchronous read of in-memory state. It never probes hardware,
|
|
20480
|
-
* never spawns a pool and never throws — an EMPTY `unhealthy` means "asked,
|
|
20481
|
-
* nothing is refused", which is what re-admits a device. A read that FAILS
|
|
20482
|
-
* (node offline, version skew) must therefore be distinguishable from an
|
|
20483
|
-
* empty answer, and it is: it rejects.
|
|
20484
|
-
*/
|
|
20485
|
-
getInferenceDeviceHealth: require_sleep.method(zod.z.object({ nodeId: zod.z.string() }), zod.z.object({ unhealthy: zod.z.array(zod.z.object({
|
|
20486
|
-
/** `<backend>:<device>`, e.g. `openvino:gpu`. */
|
|
20487
|
-
deviceKey: zod.z.string(),
|
|
20488
|
-
/**
|
|
20489
|
-
* `failed` — the per-device restart budget is exhausted; no pool
|
|
20490
|
-
* will be spawned until an operator re-arms it or the runner
|
|
20491
|
-
* respawns. `backoff` — under budget, waiting out the backoff (or
|
|
20492
|
-
* a cached pool observed dead and not yet condemned).
|
|
20493
|
-
*/
|
|
20494
|
-
state: zod.z.enum(["failed", "backoff"]),
|
|
20495
|
-
/** Epoch ms of the death that produced this state. */
|
|
20496
|
-
since: zod.z.number(),
|
|
20497
|
-
/** Pool deaths inside the current window. */
|
|
20498
|
-
deaths: zod.z.number(),
|
|
20499
|
-
/** The last death's message. */
|
|
20500
|
-
lastError: zod.z.string()
|
|
20501
|
-
})).readonly() })),
|
|
20502
|
-
/**
|
|
20503
|
-
* Re-arm a terminally `failed` inference device on `nodeId`: forget its
|
|
20504
|
-
* restart budget so the next dispatch builds a fresh pool.
|
|
20505
|
-
*
|
|
20506
|
-
* The terminal state is deliberate (the abort it bounds is deterministic —
|
|
20507
|
-
* an automatic probation would just respawn Python forever, more slowly),
|
|
20508
|
-
* and a terminal state an operator cannot leave is a silent fault. This is
|
|
20509
|
-
* the way out. `rearmed:false` means there was nothing to forget.
|
|
20510
|
-
*/
|
|
20511
|
-
rearmInferenceDevice: require_sleep.method(zod.z.object({
|
|
20512
|
-
nodeId: zod.z.string(),
|
|
20513
|
-
deviceKey: zod.z.string()
|
|
20514
|
-
}), zod.z.object({ rearmed: zod.z.boolean() }), {
|
|
20515
|
-
kind: "mutation",
|
|
20516
|
-
auth: "admin"
|
|
20517
|
-
}),
|
|
20518
|
-
getSchema: require_sleep.method(zod.z.void(), PipelineSchemaSchema),
|
|
20519
|
-
getGlobalSteps: require_sleep.method(zod.z.void(), zod.z.array(PipelineDefaultStepSchema).readonly().nullable()),
|
|
20520
|
-
getGlobalPipelineConfig: require_sleep.method(zod.z.void(), PipelineConfigBridge),
|
|
20521
|
-
getOrchestratorConfigSchema: require_sleep.method(zod.z.void(), ConfigUISchemaBridge),
|
|
20522
|
-
/**
|
|
20523
|
-
* Gate B (pre-init config-correctness gate). PURE COMPUTE against this
|
|
20524
|
-
* node's `currentEngine.format` — resolves `steps` the same way the
|
|
20525
|
-
* runtime dispatch path would, and reports what WOULD happen without
|
|
20526
|
-
* touching any node-global state. Called by the orchestrator at attach
|
|
20527
|
-
* time (`attachOn`), node-pinned to the TARGET node, so config problems
|
|
20528
|
-
* surface BEFORE `pipelineRunner.attachCamera` rather than at the first
|
|
20529
|
-
* per-frame resolve. `ok` is false iff `issues` is non-empty (both
|
|
20530
|
-
* `unknown-addon` and `no-format-build` are HARD issues); `substitutions`
|
|
20531
|
-
* is informational (a degraded-but-loadable model swap) and never
|
|
20532
|
-
* affects `ok`. Never throws.
|
|
20533
|
-
*/
|
|
20534
|
-
validatePipeline: require_sleep.method(zod.z.object({ steps: zod.z.array(PipelineStepInputSchema) }), PipelineValidationResultSchema),
|
|
20535
|
-
listTemplates: require_sleep.method(zod.z.void(), zod.z.array(PipelineTemplateSchema$1).readonly()),
|
|
20536
|
-
saveTemplate: require_sleep.method(zod.z.object({
|
|
20537
|
-
name: zod.z.string(),
|
|
20538
|
-
steps: zod.z.array(PipelineTemplateStepSchema).readonly(),
|
|
20539
|
-
engine: PipelineEngineChoiceSchema
|
|
20540
|
-
}), PipelineTemplateSchema$1, { kind: "mutation" }),
|
|
20541
|
-
updateTemplate: require_sleep.method(zod.z.object({
|
|
20542
|
-
id: zod.z.string(),
|
|
20543
|
-
name: zod.z.string().optional(),
|
|
20544
|
-
steps: zod.z.array(PipelineTemplateStepSchema).readonly().optional()
|
|
20545
|
-
}), PipelineTemplateSchema$1, { kind: "mutation" }),
|
|
20546
|
-
deleteTemplate: require_sleep.method(zod.z.object({ id: zod.z.string() }), zod.z.void(), { kind: "mutation" }),
|
|
20547
|
-
getCapabilities: require_sleep.method(zod.z.void(), InferenceCapabilitiesBridge),
|
|
20548
|
-
getAddonModels: require_sleep.method(zod.z.object({ addonId: zod.z.string() }), ModelAvailabilityListBridge),
|
|
20549
|
-
downloadModel: require_sleep.method(zod.z.object({
|
|
20550
|
-
addonId: zod.z.string(),
|
|
20551
|
-
modelId: zod.z.string(),
|
|
20552
|
-
format: ModelFormatSchema$1
|
|
20553
|
-
}), DownloadModelResultSchema, { kind: "mutation" }),
|
|
20554
|
-
deleteModel: require_sleep.method(zod.z.object({
|
|
20555
|
-
addonId: zod.z.string(),
|
|
20556
|
-
modelId: zod.z.string(),
|
|
20557
|
-
format: ModelFormatSchema$1
|
|
20558
|
-
}), zod.z.object({ success: zod.z.literal(true) }), { kind: "mutation" }),
|
|
20559
|
-
/**
|
|
20560
|
-
* Stateless single-frame execution. Callers (runner, benchmark) pass
|
|
20561
|
-
* the complete `engine` + `steps` tree; the executor holds no state
|
|
20562
|
-
* about cameras or saved pipelines.
|
|
20563
|
-
*
|
|
20564
|
-
* `engine` is optional during the migration window to preserve the
|
|
20565
|
-
* legacy call shape used by existing benchmark code; once all
|
|
20566
|
-
* callers pass it explicitly we make it required.
|
|
20567
|
-
*
|
|
20568
|
-
* Exactly one of `frame`, `frameRef`, `frameHandle`, `imageBase64`,
|
|
20569
|
-
* `referenceImage` must be provided:
|
|
20570
|
-
* - `frame`: runtime dispatch path (runner → decoded broker frame).
|
|
20571
|
-
* Carries the raw buffer, dimensions, and format; the executor
|
|
20572
|
-
* uses it directly without base64 round-tripping.
|
|
20573
|
-
* - `frameHandle` (CB5): a zero-pixel shm `FrameHandle` for the SAME
|
|
20574
|
-
* decoded frame. Both runner and executor are hub-local processes
|
|
20575
|
-
* sharing `/dev/shm`, so the executor maps the named segment and
|
|
20576
|
-
* reads the pixels back zero-copy — eliminating the ~1.2MB
|
|
20577
|
-
* re-serialisation over UDS/MsgPack the `frame` path pays per call.
|
|
20578
|
-
* High-risk: the FrameRing is a latest-wins seqlock with no
|
|
20579
|
-
* refcount, so a recycled slot yields a null read; the executor
|
|
20580
|
-
* then degrades to an empty result and the runner ships pixels via
|
|
20581
|
-
* `frame` as the fallback (queue-depth gated on the runner side).
|
|
20582
|
-
* - `imageBase64`: one-shot test path (benchmark ImageTab).
|
|
20583
|
-
* - `referenceImage`: named file from the reference-image store.
|
|
20584
|
-
*/
|
|
20585
|
-
runPipeline: require_sleep.method(zod.z.object({
|
|
20586
|
-
engine: PipelineEngineChoiceSchema.optional(),
|
|
20587
|
-
steps: zod.z.array(PipelineStepInputSchema).min(1),
|
|
20588
|
-
frame: FrameInputSchema.optional(),
|
|
20589
|
-
/**
|
|
20590
|
-
* Process-local lazy frame. Valid only when caller and provider resolve
|
|
20591
|
-
* in the same execution-group process; split/cross-node callers use
|
|
20592
|
-
* `frame`/`image` inline compatibility instead.
|
|
20593
|
-
*/
|
|
20594
|
-
frameRef: FrameRefSchema.optional(),
|
|
20595
|
-
/**
|
|
20596
|
-
* CB5 shm passthrough — a `FrameHandle` naming the same ring slot
|
|
20597
|
-
* the decoded pixels live in. One more member of the one-of
|
|
20598
|
-
* frame/frameHandle/image/imageBase64/referenceImage group.
|
|
20599
|
-
*/
|
|
20600
|
-
frameHandle: require_sleep.FrameHandleSchema.optional(),
|
|
20601
|
-
imageBase64: zod.z.string().optional(),
|
|
20602
|
-
/**
|
|
20603
|
-
* Binary JPEG bytes — preferred over `imageBase64` on internal
|
|
20604
|
-
* hops (hub → forked worker via Moleculer MsgPack) because it
|
|
20605
|
-
* skips the 33% base64 overhead + the per-call base64 decode on
|
|
20606
|
-
* the detection-pipeline worker. Callers can pass either; exactly
|
|
20607
|
-
* one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
|
|
20608
|
-
*/
|
|
20609
|
-
image: zod.z.instanceof(Uint8Array).optional(),
|
|
20610
|
-
referenceImage: zod.z.string().optional(),
|
|
20611
|
-
deviceId: zod.z.number().optional(),
|
|
20612
|
-
sessionId: zod.z.string().optional(),
|
|
20613
|
-
/**
|
|
20614
|
-
* Execution plane. 'full' (default) runs the whole tree — benchmark,
|
|
20615
|
-
* reference-image, and detail-subtree calls. 'frame' is the live
|
|
20616
|
-
* per-frame dispatch: ONLY root-plane steps run; crop children
|
|
20617
|
-
* (inputClasses ≠ null) are skipped and served per-track via
|
|
20618
|
-
* pipelineRunner.runDetailSubtree (two-plane design).
|
|
20619
|
-
*/
|
|
20620
|
-
plane: zod.z.enum(["full", "frame"]).optional(),
|
|
20621
|
-
/**
|
|
20622
|
-
* Inference-device selector (Phase 2 multi-device). Format
|
|
20623
|
-
* `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
|
|
20624
|
-
* Omitted ⇒ the runner's default device (current single-engine
|
|
20625
|
-
* behaviour). Selects WHICH device pool of the node runs the call.
|
|
20626
|
-
*/
|
|
20627
|
-
deviceKey: zod.z.string().optional(),
|
|
20628
|
-
/**
|
|
20629
|
-
* Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
|
|
20630
|
-
* when the parent crop was resolved from the frame's retained NATIVE
|
|
20631
|
-
* surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
|
|
20632
|
-
* child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
|
|
20633
|
-
* resolution from that surface — the SAME quality path faces already
|
|
20634
|
-
* had — instead of the downscaled parent tile. `handle` keys the native
|
|
20635
|
-
* surface (node-pinned to its owner); `cropFrameSpace` is the parent
|
|
20636
|
-
* crop's padded/clamped rectangle in FRAME-space pixels, used to compose
|
|
20637
|
-
* the executor's crop-normalized child ROI back into frame-normalized
|
|
20638
|
-
* coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
|
|
20639
|
-
* of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
|
|
20640
|
-
* (today's behaviour on the fallback path).
|
|
20641
|
-
*/
|
|
20642
|
-
nativeCropRef: NativeCropRefSchema.optional()
|
|
20643
|
-
}), PipelineRunResultBridge, { kind: "mutation" }),
|
|
20644
|
-
/**
|
|
20645
|
-
* Batched run — N raw frames packed into one cap call. The provider
|
|
20646
|
-
* routes the batch through `SharedInferencePool.inferBatch`
|
|
20647
|
-
* (`MSG_INFER_BATCH = 0x03`) so the IPC framing and JSON response
|
|
20648
|
-
* envelope cost is amortised N:1 vs N concurrent `runPipeline`
|
|
20649
|
-
* calls. Single root step + uniform model assumed; trees with crop
|
|
20650
|
-
* children fall back to sequential execution.
|
|
20651
|
-
*
|
|
20652
|
-
* Used by `scripts/bench-batch-style.mts` for batch benchmarking —
|
|
20653
|
-
* N frames in one call to amortise per-call IPC overhead.
|
|
20654
|
-
*/
|
|
20655
|
-
runPipelineBatch: require_sleep.method(zod.z.object({
|
|
20656
|
-
engine: PipelineEngineChoiceSchema.optional(),
|
|
20657
|
-
steps: zod.z.array(PipelineStepInputSchema).min(1),
|
|
20658
|
-
frames: zod.z.array(FrameInputSchema).min(1).max(255),
|
|
20659
|
-
deviceId: zod.z.number().optional(),
|
|
20660
|
-
sessionId: zod.z.string().optional(),
|
|
20661
|
-
/**
|
|
20662
|
-
* Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
|
|
20663
|
-
* the batch to the Python pool's bench preprocess cache
|
|
20664
|
-
* (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
|
|
20665
|
-
* preprocessed ONCE and every later inference is a pure-inference cache
|
|
20666
|
-
* hit — the sustained-throughput run measures inference, not
|
|
20667
|
-
* decode+preprocess+infer. Omitted/0 for live frames (all different →
|
|
20668
|
-
* full preprocess every call, correct). Fresh per sustained run;
|
|
20669
|
-
* released via `uncacheFrame`.
|
|
20670
|
-
*/
|
|
20671
|
-
frameId: zod.z.number().int().nonnegative().optional(),
|
|
20672
|
-
/** Inference-device selector (Phase 2 multi-device); see runPipeline. */
|
|
20673
|
-
deviceKey: zod.z.string().optional()
|
|
20674
|
-
}), zod.z.object({ results: zod.z.array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }),
|
|
20675
|
-
/**
|
|
20676
|
-
* Cache a raw frame inside the Python inference pool's memory.
|
|
20677
|
-
* Returns a numeric `frameId` that `inferCached` references —
|
|
20678
|
-
* subsequent calls send only 5 bytes through the pipe instead of
|
|
20679
|
-
* 1.2MB raw data, eliminating the pipe transfer bottleneck.
|
|
20680
|
-
*/
|
|
20681
|
-
cacheFrameInPool: require_sleep.method(zod.z.object({
|
|
20682
|
-
data: zod.z.instanceof(Uint8Array),
|
|
20683
|
-
width: zod.z.number().int().positive(),
|
|
20684
|
-
height: zod.z.number().int().positive(),
|
|
20685
|
-
format: zod.z.enum([
|
|
20686
|
-
"rgb",
|
|
20687
|
-
"bgr",
|
|
20688
|
-
"gray"
|
|
20689
|
-
])
|
|
20690
|
-
}), zod.z.object({
|
|
20691
|
-
frameId: zod.z.number(),
|
|
20692
|
-
width: zod.z.number(),
|
|
20693
|
-
height: zod.z.number()
|
|
20694
|
-
}), { kind: "mutation" }),
|
|
20695
|
-
/**
|
|
20696
|
-
* Run inference on a previously cached frame. Sends only 5 bytes
|
|
20697
|
-
* (model_idx + frameId) through the IPC pipe — eliminates the
|
|
20698
|
-
* ~35ms per-call overhead of transferring 1.2MB raw data.
|
|
20699
|
-
*/
|
|
20700
|
-
inferCached: require_sleep.method(zod.z.object({
|
|
20701
|
-
stepId: zod.z.string(),
|
|
20702
|
-
frameId: zod.z.number().int()
|
|
20703
|
-
}), zod.z.record(zod.z.string(), zod.z.unknown()), { kind: "mutation" }),
|
|
20704
|
-
/**
|
|
20705
|
-
* Release a cached frame from the Python pool's memory.
|
|
20706
|
-
*/
|
|
20707
|
-
uncacheFrame: require_sleep.method(zod.z.object({ frameId: zod.z.number().int() }), zod.z.void(), { kind: "mutation" }),
|
|
20708
|
-
/** Returns the effective pool tuning (resolved from user overrides + backend defaults). */
|
|
20709
|
-
getEffectiveTuning: require_sleep.method(zod.z.void(), zod.z.object({
|
|
20710
|
-
batchMode: zod.z.string(),
|
|
20711
|
-
windowMs: zod.z.number(),
|
|
20712
|
-
maxBatchSize: zod.z.number(),
|
|
20713
|
-
concurrency: zod.z.number()
|
|
20714
|
-
})),
|
|
20715
|
-
/**
|
|
20716
|
-
* List every EngineFactory currently loaded in this executor's RAM,
|
|
20717
|
-
* with the models resident and a coarse "in use" marker derived from
|
|
20718
|
-
* ongoing inference activity. Used by the Pipeline page Engines tab.
|
|
20719
|
-
*/
|
|
20720
|
-
listLoadedEngines: require_sleep.method(zod.z.void(), zod.z.array(zod.z.object({
|
|
20721
|
-
engineKey: zod.z.string(),
|
|
20722
|
-
engine: PipelineEngineChoiceSchema,
|
|
20723
|
-
modelsLoaded: zod.z.array(zod.z.string()).readonly(),
|
|
20724
|
-
inUseByCameras: zod.z.array(zod.z.number()).readonly(),
|
|
20725
|
-
/**
|
|
20726
|
-
* Origin of this resident factory.
|
|
20727
|
-
* - `runtime` — main camera-serving engine (no idle TTL).
|
|
20728
|
-
* - `warm-override` — benchmark/test override held in the warm
|
|
20729
|
-
* cache; auto-disposed after the idle TTL.
|
|
20730
|
-
* - `device-pool` — a concurrent per-device pool (Phase 2
|
|
20731
|
-
* multi-device, keyed by `deviceKey`) resolved
|
|
20732
|
-
* via `resolveDeviceFactory`. Runs alongside the
|
|
20733
|
-
* `runtime` engine on a DIFFERENT accelerator
|
|
20734
|
-
* (NPU / iGPU / Coral) — this is how the
|
|
20735
|
-
* Engines tab shows all pools running at once.
|
|
20736
|
-
*/
|
|
20737
|
-
kind: zod.z.enum([
|
|
20738
|
-
"runtime",
|
|
20739
|
-
"warm-override",
|
|
20740
|
-
"device-pool"
|
|
20741
|
-
]),
|
|
20742
|
-
/** Native pid of the underlying Python pool (null when no pool). */
|
|
20743
|
-
poolPid: zod.z.number().nullable(),
|
|
20744
|
-
/** ms since this factory was last used (null when not warm-tracked). */
|
|
20745
|
-
idleMs: zod.z.number().nullable(),
|
|
20746
|
-
/** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
|
|
20747
|
-
idleTtlMs: zod.z.number().nullable()
|
|
20748
|
-
})).readonly()),
|
|
20749
|
-
/** Warm up an engine without running a frame. No-op if already loaded. */
|
|
20750
|
-
spinEngine: require_sleep.method(zod.z.object({ engine: PipelineEngineChoiceSchema }), zod.z.object({ success: zod.z.literal(true) }), {
|
|
20751
|
-
kind: "mutation",
|
|
20752
|
-
auth: "admin"
|
|
20753
|
-
}),
|
|
20754
|
-
/**
|
|
20755
|
-
* Unload an engine from RAM. `force:true` unloads even when cameras
|
|
20756
|
-
* are actively using it (they re-spin on next frame). Default is
|
|
20757
|
-
* gated — returns `{success:false, reason}` when in use.
|
|
20758
|
-
*/
|
|
20759
|
-
killEngine: require_sleep.method(zod.z.object({
|
|
20760
|
-
engine: PipelineEngineChoiceSchema,
|
|
20761
|
-
force: zod.z.boolean().optional()
|
|
20762
|
-
}), zod.z.object({
|
|
20763
|
-
success: zod.z.boolean(),
|
|
20764
|
-
reason: zod.z.string().optional()
|
|
20765
|
-
}), {
|
|
20766
|
-
kind: "mutation",
|
|
20767
|
-
auth: "admin"
|
|
20768
|
-
}),
|
|
20769
|
-
listReferenceImages: require_sleep.method(zod.z.void(), zod.z.array(ReferenceImageEntrySchema).readonly()),
|
|
20770
|
-
getReferenceImage: require_sleep.method(zod.z.object({ filename: zod.z.string() }), ReferenceImageBodySchema.nullable()),
|
|
20771
|
-
getReferenceAudioFiles: require_sleep.method(zod.z.void(), zod.z.array(ReferenceAudioEntrySchema).readonly()),
|
|
20772
|
-
getReferenceAudio: require_sleep.method(zod.z.object({ filename: zod.z.string() }), ReferenceAudioBodySchema.nullable()),
|
|
20773
|
-
getAudioCapabilities: require_sleep.method(zod.z.void(), AudioCapabilitiesSchema),
|
|
20774
|
-
runAudioTest: require_sleep.method(zod.z.object({
|
|
20775
|
-
addonId: zod.z.string(),
|
|
20776
|
-
modelId: zod.z.string(),
|
|
20777
|
-
filename: zod.z.string().optional(),
|
|
20778
|
-
settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
20779
|
-
}), AudioTestResultSchema, { kind: "mutation" }),
|
|
20780
|
-
getDetectionConfigSchema: require_sleep.method(zod.z.void(), ConfigUISchemaNullableBridge)
|
|
20781
|
-
}
|
|
20782
|
-
};
|
|
20783
|
-
//#endregion
|
|
20784
|
-
//#region src/capabilities/schemas/zone-rule.ts
|
|
20785
|
-
/**
|
|
20786
|
-
* Per-stage gating mode applied to the zones a rule references.
|
|
20787
|
-
*
|
|
20788
|
-
* - `include`: the rule contributes to a **whitelist** for its stage.
|
|
20789
|
-
* When at least one `include` rule fires for a stage, only entities
|
|
20790
|
-
* inside one of those zones pass that stage.
|
|
20791
|
-
* - `exclude`: the rule contributes to a **blacklist** for its stage.
|
|
20792
|
-
* Entities inside one of those zones are dropped at that stage.
|
|
20793
|
-
*
|
|
20794
|
-
* `monitor`-style observation (count without filtering) is not a rule
|
|
20795
|
-
* mode — zones without any matching rule are observed naturally by
|
|
20796
|
-
* `zone-analytics` (live snapshot + history), so an "I just want to
|
|
20797
|
-
* count, not filter" use case needs no rule at all.
|
|
20798
|
-
*/
|
|
20799
|
-
var ZoneRuleModeEnum = zod.z.enum(["include", "exclude"]);
|
|
20800
|
-
/**
|
|
20801
|
-
* Per-consumer rule that references existing zones (geometry) and
|
|
20802
|
-
* defines how a specific pipeline stage should treat them. Each
|
|
20803
|
-
* consumer addon owns its own `ZoneRule[]` array in its per-device
|
|
20804
|
-
* settings:
|
|
20805
|
-
*
|
|
20806
|
-
* - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
|
|
20807
|
-
* - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
|
|
20808
|
-
* - future: notification rules, audio gating, etc.
|
|
20809
|
-
*
|
|
20810
|
-
* One rule applies to N zones (`zoneIds[]`) so the operator can
|
|
20811
|
-
* express "ignore motion in ALL of {garden, street}" with a single
|
|
20812
|
-
* rule. `classFilter` narrows the rule to specific object classes —
|
|
20813
|
-
* "drop person detections in the street, but keep cars" is one
|
|
20814
|
-
* `exclude` rule with `classFilter: ['person']`.
|
|
20815
|
-
*
|
|
20816
|
-
* `enabled` is a soft toggle — the operator can keep the rule
|
|
20817
|
-
* configured but inert without deleting it.
|
|
20818
|
-
*/
|
|
20819
|
-
var ZoneRuleSchema = zod.z.object({
|
|
20820
|
-
/** Stable rule id — survives edits, used by the UI for diffing. */
|
|
20821
|
-
id: zod.z.string(),
|
|
20822
|
-
/** Optional human-readable label rendered in the rule editor. */
|
|
20823
|
-
name: zod.z.string().optional(),
|
|
20824
|
-
/** Zones this rule targets. The rule's `mode` applies to ALL
|
|
20825
|
-
* listed zones (OR-set: a detection in any one of them counts).
|
|
20826
|
-
* At least one zone id required — a rule with no targets is a
|
|
20827
|
-
* configuration mistake and the form validator rejects it. */
|
|
20828
|
-
zoneIds: zod.z.array(zod.z.string()).min(1).readonly(),
|
|
20829
|
-
mode: ZoneRuleModeEnum,
|
|
20830
|
-
/**
|
|
20831
|
-
* Class names this rule applies to. Empty / undefined ⇒ rule
|
|
20832
|
-
* applies to every class. Class strings match the `macroClass`
|
|
20833
|
-
* field on detections (e.g. `person`, `car`, `dog`).
|
|
20834
|
-
*/
|
|
20835
|
-
classFilter: zod.z.array(zod.z.string()).readonly().optional(),
|
|
20836
|
-
/**
|
|
20837
|
-
* Minimum bbox/mask overlap (0–1) with any of the rule's zones
|
|
20838
|
-
* required to consider an entity "in the zone". Defaults to the
|
|
20839
|
-
* consumer's stage default when omitted. Kept for back-compat with
|
|
20840
|
-
* existing per-rule overrides; new operators pick the value via
|
|
20841
|
-
* `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
|
|
20842
|
-
* set, the lower-level engine reads it as a 0–1 fraction.
|
|
20843
|
-
*/
|
|
20844
|
-
overlapThreshold: zod.z.number().min(0).max(1).optional(),
|
|
20845
|
-
/**
|
|
20846
|
-
* Operator-friendly version of `overlapThreshold` — the percentage
|
|
20847
|
-
* of the detection's bbox that must lie inside the zone for the
|
|
20848
|
-
* rule to match. Documented default is 85%; the engine substitutes
|
|
20849
|
-
* that when the field is omitted (kept optional so existing rules
|
|
20850
|
-
* stored without it stay valid).
|
|
20851
|
-
*
|
|
20852
|
-
* When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
|
|
20853
|
-
* rule, the engine prefers `bboxInclusionPct` because it's the
|
|
20854
|
-
* field exposed in the UI. Internally both feed the same gate.
|
|
20855
|
-
*/
|
|
20856
|
-
bboxInclusionPct: zod.z.number().min(0).max(100).optional(),
|
|
20857
|
-
/**
|
|
20858
|
-
* When `true` and a detection has a segmentation mask, use the
|
|
20859
|
-
* mask for overlap instead of the bbox. Detection-stage only;
|
|
20860
|
-
* motion rules ignore this field.
|
|
20861
|
-
*/
|
|
20862
|
-
preferMask: zod.z.boolean().optional(),
|
|
20863
|
-
/**
|
|
20864
|
-
* Soft-toggle: `false` disables the rule without deleting it.
|
|
20865
|
-
* Defaults to `true` so operators creating a rule via the UI
|
|
20866
|
-
* see it active immediately.
|
|
20867
|
-
*/
|
|
20868
|
-
enabled: zod.z.boolean().default(true)
|
|
20869
|
-
});
|
|
20870
|
-
/**
|
|
20871
|
-
* Convenience array schema — used by addon device-settings
|
|
20872
|
-
* contributions and runtime payloads (e.g. `RunnerCameraConfig`).
|
|
20873
|
-
*/
|
|
20874
|
-
var ZoneRulesArraySchema = zod.z.array(ZoneRuleSchema).readonly();
|
|
20875
|
-
//#endregion
|
|
20876
|
-
//#region src/capabilities/zones.cap.ts
|
|
20877
|
-
/**
|
|
20878
|
-
* Zone — pure geometry + identity. NO filtering behaviour.
|
|
20879
|
-
*
|
|
20880
|
-
* Zones describe **where** in the frame the operator wants to flag
|
|
20881
|
-
* something; consumer-owned {@link ZoneRule} arrays describe **how**
|
|
20882
|
-
* each pipeline stage uses them. Splitting the two means a single
|
|
20883
|
-
* polygon "Driveway" can simultaneously back a motion-exclude rule,
|
|
20884
|
-
* a detection-include rule on `['car']`, and an occupancy aggregate
|
|
20885
|
-
* — without three duplicated polygons.
|
|
20886
|
-
*
|
|
20887
|
-
* Owned by the orchestrator addon (provider) and mirrored into the
|
|
20888
|
-
* `zones` device-state slice on every mutation. Consumers
|
|
20889
|
-
* (motion-wasm, pipeline-executor, analytics, admin UI) read either
|
|
20890
|
-
* via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
|
|
20891
|
-
* mirror with `onChanged`).
|
|
20892
|
-
*
|
|
20893
|
-
* Coordinates are normalised fractions of the frame (0–1) so zones
|
|
20894
|
-
* survive resolution changes and stream profile switches.
|
|
20895
|
-
*
|
|
20896
|
-
* `kind` discriminates between full polygons (closed regions used
|
|
20897
|
-
* for intrusion / occupancy filters) and tripwires (open 2-point
|
|
20898
|
-
* line segments used for cross events). Onboard / firmware-reported
|
|
20899
|
-
* zones (Reolink, ONVIF) are out of scope for now — see the deferred
|
|
20900
|
-
* task list.
|
|
20901
|
-
*/
|
|
20902
|
-
var ZoneKindEnum = zod.z.enum(["polygon", "tripwire"]);
|
|
20903
|
-
/** Polygon vertex in fraction-of-frame coordinates (0–1). */
|
|
20904
|
-
var PolygonPointSchema = zod.z.object({
|
|
20905
|
-
x: zod.z.number(),
|
|
20906
|
-
y: zod.z.number()
|
|
20907
|
-
});
|
|
20908
|
-
/** A camera detection zone — pure geometry/identity. */
|
|
20909
|
-
var ZoneSchema = zod.z.object({
|
|
20910
|
-
id: zod.z.string(),
|
|
20911
|
-
name: zod.z.string(),
|
|
20912
|
-
kind: ZoneKindEnum.default("polygon"),
|
|
20913
|
-
/** Polygon vertices, fraction of frame (0–1). */
|
|
20914
|
-
polygon: zod.z.array(PolygonPointSchema).readonly(),
|
|
20915
|
-
/** Visual color for UI rendering. */
|
|
20916
|
-
color: zod.z.string().default("#3b82f6")
|
|
20917
|
-
});
|
|
20918
|
-
/**
|
|
20919
|
-
* Zones capability — per-camera CRUD over polygon detection zones.
|
|
20920
|
-
*
|
|
20921
|
-
* Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
|
|
20922
|
-
* to per-device settings and mirrors into the `zones` device-state
|
|
20923
|
-
* slice on every mutation, so downstream consumers can subscribe via
|
|
20924
|
-
* `dev.state.zones.onChanged`.
|
|
20925
|
-
*
|
|
20926
|
-
* The cap surface only handles geometry + identity; filtering
|
|
20927
|
-
* behaviour (per-class, include/exclude, threshold) lives in the
|
|
20928
|
-
* consumer addons' rule arrays — see `ZoneRuleSchema` exported from
|
|
20929
|
-
* `capabilities/schemas/zone-rule.js`.
|
|
20930
|
-
*/
|
|
20931
|
-
var zonesCapability = {
|
|
20932
|
-
name: "zones",
|
|
20933
|
-
scope: "device",
|
|
20934
|
-
mode: "singleton",
|
|
20935
|
-
deviceTypes: [require_sleep.DeviceType.Camera],
|
|
20936
|
-
methods: {
|
|
20937
|
-
listZones: require_sleep.method(zod.z.object({ deviceId: zod.z.number() }), zod.z.array(ZoneSchema).readonly()),
|
|
20938
|
-
addZone: require_sleep.method(zod.z.object({
|
|
20939
|
-
deviceId: zod.z.number(),
|
|
20940
|
-
zone: ZoneSchema
|
|
20941
|
-
}), zod.z.void(), {
|
|
20942
|
-
kind: "mutation",
|
|
20943
|
-
auth: "admin"
|
|
20944
|
-
}),
|
|
20945
|
-
removeZone: require_sleep.method(zod.z.object({
|
|
20946
|
-
deviceId: zod.z.number(),
|
|
20947
|
-
zoneId: zod.z.string()
|
|
20948
|
-
}), zod.z.void(), {
|
|
20949
|
-
kind: "mutation",
|
|
20950
|
-
auth: "admin"
|
|
20951
|
-
}),
|
|
20952
|
-
updateZone: require_sleep.method(zod.z.object({
|
|
20953
|
-
deviceId: zod.z.number(),
|
|
20954
|
-
zone: ZoneSchema
|
|
20955
|
-
}), zod.z.void(), {
|
|
20956
|
-
kind: "mutation",
|
|
20957
|
-
auth: "admin"
|
|
20958
|
-
})
|
|
20959
|
-
},
|
|
20960
|
-
/**
|
|
20961
|
-
* Runtime-state slice — the live zone catalogue mirrored by the
|
|
20962
|
-
* orchestrator on every CRUD mutation. Consumers read via
|
|
20963
|
-
* `device.state.zones.value` / `.watch(...)` without round-tripping
|
|
20964
|
-
* the cap, and the codegen DeviceProxy auto-wires the reactive
|
|
20965
|
-
* handle. Slice shape is `{ zones: Zone[] }` so future extensions
|
|
20966
|
-
* (e.g. zone groupings) can sit alongside the polygon list.
|
|
20967
|
-
*/
|
|
20968
|
-
runtimeState: zod.z.object({ zones: zod.z.array(ZoneSchema).readonly() }),
|
|
20969
|
-
/**
|
|
20970
|
-
* 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.
|
|
20971
|
-
*
|
|
20972
|
-
* See `RuntimeStateDurability`. Enforced by
|
|
20973
|
-
* `scripts/check-runtime-state-durability.ts`.
|
|
20974
|
-
*/
|
|
20975
|
-
durability: "restored"
|
|
20976
|
-
};
|
|
20977
|
-
//#endregion
|
|
20978
|
-
//#region src/capabilities/pipeline-analytics.cap.ts
|
|
20979
|
-
/**
|
|
20980
|
-
* pipeline-analytics — device-scoped wrapper cap. Refines raw
|
|
20981
|
-
* per-frame detections emitted by the pipeline runner into tracked
|
|
20982
|
-
* objects, per-kind event collections (motion / object / audio), and
|
|
20983
|
-
* persisted media. Owns the post-detection domain end-to-end:
|
|
20984
|
-
*
|
|
20985
|
-
* runner emits PipelineInferenceResult
|
|
20986
|
-
* ↓ (event bus)
|
|
20987
|
-
* pipeline-analytics subscriber
|
|
20988
|
-
* ↓ SORT tracker + zone engine + state analyzer + event emitter
|
|
20989
|
-
* → three DB collections (one per kind), one FS media tree, one
|
|
20990
|
-
* unified event emitter (FrameTracked + TrackStarted/Ended +
|
|
20991
|
-
* DetectionEvent on bus)
|
|
20992
|
-
*
|
|
20993
|
-
* Pure subscriber model. No `processFrame` cap method — the runner
|
|
20994
|
-
* already publishes the raw frame on the bus. The cap surface is
|
|
20995
|
-
* only QUERIES + per-device settings, bound on/off via
|
|
20996
|
-
* `device-manager.setWrapperActive`. `defaultActive: true` because
|
|
20997
|
-
* every camera with a detection pipeline wants its raw detections
|
|
20998
|
-
* refined; operators opt out per-device via BindingsTab when needed.
|
|
20999
|
-
*
|
|
21000
|
-
* Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
|
|
21001
|
-
* (per-device surface) and `track-trail` caps — see P11 cleanup.
|
|
21002
|
-
*/
|
|
21003
|
-
var TrackStateSchema = zod.z.enum([
|
|
21004
|
-
"new",
|
|
21005
|
-
"entered",
|
|
21006
|
-
"left",
|
|
21007
|
-
"moving",
|
|
21008
|
-
"idle"
|
|
21009
|
-
]);
|
|
21010
|
-
var EventKindSchema = zod.z.enum([
|
|
21011
|
-
"motion",
|
|
21012
|
-
"object",
|
|
21013
|
-
"audio"
|
|
21014
|
-
]);
|
|
21015
|
-
/**
|
|
21016
|
-
* Spatial filter for `listTracks` — the rect + polygon variants of the shared
|
|
21017
|
-
* MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
|
|
21018
|
-
* of the camera frame (top-left origin), matching the drawing-plane editor.
|
|
21019
|
-
*/
|
|
21020
|
-
var TrackZoneFilterSchema = zod.z.discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
|
|
21021
|
-
/** Closed icon vocabulary so clients render a known glyph per kind. */
|
|
21022
|
-
var EventKindIconSchema = zod.z.enum([
|
|
21023
|
-
"motion",
|
|
21024
|
-
"audio",
|
|
21025
|
-
"person",
|
|
21026
|
-
"vehicle",
|
|
21027
|
-
"animal",
|
|
21028
|
-
"door",
|
|
21029
|
-
"pir",
|
|
21030
|
-
"smoke",
|
|
21031
|
-
"water",
|
|
21032
|
-
"button",
|
|
21033
|
-
"package",
|
|
21034
|
-
"generic"
|
|
21035
|
-
]);
|
|
21036
|
-
var EventKindCategorySchema = zod.z.enum([
|
|
21037
|
-
"motion",
|
|
21038
|
-
"audio",
|
|
21039
|
-
"detection",
|
|
21040
|
-
"sensor",
|
|
21041
|
-
"control",
|
|
21042
|
-
"custom",
|
|
21043
|
-
"package"
|
|
21044
|
-
]);
|
|
21045
|
-
/** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
|
|
21046
|
-
var EventKindLevelSchema = zod.z.enum(["macro", "sub"]);
|
|
21047
|
-
var EventKindDescriptorSchema = zod.z.object({
|
|
21048
|
-
/** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
|
|
21049
|
-
kind: zod.z.string(),
|
|
21050
|
-
/** i18n key resolved on the UI side; `label` is the English fallback. */
|
|
21051
|
-
labelKey: zod.z.string(),
|
|
21052
|
-
/** English fallback label (kept for clients that don't translate). */
|
|
21053
|
-
label: zod.z.string(),
|
|
21054
|
-
/** Hex color for timeline/legend rendering. */
|
|
21055
|
-
color: zod.z.string(),
|
|
21056
|
-
/** Dictionary id → lucide component on the UI side. */
|
|
21057
|
-
iconId: zod.z.string(),
|
|
21058
|
-
/** Legacy closed-vocab glyph — fallback for `iconId`. */
|
|
21059
|
-
icon: EventKindIconSchema,
|
|
21060
|
-
category: EventKindCategorySchema,
|
|
21061
|
-
/** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
|
|
21062
|
-
parentKind: zod.z.string().nullable(),
|
|
21063
|
-
/** Derived from `parentKind`, explicit for the client tree. */
|
|
21064
|
-
level: EventKindLevelSchema,
|
|
21065
|
-
/** Which cap + device contributes this kind. For built-ins the camera
|
|
21066
|
-
* itself; for sensor kinds the LINKED source device. */
|
|
21067
|
-
source: zod.z.object({
|
|
21068
|
-
capName: zod.z.string(),
|
|
21069
|
-
deviceId: zod.z.number()
|
|
21070
|
-
})
|
|
21071
|
-
});
|
|
21072
|
-
/** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
|
|
21073
|
-
var EventKindsForDeviceSchema = zod.z.object({
|
|
21074
|
-
deviceId: zod.z.number(),
|
|
21075
|
-
kinds: zod.z.array(EventKindDescriptorSchema).readonly()
|
|
21076
|
-
});
|
|
21077
|
-
var SensorEventSchema = zod.z.object({
|
|
21078
|
-
id: zod.z.string(),
|
|
21079
|
-
/** The CAMERA the event is attributed to (a sensor linked to N cameras
|
|
21080
|
-
* yields N rows, one per camera). */
|
|
21081
|
-
deviceId: zod.z.number(),
|
|
21082
|
-
/** The linked sensor device whose state changed. */
|
|
21083
|
-
sourceDeviceId: zod.z.number(),
|
|
21084
|
-
/** Event kind id — matches an `EventKindDescriptor.kind`. */
|
|
21085
|
-
kind: zod.z.string(),
|
|
21086
|
-
/** Snapshot of the sensor cap's runtime-state slice at the change. */
|
|
21087
|
-
value: zod.z.record(zod.z.string(), zod.z.unknown()).nullable(),
|
|
21088
|
-
timestamp: zod.z.number()
|
|
21089
|
-
});
|
|
21090
|
-
/**
|
|
21091
|
-
* One stored sighting on a track's trajectory.
|
|
21092
|
-
*
|
|
21093
|
-
* The array these live in is returned in TIME order (D399) — it is APPENDED in
|
|
21094
|
-
* arrival order, and the two detector passes interleave, so a consumer must not
|
|
21095
|
-
* assume the two are the same on a row written by an older build.
|
|
21096
|
-
*/
|
|
21097
|
-
var TrackPositionSchema = zod.z.object({
|
|
21098
|
-
x: zod.z.number(),
|
|
21099
|
-
y: zod.z.number(),
|
|
21100
|
-
timestamp: zod.z.number(),
|
|
21101
|
-
bbox: BoundingBoxSchema,
|
|
21102
|
-
/**
|
|
21103
|
-
* Which detector pass measured this box (D399): `frame` is the full-frame
|
|
21104
|
-
* pass on the analysis raster, `recovery` is the native-resolution
|
|
21105
|
-
* small-subject second pass (D377/D378). Both write into one array, and until
|
|
21106
|
-
* this field existed the only way to tell them apart was that full-frame boxes
|
|
21107
|
-
* are exact multiples of 1.2 while recovery boxes are full-precision floats.
|
|
21108
|
-
* Absent on rows written before D399.
|
|
21109
|
-
*/
|
|
21110
|
-
source: zod.z.enum(["frame", "recovery"]).optional(),
|
|
21111
|
-
/** Detection score of this box, so a position can be weighed and not only
|
|
21112
|
-
* plotted. Absent on rows written before D399. */
|
|
21113
|
-
score: zod.z.number().optional()
|
|
21114
|
-
});
|
|
21115
|
-
var TrackSnapshotSchema = zod.z.object({
|
|
21116
|
-
timestamp: zod.z.number(),
|
|
21117
|
-
position: TrackPositionSchema,
|
|
21118
|
-
/** The snapshot's media row id (D482); resolve via `listTrackMedia({ trackId })`. */
|
|
21119
|
-
mediaId: zod.z.number().int()
|
|
21120
|
-
});
|
|
21121
|
-
/**
|
|
21122
|
-
* Normalized 0..1 trajectory envelope (min/max over every position bbox,
|
|
21123
|
-
* divided by the track's detection-frame dims), computed at persist time.
|
|
21124
|
-
* Absent when the frame dims were unknown when the track was persisted
|
|
21125
|
-
* (legacy rows / dims-less sources) and on active (in-RAM) tracks.
|
|
21126
|
-
*/
|
|
21127
|
-
var TrackEnvelopeSchema = zod.z.object({
|
|
21128
|
-
minX: zod.z.number(),
|
|
21129
|
-
minY: zod.z.number(),
|
|
21130
|
-
maxX: zod.z.number(),
|
|
21131
|
-
maxY: zod.z.number()
|
|
21132
|
-
});
|
|
21133
|
-
/**
|
|
21134
|
-
* Row projection for track list queries. `full` (default) returns the
|
|
21135
|
-
* complete Track including the frame-rate `positions[]` history and the
|
|
21136
|
-
* `snapshots[]` references — megabytes across a page of tracks. `slim`
|
|
21137
|
-
* keeps every scalar the list surfaces actually render (ids, class(es),
|
|
21138
|
-
* label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
|
|
21139
|
-
* zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
|
|
21140
|
-
* `snapshots` as EMPTY arrays — detail views re-fetch the full row via
|
|
21141
|
-
* `getTrack`. Mirrors the event-store `projection` convention
|
|
21142
|
-
* (`getObjectEvents` et al.).
|
|
21143
|
-
*/
|
|
21144
|
-
var TrackProjectionSchema = zod.z.enum(["full", "slim"]);
|
|
21145
|
-
/**
|
|
21146
|
-
* One audio-classification label heard on the track's camera while the
|
|
21147
|
-
* track was alive, aggregated per label. An "episode" is one persisted
|
|
21148
|
-
* audio event (the confident-classification path: score ≥ the device's
|
|
21149
|
-
* `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
|
|
21150
|
-
* one 32 ms inference chunk, so counts stay human-scaled.
|
|
21151
|
-
*/
|
|
21152
|
-
var TrackAudioLabelSchema = zod.z.object({
|
|
21153
|
-
label: zod.z.string(),
|
|
21154
|
-
/** Highest classification score observed across the label's episodes. */
|
|
21155
|
-
peakScore: zod.z.number(),
|
|
21156
|
-
/** Number of coalesced audio-event episodes carrying this label. */
|
|
21157
|
-
count: zod.z.number(),
|
|
21158
|
-
firstAt: zod.z.number(),
|
|
21159
|
-
lastAt: zod.z.number()
|
|
21160
|
-
});
|
|
21161
|
-
/**
|
|
21162
|
-
* How a track was produced. `pipeline` (default / absent) = the spatial
|
|
21163
|
-
* detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
|
|
21164
|
-
* no positions, a single snapshot, and no bbox trajectory at all:
|
|
21165
|
-
*
|
|
21166
|
-
* - `sensor` — a linked sensor/control device state change.
|
|
21167
|
-
* - `audio` — an audio event on the camera itself that was anomalous for
|
|
21168
|
-
* THAT camera, loud, and heard while nothing visual was happening (D62).
|
|
21169
|
-
*
|
|
21170
|
-
* - `onboard` — the CAMERA's own firmware, paired with a decoded frame in
|
|
21171
|
-
* that frame's pixel space. A real root detector and a SPATIAL one: its
|
|
21172
|
-
* boxes are the same kind of fact `pipeline`'s are, produced by a different
|
|
21173
|
-
* detector.
|
|
21174
|
-
*
|
|
21175
|
-
* `onboard` was missing here while `DetectionSourceSchema` already had it, so
|
|
21176
|
-
* a persisted onboard track failed `safeParse` on read and came back with NO
|
|
21177
|
-
* source at all — which `isSpatialTrack` then admitted by accident, through the
|
|
21178
|
-
* `undefined` arm rather than by anybody's decision, and which `excludeSources`
|
|
21179
|
-
* could not name.
|
|
21180
|
-
*
|
|
21181
|
-
* The spatial subsystems (tracker association, occupancy count, re-id /
|
|
21182
|
-
* embedding, resurrection) MUST skip every synthetic source. Test for that
|
|
21183
|
-
* with `isSpatialTrack`, which allow-lists the spatial sources explicitly — a
|
|
21184
|
-
* `!== 'sensor'` check silently readmits every source added after it was
|
|
21185
|
-
* written.
|
|
20406
|
+
* - `onboard` — the CAMERA's own firmware, paired with a decoded frame in
|
|
20407
|
+
* that frame's pixel space. A real root detector and a SPATIAL one: its
|
|
20408
|
+
* boxes are the same kind of fact `pipeline`'s are, produced by a different
|
|
20409
|
+
* detector.
|
|
20410
|
+
*
|
|
20411
|
+
* `onboard` was missing here while `DetectionSourceSchema` already had it, so
|
|
20412
|
+
* a persisted onboard track failed `safeParse` on read and came back with NO
|
|
20413
|
+
* source at all — which `isSpatialTrack` then admitted by accident, through the
|
|
20414
|
+
* `undefined` arm rather than by anybody's decision, and which `excludeSources`
|
|
20415
|
+
* could not name.
|
|
20416
|
+
*
|
|
20417
|
+
* The spatial subsystems (tracker association, occupancy count, re-id /
|
|
20418
|
+
* embedding, resurrection) MUST skip every synthetic source. Test for that
|
|
20419
|
+
* with `isSpatialTrack`, which allow-lists the spatial sources explicitly — a
|
|
20420
|
+
* `!== 'sensor'` check silently readmits every source added after it was
|
|
20421
|
+
* written.
|
|
21186
20422
|
*/
|
|
21187
20423
|
var TrackSourceSchema = zod.z.enum([
|
|
21188
20424
|
"pipeline",
|
|
@@ -21574,6 +20810,22 @@ var TrackSchema = zod.z.object({
|
|
|
21574
20810
|
* omit it. Render nothing when absent.
|
|
21575
20811
|
*/
|
|
21576
20812
|
previewMissReason: zod.z.string().optional(),
|
|
20813
|
+
/**
|
|
20814
|
+
* The ROOT model that produced this track — the `FrameResult.rootModelId` of
|
|
20815
|
+
* the frame it was BORN on (D646). What a later replay compares against, so
|
|
20816
|
+
* "the original model" is named rather than assumed. A birth fact: never
|
|
20817
|
+
* rewritten by a later frame. **Absent ≠ unknown-model**: a row from before
|
|
20818
|
+
* the column, and a track the camera's own detector produced, carry none.
|
|
20819
|
+
*/
|
|
20820
|
+
modelId: zod.z.string().optional(),
|
|
20821
|
+
/**
|
|
20822
|
+
* Size (px) of the detection frame this track's `positions[].bbox` live in —
|
|
20823
|
+
* the frame it was born on, else the camera's latest analysis frame at
|
|
20824
|
+
* persist time. Divide a position by these to normalise it. Absent when the
|
|
20825
|
+
* size was never known.
|
|
20826
|
+
*/
|
|
20827
|
+
frameWidth: zod.z.number().optional(),
|
|
20828
|
+
frameHeight: zod.z.number().optional(),
|
|
21577
20829
|
...TrackFlagFields,
|
|
21578
20830
|
...TrackRetrainFields
|
|
21579
20831
|
});
|
|
@@ -22625,25 +21877,6 @@ var MediaReclaimStatusSchema = zod.z.object({
|
|
|
22625
21877
|
finishedAtMs: zod.z.number().nullable(),
|
|
22626
21878
|
error: zod.z.string().nullable()
|
|
22627
21879
|
});
|
|
22628
|
-
var ReplayFrameInputSchema = zod.z.object({
|
|
22629
|
-
timestamp: zod.z.number(),
|
|
22630
|
-
frame: PipelineRunResultBridge
|
|
22631
|
-
});
|
|
22632
|
-
var ReplayTrackSchema = zod.z.object({
|
|
22633
|
-
className: zod.z.string(),
|
|
22634
|
-
firstSeenMs: zod.z.number(),
|
|
22635
|
-
lastSeenMs: zod.z.number(),
|
|
22636
|
-
/** Bbox of the track's FIRST matched detection, pixel-space in the clip's
|
|
22637
|
-
* frame — a representative box for the diff's `(className, window, IoU)`
|
|
22638
|
-
* pairing (`replay-diff.ts`). A replay does not need the full per-frame
|
|
22639
|
-
* trajectory production's `Track.positions` keeps. */
|
|
22640
|
-
bbox: BoundingBoxSchema,
|
|
22641
|
-
/** How many of the input frames this track matched a real detection on
|
|
22642
|
-
* (never a coasted/extrapolated frame) — the replay's own signal for "how
|
|
22643
|
-
* solid is this track", cheaper than re-deriving it from a trajectory. */
|
|
22644
|
-
framesMatched: zod.z.number().int()
|
|
22645
|
-
});
|
|
22646
|
-
var RunReplayFrameProcessorResultSchema = zod.z.object({ tracks: zod.z.array(ReplayTrackSchema).readonly() });
|
|
22647
21880
|
/**
|
|
22648
21881
|
* The long-term series a camera produces. A closed union so a typo cannot
|
|
22649
21882
|
* invent one, and the ONE declaration of it — the addon's `AnalyticsLtsSeries`
|
|
@@ -23347,311 +22580,956 @@ var pipelineAnalyticsCapability = {
|
|
|
23347
22580
|
auth: "admin"
|
|
23348
22581
|
}),
|
|
23349
22582
|
/**
|
|
23350
|
-
* The pixels of ONE copied frame, base64.
|
|
22583
|
+
* The pixels of ONE copied frame, base64.
|
|
22584
|
+
*
|
|
22585
|
+
* Through the cap rather than a data plane because it is genuinely one
|
|
22586
|
+
* frame at a time, on demand, at human speed — the shape D9/D18 permit
|
|
22587
|
+
* (what they forbid is frames crossing a boundary at frame RATE). The
|
|
22588
|
+
* annotation canvas needs the image and its exact dimensions in the same
|
|
22589
|
+
* answer: a canvas that places a normalised box against a size it guessed
|
|
22590
|
+
* draws every box in the wrong place.
|
|
22591
|
+
*/
|
|
22592
|
+
getRetrainFrameImage: require_sleep.method(zod.z.object({ frameId: zod.z.string() }), zod.z.object({
|
|
22593
|
+
base64: zod.z.string(),
|
|
22594
|
+
width: zod.z.number().int(),
|
|
22595
|
+
height: zod.z.number().int()
|
|
22596
|
+
}), {
|
|
22597
|
+
kind: "query",
|
|
22598
|
+
auth: "admin"
|
|
22599
|
+
}),
|
|
22600
|
+
/**
|
|
22601
|
+
* Ask the pipeline what it sees, as a PROPOSAL.
|
|
22602
|
+
*
|
|
22603
|
+
* Runs through `pipelineRunner.runStatelessStep` on the COPIED frame, and
|
|
22604
|
+
* every box comes back as a draft with `source: 'assist'` plus the model and
|
|
22605
|
+
* score that produced it. The operator confirms, edits, adds and deletes;
|
|
22606
|
+
* nothing is stored until `saveRetrainAnnotations`.
|
|
22607
|
+
*
|
|
22608
|
+
* For packages the request is `rfdetr-package` on the ZONE CROP at 0.35 —
|
|
22609
|
+
* never the whole frame, where a package detector at that threshold proposes
|
|
22610
|
+
* furniture. A package request with no zone is REFUSED rather than widened,
|
|
22611
|
+
* because the silent widening would look like a bad model for as long as
|
|
22612
|
+
* nobody checked which rectangle it ran on.
|
|
22613
|
+
*/
|
|
22614
|
+
proposeRetrainAnnotations: require_sleep.method(zod.z.object({
|
|
22615
|
+
deviceId: zod.z.number(),
|
|
22616
|
+
trackId: zod.z.string(),
|
|
22617
|
+
frameId: zod.z.string(),
|
|
22618
|
+
subject: RetrainAssistSubjectSchema,
|
|
22619
|
+
/** Which node runs it. Absent ⇒ wherever an unowned call lands. */
|
|
22620
|
+
nodeId: zod.z.string().optional()
|
|
22621
|
+
}), RetrainAssistResultSchema, {
|
|
22622
|
+
kind: "mutation",
|
|
22623
|
+
auth: "admin"
|
|
22624
|
+
}),
|
|
22625
|
+
/** Every annotation on a track, oldest first. */
|
|
22626
|
+
listRetrainAnnotations: require_sleep.method(zod.z.object({ trackId: zod.z.string() }), zod.z.array(RetrainAnnotationSchema).readonly(), {
|
|
22627
|
+
kind: "query",
|
|
22628
|
+
auth: "admin"
|
|
22629
|
+
}),
|
|
22630
|
+
/**
|
|
22631
|
+
* Replace EVERY annotation on one frame with the supplied set.
|
|
22632
|
+
*
|
|
22633
|
+
* Whole-frame replacement, not per-box upsert: the unit of ground truth is
|
|
22634
|
+
* the frame, and "the operator deleted a box" must be the same durable
|
|
22635
|
+
* outcome as "the operator never drew it". A per-box patch would let a frame
|
|
22636
|
+
* keep a box the operator removed on a surface that only knew about the
|
|
22637
|
+
* boxes it sent.
|
|
22638
|
+
*
|
|
22639
|
+
* Refuses a macro class typed into `label` or `subLabel` — the tiers are
|
|
22640
|
+
* separate and the guard is at the WRITE, because a mixed taxonomy cannot
|
|
22641
|
+
* be un-mixed by reading it.
|
|
22642
|
+
*/
|
|
22643
|
+
saveRetrainAnnotations: require_sleep.method(zod.z.object({
|
|
22644
|
+
deviceId: zod.z.number(),
|
|
22645
|
+
trackId: zod.z.string(),
|
|
22646
|
+
frameId: zod.z.string(),
|
|
22647
|
+
annotations: zod.z.array(RetrainAnnotationDraftSchema)
|
|
22648
|
+
}), zod.z.array(RetrainAnnotationSchema).readonly(), {
|
|
22649
|
+
kind: "mutation",
|
|
22650
|
+
auth: "admin"
|
|
22651
|
+
}),
|
|
22652
|
+
/**
|
|
22653
|
+
* Finish with a track: `staging → trained`. **The only writer of that
|
|
22654
|
+
* state** — D81 shipped the column with it deliberately unreachable.
|
|
22655
|
+
*
|
|
22656
|
+
* Refuses a track the dataset holds no copies from. `trained` un-pins the
|
|
22657
|
+
* track's media, so completing without a copy is a delete order for material
|
|
22658
|
+
* nothing ever extracted anything from; that refusal IS the safety argument
|
|
22659
|
+
* of D81, expressed as a precondition.
|
|
22660
|
+
*/
|
|
22661
|
+
completeRetrainTrack: require_sleep.method(zod.z.object({
|
|
22662
|
+
deviceId: zod.z.number(),
|
|
22663
|
+
trackId: zod.z.string()
|
|
22664
|
+
}), RetrainTransitionResultSchema, {
|
|
22665
|
+
kind: "mutation",
|
|
22666
|
+
auth: "admin"
|
|
22667
|
+
}),
|
|
22668
|
+
/**
|
|
22669
|
+
* The deliberate return: `trained → staging`, for the rare case.
|
|
22670
|
+
*
|
|
22671
|
+
* The generic `setTrackFlags` toggle refuses this in both directions by
|
|
22672
|
+
* design (D81) — re-staging from a checkbox is how the same material gets
|
|
22673
|
+
* annotated twice under two ground truths. Doing it here means the operator
|
|
22674
|
+
* is looking at the annotations that already exist while they decide, and
|
|
22675
|
+
* those annotations are LEFT ALONE: "put this back" must not be a
|
|
22676
|
+
* destructive act wearing a navigational name.
|
|
22677
|
+
*/
|
|
22678
|
+
restageRetrainTrack: require_sleep.method(zod.z.object({
|
|
22679
|
+
deviceId: zod.z.number(),
|
|
22680
|
+
trackId: zod.z.string()
|
|
22681
|
+
}), RetrainTransitionResultSchema, {
|
|
22682
|
+
kind: "mutation",
|
|
22683
|
+
auth: "admin"
|
|
22684
|
+
}),
|
|
22685
|
+
/**
|
|
22686
|
+
* Where to download the ANNOTATED dataset.
|
|
22687
|
+
*
|
|
22688
|
+
* The sibling of `getTrainingExportUrl` and deliberately not the same
|
|
22689
|
+
* archive: that one streams a marked track's stored media verbatim, this one
|
|
22690
|
+
* streams the retrain COPIES plus an `annotations.json` carrying, for every
|
|
22691
|
+
* subject, the canonical full-frame box AND the geometry derived for each
|
|
22692
|
+
* model shape (letterboxed root / zone-cropped package / subject-cropped
|
|
22693
|
+
* classifier). Derived at export, never stored — one box in, three shapes
|
|
22694
|
+
* out, so two crops of the same subject can never end up in one feature
|
|
22695
|
+
* space (D52).
|
|
22696
|
+
*/
|
|
22697
|
+
getRetrainExportUrl: require_sleep.method(zod.z.object({ deviceIds: zod.z.array(zod.z.number()).optional() }), zod.z.object({ url: zod.z.string() }), {
|
|
22698
|
+
kind: "query",
|
|
22699
|
+
auth: "admin"
|
|
22700
|
+
}),
|
|
22701
|
+
/**
|
|
22702
|
+
* The media an EVENT owns.
|
|
22703
|
+
*
|
|
22704
|
+
* `ownerType` is REQUIRED, and that is the whole correction (D482). An
|
|
22705
|
+
* event is a row in ONE of three tables, and since D474 each numbers from
|
|
22706
|
+
* 1 independently: `motion:101314` and `object:101314` both exist. This
|
|
22707
|
+
* method took a bare `eventId` and the provider probed motion → object →
|
|
22708
|
+
* audio, stopping at the first hit — so on the live hub, where object
|
|
22709
|
+
* events own no media of their own and 299 883 of 300 559 media rows are
|
|
22710
|
+
* motion-owned, EVERY object event resolved to its motion namesake. A
|
|
22711
|
+
* track from 17:34 on camera 615 was served a snapshot from 22:35 eleven
|
|
22712
|
+
* days earlier, silently.
|
|
22713
|
+
*
|
|
22714
|
+
* D476 had already disambiguated the KEY (`motion:` vs `object:`); this is
|
|
22715
|
+
* the API catching up to it. Naming the table is not a "qualification" of
|
|
22716
|
+
* the ambiguity — a listing BY OWNER has no address to make surrogate: the
|
|
22717
|
+
* owner IS (table, id), and half of it is not a question.
|
|
22718
|
+
*/
|
|
22719
|
+
getEventMedia: require_sleep.method(zod.z.object({
|
|
22720
|
+
/** Which of the three event tables owns the row. */
|
|
22721
|
+
ownerType: EventOwnerTypeSchema,
|
|
22722
|
+
/** The event's rowid in that table (D474: an event id is a number). */
|
|
22723
|
+
eventId: zod.z.number().int(),
|
|
22724
|
+
kind: MediaFileKindEnum.optional(),
|
|
22725
|
+
deviceId: zod.z.number()
|
|
22726
|
+
}), zod.z.array(MediaFileSchema).readonly()),
|
|
22727
|
+
/** All media rows owned by a track. `kinds` narrows to a kind subset so a
|
|
22728
|
+
* client can fetch the SMALL display variants on open and pull the
|
|
22729
|
+
* multi-MB native variants only on demand (mirrors `getEventMedia.kind`).
|
|
22730
|
+
* Absent ⇒ every kind (back-compat). */
|
|
22731
|
+
getTrackMedia: require_sleep.method(zod.z.object({
|
|
22732
|
+
trackId: zod.z.string(),
|
|
22733
|
+
kinds: zod.z.array(MediaFileKindEnum).optional(),
|
|
22734
|
+
deviceId: zod.z.number()
|
|
22735
|
+
}), zod.z.array(MediaFileSchema).readonly()),
|
|
22736
|
+
/**
|
|
22737
|
+
* What media a track HAS, without any of it.
|
|
22738
|
+
*
|
|
22739
|
+
* The detail view needs the shape of a track's media to build its strip —
|
|
22740
|
+
* which kinds exist, in what order, at what size — and then wants each tile
|
|
22741
|
+
* fetched as an image, not as base64 inside this response. Measured: the
|
|
22742
|
+
* full `getTrackMedia` is 5.3-7.7 MB and blocks the view; this manifest is
|
|
22743
|
+
* ~2 KB.
|
|
22744
|
+
*
|
|
22745
|
+
* It also restores a fact a `kinds` filter destroys: filtering
|
|
22746
|
+
* `getTrackMedia` drops whole ROWS, taking `kind` and `sizeBytes` with
|
|
22747
|
+
* them, so a client that fetched only the small variants could no longer
|
|
22748
|
+
* tell a full-resolution variant existed — and the affordance that opens it
|
|
22749
|
+
* would silently disappear.
|
|
22750
|
+
*/
|
|
22751
|
+
listTrackMedia: require_sleep.method(zod.z.object({
|
|
22752
|
+
trackId: zod.z.string(),
|
|
22753
|
+
deviceId: zod.z.number()
|
|
22754
|
+
}), zod.z.array(MediaFileInfoSchema).readonly()),
|
|
22755
|
+
/**
|
|
22756
|
+
* What media an EVENT has, without any of it — the twin `getEventMedia`
|
|
22757
|
+
* never had.
|
|
23351
22758
|
*
|
|
23352
|
-
*
|
|
23353
|
-
*
|
|
23354
|
-
*
|
|
23355
|
-
*
|
|
23356
|
-
*
|
|
23357
|
-
*
|
|
22759
|
+
* `listTrackMedia` above got this treatment because a track's media is
|
|
22760
|
+
* 5-8 MB. An event's is worse per row, not better: an old-style event owns
|
|
22761
|
+
* a `crop` AND a native-resolution `fullFrameBoxed`, and the track DETAIL
|
|
22762
|
+
* modal — the one surface that legitimately shows the big kinds — unions
|
|
22763
|
+
* both listings to build its filmstrip. It then renders every tile from
|
|
22764
|
+
* the `event-media` plane by key and throws the bytes away. Measured on
|
|
22765
|
+
* the live hub: one event's `fullFrameBoxed` is 2 824 077 B, base64'd to
|
|
22766
|
+
* ~3.8 MB, allocated whole in hub-main's heap, for a list of keys.
|
|
22767
|
+
*
|
|
22768
|
+
* Same `deviceId` authorization subject as `getEventMedia`, the same
|
|
22769
|
+
* REQUIRED `ownerType` (read that method's docblock for the night-time
|
|
22770
|
+
* thumbnail this closes — D482), and the same rows: this is a projection
|
|
22771
|
+
* of that method, never a different question.
|
|
23358
22772
|
*/
|
|
23359
|
-
|
|
23360
|
-
|
|
23361
|
-
|
|
23362
|
-
|
|
23363
|
-
}),
|
|
23364
|
-
kind: "query",
|
|
23365
|
-
auth: "admin"
|
|
23366
|
-
}),
|
|
22773
|
+
listEventMedia: require_sleep.method(zod.z.object({
|
|
22774
|
+
ownerType: EventOwnerTypeSchema,
|
|
22775
|
+
eventId: zod.z.number().int(),
|
|
22776
|
+
deviceId: zod.z.number()
|
|
22777
|
+
}), zod.z.array(MediaFileInfoSchema).readonly()),
|
|
23367
22778
|
/**
|
|
23368
|
-
*
|
|
22779
|
+
* Which of `ownerIds` hold at least ONE media row — an INDEX read, never a
|
|
22780
|
+
* blob read, and the LICENCE `videoclips` needs to publish a `thumbnail`.
|
|
23369
22781
|
*
|
|
23370
|
-
*
|
|
23371
|
-
*
|
|
23372
|
-
*
|
|
23373
|
-
*
|
|
22782
|
+
* The event-media URL is stamped from a template for every event in the
|
|
22783
|
+
* system, so "the plane is up" was being served as "there are bytes": 64 of
|
|
22784
|
+
* one camera's 179 clips pointed at a 404 (device 3836, 2026-08-17). This
|
|
22785
|
+
* is the question that turns the stamp into a claim.
|
|
23374
22786
|
*
|
|
23375
|
-
*
|
|
23376
|
-
*
|
|
23377
|
-
*
|
|
23378
|
-
*
|
|
23379
|
-
*
|
|
22787
|
+
* It is on the WIRE because the clip source is registered by the addon that
|
|
22788
|
+
* owns the FOOTAGE, not by this one (D560) — the probe used to be an
|
|
22789
|
+
* in-process `MediaStore` read. One call per OWNER KIND, never one per
|
|
22790
|
+
* owner: that N+1 is what `MediaStore.ownersWithMedia` was written to
|
|
22791
|
+
* prevent, and crossing a process boundary makes it worse, not better.
|
|
22792
|
+
* `ownerIds` is bounded at the same 5 000 the annotation fetch is bounded
|
|
22793
|
+
* at, so one pathological camera-day cannot mint an unbounded request.
|
|
22794
|
+
*
|
|
22795
|
+
* THROWS rather than answering partially. A probe that quietly
|
|
22796
|
+
* under-reports reads as "these owners have nothing" and the caller drops
|
|
22797
|
+
* thumbnails that exist — the opposite failure to the one above, and
|
|
22798
|
+
* equally invisible.
|
|
22799
|
+
*
|
|
22800
|
+
* `deviceId` is the authorization subject, exactly as on `getEventMedia`.
|
|
23380
22801
|
*/
|
|
23381
|
-
|
|
22802
|
+
ownersWithMedia: require_sleep.method(zod.z.object({
|
|
23382
22803
|
deviceId: zod.z.number(),
|
|
23383
|
-
|
|
23384
|
-
|
|
23385
|
-
|
|
23386
|
-
/** Which node runs it. Absent ⇒ wherever an unowned call lands. */
|
|
23387
|
-
nodeId: zod.z.string().optional()
|
|
23388
|
-
}), RetrainAssistResultSchema, {
|
|
23389
|
-
kind: "mutation",
|
|
23390
|
-
auth: "admin"
|
|
23391
|
-
}),
|
|
22804
|
+
ownerKind: MediaPresenceOwnerKindSchema,
|
|
22805
|
+
ownerIds: zod.z.array(zod.z.string()).max(5e3)
|
|
22806
|
+
}), zod.z.array(zod.z.string()).readonly()),
|
|
23392
22807
|
/**
|
|
23393
|
-
*
|
|
23394
|
-
*
|
|
23395
|
-
* `
|
|
23396
|
-
*
|
|
23397
|
-
*
|
|
23398
|
-
*
|
|
23399
|
-
* `frames` IN THE ORDER GIVEN (the caller is responsible for time
|
|
23400
|
-
* ordering — this method does not sort), and returns the tracks it
|
|
23401
|
-
* produced. Zero persistence: no `TrackStore`, no event bus, no media
|
|
23402
|
-
* capture. `zones` / `detectionRules` are the run's OWN zone set —
|
|
23403
|
-
* typically the camera's real zones plus an ephemeral overlay
|
|
23404
|
-
* (`addon-benchmark`'s `replay-plan.ts`), never read from or written to
|
|
23405
|
-
* the `zones` capability by this method itself.
|
|
22808
|
+
* Search object events by text query using CLIP cosine similarity.
|
|
22809
|
+
* Encodes `text` via the `embedding-encoder` cap, queries the
|
|
22810
|
+
* `ObjectEmbeddingStore` with optional prefilters, ranks all matching
|
|
22811
|
+
* embeddings by cosine similarity, and joins winners to their
|
|
22812
|
+
* ObjectEvents by trackId. Returns up to `limit` events scored ≥
|
|
22813
|
+
* `minScore`, sorted descending by score.
|
|
23406
22814
|
*/
|
|
23407
|
-
|
|
23408
|
-
|
|
23409
|
-
source: DetectionSourceSchema,
|
|
23410
|
-
zones: zod.z.array(ZoneSchema).readonly().optional(),
|
|
23411
|
-
detectionRules: zod.z.array(ZoneRuleSchema).readonly().optional(),
|
|
23412
|
-
zoneMembershipMinOverlap: zod.z.number().min(0).max(1).optional(),
|
|
23413
|
-
frames: zod.z.array(ReplayFrameInputSchema).min(1)
|
|
23414
|
-
}), RunReplayFrameProcessorResultSchema, {
|
|
22815
|
+
searchObjectEvents: require_sleep.method(SearchObjectEventsInput, zod.z.array(ScoredObjectEventSchema).readonly()),
|
|
22816
|
+
wipeObjectEmbeddings: require_sleep.method(zod.z.object({}), WipeObjectEmbeddingsResultSchema, {
|
|
23415
22817
|
kind: "mutation",
|
|
23416
22818
|
auth: "admin"
|
|
23417
22819
|
}),
|
|
23418
|
-
|
|
23419
|
-
|
|
23420
|
-
kind: "query",
|
|
22820
|
+
rebuildObjectEmbeddings: require_sleep.method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
|
|
22821
|
+
kind: "mutation",
|
|
23421
22822
|
auth: "admin"
|
|
23422
22823
|
}),
|
|
22824
|
+
getObjectEmbeddingRebuildStatus: require_sleep.method(zod.z.object({}), RebuildStatusSchema)
|
|
22825
|
+
},
|
|
22826
|
+
events: {
|
|
23423
22827
|
/**
|
|
23424
|
-
*
|
|
23425
|
-
*
|
|
23426
|
-
*
|
|
23427
|
-
*
|
|
23428
|
-
*
|
|
23429
|
-
*
|
|
23430
|
-
* boxes it sent.
|
|
23431
|
-
*
|
|
23432
|
-
* Refuses a macro class typed into `label` or `subLabel` — the tiers are
|
|
23433
|
-
* separate and the guard is at the WRITE, because a mixed taxonomy cannot
|
|
23434
|
-
* be un-mixed by reading it.
|
|
22828
|
+
* Enriched frame emitted after refinement — the live-overlay source of
|
|
22829
|
+
* truth (two-plane re-injection). Carries the frame's detections in the
|
|
22830
|
+
* `ObjectDetection` wire shape: first-level roots (with track info +
|
|
22831
|
+
* enrichment labels) plus synthesized `kind:'detail'` face/plate entries
|
|
22832
|
+
* re-projected from per-track detail state, so stream overlays render
|
|
22833
|
+
* boxes + recognized names without querying full Track state.
|
|
23435
22834
|
*/
|
|
23436
|
-
|
|
22835
|
+
onFrameTracked: { data: zod.z.object({
|
|
22836
|
+
deviceId: zod.z.number(),
|
|
22837
|
+
timestamp: zod.z.number(),
|
|
22838
|
+
frameWidth: zod.z.number(),
|
|
22839
|
+
frameHeight: zod.z.number(),
|
|
22840
|
+
detections: zod.z.array(OverlayDetectionSchema).readonly()
|
|
22841
|
+
}) },
|
|
22842
|
+
/** Track entered active state (first-seen). */
|
|
22843
|
+
onTrackStarted: { data: zod.z.object({
|
|
23437
22844
|
deviceId: zod.z.number(),
|
|
23438
22845
|
trackId: zod.z.string(),
|
|
23439
|
-
|
|
23440
|
-
|
|
23441
|
-
|
|
22846
|
+
className: zod.z.string()
|
|
22847
|
+
}) },
|
|
22848
|
+
/** Track expired (TTL reached after last detection). */
|
|
22849
|
+
onTrackEnded: { data: zod.z.object({
|
|
22850
|
+
deviceId: zod.z.number(),
|
|
22851
|
+
trackId: zod.z.string(),
|
|
22852
|
+
className: zod.z.string(),
|
|
22853
|
+
durationMs: zod.z.number()
|
|
22854
|
+
}) },
|
|
22855
|
+
/** Canonical "something happened at device X" event, per-kind. */
|
|
22856
|
+
onDetectionEvent: { data: zod.z.object({
|
|
22857
|
+
deviceId: zod.z.number(),
|
|
22858
|
+
kind: EventKindSchema,
|
|
22859
|
+
eventId: zod.z.string(),
|
|
22860
|
+
timestamp: zod.z.number()
|
|
22861
|
+
}) }
|
|
22862
|
+
}
|
|
22863
|
+
};
|
|
22864
|
+
//#endregion
|
|
22865
|
+
//#region src/capabilities/pipeline-executor.cap.ts
|
|
22866
|
+
/**
|
|
22867
|
+
* Reference to the frame's retained NATIVE surface + the parent crop's placement
|
|
22868
|
+
* within the frame, so the executor can re-cut a leaf child ROI at native
|
|
22869
|
+
* resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
|
|
22870
|
+
*/
|
|
22871
|
+
var NativeCropRefSchema = zod.z.object({
|
|
22872
|
+
/** Handle keying the retained native surface (node-pinned to its owner). */
|
|
22873
|
+
handle: require_sleep.FrameHandleSchema,
|
|
22874
|
+
/** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
|
|
22875
|
+
cropFrameSpace: zod.z.object({
|
|
22876
|
+
x: zod.z.number(),
|
|
22877
|
+
y: zod.z.number(),
|
|
22878
|
+
w: zod.z.number(),
|
|
22879
|
+
h: zod.z.number()
|
|
22880
|
+
})
|
|
22881
|
+
});
|
|
22882
|
+
zod.z.object({
|
|
22883
|
+
crop: zod.z.object({
|
|
22884
|
+
left: zod.z.number(),
|
|
22885
|
+
top: zod.z.number(),
|
|
22886
|
+
width: zod.z.number().positive(),
|
|
22887
|
+
height: zod.z.number().positive()
|
|
22888
|
+
}).optional(),
|
|
22889
|
+
content: zod.z.object({
|
|
22890
|
+
width: zod.z.number().int().positive(),
|
|
22891
|
+
height: zod.z.number().int().positive()
|
|
22892
|
+
}),
|
|
22893
|
+
fit: zod.z.enum(["stretch", "contain"]),
|
|
22894
|
+
format: zod.z.enum([
|
|
22895
|
+
"rgb",
|
|
22896
|
+
"gray",
|
|
22897
|
+
"jpeg"
|
|
22898
|
+
])
|
|
22899
|
+
});
|
|
22900
|
+
/**
|
|
22901
|
+
* Process-local frame identity. It is serializable so it can ride an in-process
|
|
22902
|
+
* capability call, but `registryId` deliberately prevents resolution in any
|
|
22903
|
+
* other process or execution group.
|
|
22904
|
+
*/
|
|
22905
|
+
var FrameRefSchema = zod.z.object({
|
|
22906
|
+
registryId: zod.z.string().min(1),
|
|
22907
|
+
id: zod.z.string().min(1),
|
|
22908
|
+
width: zod.z.number().int().positive(),
|
|
22909
|
+
height: zod.z.number().int().positive(),
|
|
22910
|
+
format: zod.z.enum(["rgb", "gray"]),
|
|
22911
|
+
timestamp: zod.z.number(),
|
|
22912
|
+
capturedAt: zod.z.number().optional()
|
|
22913
|
+
});
|
|
22914
|
+
var ModelFormatSchema$1 = zod.z.enum([
|
|
22915
|
+
"onnx",
|
|
22916
|
+
"coreml",
|
|
22917
|
+
"openvino",
|
|
22918
|
+
"tflite",
|
|
22919
|
+
"pt",
|
|
22920
|
+
"gguf"
|
|
22921
|
+
]);
|
|
22922
|
+
var PipelineSlotSchema = zod.z.enum([
|
|
22923
|
+
"detector",
|
|
22924
|
+
"cropper",
|
|
22925
|
+
"classifier",
|
|
22926
|
+
"refiner",
|
|
22927
|
+
"audio-classifier"
|
|
22928
|
+
]);
|
|
22929
|
+
var PipelineEngineChoiceSchema = zod.z.object({
|
|
22930
|
+
runtime: zod.z.literal("python"),
|
|
22931
|
+
backend: zod.z.string(),
|
|
22932
|
+
format: ModelFormatSchema$1,
|
|
22933
|
+
device: zod.z.string().optional()
|
|
22934
|
+
});
|
|
22935
|
+
/**
|
|
22936
|
+
* One pool's resolved provisioning (`getEffectiveTuning`). `numWorkers` is the
|
|
22937
|
+
* knob that lifts a saturated pool (`inference-devices.md`); `concurrency` is
|
|
22938
|
+
* per-worker in-flight requests. `deviceKey` echoes the pool asked about —
|
|
22939
|
+
* `null` for the node-default pool.
|
|
22940
|
+
*/
|
|
22941
|
+
var EffectiveTuningSchema = zod.z.object({
|
|
22942
|
+
deviceKey: zod.z.string().nullable(),
|
|
22943
|
+
runtime: zod.z.string(),
|
|
22944
|
+
batchMode: zod.z.string(),
|
|
22945
|
+
windowMs: zod.z.number(),
|
|
22946
|
+
maxBatchSize: zod.z.number(),
|
|
22947
|
+
concurrency: zod.z.number(),
|
|
22948
|
+
numWorkers: zod.z.number()
|
|
22949
|
+
});
|
|
22950
|
+
var EngineDeviceInfoSchema = zod.z.object({
|
|
22951
|
+
id: zod.z.string(),
|
|
22952
|
+
label: zod.z.string(),
|
|
22953
|
+
description: zod.z.string().optional()
|
|
22954
|
+
});
|
|
22955
|
+
var AvailableEngineSchema = zod.z.object({
|
|
22956
|
+
engine: PipelineEngineChoiceSchema,
|
|
22957
|
+
devices: zod.z.array(EngineDeviceInfoSchema).readonly(),
|
|
22958
|
+
defaultDevice: zod.z.string()
|
|
22959
|
+
});
|
|
22960
|
+
var PipelineDefaultStepSchema = zod.z.lazy(() => zod.z.object({
|
|
22961
|
+
addonId: zod.z.string(),
|
|
22962
|
+
addonName: zod.z.string(),
|
|
22963
|
+
slot: PipelineSlotSchema,
|
|
22964
|
+
inputClasses: zod.z.array(zod.z.string()).readonly(),
|
|
22965
|
+
outputClasses: zod.z.array(zod.z.string()).readonly(),
|
|
22966
|
+
enabled: zod.z.boolean(),
|
|
22967
|
+
modelId: zod.z.string(),
|
|
22968
|
+
children: zod.z.array(PipelineDefaultStepSchema).readonly(),
|
|
22969
|
+
group: zod.z.string().optional(),
|
|
22970
|
+
settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
22971
|
+
}));
|
|
22972
|
+
var PipelineTemplateStepSchema = zod.z.lazy(() => zod.z.object({
|
|
22973
|
+
addonId: zod.z.string(),
|
|
22974
|
+
enabled: zod.z.boolean(),
|
|
22975
|
+
modelId: zod.z.string(),
|
|
22976
|
+
children: zod.z.array(PipelineTemplateStepSchema).readonly(),
|
|
22977
|
+
settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
22978
|
+
}));
|
|
22979
|
+
var PipelineTemplateSchema$1 = zod.z.object({
|
|
22980
|
+
id: zod.z.string(),
|
|
22981
|
+
name: zod.z.string(),
|
|
22982
|
+
createdAt: zod.z.string(),
|
|
22983
|
+
updatedAt: zod.z.string(),
|
|
22984
|
+
engine: PipelineEngineChoiceSchema,
|
|
22985
|
+
steps: zod.z.array(PipelineTemplateStepSchema).readonly()
|
|
22986
|
+
});
|
|
22987
|
+
var PipelineModelOptionSchema = zod.z.object({
|
|
22988
|
+
id: zod.z.string(),
|
|
22989
|
+
name: zod.z.string(),
|
|
22990
|
+
formats: zod.z.record(zod.z.string(), zod.z.object({
|
|
22991
|
+
downloaded: zod.z.boolean(),
|
|
22992
|
+
sizeMB: zod.z.number()
|
|
22993
|
+
})),
|
|
22994
|
+
group: ModelVariantGroupSchema.optional(),
|
|
22995
|
+
legacy: zod.z.boolean().optional(),
|
|
22996
|
+
provider: ModelProviderIdSchema.optional()
|
|
22997
|
+
});
|
|
22998
|
+
var ConfigFieldBridge = zod.z.custom();
|
|
22999
|
+
var PipelineAddonSchemaSchema = zod.z.object({
|
|
23000
|
+
id: zod.z.string(),
|
|
23001
|
+
name: zod.z.string(),
|
|
23002
|
+
slot: PipelineSlotSchema,
|
|
23003
|
+
inputClasses: zod.z.array(zod.z.string()).readonly(),
|
|
23004
|
+
outputClasses: zod.z.array(zod.z.string()).readonly(),
|
|
23005
|
+
childSlots: zod.z.array(PipelineSlotSchema).readonly(),
|
|
23006
|
+
models: zod.z.array(PipelineModelOptionSchema).readonly(),
|
|
23007
|
+
defaultModelId: zod.z.string(),
|
|
23008
|
+
defaultModelIdByFormat: zod.z.record(zod.z.string(), zod.z.string()).optional(),
|
|
23009
|
+
enabledByDefault: zod.z.boolean().optional(),
|
|
23010
|
+
backfillIntoExistingOverrides: zod.z.boolean().optional(),
|
|
23011
|
+
defaultConfidence: zod.z.number(),
|
|
23012
|
+
group: zod.z.string().optional(),
|
|
23013
|
+
configSchema: zod.z.array(ConfigFieldBridge).readonly().optional()
|
|
23014
|
+
});
|
|
23015
|
+
var PipelineSlotSchemaSchema = zod.z.object({
|
|
23016
|
+
id: PipelineSlotSchema,
|
|
23017
|
+
label: zod.z.string(),
|
|
23018
|
+
priority: zod.z.number(),
|
|
23019
|
+
parentSlot: PipelineSlotSchema.nullable(),
|
|
23020
|
+
addons: zod.z.array(PipelineAddonSchemaSchema).readonly()
|
|
23021
|
+
});
|
|
23022
|
+
var PipelineSchemaSchema = zod.z.object({
|
|
23023
|
+
availableEngines: zod.z.array(AvailableEngineSchema).readonly(),
|
|
23024
|
+
selectedEngine: PipelineEngineChoiceSchema,
|
|
23025
|
+
slots: zod.z.array(PipelineSlotSchemaSchema).readonly()
|
|
23026
|
+
});
|
|
23027
|
+
var EngineProvisioningSchema = zod.z.object({
|
|
23028
|
+
runtimeId: zod.z.enum([
|
|
23029
|
+
"onnx",
|
|
23030
|
+
"openvino",
|
|
23031
|
+
"coreml",
|
|
23032
|
+
"edgetpu"
|
|
23033
|
+
]).nullable(),
|
|
23034
|
+
device: zod.z.string().nullable(),
|
|
23035
|
+
state: zod.z.enum([
|
|
23036
|
+
"idle",
|
|
23037
|
+
"installing",
|
|
23038
|
+
"verifying",
|
|
23039
|
+
"ready",
|
|
23040
|
+
"failed"
|
|
23041
|
+
]),
|
|
23042
|
+
progress: zod.z.number().optional(),
|
|
23043
|
+
error: zod.z.string().optional(),
|
|
23044
|
+
nextRetryAt: zod.z.number().optional(),
|
|
23045
|
+
/**
|
|
23046
|
+
* Gate A (config-correctness gate at engine change): human-readable
|
|
23047
|
+
* config issues surfaced EAGERLY when the node's engine changes — model
|
|
23048
|
+
* substitutions ("chose X, running Y") and zero-build steps ("no model
|
|
23049
|
+
* has a <format> build"). Additive/optional: informational only, never
|
|
23050
|
+
* enforced here — `assertEngineReady` (readiness) still gates inference.
|
|
23051
|
+
* Absent/empty when the node-default tree resolves cleanly.
|
|
23052
|
+
*/
|
|
23053
|
+
configIssues: zod.z.array(zod.z.string()).optional()
|
|
23054
|
+
});
|
|
23055
|
+
var PipelineStepInputSchema = zod.z.lazy(() => zod.z.object({
|
|
23056
|
+
addonId: zod.z.string(),
|
|
23057
|
+
modelId: zod.z.string().optional(),
|
|
23058
|
+
enabled: zod.z.boolean().default(true),
|
|
23059
|
+
children: zod.z.array(PipelineStepInputSchema).optional(),
|
|
23060
|
+
settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
23061
|
+
jumpDeviceKey: zod.z.string().optional()
|
|
23062
|
+
}));
|
|
23063
|
+
var ModelSubstitutionSchema = zod.z.object({
|
|
23064
|
+
addonId: zod.z.string(),
|
|
23065
|
+
chosen: zod.z.string(),
|
|
23066
|
+
running: zod.z.string(),
|
|
23067
|
+
format: zod.z.string()
|
|
23068
|
+
});
|
|
23069
|
+
var PipelineValidationIssueSchema = zod.z.object({
|
|
23070
|
+
addonId: zod.z.string(),
|
|
23071
|
+
kind: zod.z.enum([
|
|
23072
|
+
"unknown-addon",
|
|
23073
|
+
"no-format-build",
|
|
23074
|
+
"unknown-device"
|
|
23075
|
+
]),
|
|
23076
|
+
detail: zod.z.string()
|
|
23077
|
+
});
|
|
23078
|
+
var PipelineValidationResultSchema = zod.z.object({
|
|
23079
|
+
ok: zod.z.boolean(),
|
|
23080
|
+
issues: zod.z.array(PipelineValidationIssueSchema).readonly(),
|
|
23081
|
+
substitutions: zod.z.array(ModelSubstitutionSchema).readonly(),
|
|
23082
|
+
/** The node's `currentEngine.format` this validation ran against. */
|
|
23083
|
+
format: zod.z.string()
|
|
23084
|
+
});
|
|
23085
|
+
var ReferenceImageEntrySchema = zod.z.object({
|
|
23086
|
+
filename: zod.z.string(),
|
|
23087
|
+
stepIds: zod.z.array(zod.z.string()).readonly().optional()
|
|
23088
|
+
});
|
|
23089
|
+
var ReferenceImageBodySchema = zod.z.object({
|
|
23090
|
+
base64: zod.z.string(),
|
|
23091
|
+
filename: zod.z.string()
|
|
23092
|
+
});
|
|
23093
|
+
var ReferenceAudioEntrySchema = zod.z.object({
|
|
23094
|
+
filename: zod.z.string(),
|
|
23095
|
+
sizeKb: zod.z.number()
|
|
23096
|
+
});
|
|
23097
|
+
var ReferenceAudioBodySchema = zod.z.object({ base64: zod.z.string() });
|
|
23098
|
+
var AudioBackendSchema = zod.z.object({
|
|
23099
|
+
id: zod.z.string(),
|
|
23100
|
+
name: zod.z.string(),
|
|
23101
|
+
description: zod.z.string(),
|
|
23102
|
+
available: zod.z.boolean(),
|
|
23103
|
+
/**
|
|
23104
|
+
* Raw classifier labels this backend can emit (e.g. YAMNet's
|
|
23105
|
+
* 521-class set or Apple SoundAnalysis's 303-class set). Used by
|
|
23106
|
+
* the benchmark UI to populate the `enabledMicroClasses` filter
|
|
23107
|
+
* specific to the selected backend without a separate fetch.
|
|
23108
|
+
*/
|
|
23109
|
+
rawLabels: zod.z.array(zod.z.string()).readonly().optional()
|
|
23110
|
+
});
|
|
23111
|
+
var AudioCapabilitiesSchema = zod.z.object({
|
|
23112
|
+
activeBackend: zod.z.string(),
|
|
23113
|
+
availableBackends: zod.z.array(AudioBackendSchema).readonly(),
|
|
23114
|
+
sampleRate: zod.z.number(),
|
|
23115
|
+
chunkDurationMs: zod.z.number()
|
|
23116
|
+
});
|
|
23117
|
+
var DownloadModelResultSchema = zod.z.object({
|
|
23118
|
+
filePath: zod.z.string(),
|
|
23119
|
+
sizeMB: zod.z.number(),
|
|
23120
|
+
durationMs: zod.z.number()
|
|
23121
|
+
});
|
|
23122
|
+
/**
|
|
23123
|
+
* Wrapper carrying a single test run's result. Replaces the legacy
|
|
23124
|
+
* ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
|
|
23125
|
+
* canonical `AudioResult` from the Phase 6 output rework: one
|
|
23126
|
+
* `AudioDetection` per class above `minScore`, top-N candidates in
|
|
23127
|
+
* `debug.alternateLabels['audio-classifier']`, per-source timings in
|
|
23128
|
+
* `debug.stepTimings`. The outer `success`/`error` fields stay so the
|
|
23129
|
+
* benchmark UI can still report a clean failure when the classifier
|
|
23130
|
+
* cap isn't available.
|
|
23131
|
+
*/
|
|
23132
|
+
var AudioTestResultSchema = zod.z.object({
|
|
23133
|
+
success: zod.z.boolean(),
|
|
23134
|
+
error: zod.z.string().optional(),
|
|
23135
|
+
frame: zod.z.custom().optional()
|
|
23136
|
+
});
|
|
23137
|
+
var PipelineConfigBridge = zod.z.custom();
|
|
23138
|
+
var ConfigUISchemaBridge = zod.z.custom();
|
|
23139
|
+
var ConfigUISchemaNullableBridge = zod.z.custom();
|
|
23140
|
+
var InferenceCapabilitiesBridge = zod.z.custom();
|
|
23141
|
+
var ModelAvailabilityListBridge = zod.z.custom();
|
|
23142
|
+
var PipelineRunResultBridge = zod.z.custom();
|
|
23143
|
+
/**
|
|
23144
|
+
* Pipeline executor — detection engine + configuration + inference API.
|
|
23145
|
+
*
|
|
23146
|
+
* Merged from: pipeline-executor, pipeline-config, inference, detection-config.
|
|
23147
|
+
* Implemented by the detection-pipeline addon.
|
|
23148
|
+
*
|
|
23149
|
+
* Per-device surface (DeviceSettingsContribution + the "is detection
|
|
23150
|
+
* enabled for this camera?" toggle) lives on the paired
|
|
23151
|
+
* `detection-pipeline` cap (device-scoped, singleton, wrapper
|
|
23152
|
+
* defaultActive) — same split pattern used by stream-broker /
|
|
23153
|
+
* camera-streams and audio-analyzer / audio-analysis.
|
|
23154
|
+
*/
|
|
23155
|
+
var pipelineExecutorCapability = {
|
|
23156
|
+
name: "pipeline-executor",
|
|
23157
|
+
scope: "system",
|
|
23158
|
+
mode: "singleton",
|
|
23159
|
+
methods: {
|
|
23160
|
+
getAvailableEngines: require_sleep.method(zod.z.void(), zod.z.array(PipelineEngineChoiceSchema)),
|
|
23161
|
+
getSelectedEngine: require_sleep.method(zod.z.void(), PipelineEngineChoiceSchema),
|
|
23162
|
+
getDefaultSteps: require_sleep.method(PipelineEngineChoiceSchema, zod.z.array(PipelineDefaultStepSchema)),
|
|
23163
|
+
/**
|
|
23164
|
+
* Per-node detection-engine provisioning snapshot. Returns the live
|
|
23165
|
+
* state of the lazy runtime-provisioning machine on `nodeId`
|
|
23166
|
+
* (idle / installing / verifying / ready / failed). The UI pairs this
|
|
23167
|
+
* one-shot query with the `pipeline.engine-provisioning` live event
|
|
23168
|
+
* (emitted on every transition) to drive a per-node "engine ready?"
|
|
23169
|
+
* indicator without polling. Phase 2.
|
|
23170
|
+
*/
|
|
23171
|
+
getEngineProvisioning: require_sleep.method(zod.z.object({ nodeId: zod.z.string() }), EngineProvisioningSchema),
|
|
23172
|
+
getVideoPipelineSteps: require_sleep.method(zod.z.void(), zod.z.record(zod.z.string(), zod.z.object({
|
|
23173
|
+
modelId: zod.z.string(),
|
|
23174
|
+
settings: zod.z.record(zod.z.string(), zod.z.unknown()).readonly()
|
|
23175
|
+
}))),
|
|
23176
|
+
setVideoPipelineSteps: require_sleep.method(zod.z.object({ steps: zod.z.record(zod.z.string(), zod.z.object({
|
|
23177
|
+
modelId: zod.z.string(),
|
|
23178
|
+
settings: zod.z.record(zod.z.string(), zod.z.unknown()).readonly()
|
|
23179
|
+
})) }), zod.z.object({ success: zod.z.literal(true) }), {
|
|
23442
23180
|
kind: "mutation",
|
|
23443
23181
|
auth: "admin"
|
|
23444
23182
|
}),
|
|
23445
23183
|
/**
|
|
23446
|
-
*
|
|
23447
|
-
*
|
|
23184
|
+
* Clear THIS node's executor-side PER-DEVICE settings stores (the
|
|
23185
|
+
* per-camera step overrides the object-detection root reads via
|
|
23186
|
+
* `applyDeviceOverridesToTree`). `nodeId` is the ROUTING key — the
|
|
23187
|
+
* generated cap-router strips it (default `nodeIdMode: 'routing'`) and
|
|
23188
|
+
* dispatches to that node, so the provider method runs ON the target
|
|
23189
|
+
* node and receives no `nodeId`.
|
|
23448
23190
|
*
|
|
23449
|
-
*
|
|
23450
|
-
*
|
|
23451
|
-
*
|
|
23452
|
-
*
|
|
23191
|
+
* This is the slimmed executor leg of the orchestrator's
|
|
23192
|
+
* `resetNodePipelineDefaults` flow (which owns the real reset: node
|
|
23193
|
+
* addonDefaults pins + per-camera orchestrator overrides). The legacy
|
|
23194
|
+
* `resetToDefault` — which reset a persisted global step-tree seed
|
|
23195
|
+
* nothing in the live per-camera path read — was removed together with
|
|
23196
|
+
* that seed.
|
|
23453
23197
|
*/
|
|
23454
|
-
|
|
23455
|
-
|
|
23456
|
-
|
|
23457
|
-
}),
|
|
23198
|
+
clearDeviceOverrides: require_sleep.method(zod.z.object({ nodeId: zod.z.string() }), zod.z.object({
|
|
23199
|
+
success: zod.z.literal(true),
|
|
23200
|
+
clearedDevices: zod.z.number()
|
|
23201
|
+
}), {
|
|
23458
23202
|
kind: "mutation",
|
|
23459
23203
|
auth: "admin"
|
|
23460
23204
|
}),
|
|
23461
23205
|
/**
|
|
23462
|
-
*
|
|
23206
|
+
* Which of THIS node's inference devices the executor currently refuses,
|
|
23207
|
+
* and why. `nodeId` is the ROUTING key (stripped by the generated router).
|
|
23208
|
+
*
|
|
23209
|
+
* The channel that did not exist. Pool health was known only inside the
|
|
23210
|
+
* detection addon and was an input to no routing decision anywhere: the
|
|
23211
|
+
* per-dispatch capability gate is keyed on model FORMAT and so can never
|
|
23212
|
+
* separate `openvino:gpu` from `openvino:npu`, and the orchestrator's live
|
|
23213
|
+
* eligibility probe (`platformProbe.getCapabilities`) answers about
|
|
23214
|
+
* HARDWARE — which was present throughout. So when the hub's `openvino:gpu`
|
|
23215
|
+
* Python worker was SIGABRT'd by the Intel GPU plugin on 2026-08-25, the
|
|
23216
|
+
* balancer went on handing that dead pool cameras by rotation for 31 hours:
|
|
23217
|
+
* ~370 000 `PoolWorker[w0]: not initialized` lines, every frame lost.
|
|
23218
|
+
*
|
|
23219
|
+
* Read semantics the caller depends on, and which the provider guarantees:
|
|
23220
|
+
* this is a synchronous read of in-memory state. It never probes hardware,
|
|
23221
|
+
* never spawns a pool and never throws — an EMPTY `unhealthy` means "asked,
|
|
23222
|
+
* nothing is refused", which is what re-admits a device. A read that FAILS
|
|
23223
|
+
* (node offline, version skew) must therefore be distinguishable from an
|
|
23224
|
+
* empty answer, and it is: it rejects.
|
|
23225
|
+
*/
|
|
23226
|
+
getInferenceDeviceHealth: require_sleep.method(zod.z.object({ nodeId: zod.z.string() }), zod.z.object({ unhealthy: zod.z.array(zod.z.object({
|
|
23227
|
+
/** `<backend>:<device>`, e.g. `openvino:gpu`. */
|
|
23228
|
+
deviceKey: zod.z.string(),
|
|
23229
|
+
/**
|
|
23230
|
+
* `failed` — the per-device restart budget is exhausted; no pool
|
|
23231
|
+
* will be spawned until an operator re-arms it or the runner
|
|
23232
|
+
* respawns. `backoff` — under budget, waiting out the backoff (or
|
|
23233
|
+
* a cached pool observed dead and not yet condemned).
|
|
23234
|
+
*/
|
|
23235
|
+
state: zod.z.enum(["failed", "backoff"]),
|
|
23236
|
+
/** Epoch ms of the death that produced this state. */
|
|
23237
|
+
since: zod.z.number(),
|
|
23238
|
+
/** Pool deaths inside the current window. */
|
|
23239
|
+
deaths: zod.z.number(),
|
|
23240
|
+
/** The last death's message. */
|
|
23241
|
+
lastError: zod.z.string()
|
|
23242
|
+
})).readonly() })),
|
|
23243
|
+
/**
|
|
23244
|
+
* Re-arm a terminally `failed` inference device on `nodeId`: forget its
|
|
23245
|
+
* restart budget so the next dispatch builds a fresh pool.
|
|
23463
23246
|
*
|
|
23464
|
-
* The
|
|
23465
|
-
*
|
|
23466
|
-
*
|
|
23467
|
-
*
|
|
23468
|
-
* those annotations are LEFT ALONE: "put this back" must not be a
|
|
23469
|
-
* destructive act wearing a navigational name.
|
|
23247
|
+
* The terminal state is deliberate (the abort it bounds is deterministic —
|
|
23248
|
+
* an automatic probation would just respawn Python forever, more slowly),
|
|
23249
|
+
* and a terminal state an operator cannot leave is a silent fault. This is
|
|
23250
|
+
* the way out. `rearmed:false` means there was nothing to forget.
|
|
23470
23251
|
*/
|
|
23471
|
-
|
|
23472
|
-
|
|
23473
|
-
|
|
23474
|
-
}),
|
|
23252
|
+
rearmInferenceDevice: require_sleep.method(zod.z.object({
|
|
23253
|
+
nodeId: zod.z.string(),
|
|
23254
|
+
deviceKey: zod.z.string()
|
|
23255
|
+
}), zod.z.object({ rearmed: zod.z.boolean() }), {
|
|
23475
23256
|
kind: "mutation",
|
|
23476
23257
|
auth: "admin"
|
|
23477
23258
|
}),
|
|
23259
|
+
getSchema: require_sleep.method(zod.z.void(), PipelineSchemaSchema),
|
|
23260
|
+
getGlobalSteps: require_sleep.method(zod.z.void(), zod.z.array(PipelineDefaultStepSchema).readonly().nullable()),
|
|
23261
|
+
getGlobalPipelineConfig: require_sleep.method(zod.z.void(), PipelineConfigBridge),
|
|
23262
|
+
getOrchestratorConfigSchema: require_sleep.method(zod.z.void(), ConfigUISchemaBridge),
|
|
23478
23263
|
/**
|
|
23479
|
-
*
|
|
23264
|
+
* Gate B (pre-init config-correctness gate). PURE COMPUTE against this
|
|
23265
|
+
* node's `currentEngine.format` — resolves `steps` the same way the
|
|
23266
|
+
* runtime dispatch path would, and reports what WOULD happen without
|
|
23267
|
+
* touching any node-global state. Called by the orchestrator at attach
|
|
23268
|
+
* time (`attachOn`), node-pinned to the TARGET node, so config problems
|
|
23269
|
+
* surface BEFORE `pipelineRunner.attachCamera` rather than at the first
|
|
23270
|
+
* per-frame resolve. `ok` is false iff `issues` is non-empty (both
|
|
23271
|
+
* `unknown-addon` and `no-format-build` are HARD issues); `substitutions`
|
|
23272
|
+
* is informational (a degraded-but-loadable model swap) and never
|
|
23273
|
+
* affects `ok`. Never throws.
|
|
23480
23274
|
*
|
|
23481
|
-
*
|
|
23482
|
-
*
|
|
23483
|
-
*
|
|
23484
|
-
* subject, the canonical full-frame box AND the geometry derived for each
|
|
23485
|
-
* model shape (letterboxed root / zone-cropped package / subject-cropped
|
|
23486
|
-
* classifier). Derived at export, never stored — one box in, three shapes
|
|
23487
|
-
* out, so two crops of the same subject can never end up in one feature
|
|
23488
|
-
* space (D52).
|
|
23275
|
+
* `deviceKey` validates against THAT device pool's format instead of the
|
|
23276
|
+
* node default (D646) — the cheap question a pinned replay asks before it
|
|
23277
|
+
* reads any media: can this (node, deviceKey) run exactly this model?
|
|
23489
23278
|
*/
|
|
23490
|
-
|
|
23491
|
-
|
|
23492
|
-
|
|
23493
|
-
}),
|
|
23279
|
+
validatePipeline: require_sleep.method(zod.z.object({
|
|
23280
|
+
steps: zod.z.array(PipelineStepInputSchema),
|
|
23281
|
+
deviceKey: zod.z.string().optional()
|
|
23282
|
+
}), PipelineValidationResultSchema),
|
|
23283
|
+
listTemplates: require_sleep.method(zod.z.void(), zod.z.array(PipelineTemplateSchema$1).readonly()),
|
|
23284
|
+
saveTemplate: require_sleep.method(zod.z.object({
|
|
23285
|
+
name: zod.z.string(),
|
|
23286
|
+
steps: zod.z.array(PipelineTemplateStepSchema).readonly(),
|
|
23287
|
+
engine: PipelineEngineChoiceSchema
|
|
23288
|
+
}), PipelineTemplateSchema$1, { kind: "mutation" }),
|
|
23289
|
+
updateTemplate: require_sleep.method(zod.z.object({
|
|
23290
|
+
id: zod.z.string(),
|
|
23291
|
+
name: zod.z.string().optional(),
|
|
23292
|
+
steps: zod.z.array(PipelineTemplateStepSchema).readonly().optional()
|
|
23293
|
+
}), PipelineTemplateSchema$1, { kind: "mutation" }),
|
|
23294
|
+
deleteTemplate: require_sleep.method(zod.z.object({ id: zod.z.string() }), zod.z.void(), { kind: "mutation" }),
|
|
23295
|
+
getCapabilities: require_sleep.method(zod.z.void(), InferenceCapabilitiesBridge),
|
|
23296
|
+
getAddonModels: require_sleep.method(zod.z.object({ addonId: zod.z.string() }), ModelAvailabilityListBridge),
|
|
23297
|
+
downloadModel: require_sleep.method(zod.z.object({
|
|
23298
|
+
addonId: zod.z.string(),
|
|
23299
|
+
modelId: zod.z.string(),
|
|
23300
|
+
format: ModelFormatSchema$1
|
|
23301
|
+
}), DownloadModelResultSchema, { kind: "mutation" }),
|
|
23302
|
+
deleteModel: require_sleep.method(zod.z.object({
|
|
23303
|
+
addonId: zod.z.string(),
|
|
23304
|
+
modelId: zod.z.string(),
|
|
23305
|
+
format: ModelFormatSchema$1
|
|
23306
|
+
}), zod.z.object({ success: zod.z.literal(true) }), { kind: "mutation" }),
|
|
23494
23307
|
/**
|
|
23495
|
-
*
|
|
23308
|
+
* Stateless single-frame execution. Callers (runner, benchmark) pass
|
|
23309
|
+
* the complete `steps` tree; the executor holds no state about cameras
|
|
23310
|
+
* or saved pipelines. WHICH pool answers is the node's own engine, or the
|
|
23311
|
+
* `deviceKey` pool when one is named.
|
|
23496
23312
|
*
|
|
23497
|
-
* `
|
|
23498
|
-
*
|
|
23499
|
-
*
|
|
23500
|
-
*
|
|
23501
|
-
* audio, stopping at the first hit — so on the live hub, where object
|
|
23502
|
-
* events own no media of their own and 299 883 of 300 559 media rows are
|
|
23503
|
-
* motion-owned, EVERY object event resolved to its motion namesake. A
|
|
23504
|
-
* track from 17:34 on camera 615 was served a snapshot from 22:35 eleven
|
|
23505
|
-
* days earlier, silently.
|
|
23313
|
+
* There is no `engine` field (D646). It existed for the benchmark and was
|
|
23314
|
+
* honoured by swapping the SHARED provider's engine, factory and executor
|
|
23315
|
+
* for the duration of the call, on a node serving live cameras. A caller
|
|
23316
|
+
* that still sends the key has it stripped here and changes nothing.
|
|
23506
23317
|
*
|
|
23507
|
-
*
|
|
23508
|
-
*
|
|
23509
|
-
*
|
|
23510
|
-
*
|
|
23318
|
+
* Exactly one of `frame`, `frameRef`, `frameHandle`, `imageBase64`,
|
|
23319
|
+
* `referenceImage` must be provided:
|
|
23320
|
+
* - `frame`: runtime dispatch path (runner → decoded broker frame).
|
|
23321
|
+
* Carries the raw buffer, dimensions, and format; the executor
|
|
23322
|
+
* uses it directly without base64 round-tripping.
|
|
23323
|
+
* - `frameHandle` (CB5): a zero-pixel shm `FrameHandle` for the SAME
|
|
23324
|
+
* decoded frame. Both runner and executor are hub-local processes
|
|
23325
|
+
* sharing `/dev/shm`, so the executor maps the named segment and
|
|
23326
|
+
* reads the pixels back zero-copy — eliminating the ~1.2MB
|
|
23327
|
+
* re-serialisation over UDS/MsgPack the `frame` path pays per call.
|
|
23328
|
+
* High-risk: the FrameRing is a latest-wins seqlock with no
|
|
23329
|
+
* refcount, so a recycled slot yields a null read; the executor
|
|
23330
|
+
* then degrades to an empty result and the runner ships pixels via
|
|
23331
|
+
* `frame` as the fallback (queue-depth gated on the runner side).
|
|
23332
|
+
* - `imageBase64`: one-shot test path (benchmark ImageTab).
|
|
23333
|
+
* - `referenceImage`: named file from the reference-image store.
|
|
23511
23334
|
*/
|
|
23512
|
-
|
|
23513
|
-
|
|
23514
|
-
|
|
23515
|
-
/**
|
|
23516
|
-
|
|
23517
|
-
|
|
23518
|
-
|
|
23519
|
-
|
|
23520
|
-
|
|
23521
|
-
|
|
23522
|
-
|
|
23523
|
-
|
|
23524
|
-
|
|
23525
|
-
|
|
23526
|
-
|
|
23527
|
-
|
|
23528
|
-
|
|
23335
|
+
runPipeline: require_sleep.method(zod.z.object({
|
|
23336
|
+
steps: zod.z.array(PipelineStepInputSchema).min(1),
|
|
23337
|
+
frame: FrameInputSchema.optional(),
|
|
23338
|
+
/**
|
|
23339
|
+
* Process-local lazy frame. Valid only when caller and provider resolve
|
|
23340
|
+
* in the same execution-group process; split/cross-node callers use
|
|
23341
|
+
* `frame`/`image` inline compatibility instead.
|
|
23342
|
+
*/
|
|
23343
|
+
frameRef: FrameRefSchema.optional(),
|
|
23344
|
+
/**
|
|
23345
|
+
* CB5 shm passthrough — a `FrameHandle` naming the same ring slot
|
|
23346
|
+
* the decoded pixels live in. One more member of the one-of
|
|
23347
|
+
* frame/frameHandle/image/imageBase64/referenceImage group.
|
|
23348
|
+
*/
|
|
23349
|
+
frameHandle: require_sleep.FrameHandleSchema.optional(),
|
|
23350
|
+
imageBase64: zod.z.string().optional(),
|
|
23351
|
+
/**
|
|
23352
|
+
* Binary JPEG bytes — preferred over `imageBase64` on internal
|
|
23353
|
+
* hops (hub → forked worker via Moleculer MsgPack) because it
|
|
23354
|
+
* skips the 33% base64 overhead + the per-call base64 decode on
|
|
23355
|
+
* the detection-pipeline worker. Callers can pass either; exactly
|
|
23356
|
+
* one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
|
|
23357
|
+
*/
|
|
23358
|
+
image: zod.z.instanceof(Uint8Array).optional(),
|
|
23359
|
+
referenceImage: zod.z.string().optional(),
|
|
23360
|
+
deviceId: zod.z.number().optional(),
|
|
23361
|
+
sessionId: zod.z.string().optional(),
|
|
23362
|
+
/**
|
|
23363
|
+
* Execution plane. 'full' (default) runs the whole tree — benchmark,
|
|
23364
|
+
* reference-image, and detail-subtree calls. 'frame' is the live
|
|
23365
|
+
* per-frame dispatch: ONLY root-plane steps run; crop children
|
|
23366
|
+
* (inputClasses ≠ null) are skipped and served per-track via
|
|
23367
|
+
* pipelineRunner.runDetailSubtree (two-plane design).
|
|
23368
|
+
*/
|
|
23369
|
+
plane: zod.z.enum(["full", "frame"]).optional(),
|
|
23370
|
+
/**
|
|
23371
|
+
* Inference-device selector (Phase 2 multi-device). Format
|
|
23372
|
+
* `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
|
|
23373
|
+
* Omitted ⇒ the runner's default device (current single-engine
|
|
23374
|
+
* behaviour). Selects WHICH device pool of the node runs the call.
|
|
23375
|
+
*/
|
|
23376
|
+
deviceKey: zod.z.string().optional(),
|
|
23377
|
+
/**
|
|
23378
|
+
* Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
|
|
23379
|
+
* when the parent crop was resolved from the frame's retained NATIVE
|
|
23380
|
+
* surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
|
|
23381
|
+
* child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
|
|
23382
|
+
* resolution from that surface — the SAME quality path faces already
|
|
23383
|
+
* had — instead of the downscaled parent tile. `handle` keys the native
|
|
23384
|
+
* surface (node-pinned to its owner); `cropFrameSpace` is the parent
|
|
23385
|
+
* crop's padded/clamped rectangle in FRAME-space pixels, used to compose
|
|
23386
|
+
* the executor's crop-normalized child ROI back into frame-normalized
|
|
23387
|
+
* coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
|
|
23388
|
+
* of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
|
|
23389
|
+
* (today's behaviour on the fallback path).
|
|
23390
|
+
*/
|
|
23391
|
+
nativeCropRef: NativeCropRefSchema.optional(),
|
|
23392
|
+
/**
|
|
23393
|
+
* Offline REPLAY of stored media for `deviceId` (D56, D646): the
|
|
23394
|
+
* camera's zone gate and overrides apply as live, every executing
|
|
23395
|
+
* step runs EXACTLY the model it names on the `deviceKey` pool it
|
|
23396
|
+
* names or the call refuses (`model-not-servable` /
|
|
23397
|
+
* `device-not-servable`), and nothing reaches the camera's live
|
|
23398
|
+
* trace stream. Absent ⇒ unchanged behaviour.
|
|
23399
|
+
*/
|
|
23400
|
+
replay: zod.z.literal(true).optional()
|
|
23401
|
+
}), PipelineRunResultBridge, { kind: "mutation" }),
|
|
23529
23402
|
/**
|
|
23530
|
-
*
|
|
23531
|
-
*
|
|
23532
|
-
*
|
|
23533
|
-
*
|
|
23534
|
-
*
|
|
23535
|
-
*
|
|
23536
|
-
* ~2 KB.
|
|
23403
|
+
* Batched run — N raw frames packed into one cap call. The provider
|
|
23404
|
+
* routes the batch through `SharedInferencePool.inferBatch`
|
|
23405
|
+
* (`MSG_INFER_BATCH = 0x03`) so the IPC framing and JSON response
|
|
23406
|
+
* envelope cost is amortised N:1 vs N concurrent `runPipeline`
|
|
23407
|
+
* calls. Single root step + uniform model assumed; trees with crop
|
|
23408
|
+
* children fall back to sequential execution.
|
|
23537
23409
|
*
|
|
23538
|
-
*
|
|
23539
|
-
*
|
|
23540
|
-
* them, so a client that fetched only the small variants could no longer
|
|
23541
|
-
* tell a full-resolution variant existed — and the affordance that opens it
|
|
23542
|
-
* would silently disappear.
|
|
23410
|
+
* Used by `scripts/bench-batch-style.mts` for batch benchmarking —
|
|
23411
|
+
* N frames in one call to amortise per-call IPC overhead.
|
|
23543
23412
|
*/
|
|
23544
|
-
|
|
23545
|
-
|
|
23546
|
-
|
|
23547
|
-
|
|
23413
|
+
runPipelineBatch: require_sleep.method(zod.z.object({
|
|
23414
|
+
steps: zod.z.array(PipelineStepInputSchema).min(1),
|
|
23415
|
+
frames: zod.z.array(FrameInputSchema).min(1).max(255),
|
|
23416
|
+
deviceId: zod.z.number().optional(),
|
|
23417
|
+
sessionId: zod.z.string().optional(),
|
|
23418
|
+
/**
|
|
23419
|
+
* Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
|
|
23420
|
+
* the batch to the Python pool's bench preprocess cache
|
|
23421
|
+
* (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
|
|
23422
|
+
* preprocessed ONCE and every later inference is a pure-inference cache
|
|
23423
|
+
* hit — the sustained-throughput run measures inference, not
|
|
23424
|
+
* decode+preprocess+infer. Omitted/0 for live frames (all different →
|
|
23425
|
+
* full preprocess every call, correct). Fresh per sustained run;
|
|
23426
|
+
* released via `uncacheFrame`.
|
|
23427
|
+
*/
|
|
23428
|
+
frameId: zod.z.number().int().nonnegative().optional(),
|
|
23429
|
+
/** Inference-device selector (Phase 2 multi-device); see runPipeline. */
|
|
23430
|
+
deviceKey: zod.z.string().optional()
|
|
23431
|
+
}), zod.z.object({ results: zod.z.array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }),
|
|
23548
23432
|
/**
|
|
23549
|
-
*
|
|
23550
|
-
*
|
|
23551
|
-
*
|
|
23552
|
-
*
|
|
23553
|
-
* 5-8 MB. An event's is worse per row, not better: an old-style event owns
|
|
23554
|
-
* a `crop` AND a native-resolution `fullFrameBoxed`, and the track DETAIL
|
|
23555
|
-
* modal — the one surface that legitimately shows the big kinds — unions
|
|
23556
|
-
* both listings to build its filmstrip. It then renders every tile from
|
|
23557
|
-
* the `event-media` plane by key and throws the bytes away. Measured on
|
|
23558
|
-
* the live hub: one event's `fullFrameBoxed` is 2 824 077 B, base64'd to
|
|
23559
|
-
* ~3.8 MB, allocated whole in hub-main's heap, for a list of keys.
|
|
23560
|
-
*
|
|
23561
|
-
* Same `deviceId` authorization subject as `getEventMedia`, the same
|
|
23562
|
-
* REQUIRED `ownerType` (read that method's docblock for the night-time
|
|
23563
|
-
* thumbnail this closes — D482), and the same rows: this is a projection
|
|
23564
|
-
* of that method, never a different question.
|
|
23433
|
+
* Cache a raw frame inside the Python inference pool's memory.
|
|
23434
|
+
* Returns a numeric `frameId` that `inferCached` references —
|
|
23435
|
+
* subsequent calls send only 5 bytes through the pipe instead of
|
|
23436
|
+
* 1.2MB raw data, eliminating the pipe transfer bottleneck.
|
|
23565
23437
|
*/
|
|
23566
|
-
|
|
23567
|
-
|
|
23568
|
-
|
|
23569
|
-
|
|
23570
|
-
|
|
23438
|
+
cacheFrameInPool: require_sleep.method(zod.z.object({
|
|
23439
|
+
data: zod.z.instanceof(Uint8Array),
|
|
23440
|
+
width: zod.z.number().int().positive(),
|
|
23441
|
+
height: zod.z.number().int().positive(),
|
|
23442
|
+
format: zod.z.enum([
|
|
23443
|
+
"rgb",
|
|
23444
|
+
"bgr",
|
|
23445
|
+
"gray"
|
|
23446
|
+
])
|
|
23447
|
+
}), zod.z.object({
|
|
23448
|
+
frameId: zod.z.number(),
|
|
23449
|
+
width: zod.z.number(),
|
|
23450
|
+
height: zod.z.number()
|
|
23451
|
+
}), { kind: "mutation" }),
|
|
23571
23452
|
/**
|
|
23572
|
-
*
|
|
23573
|
-
*
|
|
23574
|
-
*
|
|
23575
|
-
* The event-media URL is stamped from a template for every event in the
|
|
23576
|
-
* system, so "the plane is up" was being served as "there are bytes": 64 of
|
|
23577
|
-
* one camera's 179 clips pointed at a 404 (device 3836, 2026-08-17). This
|
|
23578
|
-
* is the question that turns the stamp into a claim.
|
|
23579
|
-
*
|
|
23580
|
-
* It is on the WIRE because the clip source is registered by the addon that
|
|
23581
|
-
* owns the FOOTAGE, not by this one (D560) — the probe used to be an
|
|
23582
|
-
* in-process `MediaStore` read. One call per OWNER KIND, never one per
|
|
23583
|
-
* owner: that N+1 is what `MediaStore.ownersWithMedia` was written to
|
|
23584
|
-
* prevent, and crossing a process boundary makes it worse, not better.
|
|
23585
|
-
* `ownerIds` is bounded at the same 5 000 the annotation fetch is bounded
|
|
23586
|
-
* at, so one pathological camera-day cannot mint an unbounded request.
|
|
23587
|
-
*
|
|
23588
|
-
* THROWS rather than answering partially. A probe that quietly
|
|
23589
|
-
* under-reports reads as "these owners have nothing" and the caller drops
|
|
23590
|
-
* thumbnails that exist — the opposite failure to the one above, and
|
|
23591
|
-
* equally invisible.
|
|
23592
|
-
*
|
|
23593
|
-
* `deviceId` is the authorization subject, exactly as on `getEventMedia`.
|
|
23453
|
+
* Run inference on a previously cached frame. Sends only 5 bytes
|
|
23454
|
+
* (model_idx + frameId) through the IPC pipe — eliminates the
|
|
23455
|
+
* ~35ms per-call overhead of transferring 1.2MB raw data.
|
|
23594
23456
|
*/
|
|
23595
|
-
|
|
23596
|
-
|
|
23597
|
-
|
|
23598
|
-
|
|
23599
|
-
}), zod.z.array(zod.z.string()).readonly()),
|
|
23457
|
+
inferCached: require_sleep.method(zod.z.object({
|
|
23458
|
+
stepId: zod.z.string(),
|
|
23459
|
+
frameId: zod.z.number().int()
|
|
23460
|
+
}), zod.z.record(zod.z.string(), zod.z.unknown()), { kind: "mutation" }),
|
|
23600
23461
|
/**
|
|
23601
|
-
*
|
|
23602
|
-
* Encodes `text` via the `embedding-encoder` cap, queries the
|
|
23603
|
-
* `ObjectEmbeddingStore` with optional prefilters, ranks all matching
|
|
23604
|
-
* embeddings by cosine similarity, and joins winners to their
|
|
23605
|
-
* ObjectEvents by trackId. Returns up to `limit` events scored ≥
|
|
23606
|
-
* `minScore`, sorted descending by score.
|
|
23462
|
+
* Release a cached frame from the Python pool's memory.
|
|
23607
23463
|
*/
|
|
23608
|
-
|
|
23609
|
-
|
|
23464
|
+
uncacheFrame: require_sleep.method(zod.z.object({ frameId: zod.z.number().int() }), zod.z.void(), { kind: "mutation" }),
|
|
23465
|
+
/**
|
|
23466
|
+
* The effective provisioning of ONE pool of this node (operator override →
|
|
23467
|
+
* the pool's own runtime row). `deviceKey` names the device pool; absent is
|
|
23468
|
+
* the node-default pool. It answered only for the node default until
|
|
23469
|
+
* D646, so a benchmark on `openvino:npu` recorded the onnx pool's tuning
|
|
23470
|
+
* beside an NPU measurement.
|
|
23471
|
+
*/
|
|
23472
|
+
getEffectiveTuning: require_sleep.method(zod.z.object({ deviceKey: zod.z.string().optional() }), EffectiveTuningSchema),
|
|
23473
|
+
/**
|
|
23474
|
+
* List every EngineFactory currently loaded in this executor's RAM,
|
|
23475
|
+
* with the models resident and a coarse "in use" marker derived from
|
|
23476
|
+
* ongoing inference activity. Used by the Pipeline page Engines tab.
|
|
23477
|
+
*/
|
|
23478
|
+
listLoadedEngines: require_sleep.method(zod.z.void(), zod.z.array(zod.z.object({
|
|
23479
|
+
engineKey: zod.z.string(),
|
|
23480
|
+
engine: PipelineEngineChoiceSchema,
|
|
23481
|
+
modelsLoaded: zod.z.array(zod.z.string()).readonly(),
|
|
23482
|
+
inUseByCameras: zod.z.array(zod.z.number()).readonly(),
|
|
23483
|
+
/**
|
|
23484
|
+
* Origin of this resident factory.
|
|
23485
|
+
* - `runtime` — main camera-serving engine (no idle TTL).
|
|
23486
|
+
* - `device-pool` — a concurrent per-device pool (Phase 2
|
|
23487
|
+
* multi-device, keyed by `deviceKey`) resolved
|
|
23488
|
+
* via `resolveDeviceFactory`. Runs alongside the
|
|
23489
|
+
* `runtime` engine on a DIFFERENT accelerator
|
|
23490
|
+
* (NPU / iGPU / Coral) — this is how the
|
|
23491
|
+
* Engines tab shows all pools running at once.
|
|
23492
|
+
*/
|
|
23493
|
+
kind: zod.z.enum(["runtime", "device-pool"]),
|
|
23494
|
+
/** Native pid of the underlying Python pool (null when no pool). */
|
|
23495
|
+
poolPid: zod.z.number().nullable(),
|
|
23496
|
+
/** ms since this factory was last used (null when not warm-tracked). */
|
|
23497
|
+
idleMs: zod.z.number().nullable(),
|
|
23498
|
+
/** Idle TTL after which the factory self-evicts (null when not applicable). */
|
|
23499
|
+
idleTtlMs: zod.z.number().nullable()
|
|
23500
|
+
})).readonly()),
|
|
23501
|
+
/** Warm up an engine without running a frame. No-op if already loaded. */
|
|
23502
|
+
spinEngine: require_sleep.method(zod.z.object({ engine: PipelineEngineChoiceSchema }), zod.z.object({ success: zod.z.literal(true) }), {
|
|
23610
23503
|
kind: "mutation",
|
|
23611
23504
|
auth: "admin"
|
|
23612
23505
|
}),
|
|
23613
|
-
|
|
23506
|
+
/**
|
|
23507
|
+
* Unload an engine from RAM. `force:true` unloads even when cameras
|
|
23508
|
+
* are actively using it (they re-spin on next frame). Default is
|
|
23509
|
+
* gated — returns `{success:false, reason}` when in use.
|
|
23510
|
+
*/
|
|
23511
|
+
killEngine: require_sleep.method(zod.z.object({
|
|
23512
|
+
engine: PipelineEngineChoiceSchema,
|
|
23513
|
+
force: zod.z.boolean().optional()
|
|
23514
|
+
}), zod.z.object({
|
|
23515
|
+
success: zod.z.boolean(),
|
|
23516
|
+
reason: zod.z.string().optional()
|
|
23517
|
+
}), {
|
|
23614
23518
|
kind: "mutation",
|
|
23615
23519
|
auth: "admin"
|
|
23616
23520
|
}),
|
|
23617
|
-
|
|
23618
|
-
|
|
23619
|
-
|
|
23620
|
-
|
|
23621
|
-
|
|
23622
|
-
|
|
23623
|
-
|
|
23624
|
-
|
|
23625
|
-
|
|
23626
|
-
|
|
23627
|
-
|
|
23628
|
-
|
|
23629
|
-
deviceId: zod.z.number(),
|
|
23630
|
-
timestamp: zod.z.number(),
|
|
23631
|
-
frameWidth: zod.z.number(),
|
|
23632
|
-
frameHeight: zod.z.number(),
|
|
23633
|
-
detections: zod.z.array(OverlayDetectionSchema).readonly()
|
|
23634
|
-
}) },
|
|
23635
|
-
/** Track entered active state (first-seen). */
|
|
23636
|
-
onTrackStarted: { data: zod.z.object({
|
|
23637
|
-
deviceId: zod.z.number(),
|
|
23638
|
-
trackId: zod.z.string(),
|
|
23639
|
-
className: zod.z.string()
|
|
23640
|
-
}) },
|
|
23641
|
-
/** Track expired (TTL reached after last detection). */
|
|
23642
|
-
onTrackEnded: { data: zod.z.object({
|
|
23643
|
-
deviceId: zod.z.number(),
|
|
23644
|
-
trackId: zod.z.string(),
|
|
23645
|
-
className: zod.z.string(),
|
|
23646
|
-
durationMs: zod.z.number()
|
|
23647
|
-
}) },
|
|
23648
|
-
/** Canonical "something happened at device X" event, per-kind. */
|
|
23649
|
-
onDetectionEvent: { data: zod.z.object({
|
|
23650
|
-
deviceId: zod.z.number(),
|
|
23651
|
-
kind: EventKindSchema,
|
|
23652
|
-
eventId: zod.z.string(),
|
|
23653
|
-
timestamp: zod.z.number()
|
|
23654
|
-
}) }
|
|
23521
|
+
listReferenceImages: require_sleep.method(zod.z.void(), zod.z.array(ReferenceImageEntrySchema).readonly()),
|
|
23522
|
+
getReferenceImage: require_sleep.method(zod.z.object({ filename: zod.z.string() }), ReferenceImageBodySchema.nullable()),
|
|
23523
|
+
getReferenceAudioFiles: require_sleep.method(zod.z.void(), zod.z.array(ReferenceAudioEntrySchema).readonly()),
|
|
23524
|
+
getReferenceAudio: require_sleep.method(zod.z.object({ filename: zod.z.string() }), ReferenceAudioBodySchema.nullable()),
|
|
23525
|
+
getAudioCapabilities: require_sleep.method(zod.z.void(), AudioCapabilitiesSchema),
|
|
23526
|
+
runAudioTest: require_sleep.method(zod.z.object({
|
|
23527
|
+
addonId: zod.z.string(),
|
|
23528
|
+
modelId: zod.z.string(),
|
|
23529
|
+
filename: zod.z.string().optional(),
|
|
23530
|
+
settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
23531
|
+
}), AudioTestResultSchema, { kind: "mutation" }),
|
|
23532
|
+
getDetectionConfigSchema: require_sleep.method(zod.z.void(), ConfigUISchemaNullableBridge)
|
|
23655
23533
|
}
|
|
23656
23534
|
};
|
|
23657
23535
|
//#endregion
|
|
@@ -23682,6 +23560,108 @@ var CameraMetricsSchema = zod.z.object({
|
|
|
23682
23560
|
});
|
|
23683
23561
|
var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: zod.z.number() });
|
|
23684
23562
|
//#endregion
|
|
23563
|
+
//#region src/capabilities/zones.cap.ts
|
|
23564
|
+
/**
|
|
23565
|
+
* Zone — pure geometry + identity. NO filtering behaviour.
|
|
23566
|
+
*
|
|
23567
|
+
* Zones describe **where** in the frame the operator wants to flag
|
|
23568
|
+
* something; consumer-owned {@link ZoneRule} arrays describe **how**
|
|
23569
|
+
* each pipeline stage uses them. Splitting the two means a single
|
|
23570
|
+
* polygon "Driveway" can simultaneously back a motion-exclude rule,
|
|
23571
|
+
* a detection-include rule on `['car']`, and an occupancy aggregate
|
|
23572
|
+
* — without three duplicated polygons.
|
|
23573
|
+
*
|
|
23574
|
+
* Owned by the orchestrator addon (provider) and mirrored into the
|
|
23575
|
+
* `zones` device-state slice on every mutation. Consumers
|
|
23576
|
+
* (motion-wasm, pipeline-executor, analytics, admin UI) read either
|
|
23577
|
+
* via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
|
|
23578
|
+
* mirror with `onChanged`).
|
|
23579
|
+
*
|
|
23580
|
+
* Coordinates are normalised fractions of the frame (0–1) so zones
|
|
23581
|
+
* survive resolution changes and stream profile switches.
|
|
23582
|
+
*
|
|
23583
|
+
* `kind` discriminates between full polygons (closed regions used
|
|
23584
|
+
* for intrusion / occupancy filters) and tripwires (open 2-point
|
|
23585
|
+
* line segments used for cross events). Onboard / firmware-reported
|
|
23586
|
+
* zones (Reolink, ONVIF) are out of scope for now — see the deferred
|
|
23587
|
+
* task list.
|
|
23588
|
+
*/
|
|
23589
|
+
var ZoneKindEnum = zod.z.enum(["polygon", "tripwire"]);
|
|
23590
|
+
/** Polygon vertex in fraction-of-frame coordinates (0–1). */
|
|
23591
|
+
var PolygonPointSchema = zod.z.object({
|
|
23592
|
+
x: zod.z.number(),
|
|
23593
|
+
y: zod.z.number()
|
|
23594
|
+
});
|
|
23595
|
+
/** A camera detection zone — pure geometry/identity. */
|
|
23596
|
+
var ZoneSchema = zod.z.object({
|
|
23597
|
+
id: zod.z.string(),
|
|
23598
|
+
name: zod.z.string(),
|
|
23599
|
+
kind: ZoneKindEnum.default("polygon"),
|
|
23600
|
+
/** Polygon vertices, fraction of frame (0–1). */
|
|
23601
|
+
polygon: zod.z.array(PolygonPointSchema).readonly(),
|
|
23602
|
+
/** Visual color for UI rendering. */
|
|
23603
|
+
color: zod.z.string().default("#3b82f6")
|
|
23604
|
+
});
|
|
23605
|
+
/**
|
|
23606
|
+
* Zones capability — per-camera CRUD over polygon detection zones.
|
|
23607
|
+
*
|
|
23608
|
+
* Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
|
|
23609
|
+
* to per-device settings and mirrors into the `zones` device-state
|
|
23610
|
+
* slice on every mutation, so downstream consumers can subscribe via
|
|
23611
|
+
* `dev.state.zones.onChanged`.
|
|
23612
|
+
*
|
|
23613
|
+
* The cap surface only handles geometry + identity; filtering
|
|
23614
|
+
* behaviour (per-class, include/exclude, threshold) lives in the
|
|
23615
|
+
* consumer addons' rule arrays — see `ZoneRuleSchema` exported from
|
|
23616
|
+
* `capabilities/schemas/zone-rule.js`.
|
|
23617
|
+
*/
|
|
23618
|
+
var zonesCapability = {
|
|
23619
|
+
name: "zones",
|
|
23620
|
+
scope: "device",
|
|
23621
|
+
mode: "singleton",
|
|
23622
|
+
deviceTypes: [require_sleep.DeviceType.Camera],
|
|
23623
|
+
methods: {
|
|
23624
|
+
listZones: require_sleep.method(zod.z.object({ deviceId: zod.z.number() }), zod.z.array(ZoneSchema).readonly()),
|
|
23625
|
+
addZone: require_sleep.method(zod.z.object({
|
|
23626
|
+
deviceId: zod.z.number(),
|
|
23627
|
+
zone: ZoneSchema
|
|
23628
|
+
}), zod.z.void(), {
|
|
23629
|
+
kind: "mutation",
|
|
23630
|
+
auth: "admin"
|
|
23631
|
+
}),
|
|
23632
|
+
removeZone: require_sleep.method(zod.z.object({
|
|
23633
|
+
deviceId: zod.z.number(),
|
|
23634
|
+
zoneId: zod.z.string()
|
|
23635
|
+
}), zod.z.void(), {
|
|
23636
|
+
kind: "mutation",
|
|
23637
|
+
auth: "admin"
|
|
23638
|
+
}),
|
|
23639
|
+
updateZone: require_sleep.method(zod.z.object({
|
|
23640
|
+
deviceId: zod.z.number(),
|
|
23641
|
+
zone: ZoneSchema
|
|
23642
|
+
}), zod.z.void(), {
|
|
23643
|
+
kind: "mutation",
|
|
23644
|
+
auth: "admin"
|
|
23645
|
+
})
|
|
23646
|
+
},
|
|
23647
|
+
/**
|
|
23648
|
+
* Runtime-state slice — the live zone catalogue mirrored by the
|
|
23649
|
+
* orchestrator on every CRUD mutation. Consumers read via
|
|
23650
|
+
* `device.state.zones.value` / `.watch(...)` without round-tripping
|
|
23651
|
+
* the cap, and the codegen DeviceProxy auto-wires the reactive
|
|
23652
|
+
* handle. Slice shape is `{ zones: Zone[] }` so future extensions
|
|
23653
|
+
* (e.g. zone groupings) can sit alongside the polygon list.
|
|
23654
|
+
*/
|
|
23655
|
+
runtimeState: zod.z.object({ zones: zod.z.array(ZoneSchema).readonly() }),
|
|
23656
|
+
/**
|
|
23657
|
+
* 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.
|
|
23658
|
+
*
|
|
23659
|
+
* See `RuntimeStateDurability`. Enforced by
|
|
23660
|
+
* `scripts/check-runtime-state-durability.ts`.
|
|
23661
|
+
*/
|
|
23662
|
+
durability: "restored"
|
|
23663
|
+
};
|
|
23664
|
+
//#endregion
|
|
23685
23665
|
//#region src/capabilities/pipeline-runner.cap.ts
|
|
23686
23666
|
/**
|
|
23687
23667
|
* A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
|
|
@@ -23870,7 +23850,17 @@ var DetailResultSchema = zod.z.object({
|
|
|
23870
23850
|
/** Face short side (px) measured on the NATIVE crop surface. The `bbox`
|
|
23871
23851
|
* above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
|
|
23872
23852
|
* consumers MUST prefer this when present (2026-07-22 native-gate fix). */
|
|
23873
|
-
nativeFaceShortSidePx: zod.z.number().optional()
|
|
23853
|
+
nativeFaceShortSidePx: zod.z.number().optional(),
|
|
23854
|
+
/**
|
|
23855
|
+
* The five facial landmarks of a `face` detail, in the SAME frame space as
|
|
23856
|
+
* `bbox` (D644). Additive and optional: post-analysis stores them beside the
|
|
23857
|
+
* face's source frame so a future alignment can be re-derived exactly; a
|
|
23858
|
+
* runner that predates the field sends none and the face is stored without.
|
|
23859
|
+
*/
|
|
23860
|
+
landmarks: zod.z.array(zod.z.object({
|
|
23861
|
+
x: zod.z.number(),
|
|
23862
|
+
y: zod.z.number()
|
|
23863
|
+
})).optional()
|
|
23874
23864
|
});
|
|
23875
23865
|
/**
|
|
23876
23866
|
* Why an executing node REFUSED a stateless step run (`runStatelessStep`).
|
|
@@ -37114,7 +37104,7 @@ var HardwareInfoSchema = zod.z.object({
|
|
|
37114
37104
|
coral: CoralInfoSchema.nullable().optional()
|
|
37115
37105
|
});
|
|
37116
37106
|
var PlatformScoreSchema = zod.z.object({
|
|
37117
|
-
runtime: zod.z.
|
|
37107
|
+
runtime: zod.z.literal("python"),
|
|
37118
37108
|
backend: zod.z.string(),
|
|
37119
37109
|
format: zod.z.enum([
|
|
37120
37110
|
"onnx",
|
|
@@ -37151,7 +37141,7 @@ var ModelRequirementSchema = zod.z.object({
|
|
|
37151
37141
|
});
|
|
37152
37142
|
var ResolvedInferenceConfigSchema = zod.z.object({
|
|
37153
37143
|
modelId: zod.z.string(),
|
|
37154
|
-
runtime: zod.z.
|
|
37144
|
+
runtime: zod.z.literal("python"),
|
|
37155
37145
|
backend: zod.z.string(),
|
|
37156
37146
|
format: ModelFormatSchema,
|
|
37157
37147
|
reason: zod.z.string()
|
|
@@ -40809,6 +40799,98 @@ var sceneMonitorCapability = {
|
|
|
40809
40799
|
durability: "session"
|
|
40810
40800
|
};
|
|
40811
40801
|
//#endregion
|
|
40802
|
+
//#region src/capabilities/schemas/zone-rule.ts
|
|
40803
|
+
/**
|
|
40804
|
+
* Per-stage gating mode applied to the zones a rule references.
|
|
40805
|
+
*
|
|
40806
|
+
* - `include`: the rule contributes to a **whitelist** for its stage.
|
|
40807
|
+
* When at least one `include` rule fires for a stage, only entities
|
|
40808
|
+
* inside one of those zones pass that stage.
|
|
40809
|
+
* - `exclude`: the rule contributes to a **blacklist** for its stage.
|
|
40810
|
+
* Entities inside one of those zones are dropped at that stage.
|
|
40811
|
+
*
|
|
40812
|
+
* `monitor`-style observation (count without filtering) is not a rule
|
|
40813
|
+
* mode — zones without any matching rule are observed naturally by
|
|
40814
|
+
* `zone-analytics` (live snapshot + history), so an "I just want to
|
|
40815
|
+
* count, not filter" use case needs no rule at all.
|
|
40816
|
+
*/
|
|
40817
|
+
var ZoneRuleModeEnum = zod.z.enum(["include", "exclude"]);
|
|
40818
|
+
/**
|
|
40819
|
+
* Per-consumer rule that references existing zones (geometry) and
|
|
40820
|
+
* defines how a specific pipeline stage should treat them. Each
|
|
40821
|
+
* consumer addon owns its own `ZoneRule[]` array in its per-device
|
|
40822
|
+
* settings:
|
|
40823
|
+
*
|
|
40824
|
+
* - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
|
|
40825
|
+
* - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
|
|
40826
|
+
* - future: notification rules, audio gating, etc.
|
|
40827
|
+
*
|
|
40828
|
+
* One rule applies to N zones (`zoneIds[]`) so the operator can
|
|
40829
|
+
* express "ignore motion in ALL of {garden, street}" with a single
|
|
40830
|
+
* rule. `classFilter` narrows the rule to specific object classes —
|
|
40831
|
+
* "drop person detections in the street, but keep cars" is one
|
|
40832
|
+
* `exclude` rule with `classFilter: ['person']`.
|
|
40833
|
+
*
|
|
40834
|
+
* `enabled` is a soft toggle — the operator can keep the rule
|
|
40835
|
+
* configured but inert without deleting it.
|
|
40836
|
+
*/
|
|
40837
|
+
var ZoneRuleSchema = zod.z.object({
|
|
40838
|
+
/** Stable rule id — survives edits, used by the UI for diffing. */
|
|
40839
|
+
id: zod.z.string(),
|
|
40840
|
+
/** Optional human-readable label rendered in the rule editor. */
|
|
40841
|
+
name: zod.z.string().optional(),
|
|
40842
|
+
/** Zones this rule targets. The rule's `mode` applies to ALL
|
|
40843
|
+
* listed zones (OR-set: a detection in any one of them counts).
|
|
40844
|
+
* At least one zone id required — a rule with no targets is a
|
|
40845
|
+
* configuration mistake and the form validator rejects it. */
|
|
40846
|
+
zoneIds: zod.z.array(zod.z.string()).min(1).readonly(),
|
|
40847
|
+
mode: ZoneRuleModeEnum,
|
|
40848
|
+
/**
|
|
40849
|
+
* Class names this rule applies to. Empty / undefined ⇒ rule
|
|
40850
|
+
* applies to every class. Class strings match the `macroClass`
|
|
40851
|
+
* field on detections (e.g. `person`, `car`, `dog`).
|
|
40852
|
+
*/
|
|
40853
|
+
classFilter: zod.z.array(zod.z.string()).readonly().optional(),
|
|
40854
|
+
/**
|
|
40855
|
+
* Minimum bbox/mask overlap (0–1) with any of the rule's zones
|
|
40856
|
+
* required to consider an entity "in the zone". Defaults to the
|
|
40857
|
+
* consumer's stage default when omitted. Kept for back-compat with
|
|
40858
|
+
* existing per-rule overrides; new operators pick the value via
|
|
40859
|
+
* `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
|
|
40860
|
+
* set, the lower-level engine reads it as a 0–1 fraction.
|
|
40861
|
+
*/
|
|
40862
|
+
overlapThreshold: zod.z.number().min(0).max(1).optional(),
|
|
40863
|
+
/**
|
|
40864
|
+
* Operator-friendly version of `overlapThreshold` — the percentage
|
|
40865
|
+
* of the detection's bbox that must lie inside the zone for the
|
|
40866
|
+
* rule to match. Documented default is 85%; the engine substitutes
|
|
40867
|
+
* that when the field is omitted (kept optional so existing rules
|
|
40868
|
+
* stored without it stay valid).
|
|
40869
|
+
*
|
|
40870
|
+
* When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
|
|
40871
|
+
* rule, the engine prefers `bboxInclusionPct` because it's the
|
|
40872
|
+
* field exposed in the UI. Internally both feed the same gate.
|
|
40873
|
+
*/
|
|
40874
|
+
bboxInclusionPct: zod.z.number().min(0).max(100).optional(),
|
|
40875
|
+
/**
|
|
40876
|
+
* When `true` and a detection has a segmentation mask, use the
|
|
40877
|
+
* mask for overlap instead of the bbox. Detection-stage only;
|
|
40878
|
+
* motion rules ignore this field.
|
|
40879
|
+
*/
|
|
40880
|
+
preferMask: zod.z.boolean().optional(),
|
|
40881
|
+
/**
|
|
40882
|
+
* Soft-toggle: `false` disables the rule without deleting it.
|
|
40883
|
+
* Defaults to `true` so operators creating a rule via the UI
|
|
40884
|
+
* see it active immediately.
|
|
40885
|
+
*/
|
|
40886
|
+
enabled: zod.z.boolean().default(true)
|
|
40887
|
+
});
|
|
40888
|
+
/**
|
|
40889
|
+
* Convenience array schema — used by addon device-settings
|
|
40890
|
+
* contributions and runtime payloads (e.g. `RunnerCameraConfig`).
|
|
40891
|
+
*/
|
|
40892
|
+
var ZoneRulesArraySchema = zod.z.array(ZoneRuleSchema).readonly();
|
|
40893
|
+
//#endregion
|
|
40812
40894
|
//#region src/capabilities/script-runner.cap.ts
|
|
40813
40895
|
/**
|
|
40814
40896
|
* Script-runner cap. Models HA `script.*` entities on
|
|
@@ -53096,6 +53178,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
53096
53178
|
addonId: null,
|
|
53097
53179
|
access: "view"
|
|
53098
53180
|
},
|
|
53181
|
+
"notificationRules.previewStateSummary": {
|
|
53182
|
+
capName: "notification-rules",
|
|
53183
|
+
capScope: "system",
|
|
53184
|
+
addonId: null,
|
|
53185
|
+
access: "view"
|
|
53186
|
+
},
|
|
53099
53187
|
"notificationRules.previewTemplate": {
|
|
53100
53188
|
capName: "notification-rules",
|
|
53101
53189
|
capScope: "system",
|
|
@@ -53672,12 +53760,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
53672
53760
|
addonId: null,
|
|
53673
53761
|
access: "create"
|
|
53674
53762
|
},
|
|
53675
|
-
"pipelineAnalytics.runReplayFrameProcessor": {
|
|
53676
|
-
capName: "pipeline-analytics",
|
|
53677
|
-
capScope: "device",
|
|
53678
|
-
addonId: null,
|
|
53679
|
-
access: "create"
|
|
53680
|
-
},
|
|
53681
53763
|
"pipelineAnalytics.saveRetrainAnnotations": {
|
|
53682
53764
|
capName: "pipeline-analytics",
|
|
53683
53765
|
capScope: "device",
|
|
@@ -58106,11 +58188,6 @@ var METHOD_DEVICE_SELECTORS = Object.freeze({
|
|
|
58106
58188
|
form: "single",
|
|
58107
58189
|
optional: false
|
|
58108
58190
|
}],
|
|
58109
|
-
"pipelineAnalytics.runReplayFrameProcessor": [{
|
|
58110
|
-
name: "deviceId",
|
|
58111
|
-
form: "single",
|
|
58112
|
-
optional: false
|
|
58113
|
-
}],
|
|
58114
58191
|
"pipelineAnalytics.saveRetrainAnnotations": [{
|
|
58115
58192
|
name: "deviceId",
|
|
58116
58193
|
form: "single",
|
|
@@ -61718,18 +61795,38 @@ var WEEKDAY_TO_DAY = {
|
|
|
61718
61795
|
Fri: 5,
|
|
61719
61796
|
Sat: 6
|
|
61720
61797
|
};
|
|
61721
|
-
/**
|
|
61722
|
-
*
|
|
61723
|
-
function
|
|
61724
|
-
|
|
61725
|
-
|
|
61726
|
-
|
|
61798
|
+
/**
|
|
61799
|
+
* One formatter per timezone, built once (D647 review I4). Constructing an
|
|
61800
|
+
* `Intl.DateTimeFormat` is the expensive part of this function, and a caller
|
|
61801
|
+
* that asks about many instants — a window scan — used to build one per
|
|
61802
|
+
* instant. `null` = an invalid IANA name (the host timezone is used).
|
|
61803
|
+
*/
|
|
61804
|
+
var FORMATTERS = /* @__PURE__ */ new Map();
|
|
61805
|
+
function formatterFor(timezone) {
|
|
61806
|
+
const held = FORMATTERS.get(timezone);
|
|
61807
|
+
if (held !== void 0) return held;
|
|
61808
|
+
let made;
|
|
61809
|
+
try {
|
|
61810
|
+
made = new Intl.DateTimeFormat("en-US", {
|
|
61727
61811
|
timeZone: timezone,
|
|
61728
61812
|
weekday: "short",
|
|
61729
61813
|
hour: "numeric",
|
|
61730
61814
|
minute: "numeric",
|
|
61731
61815
|
hourCycle: "h23"
|
|
61732
|
-
})
|
|
61816
|
+
});
|
|
61817
|
+
} catch {
|
|
61818
|
+
made = null;
|
|
61819
|
+
}
|
|
61820
|
+
FORMATTERS.set(timezone, made);
|
|
61821
|
+
return made;
|
|
61822
|
+
}
|
|
61823
|
+
/** Resolve (weekday, minute-of-day) of `atMs` in the schedule's timezone.
|
|
61824
|
+
* An invalid/unknown IANA name falls back to the host timezone. */
|
|
61825
|
+
function localDayMinute(atMs, timezone) {
|
|
61826
|
+
const d = new Date(atMs);
|
|
61827
|
+
const formatter = timezone !== void 0 ? formatterFor(timezone) : null;
|
|
61828
|
+
if (formatter !== null) try {
|
|
61829
|
+
const parts = formatter.formatToParts(d);
|
|
61733
61830
|
let weekday;
|
|
61734
61831
|
let hour;
|
|
61735
61832
|
let minute;
|
|
@@ -61916,6 +62013,119 @@ var DEVICE_EVENTS = [
|
|
|
61916
62013
|
"detection-blind",
|
|
61917
62014
|
...ALARM
|
|
61918
62015
|
];
|
|
62016
|
+
/** Every kind a summary may speak about — the two summarisable families. */
|
|
62017
|
+
var SUMMARISABLE = [...systemEventKindsOfFamily("device-events"), ...systemEventKindsOfFamily("system")];
|
|
62018
|
+
/** One per summary SECTION (`NC_STATE_SUMMARY_SECTIONS` in the notification
|
|
62019
|
+
* centre): the section's lines, offered when one of its kinds is selected. */
|
|
62020
|
+
var STATE_SUMMARY_SECTION_VARS = [
|
|
62021
|
+
{
|
|
62022
|
+
name: "summaryDevices",
|
|
62023
|
+
label: "Summary: devices offline / switched off",
|
|
62024
|
+
example: "Garage — offline since 07:12",
|
|
62025
|
+
kinds: [
|
|
62026
|
+
"device-offline",
|
|
62027
|
+
"device-online",
|
|
62028
|
+
"device-disabled",
|
|
62029
|
+
"device-enabled"
|
|
62030
|
+
]
|
|
62031
|
+
},
|
|
62032
|
+
{
|
|
62033
|
+
name: "summaryStreams",
|
|
62034
|
+
label: "Summary: streams offline",
|
|
62035
|
+
example: "Ingresso (high) — since 06:40",
|
|
62036
|
+
kinds: ["stream-offline", "stream-online"]
|
|
62037
|
+
},
|
|
62038
|
+
{
|
|
62039
|
+
name: "summaryBattery",
|
|
62040
|
+
label: "Summary: low batteries",
|
|
62041
|
+
example: "Sensore porta — 8 %",
|
|
62042
|
+
kinds: BATTERY
|
|
62043
|
+
},
|
|
62044
|
+
{
|
|
62045
|
+
name: "summaryConsumables",
|
|
62046
|
+
label: "Summary: consumables",
|
|
62047
|
+
example: "Robot — filter 10 %",
|
|
62048
|
+
kinds: CONSUMABLE
|
|
62049
|
+
},
|
|
62050
|
+
{
|
|
62051
|
+
name: "summaryTanks",
|
|
62052
|
+
label: "Summary: tanks",
|
|
62053
|
+
example: "Robot — clean water low",
|
|
62054
|
+
kinds: TANK
|
|
62055
|
+
},
|
|
62056
|
+
{
|
|
62057
|
+
name: "summaryDetection",
|
|
62058
|
+
label: "Summary: cameras detecting nothing",
|
|
62059
|
+
example: "Ingresso — since 05:10",
|
|
62060
|
+
kinds: ["detection-blind"]
|
|
62061
|
+
},
|
|
62062
|
+
{
|
|
62063
|
+
name: "summaryNodes",
|
|
62064
|
+
label: "Summary: nodes",
|
|
62065
|
+
example: "little-unraid — offline since 03:00",
|
|
62066
|
+
kinds: [
|
|
62067
|
+
"node-offline",
|
|
62068
|
+
"node-online",
|
|
62069
|
+
"node-inference-unavailable"
|
|
62070
|
+
]
|
|
62071
|
+
},
|
|
62072
|
+
{
|
|
62073
|
+
name: "summaryAddons",
|
|
62074
|
+
label: "Summary: addons",
|
|
62075
|
+
example: "@camstack/addon-recorder 1.2.3 → 1.2.4",
|
|
62076
|
+
kinds: [
|
|
62077
|
+
"addon-crash-loop",
|
|
62078
|
+
"addon-update-available",
|
|
62079
|
+
"addon-updated"
|
|
62080
|
+
]
|
|
62081
|
+
},
|
|
62082
|
+
{
|
|
62083
|
+
name: "summaryUpdates",
|
|
62084
|
+
label: "Summary: server & container updates",
|
|
62085
|
+
example: "server 1.2.377 → 1.2.378",
|
|
62086
|
+
kinds: [
|
|
62087
|
+
"server-update-available",
|
|
62088
|
+
"server-updated",
|
|
62089
|
+
"wrapper-update-available"
|
|
62090
|
+
]
|
|
62091
|
+
}
|
|
62092
|
+
];
|
|
62093
|
+
var STATE_SUMMARY_VARS = [
|
|
62094
|
+
{
|
|
62095
|
+
name: "summaryText",
|
|
62096
|
+
label: "Summary: every section",
|
|
62097
|
+
description: "One block per section with something to report, one line per item.",
|
|
62098
|
+
example: "Batterie scariche: Sensore porta — 8 %",
|
|
62099
|
+
group: "system",
|
|
62100
|
+
families: ["rule"],
|
|
62101
|
+
fields: [...RULE_TEXT],
|
|
62102
|
+
kinds: ["system"],
|
|
62103
|
+
systemEventKinds: [...SUMMARISABLE],
|
|
62104
|
+
systemEventDeliveries: ["summary"]
|
|
62105
|
+
},
|
|
62106
|
+
{
|
|
62107
|
+
name: "summaryCount",
|
|
62108
|
+
label: "Summary: items reported",
|
|
62109
|
+
example: "3",
|
|
62110
|
+
group: "system",
|
|
62111
|
+
families: ["rule"],
|
|
62112
|
+
fields: [...RULE_TEXT],
|
|
62113
|
+
kinds: ["system"],
|
|
62114
|
+
systemEventKinds: [...SUMMARISABLE],
|
|
62115
|
+
systemEventDeliveries: ["summary"]
|
|
62116
|
+
},
|
|
62117
|
+
...STATE_SUMMARY_SECTION_VARS.map((v) => ({
|
|
62118
|
+
name: v.name,
|
|
62119
|
+
label: v.label,
|
|
62120
|
+
example: v.example,
|
|
62121
|
+
group: "system",
|
|
62122
|
+
families: ["rule"],
|
|
62123
|
+
fields: [...RULE_TEXT],
|
|
62124
|
+
kinds: ["system"],
|
|
62125
|
+
systemEventKinds: [...v.kinds],
|
|
62126
|
+
systemEventDeliveries: ["summary"]
|
|
62127
|
+
}))
|
|
62128
|
+
];
|
|
61919
62129
|
var NC_TEMPLATE_VARS = [
|
|
61920
62130
|
{
|
|
61921
62131
|
name: "camera",
|
|
@@ -62166,7 +62376,8 @@ var NC_TEMPLATE_VARS = [
|
|
|
62166
62376
|
group: "system",
|
|
62167
62377
|
families: ["rule"],
|
|
62168
62378
|
fields: [...RULE_TEXT],
|
|
62169
|
-
kinds: ["system"]
|
|
62379
|
+
kinds: ["system"],
|
|
62380
|
+
systemEventDeliveries: ["instant"]
|
|
62170
62381
|
},
|
|
62171
62382
|
{
|
|
62172
62383
|
name: "deviceName",
|
|
@@ -62609,7 +62820,8 @@ var NC_TEMPLATE_VARS = [
|
|
|
62609
62820
|
group: "digest",
|
|
62610
62821
|
families: ["summary"],
|
|
62611
62822
|
fields: [...RULE_TEXT]
|
|
62612
|
-
}
|
|
62823
|
+
},
|
|
62824
|
+
...STATE_SUMMARY_VARS
|
|
62613
62825
|
];
|
|
62614
62826
|
/**
|
|
62615
62827
|
* System-event kinds the SERVED catalog holds back (D642): the kinds the hub
|
|
@@ -62638,11 +62850,32 @@ var NC_TEMPLATE_HELD_BACK_SYSTEM_EVENT_KINDS = [
|
|
|
62638
62850
|
* rule an installed viewer can author, which is exactly true.
|
|
62639
62851
|
*/
|
|
62640
62852
|
function servedTemplateVars() {
|
|
62641
|
-
return NC_TEMPLATE_VARS.map((d) => d.systemEventKinds === void 0 ? d : {
|
|
62853
|
+
return NC_TEMPLATE_VARS.filter((d) => !isHeldBackTemplateVar(d)).map((d) => d.systemEventKinds === void 0 ? d : {
|
|
62642
62854
|
...d,
|
|
62643
62855
|
systemEventKinds: d.systemEventKinds.filter((kind) => !NC_TEMPLATE_HELD_BACK_SYSTEM_EVENT_KINDS.includes(kind))
|
|
62644
62856
|
});
|
|
62645
62857
|
}
|
|
62858
|
+
/**
|
|
62859
|
+
* Is this descriptor held back from the SERVED catalog as a whole (D647)?
|
|
62860
|
+
* A summary-only variable is: an installed viewer does not read the delivery
|
|
62861
|
+
* axis, and would offer it on every instant system rule. The admin, built
|
|
62862
|
+
* from the workspace, restores it from its own `NC_TEMPLATE_VARS`.
|
|
62863
|
+
*/
|
|
62864
|
+
function isHeldBackTemplateVar(d) {
|
|
62865
|
+
return d.systemEventDeliveries !== void 0 && !d.systemEventDeliveries.includes("instant");
|
|
62866
|
+
}
|
|
62867
|
+
/**
|
|
62868
|
+
* Does a descriptor have a value on a system rule of this DELIVERY (D647)?
|
|
62869
|
+
* Read only for a system rule kind. An absent axis is `instant` for a
|
|
62870
|
+
* descriptor that names `systemEventKinds` (a per-event fact: a summary row
|
|
62871
|
+
* has no one device, node or package) and BOTH for one that does not
|
|
62872
|
+
* (`{{rule}}`, `{{time}}`).
|
|
62873
|
+
*/
|
|
62874
|
+
function templateVarDeliveryApplies(d, ctx) {
|
|
62875
|
+
if (!isSystemRuleKind(ctx.kind)) return true;
|
|
62876
|
+
const mode = ctx.systemEventDelivery ?? "instant";
|
|
62877
|
+
return (d.systemEventDeliveries ?? (d.systemEventKinds !== void 0 ? ["instant"] : [mode])).includes(mode);
|
|
62878
|
+
}
|
|
62646
62879
|
/** The caption fields see a fixed, smaller vocabulary (`timelapsePreviewText`,
|
|
62647
62880
|
* `summaryCaptionText`). Declared here rather than as `fields` on every
|
|
62648
62881
|
* descriptor so the whole rule stays in one line of code. */
|
|
@@ -62707,13 +62940,122 @@ function templateVarsFor(ctx) {
|
|
|
62707
62940
|
const allowed = CAPTION_VARS[ctx.field];
|
|
62708
62941
|
return NC_TEMPLATE_VARS.filter((d) => d.families.includes(ctx.family) && allowed.includes(d.name) && d.dynamic === void 0);
|
|
62709
62942
|
}
|
|
62710
|
-
return NC_TEMPLATE_VARS.filter((d) => d.families.includes(ctx.family) && onAxis(d.fields, ctx.field) && templateVarKindApplies(d.kinds, ctx.kind) && onAxis(d.deliveries, ctx.delivery) && templateVarSystemEventApplies(d, ctx));
|
|
62943
|
+
return NC_TEMPLATE_VARS.filter((d) => d.families.includes(ctx.family) && onAxis(d.fields, ctx.field) && templateVarKindApplies(d.kinds, ctx.kind) && onAxis(d.deliveries, ctx.delivery) && templateVarSystemEventApplies(d, ctx) && templateVarDeliveryApplies(d, ctx));
|
|
62711
62944
|
}
|
|
62712
62945
|
/** True when `name` is supplied in `ctx`, dynamic families (`count_<class>`) included. */
|
|
62713
62946
|
function isKnownTemplateVar(name, ctx) {
|
|
62714
62947
|
return templateVarsFor(ctx).some((d) => d.dynamic !== void 0 ? name.startsWith(d.dynamic.prefix) && name.length > d.dynamic.prefix.length : d.name === name);
|
|
62715
62948
|
}
|
|
62716
62949
|
//#endregion
|
|
62950
|
+
//#region src/notification/system-event-summary.ts
|
|
62951
|
+
/** The families a rule may summarise. The alarm is not one of them. */
|
|
62952
|
+
var NC_SYSTEM_EVENT_SUMMARY_FAMILIES = ["device-events", "system"];
|
|
62953
|
+
/** The summary's schedule, or `null` for any rule that is not a summary system rule. */
|
|
62954
|
+
function systemEventSummaryScheduleOf(rule) {
|
|
62955
|
+
if (!isSystemDelivery(rule.delivery)) return null;
|
|
62956
|
+
const delivery = rule.systemEventDelivery;
|
|
62957
|
+
return delivery?.mode === "summary" ? delivery.schedule : null;
|
|
62958
|
+
}
|
|
62959
|
+
/** Absent and `instant` are the same answer: a notification per event. */
|
|
62960
|
+
function isSystemEventSummaryRule(rule) {
|
|
62961
|
+
return systemEventSummaryScheduleOf(rule) !== null;
|
|
62962
|
+
}
|
|
62963
|
+
function actionsAreSet(actions) {
|
|
62964
|
+
return (actions?.onTrigger?.length ?? 0) > 0 || (actions?.buttons?.length ?? 0) > 0;
|
|
62965
|
+
}
|
|
62966
|
+
/**
|
|
62967
|
+
* Why the hub refuses this rule's delivery. Empty = accepted. An instant rule
|
|
62968
|
+
* (absent or `{ mode: 'instant' }`) is never refused here.
|
|
62969
|
+
*
|
|
62970
|
+
* Beside a summary, two fields are refused because they would do nothing:
|
|
62971
|
+
* the rule's own `schedule` (the summary's schedule is the send time; a second
|
|
62972
|
+
* active-hours gate would silently empty it) and `actions` (a summary is not a
|
|
62973
|
+
* match, so nothing would ever run them).
|
|
62974
|
+
*/
|
|
62975
|
+
function systemEventDeliveryProblems(rule) {
|
|
62976
|
+
if (rule.systemEventDelivery?.mode !== "summary") return [];
|
|
62977
|
+
if (!isSystemDelivery(rule.delivery)) return [{
|
|
62978
|
+
code: "not-a-system-rule",
|
|
62979
|
+
delivery: rule.delivery
|
|
62980
|
+
}];
|
|
62981
|
+
const problems = [];
|
|
62982
|
+
const verdict = systemEventFamilyOf(rule.conditions.systemEvent?.kinds ?? []);
|
|
62983
|
+
const family = verdict.kind === "family" ? verdict.family : "mixed";
|
|
62984
|
+
if (family === "mixed" || !NC_SYSTEM_EVENT_SUMMARY_FAMILIES.includes(family)) problems.push({
|
|
62985
|
+
code: "family-not-summarisable",
|
|
62986
|
+
family
|
|
62987
|
+
});
|
|
62988
|
+
const windows = rule.systemEventDelivery.schedule.windows;
|
|
62989
|
+
if (windows.length === 0) problems.push({ code: "empty-schedule" });
|
|
62990
|
+
windows.forEach((window, index) => {
|
|
62991
|
+
if (window.days.length === 0 || window.startMinute === window.endMinute) problems.push({
|
|
62992
|
+
code: "degenerate-window",
|
|
62993
|
+
index
|
|
62994
|
+
});
|
|
62995
|
+
});
|
|
62996
|
+
if (rule.schedule !== void 0) problems.push({ code: "schedule-beside-summary" });
|
|
62997
|
+
if (actionsAreSet(rule.actions)) problems.push({ code: "actions-beside-summary" });
|
|
62998
|
+
return problems;
|
|
62999
|
+
}
|
|
63000
|
+
function describeSystemEventDeliveryProblem(problem) {
|
|
63001
|
+
switch (problem.code) {
|
|
63002
|
+
case "not-a-system-rule": return `a '${problem.delivery}' rule has no summary delivery — only device-events and system rules do`;
|
|
63003
|
+
case "family-not-summarisable": return problem.family === "alarm" ? "an alarm rule cannot be a scheduled summary — the alarm stays instant" : `a ${problem.family} rule cannot be a scheduled summary — only device-events and system rules`;
|
|
63004
|
+
case "degenerate-window": return `send time ${String(problem.index + 1)} has no day, or starts and ends on the same minute — it never closes, so nothing would be sent`;
|
|
63005
|
+
case "empty-schedule": return "a summary rule needs at least one send time — its schedule has no window";
|
|
63006
|
+
case "schedule-beside-summary": return "a summary rule is sent on its summary schedule — remove the active-hours schedule";
|
|
63007
|
+
case "actions-beside-summary": return "a summary rule never matches an event, so its actions would never run — remove them";
|
|
63008
|
+
}
|
|
63009
|
+
}
|
|
63010
|
+
var DAY_MINUTES = 1440;
|
|
63011
|
+
/**
|
|
63012
|
+
* A send time is a ONE-MINUTE window that closes at that minute: the summary is
|
|
63013
|
+
* sent when a window ends. Midnight starts the window at 23:59 of the day
|
|
63014
|
+
* BEFORE, because a window's `days` are the days it STARTS on.
|
|
63015
|
+
*/
|
|
63016
|
+
function scheduleForSendTimes(times, timezone) {
|
|
63017
|
+
return {
|
|
63018
|
+
windows: times.map((time) => {
|
|
63019
|
+
const startMinute = (time.minute + DAY_MINUTES - 1) % DAY_MINUTES;
|
|
63020
|
+
return {
|
|
63021
|
+
days: (time.minute === 0 ? time.days.map((day) => (day + 6) % 7) : [...time.days]).toSorted((a, b) => a - b),
|
|
63022
|
+
startMinute,
|
|
63023
|
+
endMinute: time.minute
|
|
63024
|
+
};
|
|
63025
|
+
}),
|
|
63026
|
+
...timezone !== void 0 ? { timezone } : {}
|
|
63027
|
+
};
|
|
63028
|
+
}
|
|
63029
|
+
/**
|
|
63030
|
+
* The send times a schedule stands for, or `null` when it is not a list of
|
|
63031
|
+
* one-minute windows (an inverted or a longer window): the editor then shows
|
|
63032
|
+
* the raw windows and says the summary is sent when each one ENDS.
|
|
63033
|
+
*/
|
|
63034
|
+
function sendTimesOfSchedule(schedule) {
|
|
63035
|
+
if (schedule.invert === true) return null;
|
|
63036
|
+
const times = [];
|
|
63037
|
+
for (const window of schedule.windows) {
|
|
63038
|
+
if ((window.endMinute - window.startMinute + DAY_MINUTES) % DAY_MINUTES !== 1) return null;
|
|
63039
|
+
const days = window.endMinute === 0 ? window.days.map((day) => (day + 1) % 7) : window.days;
|
|
63040
|
+
times.push({
|
|
63041
|
+
days: days.toSorted((a, b) => a - b),
|
|
63042
|
+
minute: window.endMinute
|
|
63043
|
+
});
|
|
63044
|
+
}
|
|
63045
|
+
return times;
|
|
63046
|
+
}
|
|
63047
|
+
var SUMMARY_CONTENT_VAR = /\{\{\s*summary(?:Text|Devices|Streams|Battery|Consumables|Tanks|Detection|Nodes|Addons|Updates)\s*\}\}/;
|
|
63048
|
+
/**
|
|
63049
|
+
* Does a custom BODY carry the summary's content (`{{summaryText}}` or a
|
|
63050
|
+
* section variable)? A body that does not would send a summary with nothing
|
|
63051
|
+
* in it; the hub then appends `{{summaryText}}` and the admin warns (review
|
|
63052
|
+
* M3). An absent or blank body uses the hub's own wording, which does.
|
|
63053
|
+
*/
|
|
63054
|
+
function templateCarriesSummary(body) {
|
|
63055
|
+
if (body === void 0 || body.trim().length === 0) return true;
|
|
63056
|
+
return SUMMARY_CONTENT_VAR.test(body);
|
|
63057
|
+
}
|
|
63058
|
+
//#endregion
|
|
62717
63059
|
//#region src/notification/scope-picker-items.ts
|
|
62718
63060
|
function nodePickerItems(nodes) {
|
|
62719
63061
|
return nodes.map((node) => ({
|
|
@@ -64525,6 +64867,112 @@ function isSameAddonId(a, b) {
|
|
|
64525
64867
|
return bareAddonId(a) === bareAddonId(b);
|
|
64526
64868
|
}
|
|
64527
64869
|
//#endregion
|
|
64870
|
+
//#region src/utils/background-run-registry.ts
|
|
64871
|
+
function snapshot(run) {
|
|
64872
|
+
return {
|
|
64873
|
+
runId: run.runId,
|
|
64874
|
+
state: run.state,
|
|
64875
|
+
startedAtMs: run.startedAtMs,
|
|
64876
|
+
finishedAtMs: run.finishedAtMs,
|
|
64877
|
+
progress: run.progress,
|
|
64878
|
+
result: run.result,
|
|
64879
|
+
error: run.error
|
|
64880
|
+
};
|
|
64881
|
+
}
|
|
64882
|
+
var BackgroundRunRegistry = class {
|
|
64883
|
+
opts;
|
|
64884
|
+
runs = /* @__PURE__ */ new Map();
|
|
64885
|
+
now;
|
|
64886
|
+
constructor(opts) {
|
|
64887
|
+
this.opts = opts;
|
|
64888
|
+
this.now = opts.now ?? Date.now;
|
|
64889
|
+
}
|
|
64890
|
+
/** Runs still going. */
|
|
64891
|
+
get runningCount() {
|
|
64892
|
+
let n = 0;
|
|
64893
|
+
for (const run of this.runs.values()) if (run.state === "running") n += 1;
|
|
64894
|
+
return n;
|
|
64895
|
+
}
|
|
64896
|
+
/**
|
|
64897
|
+
* Register and start `work`. Returns the `running` receipt immediately.
|
|
64898
|
+
* Throws only for a refusal the caller must see (duplicate id, busy) — a
|
|
64899
|
+
* failure of the work itself lands in `status`, never here.
|
|
64900
|
+
*/
|
|
64901
|
+
start(runId, work) {
|
|
64902
|
+
const existing = this.runs.get(runId);
|
|
64903
|
+
if (existing !== void 0 && existing.state === "running") throw new Error(`run '${runId}' is already running`);
|
|
64904
|
+
if (this.runningCount >= this.opts.maxConcurrent) throw new Error(`busy: ${this.runningCount}/${this.opts.maxConcurrent} run(s) already in progress — wait for one to finish or abort it`);
|
|
64905
|
+
const run = {
|
|
64906
|
+
runId,
|
|
64907
|
+
state: "running",
|
|
64908
|
+
startedAtMs: this.now(),
|
|
64909
|
+
finishedAtMs: null,
|
|
64910
|
+
progress: null,
|
|
64911
|
+
result: null,
|
|
64912
|
+
error: null,
|
|
64913
|
+
controller: new AbortController()
|
|
64914
|
+
};
|
|
64915
|
+
this.runs.delete(runId);
|
|
64916
|
+
this.runs.set(runId, run);
|
|
64917
|
+
const ctx = {
|
|
64918
|
+
signal: run.controller.signal,
|
|
64919
|
+
report: (progress) => {
|
|
64920
|
+
run.progress = progress;
|
|
64921
|
+
}
|
|
64922
|
+
};
|
|
64923
|
+
const settle = (patch) => {
|
|
64924
|
+
if (patch.error !== void 0) {
|
|
64925
|
+
run.state = "failed";
|
|
64926
|
+
run.error = patch.error;
|
|
64927
|
+
} else {
|
|
64928
|
+
run.state = run.controller.signal.aborted ? "aborted" : "done";
|
|
64929
|
+
run.result = patch.result ?? null;
|
|
64930
|
+
}
|
|
64931
|
+
run.finishedAtMs = this.now();
|
|
64932
|
+
this.prune();
|
|
64933
|
+
this.opts.onSettled?.(snapshot(run));
|
|
64934
|
+
};
|
|
64935
|
+
let pending;
|
|
64936
|
+
try {
|
|
64937
|
+
pending = work(ctx);
|
|
64938
|
+
} catch (err) {
|
|
64939
|
+
pending = Promise.reject(err);
|
|
64940
|
+
}
|
|
64941
|
+
pending.then((result) => settle({ result }), (err) => settle({ error: err instanceof Error ? err.message : String(err) }));
|
|
64942
|
+
return snapshot(run);
|
|
64943
|
+
}
|
|
64944
|
+
status(runId) {
|
|
64945
|
+
const run = this.runs.get(runId);
|
|
64946
|
+
return run === void 0 ? null : snapshot(run);
|
|
64947
|
+
}
|
|
64948
|
+
/** Running runs first (newest start first), then finished ones (newest finish first). */
|
|
64949
|
+
list() {
|
|
64950
|
+
const all = [...this.runs.values()];
|
|
64951
|
+
const running = all.filter((r) => r.state === "running").toSorted((a, b) => b.startedAtMs - a.startedAtMs);
|
|
64952
|
+
const finished = all.filter((r) => r.state !== "running").toSorted((a, b) => (b.finishedAtMs ?? 0) - (a.finishedAtMs ?? 0));
|
|
64953
|
+
return [...running, ...finished].map(snapshot);
|
|
64954
|
+
}
|
|
64955
|
+
/** Signal a running run to stop. `false` for an unknown or already finished run. */
|
|
64956
|
+
abort(runId) {
|
|
64957
|
+
const run = this.runs.get(runId);
|
|
64958
|
+
if (run === void 0 || run.state !== "running") return false;
|
|
64959
|
+
run.controller.abort();
|
|
64960
|
+
return true;
|
|
64961
|
+
}
|
|
64962
|
+
/** Abort every running run (shutdown). */
|
|
64963
|
+
abortAll() {
|
|
64964
|
+
for (const run of this.runs.values()) if (run.state === "running") run.controller.abort();
|
|
64965
|
+
}
|
|
64966
|
+
prune() {
|
|
64967
|
+
const finished = [...this.runs.values()].filter((r) => r.state !== "running").toSorted((a, b) => (a.finishedAtMs ?? 0) - (b.finishedAtMs ?? 0));
|
|
64968
|
+
const excess = finished.length - this.opts.keepFinished;
|
|
64969
|
+
for (let i = 0; i < excess; i++) {
|
|
64970
|
+
const victim = finished[i];
|
|
64971
|
+
if (victim !== void 0) this.runs.delete(victim.runId);
|
|
64972
|
+
}
|
|
64973
|
+
}
|
|
64974
|
+
};
|
|
64975
|
+
//#endregion
|
|
64528
64976
|
//#region src/utils/cosine-similarity.ts
|
|
64529
64977
|
/** Cosine similarity between two embedding vectors */
|
|
64530
64978
|
function cosineSimilarity(a, b) {
|
|
@@ -65199,27 +65647,10 @@ function withTimeout(promise, ms) {
|
|
|
65199
65647
|
//#endregion
|
|
65200
65648
|
//#region src/utils/runtime-mapping.ts
|
|
65201
65649
|
/**
|
|
65202
|
-
* Map a backend ID to the model format it requires.
|
|
65203
|
-
*
|
|
65204
|
-
* Node.js backends (cpu, coreml, cuda, tensorrt) all use ONNX format
|
|
65205
|
-
* because onnxruntime-node loads .onnx and uses execution providers internally.
|
|
65206
|
-
*
|
|
65207
|
-
* Python backends use their native format.
|
|
65208
|
-
*/
|
|
65209
|
-
var BACKEND_TO_FORMAT = {
|
|
65210
|
-
cpu: "onnx",
|
|
65211
|
-
coreml: "onnx",
|
|
65212
|
-
cuda: "onnx",
|
|
65213
|
-
tensorrt: "onnx",
|
|
65214
|
-
"onnx-py": "onnx",
|
|
65215
|
-
pytorch: "pt",
|
|
65216
|
-
openvino: "openvino"
|
|
65217
|
-
};
|
|
65218
|
-
/**
|
|
65219
65650
|
* DEVICE-POOL backend → model format — the SSOT for the multi-device inference
|
|
65220
|
-
* DESCRIPTOR path (Python per-device pools),
|
|
65221
|
-
*
|
|
65222
|
-
* onnxruntime-node's CoreML EP
|
|
65651
|
+
* DESCRIPTOR path (Python per-device pools), distinct from the former BACKEND_TO_FORMAT,
|
|
65652
|
+
* which was the removed NODE runtime map (where `coreml → onnx` because
|
|
65653
|
+
* onnxruntime-node's CoreML EP loaded `.onnx`). A device pool runs the
|
|
65223
65654
|
* backend NATIVELY, so `coreml → coreml` and `edgetpu → tflite`. Consumed by
|
|
65224
65655
|
* `resolveDeviceEngine` (addon-pipeline) and the orchestrator's
|
|
65225
65656
|
* `parseDeviceKey`/`getNodeInferenceDevices` — the previously-duplicated
|
|
@@ -65260,69 +65691,6 @@ var PYTHON_SCRIPT = {
|
|
|
65260
65691
|
openvino: "openvino_inference.py"
|
|
65261
65692
|
};
|
|
65262
65693
|
/**
|
|
65263
|
-
* Resolve pipeline config (runtime + backend) to a DetectionRuntime.
|
|
65264
|
-
*
|
|
65265
|
-
* Pipeline config uses two levels:
|
|
65266
|
-
* runtime: 'node' | 'python'
|
|
65267
|
-
* backend: 'cpu' | 'coreml' | 'cuda' | 'openvino' | 'pytorch' | ...
|
|
65268
|
-
*
|
|
65269
|
-
* Addons expect a DetectionRuntime:
|
|
65270
|
-
* 'onnx' | 'coreml' | 'pytorch' | 'openvino' | 'tflite'
|
|
65271
|
-
*
|
|
65272
|
-
* Mapping rules:
|
|
65273
|
-
* node + any backend → 'onnx' (onnxruntime-node handles backend via EP)
|
|
65274
|
-
* python + coreml → 'coreml' (native .mlpackage via coremltools)
|
|
65275
|
-
* python + openvino → 'openvino'
|
|
65276
|
-
* python + pytorch → 'pytorch'
|
|
65277
|
-
* python + onnx-py → 'onnx'
|
|
65278
|
-
* python + <other> → backend as-is
|
|
65279
|
-
*/
|
|
65280
|
-
function resolveDetectionRuntime(pipelineRuntime, backend) {
|
|
65281
|
-
if (pipelineRuntime === "node") return "onnx";
|
|
65282
|
-
return {
|
|
65283
|
-
coreml: "coreml",
|
|
65284
|
-
openvino: "openvino",
|
|
65285
|
-
pytorch: "pytorch",
|
|
65286
|
-
"onnx-py": "onnx",
|
|
65287
|
-
cpu: "onnx"
|
|
65288
|
-
}[backend] ?? backend;
|
|
65289
|
-
}
|
|
65290
|
-
/**
|
|
65291
|
-
* Resolve pipeline config (runtime + backend) to a ModelFormat.
|
|
65292
|
-
*
|
|
65293
|
-
* Determines which model file format is needed (.onnx, .mlpackage, etc.)
|
|
65294
|
-
*/
|
|
65295
|
-
function resolveModelFormat(pipelineRuntime, backend) {
|
|
65296
|
-
if (pipelineRuntime === "node") return BACKEND_TO_FORMAT[backend] ?? "onnx";
|
|
65297
|
-
return {
|
|
65298
|
-
coreml: "coreml",
|
|
65299
|
-
openvino: "openvino",
|
|
65300
|
-
pytorch: "pt",
|
|
65301
|
-
"onnx-py": "onnx",
|
|
65302
|
-
cpu: "onnx"
|
|
65303
|
-
}[backend] ?? "onnx";
|
|
65304
|
-
}
|
|
65305
|
-
/**
|
|
65306
|
-
* Resolve pipeline runtime string to 'auto' | DetectionRuntime for addon consumption.
|
|
65307
|
-
* Used when building addon addonConfig from pipeline step config.
|
|
65308
|
-
*
|
|
65309
|
-
* 'python' + 'coreml' → 'coreml'
|
|
65310
|
-
* 'node' + 'coreml' → 'onnx'
|
|
65311
|
-
* 'node' + 'cpu' → 'onnx'
|
|
65312
|
-
* 'auto' → 'auto'
|
|
65313
|
-
*/
|
|
65314
|
-
function resolveAddonRuntime(pipelineRuntime, backend) {
|
|
65315
|
-
if (!pipelineRuntime || pipelineRuntime === "auto") return "auto";
|
|
65316
|
-
return resolveDetectionRuntime(pipelineRuntime, backend ?? "cpu");
|
|
65317
|
-
}
|
|
65318
|
-
/**
|
|
65319
|
-
* Get the model format needed for a given backend.
|
|
65320
|
-
* Convenience wrapper for backend-only lookup (e.g., UI components).
|
|
65321
|
-
*/
|
|
65322
|
-
function formatForBackend(backend) {
|
|
65323
|
-
return BACKEND_TO_FORMAT[backend] ?? "onnx";
|
|
65324
|
-
}
|
|
65325
|
-
/**
|
|
65326
65694
|
* Get the model format for a given DetectionRuntime.
|
|
65327
65695
|
*/
|
|
65328
65696
|
function formatForRuntime(runtime) {
|
|
@@ -65792,12 +66160,12 @@ exports.AutomationControlStatusSchema = AutomationControlStatusSchema;
|
|
|
65792
66160
|
exports.AutomationRecipeSchema = AutomationRecipeSchema;
|
|
65793
66161
|
exports.AutomationTriggerSchema = AutomationTriggerSchema;
|
|
65794
66162
|
exports.AvailableIntegrationTypeSchema = AvailableIntegrationTypeSchema;
|
|
65795
|
-
exports.BACKEND_TO_FORMAT = BACKEND_TO_FORMAT;
|
|
65796
66163
|
exports.BASE_LIVE_EGRESS_PROFILE = BASE_LIVE_EGRESS_PROFILE;
|
|
65797
66164
|
exports.BATTERY_DEVICE_PROFILE = BATTERY_DEVICE_PROFILE;
|
|
65798
66165
|
exports.BATTERY_UNREACHABLE_AFTER_MS = BATTERY_UNREACHABLE_AFTER_MS;
|
|
65799
66166
|
exports.BIRTH_DECISION_DEFAULT_LIMIT = BIRTH_DECISION_DEFAULT_LIMIT;
|
|
65800
66167
|
exports.BOOT_RECOVERY_BACKOFF_MS = require_sleep.BOOT_RECOVERY_BACKOFF_MS;
|
|
66168
|
+
exports.BackgroundRunRegistry = BackgroundRunRegistry;
|
|
65801
66169
|
exports.BacklightModeSchema = BacklightModeSchema;
|
|
65802
66170
|
exports.BackupDestinationInfoSchema = BackupDestinationInfoSchema;
|
|
65803
66171
|
exports.BackupEntrySchema = BackupEntrySchema;
|
|
@@ -66056,6 +66424,7 @@ exports.EXPRESSION_BUILTIN_NAMES = EXPRESSION_BUILTIN_NAMES;
|
|
|
66056
66424
|
exports.EXPRESSION_COMPILE_CACHE_CAPACITY = EXPRESSION_COMPILE_CACHE_CAPACITY;
|
|
66057
66425
|
exports.EXPRESSION_IDENTIFIER_RE = EXPRESSION_IDENTIFIER_RE;
|
|
66058
66426
|
exports.EXPRESSION_INJECTED_NOW = EXPRESSION_INJECTED_NOW;
|
|
66427
|
+
exports.EffectiveTuningSchema = EffectiveTuningSchema;
|
|
66059
66428
|
exports.EgressEncodeSchema = EgressEncodeSchema;
|
|
66060
66429
|
exports.EgressRateControlSchema = EgressRateControlSchema;
|
|
66061
66430
|
exports.EgressTranscodeRequestSchema = EgressTranscodeRequestSchema;
|
|
@@ -66387,6 +66756,7 @@ exports.NC_SYSTEM_EVENT_FAMILY = NC_SYSTEM_EVENT_FAMILY;
|
|
|
66387
66756
|
exports.NC_SYSTEM_EVENT_FAMILY_FILTERS = NC_SYSTEM_EVENT_FAMILY_FILTERS;
|
|
66388
66757
|
exports.NC_SYSTEM_EVENT_FILTER_KEYS = NC_SYSTEM_EVENT_FILTER_KEYS;
|
|
66389
66758
|
exports.NC_SYSTEM_EVENT_KIND_GROUP_SPECS = NC_SYSTEM_EVENT_KIND_GROUP_SPECS;
|
|
66759
|
+
exports.NC_SYSTEM_EVENT_SUMMARY_FAMILIES = NC_SYSTEM_EVENT_SUMMARY_FAMILIES;
|
|
66390
66760
|
exports.NC_SYSTEM_RULE_KINDS = NC_SYSTEM_RULE_KINDS;
|
|
66391
66761
|
exports.NC_TANK_SYSTEM_EVENT_KINDS = NC_TANK_SYSTEM_EVENT_KINDS;
|
|
66392
66762
|
exports.NC_TAXONOMY = NC_TAXONOMY;
|
|
@@ -66464,7 +66834,11 @@ exports.NcSnoozeInputSchema = NcSnoozeInputSchema;
|
|
|
66464
66834
|
exports.NcSnoozeSchema = NcSnoozeSchema;
|
|
66465
66835
|
exports.NcSnoozeScopeSchema = NcSnoozeScopeSchema;
|
|
66466
66836
|
exports.NcSnoozeSuppressedSchema = NcSnoozeSuppressedSchema;
|
|
66837
|
+
exports.NcStateSummaryPreviewSchema = NcStateSummaryPreviewSchema;
|
|
66838
|
+
exports.NcStateSummaryPreviewSectionSchema = NcStateSummaryPreviewSectionSchema;
|
|
66467
66839
|
exports.NcSystemEventConditionSchema = NcSystemEventConditionSchema;
|
|
66840
|
+
exports.NcSystemEventDeliveryModeSchema = NcSystemEventDeliveryModeSchema;
|
|
66841
|
+
exports.NcSystemEventDeliverySchema = NcSystemEventDeliverySchema;
|
|
66468
66842
|
exports.NcSystemEventKindSchema = NcSystemEventKindSchema;
|
|
66469
66843
|
exports.NcTaxonomyEntrySchema = NcTaxonomyEntrySchema;
|
|
66470
66844
|
exports.NcTaxonomySchema = NcTaxonomySchema;
|
|
@@ -67082,6 +67456,7 @@ exports.describeCustomActions = require_sleep.describeCustomActions;
|
|
|
67082
67456
|
exports.describeModelVariant = describeModelVariant;
|
|
67083
67457
|
exports.describeOnboardClamp = describeOnboardClamp;
|
|
67084
67458
|
exports.describeOnboardRefusal = describeOnboardRefusal;
|
|
67459
|
+
exports.describeSystemEventDeliveryProblem = describeSystemEventDeliveryProblem;
|
|
67085
67460
|
exports.describeSystemEventFamilyProblem = describeSystemEventFamilyProblem;
|
|
67086
67461
|
exports.detectAccessRole = detectAccessRole;
|
|
67087
67462
|
exports.detectionPipelineCapability = detectionPipelineCapability;
|
|
@@ -67139,7 +67514,6 @@ exports.filesystemBrowseCapability = filesystemBrowseCapability;
|
|
|
67139
67514
|
exports.findTimezone = findTimezone;
|
|
67140
67515
|
exports.floodCapability = floodCapability;
|
|
67141
67516
|
exports.foldSnapshotByFunction = foldSnapshotByFunction;
|
|
67142
|
-
exports.formatForBackend = formatForBackend;
|
|
67143
67517
|
exports.formatForRuntime = formatForRuntime;
|
|
67144
67518
|
exports.formatMediaOwnerKey = formatMediaOwnerKey;
|
|
67145
67519
|
exports.formatMinutes = formatMinutes;
|
|
@@ -67182,6 +67556,7 @@ exports.isDisplayIconKey = isDisplayIconKey;
|
|
|
67182
67556
|
exports.isEvent = require_sleep.isEvent;
|
|
67183
67557
|
exports.isEventOwnerType = isEventOwnerType;
|
|
67184
67558
|
exports.isFirstLevelMacroClass = isFirstLevelMacroClass;
|
|
67559
|
+
exports.isHeldBackTemplateVar = isHeldBackTemplateVar;
|
|
67185
67560
|
exports.isIsolatedBuiltin = isIsolatedBuiltin;
|
|
67186
67561
|
exports.isKnownTemplateVar = isKnownTemplateVar;
|
|
67187
67562
|
exports.isLocationEnabled = isLocationEnabled;
|
|
@@ -67198,6 +67573,7 @@ exports.isSourceCap = isSourceCap;
|
|
|
67198
67573
|
exports.isStorageLocationMode = isStorageLocationMode;
|
|
67199
67574
|
exports.isSystemDelivery = isSystemDelivery;
|
|
67200
67575
|
exports.isSystemEventFamily = isSystemEventFamily;
|
|
67576
|
+
exports.isSystemEventSummaryRule = isSystemEventSummaryRule;
|
|
67201
67577
|
exports.isSystemRuleKind = isSystemRuleKind;
|
|
67202
67578
|
exports.isVoidInput = isVoidInput;
|
|
67203
67579
|
exports.ituDbfsFromPreEpoch = ituDbfsFromPreEpoch;
|
|
@@ -67339,13 +67715,11 @@ exports.resetPoolBaseline = resetPoolBaseline;
|
|
|
67339
67715
|
exports.resolveAddonExecution = resolveAddonExecution;
|
|
67340
67716
|
exports.resolveAddonGroup = resolveAddonGroup;
|
|
67341
67717
|
exports.resolveAddonPlacement = resolveAddonPlacement;
|
|
67342
|
-
exports.resolveAddonRuntime = resolveAddonRuntime;
|
|
67343
67718
|
exports.resolveBucketMs = resolveBucketMs;
|
|
67344
67719
|
exports.resolveCapMount = require_sleep.resolveCapMount;
|
|
67345
67720
|
exports.resolveClusterStepModelId = resolveClusterStepModelId;
|
|
67346
67721
|
exports.resolveContainerPrimaryChild = resolveContainerPrimaryChild;
|
|
67347
67722
|
exports.resolveCreateExportSubject = resolveCreateExportSubject;
|
|
67348
|
-
exports.resolveDetectionRuntime = resolveDetectionRuntime;
|
|
67349
67723
|
exports.resolveDeviceControlKind = resolveDeviceControlKind;
|
|
67350
67724
|
exports.resolveDeviceProfile = resolveDeviceProfile;
|
|
67351
67725
|
exports.resolveEgressDecodeHwAccel = resolveEgressDecodeHwAccel;
|
|
@@ -67355,7 +67729,6 @@ exports.resolveHydratedFieldValue = require_sleep.resolveHydratedFieldValue;
|
|
|
67355
67729
|
exports.resolveLocationIcon = resolveLocationIcon;
|
|
67356
67730
|
exports.resolveLocationMode = resolveLocationMode;
|
|
67357
67731
|
exports.resolveMethodAuth = resolveMethodAuth;
|
|
67358
|
-
exports.resolveModelFormat = resolveModelFormat;
|
|
67359
67732
|
exports.resolveMutate = resolveMutate;
|
|
67360
67733
|
exports.resolvePoolMemoryPolicy = resolvePoolMemoryPolicy;
|
|
67361
67734
|
exports.resolveRecordingProfiles = resolveRecordingProfiles;
|
|
@@ -67376,6 +67749,7 @@ exports.runInferenceStep = runInferenceStep;
|
|
|
67376
67749
|
exports.runtimeDevices = runtimeDevices;
|
|
67377
67750
|
exports.runtimeStatePolicyFor = runtimeStatePolicyFor;
|
|
67378
67751
|
exports.sceneMonitorCapability = sceneMonitorCapability;
|
|
67752
|
+
exports.scheduleForSendTimes = scheduleForSendTimes;
|
|
67379
67753
|
exports.schemaDeclaresAnyField = schemaDeclaresAnyField;
|
|
67380
67754
|
exports.scopeInherits = scopeInherits;
|
|
67381
67755
|
exports.scopeKey = require_sleep.scopeKey;
|
|
@@ -67385,6 +67759,7 @@ exports.scoreRuntimes = scoreRuntimes;
|
|
|
67385
67759
|
exports.scriptRunnerCapability = scriptRunnerCapability;
|
|
67386
67760
|
exports.searchDisplayIcons = searchDisplayIcons;
|
|
67387
67761
|
exports.selectAssignedProfileSlots = require_sleep.selectAssignedProfileSlots;
|
|
67762
|
+
exports.sendTimesOfSchedule = sendTimesOfSchedule;
|
|
67388
67763
|
exports.sensorRaisedOf = sensorRaisedOf;
|
|
67389
67764
|
exports.sensorTransitionNeverFires = sensorTransitionNeverFires;
|
|
67390
67765
|
exports.sensorTransitionOffered = sensorTransitionOffered;
|
|
@@ -67426,12 +67801,14 @@ exports.switchCapability = switchCapability;
|
|
|
67426
67801
|
exports.switchedOffIds = switchedOffIds;
|
|
67427
67802
|
exports.synthesizeSourceInfo = synthesizeSourceInfo;
|
|
67428
67803
|
exports.systemCapability = systemCapability;
|
|
67804
|
+
exports.systemEventDeliveryProblems = systemEventDeliveryProblems;
|
|
67429
67805
|
exports.systemEventFamilyOf = systemEventFamilyOf;
|
|
67430
67806
|
exports.systemEventFamilyProblems = systemEventFamilyProblems;
|
|
67431
67807
|
exports.systemEventFilterApplies = systemEventFilterApplies;
|
|
67432
67808
|
exports.systemEventFilterAppliesToAnyKind = systemEventFilterAppliesToAnyKind;
|
|
67433
67809
|
exports.systemEventKindNamesOf = systemEventKindNamesOf;
|
|
67434
67810
|
exports.systemEventKindsOfFamily = systemEventKindsOfFamily;
|
|
67811
|
+
exports.systemEventSummaryScheduleOf = systemEventSummaryScheduleOf;
|
|
67435
67812
|
exports.systemFamilyOfKind = systemFamilyOfKind;
|
|
67436
67813
|
exports.systemRuleKindOf = systemRuleKindOf;
|
|
67437
67814
|
exports.tamperCapability = tamperCapability;
|
|
@@ -67439,6 +67816,8 @@ exports.taskLogEntrySchema = taskLogEntrySchema;
|
|
|
67439
67816
|
exports.taskPhaseSchema = taskPhaseSchema;
|
|
67440
67817
|
exports.taskTargetSchema = taskTargetSchema;
|
|
67441
67818
|
exports.temperatureSensorCapability = temperatureSensorCapability;
|
|
67819
|
+
exports.templateCarriesSummary = templateCarriesSummary;
|
|
67820
|
+
exports.templateVarDeliveryApplies = templateVarDeliveryApplies;
|
|
67442
67821
|
exports.templateVarKindApplies = templateVarKindApplies;
|
|
67443
67822
|
exports.templateVarSystemEventApplies = templateVarSystemEventApplies;
|
|
67444
67823
|
exports.templateVarsFor = templateVarsFor;
|