@camstack/addon-provider-homeassistant 1.2.144 → 1.2.145

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.
@@ -5359,7 +5359,7 @@ var ZodIssueCode = {
5359
5359
  var ZodFirstPartyTypeKind;
5360
5360
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5361
5361
  //#endregion
5362
- //#region ../types/dist/sleep-pM_J7YnY.mjs
5362
+ //#region ../types/dist/sleep-BXv0ZcRa.mjs
5363
5363
  /**
5364
5364
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5365
5365
  * window to float samples (D455).
@@ -6144,6 +6144,40 @@ var BaseAddon = class {
6144
6144
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6145
6145
  return keys.size > 0 ? projectStore(raw, keys, node) : raw;
6146
6146
  }
6147
+ /**
6148
+ * Whether ONE global key of this addon's store was written, read three-way
6149
+ * (D651). For a question a hydrated view cannot answer: `getGlobalSettings`
6150
+ * reports `value ?? default`, so "the operator chose the default" and "nobody
6151
+ * chose" look the same, and a failed read looks like both. A `perNode` key is
6152
+ * not supported here: its stored name is scoped.
6153
+ */
6154
+ async readStoredGlobalKey(key) {
6155
+ const read = this._ctx?.settings?.readAddonStoreResult;
6156
+ if (read === void 0) return {
6157
+ kind: "unreadable",
6158
+ reason: "three-way-read-unavailable"
6159
+ };
6160
+ let result;
6161
+ try {
6162
+ result = await read.call(this._ctx?.settings);
6163
+ } catch (err) {
6164
+ return {
6165
+ kind: "unreadable",
6166
+ reason: "store-read-failed",
6167
+ error: err instanceof Error ? err.message : String(err)
6168
+ };
6169
+ }
6170
+ if (result.kind === "failed") return {
6171
+ kind: "unreadable",
6172
+ reason: "store-read-failed",
6173
+ error: result.error
6174
+ };
6175
+ if (result.kind === "missing" || !Object.prototype.hasOwnProperty.call(result.value, key)) return { kind: "absent" };
6176
+ return {
6177
+ kind: "present",
6178
+ value: result.value[key]
6179
+ };
6180
+ }
6147
6181
  async updateGlobalSettings(patch, nodeId) {
6148
6182
  const keys = this.perNodeKeys();
6149
6183
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
@@ -7399,11 +7433,17 @@ var RawStateResultSchema = object({
7399
7433
  method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(object({ deviceId: number() }), array(ConfigEntrySchema$1)), method(object({
7400
7434
  deviceId: number(),
7401
7435
  values: record(string(), unknown())
7402
- }), _void(), { kind: "mutation" }), method(object({
7436
+ }), _void(), {
7437
+ kind: "mutation",
7438
+ auth: "admin"
7439
+ }), method(object({
7403
7440
  deviceId: number(),
7404
7441
  action: string().min(1),
7405
7442
  input: unknown()
7406
- }), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
7443
+ }), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), {
7444
+ kind: "mutation",
7445
+ auth: "admin"
7446
+ }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
7407
7447
  //#endregion
7408
7448
  //#region ../types/dist/err-msg-IQTHeDzc.mjs
7409
7449
  /**
@@ -9599,6 +9639,43 @@ var LogChannelWindowSchema = object({
9599
9639
  /** `null` = every camera. A non-empty list narrows to those numeric ids. */
9600
9640
  deviceIds: array(number().int()).readonly().nullable()
9601
9641
  });
9642
+ var ClipModelMetaSchema = object({
9643
+ /** The paired text encoder's catalog id (the embedding-encoder's text catalog). */
9644
+ textModelId: string().min(1),
9645
+ /** Output dimension of BOTH towers. A vector of any other length is refused. */
9646
+ embeddingDim: number().int().positive(),
9647
+ /**
9648
+ * The `vector-store` index this model's vectors live in. ONE feature space
9649
+ * per index: two models share an index only when their vectors are ranked
9650
+ * against each other, which for CLIP means never across families. MobileCLIP
9651
+ * S1 and S2 share `object-clip` for history (separated by the row's
9652
+ * `modelId`); any other model gets its own.
9653
+ */
9654
+ vectorIndex: string().regex(/^object-clip(-[a-z0-9][a-z0-9-]*)?$/),
9655
+ /**
9656
+ * The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
9657
+ * must be unique per tokenizer: every model's siblings land in ONE flat
9658
+ * models directory, so two different tokenizers under the same name would
9659
+ * silently overwrite each other (whichever model downloaded last wins, and
9660
+ * the other one tokenises with the wrong vocabulary).
9661
+ */
9662
+ tokenizerFile: string().min(1),
9663
+ /** Token window the text graph takes (SigLIP2: 64; CLIP BPE: 77). */
9664
+ contextLength: number().int().positive(),
9665
+ /** Id the tokenizer pads with. */
9666
+ padId: number().int().nonnegative(),
9667
+ /**
9668
+ * The search cosine floor at `strictness: 'loose'` — calibrated per model,
9669
+ * because cosine bands are a property of the model: 0.2 keeps 96% of matched
9670
+ * COCO caption-image pairs on MobileCLIP S1 and 2.7% on SigLIP2.
9671
+ */
9672
+ searchMinScore: number().min(0).max(1)
9673
+ });
9674
+ var ClipSearchStrictnessSchema = _enum([
9675
+ "loose",
9676
+ "balanced",
9677
+ "strict"
9678
+ ]);
9602
9679
  var MODEL_FORMATS = [
9603
9680
  "onnx",
9604
9681
  "coreml",
@@ -9627,7 +9704,7 @@ var ModelFormatEntrySchema = object({
9627
9704
  /** Multi-file payload (directory members or sibling files). */
9628
9705
  files: array(string()).readonly().optional(),
9629
9706
  /** Runtime(s) that can use this format. If omitted, inferred from ModelFormat key */
9630
- runtimes: array(_enum(["node", "python"])).readonly().optional()
9707
+ runtimes: array(_enum(["python"])).readonly().optional()
9631
9708
  });
9632
9709
  /**
9633
9710
  * Extra file that must be downloaded alongside the model (e.g., labels JSON, dict.txt).
@@ -9708,10 +9785,17 @@ var ModelCatalogEntrySchema = object({
9708
9785
  inputChannels: number().int().positive().optional(),
9709
9786
  labels: array(LabelDefinitionSchema).readonly(),
9710
9787
  inputLayout: _enum(["nchw", "nhwc"]).optional(),
9788
+ /**
9789
+ * `'scrfd'` applies InsightFace's SCRFD input contract, `(x - 127.5) / 128`
9790
+ * (upstream `insightface/model_zoo/scrfd.py`), instead of the historical
9791
+ * plain `/255`. Measured against COCO GT: 188 → 196 faces found on the
9792
+ * `scrfd-2.5g` catalog entry (2026-09-26 model-replacement spike, §2.4-2).
9793
+ */
9711
9794
  inputNormalization: _enum([
9712
9795
  "zero-one",
9713
9796
  "imagenet",
9714
- "none"
9797
+ "none",
9798
+ "scrfd"
9715
9799
  ]).optional(),
9716
9800
  /**
9717
9801
  * The model already applies softmax IN-GRAPH — its raw output is a
@@ -9795,7 +9879,14 @@ var ModelCatalogEntrySchema = object({
9795
9879
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
9796
9880
  * labels already ARE the CamStack macros (Scrypted identity map).
9797
9881
  */
9798
- classMap: DetectionCatalogClassMapSchema.optional()
9882
+ classMap: DetectionCatalogClassMapSchema.optional(),
9883
+ /**
9884
+ * The model's CLIP feature-space contract (text encoder, dimension, vector
9885
+ * index, token window, search floor) — see `clip-model.ts`. Present ONLY on a
9886
+ * CLIP image encoder; its absence is what "not a CLIP model" means to the
9887
+ * embedding encoder and the semantic-search store (D649).
9888
+ */
9889
+ clip: ClipModelMetaSchema.optional()
9799
9890
  });
9800
9891
  var ConvertTargetSchema = discriminatedUnion("format", [object({
9801
9892
  format: literal("openvino"),
@@ -9813,7 +9904,8 @@ var ModelConvertMetadataSchema = object({
9813
9904
  inputNormalization: _enum([
9814
9905
  "zero-one",
9815
9906
  "imagenet",
9816
- "none"
9907
+ "none",
9908
+ "scrfd"
9817
9909
  ]).optional(),
9818
9910
  preprocessMode: _enum(["letterbox", "resize"]).optional(),
9819
9911
  outputFormat: _enum([
@@ -11844,7 +11936,7 @@ var brokerCapability = {
11844
11936
  }),
11845
11937
  /** Read the broker's cached state for a key. Returns `null` when
11846
11938
  * unknown to the broker (never published / unknown entity). */
11847
- getState: method(GetStateInputSchema, unknown().nullable()),
11939
+ getState: method(GetStateInputSchema, unknown().nullable(), { auth: "admin" }),
11848
11940
  /** Status method — explicit registration with a `z.void()` input so
11849
11941
  * the codegen-generated tRPC router types its input as
11850
11942
  * `{addonId?: string, nodeId?: string}` (system-scoped collection
@@ -13034,17 +13126,20 @@ method(object({
13034
13126
  namespace: string().optional(),
13035
13127
  collection: string(),
13036
13128
  key: string()
13037
- }), unknown()), method(object({
13129
+ }), unknown(), { auth: "admin" }), method(object({
13038
13130
  namespace: string().optional(),
13039
13131
  collection: string(),
13040
13132
  key: string(),
13041
13133
  value: unknown()
13042
- }), _void(), { kind: "mutation" }), method(object({
13134
+ }), _void(), {
13135
+ kind: "mutation",
13136
+ auth: "admin"
13137
+ }), method(object({
13043
13138
  namespace: string().optional(),
13044
13139
  collection: string(),
13045
13140
  filter: QueryFilterSchema.optional(),
13046
13141
  columns: array(string()).readonly().optional()
13047
- }), array(SettingsRecordSchema).readonly()), method(object({
13142
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
13048
13143
  namespace: string().optional(),
13049
13144
  collection: string(),
13050
13145
  /** Declared columns identifying the slot; must be covered by a UNIQUE
@@ -13054,7 +13149,10 @@ method(object({
13054
13149
  }), object({
13055
13150
  /** The id the row HAS: assigned by SQLite on an insert, or the existing
13056
13151
  * row's own id on an update. */
13057
- id: union([string(), number()]) }), { kind: "mutation" }), method(object({
13152
+ id: union([string(), number()]) }), {
13153
+ kind: "mutation",
13154
+ auth: "admin"
13155
+ }), method(object({
13058
13156
  namespace: string().optional(),
13059
13157
  collection: string(),
13060
13158
  record: object({
@@ -13067,38 +13165,56 @@ id: union([string(), number()]) }), { kind: "mutation" }), method(object({
13067
13165
  * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
13068
13166
  * primary key — which is the only place an auto key is knowable.
13069
13167
  */
13070
- id: union([string(), number()]) }), { kind: "mutation" }), method(object({
13168
+ id: union([string(), number()]) }), {
13169
+ kind: "mutation",
13170
+ auth: "admin"
13171
+ }), method(object({
13071
13172
  namespace: string().optional(),
13072
13173
  collection: string(),
13073
13174
  records: array(BulkRecordSchema).readonly()
13074
- }), object({ inserted: number().int() }), { kind: "mutation" }), method(object({
13175
+ }), object({ inserted: number().int() }), {
13176
+ kind: "mutation",
13177
+ auth: "admin"
13178
+ }), method(object({
13075
13179
  namespace: string().optional(),
13076
13180
  collection: string(),
13077
13181
  id: string(),
13078
13182
  data: record(string(), unknown())
13079
- }), _void(), { kind: "mutation" }), method(object({
13183
+ }), _void(), {
13184
+ kind: "mutation",
13185
+ auth: "admin"
13186
+ }), method(object({
13080
13187
  namespace: string().optional(),
13081
13188
  collection: string(),
13082
13189
  key: string()
13083
- }), _void(), { kind: "mutation" }), method(object({
13190
+ }), _void(), {
13191
+ kind: "mutation",
13192
+ auth: "admin"
13193
+ }), method(object({
13084
13194
  namespace: string().optional(),
13085
13195
  collection: string(),
13086
13196
  filter: MutationFilterSchema
13087
- }), object({ deleted: number().int() }), { kind: "mutation" }), method(object({
13197
+ }), object({ deleted: number().int() }), {
13198
+ kind: "mutation",
13199
+ auth: "admin"
13200
+ }), method(object({
13088
13201
  namespace: string().optional(),
13089
13202
  collection: string(),
13090
13203
  filter: MutationFilterSchema,
13091
13204
  data: record(string(), unknown())
13092
- }), object({ updated: number().int() }), { kind: "mutation" }), method(object({
13205
+ }), object({ updated: number().int() }), {
13206
+ kind: "mutation",
13207
+ auth: "admin"
13208
+ }), method(object({
13093
13209
  namespace: string().optional(),
13094
13210
  collection: string(),
13095
13211
  filter: QueryFilterSchema.optional()
13096
- }), number()), method(object({
13212
+ }), number(), { auth: "admin" }), method(object({
13097
13213
  namespace: string().optional(),
13098
13214
  collection: string(),
13099
13215
  fields: array(AggregateFieldSchema).readonly(),
13100
13216
  filter: QueryFilterSchema.optional()
13101
- }), AggregateResultSchema), method(object({
13217
+ }), AggregateResultSchema, { auth: "admin" }), method(object({
13102
13218
  namespace: string().optional(),
13103
13219
  collection: string(),
13104
13220
  field: string(),
@@ -13108,15 +13224,18 @@ id: union([string(), number()]) }), { kind: "mutation" }), method(object({
13108
13224
  }), array(object({
13109
13225
  bucket: number().int(),
13110
13226
  count: number().int()
13111
- })).readonly()), method(object({
13227
+ })).readonly(), { auth: "admin" }), method(object({
13112
13228
  namespace: string().optional(),
13113
13229
  collection: string()
13114
- }), boolean()), method(object({
13230
+ }), boolean(), { auth: "admin" }), method(object({
13115
13231
  namespace: string().optional(),
13116
13232
  collection: string(),
13117
13233
  columns: array(CollectionColumnSchema).readonly(),
13118
13234
  indexes: array(CollectionIndexSchema).readonly().optional()
13119
- }), _void(), { kind: "mutation" });
13235
+ }), _void(), {
13236
+ kind: "mutation",
13237
+ auth: "admin"
13238
+ });
13120
13239
  /**
13121
13240
  * What one engine says about itself. The orchestrator uses `kind` to pick
13122
13241
  * a registrant for a collection; `engineId` is what a log line names when
@@ -14138,8 +14257,14 @@ var deviceExportCapability = {
14138
14257
  getStatus: method(_void(), DeviceExportStatusSchema),
14139
14258
  listSupportedDeviceKinds: method(_void(), array(DeviceKindSchema)),
14140
14259
  listExposedDevices: method(_void(), array(ExposedDeviceSchema)),
14141
- exposeDevice: method(ExposeInputSchema, _void(), { kind: "mutation" }),
14142
- unexposeDevice: method(UnexposeInputSchema, _void(), { kind: "mutation" })
14260
+ exposeDevice: method(ExposeInputSchema, _void(), {
14261
+ kind: "mutation",
14262
+ auth: "admin"
14263
+ }),
14264
+ unexposeDevice: method(UnexposeInputSchema, _void(), {
14265
+ kind: "mutation",
14266
+ auth: "admin"
14267
+ })
14143
14268
  }
14144
14269
  };
14145
14270
  /** Wire/storage schema for one icon id. */
@@ -14571,6 +14696,13 @@ var LinkedDeviceSchema = object({
14571
14696
  features: array(string()),
14572
14697
  producesTrackedEvents: boolean().optional()
14573
14698
  });
14699
+ /**
14700
+ * The `linked-devices` extension slot's editable value (D648): the operator's
14701
+ * pick list, exactly what `_linkedDeviceIds` persists. Tree children are NOT
14702
+ * in it — they are always linked and are not a pick.
14703
+ */
14704
+ var LinkedDevicesSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
14705
+ DeviceType.Camera;
14574
14706
  /** One camera's resolved linked set, tagged with the camera it belongs to.
14575
14707
  * The batch answer needs the tag; the single-device answer already has it
14576
14708
  * from the input, which is why `getLinkedDevices` keeps the untagged shape. */
@@ -14726,7 +14858,10 @@ method(object({
14726
14858
  kind: "mutation",
14727
14859
  auth: "admin",
14728
14860
  timeoutMs: 12 * 6e4
14729
- }), method(DeviceRegisterPayloadSchema, _void(), { kind: "mutation" }), method(DeviceRemovePayloadSchema, _void(), { kind: "mutation" }), method(DevicePersistConfigPayloadSchema, _void(), { kind: "mutation" }), method(object({ deviceId: number() }), record(string(), unknown())), method(object({ deviceId: number() }), record(string(), unknown())), method(object({ deviceId: number() }), DeviceMetaSchema.nullable()), method(object({
14861
+ }), method(DeviceRegisterPayloadSchema, _void(), { kind: "mutation" }), method(DeviceRemovePayloadSchema, _void(), { kind: "mutation" }), method(DevicePersistConfigPayloadSchema, _void(), {
14862
+ kind: "mutation",
14863
+ auth: "admin"
14864
+ }), method(object({ deviceId: number() }), record(string(), unknown()), { auth: "admin" }), method(object({ deviceId: number() }), record(string(), unknown()), { auth: "admin" }), method(object({ deviceId: number() }), DeviceMetaSchema.nullable()), method(object({
14730
14865
  deviceId: number(),
14731
14866
  name: string()
14732
14867
  }), _void(), {
@@ -14931,7 +15066,7 @@ method(object({
14931
15066
  }), method(object({ deviceId: number() }), array(StreamProbeResultSchema), {
14932
15067
  kind: "mutation",
14933
15068
  auth: "admin"
14934
- }), method(object({ deviceId: number() }), DeviceBindingsForDeviceSchema), method(object({ deviceIds: array(number()) }), array(DeviceBindingsForDeviceSchema)), method(object({}), array(DeviceBindingsForDeviceSchema)), method(object({
15069
+ }), method(object({ deviceId: number() }), DeviceBindingsForDeviceSchema), method(object({ deviceIds: array(number()) }), array(DeviceBindingsForDeviceSchema)), method(object({}), array(DeviceBindingsForDeviceSchema)), method(object({ capNames: array(string().min(1)).min(1).max(16) }), array(number())), method(object({
14935
15070
  deviceId: number(),
14936
15071
  capName: string(),
14937
15072
  wrapperAddonId: string(),
@@ -15093,16 +15228,101 @@ var EmbeddingResultSchema = object({
15093
15228
  embedding: array(number()),
15094
15229
  inferenceMs: number()
15095
15230
  });
15231
+ /** The two CLIP towers the encoder runs; a crash budget is kept per tower. */
15232
+ var EmbeddingTowerSchema = _enum(["image", "text"]);
15233
+ /**
15234
+ * A tower in the terminal `failed` state (D649, D6): it crashed or failed to
15235
+ * load `crashes` times within `windowMs`, and is refused by name until an
15236
+ * operator `resetFailedModels` or a model change — never on a timer.
15237
+ *
15238
+ * `nodeId` is the node whose tower failed. The state lives in THAT node's
15239
+ * encoder process (in memory — a runner respawn clears it), and one node's
15240
+ * answer says nothing about another's.
15241
+ */
15242
+ var EmbeddingFailedModelSchema = object({
15243
+ modelId: string(),
15244
+ tower: EmbeddingTowerSchema,
15245
+ nodeId: string(),
15246
+ crashes: number(),
15247
+ windowMs: number(),
15248
+ sinceMs: number(),
15249
+ lastReason: string()
15250
+ });
15251
+ /**
15252
+ * A model whose REQUIREMENTS can never be met on this node (D649 round 5):
15253
+ * an id the catalog does not know, a model URL answering 404/410, a declared
15254
+ * sibling (the tokenizer) that is not there. After `attempts` failed builds
15255
+ * it is terminally `requirements-failed`, refused by name until an operator
15256
+ * `resetFailedModels` or a model change — the same exits as a crashed tower.
15257
+ */
15258
+ var EmbeddingFailedRequirementSchema = object({
15259
+ modelId: string(),
15260
+ tower: EmbeddingTowerSchema,
15261
+ nodeId: string(),
15262
+ attempts: number(),
15263
+ sinceMs: number(),
15264
+ lastReason: string()
15265
+ });
15096
15266
  var EmbeddingInfoSchema = object({
15097
15267
  modelId: string(),
15098
15268
  embeddingDim: number(),
15099
- ready: boolean()
15100
- });
15269
+ ready: boolean(),
15270
+ /**
15271
+ * The node that answered. Absent only from an encoder older than D649's
15272
+ * crash budget — whose `failedModels` is then UNKNOWN (D315), never "none".
15273
+ */
15274
+ nodeId: string().optional(),
15275
+ /**
15276
+ * Towers in `failed` on the answering node, each row naming it. `undefined`
15277
+ * means the node could not say (pre-budget encoder); a node that has the
15278
+ * budget always answers an array, empty included.
15279
+ */
15280
+ failedModels: array(EmbeddingFailedModelSchema).optional(),
15281
+ /** Models terminally `requirements-failed` on the answering node; same reading as above. */
15282
+ failedRequirements: array(EmbeddingFailedRequirementSchema).optional()
15283
+ });
15284
+ /**
15285
+ * The THREE codes an encoder refusal can carry (D649, D6). Same shape as
15286
+ * `VECTOR_INDEX_DIM_CONFLICT`: the code rides in the MESSAGE, because an
15287
+ * Error's own properties do not survive the UDS/tRPC hop and its message does,
15288
+ * and both sides go through the helpers below — the encoder builds the
15289
+ * refusal, the live detail plane classifies on it to count refusals per
15290
+ * camera instead of logging one warning per track. The bracketed token
15291
+ * carries the code, the model, the tower and the node so a consumer never
15292
+ * parses prose.
15293
+ *
15294
+ * - `EMBEDDING_MODEL_FAILED`: the tower crashed / failed to load past the crash
15295
+ * budget — terminal until `resetFailedModels` or a model change.
15296
+ * - `EMBEDDING_REQUIREMENTS_UNAVAILABLE`: files or runtime not there right now
15297
+ * (a download or Python that failed, or the cooldown after one) — the next
15298
+ * request past the cooldown tries again.
15299
+ * - `EMBEDDING_REQUIREMENTS_FAILED`: the requirements can never be met (unknown
15300
+ * id, 404/410, missing sibling) and the bounded attempts are spent —
15301
+ * terminal, same exits as a crashed tower.
15302
+ */
15303
+ var EMBEDDING_MODEL_FAILED = "embedding-model-failed";
15304
+ var EMBEDDING_REQUIREMENTS_UNAVAILABLE = "embedding-requirements-unavailable";
15305
+ var EMBEDDING_REQUIREMENTS_FAILED = "embedding-requirements-failed";
15306
+ _enum([
15307
+ EMBEDDING_MODEL_FAILED,
15308
+ EMBEDDING_REQUIREMENTS_UNAVAILABLE,
15309
+ EMBEDDING_REQUIREMENTS_FAILED
15310
+ ]);
15311
+ new RegExp(`\\[(${EMBEDDING_MODEL_FAILED}|${EMBEDDING_REQUIREMENTS_UNAVAILABLE}|${EMBEDDING_REQUIREMENTS_FAILED}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);
15101
15312
  method(object({
15102
15313
  crop: _instanceof(Uint8Array),
15103
15314
  width: number(),
15104
15315
  height: number()
15105
- }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
15316
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({
15317
+ text: string(),
15318
+ modelId: string().min(1).optional()
15319
+ }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" }), method(object({ modelId: string().min(1).optional() }), object({
15320
+ cleared: array(string()),
15321
+ nodeId: string()
15322
+ }), {
15323
+ kind: "mutation",
15324
+ auth: "admin"
15325
+ });
15106
15326
  /**
15107
15327
  * `failure-contribution` — the capability an addon reports its OWN losses
15108
15328
  * through, per camera, with the denominator attached. It stores nothing.
@@ -15286,18 +15506,30 @@ var LlmErrorCodeSchema = _enum([
15286
15506
  "budget-exceeded",
15287
15507
  "adapter-error"
15288
15508
  ]);
15289
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
15509
+ var LlmGenerateOkSchema = object({
15290
15510
  ok: literal(true),
15291
15511
  text: string(),
15292
15512
  model: string(),
15293
15513
  usage: LlmUsageSchema,
15294
15514
  truncated: boolean(),
15295
15515
  latencyMs: number()
15296
- }), object({
15516
+ });
15517
+ /**
15518
+ * WHO refused, on a `refusal`. `guardrail` = a safety filter in front of the
15519
+ * model rejected the request before it answered (Apple Foundation Models
15520
+ * refuses surveillance-framed prompts in 0.1 s); `model` = the model itself
15521
+ * declined. They are different faults: a guardrail refusal is a property of
15522
+ * the BACKEND, so the provider falls back to the next profile; a model refusal
15523
+ * is an answer. Absent on every other code, and on a refusal a wire cannot
15524
+ * attribute.
15525
+ */
15526
+ var LlmRefusalSourceSchema = _enum(["guardrail", "model"]);
15527
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [LlmGenerateOkSchema, object({
15297
15528
  ok: literal(false),
15298
15529
  code: LlmErrorCodeSchema,
15299
15530
  message: string(),
15300
- retryAfterMs: number().optional()
15531
+ retryAfterMs: number().optional(),
15532
+ refusalSource: LlmRefusalSourceSchema.optional()
15301
15533
  })]);
15302
15534
  /**
15303
15535
  * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
@@ -15527,12 +15759,78 @@ var LlmRuntimeDiskUsageSchema = object({
15527
15759
  modelsBytes: number(),
15528
15760
  freeBytes: number().optional()
15529
15761
  });
15530
- method(LlmGenerateBaseInputSchema.extend({
15762
+ var LlmRuntimeCompleteInputSchema = LlmGenerateBaseInputSchema.extend({
15531
15763
  images: array(LlmImageSchema).optional(),
15532
15764
  runtime: ManagedRuntimeConfigSchema,
15533
15765
  /** The managed profile's timeout, threaded by the hub provider. */
15534
15766
  timeoutMs: number().int().positive().optional()
15535
- }), LlmGenerateResultSchema, {
15767
+ });
15768
+ /**
15769
+ * Why Apple Foundation Models cannot run on a node that has it in principle.
15770
+ * The first three are Apple's own `UnavailableReason`s, verbatim; the rest are
15771
+ * ours: the OS predates the framework (macOS < 26), the helper binary is not
15772
+ * in the installed addon, or it crashed past the respawn bound.
15773
+ */
15774
+ var AppleFmUnavailableReasonSchema = _enum([
15775
+ "deviceNotEligible",
15776
+ "appleIntelligenceNotEnabled",
15777
+ "modelNotReady",
15778
+ "osTooOld",
15779
+ "helperMissing",
15780
+ "helperCrashed"
15781
+ ]);
15782
+ /**
15783
+ * Apple Foundation Models on ONE node — four states, never a boolean (D315).
15784
+ *
15785
+ * - `available` — the helper probed it; what it CAN do is reported
15786
+ * here (`imageInput`, `contextSize`, languages),
15787
+ * never typed by an operator.
15788
+ * - `unavailable` — a known absence, with the reason to act on.
15789
+ * - `unsupported-platform` — not a Mac; there is nothing to enable.
15790
+ * - `unknown` — the probe did not answer (not yet run, timed
15791
+ * out, helper crashed mid-probe). A failed
15792
+ * measurement is NEVER `unavailable` (D393).
15793
+ */
15794
+ var AppleFmAvailabilitySchema = discriminatedUnion("state", [
15795
+ object({
15796
+ state: literal("available"),
15797
+ osVersion: string(),
15798
+ /** Tokens, as the framework reports it. Read at runtime, never assumed. */
15799
+ contextSize: number().int().positive(),
15800
+ /** BCP-47-ish tags (`it-IT`) of the languages the model supports. */
15801
+ languages: array(string()),
15802
+ /** Whether prompts may carry images. `false` on a macOS 26 build. */
15803
+ imageInput: boolean()
15804
+ }),
15805
+ object({
15806
+ state: literal("unavailable"),
15807
+ reason: AppleFmUnavailableReasonSchema,
15808
+ osVersion: string().nullable(),
15809
+ detail: string()
15810
+ }),
15811
+ object({
15812
+ state: literal("unsupported-platform"),
15813
+ platform: string()
15814
+ }),
15815
+ object({
15816
+ state: literal("unknown"),
15817
+ error: string()
15818
+ })
15819
+ ]);
15820
+ /**
15821
+ * A generation on the node's Apple Foundation Models helper. A separate verb
15822
+ * from `complete`, whose `runtime` is a llama.cpp config: overloading it would
15823
+ * drag a GGUF model reference into a backend that has none. `images` is part
15824
+ * of the contract so vision needs no cap change later; a node whose model has
15825
+ * no image input REFUSES them (`unavailable`), never drops them.
15826
+ */
15827
+ var LlmRuntimeAppleCompleteInputSchema = LlmGenerateBaseInputSchema.extend({
15828
+ images: array(LlmImageSchema).optional(),
15829
+ /** The profile's timeout, threaded by the hub provider. */
15830
+ timeoutMs: number().int().positive().optional()
15831
+ });
15832
+ var LlmRuntimeCancelInputSchema = object({ requestId: string() });
15833
+ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
15536
15834
  kind: "mutation",
15537
15835
  auth: "admin",
15538
15836
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
@@ -15550,7 +15848,14 @@ method(LlmGenerateBaseInputSchema.extend({
15550
15848
  }), method(object({ file: string() }), _void(), {
15551
15849
  kind: "mutation",
15552
15850
  auth: "admin"
15553
- }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" });
15851
+ }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" }), method(LlmRuntimeCancelInputSchema, _void(), {
15852
+ kind: "mutation",
15853
+ auth: "admin"
15854
+ }), method(object({}), AppleFmAvailabilitySchema, { auth: "admin" }), method(LlmRuntimeAppleCompleteInputSchema, LlmGenerateResultSchema, {
15855
+ kind: "mutation",
15856
+ auth: "admin",
15857
+ timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
15858
+ });
15554
15859
  /**
15555
15860
  * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
15556
15861
  * methods concat-fan across providers; single-row methods route to ONE
@@ -15567,7 +15872,8 @@ var LlmProfileKindSchema = _enum([
15567
15872
  "openai",
15568
15873
  "anthropic",
15569
15874
  "google",
15570
- "managed-local"
15875
+ "managed-local",
15876
+ "apple-foundation"
15571
15877
  ]);
15572
15878
  var LlmProfileSchema = object({
15573
15879
  id: string(),
@@ -15625,7 +15931,14 @@ var LlmProfileSchema = object({
15625
15931
  toolsEnabled: boolean().default(false),
15626
15932
  extraHeaders: record(string(), string()).optional(),
15627
15933
  /** kind === 'managed-local' only (spec §4). */
15628
- runtime: ManagedRuntimeConfigSchema.optional()
15934
+ runtime: ManagedRuntimeConfigSchema.optional(),
15935
+ /**
15936
+ * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
15937
+ * to configure (no key, no URL, no download; `model` is `apple-system`).
15938
+ * `supportsVision` on such a row is stamped by the provider from the node's
15939
+ * reported `imageInput`, never taken from the operator (D62).
15940
+ */
15941
+ appleFoundation: object({ nodeId: string() }).optional()
15629
15942
  });
15630
15943
  /** ConfigUISchema tree passed through untyped on the wire (the
15631
15944
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -15707,7 +16020,9 @@ var LlmRuntimeNodeSchema = object({
15707
16020
  reachable: boolean(),
15708
16021
  status: LlmRuntimeStatusSchema.optional(),
15709
16022
  disk: LlmRuntimeDiskUsageSchema.optional(),
15710
- error: string().optional()
16023
+ error: string().optional(),
16024
+ /** Absent = the node did not answer the question (render as unknown). */
16025
+ apple: AppleFmAvailabilitySchema.optional()
15711
16026
  });
15712
16027
  var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
15713
16028
  var ProfileRefInputSchema = object({
@@ -16478,7 +16793,22 @@ var StatusSchema = object({
16478
16793
  brokerCount: number(),
16479
16794
  embeddedRunning: boolean()
16480
16795
  });
16481
- method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema), method(AddBrokerInputSchema, AddBrokerResultSchema, { kind: "mutation" }), method(IdInputSchema, _void(), { kind: "mutation" }), method(IdInputSchema, TestResultSchema$1, { kind: "mutation" }), method(StartEmbeddedInputSchema, StartEmbeddedResultSchema, { kind: "mutation" }), method(IdInputSchema, _void(), { kind: "mutation" }), method(_void(), StatusSchema);
16796
+ method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
16797
+ kind: "mutation",
16798
+ auth: "admin"
16799
+ }), method(IdInputSchema, _void(), {
16800
+ kind: "mutation",
16801
+ auth: "admin"
16802
+ }), method(IdInputSchema, TestResultSchema$1, {
16803
+ kind: "mutation",
16804
+ auth: "admin"
16805
+ }), method(StartEmbeddedInputSchema, StartEmbeddedResultSchema, {
16806
+ kind: "mutation",
16807
+ auth: "admin"
16808
+ }), method(IdInputSchema, _void(), {
16809
+ kind: "mutation",
16810
+ auth: "admin"
16811
+ }), method(_void(), StatusSchema);
16482
16812
  var NetworkEndpointSchema = object({
16483
16813
  url: string(),
16484
16814
  hostname: string(),
@@ -16773,6 +17103,18 @@ var TargetKindSchema = object({
16773
17103
  */
16774
17104
  iconMediaType: string().optional(),
16775
17105
  configSchema: ConfigSchemaPassthrough,
17106
+ /**
17107
+ * The config keys that decide WHERE this kind's secrets are sent (server,
17108
+ * base URL, instance, chat, recipient). A save that changes any of them
17109
+ * while leaving a secret redacted is refused by the provider (D634), so an
17110
+ * editor uses this to ask for the secret on exactly those edits instead of
17111
+ * on every edit.
17112
+ *
17113
+ * Optional: absent from a provider that holds no secret (the Home Assistant
17114
+ * kinds) and from a provider older than this field — an editor that finds
17115
+ * it absent must assume ANY edit may need the secret.
17116
+ */
17117
+ destinationKeys: array(string()).optional(),
16776
17118
  supportsDiscovery: boolean(),
16777
17119
  caps: TargetKindCapsSchema
16778
17120
  });
@@ -16817,25 +17159,40 @@ var notificationOutputCapability = {
16817
17159
  mode: "collection",
16818
17160
  methods: {
16819
17161
  listTargetKinds: method(object({}), array(TargetKindSchema)),
16820
- listTargets: method(object({}), array(TargetSchema)),
17162
+ listTargets: method(object({}), array(TargetSchema), { auth: "admin" }),
16821
17163
  discoverTargets: method(object({
16822
17164
  kind: string(),
16823
17165
  config: record(string(), unknown()).optional()
16824
- }), array(DiscoveredTargetSchema)),
17166
+ }), array(DiscoveredTargetSchema), { auth: "admin" }),
16825
17167
  send: method(object({
16826
17168
  targetId: string(),
16827
17169
  notification: NotificationSchema
16828
- }), SendResultSchema, { kind: "mutation" }),
17170
+ }), SendResultSchema, {
17171
+ kind: "mutation",
17172
+ auth: "admin"
17173
+ }),
16829
17174
  testTarget: method(object({
16830
17175
  targetId: string(),
16831
17176
  sample: NotificationSchema.optional()
16832
- }), TestResultSchema, { kind: "mutation" }),
16833
- upsertTarget: method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }),
16834
- deleteTarget: method(object({ targetId: string() }), _void(), { kind: "mutation" }),
17177
+ }), TestResultSchema, {
17178
+ kind: "mutation",
17179
+ auth: "admin"
17180
+ }),
17181
+ upsertTarget: method(object({ target: TargetSchema }), TargetSchema, {
17182
+ kind: "mutation",
17183
+ auth: "admin"
17184
+ }),
17185
+ deleteTarget: method(object({ targetId: string() }), _void(), {
17186
+ kind: "mutation",
17187
+ auth: "admin"
17188
+ }),
16835
17189
  setTargetEnabled: method(object({
16836
17190
  targetId: string(),
16837
17191
  enabled: boolean()
16838
- }), _void(), { kind: "mutation" })
17192
+ }), _void(), {
17193
+ kind: "mutation",
17194
+ auth: "admin"
17195
+ })
16839
17196
  }
16840
17197
  };
16841
17198
  new Set([
@@ -17662,6 +18019,9 @@ var NcSystemEventKindSchema = _enum([
17662
18019
  "device-battery-normal",
17663
18020
  "device-consumable-low",
17664
18021
  "device-consumable-normal",
18022
+ "device-tank-low",
18023
+ "device-tank-full",
18024
+ "device-tank-normal",
17665
18025
  "stream-online",
17666
18026
  "stream-offline",
17667
18027
  "node-online",
@@ -17699,6 +18059,29 @@ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
17699
18059
  ]);
17700
18060
  NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
17701
18061
  /**
18062
+ * The panel's transitions, as ONE list.
18063
+ *
18064
+ * Named here rather than spelled out at each of the four sites that need them
18065
+ * (the emitter, the intake, the editor group, the combined-notification gate),
18066
+ * because a transition added to the enum and forgotten at one of them is an
18067
+ * alarm state nobody can be notified about. That is exactly what this list
18068
+ * failed to prevent while it held three: `alarm-arming` was the fourth.
18069
+ *
18070
+ * In LIFECYCLE order, which is the order an editor lists them in and the order
18071
+ * a person experiences them — not the order they were added.
18072
+ */
18073
+ var NC_ALARM_SYSTEM_EVENT_KINDS = [
18074
+ "alarm-arm-refused",
18075
+ "alarm-check-failed",
18076
+ "alarm-arming",
18077
+ "alarm-armed",
18078
+ "alarm-pending",
18079
+ "alarm-triggered",
18080
+ "alarm-rearmed",
18081
+ "alarm-sensor-bypass",
18082
+ "alarm-disarmed"
18083
+ ];
18084
+ /**
17702
18085
  * One coherent system-event condition. `kinds` is the required opt-in safety
17703
18086
  * gate; the remaining lists are optional narrowing filters relevant to the
17704
18087
  * selected kinds.
@@ -17718,8 +18101,36 @@ var NcSystemEventConditionSchema = object({
17718
18101
  * does not carry) matches no `deviceTypes` list.
17719
18102
  */
17720
18103
  deviceTypes: array(string().min(1)).min(1).optional(),
18104
+ /**
18105
+ * Devices this rule NEVER speaks about, whatever else matched. Scoped to the
18106
+ * same kind family as `deviceIds` (`systemEventFilterApplies(kind,
18107
+ * 'deviceIds')`) and applied AFTER it: include first, then exclude. A
18108
+ * consumable subject (`consumable:<id>:<key>`) is excluded by its device id.
18109
+ *
18110
+ * It never fails closed: a subject that carries no device id is not in the
18111
+ * list, so it is not excluded. "Every battery except the one thermometer that
18112
+ * reads 0 % forever" is the question this answers — expressed as an include
18113
+ * list it would have to name every other battery device, and every device
18114
+ * adopted later would be silently left out (D636).
18115
+ */
18116
+ excludeDeviceIds: array(number().int()).min(1).optional(),
17721
18117
  nodeIds: array(string().min(1)).min(1).optional(),
17722
- packageNames: array(string().min(1)).min(1).optional()
18118
+ packageNames: array(string().min(1)).min(1).optional(),
18119
+ /**
18120
+ * At or below this remaining-life %, a consumable is LOW for THIS rule
18121
+ * (D642). Absent = {@link NC_CONSUMABLE_LOW_PERCENT_DEFAULT}; at most
18122
+ * {@link NC_CONSUMABLE_LOW_PERCENT_MAX}, so every episode can recover. Scoped to the
18123
+ * consumable kinds (`systemEventFilterApplies`) and to the device-events
18124
+ * family; ignored on every other kind.
18125
+ *
18126
+ * It is a property of the RULE because the operator decided so: a rule at
18127
+ * 25 must be told about a filter at 20 %, a rule at 10 must not. The hub
18128
+ * keeps one episode per (threshold, device, item) — its own hysteresis, its
18129
+ * own reminder — and a rule hears only the episode judged at ITS threshold,
18130
+ * exactly as an occupancy rule hears only the edge of its own count. A
18131
+ * provider's own `replace` verdict is low at every threshold.
18132
+ */
18133
+ consumableLowPercent: number().int().min(1).max(95).optional()
17723
18134
  });
17724
18135
  /** Hard ceiling on a window (24h). A snooze that could not expire would be an
17725
18136
  * outage the operator asked for once and forgot. */
@@ -17737,6 +18148,25 @@ var NcScheduleSchema = object({
17737
18148
  /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
17738
18149
  invert: boolean().optional()
17739
18150
  });
18151
+ /**
18152
+ * How a system-event rule of the `device-events` or `system` family speaks
18153
+ * (D647): at once, per event (`instant`, the only behaviour before D647), or
18154
+ * as a STATE SUMMARY at the end of each window of `schedule`.
18155
+ */
18156
+ var NcSystemEventDeliveryModeSchema = _enum(["instant", "summary"]);
18157
+ /**
18158
+ * `summary`: the rule sends NOTHING per event. When a window of `schedule`
18159
+ * CLOSES, it sends one notification with the current state of its kinds
18160
+ * (low batteries, consumables to replace, devices offline, updates
18161
+ * available, ...), after its own filters. Nothing to report sends nothing.
18162
+ * The schedule is the ordinary `NcSchedule` (weekly windows, IANA timezone,
18163
+ * midnight crossing); the send time is each window's END. Refused on the
18164
+ * `alarm` family, which stays instant (`systemEventDeliveryProblems`).
18165
+ */
18166
+ var NcSystemEventDeliverySchema = discriminatedUnion("mode", [object({ mode: literal("instant") }), object({
18167
+ mode: literal("summary"),
18168
+ schedule: NcScheduleSchema
18169
+ })]);
17740
18170
  /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
17741
18171
  var NcPlateMatcherSchema = object({
17742
18172
  /**
@@ -17862,6 +18292,16 @@ var NcCrossingSchema = _enum([
17862
18292
  "exit",
17863
18293
  "any"
17864
18294
  ]);
18295
+ /**
18296
+ * Which edge of a BOOLEAN sensor fires a device-event rule (D640).
18297
+ * - `raised` — the sensor went high: water detected, smoke, open, tampered.
18298
+ * - `cleared` — it went back: dry, clear, closed.
18299
+ * - absent — both edges, which is what every rule authored before this did.
18300
+ *
18301
+ * There is no third member for "both": absence already says it, and a value
18302
+ * that means the same as absence is a second way to write one rule.
18303
+ */
18304
+ var NcSensorTransitionSchema = _enum(["raised", "cleared"]);
17865
18305
  /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
17866
18306
  var NcZoneConditionSchema = object({
17867
18307
  ids: array(string().min(1)).min(1),
@@ -18051,6 +18491,20 @@ var NcConditionsSchema = object({
18051
18491
  scene: NcSceneConditionSchema.optional(),
18052
18492
  /** Device scope — absent = all devices. */
18053
18493
  devices: array(number()).optional(),
18494
+ /**
18495
+ * Device EXCLUSION (D641) — "every device except these". Judged on the SAME
18496
+ * subject ids {@link devices} is judged on (the camera, the sensor that
18497
+ * fired, a linked set's sensor and row cameras), so a sensor fanned out per
18498
+ * linked camera is excluded exactly where an include would have tested it.
18499
+ * `min(1)`: an empty exclusion excludes nothing and is written as absent.
18500
+ *
18501
+ * Not for `system-event` rules — those carry their own
18502
+ * `systemEvent.excludeDeviceIds` (D636), and the hub refuses this key there.
18503
+ * Editors present the two lists as ONE field (All | Only these | All except
18504
+ * these); the engine evaluates each independently, so a legacy rule
18505
+ * carrying both still means "these, minus those".
18506
+ */
18507
+ devicesExclude: array(number()).min(1).optional(),
18054
18508
  /** Detector class names (any overlap with the record's class set). */
18055
18509
  classes: array(string().min(1)).optional(),
18056
18510
  /** Veto classes — any overlap fails the rule. */
@@ -18184,6 +18638,16 @@ var NcConditionsSchema = object({
18184
18638
  */
18185
18639
  sensorKinds: array(string().min(1)).optional(),
18186
18640
  /**
18641
+ * DEVICE-EVENT only (D640). Fire on one edge of a boolean sensor —
18642
+ * {@link NcSensorTransitionSchema}. Which field of the slice means "raised"
18643
+ * is `@camstack/types` → `notification/sensor-raised.ts`. A reading the
18644
+ * engine cannot place (a kind with no raise, an unreadable slice) PASSES:
18645
+ * the condition fails open towards notifying, never towards silence. Editors
18646
+ * offer it only when every chosen {@link sensorKinds} member has a raise
18647
+ * (`sensorTransitionOffered`), and the hub refuses it on any other delivery.
18648
+ */
18649
+ sensorTransition: NcSensorTransitionSchema.optional(),
18650
+ /**
18187
18651
  * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
18188
18652
  * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
18189
18653
  * when the subject's phase does not match (a subject always carries a phase
@@ -18316,7 +18780,12 @@ var NcMediaPolicySchema = object({
18316
18780
  * the degrade engine, which drops the video and keeps the still.
18317
18781
  */
18318
18782
  clip: boolean().optional(),
18319
- /** Seconds of footage BEFORE / AFTER the event instant. Defaults 3 / 7. */
18783
+ /**
18784
+ * Seconds of footage BEFORE / AFTER the event instant. Absent =
18785
+ * {@link NC_CLIP_PRE_ROLL_DEFAULT_SEC} / {@link NC_CLIP_POST_ROLL_DEFAULT_SEC}
18786
+ * (4 / 6), resolved by the Notification Center at dispatch — deliberately not
18787
+ * a Zod default, so a rule that never chose keeps following the hub's.
18788
+ */
18320
18789
  clipPreRollSec: number().int().min(0).max(30).optional(),
18321
18790
  clipPostRollSec: number().int().min(0).max(30).optional(),
18322
18791
  /**
@@ -18438,6 +18907,16 @@ var NcRuleInputSchema = object({
18438
18907
  delivery: NcDeliverySchema,
18439
18908
  conditions: NcConditionsSchema.default({}),
18440
18909
  schedule: NcScheduleSchema.optional(),
18910
+ /**
18911
+ * A `device-events` / `system` rule's delivery (D647): absent or `instant`
18912
+ * is a notification per event; `summary` is one state summary per closed
18913
+ * window of its schedule. `.optional()` and never defaulted: absent must
18914
+ * keep meaning what every rule authored before D647 meant, with no
18915
+ * migration. Top-level rather than inside `conditions.systemEvent`, so a
18916
+ * client that does not know it (an older viewer re-sending `conditions`
18917
+ * whole) leaves it standing through the store's patch merge.
18918
+ */
18919
+ systemEventDelivery: NcSystemEventDeliverySchema.optional(),
18441
18920
  /** May be empty when `targetUsers` addresses at least one user — the
18442
18921
  * "at least one addressee" invariant is enforced by the provider, because
18443
18922
  * a cross-field refine here would break `NcRulePatchSchema.partial()`. */
@@ -18666,6 +19145,28 @@ var NcRuleSchema = NcRuleInputSchema.extend({
18666
19145
  */
18667
19146
  disabledTargetIds: array(string()).default([])
18668
19147
  });
19148
+ /** One section of a previewed state summary. `unavailable` = its state could not be read. */
19149
+ var NcStateSummaryPreviewSectionSchema = object({
19150
+ id: string(),
19151
+ status: _enum(["read", "unavailable"]),
19152
+ items: number().int().nonnegative(),
19153
+ reason: string().optional()
19154
+ });
19155
+ /**
19156
+ * The summary a rule would send now. `empty` = nothing to report and every
19157
+ * section read: such a summary is NOT sent. `dropped` counts the open states
19158
+ * the rule's own filters (or a camera mute) left out, by reason.
19159
+ * `excludedGroups` names the kind groups selected that have no state to report
19160
+ * (backups & exports).
19161
+ */
19162
+ var NcStateSummaryPreviewSchema = object({
19163
+ empty: boolean(),
19164
+ count: number().int().nonnegative(),
19165
+ text: string(),
19166
+ sections: array(NcStateSummaryPreviewSectionSchema),
19167
+ dropped: record(string(), number().int().nonnegative()),
19168
+ excludedGroups: array(string())
19169
+ });
18669
19170
  var NcTestResultSchema = object({
18670
19171
  recordId: string(),
18671
19172
  recordKind: _enum([
@@ -18683,9 +19184,29 @@ var NcTestResultSchema = object({
18683
19184
  className: string().optional(),
18684
19185
  label: string().optional()
18685
19186
  });
18686
- /** The five rule kinds, as data. `NcRuleKind` in `notification/rule-kinds.ts`
18687
- * is the same union; the template-vars spec pins the two together. */
19187
+ /** The rule kinds, as data. `NcRuleKind` in `notification/rule-kinds.ts` is the
19188
+ * same union; the template-vars spec pins the two together. `mixed` is DERIVED
19189
+ * (a stored system rule whose kinds span families, D637) and never authored. */
18688
19190
  var NcRuleKindSchema = _enum([
19191
+ "detection",
19192
+ "sensor",
19193
+ "occupancy",
19194
+ "sound",
19195
+ "device-events",
19196
+ "system",
19197
+ "alarm",
19198
+ "mixed"
19199
+ ]);
19200
+ /**
19201
+ * The kinds a SERVED template-variable descriptor may name: the five that
19202
+ * existed before D637, frozen. `getTemplateCatalog` ships `kinds` to every
19203
+ * installed viewer, and a viewer at `@camstack/types` 1.2.25x parses them with a
19204
+ * strict five-member enum — one `device-events` in one descriptor fails the
19205
+ * whole catalog parse. So the WIRE says `system`, and the MATCH widens it:
19206
+ * `templateVarKindApplies` reads a `system` descriptor as applying to every
19207
+ * system rule kind (`device-events`, `system`, `alarm`, `mixed`).
19208
+ */
19209
+ var NcTemplateVarKindSchema = _enum([
18689
19210
  "detection",
18690
19211
  "sensor",
18691
19212
  "occupancy",
@@ -18723,7 +19244,7 @@ var NcTemplateVarGroupSchema = _enum([
18723
19244
  *
18724
19245
  * `families` / `fields` / `kinds` / `deliveries` / `systemEventKinds` say WHERE
18725
19246
  * it has a value; absent = no restriction on that axis. `systemEventKinds` is
18726
- * read only for a `system` rule. `dynamic` declares a FAMILY of names
19247
+ * read only for a system-event rule (any family, or `mixed`). `dynamic` declares a FAMILY of names
18727
19248
  * (`count_<class>`): the descriptor's `name` is the example member.
18728
19249
  */
18729
19250
  var NcTemplateVarDescriptorSchema = object({
@@ -18734,9 +19255,16 @@ var NcTemplateVarDescriptorSchema = object({
18734
19255
  group: NcTemplateVarGroupSchema,
18735
19256
  families: array(NcTemplateFamilySchema).min(1),
18736
19257
  fields: array(NcTemplateFieldSchema).optional(),
18737
- kinds: array(NcRuleKindSchema).optional(),
19258
+ kinds: array(NcTemplateVarKindSchema).optional(),
18738
19259
  deliveries: array(NcDeliverySchema).optional(),
18739
19260
  systemEventKinds: array(NcSystemEventKindSchema).optional(),
19261
+ /**
19262
+ * Which system-event DELIVERY has a value for it (D647). Absent = an
19263
+ * instant row only when the descriptor names `systemEventKinds` (a
19264
+ * per-event fact: a summary row has no single device), and both otherwise.
19265
+ * `['summary']` marks the state-summary vocabulary (`{{summaryText}}`, ...).
19266
+ */
19267
+ systemEventDeliveries: array(NcSystemEventDeliveryModeSchema).optional(),
18740
19268
  dynamic: object({
18741
19269
  prefix: literal("count_"),
18742
19270
  from: literal("classes")
@@ -18749,7 +19277,9 @@ var NcTemplatePreviewInputSchema = object({
18749
19277
  field: NcTemplateFieldSchema,
18750
19278
  kind: NcRuleKindSchema.optional(),
18751
19279
  delivery: NcDeliverySchema.optional(),
18752
- systemEventKinds: array(NcSystemEventKindSchema).optional()
19280
+ systemEventKinds: array(NcSystemEventKindSchema).optional(),
19281
+ /** The rule's system-event delivery (D647); absent = instant. */
19282
+ systemEventDelivery: NcSystemEventDeliveryModeSchema.optional()
18753
19283
  }),
18754
19284
  template: object({
18755
19285
  title: string().max(500).optional(),
@@ -18782,6 +19312,7 @@ var NcConditionDescriptorSchema = object({
18782
19312
  /** Editor widget the UI renders — never hardcode per-condition forms. */
18783
19313
  valueType: _enum([
18784
19314
  "deviceIdList",
19315
+ "deviceIdExcludeList",
18785
19316
  "stringList",
18786
19317
  "number01",
18787
19318
  "number",
@@ -18792,6 +19323,7 @@ var NcConditionDescriptorSchema = object({
18792
19323
  "plateMatcher",
18793
19324
  "packagePhase",
18794
19325
  "crossingSelect",
19326
+ "sensorTransition",
18795
19327
  "polygonDraw",
18796
19328
  "occupancy",
18797
19329
  "audio",
@@ -18942,6 +19474,28 @@ var NcHistoryFilterSchema = object({
18942
19474
  limit: number().int().min(1).max(500).default(100)
18943
19475
  });
18944
19476
  /**
19477
+ * Every rule's last run, in one answer.
19478
+ *
19479
+ * A rule ABSENT from `runs` produced no delivery inside `horizonMs` — how far
19480
+ * back this answer looked, in ms before the hub's now. It is the outbox prune
19481
+ * window (7 days by default, operator-configurable), NARROWED when the read hit
19482
+ * its row bound: the answer never claims a window it did not read. `null` means
19483
+ * the operator keeps the outbox forever AND the read reached its end, so absent
19484
+ * means "never on record". A UI derives its "not in the last N days" from this
19485
+ * value, never from a constant — and only when the call ANSWERED (D315).
19486
+ */
19487
+ var NcRuleLastRunsSchema = object({
19488
+ runs: array(object({
19489
+ ruleId: string(),
19490
+ /** Fire time of the newest row (`createdAt`, epoch ms). */
19491
+ lastAt: number(),
19492
+ status: NcHistoryStatusSchema,
19493
+ /** The camera/device of that row (a digest row files under its first camera). */
19494
+ deviceId: number()
19495
+ })),
19496
+ horizonMs: number().nonnegative().nullable()
19497
+ });
19498
+ /**
18945
19499
  * What a snooze covers. Broader scopes win when several overlap, so one window
18946
19500
  * leaves ONE digest rather than a rule snooze and a whole-feed snooze both
18947
19501
  * summarising the same silence.
@@ -19122,6 +19676,14 @@ var NcAlarmModeCoverageSchema = object({
19122
19676
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
19123
19677
  deviceIds: array(number().int()),
19124
19678
  /**
19679
+ * D641: the ids NOT covered although `allDevices` is true — every unscoped
19680
+ * covering rule EXCLUDES them (`conditions.devicesExclude`) and no named rule
19681
+ * covers them. Always `[]` when `allDevices` is false. Excluded by the rules,
19682
+ * which is not the same as skipped by a switch: never in `skippedDevices`.
19683
+ * Defaulted so an answer computed before this field parses as "none".
19684
+ */
19685
+ allDevicesExcept: array(number().int()).default([]),
19686
+ /**
19125
19687
  * Devices this mode NAMES but cannot actually arm, each with the switch that
19126
19688
  * excludes it.
19127
19689
  *
@@ -19251,13 +19813,17 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
19251
19813
  }), object({ results: array(NcTestResultSchema) }), {
19252
19814
  kind: "mutation",
19253
19815
  auth: "admin"
19816
+ }), method(object({ rule: NcRuleInputSchema }), NcStateSummaryPreviewSchema, {
19817
+ kind: "mutation",
19818
+ auth: "admin",
19819
+ access: "view"
19254
19820
  }), method(object({}), object({
19255
19821
  catalog: array(NcConditionDescriptorSchema),
19256
19822
  taxonomy: NcTaxonomySchema.optional()
19257
19823
  })), method(object({}), object({ vars: array(NcTemplateVarDescriptorSchema) })), method(NcTemplatePreviewInputSchema, NcTemplatePreviewSchema, {
19258
19824
  kind: "mutation",
19259
19825
  access: "view"
19260
- }), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" }), method(object({ artifactId: string().min(1) }), object({ url: string().nullable() }), { auth: "admin" }), method(object({}), object({ snoozes: array(NcSnoozeSchema) }), { caller: "required" }), method(object({ snooze: NcSnoozeInputSchema }), object({ snooze: NcSnoozeSchema }), {
19826
+ }), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" }), method(object({}), NcRuleLastRunsSchema, { auth: "admin" }), method(object({ artifactId: string().min(1) }), object({ url: string().nullable() }), { auth: "admin" }), method(object({}), object({ snoozes: array(NcSnoozeSchema) }), { caller: "required" }), method(object({ snooze: NcSnoozeInputSchema }), object({ snooze: NcSnoozeSchema }), {
19261
19827
  kind: "mutation",
19262
19828
  caller: "required"
19263
19829
  }), method(object({ snoozeId: string() }), object({ success: literal(true) }), {
@@ -19613,755 +20179,239 @@ var oauthIntegrationCapability = {
19613
20179
  getDescriptor: method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" }) }
19614
20180
  };
19615
20181
  /**
19616
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
19617
- * within the frame, so the executor can re-cut a leaf child ROI at native
19618
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
20182
+ * A model choice has a SCOPE, and a scope change has a workflow.
20183
+ *
20184
+ * ## The two scopes
20185
+ *
20186
+ * Almost every pipeline step's model is a **node** question: which build runs
20187
+ * fastest on THIS accelerator. Two nodes may legitimately answer differently —
20188
+ * a Coral runs the tflite SSD, a Mac runs the coreml YOLO — because the answers
20189
+ * are compared against nothing. They produce boxes, and a box is a box.
20190
+ *
20191
+ * Two steps are not like that. `face-embedding` and `clip-embedding` produce
20192
+ * **vectors that land in ONE shared index** (`identity_samples`,
20193
+ * `vec_object_clip`) and are ranked against each other by cosine similarity.
20194
+ * Cosine similarity between two encoders is not a weak signal, it is a
20195
+ * meaningless number — and nothing inside a vector can tell you it happened.
20196
+ * So for those two steps the model is a **cluster** question with exactly one
20197
+ * answer, stored in exactly one row.
20198
+ *
20199
+ * That is the same argument [D52](../../../../docs/decisions/adr-0052.md) makes
20200
+ * for the crop convention (`detail-crop.ts`), one level up: the crop decides
20201
+ * WHAT pixels the encoder sees, this decides WHICH encoder sees them. Both are
20202
+ * cluster-wide for the same reason and neither may become per-node.
20203
+ *
20204
+ * ## Why the registry lives here and not in the step catalog
20205
+ *
20206
+ * The scope itself is declared on the step, in
20207
+ * `detection-pipeline/registry/step-definitions.ts` (`StepDefinition.modelScope`)
20208
+ * — that is where a new step declares what kind of choice its model is. But the
20209
+ * catalog lives inside `addon-pipeline`, and three packages that must NOT
20210
+ * import an addon need to know the set: the orchestrator (which renders and
20211
+ * stores the row), post-analysis (which pins the row for a re-embed pass) and
20212
+ * admin-ui (which mirrors it). So the set is mirrored here, and
20213
+ * `scripts/check-cluster-model-scope.ts` fails the build when the two disagree.
20214
+ * A hand-copied key that stops matching is exactly how a setting silently stops
20215
+ * arriving while both sides still look correct.
20216
+ *
20217
+ * ## The defaults ARE today's behaviour
20218
+ *
20219
+ * {@link DEFAULT_CLUSTER_STEP_MODELS} reproduces the catalog `defaultModelId`
20220
+ * of both steps. Declaring the scope therefore changes nothing on the day it
20221
+ * ships: the cluster row starts out saying what every node was already doing.
20222
+ * Changing it is legitimate — that is what the knob is for — but it invalidates
20223
+ * the stored vectors of that surface, and must be followed by a re-embed pass
20224
+ * (`face-reembed-pass.ts`, `embedding-rebuild.ts`).
20225
+ */
20226
+ /**
20227
+ * Why the orchestrator cannot say which model the operator chose for a
20228
+ * cluster-scoped step (D651).
20229
+ */
20230
+ var CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS = [
20231
+ "owner-not-ready",
20232
+ "store-read-failed",
20233
+ "three-way-read-unavailable",
20234
+ "invalid-stored",
20235
+ "not-cluster-scoped"
20236
+ ];
20237
+ Object.freeze(Object.fromEntries([{
20238
+ stepId: "face-embedding",
20239
+ label: "Face recognition model",
20240
+ defaultModelId: "auraface-r100",
20241
+ indexName: "the enrolled face gallery",
20242
+ options: [
20243
+ {
20244
+ id: "auraface-r100",
20245
+ label: "AuraFace R100"
20246
+ },
20247
+ {
20248
+ id: "arcface-r100",
20249
+ label: "ArcFace (ResNet34)"
20250
+ },
20251
+ {
20252
+ id: "inception-resnet-v1",
20253
+ label: "Inception ResNet V1"
20254
+ }
20255
+ ]
20256
+ }, {
20257
+ stepId: "clip-embedding",
20258
+ label: "Semantic search model",
20259
+ defaultModelId: "mobileclip-s1",
20260
+ indexName: "the object semantic-search index",
20261
+ options: [
20262
+ {
20263
+ id: "mobileclip-s1",
20264
+ label: "MobileCLIP S1"
20265
+ },
20266
+ {
20267
+ id: "mobileclip-s2",
20268
+ label: "MobileCLIP S2"
20269
+ },
20270
+ {
20271
+ id: "siglip2-b16-224",
20272
+ label: "SigLIP2 B/16 (Apache-2.0)"
20273
+ }
20274
+ ]
20275
+ }].map((s) => [s.stepId, s.defaultModelId])));
20276
+ var CLUSTER_STEP_SETTING_FIELDS = [{
20277
+ stepId: "face-embedding",
20278
+ key: "minLandmarkFaceSize",
20279
+ label: "Min face size for recognition (detection px)",
20280
+ 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.",
20281
+ type: "slider",
20282
+ min: 0,
20283
+ max: 64,
20284
+ step: 2,
20285
+ default: 24
20286
+ }];
20287
+ function clusterStepSettingKey(stepId, fieldKey) {
20288
+ return `clusterStepSetting:${stepId}:${fieldKey}`;
20289
+ }
20290
+ var ClusterSettingNumberSchema = number().finite();
20291
+ function readClusterStepSettings(config) {
20292
+ const out = {};
20293
+ for (const field of CLUSTER_STEP_SETTING_FIELDS) {
20294
+ const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
20295
+ const value = parsed.success ? parsed.data : field.default;
20296
+ const existing = out[field.stepId] ?? {};
20297
+ out[field.stepId] = {
20298
+ ...existing,
20299
+ [field.key]: value
20300
+ };
20301
+ }
20302
+ return out;
20303
+ }
20304
+ readClusterStepSettings({});
20305
+ /**
20306
+ * pipeline-analytics — device-scoped wrapper cap. Refines raw
20307
+ * per-frame detections emitted by the pipeline runner into tracked
20308
+ * objects, per-kind event collections (motion / object / audio), and
20309
+ * persisted media. Owns the post-detection domain end-to-end:
20310
+ *
20311
+ * runner emits PipelineInferenceResult
20312
+ * ↓ (event bus)
20313
+ * pipeline-analytics subscriber
20314
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
20315
+ * → three DB collections (one per kind), one FS media tree, one
20316
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
20317
+ * DetectionEvent on bus)
20318
+ *
20319
+ * Pure subscriber model. No `processFrame` cap method — the runner
20320
+ * already publishes the raw frame on the bus. The cap surface is
20321
+ * only QUERIES + per-device settings, bound on/off via
20322
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
20323
+ * every camera with a detection pipeline wants its raw detections
20324
+ * refined; operators opt out per-device via BindingsTab when needed.
20325
+ *
20326
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
20327
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
19619
20328
  */
19620
- var NativeCropRefSchema = object({
19621
- /** Handle keying the retained native surface (node-pinned to its owner). */
19622
- handle: FrameHandleSchema,
19623
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
19624
- cropFrameSpace: object({
19625
- x: number(),
19626
- y: number(),
19627
- w: number(),
19628
- h: number()
19629
- })
19630
- });
19631
- object({
19632
- crop: object({
19633
- left: number(),
19634
- top: number(),
19635
- width: number().positive(),
19636
- height: number().positive()
19637
- }).optional(),
19638
- content: object({
19639
- width: number().int().positive(),
19640
- height: number().int().positive()
19641
- }),
19642
- fit: _enum(["stretch", "contain"]),
19643
- format: _enum([
19644
- "rgb",
19645
- "gray",
19646
- "jpeg"
19647
- ])
19648
- });
20329
+ var TrackStateSchema = _enum([
20330
+ "new",
20331
+ "entered",
20332
+ "left",
20333
+ "moving",
20334
+ "idle"
20335
+ ]);
20336
+ var EventKindSchema = _enum([
20337
+ "motion",
20338
+ "object",
20339
+ "audio"
20340
+ ]);
19649
20341
  /**
19650
- * Process-local frame identity. It is serializable so it can ride an in-process
19651
- * capability call, but `registryId` deliberately prevents resolution in any
19652
- * other process or execution group.
20342
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
20343
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
20344
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
19653
20345
  */
19654
- var FrameRefSchema = object({
19655
- registryId: string().min(1),
19656
- id: string().min(1),
19657
- width: number().int().positive(),
19658
- height: number().int().positive(),
19659
- format: _enum(["rgb", "gray"]),
19660
- timestamp: number(),
19661
- capturedAt: number().optional()
19662
- });
19663
- var ModelFormatSchema$1 = _enum([
19664
- "onnx",
19665
- "coreml",
19666
- "openvino",
19667
- "tflite",
19668
- "pt",
19669
- "gguf"
20346
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
20347
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
20348
+ var EventKindIconSchema = _enum([
20349
+ "motion",
20350
+ "audio",
20351
+ "person",
20352
+ "vehicle",
20353
+ "animal",
20354
+ "door",
20355
+ "pir",
20356
+ "smoke",
20357
+ "water",
20358
+ "button",
20359
+ "package",
20360
+ "generic"
19670
20361
  ]);
19671
- var PipelineSlotSchema = _enum([
19672
- "detector",
19673
- "cropper",
19674
- "classifier",
19675
- "refiner",
19676
- "audio-classifier"
20362
+ var EventKindCategorySchema = _enum([
20363
+ "motion",
20364
+ "audio",
20365
+ "detection",
20366
+ "sensor",
20367
+ "control",
20368
+ "custom",
20369
+ "package"
19677
20370
  ]);
19678
- var PipelineEngineChoiceSchema = object({
19679
- runtime: _enum(["node", "python"]),
19680
- backend: string(),
19681
- format: ModelFormatSchema$1,
19682
- device: string().optional()
20371
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
20372
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
20373
+ var EventKindDescriptorSchema = object({
20374
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
20375
+ kind: string(),
20376
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
20377
+ labelKey: string(),
20378
+ /** English fallback label (kept for clients that don't translate). */
20379
+ label: string(),
20380
+ /** Hex color for timeline/legend rendering. */
20381
+ color: string(),
20382
+ /** Dictionary id → lucide component on the UI side. */
20383
+ iconId: string(),
20384
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
20385
+ icon: EventKindIconSchema,
20386
+ category: EventKindCategorySchema,
20387
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
20388
+ parentKind: string().nullable(),
20389
+ /** Derived from `parentKind`, explicit for the client tree. */
20390
+ level: EventKindLevelSchema,
20391
+ /** Which cap + device contributes this kind. For built-ins the camera
20392
+ * itself; for sensor kinds the LINKED source device. */
20393
+ source: object({
20394
+ capName: string(),
20395
+ deviceId: number()
20396
+ })
19683
20397
  });
19684
- var AvailableEngineSchema = object({
19685
- engine: PipelineEngineChoiceSchema,
19686
- devices: array(object({
19687
- id: string(),
19688
- label: string(),
19689
- description: string().optional()
19690
- })).readonly(),
19691
- defaultDevice: string()
20398
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
20399
+ var EventKindsForDeviceSchema = object({
20400
+ deviceId: number(),
20401
+ kinds: array(EventKindDescriptorSchema).readonly()
19692
20402
  });
19693
- var PipelineDefaultStepSchema = lazy(() => object({
19694
- addonId: string(),
19695
- addonName: string(),
19696
- slot: PipelineSlotSchema,
19697
- inputClasses: array(string()).readonly(),
19698
- outputClasses: array(string()).readonly(),
19699
- enabled: boolean(),
19700
- modelId: string(),
19701
- children: array(PipelineDefaultStepSchema).readonly(),
19702
- group: string().optional(),
19703
- settings: record(string(), unknown()).optional()
19704
- }));
19705
- var PipelineTemplateStepSchema = lazy(() => object({
19706
- addonId: string(),
19707
- enabled: boolean(),
19708
- modelId: string(),
19709
- children: array(PipelineTemplateStepSchema).readonly(),
19710
- settings: record(string(), unknown()).optional()
19711
- }));
19712
- var PipelineTemplateSchema$1 = object({
20403
+ var SensorEventSchema = object({
19713
20404
  id: string(),
19714
- name: string(),
19715
- createdAt: string(),
19716
- updatedAt: string(),
19717
- engine: PipelineEngineChoiceSchema,
19718
- steps: array(PipelineTemplateStepSchema).readonly()
19719
- });
19720
- var PipelineModelOptionSchema = object({
19721
- id: string(),
19722
- name: string(),
19723
- formats: record(string(), object({
19724
- downloaded: boolean(),
19725
- sizeMB: number()
19726
- })),
19727
- group: ModelVariantGroupSchema.optional(),
19728
- legacy: boolean().optional(),
19729
- provider: ModelProviderIdSchema.optional()
19730
- });
19731
- var ConfigFieldBridge = custom();
19732
- var PipelineAddonSchemaSchema = object({
19733
- id: string(),
19734
- name: string(),
19735
- slot: PipelineSlotSchema,
19736
- inputClasses: array(string()).readonly(),
19737
- outputClasses: array(string()).readonly(),
19738
- childSlots: array(PipelineSlotSchema).readonly(),
19739
- models: array(PipelineModelOptionSchema).readonly(),
19740
- defaultModelId: string(),
19741
- defaultModelIdByFormat: record(string(), string()).optional(),
19742
- enabledByDefault: boolean().optional(),
19743
- backfillIntoExistingOverrides: boolean().optional(),
19744
- defaultConfidence: number(),
19745
- group: string().optional(),
19746
- configSchema: array(ConfigFieldBridge).readonly().optional()
19747
- });
19748
- var PipelineSlotSchemaSchema = object({
19749
- id: PipelineSlotSchema,
19750
- label: string(),
19751
- priority: number(),
19752
- parentSlot: PipelineSlotSchema.nullable(),
19753
- addons: array(PipelineAddonSchemaSchema).readonly()
19754
- });
19755
- var PipelineSchemaSchema = object({
19756
- availableEngines: array(AvailableEngineSchema).readonly(),
19757
- selectedEngine: PipelineEngineChoiceSchema,
19758
- slots: array(PipelineSlotSchemaSchema).readonly()
19759
- });
19760
- var EngineProvisioningSchema = object({
19761
- runtimeId: _enum([
19762
- "onnx",
19763
- "openvino",
19764
- "coreml",
19765
- "edgetpu"
19766
- ]).nullable(),
19767
- device: string().nullable(),
19768
- state: _enum([
19769
- "idle",
19770
- "installing",
19771
- "verifying",
19772
- "ready",
19773
- "failed"
19774
- ]),
19775
- progress: number().optional(),
19776
- error: string().optional(),
19777
- nextRetryAt: number().optional(),
19778
- /**
19779
- * Gate A (config-correctness gate at engine change): human-readable
19780
- * config issues surfaced EAGERLY when the node's engine changes — model
19781
- * substitutions ("chose X, running Y") and zero-build steps ("no model
19782
- * has a <format> build"). Additive/optional: informational only, never
19783
- * enforced here — `assertEngineReady` (readiness) still gates inference.
19784
- * Absent/empty when the node-default tree resolves cleanly.
19785
- */
19786
- configIssues: array(string()).optional()
19787
- });
19788
- var PipelineStepInputSchema = lazy(() => object({
19789
- addonId: string(),
19790
- modelId: string().optional(),
19791
- enabled: boolean().default(true),
19792
- children: array(PipelineStepInputSchema).optional(),
19793
- settings: record(string(), unknown()).optional(),
19794
- jumpDeviceKey: string().optional()
19795
- }));
19796
- var ModelSubstitutionSchema = object({
19797
- addonId: string(),
19798
- chosen: string(),
19799
- running: string(),
19800
- format: string()
19801
- });
19802
- var PipelineValidationIssueSchema = object({
19803
- addonId: string(),
19804
- kind: _enum(["unknown-addon", "no-format-build"]),
19805
- detail: string()
19806
- });
19807
- var PipelineValidationResultSchema = object({
19808
- ok: boolean(),
19809
- issues: array(PipelineValidationIssueSchema).readonly(),
19810
- substitutions: array(ModelSubstitutionSchema).readonly(),
19811
- /** The node's `currentEngine.format` this validation ran against. */
19812
- format: string()
19813
- });
19814
- var ReferenceImageEntrySchema = object({
19815
- filename: string(),
19816
- stepIds: array(string()).readonly().optional()
19817
- });
19818
- var ReferenceImageBodySchema = object({
19819
- base64: string(),
19820
- filename: string()
19821
- });
19822
- var ReferenceAudioEntrySchema = object({
19823
- filename: string(),
19824
- sizeKb: number()
19825
- });
19826
- var ReferenceAudioBodySchema = object({ base64: string() });
19827
- var AudioBackendSchema = object({
19828
- id: string(),
19829
- name: string(),
19830
- description: string(),
19831
- available: boolean(),
19832
- /**
19833
- * Raw classifier labels this backend can emit (e.g. YAMNet's
19834
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
19835
- * the benchmark UI to populate the `enabledMicroClasses` filter
19836
- * specific to the selected backend without a separate fetch.
19837
- */
19838
- rawLabels: array(string()).readonly().optional()
19839
- });
19840
- var AudioCapabilitiesSchema = object({
19841
- activeBackend: string(),
19842
- availableBackends: array(AudioBackendSchema).readonly(),
19843
- sampleRate: number(),
19844
- chunkDurationMs: number()
19845
- });
19846
- var DownloadModelResultSchema = object({
19847
- filePath: string(),
19848
- sizeMB: number(),
19849
- durationMs: number()
19850
- });
19851
- /**
19852
- * Wrapper carrying a single test run's result. Replaces the legacy
19853
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
19854
- * canonical `AudioResult` from the Phase 6 output rework: one
19855
- * `AudioDetection` per class above `minScore`, top-N candidates in
19856
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
19857
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
19858
- * benchmark UI can still report a clean failure when the classifier
19859
- * cap isn't available.
19860
- */
19861
- var AudioTestResultSchema = object({
19862
- success: boolean(),
19863
- error: string().optional(),
19864
- frame: custom().optional()
19865
- });
19866
- var PipelineConfigBridge = custom();
19867
- var ConfigUISchemaBridge = custom();
19868
- var ConfigUISchemaNullableBridge = custom();
19869
- var InferenceCapabilitiesBridge = custom();
19870
- var ModelAvailabilityListBridge = custom();
19871
- var PipelineRunResultBridge = custom();
19872
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
19873
- modelId: string(),
19874
- settings: record(string(), unknown()).readonly()
19875
- }))), method(object({ steps: record(string(), object({
19876
- modelId: string(),
19877
- settings: record(string(), unknown()).readonly()
19878
- })) }), object({ success: literal(true) }), {
19879
- kind: "mutation",
19880
- auth: "admin"
19881
- }), method(object({ nodeId: string() }), object({
19882
- success: literal(true),
19883
- clearedDevices: number()
19884
- }), {
19885
- kind: "mutation",
19886
- auth: "admin"
19887
- }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
19888
- /** `<backend>:<device>`, e.g. `openvino:gpu`. */
19889
- deviceKey: string(),
19890
- /**
19891
- * `failed` — the per-device restart budget is exhausted; no pool
19892
- * will be spawned until an operator re-arms it or the runner
19893
- * respawns. `backoff` — under budget, waiting out the backoff (or
19894
- * a cached pool observed dead and not yet condemned).
19895
- */
19896
- state: _enum(["failed", "backoff"]),
19897
- /** Epoch ms of the death that produced this state. */
19898
- since: number(),
19899
- /** Pool deaths inside the current window. */
19900
- deaths: number(),
19901
- /** The last death's message. */
19902
- lastError: string()
19903
- })).readonly() })), method(object({
19904
- nodeId: string(),
19905
- deviceKey: string()
19906
- }), object({ rearmed: boolean() }), {
19907
- kind: "mutation",
19908
- auth: "admin"
19909
- }), method(_void(), PipelineSchemaSchema), method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()), method(_void(), PipelineConfigBridge), method(_void(), ConfigUISchemaBridge), method(object({ steps: array(PipelineStepInputSchema) }), PipelineValidationResultSchema), method(_void(), array(PipelineTemplateSchema$1).readonly()), method(object({
19910
- name: string(),
19911
- steps: array(PipelineTemplateStepSchema).readonly(),
19912
- engine: PipelineEngineChoiceSchema
19913
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
19914
- id: string(),
19915
- name: string().optional(),
19916
- steps: array(PipelineTemplateStepSchema).readonly().optional()
19917
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
19918
- addonId: string(),
19919
- modelId: string(),
19920
- format: ModelFormatSchema$1
19921
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
19922
- addonId: string(),
19923
- modelId: string(),
19924
- format: ModelFormatSchema$1
19925
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
19926
- engine: PipelineEngineChoiceSchema.optional(),
19927
- steps: array(PipelineStepInputSchema).min(1),
19928
- frame: FrameInputSchema.optional(),
19929
- /**
19930
- * Process-local lazy frame. Valid only when caller and provider resolve
19931
- * in the same execution-group process; split/cross-node callers use
19932
- * `frame`/`image` inline compatibility instead.
19933
- */
19934
- frameRef: FrameRefSchema.optional(),
19935
- /**
19936
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
19937
- * the decoded pixels live in. One more member of the one-of
19938
- * frame/frameHandle/image/imageBase64/referenceImage group.
19939
- */
19940
- frameHandle: FrameHandleSchema.optional(),
19941
- imageBase64: string().optional(),
19942
- /**
19943
- * Binary JPEG bytes — preferred over `imageBase64` on internal
19944
- * hops (hub → forked worker via Moleculer MsgPack) because it
19945
- * skips the 33% base64 overhead + the per-call base64 decode on
19946
- * the detection-pipeline worker. Callers can pass either; exactly
19947
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
19948
- */
19949
- image: _instanceof(Uint8Array).optional(),
19950
- referenceImage: string().optional(),
19951
- deviceId: number().optional(),
19952
- sessionId: string().optional(),
19953
- /**
19954
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
19955
- * reference-image, and detail-subtree calls. 'frame' is the live
19956
- * per-frame dispatch: ONLY root-plane steps run; crop children
19957
- * (inputClasses ≠ null) are skipped and served per-track via
19958
- * pipelineRunner.runDetailSubtree (two-plane design).
19959
- */
19960
- plane: _enum(["full", "frame"]).optional(),
19961
- /**
19962
- * Inference-device selector (Phase 2 multi-device). Format
19963
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
19964
- * Omitted ⇒ the runner's default device (current single-engine
19965
- * behaviour). Selects WHICH device pool of the node runs the call.
19966
- */
19967
- deviceKey: string().optional(),
19968
- /**
19969
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
19970
- * when the parent crop was resolved from the frame's retained NATIVE
19971
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
19972
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
19973
- * resolution from that surface — the SAME quality path faces already
19974
- * had — instead of the downscaled parent tile. `handle` keys the native
19975
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
19976
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
19977
- * the executor's crop-normalized child ROI back into frame-normalized
19978
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
19979
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
19980
- * (today's behaviour on the fallback path).
19981
- */
19982
- nativeCropRef: NativeCropRefSchema.optional()
19983
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
19984
- engine: PipelineEngineChoiceSchema.optional(),
19985
- steps: array(PipelineStepInputSchema).min(1),
19986
- frames: array(FrameInputSchema).min(1).max(255),
19987
- deviceId: number().optional(),
19988
- sessionId: string().optional(),
19989
- /**
19990
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
19991
- * the batch to the Python pool's bench preprocess cache
19992
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
19993
- * preprocessed ONCE and every later inference is a pure-inference cache
19994
- * hit — the sustained-throughput run measures inference, not
19995
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
19996
- * full preprocess every call, correct). Fresh per sustained run;
19997
- * released via `uncacheFrame`.
19998
- */
19999
- frameId: number().int().nonnegative().optional(),
20000
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
20001
- deviceKey: string().optional()
20002
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
20003
- data: _instanceof(Uint8Array),
20004
- width: number().int().positive(),
20005
- height: number().int().positive(),
20006
- format: _enum([
20007
- "rgb",
20008
- "bgr",
20009
- "gray"
20010
- ])
20011
- }), object({
20012
- frameId: number(),
20013
- width: number(),
20014
- height: number()
20015
- }), { kind: "mutation" }), method(object({
20016
- stepId: string(),
20017
- frameId: number().int()
20018
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
20019
- batchMode: string(),
20020
- windowMs: number(),
20021
- maxBatchSize: number(),
20022
- concurrency: number()
20023
- })), method(_void(), array(object({
20024
- engineKey: string(),
20025
- engine: PipelineEngineChoiceSchema,
20026
- modelsLoaded: array(string()).readonly(),
20027
- inUseByCameras: array(number()).readonly(),
20028
- /**
20029
- * Origin of this resident factory.
20030
- * - `runtime` — main camera-serving engine (no idle TTL).
20031
- * - `warm-override` — benchmark/test override held in the warm
20032
- * cache; auto-disposed after the idle TTL.
20033
- * - `device-pool` — a concurrent per-device pool (Phase 2
20034
- * multi-device, keyed by `deviceKey`) resolved
20035
- * via `resolveDeviceFactory`. Runs alongside the
20036
- * `runtime` engine on a DIFFERENT accelerator
20037
- * (NPU / iGPU / Coral) — this is how the
20038
- * Engines tab shows all pools running at once.
20039
- */
20040
- kind: _enum([
20041
- "runtime",
20042
- "warm-override",
20043
- "device-pool"
20044
- ]),
20045
- /** Native pid of the underlying Python pool (null when no pool). */
20046
- poolPid: number().nullable(),
20047
- /** ms since this factory was last used (null when not warm-tracked). */
20048
- idleMs: number().nullable(),
20049
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
20050
- idleTtlMs: number().nullable()
20051
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
20052
- kind: "mutation",
20053
- auth: "admin"
20054
- }), method(object({
20055
- engine: PipelineEngineChoiceSchema,
20056
- force: boolean().optional()
20057
- }), object({
20058
- success: boolean(),
20059
- reason: string().optional()
20060
- }), {
20061
- kind: "mutation",
20062
- auth: "admin"
20063
- }), method(_void(), array(ReferenceImageEntrySchema).readonly()), method(object({ filename: string() }), ReferenceImageBodySchema.nullable()), method(_void(), array(ReferenceAudioEntrySchema).readonly()), method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()), method(_void(), AudioCapabilitiesSchema), method(object({
20064
- addonId: string(),
20065
- modelId: string(),
20066
- filename: string().optional(),
20067
- settings: record(string(), unknown()).optional()
20068
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
20069
- /**
20070
- * Per-stage gating mode applied to the zones a rule references.
20071
- *
20072
- * - `include`: the rule contributes to a **whitelist** for its stage.
20073
- * When at least one `include` rule fires for a stage, only entities
20074
- * inside one of those zones pass that stage.
20075
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
20076
- * Entities inside one of those zones are dropped at that stage.
20077
- *
20078
- * `monitor`-style observation (count without filtering) is not a rule
20079
- * mode — zones without any matching rule are observed naturally by
20080
- * `zone-analytics` (live snapshot + history), so an "I just want to
20081
- * count, not filter" use case needs no rule at all.
20082
- */
20083
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
20084
- /**
20085
- * Per-consumer rule that references existing zones (geometry) and
20086
- * defines how a specific pipeline stage should treat them. Each
20087
- * consumer addon owns its own `ZoneRule[]` array in its per-device
20088
- * settings:
20089
- *
20090
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
20091
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
20092
- * - future: notification rules, audio gating, etc.
20093
- *
20094
- * One rule applies to N zones (`zoneIds[]`) so the operator can
20095
- * express "ignore motion in ALL of {garden, street}" with a single
20096
- * rule. `classFilter` narrows the rule to specific object classes —
20097
- * "drop person detections in the street, but keep cars" is one
20098
- * `exclude` rule with `classFilter: ['person']`.
20099
- *
20100
- * `enabled` is a soft toggle — the operator can keep the rule
20101
- * configured but inert without deleting it.
20102
- */
20103
- var ZoneRuleSchema = object({
20104
- /** Stable rule id — survives edits, used by the UI for diffing. */
20105
- id: string(),
20106
- /** Optional human-readable label rendered in the rule editor. */
20107
- name: string().optional(),
20108
- /** Zones this rule targets. The rule's `mode` applies to ALL
20109
- * listed zones (OR-set: a detection in any one of them counts).
20110
- * At least one zone id required — a rule with no targets is a
20111
- * configuration mistake and the form validator rejects it. */
20112
- zoneIds: array(string()).min(1).readonly(),
20113
- mode: ZoneRuleModeEnum,
20114
- /**
20115
- * Class names this rule applies to. Empty / undefined ⇒ rule
20116
- * applies to every class. Class strings match the `macroClass`
20117
- * field on detections (e.g. `person`, `car`, `dog`).
20118
- */
20119
- classFilter: array(string()).readonly().optional(),
20120
- /**
20121
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
20122
- * required to consider an entity "in the zone". Defaults to the
20123
- * consumer's stage default when omitted. Kept for back-compat with
20124
- * existing per-rule overrides; new operators pick the value via
20125
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
20126
- * set, the lower-level engine reads it as a 0–1 fraction.
20127
- */
20128
- overlapThreshold: number().min(0).max(1).optional(),
20129
- /**
20130
- * Operator-friendly version of `overlapThreshold` — the percentage
20131
- * of the detection's bbox that must lie inside the zone for the
20132
- * rule to match. Documented default is 85%; the engine substitutes
20133
- * that when the field is omitted (kept optional so existing rules
20134
- * stored without it stay valid).
20135
- *
20136
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
20137
- * rule, the engine prefers `bboxInclusionPct` because it's the
20138
- * field exposed in the UI. Internally both feed the same gate.
20139
- */
20140
- bboxInclusionPct: number().min(0).max(100).optional(),
20141
- /**
20142
- * When `true` and a detection has a segmentation mask, use the
20143
- * mask for overlap instead of the bbox. Detection-stage only;
20144
- * motion rules ignore this field.
20145
- */
20146
- preferMask: boolean().optional(),
20147
- /**
20148
- * Soft-toggle: `false` disables the rule without deleting it.
20149
- * Defaults to `true` so operators creating a rule via the UI
20150
- * see it active immediately.
20151
- */
20152
- enabled: boolean().default(true)
20153
- });
20154
- array(ZoneRuleSchema).readonly();
20155
- /**
20156
- * Zone — pure geometry + identity. NO filtering behaviour.
20157
- *
20158
- * Zones describe **where** in the frame the operator wants to flag
20159
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
20160
- * each pipeline stage uses them. Splitting the two means a single
20161
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
20162
- * a detection-include rule on `['car']`, and an occupancy aggregate
20163
- * — without three duplicated polygons.
20164
- *
20165
- * Owned by the orchestrator addon (provider) and mirrored into the
20166
- * `zones` device-state slice on every mutation. Consumers
20167
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
20168
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
20169
- * mirror with `onChanged`).
20170
- *
20171
- * Coordinates are normalised fractions of the frame (0–1) so zones
20172
- * survive resolution changes and stream profile switches.
20173
- *
20174
- * `kind` discriminates between full polygons (closed regions used
20175
- * for intrusion / occupancy filters) and tripwires (open 2-point
20176
- * line segments used for cross events). Onboard / firmware-reported
20177
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
20178
- * task list.
20179
- */
20180
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
20181
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
20182
- var PolygonPointSchema = object({
20183
- x: number(),
20184
- y: number()
20185
- });
20186
- /** A camera detection zone — pure geometry/identity. */
20187
- var ZoneSchema = object({
20188
- id: string(),
20189
- name: string(),
20190
- kind: ZoneKindEnum.default("polygon"),
20191
- /** Polygon vertices, fraction of frame (0–1). */
20192
- polygon: array(PolygonPointSchema).readonly(),
20193
- /** Visual color for UI rendering. */
20194
- color: string().default("#3b82f6")
20195
- });
20196
- /**
20197
- * Zones capability — per-camera CRUD over polygon detection zones.
20198
- *
20199
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
20200
- * to per-device settings and mirrors into the `zones` device-state
20201
- * slice on every mutation, so downstream consumers can subscribe via
20202
- * `dev.state.zones.onChanged`.
20203
- *
20204
- * The cap surface only handles geometry + identity; filtering
20205
- * behaviour (per-class, include/exclude, threshold) lives in the
20206
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
20207
- * `capabilities/schemas/zone-rule.js`.
20208
- */
20209
- var zonesCapability = {
20210
- name: "zones",
20211
- scope: "device",
20212
- mode: "singleton",
20213
- deviceTypes: [DeviceType.Camera],
20214
- methods: {
20215
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
20216
- addZone: method(object({
20217
- deviceId: number(),
20218
- zone: ZoneSchema
20219
- }), _void(), {
20220
- kind: "mutation",
20221
- auth: "admin"
20222
- }),
20223
- removeZone: method(object({
20224
- deviceId: number(),
20225
- zoneId: string()
20226
- }), _void(), {
20227
- kind: "mutation",
20228
- auth: "admin"
20229
- }),
20230
- updateZone: method(object({
20231
- deviceId: number(),
20232
- zone: ZoneSchema
20233
- }), _void(), {
20234
- kind: "mutation",
20235
- auth: "admin"
20236
- })
20237
- },
20238
- /**
20239
- * Runtime-state slice — the live zone catalogue mirrored by the
20240
- * orchestrator on every CRUD mutation. Consumers read via
20241
- * `device.state.zones.value` / `.watch(...)` without round-tripping
20242
- * the cap, and the codegen DeviceProxy auto-wires the reactive
20243
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
20244
- * (e.g. zone groupings) can sit alongside the polygon list.
20245
- */
20246
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
20247
- /**
20248
- * 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.
20249
- *
20250
- * See `RuntimeStateDurability`. Enforced by
20251
- * `scripts/check-runtime-state-durability.ts`.
20252
- */
20253
- durability: "restored"
20254
- };
20255
- /**
20256
- * pipeline-analytics — device-scoped wrapper cap. Refines raw
20257
- * per-frame detections emitted by the pipeline runner into tracked
20258
- * objects, per-kind event collections (motion / object / audio), and
20259
- * persisted media. Owns the post-detection domain end-to-end:
20260
- *
20261
- * runner emits PipelineInferenceResult
20262
- * ↓ (event bus)
20263
- * pipeline-analytics subscriber
20264
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
20265
- * → three DB collections (one per kind), one FS media tree, one
20266
- * unified event emitter (FrameTracked + TrackStarted/Ended +
20267
- * DetectionEvent on bus)
20268
- *
20269
- * Pure subscriber model. No `processFrame` cap method — the runner
20270
- * already publishes the raw frame on the bus. The cap surface is
20271
- * only QUERIES + per-device settings, bound on/off via
20272
- * `device-manager.setWrapperActive`. `defaultActive: true` because
20273
- * every camera with a detection pipeline wants its raw detections
20274
- * refined; operators opt out per-device via BindingsTab when needed.
20275
- *
20276
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
20277
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
20278
- */
20279
- var TrackStateSchema = _enum([
20280
- "new",
20281
- "entered",
20282
- "left",
20283
- "moving",
20284
- "idle"
20285
- ]);
20286
- var EventKindSchema = _enum([
20287
- "motion",
20288
- "object",
20289
- "audio"
20290
- ]);
20291
- /**
20292
- * Spatial filter for `listTracks` — the rect + polygon variants of the shared
20293
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
20294
- * of the camera frame (top-left origin), matching the drawing-plane editor.
20295
- */
20296
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
20297
- /** Closed icon vocabulary so clients render a known glyph per kind. */
20298
- var EventKindIconSchema = _enum([
20299
- "motion",
20300
- "audio",
20301
- "person",
20302
- "vehicle",
20303
- "animal",
20304
- "door",
20305
- "pir",
20306
- "smoke",
20307
- "water",
20308
- "button",
20309
- "package",
20310
- "generic"
20311
- ]);
20312
- var EventKindCategorySchema = _enum([
20313
- "motion",
20314
- "audio",
20315
- "detection",
20316
- "sensor",
20317
- "control",
20318
- "custom",
20319
- "package"
20320
- ]);
20321
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
20322
- var EventKindLevelSchema = _enum(["macro", "sub"]);
20323
- var EventKindDescriptorSchema = object({
20324
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
20325
- kind: string(),
20326
- /** i18n key resolved on the UI side; `label` is the English fallback. */
20327
- labelKey: string(),
20328
- /** English fallback label (kept for clients that don't translate). */
20329
- label: string(),
20330
- /** Hex color for timeline/legend rendering. */
20331
- color: string(),
20332
- /** Dictionary id → lucide component on the UI side. */
20333
- iconId: string(),
20334
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
20335
- icon: EventKindIconSchema,
20336
- category: EventKindCategorySchema,
20337
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
20338
- parentKind: string().nullable(),
20339
- /** Derived from `parentKind`, explicit for the client tree. */
20340
- level: EventKindLevelSchema,
20341
- /** Which cap + device contributes this kind. For built-ins the camera
20342
- * itself; for sensor kinds the LINKED source device. */
20343
- source: object({
20344
- capName: string(),
20345
- deviceId: number()
20346
- })
20347
- });
20348
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
20349
- var EventKindsForDeviceSchema = object({
20350
- deviceId: number(),
20351
- kinds: array(EventKindDescriptorSchema).readonly()
20352
- });
20353
- var SensorEventSchema = object({
20354
- id: string(),
20355
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
20356
- * yields N rows, one per camera). */
20357
- deviceId: number(),
20358
- /** The linked sensor device whose state changed. */
20359
- sourceDeviceId: number(),
20360
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
20361
- kind: string(),
20362
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
20363
- value: record(string(), unknown()).nullable(),
20364
- timestamp: number()
20405
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
20406
+ * yields N rows, one per camera). */
20407
+ deviceId: number(),
20408
+ /** The linked sensor device whose state changed. */
20409
+ sourceDeviceId: number(),
20410
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
20411
+ kind: string(),
20412
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
20413
+ value: record(string(), unknown()).nullable(),
20414
+ timestamp: number()
20365
20415
  });
20366
20416
  /**
20367
20417
  * One stored sighting on a track's trajectory.
@@ -20823,6 +20873,22 @@ var TrackSchema = object({
20823
20873
  * omit it. Render nothing when absent.
20824
20874
  */
20825
20875
  previewMissReason: string().optional(),
20876
+ /**
20877
+ * The ROOT model that produced this track — the `FrameResult.rootModelId` of
20878
+ * the frame it was BORN on (D646). What a later replay compares against, so
20879
+ * "the original model" is named rather than assumed. A birth fact: never
20880
+ * rewritten by a later frame. **Absent ≠ unknown-model**: a row from before
20881
+ * the column, and a track the camera's own detector produced, carry none.
20882
+ */
20883
+ modelId: string().optional(),
20884
+ /**
20885
+ * Size (px) of the detection frame this track's `positions[].bbox` live in —
20886
+ * the frame it was born on, else the camera's latest analysis frame at
20887
+ * persist time. Divide a position by these to normalise it. Absent when the
20888
+ * size was never known.
20889
+ */
20890
+ frameWidth: number().optional(),
20891
+ frameHeight: number().optional(),
20826
20892
  ...TrackFlagFields,
20827
20893
  ...TrackRetrainFields
20828
20894
  });
@@ -21052,7 +21118,8 @@ var MediaFileKindEnum = _enum([
21052
21118
  "thumbnailSmall",
21053
21119
  "confirmationCrop",
21054
21120
  "debugCrop",
21055
- "sceneFrame"
21121
+ "sceneFrame",
21122
+ "lastSceneFrame"
21056
21123
  ]);
21057
21124
  /**
21058
21125
  * One media row ON THE WIRE: what it is, how big it is, and WHERE ITS BYTES
@@ -21604,7 +21671,23 @@ var SearchObjectEventsInput = object({
21604
21671
  until: number().optional(),
21605
21672
  classFilter: string().optional(),
21606
21673
  limit: number().default(50),
21607
- minScore: number().min(0).max(1).default(.2)
21674
+ /**
21675
+ * An ABSOLUTE cosine floor. Optional since D649: a floor is a property of the
21676
+ * model (0.2 kept 96% of matched pairs on MobileCLIP S1 and 2.7% on SigLIP2),
21677
+ * so an absent one resolves to the searched model's own `searchMinScore`
21678
+ * scaled by `strictness`. A number sent here is honoured verbatim.
21679
+ */
21680
+ minScore: number().min(0).max(1).optional(),
21681
+ /** Model-relative floor — see `resolveClipSearchMinScore`. Default `loose`. */
21682
+ strictness: ClipSearchStrictnessSchema.optional(),
21683
+ /**
21684
+ * Search THIS CLIP model's index instead of the cluster row's. Every index a
21685
+ * model ever wrote stays searchable until it is wiped (the MobileCLIP index
21686
+ * through a SigLIP2 cutover and its rollback window). An id with no CLIP
21687
+ * metadata is refused; an id other than the cluster row's is ADMIN-only
21688
+ * (`model-override-requires-admin`).
21689
+ */
21690
+ modelId: string().min(1).optional()
21608
21691
  });
21609
21692
  var TrackCascadeCountsSchema = object({
21610
21693
  /** Persisted track roots deleted (authoritative). */
@@ -21739,7 +21822,41 @@ var RebuildObjectEmbeddingsInput = object({
21739
21822
  * comparable, so wiping and rebuilding is the only way to be sure every vector
21740
21823
  * means the same thing.
21741
21824
  */
21742
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
21825
+ var WipeObjectEmbeddingsResultSchema = object({
21826
+ deleted: number(),
21827
+ /**
21828
+ * CLIP indexes that could NOT be emptied (unreachable, or refused at their
21829
+ * dimension) — not a clean slate. Additive and optional (D649).
21830
+ */
21831
+ failedIndexes: array(string()).optional()
21832
+ });
21833
+ /**
21834
+ * Why a rebuild did not start, BY NAME — ONE vocabulary for both gates in front
21835
+ * of a pass (D649 over D651). A bare `started: false` read the same for "the
21836
+ * stores are booting" and "the cluster row names a model with no CLIP
21837
+ * metadata", which need different fixes.
21838
+ * - `stores-unavailable` — the analytics stores or the API are not up yet.
21839
+ * - the owner's confirmation of the cluster model (D651, `ClusterPinConfirmer`):
21840
+ * a pass that rewrites an index needs two agreeing reads of the OWNER's
21841
+ * answer (`pipelineOrchestrator.getClusterModelChoice`) — a pass that cannot
21842
+ * name its model does not run (D54):
21843
+ * - the owner's own `unreadable` reasons (`owner-not-ready`,
21844
+ * `store-read-failed`, `three-way-read-unavailable`, `invalid-stored`,
21845
+ * `not-cluster-scoped`);
21846
+ * - `method-unavailable` — the orchestrator predates the method;
21847
+ * - `read-failed` — the call failed or answered something unparseable;
21848
+ * - `reads-disagree` — the two reads named different choices.
21849
+ * - `not-a-clip-model` — the CONFIRMED id has no CLIP metadata, so there is no
21850
+ * index to fill and no dimension to check against (D649).
21851
+ */
21852
+ var RebuildObjectEmbeddingsRefusalSchema = _enum([
21853
+ "stores-unavailable",
21854
+ ...CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS,
21855
+ "method-unavailable",
21856
+ "read-failed",
21857
+ "reads-disagree",
21858
+ "not-a-clip-model"
21859
+ ]);
21743
21860
  /**
21744
21861
  * Acknowledgement that a rebuild STARTED.
21745
21862
  *
@@ -21752,7 +21869,12 @@ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
21752
21869
  var RebuildObjectEmbeddingsResultSchema = object({
21753
21870
  started: boolean(),
21754
21871
  /** True when a pass was already running; the new request is ignored. */
21755
- alreadyRunning: boolean()
21872
+ alreadyRunning: boolean(),
21873
+ /** Present when the pass refused to start — see `RebuildObjectEmbeddingsRefusalSchema`. */
21874
+ refusal: RebuildObjectEmbeddingsRefusalSchema.optional(),
21875
+ /** The CLIP model the pass pinned, and the index it fills (when it started). */
21876
+ modelId: string().optional(),
21877
+ index: string().optional()
21756
21878
  });
21757
21879
  var RebuildStatusSchema = object({
21758
21880
  running: boolean(),
@@ -21786,7 +21908,11 @@ var RebuildStatusSchema = object({
21786
21908
  startedAtMs: number().nullable(),
21787
21909
  finishedAtMs: number().nullable(),
21788
21910
  /** Present when the pass ended by throwing. */
21789
- error: string().nullable()
21911
+ error: string().nullable(),
21912
+ /** The CLIP model the current / last pass pinned (D54), `null` before any. */
21913
+ modelId: string().nullable(),
21914
+ /** The index that pass fills — `ClipModelMeta.vectorIndex` of `modelId` (D649). */
21915
+ index: string().nullable()
21790
21916
  });
21791
21917
  /**
21792
21918
  * Acknowledgement that a debug-media reclaim STARTED.
@@ -21829,24 +21955,6 @@ var MediaReclaimStatusSchema = object({
21829
21955
  finishedAtMs: number().nullable(),
21830
21956
  error: string().nullable()
21831
21957
  });
21832
- var ReplayFrameInputSchema = object({
21833
- timestamp: number(),
21834
- frame: PipelineRunResultBridge
21835
- });
21836
- var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
21837
- className: string(),
21838
- firstSeenMs: number(),
21839
- lastSeenMs: number(),
21840
- /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
21841
- * frame — a representative box for the diff's `(className, window, IoU)`
21842
- * pairing (`replay-diff.ts`). A replay does not need the full per-frame
21843
- * trajectory production's `Track.positions` keeps. */
21844
- bbox: BoundingBoxSchema,
21845
- /** How many of the input frames this track matched a real detection on
21846
- * (never a coasted/extrapolated frame) — the replay's own signal for "how
21847
- * solid is this track", cheaper than re-deriving it from a trajectory. */
21848
- framesMatched: number().int()
21849
- })).readonly() });
21850
21958
  /**
21851
21959
  * The long-term series a camera produces. A closed union so a typo cannot
21852
21960
  * invent one, and the ONE declaration of it — the addon's `AnalyticsLtsSeries`
@@ -21913,255 +22021,717 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
21913
22021
  }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(SummariesQueryInput, SummariesPageSchema), method(RecentSummariesQueryInput, RecentSummariesPageSchema), method(object({ id: string() }), SummaryDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
21914
22022
  kind: "mutation",
21915
22023
  auth: "admin"
21916
- }), method(DeviceEventQueryInput, array(MotionEventSchema).readonly()), method(ObjectEventQueryInput, array(ObjectEventSchema).readonly()), method(DeviceEventQueryInput, array(AudioEventSchema).readonly()), method(object({ deviceId: number() }), array(EventKindDescriptorSchema).readonly()), method(object({ deviceIds: array(number()).min(1).max(200) }), array(EventKindsForDeviceSchema).readonly()), method(object({
21917
- deviceId: number(),
21918
- since: number().optional(),
21919
- until: number().optional(),
21920
- kinds: array(string()).optional(),
21921
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
21922
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(KeyEventBatchQueryInput, array(KeyEventsForDeviceSchema).readonly()), method(object({
21923
- deviceId: number(),
21924
- series: AnalyticsLtsSeriesSchema,
21925
- /** Omit for EVERY scope of this series in the range. */
21926
- scope: string().optional(),
21927
- from: number(),
21928
- to: number(),
21929
- limit: number().int().positive().optional()
21930
- }), array(LtsBucketSchema).readonly()), method(object({
21931
- deviceId: number(),
21932
- since: number(),
21933
- until: number(),
21934
- bucketMs: number().int().positive()
21935
- }), array(EventDensityBucketSchema).readonly()), method(object({
21936
- deviceIds: array(number()).min(1).max(200),
21937
- since: number(),
21938
- until: number(),
21939
- bucketMs: number().int().positive()
21940
- }), array(EventDensityForDeviceSchema).readonly()), method(object({
21941
- deviceId: number(),
21942
- cutoffMs: number()
21943
- }), object({
21944
- motion: number().int(),
21945
- object: number().int(),
21946
- audio: number().int()
22024
+ }), method(DeviceEventQueryInput, array(MotionEventSchema).readonly()), method(ObjectEventQueryInput, array(ObjectEventSchema).readonly()), method(DeviceEventQueryInput, array(AudioEventSchema).readonly()), method(object({ deviceId: number() }), array(EventKindDescriptorSchema).readonly()), method(object({ deviceIds: array(number()).min(1).max(200) }), array(EventKindsForDeviceSchema).readonly()), method(object({
22025
+ deviceId: number(),
22026
+ since: number().optional(),
22027
+ until: number().optional(),
22028
+ kinds: array(string()).optional(),
22029
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
22030
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(KeyEventBatchQueryInput, array(KeyEventsForDeviceSchema).readonly()), method(object({
22031
+ deviceId: number(),
22032
+ series: AnalyticsLtsSeriesSchema,
22033
+ /** Omit for EVERY scope of this series in the range. */
22034
+ scope: string().optional(),
22035
+ from: number(),
22036
+ to: number(),
22037
+ limit: number().int().positive().optional()
22038
+ }), array(LtsBucketSchema).readonly()), method(object({
22039
+ deviceId: number(),
22040
+ since: number(),
22041
+ until: number(),
22042
+ bucketMs: number().int().positive()
22043
+ }), array(EventDensityBucketSchema).readonly()), method(object({
22044
+ deviceIds: array(number()).min(1).max(200),
22045
+ since: number(),
22046
+ until: number(),
22047
+ bucketMs: number().int().positive()
22048
+ }), array(EventDensityForDeviceSchema).readonly()), method(object({
22049
+ deviceId: number(),
22050
+ cutoffMs: number()
22051
+ }), object({
22052
+ motion: number().int(),
22053
+ object: number().int(),
22054
+ audio: number().int()
22055
+ }), {
22056
+ kind: "mutation",
22057
+ auth: "admin"
22058
+ }), method(object({
22059
+ deviceId: number(),
22060
+ cutoffMs: number()
22061
+ }), TrackCascadeCountsSchema, {
22062
+ kind: "mutation",
22063
+ auth: "admin"
22064
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
22065
+ kind: "mutation",
22066
+ auth: "admin"
22067
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
22068
+ kind: "mutation",
22069
+ auth: "admin"
22070
+ }), method(object({
22071
+ deviceId: number(),
22072
+ trackIds: array(string()).min(1)
22073
+ }), object({
22074
+ deleted: number().int(),
22075
+ failed: array(string()).readonly()
22076
+ }), {
22077
+ kind: "mutation",
22078
+ auth: "admin"
22079
+ }), method(object({
22080
+ /** Log/audit scope only — the trackId is globally unique on its own. */
22081
+ deviceId: number(),
22082
+ trackId: string(),
22083
+ flags: TrackFlagsPatchSchema
22084
+ }), TrackFlagsSchema, { kind: "mutation" }), method(ArchivedDebugNoteQueryInputSchema, array(ArchivedDebugNoteSchema).readonly(), { kind: "query" }), method(BirthDecisionQueryInputSchema, array(BirthDecisionRecordSchema).readonly(), { kind: "query" }), method(object({}), EventStoreFootprintSchema, {
22085
+ kind: "query",
22086
+ auth: "admin"
22087
+ }), method(object({ deviceId: number().int().optional() }), EventMediaKindBreakdownSchema, {
22088
+ kind: "query",
22089
+ auth: "admin"
22090
+ }), method(object({
22091
+ olderThanMs: number(),
22092
+ reason: OpsLogReasonSchema.optional()
22093
+ }), EventPruneCountsSchema, {
22094
+ kind: "mutation",
22095
+ auth: "admin"
22096
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
22097
+ kind: "mutation",
22098
+ auth: "admin"
22099
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
22100
+ kind: "mutation",
22101
+ auth: "admin"
22102
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
22103
+ kind: "mutation",
22104
+ auth: "admin"
22105
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
22106
+ kind: "mutation",
22107
+ auth: "admin"
22108
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
22109
+ kind: "mutation",
22110
+ auth: "admin"
22111
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
22112
+ kind: "mutation",
22113
+ auth: "admin"
22114
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
22115
+ kind: "mutation",
22116
+ auth: "admin"
22117
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
22118
+ kind: "query",
22119
+ auth: "admin"
22120
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
22121
+ kind: "query",
22122
+ auth: "admin"
22123
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
22124
+ kind: "mutation",
22125
+ auth: "admin"
22126
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
22127
+ kind: "query",
22128
+ auth: "admin"
22129
+ }), method(MediaReclaimInputSchema, MediaReclaimStartResultSchema, {
22130
+ kind: "mutation",
22131
+ auth: "admin"
22132
+ }), method(object({}), MediaReclaimStatusSchema, {
22133
+ kind: "query",
22134
+ auth: "admin"
22135
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
22136
+ kind: "query",
22137
+ auth: "admin"
22138
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
22139
+ kind: "query",
22140
+ auth: "admin"
22141
+ }), method(object({
22142
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
22143
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
22144
+ * route it at one camera's owner, and "every camera" would stop being
22145
+ * expressible at all. */
22146
+ deviceIds: array(number()).optional(),
22147
+ limit: number().int().min(1).max(500).optional()
22148
+ }), array(RetrainTrackSchema).readonly(), {
22149
+ kind: "query",
22150
+ auth: "admin"
22151
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
22152
+ kind: "query",
22153
+ auth: "admin"
22154
+ }), method(object({
22155
+ deviceId: number(),
22156
+ trackId: string(),
22157
+ mediaIds: array(number().int()).min(1)
22158
+ }), RetrainFrameSelectionSchema, {
22159
+ kind: "mutation",
22160
+ auth: "admin"
22161
+ }), method(object({
22162
+ deviceId: number(),
22163
+ trackId: string(),
22164
+ frameId: string()
22165
+ }), object({
22166
+ removed: boolean(),
22167
+ removedAnnotations: number().int()
22168
+ }), {
22169
+ kind: "mutation",
22170
+ auth: "admin"
22171
+ }), method(object({ frameId: string() }), object({
22172
+ base64: string(),
22173
+ width: number().int(),
22174
+ height: number().int()
22175
+ }), {
22176
+ kind: "query",
22177
+ auth: "admin"
22178
+ }), method(object({
22179
+ deviceId: number(),
22180
+ trackId: string(),
22181
+ frameId: string(),
22182
+ subject: RetrainAssistSubjectSchema,
22183
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
22184
+ nodeId: string().optional()
22185
+ }), RetrainAssistResultSchema, {
22186
+ kind: "mutation",
22187
+ auth: "admin"
22188
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
22189
+ kind: "query",
22190
+ auth: "admin"
22191
+ }), method(object({
22192
+ deviceId: number(),
22193
+ trackId: string(),
22194
+ frameId: string(),
22195
+ annotations: array(RetrainAnnotationDraftSchema)
22196
+ }), array(RetrainAnnotationSchema).readonly(), {
22197
+ kind: "mutation",
22198
+ auth: "admin"
22199
+ }), method(object({
22200
+ deviceId: number(),
22201
+ trackId: string()
22202
+ }), RetrainTransitionResultSchema, {
22203
+ kind: "mutation",
22204
+ auth: "admin"
22205
+ }), method(object({
22206
+ deviceId: number(),
22207
+ trackId: string()
22208
+ }), RetrainTransitionResultSchema, {
22209
+ kind: "mutation",
22210
+ auth: "admin"
22211
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
22212
+ kind: "query",
22213
+ auth: "admin"
22214
+ }), method(object({
22215
+ /** Which of the three event tables owns the row. */
22216
+ ownerType: EventOwnerTypeSchema,
22217
+ /** The event's rowid in that table (D474: an event id is a number). */
22218
+ eventId: number().int(),
22219
+ kind: MediaFileKindEnum.optional(),
22220
+ deviceId: number()
22221
+ }), array(MediaFileSchema).readonly()), method(object({
22222
+ trackId: string(),
22223
+ kinds: array(MediaFileKindEnum).optional(),
22224
+ deviceId: number()
22225
+ }), array(MediaFileSchema).readonly()), method(object({
22226
+ trackId: string(),
22227
+ deviceId: number()
22228
+ }), array(MediaFileInfoSchema).readonly()), method(object({
22229
+ ownerType: EventOwnerTypeSchema,
22230
+ eventId: number().int(),
22231
+ deviceId: number()
22232
+ }), array(MediaFileInfoSchema).readonly()), method(object({
22233
+ deviceId: number(),
22234
+ ownerKind: MediaPresenceOwnerKindSchema,
22235
+ ownerIds: array(string()).max(5e3)
22236
+ }), array(string()).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly(), { caller: "required" }), method(object({}), WipeObjectEmbeddingsResultSchema, {
22237
+ kind: "mutation",
22238
+ auth: "admin"
22239
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
22240
+ kind: "mutation",
22241
+ auth: "admin"
22242
+ }), method(object({}), RebuildStatusSchema), object({
22243
+ deviceId: number(),
22244
+ timestamp: number(),
22245
+ frameWidth: number(),
22246
+ frameHeight: number(),
22247
+ detections: array(OverlayDetectionSchema).readonly()
22248
+ }), object({
22249
+ deviceId: number(),
22250
+ trackId: string(),
22251
+ className: string()
22252
+ }), object({
22253
+ deviceId: number(),
22254
+ trackId: string(),
22255
+ className: string(),
22256
+ durationMs: number()
22257
+ }), object({
22258
+ deviceId: number(),
22259
+ kind: EventKindSchema,
22260
+ eventId: string(),
22261
+ timestamp: number()
22262
+ });
22263
+ /**
22264
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
22265
+ * within the frame, so the executor can re-cut a leaf child ROI at native
22266
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
22267
+ */
22268
+ var NativeCropRefSchema = object({
22269
+ /** Handle keying the retained native surface (node-pinned to its owner). */
22270
+ handle: FrameHandleSchema,
22271
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
22272
+ cropFrameSpace: object({
22273
+ x: number(),
22274
+ y: number(),
22275
+ w: number(),
22276
+ h: number()
22277
+ })
22278
+ });
22279
+ object({
22280
+ crop: object({
22281
+ left: number(),
22282
+ top: number(),
22283
+ width: number().positive(),
22284
+ height: number().positive()
22285
+ }).optional(),
22286
+ content: object({
22287
+ width: number().int().positive(),
22288
+ height: number().int().positive()
22289
+ }),
22290
+ fit: _enum(["stretch", "contain"]),
22291
+ format: _enum([
22292
+ "rgb",
22293
+ "gray",
22294
+ "jpeg"
22295
+ ])
22296
+ });
22297
+ /**
22298
+ * Process-local frame identity. It is serializable so it can ride an in-process
22299
+ * capability call, but `registryId` deliberately prevents resolution in any
22300
+ * other process or execution group.
22301
+ */
22302
+ var FrameRefSchema = object({
22303
+ registryId: string().min(1),
22304
+ id: string().min(1),
22305
+ width: number().int().positive(),
22306
+ height: number().int().positive(),
22307
+ format: _enum(["rgb", "gray"]),
22308
+ timestamp: number(),
22309
+ capturedAt: number().optional()
22310
+ });
22311
+ var ModelFormatSchema$1 = _enum([
22312
+ "onnx",
22313
+ "coreml",
22314
+ "openvino",
22315
+ "tflite",
22316
+ "pt",
22317
+ "gguf"
22318
+ ]);
22319
+ var PipelineSlotSchema = _enum([
22320
+ "detector",
22321
+ "cropper",
22322
+ "classifier",
22323
+ "refiner",
22324
+ "audio-classifier"
22325
+ ]);
22326
+ var PipelineEngineChoiceSchema = object({
22327
+ runtime: literal("python"),
22328
+ backend: string(),
22329
+ format: ModelFormatSchema$1,
22330
+ device: string().optional()
22331
+ });
22332
+ /**
22333
+ * One pool's resolved provisioning (`getEffectiveTuning`). `numWorkers` is the
22334
+ * knob that lifts a saturated pool (`inference-devices.md`); `concurrency` is
22335
+ * per-worker in-flight requests. `deviceKey` echoes the pool asked about —
22336
+ * `null` for the node-default pool.
22337
+ */
22338
+ var EffectiveTuningSchema = object({
22339
+ deviceKey: string().nullable(),
22340
+ runtime: string(),
22341
+ batchMode: string(),
22342
+ windowMs: number(),
22343
+ maxBatchSize: number(),
22344
+ concurrency: number(),
22345
+ numWorkers: number()
22346
+ });
22347
+ var AvailableEngineSchema = object({
22348
+ engine: PipelineEngineChoiceSchema,
22349
+ devices: array(object({
22350
+ id: string(),
22351
+ label: string(),
22352
+ description: string().optional()
22353
+ })).readonly(),
22354
+ defaultDevice: string()
22355
+ });
22356
+ var PipelineDefaultStepSchema = lazy(() => object({
22357
+ addonId: string(),
22358
+ addonName: string(),
22359
+ slot: PipelineSlotSchema,
22360
+ inputClasses: array(string()).readonly(),
22361
+ outputClasses: array(string()).readonly(),
22362
+ enabled: boolean(),
22363
+ modelId: string(),
22364
+ children: array(PipelineDefaultStepSchema).readonly(),
22365
+ group: string().optional(),
22366
+ settings: record(string(), unknown()).optional()
22367
+ }));
22368
+ var PipelineTemplateStepSchema = lazy(() => object({
22369
+ addonId: string(),
22370
+ enabled: boolean(),
22371
+ modelId: string(),
22372
+ children: array(PipelineTemplateStepSchema).readonly(),
22373
+ settings: record(string(), unknown()).optional()
22374
+ }));
22375
+ var PipelineTemplateSchema$1 = object({
22376
+ id: string(),
22377
+ name: string(),
22378
+ createdAt: string(),
22379
+ updatedAt: string(),
22380
+ engine: PipelineEngineChoiceSchema,
22381
+ steps: array(PipelineTemplateStepSchema).readonly()
22382
+ });
22383
+ var PipelineModelOptionSchema = object({
22384
+ id: string(),
22385
+ name: string(),
22386
+ formats: record(string(), object({
22387
+ downloaded: boolean(),
22388
+ sizeMB: number()
22389
+ })),
22390
+ group: ModelVariantGroupSchema.optional(),
22391
+ legacy: boolean().optional(),
22392
+ provider: ModelProviderIdSchema.optional()
22393
+ });
22394
+ var ConfigFieldBridge = custom();
22395
+ var PipelineAddonSchemaSchema = object({
22396
+ id: string(),
22397
+ name: string(),
22398
+ slot: PipelineSlotSchema,
22399
+ inputClasses: array(string()).readonly(),
22400
+ outputClasses: array(string()).readonly(),
22401
+ childSlots: array(PipelineSlotSchema).readonly(),
22402
+ models: array(PipelineModelOptionSchema).readonly(),
22403
+ defaultModelId: string(),
22404
+ defaultModelIdByFormat: record(string(), string()).optional(),
22405
+ enabledByDefault: boolean().optional(),
22406
+ backfillIntoExistingOverrides: boolean().optional(),
22407
+ defaultConfidence: number(),
22408
+ group: string().optional(),
22409
+ configSchema: array(ConfigFieldBridge).readonly().optional()
22410
+ });
22411
+ var PipelineSlotSchemaSchema = object({
22412
+ id: PipelineSlotSchema,
22413
+ label: string(),
22414
+ priority: number(),
22415
+ parentSlot: PipelineSlotSchema.nullable(),
22416
+ addons: array(PipelineAddonSchemaSchema).readonly()
22417
+ });
22418
+ var PipelineSchemaSchema = object({
22419
+ availableEngines: array(AvailableEngineSchema).readonly(),
22420
+ selectedEngine: PipelineEngineChoiceSchema,
22421
+ slots: array(PipelineSlotSchemaSchema).readonly()
22422
+ });
22423
+ var EngineProvisioningSchema = object({
22424
+ runtimeId: _enum([
22425
+ "onnx",
22426
+ "openvino",
22427
+ "coreml",
22428
+ "edgetpu"
22429
+ ]).nullable(),
22430
+ device: string().nullable(),
22431
+ state: _enum([
22432
+ "idle",
22433
+ "installing",
22434
+ "verifying",
22435
+ "ready",
22436
+ "failed"
22437
+ ]),
22438
+ progress: number().optional(),
22439
+ error: string().optional(),
22440
+ nextRetryAt: number().optional(),
22441
+ /**
22442
+ * Gate A (config-correctness gate at engine change): human-readable
22443
+ * config issues surfaced EAGERLY when the node's engine changes — model
22444
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
22445
+ * has a <format> build"). Additive/optional: informational only, never
22446
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
22447
+ * Absent/empty when the node-default tree resolves cleanly.
22448
+ */
22449
+ configIssues: array(string()).optional()
22450
+ });
22451
+ var PipelineStepInputSchema = lazy(() => object({
22452
+ addonId: string(),
22453
+ modelId: string().optional(),
22454
+ enabled: boolean().default(true),
22455
+ children: array(PipelineStepInputSchema).optional(),
22456
+ settings: record(string(), unknown()).optional(),
22457
+ jumpDeviceKey: string().optional()
22458
+ }));
22459
+ var ModelSubstitutionSchema = object({
22460
+ addonId: string(),
22461
+ chosen: string(),
22462
+ running: string(),
22463
+ format: string()
22464
+ });
22465
+ var PipelineValidationIssueSchema = object({
22466
+ addonId: string(),
22467
+ kind: _enum([
22468
+ "unknown-addon",
22469
+ "no-format-build",
22470
+ "unknown-device"
22471
+ ]),
22472
+ detail: string()
22473
+ });
22474
+ var PipelineValidationResultSchema = object({
22475
+ ok: boolean(),
22476
+ issues: array(PipelineValidationIssueSchema).readonly(),
22477
+ substitutions: array(ModelSubstitutionSchema).readonly(),
22478
+ /** The node's `currentEngine.format` this validation ran against. */
22479
+ format: string()
22480
+ });
22481
+ var ReferenceImageEntrySchema = object({
22482
+ filename: string(),
22483
+ stepIds: array(string()).readonly().optional()
22484
+ });
22485
+ var ReferenceImageBodySchema = object({
22486
+ base64: string(),
22487
+ filename: string()
22488
+ });
22489
+ var ReferenceAudioEntrySchema = object({
22490
+ filename: string(),
22491
+ sizeKb: number()
22492
+ });
22493
+ var ReferenceAudioBodySchema = object({ base64: string() });
22494
+ var AudioBackendSchema = object({
22495
+ id: string(),
22496
+ name: string(),
22497
+ description: string(),
22498
+ available: boolean(),
22499
+ /**
22500
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
22501
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
22502
+ * the benchmark UI to populate the `enabledMicroClasses` filter
22503
+ * specific to the selected backend without a separate fetch.
22504
+ */
22505
+ rawLabels: array(string()).readonly().optional()
22506
+ });
22507
+ var AudioCapabilitiesSchema = object({
22508
+ activeBackend: string(),
22509
+ availableBackends: array(AudioBackendSchema).readonly(),
22510
+ sampleRate: number(),
22511
+ chunkDurationMs: number()
22512
+ });
22513
+ var DownloadModelResultSchema = object({
22514
+ filePath: string(),
22515
+ sizeMB: number(),
22516
+ durationMs: number()
22517
+ });
22518
+ /**
22519
+ * Wrapper carrying a single test run's result. Replaces the legacy
22520
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
22521
+ * canonical `AudioResult` from the Phase 6 output rework: one
22522
+ * `AudioDetection` per class above `minScore`, top-N candidates in
22523
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
22524
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
22525
+ * benchmark UI can still report a clean failure when the classifier
22526
+ * cap isn't available.
22527
+ */
22528
+ var AudioTestResultSchema = object({
22529
+ success: boolean(),
22530
+ error: string().optional(),
22531
+ frame: custom().optional()
22532
+ });
22533
+ var PipelineConfigBridge = custom();
22534
+ var ConfigUISchemaBridge = custom();
22535
+ var ConfigUISchemaNullableBridge = custom();
22536
+ var InferenceCapabilitiesBridge = custom();
22537
+ var ModelAvailabilityListBridge = custom();
22538
+ var PipelineRunResultBridge = custom();
22539
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
22540
+ modelId: string(),
22541
+ settings: record(string(), unknown()).readonly()
22542
+ }))), method(object({ steps: record(string(), object({
22543
+ modelId: string(),
22544
+ settings: record(string(), unknown()).readonly()
22545
+ })) }), object({ success: literal(true) }), {
22546
+ kind: "mutation",
22547
+ auth: "admin"
22548
+ }), method(object({ nodeId: string() }), object({
22549
+ success: literal(true),
22550
+ clearedDevices: number()
21947
22551
  }), {
21948
22552
  kind: "mutation",
21949
22553
  auth: "admin"
21950
- }), method(object({
21951
- deviceId: number(),
21952
- cutoffMs: number()
21953
- }), TrackCascadeCountsSchema, {
21954
- kind: "mutation",
21955
- auth: "admin"
21956
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
21957
- kind: "mutation",
21958
- auth: "admin"
21959
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
22554
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
22555
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
22556
+ deviceKey: string(),
22557
+ /**
22558
+ * `failed` — the per-device restart budget is exhausted; no pool
22559
+ * will be spawned until an operator re-arms it or the runner
22560
+ * respawns. `backoff` — under budget, waiting out the backoff (or
22561
+ * a cached pool observed dead and not yet condemned).
22562
+ */
22563
+ state: _enum(["failed", "backoff"]),
22564
+ /** Epoch ms of the death that produced this state. */
22565
+ since: number(),
22566
+ /** Pool deaths inside the current window. */
22567
+ deaths: number(),
22568
+ /** The last death's message. */
22569
+ lastError: string()
22570
+ })).readonly() })), method(object({
22571
+ nodeId: string(),
22572
+ deviceKey: string()
22573
+ }), object({ rearmed: boolean() }), {
21960
22574
  kind: "mutation",
21961
22575
  auth: "admin"
21962
- }), method(object({
21963
- deviceId: number(),
21964
- trackIds: array(string()).min(1)
22576
+ }), method(_void(), PipelineSchemaSchema), method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()), method(_void(), PipelineConfigBridge), method(_void(), ConfigUISchemaBridge), method(object({
22577
+ steps: array(PipelineStepInputSchema),
22578
+ deviceKey: string().optional()
22579
+ }), PipelineValidationResultSchema), method(_void(), array(PipelineTemplateSchema$1).readonly()), method(object({
22580
+ name: string(),
22581
+ steps: array(PipelineTemplateStepSchema).readonly(),
22582
+ engine: PipelineEngineChoiceSchema
22583
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
22584
+ id: string(),
22585
+ name: string().optional(),
22586
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
22587
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
22588
+ addonId: string(),
22589
+ modelId: string(),
22590
+ format: ModelFormatSchema$1
22591
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
22592
+ addonId: string(),
22593
+ modelId: string(),
22594
+ format: ModelFormatSchema$1
22595
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
22596
+ steps: array(PipelineStepInputSchema).min(1),
22597
+ frame: FrameInputSchema.optional(),
22598
+ /**
22599
+ * Process-local lazy frame. Valid only when caller and provider resolve
22600
+ * in the same execution-group process; split/cross-node callers use
22601
+ * `frame`/`image` inline compatibility instead.
22602
+ */
22603
+ frameRef: FrameRefSchema.optional(),
22604
+ /**
22605
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
22606
+ * the decoded pixels live in. One more member of the one-of
22607
+ * frame/frameHandle/image/imageBase64/referenceImage group.
22608
+ */
22609
+ frameHandle: FrameHandleSchema.optional(),
22610
+ imageBase64: string().optional(),
22611
+ /**
22612
+ * Binary JPEG bytes — preferred over `imageBase64` on internal
22613
+ * hops (hub → forked worker via Moleculer MsgPack) because it
22614
+ * skips the 33% base64 overhead + the per-call base64 decode on
22615
+ * the detection-pipeline worker. Callers can pass either; exactly
22616
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
22617
+ */
22618
+ image: _instanceof(Uint8Array).optional(),
22619
+ referenceImage: string().optional(),
22620
+ deviceId: number().optional(),
22621
+ sessionId: string().optional(),
22622
+ /**
22623
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
22624
+ * reference-image, and detail-subtree calls. 'frame' is the live
22625
+ * per-frame dispatch: ONLY root-plane steps run; crop children
22626
+ * (inputClasses ≠ null) are skipped and served per-track via
22627
+ * pipelineRunner.runDetailSubtree (two-plane design).
22628
+ */
22629
+ plane: _enum(["full", "frame"]).optional(),
22630
+ /**
22631
+ * Inference-device selector (Phase 2 multi-device). Format
22632
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
22633
+ * Omitted ⇒ the runner's default device (current single-engine
22634
+ * behaviour). Selects WHICH device pool of the node runs the call.
22635
+ */
22636
+ deviceKey: string().optional(),
22637
+ /**
22638
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
22639
+ * when the parent crop was resolved from the frame's retained NATIVE
22640
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
22641
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
22642
+ * resolution from that surface — the SAME quality path faces already
22643
+ * had — instead of the downscaled parent tile. `handle` keys the native
22644
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
22645
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
22646
+ * the executor's crop-normalized child ROI back into frame-normalized
22647
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
22648
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
22649
+ * (today's behaviour on the fallback path).
22650
+ */
22651
+ nativeCropRef: NativeCropRefSchema.optional(),
22652
+ /**
22653
+ * Offline REPLAY of stored media for `deviceId` (D56, D646): the
22654
+ * camera's zone gate and overrides apply as live, every executing
22655
+ * step runs EXACTLY the model it names on the `deviceKey` pool it
22656
+ * names or the call refuses (`model-not-servable` /
22657
+ * `device-not-servable`), and nothing reaches the camera's live
22658
+ * trace stream. Absent ⇒ unchanged behaviour.
22659
+ */
22660
+ replay: literal(true).optional()
22661
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
22662
+ steps: array(PipelineStepInputSchema).min(1),
22663
+ frames: array(FrameInputSchema).min(1).max(255),
22664
+ deviceId: number().optional(),
22665
+ sessionId: string().optional(),
22666
+ /**
22667
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
22668
+ * the batch to the Python pool's bench preprocess cache
22669
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
22670
+ * preprocessed ONCE and every later inference is a pure-inference cache
22671
+ * hit — the sustained-throughput run measures inference, not
22672
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
22673
+ * full preprocess every call, correct). Fresh per sustained run;
22674
+ * released via `uncacheFrame`.
22675
+ */
22676
+ frameId: number().int().nonnegative().optional(),
22677
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
22678
+ deviceKey: string().optional()
22679
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
22680
+ data: _instanceof(Uint8Array),
22681
+ width: number().int().positive(),
22682
+ height: number().int().positive(),
22683
+ format: _enum([
22684
+ "rgb",
22685
+ "bgr",
22686
+ "gray"
22687
+ ])
21965
22688
  }), object({
21966
- deleted: number().int(),
21967
- failed: array(string()).readonly()
21968
- }), {
21969
- kind: "mutation",
21970
- auth: "admin"
21971
- }), method(object({
21972
- /** Log/audit scope only — the trackId is globally unique on its own. */
21973
- deviceId: number(),
21974
- trackId: string(),
21975
- flags: TrackFlagsPatchSchema
21976
- }), TrackFlagsSchema, { kind: "mutation" }), method(ArchivedDebugNoteQueryInputSchema, array(ArchivedDebugNoteSchema).readonly(), { kind: "query" }), method(BirthDecisionQueryInputSchema, array(BirthDecisionRecordSchema).readonly(), { kind: "query" }), method(object({}), EventStoreFootprintSchema, {
21977
- kind: "query",
21978
- auth: "admin"
21979
- }), method(object({ deviceId: number().int().optional() }), EventMediaKindBreakdownSchema, {
21980
- kind: "query",
21981
- auth: "admin"
21982
- }), method(object({
21983
- olderThanMs: number(),
21984
- reason: OpsLogReasonSchema.optional()
21985
- }), EventPruneCountsSchema, {
21986
- kind: "mutation",
21987
- auth: "admin"
21988
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
21989
- kind: "mutation",
21990
- auth: "admin"
21991
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
21992
- kind: "mutation",
21993
- auth: "admin"
21994
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
21995
- kind: "mutation",
21996
- auth: "admin"
21997
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
21998
- kind: "mutation",
21999
- auth: "admin"
22000
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
22001
- kind: "mutation",
22002
- auth: "admin"
22003
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
22004
- kind: "mutation",
22005
- auth: "admin"
22006
- }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
22007
- kind: "mutation",
22008
- auth: "admin"
22009
- }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
22010
- kind: "query",
22011
- auth: "admin"
22012
- }), method(object({}), array(RelocateJobSchema).readonly(), {
22013
- kind: "query",
22014
- auth: "admin"
22015
- }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
22016
- kind: "mutation",
22017
- auth: "admin"
22018
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
22019
- kind: "query",
22020
- auth: "admin"
22021
- }), method(MediaReclaimInputSchema, MediaReclaimStartResultSchema, {
22022
- kind: "mutation",
22023
- auth: "admin"
22024
- }), method(object({}), MediaReclaimStatusSchema, {
22025
- kind: "query",
22026
- auth: "admin"
22027
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
22028
- kind: "query",
22029
- auth: "admin"
22030
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
22031
- kind: "query",
22032
- auth: "admin"
22033
- }), method(object({
22034
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
22035
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
22036
- * route it at one camera's owner, and "every camera" would stop being
22037
- * expressible at all. */
22038
- deviceIds: array(number()).optional(),
22039
- limit: number().int().min(1).max(500).optional()
22040
- }), array(RetrainTrackSchema).readonly(), {
22041
- kind: "query",
22042
- auth: "admin"
22043
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
22044
- kind: "query",
22045
- auth: "admin"
22046
- }), method(object({
22047
- deviceId: number(),
22048
- trackId: string(),
22049
- mediaIds: array(number().int()).min(1)
22050
- }), RetrainFrameSelectionSchema, {
22689
+ frameId: number(),
22690
+ width: number(),
22691
+ height: number()
22692
+ }), { kind: "mutation" }), method(object({
22693
+ stepId: string(),
22694
+ frameId: number().int()
22695
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(object({ deviceKey: string().optional() }), EffectiveTuningSchema), method(_void(), array(object({
22696
+ engineKey: string(),
22697
+ engine: PipelineEngineChoiceSchema,
22698
+ modelsLoaded: array(string()).readonly(),
22699
+ inUseByCameras: array(number()).readonly(),
22700
+ /**
22701
+ * Origin of this resident factory.
22702
+ * - `runtime` — main camera-serving engine (no idle TTL).
22703
+ * - `device-pool` — a concurrent per-device pool (Phase 2
22704
+ * multi-device, keyed by `deviceKey`) resolved
22705
+ * via `resolveDeviceFactory`. Runs alongside the
22706
+ * `runtime` engine on a DIFFERENT accelerator
22707
+ * (NPU / iGPU / Coral) — this is how the
22708
+ * Engines tab shows all pools running at once.
22709
+ */
22710
+ kind: _enum(["runtime", "device-pool"]),
22711
+ /** Native pid of the underlying Python pool (null when no pool). */
22712
+ poolPid: number().nullable(),
22713
+ /** ms since this factory was last used (null when not warm-tracked). */
22714
+ idleMs: number().nullable(),
22715
+ /** Idle TTL after which the factory self-evicts (null when not applicable). */
22716
+ idleTtlMs: number().nullable()
22717
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
22051
22718
  kind: "mutation",
22052
22719
  auth: "admin"
22053
22720
  }), method(object({
22054
- deviceId: number(),
22055
- trackId: string(),
22056
- frameId: string()
22721
+ engine: PipelineEngineChoiceSchema,
22722
+ force: boolean().optional()
22057
22723
  }), object({
22058
- removed: boolean(),
22059
- removedAnnotations: number().int()
22060
- }), {
22061
- kind: "mutation",
22062
- auth: "admin"
22063
- }), method(object({ frameId: string() }), object({
22064
- base64: string(),
22065
- width: number().int(),
22066
- height: number().int()
22724
+ success: boolean(),
22725
+ reason: string().optional()
22067
22726
  }), {
22068
- kind: "query",
22069
- auth: "admin"
22070
- }), method(object({
22071
- deviceId: number(),
22072
- trackId: string(),
22073
- frameId: string(),
22074
- subject: RetrainAssistSubjectSchema,
22075
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
22076
- nodeId: string().optional()
22077
- }), RetrainAssistResultSchema, {
22078
- kind: "mutation",
22079
- auth: "admin"
22080
- }), method(object({
22081
- deviceId: number(),
22082
- source: DetectionSourceSchema,
22083
- zones: array(ZoneSchema).readonly().optional(),
22084
- detectionRules: array(ZoneRuleSchema).readonly().optional(),
22085
- zoneMembershipMinOverlap: number().min(0).max(1).optional(),
22086
- frames: array(ReplayFrameInputSchema).min(1)
22087
- }), RunReplayFrameProcessorResultSchema, {
22088
- kind: "mutation",
22089
- auth: "admin"
22090
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
22091
- kind: "query",
22092
- auth: "admin"
22093
- }), method(object({
22094
- deviceId: number(),
22095
- trackId: string(),
22096
- frameId: string(),
22097
- annotations: array(RetrainAnnotationDraftSchema)
22098
- }), array(RetrainAnnotationSchema).readonly(), {
22099
- kind: "mutation",
22100
- auth: "admin"
22101
- }), method(object({
22102
- deviceId: number(),
22103
- trackId: string()
22104
- }), RetrainTransitionResultSchema, {
22105
- kind: "mutation",
22106
- auth: "admin"
22107
- }), method(object({
22108
- deviceId: number(),
22109
- trackId: string()
22110
- }), RetrainTransitionResultSchema, {
22111
- kind: "mutation",
22112
- auth: "admin"
22113
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
22114
- kind: "query",
22115
- auth: "admin"
22116
- }), method(object({
22117
- /** Which of the three event tables owns the row. */
22118
- ownerType: EventOwnerTypeSchema,
22119
- /** The event's rowid in that table (D474: an event id is a number). */
22120
- eventId: number().int(),
22121
- kind: MediaFileKindEnum.optional(),
22122
- deviceId: number()
22123
- }), array(MediaFileSchema).readonly()), method(object({
22124
- trackId: string(),
22125
- kinds: array(MediaFileKindEnum).optional(),
22126
- deviceId: number()
22127
- }), array(MediaFileSchema).readonly()), method(object({
22128
- trackId: string(),
22129
- deviceId: number()
22130
- }), array(MediaFileInfoSchema).readonly()), method(object({
22131
- ownerType: EventOwnerTypeSchema,
22132
- eventId: number().int(),
22133
- deviceId: number()
22134
- }), array(MediaFileInfoSchema).readonly()), method(object({
22135
- deviceId: number(),
22136
- ownerKind: MediaPresenceOwnerKindSchema,
22137
- ownerIds: array(string()).max(5e3)
22138
- }), array(string()).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
22139
- kind: "mutation",
22140
- auth: "admin"
22141
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
22142
22727
  kind: "mutation",
22143
22728
  auth: "admin"
22144
- }), method(object({}), RebuildStatusSchema), object({
22145
- deviceId: number(),
22146
- timestamp: number(),
22147
- frameWidth: number(),
22148
- frameHeight: number(),
22149
- detections: array(OverlayDetectionSchema).readonly()
22150
- }), object({
22151
- deviceId: number(),
22152
- trackId: string(),
22153
- className: string()
22154
- }), object({
22155
- deviceId: number(),
22156
- trackId: string(),
22157
- className: string(),
22158
- durationMs: number()
22159
- }), object({
22160
- deviceId: number(),
22161
- kind: EventKindSchema,
22162
- eventId: string(),
22163
- timestamp: number()
22164
- });
22729
+ }), method(_void(), array(ReferenceImageEntrySchema).readonly()), method(object({ filename: string() }), ReferenceImageBodySchema.nullable()), method(_void(), array(ReferenceAudioEntrySchema).readonly()), method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()), method(_void(), AudioCapabilitiesSchema), method(object({
22730
+ addonId: string(),
22731
+ modelId: string(),
22732
+ filename: string().optional(),
22733
+ settings: record(string(), unknown()).optional()
22734
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
22165
22735
  object({
22166
22736
  activeCameras: number(),
22167
22737
  throttledCameras: number(),
@@ -22187,6 +22757,106 @@ var CameraMetricsSchema = object({
22187
22757
  });
22188
22758
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
22189
22759
  /**
22760
+ * Zone — pure geometry + identity. NO filtering behaviour.
22761
+ *
22762
+ * Zones describe **where** in the frame the operator wants to flag
22763
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
22764
+ * each pipeline stage uses them. Splitting the two means a single
22765
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
22766
+ * a detection-include rule on `['car']`, and an occupancy aggregate
22767
+ * — without three duplicated polygons.
22768
+ *
22769
+ * Owned by the orchestrator addon (provider) and mirrored into the
22770
+ * `zones` device-state slice on every mutation. Consumers
22771
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
22772
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
22773
+ * mirror with `onChanged`).
22774
+ *
22775
+ * Coordinates are normalised fractions of the frame (0–1) so zones
22776
+ * survive resolution changes and stream profile switches.
22777
+ *
22778
+ * `kind` discriminates between full polygons (closed regions used
22779
+ * for intrusion / occupancy filters) and tripwires (open 2-point
22780
+ * line segments used for cross events). Onboard / firmware-reported
22781
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
22782
+ * task list.
22783
+ */
22784
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
22785
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
22786
+ var PolygonPointSchema = object({
22787
+ x: number(),
22788
+ y: number()
22789
+ });
22790
+ /** A camera detection zone — pure geometry/identity. */
22791
+ var ZoneSchema = object({
22792
+ id: string(),
22793
+ name: string(),
22794
+ kind: ZoneKindEnum.default("polygon"),
22795
+ /** Polygon vertices, fraction of frame (0–1). */
22796
+ polygon: array(PolygonPointSchema).readonly(),
22797
+ /** Visual color for UI rendering. */
22798
+ color: string().default("#3b82f6")
22799
+ });
22800
+ /**
22801
+ * Zones capability — per-camera CRUD over polygon detection zones.
22802
+ *
22803
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
22804
+ * to per-device settings and mirrors into the `zones` device-state
22805
+ * slice on every mutation, so downstream consumers can subscribe via
22806
+ * `dev.state.zones.onChanged`.
22807
+ *
22808
+ * The cap surface only handles geometry + identity; filtering
22809
+ * behaviour (per-class, include/exclude, threshold) lives in the
22810
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
22811
+ * `capabilities/schemas/zone-rule.js`.
22812
+ */
22813
+ var zonesCapability = {
22814
+ name: "zones",
22815
+ scope: "device",
22816
+ mode: "singleton",
22817
+ deviceTypes: [DeviceType.Camera],
22818
+ methods: {
22819
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
22820
+ addZone: method(object({
22821
+ deviceId: number(),
22822
+ zone: ZoneSchema
22823
+ }), _void(), {
22824
+ kind: "mutation",
22825
+ auth: "admin"
22826
+ }),
22827
+ removeZone: method(object({
22828
+ deviceId: number(),
22829
+ zoneId: string()
22830
+ }), _void(), {
22831
+ kind: "mutation",
22832
+ auth: "admin"
22833
+ }),
22834
+ updateZone: method(object({
22835
+ deviceId: number(),
22836
+ zone: ZoneSchema
22837
+ }), _void(), {
22838
+ kind: "mutation",
22839
+ auth: "admin"
22840
+ })
22841
+ },
22842
+ /**
22843
+ * Runtime-state slice — the live zone catalogue mirrored by the
22844
+ * orchestrator on every CRUD mutation. Consumers read via
22845
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
22846
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
22847
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
22848
+ * (e.g. zone groupings) can sit alongside the polygon list.
22849
+ */
22850
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
22851
+ /**
22852
+ * 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.
22853
+ *
22854
+ * See `RuntimeStateDurability`. Enforced by
22855
+ * `scripts/check-runtime-state-durability.ts`.
22856
+ */
22857
+ durability: "restored"
22858
+ };
22859
+ /**
22190
22860
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
22191
22861
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
22192
22862
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -22373,7 +23043,17 @@ var DetailResultSchema = object({
22373
23043
  /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
22374
23044
  * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
22375
23045
  * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
22376
- nativeFaceShortSidePx: number().optional()
23046
+ nativeFaceShortSidePx: number().optional(),
23047
+ /**
23048
+ * The five facial landmarks of a `face` detail, in the SAME frame space as
23049
+ * `bbox` (D644). Additive and optional: post-analysis stores them beside the
23050
+ * face's source frame so a future alignment can be re-derived exactly; a
23051
+ * runner that predates the field sends none and the face is stored without.
23052
+ */
23053
+ landmarks: array(object({
23054
+ x: number(),
23055
+ y: number()
23056
+ })).optional()
22377
23057
  });
22378
23058
  /**
22379
23059
  * Why an executing node REFUSED a stateless step run (`runStatelessStep`).
@@ -22628,6 +23308,17 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
22628
23308
  hubHostnameOverride: string().optional()
22629
23309
  })]).describe("Per-camera frame-source mode for the runner (P2c)");
22630
23310
  /**
23311
+ * What ONE step runs with on ONE roster device for THIS camera (D650): the
23312
+ * device's per-(node,device) base with the camera's override for that device
23313
+ * on top — the same `override ?? base` merge the orchestrator applies to the
23314
+ * elected device (`applyDeviceProvisioning`). Absent `modelId` ⇒ the executor
23315
+ * resolves the device format's default, exactly as on the elected device.
23316
+ */
23317
+ var RunnerJumpStepProvisioningSchema = object({
23318
+ modelId: string().optional(),
23319
+ settings: record(string(), unknown()).optional()
23320
+ });
23321
+ /**
22631
23322
  * One ENABLED inference device on the runner's node, as the step-tree
22632
23323
  * device-jump resolver sees it (phase 1). The orchestrator populates this
22633
23324
  * roster on the attach payload whenever the camera is elected onto a specific
@@ -22639,7 +23330,16 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
22639
23330
  var RunnerInferenceDeviceSchema = object({
22640
23331
  deviceKey: string(),
22641
23332
  weight: number().positive().default(1),
22642
- maxSessions: number().int().positive().nullable().default(null)
23333
+ maxSessions: number().int().positive().nullable().default(null),
23334
+ /**
23335
+ * Per-step provisioning for this camera on THIS device (D650), keyed by step
23336
+ * id. A step the runner jumps here runs with these fields, never with the
23337
+ * elected device's: `modelId` / `settings` are REPLACED on the jumped subtree
23338
+ * (a step absent from the map runs with neither — the target format default).
23339
+ * Absent field ⇒ an orchestrator that predates D650: the jumped step keeps
23340
+ * the elected device's provisioning, as before.
23341
+ */
23342
+ steps: record(string(), RunnerJumpStepProvisioningSchema).optional()
22643
23343
  });
22644
23344
  /**
22645
23345
  * Camera assignment payload sent by `addon-pipeline-orchestrator` to a
@@ -23514,6 +24214,28 @@ var NodeInferenceDeviceSchema = object({
23514
24214
  */
23515
24215
  exclusion: InferenceDeviceExclusionReasonSchema.nullable()
23516
24216
  });
24217
+ /**
24218
+ * The operator's model choice for one cluster-scoped step, answered by the
24219
+ * addon that OWNS the `clusterModel:*` settings (D651). Three answers, never
24220
+ * folded: a written choice, a key nobody wrote (the cluster runs the default
24221
+ * BY ABSENCE), or no answer. A caller that rewrites an index acts only on the
24222
+ * first two, read twice and agreeing.
24223
+ */
24224
+ var ClusterModelChoiceSchema = discriminatedUnion("kind", [
24225
+ object({
24226
+ kind: literal("stored"),
24227
+ modelId: string()
24228
+ }),
24229
+ object({
24230
+ kind: literal("absent"),
24231
+ defaultModelId: string()
24232
+ }),
24233
+ object({
24234
+ kind: literal("unreadable"),
24235
+ reason: _enum(CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS),
24236
+ error: string().optional()
24237
+ })
24238
+ ]);
23517
24239
  var NodeInferenceDevicesSchema = object({
23518
24240
  nodeId: string(),
23519
24241
  /** False when the node's platform-probe was unreachable (no live device set). */
@@ -23541,10 +24263,17 @@ method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
23541
24263
  }), object({ success: literal(true) }), {
23542
24264
  kind: "mutation",
23543
24265
  auth: "admin"
23544
- }), method(object({ deviceId: number() }), object({ deviceKey: string().nullable() })), method(_void(), object({ migrated: number() }), {
24266
+ }), method(object({ deviceId: number() }), object({ deviceKey: string().nullable() })), method(_void(), object({
24267
+ migrated: number(),
24268
+ skipped: array(object({
24269
+ deviceId: number(),
24270
+ targetNodeId: string(),
24271
+ reason: string()
24272
+ })).default([])
24273
+ }), {
23545
24274
  kind: "mutation",
23546
24275
  auth: "admin"
23547
- }), method(_void(), array(PipelineAssignmentSchema).readonly()), method(object({ deviceId: number() }), PipelineAssignmentSchema.nullable()), method(_void(), array(AgentLoadSummarySchema).readonly()), method(_void(), GlobalMetricsSchema), method(object({ deviceId: number() }), CameraMetricsSchema.nullable()), method(object({ nodeId: string() }), CapabilityBindingsSchema), method(object({
24276
+ }), method(_void(), array(PipelineAssignmentSchema).readonly()), method(object({ deviceId: number() }), PipelineAssignmentSchema.nullable()), method(_void(), array(AgentLoadSummarySchema).readonly()), method(object({ stepId: string() }), ClusterModelChoiceSchema), method(_void(), GlobalMetricsSchema), method(object({ deviceId: number() }), CameraMetricsSchema.nullable()), method(object({ nodeId: string() }), CapabilityBindingsSchema), method(object({
23548
24277
  nodeId: string(),
23549
24278
  capName: string(),
23550
24279
  addonId: string()
@@ -23759,7 +24488,11 @@ function buildDescriptor(capName, kind) {
23759
24488
  icon: legacyIcon(t.iconId)
23760
24489
  };
23761
24490
  }
23762
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
24491
+ /**
24492
+ * Sensor / control cap name → static event-kind descriptor. A linked device
24493
+ * contributes one entry per bound cap present in this map.
24494
+ */
24495
+ var EVENT_KIND_BY_CAP = Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
23763
24496
  /**
23764
24497
  * server-management — per-NODE singleton capability for a node's ROOT
23765
24498
  * package lifecycle (runtime-updatable node packages).
@@ -24307,41 +25040,65 @@ var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object(
24307
25040
  method(object({
24308
25041
  location: StorageLocationRefSchema,
24309
25042
  relativePath: string()
24310
- }), string()), method(object({
25043
+ }), string(), { auth: "admin" }), method(object({
24311
25044
  location: StorageLocationRefSchema,
24312
25045
  relativePath: string(),
24313
25046
  data: _instanceof(Uint8Array)
24314
- }), _void(), { kind: "mutation" }), method(object({
25047
+ }), _void(), {
25048
+ kind: "mutation",
25049
+ auth: "admin"
25050
+ }), method(object({
24315
25051
  location: StorageLocationRefSchema,
24316
25052
  relativePath: string()
24317
- }), _instanceof(Uint8Array)), method(object({
25053
+ }), _instanceof(Uint8Array), { auth: "admin" }), method(object({
24318
25054
  location: StorageLocationRefSchema,
24319
25055
  relativePath: string()
24320
- }), boolean()), method(object({
25056
+ }), boolean(), { auth: "admin" }), method(object({
24321
25057
  location: StorageLocationRefSchema,
24322
25058
  prefix: string().optional()
24323
- }), array(string()).readonly()), method(object({
25059
+ }), array(string()).readonly(), { auth: "admin" }), method(object({
24324
25060
  location: StorageLocationRefSchema,
24325
25061
  relativePath: string()
24326
- }), _void(), { kind: "mutation" }), method(object({ location: StorageLocationRefSchema }), number().nullable()), method(object({
25062
+ }), _void(), {
25063
+ kind: "mutation",
25064
+ auth: "admin"
25065
+ }), method(object({ location: StorageLocationRefSchema }), number().nullable()), method(object({
24327
25066
  location: StorageLocationRefSchema,
24328
25067
  relativePath: string(),
24329
25068
  sizeBytes: number().optional()
24330
- }), object({ uploadId: string() }), { kind: "mutation" }), method(object({
25069
+ }), object({ uploadId: string() }), {
25070
+ kind: "mutation",
25071
+ auth: "admin"
25072
+ }), method(object({
24331
25073
  uploadId: string(),
24332
25074
  offset: number(),
24333
25075
  data: _instanceof(Uint8Array)
24334
- }), _void(), { kind: "mutation" }), method(object({ uploadId: string() }), _void(), { kind: "mutation" }), method(object({ uploadId: string() }), _void(), { kind: "mutation" }), method(object({
25076
+ }), _void(), {
25077
+ kind: "mutation",
25078
+ auth: "admin"
25079
+ }), method(object({ uploadId: string() }), _void(), {
25080
+ kind: "mutation",
25081
+ auth: "admin"
25082
+ }), method(object({ uploadId: string() }), _void(), {
25083
+ kind: "mutation",
25084
+ auth: "admin"
25085
+ }), method(object({
24335
25086
  location: StorageLocationRefSchema,
24336
25087
  relativePath: string()
24337
25088
  }), object({
24338
25089
  downloadId: string(),
24339
25090
  sizeBytes: number()
24340
- }), { kind: "mutation" }), method(object({
25091
+ }), {
25092
+ kind: "mutation",
25093
+ auth: "admin"
25094
+ }), method(object({
24341
25095
  downloadId: string(),
24342
25096
  offset: number(),
24343
25097
  length: number()
24344
- }), _instanceof(Uint8Array)), method(object({ downloadId: string() }), _void(), { kind: "mutation" }), method(object({ type: StorageLocationTypeSchema.optional() }), array(StorageLocationSchema).readonly()), method(_void(), array(StorageLocationDeclarationSchema).readonly()), method(StorageLocationSchema.omit({
25098
+ }), _instanceof(Uint8Array), { auth: "admin" }), method(object({ downloadId: string() }), _void(), {
25099
+ kind: "mutation",
25100
+ auth: "admin"
25101
+ }), method(object({ type: StorageLocationTypeSchema.optional() }), array(StorageLocationSchema).readonly()), method(_void(), array(StorageLocationDeclarationSchema).readonly()), method(StorageLocationSchema.omit({
24345
25102
  createdAt: true,
24346
25103
  updatedAt: true
24347
25104
  }), StorageLocationSchema, {
@@ -25845,6 +26602,245 @@ DeviceType.Camera, method(object({
25845
26602
  auth: "protected"
25846
26603
  });
25847
26604
  /**
26605
+ * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
26606
+ * valutatore puro del suo FRONTE.
26607
+ *
26608
+ * Viveva dentro il builtin virtual-doorbell
26609
+ * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
26610
+ * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
26611
+ * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
26612
+ * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
26613
+ * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
26614
+ * SPOSTA qui e il doorbell la ri-esporta.
26615
+ *
26616
+ * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
26617
+ * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
26618
+ * regola" (e include `presence`, `cover`, `alarm-panel`), questa a "qual è il
26619
+ * booleano il cui FRONTE conta". Vocabolari deliberatamente diversi.
26620
+ */
26621
+ /**
26622
+ * Known binary / switch source caps → the boolean slice field whose
26623
+ * false→true rise counts as ACTIVE. Every entry is "fire on active".
26624
+ * Sensors whose "active" reading is not a plain boolean (presence's string
26625
+ * state, connectivity's connected flag) are deliberately excluded — a
26626
+ * reconnect is not a doorbell press, and it is not a recording either.
26627
+ */
26628
+ var SOURCE_CAP_ACTIVE_FIELD = {
26629
+ contact: "entryOpen",
26630
+ binary: "on",
26631
+ switch: "on",
26632
+ motion: "detected",
26633
+ flood: "flooded",
26634
+ gas: "detected",
26635
+ smoke: "detected",
26636
+ "carbon-monoxide": "detected",
26637
+ vibration: "detected",
26638
+ tamper: "tampered"
26639
+ };
26640
+ /** Cap names whose presence in a device's bindings qualify it as a source. */
26641
+ var SOURCE_CAPS = Object.keys(SOURCE_CAP_ACTIVE_FIELD);
26642
+ /**
26643
+ * Doorbell button cap. Two kinds of providers coexist behind this cap
26644
+ * name (same pattern as `snapshot`):
26645
+ *
26646
+ * - **Native** providers: registered per-device by device-driver
26647
+ * addons via `ctx.registerNativeCap` — either on a
26648
+ * `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
26649
+ * or directly on the camera (Reolink registers at camera level).
26650
+ * Emits an `onPressed` event every time the firmware pushes a
26651
+ * ring; status tracks the last press and a pressCount since start
26652
+ * (diagnostic).
26653
+ *
26654
+ * - **Wrapper** provider: the `virtual-doorbell` system builtin
26655
+ * (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
26656
+ * device (contact / switch / event-emitter …) into a doorbell for
26657
+ * a camera. `defaultActive: false` — the operator explicitly binds
26658
+ * it per camera in the device-bindings UI, then picks the source
26659
+ * device + trigger in the per-device settings.
26660
+ *
26661
+ * The DeviceEventPropagator re-emits `onPressed` on the camera parent
26662
+ * — subscribers listening at the camera level receive ring events
26663
+ * with `via[]` populated. No code on the parent needed.
26664
+ */
26665
+ var DoorbellStatusSchema = object({
26666
+ /** Ms epoch of the last press. null = never observed since this provider started. */
26667
+ lastPressedAt: number().nullable(),
26668
+ /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
26669
+ pressCountSinceStart: number()
26670
+ });
26671
+ var DoorbellPressEventSchema = object({
26672
+ deviceId: number(),
26673
+ timestamp: number()
26674
+ });
26675
+ /**
26676
+ * The `doorbell-source` extension slot's editable value (D648): the camera's
26677
+ * virtual-doorbell trigger devices, exactly what the wrapper's
26678
+ * `doorbellSources` persists (as `{ deviceId }` records).
26679
+ */
26680
+ var DoorbellSourceSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
26681
+ /**
26682
+ * The `doorbell-source` slot — which devices ring this camera's VIRTUAL
26683
+ * doorbell, owned by the `virtual-doorbell` wrapper over its
26684
+ * `doorbellSources` store (D648). A source rings when one of its
26685
+ * `SOURCE_CAPS` rises. Whether the wrapper is bound to the camera at all is a
26686
+ * different authority (`deviceManager.setWrapperActive`, D62) — the slot
26687
+ * reports it, it never writes it.
26688
+ */
26689
+ var DOORBELL_SOURCE_SLOT = {
26690
+ id: "doorbell-source",
26691
+ label: "Doorbell trigger devices",
26692
+ 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.",
26693
+ shape: "association",
26694
+ hostDeviceTypes: [DeviceType.Camera],
26695
+ sourceCaps: SOURCE_CAPS,
26696
+ cardinality: "many",
26697
+ value: DoorbellSourceSlotValueSchema
26698
+ };
26699
+ var doorbellCapability = {
26700
+ name: "doorbell",
26701
+ scope: "device",
26702
+ deviceNative: true,
26703
+ mode: "singleton",
26704
+ kind: "wrapper",
26705
+ defaultActive: false,
26706
+ deviceTypes: [DeviceType.Button, DeviceType.Camera],
26707
+ exposesDeviceSettings: true,
26708
+ extensionSlots: [DOORBELL_SOURCE_SLOT],
26709
+ methods: {},
26710
+ events: {
26711
+ /**
26712
+ * Fires once per physical press. Reolink delivers via Baichuan
26713
+ * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
26714
+ * release/duration — it's a pulse.
26715
+ */
26716
+ onPressed: { data: DoorbellPressEventSchema } },
26717
+ status: {
26718
+ schema: DoorbellStatusSchema,
26719
+ kind: "push"
26720
+ },
26721
+ /**
26722
+ * Runtime-state slice — last press timestamp + lifetime press count.
26723
+ * Mirrored by the kernel and readable via
26724
+ * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
26725
+ * without subscribing.
26726
+ */
26727
+ runtimeState: DoorbellStatusSchema,
26728
+ /**
26729
+ * 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.
26730
+ *
26731
+ * See `RuntimeStateDurability`. Enforced by
26732
+ * `scripts/check-runtime-state-durability.ts`.
26733
+ */
26734
+ durability: "restored"
26735
+ };
26736
+ var ExtensionSlotIdSchema = _enum(["doorbell-source", "linked-devices"]);
26737
+ DeviceType.Camera, DeviceType.Camera;
26738
+ /** A slot's editable value, discriminated on `slot`. */
26739
+ var ExtensionSlotValueSchema = discriminatedUnion("slot", [DoorbellSourceSlotValueSchema.extend({ slot: literal("doorbell-source") }), LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
26740
+ DeviceType.Camera;
26741
+ var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
26742
+ state: literal("unreachable"),
26743
+ reason: string()
26744
+ })]);
26745
+ /** One provider of slots — the D554 source-listing row. */
26746
+ var ExtensionSourceSchema = object({
26747
+ /** The routing prefix of every `slotRef` this provider serves. */
26748
+ source: string(),
26749
+ label: string(),
26750
+ /** Stamped by the dispatcher from the registry (D557). */
26751
+ addonId: string().optional(),
26752
+ availability: ExtensionSourceAvailabilitySchema
26753
+ });
26754
+ /**
26755
+ * How one picked source stands. `missing` — no such device (deleted, or an id
26756
+ * that never existed); `foreign` — a device the slot's owner cannot read from
26757
+ * (slice 2's cross-owner graft source); `unavailable` — it exists but is not a
26758
+ * valid source now (a container, which is never a pick). A source in any of
26759
+ * these states is SHOWN, never silently dropped or re-pointed.
26760
+ */
26761
+ var ExtensionSourceHealthSchema = _enum([
26762
+ "ok",
26763
+ "missing",
26764
+ "foreign",
26765
+ "unavailable"
26766
+ ]);
26767
+ var ExtensionSlotSourceSchema = object({
26768
+ deviceId: number().int(),
26769
+ /** The device's name, or null when it could not be resolved (`missing`). */
26770
+ name: string().nullable(),
26771
+ health: ExtensionSourceHealthSchema,
26772
+ detail: string().optional()
26773
+ });
26774
+ /**
26775
+ * A DIFFERENT authority that gates whether the slot's sources do anything —
26776
+ * reported read-only, named, never written through this contract (D62). The
26777
+ * virtual doorbell's sources ring only while the wrapper is bound to the
26778
+ * camera, and that binding belongs to `deviceManager.setWrapperActive`.
26779
+ * `unknown` means the gate could not be read; it is not "inactive" (D315).
26780
+ */
26781
+ var ExtensionSlotActivationSchema = object({
26782
+ state: _enum([
26783
+ "active",
26784
+ "inactive",
26785
+ "unknown"
26786
+ ]),
26787
+ authority: string(),
26788
+ detail: string().optional()
26789
+ });
26790
+ var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
26791
+ state: literal("ok"),
26792
+ /** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
26793
+ slotRef: string(),
26794
+ slot: ExtensionSlotIdSchema,
26795
+ /** Names the store written (D62), e.g. `virtual-doorbell:doorbellSources`. */
26796
+ authority: string(),
26797
+ /** graft: its switch. association: null — removing every source is "off". */
26798
+ enabled: boolean().nullable(),
26799
+ /** graft: the cap registered on the host. association: null. */
26800
+ projects: string().nullable(),
26801
+ activation: ExtensionSlotActivationSchema.nullable(),
26802
+ value: ExtensionSlotValueSchema,
26803
+ sources: array(ExtensionSlotSourceSchema)
26804
+ }), object({
26805
+ state: literal("unreachable"),
26806
+ addonId: string(),
26807
+ reason: string()
26808
+ })]);
26809
+ var ExtensionCandidatesSchema = object({ candidates: array(object({
26810
+ deviceId: number().int(),
26811
+ name: string(),
26812
+ type: string(),
26813
+ location: string().nullable(),
26814
+ /** The container a child belongs to — "Spotlight 2" alone does not say which. */
26815
+ parentName: string().nullable(),
26816
+ /** Pre-marked by the owner's suggestion rule. NEVER saved on its own (D356). */
26817
+ suggested: boolean(),
26818
+ /** Why it is suggested ("same location"), null when it is not. */
26819
+ reason: string().nullable()
26820
+ })) });
26821
+ /**
26822
+ * What a write did. `none` — applied in place. `host` / `parent` — the owner
26823
+ * reloaded the host (or, for an accessory child, its parent) because the
26824
+ * write changed what the host REGISTERS (a graft switched on or off, slice 2).
26825
+ */
26826
+ var ExtensionSetResultSchema = object({
26827
+ applied: literal(true),
26828
+ reload: _enum([
26829
+ "none",
26830
+ "host",
26831
+ "parent"
26832
+ ])
26833
+ });
26834
+ var ExtensionSlotRefInputSchema = object({
26835
+ deviceId: number().int(),
26836
+ slotRef: string().min(1)
26837
+ });
26838
+ var ExtensionSetSlotInputSchema = ExtensionSlotRefInputSchema.extend({ value: ExtensionSlotValueSchema });
26839
+ method(object({ deviceId: number().int() }), array(ExtensionSourceSchema)), method(object({ deviceId: number().int() }), array(ExtensionSlotRowSchema)), method(ExtensionSlotRefInputSchema, ExtensionCandidatesSchema), method(ExtensionSetSlotInputSchema, ExtensionSetResultSchema, {
26840
+ kind: "mutation",
26841
+ auth: "admin"
26842
+ });
26843
+ /**
25848
26844
  * Optional client-side hints sent at session creation to help the provider
25849
26845
  * pick the best native source. All fields optional — a viewer that knows
25850
26846
  * nothing still gets a sane default. (Relocated from the retired `webrtc`
@@ -25946,7 +26942,67 @@ var WebrtcLadderDecisionSchema = object({
25946
26942
  serverSending: boolean().nullable(),
25947
26943
  /** Epoch ms. The overlay prints its age; a decision from 40 minutes ago
25948
26944
  * must not read like one from this second. */
25949
- at: number()
26945
+ at: number(),
26946
+ /** The broker's own cause when it is finer than `cause` can carry, e.g.
26947
+ * `trial-revert` (reported as `stall`/`loss` for older consumers). Optional:
26948
+ * an older server strips it instead of rejecting the answer. */
26949
+ causeDetail: string().optional()
26950
+ });
26951
+ var WebrtcClimbHoldSchema = object({
26952
+ /** `stall-building` — the client receives ≪ what is sent; `delivery` — the
26953
+ * current rung is not landing whole; `no-evidence` — no receiver feedback;
26954
+ * `warming` — healthy, accumulating the streak; `cooldown` — too soon after
26955
+ * a change; `capacity` — a MEASURED probe below the next rung's bar;
26956
+ * `try-unclean` — no capacity evidence, and the path is not clean enough to
26957
+ * try; `try-backoff` — a try reverted, waiting out its backoff; `trial` —
26958
+ * this rung IS a try, reverting if it does not land; `suspended` —
26959
+ * recorded playback on the track. */
26960
+ code: string(),
26961
+ /** The rung a climb would go to. */
26962
+ nextTier: CamProfileSchema,
26963
+ /** Bytes received ÷ bytes sent over the delivery window (≥ one GOP). */
26964
+ deliveryRatio: number().nullable(),
26965
+ deliveryWindowMs: number().nullable(),
26966
+ /** The ratio a climb requires. */
26967
+ climbDeliveryRatio: number(),
26968
+ /** The receiver's bandwidth estimate (REMB), kbps. Capped by what is sent. */
26969
+ capacityKbps: number().nullable(),
26970
+ /** The viewer's downlink probe for this session, kbps. */
26971
+ probeKbps: number().nullable(),
26972
+ /** The next rung's measured bitrate, kbps. */
26973
+ nextTierKbps: number().nullable(),
26974
+ capacityMargin: number(),
26975
+ /** The capacity a climb to `nextTier` needs, kbps (bitrate × margin, or the
26976
+ * client ladder threshold when the rung has measured nothing). */
26977
+ neededKbps: number().nullable(),
26978
+ /** For `try-unclean`: which clean-path condition failed (a `WebrtcTryBlocker`,
26979
+ * carried as a string for the same reason as `code`). */
26980
+ tryBlockedBy: string().nullable(),
26981
+ /** The delivery ratio and the loss ratio a try requires / must stay under.
26982
+ * Optional, like every field added to this schema after it first shipped:
26983
+ * the router validates output, so a REQUIRED new field makes a newer server
26984
+ * reject an older broker's whole answer (review m1). */
26985
+ tryDeliveryRatio: number().optional(),
26986
+ tryMaxLossRatio: number().optional(),
26987
+ /** For `try-backoff`: time until the next try, ms. */
26988
+ retryInMs: number().nullable(),
26989
+ /** The last try that reverted in this viewer session. */
26990
+ lastRevert: object({
26991
+ tier: CamProfileSchema,
26992
+ deliveryRatio: number().nullable(),
26993
+ stalled: boolean(),
26994
+ at: number()
26995
+ }).nullable(),
26996
+ /** For `trial`: how long this rung has been on trial, and for how long it must hold. */
26997
+ trialForMs: number().nullable(),
26998
+ trialMs: number().nullable(),
26999
+ healthyForMs: number().nullable(),
27000
+ requiredHealthyMs: number().nullable(),
27001
+ /** Epoch ms this hold's code began. */
27002
+ since: number(),
27003
+ /** The same one-line account the broker logs, e.g.
27004
+ * `held: delivery 0.97 over 4.0s ok, REMB 480 kbps < mid 1800 kbps × 1.2`. */
27005
+ summary: string()
25950
27006
  });
25951
27007
  /** Per-tier count of MEASURED downgrades this viewer session has suffered. */
25952
27008
  var WebrtcTierFailureSchema = object({
@@ -26010,7 +27066,12 @@ var WebrtcSessionDebugSchema = object({
26010
27066
  tierFailures: array(WebrtcTierFailureSchema),
26011
27067
  /** Successful promotions in this viewer session (drives the progressive
26012
27068
  * healthy timer). Null when no ladder is running. */
26013
- upgradeCount: number().nullable()
27069
+ upgradeCount: number().nullable(),
27070
+ /** Why the ladder is not climbing right now. Null when no ladder runs, it
27071
+ * is at the top rung, or it just moved. Optional because this output is
27072
+ * validated by the router: a server carrying this schema must still accept
27073
+ * the answer of a stream-broker deployed before the field existed. */
27074
+ climbHold: WebrtcClimbHoldSchema.nullable().optional()
26014
27075
  });
26015
27076
  DeviceType.Camera, method(object({ deviceId: number().int().nonnegative() }), array(WebrtcStreamChoiceSchema)), method(object({
26016
27077
  deviceId: number().int().nonnegative(),
@@ -27894,12 +28955,20 @@ reset: method(object({
27894
28955
  },
27895
28956
  runtimeState: ConsumablesStatusSchema.extend({ lastFetchedAt: number() }),
27896
28957
  /**
27897
- * Runtime-state durability: **session** — the authority is the appliance; the provider re-reads the whole item array on connect.
28958
+ * Runtime-state durability: **restored** — nothing else holds the value
28959
+ * (D642). A consumable can often be read only in a device's wake window (the
28960
+ * Dreame mower's CMS counters answer only while it charges), so a restart
28961
+ * that wiped the slice left the panel empty and the alerts blind until the
28962
+ * next wake — 2026-09-26, mower 503 idle with `items: []`. A restored item is
28963
+ * the previous observation, not a claim about now; the provider overwrites it
28964
+ * the moment it reads the device again.
27898
28965
  *
27899
28966
  * See `RuntimeStateDurability`. Enforced by
27900
28967
  * `scripts/check-runtime-state-durability.ts`.
27901
28968
  */
27902
- durability: "session"
28969
+ durability: "restored",
28970
+ /** Clocks, not content: a re-read that changed no item costs no commit. */
28971
+ volatileStateFields: ["lastChangedAt", "lastFetchedAt"]
27903
28972
  };
27904
28973
  /**
27905
28974
  * Door / window / opening / garage / valve contact sensor. Boolean
@@ -28288,75 +29357,6 @@ onStatusChanged: { data: object({
28288
29357
  volatileStateFields: ["lastChangedAt"]
28289
29358
  };
28290
29359
  /**
28291
- * Doorbell button cap. Two kinds of providers coexist behind this cap
28292
- * name (same pattern as `snapshot`):
28293
- *
28294
- * - **Native** providers: registered per-device by device-driver
28295
- * addons via `ctx.registerNativeCap` — either on a
28296
- * `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
28297
- * or directly on the camera (Reolink registers at camera level).
28298
- * Emits an `onPressed` event every time the firmware pushes a
28299
- * ring; status tracks the last press and a pressCount since start
28300
- * (diagnostic).
28301
- *
28302
- * - **Wrapper** provider: the `virtual-doorbell` system builtin
28303
- * (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
28304
- * device (contact / switch / event-emitter …) into a doorbell for
28305
- * a camera. `defaultActive: false` — the operator explicitly binds
28306
- * it per camera in the device-bindings UI, then picks the source
28307
- * device + trigger in the per-device settings.
28308
- *
28309
- * The DeviceEventPropagator re-emits `onPressed` on the camera parent
28310
- * — subscribers listening at the camera level receive ring events
28311
- * with `via[]` populated. No code on the parent needed.
28312
- */
28313
- var DoorbellStatusSchema = object({
28314
- /** Ms epoch of the last press. null = never observed since this provider started. */
28315
- lastPressedAt: number().nullable(),
28316
- /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
28317
- pressCountSinceStart: number()
28318
- });
28319
- var DoorbellPressEventSchema = object({
28320
- deviceId: number(),
28321
- timestamp: number()
28322
- });
28323
- var doorbellCapability = {
28324
- name: "doorbell",
28325
- scope: "device",
28326
- deviceNative: true,
28327
- mode: "singleton",
28328
- kind: "wrapper",
28329
- defaultActive: false,
28330
- deviceTypes: [DeviceType.Button, DeviceType.Camera],
28331
- exposesDeviceSettings: true,
28332
- methods: {},
28333
- events: {
28334
- /**
28335
- * Fires once per physical press. Reolink delivers via Baichuan
28336
- * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
28337
- * release/duration — it's a pulse.
28338
- */
28339
- onPressed: { data: DoorbellPressEventSchema } },
28340
- status: {
28341
- schema: DoorbellStatusSchema,
28342
- kind: "push"
28343
- },
28344
- /**
28345
- * Runtime-state slice — last press timestamp + lifetime press count.
28346
- * Mirrored by the kernel and readable via
28347
- * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
28348
- * without subscribing.
28349
- */
28350
- runtimeState: DoorbellStatusSchema,
28351
- /**
28352
- * 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.
28353
- *
28354
- * See `RuntimeStateDurability`. Enforced by
28355
- * `scripts/check-runtime-state-durability.ts`.
28356
- */
28357
- durability: "restored"
28358
- };
28359
- /**
28360
29360
  * Enum-state sensor — a string value picked from a finite option set.
28361
29361
  * Drives HA `sensor` entries with `state_class: enum` (HVAC action
28362
29362
  * states, weather conditions, contact-source channels, mode strings).
@@ -31295,6 +32295,11 @@ var ClientNetworkStatsSchema = object({
31295
32295
  jitterMs: number(),
31296
32296
  estimatedBandwidthKbps: number(),
31297
32297
  packetLossPercent: number().min(0).max(100),
32298
+ /** The viewer's latest `/adaptive-probe` reading, Mbps — whatever it read
32299
+ * (D635 I4). Absent when it never probed or the probe failed (unknown). */
32300
+ downlinkMbps: number().optional(),
32301
+ /** Age of that reading when this report was sent, ms. */
32302
+ downlinkAgeMs: number().optional(),
31298
32303
  lastUpdated: number()
31299
32304
  });
31300
32305
  var DeviceNetworkStatsSchema = object({
@@ -31307,7 +32312,11 @@ method(object({ deviceId: number() }), DeviceNetworkStatsSchema.nullable()), met
31307
32312
  rttMs: number().min(0).max(6e4),
31308
32313
  jitterMs: number().min(0).max(1e4),
31309
32314
  estimatedBandwidthKbps: number().min(0).max(1e6),
31310
- packetLossPercent: number().min(0).max(100)
32315
+ packetLossPercent: number().min(0).max(100),
32316
+ /** Latest downlink probe, Mbps, whatever it read; absent = never / failed. */
32317
+ downlinkMbps: number().min(0).max(1e5).optional(),
32318
+ /** Age of that probe when this report is sent, ms. */
32319
+ downlinkAgeMs: number().min(0).max(864e5).optional()
31311
32320
  }), _void(), { kind: "mutation" });
31312
32321
  /**
31313
32322
  * nodes — system-scoped singleton capability for cluster topology
@@ -31426,7 +32435,30 @@ var RenameNodeResultSchema = object({
31426
32435
  nodeId: string(),
31427
32436
  name: string()
31428
32437
  });
31429
- method(_void(), array(TopologyNodeSchema).readonly(), { auth: "admin" }), method(NodeAddonInputSchema, SuccessSchema, {
32438
+ /**
32439
+ * The cheap node list. A consumer's rule for a STORED node id (a rule's
32440
+ * `nodeIds`) that is missing from `nodes`, whatever `complete` says: render it
32441
+ * as a removable chip labelled unknown, never drop it (D49). Even a complete
32442
+ * list omits a node that joined and left between two history captures, so a
32443
+ * missing id means "not known to the hub", never "removed". Only the operator
32444
+ * removes it.
32445
+ *
32446
+ * `complete` changes only the WORDING: `false` = no history read has ever
32447
+ * answered, so the list may be missing offline nodes the hub does know (D315).
32448
+ *
32449
+ * `name` is the history row's name (≤ 30 s behind a rename), or the id when
32450
+ * the history has none.
32451
+ */
32452
+ var NodeDirectorySchema = object({
32453
+ nodes: array(object({
32454
+ id: string(),
32455
+ name: string(),
32456
+ isHub: boolean(),
32457
+ isOnline: boolean()
32458
+ })).readonly(),
32459
+ complete: boolean()
32460
+ });
32461
+ method(_void(), array(TopologyNodeSchema).readonly(), { auth: "admin" }), method(_void(), NodeDirectorySchema, { auth: "admin" }), method(NodeAddonInputSchema, SuccessSchema, {
31430
32462
  kind: "mutation",
31431
32463
  auth: "admin"
31432
32464
  }), method(NodeAddonInputSchema, SuccessSchema, {
@@ -32319,7 +33351,7 @@ var HardwareInfoSchema = object({
32319
33351
  coral: CoralInfoSchema.nullable().optional()
32320
33352
  });
32321
33353
  var PlatformScoreSchema = object({
32322
- runtime: _enum(["node", "python"]),
33354
+ runtime: literal("python"),
32323
33355
  backend: string(),
32324
33356
  format: _enum([
32325
33357
  "onnx",
@@ -32356,7 +33388,7 @@ var ModelRequirementSchema = object({
32356
33388
  });
32357
33389
  var ResolvedInferenceConfigSchema = object({
32358
33390
  modelId: string(),
32359
- runtime: _enum(["node", "python"]),
33391
+ runtime: literal("python"),
32360
33392
  backend: string(),
32361
33393
  format: ModelFormatSchema,
32362
33394
  reason: string()
@@ -34923,6 +35955,92 @@ var sceneMonitorCapability = {
34923
35955
  durability: "session"
34924
35956
  };
34925
35957
  /**
35958
+ * Per-stage gating mode applied to the zones a rule references.
35959
+ *
35960
+ * - `include`: the rule contributes to a **whitelist** for its stage.
35961
+ * When at least one `include` rule fires for a stage, only entities
35962
+ * inside one of those zones pass that stage.
35963
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
35964
+ * Entities inside one of those zones are dropped at that stage.
35965
+ *
35966
+ * `monitor`-style observation (count without filtering) is not a rule
35967
+ * mode — zones without any matching rule are observed naturally by
35968
+ * `zone-analytics` (live snapshot + history), so an "I just want to
35969
+ * count, not filter" use case needs no rule at all.
35970
+ */
35971
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
35972
+ /**
35973
+ * Per-consumer rule that references existing zones (geometry) and
35974
+ * defines how a specific pipeline stage should treat them. Each
35975
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
35976
+ * settings:
35977
+ *
35978
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
35979
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
35980
+ * - future: notification rules, audio gating, etc.
35981
+ *
35982
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
35983
+ * express "ignore motion in ALL of {garden, street}" with a single
35984
+ * rule. `classFilter` narrows the rule to specific object classes —
35985
+ * "drop person detections in the street, but keep cars" is one
35986
+ * `exclude` rule with `classFilter: ['person']`.
35987
+ *
35988
+ * `enabled` is a soft toggle — the operator can keep the rule
35989
+ * configured but inert without deleting it.
35990
+ */
35991
+ var ZoneRuleSchema = object({
35992
+ /** Stable rule id — survives edits, used by the UI for diffing. */
35993
+ id: string(),
35994
+ /** Optional human-readable label rendered in the rule editor. */
35995
+ name: string().optional(),
35996
+ /** Zones this rule targets. The rule's `mode` applies to ALL
35997
+ * listed zones (OR-set: a detection in any one of them counts).
35998
+ * At least one zone id required — a rule with no targets is a
35999
+ * configuration mistake and the form validator rejects it. */
36000
+ zoneIds: array(string()).min(1).readonly(),
36001
+ mode: ZoneRuleModeEnum,
36002
+ /**
36003
+ * Class names this rule applies to. Empty / undefined ⇒ rule
36004
+ * applies to every class. Class strings match the `macroClass`
36005
+ * field on detections (e.g. `person`, `car`, `dog`).
36006
+ */
36007
+ classFilter: array(string()).readonly().optional(),
36008
+ /**
36009
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
36010
+ * required to consider an entity "in the zone". Defaults to the
36011
+ * consumer's stage default when omitted. Kept for back-compat with
36012
+ * existing per-rule overrides; new operators pick the value via
36013
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
36014
+ * set, the lower-level engine reads it as a 0–1 fraction.
36015
+ */
36016
+ overlapThreshold: number().min(0).max(1).optional(),
36017
+ /**
36018
+ * Operator-friendly version of `overlapThreshold` — the percentage
36019
+ * of the detection's bbox that must lie inside the zone for the
36020
+ * rule to match. Documented default is 85%; the engine substitutes
36021
+ * that when the field is omitted (kept optional so existing rules
36022
+ * stored without it stay valid).
36023
+ *
36024
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
36025
+ * rule, the engine prefers `bboxInclusionPct` because it's the
36026
+ * field exposed in the UI. Internally both feed the same gate.
36027
+ */
36028
+ bboxInclusionPct: number().min(0).max(100).optional(),
36029
+ /**
36030
+ * When `true` and a detection has a segmentation mask, use the
36031
+ * mask for overlap instead of the bbox. Detection-stage only;
36032
+ * motion rules ignore this field.
36033
+ */
36034
+ preferMask: boolean().optional(),
36035
+ /**
36036
+ * Soft-toggle: `false` disables the rule without deleting it.
36037
+ * Defaults to `true` so operators creating a rule via the UI
36038
+ * see it active immediately.
36039
+ */
36040
+ enabled: boolean().default(true)
36041
+ });
36042
+ array(ZoneRuleSchema).readonly();
36043
+ /**
34926
36044
  * Script-runner cap. Models HA `script.*` entities on
34927
36045
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
34928
36046
  * that can be invoked imperatively — optionally with a variables
@@ -41183,6 +42301,30 @@ Object.freeze({
41183
42301
  addonId: null,
41184
42302
  access: "create"
41185
42303
  },
42304
+ "deviceExtension.listCandidates": {
42305
+ capName: "device-extension",
42306
+ capScope: "device",
42307
+ addonId: null,
42308
+ access: "view"
42309
+ },
42310
+ "deviceExtension.listSlots": {
42311
+ capName: "device-extension",
42312
+ capScope: "device",
42313
+ addonId: null,
42314
+ access: "view"
42315
+ },
42316
+ "deviceExtension.listSources": {
42317
+ capName: "device-extension",
42318
+ capScope: "device",
42319
+ addonId: null,
42320
+ access: "view"
42321
+ },
42322
+ "deviceExtension.setSlot": {
42323
+ capName: "device-extension",
42324
+ capScope: "device",
42325
+ addonId: null,
42326
+ access: "create"
42327
+ },
41186
42328
  "deviceManager.addLocation": {
41187
42329
  capName: "device-manager",
41188
42330
  capScope: "system",
@@ -41453,6 +42595,12 @@ Object.freeze({
41453
42595
  addonId: null,
41454
42596
  access: "view"
41455
42597
  },
42598
+ "deviceManager.listDeviceIdsByCaps": {
42599
+ capName: "device-manager",
42600
+ capScope: "system",
42601
+ addonId: null,
42602
+ access: "view"
42603
+ },
41456
42604
  "deviceManager.listLocationDescriptions": {
41457
42605
  capName: "device-manager",
41458
42606
  capScope: "system",
@@ -41927,6 +43075,12 @@ Object.freeze({
41927
43075
  addonId: null,
41928
43076
  access: "view"
41929
43077
  },
43078
+ "embeddingEncoder.resetFailedModels": {
43079
+ capName: "embedding-encoder",
43080
+ capScope: "system",
43081
+ addonId: null,
43082
+ access: "delete"
43083
+ },
41930
43084
  "enumSensor.getStatus": {
41931
43085
  capName: "enum-sensor",
41932
43086
  capScope: "device",
@@ -42413,12 +43567,30 @@ Object.freeze({
42413
43567
  addonId: null,
42414
43568
  access: "create"
42415
43569
  },
43570
+ "llmRuntime.appleAvailability": {
43571
+ capName: "llm-runtime",
43572
+ capScope: "system",
43573
+ addonId: null,
43574
+ access: "view"
43575
+ },
43576
+ "llmRuntime.cancel": {
43577
+ capName: "llm-runtime",
43578
+ capScope: "system",
43579
+ addonId: null,
43580
+ access: "create"
43581
+ },
42416
43582
  "llmRuntime.complete": {
42417
43583
  capName: "llm-runtime",
42418
43584
  capScope: "system",
42419
43585
  addonId: null,
42420
43586
  access: "create"
42421
43587
  },
43588
+ "llmRuntime.completeApple": {
43589
+ capName: "llm-runtime",
43590
+ capScope: "system",
43591
+ addonId: null,
43592
+ access: "create"
43593
+ },
42422
43594
  "llmRuntime.deleteModel": {
42423
43595
  capName: "llm-runtime",
42424
43596
  capScope: "system",
@@ -43091,6 +44263,12 @@ Object.freeze({
43091
44263
  addonId: null,
43092
44264
  access: "create"
43093
44265
  },
44266
+ "nodes.directory": {
44267
+ capName: "nodes",
44268
+ capScope: "system",
44269
+ addonId: null,
44270
+ access: "view"
44271
+ },
43094
44272
  "nodes.executeQuery": {
43095
44273
  capName: "nodes",
43096
44274
  capScope: "system",
@@ -43259,6 +44437,12 @@ Object.freeze({
43259
44437
  addonId: null,
43260
44438
  access: "view"
43261
44439
  },
44440
+ "notificationRules.getRuleLastRuns": {
44441
+ capName: "notification-rules",
44442
+ capScope: "system",
44443
+ addonId: null,
44444
+ access: "view"
44445
+ },
43262
44446
  "notificationRules.getTemplateCatalog": {
43263
44447
  capName: "notification-rules",
43264
44448
  capScope: "system",
@@ -43283,6 +44467,12 @@ Object.freeze({
43283
44467
  addonId: null,
43284
44468
  access: "view"
43285
44469
  },
44470
+ "notificationRules.previewStateSummary": {
44471
+ capName: "notification-rules",
44472
+ capScope: "system",
44473
+ addonId: null,
44474
+ access: "view"
44475
+ },
43286
44476
  "notificationRules.previewTemplate": {
43287
44477
  capName: "notification-rules",
43288
44478
  capScope: "system",
@@ -43859,12 +45049,6 @@ Object.freeze({
43859
45049
  addonId: null,
43860
45050
  access: "create"
43861
45051
  },
43862
- "pipelineAnalytics.runReplayFrameProcessor": {
43863
- capName: "pipeline-analytics",
43864
- capScope: "device",
43865
- addonId: null,
43866
- access: "create"
43867
- },
43868
45052
  "pipelineAnalytics.saveRetrainAnnotations": {
43869
45053
  capName: "pipeline-analytics",
43870
45054
  capScope: "device",
@@ -44231,6 +45415,12 @@ Object.freeze({
44231
45415
  addonId: null,
44232
45416
  access: "view"
44233
45417
  },
45418
+ "pipelineOrchestrator.getClusterModelChoice": {
45419
+ capName: "pipeline-orchestrator",
45420
+ capScope: "system",
45421
+ addonId: null,
45422
+ access: "view"
45423
+ },
44234
45424
  "pipelineOrchestrator.getDeviceLiveContribution": {
44235
45425
  capName: "pipeline-orchestrator",
44236
45426
  capScope: "system",
@@ -47056,6 +48246,26 @@ Object.freeze({
47056
48246
  form: "single",
47057
48247
  optional: false
47058
48248
  }],
48249
+ "deviceExtension.listCandidates": [{
48250
+ name: "deviceId",
48251
+ form: "single",
48252
+ optional: false
48253
+ }],
48254
+ "deviceExtension.listSlots": [{
48255
+ name: "deviceId",
48256
+ form: "single",
48257
+ optional: false
48258
+ }],
48259
+ "deviceExtension.listSources": [{
48260
+ name: "deviceId",
48261
+ form: "single",
48262
+ optional: false
48263
+ }],
48264
+ "deviceExtension.setSlot": [{
48265
+ name: "deviceId",
48266
+ form: "single",
48267
+ optional: false
48268
+ }],
47059
48269
  "deviceManager.adoptionRelease": [{
47060
48270
  name: "camDeviceId",
47061
48271
  form: "single",
@@ -47962,11 +49172,6 @@ Object.freeze({
47962
49172
  form: "single",
47963
49173
  optional: false
47964
49174
  }],
47965
- "pipelineAnalytics.runReplayFrameProcessor": [{
47966
- name: "deviceId",
47967
- form: "single",
47968
- optional: false
47969
- }],
47970
49175
  "pipelineAnalytics.saveRetrainAnnotations": [{
47971
49176
  name: "deviceId",
47972
49177
  form: "single",
@@ -49062,11 +50267,232 @@ function prepareNotification(caps, n) {
49062
50267
  renderedAs
49063
50268
  };
49064
50269
  }
50270
+ /**
50271
+ * WHICH narrowing filter speaks about WHICH system-event kind — one predicate,
50272
+ * consumed by the rule ENGINE and by every rule EDITOR.
50273
+ *
50274
+ * ── The failure this file exists for ───────────────────────────────────────
50275
+ * `NcSystemEventConditionSchema` carries four optional narrowing lists
50276
+ * (`deviceIds`, `deviceTypes`, `nodeIds`, `packageNames`) beside a required
50277
+ * `kinds` gate. They are not four filters over one vocabulary: each belongs to
50278
+ * a FAMILY of kinds and is meaningless outside it. A node going away has no
50279
+ * device type; a completed export has no package; `stream-offline` deliberately
50280
+ * carries no device type at all (a stream belongs to a camera by construction).
50281
+ *
50282
+ * The engine applied all four to every kind, so a filter from one family failed
50283
+ * a kind from another family CLOSED. The operator's live rule "Eventi di
50284
+ * sistema" selected eleven kinds and set `deviceTypes: ['camera']` — the only
50285
+ * way to say "only my cameras" about the two liveness kinds — and NINE of the
50286
+ * eleven silently stopped being deliverable. Four days of history contained
50287
+ * `device-online` and `device-offline` and nothing else, across a window in
50288
+ * which agents were restarted and addons were updated.
50289
+ *
50290
+ * Both editors already computed this scoping, to decide which filter boxes to
50291
+ * render; the cap's own docblock already promised it ("Narrow a `device-*` kind
50292
+ * to these device TYPES"). Only the engine disagreed, and it disagreed in the
50293
+ * destructive direction. So the rule is stated ONCE, here, and the engine and
50294
+ * the editors are readers of it rather than three independent authors.
50295
+ *
50296
+ * ── The direction ─────────────────────────────────────────────────────────
50297
+ * Out of family ⇒ the filter is IGNORED, never fail-closed. An editor that
50298
+ * hides a box has already told the operator this filter does not speak about
50299
+ * these kinds, so honouring it as an exclusion contradicts the only
50300
+ * explanation the operator was ever given. Inside its family the filter still
50301
+ * narrows, and still fails CLOSED on a subject that cannot produce the identity
50302
+ * it tests (a device the mirror cannot name is not evidence of a camera).
50303
+ */
50304
+ /**
50305
+ * Every filter, for the callers that must cover all of them (guards, tests).
50306
+ *
50307
+ * `consumableLowPercent` (D642) is not a list but it is a filter in exactly
50308
+ * this sense: it belongs to a family of kinds (the consumable pair) and the
50309
+ * engine consults it only there. It differs in one way the readers must know —
50310
+ * its ABSENCE is not "no narrowing" but the default threshold, because a
50311
+ * consumable episode is always judged at SOME threshold.
50312
+ */
50313
+ var NC_SYSTEM_EVENT_FILTER_KEYS = [
50314
+ "deviceIds",
50315
+ "deviceTypes",
50316
+ "nodeIds",
50317
+ "packageNames",
50318
+ "consumableLowPercent"
50319
+ ];
50320
+ new Map(Object.entries({
50321
+ "device-online": "device-events",
50322
+ "device-offline": "device-events",
50323
+ "device-disabled": "device-events",
50324
+ "device-enabled": "device-events",
50325
+ "device-battery-low": "device-events",
50326
+ "device-battery-normal": "device-events",
50327
+ "device-consumable-low": "device-events",
50328
+ "device-consumable-normal": "device-events",
50329
+ "device-tank-low": "device-events",
50330
+ "device-tank-full": "device-events",
50331
+ "device-tank-normal": "device-events",
50332
+ "stream-online": "device-events",
50333
+ "stream-offline": "device-events",
50334
+ "detection-blind": "device-events",
50335
+ "node-online": "system",
50336
+ "node-offline": "system",
50337
+ "node-inference-unavailable": "system",
50338
+ "addon-crash-loop": "system",
50339
+ "addon-update-available": "system",
50340
+ "addon-updated": "system",
50341
+ "server-update-available": "system",
50342
+ "server-updated": "system",
50343
+ "wrapper-update-available": "system",
50344
+ "backup-completed": "system",
50345
+ "export-completed": "system",
50346
+ "alarm-triggered": "alarm",
50347
+ "alarm-armed": "alarm",
50348
+ "alarm-disarmed": "alarm",
50349
+ "alarm-arming": "alarm",
50350
+ "alarm-arm-refused": "alarm",
50351
+ "alarm-pending": "alarm",
50352
+ "alarm-rearmed": "alarm",
50353
+ "alarm-sensor-bypass": "alarm",
50354
+ "alarm-check-failed": "alarm",
50355
+ "camera-online": null,
50356
+ "camera-offline": null,
50357
+ "camera-disabled": null,
50358
+ "camera-enabled": null
50359
+ }));
50360
+ [...NC_SYSTEM_EVENT_FILTER_KEYS];
50361
+ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
50362
+ {
50363
+ id: "device-state",
50364
+ family: "device-events",
50365
+ label: "Device state",
50366
+ kinds: [
50367
+ "device-offline",
50368
+ "device-online",
50369
+ "device-disabled",
50370
+ "device-enabled"
50371
+ ]
50372
+ },
50373
+ {
50374
+ id: "streams",
50375
+ family: "device-events",
50376
+ label: "Streams",
50377
+ kinds: ["stream-offline", "stream-online"]
50378
+ },
50379
+ {
50380
+ id: "battery",
50381
+ family: "device-events",
50382
+ label: "Battery",
50383
+ kinds: ["device-battery-low", "device-battery-normal"]
50384
+ },
50385
+ {
50386
+ id: "consumables",
50387
+ family: "device-events",
50388
+ label: "Consumables",
50389
+ kinds: ["device-consumable-low", "device-consumable-normal"]
50390
+ },
50391
+ {
50392
+ id: "tanks",
50393
+ family: "device-events",
50394
+ label: "Tanks",
50395
+ kinds: [
50396
+ "device-tank-low",
50397
+ "device-tank-full",
50398
+ "device-tank-normal"
50399
+ ]
50400
+ },
50401
+ {
50402
+ id: "detection-blind",
50403
+ family: "device-events",
50404
+ label: "Detecting nothing",
50405
+ kinds: ["detection-blind"]
50406
+ },
50407
+ {
50408
+ id: "nodes",
50409
+ family: "system",
50410
+ label: "Nodes",
50411
+ kinds: [
50412
+ "node-offline",
50413
+ "node-online",
50414
+ "node-inference-unavailable"
50415
+ ]
50416
+ },
50417
+ {
50418
+ id: "addons",
50419
+ family: "system",
50420
+ label: "Addons",
50421
+ kinds: [
50422
+ "addon-crash-loop",
50423
+ "addon-update-available",
50424
+ "addon-updated"
50425
+ ]
50426
+ },
50427
+ {
50428
+ id: "updates",
50429
+ family: "system",
50430
+ label: "Server & container updates",
50431
+ kinds: [
50432
+ "server-update-available",
50433
+ "server-updated",
50434
+ "wrapper-update-available"
50435
+ ]
50436
+ },
50437
+ {
50438
+ id: "backups-exports",
50439
+ family: "system",
50440
+ label: "Backups & exports",
50441
+ kinds: ["backup-completed", "export-completed"]
50442
+ },
50443
+ {
50444
+ id: "alarm",
50445
+ family: "alarm",
50446
+ label: "Alarm",
50447
+ kinds: NC_ALARM_SYSTEM_EVENT_KINDS
50448
+ }
50449
+ ];
50450
+ function systemEventKindsOfFamily(family) {
50451
+ return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
50452
+ }
49065
50453
  NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
50454
+ /**
50455
+ * WHICH WAY A BOOLEAN SENSOR MOVED — read off the one slice a sensor event
50456
+ * persists (D640 "a sensor rule fires on the raise, the clear, or both").
50457
+ *
50458
+ * A device-event rule over a flood sensor notified on BOTH edges: water
50459
+ * detected, and back to dry. `NcConditions.sensorTransition` lets the rule
50460
+ * name one edge; this file answers, for one `SensorEvent`, which edge it is.
50461
+ *
50462
+ * NOT A SECOND TABLE. The "which boolean of this cap counts as HIGH" question
50463
+ * already has one answer, `SOURCE_CAP_ACTIVE_FIELD`
50464
+ * (`catalogs/sensor-active-state.ts`, the doorbell's and the recorder's edge
50465
+ * table), and a sensor event names its kind, not its cap. So the table here is
50466
+ * DERIVED: event kind → cap (`EVENT_KIND_BY_CAP`) → that cap's active field.
50467
+ * Only kinds whose taxonomy category is `sensor` take part — a switch has an
50468
+ * `on` boolean too, but "it triggers / it clears" is not a sentence about a
50469
+ * light, and offering it there would be a knob with a misleading label.
50470
+ * `presence` is a WORD (`home` / `not_home` / a zone), not a boolean, and is
50471
+ * absent from the source table, so it is absent here.
50472
+ *
50473
+ * `undefined` = never guessed: a kind with no raise (a doorbell press, a
50474
+ * button, a cover), or a slice whose field is missing or not a boolean. The
50475
+ * engine then does NOT filter — a flood alert must not go silent because one
50476
+ * read came back unreadable (the same stance as the alarm's `sensorEdgeOf`).
50477
+ *
50478
+ * Pure, RN-safe: the viewer imports the support rule from here.
50479
+ */
50480
+ /** Event kind → the boolean field of its cap slice that means "raised". */
50481
+ var NC_SENSOR_RAISED_FIELD_BY_KIND = Object.freeze(Object.fromEntries(Object.entries(EVENT_KIND_BY_CAP).flatMap(([capName, descriptor]) => {
50482
+ const field = SOURCE_CAP_ACTIVE_FIELD[capName];
50483
+ if (field === void 0 || descriptor.category !== "sensor") return [];
50484
+ return [[descriptor.kind, field]];
50485
+ })));
50486
+ Object.freeze(Object.keys(NC_SENSOR_RAISED_FIELD_BY_KIND));
49066
50487
  var RULE_BODY_ONLY = ["body"];
49067
50488
  var RULE_TEXT = ["title", "body"];
49068
50489
  var BATTERY = ["device-battery-low", "device-battery-normal"];
49069
50490
  var CONSUMABLE = ["device-consumable-low", "device-consumable-normal"];
50491
+ var TANK = [
50492
+ "device-tank-low",
50493
+ "device-tank-full",
50494
+ "device-tank-normal"
50495
+ ];
49070
50496
  var UPDATES = [
49071
50497
  "addon-update-available",
49072
50498
  "server-update-available",
@@ -49092,12 +50518,189 @@ var DEVICE_EVENTS = [
49092
50518
  "device-enabled",
49093
50519
  ...BATTERY,
49094
50520
  ...CONSUMABLE,
50521
+ ...TANK,
49095
50522
  "stream-online",
49096
50523
  "stream-offline",
49097
50524
  "detection-blind",
49098
50525
  ...ALARM
49099
50526
  ];
49100
- [...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], [...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];
50527
+ /** Every kind a summary may speak about — the two summarisable families. */
50528
+ var SUMMARISABLE = [...systemEventKindsOfFamily("device-events"), ...systemEventKindsOfFamily("system")];
50529
+ /** One per summary SECTION (`NC_STATE_SUMMARY_SECTIONS` in the notification
50530
+ * centre): the section's lines, offered when one of its kinds is selected. */
50531
+ var STATE_SUMMARY_SECTION_VARS = [
50532
+ {
50533
+ name: "summaryDevices",
50534
+ label: "Summary: devices offline / switched off",
50535
+ example: "Garage — offline since 07:12",
50536
+ kinds: [
50537
+ "device-offline",
50538
+ "device-online",
50539
+ "device-disabled",
50540
+ "device-enabled"
50541
+ ]
50542
+ },
50543
+ {
50544
+ name: "summaryStreams",
50545
+ label: "Summary: streams offline",
50546
+ example: "Ingresso (high) — since 06:40",
50547
+ kinds: ["stream-offline", "stream-online"]
50548
+ },
50549
+ {
50550
+ name: "summaryBattery",
50551
+ label: "Summary: low batteries",
50552
+ example: "Sensore porta — 8 %",
50553
+ kinds: BATTERY
50554
+ },
50555
+ {
50556
+ name: "summaryConsumables",
50557
+ label: "Summary: consumables",
50558
+ example: "Robot — filter 10 %",
50559
+ kinds: CONSUMABLE
50560
+ },
50561
+ {
50562
+ name: "summaryTanks",
50563
+ label: "Summary: tanks",
50564
+ example: "Robot — clean water low",
50565
+ kinds: TANK
50566
+ },
50567
+ {
50568
+ name: "summaryDetection",
50569
+ label: "Summary: cameras detecting nothing",
50570
+ example: "Ingresso — since 05:10",
50571
+ kinds: ["detection-blind"]
50572
+ },
50573
+ {
50574
+ name: "summaryNodes",
50575
+ label: "Summary: nodes",
50576
+ example: "little-unraid — offline since 03:00",
50577
+ kinds: [
50578
+ "node-offline",
50579
+ "node-online",
50580
+ "node-inference-unavailable"
50581
+ ]
50582
+ },
50583
+ {
50584
+ name: "summaryAddons",
50585
+ label: "Summary: addons",
50586
+ example: "@camstack/addon-recorder 1.2.3 → 1.2.4",
50587
+ kinds: [
50588
+ "addon-crash-loop",
50589
+ "addon-update-available",
50590
+ "addon-updated"
50591
+ ]
50592
+ },
50593
+ {
50594
+ name: "summaryUpdates",
50595
+ label: "Summary: server & container updates",
50596
+ example: "server 1.2.377 → 1.2.378",
50597
+ kinds: [
50598
+ "server-update-available",
50599
+ "server-updated",
50600
+ "wrapper-update-available"
50601
+ ]
50602
+ }
50603
+ ];
50604
+ var STATE_SUMMARY_VARS = [
50605
+ {
50606
+ name: "summaryText",
50607
+ label: "Summary: every section",
50608
+ description: "One block per section with something to report, one line per item.",
50609
+ example: "Batterie scariche: Sensore porta — 8 %",
50610
+ group: "system",
50611
+ families: ["rule"],
50612
+ fields: [...RULE_TEXT],
50613
+ kinds: ["system"],
50614
+ systemEventKinds: [...SUMMARISABLE],
50615
+ systemEventDeliveries: ["summary"]
50616
+ },
50617
+ {
50618
+ name: "summaryCount",
50619
+ label: "Summary: items reported",
50620
+ example: "3",
50621
+ group: "system",
50622
+ families: ["rule"],
50623
+ fields: [...RULE_TEXT],
50624
+ kinds: ["system"],
50625
+ systemEventKinds: [...SUMMARISABLE],
50626
+ systemEventDeliveries: ["summary"]
50627
+ },
50628
+ ...STATE_SUMMARY_SECTION_VARS.map((v) => ({
50629
+ name: v.name,
50630
+ label: v.label,
50631
+ example: v.example,
50632
+ group: "system",
50633
+ families: ["rule"],
50634
+ fields: [...RULE_TEXT],
50635
+ kinds: ["system"],
50636
+ systemEventKinds: [...v.kinds],
50637
+ systemEventDeliveries: ["summary"]
50638
+ }))
50639
+ ];
50640
+ [
50641
+ [...DEVICE_EVENTS],
50642
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
50643
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
50644
+ [...RULE_TEXT],
50645
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
50646
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
50647
+ [...RULE_TEXT],
50648
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
50649
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
50650
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
50651
+ [...RULE_TEXT],
50652
+ [...RULE_TEXT],
50653
+ [...RULE_TEXT],
50654
+ [...RULE_TEXT],
50655
+ [...RULE_TEXT],
50656
+ [...RULE_TEXT],
50657
+ [...RULE_TEXT],
50658
+ [...RULE_TEXT],
50659
+ [...RULE_BODY_ONLY],
50660
+ [...RULE_TEXT],
50661
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
50662
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
50663
+ ([...RULE_TEXT], [...BATTERY, ...CONSUMABLE]),
50664
+ ([...RULE_TEXT], [...CONSUMABLE]),
50665
+ ([...RULE_TEXT], [...TANK]),
50666
+ [...RULE_TEXT],
50667
+ ([...RULE_TEXT], [...UPDATES]),
50668
+ ([...RULE_TEXT], [...UPDATES]),
50669
+ [...RULE_TEXT],
50670
+ [...RULE_TEXT],
50671
+ [...RULE_TEXT],
50672
+ ([...RULE_TEXT], [...UPDATES]),
50673
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
50674
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
50675
+ ([...RULE_TEXT], [...UPDATES]),
50676
+ ([...RULE_TEXT], [...UPDATES]),
50677
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
50678
+ [...RULE_TEXT],
50679
+ [...RULE_TEXT],
50680
+ [...RULE_TEXT],
50681
+ [...RULE_TEXT],
50682
+ [...RULE_TEXT],
50683
+ [...RULE_TEXT],
50684
+ [...RULE_TEXT],
50685
+ [...RULE_TEXT],
50686
+ [...RULE_TEXT],
50687
+ [...RULE_TEXT],
50688
+ [...RULE_TEXT],
50689
+ [...RULE_TEXT],
50690
+ [...RULE_TEXT],
50691
+ [...RULE_TEXT],
50692
+ [...RULE_TEXT],
50693
+ [...RULE_TEXT],
50694
+ [...RULE_TEXT],
50695
+ [...RULE_TEXT],
50696
+ [...RULE_TEXT],
50697
+ [...RULE_TEXT],
50698
+ [...RULE_TEXT],
50699
+ [...RULE_TEXT],
50700
+ [...RULE_TEXT],
50701
+ [...RULE_TEXT],
50702
+ ...STATE_SUMMARY_VARS
50703
+ ];
49101
50704
  /**
49102
50705
  * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
49103
50706
  *
@@ -49329,68 +50932,6 @@ TimelapseRuleInputSchema.extend({
49329
50932
  createdAt: number(),
49330
50933
  updatedAt: number()
49331
50934
  });
49332
- Object.freeze(Object.fromEntries([{
49333
- stepId: "face-embedding",
49334
- label: "Face recognition model",
49335
- defaultModelId: "arcface-r100",
49336
- indexName: "the enrolled face gallery",
49337
- options: [
49338
- {
49339
- id: "arcface-r100",
49340
- label: "ArcFace (ResNet34)"
49341
- },
49342
- {
49343
- id: "auraface-r100",
49344
- label: "AuraFace R100"
49345
- },
49346
- {
49347
- id: "inception-resnet-v1",
49348
- label: "Inception ResNet V1"
49349
- }
49350
- ]
49351
- }, {
49352
- stepId: "clip-embedding",
49353
- label: "Semantic search model",
49354
- defaultModelId: "mobileclip-s1",
49355
- indexName: "the object semantic-search index",
49356
- options: [{
49357
- id: "mobileclip-s1",
49358
- label: "MobileCLIP S1"
49359
- }, {
49360
- id: "mobileclip-s2",
49361
- label: "MobileCLIP S2"
49362
- }]
49363
- }].map((s) => [s.stepId, s.defaultModelId])));
49364
- string().min(1);
49365
- var CLUSTER_STEP_SETTING_FIELDS = [{
49366
- stepId: "face-embedding",
49367
- key: "minLandmarkFaceSize",
49368
- label: "Min face size for recognition (detection px)",
49369
- 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.",
49370
- type: "slider",
49371
- min: 0,
49372
- max: 64,
49373
- step: 2,
49374
- default: 24
49375
- }];
49376
- function clusterStepSettingKey(stepId, fieldKey) {
49377
- return `clusterStepSetting:${stepId}:${fieldKey}`;
49378
- }
49379
- var ClusterSettingNumberSchema = number().finite();
49380
- function readClusterStepSettings(config) {
49381
- const out = {};
49382
- for (const field of CLUSTER_STEP_SETTING_FIELDS) {
49383
- const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
49384
- const value = parsed.success ? parsed.data : field.default;
49385
- const existing = out[field.stepId] ?? {};
49386
- out[field.stepId] = {
49387
- ...existing,
49388
- [field.key]: value
49389
- };
49390
- }
49391
- return out;
49392
- }
49393
- readClusterStepSettings({});
49394
50935
  object({
49395
50936
  /**
49396
50937
  * Fraction of the box's own size added on EACH side before cutting.