@camstack/addon-pipeline 1.2.295 → 1.2.297

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 (40) hide show
  1. package/THIRD_PARTY_MODELS.md +8 -0
  2. package/dist/audio-analyzer/index.js +2 -2
  3. package/dist/audio-analyzer/index.mjs +2 -2
  4. package/dist/{default-detection-model-wNEISVA9.js → default-detection-model-B2n_SFXt.js} +442 -50
  5. package/dist/{default-detection-model-CAUBVbgK.mjs → default-detection-model-D6DypCkI.mjs} +413 -51
  6. package/dist/detection-pipeline/index.js +1516 -269
  7. package/dist/detection-pipeline/index.mjs +1515 -268
  8. package/dist/{dist-CuxSNLKW.mjs → dist-CxHIpsQs.mjs} +834 -398
  9. package/dist/{dist-BsVcf5wO.js → dist-DUqr1zyq.js} +845 -409
  10. package/dist/motion-wasm/index.js +1 -1
  11. package/dist/motion-wasm/index.mjs +1 -1
  12. package/dist/{node-UFk6I2f6.js → node-Dx6DLQ1j.js} +1 -1
  13. package/dist/{node-Cqb1QiXk.mjs → node-DyeWu78a.mjs} +1 -1
  14. package/dist/pipeline-runner/index.js +906 -310
  15. package/dist/pipeline-runner/index.mjs +906 -310
  16. package/dist/{process-memory-D0Nvs9rr.mjs → process-memory-BVR4592X.mjs} +1 -1
  17. package/dist/{process-memory-CJV29sPf.js → process-memory-CMJ3NY-s.js} +1 -1
  18. package/dist/recorder/index.js +4 -6
  19. package/dist/recorder/index.mjs +4 -6
  20. package/dist/{segment-demux-js-DGwmf5hu.js → segment-demux-js-CmGIF_uK.js} +1 -1
  21. package/dist/{segment-demux-js-DIDWw1iE.mjs → segment-demux-js-Dzga-XgE.mjs} +1 -1
  22. package/dist/session-decode/{decode-worker-child.js → decode-worker-main.js} +481 -72
  23. package/dist/session-decode/{decode-worker-child.mjs → decode-worker-main.mjs} +482 -71
  24. package/dist/stream-broker/_stub.js +2 -2
  25. package/dist/stream-broker/{_virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-B7nBFqva.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-P71ze8cu.mjs} +2 -2
  26. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-CZkpFU-J.mjs +26 -0
  27. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-Dti8Ex88.mjs +26 -0
  28. package/dist/stream-broker/demux-worker-child.js +1 -1
  29. package/dist/stream-broker/demux-worker-child.mjs +1 -1
  30. package/dist/stream-broker/{hostInit-BKlb3qac.mjs → hostInit-CRlStbz4.mjs} +2 -2
  31. package/dist/stream-broker/index.js +4 -4
  32. package/dist/stream-broker/index.mjs +4 -4
  33. package/dist/stream-broker/remoteEntry.js +1 -1
  34. package/dist/{worker-protocol-B2MfQLlu.js → worker-protocol-C-G8qmye.js} +3 -1
  35. package/dist/{worker-protocol-C_W-P_g-.mjs → worker-protocol-D_NzPcnh.mjs} +3 -1
  36. package/package.json +1 -1
  37. package/python/inference_pool.py +422 -64
  38. package/python/test_inference_pool_compile_off_loop.py +414 -0
  39. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-CCIyBvRa.mjs +0 -26
  40. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-DeD_UFdb.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-BaRu0bS5.mjs
5363
+ //#region ../types/dist/sleep-DC-wdyeS.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).
@@ -6193,6 +6193,40 @@ var BaseAddon = class {
6193
6193
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6194
6194
  return keys.size > 0 ? projectStore(raw, keys, node) : raw;
6195
6195
  }
6196
+ /**
6197
+ * Whether ONE global key of this addon's store was written, read three-way
6198
+ * (D651). For a question a hydrated view cannot answer: `getGlobalSettings`
6199
+ * reports `value ?? default`, so "the operator chose the default" and "nobody
6200
+ * chose" look the same, and a failed read looks like both. A `perNode` key is
6201
+ * not supported here: its stored name is scoped.
6202
+ */
6203
+ async readStoredGlobalKey(key) {
6204
+ const read = this._ctx?.settings?.readAddonStoreResult;
6205
+ if (read === void 0) return {
6206
+ kind: "unreadable",
6207
+ reason: "three-way-read-unavailable"
6208
+ };
6209
+ let result;
6210
+ try {
6211
+ result = await read.call(this._ctx?.settings);
6212
+ } catch (err) {
6213
+ return {
6214
+ kind: "unreadable",
6215
+ reason: "store-read-failed",
6216
+ error: err instanceof Error ? err.message : String(err)
6217
+ };
6218
+ }
6219
+ if (result.kind === "failed") return {
6220
+ kind: "unreadable",
6221
+ reason: "store-read-failed",
6222
+ error: result.error
6223
+ };
6224
+ if (result.kind === "missing" || !Object.prototype.hasOwnProperty.call(result.value, key)) return { kind: "absent" };
6225
+ return {
6226
+ kind: "present",
6227
+ value: result.value[key]
6228
+ };
6229
+ }
6196
6230
  async updateGlobalSettings(patch, nodeId) {
6197
6231
  const keys = this.perNodeKeys();
6198
6232
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
@@ -11299,6 +11333,43 @@ var FailureCounters = class {
11299
11333
  this.counters.clear();
11300
11334
  }
11301
11335
  };
11336
+ var ClipModelMetaSchema = object({
11337
+ /** The paired text encoder's catalog id (the embedding-encoder's text catalog). */
11338
+ textModelId: string().min(1),
11339
+ /** Output dimension of BOTH towers. A vector of any other length is refused. */
11340
+ embeddingDim: number().int().positive(),
11341
+ /**
11342
+ * The `vector-store` index this model's vectors live in. ONE feature space
11343
+ * per index: two models share an index only when their vectors are ranked
11344
+ * against each other, which for CLIP means never across families. MobileCLIP
11345
+ * S1 and S2 share `object-clip` for history (separated by the row's
11346
+ * `modelId`); any other model gets its own.
11347
+ */
11348
+ vectorIndex: string().regex(/^object-clip(-[a-z0-9][a-z0-9-]*)?$/),
11349
+ /**
11350
+ * The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
11351
+ * must be unique per tokenizer: every model's siblings land in ONE flat
11352
+ * models directory, so two different tokenizers under the same name would
11353
+ * silently overwrite each other (whichever model downloaded last wins, and
11354
+ * the other one tokenises with the wrong vocabulary).
11355
+ */
11356
+ tokenizerFile: string().min(1),
11357
+ /** Token window the text graph takes (SigLIP2: 64; CLIP BPE: 77). */
11358
+ contextLength: number().int().positive(),
11359
+ /** Id the tokenizer pads with. */
11360
+ padId: number().int().nonnegative(),
11361
+ /**
11362
+ * The search cosine floor at `strictness: 'loose'` — calibrated per model,
11363
+ * because cosine bands are a property of the model: 0.2 keeps 96% of matched
11364
+ * COCO caption-image pairs on MobileCLIP S1 and 2.7% on SigLIP2.
11365
+ */
11366
+ searchMinScore: number().min(0).max(1)
11367
+ });
11368
+ var ClipSearchStrictnessSchema = _enum([
11369
+ "loose",
11370
+ "balanced",
11371
+ "strict"
11372
+ ]);
11302
11373
  var MODEL_FORMATS = [
11303
11374
  "onnx",
11304
11375
  "coreml",
@@ -11515,7 +11586,14 @@ var ModelCatalogEntrySchema = object({
11515
11586
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
11516
11587
  * labels already ARE the CamStack macros (Scrypted identity map).
11517
11588
  */
11518
- classMap: DetectionCatalogClassMapSchema.optional()
11589
+ classMap: DetectionCatalogClassMapSchema.optional(),
11590
+ /**
11591
+ * The model's CLIP feature-space contract (text encoder, dimension, vector
11592
+ * index, token window, search floor) — see `clip-model.ts`. Present ONLY on a
11593
+ * CLIP image encoder; its absence is what "not a CLIP model" means to the
11594
+ * embedding encoder and the semantic-search store (D649).
11595
+ */
11596
+ clip: ClipModelMetaSchema.optional()
11519
11597
  });
11520
11598
  var ConvertTargetSchema = discriminatedUnion("format", [object({
11521
11599
  format: literal("openvino"),
@@ -16236,6 +16314,27 @@ var LinkedDeviceSchema = object({
16236
16314
  features: array(string()),
16237
16315
  producesTrackedEvents: boolean().optional()
16238
16316
  });
16317
+ /**
16318
+ * The `linked-devices` extension slot's editable value (D648): the operator's
16319
+ * pick list, exactly what `_linkedDeviceIds` persists. Tree children are NOT
16320
+ * in it — they are always linked and are not a pick.
16321
+ *
16322
+ * `trackedDeviceIds` (D655) is the tracked-event opt-in, exactly what
16323
+ * `_linkedDeviceTrackedIds` persists: which linked devices materialize a
16324
+ * synthetic tracked event on the camera. A read always carries it AS STORED
16325
+ * (an absent key reads as `[]`, which is what the resolver makes of it —
16326
+ * NONE). On a write it is optional: absent leaves the opt-in untouched, so a
16327
+ * card built before D655 cannot erase it by saving the pick list. A present
16328
+ * list REPLACES the opt-in; each id must be a pick, a device the camera links
16329
+ * by structure (the row's `impliedSources`: tree children, a picked
16330
+ * container's child) or already stored — so what was read can always be
16331
+ * written back unchanged, and a NEW opt-in outside the linked set is refused.
16332
+ */
16333
+ var LinkedDevicesSlotValueSchema = object({
16334
+ deviceIds: array(number().int().positive()),
16335
+ trackedDeviceIds: array(number().int().positive()).optional()
16336
+ });
16337
+ DeviceType.Camera;
16239
16338
  /** One camera's resolved linked set, tagged with the camera it belongs to.
16240
16339
  * The batch answer needs the tag; the single-device answer already has it
16241
16340
  * from the input, which is why `getLinkedDevices` keeps the untagged shape. */
@@ -16761,16 +16860,101 @@ var EmbeddingResultSchema = object({
16761
16860
  embedding: array(number()),
16762
16861
  inferenceMs: number()
16763
16862
  });
16863
+ /** The two CLIP towers the encoder runs; a crash budget is kept per tower. */
16864
+ var EmbeddingTowerSchema = _enum(["image", "text"]);
16865
+ /**
16866
+ * A tower in the terminal `failed` state (D649, D6): it crashed or failed to
16867
+ * load `crashes` times within `windowMs`, and is refused by name until an
16868
+ * operator `resetFailedModels` or a model change — never on a timer.
16869
+ *
16870
+ * `nodeId` is the node whose tower failed. The state lives in THAT node's
16871
+ * encoder process (in memory — a runner respawn clears it), and one node's
16872
+ * answer says nothing about another's.
16873
+ */
16874
+ var EmbeddingFailedModelSchema = object({
16875
+ modelId: string(),
16876
+ tower: EmbeddingTowerSchema,
16877
+ nodeId: string(),
16878
+ crashes: number(),
16879
+ windowMs: number(),
16880
+ sinceMs: number(),
16881
+ lastReason: string()
16882
+ });
16883
+ /**
16884
+ * A model whose REQUIREMENTS can never be met on this node (D649 round 5):
16885
+ * an id the catalog does not know, a model URL answering 404/410, a declared
16886
+ * sibling (the tokenizer) that is not there. After `attempts` failed builds
16887
+ * it is terminally `requirements-failed`, refused by name until an operator
16888
+ * `resetFailedModels` or a model change — the same exits as a crashed tower.
16889
+ */
16890
+ var EmbeddingFailedRequirementSchema = object({
16891
+ modelId: string(),
16892
+ tower: EmbeddingTowerSchema,
16893
+ nodeId: string(),
16894
+ attempts: number(),
16895
+ sinceMs: number(),
16896
+ lastReason: string()
16897
+ });
16764
16898
  var EmbeddingInfoSchema = object({
16765
16899
  modelId: string(),
16766
16900
  embeddingDim: number(),
16767
- ready: boolean()
16768
- });
16901
+ ready: boolean(),
16902
+ /**
16903
+ * The node that answered. Absent only from an encoder older than D649's
16904
+ * crash budget — whose `failedModels` is then UNKNOWN (D315), never "none".
16905
+ */
16906
+ nodeId: string().optional(),
16907
+ /**
16908
+ * Towers in `failed` on the answering node, each row naming it. `undefined`
16909
+ * means the node could not say (pre-budget encoder); a node that has the
16910
+ * budget always answers an array, empty included.
16911
+ */
16912
+ failedModels: array(EmbeddingFailedModelSchema).optional(),
16913
+ /** Models terminally `requirements-failed` on the answering node; same reading as above. */
16914
+ failedRequirements: array(EmbeddingFailedRequirementSchema).optional()
16915
+ });
16916
+ /**
16917
+ * The THREE codes an encoder refusal can carry (D649, D6). Same shape as
16918
+ * `VECTOR_INDEX_DIM_CONFLICT`: the code rides in the MESSAGE, because an
16919
+ * Error's own properties do not survive the UDS/tRPC hop and its message does,
16920
+ * and both sides go through the helpers below — the encoder builds the
16921
+ * refusal, the live detail plane classifies on it to count refusals per
16922
+ * camera instead of logging one warning per track. The bracketed token
16923
+ * carries the code, the model, the tower and the node so a consumer never
16924
+ * parses prose.
16925
+ *
16926
+ * - `EMBEDDING_MODEL_FAILED`: the tower crashed / failed to load past the crash
16927
+ * budget — terminal until `resetFailedModels` or a model change.
16928
+ * - `EMBEDDING_REQUIREMENTS_UNAVAILABLE`: files or runtime not there right now
16929
+ * (a download or Python that failed, or the cooldown after one) — the next
16930
+ * request past the cooldown tries again.
16931
+ * - `EMBEDDING_REQUIREMENTS_FAILED`: the requirements can never be met (unknown
16932
+ * id, 404/410, missing sibling) and the bounded attempts are spent —
16933
+ * terminal, same exits as a crashed tower.
16934
+ */
16935
+ var EMBEDDING_MODEL_FAILED = "embedding-model-failed";
16936
+ var EMBEDDING_REQUIREMENTS_UNAVAILABLE = "embedding-requirements-unavailable";
16937
+ var EMBEDDING_REQUIREMENTS_FAILED = "embedding-requirements-failed";
16938
+ _enum([
16939
+ EMBEDDING_MODEL_FAILED,
16940
+ EMBEDDING_REQUIREMENTS_UNAVAILABLE,
16941
+ EMBEDDING_REQUIREMENTS_FAILED
16942
+ ]);
16943
+ new RegExp(`\\[(${EMBEDDING_MODEL_FAILED}|${EMBEDDING_REQUIREMENTS_UNAVAILABLE}|${EMBEDDING_REQUIREMENTS_FAILED}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);
16769
16944
  method(object({
16770
16945
  crop: _instanceof(Uint8Array),
16771
16946
  width: number(),
16772
16947
  height: number()
16773
- }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
16948
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({
16949
+ text: string(),
16950
+ modelId: string().min(1).optional()
16951
+ }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" }), method(object({ modelId: string().min(1).optional() }), object({
16952
+ cleared: array(string()),
16953
+ nodeId: string()
16954
+ }), {
16955
+ kind: "mutation",
16956
+ auth: "admin"
16957
+ });
16774
16958
  /**
16775
16959
  * `failure-contribution` — the capability an addon reports its OWN losses
16776
16960
  * through, per camera, with the denominator attached. It stores nothing.
@@ -20573,7 +20757,12 @@ var NcMediaPolicySchema = object({
20573
20757
  * the degrade engine, which drops the video and keeps the still.
20574
20758
  */
20575
20759
  clip: boolean().optional(),
20576
- /** Seconds of footage BEFORE / AFTER the event instant. Defaults 3 / 7. */
20760
+ /**
20761
+ * Seconds of footage BEFORE / AFTER the event instant. Absent =
20762
+ * {@link NC_CLIP_PRE_ROLL_DEFAULT_SEC} / {@link NC_CLIP_POST_ROLL_DEFAULT_SEC}
20763
+ * (4 / 6), resolved by the Notification Center at dispatch — deliberately not
20764
+ * a Zod default, so a rule that never chose keeps following the hub's.
20765
+ */
20577
20766
  clipPreRollSec: number().int().min(0).max(30).optional(),
20578
20767
  clipPostRollSec: number().int().min(0).max(30).optional(),
20579
20768
  /**
@@ -21951,6 +22140,177 @@ var OauthIntegrationDescriptorSchema = object({
21951
22140
  });
21952
22141
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
21953
22142
  /**
22143
+ * A model choice has a SCOPE, and a scope change has a workflow.
22144
+ *
22145
+ * ## The two scopes
22146
+ *
22147
+ * Almost every pipeline step's model is a **node** question: which build runs
22148
+ * fastest on THIS accelerator. Two nodes may legitimately answer differently —
22149
+ * a Coral runs the tflite SSD, a Mac runs the coreml YOLO — because the answers
22150
+ * are compared against nothing. They produce boxes, and a box is a box.
22151
+ *
22152
+ * Two steps are not like that. `face-embedding` and `clip-embedding` produce
22153
+ * **vectors that land in ONE shared index** (`identity_samples`,
22154
+ * `vec_object_clip`) and are ranked against each other by cosine similarity.
22155
+ * Cosine similarity between two encoders is not a weak signal, it is a
22156
+ * meaningless number — and nothing inside a vector can tell you it happened.
22157
+ * So for those two steps the model is a **cluster** question with exactly one
22158
+ * answer, stored in exactly one row.
22159
+ *
22160
+ * That is the same argument [D52](../../../../docs/decisions/adr-0052.md) makes
22161
+ * for the crop convention (`detail-crop.ts`), one level up: the crop decides
22162
+ * WHAT pixels the encoder sees, this decides WHICH encoder sees them. Both are
22163
+ * cluster-wide for the same reason and neither may become per-node.
22164
+ *
22165
+ * ## Why the registry lives here and not in the step catalog
22166
+ *
22167
+ * The scope itself is declared on the step, in
22168
+ * `detection-pipeline/registry/step-definitions.ts` (`StepDefinition.modelScope`)
22169
+ * — that is where a new step declares what kind of choice its model is. But the
22170
+ * catalog lives inside `addon-pipeline`, and three packages that must NOT
22171
+ * import an addon need to know the set: the orchestrator (which renders and
22172
+ * stores the row), post-analysis (which pins the row for a re-embed pass) and
22173
+ * admin-ui (which mirrors it). So the set is mirrored here, and
22174
+ * `scripts/check-cluster-model-scope.ts` fails the build when the two disagree.
22175
+ * A hand-copied key that stops matching is exactly how a setting silently stops
22176
+ * arriving while both sides still look correct.
22177
+ *
22178
+ * ## The defaults ARE today's behaviour
22179
+ *
22180
+ * {@link DEFAULT_CLUSTER_STEP_MODELS} reproduces the catalog `defaultModelId`
22181
+ * of both steps. Declaring the scope therefore changes nothing on the day it
22182
+ * ships: the cluster row starts out saying what every node was already doing.
22183
+ * Changing it is legitimate — that is what the knob is for — but it invalidates
22184
+ * the stored vectors of that surface, and must be followed by a re-embed pass
22185
+ * (`face-reembed-pass.ts`, `embedding-rebuild.ts`).
22186
+ */
22187
+ /**
22188
+ * Why the orchestrator cannot say which model the operator chose for a
22189
+ * cluster-scoped step (D651).
22190
+ */
22191
+ var CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS = [
22192
+ "owner-not-ready",
22193
+ "store-read-failed",
22194
+ "three-way-read-unavailable",
22195
+ "invalid-stored",
22196
+ "not-cluster-scoped"
22197
+ ];
22198
+ /**
22199
+ * The cluster-scoped steps. Mirrored from the catalog's `modelScope: 'cluster'`
22200
+ * declarations and guarded by `scripts/check-cluster-model-scope.ts`.
22201
+ */
22202
+ var CLUSTER_MODEL_SCOPED_STEPS = [{
22203
+ stepId: "face-embedding",
22204
+ label: "Face recognition model",
22205
+ defaultModelId: "auraface-r100",
22206
+ indexName: "the enrolled face gallery",
22207
+ options: [
22208
+ {
22209
+ id: "auraface-r100",
22210
+ label: "AuraFace R100"
22211
+ },
22212
+ {
22213
+ id: "arcface-r100",
22214
+ label: "ArcFace (ResNet34)"
22215
+ },
22216
+ {
22217
+ id: "inception-resnet-v1",
22218
+ label: "Inception ResNet V1"
22219
+ }
22220
+ ]
22221
+ }, {
22222
+ stepId: "clip-embedding",
22223
+ label: "Semantic search model",
22224
+ defaultModelId: "mobileclip-s1",
22225
+ indexName: "the object semantic-search index",
22226
+ options: [
22227
+ {
22228
+ id: "mobileclip-s1",
22229
+ label: "MobileCLIP S1"
22230
+ },
22231
+ {
22232
+ id: "mobileclip-s2",
22233
+ label: "MobileCLIP S2"
22234
+ },
22235
+ {
22236
+ id: "siglip2-b16-224",
22237
+ label: "SigLIP2 B/16 (Apache-2.0)"
22238
+ }
22239
+ ]
22240
+ }];
22241
+ Object.freeze(Object.fromEntries(CLUSTER_MODEL_SCOPED_STEPS.map((s) => [s.stepId, s.defaultModelId])));
22242
+ function isHydratedField$2(entry) {
22243
+ return typeof entry === "object" && entry !== null && "key" in entry;
22244
+ }
22245
+ /** The `wanted` keys of a hydrated view as one flat record, every section walked. */
22246
+ function flattenHydratedView(view, wanted) {
22247
+ const flat = {};
22248
+ for (const section of view.sections) for (const entry of section.fields) {
22249
+ if (!isHydratedField$2(entry) || typeof entry.key !== "string") continue;
22250
+ if (wanted.has(entry.key)) flat[entry.key] = entry.value;
22251
+ }
22252
+ return flat;
22253
+ }
22254
+ /**
22255
+ * The cluster model for `stepId`, or `null` when the step is node-scoped.
22256
+ *
22257
+ * `null` is the signal to LEAVE THE CALLER'S RESOLUTION ALONE — it is not "no
22258
+ * model". Returning a default here for a node-scoped step would quietly
22259
+ * override every per-(node,device) selection in the fleet.
22260
+ */
22261
+ function resolveClusterStepModelId(stepId, models) {
22262
+ const step = CLUSTER_MODEL_SCOPED_STEPS.find((s) => s.stepId === stepId);
22263
+ if (step === void 0) return null;
22264
+ const chosen = models[stepId];
22265
+ return chosen !== void 0 && chosen !== "" ? chosen : step.defaultModelId;
22266
+ }
22267
+ var CLUSTER_STEP_SETTING_FIELDS = [{
22268
+ stepId: "face-embedding",
22269
+ key: "minLandmarkFaceSize",
22270
+ label: "Min face size for recognition (detection px)",
22271
+ 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.",
22272
+ type: "slider",
22273
+ min: 0,
22274
+ max: 64,
22275
+ step: 2,
22276
+ default: 24
22277
+ }];
22278
+ function clusterStepSettingKey(stepId, fieldKey) {
22279
+ return `clusterStepSetting:${stepId}:${fieldKey}`;
22280
+ }
22281
+ var ClusterSettingNumberSchema = number().finite();
22282
+ function readClusterStepSettings(config) {
22283
+ const out = {};
22284
+ for (const field of CLUSTER_STEP_SETTING_FIELDS) {
22285
+ const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
22286
+ const value = parsed.success ? parsed.data : field.default;
22287
+ const existing = out[field.stepId] ?? {};
22288
+ out[field.stepId] = {
22289
+ ...existing,
22290
+ [field.key]: value
22291
+ };
22292
+ }
22293
+ return out;
22294
+ }
22295
+ var DEFAULT_CLUSTER_STEP_SETTINGS = readClusterStepSettings({});
22296
+ function pickClusterStepSettings(view) {
22297
+ if (view === null) return DEFAULT_CLUSTER_STEP_SETTINGS;
22298
+ return readClusterStepSettings(flattenHydratedView(view, new Set(CLUSTER_STEP_SETTING_FIELDS.map((field) => clusterStepSettingKey(field.stepId, field.key)))));
22299
+ }
22300
+ /**
22301
+ * Cluster knobs win over leftover per-device values. The cluster row is the
22302
+ * authority; a device-local copy is a leftover of the old per-node editor.
22303
+ */
22304
+ function overlayClusterStepSettings(stepId, deviceSettings, cluster) {
22305
+ const overlay = cluster[stepId];
22306
+ if (overlay === void 0 || Object.keys(overlay).length === 0) return deviceSettings === void 0 ? void 0 : { ...deviceSettings };
22307
+ if (deviceSettings === void 0) return { ...overlay };
22308
+ return {
22309
+ ...deviceSettings,
22310
+ ...overlay
22311
+ };
22312
+ }
22313
+ /**
21954
22314
  * pipeline-analytics — device-scoped wrapper cap. Refines raw
21955
22315
  * per-frame detections emitted by the pipeline runner into tracked
21956
22316
  * objects, per-kind event collections (motion / object / audio), and
@@ -22766,7 +23126,8 @@ var MediaFileKindEnum = _enum([
22766
23126
  "thumbnailSmall",
22767
23127
  "confirmationCrop",
22768
23128
  "debugCrop",
22769
- "sceneFrame"
23129
+ "sceneFrame",
23130
+ "lastSceneFrame"
22770
23131
  ]);
22771
23132
  /**
22772
23133
  * One media row ON THE WIRE: what it is, how big it is, and WHERE ITS BYTES
@@ -23318,7 +23679,23 @@ var SearchObjectEventsInput = object({
23318
23679
  until: number().optional(),
23319
23680
  classFilter: string().optional(),
23320
23681
  limit: number().default(50),
23321
- minScore: number().min(0).max(1).default(.2)
23682
+ /**
23683
+ * An ABSOLUTE cosine floor. Optional since D649: a floor is a property of the
23684
+ * model (0.2 kept 96% of matched pairs on MobileCLIP S1 and 2.7% on SigLIP2),
23685
+ * so an absent one resolves to the searched model's own `searchMinScore`
23686
+ * scaled by `strictness`. A number sent here is honoured verbatim.
23687
+ */
23688
+ minScore: number().min(0).max(1).optional(),
23689
+ /** Model-relative floor — see `resolveClipSearchMinScore`. Default `loose`. */
23690
+ strictness: ClipSearchStrictnessSchema.optional(),
23691
+ /**
23692
+ * Search THIS CLIP model's index instead of the cluster row's. Every index a
23693
+ * model ever wrote stays searchable until it is wiped (the MobileCLIP index
23694
+ * through a SigLIP2 cutover and its rollback window). An id with no CLIP
23695
+ * metadata is refused; an id other than the cluster row's is ADMIN-only
23696
+ * (`model-override-requires-admin`).
23697
+ */
23698
+ modelId: string().min(1).optional()
23322
23699
  });
23323
23700
  var TrackCascadeCountsSchema = object({
23324
23701
  /** Persisted track roots deleted (authoritative). */
@@ -23453,7 +23830,41 @@ var RebuildObjectEmbeddingsInput = object({
23453
23830
  * comparable, so wiping and rebuilding is the only way to be sure every vector
23454
23831
  * means the same thing.
23455
23832
  */
23456
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
23833
+ var WipeObjectEmbeddingsResultSchema = object({
23834
+ deleted: number(),
23835
+ /**
23836
+ * CLIP indexes that could NOT be emptied (unreachable, or refused at their
23837
+ * dimension) — not a clean slate. Additive and optional (D649).
23838
+ */
23839
+ failedIndexes: array(string()).optional()
23840
+ });
23841
+ /**
23842
+ * Why a rebuild did not start, BY NAME — ONE vocabulary for both gates in front
23843
+ * of a pass (D649 over D651). A bare `started: false` read the same for "the
23844
+ * stores are booting" and "the cluster row names a model with no CLIP
23845
+ * metadata", which need different fixes.
23846
+ * - `stores-unavailable` — the analytics stores or the API are not up yet.
23847
+ * - the owner's confirmation of the cluster model (D651, `ClusterPinConfirmer`):
23848
+ * a pass that rewrites an index needs two agreeing reads of the OWNER's
23849
+ * answer (`pipelineOrchestrator.getClusterModelChoice`) — a pass that cannot
23850
+ * name its model does not run (D54):
23851
+ * - the owner's own `unreadable` reasons (`owner-not-ready`,
23852
+ * `store-read-failed`, `three-way-read-unavailable`, `invalid-stored`,
23853
+ * `not-cluster-scoped`);
23854
+ * - `method-unavailable` — the orchestrator predates the method;
23855
+ * - `read-failed` — the call failed or answered something unparseable;
23856
+ * - `reads-disagree` — the two reads named different choices.
23857
+ * - `not-a-clip-model` — the CONFIRMED id has no CLIP metadata, so there is no
23858
+ * index to fill and no dimension to check against (D649).
23859
+ */
23860
+ var RebuildObjectEmbeddingsRefusalSchema = _enum([
23861
+ "stores-unavailable",
23862
+ ...CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS,
23863
+ "method-unavailable",
23864
+ "read-failed",
23865
+ "reads-disagree",
23866
+ "not-a-clip-model"
23867
+ ]);
23457
23868
  /**
23458
23869
  * Acknowledgement that a rebuild STARTED.
23459
23870
  *
@@ -23466,7 +23877,12 @@ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
23466
23877
  var RebuildObjectEmbeddingsResultSchema = object({
23467
23878
  started: boolean(),
23468
23879
  /** True when a pass was already running; the new request is ignored. */
23469
- alreadyRunning: boolean()
23880
+ alreadyRunning: boolean(),
23881
+ /** Present when the pass refused to start — see `RebuildObjectEmbeddingsRefusalSchema`. */
23882
+ refusal: RebuildObjectEmbeddingsRefusalSchema.optional(),
23883
+ /** The CLIP model the pass pinned, and the index it fills (when it started). */
23884
+ modelId: string().optional(),
23885
+ index: string().optional()
23470
23886
  });
23471
23887
  var RebuildStatusSchema = object({
23472
23888
  running: boolean(),
@@ -23500,7 +23916,11 @@ var RebuildStatusSchema = object({
23500
23916
  startedAtMs: number().nullable(),
23501
23917
  finishedAtMs: number().nullable(),
23502
23918
  /** Present when the pass ended by throwing. */
23503
- error: string().nullable()
23919
+ error: string().nullable(),
23920
+ /** The CLIP model the current / last pass pinned (D54), `null` before any. */
23921
+ modelId: string().nullable(),
23922
+ /** The index that pass fills — `ClipModelMeta.vectorIndex` of `modelId` (D649). */
23923
+ index: string().nullable()
23504
23924
  });
23505
23925
  /**
23506
23926
  * Acknowledgement that a debug-media reclaim STARTED.
@@ -23821,7 +24241,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23821
24241
  deviceId: number(),
23822
24242
  ownerKind: MediaPresenceOwnerKindSchema,
23823
24243
  ownerIds: array(string()).max(5e3)
23824
- }), array(string()).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
24244
+ }), array(string()).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly(), { caller: "required" }), method(object({}), WipeObjectEmbeddingsResultSchema, {
23825
24245
  kind: "mutation",
23826
24246
  auth: "admin"
23827
24247
  }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
@@ -24440,7 +24860,14 @@ var pipelineExecutorCapability = {
24440
24860
  */
24441
24861
  inferCached: method(object({
24442
24862
  stepId: string(),
24443
- frameId: number().int()
24863
+ frameId: number().int(),
24864
+ /**
24865
+ * The model to time — REQUIRED (D658). Without it the pool answered the
24866
+ * step's ACTIVE variant (the first loaded after boot), so a benchmark
24867
+ * of model B silently timed model A. Callers pass the `rootModelId`
24868
+ * their warmup `runPipeline` reported: the model that actually ran.
24869
+ */
24870
+ modelId: string().min(1)
24444
24871
  }), record(string(), unknown()), { kind: "mutation" }),
24445
24872
  /**
24446
24873
  * Release a cached frame from the Python pool's memory.
@@ -25052,6 +25479,17 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
25052
25479
  hubHostnameOverride: string().optional()
25053
25480
  })]).describe("Per-camera frame-source mode for the runner (P2c)");
25054
25481
  /**
25482
+ * What ONE step runs with on ONE roster device for THIS camera (D650): the
25483
+ * device's per-(node,device) base with the camera's override for that device
25484
+ * on top — the same `override ?? base` merge the orchestrator applies to the
25485
+ * elected device (`applyDeviceProvisioning`). Absent `modelId` ⇒ the executor
25486
+ * resolves the device format's default, exactly as on the elected device.
25487
+ */
25488
+ var RunnerJumpStepProvisioningSchema = object({
25489
+ modelId: string().optional(),
25490
+ settings: record(string(), unknown()).optional()
25491
+ });
25492
+ /**
25055
25493
  * One ENABLED inference device on the runner's node, as the step-tree
25056
25494
  * device-jump resolver sees it (phase 1). The orchestrator populates this
25057
25495
  * roster on the attach payload whenever the camera is elected onto a specific
@@ -25063,7 +25501,16 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
25063
25501
  var RunnerInferenceDeviceSchema = object({
25064
25502
  deviceKey: string(),
25065
25503
  weight: number().positive().default(1),
25066
- maxSessions: number().int().positive().nullable().default(null)
25504
+ maxSessions: number().int().positive().nullable().default(null),
25505
+ /**
25506
+ * Per-step provisioning for this camera on THIS device (D650), keyed by step
25507
+ * id. A step the runner jumps here runs with these fields, never with the
25508
+ * elected device's: `modelId` / `settings` are REPLACED on the jumped subtree
25509
+ * (a step absent from the map runs with neither — the target format default).
25510
+ * Absent field ⇒ an orchestrator that predates D650: the jumped step keeps
25511
+ * the elected device's provisioning, as before.
25512
+ */
25513
+ steps: record(string(), RunnerJumpStepProvisioningSchema).optional()
25067
25514
  });
25068
25515
  /**
25069
25516
  * Camera assignment payload sent by `addon-pipeline-orchestrator` to a
@@ -26130,6 +26577,28 @@ var NodeInferenceDeviceSchema = object({
26130
26577
  */
26131
26578
  exclusion: InferenceDeviceExclusionReasonSchema.nullable()
26132
26579
  });
26580
+ /**
26581
+ * The operator's model choice for one cluster-scoped step, answered by the
26582
+ * addon that OWNS the `clusterModel:*` settings (D651). Three answers, never
26583
+ * folded: a written choice, a key nobody wrote (the cluster runs the default
26584
+ * BY ABSENCE), or no answer. A caller that rewrites an index acts only on the
26585
+ * first two, read twice and agreeing.
26586
+ */
26587
+ var ClusterModelChoiceSchema = discriminatedUnion("kind", [
26588
+ object({
26589
+ kind: literal("stored"),
26590
+ modelId: string()
26591
+ }),
26592
+ object({
26593
+ kind: literal("absent"),
26594
+ defaultModelId: string()
26595
+ }),
26596
+ object({
26597
+ kind: literal("unreadable"),
26598
+ reason: _enum(CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS),
26599
+ error: string().optional()
26600
+ })
26601
+ ]);
26133
26602
  var NodeInferenceDevicesSchema = object({
26134
26603
  nodeId: string(),
26135
26604
  /** False when the node's platform-probe was unreachable (no live device set). */
@@ -26157,10 +26626,17 @@ method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
26157
26626
  }), object({ success: literal(true) }), {
26158
26627
  kind: "mutation",
26159
26628
  auth: "admin"
26160
- }), method(object({ deviceId: number() }), object({ deviceKey: string().nullable() })), method(_void(), object({ migrated: number() }), {
26629
+ }), method(object({ deviceId: number() }), object({ deviceKey: string().nullable() })), method(_void(), object({
26630
+ migrated: number(),
26631
+ skipped: array(object({
26632
+ deviceId: number(),
26633
+ targetNodeId: string(),
26634
+ reason: string()
26635
+ })).default([])
26636
+ }), {
26161
26637
  kind: "mutation",
26162
26638
  auth: "admin"
26163
- }), 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({
26639
+ }), 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({
26164
26640
  nodeId: string(),
26165
26641
  capName: string(),
26166
26642
  addonId: string()
@@ -28756,6 +29232,281 @@ var videoclipsCapability = {
28756
29232
  }
28757
29233
  };
28758
29234
  /**
29235
+ * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
29236
+ * valutatore puro del suo FRONTE.
29237
+ *
29238
+ * Viveva dentro il builtin virtual-doorbell
29239
+ * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
29240
+ * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
29241
+ * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
29242
+ * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
29243
+ * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
29244
+ * SPOSTA qui e il doorbell la ri-esporta.
29245
+ *
29246
+ * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
29247
+ * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
29248
+ * regola" (e include `presence`, `cover`, `alarm-panel`), questa a "qual è il
29249
+ * booleano il cui FRONTE conta". Vocabolari deliberatamente diversi.
29250
+ */
29251
+ /**
29252
+ * Known binary / switch source caps → the boolean slice field whose
29253
+ * false→true rise counts as ACTIVE. Every entry is "fire on active".
29254
+ * Sensors whose "active" reading is not a plain boolean (presence's string
29255
+ * state, connectivity's connected flag) are deliberately excluded — a
29256
+ * reconnect is not a doorbell press, and it is not a recording either.
29257
+ */
29258
+ var SOURCE_CAP_ACTIVE_FIELD = {
29259
+ contact: "entryOpen",
29260
+ binary: "on",
29261
+ switch: "on",
29262
+ motion: "detected",
29263
+ flood: "flooded",
29264
+ gas: "detected",
29265
+ smoke: "detected",
29266
+ "carbon-monoxide": "detected",
29267
+ vibration: "detected",
29268
+ tamper: "tampered"
29269
+ };
29270
+ /**
29271
+ * The same caps → the slice field carrying the ms-epoch timestamp of the
29272
+ * last transition. Every source cap MUST appear here (guarded by a spec):
29273
+ * without a transition timestamp the evaluator cannot tell a genuine rise
29274
+ * from a boot-time hydration when the FIRST slice it ever sees is already
29275
+ * active, and errs towards silence — swallowing the rise.
29276
+ *
29277
+ * These timestamps are UPSTREAM ones, not ingest ones: the Home Assistant
29278
+ * provider derives them from `state.last_changed`, so they survive our own
29279
+ * restarts and correctly read as "hours ago" for a state that has been
29280
+ * active for hours. `motion` names its rise timestamp `lastDetectedAt`.
29281
+ */
29282
+ var SOURCE_CAP_CHANGED_AT_FIELD = {
29283
+ contact: "lastChangedAt",
29284
+ binary: "lastChangedAt",
29285
+ switch: "lastChangedAt",
29286
+ motion: "lastDetectedAt",
29287
+ flood: "lastChangedAt",
29288
+ gas: "lastChangedAt",
29289
+ smoke: "lastChangedAt",
29290
+ "carbon-monoxide": "lastChangedAt",
29291
+ vibration: "lastChangedAt",
29292
+ tamper: "lastChangedAt"
29293
+ };
29294
+ /** True when a cap is a recognised binary/switch source. */
29295
+ function isSourceCap(capName) {
29296
+ return Object.prototype.hasOwnProperty.call(SOURCE_CAP_ACTIVE_FIELD, capName);
29297
+ }
29298
+ /** Extract the "active" boolean a source cap's slice carries, or null when
29299
+ * the cap is unknown or the field is missing / non-boolean. */
29300
+ function sliceActiveValue(capName, slice) {
29301
+ const field = SOURCE_CAP_ACTIVE_FIELD[capName];
29302
+ if (field === void 0) return null;
29303
+ const raw = slice[field];
29304
+ return typeof raw === "boolean" ? raw : null;
29305
+ }
29306
+ /** Ms-epoch transition timestamp a source cap's slice carries, or null when
29307
+ * it is absent, non-numeric or the zero "never observed" sentinel. */
29308
+ function sliceChangedAt(capName, slice) {
29309
+ const field = SOURCE_CAP_CHANGED_AT_FIELD[capName];
29310
+ if (field === void 0) return null;
29311
+ const raw = slice[field];
29312
+ if (typeof raw !== "number" || !Number.isFinite(raw) || raw <= 0) return null;
29313
+ return raw;
29314
+ }
29315
+ /**
29316
+ * How recent a source's own transition timestamp must be for a FIRST
29317
+ * sighting that is already active to count as a genuine rise rather than a
29318
+ * hydration of long-standing state.
29319
+ */
29320
+ var DEFAULT_FIRST_SIGHTING_FRESHNESS_MS = 3e4;
29321
+ /**
29322
+ * IL fronte. Puro: nessun orologio proprio, nessuna memoria — il chiamante
29323
+ * porta `prior`, `nowMs` e il proprio `startedAtMs`.
29324
+ *
29325
+ * Il caso della PRIMA slice già attiva è trattato esplicitamente e vale come
29326
+ * fronte solo se il timestamp UPSTREAM della transizione è posteriore a
29327
+ * `startedAtMs` **e** entro `firstSightingFreshnessMs`. Entrambe le metà
29328
+ * servono: la sola freschezza scatterebbe su un'idratazione al boot di uno
29329
+ * stato flippato pochi secondi prima del riavvio, e il solo "dopo che abbiamo
29330
+ * iniziato" scatterebbe, su un processo di lunga vita, per una sorgente
29331
+ * adottata oggi il cui stato è cambiato ieri. Il caso ambiguo ERRA VERSO IL
29332
+ * SILENZIO e lo dichiara (`baseline-seeded-stale-active`).
29333
+ */
29334
+ function evaluateSensorEdge(input) {
29335
+ const value = sliceActiveValue(input.capName, input.slice);
29336
+ if (value === null) return {
29337
+ edge: "none",
29338
+ value: null,
29339
+ reason: isSourceCap(input.capName) ? "non-boolean-value" : "unknown-cap"
29340
+ };
29341
+ if (input.prior === void 0) {
29342
+ if (!value) return {
29343
+ edge: "none",
29344
+ value,
29345
+ reason: "baseline-seeded-inactive"
29346
+ };
29347
+ const changedAt = sliceChangedAt(input.capName, input.slice);
29348
+ const floor = Math.max(input.startedAtMs, input.nowMs - input.firstSightingFreshnessMs);
29349
+ if (changedAt === null || changedAt < floor) return {
29350
+ edge: "none",
29351
+ value,
29352
+ reason: "baseline-seeded-stale-active"
29353
+ };
29354
+ return {
29355
+ edge: "rising",
29356
+ value: true
29357
+ };
29358
+ }
29359
+ if (input.prior === value) return {
29360
+ edge: "none",
29361
+ value,
29362
+ reason: "no-change"
29363
+ };
29364
+ if (!value) return {
29365
+ edge: "none",
29366
+ value,
29367
+ reason: "falling-edge"
29368
+ };
29369
+ return {
29370
+ edge: "rising",
29371
+ value: true
29372
+ };
29373
+ }
29374
+ object({
29375
+ /** Ms epoch of the last press. null = never observed since this provider started. */
29376
+ lastPressedAt: number().nullable(),
29377
+ /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
29378
+ pressCountSinceStart: number()
29379
+ });
29380
+ object({
29381
+ deviceId: number(),
29382
+ timestamp: number()
29383
+ });
29384
+ /**
29385
+ * The `doorbell-source` extension slot's editable value (D648): the camera's
29386
+ * virtual-doorbell trigger devices, exactly what the wrapper's
29387
+ * `doorbellSources` persists (as `{ deviceId }` records).
29388
+ */
29389
+ var DoorbellSourceSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
29390
+ DeviceType.Camera;
29391
+ DeviceType.Button, DeviceType.Camera;
29392
+ var ExtensionSlotIdSchema = _enum(["doorbell-source", "linked-devices"]);
29393
+ DeviceType.Camera, DeviceType.Camera;
29394
+ /** A slot's editable value, discriminated on `slot`. */
29395
+ var ExtensionSlotValueSchema = discriminatedUnion("slot", [DoorbellSourceSlotValueSchema.extend({ slot: literal("doorbell-source") }), LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
29396
+ DeviceType.Camera;
29397
+ var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
29398
+ state: literal("unreachable"),
29399
+ reason: string()
29400
+ })]);
29401
+ /** One provider of slots — the D554 source-listing row. */
29402
+ var ExtensionSourceSchema = object({
29403
+ /** The routing prefix of every `slotRef` this provider serves. */
29404
+ source: string(),
29405
+ label: string(),
29406
+ /** Stamped by the dispatcher from the registry (D557). */
29407
+ addonId: string().optional(),
29408
+ availability: ExtensionSourceAvailabilitySchema
29409
+ });
29410
+ /**
29411
+ * How one picked source stands. `missing` — no such device (deleted, or an id
29412
+ * that never existed); `foreign` — a device the slot's owner cannot read from
29413
+ * (slice 2's cross-owner graft source); `unavailable` — it exists but is not a
29414
+ * valid source now (a container, which is never a pick). A source in any of
29415
+ * these states is SHOWN, never silently dropped or re-pointed.
29416
+ */
29417
+ var ExtensionSourceHealthSchema = _enum([
29418
+ "ok",
29419
+ "missing",
29420
+ "foreign",
29421
+ "unavailable"
29422
+ ]);
29423
+ var ExtensionSlotSourceSchema = object({
29424
+ deviceId: number().int(),
29425
+ /** The device's name, or null when it could not be resolved (`missing`). */
29426
+ name: string().nullable(),
29427
+ health: ExtensionSourceHealthSchema,
29428
+ detail: string().optional()
29429
+ });
29430
+ /**
29431
+ * A DIFFERENT authority that gates whether the slot's sources do anything —
29432
+ * reported read-only, named, never written through this contract (D62). The
29433
+ * virtual doorbell's sources ring only while the wrapper is bound to the
29434
+ * camera, and that binding belongs to `deviceManager.setWrapperActive`.
29435
+ * `unknown` means the gate could not be read; it is not "inactive" (D315).
29436
+ */
29437
+ var ExtensionSlotActivationSchema = object({
29438
+ state: _enum([
29439
+ "active",
29440
+ "inactive",
29441
+ "unknown"
29442
+ ]),
29443
+ authority: string(),
29444
+ detail: string().optional()
29445
+ });
29446
+ var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
29447
+ state: literal("ok"),
29448
+ /** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
29449
+ slotRef: string(),
29450
+ slot: ExtensionSlotIdSchema,
29451
+ /** Names the store written (D62), e.g. `virtual-doorbell:doorbellSources`. */
29452
+ authority: string(),
29453
+ /** graft: its switch. association: null — removing every source is "off". */
29454
+ enabled: boolean().nullable(),
29455
+ /** graft: the cap registered on the host. association: null. */
29456
+ projects: string().nullable(),
29457
+ activation: ExtensionSlotActivationSchema.nullable(),
29458
+ value: ExtensionSlotValueSchema,
29459
+ sources: array(ExtensionSlotSourceSchema),
29460
+ /**
29461
+ * Devices the owner links to the host ON ITS OWN, by structure, and that
29462
+ * are therefore not in `value` (D655): a camera's device-tree children, and
29463
+ * the child a picked container stands for (D356 — a container is never a
29464
+ * pick, its children are). Read-only; the editor shows them and may offer
29465
+ * per-device options on them (the linked-devices tracked-event opt-in).
29466
+ * Absent when the owner links nothing beyond the picks, and from an owner
29467
+ * older than D655.
29468
+ */
29469
+ impliedSources: array(ExtensionSlotSourceSchema).optional()
29470
+ }), object({
29471
+ state: literal("unreachable"),
29472
+ addonId: string(),
29473
+ reason: string()
29474
+ })]);
29475
+ var ExtensionCandidatesSchema = object({ candidates: array(object({
29476
+ deviceId: number().int(),
29477
+ name: string(),
29478
+ type: string(),
29479
+ location: string().nullable(),
29480
+ /** The container a child belongs to — "Spotlight 2" alone does not say which. */
29481
+ parentName: string().nullable(),
29482
+ /** Pre-marked by the owner's suggestion rule. NEVER saved on its own (D356). */
29483
+ suggested: boolean(),
29484
+ /** Why it is suggested ("same location"), null when it is not. */
29485
+ reason: string().nullable()
29486
+ })) });
29487
+ /**
29488
+ * What a write did. `none` — applied in place. `host` / `parent` — the owner
29489
+ * reloaded the host (or, for an accessory child, its parent) because the
29490
+ * write changed what the host REGISTERS (a graft switched on or off, slice 2).
29491
+ */
29492
+ var ExtensionSetResultSchema = object({
29493
+ applied: literal(true),
29494
+ reload: _enum([
29495
+ "none",
29496
+ "host",
29497
+ "parent"
29498
+ ])
29499
+ });
29500
+ var ExtensionSlotRefInputSchema = object({
29501
+ deviceId: number().int(),
29502
+ slotRef: string().min(1)
29503
+ });
29504
+ var ExtensionSetSlotInputSchema = ExtensionSlotRefInputSchema.extend({ value: ExtensionSlotValueSchema });
29505
+ method(object({ deviceId: number().int() }), array(ExtensionSourceSchema)), method(object({ deviceId: number().int() }), array(ExtensionSlotRowSchema)), method(ExtensionSlotRefInputSchema, ExtensionCandidatesSchema), method(ExtensionSetSlotInputSchema, ExtensionSetResultSchema, {
29506
+ kind: "mutation",
29507
+ auth: "admin"
29508
+ });
29509
+ /**
28759
29510
  * Optional client-side hints sent at session creation to help the provider
28760
29511
  * pick the best native source. All fields optional — a viewer that knows
28761
29512
  * nothing still gets a sane default. (Relocated from the retired `webrtc`
@@ -30708,17 +31459,6 @@ object({
30708
31459
  deviceId: number(),
30709
31460
  status: DeviceStatusSchema
30710
31461
  });
30711
- object({
30712
- /** Ms epoch of the last press. null = never observed since this provider started. */
30713
- lastPressedAt: number().nullable(),
30714
- /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
30715
- pressCountSinceStart: number()
30716
- });
30717
- object({
30718
- deviceId: number(),
30719
- timestamp: number()
30720
- });
30721
- DeviceType.Button, DeviceType.Camera;
30722
31462
  /**
30723
31463
  * Enum-state sensor — a string value picked from a finite option set.
30724
31464
  * Drives HA `sensor` entries with `state_class: enum` (HVAC action
@@ -38029,146 +38769,6 @@ DeviceType.Camera, method(object({
38029
38769
  detection: array(ZoneRuleSchema).readonly(),
38030
38770
  package: array(ZoneRuleSchema).readonly()
38031
38771
  });
38032
- /**
38033
- * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
38034
- * valutatore puro del suo FRONTE.
38035
- *
38036
- * Viveva dentro il builtin virtual-doorbell
38037
- * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
38038
- * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
38039
- * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
38040
- * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
38041
- * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
38042
- * SPOSTA qui e il doorbell la ri-esporta.
38043
- *
38044
- * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
38045
- * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
38046
- * regola" (e include `presence`, `cover`, `alarm-panel`), questa a "qual è il
38047
- * booleano il cui FRONTE conta". Vocabolari deliberatamente diversi.
38048
- */
38049
- /**
38050
- * Known binary / switch source caps → the boolean slice field whose
38051
- * false→true rise counts as ACTIVE. Every entry is "fire on active".
38052
- * Sensors whose "active" reading is not a plain boolean (presence's string
38053
- * state, connectivity's connected flag) are deliberately excluded — a
38054
- * reconnect is not a doorbell press, and it is not a recording either.
38055
- */
38056
- var SOURCE_CAP_ACTIVE_FIELD = {
38057
- contact: "entryOpen",
38058
- binary: "on",
38059
- switch: "on",
38060
- motion: "detected",
38061
- flood: "flooded",
38062
- gas: "detected",
38063
- smoke: "detected",
38064
- "carbon-monoxide": "detected",
38065
- vibration: "detected",
38066
- tamper: "tampered"
38067
- };
38068
- /**
38069
- * The same caps → the slice field carrying the ms-epoch timestamp of the
38070
- * last transition. Every source cap MUST appear here (guarded by a spec):
38071
- * without a transition timestamp the evaluator cannot tell a genuine rise
38072
- * from a boot-time hydration when the FIRST slice it ever sees is already
38073
- * active, and errs towards silence — swallowing the rise.
38074
- *
38075
- * These timestamps are UPSTREAM ones, not ingest ones: the Home Assistant
38076
- * provider derives them from `state.last_changed`, so they survive our own
38077
- * restarts and correctly read as "hours ago" for a state that has been
38078
- * active for hours. `motion` names its rise timestamp `lastDetectedAt`.
38079
- */
38080
- var SOURCE_CAP_CHANGED_AT_FIELD = {
38081
- contact: "lastChangedAt",
38082
- binary: "lastChangedAt",
38083
- switch: "lastChangedAt",
38084
- motion: "lastDetectedAt",
38085
- flood: "lastChangedAt",
38086
- gas: "lastChangedAt",
38087
- smoke: "lastChangedAt",
38088
- "carbon-monoxide": "lastChangedAt",
38089
- vibration: "lastChangedAt",
38090
- tamper: "lastChangedAt"
38091
- };
38092
- /** True when a cap is a recognised binary/switch source. */
38093
- function isSourceCap(capName) {
38094
- return Object.prototype.hasOwnProperty.call(SOURCE_CAP_ACTIVE_FIELD, capName);
38095
- }
38096
- /** Extract the "active" boolean a source cap's slice carries, or null when
38097
- * the cap is unknown or the field is missing / non-boolean. */
38098
- function sliceActiveValue(capName, slice) {
38099
- const field = SOURCE_CAP_ACTIVE_FIELD[capName];
38100
- if (field === void 0) return null;
38101
- const raw = slice[field];
38102
- return typeof raw === "boolean" ? raw : null;
38103
- }
38104
- /** Ms-epoch transition timestamp a source cap's slice carries, or null when
38105
- * it is absent, non-numeric or the zero "never observed" sentinel. */
38106
- function sliceChangedAt(capName, slice) {
38107
- const field = SOURCE_CAP_CHANGED_AT_FIELD[capName];
38108
- if (field === void 0) return null;
38109
- const raw = slice[field];
38110
- if (typeof raw !== "number" || !Number.isFinite(raw) || raw <= 0) return null;
38111
- return raw;
38112
- }
38113
- /**
38114
- * How recent a source's own transition timestamp must be for a FIRST
38115
- * sighting that is already active to count as a genuine rise rather than a
38116
- * hydration of long-standing state.
38117
- */
38118
- var DEFAULT_FIRST_SIGHTING_FRESHNESS_MS = 3e4;
38119
- /**
38120
- * IL fronte. Puro: nessun orologio proprio, nessuna memoria — il chiamante
38121
- * porta `prior`, `nowMs` e il proprio `startedAtMs`.
38122
- *
38123
- * Il caso della PRIMA slice già attiva è trattato esplicitamente e vale come
38124
- * fronte solo se il timestamp UPSTREAM della transizione è posteriore a
38125
- * `startedAtMs` **e** entro `firstSightingFreshnessMs`. Entrambe le metà
38126
- * servono: la sola freschezza scatterebbe su un'idratazione al boot di uno
38127
- * stato flippato pochi secondi prima del riavvio, e il solo "dopo che abbiamo
38128
- * iniziato" scatterebbe, su un processo di lunga vita, per una sorgente
38129
- * adottata oggi il cui stato è cambiato ieri. Il caso ambiguo ERRA VERSO IL
38130
- * SILENZIO e lo dichiara (`baseline-seeded-stale-active`).
38131
- */
38132
- function evaluateSensorEdge(input) {
38133
- const value = sliceActiveValue(input.capName, input.slice);
38134
- if (value === null) return {
38135
- edge: "none",
38136
- value: null,
38137
- reason: isSourceCap(input.capName) ? "non-boolean-value" : "unknown-cap"
38138
- };
38139
- if (input.prior === void 0) {
38140
- if (!value) return {
38141
- edge: "none",
38142
- value,
38143
- reason: "baseline-seeded-inactive"
38144
- };
38145
- const changedAt = sliceChangedAt(input.capName, input.slice);
38146
- const floor = Math.max(input.startedAtMs, input.nowMs - input.firstSightingFreshnessMs);
38147
- if (changedAt === null || changedAt < floor) return {
38148
- edge: "none",
38149
- value,
38150
- reason: "baseline-seeded-stale-active"
38151
- };
38152
- return {
38153
- edge: "rising",
38154
- value: true
38155
- };
38156
- }
38157
- if (input.prior === value) return {
38158
- edge: "none",
38159
- value,
38160
- reason: "no-change"
38161
- };
38162
- if (!value) return {
38163
- edge: "none",
38164
- value,
38165
- reason: "falling-edge"
38166
- };
38167
- return {
38168
- edge: "rising",
38169
- value: true
38170
- };
38171
- }
38172
38772
  var HF_BASE_URL = `https://huggingface.co/camstack/camstack-models/resolve/main`;
38173
38773
  /**
38174
38774
  * Accessory device helpers — shared across drivers.
@@ -40988,6 +41588,30 @@ Object.freeze({
40988
41588
  addonId: null,
40989
41589
  access: "create"
40990
41590
  },
41591
+ "deviceExtension.listCandidates": {
41592
+ capName: "device-extension",
41593
+ capScope: "device",
41594
+ addonId: null,
41595
+ access: "view"
41596
+ },
41597
+ "deviceExtension.listSlots": {
41598
+ capName: "device-extension",
41599
+ capScope: "device",
41600
+ addonId: null,
41601
+ access: "view"
41602
+ },
41603
+ "deviceExtension.listSources": {
41604
+ capName: "device-extension",
41605
+ capScope: "device",
41606
+ addonId: null,
41607
+ access: "view"
41608
+ },
41609
+ "deviceExtension.setSlot": {
41610
+ capName: "device-extension",
41611
+ capScope: "device",
41612
+ addonId: null,
41613
+ access: "create"
41614
+ },
40991
41615
  "deviceManager.addLocation": {
40992
41616
  capName: "device-manager",
40993
41617
  capScope: "system",
@@ -41060,12 +41684,6 @@ Object.freeze({
41060
41684
  addonId: null,
41061
41685
  access: "create"
41062
41686
  },
41063
- "deviceManager.applyDeviceSettingsPatch": {
41064
- capName: "device-manager",
41065
- capScope: "system",
41066
- addonId: null,
41067
- access: "create"
41068
- },
41069
41687
  "deviceManager.applyInitialMeta": {
41070
41688
  capName: "device-manager",
41071
41689
  capScope: "system",
@@ -41168,12 +41786,6 @@ Object.freeze({
41168
41786
  addonId: null,
41169
41787
  access: "view"
41170
41788
  },
41171
- "deviceManager.getDeviceLiveContribution": {
41172
- capName: "device-manager",
41173
- capScope: "system",
41174
- addonId: null,
41175
- access: "view"
41176
- },
41177
41789
  "deviceManager.getDeviceLiveInfoAggregate": {
41178
41790
  capName: "device-manager",
41179
41791
  capScope: "system",
@@ -41186,12 +41798,6 @@ Object.freeze({
41186
41798
  addonId: null,
41187
41799
  access: "view"
41188
41800
  },
41189
- "deviceManager.getDeviceSettingsContribution": {
41190
- capName: "device-manager",
41191
- capScope: "system",
41192
- addonId: null,
41193
- access: "view"
41194
- },
41195
41801
  "deviceManager.getDeviceStatusAggregate": {
41196
41802
  capName: "device-manager",
41197
41803
  capScope: "system",
@@ -41696,24 +42302,6 @@ Object.freeze({
41696
42302
  addonId: null,
41697
42303
  access: "view"
41698
42304
  },
41699
- "doorbell.applyDeviceSettingsPatch": {
41700
- capName: "doorbell",
41701
- capScope: "device",
41702
- addonId: null,
41703
- access: "create"
41704
- },
41705
- "doorbell.getDeviceLiveContribution": {
41706
- capName: "doorbell",
41707
- capScope: "device",
41708
- addonId: null,
41709
- access: "view"
41710
- },
41711
- "doorbell.getDeviceSettingsContribution": {
41712
- capName: "doorbell",
41713
- capScope: "device",
41714
- addonId: null,
41715
- access: "view"
41716
- },
41717
42305
  "doorbell.getStatus": {
41718
42306
  capName: "doorbell",
41719
42307
  capScope: "device",
@@ -41738,6 +42326,12 @@ Object.freeze({
41738
42326
  addonId: null,
41739
42327
  access: "view"
41740
42328
  },
42329
+ "embeddingEncoder.resetFailedModels": {
42330
+ capName: "embedding-encoder",
42331
+ capScope: "system",
42332
+ addonId: null,
42333
+ access: "delete"
42334
+ },
41741
42335
  "enumSensor.getStatus": {
41742
42336
  capName: "enum-sensor",
41743
42337
  capScope: "device",
@@ -44072,6 +44666,12 @@ Object.freeze({
44072
44666
  addonId: null,
44073
44667
  access: "view"
44074
44668
  },
44669
+ "pipelineOrchestrator.getClusterModelChoice": {
44670
+ capName: "pipeline-orchestrator",
44671
+ capScope: "system",
44672
+ addonId: null,
44673
+ access: "view"
44674
+ },
44075
44675
  "pipelineOrchestrator.getDeviceLiveContribution": {
44076
44676
  capName: "pipeline-orchestrator",
44077
44677
  capScope: "system",
@@ -46897,6 +47497,26 @@ Object.freeze({
46897
47497
  form: "single",
46898
47498
  optional: false
46899
47499
  }],
47500
+ "deviceExtension.listCandidates": [{
47501
+ name: "deviceId",
47502
+ form: "single",
47503
+ optional: false
47504
+ }],
47505
+ "deviceExtension.listSlots": [{
47506
+ name: "deviceId",
47507
+ form: "single",
47508
+ optional: false
47509
+ }],
47510
+ "deviceExtension.listSources": [{
47511
+ name: "deviceId",
47512
+ form: "single",
47513
+ optional: false
47514
+ }],
47515
+ "deviceExtension.setSlot": [{
47516
+ name: "deviceId",
47517
+ form: "single",
47518
+ optional: false
47519
+ }],
46900
47520
  "deviceManager.adoptionRelease": [{
46901
47521
  name: "camDeviceId",
46902
47522
  form: "single",
@@ -49406,204 +50026,20 @@ TimelapseRuleInputSchema.extend({
49406
50026
  createdAt: number(),
49407
50027
  updatedAt: number()
49408
50028
  });
49409
- /**
49410
- * A model choice has a SCOPE, and a scope change has a workflow.
49411
- *
49412
- * ## The two scopes
49413
- *
49414
- * Almost every pipeline step's model is a **node** question: which build runs
49415
- * fastest on THIS accelerator. Two nodes may legitimately answer differently —
49416
- * a Coral runs the tflite SSD, a Mac runs the coreml YOLO — because the answers
49417
- * are compared against nothing. They produce boxes, and a box is a box.
49418
- *
49419
- * Two steps are not like that. `face-embedding` and `clip-embedding` produce
49420
- * **vectors that land in ONE shared index** (`identity_samples`,
49421
- * `vec_object_clip`) and are ranked against each other by cosine similarity.
49422
- * Cosine similarity between two encoders is not a weak signal, it is a
49423
- * meaningless number — and nothing inside a vector can tell you it happened.
49424
- * So for those two steps the model is a **cluster** question with exactly one
49425
- * answer, stored in exactly one row.
49426
- *
49427
- * That is the same argument [D52](../../../../docs/decisions/adr-0052.md) makes
49428
- * for the crop convention (`detail-crop.ts`), one level up: the crop decides
49429
- * WHAT pixels the encoder sees, this decides WHICH encoder sees them. Both are
49430
- * cluster-wide for the same reason and neither may become per-node.
49431
- *
49432
- * ## Why the registry lives here and not in the step catalog
49433
- *
49434
- * The scope itself is declared on the step, in
49435
- * `detection-pipeline/registry/step-definitions.ts` (`StepDefinition.modelScope`)
49436
- * — that is where a new step declares what kind of choice its model is. But the
49437
- * catalog lives inside `addon-pipeline`, and three packages that must NOT
49438
- * import an addon need to know the set: the orchestrator (which renders and
49439
- * stores the row), post-analysis (which pins the row for a re-embed pass) and
49440
- * admin-ui (which mirrors it). So the set is mirrored here, and
49441
- * `scripts/check-cluster-model-scope.ts` fails the build when the two disagree.
49442
- * A hand-copied key that stops matching is exactly how a setting silently stops
49443
- * arriving while both sides still look correct.
49444
- *
49445
- * ## The defaults ARE today's behaviour
49446
- *
49447
- * {@link DEFAULT_CLUSTER_STEP_MODELS} reproduces the catalog `defaultModelId`
49448
- * of both steps. Declaring the scope therefore changes nothing on the day it
49449
- * ships: the cluster row starts out saying what every node was already doing.
49450
- * Changing it is legitimate — that is what the knob is for — but it invalidates
49451
- * the stored vectors of that surface, and must be followed by a re-embed pass
49452
- * (`face-reembed-pass.ts`, `embedding-rebuild.ts`).
49453
- */
49454
- /**
49455
- * The cluster-scoped steps. Mirrored from the catalog's `modelScope: 'cluster'`
49456
- * declarations and guarded by `scripts/check-cluster-model-scope.ts`.
49457
- */
49458
- var CLUSTER_MODEL_SCOPED_STEPS = [{
49459
- stepId: "face-embedding",
49460
- label: "Face recognition model",
49461
- defaultModelId: "arcface-r100",
49462
- indexName: "the enrolled face gallery",
49463
- options: [
49464
- {
49465
- id: "arcface-r100",
49466
- label: "ArcFace (ResNet34)"
49467
- },
49468
- {
49469
- id: "auraface-r100",
49470
- label: "AuraFace R100"
49471
- },
49472
- {
49473
- id: "inception-resnet-v1",
49474
- label: "Inception ResNet V1"
49475
- }
49476
- ]
49477
- }, {
49478
- stepId: "clip-embedding",
49479
- label: "Semantic search model",
49480
- defaultModelId: "mobileclip-s1",
49481
- indexName: "the object semantic-search index",
49482
- options: [{
49483
- id: "mobileclip-s1",
49484
- label: "MobileCLIP S1"
49485
- }, {
49486
- id: "mobileclip-s2",
49487
- label: "MobileCLIP S2"
49488
- }]
49489
- }];
49490
- /**
49491
- * The settings key holding one step's cluster model choice.
49492
- *
49493
- * Step-qualified so the keys stay unique across the addon's whole schema, which
49494
- * is what lets {@link pickClusterStepModels} walk every section instead of
49495
- * trusting the section id.
49496
- */
49497
- function clusterModelSettingKey(stepId) {
49498
- return `clusterModel:${stepId}`;
50029
+ /** True when `model` ships a build for `format`. */
50030
+ function hasBuild(model, format) {
50031
+ return Boolean(model.formats[format]);
49499
50032
  }
49500
- /** The cluster row when nobody has configured one — today's catalog defaults. */
49501
- var DEFAULT_CLUSTER_STEP_MODELS = Object.freeze(Object.fromEntries(CLUSTER_MODEL_SCOPED_STEPS.map((s) => [s.stepId, s.defaultModelId])));
49502
- /** A stored choice is a non-empty model id, or it is not a choice. */
49503
- var ChosenModelIdSchema = string().min(1);
49504
50033
  /**
49505
- * Narrow a FLAT settings record to the cluster row.
49506
- *
49507
- * Per-FIELD fallback, deliberately (same rule as `readDetailCropConvention`): a
49508
- * junk face model must not also discard a valid clip model. An absent, empty or
49509
- * non-string value resolves to the step's catalog default — the historical
49510
- * behaviour — never to a blank id, because a blank id downstream becomes
49511
- * "substitute the format default", which is precisely the substitution this
49512
- * scope exists to forbid.
49513
- */
49514
- function readClusterStepModels(config) {
49515
- const out = {};
49516
- for (const step of CLUSTER_MODEL_SCOPED_STEPS) {
49517
- const parsed = ChosenModelIdSchema.safeParse(config[clusterModelSettingKey(step.stepId)]);
49518
- out[step.stepId] = parsed.success ? parsed.data : step.defaultModelId;
49519
- }
49520
- return out;
49521
- }
49522
- function isHydratedField$2(entry) {
49523
- return typeof entry === "object" && entry !== null && "key" in entry;
49524
- }
49525
- /**
49526
- * Extract the cluster row from an `addon-settings.getGlobalSettings` payload.
49527
- *
49528
- * Walks EVERY section rather than looking inside {@link CLUSTER_MODEL_SECTION_ID}
49529
- * alone: the keys are unique across the addon's schema, and a section rename
49530
- * must not silently revert the whole cluster to the defaults. A `null` payload
49531
- * (addon mid-boot) is the defaults.
49532
- */
49533
- function pickClusterStepModels(view) {
49534
- if (view === null) return DEFAULT_CLUSTER_STEP_MODELS;
49535
- const flat = {};
49536
- const wanted = new Set(CLUSTER_MODEL_SCOPED_STEPS.map((s) => clusterModelSettingKey(s.stepId)));
49537
- for (const section of view.sections) for (const entry of section.fields) {
49538
- if (!isHydratedField$2(entry) || typeof entry.key !== "string") continue;
49539
- if (wanted.has(entry.key)) flat[entry.key] = entry.value;
49540
- }
49541
- return readClusterStepModels(flat);
49542
- }
49543
- /**
49544
- * The cluster model for `stepId`, or `null` when the step is node-scoped.
49545
- *
49546
- * `null` is the signal to LEAVE THE CALLER'S RESOLUTION ALONE — it is not "no
49547
- * model". Returning a default here for a node-scoped step would quietly
49548
- * override every per-(node,device) selection in the fleet.
50034
+ * Can a pool of `format` run a step whose catalog is `models`, given the model
50035
+ * the step names (`null`/absent = unpinned, the format default)?
49549
50036
  */
49550
- function resolveClusterStepModelId(stepId, models) {
49551
- const step = CLUSTER_MODEL_SCOPED_STEPS.find((s) => s.stepId === stepId);
49552
- if (step === void 0) return null;
49553
- const chosen = models[stepId];
49554
- return chosen !== void 0 && chosen !== "" ? chosen : step.defaultModelId;
49555
- }
49556
- var CLUSTER_STEP_SETTING_FIELDS = [{
49557
- stepId: "face-embedding",
49558
- key: "minLandmarkFaceSize",
49559
- label: "Min face size for recognition (detection px)",
49560
- 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.",
49561
- type: "slider",
49562
- min: 0,
49563
- max: 64,
49564
- step: 2,
49565
- default: 24
49566
- }];
49567
- function clusterStepSettingKey(stepId, fieldKey) {
49568
- return `clusterStepSetting:${stepId}:${fieldKey}`;
49569
- }
49570
- var ClusterSettingNumberSchema = number().finite();
49571
- function readClusterStepSettings(config) {
49572
- const out = {};
49573
- for (const field of CLUSTER_STEP_SETTING_FIELDS) {
49574
- const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
49575
- const value = parsed.success ? parsed.data : field.default;
49576
- const existing = out[field.stepId] ?? {};
49577
- out[field.stepId] = {
49578
- ...existing,
49579
- [field.key]: value
49580
- };
49581
- }
49582
- return out;
49583
- }
49584
- var DEFAULT_CLUSTER_STEP_SETTINGS = readClusterStepSettings({});
49585
- function pickClusterStepSettings(view) {
49586
- if (view === null) return DEFAULT_CLUSTER_STEP_SETTINGS;
49587
- const flat = {};
49588
- const wanted = new Set(CLUSTER_STEP_SETTING_FIELDS.map((field) => clusterStepSettingKey(field.stepId, field.key)));
49589
- for (const section of view.sections) for (const entry of section.fields) {
49590
- if (!isHydratedField$2(entry) || typeof entry.key !== "string") continue;
49591
- if (wanted.has(entry.key)) flat[entry.key] = entry.value;
50037
+ function stepModelRunsOnFormat(models, modelId, format) {
50038
+ if (modelId !== void 0 && modelId !== null) {
50039
+ const named = models.find((m) => m.id === modelId);
50040
+ if (named !== void 0 && hasBuild(named, format)) return true;
49592
50041
  }
49593
- return readClusterStepSettings(flat);
49594
- }
49595
- /**
49596
- * Cluster knobs win over leftover per-device values. The cluster row is the
49597
- * authority; a device-local copy is a leftover of the old per-node editor.
49598
- */
49599
- function overlayClusterStepSettings(stepId, deviceSettings, cluster) {
49600
- const overlay = cluster[stepId];
49601
- if (overlay === void 0 || Object.keys(overlay).length === 0) return deviceSettings === void 0 ? void 0 : { ...deviceSettings };
49602
- if (deviceSettings === void 0) return { ...overlay };
49603
- return {
49604
- ...deviceSettings,
49605
- ...overlay
49606
- };
50042
+ return models.some((m) => m.legacy !== true && hasBuild(m, format));
49607
50043
  }
49608
50044
  var DETAIL_CROP_PADDING_KEY = "detailCropPaddingRatio";
49609
50045
  var DETAIL_CROP_SQUARE_KEY = "detailCropSquare";
@@ -50883,6 +51319,12 @@ Object.defineProperty(exports, "CLIP_STREAM_TRANSPORT_HEADER", {
50883
51319
  return CLIP_STREAM_TRANSPORT_HEADER;
50884
51320
  }
50885
51321
  });
51322
+ Object.defineProperty(exports, "CLUSTER_MODEL_SCOPED_STEPS", {
51323
+ enumerable: true,
51324
+ get: function() {
51325
+ return CLUSTER_MODEL_SCOPED_STEPS;
51326
+ }
51327
+ });
50886
51328
  Object.defineProperty(exports, "COCO_80_LABELS", {
50887
51329
  enumerable: true,
50888
51330
  get: function() {
@@ -50907,12 +51349,6 @@ Object.defineProperty(exports, "DEFAULT_AUDIO_ANALYZER_CONFIG", {
50907
51349
  return DEFAULT_AUDIO_ANALYZER_CONFIG;
50908
51350
  }
50909
51351
  });
50910
- Object.defineProperty(exports, "DEFAULT_CLUSTER_STEP_MODELS", {
50911
- enumerable: true,
50912
- get: function() {
50913
- return DEFAULT_CLUSTER_STEP_MODELS;
50914
- }
50915
- });
50916
51352
  Object.defineProperty(exports, "DEFAULT_CLUSTER_STEP_SETTINGS", {
50917
51353
  enumerable: true,
50918
51354
  get: function() {
@@ -51495,12 +51931,6 @@ Object.defineProperty(exports, "parseProfileBrokerId", {
51495
51931
  return parseProfileBrokerId;
51496
51932
  }
51497
51933
  });
51498
- Object.defineProperty(exports, "pickClusterStepModels", {
51499
- enumerable: true,
51500
- get: function() {
51501
- return pickClusterStepModels;
51502
- }
51503
- });
51504
51934
  Object.defineProperty(exports, "pickClusterStepSettings", {
51505
51935
  enumerable: true,
51506
51936
  get: function() {
@@ -51627,6 +52057,12 @@ Object.defineProperty(exports, "sleep", {
51627
52057
  return sleep;
51628
52058
  }
51629
52059
  });
52060
+ Object.defineProperty(exports, "stepModelRunsOnFormat", {
52061
+ enumerable: true,
52062
+ get: function() {
52063
+ return stepModelRunsOnFormat;
52064
+ }
52065
+ });
51630
52066
  Object.defineProperty(exports, "storageEvictableCapability", {
51631
52067
  enumerable: true,
51632
52068
  get: function() {