@camstack/system 1.2.304 → 1.2.305

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/addon-runner.js +1 -1
  2. package/dist/addon-runner.mjs +1 -1
  3. package/dist/addon-utils.d.ts +1 -1
  4. package/dist/addon-utils.js +3 -1
  5. package/dist/addon-utils.mjs +2 -2
  6. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  7. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  8. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  9. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  10. package/dist/builtins/alerts/alerts.addon.js +1 -1
  11. package/dist/builtins/alerts/alerts.addon.mjs +1 -1
  12. package/dist/builtins/autotrack/index.js +1 -1
  13. package/dist/builtins/autotrack/index.mjs +1 -1
  14. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
  15. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
  16. package/dist/builtins/camera-grid/index.js +1 -1
  17. package/dist/builtins/camera-grid/index.mjs +1 -1
  18. package/dist/builtins/console-logging/index.js +1 -1
  19. package/dist/builtins/console-logging/index.mjs +1 -1
  20. package/dist/builtins/core-blocks/core-blocks.addon.js +1 -1
  21. package/dist/builtins/core-blocks/core-blocks.addon.mjs +1 -1
  22. package/dist/builtins/device-manager/device-extension-linked-slot.d.ts +8 -0
  23. package/dist/builtins/device-manager/device-linked-devices.d.ts +34 -0
  24. package/dist/builtins/device-manager/device-manager.addon.js +188 -22
  25. package/dist/builtins/device-manager/device-manager.addon.mjs +188 -22
  26. package/dist/builtins/doorbell/binding-mirror.d.ts +24 -0
  27. package/dist/builtins/doorbell/doorbell-extension-slot.d.ts +66 -0
  28. package/dist/builtins/doorbell/virtual-doorbell.addon.d.ts +14 -0
  29. package/dist/builtins/doorbell/virtual-doorbell.addon.js +307 -38
  30. package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +307 -38
  31. package/dist/builtins/hub-forwarder/index.js +1 -1
  32. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  33. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  34. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  35. package/dist/builtins/local-auth/local-auth.addon.js +1 -1
  36. package/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
  37. package/dist/builtins/local-network/local-network.addon.js +1 -1
  38. package/dist/builtins/local-network/local-network.addon.mjs +1 -1
  39. package/dist/builtins/loki-logging/index.js +1 -1
  40. package/dist/builtins/loki-logging/index.mjs +1 -1
  41. package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  42. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  43. package/dist/builtins/platform-probe/index.js +1 -1
  44. package/dist/builtins/platform-probe/index.mjs +1 -1
  45. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  46. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  47. package/dist/builtins/snapshot/index.js +1 -1
  48. package/dist/builtins/snapshot/index.mjs +1 -1
  49. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  50. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  51. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +0 -0
  52. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +0 -0
  53. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  54. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  55. package/dist/builtins/system-config/system-config.addon.js +1 -1
  56. package/dist/builtins/system-config/system-config.addon.mjs +1 -1
  57. package/dist/builtins/winston-logging/index.js +1 -1
  58. package/dist/builtins/winston-logging/index.mjs +1 -1
  59. package/dist/{child-cap-dispatch-C1c3rWaX.mjs → child-cap-dispatch-BCJjUtXV.mjs} +9 -1
  60. package/dist/{child-cap-dispatch-De5_HcvR.js → child-cap-dispatch-Be8e2cBP.js} +9 -1
  61. package/dist/{dist-C571Y95Z.js → dist-BK4iP6ab.js} +1069 -310
  62. package/dist/{dist-Duqf80QM.mjs → dist-Df1NhKxm.mjs} +1046 -311
  63. package/dist/download/model-downloader.d.ts +15 -0
  64. package/dist/{event-loop-stall-monitor-GPrVvx14.mjs → event-loop-stall-monitor-EXjzIxDz.mjs} +25 -3
  65. package/dist/{event-loop-stall-monitor-CAsHdMwP.js → event-loop-stall-monitor-ey4mbofz.js} +36 -2
  66. package/dist/index.js +21 -3
  67. package/dist/index.mjs +21 -3
  68. package/dist/kernel/config-manager.d.ts +3 -1
  69. package/dist/{retired-settings-keys-0j8rNoa8.js → retired-settings-keys-DwWMph6F.js} +1 -1
  70. package/dist/{retired-settings-keys-CeO_dBHU.mjs → retired-settings-keys-dC4ckbXJ.mjs} +1 -1
  71. package/package.json +7 -1
@@ -691,7 +691,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
691
691
  return EventCategory;
692
692
  }({});
693
693
  //#endregion
694
- //#region ../types/dist/sleep-BaRu0bS5.mjs
694
+ //#region ../types/dist/sleep-BXv0ZcRa.mjs
695
695
  /**
696
696
  * The audio chunk plane's byte format, and the ONE expansion from a coded
697
697
  * window to float samples (D455).
@@ -1493,6 +1493,40 @@ var BaseAddon = class {
1493
1493
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
1494
1494
  return keys.size > 0 ? projectStore(raw, keys, node) : raw;
1495
1495
  }
1496
+ /**
1497
+ * Whether ONE global key of this addon's store was written, read three-way
1498
+ * (D651). For a question a hydrated view cannot answer: `getGlobalSettings`
1499
+ * reports `value ?? default`, so "the operator chose the default" and "nobody
1500
+ * chose" look the same, and a failed read looks like both. A `perNode` key is
1501
+ * not supported here: its stored name is scoped.
1502
+ */
1503
+ async readStoredGlobalKey(key) {
1504
+ const read = this._ctx?.settings?.readAddonStoreResult;
1505
+ if (read === void 0) return {
1506
+ kind: "unreadable",
1507
+ reason: "three-way-read-unavailable"
1508
+ };
1509
+ let result;
1510
+ try {
1511
+ result = await read.call(this._ctx?.settings);
1512
+ } catch (err) {
1513
+ return {
1514
+ kind: "unreadable",
1515
+ reason: "store-read-failed",
1516
+ error: err instanceof Error ? err.message : String(err)
1517
+ };
1518
+ }
1519
+ if (result.kind === "failed") return {
1520
+ kind: "unreadable",
1521
+ reason: "store-read-failed",
1522
+ error: result.error
1523
+ };
1524
+ if (result.kind === "missing" || !Object.prototype.hasOwnProperty.call(result.value, key)) return { kind: "absent" };
1525
+ return {
1526
+ kind: "present",
1527
+ value: result.value[key]
1528
+ };
1529
+ }
1496
1530
  async updateGlobalSettings(patch, nodeId) {
1497
1531
  const keys = this.perNodeKeys();
1498
1532
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
@@ -6389,6 +6423,43 @@ function reducePoints(points, bucketMs, origin) {
6389
6423
  }
6390
6424
  return [...buckets.values()].toSorted((a, b) => a.atMs - b.atMs);
6391
6425
  }
6426
+ var ClipModelMetaSchema = zod.z.object({
6427
+ /** The paired text encoder's catalog id (the embedding-encoder's text catalog). */
6428
+ textModelId: zod.z.string().min(1),
6429
+ /** Output dimension of BOTH towers. A vector of any other length is refused. */
6430
+ embeddingDim: zod.z.number().int().positive(),
6431
+ /**
6432
+ * The `vector-store` index this model's vectors live in. ONE feature space
6433
+ * per index: two models share an index only when their vectors are ranked
6434
+ * against each other, which for CLIP means never across families. MobileCLIP
6435
+ * S1 and S2 share `object-clip` for history (separated by the row's
6436
+ * `modelId`); any other model gets its own.
6437
+ */
6438
+ vectorIndex: zod.z.string().regex(/^object-clip(-[a-z0-9][a-z0-9-]*)?$/),
6439
+ /**
6440
+ * The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
6441
+ * must be unique per tokenizer: every model's siblings land in ONE flat
6442
+ * models directory, so two different tokenizers under the same name would
6443
+ * silently overwrite each other (whichever model downloaded last wins, and
6444
+ * the other one tokenises with the wrong vocabulary).
6445
+ */
6446
+ tokenizerFile: zod.z.string().min(1),
6447
+ /** Token window the text graph takes (SigLIP2: 64; CLIP BPE: 77). */
6448
+ contextLength: zod.z.number().int().positive(),
6449
+ /** Id the tokenizer pads with. */
6450
+ padId: zod.z.number().int().nonnegative(),
6451
+ /**
6452
+ * The search cosine floor at `strictness: 'loose'` — calibrated per model,
6453
+ * because cosine bands are a property of the model: 0.2 keeps 96% of matched
6454
+ * COCO caption-image pairs on MobileCLIP S1 and 2.7% on SigLIP2.
6455
+ */
6456
+ searchMinScore: zod.z.number().min(0).max(1)
6457
+ });
6458
+ var ClipSearchStrictnessSchema = zod.z.enum([
6459
+ "loose",
6460
+ "balanced",
6461
+ "strict"
6462
+ ]);
6392
6463
  var MODEL_FORMATS = [
6393
6464
  "onnx",
6394
6465
  "coreml",
@@ -6592,7 +6663,14 @@ var ModelCatalogEntrySchema = zod.z.object({
6592
6663
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
6593
6664
  * labels already ARE the CamStack macros (Scrypted identity map).
6594
6665
  */
6595
- classMap: DetectionCatalogClassMapSchema.optional()
6666
+ classMap: DetectionCatalogClassMapSchema.optional(),
6667
+ /**
6668
+ * The model's CLIP feature-space contract (text encoder, dimension, vector
6669
+ * index, token window, search floor) — see `clip-model.ts`. Present ONLY on a
6670
+ * CLIP image encoder; its absence is what "not a CLIP model" means to the
6671
+ * embedding encoder and the semantic-search store (D649).
6672
+ */
6673
+ clip: ClipModelMetaSchema.optional()
6596
6674
  });
6597
6675
  var ConvertTargetSchema = zod.z.discriminatedUnion("format", [zod.z.object({
6598
6676
  format: zod.z.literal("openvino"),
@@ -12617,6 +12695,28 @@ var LinkedDeviceSchema = zod.z.object({
12617
12695
  features: zod.z.array(zod.z.string()),
12618
12696
  producesTrackedEvents: zod.z.boolean().optional()
12619
12697
  });
12698
+ /**
12699
+ * The `linked-devices` extension slot's editable value (D648): the operator's
12700
+ * pick list, exactly what `_linkedDeviceIds` persists. Tree children are NOT
12701
+ * in it — they are always linked and are not a pick.
12702
+ */
12703
+ var LinkedDevicesSlotValueSchema = zod.z.object({ deviceIds: zod.z.array(zod.z.number().int().positive()) });
12704
+ /**
12705
+ * The `linked-devices` slot — a camera's companion devices, owned by the
12706
+ * device manager over `_linkedDeviceIds` (D648, D356). Any device may be a
12707
+ * source except a container (its children are picked in its place) and the
12708
+ * camera itself.
12709
+ */
12710
+ var LINKED_DEVICES_SLOT = {
12711
+ id: "linked-devices",
12712
+ label: "Linked devices",
12713
+ description: "Companion devices of this camera: their controls appear with it, and the ones you opt in produce tracked events on it.",
12714
+ shape: "association",
12715
+ hostDeviceTypes: [DeviceType.Camera],
12716
+ sourceCaps: "any",
12717
+ cardinality: "many",
12718
+ value: LinkedDevicesSlotValueSchema
12719
+ };
12620
12720
  /** One camera's resolved linked set, tagged with the camera it belongs to.
12621
12721
  * The batch answer needs the tag; the single-device answer already has it
12622
12722
  * from the input, which is why `getLinkedDevices` keeps the untagged shape. */
@@ -12766,6 +12866,7 @@ var deviceManagerCapability = {
12766
12866
  name: "device-manager",
12767
12867
  scope: "system",
12768
12868
  mode: "singleton",
12869
+ extensionSlots: [LINKED_DEVICES_SLOT],
12769
12870
  exposesDeviceSettings: true,
12770
12871
  methods: {
12771
12872
  /** Reserve (or re-resolve) a progressive numeric id for `(addonId, stableId)`.
@@ -13269,11 +13370,12 @@ var deviceManagerCapability = {
13269
13370
  /**
13270
13371
  * Resolve the devices LINKED to a camera — the single policy authority
13271
13372
  * both consumers call (viewer devices panel + pipeline-analytics event
13272
- * kinds/ingest). Device-tree children are ALWAYS included; mode 'auto'
13273
- * (default) adds every device sharing the camera's non-null `location`,
13274
- * mode 'manual' adds the persisted manual list instead. Excludes the
13275
- * camera itself; deduped. Configuration is standard per-device settings
13276
- * (see the module docblock) — there are no bespoke link mutations.
13373
+ * kinds/ingest). Device-tree children are ALWAYS included, plus the
13374
+ * operator's persisted pick list (`mode` is always `manual` since D356:
13375
+ * same-location devices are suggested by the picker, never linked on
13376
+ * their own). Excludes the camera itself; deduped. The list is written by
13377
+ * the settings section or the `linked-devices` extension slot, both over
13378
+ * `_linkedDeviceIds` (see the module docblock).
13277
13379
  */
13278
13380
  getLinkedDevices: method(zod.z.object({ deviceId: zod.z.number() }), zod.z.object({
13279
13381
  mode: LinkedDevicesModeSchema,
@@ -13818,11 +13920,98 @@ var EmbeddingResultSchema = zod.z.object({
13818
13920
  embedding: zod.z.array(zod.z.number()),
13819
13921
  inferenceMs: zod.z.number()
13820
13922
  });
13923
+ /** The two CLIP towers the encoder runs; a crash budget is kept per tower. */
13924
+ var EmbeddingTowerSchema = zod.z.enum(["image", "text"]);
13925
+ /**
13926
+ * A tower in the terminal `failed` state (D649, D6): it crashed or failed to
13927
+ * load `crashes` times within `windowMs`, and is refused by name until an
13928
+ * operator `resetFailedModels` or a model change — never on a timer.
13929
+ *
13930
+ * `nodeId` is the node whose tower failed. The state lives in THAT node's
13931
+ * encoder process (in memory — a runner respawn clears it), and one node's
13932
+ * answer says nothing about another's.
13933
+ */
13934
+ var EmbeddingFailedModelSchema = zod.z.object({
13935
+ modelId: zod.z.string(),
13936
+ tower: EmbeddingTowerSchema,
13937
+ nodeId: zod.z.string(),
13938
+ crashes: zod.z.number(),
13939
+ windowMs: zod.z.number(),
13940
+ sinceMs: zod.z.number(),
13941
+ lastReason: zod.z.string()
13942
+ });
13943
+ /**
13944
+ * A model whose REQUIREMENTS can never be met on this node (D649 round 5):
13945
+ * an id the catalog does not know, a model URL answering 404/410, a declared
13946
+ * sibling (the tokenizer) that is not there. After `attempts` failed builds
13947
+ * it is terminally `requirements-failed`, refused by name until an operator
13948
+ * `resetFailedModels` or a model change — the same exits as a crashed tower.
13949
+ */
13950
+ var EmbeddingFailedRequirementSchema = zod.z.object({
13951
+ modelId: zod.z.string(),
13952
+ tower: EmbeddingTowerSchema,
13953
+ nodeId: zod.z.string(),
13954
+ attempts: zod.z.number(),
13955
+ sinceMs: zod.z.number(),
13956
+ lastReason: zod.z.string()
13957
+ });
13821
13958
  var EmbeddingInfoSchema = zod.z.object({
13822
13959
  modelId: zod.z.string(),
13823
13960
  embeddingDim: zod.z.number(),
13824
- ready: zod.z.boolean()
13825
- });
13961
+ ready: zod.z.boolean(),
13962
+ /**
13963
+ * The node that answered. Absent only from an encoder older than D649's
13964
+ * crash budget — whose `failedModels` is then UNKNOWN (D315), never "none".
13965
+ */
13966
+ nodeId: zod.z.string().optional(),
13967
+ /**
13968
+ * Towers in `failed` on the answering node, each row naming it. `undefined`
13969
+ * means the node could not say (pre-budget encoder); a node that has the
13970
+ * budget always answers an array, empty included.
13971
+ */
13972
+ failedModels: zod.z.array(EmbeddingFailedModelSchema).optional(),
13973
+ /** Models terminally `requirements-failed` on the answering node; same reading as above. */
13974
+ failedRequirements: zod.z.array(EmbeddingFailedRequirementSchema).optional()
13975
+ });
13976
+ /**
13977
+ * The THREE codes an encoder refusal can carry (D649, D6). Same shape as
13978
+ * `VECTOR_INDEX_DIM_CONFLICT`: the code rides in the MESSAGE, because an
13979
+ * Error's own properties do not survive the UDS/tRPC hop and its message does,
13980
+ * and both sides go through the helpers below — the encoder builds the
13981
+ * refusal, the live detail plane classifies on it to count refusals per
13982
+ * camera instead of logging one warning per track. The bracketed token
13983
+ * carries the code, the model, the tower and the node so a consumer never
13984
+ * parses prose.
13985
+ *
13986
+ * - `EMBEDDING_MODEL_FAILED`: the tower crashed / failed to load past the crash
13987
+ * budget — terminal until `resetFailedModels` or a model change.
13988
+ * - `EMBEDDING_REQUIREMENTS_UNAVAILABLE`: files or runtime not there right now
13989
+ * (a download or Python that failed, or the cooldown after one) — the next
13990
+ * request past the cooldown tries again.
13991
+ * - `EMBEDDING_REQUIREMENTS_FAILED`: the requirements can never be met (unknown
13992
+ * id, 404/410, missing sibling) and the bounded attempts are spent —
13993
+ * terminal, same exits as a crashed tower.
13994
+ */
13995
+ var EMBEDDING_MODEL_FAILED = "embedding-model-failed";
13996
+ var EMBEDDING_REQUIREMENTS_UNAVAILABLE = "embedding-requirements-unavailable";
13997
+ var EMBEDDING_REQUIREMENTS_FAILED = "embedding-requirements-failed";
13998
+ zod.z.enum([
13999
+ EMBEDDING_MODEL_FAILED,
14000
+ EMBEDDING_REQUIREMENTS_UNAVAILABLE,
14001
+ EMBEDDING_REQUIREMENTS_FAILED
14002
+ ]);
14003
+ new RegExp(`\\[(${EMBEDDING_MODEL_FAILED}|${EMBEDDING_REQUIREMENTS_UNAVAILABLE}|${EMBEDDING_REQUIREMENTS_FAILED}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);
14004
+ /**
14005
+ * ONE provider per node (`placement: any-node`), addressed like every global
14006
+ * collection: the codegen injects a `{ nodeId?, addonId? }` selector on the
14007
+ * void methods and lifts a top-level `nodeId` off the object ones. A call
14008
+ * that names no node is answered by the HUB's provider — never by a merge
14009
+ * across nodes, because no global collection fans out across nodes (only the
14010
+ * providers of one node are `concatCollection`-fanned). So a fleet view of
14011
+ * `failedModels` is one `getInfo({ nodeId })` per node, and every answer
14012
+ * names the node it came from (D649 round 4); a node that cannot be asked is
14013
+ * UNKNOWN to the reader, never "no failures" (D315).
14014
+ */
13826
14015
  var embeddingEncoderCapability = {
13827
14016
  name: "embedding-encoder",
13828
14017
  scope: "system",
@@ -13841,8 +14030,30 @@ var embeddingEncoderCapability = {
13841
14030
  width: zod.z.number(),
13842
14031
  height: zod.z.number()
13843
14032
  }), EmbeddingResultSchema, { auth: "admin" }),
13844
- encodeText: method(zod.z.object({ text: zod.z.string() }), EmbeddingResultSchema, { auth: "admin" }),
13845
- getInfo: method(zod.z.void(), EmbeddingInfoSchema, { auth: "admin" })
14033
+ /**
14034
+ * `modelId` (a CLIP IMAGE model id, whose catalog `clip.textModelId` names
14035
+ * the text tower) encodes in that model's space; absent, the cluster row's
14036
+ * `clip-embedding` model — the space every writer is in (D649).
14037
+ */
14038
+ encodeText: method(zod.z.object({
14039
+ text: zod.z.string(),
14040
+ modelId: zod.z.string().min(1).optional()
14041
+ }), EmbeddingResultSchema, { auth: "admin" }),
14042
+ /** Answers for ONE node — the `nodeId` selector's, else the hub's. */
14043
+ getInfo: method(zod.z.void(), EmbeddingInfoSchema, { auth: "admin" }),
14044
+ /**
14045
+ * The operator's explicit clear of the `failed` state (one model, or all)
14046
+ * on ONE node — pass `nodeId` for an agent; the result names the node it
14047
+ * cleared. The only way out besides a model change: a crashing tower is
14048
+ * not retried on a timer.
14049
+ */
14050
+ resetFailedModels: method(zod.z.object({ modelId: zod.z.string().min(1).optional() }), zod.z.object({
14051
+ cleared: zod.z.array(zod.z.string()),
14052
+ nodeId: zod.z.string()
14053
+ }), {
14054
+ kind: "mutation",
14055
+ auth: "admin"
14056
+ })
13846
14057
  }
13847
14058
  };
13848
14059
  /**
@@ -17637,7 +17848,12 @@ var NcMediaPolicySchema = zod.z.object({
17637
17848
  * the degrade engine, which drops the video and keeps the still.
17638
17849
  */
17639
17850
  clip: zod.z.boolean().optional(),
17640
- /** Seconds of footage BEFORE / AFTER the event instant. Defaults 3 / 7. */
17851
+ /**
17852
+ * Seconds of footage BEFORE / AFTER the event instant. Absent =
17853
+ * {@link NC_CLIP_PRE_ROLL_DEFAULT_SEC} / {@link NC_CLIP_POST_ROLL_DEFAULT_SEC}
17854
+ * (4 / 6), resolved by the Notification Center at dispatch — deliberately not
17855
+ * a Zod default, so a rule that never chose keeps following the hub's.
17856
+ */
17641
17857
  clipPreRollSec: zod.z.number().int().min(0).max(30).optional(),
17642
17858
  clipPostRollSec: zod.z.number().int().min(0).max(30).optional(),
17643
17859
  /**
@@ -19212,6 +19428,130 @@ var oauthIntegrationCapability = {
19212
19428
  getDescriptor: method(zod.z.void(), OauthIntegrationDescriptorSchema, { auth: "admin" }) }
19213
19429
  };
19214
19430
  /**
19431
+ * A model choice has a SCOPE, and a scope change has a workflow.
19432
+ *
19433
+ * ## The two scopes
19434
+ *
19435
+ * Almost every pipeline step's model is a **node** question: which build runs
19436
+ * fastest on THIS accelerator. Two nodes may legitimately answer differently —
19437
+ * a Coral runs the tflite SSD, a Mac runs the coreml YOLO — because the answers
19438
+ * are compared against nothing. They produce boxes, and a box is a box.
19439
+ *
19440
+ * Two steps are not like that. `face-embedding` and `clip-embedding` produce
19441
+ * **vectors that land in ONE shared index** (`identity_samples`,
19442
+ * `vec_object_clip`) and are ranked against each other by cosine similarity.
19443
+ * Cosine similarity between two encoders is not a weak signal, it is a
19444
+ * meaningless number — and nothing inside a vector can tell you it happened.
19445
+ * So for those two steps the model is a **cluster** question with exactly one
19446
+ * answer, stored in exactly one row.
19447
+ *
19448
+ * That is the same argument [D52](../../../../docs/decisions/adr-0052.md) makes
19449
+ * for the crop convention (`detail-crop.ts`), one level up: the crop decides
19450
+ * WHAT pixels the encoder sees, this decides WHICH encoder sees them. Both are
19451
+ * cluster-wide for the same reason and neither may become per-node.
19452
+ *
19453
+ * ## Why the registry lives here and not in the step catalog
19454
+ *
19455
+ * The scope itself is declared on the step, in
19456
+ * `detection-pipeline/registry/step-definitions.ts` (`StepDefinition.modelScope`)
19457
+ * — that is where a new step declares what kind of choice its model is. But the
19458
+ * catalog lives inside `addon-pipeline`, and three packages that must NOT
19459
+ * import an addon need to know the set: the orchestrator (which renders and
19460
+ * stores the row), post-analysis (which pins the row for a re-embed pass) and
19461
+ * admin-ui (which mirrors it). So the set is mirrored here, and
19462
+ * `scripts/check-cluster-model-scope.ts` fails the build when the two disagree.
19463
+ * A hand-copied key that stops matching is exactly how a setting silently stops
19464
+ * arriving while both sides still look correct.
19465
+ *
19466
+ * ## The defaults ARE today's behaviour
19467
+ *
19468
+ * {@link DEFAULT_CLUSTER_STEP_MODELS} reproduces the catalog `defaultModelId`
19469
+ * of both steps. Declaring the scope therefore changes nothing on the day it
19470
+ * ships: the cluster row starts out saying what every node was already doing.
19471
+ * Changing it is legitimate — that is what the knob is for — but it invalidates
19472
+ * the stored vectors of that surface, and must be followed by a re-embed pass
19473
+ * (`face-reembed-pass.ts`, `embedding-rebuild.ts`).
19474
+ */
19475
+ /**
19476
+ * Why the orchestrator cannot say which model the operator chose for a
19477
+ * cluster-scoped step (D651).
19478
+ */
19479
+ var CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS = [
19480
+ "owner-not-ready",
19481
+ "store-read-failed",
19482
+ "three-way-read-unavailable",
19483
+ "invalid-stored",
19484
+ "not-cluster-scoped"
19485
+ ];
19486
+ Object.freeze(Object.fromEntries([{
19487
+ stepId: "face-embedding",
19488
+ label: "Face recognition model",
19489
+ defaultModelId: "auraface-r100",
19490
+ indexName: "the enrolled face gallery",
19491
+ options: [
19492
+ {
19493
+ id: "auraface-r100",
19494
+ label: "AuraFace R100"
19495
+ },
19496
+ {
19497
+ id: "arcface-r100",
19498
+ label: "ArcFace (ResNet34)"
19499
+ },
19500
+ {
19501
+ id: "inception-resnet-v1",
19502
+ label: "Inception ResNet V1"
19503
+ }
19504
+ ]
19505
+ }, {
19506
+ stepId: "clip-embedding",
19507
+ label: "Semantic search model",
19508
+ defaultModelId: "mobileclip-s1",
19509
+ indexName: "the object semantic-search index",
19510
+ options: [
19511
+ {
19512
+ id: "mobileclip-s1",
19513
+ label: "MobileCLIP S1"
19514
+ },
19515
+ {
19516
+ id: "mobileclip-s2",
19517
+ label: "MobileCLIP S2"
19518
+ },
19519
+ {
19520
+ id: "siglip2-b16-224",
19521
+ label: "SigLIP2 B/16 (Apache-2.0)"
19522
+ }
19523
+ ]
19524
+ }].map((s) => [s.stepId, s.defaultModelId])));
19525
+ var CLUSTER_STEP_SETTING_FIELDS = [{
19526
+ stepId: "face-embedding",
19527
+ key: "minLandmarkFaceSize",
19528
+ label: "Min face size for recognition (detection px)",
19529
+ 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.",
19530
+ type: "slider",
19531
+ min: 0,
19532
+ max: 64,
19533
+ step: 2,
19534
+ default: 24
19535
+ }];
19536
+ function clusterStepSettingKey(stepId, fieldKey) {
19537
+ return `clusterStepSetting:${stepId}:${fieldKey}`;
19538
+ }
19539
+ var ClusterSettingNumberSchema = zod.z.number().finite();
19540
+ function readClusterStepSettings(config) {
19541
+ const out = {};
19542
+ for (const field of CLUSTER_STEP_SETTING_FIELDS) {
19543
+ const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
19544
+ const value = parsed.success ? parsed.data : field.default;
19545
+ const existing = out[field.stepId] ?? {};
19546
+ out[field.stepId] = {
19547
+ ...existing,
19548
+ [field.key]: value
19549
+ };
19550
+ }
19551
+ return out;
19552
+ }
19553
+ readClusterStepSettings({});
19554
+ /**
19215
19555
  * pipeline-analytics — device-scoped wrapper cap. Refines raw
19216
19556
  * per-frame detections emitted by the pipeline runner into tracked
19217
19557
  * objects, per-kind event collections (motion / object / audio), and
@@ -20035,7 +20375,8 @@ var MediaFileKindEnum = zod.z.enum([
20035
20375
  "thumbnailSmall",
20036
20376
  "confirmationCrop",
20037
20377
  "debugCrop",
20038
- "sceneFrame"
20378
+ "sceneFrame",
20379
+ "lastSceneFrame"
20039
20380
  ]);
20040
20381
  /**
20041
20382
  * One media row ON THE WIRE: what it is, how big it is, and WHERE ITS BYTES
@@ -20597,7 +20938,23 @@ var SearchObjectEventsInput = zod.z.object({
20597
20938
  until: zod.z.number().optional(),
20598
20939
  classFilter: zod.z.string().optional(),
20599
20940
  limit: zod.z.number().default(50),
20600
- minScore: zod.z.number().min(0).max(1).default(.2)
20941
+ /**
20942
+ * An ABSOLUTE cosine floor. Optional since D649: a floor is a property of the
20943
+ * model (0.2 kept 96% of matched pairs on MobileCLIP S1 and 2.7% on SigLIP2),
20944
+ * so an absent one resolves to the searched model's own `searchMinScore`
20945
+ * scaled by `strictness`. A number sent here is honoured verbatim.
20946
+ */
20947
+ minScore: zod.z.number().min(0).max(1).optional(),
20948
+ /** Model-relative floor — see `resolveClipSearchMinScore`. Default `loose`. */
20949
+ strictness: ClipSearchStrictnessSchema.optional(),
20950
+ /**
20951
+ * Search THIS CLIP model's index instead of the cluster row's. Every index a
20952
+ * model ever wrote stays searchable until it is wiped (the MobileCLIP index
20953
+ * through a SigLIP2 cutover and its rollback window). An id with no CLIP
20954
+ * metadata is refused; an id other than the cluster row's is ADMIN-only
20955
+ * (`model-override-requires-admin`).
20956
+ */
20957
+ modelId: zod.z.string().min(1).optional()
20601
20958
  });
20602
20959
  var TrackCascadeCountsSchema = zod.z.object({
20603
20960
  /** Persisted track roots deleted (authoritative). */
@@ -20732,7 +21089,41 @@ var RebuildObjectEmbeddingsInput = zod.z.object({
20732
21089
  * comparable, so wiping and rebuilding is the only way to be sure every vector
20733
21090
  * means the same thing.
20734
21091
  */
20735
- var WipeObjectEmbeddingsResultSchema = zod.z.object({ deleted: zod.z.number() });
21092
+ var WipeObjectEmbeddingsResultSchema = zod.z.object({
21093
+ deleted: zod.z.number(),
21094
+ /**
21095
+ * CLIP indexes that could NOT be emptied (unreachable, or refused at their
21096
+ * dimension) — not a clean slate. Additive and optional (D649).
21097
+ */
21098
+ failedIndexes: zod.z.array(zod.z.string()).optional()
21099
+ });
21100
+ /**
21101
+ * Why a rebuild did not start, BY NAME — ONE vocabulary for both gates in front
21102
+ * of a pass (D649 over D651). A bare `started: false` read the same for "the
21103
+ * stores are booting" and "the cluster row names a model with no CLIP
21104
+ * metadata", which need different fixes.
21105
+ * - `stores-unavailable` — the analytics stores or the API are not up yet.
21106
+ * - the owner's confirmation of the cluster model (D651, `ClusterPinConfirmer`):
21107
+ * a pass that rewrites an index needs two agreeing reads of the OWNER's
21108
+ * answer (`pipelineOrchestrator.getClusterModelChoice`) — a pass that cannot
21109
+ * name its model does not run (D54):
21110
+ * - the owner's own `unreadable` reasons (`owner-not-ready`,
21111
+ * `store-read-failed`, `three-way-read-unavailable`, `invalid-stored`,
21112
+ * `not-cluster-scoped`);
21113
+ * - `method-unavailable` — the orchestrator predates the method;
21114
+ * - `read-failed` — the call failed or answered something unparseable;
21115
+ * - `reads-disagree` — the two reads named different choices.
21116
+ * - `not-a-clip-model` — the CONFIRMED id has no CLIP metadata, so there is no
21117
+ * index to fill and no dimension to check against (D649).
21118
+ */
21119
+ var RebuildObjectEmbeddingsRefusalSchema = zod.z.enum([
21120
+ "stores-unavailable",
21121
+ ...CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS,
21122
+ "method-unavailable",
21123
+ "read-failed",
21124
+ "reads-disagree",
21125
+ "not-a-clip-model"
21126
+ ]);
20736
21127
  /**
20737
21128
  * Acknowledgement that a rebuild STARTED.
20738
21129
  *
@@ -20745,7 +21136,12 @@ var WipeObjectEmbeddingsResultSchema = zod.z.object({ deleted: zod.z.number() })
20745
21136
  var RebuildObjectEmbeddingsResultSchema = zod.z.object({
20746
21137
  started: zod.z.boolean(),
20747
21138
  /** True when a pass was already running; the new request is ignored. */
20748
- alreadyRunning: zod.z.boolean()
21139
+ alreadyRunning: zod.z.boolean(),
21140
+ /** Present when the pass refused to start — see `RebuildObjectEmbeddingsRefusalSchema`. */
21141
+ refusal: RebuildObjectEmbeddingsRefusalSchema.optional(),
21142
+ /** The CLIP model the pass pinned, and the index it fills (when it started). */
21143
+ modelId: zod.z.string().optional(),
21144
+ index: zod.z.string().optional()
20749
21145
  });
20750
21146
  var RebuildStatusSchema = zod.z.object({
20751
21147
  running: zod.z.boolean(),
@@ -20779,7 +21175,11 @@ var RebuildStatusSchema = zod.z.object({
20779
21175
  startedAtMs: zod.z.number().nullable(),
20780
21176
  finishedAtMs: zod.z.number().nullable(),
20781
21177
  /** Present when the pass ended by throwing. */
20782
- error: zod.z.string().nullable()
21178
+ error: zod.z.string().nullable(),
21179
+ /** The CLIP model the current / last pass pinned (D54), `null` before any. */
21180
+ modelId: zod.z.string().nullable(),
21181
+ /** The index that pass fills — `ClipModelMeta.vectorIndex` of `modelId` (D649). */
21182
+ index: zod.z.string().nullable()
20783
21183
  });
20784
21184
  /**
20785
21185
  * Acknowledgement that a debug-media reclaim STARTED.
@@ -21723,7 +22123,7 @@ var pipelineAnalyticsCapability = {
21723
22123
  * ObjectEvents by trackId. Returns up to `limit` events scored ≥
21724
22124
  * `minScore`, sorted descending by score.
21725
22125
  */
21726
- searchObjectEvents: method(SearchObjectEventsInput, zod.z.array(ScoredObjectEventSchema).readonly()),
22126
+ searchObjectEvents: method(SearchObjectEventsInput, zod.z.array(ScoredObjectEventSchema).readonly(), { caller: "required" }),
21727
22127
  wipeObjectEmbeddings: method(zod.z.object({}), WipeObjectEmbeddingsResultSchema, {
21728
22128
  kind: "mutation",
21729
22129
  auth: "admin"
@@ -23017,6 +23417,17 @@ var RunnerFrameSourceSchema = zod.z.discriminatedUnion("kind", [zod.z.object({ k
23017
23417
  hubHostnameOverride: zod.z.string().optional()
23018
23418
  })]).describe("Per-camera frame-source mode for the runner (P2c)");
23019
23419
  /**
23420
+ * What ONE step runs with on ONE roster device for THIS camera (D650): the
23421
+ * device's per-(node,device) base with the camera's override for that device
23422
+ * on top — the same `override ?? base` merge the orchestrator applies to the
23423
+ * elected device (`applyDeviceProvisioning`). Absent `modelId` ⇒ the executor
23424
+ * resolves the device format's default, exactly as on the elected device.
23425
+ */
23426
+ var RunnerJumpStepProvisioningSchema = zod.z.object({
23427
+ modelId: zod.z.string().optional(),
23428
+ settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
23429
+ });
23430
+ /**
23020
23431
  * One ENABLED inference device on the runner's node, as the step-tree
23021
23432
  * device-jump resolver sees it (phase 1). The orchestrator populates this
23022
23433
  * roster on the attach payload whenever the camera is elected onto a specific
@@ -23028,7 +23439,16 @@ var RunnerFrameSourceSchema = zod.z.discriminatedUnion("kind", [zod.z.object({ k
23028
23439
  var RunnerInferenceDeviceSchema = zod.z.object({
23029
23440
  deviceKey: zod.z.string(),
23030
23441
  weight: zod.z.number().positive().default(1),
23031
- maxSessions: zod.z.number().int().positive().nullable().default(null)
23442
+ maxSessions: zod.z.number().int().positive().nullable().default(null),
23443
+ /**
23444
+ * Per-step provisioning for this camera on THIS device (D650), keyed by step
23445
+ * id. A step the runner jumps here runs with these fields, never with the
23446
+ * elected device's: `modelId` / `settings` are REPLACED on the jumped subtree
23447
+ * (a step absent from the map runs with neither — the target format default).
23448
+ * Absent field ⇒ an orchestrator that predates D650: the jumped step keeps
23449
+ * the elected device's provisioning, as before.
23450
+ */
23451
+ steps: zod.z.record(zod.z.string(), RunnerJumpStepProvisioningSchema).optional()
23032
23452
  });
23033
23453
  /**
23034
23454
  * Camera assignment payload sent by `addon-pipeline-orchestrator` to a
@@ -24125,6 +24545,28 @@ var NodeInferenceDeviceSchema = zod.z.object({
24125
24545
  */
24126
24546
  exclusion: InferenceDeviceExclusionReasonSchema.nullable()
24127
24547
  });
24548
+ /**
24549
+ * The operator's model choice for one cluster-scoped step, answered by the
24550
+ * addon that OWNS the `clusterModel:*` settings (D651). Three answers, never
24551
+ * folded: a written choice, a key nobody wrote (the cluster runs the default
24552
+ * BY ABSENCE), or no answer. A caller that rewrites an index acts only on the
24553
+ * first two, read twice and agreeing.
24554
+ */
24555
+ var ClusterModelChoiceSchema = zod.z.discriminatedUnion("kind", [
24556
+ zod.z.object({
24557
+ kind: zod.z.literal("stored"),
24558
+ modelId: zod.z.string()
24559
+ }),
24560
+ zod.z.object({
24561
+ kind: zod.z.literal("absent"),
24562
+ defaultModelId: zod.z.string()
24563
+ }),
24564
+ zod.z.object({
24565
+ kind: zod.z.literal("unreadable"),
24566
+ reason: zod.z.enum(CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS),
24567
+ error: zod.z.string().optional()
24568
+ })
24569
+ ]);
24128
24570
  var NodeInferenceDevicesSchema = zod.z.object({
24129
24571
  nodeId: zod.z.string(),
24130
24572
  /** False when the node's platform-probe was unreachable (no live device set). */
@@ -24221,9 +24663,19 @@ var pipelineOrchestratorCapability = {
24221
24663
  * Trigger a full rebalance pass. Iterates over all assigned cameras,
24222
24664
  * recomputes the optimal agent for each one based on current load +
24223
24665
  * hardware affinity, and migrates cameras whose current agent is no
24224
- * longer optimal. Pinned cameras are never migrated.
24225
- */
24226
- rebalance: method(zod.z.void(), zod.z.object({ migrated: zod.z.number() }), {
24666
+ * longer optimal. Pinned cameras are never migrated. `skipped` names the
24667
+ * cameras the pass wanted to move and could not, with why — a target node
24668
+ * that has not answered its catalog / device health yet, or a device that
24669
+ * cannot run the camera's root (D650).
24670
+ */
24671
+ rebalance: method(zod.z.void(), zod.z.object({
24672
+ migrated: zod.z.number(),
24673
+ skipped: zod.z.array(zod.z.object({
24674
+ deviceId: zod.z.number(),
24675
+ targetNodeId: zod.z.string(),
24676
+ reason: zod.z.string()
24677
+ })).default([])
24678
+ }), {
24227
24679
  kind: "mutation",
24228
24680
  auth: "admin"
24229
24681
  }),
@@ -24233,6 +24685,13 @@ var pipelineOrchestratorCapability = {
24233
24685
  getPipelineAssignment: method(zod.z.object({ deviceId: zod.z.number() }), PipelineAssignmentSchema.nullable()),
24234
24686
  /** Get per-agent load summaries used by the load balancer + dashboards. */
24235
24687
  getAgentLoad: method(zod.z.void(), zod.z.array(AgentLoadSummarySchema).readonly()),
24688
+ /**
24689
+ * The operator's STORED model choice for one cluster-scoped step (D651).
24690
+ * Read three-way from this addon's own store, only once its boot has
24691
+ * settled. Unlike `addonSettings.getGlobalSettings`, it never answers a
24692
+ * default as though someone chose it.
24693
+ */
24694
+ getClusterModelChoice: method(zod.z.object({ stepId: zod.z.string() }), ClusterModelChoiceSchema),
24236
24695
  /** Aggregate global metrics across the whole detection cluster. */
24237
24696
  getGlobalMetrics: method(zod.z.void(), GlobalMetricsSchema),
24238
24697
  /**
@@ -26703,6 +27162,20 @@ var VectorScanResultSchema = zod.z.object({
26703
27162
  */
26704
27163
  nextCursor: zod.z.number().int().nonnegative().nullable()
26705
27164
  });
27165
+ /**
27166
+ * The ONE error code for "this index exists at another dimension; refusing to
27167
+ * redeclare it" (D649). It rides in the MESSAGE — an Error's own properties do
27168
+ * not survive the UDS/tRPC hop, its message does — and both sides go through
27169
+ * the helpers below, never a copied phrase: a consumer that must tell "this
27170
+ * index can never hold my vectors" from "the provider is unreachable" (a
27171
+ * delete counts the first as nothing-to-delete and the second as still
27172
+ * present) otherwise breaks silently the day the wording changes.
27173
+ */
27174
+ var VECTOR_INDEX_DIM_CONFLICT = "vector-index-dim-conflict";
27175
+ /** The provider's refusal, carrying {@link VECTOR_INDEX_DIM_CONFLICT}. */
27176
+ function vectorIndexDimConflictError(index, declaredDim, requestedDim) {
27177
+ return /* @__PURE__ */ new Error(`[${VECTOR_INDEX_DIM_CONFLICT}] vector-store: index "${index}" is declared with dim ${String(declaredDim)}; refusing to redeclare as ${String(requestedDim)}`);
27178
+ }
26706
27179
  var VectorStatsInputSchema = zod.z.object({ index: zod.z.string() });
26707
27180
  var VectorStatsResultSchema = zod.z.object({
26708
27181
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -27561,6 +28034,424 @@ var videoclipsCapability = {
27561
28034
  }
27562
28035
  };
27563
28036
  /**
28037
+ * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
28038
+ * valutatore puro del suo FRONTE.
28039
+ *
28040
+ * Viveva dentro il builtin virtual-doorbell
28041
+ * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
28042
+ * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
28043
+ * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
28044
+ * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
28045
+ * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
28046
+ * SPOSTA qui e il doorbell la ri-esporta.
28047
+ *
28048
+ * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
28049
+ * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
28050
+ * regola" (e include `presence`, `cover`, `alarm-panel`), questa a "qual è il
28051
+ * booleano il cui FRONTE conta". Vocabolari deliberatamente diversi.
28052
+ */
28053
+ /**
28054
+ * Known binary / switch source caps → the boolean slice field whose
28055
+ * false→true rise counts as ACTIVE. Every entry is "fire on active".
28056
+ * Sensors whose "active" reading is not a plain boolean (presence's string
28057
+ * state, connectivity's connected flag) are deliberately excluded — a
28058
+ * reconnect is not a doorbell press, and it is not a recording either.
28059
+ */
28060
+ var SOURCE_CAP_ACTIVE_FIELD = {
28061
+ contact: "entryOpen",
28062
+ binary: "on",
28063
+ switch: "on",
28064
+ motion: "detected",
28065
+ flood: "flooded",
28066
+ gas: "detected",
28067
+ smoke: "detected",
28068
+ "carbon-monoxide": "detected",
28069
+ vibration: "detected",
28070
+ tamper: "tampered"
28071
+ };
28072
+ /**
28073
+ * The same caps → the slice field carrying the ms-epoch timestamp of the
28074
+ * last transition. Every source cap MUST appear here (guarded by a spec):
28075
+ * without a transition timestamp the evaluator cannot tell a genuine rise
28076
+ * from a boot-time hydration when the FIRST slice it ever sees is already
28077
+ * active, and errs towards silence — swallowing the rise.
28078
+ *
28079
+ * These timestamps are UPSTREAM ones, not ingest ones: the Home Assistant
28080
+ * provider derives them from `state.last_changed`, so they survive our own
28081
+ * restarts and correctly read as "hours ago" for a state that has been
28082
+ * active for hours. `motion` names its rise timestamp `lastDetectedAt`.
28083
+ */
28084
+ var SOURCE_CAP_CHANGED_AT_FIELD = {
28085
+ contact: "lastChangedAt",
28086
+ binary: "lastChangedAt",
28087
+ switch: "lastChangedAt",
28088
+ motion: "lastDetectedAt",
28089
+ flood: "lastChangedAt",
28090
+ gas: "lastChangedAt",
28091
+ smoke: "lastChangedAt",
28092
+ "carbon-monoxide": "lastChangedAt",
28093
+ vibration: "lastChangedAt",
28094
+ tamper: "lastChangedAt"
28095
+ };
28096
+ /** Cap names whose presence in a device's bindings qualify it as a source. */
28097
+ var SOURCE_CAPS = Object.keys(SOURCE_CAP_ACTIVE_FIELD);
28098
+ /**
28099
+ * Device `type` values (from `DeviceType`) that can host a binary/switch
28100
+ * source cap. Used by the camera's `device-multiselect` picker as the
28101
+ * CLIENT-SIDE filter, alongside `SOURCE_CAPS`.
28102
+ *
28103
+ * Why types and not caps alone: the shared picker filters
28104
+ * `deviceManager.listAll` rows client-side, and those rows carry only the
28105
+ * device's advertised `features` — NOT its registered cap list. On the live
28106
+ * cluster binary sensors and switches advertise EMPTY features (features
28107
+ * mirror only a handful of caps like `motion-trigger`), so a caps-only
28108
+ * filter matched against `features` would list nothing (the very bug this
28109
+ * replaced, which relied on the now-empty `getAllBindings`). Matching by
28110
+ * `type` is the reliable client-side signal; the union with `SOURCE_CAPS`
28111
+ * still captures any device that DOES advertise a source-cap feature.
28112
+ * `sensor` covers contact/motion/flood/gas/smoke/CO/vibration/tamper,
28113
+ * `switch` covers switches, `control` covers generic binary actuators.
28114
+ */
28115
+ var SOURCE_DEVICE_TYPES = [
28116
+ "sensor",
28117
+ "switch",
28118
+ "control"
28119
+ ];
28120
+ /** True when a cap is a recognised binary/switch source. */
28121
+ function isSourceCap(capName) {
28122
+ return Object.prototype.hasOwnProperty.call(SOURCE_CAP_ACTIVE_FIELD, capName);
28123
+ }
28124
+ /** Extract the "active" boolean a source cap's slice carries, or null when
28125
+ * the cap is unknown or the field is missing / non-boolean. */
28126
+ function sliceActiveValue(capName, slice) {
28127
+ const field = SOURCE_CAP_ACTIVE_FIELD[capName];
28128
+ if (field === void 0) return null;
28129
+ const raw = slice[field];
28130
+ return typeof raw === "boolean" ? raw : null;
28131
+ }
28132
+ /** Ms-epoch transition timestamp a source cap's slice carries, or null when
28133
+ * it is absent, non-numeric or the zero "never observed" sentinel. */
28134
+ function sliceChangedAt(capName, slice) {
28135
+ const field = SOURCE_CAP_CHANGED_AT_FIELD[capName];
28136
+ if (field === void 0) return null;
28137
+ const raw = slice[field];
28138
+ if (typeof raw !== "number" || !Number.isFinite(raw) || raw <= 0) return null;
28139
+ return raw;
28140
+ }
28141
+ /**
28142
+ * How recent a source's own transition timestamp must be for a FIRST
28143
+ * sighting that is already active to count as a genuine rise rather than a
28144
+ * hydration of long-standing state.
28145
+ */
28146
+ var DEFAULT_FIRST_SIGHTING_FRESHNESS_MS = 3e4;
28147
+ /**
28148
+ * IL fronte. Puro: nessun orologio proprio, nessuna memoria — il chiamante
28149
+ * porta `prior`, `nowMs` e il proprio `startedAtMs`.
28150
+ *
28151
+ * Il caso della PRIMA slice già attiva è trattato esplicitamente e vale come
28152
+ * fronte solo se il timestamp UPSTREAM della transizione è posteriore a
28153
+ * `startedAtMs` **e** entro `firstSightingFreshnessMs`. Entrambe le metà
28154
+ * servono: la sola freschezza scatterebbe su un'idratazione al boot di uno
28155
+ * stato flippato pochi secondi prima del riavvio, e il solo "dopo che abbiamo
28156
+ * iniziato" scatterebbe, su un processo di lunga vita, per una sorgente
28157
+ * adottata oggi il cui stato è cambiato ieri. Il caso ambiguo ERRA VERSO IL
28158
+ * SILENZIO e lo dichiara (`baseline-seeded-stale-active`).
28159
+ */
28160
+ function evaluateSensorEdge(input) {
28161
+ const value = sliceActiveValue(input.capName, input.slice);
28162
+ if (value === null) return {
28163
+ edge: "none",
28164
+ value: null,
28165
+ reason: isSourceCap(input.capName) ? "non-boolean-value" : "unknown-cap"
28166
+ };
28167
+ if (input.prior === void 0) {
28168
+ if (!value) return {
28169
+ edge: "none",
28170
+ value,
28171
+ reason: "baseline-seeded-inactive"
28172
+ };
28173
+ const changedAt = sliceChangedAt(input.capName, input.slice);
28174
+ const floor = Math.max(input.startedAtMs, input.nowMs - input.firstSightingFreshnessMs);
28175
+ if (changedAt === null || changedAt < floor) return {
28176
+ edge: "none",
28177
+ value,
28178
+ reason: "baseline-seeded-stale-active"
28179
+ };
28180
+ return {
28181
+ edge: "rising",
28182
+ value: true
28183
+ };
28184
+ }
28185
+ if (input.prior === value) return {
28186
+ edge: "none",
28187
+ value,
28188
+ reason: "no-change"
28189
+ };
28190
+ if (!value) return {
28191
+ edge: "none",
28192
+ value,
28193
+ reason: "falling-edge"
28194
+ };
28195
+ return {
28196
+ edge: "rising",
28197
+ value: true
28198
+ };
28199
+ }
28200
+ /**
28201
+ * Doorbell button cap. Two kinds of providers coexist behind this cap
28202
+ * name (same pattern as `snapshot`):
28203
+ *
28204
+ * - **Native** providers: registered per-device by device-driver
28205
+ * addons via `ctx.registerNativeCap` — either on a
28206
+ * `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
28207
+ * or directly on the camera (Reolink registers at camera level).
28208
+ * Emits an `onPressed` event every time the firmware pushes a
28209
+ * ring; status tracks the last press and a pressCount since start
28210
+ * (diagnostic).
28211
+ *
28212
+ * - **Wrapper** provider: the `virtual-doorbell` system builtin
28213
+ * (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
28214
+ * device (contact / switch / event-emitter …) into a doorbell for
28215
+ * a camera. `defaultActive: false` — the operator explicitly binds
28216
+ * it per camera in the device-bindings UI, then picks the source
28217
+ * device + trigger in the per-device settings.
28218
+ *
28219
+ * The DeviceEventPropagator re-emits `onPressed` on the camera parent
28220
+ * — subscribers listening at the camera level receive ring events
28221
+ * with `via[]` populated. No code on the parent needed.
28222
+ */
28223
+ var DoorbellStatusSchema = zod.z.object({
28224
+ /** Ms epoch of the last press. null = never observed since this provider started. */
28225
+ lastPressedAt: zod.z.number().nullable(),
28226
+ /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
28227
+ pressCountSinceStart: zod.z.number()
28228
+ });
28229
+ var DoorbellPressEventSchema = zod.z.object({
28230
+ deviceId: zod.z.number(),
28231
+ timestamp: zod.z.number()
28232
+ });
28233
+ /**
28234
+ * The `doorbell-source` extension slot's editable value (D648): the camera's
28235
+ * virtual-doorbell trigger devices, exactly what the wrapper's
28236
+ * `doorbellSources` persists (as `{ deviceId }` records).
28237
+ */
28238
+ var DoorbellSourceSlotValueSchema = zod.z.object({ deviceIds: zod.z.array(zod.z.number().int().positive()) });
28239
+ /**
28240
+ * The `doorbell-source` slot — which devices ring this camera's VIRTUAL
28241
+ * doorbell, owned by the `virtual-doorbell` wrapper over its
28242
+ * `doorbellSources` store (D648). A source rings when one of its
28243
+ * `SOURCE_CAPS` rises. Whether the wrapper is bound to the camera at all is a
28244
+ * different authority (`deviceManager.setWrapperActive`, D62) — the slot
28245
+ * reports it, it never writes it.
28246
+ */
28247
+ var DOORBELL_SOURCE_SLOT = {
28248
+ id: "doorbell-source",
28249
+ label: "Doorbell trigger devices",
28250
+ 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.",
28251
+ shape: "association",
28252
+ hostDeviceTypes: [DeviceType.Camera],
28253
+ sourceCaps: SOURCE_CAPS,
28254
+ cardinality: "many",
28255
+ value: DoorbellSourceSlotValueSchema
28256
+ };
28257
+ var doorbellCapability = {
28258
+ name: "doorbell",
28259
+ scope: "device",
28260
+ deviceNative: true,
28261
+ mode: "singleton",
28262
+ kind: "wrapper",
28263
+ defaultActive: false,
28264
+ deviceTypes: [DeviceType.Button, DeviceType.Camera],
28265
+ exposesDeviceSettings: true,
28266
+ extensionSlots: [DOORBELL_SOURCE_SLOT],
28267
+ methods: {},
28268
+ events: {
28269
+ /**
28270
+ * Fires once per physical press. Reolink delivers via Baichuan
28271
+ * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
28272
+ * release/duration — it's a pulse.
28273
+ */
28274
+ onPressed: { data: DoorbellPressEventSchema } },
28275
+ status: {
28276
+ schema: DoorbellStatusSchema,
28277
+ kind: "push"
28278
+ },
28279
+ /**
28280
+ * Runtime-state slice — last press timestamp + lifetime press count.
28281
+ * Mirrored by the kernel and readable via
28282
+ * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
28283
+ * without subscribing.
28284
+ */
28285
+ runtimeState: DoorbellStatusSchema,
28286
+ /**
28287
+ * 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.
28288
+ *
28289
+ * See `RuntimeStateDurability`. Enforced by
28290
+ * `scripts/check-runtime-state-durability.ts`.
28291
+ */
28292
+ durability: "restored"
28293
+ };
28294
+ var ExtensionSlotIdSchema = zod.z.enum(["doorbell-source", "linked-devices"]);
28295
+ var EXTENSION_SLOTS = {
28296
+ "doorbell-source": {
28297
+ descriptor: DOORBELL_SOURCE_SLOT,
28298
+ declaringCap: "doorbell",
28299
+ hostDeviceTypes: [DeviceType.Camera]
28300
+ },
28301
+ "linked-devices": {
28302
+ descriptor: LINKED_DEVICES_SLOT,
28303
+ declaringCap: "device-manager",
28304
+ hostDeviceTypes: [DeviceType.Camera]
28305
+ }
28306
+ };
28307
+ /** A slot's editable value, discriminated on `slot`. */
28308
+ var ExtensionSlotValueSchema = zod.z.discriminatedUnion("slot", [DoorbellSourceSlotValueSchema.extend({ slot: zod.z.literal("doorbell-source") }), LinkedDevicesSlotValueSchema.extend({ slot: zod.z.literal("linked-devices") })]);
28309
+ /** Every device type at least one slot is offered on — `device-extension`'s `deviceTypes`. */
28310
+ var EXTENSION_HOST_DEVICE_TYPES = [DeviceType.Camera];
28311
+ var ExtensionSourceAvailabilitySchema = zod.z.discriminatedUnion("state", [zod.z.object({ state: zod.z.literal("ok") }), zod.z.object({
28312
+ state: zod.z.literal("unreachable"),
28313
+ reason: zod.z.string()
28314
+ })]);
28315
+ /** One provider of slots — the D554 source-listing row. */
28316
+ var ExtensionSourceSchema = zod.z.object({
28317
+ /** The routing prefix of every `slotRef` this provider serves. */
28318
+ source: zod.z.string(),
28319
+ label: zod.z.string(),
28320
+ /** Stamped by the dispatcher from the registry (D557). */
28321
+ addonId: zod.z.string().optional(),
28322
+ availability: ExtensionSourceAvailabilitySchema
28323
+ });
28324
+ /**
28325
+ * How one picked source stands. `missing` — no such device (deleted, or an id
28326
+ * that never existed); `foreign` — a device the slot's owner cannot read from
28327
+ * (slice 2's cross-owner graft source); `unavailable` — it exists but is not a
28328
+ * valid source now (a container, which is never a pick). A source in any of
28329
+ * these states is SHOWN, never silently dropped or re-pointed.
28330
+ */
28331
+ var ExtensionSourceHealthSchema = zod.z.enum([
28332
+ "ok",
28333
+ "missing",
28334
+ "foreign",
28335
+ "unavailable"
28336
+ ]);
28337
+ var ExtensionSlotSourceSchema = zod.z.object({
28338
+ deviceId: zod.z.number().int(),
28339
+ /** The device's name, or null when it could not be resolved (`missing`). */
28340
+ name: zod.z.string().nullable(),
28341
+ health: ExtensionSourceHealthSchema,
28342
+ detail: zod.z.string().optional()
28343
+ });
28344
+ /**
28345
+ * A DIFFERENT authority that gates whether the slot's sources do anything —
28346
+ * reported read-only, named, never written through this contract (D62). The
28347
+ * virtual doorbell's sources ring only while the wrapper is bound to the
28348
+ * camera, and that binding belongs to `deviceManager.setWrapperActive`.
28349
+ * `unknown` means the gate could not be read; it is not "inactive" (D315).
28350
+ */
28351
+ var ExtensionSlotActivationSchema = zod.z.object({
28352
+ state: zod.z.enum([
28353
+ "active",
28354
+ "inactive",
28355
+ "unknown"
28356
+ ]),
28357
+ authority: zod.z.string(),
28358
+ detail: zod.z.string().optional()
28359
+ });
28360
+ /** One slot of one device, as its owner reads it from its own store. */
28361
+ var ExtensionSlotStateSchema = zod.z.object({
28362
+ state: zod.z.literal("ok"),
28363
+ /** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
28364
+ slotRef: zod.z.string(),
28365
+ slot: ExtensionSlotIdSchema,
28366
+ /** Names the store written (D62), e.g. `virtual-doorbell:doorbellSources`. */
28367
+ authority: zod.z.string(),
28368
+ /** graft: its switch. association: null — removing every source is "off". */
28369
+ enabled: zod.z.boolean().nullable(),
28370
+ /** graft: the cap registered on the host. association: null. */
28371
+ projects: zod.z.string().nullable(),
28372
+ activation: ExtensionSlotActivationSchema.nullable(),
28373
+ value: ExtensionSlotValueSchema,
28374
+ sources: zod.z.array(ExtensionSlotSourceSchema)
28375
+ });
28376
+ /**
28377
+ * A provider that could not answer `listSlots` at all. It could not name its
28378
+ * own slots, so the row names the ADDON and carries the refusal verbatim.
28379
+ * Written by the dispatcher, never by a provider.
28380
+ */
28381
+ var ExtensionSlotUnreachableSchema = zod.z.object({
28382
+ state: zod.z.literal("unreachable"),
28383
+ addonId: zod.z.string(),
28384
+ reason: zod.z.string()
28385
+ });
28386
+ var ExtensionSlotRowSchema = zod.z.discriminatedUnion("state", [ExtensionSlotStateSchema, ExtensionSlotUnreachableSchema]);
28387
+ /** One device the slot's editor may offer as a source. */
28388
+ var ExtensionCandidateSchema = zod.z.object({
28389
+ deviceId: zod.z.number().int(),
28390
+ name: zod.z.string(),
28391
+ type: zod.z.string(),
28392
+ location: zod.z.string().nullable(),
28393
+ /** The container a child belongs to — "Spotlight 2" alone does not say which. */
28394
+ parentName: zod.z.string().nullable(),
28395
+ /** Pre-marked by the owner's suggestion rule. NEVER saved on its own (D356). */
28396
+ suggested: zod.z.boolean(),
28397
+ /** Why it is suggested ("same location"), null when it is not. */
28398
+ reason: zod.z.string().nullable()
28399
+ });
28400
+ var ExtensionCandidatesSchema = zod.z.object({ candidates: zod.z.array(ExtensionCandidateSchema) });
28401
+ /**
28402
+ * What a write did. `none` — applied in place. `host` / `parent` — the owner
28403
+ * reloaded the host (or, for an accessory child, its parent) because the
28404
+ * write changed what the host REGISTERS (a graft switched on or off, slice 2).
28405
+ */
28406
+ var ExtensionSetResultSchema = zod.z.object({
28407
+ applied: zod.z.literal(true),
28408
+ reload: zod.z.enum([
28409
+ "none",
28410
+ "host",
28411
+ "parent"
28412
+ ])
28413
+ });
28414
+ var ExtensionSlotRefInputSchema = zod.z.object({
28415
+ deviceId: zod.z.number().int(),
28416
+ slotRef: zod.z.string().min(1)
28417
+ });
28418
+ var ExtensionSetSlotInputSchema = ExtensionSlotRefInputSchema.extend({ value: ExtensionSlotValueSchema });
28419
+ var deviceExtensionCapability = {
28420
+ name: "device-extension",
28421
+ scope: "device",
28422
+ mode: "collection",
28423
+ kind: "wrapper",
28424
+ defaultActive: true,
28425
+ deviceTypes: EXTENSION_HOST_DEVICE_TYPES,
28426
+ deviceConfig: { ui: {
28427
+ kind: "widget",
28428
+ widgetId: "host/extensions-panel",
28429
+ tab: "general",
28430
+ label: "Extensions",
28431
+ order: 72
28432
+ } },
28433
+ methods: {
28434
+ /** One row per slot owner — the D554 source listing `slotRef` routes by. */
28435
+ listSources: method(zod.z.object({ deviceId: zod.z.number().int() }), zod.z.array(ExtensionSourceSchema)),
28436
+ /**
28437
+ * Every slot this device is offered, read by each owner from its own
28438
+ * store. A provider that throws is ONE `unreachable` row (D554.4).
28439
+ */
28440
+ listSlots: method(zod.z.object({ deviceId: zod.z.number().int() }), zod.z.array(ExtensionSlotRowSchema)),
28441
+ /** The devices the slot's editor may offer, suggestions pre-marked (D356). */
28442
+ listCandidates: method(ExtensionSlotRefInputSchema, ExtensionCandidatesSchema),
28443
+ /**
28444
+ * Write one slot through its owner's EXISTING write path. The owner
28445
+ * validates (a container is never a linked device, a camera is never its
28446
+ * own source) and refuses by name before persisting.
28447
+ */
28448
+ setSlot: method(ExtensionSetSlotInputSchema, ExtensionSetResultSchema, {
28449
+ kind: "mutation",
28450
+ auth: "admin"
28451
+ })
28452
+ }
28453
+ };
28454
+ /**
27564
28455
  * Optional client-side hints sent at session creation to help the provider
27565
28456
  * pick the best native source. All fields optional — a viewer that knows
27566
28457
  * nothing still gets a sane default. (Relocated from the retired `webrtc`
@@ -30461,75 +31352,6 @@ onStatusChanged: { data: zod.z.object({
30461
31352
  volatileStateFields: ["lastChangedAt"]
30462
31353
  };
30463
31354
  /**
30464
- * Doorbell button cap. Two kinds of providers coexist behind this cap
30465
- * name (same pattern as `snapshot`):
30466
- *
30467
- * - **Native** providers: registered per-device by device-driver
30468
- * addons via `ctx.registerNativeCap` — either on a
30469
- * `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
30470
- * or directly on the camera (Reolink registers at camera level).
30471
- * Emits an `onPressed` event every time the firmware pushes a
30472
- * ring; status tracks the last press and a pressCount since start
30473
- * (diagnostic).
30474
- *
30475
- * - **Wrapper** provider: the `virtual-doorbell` system builtin
30476
- * (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
30477
- * device (contact / switch / event-emitter …) into a doorbell for
30478
- * a camera. `defaultActive: false` — the operator explicitly binds
30479
- * it per camera in the device-bindings UI, then picks the source
30480
- * device + trigger in the per-device settings.
30481
- *
30482
- * The DeviceEventPropagator re-emits `onPressed` on the camera parent
30483
- * — subscribers listening at the camera level receive ring events
30484
- * with `via[]` populated. No code on the parent needed.
30485
- */
30486
- var DoorbellStatusSchema = zod.z.object({
30487
- /** Ms epoch of the last press. null = never observed since this provider started. */
30488
- lastPressedAt: zod.z.number().nullable(),
30489
- /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
30490
- pressCountSinceStart: zod.z.number()
30491
- });
30492
- var DoorbellPressEventSchema = zod.z.object({
30493
- deviceId: zod.z.number(),
30494
- timestamp: zod.z.number()
30495
- });
30496
- var doorbellCapability = {
30497
- name: "doorbell",
30498
- scope: "device",
30499
- deviceNative: true,
30500
- mode: "singleton",
30501
- kind: "wrapper",
30502
- defaultActive: false,
30503
- deviceTypes: [DeviceType.Button, DeviceType.Camera],
30504
- exposesDeviceSettings: true,
30505
- methods: {},
30506
- events: {
30507
- /**
30508
- * Fires once per physical press. Reolink delivers via Baichuan
30509
- * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
30510
- * release/duration — it's a pulse.
30511
- */
30512
- onPressed: { data: DoorbellPressEventSchema } },
30513
- status: {
30514
- schema: DoorbellStatusSchema,
30515
- kind: "push"
30516
- },
30517
- /**
30518
- * Runtime-state slice — last press timestamp + lifetime press count.
30519
- * Mirrored by the kernel and readable via
30520
- * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
30521
- * without subscribing.
30522
- */
30523
- runtimeState: DoorbellStatusSchema,
30524
- /**
30525
- * 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.
30526
- *
30527
- * See `RuntimeStateDurability`. Enforced by
30528
- * `scripts/check-runtime-state-durability.ts`.
30529
- */
30530
- durability: "restored"
30531
- };
30532
- /**
30533
31355
  * Enum-state sensor — a string value picked from a finite option set.
30534
31356
  * Drives HA `sensor` entries with `state_class: enum` (HVAC action
30535
31357
  * states, weather conditions, contact-source channels, mode strings).
@@ -40684,168 +41506,86 @@ var zoneRulesCapability = {
40684
41506
  */
40685
41507
  durability: "restored"
40686
41508
  };
40687
- /**
40688
- * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
40689
- * valutatore puro del suo FRONTE.
40690
- *
40691
- * Viveva dentro il builtin virtual-doorbell
40692
- * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
40693
- * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
40694
- * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
40695
- * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
40696
- * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
40697
- * SPOSTA qui e il doorbell la ri-esporta.
40698
- *
40699
- * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
40700
- * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
40701
- * regola" (e include `presence`, `cover`, `alarm-panel`), questa a "qual è il
40702
- * booleano il cui FRONTE conta". Vocabolari deliberatamente diversi.
40703
- */
40704
- /**
40705
- * Known binary / switch source caps → the boolean slice field whose
40706
- * false→true rise counts as ACTIVE. Every entry is "fire on active".
40707
- * Sensors whose "active" reading is not a plain boolean (presence's string
40708
- * state, connectivity's connected flag) are deliberately excluded — a
40709
- * reconnect is not a doorbell press, and it is not a recording either.
40710
- */
40711
- var SOURCE_CAP_ACTIVE_FIELD = {
40712
- contact: "entryOpen",
40713
- binary: "on",
40714
- switch: "on",
40715
- motion: "detected",
40716
- flood: "flooded",
40717
- gas: "detected",
40718
- smoke: "detected",
40719
- "carbon-monoxide": "detected",
40720
- vibration: "detected",
40721
- tamper: "tampered"
40722
- };
40723
- /**
40724
- * The same caps → the slice field carrying the ms-epoch timestamp of the
40725
- * last transition. Every source cap MUST appear here (guarded by a spec):
40726
- * without a transition timestamp the evaluator cannot tell a genuine rise
40727
- * from a boot-time hydration when the FIRST slice it ever sees is already
40728
- * active, and errs towards silence — swallowing the rise.
40729
- *
40730
- * These timestamps are UPSTREAM ones, not ingest ones: the Home Assistant
40731
- * provider derives them from `state.last_changed`, so they survive our own
40732
- * restarts and correctly read as "hours ago" for a state that has been
40733
- * active for hours. `motion` names its rise timestamp `lastDetectedAt`.
40734
- */
40735
- var SOURCE_CAP_CHANGED_AT_FIELD = {
40736
- contact: "lastChangedAt",
40737
- binary: "lastChangedAt",
40738
- switch: "lastChangedAt",
40739
- motion: "lastDetectedAt",
40740
- flood: "lastChangedAt",
40741
- gas: "lastChangedAt",
40742
- smoke: "lastChangedAt",
40743
- "carbon-monoxide": "lastChangedAt",
40744
- vibration: "lastChangedAt",
40745
- tamper: "lastChangedAt"
40746
- };
40747
- /** Cap names whose presence in a device's bindings qualify it as a source. */
40748
- var SOURCE_CAPS = Object.keys(SOURCE_CAP_ACTIVE_FIELD);
40749
- /**
40750
- * Device `type` values (from `DeviceType`) that can host a binary/switch
40751
- * source cap. Used by the camera's `device-multiselect` picker as the
40752
- * CLIENT-SIDE filter, alongside `SOURCE_CAPS`.
40753
- *
40754
- * Why types and not caps alone: the shared picker filters
40755
- * `deviceManager.listAll` rows client-side, and those rows carry only the
40756
- * device's advertised `features` — NOT its registered cap list. On the live
40757
- * cluster binary sensors and switches advertise EMPTY features (features
40758
- * mirror only a handful of caps like `motion-trigger`), so a caps-only
40759
- * filter matched against `features` would list nothing (the very bug this
40760
- * replaced, which relied on the now-empty `getAllBindings`). Matching by
40761
- * `type` is the reliable client-side signal; the union with `SOURCE_CAPS`
40762
- * still captures any device that DOES advertise a source-cap feature.
40763
- * `sensor` covers contact/motion/flood/gas/smoke/CO/vibration/tamper,
40764
- * `switch` covers switches, `control` covers generic binary actuators.
40765
- */
40766
- var SOURCE_DEVICE_TYPES = [
40767
- "sensor",
40768
- "switch",
40769
- "control"
40770
- ];
40771
- /** True when a cap is a recognised binary/switch source. */
40772
- function isSourceCap(capName) {
40773
- return Object.prototype.hasOwnProperty.call(SOURCE_CAP_ACTIVE_FIELD, capName);
41509
+ function isValueOf(slot, value) {
41510
+ return value.slot === slot;
40774
41511
  }
40775
- /** Extract the "active" boolean a source cap's slice carries, or null when
40776
- * the cap is unknown or the field is missing / non-boolean. */
40777
- function sliceActiveValue(capName, slice) {
40778
- const field = SOURCE_CAP_ACTIVE_FIELD[capName];
40779
- if (field === void 0) return null;
40780
- const raw = slice[field];
40781
- return typeof raw === "boolean" ? raw : null;
41512
+ /** Bind slot `slot` to its owner's functions. See the module docblock. */
41513
+ function defineExtensionSlotProvider(slot, impl) {
41514
+ return {
41515
+ slot,
41516
+ list: async (deviceId) => {
41517
+ const listing = await impl.list(deviceId);
41518
+ if (listing === null) return null;
41519
+ const value = listing.value;
41520
+ return {
41521
+ ...listing,
41522
+ value
41523
+ };
41524
+ },
41525
+ set: async (deviceId, value) => {
41526
+ if (!isValueOf(slot, value)) throw new Error(`device-extension: a "${value.slot}" value was sent to slot "${slot}" — refused`);
41527
+ return await impl.set(deviceId, value);
41528
+ },
41529
+ candidates: (deviceId) => impl.candidates(deviceId)
41530
+ };
40782
41531
  }
40783
- /** Ms-epoch transition timestamp a source cap's slice carries, or null when
40784
- * it is absent, non-numeric or the zero "never observed" sentinel. */
40785
- function sliceChangedAt(capName, slice) {
40786
- const field = SOURCE_CAP_CHANGED_AT_FIELD[capName];
40787
- if (field === void 0) return null;
40788
- const raw = slice[field];
40789
- if (typeof raw !== "number" || !Number.isFinite(raw) || raw <= 0) return null;
40790
- return raw;
41532
+ /** `<source>:<slotId>`. */
41533
+ function extensionSlotRef(source, slot) {
41534
+ return `${source}:${slot}`;
40791
41535
  }
40792
- /**
40793
- * How recent a source's own transition timestamp must be for a FIRST
40794
- * sighting that is already active to count as a genuine rise rather than a
40795
- * hydration of long-standing state.
40796
- */
40797
- var DEFAULT_FIRST_SIGHTING_FRESHNESS_MS = 3e4;
40798
- /**
40799
- * IL fronte. Puro: nessun orologio proprio, nessuna memoria — il chiamante
40800
- * porta `prior`, `nowMs` e il proprio `startedAtMs`.
40801
- *
40802
- * Il caso della PRIMA slice già attiva è trattato esplicitamente e vale come
40803
- * fronte solo se il timestamp UPSTREAM della transizione è posteriore a
40804
- * `startedAtMs` **e** entro `firstSightingFreshnessMs`. Entrambe le metà
40805
- * servono: la sola freschezza scatterebbe su un'idratazione al boot di uno
40806
- * stato flippato pochi secondi prima del riavvio, e il solo "dopo che abbiamo
40807
- * iniziato" scatterebbe, su un processo di lunga vita, per una sorgente
40808
- * adottata oggi il cui stato è cambiato ieri. Il caso ambiguo ERRA VERSO IL
40809
- * SILENZIO e lo dichiara (`baseline-seeded-stale-active`).
40810
- */
40811
- function evaluateSensorEdge(input) {
40812
- const value = sliceActiveValue(input.capName, input.slice);
40813
- if (value === null) return {
40814
- edge: "none",
40815
- value: null,
40816
- reason: isSourceCap(input.capName) ? "non-boolean-value" : "unknown-cap"
40817
- };
40818
- if (input.prior === void 0) {
40819
- if (!value) return {
40820
- edge: "none",
40821
- value,
40822
- reason: "baseline-seeded-inactive"
40823
- };
40824
- const changedAt = sliceChangedAt(input.capName, input.slice);
40825
- const floor = Math.max(input.startedAtMs, input.nowMs - input.firstSightingFreshnessMs);
40826
- if (changedAt === null || changedAt < floor) return {
40827
- edge: "none",
40828
- value,
40829
- reason: "baseline-seeded-stale-active"
40830
- };
40831
- return {
40832
- edge: "rising",
40833
- value: true
40834
- };
40835
- }
40836
- if (input.prior === value) return {
40837
- edge: "none",
40838
- value,
40839
- reason: "no-change"
40840
- };
40841
- if (!value) return {
40842
- edge: "none",
40843
- value,
40844
- reason: "falling-edge"
41536
+ /** Build the `device-extension` provider one owner registers. */
41537
+ function createDeviceExtensionProvider(options) {
41538
+ const { source, label, slots, hostTypeOf, logger } = options;
41539
+ const offered = (slot, hostType) => hostType !== null && EXTENSION_SLOTS[slot].hostDeviceTypes.some((t) => t === hostType);
41540
+ const resolve = async (deviceId, slotRef) => {
41541
+ const prefix = `${source}:`;
41542
+ const slot = slotRef.startsWith(prefix) ? slots.find((s) => s.slot === slotRef.slice(prefix.length)) : void 0;
41543
+ if (slot === void 0) throw new Error(`device-extension: "${slotRef}" is not a slot of "${source}" — it serves ${slots.map((s) => extensionSlotRef(source, s.slot)).join(", ") || "(none)"}`);
41544
+ const hostType = await hostTypeOf(deviceId);
41545
+ if (!offered(slot.slot, hostType)) throw new Error(`device-extension: slot "${slot.slot}" is not offered on device ${deviceId} (type ${hostType ?? "unknown"}; offered on ${EXTENSION_SLOTS[slot.slot].hostDeviceTypes.join(", ")})`);
41546
+ return slot;
40845
41547
  };
40846
41548
  return {
40847
- edge: "rising",
40848
- value: true
41549
+ listSources: async () => [{
41550
+ source,
41551
+ label,
41552
+ availability: { state: "ok" }
41553
+ }],
41554
+ listSlots: async (input) => {
41555
+ const hostType = await hostTypeOf(input.deviceId);
41556
+ const rows = [];
41557
+ for (const slot of slots) {
41558
+ if (!offered(slot.slot, hostType)) continue;
41559
+ const listing = await slot.list(input.deviceId);
41560
+ if (listing === null) continue;
41561
+ rows.push({
41562
+ state: "ok",
41563
+ slotRef: extensionSlotRef(source, slot.slot),
41564
+ slot: slot.slot,
41565
+ authority: listing.authority,
41566
+ enabled: listing.enabled,
41567
+ projects: EXTENSION_SLOTS[slot.slot].descriptor.projects ?? null,
41568
+ activation: listing.activation,
41569
+ value: listing.value,
41570
+ sources: [...listing.sources]
41571
+ });
41572
+ }
41573
+ return rows;
41574
+ },
41575
+ listCandidates: async (input) => {
41576
+ return { candidates: [...await (await resolve(input.deviceId, input.slotRef)).candidates(input.deviceId)] };
41577
+ },
41578
+ setSlot: async (input) => {
41579
+ const result = await (await resolve(input.deviceId, input.slotRef)).set(input.deviceId, input.value);
41580
+ logger.info("device-extension: slot written", {
41581
+ tags: { deviceId: input.deviceId },
41582
+ meta: {
41583
+ slotRef: input.slotRef,
41584
+ reload: result.reload
41585
+ }
41586
+ });
41587
+ return result;
41588
+ }
40849
41589
  };
40850
41590
  }
40851
41591
  /**
@@ -43741,6 +44481,7 @@ var ALL_CAPABILITY_DEFINITIONS = [
43741
44481
  deviceAdoptionCapability,
43742
44482
  deviceDiscoveryCapability,
43743
44483
  deviceExportCapability,
44484
+ deviceExtensionCapability,
43744
44485
  deviceManagerCapability,
43745
44486
  deviceOpsCapability,
43746
44487
  deviceProviderCapability,
@@ -45289,6 +46030,30 @@ var METHOD_ACCESS_MAP = Object.freeze({
45289
46030
  addonId: null,
45290
46031
  access: "create"
45291
46032
  },
46033
+ "deviceExtension.listCandidates": {
46034
+ capName: "device-extension",
46035
+ capScope: "device",
46036
+ addonId: null,
46037
+ access: "view"
46038
+ },
46039
+ "deviceExtension.listSlots": {
46040
+ capName: "device-extension",
46041
+ capScope: "device",
46042
+ addonId: null,
46043
+ access: "view"
46044
+ },
46045
+ "deviceExtension.listSources": {
46046
+ capName: "device-extension",
46047
+ capScope: "device",
46048
+ addonId: null,
46049
+ access: "view"
46050
+ },
46051
+ "deviceExtension.setSlot": {
46052
+ capName: "device-extension",
46053
+ capScope: "device",
46054
+ addonId: null,
46055
+ access: "create"
46056
+ },
45292
46057
  "deviceManager.addLocation": {
45293
46058
  capName: "device-manager",
45294
46059
  capScope: "system",
@@ -46039,6 +46804,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
46039
46804
  addonId: null,
46040
46805
  access: "view"
46041
46806
  },
46807
+ "embeddingEncoder.resetFailedModels": {
46808
+ capName: "embedding-encoder",
46809
+ capScope: "system",
46810
+ addonId: null,
46811
+ access: "delete"
46812
+ },
46042
46813
  "enumSensor.getStatus": {
46043
46814
  capName: "enum-sensor",
46044
46815
  capScope: "device",
@@ -48373,6 +49144,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
48373
49144
  addonId: null,
48374
49145
  access: "view"
48375
49146
  },
49147
+ "pipelineOrchestrator.getClusterModelChoice": {
49148
+ capName: "pipeline-orchestrator",
49149
+ capScope: "system",
49150
+ addonId: null,
49151
+ access: "view"
49152
+ },
48376
49153
  "pipelineOrchestrator.getDeviceLiveContribution": {
48377
49154
  capName: "pipeline-orchestrator",
48378
49155
  capScope: "system",
@@ -51198,6 +51975,26 @@ Object.freeze({
51198
51975
  form: "single",
51199
51976
  optional: false
51200
51977
  }],
51978
+ "deviceExtension.listCandidates": [{
51979
+ name: "deviceId",
51980
+ form: "single",
51981
+ optional: false
51982
+ }],
51983
+ "deviceExtension.listSlots": [{
51984
+ name: "deviceId",
51985
+ form: "single",
51986
+ optional: false
51987
+ }],
51988
+ "deviceExtension.listSources": [{
51989
+ name: "deviceId",
51990
+ form: "single",
51991
+ optional: false
51992
+ }],
51993
+ "deviceExtension.setSlot": [{
51994
+ name: "deviceId",
51995
+ form: "single",
51996
+ optional: false
51997
+ }],
51201
51998
  "deviceManager.adoptionRelease": [{
51202
51999
  name: "camDeviceId",
51203
52000
  form: "single",
@@ -53957,68 +54754,6 @@ TimelapseRuleInputSchema.extend({
53957
54754
  createdAt: zod.z.number(),
53958
54755
  updatedAt: zod.z.number()
53959
54756
  });
53960
- Object.freeze(Object.fromEntries([{
53961
- stepId: "face-embedding",
53962
- label: "Face recognition model",
53963
- defaultModelId: "arcface-r100",
53964
- indexName: "the enrolled face gallery",
53965
- options: [
53966
- {
53967
- id: "arcface-r100",
53968
- label: "ArcFace (ResNet34)"
53969
- },
53970
- {
53971
- id: "auraface-r100",
53972
- label: "AuraFace R100"
53973
- },
53974
- {
53975
- id: "inception-resnet-v1",
53976
- label: "Inception ResNet V1"
53977
- }
53978
- ]
53979
- }, {
53980
- stepId: "clip-embedding",
53981
- label: "Semantic search model",
53982
- defaultModelId: "mobileclip-s1",
53983
- indexName: "the object semantic-search index",
53984
- options: [{
53985
- id: "mobileclip-s1",
53986
- label: "MobileCLIP S1"
53987
- }, {
53988
- id: "mobileclip-s2",
53989
- label: "MobileCLIP S2"
53990
- }]
53991
- }].map((s) => [s.stepId, s.defaultModelId])));
53992
- zod.z.string().min(1);
53993
- var CLUSTER_STEP_SETTING_FIELDS = [{
53994
- stepId: "face-embedding",
53995
- key: "minLandmarkFaceSize",
53996
- label: "Min face size for recognition (detection px)",
53997
- 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.",
53998
- type: "slider",
53999
- min: 0,
54000
- max: 64,
54001
- step: 2,
54002
- default: 24
54003
- }];
54004
- function clusterStepSettingKey(stepId, fieldKey) {
54005
- return `clusterStepSetting:${stepId}:${fieldKey}`;
54006
- }
54007
- var ClusterSettingNumberSchema = zod.z.number().finite();
54008
- function readClusterStepSettings(config) {
54009
- const out = {};
54010
- for (const field of CLUSTER_STEP_SETTING_FIELDS) {
54011
- const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
54012
- const value = parsed.success ? parsed.data : field.default;
54013
- const existing = out[field.stepId] ?? {};
54014
- out[field.stepId] = {
54015
- ...existing,
54016
- [field.key]: value
54017
- };
54018
- }
54019
- return out;
54020
- }
54021
- readClusterStepSettings({});
54022
54757
  zod.z.object({
54023
54758
  /**
54024
54759
  * Fraction of the box's own size added on EACH side before cutting.
@@ -54759,6 +55494,12 @@ Object.defineProperty(exports, "coreBlocksCapability", {
54759
55494
  return coreBlocksCapability;
54760
55495
  }
54761
55496
  });
55497
+ Object.defineProperty(exports, "createDeviceExtensionProvider", {
55498
+ enumerable: true,
55499
+ get: function() {
55500
+ return createDeviceExtensionProvider;
55501
+ }
55502
+ });
54762
55503
  Object.defineProperty(exports, "createEvent", {
54763
55504
  enumerable: true,
54764
55505
  get: function() {
@@ -54783,12 +55524,24 @@ Object.defineProperty(exports, "decodeVectorBase64", {
54783
55524
  return decodeVectorBase64;
54784
55525
  }
54785
55526
  });
55527
+ Object.defineProperty(exports, "defineExtensionSlotProvider", {
55528
+ enumerable: true,
55529
+ get: function() {
55530
+ return defineExtensionSlotProvider;
55531
+ }
55532
+ });
54786
55533
  Object.defineProperty(exports, "deriveBatteryPresence", {
54787
55534
  enumerable: true,
54788
55535
  get: function() {
54789
55536
  return deriveBatteryPresence;
54790
55537
  }
54791
55538
  });
55539
+ Object.defineProperty(exports, "deviceExtensionCapability", {
55540
+ enumerable: true,
55541
+ get: function() {
55542
+ return deviceExtensionCapability;
55543
+ }
55544
+ });
54792
55545
  Object.defineProperty(exports, "deviceManagerCapability", {
54793
55546
  enumerable: true,
54794
55547
  get: function() {
@@ -55245,6 +55998,12 @@ Object.defineProperty(exports, "vectorDimFromBase64", {
55245
55998
  return vectorDimFromBase64;
55246
55999
  }
55247
56000
  });
56001
+ Object.defineProperty(exports, "vectorIndexDimConflictError", {
56002
+ enumerable: true,
56003
+ get: function() {
56004
+ return vectorIndexDimConflictError;
56005
+ }
56006
+ });
55248
56007
  Object.defineProperty(exports, "vectorStoreCapability", {
55249
56008
  enumerable: true,
55250
56009
  get: function() {