@camstack/system 1.2.303 → 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 +3 -3
  44. package/dist/builtins/platform-probe/index.mjs +3 -3
  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-DzHjDpU7.js → dist-BK4iP6ab.js} +2700 -1583
  62. package/dist/{dist-FwpS07w3.mjs → dist-Df1NhKxm.mjs} +2677 -1584
  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-CNcKBSQS.js → retired-settings-keys-DwWMph6F.js} +1 -1
  70. package/dist/{retired-settings-keys-rDPn2MMp.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-DU7mu4wb.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",
@@ -6417,7 +6488,7 @@ var ModelFormatEntrySchema = zod.z.object({
6417
6488
  /** Multi-file payload (directory members or sibling files). */
6418
6489
  files: zod.z.array(zod.z.string()).readonly().optional(),
6419
6490
  /** Runtime(s) that can use this format. If omitted, inferred from ModelFormat key */
6420
- runtimes: zod.z.array(zod.z.enum(["node", "python"])).readonly().optional()
6491
+ runtimes: zod.z.array(zod.z.enum(["python"])).readonly().optional()
6421
6492
  });
6422
6493
  /**
6423
6494
  * Extra file that must be downloaded alongside the model (e.g., labels JSON, dict.txt).
@@ -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
  /**
@@ -16914,6 +17125,29 @@ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
16914
17125
  ]);
16915
17126
  NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
16916
17127
  /**
17128
+ * The panel's transitions, as ONE list.
17129
+ *
17130
+ * Named here rather than spelled out at each of the four sites that need them
17131
+ * (the emitter, the intake, the editor group, the combined-notification gate),
17132
+ * because a transition added to the enum and forgotten at one of them is an
17133
+ * alarm state nobody can be notified about. That is exactly what this list
17134
+ * failed to prevent while it held three: `alarm-arming` was the fourth.
17135
+ *
17136
+ * In LIFECYCLE order, which is the order an editor lists them in and the order
17137
+ * a person experiences them — not the order they were added.
17138
+ */
17139
+ var NC_ALARM_SYSTEM_EVENT_KINDS = [
17140
+ "alarm-arm-refused",
17141
+ "alarm-check-failed",
17142
+ "alarm-arming",
17143
+ "alarm-armed",
17144
+ "alarm-pending",
17145
+ "alarm-triggered",
17146
+ "alarm-rearmed",
17147
+ "alarm-sensor-bypass",
17148
+ "alarm-disarmed"
17149
+ ];
17150
+ /**
16917
17151
  * One coherent system-event condition. `kinds` is the required opt-in safety
16918
17152
  * gate; the remaining lists are optional narrowing filters relevant to the
16919
17153
  * selected kinds.
@@ -16982,6 +17216,25 @@ var NcScheduleSchema = zod.z.object({
16982
17216
  /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
16983
17217
  invert: zod.z.boolean().optional()
16984
17218
  });
17219
+ /**
17220
+ * How a system-event rule of the `device-events` or `system` family speaks
17221
+ * (D647): at once, per event (`instant`, the only behaviour before D647), or
17222
+ * as a STATE SUMMARY at the end of each window of `schedule`.
17223
+ */
17224
+ var NcSystemEventDeliveryModeSchema = zod.z.enum(["instant", "summary"]);
17225
+ /**
17226
+ * `summary`: the rule sends NOTHING per event. When a window of `schedule`
17227
+ * CLOSES, it sends one notification with the current state of its kinds
17228
+ * (low batteries, consumables to replace, devices offline, updates
17229
+ * available, ...), after its own filters. Nothing to report sends nothing.
17230
+ * The schedule is the ordinary `NcSchedule` (weekly windows, IANA timezone,
17231
+ * midnight crossing); the send time is each window's END. Refused on the
17232
+ * `alarm` family, which stays instant (`systemEventDeliveryProblems`).
17233
+ */
17234
+ var NcSystemEventDeliverySchema = zod.z.discriminatedUnion("mode", [zod.z.object({ mode: zod.z.literal("instant") }), zod.z.object({
17235
+ mode: zod.z.literal("summary"),
17236
+ schedule: NcScheduleSchema
17237
+ })]);
16985
17238
  /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
16986
17239
  var NcPlateMatcherSchema = zod.z.object({
16987
17240
  /**
@@ -17595,7 +17848,12 @@ var NcMediaPolicySchema = zod.z.object({
17595
17848
  * the degrade engine, which drops the video and keeps the still.
17596
17849
  */
17597
17850
  clip: zod.z.boolean().optional(),
17598
- /** 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
+ */
17599
17857
  clipPreRollSec: zod.z.number().int().min(0).max(30).optional(),
17600
17858
  clipPostRollSec: zod.z.number().int().min(0).max(30).optional(),
17601
17859
  /**
@@ -17717,6 +17975,16 @@ var NcRuleInputSchema = zod.z.object({
17717
17975
  delivery: NcDeliverySchema,
17718
17976
  conditions: NcConditionsSchema.default({}),
17719
17977
  schedule: NcScheduleSchema.optional(),
17978
+ /**
17979
+ * A `device-events` / `system` rule's delivery (D647): absent or `instant`
17980
+ * is a notification per event; `summary` is one state summary per closed
17981
+ * window of its schedule. `.optional()` and never defaulted: absent must
17982
+ * keep meaning what every rule authored before D647 meant, with no
17983
+ * migration. Top-level rather than inside `conditions.systemEvent`, so a
17984
+ * client that does not know it (an older viewer re-sending `conditions`
17985
+ * whole) leaves it standing through the store's patch merge.
17986
+ */
17987
+ systemEventDelivery: NcSystemEventDeliverySchema.optional(),
17720
17988
  /** May be empty when `targetUsers` addresses at least one user — the
17721
17989
  * "at least one addressee" invariant is enforced by the provider, because
17722
17990
  * a cross-field refine here would break `NcRulePatchSchema.partial()`. */
@@ -17945,6 +18213,28 @@ var NcRuleSchema = NcRuleInputSchema.extend({
17945
18213
  */
17946
18214
  disabledTargetIds: zod.z.array(zod.z.string()).default([])
17947
18215
  });
18216
+ /** One section of a previewed state summary. `unavailable` = its state could not be read. */
18217
+ var NcStateSummaryPreviewSectionSchema = zod.z.object({
18218
+ id: zod.z.string(),
18219
+ status: zod.z.enum(["read", "unavailable"]),
18220
+ items: zod.z.number().int().nonnegative(),
18221
+ reason: zod.z.string().optional()
18222
+ });
18223
+ /**
18224
+ * The summary a rule would send now. `empty` = nothing to report and every
18225
+ * section read: such a summary is NOT sent. `dropped` counts the open states
18226
+ * the rule's own filters (or a camera mute) left out, by reason.
18227
+ * `excludedGroups` names the kind groups selected that have no state to report
18228
+ * (backups & exports).
18229
+ */
18230
+ var NcStateSummaryPreviewSchema = zod.z.object({
18231
+ empty: zod.z.boolean(),
18232
+ count: zod.z.number().int().nonnegative(),
18233
+ text: zod.z.string(),
18234
+ sections: zod.z.array(NcStateSummaryPreviewSectionSchema),
18235
+ dropped: zod.z.record(zod.z.string(), zod.z.number().int().nonnegative()),
18236
+ excludedGroups: zod.z.array(zod.z.string())
18237
+ });
17948
18238
  var NcTestResultSchema = zod.z.object({
17949
18239
  recordId: zod.z.string(),
17950
18240
  recordKind: zod.z.enum([
@@ -18036,6 +18326,13 @@ var NcTemplateVarDescriptorSchema = zod.z.object({
18036
18326
  kinds: zod.z.array(NcTemplateVarKindSchema).optional(),
18037
18327
  deliveries: zod.z.array(NcDeliverySchema).optional(),
18038
18328
  systemEventKinds: zod.z.array(NcSystemEventKindSchema).optional(),
18329
+ /**
18330
+ * Which system-event DELIVERY has a value for it (D647). Absent = an
18331
+ * instant row only when the descriptor names `systemEventKinds` (a
18332
+ * per-event fact: a summary row has no single device), and both otherwise.
18333
+ * `['summary']` marks the state-summary vocabulary (`{{summaryText}}`, ...).
18334
+ */
18335
+ systemEventDeliveries: zod.z.array(NcSystemEventDeliveryModeSchema).optional(),
18039
18336
  dynamic: zod.z.object({
18040
18337
  prefix: zod.z.literal("count_"),
18041
18338
  from: zod.z.literal("classes")
@@ -18047,7 +18344,9 @@ var NcTemplateVarContextSchema = zod.z.object({
18047
18344
  field: NcTemplateFieldSchema,
18048
18345
  kind: NcRuleKindSchema.optional(),
18049
18346
  delivery: NcDeliverySchema.optional(),
18050
- systemEventKinds: zod.z.array(NcSystemEventKindSchema).optional()
18347
+ systemEventKinds: zod.z.array(NcSystemEventKindSchema).optional(),
18348
+ /** The rule's system-event delivery (D647); absent = instant. */
18349
+ systemEventDelivery: NcSystemEventDeliveryModeSchema.optional()
18051
18350
  });
18052
18351
  /** Input to `previewTemplate` — the editor's own context, plus the draft text. */
18053
18352
  var NcTemplatePreviewInputSchema = zod.z.object({
@@ -18658,6 +18957,17 @@ var notificationRulesCapability = {
18658
18957
  auth: "admin"
18659
18958
  }),
18660
18959
  /**
18960
+ * The STATE SUMMARY a system rule would send now (D647) — for a saved rule
18961
+ * or an unsaved draft. Pure: sends nothing, stamps nothing. A MUTATION
18962
+ * only for transport (a whole rule does not belong in a GET URL). Admin,
18963
+ * like `testRule`: it names devices and nodes across the installation.
18964
+ */
18965
+ previewStateSummary: method(zod.z.object({ rule: NcRuleInputSchema }), NcStateSummaryPreviewSchema, {
18966
+ kind: "mutation",
18967
+ auth: "admin",
18968
+ access: "view"
18969
+ }),
18970
+ /**
18661
18971
  * The machine-readable condition surface a rule editor renders from, plus
18662
18972
  * the picker VOCABULARY those conditions draw on.
18663
18973
  *
@@ -19118,1011 +19428,310 @@ var oauthIntegrationCapability = {
19118
19428
  getDescriptor: method(zod.z.void(), OauthIntegrationDescriptorSchema, { auth: "admin" }) }
19119
19429
  };
19120
19430
  /**
19121
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
19122
- * within the frame, so the executor can re-cut a leaf child ROI at native
19123
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
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
+ /**
19555
+ * pipeline-analytics — device-scoped wrapper cap. Refines raw
19556
+ * per-frame detections emitted by the pipeline runner into tracked
19557
+ * objects, per-kind event collections (motion / object / audio), and
19558
+ * persisted media. Owns the post-detection domain end-to-end:
19559
+ *
19560
+ * runner emits PipelineInferenceResult
19561
+ * ↓ (event bus)
19562
+ * pipeline-analytics subscriber
19563
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
19564
+ * → three DB collections (one per kind), one FS media tree, one
19565
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
19566
+ * DetectionEvent on bus)
19567
+ *
19568
+ * Pure subscriber model. No `processFrame` cap method — the runner
19569
+ * already publishes the raw frame on the bus. The cap surface is
19570
+ * only QUERIES + per-device settings, bound on/off via
19571
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
19572
+ * every camera with a detection pipeline wants its raw detections
19573
+ * refined; operators opt out per-device via BindingsTab when needed.
19574
+ *
19575
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
19576
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
19124
19577
  */
19125
- var NativeCropRefSchema = zod.z.object({
19126
- /** Handle keying the retained native surface (node-pinned to its owner). */
19127
- handle: FrameHandleSchema,
19128
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
19129
- cropFrameSpace: zod.z.object({
19130
- x: zod.z.number(),
19131
- y: zod.z.number(),
19132
- w: zod.z.number(),
19133
- h: zod.z.number()
19134
- })
19135
- });
19136
- zod.z.object({
19137
- crop: zod.z.object({
19138
- left: zod.z.number(),
19139
- top: zod.z.number(),
19140
- width: zod.z.number().positive(),
19141
- height: zod.z.number().positive()
19142
- }).optional(),
19143
- content: zod.z.object({
19144
- width: zod.z.number().int().positive(),
19145
- height: zod.z.number().int().positive()
19146
- }),
19147
- fit: zod.z.enum(["stretch", "contain"]),
19148
- format: zod.z.enum([
19149
- "rgb",
19150
- "gray",
19151
- "jpeg"
19152
- ])
19153
- });
19578
+ var TrackStateSchema = zod.z.enum([
19579
+ "new",
19580
+ "entered",
19581
+ "left",
19582
+ "moving",
19583
+ "idle"
19584
+ ]);
19585
+ var EventKindSchema = zod.z.enum([
19586
+ "motion",
19587
+ "object",
19588
+ "audio"
19589
+ ]);
19154
19590
  /**
19155
- * Process-local frame identity. It is serializable so it can ride an in-process
19156
- * capability call, but `registryId` deliberately prevents resolution in any
19157
- * other process or execution group.
19591
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
19592
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
19593
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
19158
19594
  */
19159
- var FrameRefSchema = zod.z.object({
19160
- registryId: zod.z.string().min(1),
19161
- id: zod.z.string().min(1),
19162
- width: zod.z.number().int().positive(),
19163
- height: zod.z.number().int().positive(),
19164
- format: zod.z.enum(["rgb", "gray"]),
19165
- timestamp: zod.z.number(),
19166
- capturedAt: zod.z.number().optional()
19167
- });
19168
- var ModelFormatSchema$1 = zod.z.enum([
19169
- "onnx",
19170
- "coreml",
19171
- "openvino",
19172
- "tflite",
19173
- "pt",
19174
- "gguf"
19595
+ var TrackZoneFilterSchema = zod.z.discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
19596
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
19597
+ var EventKindIconSchema = zod.z.enum([
19598
+ "motion",
19599
+ "audio",
19600
+ "person",
19601
+ "vehicle",
19602
+ "animal",
19603
+ "door",
19604
+ "pir",
19605
+ "smoke",
19606
+ "water",
19607
+ "button",
19608
+ "package",
19609
+ "generic"
19175
19610
  ]);
19176
- var PipelineSlotSchema = zod.z.enum([
19177
- "detector",
19178
- "cropper",
19179
- "classifier",
19180
- "refiner",
19181
- "audio-classifier"
19611
+ var EventKindCategorySchema = zod.z.enum([
19612
+ "motion",
19613
+ "audio",
19614
+ "detection",
19615
+ "sensor",
19616
+ "control",
19617
+ "custom",
19618
+ "package"
19182
19619
  ]);
19183
- var PipelineEngineChoiceSchema = zod.z.object({
19184
- runtime: zod.z.enum(["node", "python"]),
19185
- backend: zod.z.string(),
19186
- format: ModelFormatSchema$1,
19187
- device: zod.z.string().optional()
19188
- });
19189
- var EngineDeviceInfoSchema = zod.z.object({
19190
- id: zod.z.string(),
19620
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
19621
+ var EventKindLevelSchema = zod.z.enum(["macro", "sub"]);
19622
+ var EventKindDescriptorSchema = zod.z.object({
19623
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
19624
+ kind: zod.z.string(),
19625
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
19626
+ labelKey: zod.z.string(),
19627
+ /** English fallback label (kept for clients that don't translate). */
19191
19628
  label: zod.z.string(),
19192
- description: zod.z.string().optional()
19193
- });
19194
- var AvailableEngineSchema = zod.z.object({
19195
- engine: PipelineEngineChoiceSchema,
19196
- devices: zod.z.array(EngineDeviceInfoSchema).readonly(),
19197
- defaultDevice: zod.z.string()
19198
- });
19199
- var PipelineDefaultStepSchema = zod.z.lazy(() => zod.z.object({
19200
- addonId: zod.z.string(),
19201
- addonName: zod.z.string(),
19202
- slot: PipelineSlotSchema,
19203
- inputClasses: zod.z.array(zod.z.string()).readonly(),
19204
- outputClasses: zod.z.array(zod.z.string()).readonly(),
19205
- enabled: zod.z.boolean(),
19206
- modelId: zod.z.string(),
19207
- children: zod.z.array(PipelineDefaultStepSchema).readonly(),
19208
- group: zod.z.string().optional(),
19209
- settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
19210
- }));
19211
- var PipelineTemplateStepSchema = zod.z.lazy(() => zod.z.object({
19212
- addonId: zod.z.string(),
19213
- enabled: zod.z.boolean(),
19214
- modelId: zod.z.string(),
19215
- children: zod.z.array(PipelineTemplateStepSchema).readonly(),
19216
- settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
19217
- }));
19218
- var PipelineTemplateSchema$1 = zod.z.object({
19219
- id: zod.z.string(),
19220
- name: zod.z.string(),
19221
- createdAt: zod.z.string(),
19222
- updatedAt: zod.z.string(),
19223
- engine: PipelineEngineChoiceSchema,
19224
- steps: zod.z.array(PipelineTemplateStepSchema).readonly()
19629
+ /** Hex color for timeline/legend rendering. */
19630
+ color: zod.z.string(),
19631
+ /** Dictionary id → lucide component on the UI side. */
19632
+ iconId: zod.z.string(),
19633
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
19634
+ icon: EventKindIconSchema,
19635
+ category: EventKindCategorySchema,
19636
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
19637
+ parentKind: zod.z.string().nullable(),
19638
+ /** Derived from `parentKind`, explicit for the client tree. */
19639
+ level: EventKindLevelSchema,
19640
+ /** Which cap + device contributes this kind. For built-ins the camera
19641
+ * itself; for sensor kinds the LINKED source device. */
19642
+ source: zod.z.object({
19643
+ capName: zod.z.string(),
19644
+ deviceId: zod.z.number()
19645
+ })
19225
19646
  });
19226
- var PipelineModelOptionSchema = zod.z.object({
19227
- id: zod.z.string(),
19228
- name: zod.z.string(),
19229
- formats: zod.z.record(zod.z.string(), zod.z.object({
19230
- downloaded: zod.z.boolean(),
19231
- sizeMB: zod.z.number()
19232
- })),
19233
- group: ModelVariantGroupSchema.optional(),
19234
- legacy: zod.z.boolean().optional(),
19235
- provider: ModelProviderIdSchema.optional()
19647
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
19648
+ var EventKindsForDeviceSchema = zod.z.object({
19649
+ deviceId: zod.z.number(),
19650
+ kinds: zod.z.array(EventKindDescriptorSchema).readonly()
19236
19651
  });
19237
- var ConfigFieldBridge = zod.z.custom();
19238
- var PipelineAddonSchemaSchema = zod.z.object({
19652
+ var SensorEventSchema = zod.z.object({
19239
19653
  id: zod.z.string(),
19240
- name: zod.z.string(),
19241
- slot: PipelineSlotSchema,
19242
- inputClasses: zod.z.array(zod.z.string()).readonly(),
19243
- outputClasses: zod.z.array(zod.z.string()).readonly(),
19244
- childSlots: zod.z.array(PipelineSlotSchema).readonly(),
19245
- models: zod.z.array(PipelineModelOptionSchema).readonly(),
19246
- defaultModelId: zod.z.string(),
19247
- defaultModelIdByFormat: zod.z.record(zod.z.string(), zod.z.string()).optional(),
19248
- enabledByDefault: zod.z.boolean().optional(),
19249
- backfillIntoExistingOverrides: zod.z.boolean().optional(),
19250
- defaultConfidence: zod.z.number(),
19251
- group: zod.z.string().optional(),
19252
- configSchema: zod.z.array(ConfigFieldBridge).readonly().optional()
19253
- });
19254
- var PipelineSlotSchemaSchema = zod.z.object({
19255
- id: PipelineSlotSchema,
19256
- label: zod.z.string(),
19257
- priority: zod.z.number(),
19258
- parentSlot: PipelineSlotSchema.nullable(),
19259
- addons: zod.z.array(PipelineAddonSchemaSchema).readonly()
19260
- });
19261
- var PipelineSchemaSchema = zod.z.object({
19262
- availableEngines: zod.z.array(AvailableEngineSchema).readonly(),
19263
- selectedEngine: PipelineEngineChoiceSchema,
19264
- slots: zod.z.array(PipelineSlotSchemaSchema).readonly()
19654
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
19655
+ * yields N rows, one per camera). */
19656
+ deviceId: zod.z.number(),
19657
+ /** The linked sensor device whose state changed. */
19658
+ sourceDeviceId: zod.z.number(),
19659
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
19660
+ kind: zod.z.string(),
19661
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
19662
+ value: zod.z.record(zod.z.string(), zod.z.unknown()).nullable(),
19663
+ timestamp: zod.z.number()
19265
19664
  });
19266
- var EngineProvisioningSchema = zod.z.object({
19267
- runtimeId: zod.z.enum([
19268
- "onnx",
19269
- "openvino",
19270
- "coreml",
19271
- "edgetpu"
19272
- ]).nullable(),
19273
- device: zod.z.string().nullable(),
19274
- state: zod.z.enum([
19275
- "idle",
19276
- "installing",
19277
- "verifying",
19278
- "ready",
19279
- "failed"
19280
- ]),
19281
- progress: zod.z.number().optional(),
19282
- error: zod.z.string().optional(),
19283
- nextRetryAt: zod.z.number().optional(),
19665
+ /**
19666
+ * One stored sighting on a track's trajectory.
19667
+ *
19668
+ * The array these live in is returned in TIME order (D399) — it is APPENDED in
19669
+ * arrival order, and the two detector passes interleave, so a consumer must not
19670
+ * assume the two are the same on a row written by an older build.
19671
+ */
19672
+ var TrackPositionSchema = zod.z.object({
19673
+ x: zod.z.number(),
19674
+ y: zod.z.number(),
19675
+ timestamp: zod.z.number(),
19676
+ bbox: BoundingBoxSchema,
19284
19677
  /**
19285
- * Gate A (config-correctness gate at engine change): human-readable
19286
- * config issues surfaced EAGERLY when the node's engine changes — model
19287
- * substitutions ("chose X, running Y") and zero-build steps ("no model
19288
- * has a <format> build"). Additive/optional: informational only, never
19289
- * enforced here — `assertEngineReady` (readiness) still gates inference.
19290
- * Absent/empty when the node-default tree resolves cleanly.
19678
+ * Which detector pass measured this box (D399): `frame` is the full-frame
19679
+ * pass on the analysis raster, `recovery` is the native-resolution
19680
+ * small-subject second pass (D377/D378). Both write into one array, and until
19681
+ * this field existed the only way to tell them apart was that full-frame boxes
19682
+ * are exact multiples of 1.2 while recovery boxes are full-precision floats.
19683
+ * Absent on rows written before D399.
19291
19684
  */
19292
- configIssues: zod.z.array(zod.z.string()).optional()
19293
- });
19294
- var PipelineStepInputSchema = zod.z.lazy(() => zod.z.object({
19295
- addonId: zod.z.string(),
19296
- modelId: zod.z.string().optional(),
19297
- enabled: zod.z.boolean().default(true),
19298
- children: zod.z.array(PipelineStepInputSchema).optional(),
19299
- settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
19300
- jumpDeviceKey: zod.z.string().optional()
19301
- }));
19302
- var ModelSubstitutionSchema = zod.z.object({
19303
- addonId: zod.z.string(),
19304
- chosen: zod.z.string(),
19305
- running: zod.z.string(),
19306
- format: zod.z.string()
19307
- });
19308
- var PipelineValidationIssueSchema = zod.z.object({
19309
- addonId: zod.z.string(),
19310
- kind: zod.z.enum(["unknown-addon", "no-format-build"]),
19311
- detail: zod.z.string()
19685
+ source: zod.z.enum(["frame", "recovery"]).optional(),
19686
+ /** Detection score of this box, so a position can be weighed and not only
19687
+ * plotted. Absent on rows written before D399. */
19688
+ score: zod.z.number().optional()
19312
19689
  });
19313
- var PipelineValidationResultSchema = zod.z.object({
19314
- ok: zod.z.boolean(),
19315
- issues: zod.z.array(PipelineValidationIssueSchema).readonly(),
19316
- substitutions: zod.z.array(ModelSubstitutionSchema).readonly(),
19317
- /** The node's `currentEngine.format` this validation ran against. */
19318
- format: zod.z.string()
19690
+ var TrackSnapshotSchema = zod.z.object({
19691
+ timestamp: zod.z.number(),
19692
+ position: TrackPositionSchema,
19693
+ /** The snapshot's media row id (D482); resolve via `listTrackMedia({ trackId })`. */
19694
+ mediaId: zod.z.number().int()
19319
19695
  });
19320
- var ReferenceImageEntrySchema = zod.z.object({
19321
- filename: zod.z.string(),
19322
- stepIds: zod.z.array(zod.z.string()).readonly().optional()
19696
+ /**
19697
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
19698
+ * divided by the track's detection-frame dims), computed at persist time.
19699
+ * Absent when the frame dims were unknown when the track was persisted
19700
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
19701
+ */
19702
+ var TrackEnvelopeSchema = zod.z.object({
19703
+ minX: zod.z.number(),
19704
+ minY: zod.z.number(),
19705
+ maxX: zod.z.number(),
19706
+ maxY: zod.z.number()
19323
19707
  });
19324
- var ReferenceImageBodySchema = zod.z.object({
19325
- base64: zod.z.string(),
19326
- filename: zod.z.string()
19327
- });
19328
- var ReferenceAudioEntrySchema = zod.z.object({
19329
- filename: zod.z.string(),
19330
- sizeKb: zod.z.number()
19331
- });
19332
- var ReferenceAudioBodySchema = zod.z.object({ base64: zod.z.string() });
19333
- var AudioBackendSchema = zod.z.object({
19334
- id: zod.z.string(),
19335
- name: zod.z.string(),
19336
- description: zod.z.string(),
19337
- available: zod.z.boolean(),
19338
- /**
19339
- * Raw classifier labels this backend can emit (e.g. YAMNet's
19340
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
19341
- * the benchmark UI to populate the `enabledMicroClasses` filter
19342
- * specific to the selected backend without a separate fetch.
19343
- */
19344
- rawLabels: zod.z.array(zod.z.string()).readonly().optional()
19345
- });
19346
- var AudioCapabilitiesSchema = zod.z.object({
19347
- activeBackend: zod.z.string(),
19348
- availableBackends: zod.z.array(AudioBackendSchema).readonly(),
19349
- sampleRate: zod.z.number(),
19350
- chunkDurationMs: zod.z.number()
19351
- });
19352
- var DownloadModelResultSchema = zod.z.object({
19353
- filePath: zod.z.string(),
19354
- sizeMB: zod.z.number(),
19355
- durationMs: zod.z.number()
19356
- });
19357
- /**
19358
- * Wrapper carrying a single test run's result. Replaces the legacy
19359
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
19360
- * canonical `AudioResult` from the Phase 6 output rework: one
19361
- * `AudioDetection` per class above `minScore`, top-N candidates in
19362
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
19363
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
19364
- * benchmark UI can still report a clean failure when the classifier
19365
- * cap isn't available.
19366
- */
19367
- var AudioTestResultSchema = zod.z.object({
19368
- success: zod.z.boolean(),
19369
- error: zod.z.string().optional(),
19370
- frame: zod.z.custom().optional()
19371
- });
19372
- var PipelineConfigBridge = zod.z.custom();
19373
- var ConfigUISchemaBridge = zod.z.custom();
19374
- var ConfigUISchemaNullableBridge = zod.z.custom();
19375
- var InferenceCapabilitiesBridge = zod.z.custom();
19376
- var ModelAvailabilityListBridge = zod.z.custom();
19377
- var PipelineRunResultBridge = zod.z.custom();
19378
- /**
19379
- * Pipeline executor — detection engine + configuration + inference API.
19380
- *
19381
- * Merged from: pipeline-executor, pipeline-config, inference, detection-config.
19382
- * Implemented by the detection-pipeline addon.
19383
- *
19384
- * Per-device surface (DeviceSettingsContribution + the "is detection
19385
- * enabled for this camera?" toggle) lives on the paired
19386
- * `detection-pipeline` cap (device-scoped, singleton, wrapper
19387
- * defaultActive) — same split pattern used by stream-broker /
19388
- * camera-streams and audio-analyzer / audio-analysis.
19389
- */
19390
- var pipelineExecutorCapability = {
19391
- name: "pipeline-executor",
19392
- scope: "system",
19393
- mode: "singleton",
19394
- methods: {
19395
- getAvailableEngines: method(zod.z.void(), zod.z.array(PipelineEngineChoiceSchema)),
19396
- getSelectedEngine: method(zod.z.void(), PipelineEngineChoiceSchema),
19397
- getDefaultSteps: method(PipelineEngineChoiceSchema, zod.z.array(PipelineDefaultStepSchema)),
19398
- /**
19399
- * Per-node detection-engine provisioning snapshot. Returns the live
19400
- * state of the lazy runtime-provisioning machine on `nodeId`
19401
- * (idle / installing / verifying / ready / failed). The UI pairs this
19402
- * one-shot query with the `pipeline.engine-provisioning` live event
19403
- * (emitted on every transition) to drive a per-node "engine ready?"
19404
- * indicator without polling. Phase 2.
19405
- */
19406
- getEngineProvisioning: method(zod.z.object({ nodeId: zod.z.string() }), EngineProvisioningSchema),
19407
- getVideoPipelineSteps: method(zod.z.void(), zod.z.record(zod.z.string(), zod.z.object({
19408
- modelId: zod.z.string(),
19409
- settings: zod.z.record(zod.z.string(), zod.z.unknown()).readonly()
19410
- }))),
19411
- setVideoPipelineSteps: method(zod.z.object({ steps: zod.z.record(zod.z.string(), zod.z.object({
19412
- modelId: zod.z.string(),
19413
- settings: zod.z.record(zod.z.string(), zod.z.unknown()).readonly()
19414
- })) }), zod.z.object({ success: zod.z.literal(true) }), {
19415
- kind: "mutation",
19416
- auth: "admin"
19417
- }),
19418
- /**
19419
- * Clear THIS node's executor-side PER-DEVICE settings stores (the
19420
- * per-camera step overrides the object-detection root reads via
19421
- * `applyDeviceOverridesToTree`). `nodeId` is the ROUTING key — the
19422
- * generated cap-router strips it (default `nodeIdMode: 'routing'`) and
19423
- * dispatches to that node, so the provider method runs ON the target
19424
- * node and receives no `nodeId`.
19425
- *
19426
- * This is the slimmed executor leg of the orchestrator's
19427
- * `resetNodePipelineDefaults` flow (which owns the real reset: node
19428
- * addonDefaults pins + per-camera orchestrator overrides). The legacy
19429
- * `resetToDefault` — which reset a persisted global step-tree seed
19430
- * nothing in the live per-camera path read — was removed together with
19431
- * that seed.
19432
- */
19433
- clearDeviceOverrides: method(zod.z.object({ nodeId: zod.z.string() }), zod.z.object({
19434
- success: zod.z.literal(true),
19435
- clearedDevices: zod.z.number()
19436
- }), {
19437
- kind: "mutation",
19438
- auth: "admin"
19439
- }),
19440
- /**
19441
- * Which of THIS node's inference devices the executor currently refuses,
19442
- * and why. `nodeId` is the ROUTING key (stripped by the generated router).
19443
- *
19444
- * The channel that did not exist. Pool health was known only inside the
19445
- * detection addon and was an input to no routing decision anywhere: the
19446
- * per-dispatch capability gate is keyed on model FORMAT and so can never
19447
- * separate `openvino:gpu` from `openvino:npu`, and the orchestrator's live
19448
- * eligibility probe (`platformProbe.getCapabilities`) answers about
19449
- * HARDWARE — which was present throughout. So when the hub's `openvino:gpu`
19450
- * Python worker was SIGABRT'd by the Intel GPU plugin on 2026-08-25, the
19451
- * balancer went on handing that dead pool cameras by rotation for 31 hours:
19452
- * ~370 000 `PoolWorker[w0]: not initialized` lines, every frame lost.
19453
- *
19454
- * Read semantics the caller depends on, and which the provider guarantees:
19455
- * this is a synchronous read of in-memory state. It never probes hardware,
19456
- * never spawns a pool and never throws — an EMPTY `unhealthy` means "asked,
19457
- * nothing is refused", which is what re-admits a device. A read that FAILS
19458
- * (node offline, version skew) must therefore be distinguishable from an
19459
- * empty answer, and it is: it rejects.
19460
- */
19461
- getInferenceDeviceHealth: method(zod.z.object({ nodeId: zod.z.string() }), zod.z.object({ unhealthy: zod.z.array(zod.z.object({
19462
- /** `<backend>:<device>`, e.g. `openvino:gpu`. */
19463
- deviceKey: zod.z.string(),
19464
- /**
19465
- * `failed` — the per-device restart budget is exhausted; no pool
19466
- * will be spawned until an operator re-arms it or the runner
19467
- * respawns. `backoff` — under budget, waiting out the backoff (or
19468
- * a cached pool observed dead and not yet condemned).
19469
- */
19470
- state: zod.z.enum(["failed", "backoff"]),
19471
- /** Epoch ms of the death that produced this state. */
19472
- since: zod.z.number(),
19473
- /** Pool deaths inside the current window. */
19474
- deaths: zod.z.number(),
19475
- /** The last death's message. */
19476
- lastError: zod.z.string()
19477
- })).readonly() })),
19478
- /**
19479
- * Re-arm a terminally `failed` inference device on `nodeId`: forget its
19480
- * restart budget so the next dispatch builds a fresh pool.
19481
- *
19482
- * The terminal state is deliberate (the abort it bounds is deterministic —
19483
- * an automatic probation would just respawn Python forever, more slowly),
19484
- * and a terminal state an operator cannot leave is a silent fault. This is
19485
- * the way out. `rearmed:false` means there was nothing to forget.
19486
- */
19487
- rearmInferenceDevice: method(zod.z.object({
19488
- nodeId: zod.z.string(),
19489
- deviceKey: zod.z.string()
19490
- }), zod.z.object({ rearmed: zod.z.boolean() }), {
19491
- kind: "mutation",
19492
- auth: "admin"
19493
- }),
19494
- getSchema: method(zod.z.void(), PipelineSchemaSchema),
19495
- getGlobalSteps: method(zod.z.void(), zod.z.array(PipelineDefaultStepSchema).readonly().nullable()),
19496
- getGlobalPipelineConfig: method(zod.z.void(), PipelineConfigBridge),
19497
- getOrchestratorConfigSchema: method(zod.z.void(), ConfigUISchemaBridge),
19498
- /**
19499
- * Gate B (pre-init config-correctness gate). PURE COMPUTE against this
19500
- * node's `currentEngine.format` — resolves `steps` the same way the
19501
- * runtime dispatch path would, and reports what WOULD happen without
19502
- * touching any node-global state. Called by the orchestrator at attach
19503
- * time (`attachOn`), node-pinned to the TARGET node, so config problems
19504
- * surface BEFORE `pipelineRunner.attachCamera` rather than at the first
19505
- * per-frame resolve. `ok` is false iff `issues` is non-empty (both
19506
- * `unknown-addon` and `no-format-build` are HARD issues); `substitutions`
19507
- * is informational (a degraded-but-loadable model swap) and never
19508
- * affects `ok`. Never throws.
19509
- */
19510
- validatePipeline: method(zod.z.object({ steps: zod.z.array(PipelineStepInputSchema) }), PipelineValidationResultSchema),
19511
- listTemplates: method(zod.z.void(), zod.z.array(PipelineTemplateSchema$1).readonly()),
19512
- saveTemplate: method(zod.z.object({
19513
- name: zod.z.string(),
19514
- steps: zod.z.array(PipelineTemplateStepSchema).readonly(),
19515
- engine: PipelineEngineChoiceSchema
19516
- }), PipelineTemplateSchema$1, { kind: "mutation" }),
19517
- updateTemplate: method(zod.z.object({
19518
- id: zod.z.string(),
19519
- name: zod.z.string().optional(),
19520
- steps: zod.z.array(PipelineTemplateStepSchema).readonly().optional()
19521
- }), PipelineTemplateSchema$1, { kind: "mutation" }),
19522
- deleteTemplate: method(zod.z.object({ id: zod.z.string() }), zod.z.void(), { kind: "mutation" }),
19523
- getCapabilities: method(zod.z.void(), InferenceCapabilitiesBridge),
19524
- getAddonModels: method(zod.z.object({ addonId: zod.z.string() }), ModelAvailabilityListBridge),
19525
- downloadModel: method(zod.z.object({
19526
- addonId: zod.z.string(),
19527
- modelId: zod.z.string(),
19528
- format: ModelFormatSchema$1
19529
- }), DownloadModelResultSchema, { kind: "mutation" }),
19530
- deleteModel: method(zod.z.object({
19531
- addonId: zod.z.string(),
19532
- modelId: zod.z.string(),
19533
- format: ModelFormatSchema$1
19534
- }), zod.z.object({ success: zod.z.literal(true) }), { kind: "mutation" }),
19535
- /**
19536
- * Stateless single-frame execution. Callers (runner, benchmark) pass
19537
- * the complete `engine` + `steps` tree; the executor holds no state
19538
- * about cameras or saved pipelines.
19539
- *
19540
- * `engine` is optional during the migration window to preserve the
19541
- * legacy call shape used by existing benchmark code; once all
19542
- * callers pass it explicitly we make it required.
19543
- *
19544
- * Exactly one of `frame`, `frameRef`, `frameHandle`, `imageBase64`,
19545
- * `referenceImage` must be provided:
19546
- * - `frame`: runtime dispatch path (runner → decoded broker frame).
19547
- * Carries the raw buffer, dimensions, and format; the executor
19548
- * uses it directly without base64 round-tripping.
19549
- * - `frameHandle` (CB5): a zero-pixel shm `FrameHandle` for the SAME
19550
- * decoded frame. Both runner and executor are hub-local processes
19551
- * sharing `/dev/shm`, so the executor maps the named segment and
19552
- * reads the pixels back zero-copy — eliminating the ~1.2MB
19553
- * re-serialisation over UDS/MsgPack the `frame` path pays per call.
19554
- * High-risk: the FrameRing is a latest-wins seqlock with no
19555
- * refcount, so a recycled slot yields a null read; the executor
19556
- * then degrades to an empty result and the runner ships pixels via
19557
- * `frame` as the fallback (queue-depth gated on the runner side).
19558
- * - `imageBase64`: one-shot test path (benchmark ImageTab).
19559
- * - `referenceImage`: named file from the reference-image store.
19560
- */
19561
- runPipeline: method(zod.z.object({
19562
- engine: PipelineEngineChoiceSchema.optional(),
19563
- steps: zod.z.array(PipelineStepInputSchema).min(1),
19564
- frame: FrameInputSchema.optional(),
19565
- /**
19566
- * Process-local lazy frame. Valid only when caller and provider resolve
19567
- * in the same execution-group process; split/cross-node callers use
19568
- * `frame`/`image` inline compatibility instead.
19569
- */
19570
- frameRef: FrameRefSchema.optional(),
19571
- /**
19572
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
19573
- * the decoded pixels live in. One more member of the one-of
19574
- * frame/frameHandle/image/imageBase64/referenceImage group.
19575
- */
19576
- frameHandle: FrameHandleSchema.optional(),
19577
- imageBase64: zod.z.string().optional(),
19578
- /**
19579
- * Binary JPEG bytes — preferred over `imageBase64` on internal
19580
- * hops (hub → forked worker via Moleculer MsgPack) because it
19581
- * skips the 33% base64 overhead + the per-call base64 decode on
19582
- * the detection-pipeline worker. Callers can pass either; exactly
19583
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
19584
- */
19585
- image: zod.z.instanceof(Uint8Array).optional(),
19586
- referenceImage: zod.z.string().optional(),
19587
- deviceId: zod.z.number().optional(),
19588
- sessionId: zod.z.string().optional(),
19589
- /**
19590
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
19591
- * reference-image, and detail-subtree calls. 'frame' is the live
19592
- * per-frame dispatch: ONLY root-plane steps run; crop children
19593
- * (inputClasses ≠ null) are skipped and served per-track via
19594
- * pipelineRunner.runDetailSubtree (two-plane design).
19595
- */
19596
- plane: zod.z.enum(["full", "frame"]).optional(),
19597
- /**
19598
- * Inference-device selector (Phase 2 multi-device). Format
19599
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
19600
- * Omitted ⇒ the runner's default device (current single-engine
19601
- * behaviour). Selects WHICH device pool of the node runs the call.
19602
- */
19603
- deviceKey: zod.z.string().optional(),
19604
- /**
19605
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
19606
- * when the parent crop was resolved from the frame's retained NATIVE
19607
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
19608
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
19609
- * resolution from that surface — the SAME quality path faces already
19610
- * had — instead of the downscaled parent tile. `handle` keys the native
19611
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
19612
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
19613
- * the executor's crop-normalized child ROI back into frame-normalized
19614
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
19615
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
19616
- * (today's behaviour on the fallback path).
19617
- */
19618
- nativeCropRef: NativeCropRefSchema.optional()
19619
- }), PipelineRunResultBridge, { kind: "mutation" }),
19620
- /**
19621
- * Batched run — N raw frames packed into one cap call. The provider
19622
- * routes the batch through `SharedInferencePool.inferBatch`
19623
- * (`MSG_INFER_BATCH = 0x03`) so the IPC framing and JSON response
19624
- * envelope cost is amortised N:1 vs N concurrent `runPipeline`
19625
- * calls. Single root step + uniform model assumed; trees with crop
19626
- * children fall back to sequential execution.
19627
- *
19628
- * Used by `scripts/bench-batch-style.mts` for batch benchmarking —
19629
- * N frames in one call to amortise per-call IPC overhead.
19630
- */
19631
- runPipelineBatch: method(zod.z.object({
19632
- engine: PipelineEngineChoiceSchema.optional(),
19633
- steps: zod.z.array(PipelineStepInputSchema).min(1),
19634
- frames: zod.z.array(FrameInputSchema).min(1).max(255),
19635
- deviceId: zod.z.number().optional(),
19636
- sessionId: zod.z.string().optional(),
19637
- /**
19638
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
19639
- * the batch to the Python pool's bench preprocess cache
19640
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
19641
- * preprocessed ONCE and every later inference is a pure-inference cache
19642
- * hit — the sustained-throughput run measures inference, not
19643
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
19644
- * full preprocess every call, correct). Fresh per sustained run;
19645
- * released via `uncacheFrame`.
19646
- */
19647
- frameId: zod.z.number().int().nonnegative().optional(),
19648
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
19649
- deviceKey: zod.z.string().optional()
19650
- }), zod.z.object({ results: zod.z.array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }),
19651
- /**
19652
- * Cache a raw frame inside the Python inference pool's memory.
19653
- * Returns a numeric `frameId` that `inferCached` references —
19654
- * subsequent calls send only 5 bytes through the pipe instead of
19655
- * 1.2MB raw data, eliminating the pipe transfer bottleneck.
19656
- */
19657
- cacheFrameInPool: method(zod.z.object({
19658
- data: zod.z.instanceof(Uint8Array),
19659
- width: zod.z.number().int().positive(),
19660
- height: zod.z.number().int().positive(),
19661
- format: zod.z.enum([
19662
- "rgb",
19663
- "bgr",
19664
- "gray"
19665
- ])
19666
- }), zod.z.object({
19667
- frameId: zod.z.number(),
19668
- width: zod.z.number(),
19669
- height: zod.z.number()
19670
- }), { kind: "mutation" }),
19671
- /**
19672
- * Run inference on a previously cached frame. Sends only 5 bytes
19673
- * (model_idx + frameId) through the IPC pipe — eliminates the
19674
- * ~35ms per-call overhead of transferring 1.2MB raw data.
19675
- */
19676
- inferCached: method(zod.z.object({
19677
- stepId: zod.z.string(),
19678
- frameId: zod.z.number().int()
19679
- }), zod.z.record(zod.z.string(), zod.z.unknown()), { kind: "mutation" }),
19680
- /**
19681
- * Release a cached frame from the Python pool's memory.
19682
- */
19683
- uncacheFrame: method(zod.z.object({ frameId: zod.z.number().int() }), zod.z.void(), { kind: "mutation" }),
19684
- /** Returns the effective pool tuning (resolved from user overrides + backend defaults). */
19685
- getEffectiveTuning: method(zod.z.void(), zod.z.object({
19686
- batchMode: zod.z.string(),
19687
- windowMs: zod.z.number(),
19688
- maxBatchSize: zod.z.number(),
19689
- concurrency: zod.z.number()
19690
- })),
19691
- /**
19692
- * List every EngineFactory currently loaded in this executor's RAM,
19693
- * with the models resident and a coarse "in use" marker derived from
19694
- * ongoing inference activity. Used by the Pipeline page Engines tab.
19695
- */
19696
- listLoadedEngines: method(zod.z.void(), zod.z.array(zod.z.object({
19697
- engineKey: zod.z.string(),
19698
- engine: PipelineEngineChoiceSchema,
19699
- modelsLoaded: zod.z.array(zod.z.string()).readonly(),
19700
- inUseByCameras: zod.z.array(zod.z.number()).readonly(),
19701
- /**
19702
- * Origin of this resident factory.
19703
- * - `runtime` — main camera-serving engine (no idle TTL).
19704
- * - `warm-override` — benchmark/test override held in the warm
19705
- * cache; auto-disposed after the idle TTL.
19706
- * - `device-pool` — a concurrent per-device pool (Phase 2
19707
- * multi-device, keyed by `deviceKey`) resolved
19708
- * via `resolveDeviceFactory`. Runs alongside the
19709
- * `runtime` engine on a DIFFERENT accelerator
19710
- * (NPU / iGPU / Coral) — this is how the
19711
- * Engines tab shows all pools running at once.
19712
- */
19713
- kind: zod.z.enum([
19714
- "runtime",
19715
- "warm-override",
19716
- "device-pool"
19717
- ]),
19718
- /** Native pid of the underlying Python pool (null when no pool). */
19719
- poolPid: zod.z.number().nullable(),
19720
- /** ms since this factory was last used (null when not warm-tracked). */
19721
- idleMs: zod.z.number().nullable(),
19722
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
19723
- idleTtlMs: zod.z.number().nullable()
19724
- })).readonly()),
19725
- /** Warm up an engine without running a frame. No-op if already loaded. */
19726
- spinEngine: method(zod.z.object({ engine: PipelineEngineChoiceSchema }), zod.z.object({ success: zod.z.literal(true) }), {
19727
- kind: "mutation",
19728
- auth: "admin"
19729
- }),
19730
- /**
19731
- * Unload an engine from RAM. `force:true` unloads even when cameras
19732
- * are actively using it (they re-spin on next frame). Default is
19733
- * gated — returns `{success:false, reason}` when in use.
19734
- */
19735
- killEngine: method(zod.z.object({
19736
- engine: PipelineEngineChoiceSchema,
19737
- force: zod.z.boolean().optional()
19738
- }), zod.z.object({
19739
- success: zod.z.boolean(),
19740
- reason: zod.z.string().optional()
19741
- }), {
19742
- kind: "mutation",
19743
- auth: "admin"
19744
- }),
19745
- listReferenceImages: method(zod.z.void(), zod.z.array(ReferenceImageEntrySchema).readonly()),
19746
- getReferenceImage: method(zod.z.object({ filename: zod.z.string() }), ReferenceImageBodySchema.nullable()),
19747
- getReferenceAudioFiles: method(zod.z.void(), zod.z.array(ReferenceAudioEntrySchema).readonly()),
19748
- getReferenceAudio: method(zod.z.object({ filename: zod.z.string() }), ReferenceAudioBodySchema.nullable()),
19749
- getAudioCapabilities: method(zod.z.void(), AudioCapabilitiesSchema),
19750
- runAudioTest: method(zod.z.object({
19751
- addonId: zod.z.string(),
19752
- modelId: zod.z.string(),
19753
- filename: zod.z.string().optional(),
19754
- settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
19755
- }), AudioTestResultSchema, { kind: "mutation" }),
19756
- getDetectionConfigSchema: method(zod.z.void(), ConfigUISchemaNullableBridge)
19757
- }
19758
- };
19759
- /**
19760
- * Per-stage gating mode applied to the zones a rule references.
19761
- *
19762
- * - `include`: the rule contributes to a **whitelist** for its stage.
19763
- * When at least one `include` rule fires for a stage, only entities
19764
- * inside one of those zones pass that stage.
19765
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
19766
- * Entities inside one of those zones are dropped at that stage.
19767
- *
19768
- * `monitor`-style observation (count without filtering) is not a rule
19769
- * mode — zones without any matching rule are observed naturally by
19770
- * `zone-analytics` (live snapshot + history), so an "I just want to
19771
- * count, not filter" use case needs no rule at all.
19772
- */
19773
- var ZoneRuleModeEnum = zod.z.enum(["include", "exclude"]);
19774
- /**
19775
- * Per-consumer rule that references existing zones (geometry) and
19776
- * defines how a specific pipeline stage should treat them. Each
19777
- * consumer addon owns its own `ZoneRule[]` array in its per-device
19778
- * settings:
19779
- *
19780
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
19781
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
19782
- * - future: notification rules, audio gating, etc.
19783
- *
19784
- * One rule applies to N zones (`zoneIds[]`) so the operator can
19785
- * express "ignore motion in ALL of {garden, street}" with a single
19786
- * rule. `classFilter` narrows the rule to specific object classes —
19787
- * "drop person detections in the street, but keep cars" is one
19788
- * `exclude` rule with `classFilter: ['person']`.
19789
- *
19790
- * `enabled` is a soft toggle — the operator can keep the rule
19791
- * configured but inert without deleting it.
19792
- */
19793
- var ZoneRuleSchema = zod.z.object({
19794
- /** Stable rule id — survives edits, used by the UI for diffing. */
19795
- id: zod.z.string(),
19796
- /** Optional human-readable label rendered in the rule editor. */
19797
- name: zod.z.string().optional(),
19798
- /** Zones this rule targets. The rule's `mode` applies to ALL
19799
- * listed zones (OR-set: a detection in any one of them counts).
19800
- * At least one zone id required — a rule with no targets is a
19801
- * configuration mistake and the form validator rejects it. */
19802
- zoneIds: zod.z.array(zod.z.string()).min(1).readonly(),
19803
- mode: ZoneRuleModeEnum,
19804
- /**
19805
- * Class names this rule applies to. Empty / undefined ⇒ rule
19806
- * applies to every class. Class strings match the `macroClass`
19807
- * field on detections (e.g. `person`, `car`, `dog`).
19808
- */
19809
- classFilter: zod.z.array(zod.z.string()).readonly().optional(),
19810
- /**
19811
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
19812
- * required to consider an entity "in the zone". Defaults to the
19813
- * consumer's stage default when omitted. Kept for back-compat with
19814
- * existing per-rule overrides; new operators pick the value via
19815
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
19816
- * set, the lower-level engine reads it as a 0–1 fraction.
19817
- */
19818
- overlapThreshold: zod.z.number().min(0).max(1).optional(),
19819
- /**
19820
- * Operator-friendly version of `overlapThreshold` — the percentage
19821
- * of the detection's bbox that must lie inside the zone for the
19822
- * rule to match. Documented default is 85%; the engine substitutes
19823
- * that when the field is omitted (kept optional so existing rules
19824
- * stored without it stay valid).
19825
- *
19826
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
19827
- * rule, the engine prefers `bboxInclusionPct` because it's the
19828
- * field exposed in the UI. Internally both feed the same gate.
19829
- */
19830
- bboxInclusionPct: zod.z.number().min(0).max(100).optional(),
19831
- /**
19832
- * When `true` and a detection has a segmentation mask, use the
19833
- * mask for overlap instead of the bbox. Detection-stage only;
19834
- * motion rules ignore this field.
19835
- */
19836
- preferMask: zod.z.boolean().optional(),
19837
- /**
19838
- * Soft-toggle: `false` disables the rule without deleting it.
19839
- * Defaults to `true` so operators creating a rule via the UI
19840
- * see it active immediately.
19841
- */
19842
- enabled: zod.z.boolean().default(true)
19843
- });
19844
- zod.z.array(ZoneRuleSchema).readonly();
19845
- /**
19846
- * Zone — pure geometry + identity. NO filtering behaviour.
19847
- *
19848
- * Zones describe **where** in the frame the operator wants to flag
19849
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
19850
- * each pipeline stage uses them. Splitting the two means a single
19851
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
19852
- * a detection-include rule on `['car']`, and an occupancy aggregate
19853
- * — without three duplicated polygons.
19854
- *
19855
- * Owned by the orchestrator addon (provider) and mirrored into the
19856
- * `zones` device-state slice on every mutation. Consumers
19857
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
19858
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
19859
- * mirror with `onChanged`).
19860
- *
19861
- * Coordinates are normalised fractions of the frame (0–1) so zones
19862
- * survive resolution changes and stream profile switches.
19863
- *
19864
- * `kind` discriminates between full polygons (closed regions used
19865
- * for intrusion / occupancy filters) and tripwires (open 2-point
19866
- * line segments used for cross events). Onboard / firmware-reported
19867
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
19868
- * task list.
19869
- */
19870
- var ZoneKindEnum = zod.z.enum(["polygon", "tripwire"]);
19871
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
19872
- var PolygonPointSchema = zod.z.object({
19873
- x: zod.z.number(),
19874
- y: zod.z.number()
19875
- });
19876
- /** A camera detection zone — pure geometry/identity. */
19877
- var ZoneSchema = zod.z.object({
19878
- id: zod.z.string(),
19879
- name: zod.z.string(),
19880
- kind: ZoneKindEnum.default("polygon"),
19881
- /** Polygon vertices, fraction of frame (0–1). */
19882
- polygon: zod.z.array(PolygonPointSchema).readonly(),
19883
- /** Visual color for UI rendering. */
19884
- color: zod.z.string().default("#3b82f6")
19885
- });
19886
- /**
19887
- * Zones capability — per-camera CRUD over polygon detection zones.
19888
- *
19889
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
19890
- * to per-device settings and mirrors into the `zones` device-state
19891
- * slice on every mutation, so downstream consumers can subscribe via
19892
- * `dev.state.zones.onChanged`.
19893
- *
19894
- * The cap surface only handles geometry + identity; filtering
19895
- * behaviour (per-class, include/exclude, threshold) lives in the
19896
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
19897
- * `capabilities/schemas/zone-rule.js`.
19898
- */
19899
- var zonesCapability = {
19900
- name: "zones",
19901
- scope: "device",
19902
- mode: "singleton",
19903
- deviceTypes: [DeviceType.Camera],
19904
- methods: {
19905
- listZones: method(zod.z.object({ deviceId: zod.z.number() }), zod.z.array(ZoneSchema).readonly()),
19906
- addZone: method(zod.z.object({
19907
- deviceId: zod.z.number(),
19908
- zone: ZoneSchema
19909
- }), zod.z.void(), {
19910
- kind: "mutation",
19911
- auth: "admin"
19912
- }),
19913
- removeZone: method(zod.z.object({
19914
- deviceId: zod.z.number(),
19915
- zoneId: zod.z.string()
19916
- }), zod.z.void(), {
19917
- kind: "mutation",
19918
- auth: "admin"
19919
- }),
19920
- updateZone: method(zod.z.object({
19921
- deviceId: zod.z.number(),
19922
- zone: ZoneSchema
19923
- }), zod.z.void(), {
19924
- kind: "mutation",
19925
- auth: "admin"
19926
- })
19927
- },
19928
- /**
19929
- * Runtime-state slice — the live zone catalogue mirrored by the
19930
- * orchestrator on every CRUD mutation. Consumers read via
19931
- * `device.state.zones.value` / `.watch(...)` without round-tripping
19932
- * the cap, and the codegen DeviceProxy auto-wires the reactive
19933
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
19934
- * (e.g. zone groupings) can sit alongside the polygon list.
19935
- */
19936
- runtimeState: zod.z.object({ zones: zod.z.array(ZoneSchema).readonly() }),
19937
- /**
19938
- * Runtime-state durability: **restored** — written only on operator mutation, so a camera that never had one has nothing to re-derive from. This is the slice `zone-mirror-hydration.ts` exists to paper over.
19939
- *
19940
- * See `RuntimeStateDurability`. Enforced by
19941
- * `scripts/check-runtime-state-durability.ts`.
19942
- */
19943
- durability: "restored"
19944
- };
19945
- /**
19946
- * pipeline-analytics — device-scoped wrapper cap. Refines raw
19947
- * per-frame detections emitted by the pipeline runner into tracked
19948
- * objects, per-kind event collections (motion / object / audio), and
19949
- * persisted media. Owns the post-detection domain end-to-end:
19950
- *
19951
- * runner emits PipelineInferenceResult
19952
- * ↓ (event bus)
19953
- * pipeline-analytics subscriber
19954
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
19955
- * → three DB collections (one per kind), one FS media tree, one
19956
- * unified event emitter (FrameTracked + TrackStarted/Ended +
19957
- * DetectionEvent on bus)
19958
- *
19959
- * Pure subscriber model. No `processFrame` cap method — the runner
19960
- * already publishes the raw frame on the bus. The cap surface is
19961
- * only QUERIES + per-device settings, bound on/off via
19962
- * `device-manager.setWrapperActive`. `defaultActive: true` because
19963
- * every camera with a detection pipeline wants its raw detections
19964
- * refined; operators opt out per-device via BindingsTab when needed.
19965
- *
19966
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
19967
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
19968
- */
19969
- var TrackStateSchema = zod.z.enum([
19970
- "new",
19971
- "entered",
19972
- "left",
19973
- "moving",
19974
- "idle"
19975
- ]);
19976
- var EventKindSchema = zod.z.enum([
19977
- "motion",
19978
- "object",
19979
- "audio"
19980
- ]);
19981
- /**
19982
- * Spatial filter for `listTracks` — the rect + polygon variants of the shared
19983
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
19984
- * of the camera frame (top-left origin), matching the drawing-plane editor.
19985
- */
19986
- var TrackZoneFilterSchema = zod.z.discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
19987
- /** Closed icon vocabulary so clients render a known glyph per kind. */
19988
- var EventKindIconSchema = zod.z.enum([
19989
- "motion",
19990
- "audio",
19991
- "person",
19992
- "vehicle",
19993
- "animal",
19994
- "door",
19995
- "pir",
19996
- "smoke",
19997
- "water",
19998
- "button",
19999
- "package",
20000
- "generic"
20001
- ]);
20002
- var EventKindCategorySchema = zod.z.enum([
20003
- "motion",
20004
- "audio",
20005
- "detection",
20006
- "sensor",
20007
- "control",
20008
- "custom",
20009
- "package"
20010
- ]);
20011
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
20012
- var EventKindLevelSchema = zod.z.enum(["macro", "sub"]);
20013
- var EventKindDescriptorSchema = zod.z.object({
20014
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
20015
- kind: zod.z.string(),
20016
- /** i18n key resolved on the UI side; `label` is the English fallback. */
20017
- labelKey: zod.z.string(),
20018
- /** English fallback label (kept for clients that don't translate). */
20019
- label: zod.z.string(),
20020
- /** Hex color for timeline/legend rendering. */
20021
- color: zod.z.string(),
20022
- /** Dictionary id → lucide component on the UI side. */
20023
- iconId: zod.z.string(),
20024
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
20025
- icon: EventKindIconSchema,
20026
- category: EventKindCategorySchema,
20027
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
20028
- parentKind: zod.z.string().nullable(),
20029
- /** Derived from `parentKind`, explicit for the client tree. */
20030
- level: EventKindLevelSchema,
20031
- /** Which cap + device contributes this kind. For built-ins the camera
20032
- * itself; for sensor kinds the LINKED source device. */
20033
- source: zod.z.object({
20034
- capName: zod.z.string(),
20035
- deviceId: zod.z.number()
20036
- })
20037
- });
20038
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
20039
- var EventKindsForDeviceSchema = zod.z.object({
20040
- deviceId: zod.z.number(),
20041
- kinds: zod.z.array(EventKindDescriptorSchema).readonly()
20042
- });
20043
- var SensorEventSchema = zod.z.object({
20044
- id: zod.z.string(),
20045
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
20046
- * yields N rows, one per camera). */
20047
- deviceId: zod.z.number(),
20048
- /** The linked sensor device whose state changed. */
20049
- sourceDeviceId: zod.z.number(),
20050
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
20051
- kind: zod.z.string(),
20052
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
20053
- value: zod.z.record(zod.z.string(), zod.z.unknown()).nullable(),
20054
- timestamp: zod.z.number()
20055
- });
20056
- /**
20057
- * One stored sighting on a track's trajectory.
20058
- *
20059
- * The array these live in is returned in TIME order (D399) — it is APPENDED in
20060
- * arrival order, and the two detector passes interleave, so a consumer must not
20061
- * assume the two are the same on a row written by an older build.
20062
- */
20063
- var TrackPositionSchema = zod.z.object({
20064
- x: zod.z.number(),
20065
- y: zod.z.number(),
20066
- timestamp: zod.z.number(),
20067
- bbox: BoundingBoxSchema,
20068
- /**
20069
- * Which detector pass measured this box (D399): `frame` is the full-frame
20070
- * pass on the analysis raster, `recovery` is the native-resolution
20071
- * small-subject second pass (D377/D378). Both write into one array, and until
20072
- * this field existed the only way to tell them apart was that full-frame boxes
20073
- * are exact multiples of 1.2 while recovery boxes are full-precision floats.
20074
- * Absent on rows written before D399.
20075
- */
20076
- source: zod.z.enum(["frame", "recovery"]).optional(),
20077
- /** Detection score of this box, so a position can be weighed and not only
20078
- * plotted. Absent on rows written before D399. */
20079
- score: zod.z.number().optional()
20080
- });
20081
- var TrackSnapshotSchema = zod.z.object({
20082
- timestamp: zod.z.number(),
20083
- position: TrackPositionSchema,
20084
- /** The snapshot's media row id (D482); resolve via `listTrackMedia({ trackId })`. */
20085
- mediaId: zod.z.number().int()
20086
- });
20087
- /**
20088
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
20089
- * divided by the track's detection-frame dims), computed at persist time.
20090
- * Absent when the frame dims were unknown when the track was persisted
20091
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
20092
- */
20093
- var TrackEnvelopeSchema = zod.z.object({
20094
- minX: zod.z.number(),
20095
- minY: zod.z.number(),
20096
- maxX: zod.z.number(),
20097
- maxY: zod.z.number()
20098
- });
20099
- /**
20100
- * Row projection for track list queries. `full` (default) returns the
20101
- * complete Track including the frame-rate `positions[]` history and the
20102
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
20103
- * keeps every scalar the list surfaces actually render (ids, class(es),
20104
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
20105
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
20106
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
20107
- * `getTrack`. Mirrors the event-store `projection` convention
20108
- * (`getObjectEvents` et al.).
20109
- */
20110
- var TrackProjectionSchema = zod.z.enum(["full", "slim"]);
20111
- /**
20112
- * One audio-classification label heard on the track's camera while the
20113
- * track was alive, aggregated per label. An "episode" is one persisted
20114
- * audio event (the confident-classification path: score ≥ the device's
20115
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
20116
- * one 32 ms inference chunk, so counts stay human-scaled.
20117
- */
20118
- var TrackAudioLabelSchema = zod.z.object({
20119
- label: zod.z.string(),
20120
- /** Highest classification score observed across the label's episodes. */
20121
- peakScore: zod.z.number(),
20122
- /** Number of coalesced audio-event episodes carrying this label. */
20123
- count: zod.z.number(),
20124
- firstAt: zod.z.number(),
20125
- lastAt: zod.z.number()
19708
+ /**
19709
+ * Row projection for track list queries. `full` (default) returns the
19710
+ * complete Track including the frame-rate `positions[]` history and the
19711
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
19712
+ * keeps every scalar the list surfaces actually render (ids, class(es),
19713
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
19714
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
19715
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
19716
+ * `getTrack`. Mirrors the event-store `projection` convention
19717
+ * (`getObjectEvents` et al.).
19718
+ */
19719
+ var TrackProjectionSchema = zod.z.enum(["full", "slim"]);
19720
+ /**
19721
+ * One audio-classification label heard on the track's camera while the
19722
+ * track was alive, aggregated per label. An "episode" is one persisted
19723
+ * audio event (the confident-classification path: score ≥ the device's
19724
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
19725
+ * one 32 ms inference chunk, so counts stay human-scaled.
19726
+ */
19727
+ var TrackAudioLabelSchema = zod.z.object({
19728
+ label: zod.z.string(),
19729
+ /** Highest classification score observed across the label's episodes. */
19730
+ peakScore: zod.z.number(),
19731
+ /** Number of coalesced audio-event episodes carrying this label. */
19732
+ count: zod.z.number(),
19733
+ firstAt: zod.z.number(),
19734
+ lastAt: zod.z.number()
20126
19735
  });
20127
19736
  /**
20128
19737
  * How a track was produced. `pipeline` (default / absent) = the spatial
@@ -20513,6 +20122,22 @@ var TrackSchema = zod.z.object({
20513
20122
  * omit it. Render nothing when absent.
20514
20123
  */
20515
20124
  previewMissReason: zod.z.string().optional(),
20125
+ /**
20126
+ * The ROOT model that produced this track — the `FrameResult.rootModelId` of
20127
+ * the frame it was BORN on (D646). What a later replay compares against, so
20128
+ * "the original model" is named rather than assumed. A birth fact: never
20129
+ * rewritten by a later frame. **Absent ≠ unknown-model**: a row from before
20130
+ * the column, and a track the camera's own detector produced, carry none.
20131
+ */
20132
+ modelId: zod.z.string().optional(),
20133
+ /**
20134
+ * Size (px) of the detection frame this track's `positions[].bbox` live in —
20135
+ * the frame it was born on, else the camera's latest analysis frame at
20136
+ * persist time. Divide a position by these to normalise it. Absent when the
20137
+ * size was never known.
20138
+ */
20139
+ frameWidth: zod.z.number().optional(),
20140
+ frameHeight: zod.z.number().optional(),
20516
20141
  ...TrackFlagFields,
20517
20142
  ...TrackRetrainFields
20518
20143
  });
@@ -20750,7 +20375,8 @@ var MediaFileKindEnum = zod.z.enum([
20750
20375
  "thumbnailSmall",
20751
20376
  "confirmationCrop",
20752
20377
  "debugCrop",
20753
- "sceneFrame"
20378
+ "sceneFrame",
20379
+ "lastSceneFrame"
20754
20380
  ]);
20755
20381
  /**
20756
20382
  * One media row ON THE WIRE: what it is, how big it is, and WHERE ITS BYTES
@@ -21312,7 +20938,23 @@ var SearchObjectEventsInput = zod.z.object({
21312
20938
  until: zod.z.number().optional(),
21313
20939
  classFilter: zod.z.string().optional(),
21314
20940
  limit: zod.z.number().default(50),
21315
- 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()
21316
20958
  });
21317
20959
  var TrackCascadeCountsSchema = zod.z.object({
21318
20960
  /** Persisted track roots deleted (authoritative). */
@@ -21447,7 +21089,41 @@ var RebuildObjectEmbeddingsInput = zod.z.object({
21447
21089
  * comparable, so wiping and rebuilding is the only way to be sure every vector
21448
21090
  * means the same thing.
21449
21091
  */
21450
- 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
+ ]);
21451
21127
  /**
21452
21128
  * Acknowledgement that a rebuild STARTED.
21453
21129
  *
@@ -21460,7 +21136,12 @@ var WipeObjectEmbeddingsResultSchema = zod.z.object({ deleted: zod.z.number() })
21460
21136
  var RebuildObjectEmbeddingsResultSchema = zod.z.object({
21461
21137
  started: zod.z.boolean(),
21462
21138
  /** True when a pass was already running; the new request is ignored. */
21463
- 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()
21464
21145
  });
21465
21146
  var RebuildStatusSchema = zod.z.object({
21466
21147
  running: zod.z.boolean(),
@@ -21494,7 +21175,11 @@ var RebuildStatusSchema = zod.z.object({
21494
21175
  startedAtMs: zod.z.number().nullable(),
21495
21176
  finishedAtMs: zod.z.number().nullable(),
21496
21177
  /** Present when the pass ended by throwing. */
21497
- 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()
21498
21183
  });
21499
21184
  /**
21500
21185
  * Acknowledgement that a debug-media reclaim STARTED.
@@ -21537,25 +21222,6 @@ var MediaReclaimStatusSchema = zod.z.object({
21537
21222
  finishedAtMs: zod.z.number().nullable(),
21538
21223
  error: zod.z.string().nullable()
21539
21224
  });
21540
- var ReplayFrameInputSchema = zod.z.object({
21541
- timestamp: zod.z.number(),
21542
- frame: PipelineRunResultBridge
21543
- });
21544
- var ReplayTrackSchema = zod.z.object({
21545
- className: zod.z.string(),
21546
- firstSeenMs: zod.z.number(),
21547
- lastSeenMs: zod.z.number(),
21548
- /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
21549
- * frame — a representative box for the diff's `(className, window, IoU)`
21550
- * pairing (`replay-diff.ts`). A replay does not need the full per-frame
21551
- * trajectory production's `Track.positions` keeps. */
21552
- bbox: BoundingBoxSchema,
21553
- /** How many of the input frames this track matched a real detection on
21554
- * (never a coasted/extrapolated frame) — the replay's own signal for "how
21555
- * solid is this track", cheaper than re-deriving it from a trajectory. */
21556
- framesMatched: zod.z.number().int()
21557
- });
21558
- var RunReplayFrameProcessorResultSchema = zod.z.object({ tracks: zod.z.array(ReplayTrackSchema).readonly() });
21559
21225
  /**
21560
21226
  * The long-term series a camera produces. A closed union so a typo cannot
21561
21227
  * invent one, and the ONE declaration of it — the addon's `AnalyticsLtsSeries`
@@ -22227,309 +21893,952 @@ var pipelineAnalyticsCapability = {
22227
21893
  /**
22228
21894
  * The pixels of ONE copied frame, base64.
22229
21895
  *
22230
- * Through the cap rather than a data plane because it is genuinely one
22231
- * frame at a time, on demand, at human speed — the shape D9/D18 permit
22232
- * (what they forbid is frames crossing a boundary at frame RATE). The
22233
- * annotation canvas needs the image and its exact dimensions in the same
22234
- * answer: a canvas that places a normalised box against a size it guessed
22235
- * draws every box in the wrong place.
21896
+ * Through the cap rather than a data plane because it is genuinely one
21897
+ * frame at a time, on demand, at human speed — the shape D9/D18 permit
21898
+ * (what they forbid is frames crossing a boundary at frame RATE). The
21899
+ * annotation canvas needs the image and its exact dimensions in the same
21900
+ * answer: a canvas that places a normalised box against a size it guessed
21901
+ * draws every box in the wrong place.
21902
+ */
21903
+ getRetrainFrameImage: method(zod.z.object({ frameId: zod.z.string() }), zod.z.object({
21904
+ base64: zod.z.string(),
21905
+ width: zod.z.number().int(),
21906
+ height: zod.z.number().int()
21907
+ }), {
21908
+ kind: "query",
21909
+ auth: "admin"
21910
+ }),
21911
+ /**
21912
+ * Ask the pipeline what it sees, as a PROPOSAL.
21913
+ *
21914
+ * Runs through `pipelineRunner.runStatelessStep` on the COPIED frame, and
21915
+ * every box comes back as a draft with `source: 'assist'` plus the model and
21916
+ * score that produced it. The operator confirms, edits, adds and deletes;
21917
+ * nothing is stored until `saveRetrainAnnotations`.
21918
+ *
21919
+ * For packages the request is `rfdetr-package` on the ZONE CROP at 0.35 —
21920
+ * never the whole frame, where a package detector at that threshold proposes
21921
+ * furniture. A package request with no zone is REFUSED rather than widened,
21922
+ * because the silent widening would look like a bad model for as long as
21923
+ * nobody checked which rectangle it ran on.
21924
+ */
21925
+ proposeRetrainAnnotations: method(zod.z.object({
21926
+ deviceId: zod.z.number(),
21927
+ trackId: zod.z.string(),
21928
+ frameId: zod.z.string(),
21929
+ subject: RetrainAssistSubjectSchema,
21930
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
21931
+ nodeId: zod.z.string().optional()
21932
+ }), RetrainAssistResultSchema, {
21933
+ kind: "mutation",
21934
+ auth: "admin"
21935
+ }),
21936
+ /** Every annotation on a track, oldest first. */
21937
+ listRetrainAnnotations: method(zod.z.object({ trackId: zod.z.string() }), zod.z.array(RetrainAnnotationSchema).readonly(), {
21938
+ kind: "query",
21939
+ auth: "admin"
21940
+ }),
21941
+ /**
21942
+ * Replace EVERY annotation on one frame with the supplied set.
21943
+ *
21944
+ * Whole-frame replacement, not per-box upsert: the unit of ground truth is
21945
+ * the frame, and "the operator deleted a box" must be the same durable
21946
+ * outcome as "the operator never drew it". A per-box patch would let a frame
21947
+ * keep a box the operator removed on a surface that only knew about the
21948
+ * boxes it sent.
21949
+ *
21950
+ * Refuses a macro class typed into `label` or `subLabel` — the tiers are
21951
+ * separate and the guard is at the WRITE, because a mixed taxonomy cannot
21952
+ * be un-mixed by reading it.
21953
+ */
21954
+ saveRetrainAnnotations: method(zod.z.object({
21955
+ deviceId: zod.z.number(),
21956
+ trackId: zod.z.string(),
21957
+ frameId: zod.z.string(),
21958
+ annotations: zod.z.array(RetrainAnnotationDraftSchema)
21959
+ }), zod.z.array(RetrainAnnotationSchema).readonly(), {
21960
+ kind: "mutation",
21961
+ auth: "admin"
21962
+ }),
21963
+ /**
21964
+ * Finish with a track: `staging → trained`. **The only writer of that
21965
+ * state** — D81 shipped the column with it deliberately unreachable.
21966
+ *
21967
+ * Refuses a track the dataset holds no copies from. `trained` un-pins the
21968
+ * track's media, so completing without a copy is a delete order for material
21969
+ * nothing ever extracted anything from; that refusal IS the safety argument
21970
+ * of D81, expressed as a precondition.
21971
+ */
21972
+ completeRetrainTrack: method(zod.z.object({
21973
+ deviceId: zod.z.number(),
21974
+ trackId: zod.z.string()
21975
+ }), RetrainTransitionResultSchema, {
21976
+ kind: "mutation",
21977
+ auth: "admin"
21978
+ }),
21979
+ /**
21980
+ * The deliberate return: `trained → staging`, for the rare case.
21981
+ *
21982
+ * The generic `setTrackFlags` toggle refuses this in both directions by
21983
+ * design (D81) — re-staging from a checkbox is how the same material gets
21984
+ * annotated twice under two ground truths. Doing it here means the operator
21985
+ * is looking at the annotations that already exist while they decide, and
21986
+ * those annotations are LEFT ALONE: "put this back" must not be a
21987
+ * destructive act wearing a navigational name.
21988
+ */
21989
+ restageRetrainTrack: method(zod.z.object({
21990
+ deviceId: zod.z.number(),
21991
+ trackId: zod.z.string()
21992
+ }), RetrainTransitionResultSchema, {
21993
+ kind: "mutation",
21994
+ auth: "admin"
21995
+ }),
21996
+ /**
21997
+ * Where to download the ANNOTATED dataset.
21998
+ *
21999
+ * The sibling of `getTrainingExportUrl` and deliberately not the same
22000
+ * archive: that one streams a marked track's stored media verbatim, this one
22001
+ * streams the retrain COPIES plus an `annotations.json` carrying, for every
22002
+ * subject, the canonical full-frame box AND the geometry derived for each
22003
+ * model shape (letterboxed root / zone-cropped package / subject-cropped
22004
+ * classifier). Derived at export, never stored — one box in, three shapes
22005
+ * out, so two crops of the same subject can never end up in one feature
22006
+ * space (D52).
22007
+ */
22008
+ getRetrainExportUrl: method(zod.z.object({ deviceIds: zod.z.array(zod.z.number()).optional() }), zod.z.object({ url: zod.z.string() }), {
22009
+ kind: "query",
22010
+ auth: "admin"
22011
+ }),
22012
+ /**
22013
+ * The media an EVENT owns.
22014
+ *
22015
+ * `ownerType` is REQUIRED, and that is the whole correction (D482). An
22016
+ * event is a row in ONE of three tables, and since D474 each numbers from
22017
+ * 1 independently: `motion:101314` and `object:101314` both exist. This
22018
+ * method took a bare `eventId` and the provider probed motion → object →
22019
+ * audio, stopping at the first hit — so on the live hub, where object
22020
+ * events own no media of their own and 299 883 of 300 559 media rows are
22021
+ * motion-owned, EVERY object event resolved to its motion namesake. A
22022
+ * track from 17:34 on camera 615 was served a snapshot from 22:35 eleven
22023
+ * days earlier, silently.
22024
+ *
22025
+ * D476 had already disambiguated the KEY (`motion:` vs `object:`); this is
22026
+ * the API catching up to it. Naming the table is not a "qualification" of
22027
+ * the ambiguity — a listing BY OWNER has no address to make surrogate: the
22028
+ * owner IS (table, id), and half of it is not a question.
22029
+ */
22030
+ getEventMedia: method(zod.z.object({
22031
+ /** Which of the three event tables owns the row. */
22032
+ ownerType: EventOwnerTypeSchema,
22033
+ /** The event's rowid in that table (D474: an event id is a number). */
22034
+ eventId: zod.z.number().int(),
22035
+ kind: MediaFileKindEnum.optional(),
22036
+ deviceId: zod.z.number()
22037
+ }), zod.z.array(MediaFileSchema).readonly()),
22038
+ /** All media rows owned by a track. `kinds` narrows to a kind subset so a
22039
+ * client can fetch the SMALL display variants on open and pull the
22040
+ * multi-MB native variants only on demand (mirrors `getEventMedia.kind`).
22041
+ * Absent ⇒ every kind (back-compat). */
22042
+ getTrackMedia: method(zod.z.object({
22043
+ trackId: zod.z.string(),
22044
+ kinds: zod.z.array(MediaFileKindEnum).optional(),
22045
+ deviceId: zod.z.number()
22046
+ }), zod.z.array(MediaFileSchema).readonly()),
22047
+ /**
22048
+ * What media a track HAS, without any of it.
22049
+ *
22050
+ * The detail view needs the shape of a track's media to build its strip —
22051
+ * which kinds exist, in what order, at what size — and then wants each tile
22052
+ * fetched as an image, not as base64 inside this response. Measured: the
22053
+ * full `getTrackMedia` is 5.3-7.7 MB and blocks the view; this manifest is
22054
+ * ~2 KB.
22055
+ *
22056
+ * It also restores a fact a `kinds` filter destroys: filtering
22057
+ * `getTrackMedia` drops whole ROWS, taking `kind` and `sizeBytes` with
22058
+ * them, so a client that fetched only the small variants could no longer
22059
+ * tell a full-resolution variant existed — and the affordance that opens it
22060
+ * would silently disappear.
22061
+ */
22062
+ listTrackMedia: method(zod.z.object({
22063
+ trackId: zod.z.string(),
22064
+ deviceId: zod.z.number()
22065
+ }), zod.z.array(MediaFileInfoSchema).readonly()),
22066
+ /**
22067
+ * What media an EVENT has, without any of it — the twin `getEventMedia`
22068
+ * never had.
22069
+ *
22070
+ * `listTrackMedia` above got this treatment because a track's media is
22071
+ * 5-8 MB. An event's is worse per row, not better: an old-style event owns
22072
+ * a `crop` AND a native-resolution `fullFrameBoxed`, and the track DETAIL
22073
+ * modal — the one surface that legitimately shows the big kinds — unions
22074
+ * both listings to build its filmstrip. It then renders every tile from
22075
+ * the `event-media` plane by key and throws the bytes away. Measured on
22076
+ * the live hub: one event's `fullFrameBoxed` is 2 824 077 B, base64'd to
22077
+ * ~3.8 MB, allocated whole in hub-main's heap, for a list of keys.
22078
+ *
22079
+ * Same `deviceId` authorization subject as `getEventMedia`, the same
22080
+ * REQUIRED `ownerType` (read that method's docblock for the night-time
22081
+ * thumbnail this closes — D482), and the same rows: this is a projection
22082
+ * of that method, never a different question.
22236
22083
  */
22237
- getRetrainFrameImage: method(zod.z.object({ frameId: zod.z.string() }), zod.z.object({
22238
- base64: zod.z.string(),
22239
- width: zod.z.number().int(),
22240
- height: zod.z.number().int()
22241
- }), {
22242
- kind: "query",
22243
- auth: "admin"
22244
- }),
22084
+ listEventMedia: method(zod.z.object({
22085
+ ownerType: EventOwnerTypeSchema,
22086
+ eventId: zod.z.number().int(),
22087
+ deviceId: zod.z.number()
22088
+ }), zod.z.array(MediaFileInfoSchema).readonly()),
22245
22089
  /**
22246
- * Ask the pipeline what it sees, as a PROPOSAL.
22090
+ * Which of `ownerIds` hold at least ONE media row — an INDEX read, never a
22091
+ * blob read, and the LICENCE `videoclips` needs to publish a `thumbnail`.
22247
22092
  *
22248
- * Runs through `pipelineRunner.runStatelessStep` on the COPIED frame, and
22249
- * every box comes back as a draft with `source: 'assist'` plus the model and
22250
- * score that produced it. The operator confirms, edits, adds and deletes;
22251
- * nothing is stored until `saveRetrainAnnotations`.
22093
+ * The event-media URL is stamped from a template for every event in the
22094
+ * system, so "the plane is up" was being served as "there are bytes": 64 of
22095
+ * one camera's 179 clips pointed at a 404 (device 3836, 2026-08-17). This
22096
+ * is the question that turns the stamp into a claim.
22252
22097
  *
22253
- * For packages the request is `rfdetr-package` on the ZONE CROP at 0.35 —
22254
- * never the whole frame, where a package detector at that threshold proposes
22255
- * furniture. A package request with no zone is REFUSED rather than widened,
22256
- * because the silent widening would look like a bad model for as long as
22257
- * nobody checked which rectangle it ran on.
22098
+ * It is on the WIRE because the clip source is registered by the addon that
22099
+ * owns the FOOTAGE, not by this one (D560) — the probe used to be an
22100
+ * in-process `MediaStore` read. One call per OWNER KIND, never one per
22101
+ * owner: that N+1 is what `MediaStore.ownersWithMedia` was written to
22102
+ * prevent, and crossing a process boundary makes it worse, not better.
22103
+ * `ownerIds` is bounded at the same 5 000 the annotation fetch is bounded
22104
+ * at, so one pathological camera-day cannot mint an unbounded request.
22105
+ *
22106
+ * THROWS rather than answering partially. A probe that quietly
22107
+ * under-reports reads as "these owners have nothing" and the caller drops
22108
+ * thumbnails that exist — the opposite failure to the one above, and
22109
+ * equally invisible.
22110
+ *
22111
+ * `deviceId` is the authorization subject, exactly as on `getEventMedia`.
22258
22112
  */
22259
- proposeRetrainAnnotations: method(zod.z.object({
22113
+ ownersWithMedia: method(zod.z.object({
22260
22114
  deviceId: zod.z.number(),
22261
- trackId: zod.z.string(),
22262
- frameId: zod.z.string(),
22263
- subject: RetrainAssistSubjectSchema,
22264
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
22265
- nodeId: zod.z.string().optional()
22266
- }), RetrainAssistResultSchema, {
22267
- kind: "mutation",
22268
- auth: "admin"
22269
- }),
22115
+ ownerKind: MediaPresenceOwnerKindSchema,
22116
+ ownerIds: zod.z.array(zod.z.string()).max(5e3)
22117
+ }), zod.z.array(zod.z.string()).readonly()),
22270
22118
  /**
22271
- * The FrameProcessor pass of a replay run — see the `Replay` section
22272
- * above this capability's definition for why this is not the
22273
- * `processFrame` method this file's header says pipeline-analytics does
22274
- * not have.
22275
- *
22276
- * Constructs a FRESH `FrameProcessor` for `(deviceId, source)`, feeds it
22277
- * `frames` IN THE ORDER GIVEN (the caller is responsible for time
22278
- * ordering — this method does not sort), and returns the tracks it
22279
- * produced. Zero persistence: no `TrackStore`, no event bus, no media
22280
- * capture. `zones` / `detectionRules` are the run's OWN zone set —
22281
- * typically the camera's real zones plus an ephemeral overlay
22282
- * (`addon-benchmark`'s `replay-plan.ts`), never read from or written to
22283
- * the `zones` capability by this method itself.
22119
+ * Search object events by text query using CLIP cosine similarity.
22120
+ * Encodes `text` via the `embedding-encoder` cap, queries the
22121
+ * `ObjectEmbeddingStore` with optional prefilters, ranks all matching
22122
+ * embeddings by cosine similarity, and joins winners to their
22123
+ * ObjectEvents by trackId. Returns up to `limit` events scored ≥
22124
+ * `minScore`, sorted descending by score.
22284
22125
  */
22285
- runReplayFrameProcessor: method(zod.z.object({
22286
- deviceId: zod.z.number(),
22287
- source: DetectionSourceSchema,
22288
- zones: zod.z.array(ZoneSchema).readonly().optional(),
22289
- detectionRules: zod.z.array(ZoneRuleSchema).readonly().optional(),
22290
- zoneMembershipMinOverlap: zod.z.number().min(0).max(1).optional(),
22291
- frames: zod.z.array(ReplayFrameInputSchema).min(1)
22292
- }), RunReplayFrameProcessorResultSchema, {
22126
+ searchObjectEvents: method(SearchObjectEventsInput, zod.z.array(ScoredObjectEventSchema).readonly(), { caller: "required" }),
22127
+ wipeObjectEmbeddings: method(zod.z.object({}), WipeObjectEmbeddingsResultSchema, {
22293
22128
  kind: "mutation",
22294
22129
  auth: "admin"
22295
22130
  }),
22296
- /** Every annotation on a track, oldest first. */
22297
- listRetrainAnnotations: method(zod.z.object({ trackId: zod.z.string() }), zod.z.array(RetrainAnnotationSchema).readonly(), {
22298
- kind: "query",
22131
+ rebuildObjectEmbeddings: method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
22132
+ kind: "mutation",
22299
22133
  auth: "admin"
22300
22134
  }),
22135
+ getObjectEmbeddingRebuildStatus: method(zod.z.object({}), RebuildStatusSchema)
22136
+ },
22137
+ events: {
22301
22138
  /**
22302
- * Replace EVERY annotation on one frame with the supplied set.
22303
- *
22304
- * Whole-frame replacement, not per-box upsert: the unit of ground truth is
22305
- * the frame, and "the operator deleted a box" must be the same durable
22306
- * outcome as "the operator never drew it". A per-box patch would let a frame
22307
- * keep a box the operator removed on a surface that only knew about the
22308
- * boxes it sent.
22309
- *
22310
- * Refuses a macro class typed into `label` or `subLabel` — the tiers are
22311
- * separate and the guard is at the WRITE, because a mixed taxonomy cannot
22312
- * be un-mixed by reading it.
22139
+ * Enriched frame emitted after refinement — the live-overlay source of
22140
+ * truth (two-plane re-injection). Carries the frame's detections in the
22141
+ * `ObjectDetection` wire shape: first-level roots (with track info +
22142
+ * enrichment labels) plus synthesized `kind:'detail'` face/plate entries
22143
+ * re-projected from per-track detail state, so stream overlays render
22144
+ * boxes + recognized names without querying full Track state.
22313
22145
  */
22314
- saveRetrainAnnotations: method(zod.z.object({
22146
+ onFrameTracked: { data: zod.z.object({
22147
+ deviceId: zod.z.number(),
22148
+ timestamp: zod.z.number(),
22149
+ frameWidth: zod.z.number(),
22150
+ frameHeight: zod.z.number(),
22151
+ detections: zod.z.array(OverlayDetectionSchema).readonly()
22152
+ }) },
22153
+ /** Track entered active state (first-seen). */
22154
+ onTrackStarted: { data: zod.z.object({
22315
22155
  deviceId: zod.z.number(),
22316
22156
  trackId: zod.z.string(),
22317
- frameId: zod.z.string(),
22318
- annotations: zod.z.array(RetrainAnnotationDraftSchema)
22319
- }), zod.z.array(RetrainAnnotationSchema).readonly(), {
22157
+ className: zod.z.string()
22158
+ }) },
22159
+ /** Track expired (TTL reached after last detection). */
22160
+ onTrackEnded: { data: zod.z.object({
22161
+ deviceId: zod.z.number(),
22162
+ trackId: zod.z.string(),
22163
+ className: zod.z.string(),
22164
+ durationMs: zod.z.number()
22165
+ }) },
22166
+ /** Canonical "something happened at device X" event, per-kind. */
22167
+ onDetectionEvent: { data: zod.z.object({
22168
+ deviceId: zod.z.number(),
22169
+ kind: EventKindSchema,
22170
+ eventId: zod.z.string(),
22171
+ timestamp: zod.z.number()
22172
+ }) }
22173
+ }
22174
+ };
22175
+ /**
22176
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
22177
+ * within the frame, so the executor can re-cut a leaf child ROI at native
22178
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
22179
+ */
22180
+ var NativeCropRefSchema = zod.z.object({
22181
+ /** Handle keying the retained native surface (node-pinned to its owner). */
22182
+ handle: FrameHandleSchema,
22183
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
22184
+ cropFrameSpace: zod.z.object({
22185
+ x: zod.z.number(),
22186
+ y: zod.z.number(),
22187
+ w: zod.z.number(),
22188
+ h: zod.z.number()
22189
+ })
22190
+ });
22191
+ zod.z.object({
22192
+ crop: zod.z.object({
22193
+ left: zod.z.number(),
22194
+ top: zod.z.number(),
22195
+ width: zod.z.number().positive(),
22196
+ height: zod.z.number().positive()
22197
+ }).optional(),
22198
+ content: zod.z.object({
22199
+ width: zod.z.number().int().positive(),
22200
+ height: zod.z.number().int().positive()
22201
+ }),
22202
+ fit: zod.z.enum(["stretch", "contain"]),
22203
+ format: zod.z.enum([
22204
+ "rgb",
22205
+ "gray",
22206
+ "jpeg"
22207
+ ])
22208
+ });
22209
+ /**
22210
+ * Process-local frame identity. It is serializable so it can ride an in-process
22211
+ * capability call, but `registryId` deliberately prevents resolution in any
22212
+ * other process or execution group.
22213
+ */
22214
+ var FrameRefSchema = zod.z.object({
22215
+ registryId: zod.z.string().min(1),
22216
+ id: zod.z.string().min(1),
22217
+ width: zod.z.number().int().positive(),
22218
+ height: zod.z.number().int().positive(),
22219
+ format: zod.z.enum(["rgb", "gray"]),
22220
+ timestamp: zod.z.number(),
22221
+ capturedAt: zod.z.number().optional()
22222
+ });
22223
+ var ModelFormatSchema$1 = zod.z.enum([
22224
+ "onnx",
22225
+ "coreml",
22226
+ "openvino",
22227
+ "tflite",
22228
+ "pt",
22229
+ "gguf"
22230
+ ]);
22231
+ var PipelineSlotSchema = zod.z.enum([
22232
+ "detector",
22233
+ "cropper",
22234
+ "classifier",
22235
+ "refiner",
22236
+ "audio-classifier"
22237
+ ]);
22238
+ var PipelineEngineChoiceSchema = zod.z.object({
22239
+ runtime: zod.z.literal("python"),
22240
+ backend: zod.z.string(),
22241
+ format: ModelFormatSchema$1,
22242
+ device: zod.z.string().optional()
22243
+ });
22244
+ /**
22245
+ * One pool's resolved provisioning (`getEffectiveTuning`). `numWorkers` is the
22246
+ * knob that lifts a saturated pool (`inference-devices.md`); `concurrency` is
22247
+ * per-worker in-flight requests. `deviceKey` echoes the pool asked about —
22248
+ * `null` for the node-default pool.
22249
+ */
22250
+ var EffectiveTuningSchema = zod.z.object({
22251
+ deviceKey: zod.z.string().nullable(),
22252
+ runtime: zod.z.string(),
22253
+ batchMode: zod.z.string(),
22254
+ windowMs: zod.z.number(),
22255
+ maxBatchSize: zod.z.number(),
22256
+ concurrency: zod.z.number(),
22257
+ numWorkers: zod.z.number()
22258
+ });
22259
+ var EngineDeviceInfoSchema = zod.z.object({
22260
+ id: zod.z.string(),
22261
+ label: zod.z.string(),
22262
+ description: zod.z.string().optional()
22263
+ });
22264
+ var AvailableEngineSchema = zod.z.object({
22265
+ engine: PipelineEngineChoiceSchema,
22266
+ devices: zod.z.array(EngineDeviceInfoSchema).readonly(),
22267
+ defaultDevice: zod.z.string()
22268
+ });
22269
+ var PipelineDefaultStepSchema = zod.z.lazy(() => zod.z.object({
22270
+ addonId: zod.z.string(),
22271
+ addonName: zod.z.string(),
22272
+ slot: PipelineSlotSchema,
22273
+ inputClasses: zod.z.array(zod.z.string()).readonly(),
22274
+ outputClasses: zod.z.array(zod.z.string()).readonly(),
22275
+ enabled: zod.z.boolean(),
22276
+ modelId: zod.z.string(),
22277
+ children: zod.z.array(PipelineDefaultStepSchema).readonly(),
22278
+ group: zod.z.string().optional(),
22279
+ settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
22280
+ }));
22281
+ var PipelineTemplateStepSchema = zod.z.lazy(() => zod.z.object({
22282
+ addonId: zod.z.string(),
22283
+ enabled: zod.z.boolean(),
22284
+ modelId: zod.z.string(),
22285
+ children: zod.z.array(PipelineTemplateStepSchema).readonly(),
22286
+ settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
22287
+ }));
22288
+ var PipelineTemplateSchema$1 = zod.z.object({
22289
+ id: zod.z.string(),
22290
+ name: zod.z.string(),
22291
+ createdAt: zod.z.string(),
22292
+ updatedAt: zod.z.string(),
22293
+ engine: PipelineEngineChoiceSchema,
22294
+ steps: zod.z.array(PipelineTemplateStepSchema).readonly()
22295
+ });
22296
+ var PipelineModelOptionSchema = zod.z.object({
22297
+ id: zod.z.string(),
22298
+ name: zod.z.string(),
22299
+ formats: zod.z.record(zod.z.string(), zod.z.object({
22300
+ downloaded: zod.z.boolean(),
22301
+ sizeMB: zod.z.number()
22302
+ })),
22303
+ group: ModelVariantGroupSchema.optional(),
22304
+ legacy: zod.z.boolean().optional(),
22305
+ provider: ModelProviderIdSchema.optional()
22306
+ });
22307
+ var ConfigFieldBridge = zod.z.custom();
22308
+ var PipelineAddonSchemaSchema = zod.z.object({
22309
+ id: zod.z.string(),
22310
+ name: zod.z.string(),
22311
+ slot: PipelineSlotSchema,
22312
+ inputClasses: zod.z.array(zod.z.string()).readonly(),
22313
+ outputClasses: zod.z.array(zod.z.string()).readonly(),
22314
+ childSlots: zod.z.array(PipelineSlotSchema).readonly(),
22315
+ models: zod.z.array(PipelineModelOptionSchema).readonly(),
22316
+ defaultModelId: zod.z.string(),
22317
+ defaultModelIdByFormat: zod.z.record(zod.z.string(), zod.z.string()).optional(),
22318
+ enabledByDefault: zod.z.boolean().optional(),
22319
+ backfillIntoExistingOverrides: zod.z.boolean().optional(),
22320
+ defaultConfidence: zod.z.number(),
22321
+ group: zod.z.string().optional(),
22322
+ configSchema: zod.z.array(ConfigFieldBridge).readonly().optional()
22323
+ });
22324
+ var PipelineSlotSchemaSchema = zod.z.object({
22325
+ id: PipelineSlotSchema,
22326
+ label: zod.z.string(),
22327
+ priority: zod.z.number(),
22328
+ parentSlot: PipelineSlotSchema.nullable(),
22329
+ addons: zod.z.array(PipelineAddonSchemaSchema).readonly()
22330
+ });
22331
+ var PipelineSchemaSchema = zod.z.object({
22332
+ availableEngines: zod.z.array(AvailableEngineSchema).readonly(),
22333
+ selectedEngine: PipelineEngineChoiceSchema,
22334
+ slots: zod.z.array(PipelineSlotSchemaSchema).readonly()
22335
+ });
22336
+ var EngineProvisioningSchema = zod.z.object({
22337
+ runtimeId: zod.z.enum([
22338
+ "onnx",
22339
+ "openvino",
22340
+ "coreml",
22341
+ "edgetpu"
22342
+ ]).nullable(),
22343
+ device: zod.z.string().nullable(),
22344
+ state: zod.z.enum([
22345
+ "idle",
22346
+ "installing",
22347
+ "verifying",
22348
+ "ready",
22349
+ "failed"
22350
+ ]),
22351
+ progress: zod.z.number().optional(),
22352
+ error: zod.z.string().optional(),
22353
+ nextRetryAt: zod.z.number().optional(),
22354
+ /**
22355
+ * Gate A (config-correctness gate at engine change): human-readable
22356
+ * config issues surfaced EAGERLY when the node's engine changes — model
22357
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
22358
+ * has a <format> build"). Additive/optional: informational only, never
22359
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
22360
+ * Absent/empty when the node-default tree resolves cleanly.
22361
+ */
22362
+ configIssues: zod.z.array(zod.z.string()).optional()
22363
+ });
22364
+ var PipelineStepInputSchema = zod.z.lazy(() => zod.z.object({
22365
+ addonId: zod.z.string(),
22366
+ modelId: zod.z.string().optional(),
22367
+ enabled: zod.z.boolean().default(true),
22368
+ children: zod.z.array(PipelineStepInputSchema).optional(),
22369
+ settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
22370
+ jumpDeviceKey: zod.z.string().optional()
22371
+ }));
22372
+ var ModelSubstitutionSchema = zod.z.object({
22373
+ addonId: zod.z.string(),
22374
+ chosen: zod.z.string(),
22375
+ running: zod.z.string(),
22376
+ format: zod.z.string()
22377
+ });
22378
+ var PipelineValidationIssueSchema = zod.z.object({
22379
+ addonId: zod.z.string(),
22380
+ kind: zod.z.enum([
22381
+ "unknown-addon",
22382
+ "no-format-build",
22383
+ "unknown-device"
22384
+ ]),
22385
+ detail: zod.z.string()
22386
+ });
22387
+ var PipelineValidationResultSchema = zod.z.object({
22388
+ ok: zod.z.boolean(),
22389
+ issues: zod.z.array(PipelineValidationIssueSchema).readonly(),
22390
+ substitutions: zod.z.array(ModelSubstitutionSchema).readonly(),
22391
+ /** The node's `currentEngine.format` this validation ran against. */
22392
+ format: zod.z.string()
22393
+ });
22394
+ var ReferenceImageEntrySchema = zod.z.object({
22395
+ filename: zod.z.string(),
22396
+ stepIds: zod.z.array(zod.z.string()).readonly().optional()
22397
+ });
22398
+ var ReferenceImageBodySchema = zod.z.object({
22399
+ base64: zod.z.string(),
22400
+ filename: zod.z.string()
22401
+ });
22402
+ var ReferenceAudioEntrySchema = zod.z.object({
22403
+ filename: zod.z.string(),
22404
+ sizeKb: zod.z.number()
22405
+ });
22406
+ var ReferenceAudioBodySchema = zod.z.object({ base64: zod.z.string() });
22407
+ var AudioBackendSchema = zod.z.object({
22408
+ id: zod.z.string(),
22409
+ name: zod.z.string(),
22410
+ description: zod.z.string(),
22411
+ available: zod.z.boolean(),
22412
+ /**
22413
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
22414
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
22415
+ * the benchmark UI to populate the `enabledMicroClasses` filter
22416
+ * specific to the selected backend without a separate fetch.
22417
+ */
22418
+ rawLabels: zod.z.array(zod.z.string()).readonly().optional()
22419
+ });
22420
+ var AudioCapabilitiesSchema = zod.z.object({
22421
+ activeBackend: zod.z.string(),
22422
+ availableBackends: zod.z.array(AudioBackendSchema).readonly(),
22423
+ sampleRate: zod.z.number(),
22424
+ chunkDurationMs: zod.z.number()
22425
+ });
22426
+ var DownloadModelResultSchema = zod.z.object({
22427
+ filePath: zod.z.string(),
22428
+ sizeMB: zod.z.number(),
22429
+ durationMs: zod.z.number()
22430
+ });
22431
+ /**
22432
+ * Wrapper carrying a single test run's result. Replaces the legacy
22433
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
22434
+ * canonical `AudioResult` from the Phase 6 output rework: one
22435
+ * `AudioDetection` per class above `minScore`, top-N candidates in
22436
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
22437
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
22438
+ * benchmark UI can still report a clean failure when the classifier
22439
+ * cap isn't available.
22440
+ */
22441
+ var AudioTestResultSchema = zod.z.object({
22442
+ success: zod.z.boolean(),
22443
+ error: zod.z.string().optional(),
22444
+ frame: zod.z.custom().optional()
22445
+ });
22446
+ var PipelineConfigBridge = zod.z.custom();
22447
+ var ConfigUISchemaBridge = zod.z.custom();
22448
+ var ConfigUISchemaNullableBridge = zod.z.custom();
22449
+ var InferenceCapabilitiesBridge = zod.z.custom();
22450
+ var ModelAvailabilityListBridge = zod.z.custom();
22451
+ var PipelineRunResultBridge = zod.z.custom();
22452
+ /**
22453
+ * Pipeline executor — detection engine + configuration + inference API.
22454
+ *
22455
+ * Merged from: pipeline-executor, pipeline-config, inference, detection-config.
22456
+ * Implemented by the detection-pipeline addon.
22457
+ *
22458
+ * Per-device surface (DeviceSettingsContribution + the "is detection
22459
+ * enabled for this camera?" toggle) lives on the paired
22460
+ * `detection-pipeline` cap (device-scoped, singleton, wrapper
22461
+ * defaultActive) — same split pattern used by stream-broker /
22462
+ * camera-streams and audio-analyzer / audio-analysis.
22463
+ */
22464
+ var pipelineExecutorCapability = {
22465
+ name: "pipeline-executor",
22466
+ scope: "system",
22467
+ mode: "singleton",
22468
+ methods: {
22469
+ getAvailableEngines: method(zod.z.void(), zod.z.array(PipelineEngineChoiceSchema)),
22470
+ getSelectedEngine: method(zod.z.void(), PipelineEngineChoiceSchema),
22471
+ getDefaultSteps: method(PipelineEngineChoiceSchema, zod.z.array(PipelineDefaultStepSchema)),
22472
+ /**
22473
+ * Per-node detection-engine provisioning snapshot. Returns the live
22474
+ * state of the lazy runtime-provisioning machine on `nodeId`
22475
+ * (idle / installing / verifying / ready / failed). The UI pairs this
22476
+ * one-shot query with the `pipeline.engine-provisioning` live event
22477
+ * (emitted on every transition) to drive a per-node "engine ready?"
22478
+ * indicator without polling. Phase 2.
22479
+ */
22480
+ getEngineProvisioning: method(zod.z.object({ nodeId: zod.z.string() }), EngineProvisioningSchema),
22481
+ getVideoPipelineSteps: method(zod.z.void(), zod.z.record(zod.z.string(), zod.z.object({
22482
+ modelId: zod.z.string(),
22483
+ settings: zod.z.record(zod.z.string(), zod.z.unknown()).readonly()
22484
+ }))),
22485
+ setVideoPipelineSteps: method(zod.z.object({ steps: zod.z.record(zod.z.string(), zod.z.object({
22486
+ modelId: zod.z.string(),
22487
+ settings: zod.z.record(zod.z.string(), zod.z.unknown()).readonly()
22488
+ })) }), zod.z.object({ success: zod.z.literal(true) }), {
22320
22489
  kind: "mutation",
22321
22490
  auth: "admin"
22322
22491
  }),
22323
22492
  /**
22324
- * Finish with a track: `staging → trained`. **The only writer of that
22325
- * state** — D81 shipped the column with it deliberately unreachable.
22493
+ * Clear THIS node's executor-side PER-DEVICE settings stores (the
22494
+ * per-camera step overrides the object-detection root reads via
22495
+ * `applyDeviceOverridesToTree`). `nodeId` is the ROUTING key — the
22496
+ * generated cap-router strips it (default `nodeIdMode: 'routing'`) and
22497
+ * dispatches to that node, so the provider method runs ON the target
22498
+ * node and receives no `nodeId`.
22326
22499
  *
22327
- * Refuses a track the dataset holds no copies from. `trained` un-pins the
22328
- * track's media, so completing without a copy is a delete order for material
22329
- * nothing ever extracted anything from; that refusal IS the safety argument
22330
- * of D81, expressed as a precondition.
22500
+ * This is the slimmed executor leg of the orchestrator's
22501
+ * `resetNodePipelineDefaults` flow (which owns the real reset: node
22502
+ * addonDefaults pins + per-camera orchestrator overrides). The legacy
22503
+ * `resetToDefault` — which reset a persisted global step-tree seed
22504
+ * nothing in the live per-camera path read — was removed together with
22505
+ * that seed.
22331
22506
  */
22332
- completeRetrainTrack: method(zod.z.object({
22333
- deviceId: zod.z.number(),
22334
- trackId: zod.z.string()
22335
- }), RetrainTransitionResultSchema, {
22507
+ clearDeviceOverrides: method(zod.z.object({ nodeId: zod.z.string() }), zod.z.object({
22508
+ success: zod.z.literal(true),
22509
+ clearedDevices: zod.z.number()
22510
+ }), {
22336
22511
  kind: "mutation",
22337
22512
  auth: "admin"
22338
22513
  }),
22339
22514
  /**
22340
- * The deliberate return: `trained → staging`, for the rare case.
22515
+ * Which of THIS node's inference devices the executor currently refuses,
22516
+ * and why. `nodeId` is the ROUTING key (stripped by the generated router).
22341
22517
  *
22342
- * The generic `setTrackFlags` toggle refuses this in both directions by
22343
- * design (D81) — re-staging from a checkbox is how the same material gets
22344
- * annotated twice under two ground truths. Doing it here means the operator
22345
- * is looking at the annotations that already exist while they decide, and
22346
- * those annotations are LEFT ALONE: "put this back" must not be a
22347
- * destructive act wearing a navigational name.
22518
+ * The channel that did not exist. Pool health was known only inside the
22519
+ * detection addon and was an input to no routing decision anywhere: the
22520
+ * per-dispatch capability gate is keyed on model FORMAT and so can never
22521
+ * separate `openvino:gpu` from `openvino:npu`, and the orchestrator's live
22522
+ * eligibility probe (`platformProbe.getCapabilities`) answers about
22523
+ * HARDWARE — which was present throughout. So when the hub's `openvino:gpu`
22524
+ * Python worker was SIGABRT'd by the Intel GPU plugin on 2026-08-25, the
22525
+ * balancer went on handing that dead pool cameras by rotation for 31 hours:
22526
+ * ~370 000 `PoolWorker[w0]: not initialized` lines, every frame lost.
22527
+ *
22528
+ * Read semantics the caller depends on, and which the provider guarantees:
22529
+ * this is a synchronous read of in-memory state. It never probes hardware,
22530
+ * never spawns a pool and never throws — an EMPTY `unhealthy` means "asked,
22531
+ * nothing is refused", which is what re-admits a device. A read that FAILS
22532
+ * (node offline, version skew) must therefore be distinguishable from an
22533
+ * empty answer, and it is: it rejects.
22534
+ */
22535
+ getInferenceDeviceHealth: method(zod.z.object({ nodeId: zod.z.string() }), zod.z.object({ unhealthy: zod.z.array(zod.z.object({
22536
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
22537
+ deviceKey: zod.z.string(),
22538
+ /**
22539
+ * `failed` — the per-device restart budget is exhausted; no pool
22540
+ * will be spawned until an operator re-arms it or the runner
22541
+ * respawns. `backoff` — under budget, waiting out the backoff (or
22542
+ * a cached pool observed dead and not yet condemned).
22543
+ */
22544
+ state: zod.z.enum(["failed", "backoff"]),
22545
+ /** Epoch ms of the death that produced this state. */
22546
+ since: zod.z.number(),
22547
+ /** Pool deaths inside the current window. */
22548
+ deaths: zod.z.number(),
22549
+ /** The last death's message. */
22550
+ lastError: zod.z.string()
22551
+ })).readonly() })),
22552
+ /**
22553
+ * Re-arm a terminally `failed` inference device on `nodeId`: forget its
22554
+ * restart budget so the next dispatch builds a fresh pool.
22555
+ *
22556
+ * The terminal state is deliberate (the abort it bounds is deterministic —
22557
+ * an automatic probation would just respawn Python forever, more slowly),
22558
+ * and a terminal state an operator cannot leave is a silent fault. This is
22559
+ * the way out. `rearmed:false` means there was nothing to forget.
22348
22560
  */
22349
- restageRetrainTrack: method(zod.z.object({
22350
- deviceId: zod.z.number(),
22351
- trackId: zod.z.string()
22352
- }), RetrainTransitionResultSchema, {
22561
+ rearmInferenceDevice: method(zod.z.object({
22562
+ nodeId: zod.z.string(),
22563
+ deviceKey: zod.z.string()
22564
+ }), zod.z.object({ rearmed: zod.z.boolean() }), {
22353
22565
  kind: "mutation",
22354
22566
  auth: "admin"
22355
22567
  }),
22568
+ getSchema: method(zod.z.void(), PipelineSchemaSchema),
22569
+ getGlobalSteps: method(zod.z.void(), zod.z.array(PipelineDefaultStepSchema).readonly().nullable()),
22570
+ getGlobalPipelineConfig: method(zod.z.void(), PipelineConfigBridge),
22571
+ getOrchestratorConfigSchema: method(zod.z.void(), ConfigUISchemaBridge),
22356
22572
  /**
22357
- * Where to download the ANNOTATED dataset.
22573
+ * Gate B (pre-init config-correctness gate). PURE COMPUTE against this
22574
+ * node's `currentEngine.format` — resolves `steps` the same way the
22575
+ * runtime dispatch path would, and reports what WOULD happen without
22576
+ * touching any node-global state. Called by the orchestrator at attach
22577
+ * time (`attachOn`), node-pinned to the TARGET node, so config problems
22578
+ * surface BEFORE `pipelineRunner.attachCamera` rather than at the first
22579
+ * per-frame resolve. `ok` is false iff `issues` is non-empty (both
22580
+ * `unknown-addon` and `no-format-build` are HARD issues); `substitutions`
22581
+ * is informational (a degraded-but-loadable model swap) and never
22582
+ * affects `ok`. Never throws.
22358
22583
  *
22359
- * The sibling of `getTrainingExportUrl` and deliberately not the same
22360
- * archive: that one streams a marked track's stored media verbatim, this one
22361
- * streams the retrain COPIES plus an `annotations.json` carrying, for every
22362
- * subject, the canonical full-frame box AND the geometry derived for each
22363
- * model shape (letterboxed root / zone-cropped package / subject-cropped
22364
- * classifier). Derived at export, never stored — one box in, three shapes
22365
- * out, so two crops of the same subject can never end up in one feature
22366
- * space (D52).
22584
+ * `deviceKey` validates against THAT device pool's format instead of the
22585
+ * node default (D646) — the cheap question a pinned replay asks before it
22586
+ * reads any media: can this (node, deviceKey) run exactly this model?
22367
22587
  */
22368
- getRetrainExportUrl: method(zod.z.object({ deviceIds: zod.z.array(zod.z.number()).optional() }), zod.z.object({ url: zod.z.string() }), {
22369
- kind: "query",
22370
- auth: "admin"
22371
- }),
22588
+ validatePipeline: method(zod.z.object({
22589
+ steps: zod.z.array(PipelineStepInputSchema),
22590
+ deviceKey: zod.z.string().optional()
22591
+ }), PipelineValidationResultSchema),
22592
+ listTemplates: method(zod.z.void(), zod.z.array(PipelineTemplateSchema$1).readonly()),
22593
+ saveTemplate: method(zod.z.object({
22594
+ name: zod.z.string(),
22595
+ steps: zod.z.array(PipelineTemplateStepSchema).readonly(),
22596
+ engine: PipelineEngineChoiceSchema
22597
+ }), PipelineTemplateSchema$1, { kind: "mutation" }),
22598
+ updateTemplate: method(zod.z.object({
22599
+ id: zod.z.string(),
22600
+ name: zod.z.string().optional(),
22601
+ steps: zod.z.array(PipelineTemplateStepSchema).readonly().optional()
22602
+ }), PipelineTemplateSchema$1, { kind: "mutation" }),
22603
+ deleteTemplate: method(zod.z.object({ id: zod.z.string() }), zod.z.void(), { kind: "mutation" }),
22604
+ getCapabilities: method(zod.z.void(), InferenceCapabilitiesBridge),
22605
+ getAddonModels: method(zod.z.object({ addonId: zod.z.string() }), ModelAvailabilityListBridge),
22606
+ downloadModel: method(zod.z.object({
22607
+ addonId: zod.z.string(),
22608
+ modelId: zod.z.string(),
22609
+ format: ModelFormatSchema$1
22610
+ }), DownloadModelResultSchema, { kind: "mutation" }),
22611
+ deleteModel: method(zod.z.object({
22612
+ addonId: zod.z.string(),
22613
+ modelId: zod.z.string(),
22614
+ format: ModelFormatSchema$1
22615
+ }), zod.z.object({ success: zod.z.literal(true) }), { kind: "mutation" }),
22372
22616
  /**
22373
- * The media an EVENT owns.
22617
+ * Stateless single-frame execution. Callers (runner, benchmark) pass
22618
+ * the complete `steps` tree; the executor holds no state about cameras
22619
+ * or saved pipelines. WHICH pool answers is the node's own engine, or the
22620
+ * `deviceKey` pool when one is named.
22374
22621
  *
22375
- * `ownerType` is REQUIRED, and that is the whole correction (D482). An
22376
- * event is a row in ONE of three tables, and since D474 each numbers from
22377
- * 1 independently: `motion:101314` and `object:101314` both exist. This
22378
- * method took a bare `eventId` and the provider probed motion → object →
22379
- * audio, stopping at the first hit — so on the live hub, where object
22380
- * events own no media of their own and 299 883 of 300 559 media rows are
22381
- * motion-owned, EVERY object event resolved to its motion namesake. A
22382
- * track from 17:34 on camera 615 was served a snapshot from 22:35 eleven
22383
- * days earlier, silently.
22622
+ * There is no `engine` field (D646). It existed for the benchmark and was
22623
+ * honoured by swapping the SHARED provider's engine, factory and executor
22624
+ * for the duration of the call, on a node serving live cameras. A caller
22625
+ * that still sends the key has it stripped here and changes nothing.
22384
22626
  *
22385
- * D476 had already disambiguated the KEY (`motion:` vs `object:`); this is
22386
- * the API catching up to it. Naming the table is not a "qualification" of
22387
- * the ambiguity — a listing BY OWNER has no address to make surrogate: the
22388
- * owner IS (table, id), and half of it is not a question.
22627
+ * Exactly one of `frame`, `frameRef`, `frameHandle`, `imageBase64`,
22628
+ * `referenceImage` must be provided:
22629
+ * - `frame`: runtime dispatch path (runner → decoded broker frame).
22630
+ * Carries the raw buffer, dimensions, and format; the executor
22631
+ * uses it directly without base64 round-tripping.
22632
+ * - `frameHandle` (CB5): a zero-pixel shm `FrameHandle` for the SAME
22633
+ * decoded frame. Both runner and executor are hub-local processes
22634
+ * sharing `/dev/shm`, so the executor maps the named segment and
22635
+ * reads the pixels back zero-copy — eliminating the ~1.2MB
22636
+ * re-serialisation over UDS/MsgPack the `frame` path pays per call.
22637
+ * High-risk: the FrameRing is a latest-wins seqlock with no
22638
+ * refcount, so a recycled slot yields a null read; the executor
22639
+ * then degrades to an empty result and the runner ships pixels via
22640
+ * `frame` as the fallback (queue-depth gated on the runner side).
22641
+ * - `imageBase64`: one-shot test path (benchmark ImageTab).
22642
+ * - `referenceImage`: named file from the reference-image store.
22389
22643
  */
22390
- getEventMedia: method(zod.z.object({
22391
- /** Which of the three event tables owns the row. */
22392
- ownerType: EventOwnerTypeSchema,
22393
- /** The event's rowid in that table (D474: an event id is a number). */
22394
- eventId: zod.z.number().int(),
22395
- kind: MediaFileKindEnum.optional(),
22396
- deviceId: zod.z.number()
22397
- }), zod.z.array(MediaFileSchema).readonly()),
22398
- /** All media rows owned by a track. `kinds` narrows to a kind subset so a
22399
- * client can fetch the SMALL display variants on open and pull the
22400
- * multi-MB native variants only on demand (mirrors `getEventMedia.kind`).
22401
- * Absent ⇒ every kind (back-compat). */
22402
- getTrackMedia: method(zod.z.object({
22403
- trackId: zod.z.string(),
22404
- kinds: zod.z.array(MediaFileKindEnum).optional(),
22405
- deviceId: zod.z.number()
22406
- }), zod.z.array(MediaFileSchema).readonly()),
22644
+ runPipeline: method(zod.z.object({
22645
+ steps: zod.z.array(PipelineStepInputSchema).min(1),
22646
+ frame: FrameInputSchema.optional(),
22647
+ /**
22648
+ * Process-local lazy frame. Valid only when caller and provider resolve
22649
+ * in the same execution-group process; split/cross-node callers use
22650
+ * `frame`/`image` inline compatibility instead.
22651
+ */
22652
+ frameRef: FrameRefSchema.optional(),
22653
+ /**
22654
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
22655
+ * the decoded pixels live in. One more member of the one-of
22656
+ * frame/frameHandle/image/imageBase64/referenceImage group.
22657
+ */
22658
+ frameHandle: FrameHandleSchema.optional(),
22659
+ imageBase64: zod.z.string().optional(),
22660
+ /**
22661
+ * Binary JPEG bytes — preferred over `imageBase64` on internal
22662
+ * hops (hub → forked worker via Moleculer MsgPack) because it
22663
+ * skips the 33% base64 overhead + the per-call base64 decode on
22664
+ * the detection-pipeline worker. Callers can pass either; exactly
22665
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
22666
+ */
22667
+ image: zod.z.instanceof(Uint8Array).optional(),
22668
+ referenceImage: zod.z.string().optional(),
22669
+ deviceId: zod.z.number().optional(),
22670
+ sessionId: zod.z.string().optional(),
22671
+ /**
22672
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
22673
+ * reference-image, and detail-subtree calls. 'frame' is the live
22674
+ * per-frame dispatch: ONLY root-plane steps run; crop children
22675
+ * (inputClasses ≠ null) are skipped and served per-track via
22676
+ * pipelineRunner.runDetailSubtree (two-plane design).
22677
+ */
22678
+ plane: zod.z.enum(["full", "frame"]).optional(),
22679
+ /**
22680
+ * Inference-device selector (Phase 2 multi-device). Format
22681
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
22682
+ * Omitted ⇒ the runner's default device (current single-engine
22683
+ * behaviour). Selects WHICH device pool of the node runs the call.
22684
+ */
22685
+ deviceKey: zod.z.string().optional(),
22686
+ /**
22687
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
22688
+ * when the parent crop was resolved from the frame's retained NATIVE
22689
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
22690
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
22691
+ * resolution from that surface — the SAME quality path faces already
22692
+ * had — instead of the downscaled parent tile. `handle` keys the native
22693
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
22694
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
22695
+ * the executor's crop-normalized child ROI back into frame-normalized
22696
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
22697
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
22698
+ * (today's behaviour on the fallback path).
22699
+ */
22700
+ nativeCropRef: NativeCropRefSchema.optional(),
22701
+ /**
22702
+ * Offline REPLAY of stored media for `deviceId` (D56, D646): the
22703
+ * camera's zone gate and overrides apply as live, every executing
22704
+ * step runs EXACTLY the model it names on the `deviceKey` pool it
22705
+ * names or the call refuses (`model-not-servable` /
22706
+ * `device-not-servable`), and nothing reaches the camera's live
22707
+ * trace stream. Absent ⇒ unchanged behaviour.
22708
+ */
22709
+ replay: zod.z.literal(true).optional()
22710
+ }), PipelineRunResultBridge, { kind: "mutation" }),
22407
22711
  /**
22408
- * What media a track HAS, without any of it.
22409
- *
22410
- * The detail view needs the shape of a track's media to build its strip —
22411
- * which kinds exist, in what order, at what size — and then wants each tile
22412
- * fetched as an image, not as base64 inside this response. Measured: the
22413
- * full `getTrackMedia` is 5.3-7.7 MB and blocks the view; this manifest is
22414
- * ~2 KB.
22712
+ * Batched run — N raw frames packed into one cap call. The provider
22713
+ * routes the batch through `SharedInferencePool.inferBatch`
22714
+ * (`MSG_INFER_BATCH = 0x03`) so the IPC framing and JSON response
22715
+ * envelope cost is amortised N:1 vs N concurrent `runPipeline`
22716
+ * calls. Single root step + uniform model assumed; trees with crop
22717
+ * children fall back to sequential execution.
22415
22718
  *
22416
- * It also restores a fact a `kinds` filter destroys: filtering
22417
- * `getTrackMedia` drops whole ROWS, taking `kind` and `sizeBytes` with
22418
- * them, so a client that fetched only the small variants could no longer
22419
- * tell a full-resolution variant existed — and the affordance that opens it
22420
- * would silently disappear.
22719
+ * Used by `scripts/bench-batch-style.mts` for batch benchmarking —
22720
+ * N frames in one call to amortise per-call IPC overhead.
22421
22721
  */
22422
- listTrackMedia: method(zod.z.object({
22423
- trackId: zod.z.string(),
22424
- deviceId: zod.z.number()
22425
- }), zod.z.array(MediaFileInfoSchema).readonly()),
22722
+ runPipelineBatch: method(zod.z.object({
22723
+ steps: zod.z.array(PipelineStepInputSchema).min(1),
22724
+ frames: zod.z.array(FrameInputSchema).min(1).max(255),
22725
+ deviceId: zod.z.number().optional(),
22726
+ sessionId: zod.z.string().optional(),
22727
+ /**
22728
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
22729
+ * the batch to the Python pool's bench preprocess cache
22730
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
22731
+ * preprocessed ONCE and every later inference is a pure-inference cache
22732
+ * hit — the sustained-throughput run measures inference, not
22733
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
22734
+ * full preprocess every call, correct). Fresh per sustained run;
22735
+ * released via `uncacheFrame`.
22736
+ */
22737
+ frameId: zod.z.number().int().nonnegative().optional(),
22738
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
22739
+ deviceKey: zod.z.string().optional()
22740
+ }), zod.z.object({ results: zod.z.array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }),
22426
22741
  /**
22427
- * What media an EVENT has, without any of it — the twin `getEventMedia`
22428
- * never had.
22429
- *
22430
- * `listTrackMedia` above got this treatment because a track's media is
22431
- * 5-8 MB. An event's is worse per row, not better: an old-style event owns
22432
- * a `crop` AND a native-resolution `fullFrameBoxed`, and the track DETAIL
22433
- * modal — the one surface that legitimately shows the big kinds — unions
22434
- * both listings to build its filmstrip. It then renders every tile from
22435
- * the `event-media` plane by key and throws the bytes away. Measured on
22436
- * the live hub: one event's `fullFrameBoxed` is 2 824 077 B, base64'd to
22437
- * ~3.8 MB, allocated whole in hub-main's heap, for a list of keys.
22438
- *
22439
- * Same `deviceId` authorization subject as `getEventMedia`, the same
22440
- * REQUIRED `ownerType` (read that method's docblock for the night-time
22441
- * thumbnail this closes — D482), and the same rows: this is a projection
22442
- * of that method, never a different question.
22742
+ * Cache a raw frame inside the Python inference pool's memory.
22743
+ * Returns a numeric `frameId` that `inferCached` references —
22744
+ * subsequent calls send only 5 bytes through the pipe instead of
22745
+ * 1.2MB raw data, eliminating the pipe transfer bottleneck.
22443
22746
  */
22444
- listEventMedia: method(zod.z.object({
22445
- ownerType: EventOwnerTypeSchema,
22446
- eventId: zod.z.number().int(),
22447
- deviceId: zod.z.number()
22448
- }), zod.z.array(MediaFileInfoSchema).readonly()),
22747
+ cacheFrameInPool: method(zod.z.object({
22748
+ data: zod.z.instanceof(Uint8Array),
22749
+ width: zod.z.number().int().positive(),
22750
+ height: zod.z.number().int().positive(),
22751
+ format: zod.z.enum([
22752
+ "rgb",
22753
+ "bgr",
22754
+ "gray"
22755
+ ])
22756
+ }), zod.z.object({
22757
+ frameId: zod.z.number(),
22758
+ width: zod.z.number(),
22759
+ height: zod.z.number()
22760
+ }), { kind: "mutation" }),
22449
22761
  /**
22450
- * Which of `ownerIds` hold at least ONE media row — an INDEX read, never a
22451
- * blob read, and the LICENCE `videoclips` needs to publish a `thumbnail`.
22452
- *
22453
- * The event-media URL is stamped from a template for every event in the
22454
- * system, so "the plane is up" was being served as "there are bytes": 64 of
22455
- * one camera's 179 clips pointed at a 404 (device 3836, 2026-08-17). This
22456
- * is the question that turns the stamp into a claim.
22457
- *
22458
- * It is on the WIRE because the clip source is registered by the addon that
22459
- * owns the FOOTAGE, not by this one (D560) — the probe used to be an
22460
- * in-process `MediaStore` read. One call per OWNER KIND, never one per
22461
- * owner: that N+1 is what `MediaStore.ownersWithMedia` was written to
22462
- * prevent, and crossing a process boundary makes it worse, not better.
22463
- * `ownerIds` is bounded at the same 5 000 the annotation fetch is bounded
22464
- * at, so one pathological camera-day cannot mint an unbounded request.
22465
- *
22466
- * THROWS rather than answering partially. A probe that quietly
22467
- * under-reports reads as "these owners have nothing" and the caller drops
22468
- * thumbnails that exist — the opposite failure to the one above, and
22469
- * equally invisible.
22470
- *
22471
- * `deviceId` is the authorization subject, exactly as on `getEventMedia`.
22762
+ * Run inference on a previously cached frame. Sends only 5 bytes
22763
+ * (model_idx + frameId) through the IPC pipe — eliminates the
22764
+ * ~35ms per-call overhead of transferring 1.2MB raw data.
22472
22765
  */
22473
- ownersWithMedia: method(zod.z.object({
22474
- deviceId: zod.z.number(),
22475
- ownerKind: MediaPresenceOwnerKindSchema,
22476
- ownerIds: zod.z.array(zod.z.string()).max(5e3)
22477
- }), zod.z.array(zod.z.string()).readonly()),
22766
+ inferCached: method(zod.z.object({
22767
+ stepId: zod.z.string(),
22768
+ frameId: zod.z.number().int()
22769
+ }), zod.z.record(zod.z.string(), zod.z.unknown()), { kind: "mutation" }),
22478
22770
  /**
22479
- * Search object events by text query using CLIP cosine similarity.
22480
- * Encodes `text` via the `embedding-encoder` cap, queries the
22481
- * `ObjectEmbeddingStore` with optional prefilters, ranks all matching
22482
- * embeddings by cosine similarity, and joins winners to their
22483
- * ObjectEvents by trackId. Returns up to `limit` events scored ≥
22484
- * `minScore`, sorted descending by score.
22771
+ * Release a cached frame from the Python pool's memory.
22485
22772
  */
22486
- searchObjectEvents: method(SearchObjectEventsInput, zod.z.array(ScoredObjectEventSchema).readonly()),
22487
- wipeObjectEmbeddings: method(zod.z.object({}), WipeObjectEmbeddingsResultSchema, {
22773
+ uncacheFrame: method(zod.z.object({ frameId: zod.z.number().int() }), zod.z.void(), { kind: "mutation" }),
22774
+ /**
22775
+ * The effective provisioning of ONE pool of this node (operator override →
22776
+ * the pool's own runtime row). `deviceKey` names the device pool; absent is
22777
+ * the node-default pool. It answered only for the node default until
22778
+ * D646, so a benchmark on `openvino:npu` recorded the onnx pool's tuning
22779
+ * beside an NPU measurement.
22780
+ */
22781
+ getEffectiveTuning: method(zod.z.object({ deviceKey: zod.z.string().optional() }), EffectiveTuningSchema),
22782
+ /**
22783
+ * List every EngineFactory currently loaded in this executor's RAM,
22784
+ * with the models resident and a coarse "in use" marker derived from
22785
+ * ongoing inference activity. Used by the Pipeline page Engines tab.
22786
+ */
22787
+ listLoadedEngines: method(zod.z.void(), zod.z.array(zod.z.object({
22788
+ engineKey: zod.z.string(),
22789
+ engine: PipelineEngineChoiceSchema,
22790
+ modelsLoaded: zod.z.array(zod.z.string()).readonly(),
22791
+ inUseByCameras: zod.z.array(zod.z.number()).readonly(),
22792
+ /**
22793
+ * Origin of this resident factory.
22794
+ * - `runtime` — main camera-serving engine (no idle TTL).
22795
+ * - `device-pool` — a concurrent per-device pool (Phase 2
22796
+ * multi-device, keyed by `deviceKey`) resolved
22797
+ * via `resolveDeviceFactory`. Runs alongside the
22798
+ * `runtime` engine on a DIFFERENT accelerator
22799
+ * (NPU / iGPU / Coral) — this is how the
22800
+ * Engines tab shows all pools running at once.
22801
+ */
22802
+ kind: zod.z.enum(["runtime", "device-pool"]),
22803
+ /** Native pid of the underlying Python pool (null when no pool). */
22804
+ poolPid: zod.z.number().nullable(),
22805
+ /** ms since this factory was last used (null when not warm-tracked). */
22806
+ idleMs: zod.z.number().nullable(),
22807
+ /** Idle TTL after which the factory self-evicts (null when not applicable). */
22808
+ idleTtlMs: zod.z.number().nullable()
22809
+ })).readonly()),
22810
+ /** Warm up an engine without running a frame. No-op if already loaded. */
22811
+ spinEngine: method(zod.z.object({ engine: PipelineEngineChoiceSchema }), zod.z.object({ success: zod.z.literal(true) }), {
22488
22812
  kind: "mutation",
22489
22813
  auth: "admin"
22490
22814
  }),
22491
- rebuildObjectEmbeddings: method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
22815
+ /**
22816
+ * Unload an engine from RAM. `force:true` unloads even when cameras
22817
+ * are actively using it (they re-spin on next frame). Default is
22818
+ * gated — returns `{success:false, reason}` when in use.
22819
+ */
22820
+ killEngine: method(zod.z.object({
22821
+ engine: PipelineEngineChoiceSchema,
22822
+ force: zod.z.boolean().optional()
22823
+ }), zod.z.object({
22824
+ success: zod.z.boolean(),
22825
+ reason: zod.z.string().optional()
22826
+ }), {
22492
22827
  kind: "mutation",
22493
22828
  auth: "admin"
22494
22829
  }),
22495
- getObjectEmbeddingRebuildStatus: method(zod.z.object({}), RebuildStatusSchema)
22496
- },
22497
- events: {
22498
- /**
22499
- * Enriched frame emitted after refinement — the live-overlay source of
22500
- * truth (two-plane re-injection). Carries the frame's detections in the
22501
- * `ObjectDetection` wire shape: first-level roots (with track info +
22502
- * enrichment labels) plus synthesized `kind:'detail'` face/plate entries
22503
- * re-projected from per-track detail state, so stream overlays render
22504
- * boxes + recognized names without querying full Track state.
22505
- */
22506
- onFrameTracked: { data: zod.z.object({
22507
- deviceId: zod.z.number(),
22508
- timestamp: zod.z.number(),
22509
- frameWidth: zod.z.number(),
22510
- frameHeight: zod.z.number(),
22511
- detections: zod.z.array(OverlayDetectionSchema).readonly()
22512
- }) },
22513
- /** Track entered active state (first-seen). */
22514
- onTrackStarted: { data: zod.z.object({
22515
- deviceId: zod.z.number(),
22516
- trackId: zod.z.string(),
22517
- className: zod.z.string()
22518
- }) },
22519
- /** Track expired (TTL reached after last detection). */
22520
- onTrackEnded: { data: zod.z.object({
22521
- deviceId: zod.z.number(),
22522
- trackId: zod.z.string(),
22523
- className: zod.z.string(),
22524
- durationMs: zod.z.number()
22525
- }) },
22526
- /** Canonical "something happened at device X" event, per-kind. */
22527
- onDetectionEvent: { data: zod.z.object({
22528
- deviceId: zod.z.number(),
22529
- kind: EventKindSchema,
22530
- eventId: zod.z.string(),
22531
- timestamp: zod.z.number()
22532
- }) }
22830
+ listReferenceImages: method(zod.z.void(), zod.z.array(ReferenceImageEntrySchema).readonly()),
22831
+ getReferenceImage: method(zod.z.object({ filename: zod.z.string() }), ReferenceImageBodySchema.nullable()),
22832
+ getReferenceAudioFiles: method(zod.z.void(), zod.z.array(ReferenceAudioEntrySchema).readonly()),
22833
+ getReferenceAudio: method(zod.z.object({ filename: zod.z.string() }), ReferenceAudioBodySchema.nullable()),
22834
+ getAudioCapabilities: method(zod.z.void(), AudioCapabilitiesSchema),
22835
+ runAudioTest: method(zod.z.object({
22836
+ addonId: zod.z.string(),
22837
+ modelId: zod.z.string(),
22838
+ filename: zod.z.string().optional(),
22839
+ settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
22840
+ }), AudioTestResultSchema, { kind: "mutation" }),
22841
+ getDetectionConfigSchema: method(zod.z.void(), ConfigUISchemaNullableBridge)
22533
22842
  }
22534
22843
  };
22535
22844
  zod.z.object({
@@ -22557,6 +22866,106 @@ var CameraMetricsSchema = zod.z.object({
22557
22866
  });
22558
22867
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: zod.z.number() });
22559
22868
  /**
22869
+ * Zone — pure geometry + identity. NO filtering behaviour.
22870
+ *
22871
+ * Zones describe **where** in the frame the operator wants to flag
22872
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
22873
+ * each pipeline stage uses them. Splitting the two means a single
22874
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
22875
+ * a detection-include rule on `['car']`, and an occupancy aggregate
22876
+ * — without three duplicated polygons.
22877
+ *
22878
+ * Owned by the orchestrator addon (provider) and mirrored into the
22879
+ * `zones` device-state slice on every mutation. Consumers
22880
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
22881
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
22882
+ * mirror with `onChanged`).
22883
+ *
22884
+ * Coordinates are normalised fractions of the frame (0–1) so zones
22885
+ * survive resolution changes and stream profile switches.
22886
+ *
22887
+ * `kind` discriminates between full polygons (closed regions used
22888
+ * for intrusion / occupancy filters) and tripwires (open 2-point
22889
+ * line segments used for cross events). Onboard / firmware-reported
22890
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
22891
+ * task list.
22892
+ */
22893
+ var ZoneKindEnum = zod.z.enum(["polygon", "tripwire"]);
22894
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
22895
+ var PolygonPointSchema = zod.z.object({
22896
+ x: zod.z.number(),
22897
+ y: zod.z.number()
22898
+ });
22899
+ /** A camera detection zone — pure geometry/identity. */
22900
+ var ZoneSchema = zod.z.object({
22901
+ id: zod.z.string(),
22902
+ name: zod.z.string(),
22903
+ kind: ZoneKindEnum.default("polygon"),
22904
+ /** Polygon vertices, fraction of frame (0–1). */
22905
+ polygon: zod.z.array(PolygonPointSchema).readonly(),
22906
+ /** Visual color for UI rendering. */
22907
+ color: zod.z.string().default("#3b82f6")
22908
+ });
22909
+ /**
22910
+ * Zones capability — per-camera CRUD over polygon detection zones.
22911
+ *
22912
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
22913
+ * to per-device settings and mirrors into the `zones` device-state
22914
+ * slice on every mutation, so downstream consumers can subscribe via
22915
+ * `dev.state.zones.onChanged`.
22916
+ *
22917
+ * The cap surface only handles geometry + identity; filtering
22918
+ * behaviour (per-class, include/exclude, threshold) lives in the
22919
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
22920
+ * `capabilities/schemas/zone-rule.js`.
22921
+ */
22922
+ var zonesCapability = {
22923
+ name: "zones",
22924
+ scope: "device",
22925
+ mode: "singleton",
22926
+ deviceTypes: [DeviceType.Camera],
22927
+ methods: {
22928
+ listZones: method(zod.z.object({ deviceId: zod.z.number() }), zod.z.array(ZoneSchema).readonly()),
22929
+ addZone: method(zod.z.object({
22930
+ deviceId: zod.z.number(),
22931
+ zone: ZoneSchema
22932
+ }), zod.z.void(), {
22933
+ kind: "mutation",
22934
+ auth: "admin"
22935
+ }),
22936
+ removeZone: method(zod.z.object({
22937
+ deviceId: zod.z.number(),
22938
+ zoneId: zod.z.string()
22939
+ }), zod.z.void(), {
22940
+ kind: "mutation",
22941
+ auth: "admin"
22942
+ }),
22943
+ updateZone: method(zod.z.object({
22944
+ deviceId: zod.z.number(),
22945
+ zone: ZoneSchema
22946
+ }), zod.z.void(), {
22947
+ kind: "mutation",
22948
+ auth: "admin"
22949
+ })
22950
+ },
22951
+ /**
22952
+ * Runtime-state slice — the live zone catalogue mirrored by the
22953
+ * orchestrator on every CRUD mutation. Consumers read via
22954
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
22955
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
22956
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
22957
+ * (e.g. zone groupings) can sit alongside the polygon list.
22958
+ */
22959
+ runtimeState: zod.z.object({ zones: zod.z.array(ZoneSchema).readonly() }),
22960
+ /**
22961
+ * Runtime-state durability: **restored** — written only on operator mutation, so a camera that never had one has nothing to re-derive from. This is the slice `zone-mirror-hydration.ts` exists to paper over.
22962
+ *
22963
+ * See `RuntimeStateDurability`. Enforced by
22964
+ * `scripts/check-runtime-state-durability.ts`.
22965
+ */
22966
+ durability: "restored"
22967
+ };
22968
+ /**
22560
22969
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
22561
22970
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
22562
22971
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -23008,6 +23417,17 @@ var RunnerFrameSourceSchema = zod.z.discriminatedUnion("kind", [zod.z.object({ k
23008
23417
  hubHostnameOverride: zod.z.string().optional()
23009
23418
  })]).describe("Per-camera frame-source mode for the runner (P2c)");
23010
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
+ /**
23011
23431
  * One ENABLED inference device on the runner's node, as the step-tree
23012
23432
  * device-jump resolver sees it (phase 1). The orchestrator populates this
23013
23433
  * roster on the attach payload whenever the camera is elected onto a specific
@@ -23019,7 +23439,16 @@ var RunnerFrameSourceSchema = zod.z.discriminatedUnion("kind", [zod.z.object({ k
23019
23439
  var RunnerInferenceDeviceSchema = zod.z.object({
23020
23440
  deviceKey: zod.z.string(),
23021
23441
  weight: zod.z.number().positive().default(1),
23022
- 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()
23023
23452
  });
23024
23453
  /**
23025
23454
  * Camera assignment payload sent by `addon-pipeline-orchestrator` to a
@@ -24116,6 +24545,28 @@ var NodeInferenceDeviceSchema = zod.z.object({
24116
24545
  */
24117
24546
  exclusion: InferenceDeviceExclusionReasonSchema.nullable()
24118
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
+ ]);
24119
24570
  var NodeInferenceDevicesSchema = zod.z.object({
24120
24571
  nodeId: zod.z.string(),
24121
24572
  /** False when the node's platform-probe was unreachable (no live device set). */
@@ -24212,9 +24663,19 @@ var pipelineOrchestratorCapability = {
24212
24663
  * Trigger a full rebalance pass. Iterates over all assigned cameras,
24213
24664
  * recomputes the optimal agent for each one based on current load +
24214
24665
  * hardware affinity, and migrates cameras whose current agent is no
24215
- * longer optimal. Pinned cameras are never migrated.
24216
- */
24217
- 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
+ }), {
24218
24679
  kind: "mutation",
24219
24680
  auth: "admin"
24220
24681
  }),
@@ -24224,6 +24685,13 @@ var pipelineOrchestratorCapability = {
24224
24685
  getPipelineAssignment: method(zod.z.object({ deviceId: zod.z.number() }), PipelineAssignmentSchema.nullable()),
24225
24686
  /** Get per-agent load summaries used by the load balancer + dashboards. */
24226
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),
24227
24695
  /** Aggregate global metrics across the whole detection cluster. */
24228
24696
  getGlobalMetrics: method(zod.z.void(), GlobalMetricsSchema),
24229
24697
  /**
@@ -26694,6 +27162,20 @@ var VectorScanResultSchema = zod.z.object({
26694
27162
  */
26695
27163
  nextCursor: zod.z.number().int().nonnegative().nullable()
26696
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
+ }
26697
27179
  var VectorStatsInputSchema = zod.z.object({ index: zod.z.string() });
26698
27180
  var VectorStatsResultSchema = zod.z.object({
26699
27181
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -27552,6 +28034,424 @@ var videoclipsCapability = {
27552
28034
  }
27553
28035
  };
27554
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
+ /**
27555
28455
  * Optional client-side hints sent at session creation to help the provider
27556
28456
  * pick the best native source. All fields optional — a viewer that knows
27557
28457
  * nothing still gets a sane default. (Relocated from the retired `webrtc`
@@ -30452,75 +31352,6 @@ onStatusChanged: { data: zod.z.object({
30452
31352
  volatileStateFields: ["lastChangedAt"]
30453
31353
  };
30454
31354
  /**
30455
- * Doorbell button cap. Two kinds of providers coexist behind this cap
30456
- * name (same pattern as `snapshot`):
30457
- *
30458
- * - **Native** providers: registered per-device by device-driver
30459
- * addons via `ctx.registerNativeCap` — either on a
30460
- * `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
30461
- * or directly on the camera (Reolink registers at camera level).
30462
- * Emits an `onPressed` event every time the firmware pushes a
30463
- * ring; status tracks the last press and a pressCount since start
30464
- * (diagnostic).
30465
- *
30466
- * - **Wrapper** provider: the `virtual-doorbell` system builtin
30467
- * (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
30468
- * device (contact / switch / event-emitter …) into a doorbell for
30469
- * a camera. `defaultActive: false` — the operator explicitly binds
30470
- * it per camera in the device-bindings UI, then picks the source
30471
- * device + trigger in the per-device settings.
30472
- *
30473
- * The DeviceEventPropagator re-emits `onPressed` on the camera parent
30474
- * — subscribers listening at the camera level receive ring events
30475
- * with `via[]` populated. No code on the parent needed.
30476
- */
30477
- var DoorbellStatusSchema = zod.z.object({
30478
- /** Ms epoch of the last press. null = never observed since this provider started. */
30479
- lastPressedAt: zod.z.number().nullable(),
30480
- /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
30481
- pressCountSinceStart: zod.z.number()
30482
- });
30483
- var DoorbellPressEventSchema = zod.z.object({
30484
- deviceId: zod.z.number(),
30485
- timestamp: zod.z.number()
30486
- });
30487
- var doorbellCapability = {
30488
- name: "doorbell",
30489
- scope: "device",
30490
- deviceNative: true,
30491
- mode: "singleton",
30492
- kind: "wrapper",
30493
- defaultActive: false,
30494
- deviceTypes: [DeviceType.Button, DeviceType.Camera],
30495
- exposesDeviceSettings: true,
30496
- methods: {},
30497
- events: {
30498
- /**
30499
- * Fires once per physical press. Reolink delivers via Baichuan
30500
- * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
30501
- * release/duration — it's a pulse.
30502
- */
30503
- onPressed: { data: DoorbellPressEventSchema } },
30504
- status: {
30505
- schema: DoorbellStatusSchema,
30506
- kind: "push"
30507
- },
30508
- /**
30509
- * Runtime-state slice — last press timestamp + lifetime press count.
30510
- * Mirrored by the kernel and readable via
30511
- * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
30512
- * without subscribing.
30513
- */
30514
- runtimeState: DoorbellStatusSchema,
30515
- /**
30516
- * 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.
30517
- *
30518
- * See `RuntimeStateDurability`. Enforced by
30519
- * `scripts/check-runtime-state-durability.ts`.
30520
- */
30521
- durability: "restored"
30522
- };
30523
- /**
30524
31355
  * Enum-state sensor — a string value picked from a finite option set.
30525
31356
  * Drives HA `sensor` entries with `state_class: enum` (HVAC action
30526
31357
  * states, weather conditions, contact-source channels, mode strings).
@@ -34992,7 +35823,7 @@ var HardwareInfoSchema = zod.z.object({
34992
35823
  coral: CoralInfoSchema.nullable().optional()
34993
35824
  });
34994
35825
  var PlatformScoreSchema = zod.z.object({
34995
- runtime: zod.z.enum(["node", "python"]),
35826
+ runtime: zod.z.literal("python"),
34996
35827
  backend: zod.z.string(),
34997
35828
  format: zod.z.enum([
34998
35829
  "onnx",
@@ -35029,7 +35860,7 @@ var ModelRequirementSchema = zod.z.object({
35029
35860
  });
35030
35861
  var ResolvedInferenceConfigSchema = zod.z.object({
35031
35862
  modelId: zod.z.string(),
35032
- runtime: zod.z.enum(["node", "python"]),
35863
+ runtime: zod.z.literal("python"),
35033
35864
  backend: zod.z.string(),
35034
35865
  format: ModelFormatSchema,
35035
35866
  reason: zod.z.string()
@@ -38152,6 +38983,92 @@ var sceneMonitorCapability = {
38152
38983
  durability: "session"
38153
38984
  };
38154
38985
  /**
38986
+ * Per-stage gating mode applied to the zones a rule references.
38987
+ *
38988
+ * - `include`: the rule contributes to a **whitelist** for its stage.
38989
+ * When at least one `include` rule fires for a stage, only entities
38990
+ * inside one of those zones pass that stage.
38991
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
38992
+ * Entities inside one of those zones are dropped at that stage.
38993
+ *
38994
+ * `monitor`-style observation (count without filtering) is not a rule
38995
+ * mode — zones without any matching rule are observed naturally by
38996
+ * `zone-analytics` (live snapshot + history), so an "I just want to
38997
+ * count, not filter" use case needs no rule at all.
38998
+ */
38999
+ var ZoneRuleModeEnum = zod.z.enum(["include", "exclude"]);
39000
+ /**
39001
+ * Per-consumer rule that references existing zones (geometry) and
39002
+ * defines how a specific pipeline stage should treat them. Each
39003
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
39004
+ * settings:
39005
+ *
39006
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
39007
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
39008
+ * - future: notification rules, audio gating, etc.
39009
+ *
39010
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
39011
+ * express "ignore motion in ALL of {garden, street}" with a single
39012
+ * rule. `classFilter` narrows the rule to specific object classes —
39013
+ * "drop person detections in the street, but keep cars" is one
39014
+ * `exclude` rule with `classFilter: ['person']`.
39015
+ *
39016
+ * `enabled` is a soft toggle — the operator can keep the rule
39017
+ * configured but inert without deleting it.
39018
+ */
39019
+ var ZoneRuleSchema = zod.z.object({
39020
+ /** Stable rule id — survives edits, used by the UI for diffing. */
39021
+ id: zod.z.string(),
39022
+ /** Optional human-readable label rendered in the rule editor. */
39023
+ name: zod.z.string().optional(),
39024
+ /** Zones this rule targets. The rule's `mode` applies to ALL
39025
+ * listed zones (OR-set: a detection in any one of them counts).
39026
+ * At least one zone id required — a rule with no targets is a
39027
+ * configuration mistake and the form validator rejects it. */
39028
+ zoneIds: zod.z.array(zod.z.string()).min(1).readonly(),
39029
+ mode: ZoneRuleModeEnum,
39030
+ /**
39031
+ * Class names this rule applies to. Empty / undefined ⇒ rule
39032
+ * applies to every class. Class strings match the `macroClass`
39033
+ * field on detections (e.g. `person`, `car`, `dog`).
39034
+ */
39035
+ classFilter: zod.z.array(zod.z.string()).readonly().optional(),
39036
+ /**
39037
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
39038
+ * required to consider an entity "in the zone". Defaults to the
39039
+ * consumer's stage default when omitted. Kept for back-compat with
39040
+ * existing per-rule overrides; new operators pick the value via
39041
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
39042
+ * set, the lower-level engine reads it as a 0–1 fraction.
39043
+ */
39044
+ overlapThreshold: zod.z.number().min(0).max(1).optional(),
39045
+ /**
39046
+ * Operator-friendly version of `overlapThreshold` — the percentage
39047
+ * of the detection's bbox that must lie inside the zone for the
39048
+ * rule to match. Documented default is 85%; the engine substitutes
39049
+ * that when the field is omitted (kept optional so existing rules
39050
+ * stored without it stay valid).
39051
+ *
39052
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
39053
+ * rule, the engine prefers `bboxInclusionPct` because it's the
39054
+ * field exposed in the UI. Internally both feed the same gate.
39055
+ */
39056
+ bboxInclusionPct: zod.z.number().min(0).max(100).optional(),
39057
+ /**
39058
+ * When `true` and a detection has a segmentation mask, use the
39059
+ * mask for overlap instead of the bbox. Detection-stage only;
39060
+ * motion rules ignore this field.
39061
+ */
39062
+ preferMask: zod.z.boolean().optional(),
39063
+ /**
39064
+ * Soft-toggle: `false` disables the rule without deleting it.
39065
+ * Defaults to `true` so operators creating a rule via the UI
39066
+ * see it active immediately.
39067
+ */
39068
+ enabled: zod.z.boolean().default(true)
39069
+ });
39070
+ zod.z.array(ZoneRuleSchema).readonly();
39071
+ /**
38155
39072
  * Script-runner cap. Models HA `script.*` entities on
38156
39073
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
38157
39074
  * that can be invoked imperatively — optionally with a variables
@@ -40589,168 +41506,86 @@ var zoneRulesCapability = {
40589
41506
  */
40590
41507
  durability: "restored"
40591
41508
  };
40592
- /**
40593
- * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
40594
- * valutatore puro del suo FRONTE.
40595
- *
40596
- * Viveva dentro il builtin virtual-doorbell
40597
- * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
40598
- * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
40599
- * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
40600
- * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
40601
- * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
40602
- * SPOSTA qui e il doorbell la ri-esporta.
40603
- *
40604
- * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
40605
- * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
40606
- * regola" (e include `presence`, `cover`, `alarm-panel`), questa a "qual è il
40607
- * booleano il cui FRONTE conta". Vocabolari deliberatamente diversi.
40608
- */
40609
- /**
40610
- * Known binary / switch source caps → the boolean slice field whose
40611
- * false→true rise counts as ACTIVE. Every entry is "fire on active".
40612
- * Sensors whose "active" reading is not a plain boolean (presence's string
40613
- * state, connectivity's connected flag) are deliberately excluded — a
40614
- * reconnect is not a doorbell press, and it is not a recording either.
40615
- */
40616
- var SOURCE_CAP_ACTIVE_FIELD = {
40617
- contact: "entryOpen",
40618
- binary: "on",
40619
- switch: "on",
40620
- motion: "detected",
40621
- flood: "flooded",
40622
- gas: "detected",
40623
- smoke: "detected",
40624
- "carbon-monoxide": "detected",
40625
- vibration: "detected",
40626
- tamper: "tampered"
40627
- };
40628
- /**
40629
- * The same caps → the slice field carrying the ms-epoch timestamp of the
40630
- * last transition. Every source cap MUST appear here (guarded by a spec):
40631
- * without a transition timestamp the evaluator cannot tell a genuine rise
40632
- * from a boot-time hydration when the FIRST slice it ever sees is already
40633
- * active, and errs towards silence — swallowing the rise.
40634
- *
40635
- * These timestamps are UPSTREAM ones, not ingest ones: the Home Assistant
40636
- * provider derives them from `state.last_changed`, so they survive our own
40637
- * restarts and correctly read as "hours ago" for a state that has been
40638
- * active for hours. `motion` names its rise timestamp `lastDetectedAt`.
40639
- */
40640
- var SOURCE_CAP_CHANGED_AT_FIELD = {
40641
- contact: "lastChangedAt",
40642
- binary: "lastChangedAt",
40643
- switch: "lastChangedAt",
40644
- motion: "lastDetectedAt",
40645
- flood: "lastChangedAt",
40646
- gas: "lastChangedAt",
40647
- smoke: "lastChangedAt",
40648
- "carbon-monoxide": "lastChangedAt",
40649
- vibration: "lastChangedAt",
40650
- tamper: "lastChangedAt"
40651
- };
40652
- /** Cap names whose presence in a device's bindings qualify it as a source. */
40653
- var SOURCE_CAPS = Object.keys(SOURCE_CAP_ACTIVE_FIELD);
40654
- /**
40655
- * Device `type` values (from `DeviceType`) that can host a binary/switch
40656
- * source cap. Used by the camera's `device-multiselect` picker as the
40657
- * CLIENT-SIDE filter, alongside `SOURCE_CAPS`.
40658
- *
40659
- * Why types and not caps alone: the shared picker filters
40660
- * `deviceManager.listAll` rows client-side, and those rows carry only the
40661
- * device's advertised `features` — NOT its registered cap list. On the live
40662
- * cluster binary sensors and switches advertise EMPTY features (features
40663
- * mirror only a handful of caps like `motion-trigger`), so a caps-only
40664
- * filter matched against `features` would list nothing (the very bug this
40665
- * replaced, which relied on the now-empty `getAllBindings`). Matching by
40666
- * `type` is the reliable client-side signal; the union with `SOURCE_CAPS`
40667
- * still captures any device that DOES advertise a source-cap feature.
40668
- * `sensor` covers contact/motion/flood/gas/smoke/CO/vibration/tamper,
40669
- * `switch` covers switches, `control` covers generic binary actuators.
40670
- */
40671
- var SOURCE_DEVICE_TYPES = [
40672
- "sensor",
40673
- "switch",
40674
- "control"
40675
- ];
40676
- /** True when a cap is a recognised binary/switch source. */
40677
- function isSourceCap(capName) {
40678
- return Object.prototype.hasOwnProperty.call(SOURCE_CAP_ACTIVE_FIELD, capName);
41509
+ function isValueOf(slot, value) {
41510
+ return value.slot === slot;
40679
41511
  }
40680
- /** Extract the "active" boolean a source cap's slice carries, or null when
40681
- * the cap is unknown or the field is missing / non-boolean. */
40682
- function sliceActiveValue(capName, slice) {
40683
- const field = SOURCE_CAP_ACTIVE_FIELD[capName];
40684
- if (field === void 0) return null;
40685
- const raw = slice[field];
40686
- 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
+ };
40687
41531
  }
40688
- /** Ms-epoch transition timestamp a source cap's slice carries, or null when
40689
- * it is absent, non-numeric or the zero "never observed" sentinel. */
40690
- function sliceChangedAt(capName, slice) {
40691
- const field = SOURCE_CAP_CHANGED_AT_FIELD[capName];
40692
- if (field === void 0) return null;
40693
- const raw = slice[field];
40694
- if (typeof raw !== "number" || !Number.isFinite(raw) || raw <= 0) return null;
40695
- return raw;
41532
+ /** `<source>:<slotId>`. */
41533
+ function extensionSlotRef(source, slot) {
41534
+ return `${source}:${slot}`;
40696
41535
  }
40697
- /**
40698
- * How recent a source's own transition timestamp must be for a FIRST
40699
- * sighting that is already active to count as a genuine rise rather than a
40700
- * hydration of long-standing state.
40701
- */
40702
- var DEFAULT_FIRST_SIGHTING_FRESHNESS_MS = 3e4;
40703
- /**
40704
- * IL fronte. Puro: nessun orologio proprio, nessuna memoria — il chiamante
40705
- * porta `prior`, `nowMs` e il proprio `startedAtMs`.
40706
- *
40707
- * Il caso della PRIMA slice già attiva è trattato esplicitamente e vale come
40708
- * fronte solo se il timestamp UPSTREAM della transizione è posteriore a
40709
- * `startedAtMs` **e** entro `firstSightingFreshnessMs`. Entrambe le metà
40710
- * servono: la sola freschezza scatterebbe su un'idratazione al boot di uno
40711
- * stato flippato pochi secondi prima del riavvio, e il solo "dopo che abbiamo
40712
- * iniziato" scatterebbe, su un processo di lunga vita, per una sorgente
40713
- * adottata oggi il cui stato è cambiato ieri. Il caso ambiguo ERRA VERSO IL
40714
- * SILENZIO e lo dichiara (`baseline-seeded-stale-active`).
40715
- */
40716
- function evaluateSensorEdge(input) {
40717
- const value = sliceActiveValue(input.capName, input.slice);
40718
- if (value === null) return {
40719
- edge: "none",
40720
- value: null,
40721
- reason: isSourceCap(input.capName) ? "non-boolean-value" : "unknown-cap"
40722
- };
40723
- if (input.prior === void 0) {
40724
- if (!value) return {
40725
- edge: "none",
40726
- value,
40727
- reason: "baseline-seeded-inactive"
40728
- };
40729
- const changedAt = sliceChangedAt(input.capName, input.slice);
40730
- const floor = Math.max(input.startedAtMs, input.nowMs - input.firstSightingFreshnessMs);
40731
- if (changedAt === null || changedAt < floor) return {
40732
- edge: "none",
40733
- value,
40734
- reason: "baseline-seeded-stale-active"
40735
- };
40736
- return {
40737
- edge: "rising",
40738
- value: true
40739
- };
40740
- }
40741
- if (input.prior === value) return {
40742
- edge: "none",
40743
- value,
40744
- reason: "no-change"
40745
- };
40746
- if (!value) return {
40747
- edge: "none",
40748
- value,
40749
- 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;
40750
41547
  };
40751
41548
  return {
40752
- edge: "rising",
40753
- 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
+ }
40754
41589
  };
40755
41590
  }
40756
41591
  /**
@@ -43646,6 +44481,7 @@ var ALL_CAPABILITY_DEFINITIONS = [
43646
44481
  deviceAdoptionCapability,
43647
44482
  deviceDiscoveryCapability,
43648
44483
  deviceExportCapability,
44484
+ deviceExtensionCapability,
43649
44485
  deviceManagerCapability,
43650
44486
  deviceOpsCapability,
43651
44487
  deviceProviderCapability,
@@ -45194,6 +46030,30 @@ var METHOD_ACCESS_MAP = Object.freeze({
45194
46030
  addonId: null,
45195
46031
  access: "create"
45196
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
+ },
45197
46057
  "deviceManager.addLocation": {
45198
46058
  capName: "device-manager",
45199
46059
  capScope: "system",
@@ -45944,6 +46804,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
45944
46804
  addonId: null,
45945
46805
  access: "view"
45946
46806
  },
46807
+ "embeddingEncoder.resetFailedModels": {
46808
+ capName: "embedding-encoder",
46809
+ capScope: "system",
46810
+ addonId: null,
46811
+ access: "delete"
46812
+ },
45947
46813
  "enumSensor.getStatus": {
45948
46814
  capName: "enum-sensor",
45949
46815
  capScope: "device",
@@ -47330,6 +48196,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
47330
48196
  addonId: null,
47331
48197
  access: "view"
47332
48198
  },
48199
+ "notificationRules.previewStateSummary": {
48200
+ capName: "notification-rules",
48201
+ capScope: "system",
48202
+ addonId: null,
48203
+ access: "view"
48204
+ },
47333
48205
  "notificationRules.previewTemplate": {
47334
48206
  capName: "notification-rules",
47335
48207
  capScope: "system",
@@ -47906,12 +48778,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
47906
48778
  addonId: null,
47907
48779
  access: "create"
47908
48780
  },
47909
- "pipelineAnalytics.runReplayFrameProcessor": {
47910
- capName: "pipeline-analytics",
47911
- capScope: "device",
47912
- addonId: null,
47913
- access: "create"
47914
- },
47915
48781
  "pipelineAnalytics.saveRetrainAnnotations": {
47916
48782
  capName: "pipeline-analytics",
47917
48783
  capScope: "device",
@@ -48278,6 +49144,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
48278
49144
  addonId: null,
48279
49145
  access: "view"
48280
49146
  },
49147
+ "pipelineOrchestrator.getClusterModelChoice": {
49148
+ capName: "pipeline-orchestrator",
49149
+ capScope: "system",
49150
+ addonId: null,
49151
+ access: "view"
49152
+ },
48281
49153
  "pipelineOrchestrator.getDeviceLiveContribution": {
48282
49154
  capName: "pipeline-orchestrator",
48283
49155
  capScope: "system",
@@ -51103,6 +51975,26 @@ Object.freeze({
51103
51975
  form: "single",
51104
51976
  optional: false
51105
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
+ }],
51106
51998
  "deviceManager.adoptionRelease": [{
51107
51999
  name: "camDeviceId",
51108
52000
  form: "single",
@@ -52009,11 +52901,6 @@ Object.freeze({
52009
52901
  form: "single",
52010
52902
  optional: false
52011
52903
  }],
52012
- "pipelineAnalytics.runReplayFrameProcessor": [{
52013
- name: "deviceId",
52014
- form: "single",
52015
- optional: false
52016
- }],
52017
52904
  "pipelineAnalytics.saveRetrainAnnotations": [{
52018
52905
  name: "deviceId",
52019
52906
  form: "single",
@@ -53293,6 +54180,98 @@ new Map(Object.entries({
53293
54180
  "camera-enabled": null
53294
54181
  }));
53295
54182
  [...NC_SYSTEM_EVENT_FILTER_KEYS];
54183
+ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
54184
+ {
54185
+ id: "device-state",
54186
+ family: "device-events",
54187
+ label: "Device state",
54188
+ kinds: [
54189
+ "device-offline",
54190
+ "device-online",
54191
+ "device-disabled",
54192
+ "device-enabled"
54193
+ ]
54194
+ },
54195
+ {
54196
+ id: "streams",
54197
+ family: "device-events",
54198
+ label: "Streams",
54199
+ kinds: ["stream-offline", "stream-online"]
54200
+ },
54201
+ {
54202
+ id: "battery",
54203
+ family: "device-events",
54204
+ label: "Battery",
54205
+ kinds: ["device-battery-low", "device-battery-normal"]
54206
+ },
54207
+ {
54208
+ id: "consumables",
54209
+ family: "device-events",
54210
+ label: "Consumables",
54211
+ kinds: ["device-consumable-low", "device-consumable-normal"]
54212
+ },
54213
+ {
54214
+ id: "tanks",
54215
+ family: "device-events",
54216
+ label: "Tanks",
54217
+ kinds: [
54218
+ "device-tank-low",
54219
+ "device-tank-full",
54220
+ "device-tank-normal"
54221
+ ]
54222
+ },
54223
+ {
54224
+ id: "detection-blind",
54225
+ family: "device-events",
54226
+ label: "Detecting nothing",
54227
+ kinds: ["detection-blind"]
54228
+ },
54229
+ {
54230
+ id: "nodes",
54231
+ family: "system",
54232
+ label: "Nodes",
54233
+ kinds: [
54234
+ "node-offline",
54235
+ "node-online",
54236
+ "node-inference-unavailable"
54237
+ ]
54238
+ },
54239
+ {
54240
+ id: "addons",
54241
+ family: "system",
54242
+ label: "Addons",
54243
+ kinds: [
54244
+ "addon-crash-loop",
54245
+ "addon-update-available",
54246
+ "addon-updated"
54247
+ ]
54248
+ },
54249
+ {
54250
+ id: "updates",
54251
+ family: "system",
54252
+ label: "Server & container updates",
54253
+ kinds: [
54254
+ "server-update-available",
54255
+ "server-updated",
54256
+ "wrapper-update-available"
54257
+ ]
54258
+ },
54259
+ {
54260
+ id: "backups-exports",
54261
+ family: "system",
54262
+ label: "Backups & exports",
54263
+ kinds: ["backup-completed", "export-completed"]
54264
+ },
54265
+ {
54266
+ id: "alarm",
54267
+ family: "alarm",
54268
+ label: "Alarm",
54269
+ kinds: NC_ALARM_SYSTEM_EVENT_KINDS
54270
+ }
54271
+ ];
54272
+ function systemEventKindsOfFamily(family) {
54273
+ return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
54274
+ }
53296
54275
  NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
53297
54276
  /**
53298
54277
  * WHICH WAY A BOOLEAN SENSOR MOVED — read off the one slice a sensor event
@@ -53367,7 +54346,183 @@ var DEVICE_EVENTS = [
53367
54346
  "detection-blind",
53368
54347
  ...ALARM
53369
54348
  ];
53370
- [...DEVICE_EVENTS], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_BODY_ONLY], [...RULE_TEXT], [...RULE_TEXT], [...DEVICE_EVENTS], [...RULE_TEXT], [...DEVICE_EVENTS], [...RULE_TEXT], [...BATTERY, ...CONSUMABLE], [...RULE_TEXT], [...CONSUMABLE], [...RULE_TEXT], [...TANK], [...RULE_TEXT], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT];
54349
+ /** Every kind a summary may speak about — the two summarisable families. */
54350
+ var SUMMARISABLE = [...systemEventKindsOfFamily("device-events"), ...systemEventKindsOfFamily("system")];
54351
+ /** One per summary SECTION (`NC_STATE_SUMMARY_SECTIONS` in the notification
54352
+ * centre): the section's lines, offered when one of its kinds is selected. */
54353
+ var STATE_SUMMARY_SECTION_VARS = [
54354
+ {
54355
+ name: "summaryDevices",
54356
+ label: "Summary: devices offline / switched off",
54357
+ example: "Garage — offline since 07:12",
54358
+ kinds: [
54359
+ "device-offline",
54360
+ "device-online",
54361
+ "device-disabled",
54362
+ "device-enabled"
54363
+ ]
54364
+ },
54365
+ {
54366
+ name: "summaryStreams",
54367
+ label: "Summary: streams offline",
54368
+ example: "Ingresso (high) — since 06:40",
54369
+ kinds: ["stream-offline", "stream-online"]
54370
+ },
54371
+ {
54372
+ name: "summaryBattery",
54373
+ label: "Summary: low batteries",
54374
+ example: "Sensore porta — 8 %",
54375
+ kinds: BATTERY
54376
+ },
54377
+ {
54378
+ name: "summaryConsumables",
54379
+ label: "Summary: consumables",
54380
+ example: "Robot — filter 10 %",
54381
+ kinds: CONSUMABLE
54382
+ },
54383
+ {
54384
+ name: "summaryTanks",
54385
+ label: "Summary: tanks",
54386
+ example: "Robot — clean water low",
54387
+ kinds: TANK
54388
+ },
54389
+ {
54390
+ name: "summaryDetection",
54391
+ label: "Summary: cameras detecting nothing",
54392
+ example: "Ingresso — since 05:10",
54393
+ kinds: ["detection-blind"]
54394
+ },
54395
+ {
54396
+ name: "summaryNodes",
54397
+ label: "Summary: nodes",
54398
+ example: "little-unraid — offline since 03:00",
54399
+ kinds: [
54400
+ "node-offline",
54401
+ "node-online",
54402
+ "node-inference-unavailable"
54403
+ ]
54404
+ },
54405
+ {
54406
+ name: "summaryAddons",
54407
+ label: "Summary: addons",
54408
+ example: "@camstack/addon-recorder 1.2.3 → 1.2.4",
54409
+ kinds: [
54410
+ "addon-crash-loop",
54411
+ "addon-update-available",
54412
+ "addon-updated"
54413
+ ]
54414
+ },
54415
+ {
54416
+ name: "summaryUpdates",
54417
+ label: "Summary: server & container updates",
54418
+ example: "server 1.2.377 → 1.2.378",
54419
+ kinds: [
54420
+ "server-update-available",
54421
+ "server-updated",
54422
+ "wrapper-update-available"
54423
+ ]
54424
+ }
54425
+ ];
54426
+ var STATE_SUMMARY_VARS = [
54427
+ {
54428
+ name: "summaryText",
54429
+ label: "Summary: every section",
54430
+ description: "One block per section with something to report, one line per item.",
54431
+ example: "Batterie scariche: Sensore porta — 8 %",
54432
+ group: "system",
54433
+ families: ["rule"],
54434
+ fields: [...RULE_TEXT],
54435
+ kinds: ["system"],
54436
+ systemEventKinds: [...SUMMARISABLE],
54437
+ systemEventDeliveries: ["summary"]
54438
+ },
54439
+ {
54440
+ name: "summaryCount",
54441
+ label: "Summary: items reported",
54442
+ example: "3",
54443
+ group: "system",
54444
+ families: ["rule"],
54445
+ fields: [...RULE_TEXT],
54446
+ kinds: ["system"],
54447
+ systemEventKinds: [...SUMMARISABLE],
54448
+ systemEventDeliveries: ["summary"]
54449
+ },
54450
+ ...STATE_SUMMARY_SECTION_VARS.map((v) => ({
54451
+ name: v.name,
54452
+ label: v.label,
54453
+ example: v.example,
54454
+ group: "system",
54455
+ families: ["rule"],
54456
+ fields: [...RULE_TEXT],
54457
+ kinds: ["system"],
54458
+ systemEventKinds: [...v.kinds],
54459
+ systemEventDeliveries: ["summary"]
54460
+ }))
54461
+ ];
54462
+ [
54463
+ [...DEVICE_EVENTS],
54464
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
54465
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
54466
+ [...RULE_TEXT],
54467
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
54468
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
54469
+ [...RULE_TEXT],
54470
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
54471
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
54472
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
54473
+ [...RULE_TEXT],
54474
+ [...RULE_TEXT],
54475
+ [...RULE_TEXT],
54476
+ [...RULE_TEXT],
54477
+ [...RULE_TEXT],
54478
+ [...RULE_TEXT],
54479
+ [...RULE_TEXT],
54480
+ [...RULE_TEXT],
54481
+ [...RULE_BODY_ONLY],
54482
+ [...RULE_TEXT],
54483
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
54484
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
54485
+ ([...RULE_TEXT], [...BATTERY, ...CONSUMABLE]),
54486
+ ([...RULE_TEXT], [...CONSUMABLE]),
54487
+ ([...RULE_TEXT], [...TANK]),
54488
+ [...RULE_TEXT],
54489
+ ([...RULE_TEXT], [...UPDATES]),
54490
+ ([...RULE_TEXT], [...UPDATES]),
54491
+ [...RULE_TEXT],
54492
+ [...RULE_TEXT],
54493
+ [...RULE_TEXT],
54494
+ ([...RULE_TEXT], [...UPDATES]),
54495
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
54496
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
54497
+ ([...RULE_TEXT], [...UPDATES]),
54498
+ ([...RULE_TEXT], [...UPDATES]),
54499
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
54500
+ [...RULE_TEXT],
54501
+ [...RULE_TEXT],
54502
+ [...RULE_TEXT],
54503
+ [...RULE_TEXT],
54504
+ [...RULE_TEXT],
54505
+ [...RULE_TEXT],
54506
+ [...RULE_TEXT],
54507
+ [...RULE_TEXT],
54508
+ [...RULE_TEXT],
54509
+ [...RULE_TEXT],
54510
+ [...RULE_TEXT],
54511
+ [...RULE_TEXT],
54512
+ [...RULE_TEXT],
54513
+ [...RULE_TEXT],
54514
+ [...RULE_TEXT],
54515
+ [...RULE_TEXT],
54516
+ [...RULE_TEXT],
54517
+ [...RULE_TEXT],
54518
+ [...RULE_TEXT],
54519
+ [...RULE_TEXT],
54520
+ [...RULE_TEXT],
54521
+ [...RULE_TEXT],
54522
+ [...RULE_TEXT],
54523
+ [...RULE_TEXT],
54524
+ ...STATE_SUMMARY_VARS
54525
+ ];
53371
54526
  /**
53372
54527
  * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
53373
54528
  *
@@ -53599,68 +54754,6 @@ TimelapseRuleInputSchema.extend({
53599
54754
  createdAt: zod.z.number(),
53600
54755
  updatedAt: zod.z.number()
53601
54756
  });
53602
- Object.freeze(Object.fromEntries([{
53603
- stepId: "face-embedding",
53604
- label: "Face recognition model",
53605
- defaultModelId: "arcface-r100",
53606
- indexName: "the enrolled face gallery",
53607
- options: [
53608
- {
53609
- id: "arcface-r100",
53610
- label: "ArcFace (ResNet34)"
53611
- },
53612
- {
53613
- id: "auraface-r100",
53614
- label: "AuraFace R100"
53615
- },
53616
- {
53617
- id: "inception-resnet-v1",
53618
- label: "Inception ResNet V1"
53619
- }
53620
- ]
53621
- }, {
53622
- stepId: "clip-embedding",
53623
- label: "Semantic search model",
53624
- defaultModelId: "mobileclip-s1",
53625
- indexName: "the object semantic-search index",
53626
- options: [{
53627
- id: "mobileclip-s1",
53628
- label: "MobileCLIP S1"
53629
- }, {
53630
- id: "mobileclip-s2",
53631
- label: "MobileCLIP S2"
53632
- }]
53633
- }].map((s) => [s.stepId, s.defaultModelId])));
53634
- zod.z.string().min(1);
53635
- var CLUSTER_STEP_SETTING_FIELDS = [{
53636
- stepId: "face-embedding",
53637
- key: "minLandmarkFaceSize",
53638
- label: "Min face size for recognition (detection px)",
53639
- 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.",
53640
- type: "slider",
53641
- min: 0,
53642
- max: 64,
53643
- step: 2,
53644
- default: 24
53645
- }];
53646
- function clusterStepSettingKey(stepId, fieldKey) {
53647
- return `clusterStepSetting:${stepId}:${fieldKey}`;
53648
- }
53649
- var ClusterSettingNumberSchema = zod.z.number().finite();
53650
- function readClusterStepSettings(config) {
53651
- const out = {};
53652
- for (const field of CLUSTER_STEP_SETTING_FIELDS) {
53653
- const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
53654
- const value = parsed.success ? parsed.data : field.default;
53655
- const existing = out[field.stepId] ?? {};
53656
- out[field.stepId] = {
53657
- ...existing,
53658
- [field.key]: value
53659
- };
53660
- }
53661
- return out;
53662
- }
53663
- readClusterStepSettings({});
53664
54757
  zod.z.object({
53665
54758
  /**
53666
54759
  * Fraction of the box's own size added on EACH side before cutting.
@@ -54401,6 +55494,12 @@ Object.defineProperty(exports, "coreBlocksCapability", {
54401
55494
  return coreBlocksCapability;
54402
55495
  }
54403
55496
  });
55497
+ Object.defineProperty(exports, "createDeviceExtensionProvider", {
55498
+ enumerable: true,
55499
+ get: function() {
55500
+ return createDeviceExtensionProvider;
55501
+ }
55502
+ });
54404
55503
  Object.defineProperty(exports, "createEvent", {
54405
55504
  enumerable: true,
54406
55505
  get: function() {
@@ -54425,12 +55524,24 @@ Object.defineProperty(exports, "decodeVectorBase64", {
54425
55524
  return decodeVectorBase64;
54426
55525
  }
54427
55526
  });
55527
+ Object.defineProperty(exports, "defineExtensionSlotProvider", {
55528
+ enumerable: true,
55529
+ get: function() {
55530
+ return defineExtensionSlotProvider;
55531
+ }
55532
+ });
54428
55533
  Object.defineProperty(exports, "deriveBatteryPresence", {
54429
55534
  enumerable: true,
54430
55535
  get: function() {
54431
55536
  return deriveBatteryPresence;
54432
55537
  }
54433
55538
  });
55539
+ Object.defineProperty(exports, "deviceExtensionCapability", {
55540
+ enumerable: true,
55541
+ get: function() {
55542
+ return deviceExtensionCapability;
55543
+ }
55544
+ });
54434
55545
  Object.defineProperty(exports, "deviceManagerCapability", {
54435
55546
  enumerable: true,
54436
55547
  get: function() {
@@ -54887,6 +55998,12 @@ Object.defineProperty(exports, "vectorDimFromBase64", {
54887
55998
  return vectorDimFromBase64;
54888
55999
  }
54889
56000
  });
56001
+ Object.defineProperty(exports, "vectorIndexDimConflictError", {
56002
+ enumerable: true,
56003
+ get: function() {
56004
+ return vectorIndexDimConflictError;
56005
+ }
56006
+ });
54890
56007
  Object.defineProperty(exports, "vectorStoreCapability", {
54891
56008
  enumerable: true,
54892
56009
  get: function() {