@camstack/addon-post-analysis 1.2.285 → 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 +8 -0
  2. package/dist/{dist-ITESpHou.js → clip-model-registry-CY0FGcpQ.js} +1483 -403
  3. package/dist/{dist-D2tXUMfE.mjs → clip-model-registry-D4mC2M7F.mjs} +1374 -390
  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-7oasHfhD.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-B6m75Rnz.mjs → hostInit-CelYj4QN.mjs} +2 -2
  11. package/dist/pipeline-analytics/index.js +5863 -5053
  12. package/dist/pipeline-analytics/index.mjs +4510 -3700
  13. package/dist/pipeline-analytics/remoteEntry.js +1 -1
  14. package/package.json +1 -1
  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-CjeM5Bph.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-BidXbeas.mjs +0 -26
@@ -5391,7 +5391,7 @@ var ZodIssueCode = {
5391
5391
  var ZodFirstPartyTypeKind;
5392
5392
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5393
5393
  //#endregion
5394
- //#region ../types/dist/sleep-BaRu0bS5.mjs
5394
+ //#region ../types/dist/sleep-BXv0ZcRa.mjs
5395
5395
  /**
5396
5396
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5397
5397
  * window to float samples (D455).
@@ -6176,6 +6176,40 @@ var BaseAddon = class {
6176
6176
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6177
6177
  return keys.size > 0 ? projectStore(raw, keys, node) : raw;
6178
6178
  }
6179
+ /**
6180
+ * Whether ONE global key of this addon's store was written, read three-way
6181
+ * (D651). For a question a hydrated view cannot answer: `getGlobalSettings`
6182
+ * reports `value ?? default`, so "the operator chose the default" and "nobody
6183
+ * chose" look the same, and a failed read looks like both. A `perNode` key is
6184
+ * not supported here: its stored name is scoped.
6185
+ */
6186
+ async readStoredGlobalKey(key) {
6187
+ const read = this._ctx?.settings?.readAddonStoreResult;
6188
+ if (read === void 0) return {
6189
+ kind: "unreadable",
6190
+ reason: "three-way-read-unavailable"
6191
+ };
6192
+ let result;
6193
+ try {
6194
+ result = await read.call(this._ctx?.settings);
6195
+ } catch (err) {
6196
+ return {
6197
+ kind: "unreadable",
6198
+ reason: "store-read-failed",
6199
+ error: err instanceof Error ? err.message : String(err)
6200
+ };
6201
+ }
6202
+ if (result.kind === "failed") return {
6203
+ kind: "unreadable",
6204
+ reason: "store-read-failed",
6205
+ error: result.error
6206
+ };
6207
+ if (result.kind === "missing" || !Object.prototype.hasOwnProperty.call(result.value, key)) return { kind: "absent" };
6208
+ return {
6209
+ kind: "present",
6210
+ value: result.value[key]
6211
+ };
6212
+ }
6179
6213
  async updateGlobalSettings(patch, nodeId) {
6180
6214
  const keys = this.perNodeKeys();
6181
6215
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
@@ -7471,7 +7505,7 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
7471
7505
  * can answer "may a rule actuate this?" without importing the schema barrel
7472
7506
  * (~144MB RSS per runner, D28).
7473
7507
  *
7474
- * Coverage: 87 device-scoped capabilities.
7508
+ * Coverage: 88 device-scoped capabilities.
7475
7509
  */
7476
7510
  var DEVICE_SCOPED_CAPS = new Set([
7477
7511
  "accessories",
@@ -7501,6 +7535,7 @@ var DEVICE_SCOPED_CAPS = new Set([
7501
7535
  "detection-pipeline",
7502
7536
  "device-admin-link",
7503
7537
  "device-discovery",
7538
+ "device-extension",
7504
7539
  "device-ops",
7505
7540
  "device-status",
7506
7541
  "doorbell",
@@ -10027,6 +10062,60 @@ var FailureCounters = class {
10027
10062
  this.counters.clear();
10028
10063
  }
10029
10064
  };
10065
+ var ClipModelMetaSchema = object({
10066
+ /** The paired text encoder's catalog id (the embedding-encoder's text catalog). */
10067
+ textModelId: string().min(1),
10068
+ /** Output dimension of BOTH towers. A vector of any other length is refused. */
10069
+ embeddingDim: number().int().positive(),
10070
+ /**
10071
+ * The `vector-store` index this model's vectors live in. ONE feature space
10072
+ * per index: two models share an index only when their vectors are ranked
10073
+ * against each other, which for CLIP means never across families. MobileCLIP
10074
+ * S1 and S2 share `object-clip` for history (separated by the row's
10075
+ * `modelId`); any other model gets its own.
10076
+ */
10077
+ vectorIndex: string().regex(/^object-clip(-[a-z0-9][a-z0-9-]*)?$/),
10078
+ /**
10079
+ * The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
10080
+ * must be unique per tokenizer: every model's siblings land in ONE flat
10081
+ * models directory, so two different tokenizers under the same name would
10082
+ * silently overwrite each other (whichever model downloaded last wins, and
10083
+ * the other one tokenises with the wrong vocabulary).
10084
+ */
10085
+ tokenizerFile: string().min(1),
10086
+ /** Token window the text graph takes (SigLIP2: 64; CLIP BPE: 77). */
10087
+ contextLength: number().int().positive(),
10088
+ /** Id the tokenizer pads with. */
10089
+ padId: number().int().nonnegative(),
10090
+ /**
10091
+ * The search cosine floor at `strictness: 'loose'` — calibrated per model,
10092
+ * because cosine bands are a property of the model: 0.2 keeps 96% of matched
10093
+ * COCO caption-image pairs on MobileCLIP S1 and 2.7% on SigLIP2.
10094
+ */
10095
+ searchMinScore: number().min(0).max(1)
10096
+ });
10097
+ var ClipSearchStrictnessSchema = _enum([
10098
+ "loose",
10099
+ "balanced",
10100
+ "strict"
10101
+ ]);
10102
+ var CLIP_STRICTNESS_FACTOR = {
10103
+ loose: 1,
10104
+ balanced: 1.25,
10105
+ strict: 1.5
10106
+ };
10107
+ /**
10108
+ * The cosine floor a search runs with.
10109
+ *
10110
+ * An explicit `minScore` is honoured verbatim: it is a number a caller chose,
10111
+ * and silently rescaling it would make the same URL mean different things on
10112
+ * two installs. Everything else is relative to the model.
10113
+ */
10114
+ function resolveClipSearchMinScore(meta, request) {
10115
+ if (request.minScore !== void 0) return request.minScore;
10116
+ const factor = CLIP_STRICTNESS_FACTOR[request.strictness ?? "loose"];
10117
+ return Math.min(1, Math.round(meta.searchMinScore * factor * 1e3) / 1e3);
10118
+ }
10030
10119
  var MODEL_FORMATS = [
10031
10120
  "onnx",
10032
10121
  "coreml",
@@ -10230,7 +10319,14 @@ var ModelCatalogEntrySchema = object({
10230
10319
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
10231
10320
  * labels already ARE the CamStack macros (Scrypted identity map).
10232
10321
  */
10233
- classMap: DetectionCatalogClassMapSchema.optional()
10322
+ classMap: DetectionCatalogClassMapSchema.optional(),
10323
+ /**
10324
+ * The model's CLIP feature-space contract (text encoder, dimension, vector
10325
+ * index, token window, search floor) — see `clip-model.ts`. Present ONLY on a
10326
+ * CLIP image encoder; its absence is what "not a CLIP model" means to the
10327
+ * embedding encoder and the semantic-search store (D649).
10328
+ */
10329
+ clip: ClipModelMetaSchema.optional()
10234
10330
  });
10235
10331
  var ConvertTargetSchema = discriminatedUnion("format", [object({
10236
10332
  format: literal("openvino"),
@@ -14680,6 +14776,13 @@ var LinkedDeviceSchema = object({
14680
14776
  features: array(string()),
14681
14777
  producesTrackedEvents: boolean().optional()
14682
14778
  });
14779
+ /**
14780
+ * The `linked-devices` extension slot's editable value (D648): the operator's
14781
+ * pick list, exactly what `_linkedDeviceIds` persists. Tree children are NOT
14782
+ * in it — they are always linked and are not a pick.
14783
+ */
14784
+ var LinkedDevicesSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
14785
+ DeviceType.Camera;
14683
14786
  /** One camera's resolved linked set, tagged with the camera it belongs to.
14684
14787
  * The batch answer needs the tag; the single-device answer already has it
14685
14788
  * from the input, which is why `getLinkedDevices` keeps the untagged shape. */
@@ -15205,11 +15308,128 @@ var EmbeddingResultSchema = object({
15205
15308
  embedding: array(number()),
15206
15309
  inferenceMs: number()
15207
15310
  });
15311
+ /** The two CLIP towers the encoder runs; a crash budget is kept per tower. */
15312
+ var EmbeddingTowerSchema = _enum(["image", "text"]);
15313
+ /**
15314
+ * A tower in the terminal `failed` state (D649, D6): it crashed or failed to
15315
+ * load `crashes` times within `windowMs`, and is refused by name until an
15316
+ * operator `resetFailedModels` or a model change — never on a timer.
15317
+ *
15318
+ * `nodeId` is the node whose tower failed. The state lives in THAT node's
15319
+ * encoder process (in memory — a runner respawn clears it), and one node's
15320
+ * answer says nothing about another's.
15321
+ */
15322
+ var EmbeddingFailedModelSchema = object({
15323
+ modelId: string(),
15324
+ tower: EmbeddingTowerSchema,
15325
+ nodeId: string(),
15326
+ crashes: number(),
15327
+ windowMs: number(),
15328
+ sinceMs: number(),
15329
+ lastReason: string()
15330
+ });
15331
+ /**
15332
+ * A model whose REQUIREMENTS can never be met on this node (D649 round 5):
15333
+ * an id the catalog does not know, a model URL answering 404/410, a declared
15334
+ * sibling (the tokenizer) that is not there. After `attempts` failed builds
15335
+ * it is terminally `requirements-failed`, refused by name until an operator
15336
+ * `resetFailedModels` or a model change — the same exits as a crashed tower.
15337
+ */
15338
+ var EmbeddingFailedRequirementSchema = object({
15339
+ modelId: string(),
15340
+ tower: EmbeddingTowerSchema,
15341
+ nodeId: string(),
15342
+ attempts: number(),
15343
+ sinceMs: number(),
15344
+ lastReason: string()
15345
+ });
15208
15346
  var EmbeddingInfoSchema = object({
15209
15347
  modelId: string(),
15210
15348
  embeddingDim: number(),
15211
- ready: boolean()
15212
- });
15349
+ ready: boolean(),
15350
+ /**
15351
+ * The node that answered. Absent only from an encoder older than D649's
15352
+ * crash budget — whose `failedModels` is then UNKNOWN (D315), never "none".
15353
+ */
15354
+ nodeId: string().optional(),
15355
+ /**
15356
+ * Towers in `failed` on the answering node, each row naming it. `undefined`
15357
+ * means the node could not say (pre-budget encoder); a node that has the
15358
+ * budget always answers an array, empty included.
15359
+ */
15360
+ failedModels: array(EmbeddingFailedModelSchema).optional(),
15361
+ /** Models terminally `requirements-failed` on the answering node; same reading as above. */
15362
+ failedRequirements: array(EmbeddingFailedRequirementSchema).optional()
15363
+ });
15364
+ /**
15365
+ * The THREE codes an encoder refusal can carry (D649, D6). Same shape as
15366
+ * `VECTOR_INDEX_DIM_CONFLICT`: the code rides in the MESSAGE, because an
15367
+ * Error's own properties do not survive the UDS/tRPC hop and its message does,
15368
+ * and both sides go through the helpers below — the encoder builds the
15369
+ * refusal, the live detail plane classifies on it to count refusals per
15370
+ * camera instead of logging one warning per track. The bracketed token
15371
+ * carries the code, the model, the tower and the node so a consumer never
15372
+ * parses prose.
15373
+ *
15374
+ * - `EMBEDDING_MODEL_FAILED`: the tower crashed / failed to load past the crash
15375
+ * budget — terminal until `resetFailedModels` or a model change.
15376
+ * - `EMBEDDING_REQUIREMENTS_UNAVAILABLE`: files or runtime not there right now
15377
+ * (a download or Python that failed, or the cooldown after one) — the next
15378
+ * request past the cooldown tries again.
15379
+ * - `EMBEDDING_REQUIREMENTS_FAILED`: the requirements can never be met (unknown
15380
+ * id, 404/410, missing sibling) and the bounded attempts are spent —
15381
+ * terminal, same exits as a crashed tower.
15382
+ */
15383
+ var EMBEDDING_MODEL_FAILED = "embedding-model-failed";
15384
+ var EMBEDDING_REQUIREMENTS_UNAVAILABLE = "embedding-requirements-unavailable";
15385
+ var EMBEDDING_REQUIREMENTS_FAILED = "embedding-requirements-failed";
15386
+ var EmbeddingRefusalCodeSchema = _enum([
15387
+ EMBEDDING_MODEL_FAILED,
15388
+ EMBEDDING_REQUIREMENTS_UNAVAILABLE,
15389
+ EMBEDDING_REQUIREMENTS_FAILED
15390
+ ]);
15391
+ function embeddingRefusalToken(code, on) {
15392
+ return `[${code} model=${on.modelId} tower=${on.tower} node=${on.nodeId}]`;
15393
+ }
15394
+ /** The encoder's refusal for a crashed tower, carrying {@link EMBEDDING_MODEL_FAILED}. */
15395
+ function embeddingModelFailedError(row) {
15396
+ 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.`);
15397
+ }
15398
+ /** The requirements refusal for THIS request, carrying {@link EMBEDDING_REQUIREMENTS_UNAVAILABLE}. */
15399
+ function embeddingRequirementsUnavailableError(on, reason) {
15400
+ return /* @__PURE__ */ new Error(`${embeddingRefusalToken(EMBEDDING_REQUIREMENTS_UNAVAILABLE, on)} ${on.modelId} (${on.tower} tower) on ${on.nodeId}: ${reason}`);
15401
+ }
15402
+ /** The terminal requirements refusal, carrying {@link EMBEDDING_REQUIREMENTS_FAILED}. */
15403
+ function embeddingRequirementsFailedError(row) {
15404
+ 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.`);
15405
+ }
15406
+ var EMBEDDING_REFUSAL_TOKEN = new RegExp(`\\[(${EMBEDDING_MODEL_FAILED}|${EMBEDDING_REQUIREMENTS_UNAVAILABLE}|${EMBEDDING_REQUIREMENTS_FAILED}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);
15407
+ /** The refusal `err` (possibly re-wrapped by a transport) carries, or `null` for any other error. */
15408
+ function embeddingRefusalOf(err) {
15409
+ const message = err instanceof Error ? err.message : String(err);
15410
+ const match = EMBEDDING_REFUSAL_TOKEN.exec(message);
15411
+ if (match === null) return null;
15412
+ const code = EmbeddingRefusalCodeSchema.safeParse(match[1]);
15413
+ const tower = EmbeddingTowerSchema.safeParse(match[3]);
15414
+ if (!code.success || !tower.success || match[2] === void 0 || match[4] === void 0) return null;
15415
+ return {
15416
+ code: code.data,
15417
+ modelId: match[2],
15418
+ tower: tower.data,
15419
+ nodeId: match[4]
15420
+ };
15421
+ }
15422
+ /**
15423
+ * ONE provider per node (`placement: any-node`), addressed like every global
15424
+ * collection: the codegen injects a `{ nodeId?, addonId? }` selector on the
15425
+ * void methods and lifts a top-level `nodeId` off the object ones. A call
15426
+ * that names no node is answered by the HUB's provider — never by a merge
15427
+ * across nodes, because no global collection fans out across nodes (only the
15428
+ * providers of one node are `concatCollection`-fanned). So a fleet view of
15429
+ * `failedModels` is one `getInfo({ nodeId })` per node, and every answer
15430
+ * names the node it came from (D649 round 4); a node that cannot be asked is
15431
+ * UNKNOWN to the reader, never "no failures" (D315).
15432
+ */
15213
15433
  var embeddingEncoderCapability = {
15214
15434
  name: "embedding-encoder",
15215
15435
  scope: "system",
@@ -15228,8 +15448,30 @@ var embeddingEncoderCapability = {
15228
15448
  width: number(),
15229
15449
  height: number()
15230
15450
  }), EmbeddingResultSchema, { auth: "admin" }),
15231
- encodeText: method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }),
15232
- getInfo: method(_void(), EmbeddingInfoSchema, { auth: "admin" })
15451
+ /**
15452
+ * `modelId` (a CLIP IMAGE model id, whose catalog `clip.textModelId` names
15453
+ * the text tower) encodes in that model's space; absent, the cluster row's
15454
+ * `clip-embedding` model — the space every writer is in (D649).
15455
+ */
15456
+ encodeText: method(object({
15457
+ text: string(),
15458
+ modelId: string().min(1).optional()
15459
+ }), EmbeddingResultSchema, { auth: "admin" }),
15460
+ /** Answers for ONE node — the `nodeId` selector's, else the hub's. */
15461
+ getInfo: method(_void(), EmbeddingInfoSchema, { auth: "admin" }),
15462
+ /**
15463
+ * The operator's explicit clear of the `failed` state (one model, or all)
15464
+ * on ONE node — pass `nodeId` for an agent; the result names the node it
15465
+ * cleared. The only way out besides a model change: a crashing tower is
15466
+ * not retried on a timer.
15467
+ */
15468
+ resetFailedModels: method(object({ modelId: string().min(1).optional() }), object({
15469
+ cleared: array(string()),
15470
+ nodeId: string()
15471
+ }), {
15472
+ kind: "mutation",
15473
+ auth: "admin"
15474
+ })
15233
15475
  }
15234
15476
  };
15235
15477
  /**
@@ -18758,7 +19000,12 @@ var NcMediaPolicySchema = object({
18758
19000
  * the degrade engine, which drops the video and keeps the still.
18759
19001
  */
18760
19002
  clip: boolean().optional(),
18761
- /** Seconds of footage BEFORE / AFTER the event instant. Defaults 3 / 7. */
19003
+ /**
19004
+ * Seconds of footage BEFORE / AFTER the event instant. Absent =
19005
+ * {@link NC_CLIP_PRE_ROLL_DEFAULT_SEC} / {@link NC_CLIP_POST_ROLL_DEFAULT_SEC}
19006
+ * (4 / 6), resolved by the Notification Center at dispatch — deliberately not
19007
+ * a Zod default, so a rule that never chose keeps following the hub's.
19008
+ */
18762
19009
  clipPreRollSec: number().int().min(0).max(30).optional(),
18763
19010
  clipPostRollSec: number().int().min(0).max(30).optional(),
18764
19011
  /**
@@ -20841,6 +21088,202 @@ var OauthIntegrationDescriptorSchema = object({
20841
21088
  });
20842
21089
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
20843
21090
  /**
21091
+ * A model choice has a SCOPE, and a scope change has a workflow.
21092
+ *
21093
+ * ## The two scopes
21094
+ *
21095
+ * Almost every pipeline step's model is a **node** question: which build runs
21096
+ * fastest on THIS accelerator. Two nodes may legitimately answer differently —
21097
+ * a Coral runs the tflite SSD, a Mac runs the coreml YOLO — because the answers
21098
+ * are compared against nothing. They produce boxes, and a box is a box.
21099
+ *
21100
+ * Two steps are not like that. `face-embedding` and `clip-embedding` produce
21101
+ * **vectors that land in ONE shared index** (`identity_samples`,
21102
+ * `vec_object_clip`) and are ranked against each other by cosine similarity.
21103
+ * Cosine similarity between two encoders is not a weak signal, it is a
21104
+ * meaningless number — and nothing inside a vector can tell you it happened.
21105
+ * So for those two steps the model is a **cluster** question with exactly one
21106
+ * answer, stored in exactly one row.
21107
+ *
21108
+ * That is the same argument [D52](../../../../docs/decisions/adr-0052.md) makes
21109
+ * for the crop convention (`detail-crop.ts`), one level up: the crop decides
21110
+ * WHAT pixels the encoder sees, this decides WHICH encoder sees them. Both are
21111
+ * cluster-wide for the same reason and neither may become per-node.
21112
+ *
21113
+ * ## Why the registry lives here and not in the step catalog
21114
+ *
21115
+ * The scope itself is declared on the step, in
21116
+ * `detection-pipeline/registry/step-definitions.ts` (`StepDefinition.modelScope`)
21117
+ * — that is where a new step declares what kind of choice its model is. But the
21118
+ * catalog lives inside `addon-pipeline`, and three packages that must NOT
21119
+ * import an addon need to know the set: the orchestrator (which renders and
21120
+ * stores the row), post-analysis (which pins the row for a re-embed pass) and
21121
+ * admin-ui (which mirrors it). So the set is mirrored here, and
21122
+ * `scripts/check-cluster-model-scope.ts` fails the build when the two disagree.
21123
+ * A hand-copied key that stops matching is exactly how a setting silently stops
21124
+ * arriving while both sides still look correct.
21125
+ *
21126
+ * ## The defaults ARE today's behaviour
21127
+ *
21128
+ * {@link DEFAULT_CLUSTER_STEP_MODELS} reproduces the catalog `defaultModelId`
21129
+ * of both steps. Declaring the scope therefore changes nothing on the day it
21130
+ * ships: the cluster row starts out saying what every node was already doing.
21131
+ * Changing it is legitimate — that is what the knob is for — but it invalidates
21132
+ * the stored vectors of that surface, and must be followed by a re-embed pass
21133
+ * (`face-reembed-pass.ts`, `embedding-rebuild.ts`).
21134
+ */
21135
+ /**
21136
+ * Why the orchestrator cannot say which model the operator chose for a
21137
+ * cluster-scoped step (D651).
21138
+ */
21139
+ var CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS = [
21140
+ "owner-not-ready",
21141
+ "store-read-failed",
21142
+ "three-way-read-unavailable",
21143
+ "invalid-stored",
21144
+ "not-cluster-scoped"
21145
+ ];
21146
+ /**
21147
+ * The cluster-scoped steps. Mirrored from the catalog's `modelScope: 'cluster'`
21148
+ * declarations and guarded by `scripts/check-cluster-model-scope.ts`.
21149
+ */
21150
+ var CLUSTER_MODEL_SCOPED_STEPS = [{
21151
+ stepId: "face-embedding",
21152
+ label: "Face recognition model",
21153
+ defaultModelId: "auraface-r100",
21154
+ indexName: "the enrolled face gallery",
21155
+ options: [
21156
+ {
21157
+ id: "auraface-r100",
21158
+ label: "AuraFace R100"
21159
+ },
21160
+ {
21161
+ id: "arcface-r100",
21162
+ label: "ArcFace (ResNet34)"
21163
+ },
21164
+ {
21165
+ id: "inception-resnet-v1",
21166
+ label: "Inception ResNet V1"
21167
+ }
21168
+ ]
21169
+ }, {
21170
+ stepId: "clip-embedding",
21171
+ label: "Semantic search model",
21172
+ defaultModelId: "mobileclip-s1",
21173
+ indexName: "the object semantic-search index",
21174
+ options: [
21175
+ {
21176
+ id: "mobileclip-s1",
21177
+ label: "MobileCLIP S1"
21178
+ },
21179
+ {
21180
+ id: "mobileclip-s2",
21181
+ label: "MobileCLIP S2"
21182
+ },
21183
+ {
21184
+ id: "siglip2-b16-224",
21185
+ label: "SigLIP2 B/16 (Apache-2.0)"
21186
+ }
21187
+ ]
21188
+ }];
21189
+ /**
21190
+ * The settings key holding one step's cluster model choice.
21191
+ *
21192
+ * Step-qualified so the keys stay unique across the addon's whole schema, which
21193
+ * is what lets {@link pickClusterStepModels} walk every section instead of
21194
+ * trusting the section id.
21195
+ */
21196
+ function clusterModelSettingKey(stepId) {
21197
+ return `clusterModel:${stepId}`;
21198
+ }
21199
+ /** The cluster row when nobody has configured one — today's catalog defaults. */
21200
+ var DEFAULT_CLUSTER_STEP_MODELS = Object.freeze(Object.fromEntries(CLUSTER_MODEL_SCOPED_STEPS.map((s) => [s.stepId, s.defaultModelId])));
21201
+ function interpretStoredClusterModel(raw) {
21202
+ if (raw === void 0 || raw === null || raw === "") return { kind: "absent" };
21203
+ if (typeof raw === "string") return {
21204
+ kind: "chosen",
21205
+ modelId: raw
21206
+ };
21207
+ return {
21208
+ kind: "invalid",
21209
+ value: raw
21210
+ };
21211
+ }
21212
+ /**
21213
+ * Narrow a FLAT settings record to the cluster row.
21214
+ *
21215
+ * Per-FIELD fallback, deliberately (same rule as `readDetailCropConvention`): a
21216
+ * junk face model must not also discard a valid clip model. An `absent` or
21217
+ * `invalid` value ({@link interpretStoredClusterModel}) resolves to the step's
21218
+ * catalog default — never to a blank id, because a blank id downstream becomes
21219
+ * "substitute the format default", which is precisely the substitution this
21220
+ * scope exists to forbid.
21221
+ */
21222
+ function readClusterStepModels(config) {
21223
+ const out = {};
21224
+ for (const step of CLUSTER_MODEL_SCOPED_STEPS) {
21225
+ const read = interpretStoredClusterModel(config[clusterModelSettingKey(step.stepId)]);
21226
+ out[step.stepId] = read.kind === "chosen" ? read.modelId : step.defaultModelId;
21227
+ }
21228
+ return out;
21229
+ }
21230
+ function isHydratedField$2(entry) {
21231
+ return typeof entry === "object" && entry !== null && "key" in entry;
21232
+ }
21233
+ /**
21234
+ * Extract the cluster row from an `addon-settings.getGlobalSettings` payload.
21235
+ *
21236
+ * Walks EVERY section rather than looking inside {@link CLUSTER_MODEL_SECTION_ID}
21237
+ * alone: the keys are unique across the addon's schema, and a section rename
21238
+ * must not silently revert the whole cluster to the defaults. A `null` payload
21239
+ * (addon mid-boot) is the defaults.
21240
+ */
21241
+ function pickClusterStepModels(view) {
21242
+ if (view === null) return DEFAULT_CLUSTER_STEP_MODELS;
21243
+ return readClusterStepModels(flattenHydratedView(view, clusterModelKeys()));
21244
+ }
21245
+ function clusterModelKeys() {
21246
+ return new Set(CLUSTER_MODEL_SCOPED_STEPS.map((s) => clusterModelSettingKey(s.stepId)));
21247
+ }
21248
+ /** The `wanted` keys of a hydrated view as one flat record, every section walked. */
21249
+ function flattenHydratedView(view, wanted) {
21250
+ const flat = {};
21251
+ for (const section of view.sections) for (const entry of section.fields) {
21252
+ if (!isHydratedField$2(entry) || typeof entry.key !== "string") continue;
21253
+ if (wanted.has(entry.key)) flat[entry.key] = entry.value;
21254
+ }
21255
+ return flat;
21256
+ }
21257
+ var CLUSTER_STEP_SETTING_FIELDS = [{
21258
+ stepId: "face-embedding",
21259
+ key: "minLandmarkFaceSize",
21260
+ label: "Min face size for recognition (detection px)",
21261
+ 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.",
21262
+ type: "slider",
21263
+ min: 0,
21264
+ max: 64,
21265
+ step: 2,
21266
+ default: 24
21267
+ }];
21268
+ function clusterStepSettingKey(stepId, fieldKey) {
21269
+ return `clusterStepSetting:${stepId}:${fieldKey}`;
21270
+ }
21271
+ var ClusterSettingNumberSchema = number().finite();
21272
+ function readClusterStepSettings(config) {
21273
+ const out = {};
21274
+ for (const field of CLUSTER_STEP_SETTING_FIELDS) {
21275
+ const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
21276
+ const value = parsed.success ? parsed.data : field.default;
21277
+ const existing = out[field.stepId] ?? {};
21278
+ out[field.stepId] = {
21279
+ ...existing,
21280
+ [field.key]: value
21281
+ };
21282
+ }
21283
+ return out;
21284
+ }
21285
+ readClusterStepSettings({});
21286
+ /**
20844
21287
  * pipeline-analytics — device-scoped wrapper cap. Refines raw
20845
21288
  * per-frame detections emitted by the pipeline runner into tracked
20846
21289
  * objects, per-kind event collections (motion / object / audio), and
@@ -21656,7 +22099,8 @@ var MediaFileKindEnum = _enum([
21656
22099
  "thumbnailSmall",
21657
22100
  "confirmationCrop",
21658
22101
  "debugCrop",
21659
- "sceneFrame"
22102
+ "sceneFrame",
22103
+ "lastSceneFrame"
21660
22104
  ]);
21661
22105
  /**
21662
22106
  * One media row ON THE WIRE: what it is, how big it is, and WHERE ITS BYTES
@@ -22208,7 +22652,23 @@ var SearchObjectEventsInput = object({
22208
22652
  until: number().optional(),
22209
22653
  classFilter: string().optional(),
22210
22654
  limit: number().default(50),
22211
- minScore: number().min(0).max(1).default(.2)
22655
+ /**
22656
+ * An ABSOLUTE cosine floor. Optional since D649: a floor is a property of the
22657
+ * model (0.2 kept 96% of matched pairs on MobileCLIP S1 and 2.7% on SigLIP2),
22658
+ * so an absent one resolves to the searched model's own `searchMinScore`
22659
+ * scaled by `strictness`. A number sent here is honoured verbatim.
22660
+ */
22661
+ minScore: number().min(0).max(1).optional(),
22662
+ /** Model-relative floor — see `resolveClipSearchMinScore`. Default `loose`. */
22663
+ strictness: ClipSearchStrictnessSchema.optional(),
22664
+ /**
22665
+ * Search THIS CLIP model's index instead of the cluster row's. Every index a
22666
+ * model ever wrote stays searchable until it is wiped (the MobileCLIP index
22667
+ * through a SigLIP2 cutover and its rollback window). An id with no CLIP
22668
+ * metadata is refused; an id other than the cluster row's is ADMIN-only
22669
+ * (`model-override-requires-admin`).
22670
+ */
22671
+ modelId: string().min(1).optional()
22212
22672
  });
22213
22673
  var TrackCascadeCountsSchema = object({
22214
22674
  /** Persisted track roots deleted (authoritative). */
@@ -22343,7 +22803,41 @@ var RebuildObjectEmbeddingsInput = object({
22343
22803
  * comparable, so wiping and rebuilding is the only way to be sure every vector
22344
22804
  * means the same thing.
22345
22805
  */
22346
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
22806
+ var WipeObjectEmbeddingsResultSchema = object({
22807
+ deleted: number(),
22808
+ /**
22809
+ * CLIP indexes that could NOT be emptied (unreachable, or refused at their
22810
+ * dimension) — not a clean slate. Additive and optional (D649).
22811
+ */
22812
+ failedIndexes: array(string()).optional()
22813
+ });
22814
+ /**
22815
+ * Why a rebuild did not start, BY NAME — ONE vocabulary for both gates in front
22816
+ * of a pass (D649 over D651). A bare `started: false` read the same for "the
22817
+ * stores are booting" and "the cluster row names a model with no CLIP
22818
+ * metadata", which need different fixes.
22819
+ * - `stores-unavailable` — the analytics stores or the API are not up yet.
22820
+ * - the owner's confirmation of the cluster model (D651, `ClusterPinConfirmer`):
22821
+ * a pass that rewrites an index needs two agreeing reads of the OWNER's
22822
+ * answer (`pipelineOrchestrator.getClusterModelChoice`) — a pass that cannot
22823
+ * name its model does not run (D54):
22824
+ * - the owner's own `unreadable` reasons (`owner-not-ready`,
22825
+ * `store-read-failed`, `three-way-read-unavailable`, `invalid-stored`,
22826
+ * `not-cluster-scoped`);
22827
+ * - `method-unavailable` — the orchestrator predates the method;
22828
+ * - `read-failed` — the call failed or answered something unparseable;
22829
+ * - `reads-disagree` — the two reads named different choices.
22830
+ * - `not-a-clip-model` — the CONFIRMED id has no CLIP metadata, so there is no
22831
+ * index to fill and no dimension to check against (D649).
22832
+ */
22833
+ var RebuildObjectEmbeddingsRefusalSchema = _enum([
22834
+ "stores-unavailable",
22835
+ ...CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS,
22836
+ "method-unavailable",
22837
+ "read-failed",
22838
+ "reads-disagree",
22839
+ "not-a-clip-model"
22840
+ ]);
22347
22841
  /**
22348
22842
  * Acknowledgement that a rebuild STARTED.
22349
22843
  *
@@ -22356,7 +22850,12 @@ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
22356
22850
  var RebuildObjectEmbeddingsResultSchema = object({
22357
22851
  started: boolean(),
22358
22852
  /** True when a pass was already running; the new request is ignored. */
22359
- alreadyRunning: boolean()
22853
+ alreadyRunning: boolean(),
22854
+ /** Present when the pass refused to start — see `RebuildObjectEmbeddingsRefusalSchema`. */
22855
+ refusal: RebuildObjectEmbeddingsRefusalSchema.optional(),
22856
+ /** The CLIP model the pass pinned, and the index it fills (when it started). */
22857
+ modelId: string().optional(),
22858
+ index: string().optional()
22360
22859
  });
22361
22860
  var RebuildStatusSchema = object({
22362
22861
  running: boolean(),
@@ -22390,7 +22889,11 @@ var RebuildStatusSchema = object({
22390
22889
  startedAtMs: number().nullable(),
22391
22890
  finishedAtMs: number().nullable(),
22392
22891
  /** Present when the pass ended by throwing. */
22393
- error: string().nullable()
22892
+ error: string().nullable(),
22893
+ /** The CLIP model the current / last pass pinned (D54), `null` before any. */
22894
+ modelId: string().nullable(),
22895
+ /** The index that pass fills — `ClipModelMeta.vectorIndex` of `modelId` (D649). */
22896
+ index: string().nullable()
22394
22897
  });
22395
22898
  /**
22396
22899
  * Acknowledgement that a debug-media reclaim STARTED.
@@ -23349,7 +23852,7 @@ var pipelineAnalyticsCapability = {
23349
23852
  * ObjectEvents by trackId. Returns up to `limit` events scored ≥
23350
23853
  * `minScore`, sorted descending by score.
23351
23854
  */
23352
- searchObjectEvents: method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()),
23855
+ searchObjectEvents: method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly(), { caller: "required" }),
23353
23856
  wipeObjectEmbeddings: method(object({}), WipeObjectEmbeddingsResultSchema, {
23354
23857
  kind: "mutation",
23355
23858
  auth: "admin"
@@ -24446,6 +24949,17 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
24446
24949
  hubHostnameOverride: string().optional()
24447
24950
  })]).describe("Per-camera frame-source mode for the runner (P2c)");
24448
24951
  /**
24952
+ * What ONE step runs with on ONE roster device for THIS camera (D650): the
24953
+ * device's per-(node,device) base with the camera's override for that device
24954
+ * on top — the same `override ?? base` merge the orchestrator applies to the
24955
+ * elected device (`applyDeviceProvisioning`). Absent `modelId` ⇒ the executor
24956
+ * resolves the device format's default, exactly as on the elected device.
24957
+ */
24958
+ var RunnerJumpStepProvisioningSchema = object({
24959
+ modelId: string().optional(),
24960
+ settings: record(string(), unknown()).optional()
24961
+ });
24962
+ /**
24449
24963
  * One ENABLED inference device on the runner's node, as the step-tree
24450
24964
  * device-jump resolver sees it (phase 1). The orchestrator populates this
24451
24965
  * roster on the attach payload whenever the camera is elected onto a specific
@@ -24457,7 +24971,16 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
24457
24971
  var RunnerInferenceDeviceSchema = object({
24458
24972
  deviceKey: string(),
24459
24973
  weight: number().positive().default(1),
24460
- maxSessions: number().int().positive().nullable().default(null)
24974
+ maxSessions: number().int().positive().nullable().default(null),
24975
+ /**
24976
+ * Per-step provisioning for this camera on THIS device (D650), keyed by step
24977
+ * id. A step the runner jumps here runs with these fields, never with the
24978
+ * elected device's: `modelId` / `settings` are REPLACED on the jumped subtree
24979
+ * (a step absent from the map runs with neither — the target format default).
24980
+ * Absent field ⇒ an orchestrator that predates D650: the jumped step keeps
24981
+ * the elected device's provisioning, as before.
24982
+ */
24983
+ steps: record(string(), RunnerJumpStepProvisioningSchema).optional()
24461
24984
  });
24462
24985
  /**
24463
24986
  * Camera assignment payload sent by `addon-pipeline-orchestrator` to a
@@ -25332,6 +25855,28 @@ var NodeInferenceDeviceSchema = object({
25332
25855
  */
25333
25856
  exclusion: InferenceDeviceExclusionReasonSchema.nullable()
25334
25857
  });
25858
+ /**
25859
+ * The operator's model choice for one cluster-scoped step, answered by the
25860
+ * addon that OWNS the `clusterModel:*` settings (D651). Three answers, never
25861
+ * folded: a written choice, a key nobody wrote (the cluster runs the default
25862
+ * BY ABSENCE), or no answer. A caller that rewrites an index acts only on the
25863
+ * first two, read twice and agreeing.
25864
+ */
25865
+ var ClusterModelChoiceSchema = discriminatedUnion("kind", [
25866
+ object({
25867
+ kind: literal("stored"),
25868
+ modelId: string()
25869
+ }),
25870
+ object({
25871
+ kind: literal("absent"),
25872
+ defaultModelId: string()
25873
+ }),
25874
+ object({
25875
+ kind: literal("unreadable"),
25876
+ reason: _enum(CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS),
25877
+ error: string().optional()
25878
+ })
25879
+ ]);
25335
25880
  var NodeInferenceDevicesSchema = object({
25336
25881
  nodeId: string(),
25337
25882
  /** False when the node's platform-probe was unreachable (no live device set). */
@@ -25359,10 +25904,17 @@ method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
25359
25904
  }), object({ success: literal(true) }), {
25360
25905
  kind: "mutation",
25361
25906
  auth: "admin"
25362
- }), method(object({ deviceId: number() }), object({ deviceKey: string().nullable() })), method(_void(), object({ migrated: number() }), {
25907
+ }), method(object({ deviceId: number() }), object({ deviceKey: string().nullable() })), method(_void(), object({
25908
+ migrated: number(),
25909
+ skipped: array(object({
25910
+ deviceId: number(),
25911
+ targetNodeId: string(),
25912
+ reason: string()
25913
+ })).default([])
25914
+ }), {
25363
25915
  kind: "mutation",
25364
25916
  auth: "admin"
25365
- }), 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({
25917
+ }), 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({
25366
25918
  nodeId: string(),
25367
25919
  capName: string(),
25368
25920
  addonId: string()
@@ -27078,6 +27630,20 @@ var VectorScanResultSchema = object({
27078
27630
  */
27079
27631
  nextCursor: number().int().nonnegative().nullable()
27080
27632
  });
27633
+ /**
27634
+ * The ONE error code for "this index exists at another dimension; refusing to
27635
+ * redeclare it" (D649). It rides in the MESSAGE — an Error's own properties do
27636
+ * not survive the UDS/tRPC hop, its message does — and both sides go through
27637
+ * the helpers below, never a copied phrase: a consumer that must tell "this
27638
+ * index can never hold my vectors" from "the provider is unreachable" (a
27639
+ * delete counts the first as nothing-to-delete and the second as still
27640
+ * present) otherwise breaks silently the day the wording changes.
27641
+ */
27642
+ var VECTOR_INDEX_DIM_CONFLICT = "vector-index-dim-conflict";
27643
+ /** True when `err` (possibly re-wrapped by a transport) is that refusal. */
27644
+ function isVectorIndexDimConflict(err) {
27645
+ return (err instanceof Error ? err.message : String(err)).includes(`[${VECTOR_INDEX_DIM_CONFLICT}]`);
27646
+ }
27081
27647
  var VectorStatsInputSchema = object({ index: string() });
27082
27648
  var VectorStatsResultSchema = object({
27083
27649
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -27737,6 +28303,349 @@ DeviceType.Camera, method(object({
27737
28303
  auth: "protected"
27738
28304
  });
27739
28305
  /**
28306
+ * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
28307
+ * valutatore puro del suo FRONTE.
28308
+ *
28309
+ * Viveva dentro il builtin virtual-doorbell
28310
+ * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
28311
+ * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
28312
+ * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
28313
+ * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
28314
+ * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
28315
+ * SPOSTA qui e il doorbell la ri-esporta.
28316
+ *
28317
+ * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
28318
+ * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
28319
+ * regola" (e include `presence`, `cover`, `alarm-panel`), questa a "qual è il
28320
+ * booleano il cui FRONTE conta". Vocabolari deliberatamente diversi.
28321
+ */
28322
+ /**
28323
+ * Known binary / switch source caps → the boolean slice field whose
28324
+ * false→true rise counts as ACTIVE. Every entry is "fire on active".
28325
+ * Sensors whose "active" reading is not a plain boolean (presence's string
28326
+ * state, connectivity's connected flag) are deliberately excluded — a
28327
+ * reconnect is not a doorbell press, and it is not a recording either.
28328
+ */
28329
+ var SOURCE_CAP_ACTIVE_FIELD = {
28330
+ contact: "entryOpen",
28331
+ binary: "on",
28332
+ switch: "on",
28333
+ motion: "detected",
28334
+ flood: "flooded",
28335
+ gas: "detected",
28336
+ smoke: "detected",
28337
+ "carbon-monoxide": "detected",
28338
+ vibration: "detected",
28339
+ tamper: "tampered"
28340
+ };
28341
+ /**
28342
+ * The same caps → the slice field carrying the ms-epoch timestamp of the
28343
+ * last transition. Every source cap MUST appear here (guarded by a spec):
28344
+ * without a transition timestamp the evaluator cannot tell a genuine rise
28345
+ * from a boot-time hydration when the FIRST slice it ever sees is already
28346
+ * active, and errs towards silence — swallowing the rise.
28347
+ *
28348
+ * These timestamps are UPSTREAM ones, not ingest ones: the Home Assistant
28349
+ * provider derives them from `state.last_changed`, so they survive our own
28350
+ * restarts and correctly read as "hours ago" for a state that has been
28351
+ * active for hours. `motion` names its rise timestamp `lastDetectedAt`.
28352
+ */
28353
+ var SOURCE_CAP_CHANGED_AT_FIELD = {
28354
+ contact: "lastChangedAt",
28355
+ binary: "lastChangedAt",
28356
+ switch: "lastChangedAt",
28357
+ motion: "lastDetectedAt",
28358
+ flood: "lastChangedAt",
28359
+ gas: "lastChangedAt",
28360
+ smoke: "lastChangedAt",
28361
+ "carbon-monoxide": "lastChangedAt",
28362
+ vibration: "lastChangedAt",
28363
+ tamper: "lastChangedAt"
28364
+ };
28365
+ /** Cap names whose presence in a device's bindings qualify it as a source. */
28366
+ var SOURCE_CAPS = Object.keys(SOURCE_CAP_ACTIVE_FIELD);
28367
+ /** True when a cap is a recognised binary/switch source. */
28368
+ function isSourceCap(capName) {
28369
+ return Object.prototype.hasOwnProperty.call(SOURCE_CAP_ACTIVE_FIELD, capName);
28370
+ }
28371
+ /** Extract the "active" boolean a source cap's slice carries, or null when
28372
+ * the cap is unknown or the field is missing / non-boolean. */
28373
+ function sliceActiveValue(capName, slice) {
28374
+ const field = SOURCE_CAP_ACTIVE_FIELD[capName];
28375
+ if (field === void 0) return null;
28376
+ const raw = slice[field];
28377
+ return typeof raw === "boolean" ? raw : null;
28378
+ }
28379
+ /** Ms-epoch transition timestamp a source cap's slice carries, or null when
28380
+ * it is absent, non-numeric or the zero "never observed" sentinel. */
28381
+ function sliceChangedAt(capName, slice) {
28382
+ const field = SOURCE_CAP_CHANGED_AT_FIELD[capName];
28383
+ if (field === void 0) return null;
28384
+ const raw = slice[field];
28385
+ if (typeof raw !== "number" || !Number.isFinite(raw) || raw <= 0) return null;
28386
+ return raw;
28387
+ }
28388
+ /**
28389
+ * How recent a source's own transition timestamp must be for a FIRST
28390
+ * sighting that is already active to count as a genuine rise rather than a
28391
+ * hydration of long-standing state.
28392
+ */
28393
+ var DEFAULT_FIRST_SIGHTING_FRESHNESS_MS = 3e4;
28394
+ /**
28395
+ * IL fronte. Puro: nessun orologio proprio, nessuna memoria — il chiamante
28396
+ * porta `prior`, `nowMs` e il proprio `startedAtMs`.
28397
+ *
28398
+ * Il caso della PRIMA slice già attiva è trattato esplicitamente e vale come
28399
+ * fronte solo se il timestamp UPSTREAM della transizione è posteriore a
28400
+ * `startedAtMs` **e** entro `firstSightingFreshnessMs`. Entrambe le metà
28401
+ * servono: la sola freschezza scatterebbe su un'idratazione al boot di uno
28402
+ * stato flippato pochi secondi prima del riavvio, e il solo "dopo che abbiamo
28403
+ * iniziato" scatterebbe, su un processo di lunga vita, per una sorgente
28404
+ * adottata oggi il cui stato è cambiato ieri. Il caso ambiguo ERRA VERSO IL
28405
+ * SILENZIO e lo dichiara (`baseline-seeded-stale-active`).
28406
+ */
28407
+ function evaluateSensorEdge(input) {
28408
+ const value = sliceActiveValue(input.capName, input.slice);
28409
+ if (value === null) return {
28410
+ edge: "none",
28411
+ value: null,
28412
+ reason: isSourceCap(input.capName) ? "non-boolean-value" : "unknown-cap"
28413
+ };
28414
+ if (input.prior === void 0) {
28415
+ if (!value) return {
28416
+ edge: "none",
28417
+ value,
28418
+ reason: "baseline-seeded-inactive"
28419
+ };
28420
+ const changedAt = sliceChangedAt(input.capName, input.slice);
28421
+ const floor = Math.max(input.startedAtMs, input.nowMs - input.firstSightingFreshnessMs);
28422
+ if (changedAt === null || changedAt < floor) return {
28423
+ edge: "none",
28424
+ value,
28425
+ reason: "baseline-seeded-stale-active"
28426
+ };
28427
+ return {
28428
+ edge: "rising",
28429
+ value: true
28430
+ };
28431
+ }
28432
+ if (input.prior === value) return {
28433
+ edge: "none",
28434
+ value,
28435
+ reason: "no-change"
28436
+ };
28437
+ if (!value) return {
28438
+ edge: "none",
28439
+ value,
28440
+ reason: "falling-edge"
28441
+ };
28442
+ return {
28443
+ edge: "rising",
28444
+ value: true
28445
+ };
28446
+ }
28447
+ /**
28448
+ * Doorbell button cap. Two kinds of providers coexist behind this cap
28449
+ * name (same pattern as `snapshot`):
28450
+ *
28451
+ * - **Native** providers: registered per-device by device-driver
28452
+ * addons via `ctx.registerNativeCap` — either on a
28453
+ * `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
28454
+ * or directly on the camera (Reolink registers at camera level).
28455
+ * Emits an `onPressed` event every time the firmware pushes a
28456
+ * ring; status tracks the last press and a pressCount since start
28457
+ * (diagnostic).
28458
+ *
28459
+ * - **Wrapper** provider: the `virtual-doorbell` system builtin
28460
+ * (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
28461
+ * device (contact / switch / event-emitter …) into a doorbell for
28462
+ * a camera. `defaultActive: false` — the operator explicitly binds
28463
+ * it per camera in the device-bindings UI, then picks the source
28464
+ * device + trigger in the per-device settings.
28465
+ *
28466
+ * The DeviceEventPropagator re-emits `onPressed` on the camera parent
28467
+ * — subscribers listening at the camera level receive ring events
28468
+ * with `via[]` populated. No code on the parent needed.
28469
+ */
28470
+ var DoorbellStatusSchema = object({
28471
+ /** Ms epoch of the last press. null = never observed since this provider started. */
28472
+ lastPressedAt: number().nullable(),
28473
+ /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
28474
+ pressCountSinceStart: number()
28475
+ });
28476
+ var DoorbellPressEventSchema = object({
28477
+ deviceId: number(),
28478
+ timestamp: number()
28479
+ });
28480
+ /**
28481
+ * The `doorbell-source` extension slot's editable value (D648): the camera's
28482
+ * virtual-doorbell trigger devices, exactly what the wrapper's
28483
+ * `doorbellSources` persists (as `{ deviceId }` records).
28484
+ */
28485
+ var DoorbellSourceSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
28486
+ /**
28487
+ * The `doorbell-source` slot — which devices ring this camera's VIRTUAL
28488
+ * doorbell, owned by the `virtual-doorbell` wrapper over its
28489
+ * `doorbellSources` store (D648). A source rings when one of its
28490
+ * `SOURCE_CAPS` rises. Whether the wrapper is bound to the camera at all is a
28491
+ * different authority (`deviceManager.setWrapperActive`, D62) — the slot
28492
+ * reports it, it never writes it.
28493
+ */
28494
+ var DOORBELL_SOURCE_SLOT = {
28495
+ id: "doorbell-source",
28496
+ label: "Doorbell trigger devices",
28497
+ 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.",
28498
+ shape: "association",
28499
+ hostDeviceTypes: [DeviceType.Camera],
28500
+ sourceCaps: SOURCE_CAPS,
28501
+ cardinality: "many",
28502
+ value: DoorbellSourceSlotValueSchema
28503
+ };
28504
+ var doorbellCapability = {
28505
+ name: "doorbell",
28506
+ scope: "device",
28507
+ deviceNative: true,
28508
+ mode: "singleton",
28509
+ kind: "wrapper",
28510
+ defaultActive: false,
28511
+ deviceTypes: [DeviceType.Button, DeviceType.Camera],
28512
+ exposesDeviceSettings: true,
28513
+ extensionSlots: [DOORBELL_SOURCE_SLOT],
28514
+ methods: {},
28515
+ events: {
28516
+ /**
28517
+ * Fires once per physical press. Reolink delivers via Baichuan
28518
+ * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
28519
+ * release/duration — it's a pulse.
28520
+ */
28521
+ onPressed: { data: DoorbellPressEventSchema } },
28522
+ status: {
28523
+ schema: DoorbellStatusSchema,
28524
+ kind: "push"
28525
+ },
28526
+ /**
28527
+ * Runtime-state slice — last press timestamp + lifetime press count.
28528
+ * Mirrored by the kernel and readable via
28529
+ * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
28530
+ * without subscribing.
28531
+ */
28532
+ runtimeState: DoorbellStatusSchema,
28533
+ /**
28534
+ * 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.
28535
+ *
28536
+ * See `RuntimeStateDurability`. Enforced by
28537
+ * `scripts/check-runtime-state-durability.ts`.
28538
+ */
28539
+ durability: "restored"
28540
+ };
28541
+ var ExtensionSlotIdSchema = _enum(["doorbell-source", "linked-devices"]);
28542
+ DeviceType.Camera, DeviceType.Camera;
28543
+ /** A slot's editable value, discriminated on `slot`. */
28544
+ var ExtensionSlotValueSchema = discriminatedUnion("slot", [DoorbellSourceSlotValueSchema.extend({ slot: literal("doorbell-source") }), LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
28545
+ DeviceType.Camera;
28546
+ var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
28547
+ state: literal("unreachable"),
28548
+ reason: string()
28549
+ })]);
28550
+ /** One provider of slots — the D554 source-listing row. */
28551
+ var ExtensionSourceSchema = object({
28552
+ /** The routing prefix of every `slotRef` this provider serves. */
28553
+ source: string(),
28554
+ label: string(),
28555
+ /** Stamped by the dispatcher from the registry (D557). */
28556
+ addonId: string().optional(),
28557
+ availability: ExtensionSourceAvailabilitySchema
28558
+ });
28559
+ /**
28560
+ * How one picked source stands. `missing` — no such device (deleted, or an id
28561
+ * that never existed); `foreign` — a device the slot's owner cannot read from
28562
+ * (slice 2's cross-owner graft source); `unavailable` — it exists but is not a
28563
+ * valid source now (a container, which is never a pick). A source in any of
28564
+ * these states is SHOWN, never silently dropped or re-pointed.
28565
+ */
28566
+ var ExtensionSourceHealthSchema = _enum([
28567
+ "ok",
28568
+ "missing",
28569
+ "foreign",
28570
+ "unavailable"
28571
+ ]);
28572
+ var ExtensionSlotSourceSchema = object({
28573
+ deviceId: number().int(),
28574
+ /** The device's name, or null when it could not be resolved (`missing`). */
28575
+ name: string().nullable(),
28576
+ health: ExtensionSourceHealthSchema,
28577
+ detail: string().optional()
28578
+ });
28579
+ /**
28580
+ * A DIFFERENT authority that gates whether the slot's sources do anything —
28581
+ * reported read-only, named, never written through this contract (D62). The
28582
+ * virtual doorbell's sources ring only while the wrapper is bound to the
28583
+ * camera, and that binding belongs to `deviceManager.setWrapperActive`.
28584
+ * `unknown` means the gate could not be read; it is not "inactive" (D315).
28585
+ */
28586
+ var ExtensionSlotActivationSchema = object({
28587
+ state: _enum([
28588
+ "active",
28589
+ "inactive",
28590
+ "unknown"
28591
+ ]),
28592
+ authority: string(),
28593
+ detail: string().optional()
28594
+ });
28595
+ var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
28596
+ state: literal("ok"),
28597
+ /** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
28598
+ slotRef: string(),
28599
+ slot: ExtensionSlotIdSchema,
28600
+ /** Names the store written (D62), e.g. `virtual-doorbell:doorbellSources`. */
28601
+ authority: string(),
28602
+ /** graft: its switch. association: null — removing every source is "off". */
28603
+ enabled: boolean().nullable(),
28604
+ /** graft: the cap registered on the host. association: null. */
28605
+ projects: string().nullable(),
28606
+ activation: ExtensionSlotActivationSchema.nullable(),
28607
+ value: ExtensionSlotValueSchema,
28608
+ sources: array(ExtensionSlotSourceSchema)
28609
+ }), object({
28610
+ state: literal("unreachable"),
28611
+ addonId: string(),
28612
+ reason: string()
28613
+ })]);
28614
+ var ExtensionCandidatesSchema = object({ candidates: array(object({
28615
+ deviceId: number().int(),
28616
+ name: string(),
28617
+ type: string(),
28618
+ location: string().nullable(),
28619
+ /** The container a child belongs to — "Spotlight 2" alone does not say which. */
28620
+ parentName: string().nullable(),
28621
+ /** Pre-marked by the owner's suggestion rule. NEVER saved on its own (D356). */
28622
+ suggested: boolean(),
28623
+ /** Why it is suggested ("same location"), null when it is not. */
28624
+ reason: string().nullable()
28625
+ })) });
28626
+ /**
28627
+ * What a write did. `none` — applied in place. `host` / `parent` — the owner
28628
+ * reloaded the host (or, for an accessory child, its parent) because the
28629
+ * write changed what the host REGISTERS (a graft switched on or off, slice 2).
28630
+ */
28631
+ var ExtensionSetResultSchema = object({
28632
+ applied: literal(true),
28633
+ reload: _enum([
28634
+ "none",
28635
+ "host",
28636
+ "parent"
28637
+ ])
28638
+ });
28639
+ var ExtensionSlotRefInputSchema = object({
28640
+ deviceId: number().int(),
28641
+ slotRef: string().min(1)
28642
+ });
28643
+ var ExtensionSetSlotInputSchema = ExtensionSlotRefInputSchema.extend({ value: ExtensionSlotValueSchema });
28644
+ method(object({ deviceId: number().int() }), array(ExtensionSourceSchema)), method(object({ deviceId: number().int() }), array(ExtensionSlotRowSchema)), method(ExtensionSlotRefInputSchema, ExtensionCandidatesSchema), method(ExtensionSetSlotInputSchema, ExtensionSetResultSchema, {
28645
+ kind: "mutation",
28646
+ auth: "admin"
28647
+ });
28648
+ /**
27740
28649
  * Optional client-side hints sent at session creation to help the provider
27741
28650
  * pick the best native source. All fields optional — a viewer that knows
27742
28651
  * nothing still gets a sane default. (Relocated from the retired `webrtc`
@@ -30186,75 +31095,6 @@ onStatusChanged: { data: object({
30186
31095
  volatileStateFields: ["lastChangedAt"]
30187
31096
  };
30188
31097
  /**
30189
- * Doorbell button cap. Two kinds of providers coexist behind this cap
30190
- * name (same pattern as `snapshot`):
30191
- *
30192
- * - **Native** providers: registered per-device by device-driver
30193
- * addons via `ctx.registerNativeCap` — either on a
30194
- * `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
30195
- * or directly on the camera (Reolink registers at camera level).
30196
- * Emits an `onPressed` event every time the firmware pushes a
30197
- * ring; status tracks the last press and a pressCount since start
30198
- * (diagnostic).
30199
- *
30200
- * - **Wrapper** provider: the `virtual-doorbell` system builtin
30201
- * (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
30202
- * device (contact / switch / event-emitter …) into a doorbell for
30203
- * a camera. `defaultActive: false` — the operator explicitly binds
30204
- * it per camera in the device-bindings UI, then picks the source
30205
- * device + trigger in the per-device settings.
30206
- *
30207
- * The DeviceEventPropagator re-emits `onPressed` on the camera parent
30208
- * — subscribers listening at the camera level receive ring events
30209
- * with `via[]` populated. No code on the parent needed.
30210
- */
30211
- var DoorbellStatusSchema = object({
30212
- /** Ms epoch of the last press. null = never observed since this provider started. */
30213
- lastPressedAt: number().nullable(),
30214
- /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
30215
- pressCountSinceStart: number()
30216
- });
30217
- var DoorbellPressEventSchema = object({
30218
- deviceId: number(),
30219
- timestamp: number()
30220
- });
30221
- var doorbellCapability = {
30222
- name: "doorbell",
30223
- scope: "device",
30224
- deviceNative: true,
30225
- mode: "singleton",
30226
- kind: "wrapper",
30227
- defaultActive: false,
30228
- deviceTypes: [DeviceType.Button, DeviceType.Camera],
30229
- exposesDeviceSettings: true,
30230
- methods: {},
30231
- events: {
30232
- /**
30233
- * Fires once per physical press. Reolink delivers via Baichuan
30234
- * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
30235
- * release/duration — it's a pulse.
30236
- */
30237
- onPressed: { data: DoorbellPressEventSchema } },
30238
- status: {
30239
- schema: DoorbellStatusSchema,
30240
- kind: "push"
30241
- },
30242
- /**
30243
- * Runtime-state slice — last press timestamp + lifetime press count.
30244
- * Mirrored by the kernel and readable via
30245
- * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
30246
- * without subscribing.
30247
- */
30248
- runtimeState: DoorbellStatusSchema,
30249
- /**
30250
- * 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.
30251
- *
30252
- * See `RuntimeStateDurability`. Enforced by
30253
- * `scripts/check-runtime-state-durability.ts`.
30254
- */
30255
- durability: "restored"
30256
- };
30257
- /**
30258
31098
  * Enum-state sensor — a string value picked from a finite option set.
30259
31099
  * Drives HA `sensor` entries with `state_class: enum` (HVAC action
30260
31100
  * states, weather conditions, contact-source channels, mode strings).
@@ -39142,146 +39982,6 @@ function readDeviceStateFrom(runtimeState) {
39142
39982
  }
39143
39983
  }
39144
39984
  /**
39145
- * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
39146
- * valutatore puro del suo FRONTE.
39147
- *
39148
- * Viveva dentro il builtin virtual-doorbell
39149
- * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
39150
- * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
39151
- * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
39152
- * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
39153
- * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
39154
- * SPOSTA qui e il doorbell la ri-esporta.
39155
- *
39156
- * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
39157
- * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
39158
- * regola" (e include `presence`, `cover`, `alarm-panel`), questa a "qual è il
39159
- * booleano il cui FRONTE conta". Vocabolari deliberatamente diversi.
39160
- */
39161
- /**
39162
- * Known binary / switch source caps → the boolean slice field whose
39163
- * false→true rise counts as ACTIVE. Every entry is "fire on active".
39164
- * Sensors whose "active" reading is not a plain boolean (presence's string
39165
- * state, connectivity's connected flag) are deliberately excluded — a
39166
- * reconnect is not a doorbell press, and it is not a recording either.
39167
- */
39168
- var SOURCE_CAP_ACTIVE_FIELD = {
39169
- contact: "entryOpen",
39170
- binary: "on",
39171
- switch: "on",
39172
- motion: "detected",
39173
- flood: "flooded",
39174
- gas: "detected",
39175
- smoke: "detected",
39176
- "carbon-monoxide": "detected",
39177
- vibration: "detected",
39178
- tamper: "tampered"
39179
- };
39180
- /**
39181
- * The same caps → the slice field carrying the ms-epoch timestamp of the
39182
- * last transition. Every source cap MUST appear here (guarded by a spec):
39183
- * without a transition timestamp the evaluator cannot tell a genuine rise
39184
- * from a boot-time hydration when the FIRST slice it ever sees is already
39185
- * active, and errs towards silence — swallowing the rise.
39186
- *
39187
- * These timestamps are UPSTREAM ones, not ingest ones: the Home Assistant
39188
- * provider derives them from `state.last_changed`, so they survive our own
39189
- * restarts and correctly read as "hours ago" for a state that has been
39190
- * active for hours. `motion` names its rise timestamp `lastDetectedAt`.
39191
- */
39192
- var SOURCE_CAP_CHANGED_AT_FIELD = {
39193
- contact: "lastChangedAt",
39194
- binary: "lastChangedAt",
39195
- switch: "lastChangedAt",
39196
- motion: "lastDetectedAt",
39197
- flood: "lastChangedAt",
39198
- gas: "lastChangedAt",
39199
- smoke: "lastChangedAt",
39200
- "carbon-monoxide": "lastChangedAt",
39201
- vibration: "lastChangedAt",
39202
- tamper: "lastChangedAt"
39203
- };
39204
- /** True when a cap is a recognised binary/switch source. */
39205
- function isSourceCap(capName) {
39206
- return Object.prototype.hasOwnProperty.call(SOURCE_CAP_ACTIVE_FIELD, capName);
39207
- }
39208
- /** Extract the "active" boolean a source cap's slice carries, or null when
39209
- * the cap is unknown or the field is missing / non-boolean. */
39210
- function sliceActiveValue(capName, slice) {
39211
- const field = SOURCE_CAP_ACTIVE_FIELD[capName];
39212
- if (field === void 0) return null;
39213
- const raw = slice[field];
39214
- return typeof raw === "boolean" ? raw : null;
39215
- }
39216
- /** Ms-epoch transition timestamp a source cap's slice carries, or null when
39217
- * it is absent, non-numeric or the zero "never observed" sentinel. */
39218
- function sliceChangedAt(capName, slice) {
39219
- const field = SOURCE_CAP_CHANGED_AT_FIELD[capName];
39220
- if (field === void 0) return null;
39221
- const raw = slice[field];
39222
- if (typeof raw !== "number" || !Number.isFinite(raw) || raw <= 0) return null;
39223
- return raw;
39224
- }
39225
- /**
39226
- * How recent a source's own transition timestamp must be for a FIRST
39227
- * sighting that is already active to count as a genuine rise rather than a
39228
- * hydration of long-standing state.
39229
- */
39230
- var DEFAULT_FIRST_SIGHTING_FRESHNESS_MS = 3e4;
39231
- /**
39232
- * IL fronte. Puro: nessun orologio proprio, nessuna memoria — il chiamante
39233
- * porta `prior`, `nowMs` e il proprio `startedAtMs`.
39234
- *
39235
- * Il caso della PRIMA slice già attiva è trattato esplicitamente e vale come
39236
- * fronte solo se il timestamp UPSTREAM della transizione è posteriore a
39237
- * `startedAtMs` **e** entro `firstSightingFreshnessMs`. Entrambe le metà
39238
- * servono: la sola freschezza scatterebbe su un'idratazione al boot di uno
39239
- * stato flippato pochi secondi prima del riavvio, e il solo "dopo che abbiamo
39240
- * iniziato" scatterebbe, su un processo di lunga vita, per una sorgente
39241
- * adottata oggi il cui stato è cambiato ieri. Il caso ambiguo ERRA VERSO IL
39242
- * SILENZIO e lo dichiara (`baseline-seeded-stale-active`).
39243
- */
39244
- function evaluateSensorEdge(input) {
39245
- const value = sliceActiveValue(input.capName, input.slice);
39246
- if (value === null) return {
39247
- edge: "none",
39248
- value: null,
39249
- reason: isSourceCap(input.capName) ? "non-boolean-value" : "unknown-cap"
39250
- };
39251
- if (input.prior === void 0) {
39252
- if (!value) return {
39253
- edge: "none",
39254
- value,
39255
- reason: "baseline-seeded-inactive"
39256
- };
39257
- const changedAt = sliceChangedAt(input.capName, input.slice);
39258
- const floor = Math.max(input.startedAtMs, input.nowMs - input.firstSightingFreshnessMs);
39259
- if (changedAt === null || changedAt < floor) return {
39260
- edge: "none",
39261
- value,
39262
- reason: "baseline-seeded-stale-active"
39263
- };
39264
- return {
39265
- edge: "rising",
39266
- value: true
39267
- };
39268
- }
39269
- if (input.prior === value) return {
39270
- edge: "none",
39271
- value,
39272
- reason: "no-change"
39273
- };
39274
- if (!value) return {
39275
- edge: "none",
39276
- value,
39277
- reason: "falling-edge"
39278
- };
39279
- return {
39280
- edge: "rising",
39281
- value: true
39282
- };
39283
- }
39284
- /**
39285
39985
  * Accessory device helpers — shared across drivers.
39286
39986
  *
39287
39987
  * Many vendor-specific drivers register accessory child devices on
@@ -43121,6 +43821,30 @@ Object.freeze({
43121
43821
  addonId: null,
43122
43822
  access: "create"
43123
43823
  },
43824
+ "deviceExtension.listCandidates": {
43825
+ capName: "device-extension",
43826
+ capScope: "device",
43827
+ addonId: null,
43828
+ access: "view"
43829
+ },
43830
+ "deviceExtension.listSlots": {
43831
+ capName: "device-extension",
43832
+ capScope: "device",
43833
+ addonId: null,
43834
+ access: "view"
43835
+ },
43836
+ "deviceExtension.listSources": {
43837
+ capName: "device-extension",
43838
+ capScope: "device",
43839
+ addonId: null,
43840
+ access: "view"
43841
+ },
43842
+ "deviceExtension.setSlot": {
43843
+ capName: "device-extension",
43844
+ capScope: "device",
43845
+ addonId: null,
43846
+ access: "create"
43847
+ },
43124
43848
  "deviceManager.addLocation": {
43125
43849
  capName: "device-manager",
43126
43850
  capScope: "system",
@@ -43871,6 +44595,12 @@ Object.freeze({
43871
44595
  addonId: null,
43872
44596
  access: "view"
43873
44597
  },
44598
+ "embeddingEncoder.resetFailedModels": {
44599
+ capName: "embedding-encoder",
44600
+ capScope: "system",
44601
+ addonId: null,
44602
+ access: "delete"
44603
+ },
43874
44604
  "enumSensor.getStatus": {
43875
44605
  capName: "enum-sensor",
43876
44606
  capScope: "device",
@@ -46205,6 +46935,12 @@ Object.freeze({
46205
46935
  addonId: null,
46206
46936
  access: "view"
46207
46937
  },
46938
+ "pipelineOrchestrator.getClusterModelChoice": {
46939
+ capName: "pipeline-orchestrator",
46940
+ capScope: "system",
46941
+ addonId: null,
46942
+ access: "view"
46943
+ },
46208
46944
  "pipelineOrchestrator.getDeviceLiveContribution": {
46209
46945
  capName: "pipeline-orchestrator",
46210
46946
  capScope: "system",
@@ -49030,6 +49766,26 @@ Object.freeze({
49030
49766
  form: "single",
49031
49767
  optional: false
49032
49768
  }],
49769
+ "deviceExtension.listCandidates": [{
49770
+ name: "deviceId",
49771
+ form: "single",
49772
+ optional: false
49773
+ }],
49774
+ "deviceExtension.listSlots": [{
49775
+ name: "deviceId",
49776
+ form: "single",
49777
+ optional: false
49778
+ }],
49779
+ "deviceExtension.listSources": [{
49780
+ name: "deviceId",
49781
+ form: "single",
49782
+ optional: false
49783
+ }],
49784
+ "deviceExtension.setSlot": [{
49785
+ name: "deviceId",
49786
+ form: "single",
49787
+ optional: false
49788
+ }],
49033
49789
  "deviceManager.adoptionRelease": [{
49034
49790
  name: "camDeviceId",
49035
49791
  form: "single",
@@ -52652,169 +53408,6 @@ function readTimelapseGeneratedAt(rule, deviceId) {
52652
53408
  if (map !== void 0) return map[String(deviceId)] ?? 0;
52653
53409
  return rule.lastGeneratedAt ?? 0;
52654
53410
  }
52655
- /**
52656
- * A model choice has a SCOPE, and a scope change has a workflow.
52657
- *
52658
- * ## The two scopes
52659
- *
52660
- * Almost every pipeline step's model is a **node** question: which build runs
52661
- * fastest on THIS accelerator. Two nodes may legitimately answer differently —
52662
- * a Coral runs the tflite SSD, a Mac runs the coreml YOLO — because the answers
52663
- * are compared against nothing. They produce boxes, and a box is a box.
52664
- *
52665
- * Two steps are not like that. `face-embedding` and `clip-embedding` produce
52666
- * **vectors that land in ONE shared index** (`identity_samples`,
52667
- * `vec_object_clip`) and are ranked against each other by cosine similarity.
52668
- * Cosine similarity between two encoders is not a weak signal, it is a
52669
- * meaningless number — and nothing inside a vector can tell you it happened.
52670
- * So for those two steps the model is a **cluster** question with exactly one
52671
- * answer, stored in exactly one row.
52672
- *
52673
- * That is the same argument [D52](../../../../docs/decisions/adr-0052.md) makes
52674
- * for the crop convention (`detail-crop.ts`), one level up: the crop decides
52675
- * WHAT pixels the encoder sees, this decides WHICH encoder sees them. Both are
52676
- * cluster-wide for the same reason and neither may become per-node.
52677
- *
52678
- * ## Why the registry lives here and not in the step catalog
52679
- *
52680
- * The scope itself is declared on the step, in
52681
- * `detection-pipeline/registry/step-definitions.ts` (`StepDefinition.modelScope`)
52682
- * — that is where a new step declares what kind of choice its model is. But the
52683
- * catalog lives inside `addon-pipeline`, and three packages that must NOT
52684
- * import an addon need to know the set: the orchestrator (which renders and
52685
- * stores the row), post-analysis (which pins the row for a re-embed pass) and
52686
- * admin-ui (which mirrors it). So the set is mirrored here, and
52687
- * `scripts/check-cluster-model-scope.ts` fails the build when the two disagree.
52688
- * A hand-copied key that stops matching is exactly how a setting silently stops
52689
- * arriving while both sides still look correct.
52690
- *
52691
- * ## The defaults ARE today's behaviour
52692
- *
52693
- * {@link DEFAULT_CLUSTER_STEP_MODELS} reproduces the catalog `defaultModelId`
52694
- * of both steps. Declaring the scope therefore changes nothing on the day it
52695
- * ships: the cluster row starts out saying what every node was already doing.
52696
- * Changing it is legitimate — that is what the knob is for — but it invalidates
52697
- * the stored vectors of that surface, and must be followed by a re-embed pass
52698
- * (`face-reembed-pass.ts`, `embedding-rebuild.ts`).
52699
- */
52700
- /**
52701
- * The cluster-scoped steps. Mirrored from the catalog's `modelScope: 'cluster'`
52702
- * declarations and guarded by `scripts/check-cluster-model-scope.ts`.
52703
- */
52704
- var CLUSTER_MODEL_SCOPED_STEPS = [{
52705
- stepId: "face-embedding",
52706
- label: "Face recognition model",
52707
- defaultModelId: "arcface-r100",
52708
- indexName: "the enrolled face gallery",
52709
- options: [
52710
- {
52711
- id: "arcface-r100",
52712
- label: "ArcFace (ResNet34)"
52713
- },
52714
- {
52715
- id: "auraface-r100",
52716
- label: "AuraFace R100"
52717
- },
52718
- {
52719
- id: "inception-resnet-v1",
52720
- label: "Inception ResNet V1"
52721
- }
52722
- ]
52723
- }, {
52724
- stepId: "clip-embedding",
52725
- label: "Semantic search model",
52726
- defaultModelId: "mobileclip-s1",
52727
- indexName: "the object semantic-search index",
52728
- options: [{
52729
- id: "mobileclip-s1",
52730
- label: "MobileCLIP S1"
52731
- }, {
52732
- id: "mobileclip-s2",
52733
- label: "MobileCLIP S2"
52734
- }]
52735
- }];
52736
- /**
52737
- * The settings key holding one step's cluster model choice.
52738
- *
52739
- * Step-qualified so the keys stay unique across the addon's whole schema, which
52740
- * is what lets {@link pickClusterStepModels} walk every section instead of
52741
- * trusting the section id.
52742
- */
52743
- function clusterModelSettingKey(stepId) {
52744
- return `clusterModel:${stepId}`;
52745
- }
52746
- /** The cluster row when nobody has configured one — today's catalog defaults. */
52747
- var DEFAULT_CLUSTER_STEP_MODELS = Object.freeze(Object.fromEntries(CLUSTER_MODEL_SCOPED_STEPS.map((s) => [s.stepId, s.defaultModelId])));
52748
- /** A stored choice is a non-empty model id, or it is not a choice. */
52749
- var ChosenModelIdSchema = string().min(1);
52750
- /**
52751
- * Narrow a FLAT settings record to the cluster row.
52752
- *
52753
- * Per-FIELD fallback, deliberately (same rule as `readDetailCropConvention`): a
52754
- * junk face model must not also discard a valid clip model. An absent, empty or
52755
- * non-string value resolves to the step's catalog default — the historical
52756
- * behaviour — never to a blank id, because a blank id downstream becomes
52757
- * "substitute the format default", which is precisely the substitution this
52758
- * scope exists to forbid.
52759
- */
52760
- function readClusterStepModels(config) {
52761
- const out = {};
52762
- for (const step of CLUSTER_MODEL_SCOPED_STEPS) {
52763
- const parsed = ChosenModelIdSchema.safeParse(config[clusterModelSettingKey(step.stepId)]);
52764
- out[step.stepId] = parsed.success ? parsed.data : step.defaultModelId;
52765
- }
52766
- return out;
52767
- }
52768
- function isHydratedField$2(entry) {
52769
- return typeof entry === "object" && entry !== null && "key" in entry;
52770
- }
52771
- /**
52772
- * Extract the cluster row from an `addon-settings.getGlobalSettings` payload.
52773
- *
52774
- * Walks EVERY section rather than looking inside {@link CLUSTER_MODEL_SECTION_ID}
52775
- * alone: the keys are unique across the addon's schema, and a section rename
52776
- * must not silently revert the whole cluster to the defaults. A `null` payload
52777
- * (addon mid-boot) is the defaults.
52778
- */
52779
- function pickClusterStepModels(view) {
52780
- if (view === null) return DEFAULT_CLUSTER_STEP_MODELS;
52781
- const flat = {};
52782
- const wanted = new Set(CLUSTER_MODEL_SCOPED_STEPS.map((s) => clusterModelSettingKey(s.stepId)));
52783
- for (const section of view.sections) for (const entry of section.fields) {
52784
- if (!isHydratedField$2(entry) || typeof entry.key !== "string") continue;
52785
- if (wanted.has(entry.key)) flat[entry.key] = entry.value;
52786
- }
52787
- return readClusterStepModels(flat);
52788
- }
52789
- var CLUSTER_STEP_SETTING_FIELDS = [{
52790
- stepId: "face-embedding",
52791
- key: "minLandmarkFaceSize",
52792
- label: "Min face size for recognition (detection px)",
52793
- 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.",
52794
- type: "slider",
52795
- min: 0,
52796
- max: 64,
52797
- step: 2,
52798
- default: 24
52799
- }];
52800
- function clusterStepSettingKey(stepId, fieldKey) {
52801
- return `clusterStepSetting:${stepId}:${fieldKey}`;
52802
- }
52803
- var ClusterSettingNumberSchema = number().finite();
52804
- function readClusterStepSettings(config) {
52805
- const out = {};
52806
- for (const field of CLUSTER_STEP_SETTING_FIELDS) {
52807
- const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
52808
- const value = parsed.success ? parsed.data : field.default;
52809
- const existing = out[field.stepId] ?? {};
52810
- out[field.stepId] = {
52811
- ...existing,
52812
- [field.key]: value
52813
- };
52814
- }
52815
- return out;
52816
- }
52817
- readClusterStepSettings({});
52818
53411
  object({
52819
53412
  /**
52820
53413
  * Fraction of the box's own size added on EACH side before cutting.
@@ -53356,6 +53949,397 @@ function vectorDimFromBase64(encoded) {
53356
53949
  return Math.floor(Buffer.from(encoded, "base64").byteLength / 4);
53357
53950
  }
53358
53951
  //#endregion
53952
+ //#region src/pipeline-analytics/cluster-model-pin.ts
53953
+ /**
53954
+ * Where a re-embed pass gets the model it pins.
53955
+ *
53956
+ * ## Why not `embeddingEncoder.getInfo`
53957
+ *
53958
+ * That is what the CLIP rebuild used, and it answers a subtly different
53959
+ * question: "which model is the encoder addon currently holding", not "which
53960
+ * model has the operator chosen for the cluster". The two agree until they do
53961
+ * not — an encoder mid-reload, a node that never picked up a change — and when
53962
+ * they disagree the pass writes a whole index in the wrong space with a status
53963
+ * line that looks fine. Since `face-embedding` and `clip-embedding` declare
53964
+ * `modelScope: 'cluster'`, there is now exactly one authority for each, and it
53965
+ * is a stored row rather than a live process's opinion.
53966
+ *
53967
+ * ## Why the read is not cached here
53968
+ *
53969
+ * A pass reads it ONCE, at the start, and pins that value for its whole run
53970
+ * (D54). A cache would only matter for a caller that re-read it mid-pass, which
53971
+ * is precisely the thing the pin exists to prevent — so there is nothing to
53972
+ * cache and the absence is deliberate.
53973
+ *
53974
+ * ## Why a failed read refuses instead of defaulting
53975
+ *
53976
+ * A pass that cannot name its model must not run. The previous CLIP path's
53977
+ * `?? 'unknown'` is the shipped version of the alternative: rows stamped with an
53978
+ * id nothing ran, in an index whose same-model gate then has nothing to reason
53979
+ * about.
53980
+ */
53981
+ /** The addon whose GLOBAL settings hold the cluster row. */
53982
+ var CLUSTER_MODEL_OWNER_ADDON_ID = "pipeline-orchestrator";
53983
+ /** The step ids this module can pin — the same two the catalog declares. */
53984
+ var FACE_EMBEDDING_STEP_ID = "face-embedding";
53985
+ var CLIP_EMBEDDING_STEP_ID = "clip-embedding";
53986
+ /**
53987
+ * The cluster row, or `null` when it could not be read.
53988
+ *
53989
+ * `null` and not "the defaults": a caller that cannot distinguish "the operator
53990
+ * chose arcface" from "I could not ask" will run a pass on a guess. The one
53991
+ * production caller turns `null` into a refusal to start.
53992
+ */
53993
+ async function readClusterModelRow(api, logger) {
53994
+ try {
53995
+ return pickClusterStepModels(await api.addonSettings.getGlobalSettings.query({ addonId: CLUSTER_MODEL_OWNER_ADDON_ID }));
53996
+ } catch (err) {
53997
+ logger.warn("cluster model row unreadable — a re-embed pass must not guess which encoder the operator chose", { meta: {
53998
+ owner: CLUSTER_MODEL_OWNER_ADDON_ID,
53999
+ error: err instanceof Error ? err.message : String(err)
54000
+ } });
54001
+ return null;
54002
+ }
54003
+ }
54004
+ /**
54005
+ * Pin one cluster-scoped step's model for a whole pass.
54006
+ *
54007
+ * Returns `null` on an unreadable row OR an unknown step id — both mean the
54008
+ * caller must not start, and folding them together is safe because the caller's
54009
+ * move is identical: refuse, loudly.
54010
+ */
54011
+ async function resolveClusterModelPin(api, stepId, logger) {
54012
+ if (!CLUSTER_MODEL_SCOPED_STEPS.some((s) => s.stepId === stepId)) {
54013
+ logger.warn("cluster model pin requested for a step that is not cluster-scoped", { meta: {
54014
+ stepId,
54015
+ clusterScoped: CLUSTER_MODEL_SCOPED_STEPS.map((s) => s.stepId)
54016
+ } });
54017
+ return null;
54018
+ }
54019
+ const row = await readClusterModelRow(api, logger);
54020
+ if (row === null) return null;
54021
+ const modelId = row[stepId];
54022
+ return modelId !== void 0 && modelId !== "" ? modelId : null;
54023
+ }
54024
+ /**
54025
+ * The error texts a cap call carries when the provider or the router has no
54026
+ * such method: the kernel's `Capability "…" has no method "…"`, tRPC's
54027
+ * `No procedure found on path`, and the forked-child hop's
54028
+ * `method '…' not found on provider '…'` (child-cap-dispatch.ts). NOT `is not a function`: that is any
54029
+ * `TypeError` thrown INSIDE the owner while it answers, and reading it as
54030
+ * "the owner predates the method" would file a bug in the owner under a
54031
+ * rolling-release reason nobody investigates.
54032
+ */
54033
+ var METHOD_UNAVAILABLE_FINGERPRINTS = [
54034
+ /has no method/i,
54035
+ /no procedure found/i,
54036
+ /method not found/i,
54037
+ /method '[^']*' not found on provider/i
54038
+ ];
54039
+ /**
54040
+ * The pin read for a pass that REWRITES an index (D651 fix rounds 1–3).
54041
+ *
54042
+ * Asks the OWNER. The orchestrator owns `clusterModel:*` and answers from a
54043
+ * three-way read of its own store, once its boot has settled
54044
+ * (`pipelineOrchestrator.getClusterModelChoice`). Never the hydrated view,
54045
+ * which answers `value ?? default`, and never the owner's private store
54046
+ * layout. Silent on purpose: the callers log state CHANGES.
54047
+ */
54048
+ async function readClusterModelPinStrict(api, stepId) {
54049
+ const method = api.pipelineOrchestrator?.getClusterModelChoice;
54050
+ if (method === void 0) return {
54051
+ kind: "unknown",
54052
+ reason: "method-unavailable"
54053
+ };
54054
+ let raw;
54055
+ try {
54056
+ raw = await method.query({ stepId });
54057
+ } catch (err) {
54058
+ const error = err instanceof Error ? err.message : String(err);
54059
+ return METHOD_UNAVAILABLE_FINGERPRINTS.some((re) => re.test(error)) ? {
54060
+ kind: "unknown",
54061
+ reason: "method-unavailable",
54062
+ error
54063
+ } : {
54064
+ kind: "unknown",
54065
+ reason: "read-failed",
54066
+ error
54067
+ };
54068
+ }
54069
+ if (raw === void 0) return {
54070
+ kind: "unknown",
54071
+ reason: "method-unavailable"
54072
+ };
54073
+ const parsed = ClusterModelChoiceSchema.safeParse(raw);
54074
+ if (!parsed.success) return {
54075
+ kind: "unknown",
54076
+ reason: "read-failed",
54077
+ error: "unparseable owner answer"
54078
+ };
54079
+ const choice = parsed.data;
54080
+ if (choice.kind === "stored") return {
54081
+ kind: "known",
54082
+ modelId: choice.modelId
54083
+ };
54084
+ if (choice.kind === "absent") return {
54085
+ kind: "not-stored",
54086
+ defaultModelId: choice.defaultModelId
54087
+ };
54088
+ return choice.error !== void 0 ? {
54089
+ kind: "unknown",
54090
+ reason: choice.reason,
54091
+ error: choice.error
54092
+ } : {
54093
+ kind: "unknown",
54094
+ reason: choice.reason
54095
+ };
54096
+ }
54097
+ //#endregion
54098
+ //#region src/embedding-encoder/catalogs/embedding-models.ts
54099
+ var HF_REPO = "camstack/camstack-models";
54100
+ var hf = (path) => hfModelUrl(HF_REPO, path);
54101
+ /**
54102
+ * The text tower's tokenizer, in HF `tokenizers` format, hosted next to every
54103
+ * text-encoder onnx (`.../onnx/tokenizer.json`) and fetched as a sibling file so
54104
+ * it lands beside the model. Each model folder hosts ITS OWN (MobileCLIP: the
54105
+ * CLIP BPE, vocab 49408; SigLIP2: Gemma SentencePiece, 256k, lower-casing).
54106
+ */
54107
+ var TOKENIZER_FILE = "tokenizer.json";
54108
+ /** SigLIP2's tokenizer — a DIFFERENT file name on purpose: see `ClipModelMeta.tokenizerFile`. */
54109
+ var SIGLIP2_TOKENIZER_FILE = "camstack-siglip2-b16-224-tokenizer.json";
54110
+ var ovFormat = (url, sizeMB) => {
54111
+ const base = url.split("/").pop() ?? "";
54112
+ const files = base.endsWith(".xml") ? [base.replace(/\.xml$/, ".bin")] : void 0;
54113
+ return {
54114
+ url,
54115
+ sizeMB,
54116
+ runtimes: ["python"],
54117
+ ...files ? { files } : {}
54118
+ };
54119
+ };
54120
+ /**
54121
+ * Files inside an .mlpackage directory bundle.
54122
+ * Must be fetched alongside the package root when isDirectory is true.
54123
+ */
54124
+ var MLPACKAGE_FILES = [
54125
+ "Manifest.json",
54126
+ "Data/com.apple.CoreML/model.mlmodel",
54127
+ "Data/com.apple.CoreML/weights/weight.bin"
54128
+ ];
54129
+ /**
54130
+ * The MobileCLIP feature-space contract (D649 — see `clip-model.ts` in
54131
+ * `@camstack/types`). S1 and S2 share the historical 512-d `object-clip` index,
54132
+ * separated by each row's `modelId`; the CLIP BPE window is 77 tokens padded
54133
+ * with 0; 0.2 is the floor the search always shipped with, measured to keep 96%
54134
+ * of matched COCO caption-image pairs on S1.
54135
+ */
54136
+ var mobileclipMeta = (textModelId) => ({
54137
+ textModelId,
54138
+ embeddingDim: 512,
54139
+ vectorIndex: "object-clip",
54140
+ tokenizerFile: TOKENIZER_FILE,
54141
+ contextLength: 77,
54142
+ padId: 0,
54143
+ searchMinScore: .2
54144
+ });
54145
+ /**
54146
+ * SigLIP2 B/16-224 (D649). 768-d, so its OWN index; a 64-token Gemma
54147
+ * SentencePiece window padded with 0 (the hosted `tokenizer.json` lower-cases,
54148
+ * see `scripts/build-siglip2-model.py`). The floor is SIGLIP2_SEARCH_MIN_SCORE.
54149
+ */
54150
+ var SIGLIP2_META = {
54151
+ textModelId: "siglip2-b16-224-text",
54152
+ embeddingDim: 768,
54153
+ vectorIndex: "object-clip-siglip2-b16-224",
54154
+ tokenizerFile: SIGLIP2_TOKENIZER_FILE,
54155
+ contextLength: 64,
54156
+ padId: 0,
54157
+ searchMinScore: .1
54158
+ };
54159
+ /**
54160
+ * NO onnx vision builds, deliberately (2026-08-21). The int8 ONNX vision
54161
+ * exports were measured misaligned with the text encoders (matched image↔text
54162
+ * cosine ≈ 0.01 vs ≈ 0.22 for the fp16 openvino/coreml builds) — see the
54163
+ * catalog note in `addon-pipeline/.../model-catalogs.ts`. The image-encode leg
54164
+ * that consumed them here (`embeddingEncoder.encode` → PythonRawTensorEngine)
54165
+ * is retired with them: its only caller discarded the vector, and its
54166
+ * `preprocessForClip` applied OpenAI mean/std that MobileCLIP never used.
54167
+ * S0 was retired the same day (measured worst of the family on fleet crops).
54168
+ */
54169
+ var CLIP_IMAGE_MODELS = [
54170
+ {
54171
+ id: "mobileclip-s1",
54172
+ name: "MobileCLIP S1",
54173
+ description: "Apple MobileCLIP S1 — balanced vision encoder, 512-dim, 256×256 (fp16 OpenVINO/CoreML)",
54174
+ inputSize: {
54175
+ width: 256,
54176
+ height: 256
54177
+ },
54178
+ labels: [],
54179
+ inputNormalization: "none",
54180
+ clip: mobileclipMeta("mobileclip-s1-text"),
54181
+ formats: {
54182
+ openvino: ovFormat(hf("clip/mobileclip-s1/openvino/camstack-mobileclip-s1-vision.xml"), 55),
54183
+ coreml: {
54184
+ url: hf("clip/mobileclip-s1/coreml/camstack-mobileclip-s1-vision.mlpackage"),
54185
+ sizeMB: 65,
54186
+ isDirectory: true,
54187
+ files: [...MLPACKAGE_FILES],
54188
+ runtimes: ["python"]
54189
+ }
54190
+ }
54191
+ },
54192
+ {
54193
+ id: "mobileclip-s2",
54194
+ name: "MobileCLIP S2",
54195
+ description: "Apple MobileCLIP S2 — high-accuracy vision encoder, 512-dim, 256×256 (fp16 OpenVINO/CoreML)",
54196
+ inputSize: {
54197
+ width: 256,
54198
+ height: 256
54199
+ },
54200
+ labels: [],
54201
+ inputNormalization: "none",
54202
+ clip: mobileclipMeta("mobileclip-s2-text"),
54203
+ formats: {
54204
+ openvino: ovFormat(hf("clip/mobileclip-s2/openvino/camstack-mobileclip-s2-vision.xml"), 90),
54205
+ coreml: {
54206
+ url: hf("clip/mobileclip-s2/coreml/camstack-mobileclip-s2-vision.mlpackage"),
54207
+ sizeMB: 110,
54208
+ isDirectory: true,
54209
+ files: [...MLPACKAGE_FILES],
54210
+ runtimes: ["python"]
54211
+ }
54212
+ }
54213
+ },
54214
+ {
54215
+ id: "siglip2-b16-224",
54216
+ name: "SigLIP2 B/16",
54217
+ description: "Google SigLIP2 base, patch 16, 224×224 — Apache-2.0 vision encoder, 768-dim (fp16 OpenVINO/CoreML)",
54218
+ inputSize: {
54219
+ width: 224,
54220
+ height: 224
54221
+ },
54222
+ labels: [],
54223
+ inputNormalization: "none",
54224
+ license: "Apache-2.0",
54225
+ clip: SIGLIP2_META,
54226
+ formats: {
54227
+ openvino: ovFormat(hf("clip/siglip2/openvino/camstack-siglip2-b16-224-vision.xml"), 186),
54228
+ coreml: {
54229
+ url: hf("clip/siglip2/coreml/camstack-siglip2-b16-224-vision.mlpackage"),
54230
+ sizeMB: 185,
54231
+ isDirectory: true,
54232
+ files: [...MLPACKAGE_FILES],
54233
+ runtimes: ["python"]
54234
+ }
54235
+ }
54236
+ }
54237
+ ];
54238
+ /**
54239
+ * The int8 TEXT onnx encoders are healthy — unlike the retired int8 vision
54240
+ * exports. Verified 2026-08-21: the live search path (fp16 openvino vision
54241
+ * vectors ⋅ int8 onnx text queries) ranks correctly on the real index, and the
54242
+ * local cross-check aligns them with the fp16 vision space (cos ≈ 0.22 on
54243
+ * matched pairs).
54244
+ */
54245
+ var CLIP_TEXT_MODELS = [
54246
+ {
54247
+ id: "mobileclip-s1-text",
54248
+ name: "MobileCLIP S1 Text Encoder",
54249
+ description: "Text encoder for MobileCLIP S1, 512-dim, int8 quantized (61 MB)",
54250
+ inputSize: {
54251
+ width: 0,
54252
+ height: 0
54253
+ },
54254
+ labels: [],
54255
+ formats: {
54256
+ onnx: {
54257
+ url: hf("clip/mobileclip-s1/onnx/camstack-mobileclip-s1-text.onnx"),
54258
+ sizeMB: 61,
54259
+ files: [TOKENIZER_FILE]
54260
+ },
54261
+ openvino: ovFormat(hf("clip/mobileclip-s1/openvino/camstack-mobileclip-s1-text.xml"), 121)
54262
+ }
54263
+ },
54264
+ {
54265
+ id: "mobileclip-s2-text",
54266
+ name: "MobileCLIP S2 Text Encoder",
54267
+ description: "Text encoder for MobileCLIP S2, 512-dim, int8 quantized (61 MB)",
54268
+ inputSize: {
54269
+ width: 0,
54270
+ height: 0
54271
+ },
54272
+ labels: [],
54273
+ formats: {
54274
+ onnx: {
54275
+ url: hf("clip/mobileclip-s2/onnx/camstack-mobileclip-s2-text.onnx"),
54276
+ sizeMB: 61,
54277
+ files: [TOKENIZER_FILE]
54278
+ },
54279
+ openvino: ovFormat(hf("clip/mobileclip-s2/openvino/camstack-mobileclip-s2-text.xml"), 121)
54280
+ }
54281
+ },
54282
+ {
54283
+ id: "siglip2-b16-224-text",
54284
+ name: "SigLIP2 B/16 Text Encoder",
54285
+ description: "Text encoder for SigLIP2 B/16, 768-dim, fp16 (565 MB)",
54286
+ inputSize: {
54287
+ width: 0,
54288
+ height: 0
54289
+ },
54290
+ labels: [],
54291
+ license: "Apache-2.0",
54292
+ formats: {
54293
+ onnx: {
54294
+ url: hf("clip/siglip2/onnx/camstack-siglip2-b16-224-text.onnx"),
54295
+ sizeMB: 565,
54296
+ files: [SIGLIP2_TOKENIZER_FILE]
54297
+ },
54298
+ openvino: ovFormat(hf("clip/siglip2/openvino/camstack-siglip2-b16-224-text.xml"), 565)
54299
+ }
54300
+ }
54301
+ ];
54302
+ //#endregion
54303
+ //#region src/shared/clip/clip-model-registry.ts
54304
+ /** The model in force when nobody has chosen — the cluster row's default. */
54305
+ var DEFAULT_CLIP_MODEL = "mobileclip-s1";
54306
+ /**
54307
+ * Build a registry from catalog entries. Throws when two models share an index
54308
+ * at different dimensions: that is a catalog defect, and the vector store would
54309
+ * refuse the second model's writes one at a time, forever, at runtime.
54310
+ */
54311
+ function buildClipModelRegistry(entries) {
54312
+ const models = /* @__PURE__ */ new Map();
54313
+ const spaces = /* @__PURE__ */ new Map();
54314
+ for (const entry of entries) {
54315
+ const meta = entry.clip;
54316
+ if (meta === void 0) continue;
54317
+ models.set(entry.id, {
54318
+ modelId: entry.id,
54319
+ inputSize: entry.inputSize.width,
54320
+ meta
54321
+ });
54322
+ const existing = spaces.get(meta.vectorIndex);
54323
+ 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}`);
54324
+ spaces.set(meta.vectorIndex, {
54325
+ index: meta.vectorIndex,
54326
+ dim: meta.embeddingDim,
54327
+ modelIds: [...existing?.modelIds ?? [], entry.id]
54328
+ });
54329
+ }
54330
+ const all = [...spaces.values()];
54331
+ return {
54332
+ resolve: (modelId) => models.get(modelId) ?? null,
54333
+ spaceFor: (modelId) => {
54334
+ const model = models.get(modelId);
54335
+ return model === void 0 ? null : spaces.get(model.meta.vectorIndex) ?? null;
54336
+ },
54337
+ spaces: () => all
54338
+ };
54339
+ }
54340
+ /** The built-in catalog's registry. */
54341
+ var BUILTIN_CLIP_MODELS = buildClipModelRegistry(CLIP_IMAGE_MODELS);
54342
+ //#endregion
53359
54343
  Object.defineProperty(exports, "AUDIO_MACRO_LABELS", {
53360
54344
  enumerable: true,
53361
54345
  get: function() {
@@ -53374,6 +54358,12 @@ Object.defineProperty(exports, "ArchivedDebugNoteSchema", {
53374
54358
  return ArchivedDebugNoteSchema;
53375
54359
  }
53376
54360
  });
54361
+ Object.defineProperty(exports, "BUILTIN_CLIP_MODELS", {
54362
+ enumerable: true,
54363
+ get: function() {
54364
+ return BUILTIN_CLIP_MODELS;
54365
+ }
54366
+ });
53377
54367
  Object.defineProperty(exports, "BaseAddon", {
53378
54368
  enumerable: true,
53379
54369
  get: function() {
@@ -53392,10 +54382,22 @@ Object.defineProperty(exports, "BirthDecisionRecordSchema", {
53392
54382
  return BirthDecisionRecordSchema;
53393
54383
  }
53394
54384
  });
53395
- Object.defineProperty(exports, "CLUSTER_MODEL_SCOPED_STEPS", {
54385
+ Object.defineProperty(exports, "CLIP_EMBEDDING_STEP_ID", {
54386
+ enumerable: true,
54387
+ get: function() {
54388
+ return CLIP_EMBEDDING_STEP_ID;
54389
+ }
54390
+ });
54391
+ Object.defineProperty(exports, "CLIP_IMAGE_MODELS", {
53396
54392
  enumerable: true,
53397
54393
  get: function() {
53398
- return CLUSTER_MODEL_SCOPED_STEPS;
54394
+ return CLIP_IMAGE_MODELS;
54395
+ }
54396
+ });
54397
+ Object.defineProperty(exports, "CLIP_TEXT_MODELS", {
54398
+ enumerable: true,
54399
+ get: function() {
54400
+ return CLIP_TEXT_MODELS;
53399
54401
  }
53400
54402
  });
53401
54403
  Object.defineProperty(exports, "COCO_TO_MACRO", {
@@ -53416,6 +54418,12 @@ Object.defineProperty(exports, "CoverStateSchema", {
53416
54418
  return CoverStateSchema;
53417
54419
  }
53418
54420
  });
54421
+ Object.defineProperty(exports, "DEFAULT_CLIP_MODEL", {
54422
+ enumerable: true,
54423
+ get: function() {
54424
+ return DEFAULT_CLIP_MODEL;
54425
+ }
54426
+ });
53419
54427
  Object.defineProperty(exports, "DEFAULT_EVENT_COLOR", {
53420
54428
  enumerable: true,
53421
54429
  get: function() {
@@ -53458,6 +54466,24 @@ Object.defineProperty(exports, "DeviceType", {
53458
54466
  return DeviceType;
53459
54467
  }
53460
54468
  });
54469
+ Object.defineProperty(exports, "EMBEDDING_MODEL_FAILED", {
54470
+ enumerable: true,
54471
+ get: function() {
54472
+ return EMBEDDING_MODEL_FAILED;
54473
+ }
54474
+ });
54475
+ Object.defineProperty(exports, "EMBEDDING_REQUIREMENTS_FAILED", {
54476
+ enumerable: true,
54477
+ get: function() {
54478
+ return EMBEDDING_REQUIREMENTS_FAILED;
54479
+ }
54480
+ });
54481
+ Object.defineProperty(exports, "EMBEDDING_REQUIREMENTS_UNAVAILABLE", {
54482
+ enumerable: true,
54483
+ get: function() {
54484
+ return EMBEDDING_REQUIREMENTS_UNAVAILABLE;
54485
+ }
54486
+ });
53461
54487
  Object.defineProperty(exports, "EVENT_KIND_BY_CAP", {
53462
54488
  enumerable: true,
53463
54489
  get: function() {
@@ -53476,6 +54502,12 @@ Object.defineProperty(exports, "EventCategory", {
53476
54502
  return EventCategory;
53477
54503
  }
53478
54504
  });
54505
+ Object.defineProperty(exports, "FACE_EMBEDDING_STEP_ID", {
54506
+ enumerable: true,
54507
+ get: function() {
54508
+ return FACE_EMBEDDING_STEP_ID;
54509
+ }
54510
+ });
53479
54511
  Object.defineProperty(exports, "FIRST_LEVEL_MACRO_CLASSES", {
53480
54512
  enumerable: true,
53481
54513
  get: function() {
@@ -53728,6 +54760,12 @@ Object.defineProperty(exports, "RECORDING_SOURCE_CAMSTACK_ADDON", {
53728
54760
  return RECORDING_SOURCE_CAMSTACK_ADDON;
53729
54761
  }
53730
54762
  });
54763
+ Object.defineProperty(exports, "RebuildObjectEmbeddingsRefusalSchema", {
54764
+ enumerable: true,
54765
+ get: function() {
54766
+ return RebuildObjectEmbeddingsRefusalSchema;
54767
+ }
54768
+ });
53731
54769
  Object.defineProperty(exports, "RetrainStatusSchema", {
53732
54770
  enumerable: true,
53733
54771
  get: function() {
@@ -53926,6 +54964,30 @@ Object.defineProperty(exports, "embeddingEncoderCapability", {
53926
54964
  return embeddingEncoderCapability;
53927
54965
  }
53928
54966
  });
54967
+ Object.defineProperty(exports, "embeddingModelFailedError", {
54968
+ enumerable: true,
54969
+ get: function() {
54970
+ return embeddingModelFailedError;
54971
+ }
54972
+ });
54973
+ Object.defineProperty(exports, "embeddingRefusalOf", {
54974
+ enumerable: true,
54975
+ get: function() {
54976
+ return embeddingRefusalOf;
54977
+ }
54978
+ });
54979
+ Object.defineProperty(exports, "embeddingRequirementsFailedError", {
54980
+ enumerable: true,
54981
+ get: function() {
54982
+ return embeddingRequirementsFailedError;
54983
+ }
54984
+ });
54985
+ Object.defineProperty(exports, "embeddingRequirementsUnavailableError", {
54986
+ enumerable: true,
54987
+ get: function() {
54988
+ return embeddingRequirementsUnavailableError;
54989
+ }
54990
+ });
53929
54991
  Object.defineProperty(exports, "encodeVectorBase64", {
53930
54992
  enumerable: true,
53931
54993
  get: function() {
@@ -53962,12 +55024,6 @@ Object.defineProperty(exports, "failureContributionCapability", {
53962
55024
  return failureContributionCapability;
53963
55025
  }
53964
55026
  });
53965
- Object.defineProperty(exports, "hfModelUrl", {
53966
- enumerable: true,
53967
- get: function() {
53968
- return hfModelUrl;
53969
- }
53970
- });
53971
55027
  Object.defineProperty(exports, "hydrateSchema", {
53972
55028
  enumerable: true,
53973
55029
  get: function() {
@@ -54028,6 +55084,12 @@ Object.defineProperty(exports, "isSystemEventSummaryRule", {
54028
55084
  return isSystemEventSummaryRule;
54029
55085
  }
54030
55086
  });
55087
+ Object.defineProperty(exports, "isVectorIndexDimConflict", {
55088
+ enumerable: true,
55089
+ get: function() {
55090
+ return isVectorIndexDimConflict;
55091
+ }
55092
+ });
54031
55093
  Object.defineProperty(exports, "kebabToCamel", {
54032
55094
  enumerable: true,
54033
55095
  get: function() {
@@ -54052,6 +55114,12 @@ Object.defineProperty(exports, "nodePin", {
54052
55114
  return nodePin;
54053
55115
  }
54054
55116
  });
55117
+ Object.defineProperty(exports, "normalizeNodeId", {
55118
+ enumerable: true,
55119
+ get: function() {
55120
+ return normalizeNodeId;
55121
+ }
55122
+ });
54055
55123
  Object.defineProperty(exports, "notificationRulesCapability", {
54056
55124
  enumerable: true,
54057
55125
  get: function() {
@@ -54088,12 +55156,6 @@ Object.defineProperty(exports, "partialRecord", {
54088
55156
  return partialRecord;
54089
55157
  }
54090
55158
  });
54091
- Object.defineProperty(exports, "pickClusterStepModels", {
54092
- enumerable: true,
54093
- get: function() {
54094
- return pickClusterStepModels;
54095
- }
54096
- });
54097
55159
  Object.defineProperty(exports, "pipelineAnalyticsCapability", {
54098
55160
  enumerable: true,
54099
55161
  get: function() {
@@ -54106,6 +55168,12 @@ Object.defineProperty(exports, "plateGalleryCapability", {
54106
55168
  return plateGalleryCapability;
54107
55169
  }
54108
55170
  });
55171
+ Object.defineProperty(exports, "readClusterModelPinStrict", {
55172
+ enumerable: true,
55173
+ get: function() {
55174
+ return readClusterModelPinStrict;
55175
+ }
55176
+ });
54109
55177
  Object.defineProperty(exports, "readDeviceStateFrom", {
54110
55178
  enumerable: true,
54111
55179
  get: function() {
@@ -54124,6 +55192,18 @@ Object.defineProperty(exports, "record", {
54124
55192
  return record;
54125
55193
  }
54126
55194
  });
55195
+ Object.defineProperty(exports, "resolveClipSearchMinScore", {
55196
+ enumerable: true,
55197
+ get: function() {
55198
+ return resolveClipSearchMinScore;
55199
+ }
55200
+ });
55201
+ Object.defineProperty(exports, "resolveClusterModelPin", {
55202
+ enumerable: true,
55203
+ get: function() {
55204
+ return resolveClusterModelPin;
55205
+ }
55206
+ });
54127
55207
  Object.defineProperty(exports, "resolveLocationMode", {
54128
55208
  enumerable: true,
54129
55209
  get: function() {