@camstack/addon-post-analysis 1.2.285 → 1.2.287
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD_PARTY_MODELS.md +8 -0
- package/dist/{dist-D2tXUMfE.mjs → clip-model-registry-BRHeTbFV.mjs} +1405 -427
- package/dist/{dist-ITESpHou.js → clip-model-registry-Cq1X8kTo.js} +1514 -440
- package/dist/embedding-encoder/index.js +962 -428
- package/dist/embedding-encoder/index.mjs +952 -418
- package/dist/pipeline-analytics/_stub.js +2 -2
- package/dist/pipeline-analytics/{_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_analytics_widgets-7oasHfhD.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_analytics_widgets-BpJC8P0K.mjs} +2 -2
- package/dist/pipeline-analytics/_virtual_mf___mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-3dZf67Z7.mjs +26 -0
- package/dist/pipeline-analytics/_virtual_mf___mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-r4OU_ahc.mjs +26 -0
- package/dist/pipeline-analytics/{hostInit-B6m75Rnz.mjs → hostInit-BIUCfS5T.mjs} +2 -2
- package/dist/pipeline-analytics/index.js +6449 -5096
- package/dist/pipeline-analytics/index.mjs +5109 -3756
- package/dist/pipeline-analytics/remoteEntry.js +1 -1
- package/package.json +1 -1
- package/python/test_text_encoder.py +49 -2
- package/python/text_encoder_inference.py +31 -14
- 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
- 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
|
@@ -5360,7 +5360,7 @@ var ZodIssueCode = {
|
|
|
5360
5360
|
var ZodFirstPartyTypeKind;
|
|
5361
5361
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5362
5362
|
//#endregion
|
|
5363
|
-
//#region ../types/dist/sleep-
|
|
5363
|
+
//#region ../types/dist/sleep-DC-wdyeS.mjs
|
|
5364
5364
|
/**
|
|
5365
5365
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5366
5366
|
* window to float samples (D455).
|
|
@@ -6145,6 +6145,40 @@ var BaseAddon = class {
|
|
|
6145
6145
|
const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
6146
6146
|
return keys.size > 0 ? projectStore(raw, keys, node) : raw;
|
|
6147
6147
|
}
|
|
6148
|
+
/**
|
|
6149
|
+
* Whether ONE global key of this addon's store was written, read three-way
|
|
6150
|
+
* (D651). For a question a hydrated view cannot answer: `getGlobalSettings`
|
|
6151
|
+
* reports `value ?? default`, so "the operator chose the default" and "nobody
|
|
6152
|
+
* chose" look the same, and a failed read looks like both. A `perNode` key is
|
|
6153
|
+
* not supported here: its stored name is scoped.
|
|
6154
|
+
*/
|
|
6155
|
+
async readStoredGlobalKey(key) {
|
|
6156
|
+
const read = this._ctx?.settings?.readAddonStoreResult;
|
|
6157
|
+
if (read === void 0) return {
|
|
6158
|
+
kind: "unreadable",
|
|
6159
|
+
reason: "three-way-read-unavailable"
|
|
6160
|
+
};
|
|
6161
|
+
let result;
|
|
6162
|
+
try {
|
|
6163
|
+
result = await read.call(this._ctx?.settings);
|
|
6164
|
+
} catch (err) {
|
|
6165
|
+
return {
|
|
6166
|
+
kind: "unreadable",
|
|
6167
|
+
reason: "store-read-failed",
|
|
6168
|
+
error: err instanceof Error ? err.message : String(err)
|
|
6169
|
+
};
|
|
6170
|
+
}
|
|
6171
|
+
if (result.kind === "failed") return {
|
|
6172
|
+
kind: "unreadable",
|
|
6173
|
+
reason: "store-read-failed",
|
|
6174
|
+
error: result.error
|
|
6175
|
+
};
|
|
6176
|
+
if (result.kind === "missing" || !Object.prototype.hasOwnProperty.call(result.value, key)) return { kind: "absent" };
|
|
6177
|
+
return {
|
|
6178
|
+
kind: "present",
|
|
6179
|
+
value: result.value[key]
|
|
6180
|
+
};
|
|
6181
|
+
}
|
|
6148
6182
|
async updateGlobalSettings(patch, nodeId) {
|
|
6149
6183
|
const keys = this.perNodeKeys();
|
|
6150
6184
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
@@ -7440,7 +7474,7 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
|
|
|
7440
7474
|
* can answer "may a rule actuate this?" without importing the schema barrel
|
|
7441
7475
|
* (~144MB RSS per runner, D28).
|
|
7442
7476
|
*
|
|
7443
|
-
* Coverage:
|
|
7477
|
+
* Coverage: 88 device-scoped capabilities.
|
|
7444
7478
|
*/
|
|
7445
7479
|
var DEVICE_SCOPED_CAPS = new Set([
|
|
7446
7480
|
"accessories",
|
|
@@ -7470,6 +7504,7 @@ var DEVICE_SCOPED_CAPS = new Set([
|
|
|
7470
7504
|
"detection-pipeline",
|
|
7471
7505
|
"device-admin-link",
|
|
7472
7506
|
"device-discovery",
|
|
7507
|
+
"device-extension",
|
|
7473
7508
|
"device-ops",
|
|
7474
7509
|
"device-status",
|
|
7475
7510
|
"doorbell",
|
|
@@ -9996,6 +10031,60 @@ var FailureCounters = class {
|
|
|
9996
10031
|
this.counters.clear();
|
|
9997
10032
|
}
|
|
9998
10033
|
};
|
|
10034
|
+
var ClipModelMetaSchema = object({
|
|
10035
|
+
/** The paired text encoder's catalog id (the embedding-encoder's text catalog). */
|
|
10036
|
+
textModelId: string().min(1),
|
|
10037
|
+
/** Output dimension of BOTH towers. A vector of any other length is refused. */
|
|
10038
|
+
embeddingDim: number().int().positive(),
|
|
10039
|
+
/**
|
|
10040
|
+
* The `vector-store` index this model's vectors live in. ONE feature space
|
|
10041
|
+
* per index: two models share an index only when their vectors are ranked
|
|
10042
|
+
* against each other, which for CLIP means never across families. MobileCLIP
|
|
10043
|
+
* S1 and S2 share `object-clip` for history (separated by the row's
|
|
10044
|
+
* `modelId`); any other model gets its own.
|
|
10045
|
+
*/
|
|
10046
|
+
vectorIndex: string().regex(/^object-clip(-[a-z0-9][a-z0-9-]*)?$/),
|
|
10047
|
+
/**
|
|
10048
|
+
* The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
|
|
10049
|
+
* must be unique per tokenizer: every model's siblings land in ONE flat
|
|
10050
|
+
* models directory, so two different tokenizers under the same name would
|
|
10051
|
+
* silently overwrite each other (whichever model downloaded last wins, and
|
|
10052
|
+
* the other one tokenises with the wrong vocabulary).
|
|
10053
|
+
*/
|
|
10054
|
+
tokenizerFile: string().min(1),
|
|
10055
|
+
/** Token window the text graph takes (SigLIP2: 64; CLIP BPE: 77). */
|
|
10056
|
+
contextLength: number().int().positive(),
|
|
10057
|
+
/** Id the tokenizer pads with. */
|
|
10058
|
+
padId: number().int().nonnegative(),
|
|
10059
|
+
/**
|
|
10060
|
+
* The search cosine floor at `strictness: 'loose'` — calibrated per model,
|
|
10061
|
+
* because cosine bands are a property of the model: 0.2 keeps 96% of matched
|
|
10062
|
+
* COCO caption-image pairs on MobileCLIP S1 and 2.7% on SigLIP2.
|
|
10063
|
+
*/
|
|
10064
|
+
searchMinScore: number().min(0).max(1)
|
|
10065
|
+
});
|
|
10066
|
+
var ClipSearchStrictnessSchema = _enum([
|
|
10067
|
+
"loose",
|
|
10068
|
+
"balanced",
|
|
10069
|
+
"strict"
|
|
10070
|
+
]);
|
|
10071
|
+
var CLIP_STRICTNESS_FACTOR = {
|
|
10072
|
+
loose: 1,
|
|
10073
|
+
balanced: 1.25,
|
|
10074
|
+
strict: 1.5
|
|
10075
|
+
};
|
|
10076
|
+
/**
|
|
10077
|
+
* The cosine floor a search runs with.
|
|
10078
|
+
*
|
|
10079
|
+
* An explicit `minScore` is honoured verbatim: it is a number a caller chose,
|
|
10080
|
+
* and silently rescaling it would make the same URL mean different things on
|
|
10081
|
+
* two installs. Everything else is relative to the model.
|
|
10082
|
+
*/
|
|
10083
|
+
function resolveClipSearchMinScore(meta, request) {
|
|
10084
|
+
if (request.minScore !== void 0) return request.minScore;
|
|
10085
|
+
const factor = CLIP_STRICTNESS_FACTOR[request.strictness ?? "loose"];
|
|
10086
|
+
return Math.min(1, Math.round(meta.searchMinScore * factor * 1e3) / 1e3);
|
|
10087
|
+
}
|
|
9999
10088
|
var MODEL_FORMATS = [
|
|
10000
10089
|
"onnx",
|
|
10001
10090
|
"coreml",
|
|
@@ -10199,7 +10288,14 @@ var ModelCatalogEntrySchema = object({
|
|
|
10199
10288
|
* applies (Frigate / COCO public catalog). Set on a custom model whose raw
|
|
10200
10289
|
* labels already ARE the CamStack macros (Scrypted identity map).
|
|
10201
10290
|
*/
|
|
10202
|
-
classMap: DetectionCatalogClassMapSchema.optional()
|
|
10291
|
+
classMap: DetectionCatalogClassMapSchema.optional(),
|
|
10292
|
+
/**
|
|
10293
|
+
* The model's CLIP feature-space contract (text encoder, dimension, vector
|
|
10294
|
+
* index, token window, search floor) — see `clip-model.ts`. Present ONLY on a
|
|
10295
|
+
* CLIP image encoder; its absence is what "not a CLIP model" means to the
|
|
10296
|
+
* embedding encoder and the semantic-search store (D649).
|
|
10297
|
+
*/
|
|
10298
|
+
clip: ClipModelMetaSchema.optional()
|
|
10203
10299
|
});
|
|
10204
10300
|
var ConvertTargetSchema = discriminatedUnion("format", [object({
|
|
10205
10301
|
format: literal("openvino"),
|
|
@@ -14649,6 +14745,27 @@ var LinkedDeviceSchema = object({
|
|
|
14649
14745
|
features: array(string()),
|
|
14650
14746
|
producesTrackedEvents: boolean().optional()
|
|
14651
14747
|
});
|
|
14748
|
+
/**
|
|
14749
|
+
* The `linked-devices` extension slot's editable value (D648): the operator's
|
|
14750
|
+
* pick list, exactly what `_linkedDeviceIds` persists. Tree children are NOT
|
|
14751
|
+
* in it — they are always linked and are not a pick.
|
|
14752
|
+
*
|
|
14753
|
+
* `trackedDeviceIds` (D655) is the tracked-event opt-in, exactly what
|
|
14754
|
+
* `_linkedDeviceTrackedIds` persists: which linked devices materialize a
|
|
14755
|
+
* synthetic tracked event on the camera. A read always carries it AS STORED
|
|
14756
|
+
* (an absent key reads as `[]`, which is what the resolver makes of it —
|
|
14757
|
+
* NONE). On a write it is optional: absent leaves the opt-in untouched, so a
|
|
14758
|
+
* card built before D655 cannot erase it by saving the pick list. A present
|
|
14759
|
+
* list REPLACES the opt-in; each id must be a pick, a device the camera links
|
|
14760
|
+
* by structure (the row's `impliedSources`: tree children, a picked
|
|
14761
|
+
* container's child) or already stored — so what was read can always be
|
|
14762
|
+
* written back unchanged, and a NEW opt-in outside the linked set is refused.
|
|
14763
|
+
*/
|
|
14764
|
+
var LinkedDevicesSlotValueSchema = object({
|
|
14765
|
+
deviceIds: array(number().int().positive()),
|
|
14766
|
+
trackedDeviceIds: array(number().int().positive()).optional()
|
|
14767
|
+
});
|
|
14768
|
+
DeviceType.Camera;
|
|
14652
14769
|
/** One camera's resolved linked set, tagged with the camera it belongs to.
|
|
14653
14770
|
* The batch answer needs the tag; the single-device answer already has it
|
|
14654
14771
|
* from the input, which is why `getLinkedDevices` keeps the untagged shape. */
|
|
@@ -15174,11 +15291,128 @@ var EmbeddingResultSchema = object({
|
|
|
15174
15291
|
embedding: array(number()),
|
|
15175
15292
|
inferenceMs: number()
|
|
15176
15293
|
});
|
|
15294
|
+
/** The two CLIP towers the encoder runs; a crash budget is kept per tower. */
|
|
15295
|
+
var EmbeddingTowerSchema = _enum(["image", "text"]);
|
|
15296
|
+
/**
|
|
15297
|
+
* A tower in the terminal `failed` state (D649, D6): it crashed or failed to
|
|
15298
|
+
* load `crashes` times within `windowMs`, and is refused by name until an
|
|
15299
|
+
* operator `resetFailedModels` or a model change — never on a timer.
|
|
15300
|
+
*
|
|
15301
|
+
* `nodeId` is the node whose tower failed. The state lives in THAT node's
|
|
15302
|
+
* encoder process (in memory — a runner respawn clears it), and one node's
|
|
15303
|
+
* answer says nothing about another's.
|
|
15304
|
+
*/
|
|
15305
|
+
var EmbeddingFailedModelSchema = object({
|
|
15306
|
+
modelId: string(),
|
|
15307
|
+
tower: EmbeddingTowerSchema,
|
|
15308
|
+
nodeId: string(),
|
|
15309
|
+
crashes: number(),
|
|
15310
|
+
windowMs: number(),
|
|
15311
|
+
sinceMs: number(),
|
|
15312
|
+
lastReason: string()
|
|
15313
|
+
});
|
|
15314
|
+
/**
|
|
15315
|
+
* A model whose REQUIREMENTS can never be met on this node (D649 round 5):
|
|
15316
|
+
* an id the catalog does not know, a model URL answering 404/410, a declared
|
|
15317
|
+
* sibling (the tokenizer) that is not there. After `attempts` failed builds
|
|
15318
|
+
* it is terminally `requirements-failed`, refused by name until an operator
|
|
15319
|
+
* `resetFailedModels` or a model change — the same exits as a crashed tower.
|
|
15320
|
+
*/
|
|
15321
|
+
var EmbeddingFailedRequirementSchema = object({
|
|
15322
|
+
modelId: string(),
|
|
15323
|
+
tower: EmbeddingTowerSchema,
|
|
15324
|
+
nodeId: string(),
|
|
15325
|
+
attempts: number(),
|
|
15326
|
+
sinceMs: number(),
|
|
15327
|
+
lastReason: string()
|
|
15328
|
+
});
|
|
15177
15329
|
var EmbeddingInfoSchema = object({
|
|
15178
15330
|
modelId: string(),
|
|
15179
15331
|
embeddingDim: number(),
|
|
15180
|
-
ready: boolean()
|
|
15181
|
-
|
|
15332
|
+
ready: boolean(),
|
|
15333
|
+
/**
|
|
15334
|
+
* The node that answered. Absent only from an encoder older than D649's
|
|
15335
|
+
* crash budget — whose `failedModels` is then UNKNOWN (D315), never "none".
|
|
15336
|
+
*/
|
|
15337
|
+
nodeId: string().optional(),
|
|
15338
|
+
/**
|
|
15339
|
+
* Towers in `failed` on the answering node, each row naming it. `undefined`
|
|
15340
|
+
* means the node could not say (pre-budget encoder); a node that has the
|
|
15341
|
+
* budget always answers an array, empty included.
|
|
15342
|
+
*/
|
|
15343
|
+
failedModels: array(EmbeddingFailedModelSchema).optional(),
|
|
15344
|
+
/** Models terminally `requirements-failed` on the answering node; same reading as above. */
|
|
15345
|
+
failedRequirements: array(EmbeddingFailedRequirementSchema).optional()
|
|
15346
|
+
});
|
|
15347
|
+
/**
|
|
15348
|
+
* The THREE codes an encoder refusal can carry (D649, D6). Same shape as
|
|
15349
|
+
* `VECTOR_INDEX_DIM_CONFLICT`: the code rides in the MESSAGE, because an
|
|
15350
|
+
* Error's own properties do not survive the UDS/tRPC hop and its message does,
|
|
15351
|
+
* and both sides go through the helpers below — the encoder builds the
|
|
15352
|
+
* refusal, the live detail plane classifies on it to count refusals per
|
|
15353
|
+
* camera instead of logging one warning per track. The bracketed token
|
|
15354
|
+
* carries the code, the model, the tower and the node so a consumer never
|
|
15355
|
+
* parses prose.
|
|
15356
|
+
*
|
|
15357
|
+
* - `EMBEDDING_MODEL_FAILED`: the tower crashed / failed to load past the crash
|
|
15358
|
+
* budget — terminal until `resetFailedModels` or a model change.
|
|
15359
|
+
* - `EMBEDDING_REQUIREMENTS_UNAVAILABLE`: files or runtime not there right now
|
|
15360
|
+
* (a download or Python that failed, or the cooldown after one) — the next
|
|
15361
|
+
* request past the cooldown tries again.
|
|
15362
|
+
* - `EMBEDDING_REQUIREMENTS_FAILED`: the requirements can never be met (unknown
|
|
15363
|
+
* id, 404/410, missing sibling) and the bounded attempts are spent —
|
|
15364
|
+
* terminal, same exits as a crashed tower.
|
|
15365
|
+
*/
|
|
15366
|
+
var EMBEDDING_MODEL_FAILED = "embedding-model-failed";
|
|
15367
|
+
var EMBEDDING_REQUIREMENTS_UNAVAILABLE = "embedding-requirements-unavailable";
|
|
15368
|
+
var EMBEDDING_REQUIREMENTS_FAILED = "embedding-requirements-failed";
|
|
15369
|
+
var EmbeddingRefusalCodeSchema = _enum([
|
|
15370
|
+
EMBEDDING_MODEL_FAILED,
|
|
15371
|
+
EMBEDDING_REQUIREMENTS_UNAVAILABLE,
|
|
15372
|
+
EMBEDDING_REQUIREMENTS_FAILED
|
|
15373
|
+
]);
|
|
15374
|
+
function embeddingRefusalToken(code, on) {
|
|
15375
|
+
return `[${code} model=${on.modelId} tower=${on.tower} node=${on.nodeId}]`;
|
|
15376
|
+
}
|
|
15377
|
+
/** The encoder's refusal for a crashed tower, carrying {@link EMBEDDING_MODEL_FAILED}. */
|
|
15378
|
+
function embeddingModelFailedError(row) {
|
|
15379
|
+
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.`);
|
|
15380
|
+
}
|
|
15381
|
+
/** The requirements refusal for THIS request, carrying {@link EMBEDDING_REQUIREMENTS_UNAVAILABLE}. */
|
|
15382
|
+
function embeddingRequirementsUnavailableError(on, reason) {
|
|
15383
|
+
return /* @__PURE__ */ new Error(`${embeddingRefusalToken(EMBEDDING_REQUIREMENTS_UNAVAILABLE, on)} ${on.modelId} (${on.tower} tower) on ${on.nodeId}: ${reason}`);
|
|
15384
|
+
}
|
|
15385
|
+
/** The terminal requirements refusal, carrying {@link EMBEDDING_REQUIREMENTS_FAILED}. */
|
|
15386
|
+
function embeddingRequirementsFailedError(row) {
|
|
15387
|
+
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.`);
|
|
15388
|
+
}
|
|
15389
|
+
var EMBEDDING_REFUSAL_TOKEN = new RegExp(`\\[(${EMBEDDING_MODEL_FAILED}|${EMBEDDING_REQUIREMENTS_UNAVAILABLE}|${EMBEDDING_REQUIREMENTS_FAILED}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);
|
|
15390
|
+
/** The refusal `err` (possibly re-wrapped by a transport) carries, or `null` for any other error. */
|
|
15391
|
+
function embeddingRefusalOf(err) {
|
|
15392
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
15393
|
+
const match = EMBEDDING_REFUSAL_TOKEN.exec(message);
|
|
15394
|
+
if (match === null) return null;
|
|
15395
|
+
const code = EmbeddingRefusalCodeSchema.safeParse(match[1]);
|
|
15396
|
+
const tower = EmbeddingTowerSchema.safeParse(match[3]);
|
|
15397
|
+
if (!code.success || !tower.success || match[2] === void 0 || match[4] === void 0) return null;
|
|
15398
|
+
return {
|
|
15399
|
+
code: code.data,
|
|
15400
|
+
modelId: match[2],
|
|
15401
|
+
tower: tower.data,
|
|
15402
|
+
nodeId: match[4]
|
|
15403
|
+
};
|
|
15404
|
+
}
|
|
15405
|
+
/**
|
|
15406
|
+
* ONE provider per node (`placement: any-node`), addressed like every global
|
|
15407
|
+
* collection: the codegen injects a `{ nodeId?, addonId? }` selector on the
|
|
15408
|
+
* void methods and lifts a top-level `nodeId` off the object ones. A call
|
|
15409
|
+
* that names no node is answered by the HUB's provider — never by a merge
|
|
15410
|
+
* across nodes, because no global collection fans out across nodes (only the
|
|
15411
|
+
* providers of one node are `concatCollection`-fanned). So a fleet view of
|
|
15412
|
+
* `failedModels` is one `getInfo({ nodeId })` per node, and every answer
|
|
15413
|
+
* names the node it came from (D649 round 4); a node that cannot be asked is
|
|
15414
|
+
* UNKNOWN to the reader, never "no failures" (D315).
|
|
15415
|
+
*/
|
|
15182
15416
|
var embeddingEncoderCapability = {
|
|
15183
15417
|
name: "embedding-encoder",
|
|
15184
15418
|
scope: "system",
|
|
@@ -15197,8 +15431,30 @@ var embeddingEncoderCapability = {
|
|
|
15197
15431
|
width: number(),
|
|
15198
15432
|
height: number()
|
|
15199
15433
|
}), EmbeddingResultSchema, { auth: "admin" }),
|
|
15200
|
-
|
|
15201
|
-
|
|
15434
|
+
/**
|
|
15435
|
+
* `modelId` (a CLIP IMAGE model id, whose catalog `clip.textModelId` names
|
|
15436
|
+
* the text tower) encodes in that model's space; absent, the cluster row's
|
|
15437
|
+
* `clip-embedding` model — the space every writer is in (D649).
|
|
15438
|
+
*/
|
|
15439
|
+
encodeText: method(object({
|
|
15440
|
+
text: string(),
|
|
15441
|
+
modelId: string().min(1).optional()
|
|
15442
|
+
}), EmbeddingResultSchema, { auth: "admin" }),
|
|
15443
|
+
/** Answers for ONE node — the `nodeId` selector's, else the hub's. */
|
|
15444
|
+
getInfo: method(_void(), EmbeddingInfoSchema, { auth: "admin" }),
|
|
15445
|
+
/**
|
|
15446
|
+
* The operator's explicit clear of the `failed` state (one model, or all)
|
|
15447
|
+
* on ONE node — pass `nodeId` for an agent; the result names the node it
|
|
15448
|
+
* cleared. The only way out besides a model change: a crashing tower is
|
|
15449
|
+
* not retried on a timer.
|
|
15450
|
+
*/
|
|
15451
|
+
resetFailedModels: method(object({ modelId: string().min(1).optional() }), object({
|
|
15452
|
+
cleared: array(string()),
|
|
15453
|
+
nodeId: string()
|
|
15454
|
+
}), {
|
|
15455
|
+
kind: "mutation",
|
|
15456
|
+
auth: "admin"
|
|
15457
|
+
})
|
|
15202
15458
|
}
|
|
15203
15459
|
};
|
|
15204
15460
|
/**
|
|
@@ -18727,7 +18983,12 @@ var NcMediaPolicySchema = object({
|
|
|
18727
18983
|
* the degrade engine, which drops the video and keeps the still.
|
|
18728
18984
|
*/
|
|
18729
18985
|
clip: boolean().optional(),
|
|
18730
|
-
/**
|
|
18986
|
+
/**
|
|
18987
|
+
* Seconds of footage BEFORE / AFTER the event instant. Absent =
|
|
18988
|
+
* {@link NC_CLIP_PRE_ROLL_DEFAULT_SEC} / {@link NC_CLIP_POST_ROLL_DEFAULT_SEC}
|
|
18989
|
+
* (4 / 6), resolved by the Notification Center at dispatch — deliberately not
|
|
18990
|
+
* a Zod default, so a rule that never chose keeps following the hub's.
|
|
18991
|
+
*/
|
|
18731
18992
|
clipPreRollSec: number().int().min(0).max(30).optional(),
|
|
18732
18993
|
clipPostRollSec: number().int().min(0).max(30).optional(),
|
|
18733
18994
|
/**
|
|
@@ -20810,6 +21071,202 @@ var OauthIntegrationDescriptorSchema = object({
|
|
|
20810
21071
|
});
|
|
20811
21072
|
method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
|
|
20812
21073
|
/**
|
|
21074
|
+
* A model choice has a SCOPE, and a scope change has a workflow.
|
|
21075
|
+
*
|
|
21076
|
+
* ## The two scopes
|
|
21077
|
+
*
|
|
21078
|
+
* Almost every pipeline step's model is a **node** question: which build runs
|
|
21079
|
+
* fastest on THIS accelerator. Two nodes may legitimately answer differently —
|
|
21080
|
+
* a Coral runs the tflite SSD, a Mac runs the coreml YOLO — because the answers
|
|
21081
|
+
* are compared against nothing. They produce boxes, and a box is a box.
|
|
21082
|
+
*
|
|
21083
|
+
* Two steps are not like that. `face-embedding` and `clip-embedding` produce
|
|
21084
|
+
* **vectors that land in ONE shared index** (`identity_samples`,
|
|
21085
|
+
* `vec_object_clip`) and are ranked against each other by cosine similarity.
|
|
21086
|
+
* Cosine similarity between two encoders is not a weak signal, it is a
|
|
21087
|
+
* meaningless number — and nothing inside a vector can tell you it happened.
|
|
21088
|
+
* So for those two steps the model is a **cluster** question with exactly one
|
|
21089
|
+
* answer, stored in exactly one row.
|
|
21090
|
+
*
|
|
21091
|
+
* That is the same argument [D52](../../../../docs/decisions/adr-0052.md) makes
|
|
21092
|
+
* for the crop convention (`detail-crop.ts`), one level up: the crop decides
|
|
21093
|
+
* WHAT pixels the encoder sees, this decides WHICH encoder sees them. Both are
|
|
21094
|
+
* cluster-wide for the same reason and neither may become per-node.
|
|
21095
|
+
*
|
|
21096
|
+
* ## Why the registry lives here and not in the step catalog
|
|
21097
|
+
*
|
|
21098
|
+
* The scope itself is declared on the step, in
|
|
21099
|
+
* `detection-pipeline/registry/step-definitions.ts` (`StepDefinition.modelScope`)
|
|
21100
|
+
* — that is where a new step declares what kind of choice its model is. But the
|
|
21101
|
+
* catalog lives inside `addon-pipeline`, and three packages that must NOT
|
|
21102
|
+
* import an addon need to know the set: the orchestrator (which renders and
|
|
21103
|
+
* stores the row), post-analysis (which pins the row for a re-embed pass) and
|
|
21104
|
+
* admin-ui (which mirrors it). So the set is mirrored here, and
|
|
21105
|
+
* `scripts/check-cluster-model-scope.ts` fails the build when the two disagree.
|
|
21106
|
+
* A hand-copied key that stops matching is exactly how a setting silently stops
|
|
21107
|
+
* arriving while both sides still look correct.
|
|
21108
|
+
*
|
|
21109
|
+
* ## The defaults ARE today's behaviour
|
|
21110
|
+
*
|
|
21111
|
+
* {@link DEFAULT_CLUSTER_STEP_MODELS} reproduces the catalog `defaultModelId`
|
|
21112
|
+
* of both steps. Declaring the scope therefore changes nothing on the day it
|
|
21113
|
+
* ships: the cluster row starts out saying what every node was already doing.
|
|
21114
|
+
* Changing it is legitimate — that is what the knob is for — but it invalidates
|
|
21115
|
+
* the stored vectors of that surface, and must be followed by a re-embed pass
|
|
21116
|
+
* (`face-reembed-pass.ts`, `embedding-rebuild.ts`).
|
|
21117
|
+
*/
|
|
21118
|
+
/**
|
|
21119
|
+
* Why the orchestrator cannot say which model the operator chose for a
|
|
21120
|
+
* cluster-scoped step (D651).
|
|
21121
|
+
*/
|
|
21122
|
+
var CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS = [
|
|
21123
|
+
"owner-not-ready",
|
|
21124
|
+
"store-read-failed",
|
|
21125
|
+
"three-way-read-unavailable",
|
|
21126
|
+
"invalid-stored",
|
|
21127
|
+
"not-cluster-scoped"
|
|
21128
|
+
];
|
|
21129
|
+
/**
|
|
21130
|
+
* The cluster-scoped steps. Mirrored from the catalog's `modelScope: 'cluster'`
|
|
21131
|
+
* declarations and guarded by `scripts/check-cluster-model-scope.ts`.
|
|
21132
|
+
*/
|
|
21133
|
+
var CLUSTER_MODEL_SCOPED_STEPS = [{
|
|
21134
|
+
stepId: "face-embedding",
|
|
21135
|
+
label: "Face recognition model",
|
|
21136
|
+
defaultModelId: "auraface-r100",
|
|
21137
|
+
indexName: "the enrolled face gallery",
|
|
21138
|
+
options: [
|
|
21139
|
+
{
|
|
21140
|
+
id: "auraface-r100",
|
|
21141
|
+
label: "AuraFace R100"
|
|
21142
|
+
},
|
|
21143
|
+
{
|
|
21144
|
+
id: "arcface-r100",
|
|
21145
|
+
label: "ArcFace (ResNet34)"
|
|
21146
|
+
},
|
|
21147
|
+
{
|
|
21148
|
+
id: "inception-resnet-v1",
|
|
21149
|
+
label: "Inception ResNet V1"
|
|
21150
|
+
}
|
|
21151
|
+
]
|
|
21152
|
+
}, {
|
|
21153
|
+
stepId: "clip-embedding",
|
|
21154
|
+
label: "Semantic search model",
|
|
21155
|
+
defaultModelId: "mobileclip-s1",
|
|
21156
|
+
indexName: "the object semantic-search index",
|
|
21157
|
+
options: [
|
|
21158
|
+
{
|
|
21159
|
+
id: "mobileclip-s1",
|
|
21160
|
+
label: "MobileCLIP S1"
|
|
21161
|
+
},
|
|
21162
|
+
{
|
|
21163
|
+
id: "mobileclip-s2",
|
|
21164
|
+
label: "MobileCLIP S2"
|
|
21165
|
+
},
|
|
21166
|
+
{
|
|
21167
|
+
id: "siglip2-b16-224",
|
|
21168
|
+
label: "SigLIP2 B/16 (Apache-2.0)"
|
|
21169
|
+
}
|
|
21170
|
+
]
|
|
21171
|
+
}];
|
|
21172
|
+
/**
|
|
21173
|
+
* The settings key holding one step's cluster model choice.
|
|
21174
|
+
*
|
|
21175
|
+
* Step-qualified so the keys stay unique across the addon's whole schema, which
|
|
21176
|
+
* is what lets {@link pickClusterStepModels} walk every section instead of
|
|
21177
|
+
* trusting the section id.
|
|
21178
|
+
*/
|
|
21179
|
+
function clusterModelSettingKey(stepId) {
|
|
21180
|
+
return `clusterModel:${stepId}`;
|
|
21181
|
+
}
|
|
21182
|
+
/** The cluster row when nobody has configured one — today's catalog defaults. */
|
|
21183
|
+
var DEFAULT_CLUSTER_STEP_MODELS = Object.freeze(Object.fromEntries(CLUSTER_MODEL_SCOPED_STEPS.map((s) => [s.stepId, s.defaultModelId])));
|
|
21184
|
+
function interpretStoredClusterModel(raw) {
|
|
21185
|
+
if (raw === void 0 || raw === null || raw === "") return { kind: "absent" };
|
|
21186
|
+
if (typeof raw === "string") return {
|
|
21187
|
+
kind: "chosen",
|
|
21188
|
+
modelId: raw
|
|
21189
|
+
};
|
|
21190
|
+
return {
|
|
21191
|
+
kind: "invalid",
|
|
21192
|
+
value: raw
|
|
21193
|
+
};
|
|
21194
|
+
}
|
|
21195
|
+
/**
|
|
21196
|
+
* Narrow a FLAT settings record to the cluster row.
|
|
21197
|
+
*
|
|
21198
|
+
* Per-FIELD fallback, deliberately (same rule as `readDetailCropConvention`): a
|
|
21199
|
+
* junk face model must not also discard a valid clip model. An `absent` or
|
|
21200
|
+
* `invalid` value ({@link interpretStoredClusterModel}) resolves to the step's
|
|
21201
|
+
* catalog default — never to a blank id, because a blank id downstream becomes
|
|
21202
|
+
* "substitute the format default", which is precisely the substitution this
|
|
21203
|
+
* scope exists to forbid.
|
|
21204
|
+
*/
|
|
21205
|
+
function readClusterStepModels(config) {
|
|
21206
|
+
const out = {};
|
|
21207
|
+
for (const step of CLUSTER_MODEL_SCOPED_STEPS) {
|
|
21208
|
+
const read = interpretStoredClusterModel(config[clusterModelSettingKey(step.stepId)]);
|
|
21209
|
+
out[step.stepId] = read.kind === "chosen" ? read.modelId : step.defaultModelId;
|
|
21210
|
+
}
|
|
21211
|
+
return out;
|
|
21212
|
+
}
|
|
21213
|
+
function isHydratedField$2(entry) {
|
|
21214
|
+
return typeof entry === "object" && entry !== null && "key" in entry;
|
|
21215
|
+
}
|
|
21216
|
+
/**
|
|
21217
|
+
* Extract the cluster row from an `addon-settings.getGlobalSettings` payload.
|
|
21218
|
+
*
|
|
21219
|
+
* Walks EVERY section rather than looking inside {@link CLUSTER_MODEL_SECTION_ID}
|
|
21220
|
+
* alone: the keys are unique across the addon's schema, and a section rename
|
|
21221
|
+
* must not silently revert the whole cluster to the defaults. A `null` payload
|
|
21222
|
+
* (addon mid-boot) is the defaults.
|
|
21223
|
+
*/
|
|
21224
|
+
function pickClusterStepModels(view) {
|
|
21225
|
+
if (view === null) return DEFAULT_CLUSTER_STEP_MODELS;
|
|
21226
|
+
return readClusterStepModels(flattenHydratedView(view, clusterModelKeys()));
|
|
21227
|
+
}
|
|
21228
|
+
function clusterModelKeys() {
|
|
21229
|
+
return new Set(CLUSTER_MODEL_SCOPED_STEPS.map((s) => clusterModelSettingKey(s.stepId)));
|
|
21230
|
+
}
|
|
21231
|
+
/** The `wanted` keys of a hydrated view as one flat record, every section walked. */
|
|
21232
|
+
function flattenHydratedView(view, wanted) {
|
|
21233
|
+
const flat = {};
|
|
21234
|
+
for (const section of view.sections) for (const entry of section.fields) {
|
|
21235
|
+
if (!isHydratedField$2(entry) || typeof entry.key !== "string") continue;
|
|
21236
|
+
if (wanted.has(entry.key)) flat[entry.key] = entry.value;
|
|
21237
|
+
}
|
|
21238
|
+
return flat;
|
|
21239
|
+
}
|
|
21240
|
+
var CLUSTER_STEP_SETTING_FIELDS = [{
|
|
21241
|
+
stepId: "face-embedding",
|
|
21242
|
+
key: "minLandmarkFaceSize",
|
|
21243
|
+
label: "Min face size for recognition (detection px)",
|
|
21244
|
+
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.",
|
|
21245
|
+
type: "slider",
|
|
21246
|
+
min: 0,
|
|
21247
|
+
max: 64,
|
|
21248
|
+
step: 2,
|
|
21249
|
+
default: 24
|
|
21250
|
+
}];
|
|
21251
|
+
function clusterStepSettingKey(stepId, fieldKey) {
|
|
21252
|
+
return `clusterStepSetting:${stepId}:${fieldKey}`;
|
|
21253
|
+
}
|
|
21254
|
+
var ClusterSettingNumberSchema = number().finite();
|
|
21255
|
+
function readClusterStepSettings(config) {
|
|
21256
|
+
const out = {};
|
|
21257
|
+
for (const field of CLUSTER_STEP_SETTING_FIELDS) {
|
|
21258
|
+
const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
|
|
21259
|
+
const value = parsed.success ? parsed.data : field.default;
|
|
21260
|
+
const existing = out[field.stepId] ?? {};
|
|
21261
|
+
out[field.stepId] = {
|
|
21262
|
+
...existing,
|
|
21263
|
+
[field.key]: value
|
|
21264
|
+
};
|
|
21265
|
+
}
|
|
21266
|
+
return out;
|
|
21267
|
+
}
|
|
21268
|
+
readClusterStepSettings({});
|
|
21269
|
+
/**
|
|
20813
21270
|
* pipeline-analytics — device-scoped wrapper cap. Refines raw
|
|
20814
21271
|
* per-frame detections emitted by the pipeline runner into tracked
|
|
20815
21272
|
* objects, per-kind event collections (motion / object / audio), and
|
|
@@ -21625,7 +22082,8 @@ var MediaFileKindEnum = _enum([
|
|
|
21625
22082
|
"thumbnailSmall",
|
|
21626
22083
|
"confirmationCrop",
|
|
21627
22084
|
"debugCrop",
|
|
21628
|
-
"sceneFrame"
|
|
22085
|
+
"sceneFrame",
|
|
22086
|
+
"lastSceneFrame"
|
|
21629
22087
|
]);
|
|
21630
22088
|
/**
|
|
21631
22089
|
* One media row ON THE WIRE: what it is, how big it is, and WHERE ITS BYTES
|
|
@@ -22177,7 +22635,23 @@ var SearchObjectEventsInput = object({
|
|
|
22177
22635
|
until: number().optional(),
|
|
22178
22636
|
classFilter: string().optional(),
|
|
22179
22637
|
limit: number().default(50),
|
|
22180
|
-
|
|
22638
|
+
/**
|
|
22639
|
+
* An ABSOLUTE cosine floor. Optional since D649: a floor is a property of the
|
|
22640
|
+
* model (0.2 kept 96% of matched pairs on MobileCLIP S1 and 2.7% on SigLIP2),
|
|
22641
|
+
* so an absent one resolves to the searched model's own `searchMinScore`
|
|
22642
|
+
* scaled by `strictness`. A number sent here is honoured verbatim.
|
|
22643
|
+
*/
|
|
22644
|
+
minScore: number().min(0).max(1).optional(),
|
|
22645
|
+
/** Model-relative floor — see `resolveClipSearchMinScore`. Default `loose`. */
|
|
22646
|
+
strictness: ClipSearchStrictnessSchema.optional(),
|
|
22647
|
+
/**
|
|
22648
|
+
* Search THIS CLIP model's index instead of the cluster row's. Every index a
|
|
22649
|
+
* model ever wrote stays searchable until it is wiped (the MobileCLIP index
|
|
22650
|
+
* through a SigLIP2 cutover and its rollback window). An id with no CLIP
|
|
22651
|
+
* metadata is refused; an id other than the cluster row's is ADMIN-only
|
|
22652
|
+
* (`model-override-requires-admin`).
|
|
22653
|
+
*/
|
|
22654
|
+
modelId: string().min(1).optional()
|
|
22181
22655
|
});
|
|
22182
22656
|
var TrackCascadeCountsSchema = object({
|
|
22183
22657
|
/** Persisted track roots deleted (authoritative). */
|
|
@@ -22312,7 +22786,41 @@ var RebuildObjectEmbeddingsInput = object({
|
|
|
22312
22786
|
* comparable, so wiping and rebuilding is the only way to be sure every vector
|
|
22313
22787
|
* means the same thing.
|
|
22314
22788
|
*/
|
|
22315
|
-
var WipeObjectEmbeddingsResultSchema = object({
|
|
22789
|
+
var WipeObjectEmbeddingsResultSchema = object({
|
|
22790
|
+
deleted: number(),
|
|
22791
|
+
/**
|
|
22792
|
+
* CLIP indexes that could NOT be emptied (unreachable, or refused at their
|
|
22793
|
+
* dimension) — not a clean slate. Additive and optional (D649).
|
|
22794
|
+
*/
|
|
22795
|
+
failedIndexes: array(string()).optional()
|
|
22796
|
+
});
|
|
22797
|
+
/**
|
|
22798
|
+
* Why a rebuild did not start, BY NAME — ONE vocabulary for both gates in front
|
|
22799
|
+
* of a pass (D649 over D651). A bare `started: false` read the same for "the
|
|
22800
|
+
* stores are booting" and "the cluster row names a model with no CLIP
|
|
22801
|
+
* metadata", which need different fixes.
|
|
22802
|
+
* - `stores-unavailable` — the analytics stores or the API are not up yet.
|
|
22803
|
+
* - the owner's confirmation of the cluster model (D651, `ClusterPinConfirmer`):
|
|
22804
|
+
* a pass that rewrites an index needs two agreeing reads of the OWNER's
|
|
22805
|
+
* answer (`pipelineOrchestrator.getClusterModelChoice`) — a pass that cannot
|
|
22806
|
+
* name its model does not run (D54):
|
|
22807
|
+
* - the owner's own `unreadable` reasons (`owner-not-ready`,
|
|
22808
|
+
* `store-read-failed`, `three-way-read-unavailable`, `invalid-stored`,
|
|
22809
|
+
* `not-cluster-scoped`);
|
|
22810
|
+
* - `method-unavailable` — the orchestrator predates the method;
|
|
22811
|
+
* - `read-failed` — the call failed or answered something unparseable;
|
|
22812
|
+
* - `reads-disagree` — the two reads named different choices.
|
|
22813
|
+
* - `not-a-clip-model` — the CONFIRMED id has no CLIP metadata, so there is no
|
|
22814
|
+
* index to fill and no dimension to check against (D649).
|
|
22815
|
+
*/
|
|
22816
|
+
var RebuildObjectEmbeddingsRefusalSchema = _enum([
|
|
22817
|
+
"stores-unavailable",
|
|
22818
|
+
...CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS,
|
|
22819
|
+
"method-unavailable",
|
|
22820
|
+
"read-failed",
|
|
22821
|
+
"reads-disagree",
|
|
22822
|
+
"not-a-clip-model"
|
|
22823
|
+
]);
|
|
22316
22824
|
/**
|
|
22317
22825
|
* Acknowledgement that a rebuild STARTED.
|
|
22318
22826
|
*
|
|
@@ -22325,7 +22833,12 @@ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
|
|
|
22325
22833
|
var RebuildObjectEmbeddingsResultSchema = object({
|
|
22326
22834
|
started: boolean(),
|
|
22327
22835
|
/** True when a pass was already running; the new request is ignored. */
|
|
22328
|
-
alreadyRunning: boolean()
|
|
22836
|
+
alreadyRunning: boolean(),
|
|
22837
|
+
/** Present when the pass refused to start — see `RebuildObjectEmbeddingsRefusalSchema`. */
|
|
22838
|
+
refusal: RebuildObjectEmbeddingsRefusalSchema.optional(),
|
|
22839
|
+
/** The CLIP model the pass pinned, and the index it fills (when it started). */
|
|
22840
|
+
modelId: string().optional(),
|
|
22841
|
+
index: string().optional()
|
|
22329
22842
|
});
|
|
22330
22843
|
var RebuildStatusSchema = object({
|
|
22331
22844
|
running: boolean(),
|
|
@@ -22359,7 +22872,11 @@ var RebuildStatusSchema = object({
|
|
|
22359
22872
|
startedAtMs: number().nullable(),
|
|
22360
22873
|
finishedAtMs: number().nullable(),
|
|
22361
22874
|
/** Present when the pass ended by throwing. */
|
|
22362
|
-
error: string().nullable()
|
|
22875
|
+
error: string().nullable(),
|
|
22876
|
+
/** The CLIP model the current / last pass pinned (D54), `null` before any. */
|
|
22877
|
+
modelId: string().nullable(),
|
|
22878
|
+
/** The index that pass fills — `ClipModelMeta.vectorIndex` of `modelId` (D649). */
|
|
22879
|
+
index: string().nullable()
|
|
22363
22880
|
});
|
|
22364
22881
|
/**
|
|
22365
22882
|
* Acknowledgement that a debug-media reclaim STARTED.
|
|
@@ -23318,7 +23835,7 @@ var pipelineAnalyticsCapability = {
|
|
|
23318
23835
|
* ObjectEvents by trackId. Returns up to `limit` events scored ≥
|
|
23319
23836
|
* `minScore`, sorted descending by score.
|
|
23320
23837
|
*/
|
|
23321
|
-
searchObjectEvents: method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()),
|
|
23838
|
+
searchObjectEvents: method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly(), { caller: "required" }),
|
|
23322
23839
|
wipeObjectEmbeddings: method(object({}), WipeObjectEmbeddingsResultSchema, {
|
|
23323
23840
|
kind: "mutation",
|
|
23324
23841
|
auth: "admin"
|
|
@@ -23798,7 +24315,14 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
|
|
|
23798
24315
|
height: number()
|
|
23799
24316
|
}), { kind: "mutation" }), method(object({
|
|
23800
24317
|
stepId: string(),
|
|
23801
|
-
frameId: number().int()
|
|
24318
|
+
frameId: number().int(),
|
|
24319
|
+
/**
|
|
24320
|
+
* The model to time — REQUIRED (D658). Without it the pool answered the
|
|
24321
|
+
* step's ACTIVE variant (the first loaded after boot), so a benchmark
|
|
24322
|
+
* of model B silently timed model A. Callers pass the `rootModelId`
|
|
24323
|
+
* their warmup `runPipeline` reported: the model that actually ran.
|
|
24324
|
+
*/
|
|
24325
|
+
modelId: string().min(1)
|
|
23802
24326
|
}), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(object({ deviceKey: string().optional() }), EffectiveTuningSchema), method(_void(), array(object({
|
|
23803
24327
|
engineKey: string(),
|
|
23804
24328
|
engine: PipelineEngineChoiceSchema,
|
|
@@ -24415,6 +24939,17 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
|
|
|
24415
24939
|
hubHostnameOverride: string().optional()
|
|
24416
24940
|
})]).describe("Per-camera frame-source mode for the runner (P2c)");
|
|
24417
24941
|
/**
|
|
24942
|
+
* What ONE step runs with on ONE roster device for THIS camera (D650): the
|
|
24943
|
+
* device's per-(node,device) base with the camera's override for that device
|
|
24944
|
+
* on top — the same `override ?? base` merge the orchestrator applies to the
|
|
24945
|
+
* elected device (`applyDeviceProvisioning`). Absent `modelId` ⇒ the executor
|
|
24946
|
+
* resolves the device format's default, exactly as on the elected device.
|
|
24947
|
+
*/
|
|
24948
|
+
var RunnerJumpStepProvisioningSchema = object({
|
|
24949
|
+
modelId: string().optional(),
|
|
24950
|
+
settings: record(string(), unknown()).optional()
|
|
24951
|
+
});
|
|
24952
|
+
/**
|
|
24418
24953
|
* One ENABLED inference device on the runner's node, as the step-tree
|
|
24419
24954
|
* device-jump resolver sees it (phase 1). The orchestrator populates this
|
|
24420
24955
|
* roster on the attach payload whenever the camera is elected onto a specific
|
|
@@ -24426,7 +24961,16 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
|
|
|
24426
24961
|
var RunnerInferenceDeviceSchema = object({
|
|
24427
24962
|
deviceKey: string(),
|
|
24428
24963
|
weight: number().positive().default(1),
|
|
24429
|
-
maxSessions: number().int().positive().nullable().default(null)
|
|
24964
|
+
maxSessions: number().int().positive().nullable().default(null),
|
|
24965
|
+
/**
|
|
24966
|
+
* Per-step provisioning for this camera on THIS device (D650), keyed by step
|
|
24967
|
+
* id. A step the runner jumps here runs with these fields, never with the
|
|
24968
|
+
* elected device's: `modelId` / `settings` are REPLACED on the jumped subtree
|
|
24969
|
+
* (a step absent from the map runs with neither — the target format default).
|
|
24970
|
+
* Absent field ⇒ an orchestrator that predates D650: the jumped step keeps
|
|
24971
|
+
* the elected device's provisioning, as before.
|
|
24972
|
+
*/
|
|
24973
|
+
steps: record(string(), RunnerJumpStepProvisioningSchema).optional()
|
|
24430
24974
|
});
|
|
24431
24975
|
/**
|
|
24432
24976
|
* Camera assignment payload sent by `addon-pipeline-orchestrator` to a
|
|
@@ -25301,6 +25845,28 @@ var NodeInferenceDeviceSchema = object({
|
|
|
25301
25845
|
*/
|
|
25302
25846
|
exclusion: InferenceDeviceExclusionReasonSchema.nullable()
|
|
25303
25847
|
});
|
|
25848
|
+
/**
|
|
25849
|
+
* The operator's model choice for one cluster-scoped step, answered by the
|
|
25850
|
+
* addon that OWNS the `clusterModel:*` settings (D651). Three answers, never
|
|
25851
|
+
* folded: a written choice, a key nobody wrote (the cluster runs the default
|
|
25852
|
+
* BY ABSENCE), or no answer. A caller that rewrites an index acts only on the
|
|
25853
|
+
* first two, read twice and agreeing.
|
|
25854
|
+
*/
|
|
25855
|
+
var ClusterModelChoiceSchema = discriminatedUnion("kind", [
|
|
25856
|
+
object({
|
|
25857
|
+
kind: literal("stored"),
|
|
25858
|
+
modelId: string()
|
|
25859
|
+
}),
|
|
25860
|
+
object({
|
|
25861
|
+
kind: literal("absent"),
|
|
25862
|
+
defaultModelId: string()
|
|
25863
|
+
}),
|
|
25864
|
+
object({
|
|
25865
|
+
kind: literal("unreadable"),
|
|
25866
|
+
reason: _enum(CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS),
|
|
25867
|
+
error: string().optional()
|
|
25868
|
+
})
|
|
25869
|
+
]);
|
|
25304
25870
|
var NodeInferenceDevicesSchema = object({
|
|
25305
25871
|
nodeId: string(),
|
|
25306
25872
|
/** False when the node's platform-probe was unreachable (no live device set). */
|
|
@@ -25328,10 +25894,17 @@ method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
|
|
|
25328
25894
|
}), object({ success: literal(true) }), {
|
|
25329
25895
|
kind: "mutation",
|
|
25330
25896
|
auth: "admin"
|
|
25331
|
-
}), method(object({ deviceId: number() }), object({ deviceKey: string().nullable() })), method(_void(), object({
|
|
25897
|
+
}), method(object({ deviceId: number() }), object({ deviceKey: string().nullable() })), method(_void(), object({
|
|
25898
|
+
migrated: number(),
|
|
25899
|
+
skipped: array(object({
|
|
25900
|
+
deviceId: number(),
|
|
25901
|
+
targetNodeId: string(),
|
|
25902
|
+
reason: string()
|
|
25903
|
+
})).default([])
|
|
25904
|
+
}), {
|
|
25332
25905
|
kind: "mutation",
|
|
25333
25906
|
auth: "admin"
|
|
25334
|
-
}), 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({
|
|
25907
|
+
}), 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({
|
|
25335
25908
|
nodeId: string(),
|
|
25336
25909
|
capName: string(),
|
|
25337
25910
|
addonId: string()
|
|
@@ -27047,6 +27620,20 @@ var VectorScanResultSchema = object({
|
|
|
27047
27620
|
*/
|
|
27048
27621
|
nextCursor: number().int().nonnegative().nullable()
|
|
27049
27622
|
});
|
|
27623
|
+
/**
|
|
27624
|
+
* The ONE error code for "this index exists at another dimension; refusing to
|
|
27625
|
+
* redeclare it" (D649). It rides in the MESSAGE — an Error's own properties do
|
|
27626
|
+
* not survive the UDS/tRPC hop, its message does — and both sides go through
|
|
27627
|
+
* the helpers below, never a copied phrase: a consumer that must tell "this
|
|
27628
|
+
* index can never hold my vectors" from "the provider is unreachable" (a
|
|
27629
|
+
* delete counts the first as nothing-to-delete and the second as still
|
|
27630
|
+
* present) otherwise breaks silently the day the wording changes.
|
|
27631
|
+
*/
|
|
27632
|
+
var VECTOR_INDEX_DIM_CONFLICT = "vector-index-dim-conflict";
|
|
27633
|
+
/** True when `err` (possibly re-wrapped by a transport) is that refusal. */
|
|
27634
|
+
function isVectorIndexDimConflict(err) {
|
|
27635
|
+
return (err instanceof Error ? err.message : String(err)).includes(`[${VECTOR_INDEX_DIM_CONFLICT}]`);
|
|
27636
|
+
}
|
|
27050
27637
|
var VectorStatsInputSchema = object({ index: string() });
|
|
27051
27638
|
var VectorStatsResultSchema = object({
|
|
27052
27639
|
/** Provider id, so an operator can tell brute force from an ANN index. */
|
|
@@ -27706,6 +28293,358 @@ DeviceType.Camera, method(object({
|
|
|
27706
28293
|
auth: "protected"
|
|
27707
28294
|
});
|
|
27708
28295
|
/**
|
|
28296
|
+
* LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
|
|
28297
|
+
* valutatore puro del suo FRONTE.
|
|
28298
|
+
*
|
|
28299
|
+
* Viveva dentro il builtin virtual-doorbell
|
|
28300
|
+
* (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
|
|
28301
|
+
* predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
|
|
28302
|
+
* `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
|
|
28303
|
+
* tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
|
|
28304
|
+
* fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
|
|
28305
|
+
* SPOSTA qui e il doorbell la ri-esporta.
|
|
28306
|
+
*
|
|
28307
|
+
* ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
|
|
28308
|
+
* due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
|
|
28309
|
+
* regola" (e include `presence`, `cover`, `alarm-panel`), questa a "qual è il
|
|
28310
|
+
* booleano il cui FRONTE conta". Vocabolari deliberatamente diversi.
|
|
28311
|
+
*/
|
|
28312
|
+
/**
|
|
28313
|
+
* Known binary / switch source caps → the boolean slice field whose
|
|
28314
|
+
* false→true rise counts as ACTIVE. Every entry is "fire on active".
|
|
28315
|
+
* Sensors whose "active" reading is not a plain boolean (presence's string
|
|
28316
|
+
* state, connectivity's connected flag) are deliberately excluded — a
|
|
28317
|
+
* reconnect is not a doorbell press, and it is not a recording either.
|
|
28318
|
+
*/
|
|
28319
|
+
var SOURCE_CAP_ACTIVE_FIELD = {
|
|
28320
|
+
contact: "entryOpen",
|
|
28321
|
+
binary: "on",
|
|
28322
|
+
switch: "on",
|
|
28323
|
+
motion: "detected",
|
|
28324
|
+
flood: "flooded",
|
|
28325
|
+
gas: "detected",
|
|
28326
|
+
smoke: "detected",
|
|
28327
|
+
"carbon-monoxide": "detected",
|
|
28328
|
+
vibration: "detected",
|
|
28329
|
+
tamper: "tampered"
|
|
28330
|
+
};
|
|
28331
|
+
/**
|
|
28332
|
+
* The same caps → the slice field carrying the ms-epoch timestamp of the
|
|
28333
|
+
* last transition. Every source cap MUST appear here (guarded by a spec):
|
|
28334
|
+
* without a transition timestamp the evaluator cannot tell a genuine rise
|
|
28335
|
+
* from a boot-time hydration when the FIRST slice it ever sees is already
|
|
28336
|
+
* active, and errs towards silence — swallowing the rise.
|
|
28337
|
+
*
|
|
28338
|
+
* These timestamps are UPSTREAM ones, not ingest ones: the Home Assistant
|
|
28339
|
+
* provider derives them from `state.last_changed`, so they survive our own
|
|
28340
|
+
* restarts and correctly read as "hours ago" for a state that has been
|
|
28341
|
+
* active for hours. `motion` names its rise timestamp `lastDetectedAt`.
|
|
28342
|
+
*/
|
|
28343
|
+
var SOURCE_CAP_CHANGED_AT_FIELD = {
|
|
28344
|
+
contact: "lastChangedAt",
|
|
28345
|
+
binary: "lastChangedAt",
|
|
28346
|
+
switch: "lastChangedAt",
|
|
28347
|
+
motion: "lastDetectedAt",
|
|
28348
|
+
flood: "lastChangedAt",
|
|
28349
|
+
gas: "lastChangedAt",
|
|
28350
|
+
smoke: "lastChangedAt",
|
|
28351
|
+
"carbon-monoxide": "lastChangedAt",
|
|
28352
|
+
vibration: "lastChangedAt",
|
|
28353
|
+
tamper: "lastChangedAt"
|
|
28354
|
+
};
|
|
28355
|
+
/** Cap names whose presence in a device's bindings qualify it as a source. */
|
|
28356
|
+
var SOURCE_CAPS = Object.keys(SOURCE_CAP_ACTIVE_FIELD);
|
|
28357
|
+
/** True when a cap is a recognised binary/switch source. */
|
|
28358
|
+
function isSourceCap(capName) {
|
|
28359
|
+
return Object.prototype.hasOwnProperty.call(SOURCE_CAP_ACTIVE_FIELD, capName);
|
|
28360
|
+
}
|
|
28361
|
+
/** Extract the "active" boolean a source cap's slice carries, or null when
|
|
28362
|
+
* the cap is unknown or the field is missing / non-boolean. */
|
|
28363
|
+
function sliceActiveValue(capName, slice) {
|
|
28364
|
+
const field = SOURCE_CAP_ACTIVE_FIELD[capName];
|
|
28365
|
+
if (field === void 0) return null;
|
|
28366
|
+
const raw = slice[field];
|
|
28367
|
+
return typeof raw === "boolean" ? raw : null;
|
|
28368
|
+
}
|
|
28369
|
+
/** Ms-epoch transition timestamp a source cap's slice carries, or null when
|
|
28370
|
+
* it is absent, non-numeric or the zero "never observed" sentinel. */
|
|
28371
|
+
function sliceChangedAt(capName, slice) {
|
|
28372
|
+
const field = SOURCE_CAP_CHANGED_AT_FIELD[capName];
|
|
28373
|
+
if (field === void 0) return null;
|
|
28374
|
+
const raw = slice[field];
|
|
28375
|
+
if (typeof raw !== "number" || !Number.isFinite(raw) || raw <= 0) return null;
|
|
28376
|
+
return raw;
|
|
28377
|
+
}
|
|
28378
|
+
/**
|
|
28379
|
+
* How recent a source's own transition timestamp must be for a FIRST
|
|
28380
|
+
* sighting that is already active to count as a genuine rise rather than a
|
|
28381
|
+
* hydration of long-standing state.
|
|
28382
|
+
*/
|
|
28383
|
+
var DEFAULT_FIRST_SIGHTING_FRESHNESS_MS = 3e4;
|
|
28384
|
+
/**
|
|
28385
|
+
* IL fronte. Puro: nessun orologio proprio, nessuna memoria — il chiamante
|
|
28386
|
+
* porta `prior`, `nowMs` e il proprio `startedAtMs`.
|
|
28387
|
+
*
|
|
28388
|
+
* Il caso della PRIMA slice già attiva è trattato esplicitamente e vale come
|
|
28389
|
+
* fronte solo se il timestamp UPSTREAM della transizione è posteriore a
|
|
28390
|
+
* `startedAtMs` **e** entro `firstSightingFreshnessMs`. Entrambe le metà
|
|
28391
|
+
* servono: la sola freschezza scatterebbe su un'idratazione al boot di uno
|
|
28392
|
+
* stato flippato pochi secondi prima del riavvio, e il solo "dopo che abbiamo
|
|
28393
|
+
* iniziato" scatterebbe, su un processo di lunga vita, per una sorgente
|
|
28394
|
+
* adottata oggi il cui stato è cambiato ieri. Il caso ambiguo ERRA VERSO IL
|
|
28395
|
+
* SILENZIO e lo dichiara (`baseline-seeded-stale-active`).
|
|
28396
|
+
*/
|
|
28397
|
+
function evaluateSensorEdge(input) {
|
|
28398
|
+
const value = sliceActiveValue(input.capName, input.slice);
|
|
28399
|
+
if (value === null) return {
|
|
28400
|
+
edge: "none",
|
|
28401
|
+
value: null,
|
|
28402
|
+
reason: isSourceCap(input.capName) ? "non-boolean-value" : "unknown-cap"
|
|
28403
|
+
};
|
|
28404
|
+
if (input.prior === void 0) {
|
|
28405
|
+
if (!value) return {
|
|
28406
|
+
edge: "none",
|
|
28407
|
+
value,
|
|
28408
|
+
reason: "baseline-seeded-inactive"
|
|
28409
|
+
};
|
|
28410
|
+
const changedAt = sliceChangedAt(input.capName, input.slice);
|
|
28411
|
+
const floor = Math.max(input.startedAtMs, input.nowMs - input.firstSightingFreshnessMs);
|
|
28412
|
+
if (changedAt === null || changedAt < floor) return {
|
|
28413
|
+
edge: "none",
|
|
28414
|
+
value,
|
|
28415
|
+
reason: "baseline-seeded-stale-active"
|
|
28416
|
+
};
|
|
28417
|
+
return {
|
|
28418
|
+
edge: "rising",
|
|
28419
|
+
value: true
|
|
28420
|
+
};
|
|
28421
|
+
}
|
|
28422
|
+
if (input.prior === value) return {
|
|
28423
|
+
edge: "none",
|
|
28424
|
+
value,
|
|
28425
|
+
reason: "no-change"
|
|
28426
|
+
};
|
|
28427
|
+
if (!value) return {
|
|
28428
|
+
edge: "none",
|
|
28429
|
+
value,
|
|
28430
|
+
reason: "falling-edge"
|
|
28431
|
+
};
|
|
28432
|
+
return {
|
|
28433
|
+
edge: "rising",
|
|
28434
|
+
value: true
|
|
28435
|
+
};
|
|
28436
|
+
}
|
|
28437
|
+
/**
|
|
28438
|
+
* Doorbell button cap. Two kinds of providers coexist behind this cap
|
|
28439
|
+
* name (same pattern as `snapshot`):
|
|
28440
|
+
*
|
|
28441
|
+
* - **Native** providers: registered per-device by device-driver
|
|
28442
|
+
* addons via `ctx.registerNativeCap` — either on a
|
|
28443
|
+
* `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
|
|
28444
|
+
* or directly on the camera (Reolink registers at camera level).
|
|
28445
|
+
* Emits an `onPressed` event every time the firmware pushes a
|
|
28446
|
+
* ring; status tracks the last press and a pressCount since start
|
|
28447
|
+
* (diagnostic).
|
|
28448
|
+
*
|
|
28449
|
+
* - **Wrapper** provider: the `virtual-doorbell` system builtin
|
|
28450
|
+
* (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
|
|
28451
|
+
* device (contact / switch / event-emitter …) into a doorbell for
|
|
28452
|
+
* a camera. `defaultActive: false` — the operator explicitly binds
|
|
28453
|
+
* it per camera in the device-bindings UI, then picks the source
|
|
28454
|
+
* device + trigger in the per-device settings.
|
|
28455
|
+
*
|
|
28456
|
+
* The DeviceEventPropagator re-emits `onPressed` on the camera parent
|
|
28457
|
+
* — subscribers listening at the camera level receive ring events
|
|
28458
|
+
* with `via[]` populated. No code on the parent needed.
|
|
28459
|
+
*/
|
|
28460
|
+
var DoorbellStatusSchema = object({
|
|
28461
|
+
/** Ms epoch of the last press. null = never observed since this provider started. */
|
|
28462
|
+
lastPressedAt: number().nullable(),
|
|
28463
|
+
/** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
|
|
28464
|
+
pressCountSinceStart: number()
|
|
28465
|
+
});
|
|
28466
|
+
var DoorbellPressEventSchema = object({
|
|
28467
|
+
deviceId: number(),
|
|
28468
|
+
timestamp: number()
|
|
28469
|
+
});
|
|
28470
|
+
/**
|
|
28471
|
+
* The `doorbell-source` extension slot's editable value (D648): the camera's
|
|
28472
|
+
* virtual-doorbell trigger devices, exactly what the wrapper's
|
|
28473
|
+
* `doorbellSources` persists (as `{ deviceId }` records).
|
|
28474
|
+
*/
|
|
28475
|
+
var DoorbellSourceSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
|
|
28476
|
+
/**
|
|
28477
|
+
* The `doorbell-source` slot — which devices ring this camera's VIRTUAL
|
|
28478
|
+
* doorbell, owned by the `virtual-doorbell` wrapper over its
|
|
28479
|
+
* `doorbellSources` store (D648). A source rings when one of its
|
|
28480
|
+
* `SOURCE_CAPS` rises. Whether the wrapper is bound to the camera at all is a
|
|
28481
|
+
* different authority (`deviceManager.setWrapperActive`, D62) — the slot
|
|
28482
|
+
* reports it, it never writes it.
|
|
28483
|
+
*/
|
|
28484
|
+
var DOORBELL_SOURCE_SLOT = {
|
|
28485
|
+
id: "doorbell-source",
|
|
28486
|
+
label: "Doorbell trigger devices",
|
|
28487
|
+
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.",
|
|
28488
|
+
shape: "association",
|
|
28489
|
+
hostDeviceTypes: [DeviceType.Camera],
|
|
28490
|
+
sourceCaps: SOURCE_CAPS,
|
|
28491
|
+
cardinality: "many",
|
|
28492
|
+
value: DoorbellSourceSlotValueSchema
|
|
28493
|
+
};
|
|
28494
|
+
var doorbellCapability = {
|
|
28495
|
+
name: "doorbell",
|
|
28496
|
+
scope: "device",
|
|
28497
|
+
deviceNative: true,
|
|
28498
|
+
mode: "singleton",
|
|
28499
|
+
kind: "wrapper",
|
|
28500
|
+
defaultActive: false,
|
|
28501
|
+
deviceTypes: [DeviceType.Button, DeviceType.Camera],
|
|
28502
|
+
extensionSlots: [DOORBELL_SOURCE_SLOT],
|
|
28503
|
+
methods: {},
|
|
28504
|
+
events: {
|
|
28505
|
+
/**
|
|
28506
|
+
* Fires once per physical press. Reolink delivers via Baichuan
|
|
28507
|
+
* push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
|
|
28508
|
+
* release/duration — it's a pulse.
|
|
28509
|
+
*/
|
|
28510
|
+
onPressed: { data: DoorbellPressEventSchema } },
|
|
28511
|
+
status: {
|
|
28512
|
+
schema: DoorbellStatusSchema,
|
|
28513
|
+
kind: "push"
|
|
28514
|
+
},
|
|
28515
|
+
/**
|
|
28516
|
+
* Runtime-state slice — last press timestamp + lifetime press count.
|
|
28517
|
+
* Mirrored by the kernel and readable via
|
|
28518
|
+
* `device.state.doorbell.value`. UIs can show "last ring 5m ago"
|
|
28519
|
+
* without subscribing.
|
|
28520
|
+
*/
|
|
28521
|
+
runtimeState: DoorbellStatusSchema,
|
|
28522
|
+
/**
|
|
28523
|
+
* 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.
|
|
28524
|
+
*
|
|
28525
|
+
* See `RuntimeStateDurability`. Enforced by
|
|
28526
|
+
* `scripts/check-runtime-state-durability.ts`.
|
|
28527
|
+
*/
|
|
28528
|
+
durability: "restored"
|
|
28529
|
+
};
|
|
28530
|
+
var ExtensionSlotIdSchema = _enum(["doorbell-source", "linked-devices"]);
|
|
28531
|
+
DeviceType.Camera, DeviceType.Camera;
|
|
28532
|
+
/** A slot's editable value, discriminated on `slot`. */
|
|
28533
|
+
var ExtensionSlotValueSchema = discriminatedUnion("slot", [DoorbellSourceSlotValueSchema.extend({ slot: literal("doorbell-source") }), LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
|
|
28534
|
+
DeviceType.Camera;
|
|
28535
|
+
var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
|
|
28536
|
+
state: literal("unreachable"),
|
|
28537
|
+
reason: string()
|
|
28538
|
+
})]);
|
|
28539
|
+
/** One provider of slots — the D554 source-listing row. */
|
|
28540
|
+
var ExtensionSourceSchema = object({
|
|
28541
|
+
/** The routing prefix of every `slotRef` this provider serves. */
|
|
28542
|
+
source: string(),
|
|
28543
|
+
label: string(),
|
|
28544
|
+
/** Stamped by the dispatcher from the registry (D557). */
|
|
28545
|
+
addonId: string().optional(),
|
|
28546
|
+
availability: ExtensionSourceAvailabilitySchema
|
|
28547
|
+
});
|
|
28548
|
+
/**
|
|
28549
|
+
* How one picked source stands. `missing` — no such device (deleted, or an id
|
|
28550
|
+
* that never existed); `foreign` — a device the slot's owner cannot read from
|
|
28551
|
+
* (slice 2's cross-owner graft source); `unavailable` — it exists but is not a
|
|
28552
|
+
* valid source now (a container, which is never a pick). A source in any of
|
|
28553
|
+
* these states is SHOWN, never silently dropped or re-pointed.
|
|
28554
|
+
*/
|
|
28555
|
+
var ExtensionSourceHealthSchema = _enum([
|
|
28556
|
+
"ok",
|
|
28557
|
+
"missing",
|
|
28558
|
+
"foreign",
|
|
28559
|
+
"unavailable"
|
|
28560
|
+
]);
|
|
28561
|
+
var ExtensionSlotSourceSchema = object({
|
|
28562
|
+
deviceId: number().int(),
|
|
28563
|
+
/** The device's name, or null when it could not be resolved (`missing`). */
|
|
28564
|
+
name: string().nullable(),
|
|
28565
|
+
health: ExtensionSourceHealthSchema,
|
|
28566
|
+
detail: string().optional()
|
|
28567
|
+
});
|
|
28568
|
+
/**
|
|
28569
|
+
* A DIFFERENT authority that gates whether the slot's sources do anything —
|
|
28570
|
+
* reported read-only, named, never written through this contract (D62). The
|
|
28571
|
+
* virtual doorbell's sources ring only while the wrapper is bound to the
|
|
28572
|
+
* camera, and that binding belongs to `deviceManager.setWrapperActive`.
|
|
28573
|
+
* `unknown` means the gate could not be read; it is not "inactive" (D315).
|
|
28574
|
+
*/
|
|
28575
|
+
var ExtensionSlotActivationSchema = object({
|
|
28576
|
+
state: _enum([
|
|
28577
|
+
"active",
|
|
28578
|
+
"inactive",
|
|
28579
|
+
"unknown"
|
|
28580
|
+
]),
|
|
28581
|
+
authority: string(),
|
|
28582
|
+
detail: string().optional()
|
|
28583
|
+
});
|
|
28584
|
+
var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
|
|
28585
|
+
state: literal("ok"),
|
|
28586
|
+
/** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
|
|
28587
|
+
slotRef: string(),
|
|
28588
|
+
slot: ExtensionSlotIdSchema,
|
|
28589
|
+
/** Names the store written (D62), e.g. `virtual-doorbell:doorbellSources`. */
|
|
28590
|
+
authority: string(),
|
|
28591
|
+
/** graft: its switch. association: null — removing every source is "off". */
|
|
28592
|
+
enabled: boolean().nullable(),
|
|
28593
|
+
/** graft: the cap registered on the host. association: null. */
|
|
28594
|
+
projects: string().nullable(),
|
|
28595
|
+
activation: ExtensionSlotActivationSchema.nullable(),
|
|
28596
|
+
value: ExtensionSlotValueSchema,
|
|
28597
|
+
sources: array(ExtensionSlotSourceSchema),
|
|
28598
|
+
/**
|
|
28599
|
+
* Devices the owner links to the host ON ITS OWN, by structure, and that
|
|
28600
|
+
* are therefore not in `value` (D655): a camera's device-tree children, and
|
|
28601
|
+
* the child a picked container stands for (D356 — a container is never a
|
|
28602
|
+
* pick, its children are). Read-only; the editor shows them and may offer
|
|
28603
|
+
* per-device options on them (the linked-devices tracked-event opt-in).
|
|
28604
|
+
* Absent when the owner links nothing beyond the picks, and from an owner
|
|
28605
|
+
* older than D655.
|
|
28606
|
+
*/
|
|
28607
|
+
impliedSources: array(ExtensionSlotSourceSchema).optional()
|
|
28608
|
+
}), object({
|
|
28609
|
+
state: literal("unreachable"),
|
|
28610
|
+
addonId: string(),
|
|
28611
|
+
reason: string()
|
|
28612
|
+
})]);
|
|
28613
|
+
var ExtensionCandidatesSchema = object({ candidates: array(object({
|
|
28614
|
+
deviceId: number().int(),
|
|
28615
|
+
name: string(),
|
|
28616
|
+
type: string(),
|
|
28617
|
+
location: string().nullable(),
|
|
28618
|
+
/** The container a child belongs to — "Spotlight 2" alone does not say which. */
|
|
28619
|
+
parentName: string().nullable(),
|
|
28620
|
+
/** Pre-marked by the owner's suggestion rule. NEVER saved on its own (D356). */
|
|
28621
|
+
suggested: boolean(),
|
|
28622
|
+
/** Why it is suggested ("same location"), null when it is not. */
|
|
28623
|
+
reason: string().nullable()
|
|
28624
|
+
})) });
|
|
28625
|
+
/**
|
|
28626
|
+
* What a write did. `none` — applied in place. `host` / `parent` — the owner
|
|
28627
|
+
* reloaded the host (or, for an accessory child, its parent) because the
|
|
28628
|
+
* write changed what the host REGISTERS (a graft switched on or off, slice 2).
|
|
28629
|
+
*/
|
|
28630
|
+
var ExtensionSetResultSchema = object({
|
|
28631
|
+
applied: literal(true),
|
|
28632
|
+
reload: _enum([
|
|
28633
|
+
"none",
|
|
28634
|
+
"host",
|
|
28635
|
+
"parent"
|
|
28636
|
+
])
|
|
28637
|
+
});
|
|
28638
|
+
var ExtensionSlotRefInputSchema = object({
|
|
28639
|
+
deviceId: number().int(),
|
|
28640
|
+
slotRef: string().min(1)
|
|
28641
|
+
});
|
|
28642
|
+
var ExtensionSetSlotInputSchema = ExtensionSlotRefInputSchema.extend({ value: ExtensionSlotValueSchema });
|
|
28643
|
+
method(object({ deviceId: number().int() }), array(ExtensionSourceSchema)), method(object({ deviceId: number().int() }), array(ExtensionSlotRowSchema)), method(ExtensionSlotRefInputSchema, ExtensionCandidatesSchema), method(ExtensionSetSlotInputSchema, ExtensionSetResultSchema, {
|
|
28644
|
+
kind: "mutation",
|
|
28645
|
+
auth: "admin"
|
|
28646
|
+
});
|
|
28647
|
+
/**
|
|
27709
28648
|
* Optional client-side hints sent at session creation to help the provider
|
|
27710
28649
|
* pick the best native source. All fields optional — a viewer that knows
|
|
27711
28650
|
* nothing still gets a sane default. (Relocated from the retired `webrtc`
|
|
@@ -30155,75 +31094,6 @@ onStatusChanged: { data: object({
|
|
|
30155
31094
|
volatileStateFields: ["lastChangedAt"]
|
|
30156
31095
|
};
|
|
30157
31096
|
/**
|
|
30158
|
-
* Doorbell button cap. Two kinds of providers coexist behind this cap
|
|
30159
|
-
* name (same pattern as `snapshot`):
|
|
30160
|
-
*
|
|
30161
|
-
* - **Native** providers: registered per-device by device-driver
|
|
30162
|
-
* addons via `ctx.registerNativeCap` — either on a
|
|
30163
|
-
* `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
|
|
30164
|
-
* or directly on the camera (Reolink registers at camera level).
|
|
30165
|
-
* Emits an `onPressed` event every time the firmware pushes a
|
|
30166
|
-
* ring; status tracks the last press and a pressCount since start
|
|
30167
|
-
* (diagnostic).
|
|
30168
|
-
*
|
|
30169
|
-
* - **Wrapper** provider: the `virtual-doorbell` system builtin
|
|
30170
|
-
* (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
|
|
30171
|
-
* device (contact / switch / event-emitter …) into a doorbell for
|
|
30172
|
-
* a camera. `defaultActive: false` — the operator explicitly binds
|
|
30173
|
-
* it per camera in the device-bindings UI, then picks the source
|
|
30174
|
-
* device + trigger in the per-device settings.
|
|
30175
|
-
*
|
|
30176
|
-
* The DeviceEventPropagator re-emits `onPressed` on the camera parent
|
|
30177
|
-
* — subscribers listening at the camera level receive ring events
|
|
30178
|
-
* with `via[]` populated. No code on the parent needed.
|
|
30179
|
-
*/
|
|
30180
|
-
var DoorbellStatusSchema = object({
|
|
30181
|
-
/** Ms epoch of the last press. null = never observed since this provider started. */
|
|
30182
|
-
lastPressedAt: number().nullable(),
|
|
30183
|
-
/** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
|
|
30184
|
-
pressCountSinceStart: number()
|
|
30185
|
-
});
|
|
30186
|
-
var DoorbellPressEventSchema = object({
|
|
30187
|
-
deviceId: number(),
|
|
30188
|
-
timestamp: number()
|
|
30189
|
-
});
|
|
30190
|
-
var doorbellCapability = {
|
|
30191
|
-
name: "doorbell",
|
|
30192
|
-
scope: "device",
|
|
30193
|
-
deviceNative: true,
|
|
30194
|
-
mode: "singleton",
|
|
30195
|
-
kind: "wrapper",
|
|
30196
|
-
defaultActive: false,
|
|
30197
|
-
deviceTypes: [DeviceType.Button, DeviceType.Camera],
|
|
30198
|
-
exposesDeviceSettings: true,
|
|
30199
|
-
methods: {},
|
|
30200
|
-
events: {
|
|
30201
|
-
/**
|
|
30202
|
-
* Fires once per physical press. Reolink delivers via Baichuan
|
|
30203
|
-
* push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
|
|
30204
|
-
* release/duration — it's a pulse.
|
|
30205
|
-
*/
|
|
30206
|
-
onPressed: { data: DoorbellPressEventSchema } },
|
|
30207
|
-
status: {
|
|
30208
|
-
schema: DoorbellStatusSchema,
|
|
30209
|
-
kind: "push"
|
|
30210
|
-
},
|
|
30211
|
-
/**
|
|
30212
|
-
* Runtime-state slice — last press timestamp + lifetime press count.
|
|
30213
|
-
* Mirrored by the kernel and readable via
|
|
30214
|
-
* `device.state.doorbell.value`. UIs can show "last ring 5m ago"
|
|
30215
|
-
* without subscribing.
|
|
30216
|
-
*/
|
|
30217
|
-
runtimeState: DoorbellStatusSchema,
|
|
30218
|
-
/**
|
|
30219
|
-
* 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.
|
|
30220
|
-
*
|
|
30221
|
-
* See `RuntimeStateDurability`. Enforced by
|
|
30222
|
-
* `scripts/check-runtime-state-durability.ts`.
|
|
30223
|
-
*/
|
|
30224
|
-
durability: "restored"
|
|
30225
|
-
};
|
|
30226
|
-
/**
|
|
30227
31097
|
* Enum-state sensor — a string value picked from a finite option set.
|
|
30228
31098
|
* Drives HA `sensor` entries with `state_class: enum` (HVAC action
|
|
30229
31099
|
* states, weather conditions, contact-source channels, mode strings).
|
|
@@ -39111,146 +39981,6 @@ function readDeviceStateFrom(runtimeState) {
|
|
|
39111
39981
|
}
|
|
39112
39982
|
}
|
|
39113
39983
|
/**
|
|
39114
|
-
* LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
|
|
39115
|
-
* valutatore puro del suo FRONTE.
|
|
39116
|
-
*
|
|
39117
|
-
* Viveva dentro il builtin virtual-doorbell
|
|
39118
|
-
* (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
|
|
39119
|
-
* predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
|
|
39120
|
-
* `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
|
|
39121
|
-
* tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
|
|
39122
|
-
* fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
|
|
39123
|
-
* SPOSTA qui e il doorbell la ri-esporta.
|
|
39124
|
-
*
|
|
39125
|
-
* ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
|
|
39126
|
-
* due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
|
|
39127
|
-
* regola" (e include `presence`, `cover`, `alarm-panel`), questa a "qual è il
|
|
39128
|
-
* booleano il cui FRONTE conta". Vocabolari deliberatamente diversi.
|
|
39129
|
-
*/
|
|
39130
|
-
/**
|
|
39131
|
-
* Known binary / switch source caps → the boolean slice field whose
|
|
39132
|
-
* false→true rise counts as ACTIVE. Every entry is "fire on active".
|
|
39133
|
-
* Sensors whose "active" reading is not a plain boolean (presence's string
|
|
39134
|
-
* state, connectivity's connected flag) are deliberately excluded — a
|
|
39135
|
-
* reconnect is not a doorbell press, and it is not a recording either.
|
|
39136
|
-
*/
|
|
39137
|
-
var SOURCE_CAP_ACTIVE_FIELD = {
|
|
39138
|
-
contact: "entryOpen",
|
|
39139
|
-
binary: "on",
|
|
39140
|
-
switch: "on",
|
|
39141
|
-
motion: "detected",
|
|
39142
|
-
flood: "flooded",
|
|
39143
|
-
gas: "detected",
|
|
39144
|
-
smoke: "detected",
|
|
39145
|
-
"carbon-monoxide": "detected",
|
|
39146
|
-
vibration: "detected",
|
|
39147
|
-
tamper: "tampered"
|
|
39148
|
-
};
|
|
39149
|
-
/**
|
|
39150
|
-
* The same caps → the slice field carrying the ms-epoch timestamp of the
|
|
39151
|
-
* last transition. Every source cap MUST appear here (guarded by a spec):
|
|
39152
|
-
* without a transition timestamp the evaluator cannot tell a genuine rise
|
|
39153
|
-
* from a boot-time hydration when the FIRST slice it ever sees is already
|
|
39154
|
-
* active, and errs towards silence — swallowing the rise.
|
|
39155
|
-
*
|
|
39156
|
-
* These timestamps are UPSTREAM ones, not ingest ones: the Home Assistant
|
|
39157
|
-
* provider derives them from `state.last_changed`, so they survive our own
|
|
39158
|
-
* restarts and correctly read as "hours ago" for a state that has been
|
|
39159
|
-
* active for hours. `motion` names its rise timestamp `lastDetectedAt`.
|
|
39160
|
-
*/
|
|
39161
|
-
var SOURCE_CAP_CHANGED_AT_FIELD = {
|
|
39162
|
-
contact: "lastChangedAt",
|
|
39163
|
-
binary: "lastChangedAt",
|
|
39164
|
-
switch: "lastChangedAt",
|
|
39165
|
-
motion: "lastDetectedAt",
|
|
39166
|
-
flood: "lastChangedAt",
|
|
39167
|
-
gas: "lastChangedAt",
|
|
39168
|
-
smoke: "lastChangedAt",
|
|
39169
|
-
"carbon-monoxide": "lastChangedAt",
|
|
39170
|
-
vibration: "lastChangedAt",
|
|
39171
|
-
tamper: "lastChangedAt"
|
|
39172
|
-
};
|
|
39173
|
-
/** True when a cap is a recognised binary/switch source. */
|
|
39174
|
-
function isSourceCap(capName) {
|
|
39175
|
-
return Object.prototype.hasOwnProperty.call(SOURCE_CAP_ACTIVE_FIELD, capName);
|
|
39176
|
-
}
|
|
39177
|
-
/** Extract the "active" boolean a source cap's slice carries, or null when
|
|
39178
|
-
* the cap is unknown or the field is missing / non-boolean. */
|
|
39179
|
-
function sliceActiveValue(capName, slice) {
|
|
39180
|
-
const field = SOURCE_CAP_ACTIVE_FIELD[capName];
|
|
39181
|
-
if (field === void 0) return null;
|
|
39182
|
-
const raw = slice[field];
|
|
39183
|
-
return typeof raw === "boolean" ? raw : null;
|
|
39184
|
-
}
|
|
39185
|
-
/** Ms-epoch transition timestamp a source cap's slice carries, or null when
|
|
39186
|
-
* it is absent, non-numeric or the zero "never observed" sentinel. */
|
|
39187
|
-
function sliceChangedAt(capName, slice) {
|
|
39188
|
-
const field = SOURCE_CAP_CHANGED_AT_FIELD[capName];
|
|
39189
|
-
if (field === void 0) return null;
|
|
39190
|
-
const raw = slice[field];
|
|
39191
|
-
if (typeof raw !== "number" || !Number.isFinite(raw) || raw <= 0) return null;
|
|
39192
|
-
return raw;
|
|
39193
|
-
}
|
|
39194
|
-
/**
|
|
39195
|
-
* How recent a source's own transition timestamp must be for a FIRST
|
|
39196
|
-
* sighting that is already active to count as a genuine rise rather than a
|
|
39197
|
-
* hydration of long-standing state.
|
|
39198
|
-
*/
|
|
39199
|
-
var DEFAULT_FIRST_SIGHTING_FRESHNESS_MS = 3e4;
|
|
39200
|
-
/**
|
|
39201
|
-
* IL fronte. Puro: nessun orologio proprio, nessuna memoria — il chiamante
|
|
39202
|
-
* porta `prior`, `nowMs` e il proprio `startedAtMs`.
|
|
39203
|
-
*
|
|
39204
|
-
* Il caso della PRIMA slice già attiva è trattato esplicitamente e vale come
|
|
39205
|
-
* fronte solo se il timestamp UPSTREAM della transizione è posteriore a
|
|
39206
|
-
* `startedAtMs` **e** entro `firstSightingFreshnessMs`. Entrambe le metà
|
|
39207
|
-
* servono: la sola freschezza scatterebbe su un'idratazione al boot di uno
|
|
39208
|
-
* stato flippato pochi secondi prima del riavvio, e il solo "dopo che abbiamo
|
|
39209
|
-
* iniziato" scatterebbe, su un processo di lunga vita, per una sorgente
|
|
39210
|
-
* adottata oggi il cui stato è cambiato ieri. Il caso ambiguo ERRA VERSO IL
|
|
39211
|
-
* SILENZIO e lo dichiara (`baseline-seeded-stale-active`).
|
|
39212
|
-
*/
|
|
39213
|
-
function evaluateSensorEdge(input) {
|
|
39214
|
-
const value = sliceActiveValue(input.capName, input.slice);
|
|
39215
|
-
if (value === null) return {
|
|
39216
|
-
edge: "none",
|
|
39217
|
-
value: null,
|
|
39218
|
-
reason: isSourceCap(input.capName) ? "non-boolean-value" : "unknown-cap"
|
|
39219
|
-
};
|
|
39220
|
-
if (input.prior === void 0) {
|
|
39221
|
-
if (!value) return {
|
|
39222
|
-
edge: "none",
|
|
39223
|
-
value,
|
|
39224
|
-
reason: "baseline-seeded-inactive"
|
|
39225
|
-
};
|
|
39226
|
-
const changedAt = sliceChangedAt(input.capName, input.slice);
|
|
39227
|
-
const floor = Math.max(input.startedAtMs, input.nowMs - input.firstSightingFreshnessMs);
|
|
39228
|
-
if (changedAt === null || changedAt < floor) return {
|
|
39229
|
-
edge: "none",
|
|
39230
|
-
value,
|
|
39231
|
-
reason: "baseline-seeded-stale-active"
|
|
39232
|
-
};
|
|
39233
|
-
return {
|
|
39234
|
-
edge: "rising",
|
|
39235
|
-
value: true
|
|
39236
|
-
};
|
|
39237
|
-
}
|
|
39238
|
-
if (input.prior === value) return {
|
|
39239
|
-
edge: "none",
|
|
39240
|
-
value,
|
|
39241
|
-
reason: "no-change"
|
|
39242
|
-
};
|
|
39243
|
-
if (!value) return {
|
|
39244
|
-
edge: "none",
|
|
39245
|
-
value,
|
|
39246
|
-
reason: "falling-edge"
|
|
39247
|
-
};
|
|
39248
|
-
return {
|
|
39249
|
-
edge: "rising",
|
|
39250
|
-
value: true
|
|
39251
|
-
};
|
|
39252
|
-
}
|
|
39253
|
-
/**
|
|
39254
39984
|
* Accessory device helpers — shared across drivers.
|
|
39255
39985
|
*
|
|
39256
39986
|
* Many vendor-specific drivers register accessory child devices on
|
|
@@ -43090,6 +43820,30 @@ Object.freeze({
|
|
|
43090
43820
|
addonId: null,
|
|
43091
43821
|
access: "create"
|
|
43092
43822
|
},
|
|
43823
|
+
"deviceExtension.listCandidates": {
|
|
43824
|
+
capName: "device-extension",
|
|
43825
|
+
capScope: "device",
|
|
43826
|
+
addonId: null,
|
|
43827
|
+
access: "view"
|
|
43828
|
+
},
|
|
43829
|
+
"deviceExtension.listSlots": {
|
|
43830
|
+
capName: "device-extension",
|
|
43831
|
+
capScope: "device",
|
|
43832
|
+
addonId: null,
|
|
43833
|
+
access: "view"
|
|
43834
|
+
},
|
|
43835
|
+
"deviceExtension.listSources": {
|
|
43836
|
+
capName: "device-extension",
|
|
43837
|
+
capScope: "device",
|
|
43838
|
+
addonId: null,
|
|
43839
|
+
access: "view"
|
|
43840
|
+
},
|
|
43841
|
+
"deviceExtension.setSlot": {
|
|
43842
|
+
capName: "device-extension",
|
|
43843
|
+
capScope: "device",
|
|
43844
|
+
addonId: null,
|
|
43845
|
+
access: "create"
|
|
43846
|
+
},
|
|
43093
43847
|
"deviceManager.addLocation": {
|
|
43094
43848
|
capName: "device-manager",
|
|
43095
43849
|
capScope: "system",
|
|
@@ -43162,12 +43916,6 @@ Object.freeze({
|
|
|
43162
43916
|
addonId: null,
|
|
43163
43917
|
access: "create"
|
|
43164
43918
|
},
|
|
43165
|
-
"deviceManager.applyDeviceSettingsPatch": {
|
|
43166
|
-
capName: "device-manager",
|
|
43167
|
-
capScope: "system",
|
|
43168
|
-
addonId: null,
|
|
43169
|
-
access: "create"
|
|
43170
|
-
},
|
|
43171
43919
|
"deviceManager.applyInitialMeta": {
|
|
43172
43920
|
capName: "device-manager",
|
|
43173
43921
|
capScope: "system",
|
|
@@ -43270,12 +44018,6 @@ Object.freeze({
|
|
|
43270
44018
|
addonId: null,
|
|
43271
44019
|
access: "view"
|
|
43272
44020
|
},
|
|
43273
|
-
"deviceManager.getDeviceLiveContribution": {
|
|
43274
|
-
capName: "device-manager",
|
|
43275
|
-
capScope: "system",
|
|
43276
|
-
addonId: null,
|
|
43277
|
-
access: "view"
|
|
43278
|
-
},
|
|
43279
44021
|
"deviceManager.getDeviceLiveInfoAggregate": {
|
|
43280
44022
|
capName: "device-manager",
|
|
43281
44023
|
capScope: "system",
|
|
@@ -43288,12 +44030,6 @@ Object.freeze({
|
|
|
43288
44030
|
addonId: null,
|
|
43289
44031
|
access: "view"
|
|
43290
44032
|
},
|
|
43291
|
-
"deviceManager.getDeviceSettingsContribution": {
|
|
43292
|
-
capName: "device-manager",
|
|
43293
|
-
capScope: "system",
|
|
43294
|
-
addonId: null,
|
|
43295
|
-
access: "view"
|
|
43296
|
-
},
|
|
43297
44033
|
"deviceManager.getDeviceStatusAggregate": {
|
|
43298
44034
|
capName: "device-manager",
|
|
43299
44035
|
capScope: "system",
|
|
@@ -43798,24 +44534,6 @@ Object.freeze({
|
|
|
43798
44534
|
addonId: null,
|
|
43799
44535
|
access: "view"
|
|
43800
44536
|
},
|
|
43801
|
-
"doorbell.applyDeviceSettingsPatch": {
|
|
43802
|
-
capName: "doorbell",
|
|
43803
|
-
capScope: "device",
|
|
43804
|
-
addonId: null,
|
|
43805
|
-
access: "create"
|
|
43806
|
-
},
|
|
43807
|
-
"doorbell.getDeviceLiveContribution": {
|
|
43808
|
-
capName: "doorbell",
|
|
43809
|
-
capScope: "device",
|
|
43810
|
-
addonId: null,
|
|
43811
|
-
access: "view"
|
|
43812
|
-
},
|
|
43813
|
-
"doorbell.getDeviceSettingsContribution": {
|
|
43814
|
-
capName: "doorbell",
|
|
43815
|
-
capScope: "device",
|
|
43816
|
-
addonId: null,
|
|
43817
|
-
access: "view"
|
|
43818
|
-
},
|
|
43819
44537
|
"doorbell.getStatus": {
|
|
43820
44538
|
capName: "doorbell",
|
|
43821
44539
|
capScope: "device",
|
|
@@ -43840,6 +44558,12 @@ Object.freeze({
|
|
|
43840
44558
|
addonId: null,
|
|
43841
44559
|
access: "view"
|
|
43842
44560
|
},
|
|
44561
|
+
"embeddingEncoder.resetFailedModels": {
|
|
44562
|
+
capName: "embedding-encoder",
|
|
44563
|
+
capScope: "system",
|
|
44564
|
+
addonId: null,
|
|
44565
|
+
access: "delete"
|
|
44566
|
+
},
|
|
43843
44567
|
"enumSensor.getStatus": {
|
|
43844
44568
|
capName: "enum-sensor",
|
|
43845
44569
|
capScope: "device",
|
|
@@ -46174,6 +46898,12 @@ Object.freeze({
|
|
|
46174
46898
|
addonId: null,
|
|
46175
46899
|
access: "view"
|
|
46176
46900
|
},
|
|
46901
|
+
"pipelineOrchestrator.getClusterModelChoice": {
|
|
46902
|
+
capName: "pipeline-orchestrator",
|
|
46903
|
+
capScope: "system",
|
|
46904
|
+
addonId: null,
|
|
46905
|
+
access: "view"
|
|
46906
|
+
},
|
|
46177
46907
|
"pipelineOrchestrator.getDeviceLiveContribution": {
|
|
46178
46908
|
capName: "pipeline-orchestrator",
|
|
46179
46909
|
capScope: "system",
|
|
@@ -48999,6 +49729,26 @@ Object.freeze({
|
|
|
48999
49729
|
form: "single",
|
|
49000
49730
|
optional: false
|
|
49001
49731
|
}],
|
|
49732
|
+
"deviceExtension.listCandidates": [{
|
|
49733
|
+
name: "deviceId",
|
|
49734
|
+
form: "single",
|
|
49735
|
+
optional: false
|
|
49736
|
+
}],
|
|
49737
|
+
"deviceExtension.listSlots": [{
|
|
49738
|
+
name: "deviceId",
|
|
49739
|
+
form: "single",
|
|
49740
|
+
optional: false
|
|
49741
|
+
}],
|
|
49742
|
+
"deviceExtension.listSources": [{
|
|
49743
|
+
name: "deviceId",
|
|
49744
|
+
form: "single",
|
|
49745
|
+
optional: false
|
|
49746
|
+
}],
|
|
49747
|
+
"deviceExtension.setSlot": [{
|
|
49748
|
+
name: "deviceId",
|
|
49749
|
+
form: "single",
|
|
49750
|
+
optional: false
|
|
49751
|
+
}],
|
|
49002
49752
|
"deviceManager.adoptionRelease": [{
|
|
49003
49753
|
name: "camDeviceId",
|
|
49004
49754
|
form: "single",
|
|
@@ -52621,169 +53371,6 @@ function readTimelapseGeneratedAt(rule, deviceId) {
|
|
|
52621
53371
|
if (map !== void 0) return map[String(deviceId)] ?? 0;
|
|
52622
53372
|
return rule.lastGeneratedAt ?? 0;
|
|
52623
53373
|
}
|
|
52624
|
-
/**
|
|
52625
|
-
* A model choice has a SCOPE, and a scope change has a workflow.
|
|
52626
|
-
*
|
|
52627
|
-
* ## The two scopes
|
|
52628
|
-
*
|
|
52629
|
-
* Almost every pipeline step's model is a **node** question: which build runs
|
|
52630
|
-
* fastest on THIS accelerator. Two nodes may legitimately answer differently —
|
|
52631
|
-
* a Coral runs the tflite SSD, a Mac runs the coreml YOLO — because the answers
|
|
52632
|
-
* are compared against nothing. They produce boxes, and a box is a box.
|
|
52633
|
-
*
|
|
52634
|
-
* Two steps are not like that. `face-embedding` and `clip-embedding` produce
|
|
52635
|
-
* **vectors that land in ONE shared index** (`identity_samples`,
|
|
52636
|
-
* `vec_object_clip`) and are ranked against each other by cosine similarity.
|
|
52637
|
-
* Cosine similarity between two encoders is not a weak signal, it is a
|
|
52638
|
-
* meaningless number — and nothing inside a vector can tell you it happened.
|
|
52639
|
-
* So for those two steps the model is a **cluster** question with exactly one
|
|
52640
|
-
* answer, stored in exactly one row.
|
|
52641
|
-
*
|
|
52642
|
-
* That is the same argument [D52](../../../../docs/decisions/adr-0052.md) makes
|
|
52643
|
-
* for the crop convention (`detail-crop.ts`), one level up: the crop decides
|
|
52644
|
-
* WHAT pixels the encoder sees, this decides WHICH encoder sees them. Both are
|
|
52645
|
-
* cluster-wide for the same reason and neither may become per-node.
|
|
52646
|
-
*
|
|
52647
|
-
* ## Why the registry lives here and not in the step catalog
|
|
52648
|
-
*
|
|
52649
|
-
* The scope itself is declared on the step, in
|
|
52650
|
-
* `detection-pipeline/registry/step-definitions.ts` (`StepDefinition.modelScope`)
|
|
52651
|
-
* — that is where a new step declares what kind of choice its model is. But the
|
|
52652
|
-
* catalog lives inside `addon-pipeline`, and three packages that must NOT
|
|
52653
|
-
* import an addon need to know the set: the orchestrator (which renders and
|
|
52654
|
-
* stores the row), post-analysis (which pins the row for a re-embed pass) and
|
|
52655
|
-
* admin-ui (which mirrors it). So the set is mirrored here, and
|
|
52656
|
-
* `scripts/check-cluster-model-scope.ts` fails the build when the two disagree.
|
|
52657
|
-
* A hand-copied key that stops matching is exactly how a setting silently stops
|
|
52658
|
-
* arriving while both sides still look correct.
|
|
52659
|
-
*
|
|
52660
|
-
* ## The defaults ARE today's behaviour
|
|
52661
|
-
*
|
|
52662
|
-
* {@link DEFAULT_CLUSTER_STEP_MODELS} reproduces the catalog `defaultModelId`
|
|
52663
|
-
* of both steps. Declaring the scope therefore changes nothing on the day it
|
|
52664
|
-
* ships: the cluster row starts out saying what every node was already doing.
|
|
52665
|
-
* Changing it is legitimate — that is what the knob is for — but it invalidates
|
|
52666
|
-
* the stored vectors of that surface, and must be followed by a re-embed pass
|
|
52667
|
-
* (`face-reembed-pass.ts`, `embedding-rebuild.ts`).
|
|
52668
|
-
*/
|
|
52669
|
-
/**
|
|
52670
|
-
* The cluster-scoped steps. Mirrored from the catalog's `modelScope: 'cluster'`
|
|
52671
|
-
* declarations and guarded by `scripts/check-cluster-model-scope.ts`.
|
|
52672
|
-
*/
|
|
52673
|
-
var CLUSTER_MODEL_SCOPED_STEPS = [{
|
|
52674
|
-
stepId: "face-embedding",
|
|
52675
|
-
label: "Face recognition model",
|
|
52676
|
-
defaultModelId: "arcface-r100",
|
|
52677
|
-
indexName: "the enrolled face gallery",
|
|
52678
|
-
options: [
|
|
52679
|
-
{
|
|
52680
|
-
id: "arcface-r100",
|
|
52681
|
-
label: "ArcFace (ResNet34)"
|
|
52682
|
-
},
|
|
52683
|
-
{
|
|
52684
|
-
id: "auraface-r100",
|
|
52685
|
-
label: "AuraFace R100"
|
|
52686
|
-
},
|
|
52687
|
-
{
|
|
52688
|
-
id: "inception-resnet-v1",
|
|
52689
|
-
label: "Inception ResNet V1"
|
|
52690
|
-
}
|
|
52691
|
-
]
|
|
52692
|
-
}, {
|
|
52693
|
-
stepId: "clip-embedding",
|
|
52694
|
-
label: "Semantic search model",
|
|
52695
|
-
defaultModelId: "mobileclip-s1",
|
|
52696
|
-
indexName: "the object semantic-search index",
|
|
52697
|
-
options: [{
|
|
52698
|
-
id: "mobileclip-s1",
|
|
52699
|
-
label: "MobileCLIP S1"
|
|
52700
|
-
}, {
|
|
52701
|
-
id: "mobileclip-s2",
|
|
52702
|
-
label: "MobileCLIP S2"
|
|
52703
|
-
}]
|
|
52704
|
-
}];
|
|
52705
|
-
/**
|
|
52706
|
-
* The settings key holding one step's cluster model choice.
|
|
52707
|
-
*
|
|
52708
|
-
* Step-qualified so the keys stay unique across the addon's whole schema, which
|
|
52709
|
-
* is what lets {@link pickClusterStepModels} walk every section instead of
|
|
52710
|
-
* trusting the section id.
|
|
52711
|
-
*/
|
|
52712
|
-
function clusterModelSettingKey(stepId) {
|
|
52713
|
-
return `clusterModel:${stepId}`;
|
|
52714
|
-
}
|
|
52715
|
-
/** The cluster row when nobody has configured one — today's catalog defaults. */
|
|
52716
|
-
var DEFAULT_CLUSTER_STEP_MODELS = Object.freeze(Object.fromEntries(CLUSTER_MODEL_SCOPED_STEPS.map((s) => [s.stepId, s.defaultModelId])));
|
|
52717
|
-
/** A stored choice is a non-empty model id, or it is not a choice. */
|
|
52718
|
-
var ChosenModelIdSchema = string().min(1);
|
|
52719
|
-
/**
|
|
52720
|
-
* Narrow a FLAT settings record to the cluster row.
|
|
52721
|
-
*
|
|
52722
|
-
* Per-FIELD fallback, deliberately (same rule as `readDetailCropConvention`): a
|
|
52723
|
-
* junk face model must not also discard a valid clip model. An absent, empty or
|
|
52724
|
-
* non-string value resolves to the step's catalog default — the historical
|
|
52725
|
-
* behaviour — never to a blank id, because a blank id downstream becomes
|
|
52726
|
-
* "substitute the format default", which is precisely the substitution this
|
|
52727
|
-
* scope exists to forbid.
|
|
52728
|
-
*/
|
|
52729
|
-
function readClusterStepModels(config) {
|
|
52730
|
-
const out = {};
|
|
52731
|
-
for (const step of CLUSTER_MODEL_SCOPED_STEPS) {
|
|
52732
|
-
const parsed = ChosenModelIdSchema.safeParse(config[clusterModelSettingKey(step.stepId)]);
|
|
52733
|
-
out[step.stepId] = parsed.success ? parsed.data : step.defaultModelId;
|
|
52734
|
-
}
|
|
52735
|
-
return out;
|
|
52736
|
-
}
|
|
52737
|
-
function isHydratedField$2(entry) {
|
|
52738
|
-
return typeof entry === "object" && entry !== null && "key" in entry;
|
|
52739
|
-
}
|
|
52740
|
-
/**
|
|
52741
|
-
* Extract the cluster row from an `addon-settings.getGlobalSettings` payload.
|
|
52742
|
-
*
|
|
52743
|
-
* Walks EVERY section rather than looking inside {@link CLUSTER_MODEL_SECTION_ID}
|
|
52744
|
-
* alone: the keys are unique across the addon's schema, and a section rename
|
|
52745
|
-
* must not silently revert the whole cluster to the defaults. A `null` payload
|
|
52746
|
-
* (addon mid-boot) is the defaults.
|
|
52747
|
-
*/
|
|
52748
|
-
function pickClusterStepModels(view) {
|
|
52749
|
-
if (view === null) return DEFAULT_CLUSTER_STEP_MODELS;
|
|
52750
|
-
const flat = {};
|
|
52751
|
-
const wanted = new Set(CLUSTER_MODEL_SCOPED_STEPS.map((s) => clusterModelSettingKey(s.stepId)));
|
|
52752
|
-
for (const section of view.sections) for (const entry of section.fields) {
|
|
52753
|
-
if (!isHydratedField$2(entry) || typeof entry.key !== "string") continue;
|
|
52754
|
-
if (wanted.has(entry.key)) flat[entry.key] = entry.value;
|
|
52755
|
-
}
|
|
52756
|
-
return readClusterStepModels(flat);
|
|
52757
|
-
}
|
|
52758
|
-
var CLUSTER_STEP_SETTING_FIELDS = [{
|
|
52759
|
-
stepId: "face-embedding",
|
|
52760
|
-
key: "minLandmarkFaceSize",
|
|
52761
|
-
label: "Min face size for recognition (detection px)",
|
|
52762
|
-
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.",
|
|
52763
|
-
type: "slider",
|
|
52764
|
-
min: 0,
|
|
52765
|
-
max: 64,
|
|
52766
|
-
step: 2,
|
|
52767
|
-
default: 24
|
|
52768
|
-
}];
|
|
52769
|
-
function clusterStepSettingKey(stepId, fieldKey) {
|
|
52770
|
-
return `clusterStepSetting:${stepId}:${fieldKey}`;
|
|
52771
|
-
}
|
|
52772
|
-
var ClusterSettingNumberSchema = number().finite();
|
|
52773
|
-
function readClusterStepSettings(config) {
|
|
52774
|
-
const out = {};
|
|
52775
|
-
for (const field of CLUSTER_STEP_SETTING_FIELDS) {
|
|
52776
|
-
const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
|
|
52777
|
-
const value = parsed.success ? parsed.data : field.default;
|
|
52778
|
-
const existing = out[field.stepId] ?? {};
|
|
52779
|
-
out[field.stepId] = {
|
|
52780
|
-
...existing,
|
|
52781
|
-
[field.key]: value
|
|
52782
|
-
};
|
|
52783
|
-
}
|
|
52784
|
-
return out;
|
|
52785
|
-
}
|
|
52786
|
-
readClusterStepSettings({});
|
|
52787
53374
|
object({
|
|
52788
53375
|
/**
|
|
52789
53376
|
* Fraction of the box's own size added on EACH side before cutting.
|
|
@@ -53325,4 +53912,395 @@ function vectorDimFromBase64(encoded) {
|
|
|
53325
53912
|
return Math.floor(Buffer.from(encoded, "base64").byteLength / 4);
|
|
53326
53913
|
}
|
|
53327
53914
|
//#endregion
|
|
53328
|
-
|
|
53915
|
+
//#region src/pipeline-analytics/cluster-model-pin.ts
|
|
53916
|
+
/**
|
|
53917
|
+
* Where a re-embed pass gets the model it pins.
|
|
53918
|
+
*
|
|
53919
|
+
* ## Why not `embeddingEncoder.getInfo`
|
|
53920
|
+
*
|
|
53921
|
+
* That is what the CLIP rebuild used, and it answers a subtly different
|
|
53922
|
+
* question: "which model is the encoder addon currently holding", not "which
|
|
53923
|
+
* model has the operator chosen for the cluster". The two agree until they do
|
|
53924
|
+
* not — an encoder mid-reload, a node that never picked up a change — and when
|
|
53925
|
+
* they disagree the pass writes a whole index in the wrong space with a status
|
|
53926
|
+
* line that looks fine. Since `face-embedding` and `clip-embedding` declare
|
|
53927
|
+
* `modelScope: 'cluster'`, there is now exactly one authority for each, and it
|
|
53928
|
+
* is a stored row rather than a live process's opinion.
|
|
53929
|
+
*
|
|
53930
|
+
* ## Why the read is not cached here
|
|
53931
|
+
*
|
|
53932
|
+
* A pass reads it ONCE, at the start, and pins that value for its whole run
|
|
53933
|
+
* (D54). A cache would only matter for a caller that re-read it mid-pass, which
|
|
53934
|
+
* is precisely the thing the pin exists to prevent — so there is nothing to
|
|
53935
|
+
* cache and the absence is deliberate.
|
|
53936
|
+
*
|
|
53937
|
+
* ## Why a failed read refuses instead of defaulting
|
|
53938
|
+
*
|
|
53939
|
+
* A pass that cannot name its model must not run. The previous CLIP path's
|
|
53940
|
+
* `?? 'unknown'` is the shipped version of the alternative: rows stamped with an
|
|
53941
|
+
* id nothing ran, in an index whose same-model gate then has nothing to reason
|
|
53942
|
+
* about.
|
|
53943
|
+
*/
|
|
53944
|
+
/** The addon whose GLOBAL settings hold the cluster row. */
|
|
53945
|
+
var CLUSTER_MODEL_OWNER_ADDON_ID = "pipeline-orchestrator";
|
|
53946
|
+
/** The step ids this module can pin — the same two the catalog declares. */
|
|
53947
|
+
var FACE_EMBEDDING_STEP_ID = "face-embedding";
|
|
53948
|
+
var CLIP_EMBEDDING_STEP_ID = "clip-embedding";
|
|
53949
|
+
/**
|
|
53950
|
+
* The cluster row, or `null` when it could not be read.
|
|
53951
|
+
*
|
|
53952
|
+
* `null` and not "the defaults": a caller that cannot distinguish "the operator
|
|
53953
|
+
* chose arcface" from "I could not ask" will run a pass on a guess. The one
|
|
53954
|
+
* production caller turns `null` into a refusal to start.
|
|
53955
|
+
*/
|
|
53956
|
+
async function readClusterModelRow(api, logger) {
|
|
53957
|
+
try {
|
|
53958
|
+
return pickClusterStepModels(await api.addonSettings.getGlobalSettings.query({ addonId: CLUSTER_MODEL_OWNER_ADDON_ID }));
|
|
53959
|
+
} catch (err) {
|
|
53960
|
+
logger.warn("cluster model row unreadable — a re-embed pass must not guess which encoder the operator chose", { meta: {
|
|
53961
|
+
owner: CLUSTER_MODEL_OWNER_ADDON_ID,
|
|
53962
|
+
error: err instanceof Error ? err.message : String(err)
|
|
53963
|
+
} });
|
|
53964
|
+
return null;
|
|
53965
|
+
}
|
|
53966
|
+
}
|
|
53967
|
+
/**
|
|
53968
|
+
* Pin one cluster-scoped step's model for a whole pass.
|
|
53969
|
+
*
|
|
53970
|
+
* Returns `null` on an unreadable row OR an unknown step id — both mean the
|
|
53971
|
+
* caller must not start, and folding them together is safe because the caller's
|
|
53972
|
+
* move is identical: refuse, loudly.
|
|
53973
|
+
*/
|
|
53974
|
+
async function resolveClusterModelPin(api, stepId, logger) {
|
|
53975
|
+
if (!CLUSTER_MODEL_SCOPED_STEPS.some((s) => s.stepId === stepId)) {
|
|
53976
|
+
logger.warn("cluster model pin requested for a step that is not cluster-scoped", { meta: {
|
|
53977
|
+
stepId,
|
|
53978
|
+
clusterScoped: CLUSTER_MODEL_SCOPED_STEPS.map((s) => s.stepId)
|
|
53979
|
+
} });
|
|
53980
|
+
return null;
|
|
53981
|
+
}
|
|
53982
|
+
const row = await readClusterModelRow(api, logger);
|
|
53983
|
+
if (row === null) return null;
|
|
53984
|
+
const modelId = row[stepId];
|
|
53985
|
+
return modelId !== void 0 && modelId !== "" ? modelId : null;
|
|
53986
|
+
}
|
|
53987
|
+
/**
|
|
53988
|
+
* The error texts a cap call carries when the provider or the router has no
|
|
53989
|
+
* such method: the kernel's `Capability "…" has no method "…"`, tRPC's
|
|
53990
|
+
* `No procedure found on path`, and the forked-child hop's
|
|
53991
|
+
* `method '…' not found on provider '…'` (child-cap-dispatch.ts). NOT `is not a function`: that is any
|
|
53992
|
+
* `TypeError` thrown INSIDE the owner while it answers, and reading it as
|
|
53993
|
+
* "the owner predates the method" would file a bug in the owner under a
|
|
53994
|
+
* rolling-release reason nobody investigates.
|
|
53995
|
+
*/
|
|
53996
|
+
var METHOD_UNAVAILABLE_FINGERPRINTS = [
|
|
53997
|
+
/has no method/i,
|
|
53998
|
+
/no procedure found/i,
|
|
53999
|
+
/method not found/i,
|
|
54000
|
+
/method '[^']*' not found on provider/i
|
|
54001
|
+
];
|
|
54002
|
+
/**
|
|
54003
|
+
* The pin read for a pass that REWRITES an index (D651 fix rounds 1–3).
|
|
54004
|
+
*
|
|
54005
|
+
* Asks the OWNER. The orchestrator owns `clusterModel:*` and answers from a
|
|
54006
|
+
* three-way read of its own store, once its boot has settled
|
|
54007
|
+
* (`pipelineOrchestrator.getClusterModelChoice`). Never the hydrated view,
|
|
54008
|
+
* which answers `value ?? default`, and never the owner's private store
|
|
54009
|
+
* layout. Silent on purpose: the callers log state CHANGES.
|
|
54010
|
+
*/
|
|
54011
|
+
async function readClusterModelPinStrict(api, stepId) {
|
|
54012
|
+
const method = api.pipelineOrchestrator?.getClusterModelChoice;
|
|
54013
|
+
if (method === void 0) return {
|
|
54014
|
+
kind: "unknown",
|
|
54015
|
+
reason: "method-unavailable"
|
|
54016
|
+
};
|
|
54017
|
+
let raw;
|
|
54018
|
+
try {
|
|
54019
|
+
raw = await method.query({ stepId });
|
|
54020
|
+
} catch (err) {
|
|
54021
|
+
const error = err instanceof Error ? err.message : String(err);
|
|
54022
|
+
return METHOD_UNAVAILABLE_FINGERPRINTS.some((re) => re.test(error)) ? {
|
|
54023
|
+
kind: "unknown",
|
|
54024
|
+
reason: "method-unavailable",
|
|
54025
|
+
error
|
|
54026
|
+
} : {
|
|
54027
|
+
kind: "unknown",
|
|
54028
|
+
reason: "read-failed",
|
|
54029
|
+
error
|
|
54030
|
+
};
|
|
54031
|
+
}
|
|
54032
|
+
if (raw === void 0) return {
|
|
54033
|
+
kind: "unknown",
|
|
54034
|
+
reason: "method-unavailable"
|
|
54035
|
+
};
|
|
54036
|
+
const parsed = ClusterModelChoiceSchema.safeParse(raw);
|
|
54037
|
+
if (!parsed.success) return {
|
|
54038
|
+
kind: "unknown",
|
|
54039
|
+
reason: "read-failed",
|
|
54040
|
+
error: "unparseable owner answer"
|
|
54041
|
+
};
|
|
54042
|
+
const choice = parsed.data;
|
|
54043
|
+
if (choice.kind === "stored") return {
|
|
54044
|
+
kind: "known",
|
|
54045
|
+
modelId: choice.modelId
|
|
54046
|
+
};
|
|
54047
|
+
if (choice.kind === "absent") return {
|
|
54048
|
+
kind: "not-stored",
|
|
54049
|
+
defaultModelId: choice.defaultModelId
|
|
54050
|
+
};
|
|
54051
|
+
return choice.error !== void 0 ? {
|
|
54052
|
+
kind: "unknown",
|
|
54053
|
+
reason: choice.reason,
|
|
54054
|
+
error: choice.error
|
|
54055
|
+
} : {
|
|
54056
|
+
kind: "unknown",
|
|
54057
|
+
reason: choice.reason
|
|
54058
|
+
};
|
|
54059
|
+
}
|
|
54060
|
+
//#endregion
|
|
54061
|
+
//#region src/embedding-encoder/catalogs/embedding-models.ts
|
|
54062
|
+
var HF_REPO = "camstack/camstack-models";
|
|
54063
|
+
var hf = (path) => hfModelUrl(HF_REPO, path);
|
|
54064
|
+
/**
|
|
54065
|
+
* The text tower's tokenizer, in HF `tokenizers` format, hosted next to every
|
|
54066
|
+
* text-encoder onnx (`.../onnx/tokenizer.json`) and fetched as a sibling file so
|
|
54067
|
+
* it lands beside the model. Each model folder hosts ITS OWN (MobileCLIP: the
|
|
54068
|
+
* CLIP BPE, vocab 49408; SigLIP2: Gemma SentencePiece, 256k, lower-casing).
|
|
54069
|
+
*/
|
|
54070
|
+
var TOKENIZER_FILE = "tokenizer.json";
|
|
54071
|
+
/** SigLIP2's tokenizer — a DIFFERENT file name on purpose: see `ClipModelMeta.tokenizerFile`. */
|
|
54072
|
+
var SIGLIP2_TOKENIZER_FILE = "camstack-siglip2-b16-224-tokenizer.json";
|
|
54073
|
+
var ovFormat = (url, sizeMB) => {
|
|
54074
|
+
const base = url.split("/").pop() ?? "";
|
|
54075
|
+
const files = base.endsWith(".xml") ? [base.replace(/\.xml$/, ".bin")] : void 0;
|
|
54076
|
+
return {
|
|
54077
|
+
url,
|
|
54078
|
+
sizeMB,
|
|
54079
|
+
runtimes: ["python"],
|
|
54080
|
+
...files ? { files } : {}
|
|
54081
|
+
};
|
|
54082
|
+
};
|
|
54083
|
+
/**
|
|
54084
|
+
* Files inside an .mlpackage directory bundle.
|
|
54085
|
+
* Must be fetched alongside the package root when isDirectory is true.
|
|
54086
|
+
*/
|
|
54087
|
+
var MLPACKAGE_FILES = [
|
|
54088
|
+
"Manifest.json",
|
|
54089
|
+
"Data/com.apple.CoreML/model.mlmodel",
|
|
54090
|
+
"Data/com.apple.CoreML/weights/weight.bin"
|
|
54091
|
+
];
|
|
54092
|
+
/**
|
|
54093
|
+
* The MobileCLIP feature-space contract (D649 — see `clip-model.ts` in
|
|
54094
|
+
* `@camstack/types`). S1 and S2 share the historical 512-d `object-clip` index,
|
|
54095
|
+
* separated by each row's `modelId`; the CLIP BPE window is 77 tokens padded
|
|
54096
|
+
* with 0; 0.2 is the floor the search always shipped with, measured to keep 96%
|
|
54097
|
+
* of matched COCO caption-image pairs on S1.
|
|
54098
|
+
*/
|
|
54099
|
+
var mobileclipMeta = (textModelId) => ({
|
|
54100
|
+
textModelId,
|
|
54101
|
+
embeddingDim: 512,
|
|
54102
|
+
vectorIndex: "object-clip",
|
|
54103
|
+
tokenizerFile: TOKENIZER_FILE,
|
|
54104
|
+
contextLength: 77,
|
|
54105
|
+
padId: 0,
|
|
54106
|
+
searchMinScore: .2
|
|
54107
|
+
});
|
|
54108
|
+
/**
|
|
54109
|
+
* SigLIP2 B/16-224 (D649). 768-d, so its OWN index; a 64-token Gemma
|
|
54110
|
+
* SentencePiece window padded with 0 (the hosted `tokenizer.json` lower-cases,
|
|
54111
|
+
* see `scripts/build-siglip2-model.py`). The floor is SIGLIP2_SEARCH_MIN_SCORE.
|
|
54112
|
+
*/
|
|
54113
|
+
var SIGLIP2_META = {
|
|
54114
|
+
textModelId: "siglip2-b16-224-text",
|
|
54115
|
+
embeddingDim: 768,
|
|
54116
|
+
vectorIndex: "object-clip-siglip2-b16-224",
|
|
54117
|
+
tokenizerFile: SIGLIP2_TOKENIZER_FILE,
|
|
54118
|
+
contextLength: 64,
|
|
54119
|
+
padId: 0,
|
|
54120
|
+
searchMinScore: .1
|
|
54121
|
+
};
|
|
54122
|
+
/**
|
|
54123
|
+
* NO onnx vision builds, deliberately (2026-08-21). The int8 ONNX vision
|
|
54124
|
+
* exports were measured misaligned with the text encoders (matched image↔text
|
|
54125
|
+
* cosine ≈ 0.01 vs ≈ 0.22 for the fp16 openvino/coreml builds) — see the
|
|
54126
|
+
* catalog note in `addon-pipeline/.../model-catalogs.ts`. The image-encode leg
|
|
54127
|
+
* that consumed them here (`embeddingEncoder.encode` → PythonRawTensorEngine)
|
|
54128
|
+
* is retired with them: its only caller discarded the vector, and its
|
|
54129
|
+
* `preprocessForClip` applied OpenAI mean/std that MobileCLIP never used.
|
|
54130
|
+
* S0 was retired the same day (measured worst of the family on fleet crops).
|
|
54131
|
+
*/
|
|
54132
|
+
var CLIP_IMAGE_MODELS = [
|
|
54133
|
+
{
|
|
54134
|
+
id: "mobileclip-s1",
|
|
54135
|
+
name: "MobileCLIP S1",
|
|
54136
|
+
description: "Apple MobileCLIP S1 — balanced vision encoder, 512-dim, 256×256 (fp16 OpenVINO/CoreML)",
|
|
54137
|
+
inputSize: {
|
|
54138
|
+
width: 256,
|
|
54139
|
+
height: 256
|
|
54140
|
+
},
|
|
54141
|
+
labels: [],
|
|
54142
|
+
inputNormalization: "none",
|
|
54143
|
+
clip: mobileclipMeta("mobileclip-s1-text"),
|
|
54144
|
+
formats: {
|
|
54145
|
+
openvino: ovFormat(hf("clip/mobileclip-s1/openvino/camstack-mobileclip-s1-vision.xml"), 55),
|
|
54146
|
+
coreml: {
|
|
54147
|
+
url: hf("clip/mobileclip-s1/coreml/camstack-mobileclip-s1-vision.mlpackage"),
|
|
54148
|
+
sizeMB: 65,
|
|
54149
|
+
isDirectory: true,
|
|
54150
|
+
files: [...MLPACKAGE_FILES],
|
|
54151
|
+
runtimes: ["python"]
|
|
54152
|
+
}
|
|
54153
|
+
}
|
|
54154
|
+
},
|
|
54155
|
+
{
|
|
54156
|
+
id: "mobileclip-s2",
|
|
54157
|
+
name: "MobileCLIP S2",
|
|
54158
|
+
description: "Apple MobileCLIP S2 — high-accuracy vision encoder, 512-dim, 256×256 (fp16 OpenVINO/CoreML)",
|
|
54159
|
+
inputSize: {
|
|
54160
|
+
width: 256,
|
|
54161
|
+
height: 256
|
|
54162
|
+
},
|
|
54163
|
+
labels: [],
|
|
54164
|
+
inputNormalization: "none",
|
|
54165
|
+
clip: mobileclipMeta("mobileclip-s2-text"),
|
|
54166
|
+
formats: {
|
|
54167
|
+
openvino: ovFormat(hf("clip/mobileclip-s2/openvino/camstack-mobileclip-s2-vision.xml"), 90),
|
|
54168
|
+
coreml: {
|
|
54169
|
+
url: hf("clip/mobileclip-s2/coreml/camstack-mobileclip-s2-vision.mlpackage"),
|
|
54170
|
+
sizeMB: 110,
|
|
54171
|
+
isDirectory: true,
|
|
54172
|
+
files: [...MLPACKAGE_FILES],
|
|
54173
|
+
runtimes: ["python"]
|
|
54174
|
+
}
|
|
54175
|
+
}
|
|
54176
|
+
},
|
|
54177
|
+
{
|
|
54178
|
+
id: "siglip2-b16-224",
|
|
54179
|
+
name: "SigLIP2 B/16",
|
|
54180
|
+
description: "Google SigLIP2 base, patch 16, 224×224 — Apache-2.0 vision encoder, 768-dim (fp16 OpenVINO/CoreML)",
|
|
54181
|
+
inputSize: {
|
|
54182
|
+
width: 224,
|
|
54183
|
+
height: 224
|
|
54184
|
+
},
|
|
54185
|
+
labels: [],
|
|
54186
|
+
inputNormalization: "none",
|
|
54187
|
+
license: "Apache-2.0",
|
|
54188
|
+
clip: SIGLIP2_META,
|
|
54189
|
+
formats: {
|
|
54190
|
+
openvino: ovFormat(hf("clip/siglip2/openvino/camstack-siglip2-b16-224-vision.xml"), 186),
|
|
54191
|
+
coreml: {
|
|
54192
|
+
url: hf("clip/siglip2/coreml/camstack-siglip2-b16-224-vision.mlpackage"),
|
|
54193
|
+
sizeMB: 185,
|
|
54194
|
+
isDirectory: true,
|
|
54195
|
+
files: [...MLPACKAGE_FILES],
|
|
54196
|
+
runtimes: ["python"]
|
|
54197
|
+
}
|
|
54198
|
+
}
|
|
54199
|
+
}
|
|
54200
|
+
];
|
|
54201
|
+
/**
|
|
54202
|
+
* The int8 TEXT onnx encoders are healthy — unlike the retired int8 vision
|
|
54203
|
+
* exports. Verified 2026-08-21: the live search path (fp16 openvino vision
|
|
54204
|
+
* vectors ⋅ int8 onnx text queries) ranks correctly on the real index, and the
|
|
54205
|
+
* local cross-check aligns them with the fp16 vision space (cos ≈ 0.22 on
|
|
54206
|
+
* matched pairs).
|
|
54207
|
+
*/
|
|
54208
|
+
var CLIP_TEXT_MODELS = [
|
|
54209
|
+
{
|
|
54210
|
+
id: "mobileclip-s1-text",
|
|
54211
|
+
name: "MobileCLIP S1 Text Encoder",
|
|
54212
|
+
description: "Text encoder for MobileCLIP S1, 512-dim, int8 quantized (61 MB)",
|
|
54213
|
+
inputSize: {
|
|
54214
|
+
width: 0,
|
|
54215
|
+
height: 0
|
|
54216
|
+
},
|
|
54217
|
+
labels: [],
|
|
54218
|
+
formats: {
|
|
54219
|
+
onnx: {
|
|
54220
|
+
url: hf("clip/mobileclip-s1/onnx/camstack-mobileclip-s1-text.onnx"),
|
|
54221
|
+
sizeMB: 61,
|
|
54222
|
+
files: [TOKENIZER_FILE]
|
|
54223
|
+
},
|
|
54224
|
+
openvino: ovFormat(hf("clip/mobileclip-s1/openvino/camstack-mobileclip-s1-text.xml"), 121)
|
|
54225
|
+
}
|
|
54226
|
+
},
|
|
54227
|
+
{
|
|
54228
|
+
id: "mobileclip-s2-text",
|
|
54229
|
+
name: "MobileCLIP S2 Text Encoder",
|
|
54230
|
+
description: "Text encoder for MobileCLIP S2, 512-dim, int8 quantized (61 MB)",
|
|
54231
|
+
inputSize: {
|
|
54232
|
+
width: 0,
|
|
54233
|
+
height: 0
|
|
54234
|
+
},
|
|
54235
|
+
labels: [],
|
|
54236
|
+
formats: {
|
|
54237
|
+
onnx: {
|
|
54238
|
+
url: hf("clip/mobileclip-s2/onnx/camstack-mobileclip-s2-text.onnx"),
|
|
54239
|
+
sizeMB: 61,
|
|
54240
|
+
files: [TOKENIZER_FILE]
|
|
54241
|
+
},
|
|
54242
|
+
openvino: ovFormat(hf("clip/mobileclip-s2/openvino/camstack-mobileclip-s2-text.xml"), 121)
|
|
54243
|
+
}
|
|
54244
|
+
},
|
|
54245
|
+
{
|
|
54246
|
+
id: "siglip2-b16-224-text",
|
|
54247
|
+
name: "SigLIP2 B/16 Text Encoder",
|
|
54248
|
+
description: "Text encoder for SigLIP2 B/16, 768-dim, fp16 (565 MB)",
|
|
54249
|
+
inputSize: {
|
|
54250
|
+
width: 0,
|
|
54251
|
+
height: 0
|
|
54252
|
+
},
|
|
54253
|
+
labels: [],
|
|
54254
|
+
license: "Apache-2.0",
|
|
54255
|
+
formats: {
|
|
54256
|
+
onnx: {
|
|
54257
|
+
url: hf("clip/siglip2/onnx/camstack-siglip2-b16-224-text.onnx"),
|
|
54258
|
+
sizeMB: 565,
|
|
54259
|
+
files: [SIGLIP2_TOKENIZER_FILE]
|
|
54260
|
+
},
|
|
54261
|
+
openvino: ovFormat(hf("clip/siglip2/openvino/camstack-siglip2-b16-224-text.xml"), 565)
|
|
54262
|
+
}
|
|
54263
|
+
}
|
|
54264
|
+
];
|
|
54265
|
+
//#endregion
|
|
54266
|
+
//#region src/shared/clip/clip-model-registry.ts
|
|
54267
|
+
/** The model in force when nobody has chosen — the cluster row's default. */
|
|
54268
|
+
var DEFAULT_CLIP_MODEL = "mobileclip-s1";
|
|
54269
|
+
/**
|
|
54270
|
+
* Build a registry from catalog entries. Throws when two models share an index
|
|
54271
|
+
* at different dimensions: that is a catalog defect, and the vector store would
|
|
54272
|
+
* refuse the second model's writes one at a time, forever, at runtime.
|
|
54273
|
+
*/
|
|
54274
|
+
function buildClipModelRegistry(entries) {
|
|
54275
|
+
const models = /* @__PURE__ */ new Map();
|
|
54276
|
+
const spaces = /* @__PURE__ */ new Map();
|
|
54277
|
+
for (const entry of entries) {
|
|
54278
|
+
const meta = entry.clip;
|
|
54279
|
+
if (meta === void 0) continue;
|
|
54280
|
+
models.set(entry.id, {
|
|
54281
|
+
modelId: entry.id,
|
|
54282
|
+
inputSize: entry.inputSize.width,
|
|
54283
|
+
meta
|
|
54284
|
+
});
|
|
54285
|
+
const existing = spaces.get(meta.vectorIndex);
|
|
54286
|
+
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}`);
|
|
54287
|
+
spaces.set(meta.vectorIndex, {
|
|
54288
|
+
index: meta.vectorIndex,
|
|
54289
|
+
dim: meta.embeddingDim,
|
|
54290
|
+
modelIds: [...existing?.modelIds ?? [], entry.id]
|
|
54291
|
+
});
|
|
54292
|
+
}
|
|
54293
|
+
const all = [...spaces.values()];
|
|
54294
|
+
return {
|
|
54295
|
+
resolve: (modelId) => models.get(modelId) ?? null,
|
|
54296
|
+
spaceFor: (modelId) => {
|
|
54297
|
+
const model = models.get(modelId);
|
|
54298
|
+
return model === void 0 ? null : spaces.get(model.meta.vectorIndex) ?? null;
|
|
54299
|
+
},
|
|
54300
|
+
spaces: () => all
|
|
54301
|
+
};
|
|
54302
|
+
}
|
|
54303
|
+
/** The built-in catalog's registry. */
|
|
54304
|
+
var BUILTIN_CLIP_MODELS = buildClipModelRegistry(CLIP_IMAGE_MODELS);
|
|
54305
|
+
//#endregion
|
|
54306
|
+
export { NcRuleSchema as $, EventCategory as $n, isSourceCap as $t, LabelAttributionSchema as A, canonicalHash as An, audioMetricsCapability as At, NC_DEFAULT_SNOOZE_MINUTES as B, normalizeNodeId as Bn, embeddingRefusalOf as Bt, EMBEDDING_REQUIREMENTS_FAILED as C, systemEventFilterApplies as Cn, TimelapseRuleInputSchema as Ct, FIRST_LEVEL_MACRO_CLASSES as D, vectorDimFromBase64 as Dn, addonWidgetsSourceCapability as Dt, EVENT_OWNER_TYPES as E, templateVarsFor as En, TrackSourceSchema as Et, MOTION_CLOSE_AFTER_MS as F, customAction as Fn, deriveRecordingMode as Ft, NC_TAXONOMY as G, discriminatedUnion as Gn, evictionPolicyOfLocation as Gt, NC_SNOOZE_MAX_MINUTES as H, _enum as Hn, embeddingRequirementsUnavailableError as Ht, MediaFileKindEnum as I, defineCustomActions as In, describeSystemEventDeliveryProblem as It, NcAlarmSettingsPatchSchema as J, object as Jn, isDetectionMacroClass as Jt, NC_TEMPLATE_VARS as K, literal as Kn, faceGalleryCapability as Kt, NC_ALARM_SYSTEM_EVENT_KINDS as L, hydrateSchema as Ln, describeSystemEventFamilyProblem as Lt, MAX_ARCHIVED_DEBUG_NOTES as M, CamProfileSchema as Mn, buildEventKindDescriptor as Mt, MAX_BIRTH_DECISION_RECORDS as N, DeviceType as Nn, consumableLowPercentOf as Nt, FULL_IMAGE_BBOX as O, zoneAnalyticsCapability as On, alarmPanelCapability as Ot, MAX_BIRTH_LATENCY_PROXY_MS as P, createEvent as Pn, cosineSimilarity as Pt, NcRulePatchSchema as Q, unknown as Qn, isScheduleActive as Qt, NC_CONDITION_CATALOG as R, isDeviceScopedCap as Rn, embeddingEncoderCapability as Rt, EMBEDDING_MODEL_FAILED as S, systemEventFamilyProblems as Sn, TIMELAPSE_DENSE_FLOOR_SEC as St, EVENT_KIND_BY_CAP as T, templateCarriesSummary as Tn, TimelapseRuleSchema as Tt, NC_SYSTEM_EVENT_KIND_GROUP_SPECS as U, array as Un, encodeVectorBase64 as Ut, NC_SENSOR_TRANSITION_KINDS as V, sleep as Vn, embeddingRequirementsFailedError as Vt, NC_TANK_SYSTEM_EVENT_KINDS as W, boolean as Wn, evaluateSensorEdge as Wt, NcConditionsSchema as X, record as Xn, isKnownTemplateVar as Xt, NcConditionDescriptorSchema as Y, partialRecord as Yn, isEventOwnerType as Yt, NcRuleInputSchema as Z, string as Zn, isMediaOwnerType as Zt, DEFAULT_FIRST_SIGHTING_FRESHNESS_MS as _, sensorRaisedOf as _n, SCENE_CONFIRM_DEFAULT_TIMEOUT_MS as _t, CLIP_EMBEDDING_STEP_ID as a, notificationRulesCapability as an, NcSnoozeSuppressedSchema as at, DETECTION_PIPELINE_CAP_NAME as b, subKindsOf as bn, SCENE_DIVERGED as bt, resolveClusterModelPin as c, pipelineAnalyticsCapability as cn, NcTemplatePreviewInputSchema as ct, ArchivedDebugNoteSchema as d, readTimelapseGeneratedAt as dn, OpsLogEntrySchema as dt, isSystemDelivery as en, NcRuleTargetSchema as et, BaseDevice as f, resolveClipSearchMinScore as fn, PoolMemoryWatchdog as ft, DEFAULT_EVENT_COLOR as g, sceneMonitorCapability as gn, RetrainStatusSchema as gt, CoverStateSchema as h, ruleBelongsToAlarm as hn, RebuildObjectEmbeddingsRefusalSchema as ht, CLIP_TEXT_MODELS as i, mayWriteToLocation as in, NcSnoozeSchema as it, LockStateSchema as j, BaseAddon as jn, audioModeOf as jt, FailureCounters as k, errMsg as kn, assertTimelapseCadences as kt, AUDIO_MACRO_LABELS as l, plateGalleryCapability as ln, NcTemplatePreviewSchema as lt, COCO_TO_MACRO as m, resolvePoolMemoryPolicy as mn, RECORDING_SOURCE_CAMSTACK_ADDON as mt, DEFAULT_CLIP_MODEL as n, isVectorIndexDimConflict as nn, NcScheduleSchema as nt, FACE_EMBEDDING_STEP_ID as o, occupancyScope as on, NcSystemEventKindSchema as ot, BirthDecisionRecordSchema as p, resolveLocationMode as pn, RECORDING_EXPORT_MAX_READ_BYTES as pt, NcAlarmConfigSchema as q, number as qn, failureContributionCapability as qt, CLIP_IMAGE_MODELS as r, kebabToCamel as rn, NcSnoozeInputSchema as rt, readClusterModelPinStrict as s, parseProcStatus as sn, NcTaxonomySchema as st, BUILTIN_CLIP_MODELS as t, isSystemEventSummaryRule as tn, NcRuleUpdateInputSchema as tt, AlarmArmModeSchema as u, readDeviceStateFrom as un, NcTemplateVarDescriptorSchema as ut, DEFAULT_TIMELAPSE_PREVIEW_TEXT as v, servedTemplateVars as vn, SCENE_DEFAULT_ANCHOR_THRESHOLD as vt, EMBEDDING_REQUIREMENTS_UNAVAILABLE as w, systemEventSummaryScheduleOf as wn, TimelapseRulePatchSchema as wt, DeclaredDevices as x, systemEventDeliveryProblems as xn, SceneMonitorSchema as xt, DETECTION_MACRO_CLASSES as y, storageOccupancyCapability as yn, SCENE_DEFAULT_UNCOVERED_POLICY as yt, NC_CONSUMABLE_SYSTEM_EVENT_KINDS as z, nodePin as zn, embeddingModelFailedError as zt };
|