@camstack/addon-post-analysis 1.2.284 → 1.2.286

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 (18) hide show
  1. package/THIRD_PARTY_MODELS.md +241 -0
  2. package/dist/{dist-Bpx5JMso.js → clip-model-registry-CY0FGcpQ.js} +2661 -1244
  3. package/dist/{dist-C770IfQJ.mjs → clip-model-registry-D4mC2M7F.mjs} +2516 -1231
  4. package/dist/embedding-encoder/index.js +962 -428
  5. package/dist/embedding-encoder/index.mjs +952 -418
  6. package/dist/pipeline-analytics/_stub.js +2 -2
  7. package/dist/pipeline-analytics/{_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_analytics_widgets-Cc4KIQdo.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_analytics_widgets-CkfvSztj.mjs} +2 -2
  8. package/dist/pipeline-analytics/_virtual_mf___mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-NKbCrEkH.mjs +26 -0
  9. package/dist/pipeline-analytics/_virtual_mf___mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-BAYoLHsN.mjs +26 -0
  10. package/dist/pipeline-analytics/{hostInit-BzoLW-k9.mjs → hostInit-CelYj4QN.mjs} +2 -2
  11. package/dist/pipeline-analytics/index.js +10273 -7693
  12. package/dist/pipeline-analytics/index.mjs +7707 -5127
  13. package/dist/pipeline-analytics/remoteEntry.js +1 -1
  14. package/package.json +3 -2
  15. package/python/test_text_encoder.py +49 -2
  16. package/python/text_encoder_inference.py +31 -14
  17. package/dist/pipeline-analytics/_virtual_mf___mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-CZkZhroP.mjs +0 -26
  18. package/dist/pipeline-analytics/_virtual_mf___mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-DWPDYuJS.mjs +0 -26
@@ -5360,7 +5360,7 @@ var ZodIssueCode = {
5360
5360
  var ZodFirstPartyTypeKind;
5361
5361
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5362
5362
  //#endregion
5363
- //#region ../types/dist/sleep-DU7mu4wb.mjs
5363
+ //#region ../types/dist/sleep-BXv0ZcRa.mjs
5364
5364
  /**
5365
5365
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5366
5366
  * window to float samples (D455).
@@ -6145,6 +6145,40 @@ var BaseAddon = class {
6145
6145
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6146
6146
  return keys.size > 0 ? projectStore(raw, keys, node) : raw;
6147
6147
  }
6148
+ /**
6149
+ * Whether ONE global key of this addon's store was written, read three-way
6150
+ * (D651). For a question a hydrated view cannot answer: `getGlobalSettings`
6151
+ * reports `value ?? default`, so "the operator chose the default" and "nobody
6152
+ * chose" look the same, and a failed read looks like both. A `perNode` key is
6153
+ * not supported here: its stored name is scoped.
6154
+ */
6155
+ async readStoredGlobalKey(key) {
6156
+ const read = this._ctx?.settings?.readAddonStoreResult;
6157
+ if (read === void 0) return {
6158
+ kind: "unreadable",
6159
+ reason: "three-way-read-unavailable"
6160
+ };
6161
+ let result;
6162
+ try {
6163
+ result = await read.call(this._ctx?.settings);
6164
+ } catch (err) {
6165
+ return {
6166
+ kind: "unreadable",
6167
+ reason: "store-read-failed",
6168
+ error: err instanceof Error ? err.message : String(err)
6169
+ };
6170
+ }
6171
+ if (result.kind === "failed") return {
6172
+ kind: "unreadable",
6173
+ reason: "store-read-failed",
6174
+ error: result.error
6175
+ };
6176
+ if (result.kind === "missing" || !Object.prototype.hasOwnProperty.call(result.value, key)) return { kind: "absent" };
6177
+ return {
6178
+ kind: "present",
6179
+ value: result.value[key]
6180
+ };
6181
+ }
6148
6182
  async updateGlobalSettings(patch, nodeId) {
6149
6183
  const keys = this.perNodeKeys();
6150
6184
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
@@ -7440,7 +7474,7 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
7440
7474
  * can answer "may a rule actuate this?" without importing the schema barrel
7441
7475
  * (~144MB RSS per runner, D28).
7442
7476
  *
7443
- * Coverage: 87 device-scoped capabilities.
7477
+ * Coverage: 88 device-scoped capabilities.
7444
7478
  */
7445
7479
  var DEVICE_SCOPED_CAPS = new Set([
7446
7480
  "accessories",
@@ -7470,6 +7504,7 @@ var DEVICE_SCOPED_CAPS = new Set([
7470
7504
  "detection-pipeline",
7471
7505
  "device-admin-link",
7472
7506
  "device-discovery",
7507
+ "device-extension",
7473
7508
  "device-ops",
7474
7509
  "device-status",
7475
7510
  "doorbell",
@@ -9996,6 +10031,60 @@ var FailureCounters = class {
9996
10031
  this.counters.clear();
9997
10032
  }
9998
10033
  };
10034
+ var ClipModelMetaSchema = object({
10035
+ /** The paired text encoder's catalog id (the embedding-encoder's text catalog). */
10036
+ textModelId: string().min(1),
10037
+ /** Output dimension of BOTH towers. A vector of any other length is refused. */
10038
+ embeddingDim: number().int().positive(),
10039
+ /**
10040
+ * The `vector-store` index this model's vectors live in. ONE feature space
10041
+ * per index: two models share an index only when their vectors are ranked
10042
+ * against each other, which for CLIP means never across families. MobileCLIP
10043
+ * S1 and S2 share `object-clip` for history (separated by the row's
10044
+ * `modelId`); any other model gets its own.
10045
+ */
10046
+ vectorIndex: string().regex(/^object-clip(-[a-z0-9][a-z0-9-]*)?$/),
10047
+ /**
10048
+ * The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
10049
+ * must be unique per tokenizer: every model's siblings land in ONE flat
10050
+ * models directory, so two different tokenizers under the same name would
10051
+ * silently overwrite each other (whichever model downloaded last wins, and
10052
+ * the other one tokenises with the wrong vocabulary).
10053
+ */
10054
+ tokenizerFile: string().min(1),
10055
+ /** Token window the text graph takes (SigLIP2: 64; CLIP BPE: 77). */
10056
+ contextLength: number().int().positive(),
10057
+ /** Id the tokenizer pads with. */
10058
+ padId: number().int().nonnegative(),
10059
+ /**
10060
+ * The search cosine floor at `strictness: 'loose'` — calibrated per model,
10061
+ * because cosine bands are a property of the model: 0.2 keeps 96% of matched
10062
+ * COCO caption-image pairs on MobileCLIP S1 and 2.7% on SigLIP2.
10063
+ */
10064
+ searchMinScore: number().min(0).max(1)
10065
+ });
10066
+ var ClipSearchStrictnessSchema = _enum([
10067
+ "loose",
10068
+ "balanced",
10069
+ "strict"
10070
+ ]);
10071
+ var CLIP_STRICTNESS_FACTOR = {
10072
+ loose: 1,
10073
+ balanced: 1.25,
10074
+ strict: 1.5
10075
+ };
10076
+ /**
10077
+ * The cosine floor a search runs with.
10078
+ *
10079
+ * An explicit `minScore` is honoured verbatim: it is a number a caller chose,
10080
+ * and silently rescaling it would make the same URL mean different things on
10081
+ * two installs. Everything else is relative to the model.
10082
+ */
10083
+ function resolveClipSearchMinScore(meta, request) {
10084
+ if (request.minScore !== void 0) return request.minScore;
10085
+ const factor = CLIP_STRICTNESS_FACTOR[request.strictness ?? "loose"];
10086
+ return Math.min(1, Math.round(meta.searchMinScore * factor * 1e3) / 1e3);
10087
+ }
9999
10088
  var MODEL_FORMATS = [
10000
10089
  "onnx",
10001
10090
  "coreml",
@@ -10024,7 +10113,7 @@ var ModelFormatEntrySchema = object({
10024
10113
  /** Multi-file payload (directory members or sibling files). */
10025
10114
  files: array(string()).readonly().optional(),
10026
10115
  /** Runtime(s) that can use this format. If omitted, inferred from ModelFormat key */
10027
- runtimes: array(_enum(["node", "python"])).readonly().optional()
10116
+ runtimes: array(_enum(["python"])).readonly().optional()
10028
10117
  });
10029
10118
  /**
10030
10119
  * Extra file that must be downloaded alongside the model (e.g., labels JSON, dict.txt).
@@ -10199,7 +10288,14 @@ var ModelCatalogEntrySchema = object({
10199
10288
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
10200
10289
  * labels already ARE the CamStack macros (Scrypted identity map).
10201
10290
  */
10202
- classMap: DetectionCatalogClassMapSchema.optional()
10291
+ classMap: DetectionCatalogClassMapSchema.optional(),
10292
+ /**
10293
+ * The model's CLIP feature-space contract (text encoder, dimension, vector
10294
+ * index, token window, search floor) — see `clip-model.ts`. Present ONLY on a
10295
+ * CLIP image encoder; its absence is what "not a CLIP model" means to the
10296
+ * embedding encoder and the semantic-search store (D649).
10297
+ */
10298
+ clip: ClipModelMetaSchema.optional()
10203
10299
  });
10204
10300
  var ConvertTargetSchema = discriminatedUnion("format", [object({
10205
10301
  format: literal("openvino"),
@@ -14649,6 +14745,13 @@ var LinkedDeviceSchema = object({
14649
14745
  features: array(string()),
14650
14746
  producesTrackedEvents: boolean().optional()
14651
14747
  });
14748
+ /**
14749
+ * The `linked-devices` extension slot's editable value (D648): the operator's
14750
+ * pick list, exactly what `_linkedDeviceIds` persists. Tree children are NOT
14751
+ * in it — they are always linked and are not a pick.
14752
+ */
14753
+ var LinkedDevicesSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
14754
+ DeviceType.Camera;
14652
14755
  /** One camera's resolved linked set, tagged with the camera it belongs to.
14653
14756
  * The batch answer needs the tag; the single-device answer already has it
14654
14757
  * from the input, which is why `getLinkedDevices` keeps the untagged shape. */
@@ -15174,11 +15277,128 @@ var EmbeddingResultSchema = object({
15174
15277
  embedding: array(number()),
15175
15278
  inferenceMs: number()
15176
15279
  });
15280
+ /** The two CLIP towers the encoder runs; a crash budget is kept per tower. */
15281
+ var EmbeddingTowerSchema = _enum(["image", "text"]);
15282
+ /**
15283
+ * A tower in the terminal `failed` state (D649, D6): it crashed or failed to
15284
+ * load `crashes` times within `windowMs`, and is refused by name until an
15285
+ * operator `resetFailedModels` or a model change — never on a timer.
15286
+ *
15287
+ * `nodeId` is the node whose tower failed. The state lives in THAT node's
15288
+ * encoder process (in memory — a runner respawn clears it), and one node's
15289
+ * answer says nothing about another's.
15290
+ */
15291
+ var EmbeddingFailedModelSchema = object({
15292
+ modelId: string(),
15293
+ tower: EmbeddingTowerSchema,
15294
+ nodeId: string(),
15295
+ crashes: number(),
15296
+ windowMs: number(),
15297
+ sinceMs: number(),
15298
+ lastReason: string()
15299
+ });
15300
+ /**
15301
+ * A model whose REQUIREMENTS can never be met on this node (D649 round 5):
15302
+ * an id the catalog does not know, a model URL answering 404/410, a declared
15303
+ * sibling (the tokenizer) that is not there. After `attempts` failed builds
15304
+ * it is terminally `requirements-failed`, refused by name until an operator
15305
+ * `resetFailedModels` or a model change — the same exits as a crashed tower.
15306
+ */
15307
+ var EmbeddingFailedRequirementSchema = object({
15308
+ modelId: string(),
15309
+ tower: EmbeddingTowerSchema,
15310
+ nodeId: string(),
15311
+ attempts: number(),
15312
+ sinceMs: number(),
15313
+ lastReason: string()
15314
+ });
15177
15315
  var EmbeddingInfoSchema = object({
15178
15316
  modelId: string(),
15179
15317
  embeddingDim: number(),
15180
- ready: boolean()
15181
- });
15318
+ ready: boolean(),
15319
+ /**
15320
+ * The node that answered. Absent only from an encoder older than D649's
15321
+ * crash budget — whose `failedModels` is then UNKNOWN (D315), never "none".
15322
+ */
15323
+ nodeId: string().optional(),
15324
+ /**
15325
+ * Towers in `failed` on the answering node, each row naming it. `undefined`
15326
+ * means the node could not say (pre-budget encoder); a node that has the
15327
+ * budget always answers an array, empty included.
15328
+ */
15329
+ failedModels: array(EmbeddingFailedModelSchema).optional(),
15330
+ /** Models terminally `requirements-failed` on the answering node; same reading as above. */
15331
+ failedRequirements: array(EmbeddingFailedRequirementSchema).optional()
15332
+ });
15333
+ /**
15334
+ * The THREE codes an encoder refusal can carry (D649, D6). Same shape as
15335
+ * `VECTOR_INDEX_DIM_CONFLICT`: the code rides in the MESSAGE, because an
15336
+ * Error's own properties do not survive the UDS/tRPC hop and its message does,
15337
+ * and both sides go through the helpers below — the encoder builds the
15338
+ * refusal, the live detail plane classifies on it to count refusals per
15339
+ * camera instead of logging one warning per track. The bracketed token
15340
+ * carries the code, the model, the tower and the node so a consumer never
15341
+ * parses prose.
15342
+ *
15343
+ * - `EMBEDDING_MODEL_FAILED`: the tower crashed / failed to load past the crash
15344
+ * budget — terminal until `resetFailedModels` or a model change.
15345
+ * - `EMBEDDING_REQUIREMENTS_UNAVAILABLE`: files or runtime not there right now
15346
+ * (a download or Python that failed, or the cooldown after one) — the next
15347
+ * request past the cooldown tries again.
15348
+ * - `EMBEDDING_REQUIREMENTS_FAILED`: the requirements can never be met (unknown
15349
+ * id, 404/410, missing sibling) and the bounded attempts are spent —
15350
+ * terminal, same exits as a crashed tower.
15351
+ */
15352
+ var EMBEDDING_MODEL_FAILED = "embedding-model-failed";
15353
+ var EMBEDDING_REQUIREMENTS_UNAVAILABLE = "embedding-requirements-unavailable";
15354
+ var EMBEDDING_REQUIREMENTS_FAILED = "embedding-requirements-failed";
15355
+ var EmbeddingRefusalCodeSchema = _enum([
15356
+ EMBEDDING_MODEL_FAILED,
15357
+ EMBEDDING_REQUIREMENTS_UNAVAILABLE,
15358
+ EMBEDDING_REQUIREMENTS_FAILED
15359
+ ]);
15360
+ function embeddingRefusalToken(code, on) {
15361
+ return `[${code} model=${on.modelId} tower=${on.tower} node=${on.nodeId}]`;
15362
+ }
15363
+ /** The encoder's refusal for a crashed tower, carrying {@link EMBEDDING_MODEL_FAILED}. */
15364
+ function embeddingModelFailedError(row) {
15365
+ return /* @__PURE__ */ new Error(`${embeddingRefusalToken(EMBEDDING_MODEL_FAILED, row)} ${row.modelId} (${row.tower} tower) crashed ${String(row.crashes)} times in ${String(Math.round(row.windowMs / 1e3))}s on ${row.nodeId} — ${row.lastReason}. Cleared by embeddingEncoder.resetFailedModels({ modelId: "${row.modelId}", nodeId: "${row.nodeId}" }) or a model change.`);
15366
+ }
15367
+ /** The requirements refusal for THIS request, carrying {@link EMBEDDING_REQUIREMENTS_UNAVAILABLE}. */
15368
+ function embeddingRequirementsUnavailableError(on, reason) {
15369
+ return /* @__PURE__ */ new Error(`${embeddingRefusalToken(EMBEDDING_REQUIREMENTS_UNAVAILABLE, on)} ${on.modelId} (${on.tower} tower) on ${on.nodeId}: ${reason}`);
15370
+ }
15371
+ /** The terminal requirements refusal, carrying {@link EMBEDDING_REQUIREMENTS_FAILED}. */
15372
+ function embeddingRequirementsFailedError(row) {
15373
+ return /* @__PURE__ */ new Error(`${embeddingRefusalToken(EMBEDDING_REQUIREMENTS_FAILED, row)} ${row.modelId} (${row.tower} tower) on ${row.nodeId}: requirements can never be met — ${String(row.attempts)} attempts, last: ${row.lastReason}. Cleared by embeddingEncoder.resetFailedModels({ modelId: "${row.modelId}", nodeId: "${row.nodeId}" }) or a model change.`);
15374
+ }
15375
+ var EMBEDDING_REFUSAL_TOKEN = new RegExp(`\\[(${EMBEDDING_MODEL_FAILED}|${EMBEDDING_REQUIREMENTS_UNAVAILABLE}|${EMBEDDING_REQUIREMENTS_FAILED}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);
15376
+ /** The refusal `err` (possibly re-wrapped by a transport) carries, or `null` for any other error. */
15377
+ function embeddingRefusalOf(err) {
15378
+ const message = err instanceof Error ? err.message : String(err);
15379
+ const match = EMBEDDING_REFUSAL_TOKEN.exec(message);
15380
+ if (match === null) return null;
15381
+ const code = EmbeddingRefusalCodeSchema.safeParse(match[1]);
15382
+ const tower = EmbeddingTowerSchema.safeParse(match[3]);
15383
+ if (!code.success || !tower.success || match[2] === void 0 || match[4] === void 0) return null;
15384
+ return {
15385
+ code: code.data,
15386
+ modelId: match[2],
15387
+ tower: tower.data,
15388
+ nodeId: match[4]
15389
+ };
15390
+ }
15391
+ /**
15392
+ * ONE provider per node (`placement: any-node`), addressed like every global
15393
+ * collection: the codegen injects a `{ nodeId?, addonId? }` selector on the
15394
+ * void methods and lifts a top-level `nodeId` off the object ones. A call
15395
+ * that names no node is answered by the HUB's provider — never by a merge
15396
+ * across nodes, because no global collection fans out across nodes (only the
15397
+ * providers of one node are `concatCollection`-fanned). So a fleet view of
15398
+ * `failedModels` is one `getInfo({ nodeId })` per node, and every answer
15399
+ * names the node it came from (D649 round 4); a node that cannot be asked is
15400
+ * UNKNOWN to the reader, never "no failures" (D315).
15401
+ */
15182
15402
  var embeddingEncoderCapability = {
15183
15403
  name: "embedding-encoder",
15184
15404
  scope: "system",
@@ -15197,8 +15417,30 @@ var embeddingEncoderCapability = {
15197
15417
  width: number(),
15198
15418
  height: number()
15199
15419
  }), EmbeddingResultSchema, { auth: "admin" }),
15200
- encodeText: method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }),
15201
- getInfo: method(_void(), EmbeddingInfoSchema, { auth: "admin" })
15420
+ /**
15421
+ * `modelId` (a CLIP IMAGE model id, whose catalog `clip.textModelId` names
15422
+ * the text tower) encodes in that model's space; absent, the cluster row's
15423
+ * `clip-embedding` model — the space every writer is in (D649).
15424
+ */
15425
+ encodeText: method(object({
15426
+ text: string(),
15427
+ modelId: string().min(1).optional()
15428
+ }), EmbeddingResultSchema, { auth: "admin" }),
15429
+ /** Answers for ONE node — the `nodeId` selector's, else the hub's. */
15430
+ getInfo: method(_void(), EmbeddingInfoSchema, { auth: "admin" }),
15431
+ /**
15432
+ * The operator's explicit clear of the `failed` state (one model, or all)
15433
+ * on ONE node — pass `nodeId` for an agent; the result names the node it
15434
+ * cleared. The only way out besides a model change: a crashing tower is
15435
+ * not retried on a timer.
15436
+ */
15437
+ resetFailedModels: method(object({ modelId: string().min(1).optional() }), object({
15438
+ cleared: array(string()),
15439
+ nodeId: string()
15440
+ }), {
15441
+ kind: "mutation",
15442
+ auth: "admin"
15443
+ })
15202
15444
  }
15203
15445
  };
15204
15446
  /**
@@ -18095,6 +18337,25 @@ var NcScheduleSchema = object({
18095
18337
  /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
18096
18338
  invert: boolean().optional()
18097
18339
  });
18340
+ /**
18341
+ * How a system-event rule of the `device-events` or `system` family speaks
18342
+ * (D647): at once, per event (`instant`, the only behaviour before D647), or
18343
+ * as a STATE SUMMARY at the end of each window of `schedule`.
18344
+ */
18345
+ var NcSystemEventDeliveryModeSchema = _enum(["instant", "summary"]);
18346
+ /**
18347
+ * `summary`: the rule sends NOTHING per event. When a window of `schedule`
18348
+ * CLOSES, it sends one notification with the current state of its kinds
18349
+ * (low batteries, consumables to replace, devices offline, updates
18350
+ * available, ...), after its own filters. Nothing to report sends nothing.
18351
+ * The schedule is the ordinary `NcSchedule` (weekly windows, IANA timezone,
18352
+ * midnight crossing); the send time is each window's END. Refused on the
18353
+ * `alarm` family, which stays instant (`systemEventDeliveryProblems`).
18354
+ */
18355
+ var NcSystemEventDeliverySchema = discriminatedUnion("mode", [object({ mode: literal("instant") }), object({
18356
+ mode: literal("summary"),
18357
+ schedule: NcScheduleSchema
18358
+ })]);
18098
18359
  /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
18099
18360
  var NcPlateMatcherSchema = object({
18100
18361
  /**
@@ -18708,7 +18969,12 @@ var NcMediaPolicySchema = object({
18708
18969
  * the degrade engine, which drops the video and keeps the still.
18709
18970
  */
18710
18971
  clip: boolean().optional(),
18711
- /** Seconds of footage BEFORE / AFTER the event instant. Defaults 3 / 7. */
18972
+ /**
18973
+ * Seconds of footage BEFORE / AFTER the event instant. Absent =
18974
+ * {@link NC_CLIP_PRE_ROLL_DEFAULT_SEC} / {@link NC_CLIP_POST_ROLL_DEFAULT_SEC}
18975
+ * (4 / 6), resolved by the Notification Center at dispatch — deliberately not
18976
+ * a Zod default, so a rule that never chose keeps following the hub's.
18977
+ */
18712
18978
  clipPreRollSec: number().int().min(0).max(30).optional(),
18713
18979
  clipPostRollSec: number().int().min(0).max(30).optional(),
18714
18980
  /**
@@ -18830,6 +19096,16 @@ var NcRuleInputSchema = object({
18830
19096
  delivery: NcDeliverySchema,
18831
19097
  conditions: NcConditionsSchema.default({}),
18832
19098
  schedule: NcScheduleSchema.optional(),
19099
+ /**
19100
+ * A `device-events` / `system` rule's delivery (D647): absent or `instant`
19101
+ * is a notification per event; `summary` is one state summary per closed
19102
+ * window of its schedule. `.optional()` and never defaulted: absent must
19103
+ * keep meaning what every rule authored before D647 meant, with no
19104
+ * migration. Top-level rather than inside `conditions.systemEvent`, so a
19105
+ * client that does not know it (an older viewer re-sending `conditions`
19106
+ * whole) leaves it standing through the store's patch merge.
19107
+ */
19108
+ systemEventDelivery: NcSystemEventDeliverySchema.optional(),
18833
19109
  /** May be empty when `targetUsers` addresses at least one user — the
18834
19110
  * "at least one addressee" invariant is enforced by the provider, because
18835
19111
  * a cross-field refine here would break `NcRulePatchSchema.partial()`. */
@@ -19058,6 +19334,28 @@ var NcRuleSchema = NcRuleInputSchema.extend({
19058
19334
  */
19059
19335
  disabledTargetIds: array(string()).default([])
19060
19336
  });
19337
+ /** One section of a previewed state summary. `unavailable` = its state could not be read. */
19338
+ var NcStateSummaryPreviewSectionSchema = object({
19339
+ id: string(),
19340
+ status: _enum(["read", "unavailable"]),
19341
+ items: number().int().nonnegative(),
19342
+ reason: string().optional()
19343
+ });
19344
+ /**
19345
+ * The summary a rule would send now. `empty` = nothing to report and every
19346
+ * section read: such a summary is NOT sent. `dropped` counts the open states
19347
+ * the rule's own filters (or a camera mute) left out, by reason.
19348
+ * `excludedGroups` names the kind groups selected that have no state to report
19349
+ * (backups & exports).
19350
+ */
19351
+ var NcStateSummaryPreviewSchema = object({
19352
+ empty: boolean(),
19353
+ count: number().int().nonnegative(),
19354
+ text: string(),
19355
+ sections: array(NcStateSummaryPreviewSectionSchema),
19356
+ dropped: record(string(), number().int().nonnegative()),
19357
+ excludedGroups: array(string())
19358
+ });
19061
19359
  var NcTestResultSchema = object({
19062
19360
  recordId: string(),
19063
19361
  recordKind: _enum([
@@ -19149,6 +19447,13 @@ var NcTemplateVarDescriptorSchema = object({
19149
19447
  kinds: array(NcTemplateVarKindSchema).optional(),
19150
19448
  deliveries: array(NcDeliverySchema).optional(),
19151
19449
  systemEventKinds: array(NcSystemEventKindSchema).optional(),
19450
+ /**
19451
+ * Which system-event DELIVERY has a value for it (D647). Absent = an
19452
+ * instant row only when the descriptor names `systemEventKinds` (a
19453
+ * per-event fact: a summary row has no single device), and both otherwise.
19454
+ * `['summary']` marks the state-summary vocabulary (`{{summaryText}}`, ...).
19455
+ */
19456
+ systemEventDeliveries: array(NcSystemEventDeliveryModeSchema).optional(),
19152
19457
  dynamic: object({
19153
19458
  prefix: literal("count_"),
19154
19459
  from: literal("classes")
@@ -19161,7 +19466,9 @@ var NcTemplatePreviewInputSchema = object({
19161
19466
  field: NcTemplateFieldSchema,
19162
19467
  kind: NcRuleKindSchema.optional(),
19163
19468
  delivery: NcDeliverySchema.optional(),
19164
- systemEventKinds: array(NcSystemEventKindSchema).optional()
19469
+ systemEventKinds: array(NcSystemEventKindSchema).optional(),
19470
+ /** The rule's system-event delivery (D647); absent = instant. */
19471
+ systemEventDelivery: NcSystemEventDeliveryModeSchema.optional()
19165
19472
  }),
19166
19473
  template: object({
19167
19474
  title: string().max(500).optional(),
@@ -20295,6 +20602,17 @@ var notificationRulesCapability = {
20295
20602
  auth: "admin"
20296
20603
  }),
20297
20604
  /**
20605
+ * The STATE SUMMARY a system rule would send now (D647) — for a saved rule
20606
+ * or an unsaved draft. Pure: sends nothing, stamps nothing. A MUTATION
20607
+ * only for transport (a whole rule does not belong in a GET URL). Admin,
20608
+ * like `testRule`: it names devices and nodes across the installation.
20609
+ */
20610
+ previewStateSummary: method(object({ rule: NcRuleInputSchema }), NcStateSummaryPreviewSchema, {
20611
+ kind: "mutation",
20612
+ auth: "admin",
20613
+ access: "view"
20614
+ }),
20615
+ /**
20298
20616
  * The machine-readable condition surface a rule editor renders from, plus
20299
20617
  * the picker VOCABULARY those conditions draw on.
20300
20618
  *
@@ -20739,786 +21057,342 @@ var OauthIntegrationDescriptorSchema = object({
20739
21057
  });
20740
21058
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
20741
21059
  /**
20742
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
20743
- * within the frame, so the executor can re-cut a leaf child ROI at native
20744
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
21060
+ * A model choice has a SCOPE, and a scope change has a workflow.
21061
+ *
21062
+ * ## The two scopes
21063
+ *
21064
+ * Almost every pipeline step's model is a **node** question: which build runs
21065
+ * fastest on THIS accelerator. Two nodes may legitimately answer differently —
21066
+ * a Coral runs the tflite SSD, a Mac runs the coreml YOLO — because the answers
21067
+ * are compared against nothing. They produce boxes, and a box is a box.
21068
+ *
21069
+ * Two steps are not like that. `face-embedding` and `clip-embedding` produce
21070
+ * **vectors that land in ONE shared index** (`identity_samples`,
21071
+ * `vec_object_clip`) and are ranked against each other by cosine similarity.
21072
+ * Cosine similarity between two encoders is not a weak signal, it is a
21073
+ * meaningless number — and nothing inside a vector can tell you it happened.
21074
+ * So for those two steps the model is a **cluster** question with exactly one
21075
+ * answer, stored in exactly one row.
21076
+ *
21077
+ * That is the same argument [D52](../../../../docs/decisions/adr-0052.md) makes
21078
+ * for the crop convention (`detail-crop.ts`), one level up: the crop decides
21079
+ * WHAT pixels the encoder sees, this decides WHICH encoder sees them. Both are
21080
+ * cluster-wide for the same reason and neither may become per-node.
21081
+ *
21082
+ * ## Why the registry lives here and not in the step catalog
21083
+ *
21084
+ * The scope itself is declared on the step, in
21085
+ * `detection-pipeline/registry/step-definitions.ts` (`StepDefinition.modelScope`)
21086
+ * — that is where a new step declares what kind of choice its model is. But the
21087
+ * catalog lives inside `addon-pipeline`, and three packages that must NOT
21088
+ * import an addon need to know the set: the orchestrator (which renders and
21089
+ * stores the row), post-analysis (which pins the row for a re-embed pass) and
21090
+ * admin-ui (which mirrors it). So the set is mirrored here, and
21091
+ * `scripts/check-cluster-model-scope.ts` fails the build when the two disagree.
21092
+ * A hand-copied key that stops matching is exactly how a setting silently stops
21093
+ * arriving while both sides still look correct.
21094
+ *
21095
+ * ## The defaults ARE today's behaviour
21096
+ *
21097
+ * {@link DEFAULT_CLUSTER_STEP_MODELS} reproduces the catalog `defaultModelId`
21098
+ * of both steps. Declaring the scope therefore changes nothing on the day it
21099
+ * ships: the cluster row starts out saying what every node was already doing.
21100
+ * Changing it is legitimate — that is what the knob is for — but it invalidates
21101
+ * the stored vectors of that surface, and must be followed by a re-embed pass
21102
+ * (`face-reembed-pass.ts`, `embedding-rebuild.ts`).
20745
21103
  */
20746
- var NativeCropRefSchema = object({
20747
- /** Handle keying the retained native surface (node-pinned to its owner). */
20748
- handle: FrameHandleSchema,
20749
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
20750
- cropFrameSpace: object({
20751
- x: number(),
20752
- y: number(),
20753
- w: number(),
20754
- h: number()
20755
- })
20756
- });
20757
- object({
20758
- crop: object({
20759
- left: number(),
20760
- top: number(),
20761
- width: number().positive(),
20762
- height: number().positive()
20763
- }).optional(),
20764
- content: object({
20765
- width: number().int().positive(),
20766
- height: number().int().positive()
20767
- }),
20768
- fit: _enum(["stretch", "contain"]),
20769
- format: _enum([
20770
- "rgb",
20771
- "gray",
20772
- "jpeg"
20773
- ])
20774
- });
20775
21104
  /**
20776
- * Process-local frame identity. It is serializable so it can ride an in-process
20777
- * capability call, but `registryId` deliberately prevents resolution in any
20778
- * other process or execution group.
21105
+ * Why the orchestrator cannot say which model the operator chose for a
21106
+ * cluster-scoped step (D651).
20779
21107
  */
20780
- var FrameRefSchema = object({
20781
- registryId: string().min(1),
20782
- id: string().min(1),
20783
- width: number().int().positive(),
20784
- height: number().int().positive(),
20785
- format: _enum(["rgb", "gray"]),
20786
- timestamp: number(),
20787
- capturedAt: number().optional()
20788
- });
20789
- var ModelFormatSchema$1 = _enum([
20790
- "onnx",
20791
- "coreml",
20792
- "openvino",
20793
- "tflite",
20794
- "pt",
20795
- "gguf"
21108
+ var CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS = [
21109
+ "owner-not-ready",
21110
+ "store-read-failed",
21111
+ "three-way-read-unavailable",
21112
+ "invalid-stored",
21113
+ "not-cluster-scoped"
21114
+ ];
21115
+ /**
21116
+ * The cluster-scoped steps. Mirrored from the catalog's `modelScope: 'cluster'`
21117
+ * declarations and guarded by `scripts/check-cluster-model-scope.ts`.
21118
+ */
21119
+ var CLUSTER_MODEL_SCOPED_STEPS = [{
21120
+ stepId: "face-embedding",
21121
+ label: "Face recognition model",
21122
+ defaultModelId: "auraface-r100",
21123
+ indexName: "the enrolled face gallery",
21124
+ options: [
21125
+ {
21126
+ id: "auraface-r100",
21127
+ label: "AuraFace R100"
21128
+ },
21129
+ {
21130
+ id: "arcface-r100",
21131
+ label: "ArcFace (ResNet34)"
21132
+ },
21133
+ {
21134
+ id: "inception-resnet-v1",
21135
+ label: "Inception ResNet V1"
21136
+ }
21137
+ ]
21138
+ }, {
21139
+ stepId: "clip-embedding",
21140
+ label: "Semantic search model",
21141
+ defaultModelId: "mobileclip-s1",
21142
+ indexName: "the object semantic-search index",
21143
+ options: [
21144
+ {
21145
+ id: "mobileclip-s1",
21146
+ label: "MobileCLIP S1"
21147
+ },
21148
+ {
21149
+ id: "mobileclip-s2",
21150
+ label: "MobileCLIP S2"
21151
+ },
21152
+ {
21153
+ id: "siglip2-b16-224",
21154
+ label: "SigLIP2 B/16 (Apache-2.0)"
21155
+ }
21156
+ ]
21157
+ }];
21158
+ /**
21159
+ * The settings key holding one step's cluster model choice.
21160
+ *
21161
+ * Step-qualified so the keys stay unique across the addon's whole schema, which
21162
+ * is what lets {@link pickClusterStepModels} walk every section instead of
21163
+ * trusting the section id.
21164
+ */
21165
+ function clusterModelSettingKey(stepId) {
21166
+ return `clusterModel:${stepId}`;
21167
+ }
21168
+ /** The cluster row when nobody has configured one — today's catalog defaults. */
21169
+ var DEFAULT_CLUSTER_STEP_MODELS = Object.freeze(Object.fromEntries(CLUSTER_MODEL_SCOPED_STEPS.map((s) => [s.stepId, s.defaultModelId])));
21170
+ function interpretStoredClusterModel(raw) {
21171
+ if (raw === void 0 || raw === null || raw === "") return { kind: "absent" };
21172
+ if (typeof raw === "string") return {
21173
+ kind: "chosen",
21174
+ modelId: raw
21175
+ };
21176
+ return {
21177
+ kind: "invalid",
21178
+ value: raw
21179
+ };
21180
+ }
21181
+ /**
21182
+ * Narrow a FLAT settings record to the cluster row.
21183
+ *
21184
+ * Per-FIELD fallback, deliberately (same rule as `readDetailCropConvention`): a
21185
+ * junk face model must not also discard a valid clip model. An `absent` or
21186
+ * `invalid` value ({@link interpretStoredClusterModel}) resolves to the step's
21187
+ * catalog default — never to a blank id, because a blank id downstream becomes
21188
+ * "substitute the format default", which is precisely the substitution this
21189
+ * scope exists to forbid.
21190
+ */
21191
+ function readClusterStepModels(config) {
21192
+ const out = {};
21193
+ for (const step of CLUSTER_MODEL_SCOPED_STEPS) {
21194
+ const read = interpretStoredClusterModel(config[clusterModelSettingKey(step.stepId)]);
21195
+ out[step.stepId] = read.kind === "chosen" ? read.modelId : step.defaultModelId;
21196
+ }
21197
+ return out;
21198
+ }
21199
+ function isHydratedField$2(entry) {
21200
+ return typeof entry === "object" && entry !== null && "key" in entry;
21201
+ }
21202
+ /**
21203
+ * Extract the cluster row from an `addon-settings.getGlobalSettings` payload.
21204
+ *
21205
+ * Walks EVERY section rather than looking inside {@link CLUSTER_MODEL_SECTION_ID}
21206
+ * alone: the keys are unique across the addon's schema, and a section rename
21207
+ * must not silently revert the whole cluster to the defaults. A `null` payload
21208
+ * (addon mid-boot) is the defaults.
21209
+ */
21210
+ function pickClusterStepModels(view) {
21211
+ if (view === null) return DEFAULT_CLUSTER_STEP_MODELS;
21212
+ return readClusterStepModels(flattenHydratedView(view, clusterModelKeys()));
21213
+ }
21214
+ function clusterModelKeys() {
21215
+ return new Set(CLUSTER_MODEL_SCOPED_STEPS.map((s) => clusterModelSettingKey(s.stepId)));
21216
+ }
21217
+ /** The `wanted` keys of a hydrated view as one flat record, every section walked. */
21218
+ function flattenHydratedView(view, wanted) {
21219
+ const flat = {};
21220
+ for (const section of view.sections) for (const entry of section.fields) {
21221
+ if (!isHydratedField$2(entry) || typeof entry.key !== "string") continue;
21222
+ if (wanted.has(entry.key)) flat[entry.key] = entry.value;
21223
+ }
21224
+ return flat;
21225
+ }
21226
+ var CLUSTER_STEP_SETTING_FIELDS = [{
21227
+ stepId: "face-embedding",
21228
+ key: "minLandmarkFaceSize",
21229
+ label: "Min face size for recognition (detection px)",
21230
+ 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.",
21231
+ type: "slider",
21232
+ min: 0,
21233
+ max: 64,
21234
+ step: 2,
21235
+ default: 24
21236
+ }];
21237
+ function clusterStepSettingKey(stepId, fieldKey) {
21238
+ return `clusterStepSetting:${stepId}:${fieldKey}`;
21239
+ }
21240
+ var ClusterSettingNumberSchema = number().finite();
21241
+ function readClusterStepSettings(config) {
21242
+ const out = {};
21243
+ for (const field of CLUSTER_STEP_SETTING_FIELDS) {
21244
+ const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
21245
+ const value = parsed.success ? parsed.data : field.default;
21246
+ const existing = out[field.stepId] ?? {};
21247
+ out[field.stepId] = {
21248
+ ...existing,
21249
+ [field.key]: value
21250
+ };
21251
+ }
21252
+ return out;
21253
+ }
21254
+ readClusterStepSettings({});
21255
+ /**
21256
+ * pipeline-analytics — device-scoped wrapper cap. Refines raw
21257
+ * per-frame detections emitted by the pipeline runner into tracked
21258
+ * objects, per-kind event collections (motion / object / audio), and
21259
+ * persisted media. Owns the post-detection domain end-to-end:
21260
+ *
21261
+ * runner emits PipelineInferenceResult
21262
+ * ↓ (event bus)
21263
+ * pipeline-analytics subscriber
21264
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
21265
+ * → three DB collections (one per kind), one FS media tree, one
21266
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
21267
+ * DetectionEvent on bus)
21268
+ *
21269
+ * Pure subscriber model. No `processFrame` cap method — the runner
21270
+ * already publishes the raw frame on the bus. The cap surface is
21271
+ * only QUERIES + per-device settings, bound on/off via
21272
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
21273
+ * every camera with a detection pipeline wants its raw detections
21274
+ * refined; operators opt out per-device via BindingsTab when needed.
21275
+ *
21276
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
21277
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
21278
+ */
21279
+ var TrackStateSchema = _enum([
21280
+ "new",
21281
+ "entered",
21282
+ "left",
21283
+ "moving",
21284
+ "idle"
20796
21285
  ]);
20797
- var PipelineSlotSchema = _enum([
20798
- "detector",
20799
- "cropper",
20800
- "classifier",
20801
- "refiner",
20802
- "audio-classifier"
21286
+ var EventKindSchema = _enum([
21287
+ "motion",
21288
+ "object",
21289
+ "audio"
20803
21290
  ]);
20804
- var PipelineEngineChoiceSchema = object({
20805
- runtime: _enum(["node", "python"]),
20806
- backend: string(),
20807
- format: ModelFormatSchema$1,
20808
- device: string().optional()
20809
- });
20810
- var AvailableEngineSchema = object({
20811
- engine: PipelineEngineChoiceSchema,
20812
- devices: array(object({
20813
- id: string(),
20814
- label: string(),
20815
- description: string().optional()
20816
- })).readonly(),
20817
- defaultDevice: string()
20818
- });
20819
- var PipelineDefaultStepSchema = lazy(() => object({
20820
- addonId: string(),
20821
- addonName: string(),
20822
- slot: PipelineSlotSchema,
20823
- inputClasses: array(string()).readonly(),
20824
- outputClasses: array(string()).readonly(),
20825
- enabled: boolean(),
20826
- modelId: string(),
20827
- children: array(PipelineDefaultStepSchema).readonly(),
20828
- group: string().optional(),
20829
- settings: record(string(), unknown()).optional()
20830
- }));
20831
- var PipelineTemplateStepSchema = lazy(() => object({
20832
- addonId: string(),
20833
- enabled: boolean(),
20834
- modelId: string(),
20835
- children: array(PipelineTemplateStepSchema).readonly(),
20836
- settings: record(string(), unknown()).optional()
20837
- }));
20838
- var PipelineTemplateSchema$1 = object({
20839
- id: string(),
20840
- name: string(),
20841
- createdAt: string(),
20842
- updatedAt: string(),
20843
- engine: PipelineEngineChoiceSchema,
20844
- steps: array(PipelineTemplateStepSchema).readonly()
21291
+ /**
21292
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
21293
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
21294
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
21295
+ */
21296
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
21297
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
21298
+ var EventKindIconSchema = _enum([
21299
+ "motion",
21300
+ "audio",
21301
+ "person",
21302
+ "vehicle",
21303
+ "animal",
21304
+ "door",
21305
+ "pir",
21306
+ "smoke",
21307
+ "water",
21308
+ "button",
21309
+ "package",
21310
+ "generic"
21311
+ ]);
21312
+ var EventKindCategorySchema = _enum([
21313
+ "motion",
21314
+ "audio",
21315
+ "detection",
21316
+ "sensor",
21317
+ "control",
21318
+ "custom",
21319
+ "package"
21320
+ ]);
21321
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
21322
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
21323
+ var EventKindDescriptorSchema = object({
21324
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
21325
+ kind: string(),
21326
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
21327
+ labelKey: string(),
21328
+ /** English fallback label (kept for clients that don't translate). */
21329
+ label: string(),
21330
+ /** Hex color for timeline/legend rendering. */
21331
+ color: string(),
21332
+ /** Dictionary id → lucide component on the UI side. */
21333
+ iconId: string(),
21334
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
21335
+ icon: EventKindIconSchema,
21336
+ category: EventKindCategorySchema,
21337
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
21338
+ parentKind: string().nullable(),
21339
+ /** Derived from `parentKind`, explicit for the client tree. */
21340
+ level: EventKindLevelSchema,
21341
+ /** Which cap + device contributes this kind. For built-ins the camera
21342
+ * itself; for sensor kinds the LINKED source device. */
21343
+ source: object({
21344
+ capName: string(),
21345
+ deviceId: number()
21346
+ })
20845
21347
  });
20846
- var PipelineModelOptionSchema = object({
20847
- id: string(),
20848
- name: string(),
20849
- formats: record(string(), object({
20850
- downloaded: boolean(),
20851
- sizeMB: number()
20852
- })),
20853
- group: ModelVariantGroupSchema.optional(),
20854
- legacy: boolean().optional(),
20855
- provider: ModelProviderIdSchema.optional()
21348
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
21349
+ var EventKindsForDeviceSchema = object({
21350
+ deviceId: number(),
21351
+ kinds: array(EventKindDescriptorSchema).readonly()
20856
21352
  });
20857
- var ConfigFieldBridge = custom();
20858
- var PipelineAddonSchemaSchema = object({
21353
+ var SensorEventSchema = object({
20859
21354
  id: string(),
20860
- name: string(),
20861
- slot: PipelineSlotSchema,
20862
- inputClasses: array(string()).readonly(),
20863
- outputClasses: array(string()).readonly(),
20864
- childSlots: array(PipelineSlotSchema).readonly(),
20865
- models: array(PipelineModelOptionSchema).readonly(),
20866
- defaultModelId: string(),
20867
- defaultModelIdByFormat: record(string(), string()).optional(),
20868
- enabledByDefault: boolean().optional(),
20869
- backfillIntoExistingOverrides: boolean().optional(),
20870
- defaultConfidence: number(),
20871
- group: string().optional(),
20872
- configSchema: array(ConfigFieldBridge).readonly().optional()
21355
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
21356
+ * yields N rows, one per camera). */
21357
+ deviceId: number(),
21358
+ /** The linked sensor device whose state changed. */
21359
+ sourceDeviceId: number(),
21360
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
21361
+ kind: string(),
21362
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
21363
+ value: record(string(), unknown()).nullable(),
21364
+ timestamp: number()
20873
21365
  });
20874
- var PipelineSlotSchemaSchema = object({
20875
- id: PipelineSlotSchema,
20876
- label: string(),
20877
- priority: number(),
20878
- parentSlot: PipelineSlotSchema.nullable(),
20879
- addons: array(PipelineAddonSchemaSchema).readonly()
21366
+ /**
21367
+ * One stored sighting on a track's trajectory.
21368
+ *
21369
+ * The array these live in is returned in TIME order (D399) — it is APPENDED in
21370
+ * arrival order, and the two detector passes interleave, so a consumer must not
21371
+ * assume the two are the same on a row written by an older build.
21372
+ */
21373
+ var TrackPositionSchema = object({
21374
+ x: number(),
21375
+ y: number(),
21376
+ timestamp: number(),
21377
+ bbox: BoundingBoxSchema,
21378
+ /**
21379
+ * Which detector pass measured this box (D399): `frame` is the full-frame
21380
+ * pass on the analysis raster, `recovery` is the native-resolution
21381
+ * small-subject second pass (D377/D378). Both write into one array, and until
21382
+ * this field existed the only way to tell them apart was that full-frame boxes
21383
+ * are exact multiples of 1.2 while recovery boxes are full-precision floats.
21384
+ * Absent on rows written before D399.
21385
+ */
21386
+ source: _enum(["frame", "recovery"]).optional(),
21387
+ /** Detection score of this box, so a position can be weighed and not only
21388
+ * plotted. Absent on rows written before D399. */
21389
+ score: number().optional()
20880
21390
  });
20881
- var PipelineSchemaSchema = object({
20882
- availableEngines: array(AvailableEngineSchema).readonly(),
20883
- selectedEngine: PipelineEngineChoiceSchema,
20884
- slots: array(PipelineSlotSchemaSchema).readonly()
20885
- });
20886
- var EngineProvisioningSchema = object({
20887
- runtimeId: _enum([
20888
- "onnx",
20889
- "openvino",
20890
- "coreml",
20891
- "edgetpu"
20892
- ]).nullable(),
20893
- device: string().nullable(),
20894
- state: _enum([
20895
- "idle",
20896
- "installing",
20897
- "verifying",
20898
- "ready",
20899
- "failed"
20900
- ]),
20901
- progress: number().optional(),
20902
- error: string().optional(),
20903
- nextRetryAt: number().optional(),
20904
- /**
20905
- * Gate A (config-correctness gate at engine change): human-readable
20906
- * config issues surfaced EAGERLY when the node's engine changes — model
20907
- * substitutions ("chose X, running Y") and zero-build steps ("no model
20908
- * has a <format> build"). Additive/optional: informational only, never
20909
- * enforced here — `assertEngineReady` (readiness) still gates inference.
20910
- * Absent/empty when the node-default tree resolves cleanly.
20911
- */
20912
- configIssues: array(string()).optional()
20913
- });
20914
- var PipelineStepInputSchema = lazy(() => object({
20915
- addonId: string(),
20916
- modelId: string().optional(),
20917
- enabled: boolean().default(true),
20918
- children: array(PipelineStepInputSchema).optional(),
20919
- settings: record(string(), unknown()).optional(),
20920
- jumpDeviceKey: string().optional()
20921
- }));
20922
- var ModelSubstitutionSchema = object({
20923
- addonId: string(),
20924
- chosen: string(),
20925
- running: string(),
20926
- format: string()
20927
- });
20928
- var PipelineValidationIssueSchema = object({
20929
- addonId: string(),
20930
- kind: _enum(["unknown-addon", "no-format-build"]),
20931
- detail: string()
20932
- });
20933
- var PipelineValidationResultSchema = object({
20934
- ok: boolean(),
20935
- issues: array(PipelineValidationIssueSchema).readonly(),
20936
- substitutions: array(ModelSubstitutionSchema).readonly(),
20937
- /** The node's `currentEngine.format` this validation ran against. */
20938
- format: string()
20939
- });
20940
- var ReferenceImageEntrySchema = object({
20941
- filename: string(),
20942
- stepIds: array(string()).readonly().optional()
20943
- });
20944
- var ReferenceImageBodySchema = object({
20945
- base64: string(),
20946
- filename: string()
20947
- });
20948
- var ReferenceAudioEntrySchema = object({
20949
- filename: string(),
20950
- sizeKb: number()
20951
- });
20952
- var ReferenceAudioBodySchema = object({ base64: string() });
20953
- var AudioBackendSchema = object({
20954
- id: string(),
20955
- name: string(),
20956
- description: string(),
20957
- available: boolean(),
20958
- /**
20959
- * Raw classifier labels this backend can emit (e.g. YAMNet's
20960
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
20961
- * the benchmark UI to populate the `enabledMicroClasses` filter
20962
- * specific to the selected backend without a separate fetch.
20963
- */
20964
- rawLabels: array(string()).readonly().optional()
20965
- });
20966
- var AudioCapabilitiesSchema = object({
20967
- activeBackend: string(),
20968
- availableBackends: array(AudioBackendSchema).readonly(),
20969
- sampleRate: number(),
20970
- chunkDurationMs: number()
20971
- });
20972
- var DownloadModelResultSchema = object({
20973
- filePath: string(),
20974
- sizeMB: number(),
20975
- durationMs: number()
20976
- });
20977
- /**
20978
- * Wrapper carrying a single test run's result. Replaces the legacy
20979
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
20980
- * canonical `AudioResult` from the Phase 6 output rework: one
20981
- * `AudioDetection` per class above `minScore`, top-N candidates in
20982
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
20983
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
20984
- * benchmark UI can still report a clean failure when the classifier
20985
- * cap isn't available.
20986
- */
20987
- var AudioTestResultSchema = object({
20988
- success: boolean(),
20989
- error: string().optional(),
20990
- frame: custom().optional()
20991
- });
20992
- var PipelineConfigBridge = custom();
20993
- var ConfigUISchemaBridge = custom();
20994
- var ConfigUISchemaNullableBridge = custom();
20995
- var InferenceCapabilitiesBridge = custom();
20996
- var ModelAvailabilityListBridge = custom();
20997
- var PipelineRunResultBridge = custom();
20998
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
20999
- modelId: string(),
21000
- settings: record(string(), unknown()).readonly()
21001
- }))), method(object({ steps: record(string(), object({
21002
- modelId: string(),
21003
- settings: record(string(), unknown()).readonly()
21004
- })) }), object({ success: literal(true) }), {
21005
- kind: "mutation",
21006
- auth: "admin"
21007
- }), method(object({ nodeId: string() }), object({
21008
- success: literal(true),
21009
- clearedDevices: number()
21010
- }), {
21011
- kind: "mutation",
21012
- auth: "admin"
21013
- }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
21014
- /** `<backend>:<device>`, e.g. `openvino:gpu`. */
21015
- deviceKey: string(),
21016
- /**
21017
- * `failed` — the per-device restart budget is exhausted; no pool
21018
- * will be spawned until an operator re-arms it or the runner
21019
- * respawns. `backoff` — under budget, waiting out the backoff (or
21020
- * a cached pool observed dead and not yet condemned).
21021
- */
21022
- state: _enum(["failed", "backoff"]),
21023
- /** Epoch ms of the death that produced this state. */
21024
- since: number(),
21025
- /** Pool deaths inside the current window. */
21026
- deaths: number(),
21027
- /** The last death's message. */
21028
- lastError: string()
21029
- })).readonly() })), method(object({
21030
- nodeId: string(),
21031
- deviceKey: string()
21032
- }), object({ rearmed: boolean() }), {
21033
- kind: "mutation",
21034
- auth: "admin"
21035
- }), 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({
21036
- name: string(),
21037
- steps: array(PipelineTemplateStepSchema).readonly(),
21038
- engine: PipelineEngineChoiceSchema
21039
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
21040
- id: string(),
21041
- name: string().optional(),
21042
- steps: array(PipelineTemplateStepSchema).readonly().optional()
21043
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
21044
- addonId: string(),
21045
- modelId: string(),
21046
- format: ModelFormatSchema$1
21047
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
21048
- addonId: string(),
21049
- modelId: string(),
21050
- format: ModelFormatSchema$1
21051
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
21052
- engine: PipelineEngineChoiceSchema.optional(),
21053
- steps: array(PipelineStepInputSchema).min(1),
21054
- frame: FrameInputSchema.optional(),
21055
- /**
21056
- * Process-local lazy frame. Valid only when caller and provider resolve
21057
- * in the same execution-group process; split/cross-node callers use
21058
- * `frame`/`image` inline compatibility instead.
21059
- */
21060
- frameRef: FrameRefSchema.optional(),
21061
- /**
21062
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
21063
- * the decoded pixels live in. One more member of the one-of
21064
- * frame/frameHandle/image/imageBase64/referenceImage group.
21065
- */
21066
- frameHandle: FrameHandleSchema.optional(),
21067
- imageBase64: string().optional(),
21068
- /**
21069
- * Binary JPEG bytes — preferred over `imageBase64` on internal
21070
- * hops (hub → forked worker via Moleculer MsgPack) because it
21071
- * skips the 33% base64 overhead + the per-call base64 decode on
21072
- * the detection-pipeline worker. Callers can pass either; exactly
21073
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
21074
- */
21075
- image: _instanceof(Uint8Array).optional(),
21076
- referenceImage: string().optional(),
21077
- deviceId: number().optional(),
21078
- sessionId: string().optional(),
21079
- /**
21080
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
21081
- * reference-image, and detail-subtree calls. 'frame' is the live
21082
- * per-frame dispatch: ONLY root-plane steps run; crop children
21083
- * (inputClasses ≠ null) are skipped and served per-track via
21084
- * pipelineRunner.runDetailSubtree (two-plane design).
21085
- */
21086
- plane: _enum(["full", "frame"]).optional(),
21087
- /**
21088
- * Inference-device selector (Phase 2 multi-device). Format
21089
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
21090
- * Omitted ⇒ the runner's default device (current single-engine
21091
- * behaviour). Selects WHICH device pool of the node runs the call.
21092
- */
21093
- deviceKey: string().optional(),
21094
- /**
21095
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
21096
- * when the parent crop was resolved from the frame's retained NATIVE
21097
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
21098
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
21099
- * resolution from that surface — the SAME quality path faces already
21100
- * had — instead of the downscaled parent tile. `handle` keys the native
21101
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
21102
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
21103
- * the executor's crop-normalized child ROI back into frame-normalized
21104
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
21105
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
21106
- * (today's behaviour on the fallback path).
21107
- */
21108
- nativeCropRef: NativeCropRefSchema.optional()
21109
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
21110
- engine: PipelineEngineChoiceSchema.optional(),
21111
- steps: array(PipelineStepInputSchema).min(1),
21112
- frames: array(FrameInputSchema).min(1).max(255),
21113
- deviceId: number().optional(),
21114
- sessionId: string().optional(),
21115
- /**
21116
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
21117
- * the batch to the Python pool's bench preprocess cache
21118
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
21119
- * preprocessed ONCE and every later inference is a pure-inference cache
21120
- * hit — the sustained-throughput run measures inference, not
21121
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
21122
- * full preprocess every call, correct). Fresh per sustained run;
21123
- * released via `uncacheFrame`.
21124
- */
21125
- frameId: number().int().nonnegative().optional(),
21126
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
21127
- deviceKey: string().optional()
21128
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
21129
- data: _instanceof(Uint8Array),
21130
- width: number().int().positive(),
21131
- height: number().int().positive(),
21132
- format: _enum([
21133
- "rgb",
21134
- "bgr",
21135
- "gray"
21136
- ])
21137
- }), object({
21138
- frameId: number(),
21139
- width: number(),
21140
- height: number()
21141
- }), { kind: "mutation" }), method(object({
21142
- stepId: string(),
21143
- frameId: number().int()
21144
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
21145
- batchMode: string(),
21146
- windowMs: number(),
21147
- maxBatchSize: number(),
21148
- concurrency: number()
21149
- })), method(_void(), array(object({
21150
- engineKey: string(),
21151
- engine: PipelineEngineChoiceSchema,
21152
- modelsLoaded: array(string()).readonly(),
21153
- inUseByCameras: array(number()).readonly(),
21154
- /**
21155
- * Origin of this resident factory.
21156
- * - `runtime` — main camera-serving engine (no idle TTL).
21157
- * - `warm-override` — benchmark/test override held in the warm
21158
- * cache; auto-disposed after the idle TTL.
21159
- * - `device-pool` — a concurrent per-device pool (Phase 2
21160
- * multi-device, keyed by `deviceKey`) resolved
21161
- * via `resolveDeviceFactory`. Runs alongside the
21162
- * `runtime` engine on a DIFFERENT accelerator
21163
- * (NPU / iGPU / Coral) — this is how the
21164
- * Engines tab shows all pools running at once.
21165
- */
21166
- kind: _enum([
21167
- "runtime",
21168
- "warm-override",
21169
- "device-pool"
21170
- ]),
21171
- /** Native pid of the underlying Python pool (null when no pool). */
21172
- poolPid: number().nullable(),
21173
- /** ms since this factory was last used (null when not warm-tracked). */
21174
- idleMs: number().nullable(),
21175
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
21176
- idleTtlMs: number().nullable()
21177
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
21178
- kind: "mutation",
21179
- auth: "admin"
21180
- }), method(object({
21181
- engine: PipelineEngineChoiceSchema,
21182
- force: boolean().optional()
21183
- }), object({
21184
- success: boolean(),
21185
- reason: string().optional()
21186
- }), {
21187
- kind: "mutation",
21188
- auth: "admin"
21189
- }), 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({
21190
- addonId: string(),
21191
- modelId: string(),
21192
- filename: string().optional(),
21193
- settings: record(string(), unknown()).optional()
21194
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
21195
- /**
21196
- * Per-stage gating mode applied to the zones a rule references.
21197
- *
21198
- * - `include`: the rule contributes to a **whitelist** for its stage.
21199
- * When at least one `include` rule fires for a stage, only entities
21200
- * inside one of those zones pass that stage.
21201
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
21202
- * Entities inside one of those zones are dropped at that stage.
21203
- *
21204
- * `monitor`-style observation (count without filtering) is not a rule
21205
- * mode — zones without any matching rule are observed naturally by
21206
- * `zone-analytics` (live snapshot + history), so an "I just want to
21207
- * count, not filter" use case needs no rule at all.
21208
- */
21209
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
21210
- /**
21211
- * Per-consumer rule that references existing zones (geometry) and
21212
- * defines how a specific pipeline stage should treat them. Each
21213
- * consumer addon owns its own `ZoneRule[]` array in its per-device
21214
- * settings:
21215
- *
21216
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
21217
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
21218
- * - future: notification rules, audio gating, etc.
21219
- *
21220
- * One rule applies to N zones (`zoneIds[]`) so the operator can
21221
- * express "ignore motion in ALL of {garden, street}" with a single
21222
- * rule. `classFilter` narrows the rule to specific object classes —
21223
- * "drop person detections in the street, but keep cars" is one
21224
- * `exclude` rule with `classFilter: ['person']`.
21225
- *
21226
- * `enabled` is a soft toggle — the operator can keep the rule
21227
- * configured but inert without deleting it.
21228
- */
21229
- var ZoneRuleSchema = object({
21230
- /** Stable rule id — survives edits, used by the UI for diffing. */
21231
- id: string(),
21232
- /** Optional human-readable label rendered in the rule editor. */
21233
- name: string().optional(),
21234
- /** Zones this rule targets. The rule's `mode` applies to ALL
21235
- * listed zones (OR-set: a detection in any one of them counts).
21236
- * At least one zone id required — a rule with no targets is a
21237
- * configuration mistake and the form validator rejects it. */
21238
- zoneIds: array(string()).min(1).readonly(),
21239
- mode: ZoneRuleModeEnum,
21240
- /**
21241
- * Class names this rule applies to. Empty / undefined ⇒ rule
21242
- * applies to every class. Class strings match the `macroClass`
21243
- * field on detections (e.g. `person`, `car`, `dog`).
21244
- */
21245
- classFilter: array(string()).readonly().optional(),
21246
- /**
21247
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
21248
- * required to consider an entity "in the zone". Defaults to the
21249
- * consumer's stage default when omitted. Kept for back-compat with
21250
- * existing per-rule overrides; new operators pick the value via
21251
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
21252
- * set, the lower-level engine reads it as a 0–1 fraction.
21253
- */
21254
- overlapThreshold: number().min(0).max(1).optional(),
21255
- /**
21256
- * Operator-friendly version of `overlapThreshold` — the percentage
21257
- * of the detection's bbox that must lie inside the zone for the
21258
- * rule to match. Documented default is 85%; the engine substitutes
21259
- * that when the field is omitted (kept optional so existing rules
21260
- * stored without it stay valid).
21261
- *
21262
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
21263
- * rule, the engine prefers `bboxInclusionPct` because it's the
21264
- * field exposed in the UI. Internally both feed the same gate.
21265
- */
21266
- bboxInclusionPct: number().min(0).max(100).optional(),
21267
- /**
21268
- * When `true` and a detection has a segmentation mask, use the
21269
- * mask for overlap instead of the bbox. Detection-stage only;
21270
- * motion rules ignore this field.
21271
- */
21272
- preferMask: boolean().optional(),
21273
- /**
21274
- * Soft-toggle: `false` disables the rule without deleting it.
21275
- * Defaults to `true` so operators creating a rule via the UI
21276
- * see it active immediately.
21277
- */
21278
- enabled: boolean().default(true)
21279
- });
21280
- array(ZoneRuleSchema).readonly();
21281
- /**
21282
- * Zone — pure geometry + identity. NO filtering behaviour.
21283
- *
21284
- * Zones describe **where** in the frame the operator wants to flag
21285
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
21286
- * each pipeline stage uses them. Splitting the two means a single
21287
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
21288
- * a detection-include rule on `['car']`, and an occupancy aggregate
21289
- * — without three duplicated polygons.
21290
- *
21291
- * Owned by the orchestrator addon (provider) and mirrored into the
21292
- * `zones` device-state slice on every mutation. Consumers
21293
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
21294
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
21295
- * mirror with `onChanged`).
21296
- *
21297
- * Coordinates are normalised fractions of the frame (0–1) so zones
21298
- * survive resolution changes and stream profile switches.
21299
- *
21300
- * `kind` discriminates between full polygons (closed regions used
21301
- * for intrusion / occupancy filters) and tripwires (open 2-point
21302
- * line segments used for cross events). Onboard / firmware-reported
21303
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
21304
- * task list.
21305
- */
21306
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
21307
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
21308
- var PolygonPointSchema = object({
21309
- x: number(),
21310
- y: number()
21311
- });
21312
- /** A camera detection zone — pure geometry/identity. */
21313
- var ZoneSchema = object({
21314
- id: string(),
21315
- name: string(),
21316
- kind: ZoneKindEnum.default("polygon"),
21317
- /** Polygon vertices, fraction of frame (0–1). */
21318
- polygon: array(PolygonPointSchema).readonly(),
21319
- /** Visual color for UI rendering. */
21320
- color: string().default("#3b82f6")
21321
- });
21322
- /**
21323
- * Zones capability — per-camera CRUD over polygon detection zones.
21324
- *
21325
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
21326
- * to per-device settings and mirrors into the `zones` device-state
21327
- * slice on every mutation, so downstream consumers can subscribe via
21328
- * `dev.state.zones.onChanged`.
21329
- *
21330
- * The cap surface only handles geometry + identity; filtering
21331
- * behaviour (per-class, include/exclude, threshold) lives in the
21332
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
21333
- * `capabilities/schemas/zone-rule.js`.
21334
- */
21335
- var zonesCapability = {
21336
- name: "zones",
21337
- scope: "device",
21338
- mode: "singleton",
21339
- deviceTypes: [DeviceType.Camera],
21340
- methods: {
21341
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
21342
- addZone: method(object({
21343
- deviceId: number(),
21344
- zone: ZoneSchema
21345
- }), _void(), {
21346
- kind: "mutation",
21347
- auth: "admin"
21348
- }),
21349
- removeZone: method(object({
21350
- deviceId: number(),
21351
- zoneId: string()
21352
- }), _void(), {
21353
- kind: "mutation",
21354
- auth: "admin"
21355
- }),
21356
- updateZone: method(object({
21357
- deviceId: number(),
21358
- zone: ZoneSchema
21359
- }), _void(), {
21360
- kind: "mutation",
21361
- auth: "admin"
21362
- })
21363
- },
21364
- /**
21365
- * Runtime-state slice — the live zone catalogue mirrored by the
21366
- * orchestrator on every CRUD mutation. Consumers read via
21367
- * `device.state.zones.value` / `.watch(...)` without round-tripping
21368
- * the cap, and the codegen DeviceProxy auto-wires the reactive
21369
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
21370
- * (e.g. zone groupings) can sit alongside the polygon list.
21371
- */
21372
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
21373
- /**
21374
- * Runtime-state durability: **restored** — written only on operator mutation, so a camera that never had one has nothing to re-derive from. This is the slice `zone-mirror-hydration.ts` exists to paper over.
21375
- *
21376
- * See `RuntimeStateDurability`. Enforced by
21377
- * `scripts/check-runtime-state-durability.ts`.
21378
- */
21379
- durability: "restored"
21380
- };
21381
- /**
21382
- * pipeline-analytics — device-scoped wrapper cap. Refines raw
21383
- * per-frame detections emitted by the pipeline runner into tracked
21384
- * objects, per-kind event collections (motion / object / audio), and
21385
- * persisted media. Owns the post-detection domain end-to-end:
21386
- *
21387
- * runner emits PipelineInferenceResult
21388
- * ↓ (event bus)
21389
- * pipeline-analytics subscriber
21390
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
21391
- * → three DB collections (one per kind), one FS media tree, one
21392
- * unified event emitter (FrameTracked + TrackStarted/Ended +
21393
- * DetectionEvent on bus)
21394
- *
21395
- * Pure subscriber model. No `processFrame` cap method — the runner
21396
- * already publishes the raw frame on the bus. The cap surface is
21397
- * only QUERIES + per-device settings, bound on/off via
21398
- * `device-manager.setWrapperActive`. `defaultActive: true` because
21399
- * every camera with a detection pipeline wants its raw detections
21400
- * refined; operators opt out per-device via BindingsTab when needed.
21401
- *
21402
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
21403
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
21404
- */
21405
- var TrackStateSchema = _enum([
21406
- "new",
21407
- "entered",
21408
- "left",
21409
- "moving",
21410
- "idle"
21411
- ]);
21412
- var EventKindSchema = _enum([
21413
- "motion",
21414
- "object",
21415
- "audio"
21416
- ]);
21417
- /**
21418
- * Spatial filter for `listTracks` — the rect + polygon variants of the shared
21419
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
21420
- * of the camera frame (top-left origin), matching the drawing-plane editor.
21421
- */
21422
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
21423
- /** Closed icon vocabulary so clients render a known glyph per kind. */
21424
- var EventKindIconSchema = _enum([
21425
- "motion",
21426
- "audio",
21427
- "person",
21428
- "vehicle",
21429
- "animal",
21430
- "door",
21431
- "pir",
21432
- "smoke",
21433
- "water",
21434
- "button",
21435
- "package",
21436
- "generic"
21437
- ]);
21438
- var EventKindCategorySchema = _enum([
21439
- "motion",
21440
- "audio",
21441
- "detection",
21442
- "sensor",
21443
- "control",
21444
- "custom",
21445
- "package"
21446
- ]);
21447
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
21448
- var EventKindLevelSchema = _enum(["macro", "sub"]);
21449
- var EventKindDescriptorSchema = object({
21450
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
21451
- kind: string(),
21452
- /** i18n key resolved on the UI side; `label` is the English fallback. */
21453
- labelKey: string(),
21454
- /** English fallback label (kept for clients that don't translate). */
21455
- label: string(),
21456
- /** Hex color for timeline/legend rendering. */
21457
- color: string(),
21458
- /** Dictionary id → lucide component on the UI side. */
21459
- iconId: string(),
21460
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
21461
- icon: EventKindIconSchema,
21462
- category: EventKindCategorySchema,
21463
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
21464
- parentKind: string().nullable(),
21465
- /** Derived from `parentKind`, explicit for the client tree. */
21466
- level: EventKindLevelSchema,
21467
- /** Which cap + device contributes this kind. For built-ins the camera
21468
- * itself; for sensor kinds the LINKED source device. */
21469
- source: object({
21470
- capName: string(),
21471
- deviceId: number()
21472
- })
21473
- });
21474
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
21475
- var EventKindsForDeviceSchema = object({
21476
- deviceId: number(),
21477
- kinds: array(EventKindDescriptorSchema).readonly()
21478
- });
21479
- var SensorEventSchema = object({
21480
- id: string(),
21481
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
21482
- * yields N rows, one per camera). */
21483
- deviceId: number(),
21484
- /** The linked sensor device whose state changed. */
21485
- sourceDeviceId: number(),
21486
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
21487
- kind: string(),
21488
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
21489
- value: record(string(), unknown()).nullable(),
21490
- timestamp: number()
21491
- });
21492
- /**
21493
- * One stored sighting on a track's trajectory.
21494
- *
21495
- * The array these live in is returned in TIME order (D399) — it is APPENDED in
21496
- * arrival order, and the two detector passes interleave, so a consumer must not
21497
- * assume the two are the same on a row written by an older build.
21498
- */
21499
- var TrackPositionSchema = object({
21500
- x: number(),
21501
- y: number(),
21502
- timestamp: number(),
21503
- bbox: BoundingBoxSchema,
21504
- /**
21505
- * Which detector pass measured this box (D399): `frame` is the full-frame
21506
- * pass on the analysis raster, `recovery` is the native-resolution
21507
- * small-subject second pass (D377/D378). Both write into one array, and until
21508
- * this field existed the only way to tell them apart was that full-frame boxes
21509
- * are exact multiples of 1.2 while recovery boxes are full-precision floats.
21510
- * Absent on rows written before D399.
21511
- */
21512
- source: _enum(["frame", "recovery"]).optional(),
21513
- /** Detection score of this box, so a position can be weighed and not only
21514
- * plotted. Absent on rows written before D399. */
21515
- score: number().optional()
21516
- });
21517
- var TrackSnapshotSchema = object({
21518
- timestamp: number(),
21519
- position: TrackPositionSchema,
21520
- /** The snapshot's media row id (D482); resolve via `listTrackMedia({ trackId })`. */
21521
- mediaId: number().int()
21391
+ var TrackSnapshotSchema = object({
21392
+ timestamp: number(),
21393
+ position: TrackPositionSchema,
21394
+ /** The snapshot's media row id (D482); resolve via `listTrackMedia({ trackId })`. */
21395
+ mediaId: number().int()
21522
21396
  });
21523
21397
  /**
21524
21398
  * Normalized 0..1 trajectory envelope (min/max over every position bbox,
@@ -21949,6 +21823,22 @@ var TrackSchema = object({
21949
21823
  * omit it. Render nothing when absent.
21950
21824
  */
21951
21825
  previewMissReason: string().optional(),
21826
+ /**
21827
+ * The ROOT model that produced this track — the `FrameResult.rootModelId` of
21828
+ * the frame it was BORN on (D646). What a later replay compares against, so
21829
+ * "the original model" is named rather than assumed. A birth fact: never
21830
+ * rewritten by a later frame. **Absent ≠ unknown-model**: a row from before
21831
+ * the column, and a track the camera's own detector produced, carry none.
21832
+ */
21833
+ modelId: string().optional(),
21834
+ /**
21835
+ * Size (px) of the detection frame this track's `positions[].bbox` live in —
21836
+ * the frame it was born on, else the camera's latest analysis frame at
21837
+ * persist time. Divide a position by these to normalise it. Absent when the
21838
+ * size was never known.
21839
+ */
21840
+ frameWidth: number().optional(),
21841
+ frameHeight: number().optional(),
21952
21842
  ...TrackFlagFields,
21953
21843
  ...TrackRetrainFields
21954
21844
  });
@@ -22178,7 +22068,8 @@ var MediaFileKindEnum = _enum([
22178
22068
  "thumbnailSmall",
22179
22069
  "confirmationCrop",
22180
22070
  "debugCrop",
22181
- "sceneFrame"
22071
+ "sceneFrame",
22072
+ "lastSceneFrame"
22182
22073
  ]);
22183
22074
  /**
22184
22075
  * One media row ON THE WIRE: what it is, how big it is, and WHERE ITS BYTES
@@ -22730,7 +22621,23 @@ var SearchObjectEventsInput = object({
22730
22621
  until: number().optional(),
22731
22622
  classFilter: string().optional(),
22732
22623
  limit: number().default(50),
22733
- minScore: number().min(0).max(1).default(.2)
22624
+ /**
22625
+ * An ABSOLUTE cosine floor. Optional since D649: a floor is a property of the
22626
+ * model (0.2 kept 96% of matched pairs on MobileCLIP S1 and 2.7% on SigLIP2),
22627
+ * so an absent one resolves to the searched model's own `searchMinScore`
22628
+ * scaled by `strictness`. A number sent here is honoured verbatim.
22629
+ */
22630
+ minScore: number().min(0).max(1).optional(),
22631
+ /** Model-relative floor — see `resolveClipSearchMinScore`. Default `loose`. */
22632
+ strictness: ClipSearchStrictnessSchema.optional(),
22633
+ /**
22634
+ * Search THIS CLIP model's index instead of the cluster row's. Every index a
22635
+ * model ever wrote stays searchable until it is wiped (the MobileCLIP index
22636
+ * through a SigLIP2 cutover and its rollback window). An id with no CLIP
22637
+ * metadata is refused; an id other than the cluster row's is ADMIN-only
22638
+ * (`model-override-requires-admin`).
22639
+ */
22640
+ modelId: string().min(1).optional()
22734
22641
  });
22735
22642
  var TrackCascadeCountsSchema = object({
22736
22643
  /** Persisted track roots deleted (authoritative). */
@@ -22865,7 +22772,41 @@ var RebuildObjectEmbeddingsInput = object({
22865
22772
  * comparable, so wiping and rebuilding is the only way to be sure every vector
22866
22773
  * means the same thing.
22867
22774
  */
22868
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
22775
+ var WipeObjectEmbeddingsResultSchema = object({
22776
+ deleted: number(),
22777
+ /**
22778
+ * CLIP indexes that could NOT be emptied (unreachable, or refused at their
22779
+ * dimension) — not a clean slate. Additive and optional (D649).
22780
+ */
22781
+ failedIndexes: array(string()).optional()
22782
+ });
22783
+ /**
22784
+ * Why a rebuild did not start, BY NAME — ONE vocabulary for both gates in front
22785
+ * of a pass (D649 over D651). A bare `started: false` read the same for "the
22786
+ * stores are booting" and "the cluster row names a model with no CLIP
22787
+ * metadata", which need different fixes.
22788
+ * - `stores-unavailable` — the analytics stores or the API are not up yet.
22789
+ * - the owner's confirmation of the cluster model (D651, `ClusterPinConfirmer`):
22790
+ * a pass that rewrites an index needs two agreeing reads of the OWNER's
22791
+ * answer (`pipelineOrchestrator.getClusterModelChoice`) — a pass that cannot
22792
+ * name its model does not run (D54):
22793
+ * - the owner's own `unreadable` reasons (`owner-not-ready`,
22794
+ * `store-read-failed`, `three-way-read-unavailable`, `invalid-stored`,
22795
+ * `not-cluster-scoped`);
22796
+ * - `method-unavailable` — the orchestrator predates the method;
22797
+ * - `read-failed` — the call failed or answered something unparseable;
22798
+ * - `reads-disagree` — the two reads named different choices.
22799
+ * - `not-a-clip-model` — the CONFIRMED id has no CLIP metadata, so there is no
22800
+ * index to fill and no dimension to check against (D649).
22801
+ */
22802
+ var RebuildObjectEmbeddingsRefusalSchema = _enum([
22803
+ "stores-unavailable",
22804
+ ...CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS,
22805
+ "method-unavailable",
22806
+ "read-failed",
22807
+ "reads-disagree",
22808
+ "not-a-clip-model"
22809
+ ]);
22869
22810
  /**
22870
22811
  * Acknowledgement that a rebuild STARTED.
22871
22812
  *
@@ -22878,7 +22819,12 @@ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
22878
22819
  var RebuildObjectEmbeddingsResultSchema = object({
22879
22820
  started: boolean(),
22880
22821
  /** True when a pass was already running; the new request is ignored. */
22881
- alreadyRunning: boolean()
22822
+ alreadyRunning: boolean(),
22823
+ /** Present when the pass refused to start — see `RebuildObjectEmbeddingsRefusalSchema`. */
22824
+ refusal: RebuildObjectEmbeddingsRefusalSchema.optional(),
22825
+ /** The CLIP model the pass pinned, and the index it fills (when it started). */
22826
+ modelId: string().optional(),
22827
+ index: string().optional()
22882
22828
  });
22883
22829
  var RebuildStatusSchema = object({
22884
22830
  running: boolean(),
@@ -22912,7 +22858,11 @@ var RebuildStatusSchema = object({
22912
22858
  startedAtMs: number().nullable(),
22913
22859
  finishedAtMs: number().nullable(),
22914
22860
  /** Present when the pass ended by throwing. */
22915
- error: string().nullable()
22861
+ error: string().nullable(),
22862
+ /** The CLIP model the current / last pass pinned (D54), `null` before any. */
22863
+ modelId: string().nullable(),
22864
+ /** The index that pass fills — `ClipModelMeta.vectorIndex` of `modelId` (D649). */
22865
+ index: string().nullable()
22916
22866
  });
22917
22867
  /**
22918
22868
  * Acknowledgement that a debug-media reclaim STARTED.
@@ -22955,24 +22905,6 @@ var MediaReclaimStatusSchema = object({
22955
22905
  finishedAtMs: number().nullable(),
22956
22906
  error: string().nullable()
22957
22907
  });
22958
- var ReplayFrameInputSchema = object({
22959
- timestamp: number(),
22960
- frame: PipelineRunResultBridge
22961
- });
22962
- var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
22963
- className: string(),
22964
- firstSeenMs: number(),
22965
- lastSeenMs: number(),
22966
- /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
22967
- * frame — a representative box for the diff's `(className, window, IoU)`
22968
- * pairing (`replay-diff.ts`). A replay does not need the full per-frame
22969
- * trajectory production's `Track.positions` keeps. */
22970
- bbox: BoundingBoxSchema,
22971
- /** How many of the input frames this track matched a real detection on
22972
- * (never a coasted/extrapolated frame) — the replay's own signal for "how
22973
- * solid is this track", cheaper than re-deriving it from a trajectory. */
22974
- framesMatched: number().int()
22975
- })).readonly() });
22976
22908
  /**
22977
22909
  * The long-term series a camera produces. A closed union so a typo cannot
22978
22910
  * invent one, and the ONE declaration of it — the addon's `AnalyticsLtsSeries`
@@ -23699,32 +23631,6 @@ var pipelineAnalyticsCapability = {
23699
23631
  kind: "mutation",
23700
23632
  auth: "admin"
23701
23633
  }),
23702
- /**
23703
- * The FrameProcessor pass of a replay run — see the `Replay` section
23704
- * above this capability's definition for why this is not the
23705
- * `processFrame` method this file's header says pipeline-analytics does
23706
- * not have.
23707
- *
23708
- * Constructs a FRESH `FrameProcessor` for `(deviceId, source)`, feeds it
23709
- * `frames` IN THE ORDER GIVEN (the caller is responsible for time
23710
- * ordering — this method does not sort), and returns the tracks it
23711
- * produced. Zero persistence: no `TrackStore`, no event bus, no media
23712
- * capture. `zones` / `detectionRules` are the run's OWN zone set —
23713
- * typically the camera's real zones plus an ephemeral overlay
23714
- * (`addon-benchmark`'s `replay-plan.ts`), never read from or written to
23715
- * the `zones` capability by this method itself.
23716
- */
23717
- runReplayFrameProcessor: method(object({
23718
- deviceId: number(),
23719
- source: DetectionSourceSchema,
23720
- zones: array(ZoneSchema).readonly().optional(),
23721
- detectionRules: array(ZoneRuleSchema).readonly().optional(),
23722
- zoneMembershipMinOverlap: number().min(0).max(1).optional(),
23723
- frames: array(ReplayFrameInputSchema).min(1)
23724
- }), RunReplayFrameProcessorResultSchema, {
23725
- kind: "mutation",
23726
- auth: "admin"
23727
- }),
23728
23634
  /** Every annotation on a track, oldest first. */
23729
23635
  listRetrainAnnotations: method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
23730
23636
  kind: "query",
@@ -23915,7 +23821,7 @@ var pipelineAnalyticsCapability = {
23915
23821
  * ObjectEvents by trackId. Returns up to `limit` events scored ≥
23916
23822
  * `minScore`, sorted descending by score.
23917
23823
  */
23918
- searchObjectEvents: method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()),
23824
+ searchObjectEvents: method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly(), { caller: "required" }),
23919
23825
  wipeObjectEmbeddings: method(object({}), WipeObjectEmbeddingsResultSchema, {
23920
23826
  kind: "mutation",
23921
23827
  auth: "admin"
@@ -23964,6 +23870,478 @@ var pipelineAnalyticsCapability = {
23964
23870
  }) }
23965
23871
  }
23966
23872
  };
23873
+ /**
23874
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
23875
+ * within the frame, so the executor can re-cut a leaf child ROI at native
23876
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
23877
+ */
23878
+ var NativeCropRefSchema = object({
23879
+ /** Handle keying the retained native surface (node-pinned to its owner). */
23880
+ handle: FrameHandleSchema,
23881
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
23882
+ cropFrameSpace: object({
23883
+ x: number(),
23884
+ y: number(),
23885
+ w: number(),
23886
+ h: number()
23887
+ })
23888
+ });
23889
+ object({
23890
+ crop: object({
23891
+ left: number(),
23892
+ top: number(),
23893
+ width: number().positive(),
23894
+ height: number().positive()
23895
+ }).optional(),
23896
+ content: object({
23897
+ width: number().int().positive(),
23898
+ height: number().int().positive()
23899
+ }),
23900
+ fit: _enum(["stretch", "contain"]),
23901
+ format: _enum([
23902
+ "rgb",
23903
+ "gray",
23904
+ "jpeg"
23905
+ ])
23906
+ });
23907
+ /**
23908
+ * Process-local frame identity. It is serializable so it can ride an in-process
23909
+ * capability call, but `registryId` deliberately prevents resolution in any
23910
+ * other process or execution group.
23911
+ */
23912
+ var FrameRefSchema = object({
23913
+ registryId: string().min(1),
23914
+ id: string().min(1),
23915
+ width: number().int().positive(),
23916
+ height: number().int().positive(),
23917
+ format: _enum(["rgb", "gray"]),
23918
+ timestamp: number(),
23919
+ capturedAt: number().optional()
23920
+ });
23921
+ var ModelFormatSchema$1 = _enum([
23922
+ "onnx",
23923
+ "coreml",
23924
+ "openvino",
23925
+ "tflite",
23926
+ "pt",
23927
+ "gguf"
23928
+ ]);
23929
+ var PipelineSlotSchema = _enum([
23930
+ "detector",
23931
+ "cropper",
23932
+ "classifier",
23933
+ "refiner",
23934
+ "audio-classifier"
23935
+ ]);
23936
+ var PipelineEngineChoiceSchema = object({
23937
+ runtime: literal("python"),
23938
+ backend: string(),
23939
+ format: ModelFormatSchema$1,
23940
+ device: string().optional()
23941
+ });
23942
+ /**
23943
+ * One pool's resolved provisioning (`getEffectiveTuning`). `numWorkers` is the
23944
+ * knob that lifts a saturated pool (`inference-devices.md`); `concurrency` is
23945
+ * per-worker in-flight requests. `deviceKey` echoes the pool asked about —
23946
+ * `null` for the node-default pool.
23947
+ */
23948
+ var EffectiveTuningSchema = object({
23949
+ deviceKey: string().nullable(),
23950
+ runtime: string(),
23951
+ batchMode: string(),
23952
+ windowMs: number(),
23953
+ maxBatchSize: number(),
23954
+ concurrency: number(),
23955
+ numWorkers: number()
23956
+ });
23957
+ var AvailableEngineSchema = object({
23958
+ engine: PipelineEngineChoiceSchema,
23959
+ devices: array(object({
23960
+ id: string(),
23961
+ label: string(),
23962
+ description: string().optional()
23963
+ })).readonly(),
23964
+ defaultDevice: string()
23965
+ });
23966
+ var PipelineDefaultStepSchema = lazy(() => object({
23967
+ addonId: string(),
23968
+ addonName: string(),
23969
+ slot: PipelineSlotSchema,
23970
+ inputClasses: array(string()).readonly(),
23971
+ outputClasses: array(string()).readonly(),
23972
+ enabled: boolean(),
23973
+ modelId: string(),
23974
+ children: array(PipelineDefaultStepSchema).readonly(),
23975
+ group: string().optional(),
23976
+ settings: record(string(), unknown()).optional()
23977
+ }));
23978
+ var PipelineTemplateStepSchema = lazy(() => object({
23979
+ addonId: string(),
23980
+ enabled: boolean(),
23981
+ modelId: string(),
23982
+ children: array(PipelineTemplateStepSchema).readonly(),
23983
+ settings: record(string(), unknown()).optional()
23984
+ }));
23985
+ var PipelineTemplateSchema$1 = object({
23986
+ id: string(),
23987
+ name: string(),
23988
+ createdAt: string(),
23989
+ updatedAt: string(),
23990
+ engine: PipelineEngineChoiceSchema,
23991
+ steps: array(PipelineTemplateStepSchema).readonly()
23992
+ });
23993
+ var PipelineModelOptionSchema = object({
23994
+ id: string(),
23995
+ name: string(),
23996
+ formats: record(string(), object({
23997
+ downloaded: boolean(),
23998
+ sizeMB: number()
23999
+ })),
24000
+ group: ModelVariantGroupSchema.optional(),
24001
+ legacy: boolean().optional(),
24002
+ provider: ModelProviderIdSchema.optional()
24003
+ });
24004
+ var ConfigFieldBridge = custom();
24005
+ var PipelineAddonSchemaSchema = object({
24006
+ id: string(),
24007
+ name: string(),
24008
+ slot: PipelineSlotSchema,
24009
+ inputClasses: array(string()).readonly(),
24010
+ outputClasses: array(string()).readonly(),
24011
+ childSlots: array(PipelineSlotSchema).readonly(),
24012
+ models: array(PipelineModelOptionSchema).readonly(),
24013
+ defaultModelId: string(),
24014
+ defaultModelIdByFormat: record(string(), string()).optional(),
24015
+ enabledByDefault: boolean().optional(),
24016
+ backfillIntoExistingOverrides: boolean().optional(),
24017
+ defaultConfidence: number(),
24018
+ group: string().optional(),
24019
+ configSchema: array(ConfigFieldBridge).readonly().optional()
24020
+ });
24021
+ var PipelineSlotSchemaSchema = object({
24022
+ id: PipelineSlotSchema,
24023
+ label: string(),
24024
+ priority: number(),
24025
+ parentSlot: PipelineSlotSchema.nullable(),
24026
+ addons: array(PipelineAddonSchemaSchema).readonly()
24027
+ });
24028
+ var PipelineSchemaSchema = object({
24029
+ availableEngines: array(AvailableEngineSchema).readonly(),
24030
+ selectedEngine: PipelineEngineChoiceSchema,
24031
+ slots: array(PipelineSlotSchemaSchema).readonly()
24032
+ });
24033
+ var EngineProvisioningSchema = object({
24034
+ runtimeId: _enum([
24035
+ "onnx",
24036
+ "openvino",
24037
+ "coreml",
24038
+ "edgetpu"
24039
+ ]).nullable(),
24040
+ device: string().nullable(),
24041
+ state: _enum([
24042
+ "idle",
24043
+ "installing",
24044
+ "verifying",
24045
+ "ready",
24046
+ "failed"
24047
+ ]),
24048
+ progress: number().optional(),
24049
+ error: string().optional(),
24050
+ nextRetryAt: number().optional(),
24051
+ /**
24052
+ * Gate A (config-correctness gate at engine change): human-readable
24053
+ * config issues surfaced EAGERLY when the node's engine changes — model
24054
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
24055
+ * has a <format> build"). Additive/optional: informational only, never
24056
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
24057
+ * Absent/empty when the node-default tree resolves cleanly.
24058
+ */
24059
+ configIssues: array(string()).optional()
24060
+ });
24061
+ var PipelineStepInputSchema = lazy(() => object({
24062
+ addonId: string(),
24063
+ modelId: string().optional(),
24064
+ enabled: boolean().default(true),
24065
+ children: array(PipelineStepInputSchema).optional(),
24066
+ settings: record(string(), unknown()).optional(),
24067
+ jumpDeviceKey: string().optional()
24068
+ }));
24069
+ var ModelSubstitutionSchema = object({
24070
+ addonId: string(),
24071
+ chosen: string(),
24072
+ running: string(),
24073
+ format: string()
24074
+ });
24075
+ var PipelineValidationIssueSchema = object({
24076
+ addonId: string(),
24077
+ kind: _enum([
24078
+ "unknown-addon",
24079
+ "no-format-build",
24080
+ "unknown-device"
24081
+ ]),
24082
+ detail: string()
24083
+ });
24084
+ var PipelineValidationResultSchema = object({
24085
+ ok: boolean(),
24086
+ issues: array(PipelineValidationIssueSchema).readonly(),
24087
+ substitutions: array(ModelSubstitutionSchema).readonly(),
24088
+ /** The node's `currentEngine.format` this validation ran against. */
24089
+ format: string()
24090
+ });
24091
+ var ReferenceImageEntrySchema = object({
24092
+ filename: string(),
24093
+ stepIds: array(string()).readonly().optional()
24094
+ });
24095
+ var ReferenceImageBodySchema = object({
24096
+ base64: string(),
24097
+ filename: string()
24098
+ });
24099
+ var ReferenceAudioEntrySchema = object({
24100
+ filename: string(),
24101
+ sizeKb: number()
24102
+ });
24103
+ var ReferenceAudioBodySchema = object({ base64: string() });
24104
+ var AudioBackendSchema = object({
24105
+ id: string(),
24106
+ name: string(),
24107
+ description: string(),
24108
+ available: boolean(),
24109
+ /**
24110
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
24111
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
24112
+ * the benchmark UI to populate the `enabledMicroClasses` filter
24113
+ * specific to the selected backend without a separate fetch.
24114
+ */
24115
+ rawLabels: array(string()).readonly().optional()
24116
+ });
24117
+ var AudioCapabilitiesSchema = object({
24118
+ activeBackend: string(),
24119
+ availableBackends: array(AudioBackendSchema).readonly(),
24120
+ sampleRate: number(),
24121
+ chunkDurationMs: number()
24122
+ });
24123
+ var DownloadModelResultSchema = object({
24124
+ filePath: string(),
24125
+ sizeMB: number(),
24126
+ durationMs: number()
24127
+ });
24128
+ /**
24129
+ * Wrapper carrying a single test run's result. Replaces the legacy
24130
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
24131
+ * canonical `AudioResult` from the Phase 6 output rework: one
24132
+ * `AudioDetection` per class above `minScore`, top-N candidates in
24133
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
24134
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
24135
+ * benchmark UI can still report a clean failure when the classifier
24136
+ * cap isn't available.
24137
+ */
24138
+ var AudioTestResultSchema = object({
24139
+ success: boolean(),
24140
+ error: string().optional(),
24141
+ frame: custom().optional()
24142
+ });
24143
+ var PipelineConfigBridge = custom();
24144
+ var ConfigUISchemaBridge = custom();
24145
+ var ConfigUISchemaNullableBridge = custom();
24146
+ var InferenceCapabilitiesBridge = custom();
24147
+ var ModelAvailabilityListBridge = custom();
24148
+ var PipelineRunResultBridge = custom();
24149
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
24150
+ modelId: string(),
24151
+ settings: record(string(), unknown()).readonly()
24152
+ }))), method(object({ steps: record(string(), object({
24153
+ modelId: string(),
24154
+ settings: record(string(), unknown()).readonly()
24155
+ })) }), object({ success: literal(true) }), {
24156
+ kind: "mutation",
24157
+ auth: "admin"
24158
+ }), method(object({ nodeId: string() }), object({
24159
+ success: literal(true),
24160
+ clearedDevices: number()
24161
+ }), {
24162
+ kind: "mutation",
24163
+ auth: "admin"
24164
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
24165
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
24166
+ deviceKey: string(),
24167
+ /**
24168
+ * `failed` — the per-device restart budget is exhausted; no pool
24169
+ * will be spawned until an operator re-arms it or the runner
24170
+ * respawns. `backoff` — under budget, waiting out the backoff (or
24171
+ * a cached pool observed dead and not yet condemned).
24172
+ */
24173
+ state: _enum(["failed", "backoff"]),
24174
+ /** Epoch ms of the death that produced this state. */
24175
+ since: number(),
24176
+ /** Pool deaths inside the current window. */
24177
+ deaths: number(),
24178
+ /** The last death's message. */
24179
+ lastError: string()
24180
+ })).readonly() })), method(object({
24181
+ nodeId: string(),
24182
+ deviceKey: string()
24183
+ }), object({ rearmed: boolean() }), {
24184
+ kind: "mutation",
24185
+ auth: "admin"
24186
+ }), method(_void(), PipelineSchemaSchema), method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()), method(_void(), PipelineConfigBridge), method(_void(), ConfigUISchemaBridge), method(object({
24187
+ steps: array(PipelineStepInputSchema),
24188
+ deviceKey: string().optional()
24189
+ }), PipelineValidationResultSchema), method(_void(), array(PipelineTemplateSchema$1).readonly()), method(object({
24190
+ name: string(),
24191
+ steps: array(PipelineTemplateStepSchema).readonly(),
24192
+ engine: PipelineEngineChoiceSchema
24193
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
24194
+ id: string(),
24195
+ name: string().optional(),
24196
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
24197
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
24198
+ addonId: string(),
24199
+ modelId: string(),
24200
+ format: ModelFormatSchema$1
24201
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
24202
+ addonId: string(),
24203
+ modelId: string(),
24204
+ format: ModelFormatSchema$1
24205
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
24206
+ steps: array(PipelineStepInputSchema).min(1),
24207
+ frame: FrameInputSchema.optional(),
24208
+ /**
24209
+ * Process-local lazy frame. Valid only when caller and provider resolve
24210
+ * in the same execution-group process; split/cross-node callers use
24211
+ * `frame`/`image` inline compatibility instead.
24212
+ */
24213
+ frameRef: FrameRefSchema.optional(),
24214
+ /**
24215
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
24216
+ * the decoded pixels live in. One more member of the one-of
24217
+ * frame/frameHandle/image/imageBase64/referenceImage group.
24218
+ */
24219
+ frameHandle: FrameHandleSchema.optional(),
24220
+ imageBase64: string().optional(),
24221
+ /**
24222
+ * Binary JPEG bytes — preferred over `imageBase64` on internal
24223
+ * hops (hub → forked worker via Moleculer MsgPack) because it
24224
+ * skips the 33% base64 overhead + the per-call base64 decode on
24225
+ * the detection-pipeline worker. Callers can pass either; exactly
24226
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
24227
+ */
24228
+ image: _instanceof(Uint8Array).optional(),
24229
+ referenceImage: string().optional(),
24230
+ deviceId: number().optional(),
24231
+ sessionId: string().optional(),
24232
+ /**
24233
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
24234
+ * reference-image, and detail-subtree calls. 'frame' is the live
24235
+ * per-frame dispatch: ONLY root-plane steps run; crop children
24236
+ * (inputClasses ≠ null) are skipped and served per-track via
24237
+ * pipelineRunner.runDetailSubtree (two-plane design).
24238
+ */
24239
+ plane: _enum(["full", "frame"]).optional(),
24240
+ /**
24241
+ * Inference-device selector (Phase 2 multi-device). Format
24242
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
24243
+ * Omitted ⇒ the runner's default device (current single-engine
24244
+ * behaviour). Selects WHICH device pool of the node runs the call.
24245
+ */
24246
+ deviceKey: string().optional(),
24247
+ /**
24248
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
24249
+ * when the parent crop was resolved from the frame's retained NATIVE
24250
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
24251
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
24252
+ * resolution from that surface — the SAME quality path faces already
24253
+ * had — instead of the downscaled parent tile. `handle` keys the native
24254
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
24255
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
24256
+ * the executor's crop-normalized child ROI back into frame-normalized
24257
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
24258
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
24259
+ * (today's behaviour on the fallback path).
24260
+ */
24261
+ nativeCropRef: NativeCropRefSchema.optional(),
24262
+ /**
24263
+ * Offline REPLAY of stored media for `deviceId` (D56, D646): the
24264
+ * camera's zone gate and overrides apply as live, every executing
24265
+ * step runs EXACTLY the model it names on the `deviceKey` pool it
24266
+ * names or the call refuses (`model-not-servable` /
24267
+ * `device-not-servable`), and nothing reaches the camera's live
24268
+ * trace stream. Absent ⇒ unchanged behaviour.
24269
+ */
24270
+ replay: literal(true).optional()
24271
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
24272
+ steps: array(PipelineStepInputSchema).min(1),
24273
+ frames: array(FrameInputSchema).min(1).max(255),
24274
+ deviceId: number().optional(),
24275
+ sessionId: string().optional(),
24276
+ /**
24277
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
24278
+ * the batch to the Python pool's bench preprocess cache
24279
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
24280
+ * preprocessed ONCE and every later inference is a pure-inference cache
24281
+ * hit — the sustained-throughput run measures inference, not
24282
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
24283
+ * full preprocess every call, correct). Fresh per sustained run;
24284
+ * released via `uncacheFrame`.
24285
+ */
24286
+ frameId: number().int().nonnegative().optional(),
24287
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
24288
+ deviceKey: string().optional()
24289
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
24290
+ data: _instanceof(Uint8Array),
24291
+ width: number().int().positive(),
24292
+ height: number().int().positive(),
24293
+ format: _enum([
24294
+ "rgb",
24295
+ "bgr",
24296
+ "gray"
24297
+ ])
24298
+ }), object({
24299
+ frameId: number(),
24300
+ width: number(),
24301
+ height: number()
24302
+ }), { kind: "mutation" }), method(object({
24303
+ stepId: string(),
24304
+ frameId: number().int()
24305
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(object({ deviceKey: string().optional() }), EffectiveTuningSchema), method(_void(), array(object({
24306
+ engineKey: string(),
24307
+ engine: PipelineEngineChoiceSchema,
24308
+ modelsLoaded: array(string()).readonly(),
24309
+ inUseByCameras: array(number()).readonly(),
24310
+ /**
24311
+ * Origin of this resident factory.
24312
+ * - `runtime` — main camera-serving engine (no idle TTL).
24313
+ * - `device-pool` — a concurrent per-device pool (Phase 2
24314
+ * multi-device, keyed by `deviceKey`) resolved
24315
+ * via `resolveDeviceFactory`. Runs alongside the
24316
+ * `runtime` engine on a DIFFERENT accelerator
24317
+ * (NPU / iGPU / Coral) — this is how the
24318
+ * Engines tab shows all pools running at once.
24319
+ */
24320
+ kind: _enum(["runtime", "device-pool"]),
24321
+ /** Native pid of the underlying Python pool (null when no pool). */
24322
+ poolPid: number().nullable(),
24323
+ /** ms since this factory was last used (null when not warm-tracked). */
24324
+ idleMs: number().nullable(),
24325
+ /** Idle TTL after which the factory self-evicts (null when not applicable). */
24326
+ idleTtlMs: number().nullable()
24327
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
24328
+ kind: "mutation",
24329
+ auth: "admin"
24330
+ }), method(object({
24331
+ engine: PipelineEngineChoiceSchema,
24332
+ force: boolean().optional()
24333
+ }), object({
24334
+ success: boolean(),
24335
+ reason: string().optional()
24336
+ }), {
24337
+ kind: "mutation",
24338
+ auth: "admin"
24339
+ }), 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({
24340
+ addonId: string(),
24341
+ modelId: string(),
24342
+ filename: string().optional(),
24343
+ settings: record(string(), unknown()).optional()
24344
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
23967
24345
  object({
23968
24346
  activeCameras: number(),
23969
24347
  throttledCameras: number(),
@@ -23989,6 +24367,106 @@ var CameraMetricsSchema = object({
23989
24367
  });
23990
24368
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
23991
24369
  /**
24370
+ * Zone — pure geometry + identity. NO filtering behaviour.
24371
+ *
24372
+ * Zones describe **where** in the frame the operator wants to flag
24373
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
24374
+ * each pipeline stage uses them. Splitting the two means a single
24375
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
24376
+ * a detection-include rule on `['car']`, and an occupancy aggregate
24377
+ * — without three duplicated polygons.
24378
+ *
24379
+ * Owned by the orchestrator addon (provider) and mirrored into the
24380
+ * `zones` device-state slice on every mutation. Consumers
24381
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
24382
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
24383
+ * mirror with `onChanged`).
24384
+ *
24385
+ * Coordinates are normalised fractions of the frame (0–1) so zones
24386
+ * survive resolution changes and stream profile switches.
24387
+ *
24388
+ * `kind` discriminates between full polygons (closed regions used
24389
+ * for intrusion / occupancy filters) and tripwires (open 2-point
24390
+ * line segments used for cross events). Onboard / firmware-reported
24391
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
24392
+ * task list.
24393
+ */
24394
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
24395
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
24396
+ var PolygonPointSchema = object({
24397
+ x: number(),
24398
+ y: number()
24399
+ });
24400
+ /** A camera detection zone — pure geometry/identity. */
24401
+ var ZoneSchema = object({
24402
+ id: string(),
24403
+ name: string(),
24404
+ kind: ZoneKindEnum.default("polygon"),
24405
+ /** Polygon vertices, fraction of frame (0–1). */
24406
+ polygon: array(PolygonPointSchema).readonly(),
24407
+ /** Visual color for UI rendering. */
24408
+ color: string().default("#3b82f6")
24409
+ });
24410
+ /**
24411
+ * Zones capability — per-camera CRUD over polygon detection zones.
24412
+ *
24413
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
24414
+ * to per-device settings and mirrors into the `zones` device-state
24415
+ * slice on every mutation, so downstream consumers can subscribe via
24416
+ * `dev.state.zones.onChanged`.
24417
+ *
24418
+ * The cap surface only handles geometry + identity; filtering
24419
+ * behaviour (per-class, include/exclude, threshold) lives in the
24420
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
24421
+ * `capabilities/schemas/zone-rule.js`.
24422
+ */
24423
+ var zonesCapability = {
24424
+ name: "zones",
24425
+ scope: "device",
24426
+ mode: "singleton",
24427
+ deviceTypes: [DeviceType.Camera],
24428
+ methods: {
24429
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
24430
+ addZone: method(object({
24431
+ deviceId: number(),
24432
+ zone: ZoneSchema
24433
+ }), _void(), {
24434
+ kind: "mutation",
24435
+ auth: "admin"
24436
+ }),
24437
+ removeZone: method(object({
24438
+ deviceId: number(),
24439
+ zoneId: string()
24440
+ }), _void(), {
24441
+ kind: "mutation",
24442
+ auth: "admin"
24443
+ }),
24444
+ updateZone: method(object({
24445
+ deviceId: number(),
24446
+ zone: ZoneSchema
24447
+ }), _void(), {
24448
+ kind: "mutation",
24449
+ auth: "admin"
24450
+ })
24451
+ },
24452
+ /**
24453
+ * Runtime-state slice — the live zone catalogue mirrored by the
24454
+ * orchestrator on every CRUD mutation. Consumers read via
24455
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
24456
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
24457
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
24458
+ * (e.g. zone groupings) can sit alongside the polygon list.
24459
+ */
24460
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
24461
+ /**
24462
+ * Runtime-state durability: **restored** — written only on operator mutation, so a camera that never had one has nothing to re-derive from. This is the slice `zone-mirror-hydration.ts` exists to paper over.
24463
+ *
24464
+ * See `RuntimeStateDurability`. Enforced by
24465
+ * `scripts/check-runtime-state-durability.ts`.
24466
+ */
24467
+ durability: "restored"
24468
+ };
24469
+ /**
23992
24470
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
23993
24471
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
23994
24472
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -24440,6 +24918,17 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
24440
24918
  hubHostnameOverride: string().optional()
24441
24919
  })]).describe("Per-camera frame-source mode for the runner (P2c)");
24442
24920
  /**
24921
+ * What ONE step runs with on ONE roster device for THIS camera (D650): the
24922
+ * device's per-(node,device) base with the camera's override for that device
24923
+ * on top — the same `override ?? base` merge the orchestrator applies to the
24924
+ * elected device (`applyDeviceProvisioning`). Absent `modelId` ⇒ the executor
24925
+ * resolves the device format's default, exactly as on the elected device.
24926
+ */
24927
+ var RunnerJumpStepProvisioningSchema = object({
24928
+ modelId: string().optional(),
24929
+ settings: record(string(), unknown()).optional()
24930
+ });
24931
+ /**
24443
24932
  * One ENABLED inference device on the runner's node, as the step-tree
24444
24933
  * device-jump resolver sees it (phase 1). The orchestrator populates this
24445
24934
  * roster on the attach payload whenever the camera is elected onto a specific
@@ -24451,7 +24940,16 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
24451
24940
  var RunnerInferenceDeviceSchema = object({
24452
24941
  deviceKey: string(),
24453
24942
  weight: number().positive().default(1),
24454
- maxSessions: number().int().positive().nullable().default(null)
24943
+ maxSessions: number().int().positive().nullable().default(null),
24944
+ /**
24945
+ * Per-step provisioning for this camera on THIS device (D650), keyed by step
24946
+ * id. A step the runner jumps here runs with these fields, never with the
24947
+ * elected device's: `modelId` / `settings` are REPLACED on the jumped subtree
24948
+ * (a step absent from the map runs with neither — the target format default).
24949
+ * Absent field ⇒ an orchestrator that predates D650: the jumped step keeps
24950
+ * the elected device's provisioning, as before.
24951
+ */
24952
+ steps: record(string(), RunnerJumpStepProvisioningSchema).optional()
24455
24953
  });
24456
24954
  /**
24457
24955
  * Camera assignment payload sent by `addon-pipeline-orchestrator` to a
@@ -25326,6 +25824,28 @@ var NodeInferenceDeviceSchema = object({
25326
25824
  */
25327
25825
  exclusion: InferenceDeviceExclusionReasonSchema.nullable()
25328
25826
  });
25827
+ /**
25828
+ * The operator's model choice for one cluster-scoped step, answered by the
25829
+ * addon that OWNS the `clusterModel:*` settings (D651). Three answers, never
25830
+ * folded: a written choice, a key nobody wrote (the cluster runs the default
25831
+ * BY ABSENCE), or no answer. A caller that rewrites an index acts only on the
25832
+ * first two, read twice and agreeing.
25833
+ */
25834
+ var ClusterModelChoiceSchema = discriminatedUnion("kind", [
25835
+ object({
25836
+ kind: literal("stored"),
25837
+ modelId: string()
25838
+ }),
25839
+ object({
25840
+ kind: literal("absent"),
25841
+ defaultModelId: string()
25842
+ }),
25843
+ object({
25844
+ kind: literal("unreadable"),
25845
+ reason: _enum(CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS),
25846
+ error: string().optional()
25847
+ })
25848
+ ]);
25329
25849
  var NodeInferenceDevicesSchema = object({
25330
25850
  nodeId: string(),
25331
25851
  /** False when the node's platform-probe was unreachable (no live device set). */
@@ -25353,10 +25873,17 @@ method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
25353
25873
  }), object({ success: literal(true) }), {
25354
25874
  kind: "mutation",
25355
25875
  auth: "admin"
25356
- }), method(object({ deviceId: number() }), object({ deviceKey: string().nullable() })), method(_void(), object({ migrated: number() }), {
25876
+ }), method(object({ deviceId: number() }), object({ deviceKey: string().nullable() })), method(_void(), object({
25877
+ migrated: number(),
25878
+ skipped: array(object({
25879
+ deviceId: number(),
25880
+ targetNodeId: string(),
25881
+ reason: string()
25882
+ })).default([])
25883
+ }), {
25357
25884
  kind: "mutation",
25358
25885
  auth: "admin"
25359
- }), 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({
25886
+ }), 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({
25360
25887
  nodeId: string(),
25361
25888
  capName: string(),
25362
25889
  addonId: string()
@@ -27072,6 +27599,20 @@ var VectorScanResultSchema = object({
27072
27599
  */
27073
27600
  nextCursor: number().int().nonnegative().nullable()
27074
27601
  });
27602
+ /**
27603
+ * The ONE error code for "this index exists at another dimension; refusing to
27604
+ * redeclare it" (D649). It rides in the MESSAGE — an Error's own properties do
27605
+ * not survive the UDS/tRPC hop, its message does — and both sides go through
27606
+ * the helpers below, never a copied phrase: a consumer that must tell "this
27607
+ * index can never hold my vectors" from "the provider is unreachable" (a
27608
+ * delete counts the first as nothing-to-delete and the second as still
27609
+ * present) otherwise breaks silently the day the wording changes.
27610
+ */
27611
+ var VECTOR_INDEX_DIM_CONFLICT = "vector-index-dim-conflict";
27612
+ /** True when `err` (possibly re-wrapped by a transport) is that refusal. */
27613
+ function isVectorIndexDimConflict(err) {
27614
+ return (err instanceof Error ? err.message : String(err)).includes(`[${VECTOR_INDEX_DIM_CONFLICT}]`);
27615
+ }
27075
27616
  var VectorStatsInputSchema = object({ index: string() });
27076
27617
  var VectorStatsResultSchema = object({
27077
27618
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -27731,6 +28272,349 @@ DeviceType.Camera, method(object({
27731
28272
  auth: "protected"
27732
28273
  });
27733
28274
  /**
28275
+ * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
28276
+ * valutatore puro del suo FRONTE.
28277
+ *
28278
+ * Viveva dentro il builtin virtual-doorbell
28279
+ * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
28280
+ * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
28281
+ * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
28282
+ * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
28283
+ * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
28284
+ * SPOSTA qui e il doorbell la ri-esporta.
28285
+ *
28286
+ * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
28287
+ * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
28288
+ * regola" (e include `presence`, `cover`, `alarm-panel`), questa a "qual è il
28289
+ * booleano il cui FRONTE conta". Vocabolari deliberatamente diversi.
28290
+ */
28291
+ /**
28292
+ * Known binary / switch source caps → the boolean slice field whose
28293
+ * false→true rise counts as ACTIVE. Every entry is "fire on active".
28294
+ * Sensors whose "active" reading is not a plain boolean (presence's string
28295
+ * state, connectivity's connected flag) are deliberately excluded — a
28296
+ * reconnect is not a doorbell press, and it is not a recording either.
28297
+ */
28298
+ var SOURCE_CAP_ACTIVE_FIELD = {
28299
+ contact: "entryOpen",
28300
+ binary: "on",
28301
+ switch: "on",
28302
+ motion: "detected",
28303
+ flood: "flooded",
28304
+ gas: "detected",
28305
+ smoke: "detected",
28306
+ "carbon-monoxide": "detected",
28307
+ vibration: "detected",
28308
+ tamper: "tampered"
28309
+ };
28310
+ /**
28311
+ * The same caps → the slice field carrying the ms-epoch timestamp of the
28312
+ * last transition. Every source cap MUST appear here (guarded by a spec):
28313
+ * without a transition timestamp the evaluator cannot tell a genuine rise
28314
+ * from a boot-time hydration when the FIRST slice it ever sees is already
28315
+ * active, and errs towards silence — swallowing the rise.
28316
+ *
28317
+ * These timestamps are UPSTREAM ones, not ingest ones: the Home Assistant
28318
+ * provider derives them from `state.last_changed`, so they survive our own
28319
+ * restarts and correctly read as "hours ago" for a state that has been
28320
+ * active for hours. `motion` names its rise timestamp `lastDetectedAt`.
28321
+ */
28322
+ var SOURCE_CAP_CHANGED_AT_FIELD = {
28323
+ contact: "lastChangedAt",
28324
+ binary: "lastChangedAt",
28325
+ switch: "lastChangedAt",
28326
+ motion: "lastDetectedAt",
28327
+ flood: "lastChangedAt",
28328
+ gas: "lastChangedAt",
28329
+ smoke: "lastChangedAt",
28330
+ "carbon-monoxide": "lastChangedAt",
28331
+ vibration: "lastChangedAt",
28332
+ tamper: "lastChangedAt"
28333
+ };
28334
+ /** Cap names whose presence in a device's bindings qualify it as a source. */
28335
+ var SOURCE_CAPS = Object.keys(SOURCE_CAP_ACTIVE_FIELD);
28336
+ /** True when a cap is a recognised binary/switch source. */
28337
+ function isSourceCap(capName) {
28338
+ return Object.prototype.hasOwnProperty.call(SOURCE_CAP_ACTIVE_FIELD, capName);
28339
+ }
28340
+ /** Extract the "active" boolean a source cap's slice carries, or null when
28341
+ * the cap is unknown or the field is missing / non-boolean. */
28342
+ function sliceActiveValue(capName, slice) {
28343
+ const field = SOURCE_CAP_ACTIVE_FIELD[capName];
28344
+ if (field === void 0) return null;
28345
+ const raw = slice[field];
28346
+ return typeof raw === "boolean" ? raw : null;
28347
+ }
28348
+ /** Ms-epoch transition timestamp a source cap's slice carries, or null when
28349
+ * it is absent, non-numeric or the zero "never observed" sentinel. */
28350
+ function sliceChangedAt(capName, slice) {
28351
+ const field = SOURCE_CAP_CHANGED_AT_FIELD[capName];
28352
+ if (field === void 0) return null;
28353
+ const raw = slice[field];
28354
+ if (typeof raw !== "number" || !Number.isFinite(raw) || raw <= 0) return null;
28355
+ return raw;
28356
+ }
28357
+ /**
28358
+ * How recent a source's own transition timestamp must be for a FIRST
28359
+ * sighting that is already active to count as a genuine rise rather than a
28360
+ * hydration of long-standing state.
28361
+ */
28362
+ var DEFAULT_FIRST_SIGHTING_FRESHNESS_MS = 3e4;
28363
+ /**
28364
+ * IL fronte. Puro: nessun orologio proprio, nessuna memoria — il chiamante
28365
+ * porta `prior`, `nowMs` e il proprio `startedAtMs`.
28366
+ *
28367
+ * Il caso della PRIMA slice già attiva è trattato esplicitamente e vale come
28368
+ * fronte solo se il timestamp UPSTREAM della transizione è posteriore a
28369
+ * `startedAtMs` **e** entro `firstSightingFreshnessMs`. Entrambe le metà
28370
+ * servono: la sola freschezza scatterebbe su un'idratazione al boot di uno
28371
+ * stato flippato pochi secondi prima del riavvio, e il solo "dopo che abbiamo
28372
+ * iniziato" scatterebbe, su un processo di lunga vita, per una sorgente
28373
+ * adottata oggi il cui stato è cambiato ieri. Il caso ambiguo ERRA VERSO IL
28374
+ * SILENZIO e lo dichiara (`baseline-seeded-stale-active`).
28375
+ */
28376
+ function evaluateSensorEdge(input) {
28377
+ const value = sliceActiveValue(input.capName, input.slice);
28378
+ if (value === null) return {
28379
+ edge: "none",
28380
+ value: null,
28381
+ reason: isSourceCap(input.capName) ? "non-boolean-value" : "unknown-cap"
28382
+ };
28383
+ if (input.prior === void 0) {
28384
+ if (!value) return {
28385
+ edge: "none",
28386
+ value,
28387
+ reason: "baseline-seeded-inactive"
28388
+ };
28389
+ const changedAt = sliceChangedAt(input.capName, input.slice);
28390
+ const floor = Math.max(input.startedAtMs, input.nowMs - input.firstSightingFreshnessMs);
28391
+ if (changedAt === null || changedAt < floor) return {
28392
+ edge: "none",
28393
+ value,
28394
+ reason: "baseline-seeded-stale-active"
28395
+ };
28396
+ return {
28397
+ edge: "rising",
28398
+ value: true
28399
+ };
28400
+ }
28401
+ if (input.prior === value) return {
28402
+ edge: "none",
28403
+ value,
28404
+ reason: "no-change"
28405
+ };
28406
+ if (!value) return {
28407
+ edge: "none",
28408
+ value,
28409
+ reason: "falling-edge"
28410
+ };
28411
+ return {
28412
+ edge: "rising",
28413
+ value: true
28414
+ };
28415
+ }
28416
+ /**
28417
+ * Doorbell button cap. Two kinds of providers coexist behind this cap
28418
+ * name (same pattern as `snapshot`):
28419
+ *
28420
+ * - **Native** providers: registered per-device by device-driver
28421
+ * addons via `ctx.registerNativeCap` — either on a
28422
+ * `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
28423
+ * or directly on the camera (Reolink registers at camera level).
28424
+ * Emits an `onPressed` event every time the firmware pushes a
28425
+ * ring; status tracks the last press and a pressCount since start
28426
+ * (diagnostic).
28427
+ *
28428
+ * - **Wrapper** provider: the `virtual-doorbell` system builtin
28429
+ * (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
28430
+ * device (contact / switch / event-emitter …) into a doorbell for
28431
+ * a camera. `defaultActive: false` — the operator explicitly binds
28432
+ * it per camera in the device-bindings UI, then picks the source
28433
+ * device + trigger in the per-device settings.
28434
+ *
28435
+ * The DeviceEventPropagator re-emits `onPressed` on the camera parent
28436
+ * — subscribers listening at the camera level receive ring events
28437
+ * with `via[]` populated. No code on the parent needed.
28438
+ */
28439
+ var DoorbellStatusSchema = object({
28440
+ /** Ms epoch of the last press. null = never observed since this provider started. */
28441
+ lastPressedAt: number().nullable(),
28442
+ /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
28443
+ pressCountSinceStart: number()
28444
+ });
28445
+ var DoorbellPressEventSchema = object({
28446
+ deviceId: number(),
28447
+ timestamp: number()
28448
+ });
28449
+ /**
28450
+ * The `doorbell-source` extension slot's editable value (D648): the camera's
28451
+ * virtual-doorbell trigger devices, exactly what the wrapper's
28452
+ * `doorbellSources` persists (as `{ deviceId }` records).
28453
+ */
28454
+ var DoorbellSourceSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
28455
+ /**
28456
+ * The `doorbell-source` slot — which devices ring this camera's VIRTUAL
28457
+ * doorbell, owned by the `virtual-doorbell` wrapper over its
28458
+ * `doorbellSources` store (D648). A source rings when one of its
28459
+ * `SOURCE_CAPS` rises. Whether the wrapper is bound to the camera at all is a
28460
+ * different authority (`deviceManager.setWrapperActive`, D62) — the slot
28461
+ * reports it, it never writes it.
28462
+ */
28463
+ var DOORBELL_SOURCE_SLOT = {
28464
+ id: "doorbell-source",
28465
+ label: "Doorbell trigger devices",
28466
+ description: "Any of these becoming active rings this camera's virtual doorbell: a binary sensor when it goes active, a switch when it turns on.",
28467
+ shape: "association",
28468
+ hostDeviceTypes: [DeviceType.Camera],
28469
+ sourceCaps: SOURCE_CAPS,
28470
+ cardinality: "many",
28471
+ value: DoorbellSourceSlotValueSchema
28472
+ };
28473
+ var doorbellCapability = {
28474
+ name: "doorbell",
28475
+ scope: "device",
28476
+ deviceNative: true,
28477
+ mode: "singleton",
28478
+ kind: "wrapper",
28479
+ defaultActive: false,
28480
+ deviceTypes: [DeviceType.Button, DeviceType.Camera],
28481
+ exposesDeviceSettings: true,
28482
+ extensionSlots: [DOORBELL_SOURCE_SLOT],
28483
+ methods: {},
28484
+ events: {
28485
+ /**
28486
+ * Fires once per physical press. Reolink delivers via Baichuan
28487
+ * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
28488
+ * release/duration — it's a pulse.
28489
+ */
28490
+ onPressed: { data: DoorbellPressEventSchema } },
28491
+ status: {
28492
+ schema: DoorbellStatusSchema,
28493
+ kind: "push"
28494
+ },
28495
+ /**
28496
+ * Runtime-state slice — last press timestamp + lifetime press count.
28497
+ * Mirrored by the kernel and readable via
28498
+ * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
28499
+ * without subscribing.
28500
+ */
28501
+ runtimeState: DoorbellStatusSchema,
28502
+ /**
28503
+ * Runtime-state durability: **restored** — a monotonic accumulator: the slice IS the record. `lastPressedAt` is content here, not a clock, so it is deliberately NOT volatile.
28504
+ *
28505
+ * See `RuntimeStateDurability`. Enforced by
28506
+ * `scripts/check-runtime-state-durability.ts`.
28507
+ */
28508
+ durability: "restored"
28509
+ };
28510
+ var ExtensionSlotIdSchema = _enum(["doorbell-source", "linked-devices"]);
28511
+ DeviceType.Camera, DeviceType.Camera;
28512
+ /** A slot's editable value, discriminated on `slot`. */
28513
+ var ExtensionSlotValueSchema = discriminatedUnion("slot", [DoorbellSourceSlotValueSchema.extend({ slot: literal("doorbell-source") }), LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
28514
+ DeviceType.Camera;
28515
+ var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
28516
+ state: literal("unreachable"),
28517
+ reason: string()
28518
+ })]);
28519
+ /** One provider of slots — the D554 source-listing row. */
28520
+ var ExtensionSourceSchema = object({
28521
+ /** The routing prefix of every `slotRef` this provider serves. */
28522
+ source: string(),
28523
+ label: string(),
28524
+ /** Stamped by the dispatcher from the registry (D557). */
28525
+ addonId: string().optional(),
28526
+ availability: ExtensionSourceAvailabilitySchema
28527
+ });
28528
+ /**
28529
+ * How one picked source stands. `missing` — no such device (deleted, or an id
28530
+ * that never existed); `foreign` — a device the slot's owner cannot read from
28531
+ * (slice 2's cross-owner graft source); `unavailable` — it exists but is not a
28532
+ * valid source now (a container, which is never a pick). A source in any of
28533
+ * these states is SHOWN, never silently dropped or re-pointed.
28534
+ */
28535
+ var ExtensionSourceHealthSchema = _enum([
28536
+ "ok",
28537
+ "missing",
28538
+ "foreign",
28539
+ "unavailable"
28540
+ ]);
28541
+ var ExtensionSlotSourceSchema = object({
28542
+ deviceId: number().int(),
28543
+ /** The device's name, or null when it could not be resolved (`missing`). */
28544
+ name: string().nullable(),
28545
+ health: ExtensionSourceHealthSchema,
28546
+ detail: string().optional()
28547
+ });
28548
+ /**
28549
+ * A DIFFERENT authority that gates whether the slot's sources do anything —
28550
+ * reported read-only, named, never written through this contract (D62). The
28551
+ * virtual doorbell's sources ring only while the wrapper is bound to the
28552
+ * camera, and that binding belongs to `deviceManager.setWrapperActive`.
28553
+ * `unknown` means the gate could not be read; it is not "inactive" (D315).
28554
+ */
28555
+ var ExtensionSlotActivationSchema = object({
28556
+ state: _enum([
28557
+ "active",
28558
+ "inactive",
28559
+ "unknown"
28560
+ ]),
28561
+ authority: string(),
28562
+ detail: string().optional()
28563
+ });
28564
+ var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
28565
+ state: literal("ok"),
28566
+ /** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
28567
+ slotRef: string(),
28568
+ slot: ExtensionSlotIdSchema,
28569
+ /** Names the store written (D62), e.g. `virtual-doorbell:doorbellSources`. */
28570
+ authority: string(),
28571
+ /** graft: its switch. association: null — removing every source is "off". */
28572
+ enabled: boolean().nullable(),
28573
+ /** graft: the cap registered on the host. association: null. */
28574
+ projects: string().nullable(),
28575
+ activation: ExtensionSlotActivationSchema.nullable(),
28576
+ value: ExtensionSlotValueSchema,
28577
+ sources: array(ExtensionSlotSourceSchema)
28578
+ }), object({
28579
+ state: literal("unreachable"),
28580
+ addonId: string(),
28581
+ reason: string()
28582
+ })]);
28583
+ var ExtensionCandidatesSchema = object({ candidates: array(object({
28584
+ deviceId: number().int(),
28585
+ name: string(),
28586
+ type: string(),
28587
+ location: string().nullable(),
28588
+ /** The container a child belongs to — "Spotlight 2" alone does not say which. */
28589
+ parentName: string().nullable(),
28590
+ /** Pre-marked by the owner's suggestion rule. NEVER saved on its own (D356). */
28591
+ suggested: boolean(),
28592
+ /** Why it is suggested ("same location"), null when it is not. */
28593
+ reason: string().nullable()
28594
+ })) });
28595
+ /**
28596
+ * What a write did. `none` — applied in place. `host` / `parent` — the owner
28597
+ * reloaded the host (or, for an accessory child, its parent) because the
28598
+ * write changed what the host REGISTERS (a graft switched on or off, slice 2).
28599
+ */
28600
+ var ExtensionSetResultSchema = object({
28601
+ applied: literal(true),
28602
+ reload: _enum([
28603
+ "none",
28604
+ "host",
28605
+ "parent"
28606
+ ])
28607
+ });
28608
+ var ExtensionSlotRefInputSchema = object({
28609
+ deviceId: number().int(),
28610
+ slotRef: string().min(1)
28611
+ });
28612
+ var ExtensionSetSlotInputSchema = ExtensionSlotRefInputSchema.extend({ value: ExtensionSlotValueSchema });
28613
+ method(object({ deviceId: number().int() }), array(ExtensionSourceSchema)), method(object({ deviceId: number().int() }), array(ExtensionSlotRowSchema)), method(ExtensionSlotRefInputSchema, ExtensionCandidatesSchema), method(ExtensionSetSlotInputSchema, ExtensionSetResultSchema, {
28614
+ kind: "mutation",
28615
+ auth: "admin"
28616
+ });
28617
+ /**
27734
28618
  * Optional client-side hints sent at session creation to help the provider
27735
28619
  * pick the best native source. All fields optional — a viewer that knows
27736
28620
  * nothing still gets a sane default. (Relocated from the retired `webrtc`
@@ -30180,75 +31064,6 @@ onStatusChanged: { data: object({
30180
31064
  volatileStateFields: ["lastChangedAt"]
30181
31065
  };
30182
31066
  /**
30183
- * Doorbell button cap. Two kinds of providers coexist behind this cap
30184
- * name (same pattern as `snapshot`):
30185
- *
30186
- * - **Native** providers: registered per-device by device-driver
30187
- * addons via `ctx.registerNativeCap` — either on a
30188
- * `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
30189
- * or directly on the camera (Reolink registers at camera level).
30190
- * Emits an `onPressed` event every time the firmware pushes a
30191
- * ring; status tracks the last press and a pressCount since start
30192
- * (diagnostic).
30193
- *
30194
- * - **Wrapper** provider: the `virtual-doorbell` system builtin
30195
- * (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
30196
- * device (contact / switch / event-emitter …) into a doorbell for
30197
- * a camera. `defaultActive: false` — the operator explicitly binds
30198
- * it per camera in the device-bindings UI, then picks the source
30199
- * device + trigger in the per-device settings.
30200
- *
30201
- * The DeviceEventPropagator re-emits `onPressed` on the camera parent
30202
- * — subscribers listening at the camera level receive ring events
30203
- * with `via[]` populated. No code on the parent needed.
30204
- */
30205
- var DoorbellStatusSchema = object({
30206
- /** Ms epoch of the last press. null = never observed since this provider started. */
30207
- lastPressedAt: number().nullable(),
30208
- /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
30209
- pressCountSinceStart: number()
30210
- });
30211
- var DoorbellPressEventSchema = object({
30212
- deviceId: number(),
30213
- timestamp: number()
30214
- });
30215
- var doorbellCapability = {
30216
- name: "doorbell",
30217
- scope: "device",
30218
- deviceNative: true,
30219
- mode: "singleton",
30220
- kind: "wrapper",
30221
- defaultActive: false,
30222
- deviceTypes: [DeviceType.Button, DeviceType.Camera],
30223
- exposesDeviceSettings: true,
30224
- methods: {},
30225
- events: {
30226
- /**
30227
- * Fires once per physical press. Reolink delivers via Baichuan
30228
- * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
30229
- * release/duration — it's a pulse.
30230
- */
30231
- onPressed: { data: DoorbellPressEventSchema } },
30232
- status: {
30233
- schema: DoorbellStatusSchema,
30234
- kind: "push"
30235
- },
30236
- /**
30237
- * Runtime-state slice — last press timestamp + lifetime press count.
30238
- * Mirrored by the kernel and readable via
30239
- * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
30240
- * without subscribing.
30241
- */
30242
- runtimeState: DoorbellStatusSchema,
30243
- /**
30244
- * Runtime-state durability: **restored** — a monotonic accumulator: the slice IS the record. `lastPressedAt` is content here, not a clock, so it is deliberately NOT volatile.
30245
- *
30246
- * See `RuntimeStateDurability`. Enforced by
30247
- * `scripts/check-runtime-state-durability.ts`.
30248
- */
30249
- durability: "restored"
30250
- };
30251
- /**
30252
31067
  * Enum-state sensor — a string value picked from a finite option set.
30253
31068
  * Drives HA `sensor` entries with `state_class: enum` (HVAC action
30254
31069
  * states, weather conditions, contact-source channels, mode strings).
@@ -34362,7 +35177,7 @@ var HardwareInfoSchema = object({
34362
35177
  coral: CoralInfoSchema.nullable().optional()
34363
35178
  });
34364
35179
  var PlatformScoreSchema = object({
34365
- runtime: _enum(["node", "python"]),
35180
+ runtime: literal("python"),
34366
35181
  backend: string(),
34367
35182
  format: _enum([
34368
35183
  "onnx",
@@ -34399,7 +35214,7 @@ var ModelRequirementSchema = object({
34399
35214
  });
34400
35215
  var ResolvedInferenceConfigSchema = object({
34401
35216
  modelId: string(),
34402
- runtime: _enum(["node", "python"]),
35217
+ runtime: literal("python"),
34403
35218
  backend: string(),
34404
35219
  format: ModelFormatSchema,
34405
35220
  reason: string()
@@ -36994,6 +37809,92 @@ var sceneMonitorCapability = {
36994
37809
  durability: "session"
36995
37810
  };
36996
37811
  /**
37812
+ * Per-stage gating mode applied to the zones a rule references.
37813
+ *
37814
+ * - `include`: the rule contributes to a **whitelist** for its stage.
37815
+ * When at least one `include` rule fires for a stage, only entities
37816
+ * inside one of those zones pass that stage.
37817
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
37818
+ * Entities inside one of those zones are dropped at that stage.
37819
+ *
37820
+ * `monitor`-style observation (count without filtering) is not a rule
37821
+ * mode — zones without any matching rule are observed naturally by
37822
+ * `zone-analytics` (live snapshot + history), so an "I just want to
37823
+ * count, not filter" use case needs no rule at all.
37824
+ */
37825
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
37826
+ /**
37827
+ * Per-consumer rule that references existing zones (geometry) and
37828
+ * defines how a specific pipeline stage should treat them. Each
37829
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
37830
+ * settings:
37831
+ *
37832
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
37833
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
37834
+ * - future: notification rules, audio gating, etc.
37835
+ *
37836
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
37837
+ * express "ignore motion in ALL of {garden, street}" with a single
37838
+ * rule. `classFilter` narrows the rule to specific object classes —
37839
+ * "drop person detections in the street, but keep cars" is one
37840
+ * `exclude` rule with `classFilter: ['person']`.
37841
+ *
37842
+ * `enabled` is a soft toggle — the operator can keep the rule
37843
+ * configured but inert without deleting it.
37844
+ */
37845
+ var ZoneRuleSchema = object({
37846
+ /** Stable rule id — survives edits, used by the UI for diffing. */
37847
+ id: string(),
37848
+ /** Optional human-readable label rendered in the rule editor. */
37849
+ name: string().optional(),
37850
+ /** Zones this rule targets. The rule's `mode` applies to ALL
37851
+ * listed zones (OR-set: a detection in any one of them counts).
37852
+ * At least one zone id required — a rule with no targets is a
37853
+ * configuration mistake and the form validator rejects it. */
37854
+ zoneIds: array(string()).min(1).readonly(),
37855
+ mode: ZoneRuleModeEnum,
37856
+ /**
37857
+ * Class names this rule applies to. Empty / undefined ⇒ rule
37858
+ * applies to every class. Class strings match the `macroClass`
37859
+ * field on detections (e.g. `person`, `car`, `dog`).
37860
+ */
37861
+ classFilter: array(string()).readonly().optional(),
37862
+ /**
37863
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
37864
+ * required to consider an entity "in the zone". Defaults to the
37865
+ * consumer's stage default when omitted. Kept for back-compat with
37866
+ * existing per-rule overrides; new operators pick the value via
37867
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
37868
+ * set, the lower-level engine reads it as a 0–1 fraction.
37869
+ */
37870
+ overlapThreshold: number().min(0).max(1).optional(),
37871
+ /**
37872
+ * Operator-friendly version of `overlapThreshold` — the percentage
37873
+ * of the detection's bbox that must lie inside the zone for the
37874
+ * rule to match. Documented default is 85%; the engine substitutes
37875
+ * that when the field is omitted (kept optional so existing rules
37876
+ * stored without it stay valid).
37877
+ *
37878
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
37879
+ * rule, the engine prefers `bboxInclusionPct` because it's the
37880
+ * field exposed in the UI. Internally both feed the same gate.
37881
+ */
37882
+ bboxInclusionPct: number().min(0).max(100).optional(),
37883
+ /**
37884
+ * When `true` and a detection has a segmentation mask, use the
37885
+ * mask for overlap instead of the bbox. Detection-stage only;
37886
+ * motion rules ignore this field.
37887
+ */
37888
+ preferMask: boolean().optional(),
37889
+ /**
37890
+ * Soft-toggle: `false` disables the rule without deleting it.
37891
+ * Defaults to `true` so operators creating a rule via the UI
37892
+ * see it active immediately.
37893
+ */
37894
+ enabled: boolean().default(true)
37895
+ });
37896
+ array(ZoneRuleSchema).readonly();
37897
+ /**
36997
37898
  * Script-runner cap. Models HA `script.*` entities on
36998
37899
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
36999
37900
  * that can be invoked imperatively — optionally with a variables
@@ -39050,146 +39951,6 @@ function readDeviceStateFrom(runtimeState) {
39050
39951
  }
39051
39952
  }
39052
39953
  /**
39053
- * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
39054
- * valutatore puro del suo FRONTE.
39055
- *
39056
- * Viveva dentro il builtin virtual-doorbell
39057
- * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
39058
- * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
39059
- * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
39060
- * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
39061
- * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
39062
- * SPOSTA qui e il doorbell la ri-esporta.
39063
- *
39064
- * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
39065
- * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
39066
- * regola" (e include `presence`, `cover`, `alarm-panel`), questa a "qual è il
39067
- * booleano il cui FRONTE conta". Vocabolari deliberatamente diversi.
39068
- */
39069
- /**
39070
- * Known binary / switch source caps → the boolean slice field whose
39071
- * false→true rise counts as ACTIVE. Every entry is "fire on active".
39072
- * Sensors whose "active" reading is not a plain boolean (presence's string
39073
- * state, connectivity's connected flag) are deliberately excluded — a
39074
- * reconnect is not a doorbell press, and it is not a recording either.
39075
- */
39076
- var SOURCE_CAP_ACTIVE_FIELD = {
39077
- contact: "entryOpen",
39078
- binary: "on",
39079
- switch: "on",
39080
- motion: "detected",
39081
- flood: "flooded",
39082
- gas: "detected",
39083
- smoke: "detected",
39084
- "carbon-monoxide": "detected",
39085
- vibration: "detected",
39086
- tamper: "tampered"
39087
- };
39088
- /**
39089
- * The same caps → the slice field carrying the ms-epoch timestamp of the
39090
- * last transition. Every source cap MUST appear here (guarded by a spec):
39091
- * without a transition timestamp the evaluator cannot tell a genuine rise
39092
- * from a boot-time hydration when the FIRST slice it ever sees is already
39093
- * active, and errs towards silence — swallowing the rise.
39094
- *
39095
- * These timestamps are UPSTREAM ones, not ingest ones: the Home Assistant
39096
- * provider derives them from `state.last_changed`, so they survive our own
39097
- * restarts and correctly read as "hours ago" for a state that has been
39098
- * active for hours. `motion` names its rise timestamp `lastDetectedAt`.
39099
- */
39100
- var SOURCE_CAP_CHANGED_AT_FIELD = {
39101
- contact: "lastChangedAt",
39102
- binary: "lastChangedAt",
39103
- switch: "lastChangedAt",
39104
- motion: "lastDetectedAt",
39105
- flood: "lastChangedAt",
39106
- gas: "lastChangedAt",
39107
- smoke: "lastChangedAt",
39108
- "carbon-monoxide": "lastChangedAt",
39109
- vibration: "lastChangedAt",
39110
- tamper: "lastChangedAt"
39111
- };
39112
- /** True when a cap is a recognised binary/switch source. */
39113
- function isSourceCap(capName) {
39114
- return Object.prototype.hasOwnProperty.call(SOURCE_CAP_ACTIVE_FIELD, capName);
39115
- }
39116
- /** Extract the "active" boolean a source cap's slice carries, or null when
39117
- * the cap is unknown or the field is missing / non-boolean. */
39118
- function sliceActiveValue(capName, slice) {
39119
- const field = SOURCE_CAP_ACTIVE_FIELD[capName];
39120
- if (field === void 0) return null;
39121
- const raw = slice[field];
39122
- return typeof raw === "boolean" ? raw : null;
39123
- }
39124
- /** Ms-epoch transition timestamp a source cap's slice carries, or null when
39125
- * it is absent, non-numeric or the zero "never observed" sentinel. */
39126
- function sliceChangedAt(capName, slice) {
39127
- const field = SOURCE_CAP_CHANGED_AT_FIELD[capName];
39128
- if (field === void 0) return null;
39129
- const raw = slice[field];
39130
- if (typeof raw !== "number" || !Number.isFinite(raw) || raw <= 0) return null;
39131
- return raw;
39132
- }
39133
- /**
39134
- * How recent a source's own transition timestamp must be for a FIRST
39135
- * sighting that is already active to count as a genuine rise rather than a
39136
- * hydration of long-standing state.
39137
- */
39138
- var DEFAULT_FIRST_SIGHTING_FRESHNESS_MS = 3e4;
39139
- /**
39140
- * IL fronte. Puro: nessun orologio proprio, nessuna memoria — il chiamante
39141
- * porta `prior`, `nowMs` e il proprio `startedAtMs`.
39142
- *
39143
- * Il caso della PRIMA slice già attiva è trattato esplicitamente e vale come
39144
- * fronte solo se il timestamp UPSTREAM della transizione è posteriore a
39145
- * `startedAtMs` **e** entro `firstSightingFreshnessMs`. Entrambe le metà
39146
- * servono: la sola freschezza scatterebbe su un'idratazione al boot di uno
39147
- * stato flippato pochi secondi prima del riavvio, e il solo "dopo che abbiamo
39148
- * iniziato" scatterebbe, su un processo di lunga vita, per una sorgente
39149
- * adottata oggi il cui stato è cambiato ieri. Il caso ambiguo ERRA VERSO IL
39150
- * SILENZIO e lo dichiara (`baseline-seeded-stale-active`).
39151
- */
39152
- function evaluateSensorEdge(input) {
39153
- const value = sliceActiveValue(input.capName, input.slice);
39154
- if (value === null) return {
39155
- edge: "none",
39156
- value: null,
39157
- reason: isSourceCap(input.capName) ? "non-boolean-value" : "unknown-cap"
39158
- };
39159
- if (input.prior === void 0) {
39160
- if (!value) return {
39161
- edge: "none",
39162
- value,
39163
- reason: "baseline-seeded-inactive"
39164
- };
39165
- const changedAt = sliceChangedAt(input.capName, input.slice);
39166
- const floor = Math.max(input.startedAtMs, input.nowMs - input.firstSightingFreshnessMs);
39167
- if (changedAt === null || changedAt < floor) return {
39168
- edge: "none",
39169
- value,
39170
- reason: "baseline-seeded-stale-active"
39171
- };
39172
- return {
39173
- edge: "rising",
39174
- value: true
39175
- };
39176
- }
39177
- if (input.prior === value) return {
39178
- edge: "none",
39179
- value,
39180
- reason: "no-change"
39181
- };
39182
- if (!value) return {
39183
- edge: "none",
39184
- value,
39185
- reason: "falling-edge"
39186
- };
39187
- return {
39188
- edge: "rising",
39189
- value: true
39190
- };
39191
- }
39192
- /**
39193
39954
  * Accessory device helpers — shared across drivers.
39194
39955
  *
39195
39956
  * Many vendor-specific drivers register accessory child devices on
@@ -43029,6 +43790,30 @@ Object.freeze({
43029
43790
  addonId: null,
43030
43791
  access: "create"
43031
43792
  },
43793
+ "deviceExtension.listCandidates": {
43794
+ capName: "device-extension",
43795
+ capScope: "device",
43796
+ addonId: null,
43797
+ access: "view"
43798
+ },
43799
+ "deviceExtension.listSlots": {
43800
+ capName: "device-extension",
43801
+ capScope: "device",
43802
+ addonId: null,
43803
+ access: "view"
43804
+ },
43805
+ "deviceExtension.listSources": {
43806
+ capName: "device-extension",
43807
+ capScope: "device",
43808
+ addonId: null,
43809
+ access: "view"
43810
+ },
43811
+ "deviceExtension.setSlot": {
43812
+ capName: "device-extension",
43813
+ capScope: "device",
43814
+ addonId: null,
43815
+ access: "create"
43816
+ },
43032
43817
  "deviceManager.addLocation": {
43033
43818
  capName: "device-manager",
43034
43819
  capScope: "system",
@@ -43779,6 +44564,12 @@ Object.freeze({
43779
44564
  addonId: null,
43780
44565
  access: "view"
43781
44566
  },
44567
+ "embeddingEncoder.resetFailedModels": {
44568
+ capName: "embedding-encoder",
44569
+ capScope: "system",
44570
+ addonId: null,
44571
+ access: "delete"
44572
+ },
43782
44573
  "enumSensor.getStatus": {
43783
44574
  capName: "enum-sensor",
43784
44575
  capScope: "device",
@@ -45165,6 +45956,12 @@ Object.freeze({
45165
45956
  addonId: null,
45166
45957
  access: "view"
45167
45958
  },
45959
+ "notificationRules.previewStateSummary": {
45960
+ capName: "notification-rules",
45961
+ capScope: "system",
45962
+ addonId: null,
45963
+ access: "view"
45964
+ },
45168
45965
  "notificationRules.previewTemplate": {
45169
45966
  capName: "notification-rules",
45170
45967
  capScope: "system",
@@ -45741,12 +46538,6 @@ Object.freeze({
45741
46538
  addonId: null,
45742
46539
  access: "create"
45743
46540
  },
45744
- "pipelineAnalytics.runReplayFrameProcessor": {
45745
- capName: "pipeline-analytics",
45746
- capScope: "device",
45747
- addonId: null,
45748
- access: "create"
45749
- },
45750
46541
  "pipelineAnalytics.saveRetrainAnnotations": {
45751
46542
  capName: "pipeline-analytics",
45752
46543
  capScope: "device",
@@ -46113,6 +46904,12 @@ Object.freeze({
46113
46904
  addonId: null,
46114
46905
  access: "view"
46115
46906
  },
46907
+ "pipelineOrchestrator.getClusterModelChoice": {
46908
+ capName: "pipeline-orchestrator",
46909
+ capScope: "system",
46910
+ addonId: null,
46911
+ access: "view"
46912
+ },
46116
46913
  "pipelineOrchestrator.getDeviceLiveContribution": {
46117
46914
  capName: "pipeline-orchestrator",
46118
46915
  capScope: "system",
@@ -48938,6 +49735,26 @@ Object.freeze({
48938
49735
  form: "single",
48939
49736
  optional: false
48940
49737
  }],
49738
+ "deviceExtension.listCandidates": [{
49739
+ name: "deviceId",
49740
+ form: "single",
49741
+ optional: false
49742
+ }],
49743
+ "deviceExtension.listSlots": [{
49744
+ name: "deviceId",
49745
+ form: "single",
49746
+ optional: false
49747
+ }],
49748
+ "deviceExtension.listSources": [{
49749
+ name: "deviceId",
49750
+ form: "single",
49751
+ optional: false
49752
+ }],
49753
+ "deviceExtension.setSlot": [{
49754
+ name: "deviceId",
49755
+ form: "single",
49756
+ optional: false
49757
+ }],
48941
49758
  "deviceManager.adoptionRelease": [{
48942
49759
  name: "camDeviceId",
48943
49760
  form: "single",
@@ -49844,11 +50661,6 @@ Object.freeze({
49844
50661
  form: "single",
49845
50662
  optional: false
49846
50663
  }],
49847
- "pipelineAnalytics.runReplayFrameProcessor": [{
49848
- name: "deviceId",
49849
- form: "single",
49850
- optional: false
49851
- }],
49852
50664
  "pipelineAnalytics.saveRetrainAnnotations": [{
49853
50665
  name: "deviceId",
49854
50666
  form: "single",
@@ -50886,7 +51698,8 @@ var NC_SYSTEM_EVENT_FAMILY = {
50886
51698
  "camera-disabled": null,
50887
51699
  "camera-enabled": null
50888
51700
  };
50889
- new Map(Object.entries(NC_SYSTEM_EVENT_FAMILY));
51701
+ /** Read by NAME, for kinds that arrive as plain strings (a newer hub, the viewer's mirror). */
51702
+ var FAMILY_BY_NAME = new Map(Object.entries(NC_SYSTEM_EVENT_FAMILY));
50890
51703
  var NC_SYSTEM_EVENT_CONDITION_FILTER_KEYS = [...NC_SYSTEM_EVENT_FILTER_KEYS, "excludeDeviceIds"];
50891
51704
  /**
50892
51705
  * The filters a family may carry. The base filters are the union of
@@ -50997,6 +51810,24 @@ function systemEventKindsOfFamily(family) {
50997
51810
  return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
50998
51811
  }
50999
51812
  /**
51813
+ * One family, or `mixed`. Mixed covers kinds that span families, a legacy kind,
51814
+ * a kind this build does not know (it fails toward read-only and never toward
51815
+ * editable), and an empty selection (nothing to decide on).
51816
+ */
51817
+ function systemEventFamilyOf(kindNames) {
51818
+ const families = /* @__PURE__ */ new Set();
51819
+ for (const name of kindNames) {
51820
+ const family = FAMILY_BY_NAME.get(name);
51821
+ if (family === void 0 || family === null) return { kind: "mixed" };
51822
+ families.add(family);
51823
+ }
51824
+ const [only] = [...families];
51825
+ return families.size === 1 && only !== void 0 ? {
51826
+ kind: "family",
51827
+ family: only
51828
+ } : { kind: "mixed" };
51829
+ }
51830
+ /**
51000
51831
  * Why the hub refuses this condition on a new or updated rule. Empty = accepted.
51001
51832
  * Families are reported in `NC_SYSTEM_EVENT_FAMILIES` order, and filters in
51002
51833
  * `NC_SYSTEM_EVENT_CONDITION_FILTER_KEYS` order, so a refusal reads the same
@@ -51072,18 +51903,38 @@ var WEEKDAY_TO_DAY = {
51072
51903
  Fri: 5,
51073
51904
  Sat: 6
51074
51905
  };
51075
- /** Resolve (weekday, minute-of-day) of `atMs` in the schedule's timezone.
51076
- * An invalid/unknown IANA name falls back to the host timezone. */
51077
- function localDayMinute(atMs, timezone) {
51078
- const d = new Date(atMs);
51079
- if (timezone !== void 0) try {
51080
- const parts = new Intl.DateTimeFormat("en-US", {
51906
+ /**
51907
+ * One formatter per timezone, built once (D647 review I4). Constructing an
51908
+ * `Intl.DateTimeFormat` is the expensive part of this function, and a caller
51909
+ * that asks about many instants — a window scan — used to build one per
51910
+ * instant. `null` = an invalid IANA name (the host timezone is used).
51911
+ */
51912
+ var FORMATTERS = /* @__PURE__ */ new Map();
51913
+ function formatterFor(timezone) {
51914
+ const held = FORMATTERS.get(timezone);
51915
+ if (held !== void 0) return held;
51916
+ let made;
51917
+ try {
51918
+ made = new Intl.DateTimeFormat("en-US", {
51081
51919
  timeZone: timezone,
51082
51920
  weekday: "short",
51083
51921
  hour: "numeric",
51084
51922
  minute: "numeric",
51085
51923
  hourCycle: "h23"
51086
- }).formatToParts(d);
51924
+ });
51925
+ } catch {
51926
+ made = null;
51927
+ }
51928
+ FORMATTERS.set(timezone, made);
51929
+ return made;
51930
+ }
51931
+ /** Resolve (weekday, minute-of-day) of `atMs` in the schedule's timezone.
51932
+ * An invalid/unknown IANA name falls back to the host timezone. */
51933
+ function localDayMinute(atMs, timezone) {
51934
+ const d = new Date(atMs);
51935
+ const formatter = timezone !== void 0 ? formatterFor(timezone) : null;
51936
+ if (formatter !== null) try {
51937
+ const parts = formatter.formatToParts(d);
51087
51938
  let weekday;
51088
51939
  let hour;
51089
51940
  let minute;
@@ -51223,6 +52074,119 @@ var DEVICE_EVENTS = [
51223
52074
  "detection-blind",
51224
52075
  ...ALARM
51225
52076
  ];
52077
+ /** Every kind a summary may speak about — the two summarisable families. */
52078
+ var SUMMARISABLE = [...systemEventKindsOfFamily("device-events"), ...systemEventKindsOfFamily("system")];
52079
+ /** One per summary SECTION (`NC_STATE_SUMMARY_SECTIONS` in the notification
52080
+ * centre): the section's lines, offered when one of its kinds is selected. */
52081
+ var STATE_SUMMARY_SECTION_VARS = [
52082
+ {
52083
+ name: "summaryDevices",
52084
+ label: "Summary: devices offline / switched off",
52085
+ example: "Garage — offline since 07:12",
52086
+ kinds: [
52087
+ "device-offline",
52088
+ "device-online",
52089
+ "device-disabled",
52090
+ "device-enabled"
52091
+ ]
52092
+ },
52093
+ {
52094
+ name: "summaryStreams",
52095
+ label: "Summary: streams offline",
52096
+ example: "Ingresso (high) — since 06:40",
52097
+ kinds: ["stream-offline", "stream-online"]
52098
+ },
52099
+ {
52100
+ name: "summaryBattery",
52101
+ label: "Summary: low batteries",
52102
+ example: "Sensore porta — 8 %",
52103
+ kinds: BATTERY
52104
+ },
52105
+ {
52106
+ name: "summaryConsumables",
52107
+ label: "Summary: consumables",
52108
+ example: "Robot — filter 10 %",
52109
+ kinds: CONSUMABLE
52110
+ },
52111
+ {
52112
+ name: "summaryTanks",
52113
+ label: "Summary: tanks",
52114
+ example: "Robot — clean water low",
52115
+ kinds: TANK
52116
+ },
52117
+ {
52118
+ name: "summaryDetection",
52119
+ label: "Summary: cameras detecting nothing",
52120
+ example: "Ingresso — since 05:10",
52121
+ kinds: ["detection-blind"]
52122
+ },
52123
+ {
52124
+ name: "summaryNodes",
52125
+ label: "Summary: nodes",
52126
+ example: "little-unraid — offline since 03:00",
52127
+ kinds: [
52128
+ "node-offline",
52129
+ "node-online",
52130
+ "node-inference-unavailable"
52131
+ ]
52132
+ },
52133
+ {
52134
+ name: "summaryAddons",
52135
+ label: "Summary: addons",
52136
+ example: "@camstack/addon-recorder 1.2.3 → 1.2.4",
52137
+ kinds: [
52138
+ "addon-crash-loop",
52139
+ "addon-update-available",
52140
+ "addon-updated"
52141
+ ]
52142
+ },
52143
+ {
52144
+ name: "summaryUpdates",
52145
+ label: "Summary: server & container updates",
52146
+ example: "server 1.2.377 → 1.2.378",
52147
+ kinds: [
52148
+ "server-update-available",
52149
+ "server-updated",
52150
+ "wrapper-update-available"
52151
+ ]
52152
+ }
52153
+ ];
52154
+ var STATE_SUMMARY_VARS = [
52155
+ {
52156
+ name: "summaryText",
52157
+ label: "Summary: every section",
52158
+ description: "One block per section with something to report, one line per item.",
52159
+ example: "Batterie scariche: Sensore porta — 8 %",
52160
+ group: "system",
52161
+ families: ["rule"],
52162
+ fields: [...RULE_TEXT],
52163
+ kinds: ["system"],
52164
+ systemEventKinds: [...SUMMARISABLE],
52165
+ systemEventDeliveries: ["summary"]
52166
+ },
52167
+ {
52168
+ name: "summaryCount",
52169
+ label: "Summary: items reported",
52170
+ example: "3",
52171
+ group: "system",
52172
+ families: ["rule"],
52173
+ fields: [...RULE_TEXT],
52174
+ kinds: ["system"],
52175
+ systemEventKinds: [...SUMMARISABLE],
52176
+ systemEventDeliveries: ["summary"]
52177
+ },
52178
+ ...STATE_SUMMARY_SECTION_VARS.map((v) => ({
52179
+ name: v.name,
52180
+ label: v.label,
52181
+ example: v.example,
52182
+ group: "system",
52183
+ families: ["rule"],
52184
+ fields: [...RULE_TEXT],
52185
+ kinds: ["system"],
52186
+ systemEventKinds: [...v.kinds],
52187
+ systemEventDeliveries: ["summary"]
52188
+ }))
52189
+ ];
51226
52190
  var NC_TEMPLATE_VARS = [
51227
52191
  {
51228
52192
  name: "camera",
@@ -51473,7 +52437,8 @@ var NC_TEMPLATE_VARS = [
51473
52437
  group: "system",
51474
52438
  families: ["rule"],
51475
52439
  fields: [...RULE_TEXT],
51476
- kinds: ["system"]
52440
+ kinds: ["system"],
52441
+ systemEventDeliveries: ["instant"]
51477
52442
  },
51478
52443
  {
51479
52444
  name: "deviceName",
@@ -51916,7 +52881,8 @@ var NC_TEMPLATE_VARS = [
51916
52881
  group: "digest",
51917
52882
  families: ["summary"],
51918
52883
  fields: [...RULE_TEXT]
51919
- }
52884
+ },
52885
+ ...STATE_SUMMARY_VARS
51920
52886
  ];
51921
52887
  /**
51922
52888
  * System-event kinds the SERVED catalog holds back (D642): the kinds the hub
@@ -51945,11 +52911,32 @@ var NC_TEMPLATE_HELD_BACK_SYSTEM_EVENT_KINDS = [
51945
52911
  * rule an installed viewer can author, which is exactly true.
51946
52912
  */
51947
52913
  function servedTemplateVars() {
51948
- return NC_TEMPLATE_VARS.map((d) => d.systemEventKinds === void 0 ? d : {
52914
+ return NC_TEMPLATE_VARS.filter((d) => !isHeldBackTemplateVar(d)).map((d) => d.systemEventKinds === void 0 ? d : {
51949
52915
  ...d,
51950
52916
  systemEventKinds: d.systemEventKinds.filter((kind) => !NC_TEMPLATE_HELD_BACK_SYSTEM_EVENT_KINDS.includes(kind))
51951
52917
  });
51952
52918
  }
52919
+ /**
52920
+ * Is this descriptor held back from the SERVED catalog as a whole (D647)?
52921
+ * A summary-only variable is: an installed viewer does not read the delivery
52922
+ * axis, and would offer it on every instant system rule. The admin, built
52923
+ * from the workspace, restores it from its own `NC_TEMPLATE_VARS`.
52924
+ */
52925
+ function isHeldBackTemplateVar(d) {
52926
+ return d.systemEventDeliveries !== void 0 && !d.systemEventDeliveries.includes("instant");
52927
+ }
52928
+ /**
52929
+ * Does a descriptor have a value on a system rule of this DELIVERY (D647)?
52930
+ * Read only for a system rule kind. An absent axis is `instant` for a
52931
+ * descriptor that names `systemEventKinds` (a per-event fact: a summary row
52932
+ * has no one device, node or package) and BOTH for one that does not
52933
+ * (`{{rule}}`, `{{time}}`).
52934
+ */
52935
+ function templateVarDeliveryApplies(d, ctx) {
52936
+ if (!isSystemRuleKind(ctx.kind)) return true;
52937
+ const mode = ctx.systemEventDelivery ?? "instant";
52938
+ return (d.systemEventDeliveries ?? (d.systemEventKinds !== void 0 ? ["instant"] : [mode])).includes(mode);
52939
+ }
51953
52940
  /** The caption fields see a fixed, smaller vocabulary (`timelapsePreviewText`,
51954
52941
  * `summaryCaptionText`). Declared here rather than as `fields` on every
51955
52942
  * descriptor so the whole rule stays in one line of code. */
@@ -52014,12 +53001,82 @@ function templateVarsFor(ctx) {
52014
53001
  const allowed = CAPTION_VARS[ctx.field];
52015
53002
  return NC_TEMPLATE_VARS.filter((d) => d.families.includes(ctx.family) && allowed.includes(d.name) && d.dynamic === void 0);
52016
53003
  }
52017
- return NC_TEMPLATE_VARS.filter((d) => d.families.includes(ctx.family) && onAxis(d.fields, ctx.field) && templateVarKindApplies(d.kinds, ctx.kind) && onAxis(d.deliveries, ctx.delivery) && templateVarSystemEventApplies(d, ctx));
53004
+ return NC_TEMPLATE_VARS.filter((d) => d.families.includes(ctx.family) && onAxis(d.fields, ctx.field) && templateVarKindApplies(d.kinds, ctx.kind) && onAxis(d.deliveries, ctx.delivery) && templateVarSystemEventApplies(d, ctx) && templateVarDeliveryApplies(d, ctx));
52018
53005
  }
52019
53006
  /** True when `name` is supplied in `ctx`, dynamic families (`count_<class>`) included. */
52020
53007
  function isKnownTemplateVar(name, ctx) {
52021
53008
  return templateVarsFor(ctx).some((d) => d.dynamic !== void 0 ? name.startsWith(d.dynamic.prefix) && name.length > d.dynamic.prefix.length : d.name === name);
52022
53009
  }
53010
+ /** The families a rule may summarise. The alarm is not one of them. */
53011
+ var NC_SYSTEM_EVENT_SUMMARY_FAMILIES = ["device-events", "system"];
53012
+ /** The summary's schedule, or `null` for any rule that is not a summary system rule. */
53013
+ function systemEventSummaryScheduleOf(rule) {
53014
+ if (!isSystemDelivery(rule.delivery)) return null;
53015
+ const delivery = rule.systemEventDelivery;
53016
+ return delivery?.mode === "summary" ? delivery.schedule : null;
53017
+ }
53018
+ /** Absent and `instant` are the same answer: a notification per event. */
53019
+ function isSystemEventSummaryRule(rule) {
53020
+ return systemEventSummaryScheduleOf(rule) !== null;
53021
+ }
53022
+ function actionsAreSet(actions) {
53023
+ return (actions?.onTrigger?.length ?? 0) > 0 || (actions?.buttons?.length ?? 0) > 0;
53024
+ }
53025
+ /**
53026
+ * Why the hub refuses this rule's delivery. Empty = accepted. An instant rule
53027
+ * (absent or `{ mode: 'instant' }`) is never refused here.
53028
+ *
53029
+ * Beside a summary, two fields are refused because they would do nothing:
53030
+ * the rule's own `schedule` (the summary's schedule is the send time; a second
53031
+ * active-hours gate would silently empty it) and `actions` (a summary is not a
53032
+ * match, so nothing would ever run them).
53033
+ */
53034
+ function systemEventDeliveryProblems(rule) {
53035
+ if (rule.systemEventDelivery?.mode !== "summary") return [];
53036
+ if (!isSystemDelivery(rule.delivery)) return [{
53037
+ code: "not-a-system-rule",
53038
+ delivery: rule.delivery
53039
+ }];
53040
+ const problems = [];
53041
+ const verdict = systemEventFamilyOf(rule.conditions.systemEvent?.kinds ?? []);
53042
+ const family = verdict.kind === "family" ? verdict.family : "mixed";
53043
+ if (family === "mixed" || !NC_SYSTEM_EVENT_SUMMARY_FAMILIES.includes(family)) problems.push({
53044
+ code: "family-not-summarisable",
53045
+ family
53046
+ });
53047
+ const windows = rule.systemEventDelivery.schedule.windows;
53048
+ if (windows.length === 0) problems.push({ code: "empty-schedule" });
53049
+ windows.forEach((window, index) => {
53050
+ if (window.days.length === 0 || window.startMinute === window.endMinute) problems.push({
53051
+ code: "degenerate-window",
53052
+ index
53053
+ });
53054
+ });
53055
+ if (rule.schedule !== void 0) problems.push({ code: "schedule-beside-summary" });
53056
+ if (actionsAreSet(rule.actions)) problems.push({ code: "actions-beside-summary" });
53057
+ return problems;
53058
+ }
53059
+ function describeSystemEventDeliveryProblem(problem) {
53060
+ switch (problem.code) {
53061
+ case "not-a-system-rule": return `a '${problem.delivery}' rule has no summary delivery — only device-events and system rules do`;
53062
+ case "family-not-summarisable": return problem.family === "alarm" ? "an alarm rule cannot be a scheduled summary — the alarm stays instant" : `a ${problem.family} rule cannot be a scheduled summary — only device-events and system rules`;
53063
+ case "degenerate-window": return `send time ${String(problem.index + 1)} has no day, or starts and ends on the same minute — it never closes, so nothing would be sent`;
53064
+ case "empty-schedule": return "a summary rule needs at least one send time — its schedule has no window";
53065
+ case "schedule-beside-summary": return "a summary rule is sent on its summary schedule — remove the active-hours schedule";
53066
+ case "actions-beside-summary": return "a summary rule never matches an event, so its actions would never run — remove them";
53067
+ }
53068
+ }
53069
+ var SUMMARY_CONTENT_VAR = /\{\{\s*summary(?:Text|Devices|Streams|Battery|Consumables|Tanks|Detection|Nodes|Addons|Updates)\s*\}\}/;
53070
+ /**
53071
+ * Does a custom BODY carry the summary's content (`{{summaryText}}` or a
53072
+ * section variable)? A body that does not would send a summary with nothing
53073
+ * in it; the hub then appends `{{summaryText}}` and the admin warns (review
53074
+ * M3). An absent or blank body uses the hub's own wording, which does.
53075
+ */
53076
+ function templateCarriesSummary(body) {
53077
+ if (body === void 0 || body.trim().length === 0) return true;
53078
+ return SUMMARY_CONTENT_VAR.test(body);
53079
+ }
52023
53080
  /**
52024
53081
  * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
52025
53082
  *
@@ -52320,169 +53377,6 @@ function readTimelapseGeneratedAt(rule, deviceId) {
52320
53377
  if (map !== void 0) return map[String(deviceId)] ?? 0;
52321
53378
  return rule.lastGeneratedAt ?? 0;
52322
53379
  }
52323
- /**
52324
- * A model choice has a SCOPE, and a scope change has a workflow.
52325
- *
52326
- * ## The two scopes
52327
- *
52328
- * Almost every pipeline step's model is a **node** question: which build runs
52329
- * fastest on THIS accelerator. Two nodes may legitimately answer differently —
52330
- * a Coral runs the tflite SSD, a Mac runs the coreml YOLO — because the answers
52331
- * are compared against nothing. They produce boxes, and a box is a box.
52332
- *
52333
- * Two steps are not like that. `face-embedding` and `clip-embedding` produce
52334
- * **vectors that land in ONE shared index** (`identity_samples`,
52335
- * `vec_object_clip`) and are ranked against each other by cosine similarity.
52336
- * Cosine similarity between two encoders is not a weak signal, it is a
52337
- * meaningless number — and nothing inside a vector can tell you it happened.
52338
- * So for those two steps the model is a **cluster** question with exactly one
52339
- * answer, stored in exactly one row.
52340
- *
52341
- * That is the same argument [D52](../../../../docs/decisions/adr-0052.md) makes
52342
- * for the crop convention (`detail-crop.ts`), one level up: the crop decides
52343
- * WHAT pixels the encoder sees, this decides WHICH encoder sees them. Both are
52344
- * cluster-wide for the same reason and neither may become per-node.
52345
- *
52346
- * ## Why the registry lives here and not in the step catalog
52347
- *
52348
- * The scope itself is declared on the step, in
52349
- * `detection-pipeline/registry/step-definitions.ts` (`StepDefinition.modelScope`)
52350
- * — that is where a new step declares what kind of choice its model is. But the
52351
- * catalog lives inside `addon-pipeline`, and three packages that must NOT
52352
- * import an addon need to know the set: the orchestrator (which renders and
52353
- * stores the row), post-analysis (which pins the row for a re-embed pass) and
52354
- * admin-ui (which mirrors it). So the set is mirrored here, and
52355
- * `scripts/check-cluster-model-scope.ts` fails the build when the two disagree.
52356
- * A hand-copied key that stops matching is exactly how a setting silently stops
52357
- * arriving while both sides still look correct.
52358
- *
52359
- * ## The defaults ARE today's behaviour
52360
- *
52361
- * {@link DEFAULT_CLUSTER_STEP_MODELS} reproduces the catalog `defaultModelId`
52362
- * of both steps. Declaring the scope therefore changes nothing on the day it
52363
- * ships: the cluster row starts out saying what every node was already doing.
52364
- * Changing it is legitimate — that is what the knob is for — but it invalidates
52365
- * the stored vectors of that surface, and must be followed by a re-embed pass
52366
- * (`face-reembed-pass.ts`, `embedding-rebuild.ts`).
52367
- */
52368
- /**
52369
- * The cluster-scoped steps. Mirrored from the catalog's `modelScope: 'cluster'`
52370
- * declarations and guarded by `scripts/check-cluster-model-scope.ts`.
52371
- */
52372
- var CLUSTER_MODEL_SCOPED_STEPS = [{
52373
- stepId: "face-embedding",
52374
- label: "Face recognition model",
52375
- defaultModelId: "arcface-r100",
52376
- indexName: "the enrolled face gallery",
52377
- options: [
52378
- {
52379
- id: "arcface-r100",
52380
- label: "ArcFace (ResNet34)"
52381
- },
52382
- {
52383
- id: "auraface-r100",
52384
- label: "AuraFace R100"
52385
- },
52386
- {
52387
- id: "inception-resnet-v1",
52388
- label: "Inception ResNet V1"
52389
- }
52390
- ]
52391
- }, {
52392
- stepId: "clip-embedding",
52393
- label: "Semantic search model",
52394
- defaultModelId: "mobileclip-s1",
52395
- indexName: "the object semantic-search index",
52396
- options: [{
52397
- id: "mobileclip-s1",
52398
- label: "MobileCLIP S1"
52399
- }, {
52400
- id: "mobileclip-s2",
52401
- label: "MobileCLIP S2"
52402
- }]
52403
- }];
52404
- /**
52405
- * The settings key holding one step's cluster model choice.
52406
- *
52407
- * Step-qualified so the keys stay unique across the addon's whole schema, which
52408
- * is what lets {@link pickClusterStepModels} walk every section instead of
52409
- * trusting the section id.
52410
- */
52411
- function clusterModelSettingKey(stepId) {
52412
- return `clusterModel:${stepId}`;
52413
- }
52414
- /** The cluster row when nobody has configured one — today's catalog defaults. */
52415
- var DEFAULT_CLUSTER_STEP_MODELS = Object.freeze(Object.fromEntries(CLUSTER_MODEL_SCOPED_STEPS.map((s) => [s.stepId, s.defaultModelId])));
52416
- /** A stored choice is a non-empty model id, or it is not a choice. */
52417
- var ChosenModelIdSchema = string().min(1);
52418
- /**
52419
- * Narrow a FLAT settings record to the cluster row.
52420
- *
52421
- * Per-FIELD fallback, deliberately (same rule as `readDetailCropConvention`): a
52422
- * junk face model must not also discard a valid clip model. An absent, empty or
52423
- * non-string value resolves to the step's catalog default — the historical
52424
- * behaviour — never to a blank id, because a blank id downstream becomes
52425
- * "substitute the format default", which is precisely the substitution this
52426
- * scope exists to forbid.
52427
- */
52428
- function readClusterStepModels(config) {
52429
- const out = {};
52430
- for (const step of CLUSTER_MODEL_SCOPED_STEPS) {
52431
- const parsed = ChosenModelIdSchema.safeParse(config[clusterModelSettingKey(step.stepId)]);
52432
- out[step.stepId] = parsed.success ? parsed.data : step.defaultModelId;
52433
- }
52434
- return out;
52435
- }
52436
- function isHydratedField$2(entry) {
52437
- return typeof entry === "object" && entry !== null && "key" in entry;
52438
- }
52439
- /**
52440
- * Extract the cluster row from an `addon-settings.getGlobalSettings` payload.
52441
- *
52442
- * Walks EVERY section rather than looking inside {@link CLUSTER_MODEL_SECTION_ID}
52443
- * alone: the keys are unique across the addon's schema, and a section rename
52444
- * must not silently revert the whole cluster to the defaults. A `null` payload
52445
- * (addon mid-boot) is the defaults.
52446
- */
52447
- function pickClusterStepModels(view) {
52448
- if (view === null) return DEFAULT_CLUSTER_STEP_MODELS;
52449
- const flat = {};
52450
- const wanted = new Set(CLUSTER_MODEL_SCOPED_STEPS.map((s) => clusterModelSettingKey(s.stepId)));
52451
- for (const section of view.sections) for (const entry of section.fields) {
52452
- if (!isHydratedField$2(entry) || typeof entry.key !== "string") continue;
52453
- if (wanted.has(entry.key)) flat[entry.key] = entry.value;
52454
- }
52455
- return readClusterStepModels(flat);
52456
- }
52457
- var CLUSTER_STEP_SETTING_FIELDS = [{
52458
- stepId: "face-embedding",
52459
- key: "minLandmarkFaceSize",
52460
- label: "Min face size for recognition (detection px)",
52461
- 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.",
52462
- type: "slider",
52463
- min: 0,
52464
- max: 64,
52465
- step: 2,
52466
- default: 24
52467
- }];
52468
- function clusterStepSettingKey(stepId, fieldKey) {
52469
- return `clusterStepSetting:${stepId}:${fieldKey}`;
52470
- }
52471
- var ClusterSettingNumberSchema = number().finite();
52472
- function readClusterStepSettings(config) {
52473
- const out = {};
52474
- for (const field of CLUSTER_STEP_SETTING_FIELDS) {
52475
- const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
52476
- const value = parsed.success ? parsed.data : field.default;
52477
- const existing = out[field.stepId] ?? {};
52478
- out[field.stepId] = {
52479
- ...existing,
52480
- [field.key]: value
52481
- };
52482
- }
52483
- return out;
52484
- }
52485
- readClusterStepSettings({});
52486
53380
  object({
52487
53381
  /**
52488
53382
  * Fraction of the box's own size added on EACH side before cutting.
@@ -53024,4 +53918,395 @@ function vectorDimFromBase64(encoded) {
53024
53918
  return Math.floor(Buffer.from(encoded, "base64").byteLength / 4);
53025
53919
  }
53026
53920
  //#endregion
53027
- export { NcTemplateVarDescriptorSchema as $, sensorRaisedOf as $t, NC_DEFAULT_SNOOZE_MINUTES as A, unknown as An, failureContributionCapability as At, NcRuleInputSchema as B, mayWriteToLocation as Bt, MAX_BIRTH_DECISION_RECORDS as C, discriminatedUnion as Cn, deriveRecordingMode as Ct, NC_ALARM_SYSTEM_EVENT_KINDS as D, partialRecord as Dn, evaluateSensorEdge as Dt, MediaFileKindEnum as E, object as En, encodeVectorBase64 as Et, NC_TEMPLATE_VARS as F, isMediaOwnerType as Ft, NcScheduleSchema as G, pipelineAnalyticsCapability as Gt, NcRuleSchema as H, occupancyScope as Ht, NcAlarmConfigSchema as I, isScheduleActive as It, NcSnoozeSuppressedSchema as J, readTimelapseGeneratedAt as Jt, NcSnoozeInputSchema as K, plateGalleryCapability as Kt, NcAlarmSettingsPatchSchema as L, isSourceCap as Lt, NC_SNOOZE_MAX_MINUTES as M, isDetectionMacroClass as Mt, NC_TANK_SYSTEM_EVENT_KINDS as N, isEventOwnerType as Nt, NC_CONDITION_CATALOG as O, record as On, evictionPolicyOfLocation as Ot, NC_TAXONOMY as P, isKnownTemplateVar as Pt, NcTemplatePreviewSchema as Q, sceneMonitorCapability as Qt, NcConditionDescriptorSchema as R, isSystemDelivery as Rt, MAX_ARCHIVED_DEBUG_NOTES as S, boolean as Sn, cosineSimilarity as St, MOTION_CLOSE_AFTER_MS as T, number as Tn, embeddingEncoderCapability as Tt, NcRuleTargetSchema as U, parseProcStatus as Ut, NcRulePatchSchema as V, notificationRulesCapability as Vt, NcRuleUpdateInputSchema as W, pickClusterStepModels as Wt, NcTaxonomySchema as X, resolvePoolMemoryPolicy as Xt, NcSystemEventKindSchema as Y, resolveLocationMode as Yt, NcTemplatePreviewInputSchema as Z, ruleBelongsToAlarm as Zt, FIRST_LEVEL_MACRO_CLASSES as _, isDeviceScopedCap as _n, assertTimelapseCadences as _t, BirthDecisionRecordSchema as a, templateVarsFor as an, SCENE_CONFIRM_DEFAULT_TIMEOUT_MS as at, LabelAttributionSchema as b, _enum as bn, buildEventKindDescriptor as bt, CoverStateSchema as c, errMsg as cn, SCENE_DIVERGED as ct, DEFAULT_TIMELAPSE_PREVIEW_TEXT as d, CamProfileSchema as dn, TimelapseRuleInputSchema as dt, servedTemplateVars as en, OpsLogEntrySchema as et, DETECTION_MACRO_CLASSES as f, DeviceType as fn, TimelapseRulePatchSchema as ft, EVENT_OWNER_TYPES as g, hydrateSchema as gn, alarmPanelCapability as gt, EVENT_KIND_BY_CAP as h, defineCustomActions as hn, addonWidgetsSourceCapability as ht, BaseDevice as i, systemEventFilterApplies as in, RetrainStatusSchema as it, NC_SENSOR_TRANSITION_KINDS as j, EventCategory as jn, hfModelUrl as jt, NC_CONSUMABLE_SYSTEM_EVENT_KINDS as k, string as kn, faceGalleryCapability as kt, DEFAULT_EVENT_COLOR as l, canonicalHash as ln, SceneMonitorSchema as lt, DeclaredDevices as m, customAction as mn, TrackSourceSchema as mt, AlarmArmModeSchema as n, subKindsOf as nn, RECORDING_EXPORT_MAX_READ_BYTES as nt, CLUSTER_MODEL_SCOPED_STEPS as o, vectorDimFromBase64 as on, SCENE_DEFAULT_ANCHOR_THRESHOLD as ot, DETECTION_PIPELINE_CAP_NAME as p, createEvent as pn, TimelapseRuleSchema as pt, NcSnoozeSchema as q, readDeviceStateFrom as qt, ArchivedDebugNoteSchema as r, systemEventFamilyProblems as rn, RECORDING_SOURCE_CAMSTACK_ADDON as rt, COCO_TO_MACRO as s, zoneAnalyticsCapability as sn, SCENE_DEFAULT_UNCOVERED_POLICY as st, AUDIO_MACRO_LABELS as t, storageOccupancyCapability as tn, PoolMemoryWatchdog as tt, DEFAULT_FIRST_SIGHTING_FRESHNESS_MS as u, BaseAddon as un, TIMELAPSE_DENSE_FLOOR_SEC as ut, FULL_IMAGE_BBOX as v, nodePin as vn, audioMetricsCapability as vt, MAX_BIRTH_LATENCY_PROXY_MS as w, literal as wn, describeSystemEventFamilyProblem as wt, LockStateSchema as x, array as xn, consumableLowPercentOf as xt, FailureCounters as y, sleep as yn, audioModeOf as yt, NcConditionsSchema as z, kebabToCamel as zt };
53921
+ //#region src/pipeline-analytics/cluster-model-pin.ts
53922
+ /**
53923
+ * Where a re-embed pass gets the model it pins.
53924
+ *
53925
+ * ## Why not `embeddingEncoder.getInfo`
53926
+ *
53927
+ * That is what the CLIP rebuild used, and it answers a subtly different
53928
+ * question: "which model is the encoder addon currently holding", not "which
53929
+ * model has the operator chosen for the cluster". The two agree until they do
53930
+ * not — an encoder mid-reload, a node that never picked up a change — and when
53931
+ * they disagree the pass writes a whole index in the wrong space with a status
53932
+ * line that looks fine. Since `face-embedding` and `clip-embedding` declare
53933
+ * `modelScope: 'cluster'`, there is now exactly one authority for each, and it
53934
+ * is a stored row rather than a live process's opinion.
53935
+ *
53936
+ * ## Why the read is not cached here
53937
+ *
53938
+ * A pass reads it ONCE, at the start, and pins that value for its whole run
53939
+ * (D54). A cache would only matter for a caller that re-read it mid-pass, which
53940
+ * is precisely the thing the pin exists to prevent — so there is nothing to
53941
+ * cache and the absence is deliberate.
53942
+ *
53943
+ * ## Why a failed read refuses instead of defaulting
53944
+ *
53945
+ * A pass that cannot name its model must not run. The previous CLIP path's
53946
+ * `?? 'unknown'` is the shipped version of the alternative: rows stamped with an
53947
+ * id nothing ran, in an index whose same-model gate then has nothing to reason
53948
+ * about.
53949
+ */
53950
+ /** The addon whose GLOBAL settings hold the cluster row. */
53951
+ var CLUSTER_MODEL_OWNER_ADDON_ID = "pipeline-orchestrator";
53952
+ /** The step ids this module can pin — the same two the catalog declares. */
53953
+ var FACE_EMBEDDING_STEP_ID = "face-embedding";
53954
+ var CLIP_EMBEDDING_STEP_ID = "clip-embedding";
53955
+ /**
53956
+ * The cluster row, or `null` when it could not be read.
53957
+ *
53958
+ * `null` and not "the defaults": a caller that cannot distinguish "the operator
53959
+ * chose arcface" from "I could not ask" will run a pass on a guess. The one
53960
+ * production caller turns `null` into a refusal to start.
53961
+ */
53962
+ async function readClusterModelRow(api, logger) {
53963
+ try {
53964
+ return pickClusterStepModels(await api.addonSettings.getGlobalSettings.query({ addonId: CLUSTER_MODEL_OWNER_ADDON_ID }));
53965
+ } catch (err) {
53966
+ logger.warn("cluster model row unreadable — a re-embed pass must not guess which encoder the operator chose", { meta: {
53967
+ owner: CLUSTER_MODEL_OWNER_ADDON_ID,
53968
+ error: err instanceof Error ? err.message : String(err)
53969
+ } });
53970
+ return null;
53971
+ }
53972
+ }
53973
+ /**
53974
+ * Pin one cluster-scoped step's model for a whole pass.
53975
+ *
53976
+ * Returns `null` on an unreadable row OR an unknown step id — both mean the
53977
+ * caller must not start, and folding them together is safe because the caller's
53978
+ * move is identical: refuse, loudly.
53979
+ */
53980
+ async function resolveClusterModelPin(api, stepId, logger) {
53981
+ if (!CLUSTER_MODEL_SCOPED_STEPS.some((s) => s.stepId === stepId)) {
53982
+ logger.warn("cluster model pin requested for a step that is not cluster-scoped", { meta: {
53983
+ stepId,
53984
+ clusterScoped: CLUSTER_MODEL_SCOPED_STEPS.map((s) => s.stepId)
53985
+ } });
53986
+ return null;
53987
+ }
53988
+ const row = await readClusterModelRow(api, logger);
53989
+ if (row === null) return null;
53990
+ const modelId = row[stepId];
53991
+ return modelId !== void 0 && modelId !== "" ? modelId : null;
53992
+ }
53993
+ /**
53994
+ * The error texts a cap call carries when the provider or the router has no
53995
+ * such method: the kernel's `Capability "…" has no method "…"`, tRPC's
53996
+ * `No procedure found on path`, and the forked-child hop's
53997
+ * `method '…' not found on provider '…'` (child-cap-dispatch.ts). NOT `is not a function`: that is any
53998
+ * `TypeError` thrown INSIDE the owner while it answers, and reading it as
53999
+ * "the owner predates the method" would file a bug in the owner under a
54000
+ * rolling-release reason nobody investigates.
54001
+ */
54002
+ var METHOD_UNAVAILABLE_FINGERPRINTS = [
54003
+ /has no method/i,
54004
+ /no procedure found/i,
54005
+ /method not found/i,
54006
+ /method '[^']*' not found on provider/i
54007
+ ];
54008
+ /**
54009
+ * The pin read for a pass that REWRITES an index (D651 fix rounds 1–3).
54010
+ *
54011
+ * Asks the OWNER. The orchestrator owns `clusterModel:*` and answers from a
54012
+ * three-way read of its own store, once its boot has settled
54013
+ * (`pipelineOrchestrator.getClusterModelChoice`). Never the hydrated view,
54014
+ * which answers `value ?? default`, and never the owner's private store
54015
+ * layout. Silent on purpose: the callers log state CHANGES.
54016
+ */
54017
+ async function readClusterModelPinStrict(api, stepId) {
54018
+ const method = api.pipelineOrchestrator?.getClusterModelChoice;
54019
+ if (method === void 0) return {
54020
+ kind: "unknown",
54021
+ reason: "method-unavailable"
54022
+ };
54023
+ let raw;
54024
+ try {
54025
+ raw = await method.query({ stepId });
54026
+ } catch (err) {
54027
+ const error = err instanceof Error ? err.message : String(err);
54028
+ return METHOD_UNAVAILABLE_FINGERPRINTS.some((re) => re.test(error)) ? {
54029
+ kind: "unknown",
54030
+ reason: "method-unavailable",
54031
+ error
54032
+ } : {
54033
+ kind: "unknown",
54034
+ reason: "read-failed",
54035
+ error
54036
+ };
54037
+ }
54038
+ if (raw === void 0) return {
54039
+ kind: "unknown",
54040
+ reason: "method-unavailable"
54041
+ };
54042
+ const parsed = ClusterModelChoiceSchema.safeParse(raw);
54043
+ if (!parsed.success) return {
54044
+ kind: "unknown",
54045
+ reason: "read-failed",
54046
+ error: "unparseable owner answer"
54047
+ };
54048
+ const choice = parsed.data;
54049
+ if (choice.kind === "stored") return {
54050
+ kind: "known",
54051
+ modelId: choice.modelId
54052
+ };
54053
+ if (choice.kind === "absent") return {
54054
+ kind: "not-stored",
54055
+ defaultModelId: choice.defaultModelId
54056
+ };
54057
+ return choice.error !== void 0 ? {
54058
+ kind: "unknown",
54059
+ reason: choice.reason,
54060
+ error: choice.error
54061
+ } : {
54062
+ kind: "unknown",
54063
+ reason: choice.reason
54064
+ };
54065
+ }
54066
+ //#endregion
54067
+ //#region src/embedding-encoder/catalogs/embedding-models.ts
54068
+ var HF_REPO = "camstack/camstack-models";
54069
+ var hf = (path) => hfModelUrl(HF_REPO, path);
54070
+ /**
54071
+ * The text tower's tokenizer, in HF `tokenizers` format, hosted next to every
54072
+ * text-encoder onnx (`.../onnx/tokenizer.json`) and fetched as a sibling file so
54073
+ * it lands beside the model. Each model folder hosts ITS OWN (MobileCLIP: the
54074
+ * CLIP BPE, vocab 49408; SigLIP2: Gemma SentencePiece, 256k, lower-casing).
54075
+ */
54076
+ var TOKENIZER_FILE = "tokenizer.json";
54077
+ /** SigLIP2's tokenizer — a DIFFERENT file name on purpose: see `ClipModelMeta.tokenizerFile`. */
54078
+ var SIGLIP2_TOKENIZER_FILE = "camstack-siglip2-b16-224-tokenizer.json";
54079
+ var ovFormat = (url, sizeMB) => {
54080
+ const base = url.split("/").pop() ?? "";
54081
+ const files = base.endsWith(".xml") ? [base.replace(/\.xml$/, ".bin")] : void 0;
54082
+ return {
54083
+ url,
54084
+ sizeMB,
54085
+ runtimes: ["python"],
54086
+ ...files ? { files } : {}
54087
+ };
54088
+ };
54089
+ /**
54090
+ * Files inside an .mlpackage directory bundle.
54091
+ * Must be fetched alongside the package root when isDirectory is true.
54092
+ */
54093
+ var MLPACKAGE_FILES = [
54094
+ "Manifest.json",
54095
+ "Data/com.apple.CoreML/model.mlmodel",
54096
+ "Data/com.apple.CoreML/weights/weight.bin"
54097
+ ];
54098
+ /**
54099
+ * The MobileCLIP feature-space contract (D649 — see `clip-model.ts` in
54100
+ * `@camstack/types`). S1 and S2 share the historical 512-d `object-clip` index,
54101
+ * separated by each row's `modelId`; the CLIP BPE window is 77 tokens padded
54102
+ * with 0; 0.2 is the floor the search always shipped with, measured to keep 96%
54103
+ * of matched COCO caption-image pairs on S1.
54104
+ */
54105
+ var mobileclipMeta = (textModelId) => ({
54106
+ textModelId,
54107
+ embeddingDim: 512,
54108
+ vectorIndex: "object-clip",
54109
+ tokenizerFile: TOKENIZER_FILE,
54110
+ contextLength: 77,
54111
+ padId: 0,
54112
+ searchMinScore: .2
54113
+ });
54114
+ /**
54115
+ * SigLIP2 B/16-224 (D649). 768-d, so its OWN index; a 64-token Gemma
54116
+ * SentencePiece window padded with 0 (the hosted `tokenizer.json` lower-cases,
54117
+ * see `scripts/build-siglip2-model.py`). The floor is SIGLIP2_SEARCH_MIN_SCORE.
54118
+ */
54119
+ var SIGLIP2_META = {
54120
+ textModelId: "siglip2-b16-224-text",
54121
+ embeddingDim: 768,
54122
+ vectorIndex: "object-clip-siglip2-b16-224",
54123
+ tokenizerFile: SIGLIP2_TOKENIZER_FILE,
54124
+ contextLength: 64,
54125
+ padId: 0,
54126
+ searchMinScore: .1
54127
+ };
54128
+ /**
54129
+ * NO onnx vision builds, deliberately (2026-08-21). The int8 ONNX vision
54130
+ * exports were measured misaligned with the text encoders (matched image↔text
54131
+ * cosine ≈ 0.01 vs ≈ 0.22 for the fp16 openvino/coreml builds) — see the
54132
+ * catalog note in `addon-pipeline/.../model-catalogs.ts`. The image-encode leg
54133
+ * that consumed them here (`embeddingEncoder.encode` → PythonRawTensorEngine)
54134
+ * is retired with them: its only caller discarded the vector, and its
54135
+ * `preprocessForClip` applied OpenAI mean/std that MobileCLIP never used.
54136
+ * S0 was retired the same day (measured worst of the family on fleet crops).
54137
+ */
54138
+ var CLIP_IMAGE_MODELS = [
54139
+ {
54140
+ id: "mobileclip-s1",
54141
+ name: "MobileCLIP S1",
54142
+ description: "Apple MobileCLIP S1 — balanced vision encoder, 512-dim, 256×256 (fp16 OpenVINO/CoreML)",
54143
+ inputSize: {
54144
+ width: 256,
54145
+ height: 256
54146
+ },
54147
+ labels: [],
54148
+ inputNormalization: "none",
54149
+ clip: mobileclipMeta("mobileclip-s1-text"),
54150
+ formats: {
54151
+ openvino: ovFormat(hf("clip/mobileclip-s1/openvino/camstack-mobileclip-s1-vision.xml"), 55),
54152
+ coreml: {
54153
+ url: hf("clip/mobileclip-s1/coreml/camstack-mobileclip-s1-vision.mlpackage"),
54154
+ sizeMB: 65,
54155
+ isDirectory: true,
54156
+ files: [...MLPACKAGE_FILES],
54157
+ runtimes: ["python"]
54158
+ }
54159
+ }
54160
+ },
54161
+ {
54162
+ id: "mobileclip-s2",
54163
+ name: "MobileCLIP S2",
54164
+ description: "Apple MobileCLIP S2 — high-accuracy vision encoder, 512-dim, 256×256 (fp16 OpenVINO/CoreML)",
54165
+ inputSize: {
54166
+ width: 256,
54167
+ height: 256
54168
+ },
54169
+ labels: [],
54170
+ inputNormalization: "none",
54171
+ clip: mobileclipMeta("mobileclip-s2-text"),
54172
+ formats: {
54173
+ openvino: ovFormat(hf("clip/mobileclip-s2/openvino/camstack-mobileclip-s2-vision.xml"), 90),
54174
+ coreml: {
54175
+ url: hf("clip/mobileclip-s2/coreml/camstack-mobileclip-s2-vision.mlpackage"),
54176
+ sizeMB: 110,
54177
+ isDirectory: true,
54178
+ files: [...MLPACKAGE_FILES],
54179
+ runtimes: ["python"]
54180
+ }
54181
+ }
54182
+ },
54183
+ {
54184
+ id: "siglip2-b16-224",
54185
+ name: "SigLIP2 B/16",
54186
+ description: "Google SigLIP2 base, patch 16, 224×224 — Apache-2.0 vision encoder, 768-dim (fp16 OpenVINO/CoreML)",
54187
+ inputSize: {
54188
+ width: 224,
54189
+ height: 224
54190
+ },
54191
+ labels: [],
54192
+ inputNormalization: "none",
54193
+ license: "Apache-2.0",
54194
+ clip: SIGLIP2_META,
54195
+ formats: {
54196
+ openvino: ovFormat(hf("clip/siglip2/openvino/camstack-siglip2-b16-224-vision.xml"), 186),
54197
+ coreml: {
54198
+ url: hf("clip/siglip2/coreml/camstack-siglip2-b16-224-vision.mlpackage"),
54199
+ sizeMB: 185,
54200
+ isDirectory: true,
54201
+ files: [...MLPACKAGE_FILES],
54202
+ runtimes: ["python"]
54203
+ }
54204
+ }
54205
+ }
54206
+ ];
54207
+ /**
54208
+ * The int8 TEXT onnx encoders are healthy — unlike the retired int8 vision
54209
+ * exports. Verified 2026-08-21: the live search path (fp16 openvino vision
54210
+ * vectors ⋅ int8 onnx text queries) ranks correctly on the real index, and the
54211
+ * local cross-check aligns them with the fp16 vision space (cos ≈ 0.22 on
54212
+ * matched pairs).
54213
+ */
54214
+ var CLIP_TEXT_MODELS = [
54215
+ {
54216
+ id: "mobileclip-s1-text",
54217
+ name: "MobileCLIP S1 Text Encoder",
54218
+ description: "Text encoder for MobileCLIP S1, 512-dim, int8 quantized (61 MB)",
54219
+ inputSize: {
54220
+ width: 0,
54221
+ height: 0
54222
+ },
54223
+ labels: [],
54224
+ formats: {
54225
+ onnx: {
54226
+ url: hf("clip/mobileclip-s1/onnx/camstack-mobileclip-s1-text.onnx"),
54227
+ sizeMB: 61,
54228
+ files: [TOKENIZER_FILE]
54229
+ },
54230
+ openvino: ovFormat(hf("clip/mobileclip-s1/openvino/camstack-mobileclip-s1-text.xml"), 121)
54231
+ }
54232
+ },
54233
+ {
54234
+ id: "mobileclip-s2-text",
54235
+ name: "MobileCLIP S2 Text Encoder",
54236
+ description: "Text encoder for MobileCLIP S2, 512-dim, int8 quantized (61 MB)",
54237
+ inputSize: {
54238
+ width: 0,
54239
+ height: 0
54240
+ },
54241
+ labels: [],
54242
+ formats: {
54243
+ onnx: {
54244
+ url: hf("clip/mobileclip-s2/onnx/camstack-mobileclip-s2-text.onnx"),
54245
+ sizeMB: 61,
54246
+ files: [TOKENIZER_FILE]
54247
+ },
54248
+ openvino: ovFormat(hf("clip/mobileclip-s2/openvino/camstack-mobileclip-s2-text.xml"), 121)
54249
+ }
54250
+ },
54251
+ {
54252
+ id: "siglip2-b16-224-text",
54253
+ name: "SigLIP2 B/16 Text Encoder",
54254
+ description: "Text encoder for SigLIP2 B/16, 768-dim, fp16 (565 MB)",
54255
+ inputSize: {
54256
+ width: 0,
54257
+ height: 0
54258
+ },
54259
+ labels: [],
54260
+ license: "Apache-2.0",
54261
+ formats: {
54262
+ onnx: {
54263
+ url: hf("clip/siglip2/onnx/camstack-siglip2-b16-224-text.onnx"),
54264
+ sizeMB: 565,
54265
+ files: [SIGLIP2_TOKENIZER_FILE]
54266
+ },
54267
+ openvino: ovFormat(hf("clip/siglip2/openvino/camstack-siglip2-b16-224-text.xml"), 565)
54268
+ }
54269
+ }
54270
+ ];
54271
+ //#endregion
54272
+ //#region src/shared/clip/clip-model-registry.ts
54273
+ /** The model in force when nobody has chosen — the cluster row's default. */
54274
+ var DEFAULT_CLIP_MODEL = "mobileclip-s1";
54275
+ /**
54276
+ * Build a registry from catalog entries. Throws when two models share an index
54277
+ * at different dimensions: that is a catalog defect, and the vector store would
54278
+ * refuse the second model's writes one at a time, forever, at runtime.
54279
+ */
54280
+ function buildClipModelRegistry(entries) {
54281
+ const models = /* @__PURE__ */ new Map();
54282
+ const spaces = /* @__PURE__ */ new Map();
54283
+ for (const entry of entries) {
54284
+ const meta = entry.clip;
54285
+ if (meta === void 0) continue;
54286
+ models.set(entry.id, {
54287
+ modelId: entry.id,
54288
+ inputSize: entry.inputSize.width,
54289
+ meta
54290
+ });
54291
+ const existing = spaces.get(meta.vectorIndex);
54292
+ if (existing !== void 0 && existing.dim !== meta.embeddingDim) throw new Error(`CLIP index "${meta.vectorIndex}" declared at ${String(existing.dim)} dims by ${existing.modelIds.join(", ")} and at ${String(meta.embeddingDim)} by ${entry.id}`);
54293
+ spaces.set(meta.vectorIndex, {
54294
+ index: meta.vectorIndex,
54295
+ dim: meta.embeddingDim,
54296
+ modelIds: [...existing?.modelIds ?? [], entry.id]
54297
+ });
54298
+ }
54299
+ const all = [...spaces.values()];
54300
+ return {
54301
+ resolve: (modelId) => models.get(modelId) ?? null,
54302
+ spaceFor: (modelId) => {
54303
+ const model = models.get(modelId);
54304
+ return model === void 0 ? null : spaces.get(model.meta.vectorIndex) ?? null;
54305
+ },
54306
+ spaces: () => all
54307
+ };
54308
+ }
54309
+ /** The built-in catalog's registry. */
54310
+ var BUILTIN_CLIP_MODELS = buildClipModelRegistry(CLIP_IMAGE_MODELS);
54311
+ //#endregion
54312
+ export { NcRuleSchema as $, EventCategory as $n, isSourceCap as $t, LabelAttributionSchema as A, canonicalHash as An, audioMetricsCapability as At, NC_DEFAULT_SNOOZE_MINUTES as B, normalizeNodeId as Bn, embeddingRefusalOf as Bt, EMBEDDING_REQUIREMENTS_FAILED as C, systemEventFilterApplies as Cn, TimelapseRuleInputSchema as Ct, FIRST_LEVEL_MACRO_CLASSES as D, vectorDimFromBase64 as Dn, addonWidgetsSourceCapability as Dt, EVENT_OWNER_TYPES as E, templateVarsFor as En, TrackSourceSchema as Et, MOTION_CLOSE_AFTER_MS as F, customAction as Fn, deriveRecordingMode as Ft, NC_TAXONOMY as G, discriminatedUnion as Gn, evictionPolicyOfLocation as Gt, NC_SNOOZE_MAX_MINUTES as H, _enum as Hn, embeddingRequirementsUnavailableError as Ht, MediaFileKindEnum as I, defineCustomActions as In, describeSystemEventDeliveryProblem as It, NcAlarmSettingsPatchSchema as J, object as Jn, isDetectionMacroClass as Jt, NC_TEMPLATE_VARS as K, literal as Kn, faceGalleryCapability as Kt, NC_ALARM_SYSTEM_EVENT_KINDS as L, hydrateSchema as Ln, describeSystemEventFamilyProblem as Lt, MAX_ARCHIVED_DEBUG_NOTES as M, CamProfileSchema as Mn, buildEventKindDescriptor as Mt, MAX_BIRTH_DECISION_RECORDS as N, DeviceType as Nn, consumableLowPercentOf as Nt, FULL_IMAGE_BBOX as O, zoneAnalyticsCapability as On, alarmPanelCapability as Ot, MAX_BIRTH_LATENCY_PROXY_MS as P, createEvent as Pn, cosineSimilarity as Pt, NcRulePatchSchema as Q, unknown as Qn, isScheduleActive as Qt, NC_CONDITION_CATALOG as R, isDeviceScopedCap as Rn, embeddingEncoderCapability as Rt, EMBEDDING_MODEL_FAILED as S, systemEventFamilyProblems as Sn, TIMELAPSE_DENSE_FLOOR_SEC as St, EVENT_KIND_BY_CAP as T, templateCarriesSummary as Tn, TimelapseRuleSchema as Tt, NC_SYSTEM_EVENT_KIND_GROUP_SPECS as U, array as Un, encodeVectorBase64 as Ut, NC_SENSOR_TRANSITION_KINDS as V, sleep as Vn, embeddingRequirementsFailedError as Vt, NC_TANK_SYSTEM_EVENT_KINDS as W, boolean as Wn, evaluateSensorEdge as Wt, NcConditionsSchema as X, record as Xn, isKnownTemplateVar as Xt, NcConditionDescriptorSchema as Y, partialRecord as Yn, isEventOwnerType as Yt, NcRuleInputSchema as Z, string as Zn, isMediaOwnerType as Zt, DEFAULT_FIRST_SIGHTING_FRESHNESS_MS as _, sensorRaisedOf as _n, SCENE_CONFIRM_DEFAULT_TIMEOUT_MS as _t, CLIP_EMBEDDING_STEP_ID as a, notificationRulesCapability as an, NcSnoozeSuppressedSchema as at, DETECTION_PIPELINE_CAP_NAME as b, subKindsOf as bn, SCENE_DIVERGED as bt, resolveClusterModelPin as c, pipelineAnalyticsCapability as cn, NcTemplatePreviewInputSchema as ct, ArchivedDebugNoteSchema as d, readTimelapseGeneratedAt as dn, OpsLogEntrySchema as dt, isSystemDelivery as en, NcRuleTargetSchema as et, BaseDevice as f, resolveClipSearchMinScore as fn, PoolMemoryWatchdog as ft, DEFAULT_EVENT_COLOR as g, sceneMonitorCapability as gn, RetrainStatusSchema as gt, CoverStateSchema as h, ruleBelongsToAlarm as hn, RebuildObjectEmbeddingsRefusalSchema as ht, CLIP_TEXT_MODELS as i, mayWriteToLocation as in, NcSnoozeSchema as it, LockStateSchema as j, BaseAddon as jn, audioModeOf as jt, FailureCounters as k, errMsg as kn, assertTimelapseCadences as kt, AUDIO_MACRO_LABELS as l, plateGalleryCapability as ln, NcTemplatePreviewSchema as lt, COCO_TO_MACRO as m, resolvePoolMemoryPolicy as mn, RECORDING_SOURCE_CAMSTACK_ADDON as mt, DEFAULT_CLIP_MODEL as n, isVectorIndexDimConflict as nn, NcScheduleSchema as nt, FACE_EMBEDDING_STEP_ID as o, occupancyScope as on, NcSystemEventKindSchema as ot, BirthDecisionRecordSchema as p, resolveLocationMode as pn, RECORDING_EXPORT_MAX_READ_BYTES as pt, NcAlarmConfigSchema as q, number as qn, failureContributionCapability as qt, CLIP_IMAGE_MODELS as r, kebabToCamel as rn, NcSnoozeInputSchema as rt, readClusterModelPinStrict as s, parseProcStatus as sn, NcTaxonomySchema as st, BUILTIN_CLIP_MODELS as t, isSystemEventSummaryRule as tn, NcRuleUpdateInputSchema as tt, AlarmArmModeSchema as u, readDeviceStateFrom as un, NcTemplateVarDescriptorSchema as ut, DEFAULT_TIMELAPSE_PREVIEW_TEXT as v, servedTemplateVars as vn, SCENE_DEFAULT_ANCHOR_THRESHOLD as vt, EMBEDDING_REQUIREMENTS_UNAVAILABLE as w, systemEventSummaryScheduleOf as wn, TimelapseRulePatchSchema as wt, DeclaredDevices as x, systemEventDeliveryProblems as xn, SceneMonitorSchema as xt, DETECTION_MACRO_CLASSES as y, storageOccupancyCapability as yn, SCENE_DEFAULT_UNCOVERED_POLICY as yt, NC_CONSUMABLE_SYSTEM_EVENT_KINDS as z, nodePin as zn, embeddingModelFailedError as zt };