@camstack/addon-model-studio 1.1.173 → 1.1.175

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (19) hide show
  1. package/dist/{MotionZonesSettings-BfCoYgxT.mjs → MotionZonesSettings-BnPKd-p7.mjs} +2 -2
  2. package/dist/{PrivacyMaskSettings-Th5IVviI.mjs → PrivacyMaskSettings-DuPNepvj.mjs} +4 -4
  3. package/dist/{SceneMonitorEditor-BERqxPAZ.mjs → SceneMonitorEditor-shkSy7R6.mjs} +3 -3
  4. package/dist/_stub.js +12 -12
  5. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_model_studio_page-CP30dIZR.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_model_studio_page-BtQXSIcN.mjs} +3 -3
  6. package/dist/_virtual_mf___mfe_internal__addon_model_studio_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-CSU-vA08.mjs +26 -0
  7. package/dist/addon-model-studio.css +1 -1
  8. package/dist/{hostInit-BZQ7ikZC.mjs → hostInit-v1KM-izE.mjs} +2 -2
  9. package/dist/model-studio.addon.js +2007 -1047
  10. package/dist/model-studio.addon.mjs +2007 -1047
  11. package/dist/{player-overlays-B4uXOi-a.mjs → player-overlays-XBDUBreN.mjs} +1 -1
  12. package/dist/remoteEntry.js +1 -1
  13. package/dist/{responsive-CEbpemt_.mjs → responsive-Ct9r9fcD.mjs} +1 -1
  14. package/dist/{scene-monitor-copy-DXDF5cQH.mjs → scene-monitor-copy-6edUqagK.mjs} +1 -1
  15. package/dist/{square-B_pecyJV.mjs → square-xaUv7lAA.mjs} +1 -1
  16. package/dist/{trash-2-DfAU2tvI.mjs → trash-2-BjU_ykxW.mjs} +1 -1
  17. package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_model_studio_page__remoteEntry_js-DRHKHJI4.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_model_studio_page__remoteEntry_js-Byr-xHCs.mjs} +1 -1
  18. package/package.json +1 -1
  19. package/dist/_virtual_mf___mfe_internal__addon_model_studio_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-ak-DR-J7.mjs +0 -26
@@ -5884,7 +5884,7 @@ var ZodIssueCode = {
5884
5884
  var ZodFirstPartyTypeKind;
5885
5885
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5886
5886
  //#endregion
5887
- //#region ../types/dist/sleep-DU7mu4wb.mjs
5887
+ //#region ../types/dist/sleep-BXv0ZcRa.mjs
5888
5888
  /**
5889
5889
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5890
5890
  * window to float samples (D455).
@@ -6669,6 +6669,40 @@ var BaseAddon = class {
6669
6669
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6670
6670
  return keys.size > 0 ? projectStore(raw, keys, node) : raw;
6671
6671
  }
6672
+ /**
6673
+ * Whether ONE global key of this addon's store was written, read three-way
6674
+ * (D651). For a question a hydrated view cannot answer: `getGlobalSettings`
6675
+ * reports `value ?? default`, so "the operator chose the default" and "nobody
6676
+ * chose" look the same, and a failed read looks like both. A `perNode` key is
6677
+ * not supported here: its stored name is scoped.
6678
+ */
6679
+ async readStoredGlobalKey(key) {
6680
+ const read = this._ctx?.settings?.readAddonStoreResult;
6681
+ if (read === void 0) return {
6682
+ kind: "unreadable",
6683
+ reason: "three-way-read-unavailable"
6684
+ };
6685
+ let result;
6686
+ try {
6687
+ result = await read.call(this._ctx?.settings);
6688
+ } catch (err) {
6689
+ return {
6690
+ kind: "unreadable",
6691
+ reason: "store-read-failed",
6692
+ error: err instanceof Error ? err.message : String(err)
6693
+ };
6694
+ }
6695
+ if (result.kind === "failed") return {
6696
+ kind: "unreadable",
6697
+ reason: "store-read-failed",
6698
+ error: result.error
6699
+ };
6700
+ if (result.kind === "missing" || !Object.prototype.hasOwnProperty.call(result.value, key)) return { kind: "absent" };
6701
+ return {
6702
+ kind: "present",
6703
+ value: result.value[key]
6704
+ };
6705
+ }
6672
6706
  async updateGlobalSettings(patch, nodeId) {
6673
6707
  const keys = this.perNodeKeys();
6674
6708
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
@@ -9992,6 +10026,43 @@ var LogChannelWindowSchema = object({
9992
10026
  /** `null` = every camera. A non-empty list narrows to those numeric ids. */
9993
10027
  deviceIds: array(number().int()).readonly().nullable()
9994
10028
  });
10029
+ var ClipModelMetaSchema = object({
10030
+ /** The paired text encoder's catalog id (the embedding-encoder's text catalog). */
10031
+ textModelId: string().min(1),
10032
+ /** Output dimension of BOTH towers. A vector of any other length is refused. */
10033
+ embeddingDim: number().int().positive(),
10034
+ /**
10035
+ * The `vector-store` index this model's vectors live in. ONE feature space
10036
+ * per index: two models share an index only when their vectors are ranked
10037
+ * against each other, which for CLIP means never across families. MobileCLIP
10038
+ * S1 and S2 share `object-clip` for history (separated by the row's
10039
+ * `modelId`); any other model gets its own.
10040
+ */
10041
+ vectorIndex: string().regex(/^object-clip(-[a-z0-9][a-z0-9-]*)?$/),
10042
+ /**
10043
+ * The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
10044
+ * must be unique per tokenizer: every model's siblings land in ONE flat
10045
+ * models directory, so two different tokenizers under the same name would
10046
+ * silently overwrite each other (whichever model downloaded last wins, and
10047
+ * the other one tokenises with the wrong vocabulary).
10048
+ */
10049
+ tokenizerFile: string().min(1),
10050
+ /** Token window the text graph takes (SigLIP2: 64; CLIP BPE: 77). */
10051
+ contextLength: number().int().positive(),
10052
+ /** Id the tokenizer pads with. */
10053
+ padId: number().int().nonnegative(),
10054
+ /**
10055
+ * The search cosine floor at `strictness: 'loose'` — calibrated per model,
10056
+ * because cosine bands are a property of the model: 0.2 keeps 96% of matched
10057
+ * COCO caption-image pairs on MobileCLIP S1 and 2.7% on SigLIP2.
10058
+ */
10059
+ searchMinScore: number().min(0).max(1)
10060
+ });
10061
+ var ClipSearchStrictnessSchema = _enum([
10062
+ "loose",
10063
+ "balanced",
10064
+ "strict"
10065
+ ]);
9995
10066
  var MODEL_FORMATS = [
9996
10067
  "onnx",
9997
10068
  "coreml",
@@ -10020,7 +10091,7 @@ var ModelFormatEntrySchema = object({
10020
10091
  /** Multi-file payload (directory members or sibling files). */
10021
10092
  files: array(string()).readonly().optional(),
10022
10093
  /** Runtime(s) that can use this format. If omitted, inferred from ModelFormat key */
10023
- runtimes: array(_enum(["node", "python"])).readonly().optional()
10094
+ runtimes: array(_enum(["python"])).readonly().optional()
10024
10095
  });
10025
10096
  /**
10026
10097
  * Extra file that must be downloaded alongside the model (e.g., labels JSON, dict.txt).
@@ -10101,10 +10172,17 @@ var ModelCatalogEntrySchema = object({
10101
10172
  inputChannels: number().int().positive().optional(),
10102
10173
  labels: array(LabelDefinitionSchema).readonly(),
10103
10174
  inputLayout: _enum(["nchw", "nhwc"]).optional(),
10175
+ /**
10176
+ * `'scrfd'` applies InsightFace's SCRFD input contract, `(x - 127.5) / 128`
10177
+ * (upstream `insightface/model_zoo/scrfd.py`), instead of the historical
10178
+ * plain `/255`. Measured against COCO GT: 188 → 196 faces found on the
10179
+ * `scrfd-2.5g` catalog entry (2026-09-26 model-replacement spike, §2.4-2).
10180
+ */
10104
10181
  inputNormalization: _enum([
10105
10182
  "zero-one",
10106
10183
  "imagenet",
10107
- "none"
10184
+ "none",
10185
+ "scrfd"
10108
10186
  ]).optional(),
10109
10187
  /**
10110
10188
  * The model already applies softmax IN-GRAPH — its raw output is a
@@ -10188,7 +10266,14 @@ var ModelCatalogEntrySchema = object({
10188
10266
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
10189
10267
  * labels already ARE the CamStack macros (Scrypted identity map).
10190
10268
  */
10191
- classMap: DetectionCatalogClassMapSchema.optional()
10269
+ classMap: DetectionCatalogClassMapSchema.optional(),
10270
+ /**
10271
+ * The model's CLIP feature-space contract (text encoder, dimension, vector
10272
+ * index, token window, search floor) — see `clip-model.ts`. Present ONLY on a
10273
+ * CLIP image encoder; its absence is what "not a CLIP model" means to the
10274
+ * embedding encoder and the semantic-search store (D649).
10275
+ */
10276
+ clip: ClipModelMetaSchema.optional()
10192
10277
  });
10193
10278
  var ConvertTargetSchema = discriminatedUnion("format", [object({
10194
10279
  format: literal("openvino"),
@@ -10206,7 +10291,8 @@ var ModelConvertMetadataSchema = object({
10206
10291
  inputNormalization: _enum([
10207
10292
  "zero-one",
10208
10293
  "imagenet",
10209
- "none"
10294
+ "none",
10295
+ "scrfd"
10210
10296
  ]).optional(),
10211
10297
  preprocessMode: _enum(["letterbox", "resize"]).optional(),
10212
10298
  outputFormat: _enum([
@@ -14439,6 +14525,13 @@ var LinkedDeviceSchema = object({
14439
14525
  features: array(string()),
14440
14526
  producesTrackedEvents: boolean().optional()
14441
14527
  });
14528
+ /**
14529
+ * The `linked-devices` extension slot's editable value (D648): the operator's
14530
+ * pick list, exactly what `_linkedDeviceIds` persists. Tree children are NOT
14531
+ * in it — they are always linked and are not a pick.
14532
+ */
14533
+ var LinkedDevicesSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
14534
+ DeviceType.Camera;
14442
14535
  /** One camera's resolved linked set, tagged with the camera it belongs to.
14443
14536
  * The batch answer needs the tag; the single-device answer already has it
14444
14537
  * from the input, which is why `getLinkedDevices` keeps the untagged shape. */
@@ -14964,16 +15057,101 @@ var EmbeddingResultSchema = object({
14964
15057
  embedding: array(number()),
14965
15058
  inferenceMs: number()
14966
15059
  });
15060
+ /** The two CLIP towers the encoder runs; a crash budget is kept per tower. */
15061
+ var EmbeddingTowerSchema = _enum(["image", "text"]);
15062
+ /**
15063
+ * A tower in the terminal `failed` state (D649, D6): it crashed or failed to
15064
+ * load `crashes` times within `windowMs`, and is refused by name until an
15065
+ * operator `resetFailedModels` or a model change — never on a timer.
15066
+ *
15067
+ * `nodeId` is the node whose tower failed. The state lives in THAT node's
15068
+ * encoder process (in memory — a runner respawn clears it), and one node's
15069
+ * answer says nothing about another's.
15070
+ */
15071
+ var EmbeddingFailedModelSchema = object({
15072
+ modelId: string(),
15073
+ tower: EmbeddingTowerSchema,
15074
+ nodeId: string(),
15075
+ crashes: number(),
15076
+ windowMs: number(),
15077
+ sinceMs: number(),
15078
+ lastReason: string()
15079
+ });
15080
+ /**
15081
+ * A model whose REQUIREMENTS can never be met on this node (D649 round 5):
15082
+ * an id the catalog does not know, a model URL answering 404/410, a declared
15083
+ * sibling (the tokenizer) that is not there. After `attempts` failed builds
15084
+ * it is terminally `requirements-failed`, refused by name until an operator
15085
+ * `resetFailedModels` or a model change — the same exits as a crashed tower.
15086
+ */
15087
+ var EmbeddingFailedRequirementSchema = object({
15088
+ modelId: string(),
15089
+ tower: EmbeddingTowerSchema,
15090
+ nodeId: string(),
15091
+ attempts: number(),
15092
+ sinceMs: number(),
15093
+ lastReason: string()
15094
+ });
14967
15095
  var EmbeddingInfoSchema = object({
14968
15096
  modelId: string(),
14969
15097
  embeddingDim: number(),
14970
- ready: boolean()
14971
- });
15098
+ ready: boolean(),
15099
+ /**
15100
+ * The node that answered. Absent only from an encoder older than D649's
15101
+ * crash budget — whose `failedModels` is then UNKNOWN (D315), never "none".
15102
+ */
15103
+ nodeId: string().optional(),
15104
+ /**
15105
+ * Towers in `failed` on the answering node, each row naming it. `undefined`
15106
+ * means the node could not say (pre-budget encoder); a node that has the
15107
+ * budget always answers an array, empty included.
15108
+ */
15109
+ failedModels: array(EmbeddingFailedModelSchema).optional(),
15110
+ /** Models terminally `requirements-failed` on the answering node; same reading as above. */
15111
+ failedRequirements: array(EmbeddingFailedRequirementSchema).optional()
15112
+ });
15113
+ /**
15114
+ * The THREE codes an encoder refusal can carry (D649, D6). Same shape as
15115
+ * `VECTOR_INDEX_DIM_CONFLICT`: the code rides in the MESSAGE, because an
15116
+ * Error's own properties do not survive the UDS/tRPC hop and its message does,
15117
+ * and both sides go through the helpers below — the encoder builds the
15118
+ * refusal, the live detail plane classifies on it to count refusals per
15119
+ * camera instead of logging one warning per track. The bracketed token
15120
+ * carries the code, the model, the tower and the node so a consumer never
15121
+ * parses prose.
15122
+ *
15123
+ * - `EMBEDDING_MODEL_FAILED`: the tower crashed / failed to load past the crash
15124
+ * budget — terminal until `resetFailedModels` or a model change.
15125
+ * - `EMBEDDING_REQUIREMENTS_UNAVAILABLE`: files or runtime not there right now
15126
+ * (a download or Python that failed, or the cooldown after one) — the next
15127
+ * request past the cooldown tries again.
15128
+ * - `EMBEDDING_REQUIREMENTS_FAILED`: the requirements can never be met (unknown
15129
+ * id, 404/410, missing sibling) and the bounded attempts are spent —
15130
+ * terminal, same exits as a crashed tower.
15131
+ */
15132
+ var EMBEDDING_MODEL_FAILED = "embedding-model-failed";
15133
+ var EMBEDDING_REQUIREMENTS_UNAVAILABLE = "embedding-requirements-unavailable";
15134
+ var EMBEDDING_REQUIREMENTS_FAILED = "embedding-requirements-failed";
15135
+ _enum([
15136
+ EMBEDDING_MODEL_FAILED,
15137
+ EMBEDDING_REQUIREMENTS_UNAVAILABLE,
15138
+ EMBEDDING_REQUIREMENTS_FAILED
15139
+ ]);
15140
+ new RegExp(`\\[(${EMBEDDING_MODEL_FAILED}|${EMBEDDING_REQUIREMENTS_UNAVAILABLE}|${EMBEDDING_REQUIREMENTS_FAILED}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);
14972
15141
  method(object({
14973
15142
  crop: _instanceof(Uint8Array),
14974
15143
  width: number(),
14975
15144
  height: number()
14976
- }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
15145
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({
15146
+ text: string(),
15147
+ modelId: string().min(1).optional()
15148
+ }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" }), method(object({ modelId: string().min(1).optional() }), object({
15149
+ cleared: array(string()),
15150
+ nodeId: string()
15151
+ }), {
15152
+ kind: "mutation",
15153
+ auth: "admin"
15154
+ });
14977
15155
  /**
14978
15156
  * `failure-contribution` — the capability an addon reports its OWN losses
14979
15157
  * through, per camera, with the denominator attached. It stores nothing.
@@ -17624,6 +17802,9 @@ var NcSystemEventKindSchema = _enum([
17624
17802
  "device-battery-normal",
17625
17803
  "device-consumable-low",
17626
17804
  "device-consumable-normal",
17805
+ "device-tank-low",
17806
+ "device-tank-full",
17807
+ "device-tank-normal",
17627
17808
  "stream-online",
17628
17809
  "stream-offline",
17629
17810
  "node-online",
@@ -17661,6 +17842,29 @@ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
17661
17842
  ]);
17662
17843
  NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
17663
17844
  /**
17845
+ * The panel's transitions, as ONE list.
17846
+ *
17847
+ * Named here rather than spelled out at each of the four sites that need them
17848
+ * (the emitter, the intake, the editor group, the combined-notification gate),
17849
+ * because a transition added to the enum and forgotten at one of them is an
17850
+ * alarm state nobody can be notified about. That is exactly what this list
17851
+ * failed to prevent while it held three: `alarm-arming` was the fourth.
17852
+ *
17853
+ * In LIFECYCLE order, which is the order an editor lists them in and the order
17854
+ * a person experiences them — not the order they were added.
17855
+ */
17856
+ var NC_ALARM_SYSTEM_EVENT_KINDS = [
17857
+ "alarm-arm-refused",
17858
+ "alarm-check-failed",
17859
+ "alarm-arming",
17860
+ "alarm-armed",
17861
+ "alarm-pending",
17862
+ "alarm-triggered",
17863
+ "alarm-rearmed",
17864
+ "alarm-sensor-bypass",
17865
+ "alarm-disarmed"
17866
+ ];
17867
+ /**
17664
17868
  * One coherent system-event condition. `kinds` is the required opt-in safety
17665
17869
  * gate; the remaining lists are optional narrowing filters relevant to the
17666
17870
  * selected kinds.
@@ -17694,7 +17898,22 @@ var NcSystemEventConditionSchema = object({
17694
17898
  */
17695
17899
  excludeDeviceIds: array(number().int()).min(1).optional(),
17696
17900
  nodeIds: array(string().min(1)).min(1).optional(),
17697
- packageNames: array(string().min(1)).min(1).optional()
17901
+ packageNames: array(string().min(1)).min(1).optional(),
17902
+ /**
17903
+ * At or below this remaining-life %, a consumable is LOW for THIS rule
17904
+ * (D642). Absent = {@link NC_CONSUMABLE_LOW_PERCENT_DEFAULT}; at most
17905
+ * {@link NC_CONSUMABLE_LOW_PERCENT_MAX}, so every episode can recover. Scoped to the
17906
+ * consumable kinds (`systemEventFilterApplies`) and to the device-events
17907
+ * family; ignored on every other kind.
17908
+ *
17909
+ * It is a property of the RULE because the operator decided so: a rule at
17910
+ * 25 must be told about a filter at 20 %, a rule at 10 must not. The hub
17911
+ * keeps one episode per (threshold, device, item) — its own hysteresis, its
17912
+ * own reminder — and a rule hears only the episode judged at ITS threshold,
17913
+ * exactly as an occupancy rule hears only the edge of its own count. A
17914
+ * provider's own `replace` verdict is low at every threshold.
17915
+ */
17916
+ consumableLowPercent: number().int().min(1).max(95).optional()
17698
17917
  });
17699
17918
  /** Hard ceiling on a window (24h). A snooze that could not expire would be an
17700
17919
  * outage the operator asked for once and forgot. */
@@ -17712,6 +17931,25 @@ var NcScheduleSchema = object({
17712
17931
  /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
17713
17932
  invert: boolean().optional()
17714
17933
  });
17934
+ /**
17935
+ * How a system-event rule of the `device-events` or `system` family speaks
17936
+ * (D647): at once, per event (`instant`, the only behaviour before D647), or
17937
+ * as a STATE SUMMARY at the end of each window of `schedule`.
17938
+ */
17939
+ var NcSystemEventDeliveryModeSchema = _enum(["instant", "summary"]);
17940
+ /**
17941
+ * `summary`: the rule sends NOTHING per event. When a window of `schedule`
17942
+ * CLOSES, it sends one notification with the current state of its kinds
17943
+ * (low batteries, consumables to replace, devices offline, updates
17944
+ * available, ...), after its own filters. Nothing to report sends nothing.
17945
+ * The schedule is the ordinary `NcSchedule` (weekly windows, IANA timezone,
17946
+ * midnight crossing); the send time is each window's END. Refused on the
17947
+ * `alarm` family, which stays instant (`systemEventDeliveryProblems`).
17948
+ */
17949
+ var NcSystemEventDeliverySchema = discriminatedUnion("mode", [object({ mode: literal("instant") }), object({
17950
+ mode: literal("summary"),
17951
+ schedule: NcScheduleSchema
17952
+ })]);
17715
17953
  /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
17716
17954
  var NcPlateMatcherSchema = object({
17717
17955
  /**
@@ -18325,7 +18563,12 @@ var NcMediaPolicySchema = object({
18325
18563
  * the degrade engine, which drops the video and keeps the still.
18326
18564
  */
18327
18565
  clip: boolean().optional(),
18328
- /** Seconds of footage BEFORE / AFTER the event instant. Defaults 3 / 7. */
18566
+ /**
18567
+ * Seconds of footage BEFORE / AFTER the event instant. Absent =
18568
+ * {@link NC_CLIP_PRE_ROLL_DEFAULT_SEC} / {@link NC_CLIP_POST_ROLL_DEFAULT_SEC}
18569
+ * (4 / 6), resolved by the Notification Center at dispatch — deliberately not
18570
+ * a Zod default, so a rule that never chose keeps following the hub's.
18571
+ */
18329
18572
  clipPreRollSec: number().int().min(0).max(30).optional(),
18330
18573
  clipPostRollSec: number().int().min(0).max(30).optional(),
18331
18574
  /**
@@ -18447,6 +18690,16 @@ var NcRuleInputSchema = object({
18447
18690
  delivery: NcDeliverySchema,
18448
18691
  conditions: NcConditionsSchema.default({}),
18449
18692
  schedule: NcScheduleSchema.optional(),
18693
+ /**
18694
+ * A `device-events` / `system` rule's delivery (D647): absent or `instant`
18695
+ * is a notification per event; `summary` is one state summary per closed
18696
+ * window of its schedule. `.optional()` and never defaulted: absent must
18697
+ * keep meaning what every rule authored before D647 meant, with no
18698
+ * migration. Top-level rather than inside `conditions.systemEvent`, so a
18699
+ * client that does not know it (an older viewer re-sending `conditions`
18700
+ * whole) leaves it standing through the store's patch merge.
18701
+ */
18702
+ systemEventDelivery: NcSystemEventDeliverySchema.optional(),
18450
18703
  /** May be empty when `targetUsers` addresses at least one user — the
18451
18704
  * "at least one addressee" invariant is enforced by the provider, because
18452
18705
  * a cross-field refine here would break `NcRulePatchSchema.partial()`. */
@@ -18675,6 +18928,28 @@ var NcRuleSchema = NcRuleInputSchema.extend({
18675
18928
  */
18676
18929
  disabledTargetIds: array(string()).default([])
18677
18930
  });
18931
+ /** One section of a previewed state summary. `unavailable` = its state could not be read. */
18932
+ var NcStateSummaryPreviewSectionSchema = object({
18933
+ id: string(),
18934
+ status: _enum(["read", "unavailable"]),
18935
+ items: number().int().nonnegative(),
18936
+ reason: string().optional()
18937
+ });
18938
+ /**
18939
+ * The summary a rule would send now. `empty` = nothing to report and every
18940
+ * section read: such a summary is NOT sent. `dropped` counts the open states
18941
+ * the rule's own filters (or a camera mute) left out, by reason.
18942
+ * `excludedGroups` names the kind groups selected that have no state to report
18943
+ * (backups & exports).
18944
+ */
18945
+ var NcStateSummaryPreviewSchema = object({
18946
+ empty: boolean(),
18947
+ count: number().int().nonnegative(),
18948
+ text: string(),
18949
+ sections: array(NcStateSummaryPreviewSectionSchema),
18950
+ dropped: record(string(), number().int().nonnegative()),
18951
+ excludedGroups: array(string())
18952
+ });
18678
18953
  var NcTestResultSchema = object({
18679
18954
  recordId: string(),
18680
18955
  recordKind: _enum([
@@ -18766,6 +19041,13 @@ var NcTemplateVarDescriptorSchema = object({
18766
19041
  kinds: array(NcTemplateVarKindSchema).optional(),
18767
19042
  deliveries: array(NcDeliverySchema).optional(),
18768
19043
  systemEventKinds: array(NcSystemEventKindSchema).optional(),
19044
+ /**
19045
+ * Which system-event DELIVERY has a value for it (D647). Absent = an
19046
+ * instant row only when the descriptor names `systemEventKinds` (a
19047
+ * per-event fact: a summary row has no single device), and both otherwise.
19048
+ * `['summary']` marks the state-summary vocabulary (`{{summaryText}}`, ...).
19049
+ */
19050
+ systemEventDeliveries: array(NcSystemEventDeliveryModeSchema).optional(),
18769
19051
  dynamic: object({
18770
19052
  prefix: literal("count_"),
18771
19053
  from: literal("classes")
@@ -18778,7 +19060,9 @@ var NcTemplatePreviewInputSchema = object({
18778
19060
  field: NcTemplateFieldSchema,
18779
19061
  kind: NcRuleKindSchema.optional(),
18780
19062
  delivery: NcDeliverySchema.optional(),
18781
- systemEventKinds: array(NcSystemEventKindSchema).optional()
19063
+ systemEventKinds: array(NcSystemEventKindSchema).optional(),
19064
+ /** The rule's system-event delivery (D647); absent = instant. */
19065
+ systemEventDelivery: NcSystemEventDeliveryModeSchema.optional()
18782
19066
  }),
18783
19067
  template: object({
18784
19068
  title: string().max(500).optional(),
@@ -19312,6 +19596,10 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
19312
19596
  }), object({ results: array(NcTestResultSchema) }), {
19313
19597
  kind: "mutation",
19314
19598
  auth: "admin"
19599
+ }), method(object({ rule: NcRuleInputSchema }), NcStateSummaryPreviewSchema, {
19600
+ kind: "mutation",
19601
+ auth: "admin",
19602
+ access: "view"
19315
19603
  }), method(object({}), object({
19316
19604
  catalog: array(NcConditionDescriptorSchema),
19317
19605
  taxonomy: NcTaxonomySchema.optional()
@@ -19658,758 +19946,282 @@ var OauthIntegrationDescriptorSchema = object({
19658
19946
  });
19659
19947
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
19660
19948
  /**
19661
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
19662
- * within the frame, so the executor can re-cut a leaf child ROI at native
19663
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
19949
+ * A model choice has a SCOPE, and a scope change has a workflow.
19950
+ *
19951
+ * ## The two scopes
19952
+ *
19953
+ * Almost every pipeline step's model is a **node** question: which build runs
19954
+ * fastest on THIS accelerator. Two nodes may legitimately answer differently —
19955
+ * a Coral runs the tflite SSD, a Mac runs the coreml YOLO — because the answers
19956
+ * are compared against nothing. They produce boxes, and a box is a box.
19957
+ *
19958
+ * Two steps are not like that. `face-embedding` and `clip-embedding` produce
19959
+ * **vectors that land in ONE shared index** (`identity_samples`,
19960
+ * `vec_object_clip`) and are ranked against each other by cosine similarity.
19961
+ * Cosine similarity between two encoders is not a weak signal, it is a
19962
+ * meaningless number — and nothing inside a vector can tell you it happened.
19963
+ * So for those two steps the model is a **cluster** question with exactly one
19964
+ * answer, stored in exactly one row.
19965
+ *
19966
+ * That is the same argument [D52](../../../../docs/decisions/adr-0052.md) makes
19967
+ * for the crop convention (`detail-crop.ts`), one level up: the crop decides
19968
+ * WHAT pixels the encoder sees, this decides WHICH encoder sees them. Both are
19969
+ * cluster-wide for the same reason and neither may become per-node.
19970
+ *
19971
+ * ## Why the registry lives here and not in the step catalog
19972
+ *
19973
+ * The scope itself is declared on the step, in
19974
+ * `detection-pipeline/registry/step-definitions.ts` (`StepDefinition.modelScope`)
19975
+ * — that is where a new step declares what kind of choice its model is. But the
19976
+ * catalog lives inside `addon-pipeline`, and three packages that must NOT
19977
+ * import an addon need to know the set: the orchestrator (which renders and
19978
+ * stores the row), post-analysis (which pins the row for a re-embed pass) and
19979
+ * admin-ui (which mirrors it). So the set is mirrored here, and
19980
+ * `scripts/check-cluster-model-scope.ts` fails the build when the two disagree.
19981
+ * A hand-copied key that stops matching is exactly how a setting silently stops
19982
+ * arriving while both sides still look correct.
19983
+ *
19984
+ * ## The defaults ARE today's behaviour
19985
+ *
19986
+ * {@link DEFAULT_CLUSTER_STEP_MODELS} reproduces the catalog `defaultModelId`
19987
+ * of both steps. Declaring the scope therefore changes nothing on the day it
19988
+ * ships: the cluster row starts out saying what every node was already doing.
19989
+ * Changing it is legitimate — that is what the knob is for — but it invalidates
19990
+ * the stored vectors of that surface, and must be followed by a re-embed pass
19991
+ * (`face-reembed-pass.ts`, `embedding-rebuild.ts`).
19992
+ */
19993
+ /**
19994
+ * Why the orchestrator cannot say which model the operator chose for a
19995
+ * cluster-scoped step (D651).
19996
+ */
19997
+ var CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS = [
19998
+ "owner-not-ready",
19999
+ "store-read-failed",
20000
+ "three-way-read-unavailable",
20001
+ "invalid-stored",
20002
+ "not-cluster-scoped"
20003
+ ];
20004
+ Object.freeze(Object.fromEntries([{
20005
+ stepId: "face-embedding",
20006
+ label: "Face recognition model",
20007
+ defaultModelId: "auraface-r100",
20008
+ indexName: "the enrolled face gallery",
20009
+ options: [
20010
+ {
20011
+ id: "auraface-r100",
20012
+ label: "AuraFace R100"
20013
+ },
20014
+ {
20015
+ id: "arcface-r100",
20016
+ label: "ArcFace (ResNet34)"
20017
+ },
20018
+ {
20019
+ id: "inception-resnet-v1",
20020
+ label: "Inception ResNet V1"
20021
+ }
20022
+ ]
20023
+ }, {
20024
+ stepId: "clip-embedding",
20025
+ label: "Semantic search model",
20026
+ defaultModelId: "mobileclip-s1",
20027
+ indexName: "the object semantic-search index",
20028
+ options: [
20029
+ {
20030
+ id: "mobileclip-s1",
20031
+ label: "MobileCLIP S1"
20032
+ },
20033
+ {
20034
+ id: "mobileclip-s2",
20035
+ label: "MobileCLIP S2"
20036
+ },
20037
+ {
20038
+ id: "siglip2-b16-224",
20039
+ label: "SigLIP2 B/16 (Apache-2.0)"
20040
+ }
20041
+ ]
20042
+ }].map((s) => [s.stepId, s.defaultModelId])));
20043
+ var CLUSTER_STEP_SETTING_FIELDS = [{
20044
+ stepId: "face-embedding",
20045
+ key: "minLandmarkFaceSize",
20046
+ label: "Min face size for recognition (detection px)",
20047
+ description: "Refuse to embed a face smaller than this IN THE DETECTION FRAME. Applies to every node — the enrolled gallery is one index, and two admission floors would fill it from two policies. 0 disables the gate.",
20048
+ type: "slider",
20049
+ min: 0,
20050
+ max: 64,
20051
+ step: 2,
20052
+ default: 24
20053
+ }];
20054
+ function clusterStepSettingKey(stepId, fieldKey) {
20055
+ return `clusterStepSetting:${stepId}:${fieldKey}`;
20056
+ }
20057
+ var ClusterSettingNumberSchema = number().finite();
20058
+ function readClusterStepSettings(config) {
20059
+ const out = {};
20060
+ for (const field of CLUSTER_STEP_SETTING_FIELDS) {
20061
+ const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
20062
+ const value = parsed.success ? parsed.data : field.default;
20063
+ const existing = out[field.stepId] ?? {};
20064
+ out[field.stepId] = {
20065
+ ...existing,
20066
+ [field.key]: value
20067
+ };
20068
+ }
20069
+ return out;
20070
+ }
20071
+ readClusterStepSettings({});
20072
+ /**
20073
+ * pipeline-analytics — device-scoped wrapper cap. Refines raw
20074
+ * per-frame detections emitted by the pipeline runner into tracked
20075
+ * objects, per-kind event collections (motion / object / audio), and
20076
+ * persisted media. Owns the post-detection domain end-to-end:
20077
+ *
20078
+ * runner emits PipelineInferenceResult
20079
+ * ↓ (event bus)
20080
+ * pipeline-analytics subscriber
20081
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
20082
+ * → three DB collections (one per kind), one FS media tree, one
20083
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
20084
+ * DetectionEvent on bus)
20085
+ *
20086
+ * Pure subscriber model. No `processFrame` cap method — the runner
20087
+ * already publishes the raw frame on the bus. The cap surface is
20088
+ * only QUERIES + per-device settings, bound on/off via
20089
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
20090
+ * every camera with a detection pipeline wants its raw detections
20091
+ * refined; operators opt out per-device via BindingsTab when needed.
20092
+ *
20093
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
20094
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
19664
20095
  */
19665
- var NativeCropRefSchema = object({
19666
- /** Handle keying the retained native surface (node-pinned to its owner). */
19667
- handle: FrameHandleSchema,
19668
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
19669
- cropFrameSpace: object({
19670
- x: number(),
19671
- y: number(),
19672
- w: number(),
19673
- h: number()
19674
- })
19675
- });
19676
- object({
19677
- crop: object({
19678
- left: number(),
19679
- top: number(),
19680
- width: number().positive(),
19681
- height: number().positive()
19682
- }).optional(),
19683
- content: object({
19684
- width: number().int().positive(),
19685
- height: number().int().positive()
19686
- }),
19687
- fit: _enum(["stretch", "contain"]),
19688
- format: _enum([
19689
- "rgb",
19690
- "gray",
19691
- "jpeg"
19692
- ])
19693
- });
20096
+ var TrackStateSchema = _enum([
20097
+ "new",
20098
+ "entered",
20099
+ "left",
20100
+ "moving",
20101
+ "idle"
20102
+ ]);
20103
+ var EventKindSchema = _enum([
20104
+ "motion",
20105
+ "object",
20106
+ "audio"
20107
+ ]);
19694
20108
  /**
19695
- * Process-local frame identity. It is serializable so it can ride an in-process
19696
- * capability call, but `registryId` deliberately prevents resolution in any
19697
- * other process or execution group.
20109
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
20110
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
20111
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
19698
20112
  */
19699
- var FrameRefSchema = object({
19700
- registryId: string().min(1),
19701
- id: string().min(1),
19702
- width: number().int().positive(),
19703
- height: number().int().positive(),
19704
- format: _enum(["rgb", "gray"]),
19705
- timestamp: number(),
19706
- capturedAt: number().optional()
19707
- });
19708
- var ModelFormatSchema$1 = _enum([
19709
- "onnx",
19710
- "coreml",
19711
- "openvino",
19712
- "tflite",
19713
- "pt",
19714
- "gguf"
20113
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
20114
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
20115
+ var EventKindIconSchema = _enum([
20116
+ "motion",
20117
+ "audio",
20118
+ "person",
20119
+ "vehicle",
20120
+ "animal",
20121
+ "door",
20122
+ "pir",
20123
+ "smoke",
20124
+ "water",
20125
+ "button",
20126
+ "package",
20127
+ "generic"
19715
20128
  ]);
19716
- var PipelineSlotSchema = _enum([
19717
- "detector",
19718
- "cropper",
19719
- "classifier",
19720
- "refiner",
19721
- "audio-classifier"
20129
+ var EventKindCategorySchema = _enum([
20130
+ "motion",
20131
+ "audio",
20132
+ "detection",
20133
+ "sensor",
20134
+ "control",
20135
+ "custom",
20136
+ "package"
19722
20137
  ]);
19723
- var PipelineEngineChoiceSchema = object({
19724
- runtime: _enum(["node", "python"]),
19725
- backend: string(),
19726
- format: ModelFormatSchema$1,
19727
- device: string().optional()
19728
- });
19729
- var AvailableEngineSchema = object({
19730
- engine: PipelineEngineChoiceSchema,
19731
- devices: array(object({
19732
- id: string(),
19733
- label: string(),
19734
- description: string().optional()
19735
- })).readonly(),
19736
- defaultDevice: string()
19737
- });
19738
- var PipelineDefaultStepSchema = lazy(() => object({
19739
- addonId: string(),
19740
- addonName: string(),
19741
- slot: PipelineSlotSchema,
19742
- inputClasses: array(string()).readonly(),
19743
- outputClasses: array(string()).readonly(),
19744
- enabled: boolean(),
19745
- modelId: string(),
19746
- children: array(PipelineDefaultStepSchema).readonly(),
19747
- group: string().optional(),
19748
- settings: record(string(), unknown()).optional()
19749
- }));
19750
- var PipelineTemplateStepSchema = lazy(() => object({
19751
- addonId: string(),
19752
- enabled: boolean(),
19753
- modelId: string(),
19754
- children: array(PipelineTemplateStepSchema).readonly(),
19755
- settings: record(string(), unknown()).optional()
19756
- }));
19757
- var PipelineTemplateSchema$1 = object({
19758
- id: string(),
19759
- name: string(),
19760
- createdAt: string(),
19761
- updatedAt: string(),
19762
- engine: PipelineEngineChoiceSchema,
19763
- steps: array(PipelineTemplateStepSchema).readonly()
19764
- });
19765
- var PipelineModelOptionSchema = object({
19766
- id: string(),
19767
- name: string(),
19768
- formats: record(string(), object({
19769
- downloaded: boolean(),
19770
- sizeMB: number()
19771
- })),
19772
- group: ModelVariantGroupSchema.optional(),
19773
- legacy: boolean().optional(),
19774
- provider: ModelProviderIdSchema.optional()
19775
- });
19776
- var ConfigFieldBridge = custom();
19777
- var PipelineAddonSchemaSchema = object({
19778
- id: string(),
19779
- name: string(),
19780
- slot: PipelineSlotSchema,
19781
- inputClasses: array(string()).readonly(),
19782
- outputClasses: array(string()).readonly(),
19783
- childSlots: array(PipelineSlotSchema).readonly(),
19784
- models: array(PipelineModelOptionSchema).readonly(),
19785
- defaultModelId: string(),
19786
- defaultModelIdByFormat: record(string(), string()).optional(),
19787
- enabledByDefault: boolean().optional(),
19788
- backfillIntoExistingOverrides: boolean().optional(),
19789
- defaultConfidence: number(),
19790
- group: string().optional(),
19791
- configSchema: array(ConfigFieldBridge).readonly().optional()
19792
- });
19793
- var PipelineSlotSchemaSchema = object({
19794
- id: PipelineSlotSchema,
20138
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
20139
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
20140
+ var EventKindDescriptorSchema = object({
20141
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
20142
+ kind: string(),
20143
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
20144
+ labelKey: string(),
20145
+ /** English fallback label (kept for clients that don't translate). */
19795
20146
  label: string(),
19796
- priority: number(),
19797
- parentSlot: PipelineSlotSchema.nullable(),
19798
- addons: array(PipelineAddonSchemaSchema).readonly()
19799
- });
19800
- var PipelineSchemaSchema = object({
19801
- availableEngines: array(AvailableEngineSchema).readonly(),
19802
- selectedEngine: PipelineEngineChoiceSchema,
19803
- slots: array(PipelineSlotSchemaSchema).readonly()
19804
- });
19805
- var EngineProvisioningSchema = object({
19806
- runtimeId: _enum([
19807
- "onnx",
19808
- "openvino",
19809
- "coreml",
19810
- "edgetpu"
19811
- ]).nullable(),
19812
- device: string().nullable(),
19813
- state: _enum([
19814
- "idle",
19815
- "installing",
19816
- "verifying",
19817
- "ready",
19818
- "failed"
19819
- ]),
19820
- progress: number().optional(),
19821
- error: string().optional(),
19822
- nextRetryAt: number().optional(),
19823
- /**
19824
- * Gate A (config-correctness gate at engine change): human-readable
19825
- * config issues surfaced EAGERLY when the node's engine changes — model
19826
- * substitutions ("chose X, running Y") and zero-build steps ("no model
19827
- * has a <format> build"). Additive/optional: informational only, never
19828
- * enforced here — `assertEngineReady` (readiness) still gates inference.
19829
- * Absent/empty when the node-default tree resolves cleanly.
19830
- */
19831
- configIssues: array(string()).optional()
19832
- });
19833
- var PipelineStepInputSchema = lazy(() => object({
19834
- addonId: string(),
19835
- modelId: string().optional(),
19836
- enabled: boolean().default(true),
19837
- children: array(PipelineStepInputSchema).optional(),
19838
- settings: record(string(), unknown()).optional(),
19839
- jumpDeviceKey: string().optional()
19840
- }));
19841
- var ModelSubstitutionSchema = object({
19842
- addonId: string(),
19843
- chosen: string(),
19844
- running: string(),
19845
- format: string()
19846
- });
19847
- var PipelineValidationIssueSchema = object({
19848
- addonId: string(),
19849
- kind: _enum(["unknown-addon", "no-format-build"]),
19850
- detail: string()
19851
- });
19852
- var PipelineValidationResultSchema = object({
19853
- ok: boolean(),
19854
- issues: array(PipelineValidationIssueSchema).readonly(),
19855
- substitutions: array(ModelSubstitutionSchema).readonly(),
19856
- /** The node's `currentEngine.format` this validation ran against. */
19857
- format: string()
19858
- });
19859
- var ReferenceImageEntrySchema = object({
19860
- filename: string(),
19861
- stepIds: array(string()).readonly().optional()
19862
- });
19863
- var ReferenceImageBodySchema = object({
19864
- base64: string(),
19865
- filename: string()
20147
+ /** Hex color for timeline/legend rendering. */
20148
+ color: string(),
20149
+ /** Dictionary id → lucide component on the UI side. */
20150
+ iconId: string(),
20151
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
20152
+ icon: EventKindIconSchema,
20153
+ category: EventKindCategorySchema,
20154
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
20155
+ parentKind: string().nullable(),
20156
+ /** Derived from `parentKind`, explicit for the client tree. */
20157
+ level: EventKindLevelSchema,
20158
+ /** Which cap + device contributes this kind. For built-ins the camera
20159
+ * itself; for sensor kinds the LINKED source device. */
20160
+ source: object({
20161
+ capName: string(),
20162
+ deviceId: number()
20163
+ })
19866
20164
  });
19867
- var ReferenceAudioEntrySchema = object({
19868
- filename: string(),
19869
- sizeKb: number()
20165
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
20166
+ var EventKindsForDeviceSchema = object({
20167
+ deviceId: number(),
20168
+ kinds: array(EventKindDescriptorSchema).readonly()
19870
20169
  });
19871
- var ReferenceAudioBodySchema = object({ base64: string() });
19872
- var AudioBackendSchema = object({
20170
+ var SensorEventSchema = object({
19873
20171
  id: string(),
19874
- name: string(),
19875
- description: string(),
19876
- available: boolean(),
20172
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
20173
+ * yields N rows, one per camera). */
20174
+ deviceId: number(),
20175
+ /** The linked sensor device whose state changed. */
20176
+ sourceDeviceId: number(),
20177
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
20178
+ kind: string(),
20179
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
20180
+ value: record(string(), unknown()).nullable(),
20181
+ timestamp: number()
20182
+ });
20183
+ /**
20184
+ * One stored sighting on a track's trajectory.
20185
+ *
20186
+ * The array these live in is returned in TIME order (D399) — it is APPENDED in
20187
+ * arrival order, and the two detector passes interleave, so a consumer must not
20188
+ * assume the two are the same on a row written by an older build.
20189
+ */
20190
+ var TrackPositionSchema = object({
20191
+ x: number(),
20192
+ y: number(),
20193
+ timestamp: number(),
20194
+ bbox: BoundingBoxSchema,
19877
20195
  /**
19878
- * Raw classifier labels this backend can emit (e.g. YAMNet's
19879
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
19880
- * the benchmark UI to populate the `enabledMicroClasses` filter
19881
- * specific to the selected backend without a separate fetch.
20196
+ * Which detector pass measured this box (D399): `frame` is the full-frame
20197
+ * pass on the analysis raster, `recovery` is the native-resolution
20198
+ * small-subject second pass (D377/D378). Both write into one array, and until
20199
+ * this field existed the only way to tell them apart was that full-frame boxes
20200
+ * are exact multiples of 1.2 while recovery boxes are full-precision floats.
20201
+ * Absent on rows written before D399.
19882
20202
  */
19883
- rawLabels: array(string()).readonly().optional()
20203
+ source: _enum(["frame", "recovery"]).optional(),
20204
+ /** Detection score of this box, so a position can be weighed and not only
20205
+ * plotted. Absent on rows written before D399. */
20206
+ score: number().optional()
19884
20207
  });
19885
- var AudioCapabilitiesSchema = object({
19886
- activeBackend: string(),
19887
- availableBackends: array(AudioBackendSchema).readonly(),
19888
- sampleRate: number(),
19889
- chunkDurationMs: number()
20208
+ var TrackSnapshotSchema = object({
20209
+ timestamp: number(),
20210
+ position: TrackPositionSchema,
20211
+ /** The snapshot's media row id (D482); resolve via `listTrackMedia({ trackId })`. */
20212
+ mediaId: number().int()
19890
20213
  });
19891
- var DownloadModelResultSchema = object({
19892
- filePath: string(),
19893
- sizeMB: number(),
19894
- durationMs: number()
19895
- });
19896
- /**
19897
- * Wrapper carrying a single test run's result. Replaces the legacy
19898
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
19899
- * canonical `AudioResult` from the Phase 6 output rework: one
19900
- * `AudioDetection` per class above `minScore`, top-N candidates in
19901
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
19902
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
19903
- * benchmark UI can still report a clean failure when the classifier
19904
- * cap isn't available.
19905
- */
19906
- var AudioTestResultSchema = object({
19907
- success: boolean(),
19908
- error: string().optional(),
19909
- frame: custom().optional()
19910
- });
19911
- var PipelineConfigBridge = custom();
19912
- var ConfigUISchemaBridge = custom();
19913
- var ConfigUISchemaNullableBridge = custom();
19914
- var InferenceCapabilitiesBridge = custom();
19915
- var ModelAvailabilityListBridge = custom();
19916
- var PipelineRunResultBridge = custom();
19917
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
19918
- modelId: string(),
19919
- settings: record(string(), unknown()).readonly()
19920
- }))), method(object({ steps: record(string(), object({
19921
- modelId: string(),
19922
- settings: record(string(), unknown()).readonly()
19923
- })) }), object({ success: literal(true) }), {
19924
- kind: "mutation",
19925
- auth: "admin"
19926
- }), method(object({ nodeId: string() }), object({
19927
- success: literal(true),
19928
- clearedDevices: number()
19929
- }), {
19930
- kind: "mutation",
19931
- auth: "admin"
19932
- }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
19933
- /** `<backend>:<device>`, e.g. `openvino:gpu`. */
19934
- deviceKey: string(),
19935
- /**
19936
- * `failed` — the per-device restart budget is exhausted; no pool
19937
- * will be spawned until an operator re-arms it or the runner
19938
- * respawns. `backoff` — under budget, waiting out the backoff (or
19939
- * a cached pool observed dead and not yet condemned).
19940
- */
19941
- state: _enum(["failed", "backoff"]),
19942
- /** Epoch ms of the death that produced this state. */
19943
- since: number(),
19944
- /** Pool deaths inside the current window. */
19945
- deaths: number(),
19946
- /** The last death's message. */
19947
- lastError: string()
19948
- })).readonly() })), method(object({
19949
- nodeId: string(),
19950
- deviceKey: string()
19951
- }), object({ rearmed: boolean() }), {
19952
- kind: "mutation",
19953
- auth: "admin"
19954
- }), method(_void(), PipelineSchemaSchema), method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()), method(_void(), PipelineConfigBridge), method(_void(), ConfigUISchemaBridge), method(object({ steps: array(PipelineStepInputSchema) }), PipelineValidationResultSchema), method(_void(), array(PipelineTemplateSchema$1).readonly()), method(object({
19955
- name: string(),
19956
- steps: array(PipelineTemplateStepSchema).readonly(),
19957
- engine: PipelineEngineChoiceSchema
19958
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
19959
- id: string(),
19960
- name: string().optional(),
19961
- steps: array(PipelineTemplateStepSchema).readonly().optional()
19962
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
19963
- addonId: string(),
19964
- modelId: string(),
19965
- format: ModelFormatSchema$1
19966
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
19967
- addonId: string(),
19968
- modelId: string(),
19969
- format: ModelFormatSchema$1
19970
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
19971
- engine: PipelineEngineChoiceSchema.optional(),
19972
- steps: array(PipelineStepInputSchema).min(1),
19973
- frame: FrameInputSchema.optional(),
19974
- /**
19975
- * Process-local lazy frame. Valid only when caller and provider resolve
19976
- * in the same execution-group process; split/cross-node callers use
19977
- * `frame`/`image` inline compatibility instead.
19978
- */
19979
- frameRef: FrameRefSchema.optional(),
19980
- /**
19981
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
19982
- * the decoded pixels live in. One more member of the one-of
19983
- * frame/frameHandle/image/imageBase64/referenceImage group.
19984
- */
19985
- frameHandle: FrameHandleSchema.optional(),
19986
- imageBase64: string().optional(),
19987
- /**
19988
- * Binary JPEG bytes — preferred over `imageBase64` on internal
19989
- * hops (hub → forked worker via Moleculer MsgPack) because it
19990
- * skips the 33% base64 overhead + the per-call base64 decode on
19991
- * the detection-pipeline worker. Callers can pass either; exactly
19992
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
19993
- */
19994
- image: _instanceof(Uint8Array).optional(),
19995
- referenceImage: string().optional(),
19996
- deviceId: number().optional(),
19997
- sessionId: string().optional(),
19998
- /**
19999
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
20000
- * reference-image, and detail-subtree calls. 'frame' is the live
20001
- * per-frame dispatch: ONLY root-plane steps run; crop children
20002
- * (inputClasses ≠ null) are skipped and served per-track via
20003
- * pipelineRunner.runDetailSubtree (two-plane design).
20004
- */
20005
- plane: _enum(["full", "frame"]).optional(),
20006
- /**
20007
- * Inference-device selector (Phase 2 multi-device). Format
20008
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
20009
- * Omitted ⇒ the runner's default device (current single-engine
20010
- * behaviour). Selects WHICH device pool of the node runs the call.
20011
- */
20012
- deviceKey: string().optional(),
20013
- /**
20014
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
20015
- * when the parent crop was resolved from the frame's retained NATIVE
20016
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
20017
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
20018
- * resolution from that surface — the SAME quality path faces already
20019
- * had — instead of the downscaled parent tile. `handle` keys the native
20020
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
20021
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
20022
- * the executor's crop-normalized child ROI back into frame-normalized
20023
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
20024
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
20025
- * (today's behaviour on the fallback path).
20026
- */
20027
- nativeCropRef: NativeCropRefSchema.optional()
20028
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
20029
- engine: PipelineEngineChoiceSchema.optional(),
20030
- steps: array(PipelineStepInputSchema).min(1),
20031
- frames: array(FrameInputSchema).min(1).max(255),
20032
- deviceId: number().optional(),
20033
- sessionId: string().optional(),
20034
- /**
20035
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
20036
- * the batch to the Python pool's bench preprocess cache
20037
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
20038
- * preprocessed ONCE and every later inference is a pure-inference cache
20039
- * hit — the sustained-throughput run measures inference, not
20040
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
20041
- * full preprocess every call, correct). Fresh per sustained run;
20042
- * released via `uncacheFrame`.
20043
- */
20044
- frameId: number().int().nonnegative().optional(),
20045
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
20046
- deviceKey: string().optional()
20047
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
20048
- data: _instanceof(Uint8Array),
20049
- width: number().int().positive(),
20050
- height: number().int().positive(),
20051
- format: _enum([
20052
- "rgb",
20053
- "bgr",
20054
- "gray"
20055
- ])
20056
- }), object({
20057
- frameId: number(),
20058
- width: number(),
20059
- height: number()
20060
- }), { kind: "mutation" }), method(object({
20061
- stepId: string(),
20062
- frameId: number().int()
20063
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
20064
- batchMode: string(),
20065
- windowMs: number(),
20066
- maxBatchSize: number(),
20067
- concurrency: number()
20068
- })), method(_void(), array(object({
20069
- engineKey: string(),
20070
- engine: PipelineEngineChoiceSchema,
20071
- modelsLoaded: array(string()).readonly(),
20072
- inUseByCameras: array(number()).readonly(),
20073
- /**
20074
- * Origin of this resident factory.
20075
- * - `runtime` — main camera-serving engine (no idle TTL).
20076
- * - `warm-override` — benchmark/test override held in the warm
20077
- * cache; auto-disposed after the idle TTL.
20078
- * - `device-pool` — a concurrent per-device pool (Phase 2
20079
- * multi-device, keyed by `deviceKey`) resolved
20080
- * via `resolveDeviceFactory`. Runs alongside the
20081
- * `runtime` engine on a DIFFERENT accelerator
20082
- * (NPU / iGPU / Coral) — this is how the
20083
- * Engines tab shows all pools running at once.
20084
- */
20085
- kind: _enum([
20086
- "runtime",
20087
- "warm-override",
20088
- "device-pool"
20089
- ]),
20090
- /** Native pid of the underlying Python pool (null when no pool). */
20091
- poolPid: number().nullable(),
20092
- /** ms since this factory was last used (null when not warm-tracked). */
20093
- idleMs: number().nullable(),
20094
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
20095
- idleTtlMs: number().nullable()
20096
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
20097
- kind: "mutation",
20098
- auth: "admin"
20099
- }), method(object({
20100
- engine: PipelineEngineChoiceSchema,
20101
- force: boolean().optional()
20102
- }), object({
20103
- success: boolean(),
20104
- reason: string().optional()
20105
- }), {
20106
- kind: "mutation",
20107
- auth: "admin"
20108
- }), method(_void(), array(ReferenceImageEntrySchema).readonly()), method(object({ filename: string() }), ReferenceImageBodySchema.nullable()), method(_void(), array(ReferenceAudioEntrySchema).readonly()), method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()), method(_void(), AudioCapabilitiesSchema), method(object({
20109
- addonId: string(),
20110
- modelId: string(),
20111
- filename: string().optional(),
20112
- settings: record(string(), unknown()).optional()
20113
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
20114
- /**
20115
- * Per-stage gating mode applied to the zones a rule references.
20116
- *
20117
- * - `include`: the rule contributes to a **whitelist** for its stage.
20118
- * When at least one `include` rule fires for a stage, only entities
20119
- * inside one of those zones pass that stage.
20120
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
20121
- * Entities inside one of those zones are dropped at that stage.
20122
- *
20123
- * `monitor`-style observation (count without filtering) is not a rule
20124
- * mode — zones without any matching rule are observed naturally by
20125
- * `zone-analytics` (live snapshot + history), so an "I just want to
20126
- * count, not filter" use case needs no rule at all.
20127
- */
20128
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
20129
- /**
20130
- * Per-consumer rule that references existing zones (geometry) and
20131
- * defines how a specific pipeline stage should treat them. Each
20132
- * consumer addon owns its own `ZoneRule[]` array in its per-device
20133
- * settings:
20134
- *
20135
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
20136
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
20137
- * - future: notification rules, audio gating, etc.
20138
- *
20139
- * One rule applies to N zones (`zoneIds[]`) so the operator can
20140
- * express "ignore motion in ALL of {garden, street}" with a single
20141
- * rule. `classFilter` narrows the rule to specific object classes —
20142
- * "drop person detections in the street, but keep cars" is one
20143
- * `exclude` rule with `classFilter: ['person']`.
20144
- *
20145
- * `enabled` is a soft toggle — the operator can keep the rule
20146
- * configured but inert without deleting it.
20147
- */
20148
- var ZoneRuleSchema = object({
20149
- /** Stable rule id — survives edits, used by the UI for diffing. */
20150
- id: string(),
20151
- /** Optional human-readable label rendered in the rule editor. */
20152
- name: string().optional(),
20153
- /** Zones this rule targets. The rule's `mode` applies to ALL
20154
- * listed zones (OR-set: a detection in any one of them counts).
20155
- * At least one zone id required — a rule with no targets is a
20156
- * configuration mistake and the form validator rejects it. */
20157
- zoneIds: array(string()).min(1).readonly(),
20158
- mode: ZoneRuleModeEnum,
20159
- /**
20160
- * Class names this rule applies to. Empty / undefined ⇒ rule
20161
- * applies to every class. Class strings match the `macroClass`
20162
- * field on detections (e.g. `person`, `car`, `dog`).
20163
- */
20164
- classFilter: array(string()).readonly().optional(),
20165
- /**
20166
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
20167
- * required to consider an entity "in the zone". Defaults to the
20168
- * consumer's stage default when omitted. Kept for back-compat with
20169
- * existing per-rule overrides; new operators pick the value via
20170
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
20171
- * set, the lower-level engine reads it as a 0–1 fraction.
20172
- */
20173
- overlapThreshold: number().min(0).max(1).optional(),
20174
- /**
20175
- * Operator-friendly version of `overlapThreshold` — the percentage
20176
- * of the detection's bbox that must lie inside the zone for the
20177
- * rule to match. Documented default is 85%; the engine substitutes
20178
- * that when the field is omitted (kept optional so existing rules
20179
- * stored without it stay valid).
20180
- *
20181
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
20182
- * rule, the engine prefers `bboxInclusionPct` because it's the
20183
- * field exposed in the UI. Internally both feed the same gate.
20184
- */
20185
- bboxInclusionPct: number().min(0).max(100).optional(),
20186
- /**
20187
- * When `true` and a detection has a segmentation mask, use the
20188
- * mask for overlap instead of the bbox. Detection-stage only;
20189
- * motion rules ignore this field.
20190
- */
20191
- preferMask: boolean().optional(),
20192
- /**
20193
- * Soft-toggle: `false` disables the rule without deleting it.
20194
- * Defaults to `true` so operators creating a rule via the UI
20195
- * see it active immediately.
20196
- */
20197
- enabled: boolean().default(true)
20198
- });
20199
- array(ZoneRuleSchema).readonly();
20200
- /**
20201
- * Zone — pure geometry + identity. NO filtering behaviour.
20202
- *
20203
- * Zones describe **where** in the frame the operator wants to flag
20204
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
20205
- * each pipeline stage uses them. Splitting the two means a single
20206
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
20207
- * a detection-include rule on `['car']`, and an occupancy aggregate
20208
- * — without three duplicated polygons.
20209
- *
20210
- * Owned by the orchestrator addon (provider) and mirrored into the
20211
- * `zones` device-state slice on every mutation. Consumers
20212
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
20213
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
20214
- * mirror with `onChanged`).
20215
- *
20216
- * Coordinates are normalised fractions of the frame (0–1) so zones
20217
- * survive resolution changes and stream profile switches.
20218
- *
20219
- * `kind` discriminates between full polygons (closed regions used
20220
- * for intrusion / occupancy filters) and tripwires (open 2-point
20221
- * line segments used for cross events). Onboard / firmware-reported
20222
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
20223
- * task list.
20224
- */
20225
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
20226
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
20227
- var PolygonPointSchema = object({
20228
- x: number(),
20229
- y: number()
20230
- });
20231
- /** A camera detection zone — pure geometry/identity. */
20232
- var ZoneSchema = object({
20233
- id: string(),
20234
- name: string(),
20235
- kind: ZoneKindEnum.default("polygon"),
20236
- /** Polygon vertices, fraction of frame (0–1). */
20237
- polygon: array(PolygonPointSchema).readonly(),
20238
- /** Visual color for UI rendering. */
20239
- color: string().default("#3b82f6")
20240
- });
20241
- DeviceType.Camera, method(object({ deviceId: number() }), array(ZoneSchema).readonly()), method(object({
20242
- deviceId: number(),
20243
- zone: ZoneSchema
20244
- }), _void(), {
20245
- kind: "mutation",
20246
- auth: "admin"
20247
- }), method(object({
20248
- deviceId: number(),
20249
- zoneId: string()
20250
- }), _void(), {
20251
- kind: "mutation",
20252
- auth: "admin"
20253
- }), method(object({
20254
- deviceId: number(),
20255
- zone: ZoneSchema
20256
- }), _void(), {
20257
- kind: "mutation",
20258
- auth: "admin"
20259
- }), object({ zones: array(ZoneSchema).readonly() });
20260
- /**
20261
- * pipeline-analytics — device-scoped wrapper cap. Refines raw
20262
- * per-frame detections emitted by the pipeline runner into tracked
20263
- * objects, per-kind event collections (motion / object / audio), and
20264
- * persisted media. Owns the post-detection domain end-to-end:
20265
- *
20266
- * runner emits PipelineInferenceResult
20267
- * ↓ (event bus)
20268
- * pipeline-analytics subscriber
20269
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
20270
- * → three DB collections (one per kind), one FS media tree, one
20271
- * unified event emitter (FrameTracked + TrackStarted/Ended +
20272
- * DetectionEvent on bus)
20273
- *
20274
- * Pure subscriber model. No `processFrame` cap method — the runner
20275
- * already publishes the raw frame on the bus. The cap surface is
20276
- * only QUERIES + per-device settings, bound on/off via
20277
- * `device-manager.setWrapperActive`. `defaultActive: true` because
20278
- * every camera with a detection pipeline wants its raw detections
20279
- * refined; operators opt out per-device via BindingsTab when needed.
20280
- *
20281
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
20282
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
20283
- */
20284
- var TrackStateSchema = _enum([
20285
- "new",
20286
- "entered",
20287
- "left",
20288
- "moving",
20289
- "idle"
20290
- ]);
20291
- var EventKindSchema = _enum([
20292
- "motion",
20293
- "object",
20294
- "audio"
20295
- ]);
20296
- /**
20297
- * Spatial filter for `listTracks` — the rect + polygon variants of the shared
20298
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
20299
- * of the camera frame (top-left origin), matching the drawing-plane editor.
20300
- */
20301
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
20302
- /** Closed icon vocabulary so clients render a known glyph per kind. */
20303
- var EventKindIconSchema = _enum([
20304
- "motion",
20305
- "audio",
20306
- "person",
20307
- "vehicle",
20308
- "animal",
20309
- "door",
20310
- "pir",
20311
- "smoke",
20312
- "water",
20313
- "button",
20314
- "package",
20315
- "generic"
20316
- ]);
20317
- var EventKindCategorySchema = _enum([
20318
- "motion",
20319
- "audio",
20320
- "detection",
20321
- "sensor",
20322
- "control",
20323
- "custom",
20324
- "package"
20325
- ]);
20326
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
20327
- var EventKindLevelSchema = _enum(["macro", "sub"]);
20328
- var EventKindDescriptorSchema = object({
20329
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
20330
- kind: string(),
20331
- /** i18n key resolved on the UI side; `label` is the English fallback. */
20332
- labelKey: string(),
20333
- /** English fallback label (kept for clients that don't translate). */
20334
- label: string(),
20335
- /** Hex color for timeline/legend rendering. */
20336
- color: string(),
20337
- /** Dictionary id → lucide component on the UI side. */
20338
- iconId: string(),
20339
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
20340
- icon: EventKindIconSchema,
20341
- category: EventKindCategorySchema,
20342
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
20343
- parentKind: string().nullable(),
20344
- /** Derived from `parentKind`, explicit for the client tree. */
20345
- level: EventKindLevelSchema,
20346
- /** Which cap + device contributes this kind. For built-ins the camera
20347
- * itself; for sensor kinds the LINKED source device. */
20348
- source: object({
20349
- capName: string(),
20350
- deviceId: number()
20351
- })
20352
- });
20353
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
20354
- var EventKindsForDeviceSchema = object({
20355
- deviceId: number(),
20356
- kinds: array(EventKindDescriptorSchema).readonly()
20357
- });
20358
- var SensorEventSchema = object({
20359
- id: string(),
20360
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
20361
- * yields N rows, one per camera). */
20362
- deviceId: number(),
20363
- /** The linked sensor device whose state changed. */
20364
- sourceDeviceId: number(),
20365
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
20366
- kind: string(),
20367
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
20368
- value: record(string(), unknown()).nullable(),
20369
- timestamp: number()
20370
- });
20371
- /**
20372
- * One stored sighting on a track's trajectory.
20373
- *
20374
- * The array these live in is returned in TIME order (D399) — it is APPENDED in
20375
- * arrival order, and the two detector passes interleave, so a consumer must not
20376
- * assume the two are the same on a row written by an older build.
20377
- */
20378
- var TrackPositionSchema = object({
20379
- x: number(),
20380
- y: number(),
20381
- timestamp: number(),
20382
- bbox: BoundingBoxSchema,
20383
- /**
20384
- * Which detector pass measured this box (D399): `frame` is the full-frame
20385
- * pass on the analysis raster, `recovery` is the native-resolution
20386
- * small-subject second pass (D377/D378). Both write into one array, and until
20387
- * this field existed the only way to tell them apart was that full-frame boxes
20388
- * are exact multiples of 1.2 while recovery boxes are full-precision floats.
20389
- * Absent on rows written before D399.
20390
- */
20391
- source: _enum(["frame", "recovery"]).optional(),
20392
- /** Detection score of this box, so a position can be weighed and not only
20393
- * plotted. Absent on rows written before D399. */
20394
- score: number().optional()
20395
- });
20396
- var TrackSnapshotSchema = object({
20397
- timestamp: number(),
20398
- position: TrackPositionSchema,
20399
- /** The snapshot's media row id (D482); resolve via `listTrackMedia({ trackId })`. */
20400
- mediaId: number().int()
20401
- });
20402
- /**
20403
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
20404
- * divided by the track's detection-frame dims), computed at persist time.
20405
- * Absent when the frame dims were unknown when the track was persisted
20406
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
20407
- */
20408
- var TrackEnvelopeSchema = object({
20409
- minX: number(),
20410
- minY: number(),
20411
- maxX: number(),
20412
- maxY: number()
20214
+ /**
20215
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
20216
+ * divided by the track's detection-frame dims), computed at persist time.
20217
+ * Absent when the frame dims were unknown when the track was persisted
20218
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
20219
+ */
20220
+ var TrackEnvelopeSchema = object({
20221
+ minX: number(),
20222
+ minY: number(),
20223
+ maxX: number(),
20224
+ maxY: number()
20413
20225
  });
20414
20226
  /**
20415
20227
  * Row projection for track list queries. `full` (default) returns the
@@ -20828,6 +20640,22 @@ var TrackSchema = object({
20828
20640
  * omit it. Render nothing when absent.
20829
20641
  */
20830
20642
  previewMissReason: string().optional(),
20643
+ /**
20644
+ * The ROOT model that produced this track — the `FrameResult.rootModelId` of
20645
+ * the frame it was BORN on (D646). What a later replay compares against, so
20646
+ * "the original model" is named rather than assumed. A birth fact: never
20647
+ * rewritten by a later frame. **Absent ≠ unknown-model**: a row from before
20648
+ * the column, and a track the camera's own detector produced, carry none.
20649
+ */
20650
+ modelId: string().optional(),
20651
+ /**
20652
+ * Size (px) of the detection frame this track's `positions[].bbox` live in —
20653
+ * the frame it was born on, else the camera's latest analysis frame at
20654
+ * persist time. Divide a position by these to normalise it. Absent when the
20655
+ * size was never known.
20656
+ */
20657
+ frameWidth: number().optional(),
20658
+ frameHeight: number().optional(),
20831
20659
  ...TrackFlagFields,
20832
20660
  ...TrackRetrainFields
20833
20661
  });
@@ -21057,7 +20885,8 @@ var MediaFileKindEnum = _enum([
21057
20885
  "thumbnailSmall",
21058
20886
  "confirmationCrop",
21059
20887
  "debugCrop",
21060
- "sceneFrame"
20888
+ "sceneFrame",
20889
+ "lastSceneFrame"
21061
20890
  ]);
21062
20891
  /**
21063
20892
  * One media row ON THE WIRE: what it is, how big it is, and WHERE ITS BYTES
@@ -21609,7 +21438,23 @@ var SearchObjectEventsInput = object({
21609
21438
  until: number().optional(),
21610
21439
  classFilter: string().optional(),
21611
21440
  limit: number().default(50),
21612
- minScore: number().min(0).max(1).default(.2)
21441
+ /**
21442
+ * An ABSOLUTE cosine floor. Optional since D649: a floor is a property of the
21443
+ * model (0.2 kept 96% of matched pairs on MobileCLIP S1 and 2.7% on SigLIP2),
21444
+ * so an absent one resolves to the searched model's own `searchMinScore`
21445
+ * scaled by `strictness`. A number sent here is honoured verbatim.
21446
+ */
21447
+ minScore: number().min(0).max(1).optional(),
21448
+ /** Model-relative floor — see `resolveClipSearchMinScore`. Default `loose`. */
21449
+ strictness: ClipSearchStrictnessSchema.optional(),
21450
+ /**
21451
+ * Search THIS CLIP model's index instead of the cluster row's. Every index a
21452
+ * model ever wrote stays searchable until it is wiped (the MobileCLIP index
21453
+ * through a SigLIP2 cutover and its rollback window). An id with no CLIP
21454
+ * metadata is refused; an id other than the cluster row's is ADMIN-only
21455
+ * (`model-override-requires-admin`).
21456
+ */
21457
+ modelId: string().min(1).optional()
21613
21458
  });
21614
21459
  var TrackCascadeCountsSchema = object({
21615
21460
  /** Persisted track roots deleted (authoritative). */
@@ -21744,7 +21589,41 @@ var RebuildObjectEmbeddingsInput = object({
21744
21589
  * comparable, so wiping and rebuilding is the only way to be sure every vector
21745
21590
  * means the same thing.
21746
21591
  */
21747
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
21592
+ var WipeObjectEmbeddingsResultSchema = object({
21593
+ deleted: number(),
21594
+ /**
21595
+ * CLIP indexes that could NOT be emptied (unreachable, or refused at their
21596
+ * dimension) — not a clean slate. Additive and optional (D649).
21597
+ */
21598
+ failedIndexes: array(string()).optional()
21599
+ });
21600
+ /**
21601
+ * Why a rebuild did not start, BY NAME — ONE vocabulary for both gates in front
21602
+ * of a pass (D649 over D651). A bare `started: false` read the same for "the
21603
+ * stores are booting" and "the cluster row names a model with no CLIP
21604
+ * metadata", which need different fixes.
21605
+ * - `stores-unavailable` — the analytics stores or the API are not up yet.
21606
+ * - the owner's confirmation of the cluster model (D651, `ClusterPinConfirmer`):
21607
+ * a pass that rewrites an index needs two agreeing reads of the OWNER's
21608
+ * answer (`pipelineOrchestrator.getClusterModelChoice`) — a pass that cannot
21609
+ * name its model does not run (D54):
21610
+ * - the owner's own `unreadable` reasons (`owner-not-ready`,
21611
+ * `store-read-failed`, `three-way-read-unavailable`, `invalid-stored`,
21612
+ * `not-cluster-scoped`);
21613
+ * - `method-unavailable` — the orchestrator predates the method;
21614
+ * - `read-failed` — the call failed or answered something unparseable;
21615
+ * - `reads-disagree` — the two reads named different choices.
21616
+ * - `not-a-clip-model` — the CONFIRMED id has no CLIP metadata, so there is no
21617
+ * index to fill and no dimension to check against (D649).
21618
+ */
21619
+ var RebuildObjectEmbeddingsRefusalSchema = _enum([
21620
+ "stores-unavailable",
21621
+ ...CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS,
21622
+ "method-unavailable",
21623
+ "read-failed",
21624
+ "reads-disagree",
21625
+ "not-a-clip-model"
21626
+ ]);
21748
21627
  /**
21749
21628
  * Acknowledgement that a rebuild STARTED.
21750
21629
  *
@@ -21757,7 +21636,12 @@ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
21757
21636
  var RebuildObjectEmbeddingsResultSchema = object({
21758
21637
  started: boolean(),
21759
21638
  /** True when a pass was already running; the new request is ignored. */
21760
- alreadyRunning: boolean()
21639
+ alreadyRunning: boolean(),
21640
+ /** Present when the pass refused to start — see `RebuildObjectEmbeddingsRefusalSchema`. */
21641
+ refusal: RebuildObjectEmbeddingsRefusalSchema.optional(),
21642
+ /** The CLIP model the pass pinned, and the index it fills (when it started). */
21643
+ modelId: string().optional(),
21644
+ index: string().optional()
21761
21645
  });
21762
21646
  var RebuildStatusSchema = object({
21763
21647
  running: boolean(),
@@ -21791,7 +21675,11 @@ var RebuildStatusSchema = object({
21791
21675
  startedAtMs: number().nullable(),
21792
21676
  finishedAtMs: number().nullable(),
21793
21677
  /** Present when the pass ended by throwing. */
21794
- error: string().nullable()
21678
+ error: string().nullable(),
21679
+ /** The CLIP model the current / last pass pinned (D54), `null` before any. */
21680
+ modelId: string().nullable(),
21681
+ /** The index that pass fills — `ClipModelMeta.vectorIndex` of `modelId` (D649). */
21682
+ index: string().nullable()
21795
21683
  });
21796
21684
  /**
21797
21685
  * Acknowledgement that a debug-media reclaim STARTED.
@@ -21834,24 +21722,6 @@ var MediaReclaimStatusSchema = object({
21834
21722
  finishedAtMs: number().nullable(),
21835
21723
  error: string().nullable()
21836
21724
  });
21837
- var ReplayFrameInputSchema = object({
21838
- timestamp: number(),
21839
- frame: PipelineRunResultBridge
21840
- });
21841
- var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
21842
- className: string(),
21843
- firstSeenMs: number(),
21844
- lastSeenMs: number(),
21845
- /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
21846
- * frame — a representative box for the diff's `(className, window, IoU)`
21847
- * pairing (`replay-diff.ts`). A replay does not need the full per-frame
21848
- * trajectory production's `Track.positions` keeps. */
21849
- bbox: BoundingBoxSchema,
21850
- /** How many of the input frames this track matched a real detection on
21851
- * (never a coasted/extrapolated frame) — the replay's own signal for "how
21852
- * solid is this track", cheaper than re-deriving it from a trajectory. */
21853
- framesMatched: number().int()
21854
- })).readonly() });
21855
21725
  /**
21856
21726
  * The long-term series a camera produces. A closed union so a typo cannot
21857
21727
  * invent one, and the ONE declaration of it — the addon's `AnalyticsLtsSeries`
@@ -22011,162 +21881,624 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22011
21881
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
22012
21882
  kind: "mutation",
22013
21883
  auth: "admin"
22014
- }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
22015
- kind: "query",
22016
- auth: "admin"
22017
- }), method(object({}), array(RelocateJobSchema).readonly(), {
22018
- kind: "query",
22019
- auth: "admin"
22020
- }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21884
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
21885
+ kind: "query",
21886
+ auth: "admin"
21887
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
21888
+ kind: "query",
21889
+ auth: "admin"
21890
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21891
+ kind: "mutation",
21892
+ auth: "admin"
21893
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
21894
+ kind: "query",
21895
+ auth: "admin"
21896
+ }), method(MediaReclaimInputSchema, MediaReclaimStartResultSchema, {
21897
+ kind: "mutation",
21898
+ auth: "admin"
21899
+ }), method(object({}), MediaReclaimStatusSchema, {
21900
+ kind: "query",
21901
+ auth: "admin"
21902
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
21903
+ kind: "query",
21904
+ auth: "admin"
21905
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
21906
+ kind: "query",
21907
+ auth: "admin"
21908
+ }), method(object({
21909
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
21910
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
21911
+ * route it at one camera's owner, and "every camera" would stop being
21912
+ * expressible at all. */
21913
+ deviceIds: array(number()).optional(),
21914
+ limit: number().int().min(1).max(500).optional()
21915
+ }), array(RetrainTrackSchema).readonly(), {
21916
+ kind: "query",
21917
+ auth: "admin"
21918
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
21919
+ kind: "query",
21920
+ auth: "admin"
21921
+ }), method(object({
21922
+ deviceId: number(),
21923
+ trackId: string(),
21924
+ mediaIds: array(number().int()).min(1)
21925
+ }), RetrainFrameSelectionSchema, {
21926
+ kind: "mutation",
21927
+ auth: "admin"
21928
+ }), method(object({
21929
+ deviceId: number(),
21930
+ trackId: string(),
21931
+ frameId: string()
21932
+ }), object({
21933
+ removed: boolean(),
21934
+ removedAnnotations: number().int()
21935
+ }), {
21936
+ kind: "mutation",
21937
+ auth: "admin"
21938
+ }), method(object({ frameId: string() }), object({
21939
+ base64: string(),
21940
+ width: number().int(),
21941
+ height: number().int()
21942
+ }), {
21943
+ kind: "query",
21944
+ auth: "admin"
21945
+ }), method(object({
21946
+ deviceId: number(),
21947
+ trackId: string(),
21948
+ frameId: string(),
21949
+ subject: RetrainAssistSubjectSchema,
21950
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
21951
+ nodeId: string().optional()
21952
+ }), RetrainAssistResultSchema, {
21953
+ kind: "mutation",
21954
+ auth: "admin"
21955
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
21956
+ kind: "query",
21957
+ auth: "admin"
21958
+ }), method(object({
21959
+ deviceId: number(),
21960
+ trackId: string(),
21961
+ frameId: string(),
21962
+ annotations: array(RetrainAnnotationDraftSchema)
21963
+ }), array(RetrainAnnotationSchema).readonly(), {
21964
+ kind: "mutation",
21965
+ auth: "admin"
21966
+ }), method(object({
21967
+ deviceId: number(),
21968
+ trackId: string()
21969
+ }), RetrainTransitionResultSchema, {
21970
+ kind: "mutation",
21971
+ auth: "admin"
21972
+ }), method(object({
21973
+ deviceId: number(),
21974
+ trackId: string()
21975
+ }), RetrainTransitionResultSchema, {
21976
+ kind: "mutation",
21977
+ auth: "admin"
21978
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
21979
+ kind: "query",
21980
+ auth: "admin"
21981
+ }), method(object({
21982
+ /** Which of the three event tables owns the row. */
21983
+ ownerType: EventOwnerTypeSchema,
21984
+ /** The event's rowid in that table (D474: an event id is a number). */
21985
+ eventId: number().int(),
21986
+ kind: MediaFileKindEnum.optional(),
21987
+ deviceId: number()
21988
+ }), array(MediaFileSchema).readonly()), method(object({
21989
+ trackId: string(),
21990
+ kinds: array(MediaFileKindEnum).optional(),
21991
+ deviceId: number()
21992
+ }), array(MediaFileSchema).readonly()), method(object({
21993
+ trackId: string(),
21994
+ deviceId: number()
21995
+ }), array(MediaFileInfoSchema).readonly()), method(object({
21996
+ ownerType: EventOwnerTypeSchema,
21997
+ eventId: number().int(),
21998
+ deviceId: number()
21999
+ }), array(MediaFileInfoSchema).readonly()), method(object({
22000
+ deviceId: number(),
22001
+ ownerKind: MediaPresenceOwnerKindSchema,
22002
+ ownerIds: array(string()).max(5e3)
22003
+ }), array(string()).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly(), { caller: "required" }), method(object({}), WipeObjectEmbeddingsResultSchema, {
22004
+ kind: "mutation",
22005
+ auth: "admin"
22006
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
22007
+ kind: "mutation",
22008
+ auth: "admin"
22009
+ }), method(object({}), RebuildStatusSchema), object({
22010
+ deviceId: number(),
22011
+ timestamp: number(),
22012
+ frameWidth: number(),
22013
+ frameHeight: number(),
22014
+ detections: array(OverlayDetectionSchema).readonly()
22015
+ }), object({
22016
+ deviceId: number(),
22017
+ trackId: string(),
22018
+ className: string()
22019
+ }), object({
22020
+ deviceId: number(),
22021
+ trackId: string(),
22022
+ className: string(),
22023
+ durationMs: number()
22024
+ }), object({
22025
+ deviceId: number(),
22026
+ kind: EventKindSchema,
22027
+ eventId: string(),
22028
+ timestamp: number()
22029
+ });
22030
+ /**
22031
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
22032
+ * within the frame, so the executor can re-cut a leaf child ROI at native
22033
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
22034
+ */
22035
+ var NativeCropRefSchema = object({
22036
+ /** Handle keying the retained native surface (node-pinned to its owner). */
22037
+ handle: FrameHandleSchema,
22038
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
22039
+ cropFrameSpace: object({
22040
+ x: number(),
22041
+ y: number(),
22042
+ w: number(),
22043
+ h: number()
22044
+ })
22045
+ });
22046
+ object({
22047
+ crop: object({
22048
+ left: number(),
22049
+ top: number(),
22050
+ width: number().positive(),
22051
+ height: number().positive()
22052
+ }).optional(),
22053
+ content: object({
22054
+ width: number().int().positive(),
22055
+ height: number().int().positive()
22056
+ }),
22057
+ fit: _enum(["stretch", "contain"]),
22058
+ format: _enum([
22059
+ "rgb",
22060
+ "gray",
22061
+ "jpeg"
22062
+ ])
22063
+ });
22064
+ /**
22065
+ * Process-local frame identity. It is serializable so it can ride an in-process
22066
+ * capability call, but `registryId` deliberately prevents resolution in any
22067
+ * other process or execution group.
22068
+ */
22069
+ var FrameRefSchema = object({
22070
+ registryId: string().min(1),
22071
+ id: string().min(1),
22072
+ width: number().int().positive(),
22073
+ height: number().int().positive(),
22074
+ format: _enum(["rgb", "gray"]),
22075
+ timestamp: number(),
22076
+ capturedAt: number().optional()
22077
+ });
22078
+ var ModelFormatSchema$1 = _enum([
22079
+ "onnx",
22080
+ "coreml",
22081
+ "openvino",
22082
+ "tflite",
22083
+ "pt",
22084
+ "gguf"
22085
+ ]);
22086
+ var PipelineSlotSchema = _enum([
22087
+ "detector",
22088
+ "cropper",
22089
+ "classifier",
22090
+ "refiner",
22091
+ "audio-classifier"
22092
+ ]);
22093
+ var PipelineEngineChoiceSchema = object({
22094
+ runtime: literal("python"),
22095
+ backend: string(),
22096
+ format: ModelFormatSchema$1,
22097
+ device: string().optional()
22098
+ });
22099
+ /**
22100
+ * One pool's resolved provisioning (`getEffectiveTuning`). `numWorkers` is the
22101
+ * knob that lifts a saturated pool (`inference-devices.md`); `concurrency` is
22102
+ * per-worker in-flight requests. `deviceKey` echoes the pool asked about —
22103
+ * `null` for the node-default pool.
22104
+ */
22105
+ var EffectiveTuningSchema = object({
22106
+ deviceKey: string().nullable(),
22107
+ runtime: string(),
22108
+ batchMode: string(),
22109
+ windowMs: number(),
22110
+ maxBatchSize: number(),
22111
+ concurrency: number(),
22112
+ numWorkers: number()
22113
+ });
22114
+ var AvailableEngineSchema = object({
22115
+ engine: PipelineEngineChoiceSchema,
22116
+ devices: array(object({
22117
+ id: string(),
22118
+ label: string(),
22119
+ description: string().optional()
22120
+ })).readonly(),
22121
+ defaultDevice: string()
22122
+ });
22123
+ var PipelineDefaultStepSchema = lazy(() => object({
22124
+ addonId: string(),
22125
+ addonName: string(),
22126
+ slot: PipelineSlotSchema,
22127
+ inputClasses: array(string()).readonly(),
22128
+ outputClasses: array(string()).readonly(),
22129
+ enabled: boolean(),
22130
+ modelId: string(),
22131
+ children: array(PipelineDefaultStepSchema).readonly(),
22132
+ group: string().optional(),
22133
+ settings: record(string(), unknown()).optional()
22134
+ }));
22135
+ var PipelineTemplateStepSchema = lazy(() => object({
22136
+ addonId: string(),
22137
+ enabled: boolean(),
22138
+ modelId: string(),
22139
+ children: array(PipelineTemplateStepSchema).readonly(),
22140
+ settings: record(string(), unknown()).optional()
22141
+ }));
22142
+ var PipelineTemplateSchema$1 = object({
22143
+ id: string(),
22144
+ name: string(),
22145
+ createdAt: string(),
22146
+ updatedAt: string(),
22147
+ engine: PipelineEngineChoiceSchema,
22148
+ steps: array(PipelineTemplateStepSchema).readonly()
22149
+ });
22150
+ var PipelineModelOptionSchema = object({
22151
+ id: string(),
22152
+ name: string(),
22153
+ formats: record(string(), object({
22154
+ downloaded: boolean(),
22155
+ sizeMB: number()
22156
+ })),
22157
+ group: ModelVariantGroupSchema.optional(),
22158
+ legacy: boolean().optional(),
22159
+ provider: ModelProviderIdSchema.optional()
22160
+ });
22161
+ var ConfigFieldBridge = custom();
22162
+ var PipelineAddonSchemaSchema = object({
22163
+ id: string(),
22164
+ name: string(),
22165
+ slot: PipelineSlotSchema,
22166
+ inputClasses: array(string()).readonly(),
22167
+ outputClasses: array(string()).readonly(),
22168
+ childSlots: array(PipelineSlotSchema).readonly(),
22169
+ models: array(PipelineModelOptionSchema).readonly(),
22170
+ defaultModelId: string(),
22171
+ defaultModelIdByFormat: record(string(), string()).optional(),
22172
+ enabledByDefault: boolean().optional(),
22173
+ backfillIntoExistingOverrides: boolean().optional(),
22174
+ defaultConfidence: number(),
22175
+ group: string().optional(),
22176
+ configSchema: array(ConfigFieldBridge).readonly().optional()
22177
+ });
22178
+ var PipelineSlotSchemaSchema = object({
22179
+ id: PipelineSlotSchema,
22180
+ label: string(),
22181
+ priority: number(),
22182
+ parentSlot: PipelineSlotSchema.nullable(),
22183
+ addons: array(PipelineAddonSchemaSchema).readonly()
22184
+ });
22185
+ var PipelineSchemaSchema = object({
22186
+ availableEngines: array(AvailableEngineSchema).readonly(),
22187
+ selectedEngine: PipelineEngineChoiceSchema,
22188
+ slots: array(PipelineSlotSchemaSchema).readonly()
22189
+ });
22190
+ var EngineProvisioningSchema = object({
22191
+ runtimeId: _enum([
22192
+ "onnx",
22193
+ "openvino",
22194
+ "coreml",
22195
+ "edgetpu"
22196
+ ]).nullable(),
22197
+ device: string().nullable(),
22198
+ state: _enum([
22199
+ "idle",
22200
+ "installing",
22201
+ "verifying",
22202
+ "ready",
22203
+ "failed"
22204
+ ]),
22205
+ progress: number().optional(),
22206
+ error: string().optional(),
22207
+ nextRetryAt: number().optional(),
22208
+ /**
22209
+ * Gate A (config-correctness gate at engine change): human-readable
22210
+ * config issues surfaced EAGERLY when the node's engine changes — model
22211
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
22212
+ * has a <format> build"). Additive/optional: informational only, never
22213
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
22214
+ * Absent/empty when the node-default tree resolves cleanly.
22215
+ */
22216
+ configIssues: array(string()).optional()
22217
+ });
22218
+ var PipelineStepInputSchema = lazy(() => object({
22219
+ addonId: string(),
22220
+ modelId: string().optional(),
22221
+ enabled: boolean().default(true),
22222
+ children: array(PipelineStepInputSchema).optional(),
22223
+ settings: record(string(), unknown()).optional(),
22224
+ jumpDeviceKey: string().optional()
22225
+ }));
22226
+ var ModelSubstitutionSchema = object({
22227
+ addonId: string(),
22228
+ chosen: string(),
22229
+ running: string(),
22230
+ format: string()
22231
+ });
22232
+ var PipelineValidationIssueSchema = object({
22233
+ addonId: string(),
22234
+ kind: _enum([
22235
+ "unknown-addon",
22236
+ "no-format-build",
22237
+ "unknown-device"
22238
+ ]),
22239
+ detail: string()
22240
+ });
22241
+ var PipelineValidationResultSchema = object({
22242
+ ok: boolean(),
22243
+ issues: array(PipelineValidationIssueSchema).readonly(),
22244
+ substitutions: array(ModelSubstitutionSchema).readonly(),
22245
+ /** The node's `currentEngine.format` this validation ran against. */
22246
+ format: string()
22247
+ });
22248
+ var ReferenceImageEntrySchema = object({
22249
+ filename: string(),
22250
+ stepIds: array(string()).readonly().optional()
22251
+ });
22252
+ var ReferenceImageBodySchema = object({
22253
+ base64: string(),
22254
+ filename: string()
22255
+ });
22256
+ var ReferenceAudioEntrySchema = object({
22257
+ filename: string(),
22258
+ sizeKb: number()
22259
+ });
22260
+ var ReferenceAudioBodySchema = object({ base64: string() });
22261
+ var AudioBackendSchema = object({
22262
+ id: string(),
22263
+ name: string(),
22264
+ description: string(),
22265
+ available: boolean(),
22266
+ /**
22267
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
22268
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
22269
+ * the benchmark UI to populate the `enabledMicroClasses` filter
22270
+ * specific to the selected backend without a separate fetch.
22271
+ */
22272
+ rawLabels: array(string()).readonly().optional()
22273
+ });
22274
+ var AudioCapabilitiesSchema = object({
22275
+ activeBackend: string(),
22276
+ availableBackends: array(AudioBackendSchema).readonly(),
22277
+ sampleRate: number(),
22278
+ chunkDurationMs: number()
22279
+ });
22280
+ var DownloadModelResultSchema = object({
22281
+ filePath: string(),
22282
+ sizeMB: number(),
22283
+ durationMs: number()
22284
+ });
22285
+ /**
22286
+ * Wrapper carrying a single test run's result. Replaces the legacy
22287
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
22288
+ * canonical `AudioResult` from the Phase 6 output rework: one
22289
+ * `AudioDetection` per class above `minScore`, top-N candidates in
22290
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
22291
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
22292
+ * benchmark UI can still report a clean failure when the classifier
22293
+ * cap isn't available.
22294
+ */
22295
+ var AudioTestResultSchema = object({
22296
+ success: boolean(),
22297
+ error: string().optional(),
22298
+ frame: custom().optional()
22299
+ });
22300
+ var PipelineConfigBridge = custom();
22301
+ var ConfigUISchemaBridge = custom();
22302
+ var ConfigUISchemaNullableBridge = custom();
22303
+ var InferenceCapabilitiesBridge = custom();
22304
+ var ModelAvailabilityListBridge = custom();
22305
+ var PipelineRunResultBridge = custom();
22306
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
22307
+ modelId: string(),
22308
+ settings: record(string(), unknown()).readonly()
22309
+ }))), method(object({ steps: record(string(), object({
22310
+ modelId: string(),
22311
+ settings: record(string(), unknown()).readonly()
22312
+ })) }), object({ success: literal(true) }), {
22313
+ kind: "mutation",
22314
+ auth: "admin"
22315
+ }), method(object({ nodeId: string() }), object({
22316
+ success: literal(true),
22317
+ clearedDevices: number()
22318
+ }), {
22021
22319
  kind: "mutation",
22022
22320
  auth: "admin"
22023
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
22024
- kind: "query",
22025
- auth: "admin"
22026
- }), method(MediaReclaimInputSchema, MediaReclaimStartResultSchema, {
22321
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
22322
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
22323
+ deviceKey: string(),
22324
+ /**
22325
+ * `failed` — the per-device restart budget is exhausted; no pool
22326
+ * will be spawned until an operator re-arms it or the runner
22327
+ * respawns. `backoff` — under budget, waiting out the backoff (or
22328
+ * a cached pool observed dead and not yet condemned).
22329
+ */
22330
+ state: _enum(["failed", "backoff"]),
22331
+ /** Epoch ms of the death that produced this state. */
22332
+ since: number(),
22333
+ /** Pool deaths inside the current window. */
22334
+ deaths: number(),
22335
+ /** The last death's message. */
22336
+ lastError: string()
22337
+ })).readonly() })), method(object({
22338
+ nodeId: string(),
22339
+ deviceKey: string()
22340
+ }), object({ rearmed: boolean() }), {
22027
22341
  kind: "mutation",
22028
22342
  auth: "admin"
22029
- }), method(object({}), MediaReclaimStatusSchema, {
22030
- kind: "query",
22031
- auth: "admin"
22032
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
22033
- kind: "query",
22034
- auth: "admin"
22035
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
22036
- kind: "query",
22037
- auth: "admin"
22038
- }), method(object({
22039
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
22040
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
22041
- * route it at one camera's owner, and "every camera" would stop being
22042
- * expressible at all. */
22043
- deviceIds: array(number()).optional(),
22044
- limit: number().int().min(1).max(500).optional()
22045
- }), array(RetrainTrackSchema).readonly(), {
22046
- kind: "query",
22047
- auth: "admin"
22048
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
22049
- kind: "query",
22050
- auth: "admin"
22051
- }), method(object({
22052
- deviceId: number(),
22053
- trackId: string(),
22054
- mediaIds: array(number().int()).min(1)
22055
- }), RetrainFrameSelectionSchema, {
22343
+ }), method(_void(), PipelineSchemaSchema), method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()), method(_void(), PipelineConfigBridge), method(_void(), ConfigUISchemaBridge), method(object({
22344
+ steps: array(PipelineStepInputSchema),
22345
+ deviceKey: string().optional()
22346
+ }), PipelineValidationResultSchema), method(_void(), array(PipelineTemplateSchema$1).readonly()), method(object({
22347
+ name: string(),
22348
+ steps: array(PipelineTemplateStepSchema).readonly(),
22349
+ engine: PipelineEngineChoiceSchema
22350
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
22351
+ id: string(),
22352
+ name: string().optional(),
22353
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
22354
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
22355
+ addonId: string(),
22356
+ modelId: string(),
22357
+ format: ModelFormatSchema$1
22358
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
22359
+ addonId: string(),
22360
+ modelId: string(),
22361
+ format: ModelFormatSchema$1
22362
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
22363
+ steps: array(PipelineStepInputSchema).min(1),
22364
+ frame: FrameInputSchema.optional(),
22365
+ /**
22366
+ * Process-local lazy frame. Valid only when caller and provider resolve
22367
+ * in the same execution-group process; split/cross-node callers use
22368
+ * `frame`/`image` inline compatibility instead.
22369
+ */
22370
+ frameRef: FrameRefSchema.optional(),
22371
+ /**
22372
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
22373
+ * the decoded pixels live in. One more member of the one-of
22374
+ * frame/frameHandle/image/imageBase64/referenceImage group.
22375
+ */
22376
+ frameHandle: FrameHandleSchema.optional(),
22377
+ imageBase64: string().optional(),
22378
+ /**
22379
+ * Binary JPEG bytes — preferred over `imageBase64` on internal
22380
+ * hops (hub → forked worker via Moleculer MsgPack) because it
22381
+ * skips the 33% base64 overhead + the per-call base64 decode on
22382
+ * the detection-pipeline worker. Callers can pass either; exactly
22383
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
22384
+ */
22385
+ image: _instanceof(Uint8Array).optional(),
22386
+ referenceImage: string().optional(),
22387
+ deviceId: number().optional(),
22388
+ sessionId: string().optional(),
22389
+ /**
22390
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
22391
+ * reference-image, and detail-subtree calls. 'frame' is the live
22392
+ * per-frame dispatch: ONLY root-plane steps run; crop children
22393
+ * (inputClasses ≠ null) are skipped and served per-track via
22394
+ * pipelineRunner.runDetailSubtree (two-plane design).
22395
+ */
22396
+ plane: _enum(["full", "frame"]).optional(),
22397
+ /**
22398
+ * Inference-device selector (Phase 2 multi-device). Format
22399
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
22400
+ * Omitted ⇒ the runner's default device (current single-engine
22401
+ * behaviour). Selects WHICH device pool of the node runs the call.
22402
+ */
22403
+ deviceKey: string().optional(),
22404
+ /**
22405
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
22406
+ * when the parent crop was resolved from the frame's retained NATIVE
22407
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
22408
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
22409
+ * resolution from that surface — the SAME quality path faces already
22410
+ * had — instead of the downscaled parent tile. `handle` keys the native
22411
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
22412
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
22413
+ * the executor's crop-normalized child ROI back into frame-normalized
22414
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
22415
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
22416
+ * (today's behaviour on the fallback path).
22417
+ */
22418
+ nativeCropRef: NativeCropRefSchema.optional(),
22419
+ /**
22420
+ * Offline REPLAY of stored media for `deviceId` (D56, D646): the
22421
+ * camera's zone gate and overrides apply as live, every executing
22422
+ * step runs EXACTLY the model it names on the `deviceKey` pool it
22423
+ * names or the call refuses (`model-not-servable` /
22424
+ * `device-not-servable`), and nothing reaches the camera's live
22425
+ * trace stream. Absent ⇒ unchanged behaviour.
22426
+ */
22427
+ replay: literal(true).optional()
22428
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
22429
+ steps: array(PipelineStepInputSchema).min(1),
22430
+ frames: array(FrameInputSchema).min(1).max(255),
22431
+ deviceId: number().optional(),
22432
+ sessionId: string().optional(),
22433
+ /**
22434
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
22435
+ * the batch to the Python pool's bench preprocess cache
22436
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
22437
+ * preprocessed ONCE and every later inference is a pure-inference cache
22438
+ * hit — the sustained-throughput run measures inference, not
22439
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
22440
+ * full preprocess every call, correct). Fresh per sustained run;
22441
+ * released via `uncacheFrame`.
22442
+ */
22443
+ frameId: number().int().nonnegative().optional(),
22444
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
22445
+ deviceKey: string().optional()
22446
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
22447
+ data: _instanceof(Uint8Array),
22448
+ width: number().int().positive(),
22449
+ height: number().int().positive(),
22450
+ format: _enum([
22451
+ "rgb",
22452
+ "bgr",
22453
+ "gray"
22454
+ ])
22455
+ }), object({
22456
+ frameId: number(),
22457
+ width: number(),
22458
+ height: number()
22459
+ }), { kind: "mutation" }), method(object({
22460
+ stepId: string(),
22461
+ frameId: number().int()
22462
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(object({ deviceKey: string().optional() }), EffectiveTuningSchema), method(_void(), array(object({
22463
+ engineKey: string(),
22464
+ engine: PipelineEngineChoiceSchema,
22465
+ modelsLoaded: array(string()).readonly(),
22466
+ inUseByCameras: array(number()).readonly(),
22467
+ /**
22468
+ * Origin of this resident factory.
22469
+ * - `runtime` — main camera-serving engine (no idle TTL).
22470
+ * - `device-pool` — a concurrent per-device pool (Phase 2
22471
+ * multi-device, keyed by `deviceKey`) resolved
22472
+ * via `resolveDeviceFactory`. Runs alongside the
22473
+ * `runtime` engine on a DIFFERENT accelerator
22474
+ * (NPU / iGPU / Coral) — this is how the
22475
+ * Engines tab shows all pools running at once.
22476
+ */
22477
+ kind: _enum(["runtime", "device-pool"]),
22478
+ /** Native pid of the underlying Python pool (null when no pool). */
22479
+ poolPid: number().nullable(),
22480
+ /** ms since this factory was last used (null when not warm-tracked). */
22481
+ idleMs: number().nullable(),
22482
+ /** Idle TTL after which the factory self-evicts (null when not applicable). */
22483
+ idleTtlMs: number().nullable()
22484
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
22056
22485
  kind: "mutation",
22057
22486
  auth: "admin"
22058
22487
  }), method(object({
22059
- deviceId: number(),
22060
- trackId: string(),
22061
- frameId: string()
22488
+ engine: PipelineEngineChoiceSchema,
22489
+ force: boolean().optional()
22062
22490
  }), object({
22063
- removed: boolean(),
22064
- removedAnnotations: number().int()
22065
- }), {
22066
- kind: "mutation",
22067
- auth: "admin"
22068
- }), method(object({ frameId: string() }), object({
22069
- base64: string(),
22070
- width: number().int(),
22071
- height: number().int()
22491
+ success: boolean(),
22492
+ reason: string().optional()
22072
22493
  }), {
22073
- kind: "query",
22074
- auth: "admin"
22075
- }), method(object({
22076
- deviceId: number(),
22077
- trackId: string(),
22078
- frameId: string(),
22079
- subject: RetrainAssistSubjectSchema,
22080
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
22081
- nodeId: string().optional()
22082
- }), RetrainAssistResultSchema, {
22083
- kind: "mutation",
22084
- auth: "admin"
22085
- }), method(object({
22086
- deviceId: number(),
22087
- source: DetectionSourceSchema,
22088
- zones: array(ZoneSchema).readonly().optional(),
22089
- detectionRules: array(ZoneRuleSchema).readonly().optional(),
22090
- zoneMembershipMinOverlap: number().min(0).max(1).optional(),
22091
- frames: array(ReplayFrameInputSchema).min(1)
22092
- }), RunReplayFrameProcessorResultSchema, {
22093
- kind: "mutation",
22094
- auth: "admin"
22095
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
22096
- kind: "query",
22097
- auth: "admin"
22098
- }), method(object({
22099
- deviceId: number(),
22100
- trackId: string(),
22101
- frameId: string(),
22102
- annotations: array(RetrainAnnotationDraftSchema)
22103
- }), array(RetrainAnnotationSchema).readonly(), {
22104
- kind: "mutation",
22105
- auth: "admin"
22106
- }), method(object({
22107
- deviceId: number(),
22108
- trackId: string()
22109
- }), RetrainTransitionResultSchema, {
22110
- kind: "mutation",
22111
- auth: "admin"
22112
- }), method(object({
22113
- deviceId: number(),
22114
- trackId: string()
22115
- }), RetrainTransitionResultSchema, {
22116
- kind: "mutation",
22117
- auth: "admin"
22118
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
22119
- kind: "query",
22120
- auth: "admin"
22121
- }), method(object({
22122
- /** Which of the three event tables owns the row. */
22123
- ownerType: EventOwnerTypeSchema,
22124
- /** The event's rowid in that table (D474: an event id is a number). */
22125
- eventId: number().int(),
22126
- kind: MediaFileKindEnum.optional(),
22127
- deviceId: number()
22128
- }), array(MediaFileSchema).readonly()), method(object({
22129
- trackId: string(),
22130
- kinds: array(MediaFileKindEnum).optional(),
22131
- deviceId: number()
22132
- }), array(MediaFileSchema).readonly()), method(object({
22133
- trackId: string(),
22134
- deviceId: number()
22135
- }), array(MediaFileInfoSchema).readonly()), method(object({
22136
- ownerType: EventOwnerTypeSchema,
22137
- eventId: number().int(),
22138
- deviceId: number()
22139
- }), array(MediaFileInfoSchema).readonly()), method(object({
22140
- deviceId: number(),
22141
- ownerKind: MediaPresenceOwnerKindSchema,
22142
- ownerIds: array(string()).max(5e3)
22143
- }), array(string()).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
22144
22494
  kind: "mutation",
22145
22495
  auth: "admin"
22146
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
22147
- kind: "mutation",
22148
- auth: "admin"
22149
- }), method(object({}), RebuildStatusSchema), object({
22150
- deviceId: number(),
22151
- timestamp: number(),
22152
- frameWidth: number(),
22153
- frameHeight: number(),
22154
- detections: array(OverlayDetectionSchema).readonly()
22155
- }), object({
22156
- deviceId: number(),
22157
- trackId: string(),
22158
- className: string()
22159
- }), object({
22160
- deviceId: number(),
22161
- trackId: string(),
22162
- className: string(),
22163
- durationMs: number()
22164
- }), object({
22165
- deviceId: number(),
22166
- kind: EventKindSchema,
22167
- eventId: string(),
22168
- timestamp: number()
22169
- });
22496
+ }), method(_void(), array(ReferenceImageEntrySchema).readonly()), method(object({ filename: string() }), ReferenceImageBodySchema.nullable()), method(_void(), array(ReferenceAudioEntrySchema).readonly()), method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()), method(_void(), AudioCapabilitiesSchema), method(object({
22497
+ addonId: string(),
22498
+ modelId: string(),
22499
+ filename: string().optional(),
22500
+ settings: record(string(), unknown()).optional()
22501
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
22170
22502
  object({
22171
22503
  activeCameras: number(),
22172
22504
  throttledCameras: number(),
@@ -22192,6 +22524,66 @@ var CameraMetricsSchema = object({
22192
22524
  });
22193
22525
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
22194
22526
  /**
22527
+ * Zone — pure geometry + identity. NO filtering behaviour.
22528
+ *
22529
+ * Zones describe **where** in the frame the operator wants to flag
22530
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
22531
+ * each pipeline stage uses them. Splitting the two means a single
22532
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
22533
+ * a detection-include rule on `['car']`, and an occupancy aggregate
22534
+ * — without three duplicated polygons.
22535
+ *
22536
+ * Owned by the orchestrator addon (provider) and mirrored into the
22537
+ * `zones` device-state slice on every mutation. Consumers
22538
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
22539
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
22540
+ * mirror with `onChanged`).
22541
+ *
22542
+ * Coordinates are normalised fractions of the frame (0–1) so zones
22543
+ * survive resolution changes and stream profile switches.
22544
+ *
22545
+ * `kind` discriminates between full polygons (closed regions used
22546
+ * for intrusion / occupancy filters) and tripwires (open 2-point
22547
+ * line segments used for cross events). Onboard / firmware-reported
22548
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
22549
+ * task list.
22550
+ */
22551
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
22552
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
22553
+ var PolygonPointSchema = object({
22554
+ x: number(),
22555
+ y: number()
22556
+ });
22557
+ /** A camera detection zone — pure geometry/identity. */
22558
+ var ZoneSchema = object({
22559
+ id: string(),
22560
+ name: string(),
22561
+ kind: ZoneKindEnum.default("polygon"),
22562
+ /** Polygon vertices, fraction of frame (0–1). */
22563
+ polygon: array(PolygonPointSchema).readonly(),
22564
+ /** Visual color for UI rendering. */
22565
+ color: string().default("#3b82f6")
22566
+ });
22567
+ DeviceType.Camera, method(object({ deviceId: number() }), array(ZoneSchema).readonly()), method(object({
22568
+ deviceId: number(),
22569
+ zone: ZoneSchema
22570
+ }), _void(), {
22571
+ kind: "mutation",
22572
+ auth: "admin"
22573
+ }), method(object({
22574
+ deviceId: number(),
22575
+ zoneId: string()
22576
+ }), _void(), {
22577
+ kind: "mutation",
22578
+ auth: "admin"
22579
+ }), method(object({
22580
+ deviceId: number(),
22581
+ zone: ZoneSchema
22582
+ }), _void(), {
22583
+ kind: "mutation",
22584
+ auth: "admin"
22585
+ }), object({ zones: array(ZoneSchema).readonly() });
22586
+ /**
22195
22587
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
22196
22588
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
22197
22589
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -22378,7 +22770,17 @@ var DetailResultSchema = object({
22378
22770
  /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
22379
22771
  * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
22380
22772
  * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
22381
- nativeFaceShortSidePx: number().optional()
22773
+ nativeFaceShortSidePx: number().optional(),
22774
+ /**
22775
+ * The five facial landmarks of a `face` detail, in the SAME frame space as
22776
+ * `bbox` (D644). Additive and optional: post-analysis stores them beside the
22777
+ * face's source frame so a future alignment can be re-derived exactly; a
22778
+ * runner that predates the field sends none and the face is stored without.
22779
+ */
22780
+ landmarks: array(object({
22781
+ x: number(),
22782
+ y: number()
22783
+ })).optional()
22382
22784
  });
22383
22785
  /**
22384
22786
  * Why an executing node REFUSED a stateless step run (`runStatelessStep`).
@@ -22633,6 +23035,17 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
22633
23035
  hubHostnameOverride: string().optional()
22634
23036
  })]).describe("Per-camera frame-source mode for the runner (P2c)");
22635
23037
  /**
23038
+ * What ONE step runs with on ONE roster device for THIS camera (D650): the
23039
+ * device's per-(node,device) base with the camera's override for that device
23040
+ * on top — the same `override ?? base` merge the orchestrator applies to the
23041
+ * elected device (`applyDeviceProvisioning`). Absent `modelId` ⇒ the executor
23042
+ * resolves the device format's default, exactly as on the elected device.
23043
+ */
23044
+ var RunnerJumpStepProvisioningSchema = object({
23045
+ modelId: string().optional(),
23046
+ settings: record(string(), unknown()).optional()
23047
+ });
23048
+ /**
22636
23049
  * One ENABLED inference device on the runner's node, as the step-tree
22637
23050
  * device-jump resolver sees it (phase 1). The orchestrator populates this
22638
23051
  * roster on the attach payload whenever the camera is elected onto a specific
@@ -22644,7 +23057,16 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
22644
23057
  var RunnerInferenceDeviceSchema = object({
22645
23058
  deviceKey: string(),
22646
23059
  weight: number().positive().default(1),
22647
- maxSessions: number().int().positive().nullable().default(null)
23060
+ maxSessions: number().int().positive().nullable().default(null),
23061
+ /**
23062
+ * Per-step provisioning for this camera on THIS device (D650), keyed by step
23063
+ * id. A step the runner jumps here runs with these fields, never with the
23064
+ * elected device's: `modelId` / `settings` are REPLACED on the jumped subtree
23065
+ * (a step absent from the map runs with neither — the target format default).
23066
+ * Absent field ⇒ an orchestrator that predates D650: the jumped step keeps
23067
+ * the elected device's provisioning, as before.
23068
+ */
23069
+ steps: record(string(), RunnerJumpStepProvisioningSchema).optional()
22648
23070
  });
22649
23071
  /**
22650
23072
  * Camera assignment payload sent by `addon-pipeline-orchestrator` to a
@@ -23519,6 +23941,28 @@ var NodeInferenceDeviceSchema = object({
23519
23941
  */
23520
23942
  exclusion: InferenceDeviceExclusionReasonSchema.nullable()
23521
23943
  });
23944
+ /**
23945
+ * The operator's model choice for one cluster-scoped step, answered by the
23946
+ * addon that OWNS the `clusterModel:*` settings (D651). Three answers, never
23947
+ * folded: a written choice, a key nobody wrote (the cluster runs the default
23948
+ * BY ABSENCE), or no answer. A caller that rewrites an index acts only on the
23949
+ * first two, read twice and agreeing.
23950
+ */
23951
+ var ClusterModelChoiceSchema = discriminatedUnion("kind", [
23952
+ object({
23953
+ kind: literal("stored"),
23954
+ modelId: string()
23955
+ }),
23956
+ object({
23957
+ kind: literal("absent"),
23958
+ defaultModelId: string()
23959
+ }),
23960
+ object({
23961
+ kind: literal("unreadable"),
23962
+ reason: _enum(CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS),
23963
+ error: string().optional()
23964
+ })
23965
+ ]);
23522
23966
  var NodeInferenceDevicesSchema = object({
23523
23967
  nodeId: string(),
23524
23968
  /** False when the node's platform-probe was unreachable (no live device set). */
@@ -23546,10 +23990,17 @@ method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
23546
23990
  }), object({ success: literal(true) }), {
23547
23991
  kind: "mutation",
23548
23992
  auth: "admin"
23549
- }), method(object({ deviceId: number() }), object({ deviceKey: string().nullable() })), method(_void(), object({ migrated: number() }), {
23993
+ }), method(object({ deviceId: number() }), object({ deviceKey: string().nullable() })), method(_void(), object({
23994
+ migrated: number(),
23995
+ skipped: array(object({
23996
+ deviceId: number(),
23997
+ targetNodeId: string(),
23998
+ reason: string()
23999
+ })).default([])
24000
+ }), {
23550
24001
  kind: "mutation",
23551
24002
  auth: "admin"
23552
- }), method(_void(), array(PipelineAssignmentSchema).readonly()), method(object({ deviceId: number() }), PipelineAssignmentSchema.nullable()), method(_void(), array(AgentLoadSummarySchema).readonly()), method(_void(), GlobalMetricsSchema), method(object({ deviceId: number() }), CameraMetricsSchema.nullable()), method(object({ nodeId: string() }), CapabilityBindingsSchema), method(object({
24003
+ }), method(_void(), array(PipelineAssignmentSchema).readonly()), method(object({ deviceId: number() }), PipelineAssignmentSchema.nullable()), method(_void(), array(AgentLoadSummarySchema).readonly()), method(object({ stepId: string() }), ClusterModelChoiceSchema), method(_void(), GlobalMetricsSchema), method(object({ deviceId: number() }), CameraMetricsSchema.nullable()), method(object({ nodeId: string() }), CapabilityBindingsSchema), method(object({
23553
24004
  nodeId: string(),
23554
24005
  capName: string(),
23555
24006
  addonId: string()
@@ -25849,6 +26300,167 @@ DeviceType.Camera, method(object({
25849
26300
  auth: "protected"
25850
26301
  });
25851
26302
  /**
26303
+ * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
26304
+ * valutatore puro del suo FRONTE.
26305
+ *
26306
+ * Viveva dentro il builtin virtual-doorbell
26307
+ * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
26308
+ * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
26309
+ * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
26310
+ * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
26311
+ * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
26312
+ * SPOSTA qui e il doorbell la ri-esporta.
26313
+ *
26314
+ * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
26315
+ * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
26316
+ * regola" (e include `presence`, `cover`, `alarm-panel`), questa a "qual è il
26317
+ * booleano il cui FRONTE conta". Vocabolari deliberatamente diversi.
26318
+ */
26319
+ /**
26320
+ * Known binary / switch source caps → the boolean slice field whose
26321
+ * false→true rise counts as ACTIVE. Every entry is "fire on active".
26322
+ * Sensors whose "active" reading is not a plain boolean (presence's string
26323
+ * state, connectivity's connected flag) are deliberately excluded — a
26324
+ * reconnect is not a doorbell press, and it is not a recording either.
26325
+ */
26326
+ var SOURCE_CAP_ACTIVE_FIELD = {
26327
+ contact: "entryOpen",
26328
+ binary: "on",
26329
+ switch: "on",
26330
+ motion: "detected",
26331
+ flood: "flooded",
26332
+ gas: "detected",
26333
+ smoke: "detected",
26334
+ "carbon-monoxide": "detected",
26335
+ vibration: "detected",
26336
+ tamper: "tampered"
26337
+ };
26338
+ object({
26339
+ /** Ms epoch of the last press. null = never observed since this provider started. */
26340
+ lastPressedAt: number().nullable(),
26341
+ /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
26342
+ pressCountSinceStart: number()
26343
+ });
26344
+ object({
26345
+ deviceId: number(),
26346
+ timestamp: number()
26347
+ });
26348
+ /**
26349
+ * The `doorbell-source` extension slot's editable value (D648): the camera's
26350
+ * virtual-doorbell trigger devices, exactly what the wrapper's
26351
+ * `doorbellSources` persists (as `{ deviceId }` records).
26352
+ */
26353
+ var DoorbellSourceSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
26354
+ DeviceType.Camera;
26355
+ DeviceType.Button, DeviceType.Camera;
26356
+ var ExtensionSlotIdSchema = _enum(["doorbell-source", "linked-devices"]);
26357
+ DeviceType.Camera, DeviceType.Camera;
26358
+ /** A slot's editable value, discriminated on `slot`. */
26359
+ var ExtensionSlotValueSchema = discriminatedUnion("slot", [DoorbellSourceSlotValueSchema.extend({ slot: literal("doorbell-source") }), LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
26360
+ DeviceType.Camera;
26361
+ var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
26362
+ state: literal("unreachable"),
26363
+ reason: string()
26364
+ })]);
26365
+ /** One provider of slots — the D554 source-listing row. */
26366
+ var ExtensionSourceSchema = object({
26367
+ /** The routing prefix of every `slotRef` this provider serves. */
26368
+ source: string(),
26369
+ label: string(),
26370
+ /** Stamped by the dispatcher from the registry (D557). */
26371
+ addonId: string().optional(),
26372
+ availability: ExtensionSourceAvailabilitySchema
26373
+ });
26374
+ /**
26375
+ * How one picked source stands. `missing` — no such device (deleted, or an id
26376
+ * that never existed); `foreign` — a device the slot's owner cannot read from
26377
+ * (slice 2's cross-owner graft source); `unavailable` — it exists but is not a
26378
+ * valid source now (a container, which is never a pick). A source in any of
26379
+ * these states is SHOWN, never silently dropped or re-pointed.
26380
+ */
26381
+ var ExtensionSourceHealthSchema = _enum([
26382
+ "ok",
26383
+ "missing",
26384
+ "foreign",
26385
+ "unavailable"
26386
+ ]);
26387
+ var ExtensionSlotSourceSchema = object({
26388
+ deviceId: number().int(),
26389
+ /** The device's name, or null when it could not be resolved (`missing`). */
26390
+ name: string().nullable(),
26391
+ health: ExtensionSourceHealthSchema,
26392
+ detail: string().optional()
26393
+ });
26394
+ /**
26395
+ * A DIFFERENT authority that gates whether the slot's sources do anything —
26396
+ * reported read-only, named, never written through this contract (D62). The
26397
+ * virtual doorbell's sources ring only while the wrapper is bound to the
26398
+ * camera, and that binding belongs to `deviceManager.setWrapperActive`.
26399
+ * `unknown` means the gate could not be read; it is not "inactive" (D315).
26400
+ */
26401
+ var ExtensionSlotActivationSchema = object({
26402
+ state: _enum([
26403
+ "active",
26404
+ "inactive",
26405
+ "unknown"
26406
+ ]),
26407
+ authority: string(),
26408
+ detail: string().optional()
26409
+ });
26410
+ var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
26411
+ state: literal("ok"),
26412
+ /** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
26413
+ slotRef: string(),
26414
+ slot: ExtensionSlotIdSchema,
26415
+ /** Names the store written (D62), e.g. `virtual-doorbell:doorbellSources`. */
26416
+ authority: string(),
26417
+ /** graft: its switch. association: null — removing every source is "off". */
26418
+ enabled: boolean().nullable(),
26419
+ /** graft: the cap registered on the host. association: null. */
26420
+ projects: string().nullable(),
26421
+ activation: ExtensionSlotActivationSchema.nullable(),
26422
+ value: ExtensionSlotValueSchema,
26423
+ sources: array(ExtensionSlotSourceSchema)
26424
+ }), object({
26425
+ state: literal("unreachable"),
26426
+ addonId: string(),
26427
+ reason: string()
26428
+ })]);
26429
+ var ExtensionCandidatesSchema = object({ candidates: array(object({
26430
+ deviceId: number().int(),
26431
+ name: string(),
26432
+ type: string(),
26433
+ location: string().nullable(),
26434
+ /** The container a child belongs to — "Spotlight 2" alone does not say which. */
26435
+ parentName: string().nullable(),
26436
+ /** Pre-marked by the owner's suggestion rule. NEVER saved on its own (D356). */
26437
+ suggested: boolean(),
26438
+ /** Why it is suggested ("same location"), null when it is not. */
26439
+ reason: string().nullable()
26440
+ })) });
26441
+ /**
26442
+ * What a write did. `none` — applied in place. `host` / `parent` — the owner
26443
+ * reloaded the host (or, for an accessory child, its parent) because the
26444
+ * write changed what the host REGISTERS (a graft switched on or off, slice 2).
26445
+ */
26446
+ var ExtensionSetResultSchema = object({
26447
+ applied: literal(true),
26448
+ reload: _enum([
26449
+ "none",
26450
+ "host",
26451
+ "parent"
26452
+ ])
26453
+ });
26454
+ var ExtensionSlotRefInputSchema = object({
26455
+ deviceId: number().int(),
26456
+ slotRef: string().min(1)
26457
+ });
26458
+ var ExtensionSetSlotInputSchema = ExtensionSlotRefInputSchema.extend({ value: ExtensionSlotValueSchema });
26459
+ method(object({ deviceId: number().int() }), array(ExtensionSourceSchema)), method(object({ deviceId: number().int() }), array(ExtensionSlotRowSchema)), method(ExtensionSlotRefInputSchema, ExtensionCandidatesSchema), method(ExtensionSetSlotInputSchema, ExtensionSetResultSchema, {
26460
+ kind: "mutation",
26461
+ auth: "admin"
26462
+ });
26463
+ /**
25852
26464
  * Optional client-side hints sent at session creation to help the provider
25853
26465
  * pick the best native source. All fields optional — a viewer that knows
25854
26466
  * nothing still gets a sane default. (Relocated from the retired `webrtc`
@@ -27637,17 +28249,6 @@ object({
27637
28249
  deviceId: number(),
27638
28250
  status: DeviceStatusSchema
27639
28251
  });
27640
- object({
27641
- /** Ms epoch of the last press. null = never observed since this provider started. */
27642
- lastPressedAt: number().nullable(),
27643
- /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
27644
- pressCountSinceStart: number()
27645
- });
27646
- object({
27647
- deviceId: number(),
27648
- timestamp: number()
27649
- });
27650
- DeviceType.Button, DeviceType.Camera;
27651
28252
  /**
27652
28253
  * Enum-state sensor — a string value picked from a finite option set.
27653
28254
  * Drives HA `sensor` entries with `state_class: enum` (HVAC action
@@ -30703,7 +31304,7 @@ var HardwareInfoSchema = object({
30703
31304
  coral: CoralInfoSchema.nullable().optional()
30704
31305
  });
30705
31306
  var PlatformScoreSchema = object({
30706
- runtime: _enum(["node", "python"]),
31307
+ runtime: literal("python"),
30707
31308
  backend: string(),
30708
31309
  format: _enum([
30709
31310
  "onnx",
@@ -30740,7 +31341,7 @@ var ModelRequirementSchema = object({
30740
31341
  });
30741
31342
  var ResolvedInferenceConfigSchema = object({
30742
31343
  modelId: string(),
30743
- runtime: _enum(["node", "python"]),
31344
+ runtime: literal("python"),
30744
31345
  backend: string(),
30745
31346
  format: ModelFormatSchema,
30746
31347
  reason: string()
@@ -32947,6 +33548,92 @@ DeviceType.Camera, method(object({ deviceId: number() }), SceneMonitorStatusSche
32947
33548
  kind: "mutation",
32948
33549
  auth: "admin"
32949
33550
  });
33551
+ /**
33552
+ * Per-stage gating mode applied to the zones a rule references.
33553
+ *
33554
+ * - `include`: the rule contributes to a **whitelist** for its stage.
33555
+ * When at least one `include` rule fires for a stage, only entities
33556
+ * inside one of those zones pass that stage.
33557
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
33558
+ * Entities inside one of those zones are dropped at that stage.
33559
+ *
33560
+ * `monitor`-style observation (count without filtering) is not a rule
33561
+ * mode — zones without any matching rule are observed naturally by
33562
+ * `zone-analytics` (live snapshot + history), so an "I just want to
33563
+ * count, not filter" use case needs no rule at all.
33564
+ */
33565
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
33566
+ /**
33567
+ * Per-consumer rule that references existing zones (geometry) and
33568
+ * defines how a specific pipeline stage should treat them. Each
33569
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
33570
+ * settings:
33571
+ *
33572
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
33573
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
33574
+ * - future: notification rules, audio gating, etc.
33575
+ *
33576
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
33577
+ * express "ignore motion in ALL of {garden, street}" with a single
33578
+ * rule. `classFilter` narrows the rule to specific object classes —
33579
+ * "drop person detections in the street, but keep cars" is one
33580
+ * `exclude` rule with `classFilter: ['person']`.
33581
+ *
33582
+ * `enabled` is a soft toggle — the operator can keep the rule
33583
+ * configured but inert without deleting it.
33584
+ */
33585
+ var ZoneRuleSchema = object({
33586
+ /** Stable rule id — survives edits, used by the UI for diffing. */
33587
+ id: string(),
33588
+ /** Optional human-readable label rendered in the rule editor. */
33589
+ name: string().optional(),
33590
+ /** Zones this rule targets. The rule's `mode` applies to ALL
33591
+ * listed zones (OR-set: a detection in any one of them counts).
33592
+ * At least one zone id required — a rule with no targets is a
33593
+ * configuration mistake and the form validator rejects it. */
33594
+ zoneIds: array(string()).min(1).readonly(),
33595
+ mode: ZoneRuleModeEnum,
33596
+ /**
33597
+ * Class names this rule applies to. Empty / undefined ⇒ rule
33598
+ * applies to every class. Class strings match the `macroClass`
33599
+ * field on detections (e.g. `person`, `car`, `dog`).
33600
+ */
33601
+ classFilter: array(string()).readonly().optional(),
33602
+ /**
33603
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
33604
+ * required to consider an entity "in the zone". Defaults to the
33605
+ * consumer's stage default when omitted. Kept for back-compat with
33606
+ * existing per-rule overrides; new operators pick the value via
33607
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
33608
+ * set, the lower-level engine reads it as a 0–1 fraction.
33609
+ */
33610
+ overlapThreshold: number().min(0).max(1).optional(),
33611
+ /**
33612
+ * Operator-friendly version of `overlapThreshold` — the percentage
33613
+ * of the detection's bbox that must lie inside the zone for the
33614
+ * rule to match. Documented default is 85%; the engine substitutes
33615
+ * that when the field is omitted (kept optional so existing rules
33616
+ * stored without it stay valid).
33617
+ *
33618
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
33619
+ * rule, the engine prefers `bboxInclusionPct` because it's the
33620
+ * field exposed in the UI. Internally both feed the same gate.
33621
+ */
33622
+ bboxInclusionPct: number().min(0).max(100).optional(),
33623
+ /**
33624
+ * When `true` and a detection has a segmentation mask, use the
33625
+ * mask for overlap instead of the bbox. Detection-stage only;
33626
+ * motion rules ignore this field.
33627
+ */
33628
+ preferMask: boolean().optional(),
33629
+ /**
33630
+ * Soft-toggle: `false` disables the rule without deleting it.
33631
+ * Defaults to `true` so operators creating a rule via the UI
33632
+ * see it active immediately.
33633
+ */
33634
+ enabled: boolean().default(true)
33635
+ });
33636
+ array(ZoneRuleSchema).readonly();
32950
33637
  object({
32951
33638
  /** Whether the script is currently executing. */
32952
33639
  isRunning: boolean(),
@@ -34328,42 +35015,6 @@ DeviceType.Camera, method(object({
34328
35015
  package: array(ZoneRuleSchema).readonly()
34329
35016
  });
34330
35017
  /**
34331
- * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
34332
- * valutatore puro del suo FRONTE.
34333
- *
34334
- * Viveva dentro il builtin virtual-doorbell
34335
- * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
34336
- * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
34337
- * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
34338
- * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
34339
- * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
34340
- * SPOSTA qui e il doorbell la ri-esporta.
34341
- *
34342
- * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
34343
- * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
34344
- * regola" (e include `presence`, `cover`, `alarm-panel`), questa a "qual è il
34345
- * booleano il cui FRONTE conta". Vocabolari deliberatamente diversi.
34346
- */
34347
- /**
34348
- * Known binary / switch source caps → the boolean slice field whose
34349
- * false→true rise counts as ACTIVE. Every entry is "fire on active".
34350
- * Sensors whose "active" reading is not a plain boolean (presence's string
34351
- * state, connectivity's connected flag) are deliberately excluded — a
34352
- * reconnect is not a doorbell press, and it is not a recording either.
34353
- */
34354
- var SOURCE_CAP_ACTIVE_FIELD = {
34355
- contact: "entryOpen",
34356
- binary: "on",
34357
- switch: "on",
34358
- motion: "detected",
34359
- flood: "flooded",
34360
- gas: "detected",
34361
- smoke: "detected",
34362
- "carbon-monoxide": "detected",
34363
- vibration: "detected",
34364
- tamper: "tampered"
34365
- };
34366
- /**
34367
35018
  * Accessory device helpers — shared across drivers.
34368
35019
  *
34369
35020
  * Many vendor-specific drivers register accessory child devices on
@@ -37163,6 +37814,30 @@ Object.freeze({
37163
37814
  addonId: null,
37164
37815
  access: "create"
37165
37816
  },
37817
+ "deviceExtension.listCandidates": {
37818
+ capName: "device-extension",
37819
+ capScope: "device",
37820
+ addonId: null,
37821
+ access: "view"
37822
+ },
37823
+ "deviceExtension.listSlots": {
37824
+ capName: "device-extension",
37825
+ capScope: "device",
37826
+ addonId: null,
37827
+ access: "view"
37828
+ },
37829
+ "deviceExtension.listSources": {
37830
+ capName: "device-extension",
37831
+ capScope: "device",
37832
+ addonId: null,
37833
+ access: "view"
37834
+ },
37835
+ "deviceExtension.setSlot": {
37836
+ capName: "device-extension",
37837
+ capScope: "device",
37838
+ addonId: null,
37839
+ access: "create"
37840
+ },
37166
37841
  "deviceManager.addLocation": {
37167
37842
  capName: "device-manager",
37168
37843
  capScope: "system",
@@ -37913,6 +38588,12 @@ Object.freeze({
37913
38588
  addonId: null,
37914
38589
  access: "view"
37915
38590
  },
38591
+ "embeddingEncoder.resetFailedModels": {
38592
+ capName: "embedding-encoder",
38593
+ capScope: "system",
38594
+ addonId: null,
38595
+ access: "delete"
38596
+ },
37916
38597
  "enumSensor.getStatus": {
37917
38598
  capName: "enum-sensor",
37918
38599
  capScope: "device",
@@ -39299,6 +39980,12 @@ Object.freeze({
39299
39980
  addonId: null,
39300
39981
  access: "view"
39301
39982
  },
39983
+ "notificationRules.previewStateSummary": {
39984
+ capName: "notification-rules",
39985
+ capScope: "system",
39986
+ addonId: null,
39987
+ access: "view"
39988
+ },
39302
39989
  "notificationRules.previewTemplate": {
39303
39990
  capName: "notification-rules",
39304
39991
  capScope: "system",
@@ -39875,12 +40562,6 @@ Object.freeze({
39875
40562
  addonId: null,
39876
40563
  access: "create"
39877
40564
  },
39878
- "pipelineAnalytics.runReplayFrameProcessor": {
39879
- capName: "pipeline-analytics",
39880
- capScope: "device",
39881
- addonId: null,
39882
- access: "create"
39883
- },
39884
40565
  "pipelineAnalytics.saveRetrainAnnotations": {
39885
40566
  capName: "pipeline-analytics",
39886
40567
  capScope: "device",
@@ -40247,6 +40928,12 @@ Object.freeze({
40247
40928
  addonId: null,
40248
40929
  access: "view"
40249
40930
  },
40931
+ "pipelineOrchestrator.getClusterModelChoice": {
40932
+ capName: "pipeline-orchestrator",
40933
+ capScope: "system",
40934
+ addonId: null,
40935
+ access: "view"
40936
+ },
40250
40937
  "pipelineOrchestrator.getDeviceLiveContribution": {
40251
40938
  capName: "pipeline-orchestrator",
40252
40939
  capScope: "system",
@@ -43072,6 +43759,26 @@ Object.freeze({
43072
43759
  form: "single",
43073
43760
  optional: false
43074
43761
  }],
43762
+ "deviceExtension.listCandidates": [{
43763
+ name: "deviceId",
43764
+ form: "single",
43765
+ optional: false
43766
+ }],
43767
+ "deviceExtension.listSlots": [{
43768
+ name: "deviceId",
43769
+ form: "single",
43770
+ optional: false
43771
+ }],
43772
+ "deviceExtension.listSources": [{
43773
+ name: "deviceId",
43774
+ form: "single",
43775
+ optional: false
43776
+ }],
43777
+ "deviceExtension.setSlot": [{
43778
+ name: "deviceId",
43779
+ form: "single",
43780
+ optional: false
43781
+ }],
43075
43782
  "deviceManager.adoptionRelease": [{
43076
43783
  name: "camDeviceId",
43077
43784
  form: "single",
@@ -43978,11 +44685,6 @@ Object.freeze({
43978
44685
  form: "single",
43979
44686
  optional: false
43980
44687
  }],
43981
- "pipelineAnalytics.runReplayFrameProcessor": [{
43982
- name: "deviceId",
43983
- form: "single",
43984
- optional: false
43985
- }],
43986
44688
  "pipelineAnalytics.saveRetrainAnnotations": [{
43987
44689
  name: "deviceId",
43988
44690
  form: "single",
@@ -44871,12 +45573,55 @@ var NC_AUDIO_DEFAULTS = {
44871
45573
  samplingSeconds: 10
44872
45574
  };
44873
45575
  new Set(["devices", "classes"]);
44874
- /** Every filter, for the callers that must cover all four (guards, tests). */
45576
+ /**
45577
+ * WHICH narrowing filter speaks about WHICH system-event kind — one predicate,
45578
+ * consumed by the rule ENGINE and by every rule EDITOR.
45579
+ *
45580
+ * ── The failure this file exists for ───────────────────────────────────────
45581
+ * `NcSystemEventConditionSchema` carries four optional narrowing lists
45582
+ * (`deviceIds`, `deviceTypes`, `nodeIds`, `packageNames`) beside a required
45583
+ * `kinds` gate. They are not four filters over one vocabulary: each belongs to
45584
+ * a FAMILY of kinds and is meaningless outside it. A node going away has no
45585
+ * device type; a completed export has no package; `stream-offline` deliberately
45586
+ * carries no device type at all (a stream belongs to a camera by construction).
45587
+ *
45588
+ * The engine applied all four to every kind, so a filter from one family failed
45589
+ * a kind from another family CLOSED. The operator's live rule "Eventi di
45590
+ * sistema" selected eleven kinds and set `deviceTypes: ['camera']` — the only
45591
+ * way to say "only my cameras" about the two liveness kinds — and NINE of the
45592
+ * eleven silently stopped being deliverable. Four days of history contained
45593
+ * `device-online` and `device-offline` and nothing else, across a window in
45594
+ * which agents were restarted and addons were updated.
45595
+ *
45596
+ * Both editors already computed this scoping, to decide which filter boxes to
45597
+ * render; the cap's own docblock already promised it ("Narrow a `device-*` kind
45598
+ * to these device TYPES"). Only the engine disagreed, and it disagreed in the
45599
+ * destructive direction. So the rule is stated ONCE, here, and the engine and
45600
+ * the editors are readers of it rather than three independent authors.
45601
+ *
45602
+ * ── The direction ─────────────────────────────────────────────────────────
45603
+ * Out of family ⇒ the filter is IGNORED, never fail-closed. An editor that
45604
+ * hides a box has already told the operator this filter does not speak about
45605
+ * these kinds, so honouring it as an exclusion contradicts the only
45606
+ * explanation the operator was ever given. Inside its family the filter still
45607
+ * narrows, and still fails CLOSED on a subject that cannot produce the identity
45608
+ * it tests (a device the mirror cannot name is not evidence of a camera).
45609
+ */
45610
+ /**
45611
+ * Every filter, for the callers that must cover all of them (guards, tests).
45612
+ *
45613
+ * `consumableLowPercent` (D642) is not a list but it is a filter in exactly
45614
+ * this sense: it belongs to a family of kinds (the consumable pair) and the
45615
+ * engine consults it only there. It differs in one way the readers must know —
45616
+ * its ABSENCE is not "no narrowing" but the default threshold, because a
45617
+ * consumable episode is always judged at SOME threshold.
45618
+ */
44875
45619
  var NC_SYSTEM_EVENT_FILTER_KEYS = [
44876
45620
  "deviceIds",
44877
45621
  "deviceTypes",
44878
45622
  "nodeIds",
44879
- "packageNames"
45623
+ "packageNames",
45624
+ "consumableLowPercent"
44880
45625
  ];
44881
45626
  new Map(Object.entries({
44882
45627
  "device-online": "device-events",
@@ -44887,6 +45632,9 @@ new Map(Object.entries({
44887
45632
  "device-battery-normal": "device-events",
44888
45633
  "device-consumable-low": "device-events",
44889
45634
  "device-consumable-normal": "device-events",
45635
+ "device-tank-low": "device-events",
45636
+ "device-tank-full": "device-events",
45637
+ "device-tank-normal": "device-events",
44890
45638
  "stream-online": "device-events",
44891
45639
  "stream-offline": "device-events",
44892
45640
  "detection-blind": "device-events",
@@ -44916,6 +45664,98 @@ new Map(Object.entries({
44916
45664
  "camera-enabled": null
44917
45665
  }));
44918
45666
  [...NC_SYSTEM_EVENT_FILTER_KEYS];
45667
+ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
45668
+ {
45669
+ id: "device-state",
45670
+ family: "device-events",
45671
+ label: "Device state",
45672
+ kinds: [
45673
+ "device-offline",
45674
+ "device-online",
45675
+ "device-disabled",
45676
+ "device-enabled"
45677
+ ]
45678
+ },
45679
+ {
45680
+ id: "streams",
45681
+ family: "device-events",
45682
+ label: "Streams",
45683
+ kinds: ["stream-offline", "stream-online"]
45684
+ },
45685
+ {
45686
+ id: "battery",
45687
+ family: "device-events",
45688
+ label: "Battery",
45689
+ kinds: ["device-battery-low", "device-battery-normal"]
45690
+ },
45691
+ {
45692
+ id: "consumables",
45693
+ family: "device-events",
45694
+ label: "Consumables",
45695
+ kinds: ["device-consumable-low", "device-consumable-normal"]
45696
+ },
45697
+ {
45698
+ id: "tanks",
45699
+ family: "device-events",
45700
+ label: "Tanks",
45701
+ kinds: [
45702
+ "device-tank-low",
45703
+ "device-tank-full",
45704
+ "device-tank-normal"
45705
+ ]
45706
+ },
45707
+ {
45708
+ id: "detection-blind",
45709
+ family: "device-events",
45710
+ label: "Detecting nothing",
45711
+ kinds: ["detection-blind"]
45712
+ },
45713
+ {
45714
+ id: "nodes",
45715
+ family: "system",
45716
+ label: "Nodes",
45717
+ kinds: [
45718
+ "node-offline",
45719
+ "node-online",
45720
+ "node-inference-unavailable"
45721
+ ]
45722
+ },
45723
+ {
45724
+ id: "addons",
45725
+ family: "system",
45726
+ label: "Addons",
45727
+ kinds: [
45728
+ "addon-crash-loop",
45729
+ "addon-update-available",
45730
+ "addon-updated"
45731
+ ]
45732
+ },
45733
+ {
45734
+ id: "updates",
45735
+ family: "system",
45736
+ label: "Server & container updates",
45737
+ kinds: [
45738
+ "server-update-available",
45739
+ "server-updated",
45740
+ "wrapper-update-available"
45741
+ ]
45742
+ },
45743
+ {
45744
+ id: "backups-exports",
45745
+ family: "system",
45746
+ label: "Backups & exports",
45747
+ kinds: ["backup-completed", "export-completed"]
45748
+ },
45749
+ {
45750
+ id: "alarm",
45751
+ family: "alarm",
45752
+ label: "Alarm",
45753
+ kinds: NC_ALARM_SYSTEM_EVENT_KINDS
45754
+ }
45755
+ ];
45756
+ function systemEventKindsOfFamily(family) {
45757
+ return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
45758
+ }
44919
45759
  NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
44920
45760
  /**
44921
45761
  * WHICH WAY A BOOLEAN SENSOR MOVED — read off the one slice a sensor event
@@ -44954,6 +45794,11 @@ var RULE_BODY_ONLY = ["body"];
44954
45794
  var RULE_TEXT = ["title", "body"];
44955
45795
  var BATTERY = ["device-battery-low", "device-battery-normal"];
44956
45796
  var CONSUMABLE = ["device-consumable-low", "device-consumable-normal"];
45797
+ var TANK = [
45798
+ "device-tank-low",
45799
+ "device-tank-full",
45800
+ "device-tank-normal"
45801
+ ];
44957
45802
  var UPDATES = [
44958
45803
  "addon-update-available",
44959
45804
  "server-update-available",
@@ -44979,12 +45824,189 @@ var DEVICE_EVENTS = [
44979
45824
  "device-enabled",
44980
45825
  ...BATTERY,
44981
45826
  ...CONSUMABLE,
45827
+ ...TANK,
44982
45828
  "stream-online",
44983
45829
  "stream-offline",
44984
45830
  "detection-blind",
44985
45831
  ...ALARM
44986
45832
  ];
44987
- [...DEVICE_EVENTS], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_BODY_ONLY], [...RULE_TEXT], [...RULE_TEXT], [...DEVICE_EVENTS], [...RULE_TEXT], [...DEVICE_EVENTS], [...RULE_TEXT], [...BATTERY, ...CONSUMABLE], [...RULE_TEXT], [...CONSUMABLE], [...RULE_TEXT], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT];
45833
+ /** Every kind a summary may speak about — the two summarisable families. */
45834
+ var SUMMARISABLE = [...systemEventKindsOfFamily("device-events"), ...systemEventKindsOfFamily("system")];
45835
+ /** One per summary SECTION (`NC_STATE_SUMMARY_SECTIONS` in the notification
45836
+ * centre): the section's lines, offered when one of its kinds is selected. */
45837
+ var STATE_SUMMARY_SECTION_VARS = [
45838
+ {
45839
+ name: "summaryDevices",
45840
+ label: "Summary: devices offline / switched off",
45841
+ example: "Garage — offline since 07:12",
45842
+ kinds: [
45843
+ "device-offline",
45844
+ "device-online",
45845
+ "device-disabled",
45846
+ "device-enabled"
45847
+ ]
45848
+ },
45849
+ {
45850
+ name: "summaryStreams",
45851
+ label: "Summary: streams offline",
45852
+ example: "Ingresso (high) — since 06:40",
45853
+ kinds: ["stream-offline", "stream-online"]
45854
+ },
45855
+ {
45856
+ name: "summaryBattery",
45857
+ label: "Summary: low batteries",
45858
+ example: "Sensore porta — 8 %",
45859
+ kinds: BATTERY
45860
+ },
45861
+ {
45862
+ name: "summaryConsumables",
45863
+ label: "Summary: consumables",
45864
+ example: "Robot — filter 10 %",
45865
+ kinds: CONSUMABLE
45866
+ },
45867
+ {
45868
+ name: "summaryTanks",
45869
+ label: "Summary: tanks",
45870
+ example: "Robot — clean water low",
45871
+ kinds: TANK
45872
+ },
45873
+ {
45874
+ name: "summaryDetection",
45875
+ label: "Summary: cameras detecting nothing",
45876
+ example: "Ingresso — since 05:10",
45877
+ kinds: ["detection-blind"]
45878
+ },
45879
+ {
45880
+ name: "summaryNodes",
45881
+ label: "Summary: nodes",
45882
+ example: "little-unraid — offline since 03:00",
45883
+ kinds: [
45884
+ "node-offline",
45885
+ "node-online",
45886
+ "node-inference-unavailable"
45887
+ ]
45888
+ },
45889
+ {
45890
+ name: "summaryAddons",
45891
+ label: "Summary: addons",
45892
+ example: "@camstack/addon-recorder 1.2.3 → 1.2.4",
45893
+ kinds: [
45894
+ "addon-crash-loop",
45895
+ "addon-update-available",
45896
+ "addon-updated"
45897
+ ]
45898
+ },
45899
+ {
45900
+ name: "summaryUpdates",
45901
+ label: "Summary: server & container updates",
45902
+ example: "server 1.2.377 → 1.2.378",
45903
+ kinds: [
45904
+ "server-update-available",
45905
+ "server-updated",
45906
+ "wrapper-update-available"
45907
+ ]
45908
+ }
45909
+ ];
45910
+ var STATE_SUMMARY_VARS = [
45911
+ {
45912
+ name: "summaryText",
45913
+ label: "Summary: every section",
45914
+ description: "One block per section with something to report, one line per item.",
45915
+ example: "Batterie scariche: Sensore porta — 8 %",
45916
+ group: "system",
45917
+ families: ["rule"],
45918
+ fields: [...RULE_TEXT],
45919
+ kinds: ["system"],
45920
+ systemEventKinds: [...SUMMARISABLE],
45921
+ systemEventDeliveries: ["summary"]
45922
+ },
45923
+ {
45924
+ name: "summaryCount",
45925
+ label: "Summary: items reported",
45926
+ example: "3",
45927
+ group: "system",
45928
+ families: ["rule"],
45929
+ fields: [...RULE_TEXT],
45930
+ kinds: ["system"],
45931
+ systemEventKinds: [...SUMMARISABLE],
45932
+ systemEventDeliveries: ["summary"]
45933
+ },
45934
+ ...STATE_SUMMARY_SECTION_VARS.map((v) => ({
45935
+ name: v.name,
45936
+ label: v.label,
45937
+ example: v.example,
45938
+ group: "system",
45939
+ families: ["rule"],
45940
+ fields: [...RULE_TEXT],
45941
+ kinds: ["system"],
45942
+ systemEventKinds: [...v.kinds],
45943
+ systemEventDeliveries: ["summary"]
45944
+ }))
45945
+ ];
45946
+ [
45947
+ [...DEVICE_EVENTS],
45948
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
45949
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
45950
+ [...RULE_TEXT],
45951
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
45952
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
45953
+ [...RULE_TEXT],
45954
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
45955
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
45956
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
45957
+ [...RULE_TEXT],
45958
+ [...RULE_TEXT],
45959
+ [...RULE_TEXT],
45960
+ [...RULE_TEXT],
45961
+ [...RULE_TEXT],
45962
+ [...RULE_TEXT],
45963
+ [...RULE_TEXT],
45964
+ [...RULE_TEXT],
45965
+ [...RULE_BODY_ONLY],
45966
+ [...RULE_TEXT],
45967
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
45968
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
45969
+ ([...RULE_TEXT], [...BATTERY, ...CONSUMABLE]),
45970
+ ([...RULE_TEXT], [...CONSUMABLE]),
45971
+ ([...RULE_TEXT], [...TANK]),
45972
+ [...RULE_TEXT],
45973
+ ([...RULE_TEXT], [...UPDATES]),
45974
+ ([...RULE_TEXT], [...UPDATES]),
45975
+ [...RULE_TEXT],
45976
+ [...RULE_TEXT],
45977
+ [...RULE_TEXT],
45978
+ ([...RULE_TEXT], [...UPDATES]),
45979
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
45980
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
45981
+ ([...RULE_TEXT], [...UPDATES]),
45982
+ ([...RULE_TEXT], [...UPDATES]),
45983
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
45984
+ [...RULE_TEXT],
45985
+ [...RULE_TEXT],
45986
+ [...RULE_TEXT],
45987
+ [...RULE_TEXT],
45988
+ [...RULE_TEXT],
45989
+ [...RULE_TEXT],
45990
+ [...RULE_TEXT],
45991
+ [...RULE_TEXT],
45992
+ [...RULE_TEXT],
45993
+ [...RULE_TEXT],
45994
+ [...RULE_TEXT],
45995
+ [...RULE_TEXT],
45996
+ [...RULE_TEXT],
45997
+ [...RULE_TEXT],
45998
+ [...RULE_TEXT],
45999
+ [...RULE_TEXT],
46000
+ [...RULE_TEXT],
46001
+ [...RULE_TEXT],
46002
+ [...RULE_TEXT],
46003
+ [...RULE_TEXT],
46004
+ [...RULE_TEXT],
46005
+ [...RULE_TEXT],
46006
+ [...RULE_TEXT],
46007
+ [...RULE_TEXT],
46008
+ ...STATE_SUMMARY_VARS
46009
+ ];
44988
46010
  /**
44989
46011
  * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
44990
46012
  *
@@ -45216,68 +46238,6 @@ TimelapseRuleInputSchema.extend({
45216
46238
  createdAt: number(),
45217
46239
  updatedAt: number()
45218
46240
  });
45219
- Object.freeze(Object.fromEntries([{
45220
- stepId: "face-embedding",
45221
- label: "Face recognition model",
45222
- defaultModelId: "arcface-r100",
45223
- indexName: "the enrolled face gallery",
45224
- options: [
45225
- {
45226
- id: "arcface-r100",
45227
- label: "ArcFace (ResNet34)"
45228
- },
45229
- {
45230
- id: "auraface-r100",
45231
- label: "AuraFace R100"
45232
- },
45233
- {
45234
- id: "inception-resnet-v1",
45235
- label: "Inception ResNet V1"
45236
- }
45237
- ]
45238
- }, {
45239
- stepId: "clip-embedding",
45240
- label: "Semantic search model",
45241
- defaultModelId: "mobileclip-s1",
45242
- indexName: "the object semantic-search index",
45243
- options: [{
45244
- id: "mobileclip-s1",
45245
- label: "MobileCLIP S1"
45246
- }, {
45247
- id: "mobileclip-s2",
45248
- label: "MobileCLIP S2"
45249
- }]
45250
- }].map((s) => [s.stepId, s.defaultModelId])));
45251
- string().min(1);
45252
- var CLUSTER_STEP_SETTING_FIELDS = [{
45253
- stepId: "face-embedding",
45254
- key: "minLandmarkFaceSize",
45255
- label: "Min face size for recognition (detection px)",
45256
- description: "Refuse to embed a face smaller than this IN THE DETECTION FRAME. Applies to every node — the enrolled gallery is one index, and two admission floors would fill it from two policies. 0 disables the gate.",
45257
- type: "slider",
45258
- min: 0,
45259
- max: 64,
45260
- step: 2,
45261
- default: 24
45262
- }];
45263
- function clusterStepSettingKey(stepId, fieldKey) {
45264
- return `clusterStepSetting:${stepId}:${fieldKey}`;
45265
- }
45266
- var ClusterSettingNumberSchema = number().finite();
45267
- function readClusterStepSettings(config) {
45268
- const out = {};
45269
- for (const field of CLUSTER_STEP_SETTING_FIELDS) {
45270
- const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
45271
- const value = parsed.success ? parsed.data : field.default;
45272
- const existing = out[field.stepId] ?? {};
45273
- out[field.stepId] = {
45274
- ...existing,
45275
- [field.key]: value
45276
- };
45277
- }
45278
- return out;
45279
- }
45280
- readClusterStepSettings({});
45281
46241
  object({
45282
46242
  /**
45283
46243
  * Fraction of the box's own size added on EACH side before cutting.