@camstack/addon-notifiers 1.2.120 → 1.2.121

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +2688 -824
  2. package/dist/addon.mjs +2688 -824
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -5390,7 +5390,7 @@ var ZodIssueCode = {
5390
5390
  var ZodFirstPartyTypeKind;
5391
5391
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5392
5392
  //#endregion
5393
- //#region ../types/dist/sleep-D_4W7xuQ.mjs
5393
+ //#region ../types/dist/sleep-DC-wdyeS.mjs
5394
5394
  /**
5395
5395
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5396
5396
  * window to float samples (D455).
@@ -6175,6 +6175,40 @@ var BaseAddon = class {
6175
6175
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6176
6176
  return keys.size > 0 ? projectStore(raw, keys, node) : raw;
6177
6177
  }
6178
+ /**
6179
+ * Whether ONE global key of this addon's store was written, read three-way
6180
+ * (D651). For a question a hydrated view cannot answer: `getGlobalSettings`
6181
+ * reports `value ?? default`, so "the operator chose the default" and "nobody
6182
+ * chose" look the same, and a failed read looks like both. A `perNode` key is
6183
+ * not supported here: its stored name is scoped.
6184
+ */
6185
+ async readStoredGlobalKey(key) {
6186
+ const read = this._ctx?.settings?.readAddonStoreResult;
6187
+ if (read === void 0) return {
6188
+ kind: "unreadable",
6189
+ reason: "three-way-read-unavailable"
6190
+ };
6191
+ let result;
6192
+ try {
6193
+ result = await read.call(this._ctx?.settings);
6194
+ } catch (err) {
6195
+ return {
6196
+ kind: "unreadable",
6197
+ reason: "store-read-failed",
6198
+ error: err instanceof Error ? err.message : String(err)
6199
+ };
6200
+ }
6201
+ if (result.kind === "failed") return {
6202
+ kind: "unreadable",
6203
+ reason: "store-read-failed",
6204
+ error: result.error
6205
+ };
6206
+ if (result.kind === "missing" || !Object.prototype.hasOwnProperty.call(result.value, key)) return { kind: "absent" };
6207
+ return {
6208
+ kind: "present",
6209
+ value: result.value[key]
6210
+ };
6211
+ }
6178
6212
  async updateGlobalSettings(patch, nodeId) {
6179
6213
  const keys = this.perNodeKeys();
6180
6214
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
@@ -9556,6 +9590,43 @@ var LogChannelWindowSchema = object({
9556
9590
  /** `null` = every camera. A non-empty list narrows to those numeric ids. */
9557
9591
  deviceIds: array(number().int()).readonly().nullable()
9558
9592
  });
9593
+ var ClipModelMetaSchema = object({
9594
+ /** The paired text encoder's catalog id (the embedding-encoder's text catalog). */
9595
+ textModelId: string().min(1),
9596
+ /** Output dimension of BOTH towers. A vector of any other length is refused. */
9597
+ embeddingDim: number().int().positive(),
9598
+ /**
9599
+ * The `vector-store` index this model's vectors live in. ONE feature space
9600
+ * per index: two models share an index only when their vectors are ranked
9601
+ * against each other, which for CLIP means never across families. MobileCLIP
9602
+ * S1 and S2 share `object-clip` for history (separated by the row's
9603
+ * `modelId`); any other model gets its own.
9604
+ */
9605
+ vectorIndex: string().regex(/^object-clip(-[a-z0-9][a-z0-9-]*)?$/),
9606
+ /**
9607
+ * The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
9608
+ * must be unique per tokenizer: every model's siblings land in ONE flat
9609
+ * models directory, so two different tokenizers under the same name would
9610
+ * silently overwrite each other (whichever model downloaded last wins, and
9611
+ * the other one tokenises with the wrong vocabulary).
9612
+ */
9613
+ tokenizerFile: string().min(1),
9614
+ /** Token window the text graph takes (SigLIP2: 64; CLIP BPE: 77). */
9615
+ contextLength: number().int().positive(),
9616
+ /** Id the tokenizer pads with. */
9617
+ padId: number().int().nonnegative(),
9618
+ /**
9619
+ * The search cosine floor at `strictness: 'loose'` — calibrated per model,
9620
+ * because cosine bands are a property of the model: 0.2 keeps 96% of matched
9621
+ * COCO caption-image pairs on MobileCLIP S1 and 2.7% on SigLIP2.
9622
+ */
9623
+ searchMinScore: number().min(0).max(1)
9624
+ });
9625
+ var ClipSearchStrictnessSchema = _enum([
9626
+ "loose",
9627
+ "balanced",
9628
+ "strict"
9629
+ ]);
9559
9630
  var MODEL_FORMATS = [
9560
9631
  "onnx",
9561
9632
  "coreml",
@@ -9584,7 +9655,7 @@ var ModelFormatEntrySchema = object({
9584
9655
  /** Multi-file payload (directory members or sibling files). */
9585
9656
  files: array(string()).readonly().optional(),
9586
9657
  /** Runtime(s) that can use this format. If omitted, inferred from ModelFormat key */
9587
- runtimes: array(_enum(["node", "python"])).readonly().optional()
9658
+ runtimes: array(_enum(["python"])).readonly().optional()
9588
9659
  });
9589
9660
  /**
9590
9661
  * Extra file that must be downloaded alongside the model (e.g., labels JSON, dict.txt).
@@ -9645,6 +9716,48 @@ var ModelProviderIdSchema = _enum([
9645
9716
  "scrypted",
9646
9717
  "custom"
9647
9718
  ]);
9719
+ /**
9720
+ * The licence of a model, as a record rather than a bare SPDX string: a
9721
+ * permissive CODE licence routinely sits on top of restrictive WEIGHTS or
9722
+ * DATA, and the obligations (attribution, modification notices, source offers)
9723
+ * are per upstream. A persisted custom-model row written when this field was a
9724
+ * string still parses — the string is lifted into `{ weights }`.
9725
+ *
9726
+ * Every licence surface (the admin "Models and licenses" page,
9727
+ * `THIRD_PARTY_MODELS.md`, the Hugging Face model table) is GENERATED from
9728
+ * these records by `scripts/gen-model-licenses.ts` (D661).
9729
+ */
9730
+ var ModelLicenseSchema = preprocess((value) => typeof value === "string" ? { weights: value } : value, object({
9731
+ /** SPDX id of the WEIGHTS' terms, a `LicenseRef-*` for non-SPDX terms, or `UNKNOWN`. */
9732
+ weights: string().min(1),
9733
+ /** SPDX id of the upstream code that defines / trained the network. */
9734
+ code: string().min(1).optional(),
9735
+ /** Training data whose terms add obligations (attribution, non-commercial). */
9736
+ data: object({
9737
+ name: string().min(1),
9738
+ terms: string().min(1),
9739
+ url: string().url().optional()
9740
+ }).optional(),
9741
+ /** The project the weights come from. Required on built-in entries (guard). */
9742
+ upstream: object({
9743
+ name: string().min(1),
9744
+ url: string().url()
9745
+ }).optional(),
9746
+ /** Where the licence text governing the weights is published. */
9747
+ url: string().url().optional(),
9748
+ /** Attribution the licence REQUIRES, verbatim. */
9749
+ attribution: string().min(1).optional(),
9750
+ /** What CamStack changed. Required when `hosting` is `camstack-hf` (guard). */
9751
+ modifications: string().min(1).optional(),
9752
+ /** Who serves the file a node downloads. */
9753
+ hosting: _enum([
9754
+ "camstack-hf",
9755
+ "third-party",
9756
+ "built-in"
9757
+ ]).optional(),
9758
+ /** True when the weights or their data forbid commercial use. */
9759
+ nonCommercial: boolean().optional()
9760
+ }));
9648
9761
  var ModelCatalogEntrySchema = object({
9649
9762
  id: string(),
9650
9763
  name: string(),
@@ -9665,10 +9778,17 @@ var ModelCatalogEntrySchema = object({
9665
9778
  inputChannels: number().int().positive().optional(),
9666
9779
  labels: array(LabelDefinitionSchema).readonly(),
9667
9780
  inputLayout: _enum(["nchw", "nhwc"]).optional(),
9781
+ /**
9782
+ * `'scrfd'` applies InsightFace's SCRFD input contract, `(x - 127.5) / 128`
9783
+ * (upstream `insightface/model_zoo/scrfd.py`), instead of the historical
9784
+ * plain `/255`. Measured against COCO GT: 188 → 196 faces found on the
9785
+ * `scrfd-2.5g` catalog entry (2026-09-26 model-replacement spike, §2.4-2).
9786
+ */
9668
9787
  inputNormalization: _enum([
9669
9788
  "zero-one",
9670
9789
  "imagenet",
9671
- "none"
9790
+ "none",
9791
+ "scrfd"
9672
9792
  ]).optional(),
9673
9793
  /**
9674
9794
  * The model already applies softmax IN-GRAPH — its raw output is a
@@ -9726,11 +9846,11 @@ var ModelCatalogEntrySchema = object({
9726
9846
  p95LatencyMs: record(string(), number()).optional()
9727
9847
  }).optional(),
9728
9848
  /**
9729
- * SPDX-ish license id of the model weights (e.g. `AGPL-3.0` for Ultralytics
9730
- * YOLO26, `GPL-3.0` for YOLOv9, `Apache-2.0` for D-FINE/RF-DETR). Matters for
9731
- * the retraining addon and any future commercial distribution.
9849
+ * The model's licence record — see {@link ModelLicenseSchema}. Optional in
9850
+ * the schema (a custom model's author may state none); REQUIRED and complete
9851
+ * on every built-in catalog entry (`scripts/check-catalog-licence.ts`).
9732
9852
  */
9733
- license: string().optional(),
9853
+ license: ModelLicenseSchema.optional(),
9734
9854
  /**
9735
9855
  * Variant-selector grouping. The UI groups models by `family` + `tier` and
9736
9856
  * offers `precision` / `optimization` as variant axes WITHIN a tier — so all
@@ -9752,7 +9872,14 @@ var ModelCatalogEntrySchema = object({
9752
9872
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
9753
9873
  * labels already ARE the CamStack macros (Scrypted identity map).
9754
9874
  */
9755
- classMap: DetectionCatalogClassMapSchema.optional()
9875
+ classMap: DetectionCatalogClassMapSchema.optional(),
9876
+ /**
9877
+ * The model's CLIP feature-space contract (text encoder, dimension, vector
9878
+ * index, token window, search floor) — see `clip-model.ts`. Present ONLY on a
9879
+ * CLIP image encoder; its absence is what "not a CLIP model" means to the
9880
+ * embedding encoder and the semantic-search store (D649).
9881
+ */
9882
+ clip: ClipModelMetaSchema.optional()
9756
9883
  });
9757
9884
  var ConvertTargetSchema = discriminatedUnion("format", [object({
9758
9885
  format: literal("openvino"),
@@ -9770,7 +9897,8 @@ var ModelConvertMetadataSchema = object({
9770
9897
  inputNormalization: _enum([
9771
9898
  "zero-one",
9772
9899
  "imagenet",
9773
- "none"
9900
+ "none",
9901
+ "scrfd"
9774
9902
  ]).optional(),
9775
9903
  preprocessMode: _enum(["letterbox", "resize"]).optional(),
9776
9904
  outputFormat: _enum([
@@ -9817,23 +9945,6 @@ var ExpressionEvalError = class extends Error {
9817
9945
  this.name = "ExpressionEvalError";
9818
9946
  }
9819
9947
  };
9820
- /**
9821
- * Frozen, null-prototype builtin function table for the expression engine
9822
- * (spec §4 rule 4). The table is the SOLE surface of callable functions: the
9823
- * parser rejects any callee not in it, and the evaluator gates each call on an
9824
- * own-property check against it.
9825
- *
9826
- * Because the object has a NULL prototype AND is `Object.freeze`d:
9827
- * - it cannot be polluted (no `__proto__` / `constructor` write reaches it);
9828
- * - a lookup for `toString` / `hasOwnProperty` / `constructor` finds NOTHING
9829
- * (there is no `Object.prototype` in the chain), so those names are not
9830
- * callable — they are simply "unknown function" at parse time.
9831
- *
9832
- * Every numeric argument is validated as a finite number and every numeric
9833
- * RESULT is re-checked finite, so `/0`, `sqrt(-1)` (→ NaN) and overflow
9834
- * (`pow(10,400)` → Infinity) all raise `ExpressionEvalError` and fail the link
9835
- * closed rather than emitting a garbage value.
9836
- */
9837
9948
  function asFiniteNumber(value, name, index) {
9838
9949
  if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
9839
9950
  return value;
@@ -9849,6 +9960,10 @@ function finiteResult(value, name) {
9849
9960
  function allFiniteNumbers(args, name) {
9850
9961
  return args.map((a, idx) => asFiniteNumber(a, name, idx));
9851
9962
  }
9963
+ function asBoolean$1(value, name, index) {
9964
+ if (typeof value !== "boolean") throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a boolean`);
9965
+ return value;
9966
+ }
9852
9967
  var INF = Number.POSITIVE_INFINITY;
9853
9968
  var table = {
9854
9969
  min: {
@@ -9949,6 +10064,40 @@ var table = {
9949
10064
  if (from === to) return x;
9950
10065
  throw new ExpressionEvalError("convert: unit conversion table not installed");
9951
10066
  }
10067
+ },
10068
+ any: {
10069
+ minArgs: 1,
10070
+ maxArgs: INF,
10071
+ apply: (args) => args.map((a, i) => asBoolean$1(a, "any", i)).some((b) => b)
10072
+ },
10073
+ all: {
10074
+ minArgs: 1,
10075
+ maxArgs: INF,
10076
+ apply: (args) => args.map((a, i) => asBoolean$1(a, "all", i)).every((b) => b)
10077
+ },
10078
+ within: {
10079
+ minArgs: 2,
10080
+ maxArgs: 2,
10081
+ apply: (args, hooks) => {
10082
+ const windowMs = asFiniteNumber(args[1], "within", 1);
10083
+ if (windowMs < 0) throw new ExpressionEvalError("within: the window must not be negative");
10084
+ const at = args[0];
10085
+ if (at === null) return false;
10086
+ const ts = asFiniteNumber(at, "within", 0);
10087
+ const now = hooks.now;
10088
+ if (now === void 0 || !Number.isFinite(now)) throw new ExpressionEvalError("within: no clock was supplied to this evaluation");
10089
+ const inside = now - ts <= windowMs;
10090
+ if (inside) hooks.noteDeadline?.(ts + windowMs + 1);
10091
+ return inside;
10092
+ }
10093
+ },
10094
+ latest: {
10095
+ minArgs: 1,
10096
+ maxArgs: INF,
10097
+ apply: (args) => {
10098
+ const present = args.flatMap((a, i) => a === null ? [] : [asFiniteNumber(a, "latest", i)]);
10099
+ return present.length === 0 ? null : finiteResult(Math.max(...present), "latest");
10100
+ }
9952
10101
  }
9953
10102
  };
9954
10103
  Object.freeze(Object.assign(Object.create(null), table));
@@ -10563,7 +10712,7 @@ var AutomationActionSchema = discriminatedUnion("kind", [
10563
10712
  code: string().min(1).max(2e4)
10564
10713
  })
10565
10714
  ]);
10566
- object({
10715
+ var AutomationRecipeSchema = object({
10567
10716
  triggers: array(AutomationTriggerSchema),
10568
10717
  conditions: AutomationConditionSchema.optional(),
10569
10718
  actions: array(AutomationActionSchema)
@@ -11050,12 +11199,32 @@ var AudioClassificationLabelSchema = object({
11050
11199
  originalClass: string().optional(),
11051
11200
  score: number()
11052
11201
  });
11202
+ /**
11203
+ * Did the classifier RUN on this window? (D660)
11204
+ *
11205
+ * `classified` with no labels means the model heard nothing above the
11206
+ * camera's floor. `not-classified` means nobody listened — and until D660 the
11207
+ * two were the same shape (`classification` absent), so a window the global
11208
+ * busy gate threw away read downstream exactly like a quiet one (D393).
11209
+ */
11210
+ var AudioClassifyOutcomeSchema = discriminatedUnion("state", [object({ state: literal("classified") }), object({
11211
+ state: literal("not-classified"),
11212
+ reason: _enum([
11213
+ "superseded",
11214
+ "error",
11215
+ "timeout",
11216
+ "disposed"
11217
+ ])
11218
+ })]);
11053
11219
  var AudioAnalysisResultSchema = object({
11054
11220
  level: AudioLevelSchema,
11221
+ /** Labels at or above the camera's floor. Absent = none — read `classifyOutcome` to know whether the model ran at all. */
11055
11222
  classification: object({
11056
11223
  labels: array(AudioClassificationLabelSchema).readonly(),
11057
11224
  inferenceMs: number()
11058
11225
  }).optional(),
11226
+ /** Whether the classifier ran on this window (D660). */
11227
+ classifyOutcome: AudioClassifyOutcomeSchema,
11059
11228
  timestamp: number()
11060
11229
  });
11061
11230
  var AudioAnalysisSettingsSchema = object({
@@ -12613,6 +12782,195 @@ DeviceType.Camera, method(object({ deviceId: number().int().nonnegative() }), ar
12613
12782
  }),
12614
12783
  lastChangedAt: number()
12615
12784
  });
12785
+ /** A composed device's stableId is this prefix plus the block id. */
12786
+ var COMPOSED_DEVICE_STABLE_ID_PREFIX = "composed-";
12787
+ /** Longest snippet a `code` source may carry (slice 4). */
12788
+ var MAX_COMPOSITION_CODE_LENGTH = 2e4;
12789
+ var CompositionSourceRefSchema = object({
12790
+ /** The owning addon; `stableId` is unique only within it. */
12791
+ addonId: string().min(1),
12792
+ stableId: string().min(1)
12793
+ });
12794
+ /** One field of one capability of one source device. */
12795
+ var CompositionFieldReadSchema = object({
12796
+ source: CompositionSourceRefSchema,
12797
+ cap: string().min(1),
12798
+ /** Dotted path into the source cap's runtime-state slice. */
12799
+ fieldPath: string().min(1)
12800
+ });
12801
+ /** `from`: copy one source field verbatim. It is also an expression's `from` binding. */
12802
+ var CompositionFromSourceSchema = CompositionFieldReadSchema.extend({ kind: literal("from") });
12803
+ var CompositionBindingSchema = discriminatedUnion("kind", [CompositionFromSourceSchema, object({
12804
+ kind: literal("literal"),
12805
+ value: union([
12806
+ string(),
12807
+ number(),
12808
+ boolean(),
12809
+ _null()
12810
+ ])
12811
+ })]);
12812
+ /**
12813
+ * `expression`: a formula over named bindings, in the salvaged expression
12814
+ * engine. Validated at parse by the SAME function every other consumer runs,
12815
+ * so the editor and the store cannot disagree.
12816
+ */
12817
+ var CompositionExpressionSourceSchema = object({
12818
+ kind: literal("expression"),
12819
+ expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
12820
+ bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), CompositionBindingSchema)
12821
+ }).superRefine((src, ctx) => {
12822
+ const err = validateExpressionSource(src);
12823
+ if (err !== null) ctx.addIssue({
12824
+ code: "custom",
12825
+ message: err,
12826
+ path: ["expr"]
12827
+ });
12828
+ });
12829
+ /** `code`: RESERVED for slice 4 (own runner, one-way eject). */
12830
+ var CompositionCodeSourceSchema = object({
12831
+ kind: literal("code"),
12832
+ code: string().min(1).max(MAX_COMPOSITION_CODE_LENGTH)
12833
+ });
12834
+ var CompositionFieldSourceSchema = discriminatedUnion("kind", [
12835
+ CompositionFromSourceSchema,
12836
+ CompositionExpressionSourceSchema,
12837
+ CompositionCodeSourceSchema
12838
+ ]);
12839
+ var CompositionCommandTargetSchema = discriminatedUnion("kind", [object({
12840
+ kind: literal("forward"),
12841
+ source: CompositionSourceRefSchema,
12842
+ cap: string().min(1),
12843
+ method: string().min(1)
12844
+ }), CompositionCodeSourceSchema]);
12845
+ var CompositionFeatureSchema = discriminatedUnion("kind", [object({
12846
+ kind: literal("fields"),
12847
+ cap: string().min(1),
12848
+ fields: record(string().min(1), CompositionFieldSourceSchema).refine((fields) => Object.keys(fields).length <= 32, { message: `at most 32 fields per capability` }),
12849
+ /** RESERVED for slice 3; refused by the validator when non-empty. */
12850
+ commands: record(string().min(1), CompositionCommandTargetSchema).optional()
12851
+ }), object({
12852
+ kind: literal("passthrough"),
12853
+ cap: string().min(1),
12854
+ source: CompositionSourceRefSchema
12855
+ })]);
12856
+ var CompositionSchema = object({
12857
+ target: discriminatedUnion("kind", [object({
12858
+ kind: literal("new"),
12859
+ type: _enum(DeviceType),
12860
+ role: _enum(DeviceRole).optional()
12861
+ }), object({
12862
+ kind: literal("existing"),
12863
+ device: CompositionSourceRefSchema
12864
+ })]),
12865
+ features: array(CompositionFeatureSchema).min(1).max(16)
12866
+ }).superRefine((composition, ctx) => {
12867
+ const seen = /* @__PURE__ */ new Set();
12868
+ composition.features.forEach((feature, index) => {
12869
+ if (seen.has(feature.cap)) ctx.addIssue({
12870
+ code: "custom",
12871
+ message: `capability \`${feature.cap}\` is composed twice — one feature per capability`,
12872
+ path: [
12873
+ "features",
12874
+ index,
12875
+ "cap"
12876
+ ]
12877
+ });
12878
+ seen.add(feature.cap);
12879
+ });
12880
+ });
12881
+ /** One refusal, named (D391). `path` points into the composition, e.g. `features[0].fields.celsius`. */
12882
+ var CompositionProblemSchema = object({
12883
+ code: _enum([
12884
+ "reserved-variant",
12885
+ "unknown-capability",
12886
+ "not-composable",
12887
+ "wrong-device-type",
12888
+ "has-commands",
12889
+ "unknown-field",
12890
+ "nested-field",
12891
+ "missing-field",
12892
+ "kind-mismatch",
12893
+ "may-be-null",
12894
+ "source-missing",
12895
+ "source-unreadable",
12896
+ "source-capability-missing",
12897
+ "source-field-unknown",
12898
+ "expression-invalid",
12899
+ "cycle",
12900
+ "duplicate-target"
12901
+ ]),
12902
+ path: string(),
12903
+ message: string()
12904
+ });
12905
+ var CompositionFieldKindSchema = _enum([
12906
+ "string",
12907
+ "number",
12908
+ "boolean",
12909
+ "enum"
12910
+ ]);
12911
+ /** How a field says "unavailable": `null` when its schema allows it, else the device goes offline (D393). */
12912
+ var CompositionUnavailableModeSchema = _enum(["null", "offline"]);
12913
+ /**
12914
+ * `derived` reads a source · `clock` reads only `now`, recomputed when a sibling
12915
+ * field of its cap changes value · `constant` reads nothing, computed once.
12916
+ */
12917
+ var CompositionFieldRoleSchema = _enum([
12918
+ "derived",
12919
+ "clock",
12920
+ "constant"
12921
+ ]);
12922
+ var CompositionFieldPlanSchema = object({
12923
+ cap: string(),
12924
+ path: string(),
12925
+ /** Index into `composition.features` this field's capability came from —
12926
+ * lets a source/cycle problem name its path as `features[N].fields.<path>`
12927
+ * (the same convention `planComposition`'s own problems already use). */
12928
+ featureIndex: number().int().nonnegative(),
12929
+ kind: CompositionFieldKindSchema,
12930
+ nullable: boolean(),
12931
+ required: boolean(),
12932
+ unavailable: CompositionUnavailableModeSchema,
12933
+ role: CompositionFieldRoleSchema,
12934
+ source: CompositionFieldSourceSchema,
12935
+ reads: array(CompositionFieldReadSchema)
12936
+ });
12937
+ var CompositionValidationSchema = object({
12938
+ ok: boolean(),
12939
+ problems: array(CompositionProblemSchema),
12940
+ fields: array(CompositionFieldPlanSchema)
12941
+ });
12942
+ /** Mirrors `CoreBlockStatus`, pinned by `core-blocks-source.spec.ts` (Task 11). */
12943
+ var CompositionRunStatusSchema = _enum([
12944
+ "stopped",
12945
+ "starting",
12946
+ "running",
12947
+ "failed"
12948
+ ]);
12949
+ var CompositionFieldStateKindSchema = _enum([
12950
+ "fresh",
12951
+ "stale",
12952
+ "unavailable"
12953
+ ]);
12954
+ var CompositionFieldStateSchema = object({
12955
+ cap: string(),
12956
+ path: string(),
12957
+ state: CompositionFieldStateKindSchema,
12958
+ /** `null` whenever `state === 'unavailable'`; never a plausible stand-in (D393). */
12959
+ value: union([
12960
+ string(),
12961
+ number(),
12962
+ boolean(),
12963
+ _null()
12964
+ ]),
12965
+ reason: string().optional()
12966
+ });
12967
+ var CompositionBlockStateSchema = object({
12968
+ blockId: string(),
12969
+ deviceId: number().nullable(),
12970
+ status: CompositionRunStatusSchema,
12971
+ reason: string().optional(),
12972
+ fields: array(CompositionFieldStateSchema)
12973
+ });
12616
12974
  /** Where a block runs. The operator chooses — a block driving a device on an
12617
12975
  * agent is the reason placement is not fixed to the hub. */
12618
12976
  var CoreBlockPlacementSchema = union([literal("hub"), string().min(1)]);
@@ -12639,6 +12997,30 @@ var CoreBlockInputSchema = object({
12639
12997
  */
12640
12998
  integrationId: string().optional()
12641
12999
  });
13000
+ /**
13001
+ * What a block IS (D659). Absent means `code` — every row stored before this
13002
+ * union keeps working unchanged.
13003
+ * - `code`: the TypeScript in `code`, compiled and run in its own runner;
13004
+ * - `recipe`: RESERVED (automations), stored shape only; refused at run by name;
13005
+ * - `composition`: declarative, run by the shared `composer`; `code` is `''`.
13006
+ */
13007
+ var CoreBlockSourceSchema = discriminatedUnion("kind", [
13008
+ object({ kind: literal("code") }),
13009
+ object({
13010
+ kind: literal("recipe"),
13011
+ recipe: AutomationRecipeSchema
13012
+ }),
13013
+ object({
13014
+ kind: literal("composition"),
13015
+ composition: CompositionSchema
13016
+ })
13017
+ ]);
13018
+ /** The client-authored half of a composition block. No `code`, no placement (hub-only; Phase 7). */
13019
+ var CompositionBlockInputSchema = object({
13020
+ name: string().min(1).max(120),
13021
+ enabled: boolean(),
13022
+ composition: CompositionSchema
13023
+ });
12642
13024
  /** A stored block. */
12643
13025
  var CoreBlockSchema = CoreBlockInputSchema.extend({
12644
13026
  id: string(),
@@ -12654,8 +13036,38 @@ var CoreBlockSchema = CoreBlockInputSchema.extend({
12654
13036
  */
12655
13037
  lastError: string().optional(),
12656
13038
  /** Ms epoch of the last state change. */
12657
- lastChangedAt: number()
13039
+ lastChangedAt: number(),
13040
+ /** What the block is. Absent means `code` (D659). */
13041
+ source: CoreBlockSourceSchema.optional()
13042
+ });
13043
+ /** A stored composition block and what the composer says about it. */
13044
+ var CompositionViewSchema = object({
13045
+ block: CoreBlockSchema,
13046
+ state: discriminatedUnion("kind", [object({
13047
+ kind: literal("answered"),
13048
+ state: CompositionBlockStateSchema.nullable()
13049
+ }), object({
13050
+ kind: literal("unreachable"),
13051
+ error: string()
13052
+ })])
13053
+ });
13054
+ /**
13055
+ * A read of the stored compositions. `not-loaded` while the `core_blocks`
13056
+ * table has not been READ: an empty answer then would make "not yet known"
13057
+ * look like "none", and invite the operator to recreate what exists (D315).
13058
+ */
13059
+ var CompositionsNotLoadedSchema = object({
13060
+ state: literal("not-loaded"),
13061
+ reason: string()
12658
13062
  });
13063
+ var CompositionListReadSchema = discriminatedUnion("state", [object({
13064
+ state: literal("loaded"),
13065
+ views: array(CompositionViewSchema)
13066
+ }), CompositionsNotLoadedSchema]);
13067
+ var CompositionGetReadSchema = discriminatedUnion("state", [object({
13068
+ state: literal("loaded"),
13069
+ view: CompositionViewSchema.nullable()
13070
+ }), CompositionsNotLoadedSchema]);
12659
13071
  /** What a compile attempt produced. */
12660
13072
  var CoreBlockCompileResultSchema = object({
12661
13073
  ok: boolean(),
@@ -12693,7 +13105,72 @@ method(object({}), object({ blocks: array(CoreBlockSchema) }), { auth: "admin" }
12693
13105
  }), method(object({}), object({ libs: array(object({
12694
13106
  filePath: string(),
12695
13107
  content: string()
12696
- })) }), { auth: "admin" });
13108
+ })) }), { auth: "admin" }), method(object({ block: CompositionBlockInputSchema }), object({ block: CoreBlockSchema }), {
13109
+ kind: "mutation",
13110
+ auth: "admin",
13111
+ caller: "required"
13112
+ }), method(object({
13113
+ blockId: string(),
13114
+ expectedUpdatedAt: number(),
13115
+ block: CompositionBlockInputSchema.partial()
13116
+ }), object({ block: CoreBlockSchema }), {
13117
+ kind: "mutation",
13118
+ auth: "admin",
13119
+ caller: "required"
13120
+ }), method(object({ blockId: string() }), CompositionGetReadSchema, { auth: "admin" }), method(object({}), CompositionListReadSchema, { auth: "admin" }), method(object({
13121
+ composition: CompositionSchema,
13122
+ blockId: string().optional()
13123
+ }), CompositionValidationSchema, {
13124
+ kind: "mutation",
13125
+ auth: "admin",
13126
+ access: "view"
13127
+ });
13128
+ var ComposerBlockSchema = object({
13129
+ id: string().min(1),
13130
+ name: string().min(1).max(120),
13131
+ enabled: boolean(),
13132
+ updatedAt: number(),
13133
+ composition: CompositionSchema
13134
+ });
13135
+ /**
13136
+ * A stored composition row that no longer PARSES — a schema a release
13137
+ * tightened, a row written by a newer build. Sent by id so the composer keeps
13138
+ * its device as a placeholder and reports the block `failed` naming the parse
13139
+ * error. Leaving it out would read, twice, exactly like a delete (D49).
13140
+ */
13141
+ var ComposerUnreadableBlockSchema = object({
13142
+ id: string().min(1),
13143
+ /** The row's stored name column; null when even that is unreadable (the device keeps the name it has). */
13144
+ name: string().nullable(),
13145
+ /** The parse error, in the operator's words. */
13146
+ error: string()
13147
+ });
13148
+ method(object({
13149
+ /** The shared Blocks integration; null until `core-blocks` has reconciled it. */
13150
+ integrationId: string().nullable(),
13151
+ /** False when the `core_blocks` read failed: then nothing may be withdrawn (D49). */
13152
+ storeLoaded: boolean(),
13153
+ blocks: array(ComposerBlockSchema),
13154
+ /** Operator restarts: rebuild these runtimes and re-resolve their sources. Stores nothing (D62). */
13155
+ restartBlockIds: array(string()),
13156
+ /** Composition rows that exist but do not parse: held, never withdrawn, reported failed. */
13157
+ unreadableBlocks: array(ComposerUnreadableBlockSchema)
13158
+ }), object({
13159
+ blocks: array(object({
13160
+ blockId: string(),
13161
+ status: CompositionRunStatusSchema,
13162
+ reason: string().optional()
13163
+ })),
13164
+ /**
13165
+ * False when the composer declared and withdrew NOTHING (store not loaded,
13166
+ * integration unknown, its own rows unread or read empty once). An empty
13167
+ * apply the caller owes is paid off only by one the composer acted on (D49).
13168
+ */
13169
+ acted: boolean()
13170
+ }), {
13171
+ kind: "mutation",
13172
+ auth: "admin"
13173
+ }), method(object({ blockIds: array(string()) }), object({ states: array(CompositionBlockStateSchema) }), { auth: "admin" });
12697
13174
  /**
12698
13175
  * `custom-model-registry` — collection cap exposing operator-registered
12699
13176
  * custom detection models. Each provider (today: `addon-model-studio`)
@@ -13988,6 +14465,27 @@ var LinkedDeviceSchema = object({
13988
14465
  features: array(string()),
13989
14466
  producesTrackedEvents: boolean().optional()
13990
14467
  });
14468
+ /**
14469
+ * The `linked-devices` extension slot's editable value (D648): the operator's
14470
+ * pick list, exactly what `_linkedDeviceIds` persists. Tree children are NOT
14471
+ * in it — they are always linked and are not a pick.
14472
+ *
14473
+ * `trackedDeviceIds` (D655) is the tracked-event opt-in, exactly what
14474
+ * `_linkedDeviceTrackedIds` persists: which linked devices materialize a
14475
+ * synthetic tracked event on the camera. A read always carries it AS STORED
14476
+ * (an absent key reads as `[]`, which is what the resolver makes of it —
14477
+ * NONE). On a write it is optional: absent leaves the opt-in untouched, so a
14478
+ * card built before D655 cannot erase it by saving the pick list. A present
14479
+ * list REPLACES the opt-in; each id must be a pick, a device the camera links
14480
+ * by structure (the row's `impliedSources`: tree children, a picked
14481
+ * container's child) or already stored — so what was read can always be
14482
+ * written back unchanged, and a NEW opt-in outside the linked set is refused.
14483
+ */
14484
+ var LinkedDevicesSlotValueSchema = object({
14485
+ deviceIds: array(number().int().positive()),
14486
+ trackedDeviceIds: array(number().int().positive()).optional()
14487
+ });
14488
+ DeviceType.Camera;
13991
14489
  /** One camera's resolved linked set, tagged with the camera it belongs to.
13992
14490
  * The batch answer needs the tag; the single-device answer already has it
13993
14491
  * from the input, which is why `getLinkedDevices` keeps the untagged shape. */
@@ -14351,7 +14849,7 @@ method(object({
14351
14849
  }), method(object({ deviceId: number() }), array(StreamProbeResultSchema), {
14352
14850
  kind: "mutation",
14353
14851
  auth: "admin"
14354
- }), method(object({ deviceId: number() }), DeviceBindingsForDeviceSchema), method(object({ deviceIds: array(number()) }), array(DeviceBindingsForDeviceSchema)), method(object({}), array(DeviceBindingsForDeviceSchema)), method(object({
14852
+ }), 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({
14355
14853
  deviceId: number(),
14356
14854
  capName: string(),
14357
14855
  wrapperAddonId: string(),
@@ -14513,16 +15011,101 @@ var EmbeddingResultSchema = object({
14513
15011
  embedding: array(number()),
14514
15012
  inferenceMs: number()
14515
15013
  });
15014
+ /** The two CLIP towers the encoder runs; a crash budget is kept per tower. */
15015
+ var EmbeddingTowerSchema = _enum(["image", "text"]);
15016
+ /**
15017
+ * A tower in the terminal `failed` state (D649, D6): it crashed or failed to
15018
+ * load `crashes` times within `windowMs`, and is refused by name until an
15019
+ * operator `resetFailedModels` or a model change — never on a timer.
15020
+ *
15021
+ * `nodeId` is the node whose tower failed. The state lives in THAT node's
15022
+ * encoder process (in memory — a runner respawn clears it), and one node's
15023
+ * answer says nothing about another's.
15024
+ */
15025
+ var EmbeddingFailedModelSchema = object({
15026
+ modelId: string(),
15027
+ tower: EmbeddingTowerSchema,
15028
+ nodeId: string(),
15029
+ crashes: number(),
15030
+ windowMs: number(),
15031
+ sinceMs: number(),
15032
+ lastReason: string()
15033
+ });
15034
+ /**
15035
+ * A model whose REQUIREMENTS can never be met on this node (D649 round 5):
15036
+ * an id the catalog does not know, a model URL answering 404/410, a declared
15037
+ * sibling (the tokenizer) that is not there. After `attempts` failed builds
15038
+ * it is terminally `requirements-failed`, refused by name until an operator
15039
+ * `resetFailedModels` or a model change — the same exits as a crashed tower.
15040
+ */
15041
+ var EmbeddingFailedRequirementSchema = object({
15042
+ modelId: string(),
15043
+ tower: EmbeddingTowerSchema,
15044
+ nodeId: string(),
15045
+ attempts: number(),
15046
+ sinceMs: number(),
15047
+ lastReason: string()
15048
+ });
14516
15049
  var EmbeddingInfoSchema = object({
14517
15050
  modelId: string(),
14518
15051
  embeddingDim: number(),
14519
- ready: boolean()
14520
- });
15052
+ ready: boolean(),
15053
+ /**
15054
+ * The node that answered. Absent only from an encoder older than D649's
15055
+ * crash budget — whose `failedModels` is then UNKNOWN (D315), never "none".
15056
+ */
15057
+ nodeId: string().optional(),
15058
+ /**
15059
+ * Towers in `failed` on the answering node, each row naming it. `undefined`
15060
+ * means the node could not say (pre-budget encoder); a node that has the
15061
+ * budget always answers an array, empty included.
15062
+ */
15063
+ failedModels: array(EmbeddingFailedModelSchema).optional(),
15064
+ /** Models terminally `requirements-failed` on the answering node; same reading as above. */
15065
+ failedRequirements: array(EmbeddingFailedRequirementSchema).optional()
15066
+ });
15067
+ /**
15068
+ * The THREE codes an encoder refusal can carry (D649, D6). Same shape as
15069
+ * `VECTOR_INDEX_DIM_CONFLICT`: the code rides in the MESSAGE, because an
15070
+ * Error's own properties do not survive the UDS/tRPC hop and its message does,
15071
+ * and both sides go through the helpers below — the encoder builds the
15072
+ * refusal, the live detail plane classifies on it to count refusals per
15073
+ * camera instead of logging one warning per track. The bracketed token
15074
+ * carries the code, the model, the tower and the node so a consumer never
15075
+ * parses prose.
15076
+ *
15077
+ * - `EMBEDDING_MODEL_FAILED`: the tower crashed / failed to load past the crash
15078
+ * budget — terminal until `resetFailedModels` or a model change.
15079
+ * - `EMBEDDING_REQUIREMENTS_UNAVAILABLE`: files or runtime not there right now
15080
+ * (a download or Python that failed, or the cooldown after one) — the next
15081
+ * request past the cooldown tries again.
15082
+ * - `EMBEDDING_REQUIREMENTS_FAILED`: the requirements can never be met (unknown
15083
+ * id, 404/410, missing sibling) and the bounded attempts are spent —
15084
+ * terminal, same exits as a crashed tower.
15085
+ */
15086
+ var EMBEDDING_MODEL_FAILED = "embedding-model-failed";
15087
+ var EMBEDDING_REQUIREMENTS_UNAVAILABLE = "embedding-requirements-unavailable";
15088
+ var EMBEDDING_REQUIREMENTS_FAILED = "embedding-requirements-failed";
15089
+ _enum([
15090
+ EMBEDDING_MODEL_FAILED,
15091
+ EMBEDDING_REQUIREMENTS_UNAVAILABLE,
15092
+ EMBEDDING_REQUIREMENTS_FAILED
15093
+ ]);
15094
+ new RegExp(`\\[(${EMBEDDING_MODEL_FAILED}|${EMBEDDING_REQUIREMENTS_UNAVAILABLE}|${EMBEDDING_REQUIREMENTS_FAILED}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);
14521
15095
  method(object({
14522
15096
  crop: _instanceof(Uint8Array),
14523
15097
  width: number(),
14524
15098
  height: number()
14525
- }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
15099
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({
15100
+ text: string(),
15101
+ modelId: string().min(1).optional()
15102
+ }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" }), method(object({ modelId: string().min(1).optional() }), object({
15103
+ cleared: array(string()),
15104
+ nodeId: string()
15105
+ }), {
15106
+ kind: "mutation",
15107
+ auth: "admin"
15108
+ });
14526
15109
  /**
14527
15110
  * `failure-contribution` — the capability an addon reports its OWN losses
14528
15111
  * through, per camera, with the denominator attached. It stores nothing.
@@ -14706,18 +15289,30 @@ var LlmErrorCodeSchema = _enum([
14706
15289
  "budget-exceeded",
14707
15290
  "adapter-error"
14708
15291
  ]);
14709
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
15292
+ var LlmGenerateOkSchema = object({
14710
15293
  ok: literal(true),
14711
15294
  text: string(),
14712
15295
  model: string(),
14713
15296
  usage: LlmUsageSchema,
14714
15297
  truncated: boolean(),
14715
15298
  latencyMs: number()
14716
- }), object({
15299
+ });
15300
+ /**
15301
+ * WHO refused, on a `refusal`. `guardrail` = a safety filter in front of the
15302
+ * model rejected the request before it answered (Apple Foundation Models
15303
+ * refuses surveillance-framed prompts in 0.1 s); `model` = the model itself
15304
+ * declined. They are different faults: a guardrail refusal is a property of
15305
+ * the BACKEND, so the provider falls back to the next profile; a model refusal
15306
+ * is an answer. Absent on every other code, and on a refusal a wire cannot
15307
+ * attribute.
15308
+ */
15309
+ var LlmRefusalSourceSchema = _enum(["guardrail", "model"]);
15310
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [LlmGenerateOkSchema, object({
14717
15311
  ok: literal(false),
14718
15312
  code: LlmErrorCodeSchema,
14719
15313
  message: string(),
14720
- retryAfterMs: number().optional()
15314
+ retryAfterMs: number().optional(),
15315
+ refusalSource: LlmRefusalSourceSchema.optional()
14721
15316
  })]);
14722
15317
  /**
14723
15318
  * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
@@ -14947,12 +15542,78 @@ var LlmRuntimeDiskUsageSchema = object({
14947
15542
  modelsBytes: number(),
14948
15543
  freeBytes: number().optional()
14949
15544
  });
14950
- method(LlmGenerateBaseInputSchema.extend({
15545
+ var LlmRuntimeCompleteInputSchema = LlmGenerateBaseInputSchema.extend({
14951
15546
  images: array(LlmImageSchema).optional(),
14952
15547
  runtime: ManagedRuntimeConfigSchema,
14953
15548
  /** The managed profile's timeout, threaded by the hub provider. */
14954
15549
  timeoutMs: number().int().positive().optional()
14955
- }), LlmGenerateResultSchema, {
15550
+ });
15551
+ /**
15552
+ * Why Apple Foundation Models cannot run on a node that has it in principle.
15553
+ * The first three are Apple's own `UnavailableReason`s, verbatim; the rest are
15554
+ * ours: the OS predates the framework (macOS < 26), the helper binary is not
15555
+ * in the installed addon, or it crashed past the respawn bound.
15556
+ */
15557
+ var AppleFmUnavailableReasonSchema = _enum([
15558
+ "deviceNotEligible",
15559
+ "appleIntelligenceNotEnabled",
15560
+ "modelNotReady",
15561
+ "osTooOld",
15562
+ "helperMissing",
15563
+ "helperCrashed"
15564
+ ]);
15565
+ /**
15566
+ * Apple Foundation Models on ONE node — four states, never a boolean (D315).
15567
+ *
15568
+ * - `available` — the helper probed it; what it CAN do is reported
15569
+ * here (`imageInput`, `contextSize`, languages),
15570
+ * never typed by an operator.
15571
+ * - `unavailable` — a known absence, with the reason to act on.
15572
+ * - `unsupported-platform` — not a Mac; there is nothing to enable.
15573
+ * - `unknown` — the probe did not answer (not yet run, timed
15574
+ * out, helper crashed mid-probe). A failed
15575
+ * measurement is NEVER `unavailable` (D393).
15576
+ */
15577
+ var AppleFmAvailabilitySchema = discriminatedUnion("state", [
15578
+ object({
15579
+ state: literal("available"),
15580
+ osVersion: string(),
15581
+ /** Tokens, as the framework reports it. Read at runtime, never assumed. */
15582
+ contextSize: number().int().positive(),
15583
+ /** BCP-47-ish tags (`it-IT`) of the languages the model supports. */
15584
+ languages: array(string()),
15585
+ /** Whether prompts may carry images. `false` on a macOS 26 build. */
15586
+ imageInput: boolean()
15587
+ }),
15588
+ object({
15589
+ state: literal("unavailable"),
15590
+ reason: AppleFmUnavailableReasonSchema,
15591
+ osVersion: string().nullable(),
15592
+ detail: string()
15593
+ }),
15594
+ object({
15595
+ state: literal("unsupported-platform"),
15596
+ platform: string()
15597
+ }),
15598
+ object({
15599
+ state: literal("unknown"),
15600
+ error: string()
15601
+ })
15602
+ ]);
15603
+ /**
15604
+ * A generation on the node's Apple Foundation Models helper. A separate verb
15605
+ * from `complete`, whose `runtime` is a llama.cpp config: overloading it would
15606
+ * drag a GGUF model reference into a backend that has none. `images` is part
15607
+ * of the contract so vision needs no cap change later; a node whose model has
15608
+ * no image input REFUSES them (`unavailable`), never drops them.
15609
+ */
15610
+ var LlmRuntimeAppleCompleteInputSchema = LlmGenerateBaseInputSchema.extend({
15611
+ images: array(LlmImageSchema).optional(),
15612
+ /** The profile's timeout, threaded by the hub provider. */
15613
+ timeoutMs: number().int().positive().optional()
15614
+ });
15615
+ var LlmRuntimeCancelInputSchema = object({ requestId: string() });
15616
+ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
14956
15617
  kind: "mutation",
14957
15618
  auth: "admin",
14958
15619
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
@@ -14970,7 +15631,14 @@ method(LlmGenerateBaseInputSchema.extend({
14970
15631
  }), method(object({ file: string() }), _void(), {
14971
15632
  kind: "mutation",
14972
15633
  auth: "admin"
14973
- }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" });
15634
+ }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" }), method(LlmRuntimeCancelInputSchema, _void(), {
15635
+ kind: "mutation",
15636
+ auth: "admin"
15637
+ }), method(object({}), AppleFmAvailabilitySchema, { auth: "admin" }), method(LlmRuntimeAppleCompleteInputSchema, LlmGenerateResultSchema, {
15638
+ kind: "mutation",
15639
+ auth: "admin",
15640
+ timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
15641
+ });
14974
15642
  /**
14975
15643
  * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
14976
15644
  * methods concat-fan across providers; single-row methods route to ONE
@@ -14987,7 +15655,8 @@ var LlmProfileKindSchema = _enum([
14987
15655
  "openai",
14988
15656
  "anthropic",
14989
15657
  "google",
14990
- "managed-local"
15658
+ "managed-local",
15659
+ "apple-foundation"
14991
15660
  ]);
14992
15661
  var LlmProfileSchema = object({
14993
15662
  id: string(),
@@ -15045,7 +15714,14 @@ var LlmProfileSchema = object({
15045
15714
  toolsEnabled: boolean().default(false),
15046
15715
  extraHeaders: record(string(), string()).optional(),
15047
15716
  /** kind === 'managed-local' only (spec §4). */
15048
- runtime: ManagedRuntimeConfigSchema.optional()
15717
+ runtime: ManagedRuntimeConfigSchema.optional(),
15718
+ /**
15719
+ * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
15720
+ * to configure (no key, no URL, no download; `model` is `apple-system`).
15721
+ * `supportsVision` on such a row is stamped by the provider from the node's
15722
+ * reported `imageInput`, never taken from the operator (D62).
15723
+ */
15724
+ appleFoundation: object({ nodeId: string() }).optional()
15049
15725
  });
15050
15726
  /** ConfigUISchema tree passed through untyped on the wire (the
15051
15727
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -15127,7 +15803,9 @@ var LlmRuntimeNodeSchema = object({
15127
15803
  reachable: boolean(),
15128
15804
  status: LlmRuntimeStatusSchema.optional(),
15129
15805
  disk: LlmRuntimeDiskUsageSchema.optional(),
15130
- error: string().optional()
15806
+ error: string().optional(),
15807
+ /** Absent = the node did not answer the question (render as unknown). */
15808
+ apple: AppleFmAvailabilitySchema.optional()
15131
15809
  });
15132
15810
  var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
15133
15811
  var ProfileRefInputSchema = object({
@@ -17086,6 +17764,9 @@ var NcSystemEventKindSchema = _enum([
17086
17764
  "device-battery-normal",
17087
17765
  "device-consumable-low",
17088
17766
  "device-consumable-normal",
17767
+ "device-tank-low",
17768
+ "device-tank-full",
17769
+ "device-tank-normal",
17089
17770
  "stream-online",
17090
17771
  "stream-offline",
17091
17772
  "node-online",
@@ -17123,6 +17804,29 @@ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
17123
17804
  ]);
17124
17805
  NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
17125
17806
  /**
17807
+ * The panel's transitions, as ONE list.
17808
+ *
17809
+ * Named here rather than spelled out at each of the four sites that need them
17810
+ * (the emitter, the intake, the editor group, the combined-notification gate),
17811
+ * because a transition added to the enum and forgotten at one of them is an
17812
+ * alarm state nobody can be notified about. That is exactly what this list
17813
+ * failed to prevent while it held three: `alarm-arming` was the fourth.
17814
+ *
17815
+ * In LIFECYCLE order, which is the order an editor lists them in and the order
17816
+ * a person experiences them — not the order they were added.
17817
+ */
17818
+ var NC_ALARM_SYSTEM_EVENT_KINDS = [
17819
+ "alarm-arm-refused",
17820
+ "alarm-check-failed",
17821
+ "alarm-arming",
17822
+ "alarm-armed",
17823
+ "alarm-pending",
17824
+ "alarm-triggered",
17825
+ "alarm-rearmed",
17826
+ "alarm-sensor-bypass",
17827
+ "alarm-disarmed"
17828
+ ];
17829
+ /**
17126
17830
  * One coherent system-event condition. `kinds` is the required opt-in safety
17127
17831
  * gate; the remaining lists are optional narrowing filters relevant to the
17128
17832
  * selected kinds.
@@ -17142,8 +17846,36 @@ var NcSystemEventConditionSchema = object({
17142
17846
  * does not carry) matches no `deviceTypes` list.
17143
17847
  */
17144
17848
  deviceTypes: array(string().min(1)).min(1).optional(),
17849
+ /**
17850
+ * Devices this rule NEVER speaks about, whatever else matched. Scoped to the
17851
+ * same kind family as `deviceIds` (`systemEventFilterApplies(kind,
17852
+ * 'deviceIds')`) and applied AFTER it: include first, then exclude. A
17853
+ * consumable subject (`consumable:<id>:<key>`) is excluded by its device id.
17854
+ *
17855
+ * It never fails closed: a subject that carries no device id is not in the
17856
+ * list, so it is not excluded. "Every battery except the one thermometer that
17857
+ * reads 0 % forever" is the question this answers — expressed as an include
17858
+ * list it would have to name every other battery device, and every device
17859
+ * adopted later would be silently left out (D636).
17860
+ */
17861
+ excludeDeviceIds: array(number().int()).min(1).optional(),
17145
17862
  nodeIds: array(string().min(1)).min(1).optional(),
17146
- packageNames: array(string().min(1)).min(1).optional()
17863
+ packageNames: array(string().min(1)).min(1).optional(),
17864
+ /**
17865
+ * At or below this remaining-life %, a consumable is LOW for THIS rule
17866
+ * (D642). Absent = {@link NC_CONSUMABLE_LOW_PERCENT_DEFAULT}; at most
17867
+ * {@link NC_CONSUMABLE_LOW_PERCENT_MAX}, so every episode can recover. Scoped to the
17868
+ * consumable kinds (`systemEventFilterApplies`) and to the device-events
17869
+ * family; ignored on every other kind.
17870
+ *
17871
+ * It is a property of the RULE because the operator decided so: a rule at
17872
+ * 25 must be told about a filter at 20 %, a rule at 10 must not. The hub
17873
+ * keeps one episode per (threshold, device, item) — its own hysteresis, its
17874
+ * own reminder — and a rule hears only the episode judged at ITS threshold,
17875
+ * exactly as an occupancy rule hears only the edge of its own count. A
17876
+ * provider's own `replace` verdict is low at every threshold.
17877
+ */
17878
+ consumableLowPercent: number().int().min(1).max(95).optional()
17147
17879
  });
17148
17880
  /** Hard ceiling on a window (24h). A snooze that could not expire would be an
17149
17881
  * outage the operator asked for once and forgot. */
@@ -17161,6 +17893,25 @@ var NcScheduleSchema = object({
17161
17893
  /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
17162
17894
  invert: boolean().optional()
17163
17895
  });
17896
+ /**
17897
+ * How a system-event rule of the `device-events` or `system` family speaks
17898
+ * (D647): at once, per event (`instant`, the only behaviour before D647), or
17899
+ * as a STATE SUMMARY at the end of each window of `schedule`.
17900
+ */
17901
+ var NcSystemEventDeliveryModeSchema = _enum(["instant", "summary"]);
17902
+ /**
17903
+ * `summary`: the rule sends NOTHING per event. When a window of `schedule`
17904
+ * CLOSES, it sends one notification with the current state of its kinds
17905
+ * (low batteries, consumables to replace, devices offline, updates
17906
+ * available, ...), after its own filters. Nothing to report sends nothing.
17907
+ * The schedule is the ordinary `NcSchedule` (weekly windows, IANA timezone,
17908
+ * midnight crossing); the send time is each window's END. Refused on the
17909
+ * `alarm` family, which stays instant (`systemEventDeliveryProblems`).
17910
+ */
17911
+ var NcSystemEventDeliverySchema = discriminatedUnion("mode", [object({ mode: literal("instant") }), object({
17912
+ mode: literal("summary"),
17913
+ schedule: NcScheduleSchema
17914
+ })]);
17164
17915
  /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
17165
17916
  var NcPlateMatcherSchema = object({
17166
17917
  /**
@@ -17286,6 +18037,16 @@ var NcCrossingSchema = _enum([
17286
18037
  "exit",
17287
18038
  "any"
17288
18039
  ]);
18040
+ /**
18041
+ * Which edge of a BOOLEAN sensor fires a device-event rule (D640).
18042
+ * - `raised` — the sensor went high: water detected, smoke, open, tampered.
18043
+ * - `cleared` — it went back: dry, clear, closed.
18044
+ * - absent — both edges, which is what every rule authored before this did.
18045
+ *
18046
+ * There is no third member for "both": absence already says it, and a value
18047
+ * that means the same as absence is a second way to write one rule.
18048
+ */
18049
+ var NcSensorTransitionSchema = _enum(["raised", "cleared"]);
17289
18050
  /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
17290
18051
  var NcZoneConditionSchema = object({
17291
18052
  ids: array(string().min(1)).min(1),
@@ -17475,6 +18236,20 @@ var NcConditionsSchema = object({
17475
18236
  scene: NcSceneConditionSchema.optional(),
17476
18237
  /** Device scope — absent = all devices. */
17477
18238
  devices: array(number()).optional(),
18239
+ /**
18240
+ * Device EXCLUSION (D641) — "every device except these". Judged on the SAME
18241
+ * subject ids {@link devices} is judged on (the camera, the sensor that
18242
+ * fired, a linked set's sensor and row cameras), so a sensor fanned out per
18243
+ * linked camera is excluded exactly where an include would have tested it.
18244
+ * `min(1)`: an empty exclusion excludes nothing and is written as absent.
18245
+ *
18246
+ * Not for `system-event` rules — those carry their own
18247
+ * `systemEvent.excludeDeviceIds` (D636), and the hub refuses this key there.
18248
+ * Editors present the two lists as ONE field (All | Only these | All except
18249
+ * these); the engine evaluates each independently, so a legacy rule
18250
+ * carrying both still means "these, minus those".
18251
+ */
18252
+ devicesExclude: array(number()).min(1).optional(),
17478
18253
  /** Detector class names (any overlap with the record's class set). */
17479
18254
  classes: array(string().min(1)).optional(),
17480
18255
  /** Veto classes — any overlap fails the rule. */
@@ -17608,6 +18383,16 @@ var NcConditionsSchema = object({
17608
18383
  */
17609
18384
  sensorKinds: array(string().min(1)).optional(),
17610
18385
  /**
18386
+ * DEVICE-EVENT only (D640). Fire on one edge of a boolean sensor —
18387
+ * {@link NcSensorTransitionSchema}. Which field of the slice means "raised"
18388
+ * is `@camstack/types` → `notification/sensor-raised.ts`. A reading the
18389
+ * engine cannot place (a kind with no raise, an unreadable slice) PASSES:
18390
+ * the condition fails open towards notifying, never towards silence. Editors
18391
+ * offer it only when every chosen {@link sensorKinds} member has a raise
18392
+ * (`sensorTransitionOffered`), and the hub refuses it on any other delivery.
18393
+ */
18394
+ sensorTransition: NcSensorTransitionSchema.optional(),
18395
+ /**
17611
18396
  * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
17612
18397
  * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
17613
18398
  * when the subject's phase does not match (a subject always carries a phase
@@ -17740,7 +18525,12 @@ var NcMediaPolicySchema = object({
17740
18525
  * the degrade engine, which drops the video and keeps the still.
17741
18526
  */
17742
18527
  clip: boolean().optional(),
17743
- /** Seconds of footage BEFORE / AFTER the event instant. Defaults 3 / 7. */
18528
+ /**
18529
+ * Seconds of footage BEFORE / AFTER the event instant. Absent =
18530
+ * {@link NC_CLIP_PRE_ROLL_DEFAULT_SEC} / {@link NC_CLIP_POST_ROLL_DEFAULT_SEC}
18531
+ * (4 / 6), resolved by the Notification Center at dispatch — deliberately not
18532
+ * a Zod default, so a rule that never chose keeps following the hub's.
18533
+ */
17744
18534
  clipPreRollSec: number().int().min(0).max(30).optional(),
17745
18535
  clipPostRollSec: number().int().min(0).max(30).optional(),
17746
18536
  /**
@@ -17862,6 +18652,16 @@ var NcRuleInputSchema = object({
17862
18652
  delivery: NcDeliverySchema,
17863
18653
  conditions: NcConditionsSchema.default({}),
17864
18654
  schedule: NcScheduleSchema.optional(),
18655
+ /**
18656
+ * A `device-events` / `system` rule's delivery (D647): absent or `instant`
18657
+ * is a notification per event; `summary` is one state summary per closed
18658
+ * window of its schedule. `.optional()` and never defaulted: absent must
18659
+ * keep meaning what every rule authored before D647 meant, with no
18660
+ * migration. Top-level rather than inside `conditions.systemEvent`, so a
18661
+ * client that does not know it (an older viewer re-sending `conditions`
18662
+ * whole) leaves it standing through the store's patch merge.
18663
+ */
18664
+ systemEventDelivery: NcSystemEventDeliverySchema.optional(),
17865
18665
  /** May be empty when `targetUsers` addresses at least one user — the
17866
18666
  * "at least one addressee" invariant is enforced by the provider, because
17867
18667
  * a cross-field refine here would break `NcRulePatchSchema.partial()`. */
@@ -18090,6 +18890,28 @@ var NcRuleSchema = NcRuleInputSchema.extend({
18090
18890
  */
18091
18891
  disabledTargetIds: array(string()).default([])
18092
18892
  });
18893
+ /** One section of a previewed state summary. `unavailable` = its state could not be read. */
18894
+ var NcStateSummaryPreviewSectionSchema = object({
18895
+ id: string(),
18896
+ status: _enum(["read", "unavailable"]),
18897
+ items: number().int().nonnegative(),
18898
+ reason: string().optional()
18899
+ });
18900
+ /**
18901
+ * The summary a rule would send now. `empty` = nothing to report and every
18902
+ * section read: such a summary is NOT sent. `dropped` counts the open states
18903
+ * the rule's own filters (or a camera mute) left out, by reason.
18904
+ * `excludedGroups` names the kind groups selected that have no state to report
18905
+ * (backups & exports).
18906
+ */
18907
+ var NcStateSummaryPreviewSchema = object({
18908
+ empty: boolean(),
18909
+ count: number().int().nonnegative(),
18910
+ text: string(),
18911
+ sections: array(NcStateSummaryPreviewSectionSchema),
18912
+ dropped: record(string(), number().int().nonnegative()),
18913
+ excludedGroups: array(string())
18914
+ });
18093
18915
  var NcTestResultSchema = object({
18094
18916
  recordId: string(),
18095
18917
  recordKind: _enum([
@@ -18107,9 +18929,29 @@ var NcTestResultSchema = object({
18107
18929
  className: string().optional(),
18108
18930
  label: string().optional()
18109
18931
  });
18110
- /** The five rule kinds, as data. `NcRuleKind` in `notification/rule-kinds.ts`
18111
- * is the same union; the template-vars spec pins the two together. */
18932
+ /** The rule kinds, as data. `NcRuleKind` in `notification/rule-kinds.ts` is
18933
+ * `z.infer` of this schema — one shape, no twin. `mixed` is DERIVED
18934
+ * (a stored system rule whose kinds span families, D637) and never authored. */
18112
18935
  var NcRuleKindSchema = _enum([
18936
+ "detection",
18937
+ "sensor",
18938
+ "occupancy",
18939
+ "sound",
18940
+ "device-events",
18941
+ "system",
18942
+ "alarm",
18943
+ "mixed"
18944
+ ]);
18945
+ /**
18946
+ * The kinds a SERVED template-variable descriptor may name: the five that
18947
+ * existed before D637, frozen. `getTemplateCatalog` ships `kinds` to every
18948
+ * installed viewer, and a viewer at `@camstack/types` 1.2.25x parses them with a
18949
+ * strict five-member enum — one `device-events` in one descriptor fails the
18950
+ * whole catalog parse. So the WIRE says `system`, and the MATCH widens it:
18951
+ * `templateVarKindApplies` reads a `system` descriptor as applying to every
18952
+ * system rule kind (`device-events`, `system`, `alarm`, `mixed`).
18953
+ */
18954
+ var NcTemplateVarKindSchema = _enum([
18113
18955
  "detection",
18114
18956
  "sensor",
18115
18957
  "occupancy",
@@ -18147,7 +18989,7 @@ var NcTemplateVarGroupSchema = _enum([
18147
18989
  *
18148
18990
  * `families` / `fields` / `kinds` / `deliveries` / `systemEventKinds` say WHERE
18149
18991
  * it has a value; absent = no restriction on that axis. `systemEventKinds` is
18150
- * read only for a `system` rule. `dynamic` declares a FAMILY of names
18992
+ * read only for a system-event rule (any family, or `mixed`). `dynamic` declares a FAMILY of names
18151
18993
  * (`count_<class>`): the descriptor's `name` is the example member.
18152
18994
  */
18153
18995
  var NcTemplateVarDescriptorSchema = object({
@@ -18158,9 +19000,16 @@ var NcTemplateVarDescriptorSchema = object({
18158
19000
  group: NcTemplateVarGroupSchema,
18159
19001
  families: array(NcTemplateFamilySchema).min(1),
18160
19002
  fields: array(NcTemplateFieldSchema).optional(),
18161
- kinds: array(NcRuleKindSchema).optional(),
19003
+ kinds: array(NcTemplateVarKindSchema).optional(),
18162
19004
  deliveries: array(NcDeliverySchema).optional(),
18163
19005
  systemEventKinds: array(NcSystemEventKindSchema).optional(),
19006
+ /**
19007
+ * Which system-event DELIVERY has a value for it (D647). Absent = an
19008
+ * instant row only when the descriptor names `systemEventKinds` (a
19009
+ * per-event fact: a summary row has no single device), and both otherwise.
19010
+ * `['summary']` marks the state-summary vocabulary (`{{summaryText}}`, ...).
19011
+ */
19012
+ systemEventDeliveries: array(NcSystemEventDeliveryModeSchema).optional(),
18164
19013
  dynamic: object({
18165
19014
  prefix: literal("count_"),
18166
19015
  from: literal("classes")
@@ -18173,7 +19022,9 @@ var NcTemplatePreviewInputSchema = object({
18173
19022
  field: NcTemplateFieldSchema,
18174
19023
  kind: NcRuleKindSchema.optional(),
18175
19024
  delivery: NcDeliverySchema.optional(),
18176
- systemEventKinds: array(NcSystemEventKindSchema).optional()
19025
+ systemEventKinds: array(NcSystemEventKindSchema).optional(),
19026
+ /** The rule's system-event delivery (D647); absent = instant. */
19027
+ systemEventDelivery: NcSystemEventDeliveryModeSchema.optional()
18177
19028
  }),
18178
19029
  template: object({
18179
19030
  title: string().max(500).optional(),
@@ -18206,6 +19057,7 @@ var NcConditionDescriptorSchema = object({
18206
19057
  /** Editor widget the UI renders — never hardcode per-condition forms. */
18207
19058
  valueType: _enum([
18208
19059
  "deviceIdList",
19060
+ "deviceIdExcludeList",
18209
19061
  "stringList",
18210
19062
  "number01",
18211
19063
  "number",
@@ -18216,6 +19068,7 @@ var NcConditionDescriptorSchema = object({
18216
19068
  "plateMatcher",
18217
19069
  "packagePhase",
18218
19070
  "crossingSelect",
19071
+ "sensorTransition",
18219
19072
  "polygonDraw",
18220
19073
  "occupancy",
18221
19074
  "audio",
@@ -18366,6 +19219,28 @@ var NcHistoryFilterSchema = object({
18366
19219
  limit: number().int().min(1).max(500).default(100)
18367
19220
  });
18368
19221
  /**
19222
+ * Every rule's last run, in one answer.
19223
+ *
19224
+ * A rule ABSENT from `runs` produced no delivery inside `horizonMs` — how far
19225
+ * back this answer looked, in ms before the hub's now. It is the outbox prune
19226
+ * window (7 days by default, operator-configurable), NARROWED when the read hit
19227
+ * its row bound: the answer never claims a window it did not read. `null` means
19228
+ * the operator keeps the outbox forever AND the read reached its end, so absent
19229
+ * means "never on record". A UI derives its "not in the last N days" from this
19230
+ * value, never from a constant — and only when the call ANSWERED (D315).
19231
+ */
19232
+ var NcRuleLastRunsSchema = object({
19233
+ runs: array(object({
19234
+ ruleId: string(),
19235
+ /** Fire time of the newest row (`createdAt`, epoch ms). */
19236
+ lastAt: number(),
19237
+ status: NcHistoryStatusSchema,
19238
+ /** The camera/device of that row (a digest row files under its first camera). */
19239
+ deviceId: number()
19240
+ })),
19241
+ horizonMs: number().nonnegative().nullable()
19242
+ });
19243
+ /**
18369
19244
  * What a snooze covers. Broader scopes win when several overlap, so one window
18370
19245
  * leaves ONE digest rather than a rule snooze and a whole-feed snooze both
18371
19246
  * summarising the same silence.
@@ -18546,6 +19421,14 @@ var NcAlarmModeCoverageSchema = object({
18546
19421
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
18547
19422
  deviceIds: array(number().int()),
18548
19423
  /**
19424
+ * D641: the ids NOT covered although `allDevices` is true — every unscoped
19425
+ * covering rule EXCLUDES them (`conditions.devicesExclude`) and no named rule
19426
+ * covers them. Always `[]` when `allDevices` is false. Excluded by the rules,
19427
+ * which is not the same as skipped by a switch: never in `skippedDevices`.
19428
+ * Defaulted so an answer computed before this field parses as "none".
19429
+ */
19430
+ allDevicesExcept: array(number().int()).default([]),
19431
+ /**
18549
19432
  * Devices this mode NAMES but cannot actually arm, each with the switch that
18550
19433
  * excludes it.
18551
19434
  *
@@ -18675,13 +19558,17 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
18675
19558
  }), object({ results: array(NcTestResultSchema) }), {
18676
19559
  kind: "mutation",
18677
19560
  auth: "admin"
19561
+ }), method(object({ rule: NcRuleInputSchema }), NcStateSummaryPreviewSchema, {
19562
+ kind: "mutation",
19563
+ auth: "admin",
19564
+ access: "view"
18678
19565
  }), method(object({}), object({
18679
19566
  catalog: array(NcConditionDescriptorSchema),
18680
19567
  taxonomy: NcTaxonomySchema.optional()
18681
19568
  })), method(object({}), object({ vars: array(NcTemplateVarDescriptorSchema) })), method(NcTemplatePreviewInputSchema, NcTemplatePreviewSchema, {
18682
19569
  kind: "mutation",
18683
19570
  access: "view"
18684
- }), 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 }), {
19571
+ }), 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 }), {
18685
19572
  kind: "mutation",
18686
19573
  caller: "required"
18687
19574
  }), method(object({ snoozeId: string() }), object({ success: literal(true) }), {
@@ -19021,605 +19908,129 @@ var OauthIntegrationDescriptorSchema = object({
19021
19908
  });
19022
19909
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
19023
19910
  /**
19024
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
19025
- * within the frame, so the executor can re-cut a leaf child ROI at native
19026
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
19027
- */
19028
- var NativeCropRefSchema = object({
19029
- /** Handle keying the retained native surface (node-pinned to its owner). */
19030
- handle: FrameHandleSchema,
19031
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
19032
- cropFrameSpace: object({
19033
- x: number(),
19034
- y: number(),
19035
- w: number(),
19036
- h: number()
19037
- })
19038
- });
19039
- object({
19040
- crop: object({
19041
- left: number(),
19042
- top: number(),
19043
- width: number().positive(),
19044
- height: number().positive()
19045
- }).optional(),
19046
- content: object({
19047
- width: number().int().positive(),
19048
- height: number().int().positive()
19049
- }),
19050
- fit: _enum(["stretch", "contain"]),
19051
- format: _enum([
19052
- "rgb",
19053
- "gray",
19054
- "jpeg"
19055
- ])
19056
- });
19057
- /**
19058
- * Process-local frame identity. It is serializable so it can ride an in-process
19059
- * capability call, but `registryId` deliberately prevents resolution in any
19060
- * other process or execution group.
19061
- */
19062
- var FrameRefSchema = object({
19063
- registryId: string().min(1),
19064
- id: string().min(1),
19065
- width: number().int().positive(),
19066
- height: number().int().positive(),
19067
- format: _enum(["rgb", "gray"]),
19068
- timestamp: number(),
19069
- capturedAt: number().optional()
19070
- });
19071
- var ModelFormatSchema$1 = _enum([
19072
- "onnx",
19073
- "coreml",
19074
- "openvino",
19075
- "tflite",
19076
- "pt",
19077
- "gguf"
19078
- ]);
19079
- var PipelineSlotSchema = _enum([
19080
- "detector",
19081
- "cropper",
19082
- "classifier",
19083
- "refiner",
19084
- "audio-classifier"
19085
- ]);
19086
- var PipelineEngineChoiceSchema = object({
19087
- runtime: _enum(["node", "python"]),
19088
- backend: string(),
19089
- format: ModelFormatSchema$1,
19090
- device: string().optional()
19091
- });
19092
- var AvailableEngineSchema = object({
19093
- engine: PipelineEngineChoiceSchema,
19094
- devices: array(object({
19095
- id: string(),
19096
- label: string(),
19097
- description: string().optional()
19098
- })).readonly(),
19099
- defaultDevice: string()
19100
- });
19101
- var PipelineDefaultStepSchema = lazy(() => object({
19102
- addonId: string(),
19103
- addonName: string(),
19104
- slot: PipelineSlotSchema,
19105
- inputClasses: array(string()).readonly(),
19106
- outputClasses: array(string()).readonly(),
19107
- enabled: boolean(),
19108
- modelId: string(),
19109
- children: array(PipelineDefaultStepSchema).readonly(),
19110
- group: string().optional(),
19111
- settings: record(string(), unknown()).optional()
19112
- }));
19113
- var PipelineTemplateStepSchema = lazy(() => object({
19114
- addonId: string(),
19115
- enabled: boolean(),
19116
- modelId: string(),
19117
- children: array(PipelineTemplateStepSchema).readonly(),
19118
- settings: record(string(), unknown()).optional()
19119
- }));
19120
- var PipelineTemplateSchema$1 = object({
19121
- id: string(),
19122
- name: string(),
19123
- createdAt: string(),
19124
- updatedAt: string(),
19125
- engine: PipelineEngineChoiceSchema,
19126
- steps: array(PipelineTemplateStepSchema).readonly()
19127
- });
19128
- var PipelineModelOptionSchema = object({
19129
- id: string(),
19130
- name: string(),
19131
- formats: record(string(), object({
19132
- downloaded: boolean(),
19133
- sizeMB: number()
19134
- })),
19135
- group: ModelVariantGroupSchema.optional(),
19136
- legacy: boolean().optional(),
19137
- provider: ModelProviderIdSchema.optional()
19138
- });
19139
- var ConfigFieldBridge = custom();
19140
- var PipelineAddonSchemaSchema = object({
19141
- id: string(),
19142
- name: string(),
19143
- slot: PipelineSlotSchema,
19144
- inputClasses: array(string()).readonly(),
19145
- outputClasses: array(string()).readonly(),
19146
- childSlots: array(PipelineSlotSchema).readonly(),
19147
- models: array(PipelineModelOptionSchema).readonly(),
19148
- defaultModelId: string(),
19149
- defaultModelIdByFormat: record(string(), string()).optional(),
19150
- enabledByDefault: boolean().optional(),
19151
- backfillIntoExistingOverrides: boolean().optional(),
19152
- defaultConfidence: number(),
19153
- group: string().optional(),
19154
- configSchema: array(ConfigFieldBridge).readonly().optional()
19155
- });
19156
- var PipelineSlotSchemaSchema = object({
19157
- id: PipelineSlotSchema,
19158
- label: string(),
19159
- priority: number(),
19160
- parentSlot: PipelineSlotSchema.nullable(),
19161
- addons: array(PipelineAddonSchemaSchema).readonly()
19162
- });
19163
- var PipelineSchemaSchema = object({
19164
- availableEngines: array(AvailableEngineSchema).readonly(),
19165
- selectedEngine: PipelineEngineChoiceSchema,
19166
- slots: array(PipelineSlotSchemaSchema).readonly()
19167
- });
19168
- var EngineProvisioningSchema = object({
19169
- runtimeId: _enum([
19170
- "onnx",
19171
- "openvino",
19172
- "coreml",
19173
- "edgetpu"
19174
- ]).nullable(),
19175
- device: string().nullable(),
19176
- state: _enum([
19177
- "idle",
19178
- "installing",
19179
- "verifying",
19180
- "ready",
19181
- "failed"
19182
- ]),
19183
- progress: number().optional(),
19184
- error: string().optional(),
19185
- nextRetryAt: number().optional(),
19186
- /**
19187
- * Gate A (config-correctness gate at engine change): human-readable
19188
- * config issues surfaced EAGERLY when the node's engine changes — model
19189
- * substitutions ("chose X, running Y") and zero-build steps ("no model
19190
- * has a <format> build"). Additive/optional: informational only, never
19191
- * enforced here — `assertEngineReady` (readiness) still gates inference.
19192
- * Absent/empty when the node-default tree resolves cleanly.
19193
- */
19194
- configIssues: array(string()).optional()
19195
- });
19196
- var PipelineStepInputSchema = lazy(() => object({
19197
- addonId: string(),
19198
- modelId: string().optional(),
19199
- enabled: boolean().default(true),
19200
- children: array(PipelineStepInputSchema).optional(),
19201
- settings: record(string(), unknown()).optional(),
19202
- jumpDeviceKey: string().optional()
19203
- }));
19204
- var ModelSubstitutionSchema = object({
19205
- addonId: string(),
19206
- chosen: string(),
19207
- running: string(),
19208
- format: string()
19209
- });
19210
- var PipelineValidationIssueSchema = object({
19211
- addonId: string(),
19212
- kind: _enum(["unknown-addon", "no-format-build"]),
19213
- detail: string()
19214
- });
19215
- var PipelineValidationResultSchema = object({
19216
- ok: boolean(),
19217
- issues: array(PipelineValidationIssueSchema).readonly(),
19218
- substitutions: array(ModelSubstitutionSchema).readonly(),
19219
- /** The node's `currentEngine.format` this validation ran against. */
19220
- format: string()
19221
- });
19222
- var ReferenceImageEntrySchema = object({
19223
- filename: string(),
19224
- stepIds: array(string()).readonly().optional()
19225
- });
19226
- var ReferenceImageBodySchema = object({
19227
- base64: string(),
19228
- filename: string()
19229
- });
19230
- var ReferenceAudioEntrySchema = object({
19231
- filename: string(),
19232
- sizeKb: number()
19233
- });
19234
- var ReferenceAudioBodySchema = object({ base64: string() });
19235
- var AudioBackendSchema = object({
19236
- id: string(),
19237
- name: string(),
19238
- description: string(),
19239
- available: boolean(),
19240
- /**
19241
- * Raw classifier labels this backend can emit (e.g. YAMNet's
19242
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
19243
- * the benchmark UI to populate the `enabledMicroClasses` filter
19244
- * specific to the selected backend without a separate fetch.
19245
- */
19246
- rawLabels: array(string()).readonly().optional()
19247
- });
19248
- var AudioCapabilitiesSchema = object({
19249
- activeBackend: string(),
19250
- availableBackends: array(AudioBackendSchema).readonly(),
19251
- sampleRate: number(),
19252
- chunkDurationMs: number()
19253
- });
19254
- var DownloadModelResultSchema = object({
19255
- filePath: string(),
19256
- sizeMB: number(),
19257
- durationMs: number()
19258
- });
19259
- /**
19260
- * Wrapper carrying a single test run's result. Replaces the legacy
19261
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
19262
- * canonical `AudioResult` from the Phase 6 output rework: one
19263
- * `AudioDetection` per class above `minScore`, top-N candidates in
19264
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
19265
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
19266
- * benchmark UI can still report a clean failure when the classifier
19267
- * cap isn't available.
19268
- */
19269
- var AudioTestResultSchema = object({
19270
- success: boolean(),
19271
- error: string().optional(),
19272
- frame: custom().optional()
19273
- });
19274
- var PipelineConfigBridge = custom();
19275
- var ConfigUISchemaBridge = custom();
19276
- var ConfigUISchemaNullableBridge = custom();
19277
- var InferenceCapabilitiesBridge = custom();
19278
- var ModelAvailabilityListBridge = custom();
19279
- var PipelineRunResultBridge = custom();
19280
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
19281
- modelId: string(),
19282
- settings: record(string(), unknown()).readonly()
19283
- }))), method(object({ steps: record(string(), object({
19284
- modelId: string(),
19285
- settings: record(string(), unknown()).readonly()
19286
- })) }), object({ success: literal(true) }), {
19287
- kind: "mutation",
19288
- auth: "admin"
19289
- }), method(object({ nodeId: string() }), object({
19290
- success: literal(true),
19291
- clearedDevices: number()
19292
- }), {
19293
- kind: "mutation",
19294
- auth: "admin"
19295
- }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
19296
- /** `<backend>:<device>`, e.g. `openvino:gpu`. */
19297
- deviceKey: string(),
19298
- /**
19299
- * `failed` — the per-device restart budget is exhausted; no pool
19300
- * will be spawned until an operator re-arms it or the runner
19301
- * respawns. `backoff` — under budget, waiting out the backoff (or
19302
- * a cached pool observed dead and not yet condemned).
19303
- */
19304
- state: _enum(["failed", "backoff"]),
19305
- /** Epoch ms of the death that produced this state. */
19306
- since: number(),
19307
- /** Pool deaths inside the current window. */
19308
- deaths: number(),
19309
- /** The last death's message. */
19310
- lastError: string()
19311
- })).readonly() })), method(object({
19312
- nodeId: string(),
19313
- deviceKey: string()
19314
- }), object({ rearmed: boolean() }), {
19315
- kind: "mutation",
19316
- auth: "admin"
19317
- }), 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({
19318
- name: string(),
19319
- steps: array(PipelineTemplateStepSchema).readonly(),
19320
- engine: PipelineEngineChoiceSchema
19321
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
19322
- id: string(),
19323
- name: string().optional(),
19324
- steps: array(PipelineTemplateStepSchema).readonly().optional()
19325
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
19326
- addonId: string(),
19327
- modelId: string(),
19328
- format: ModelFormatSchema$1
19329
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
19330
- addonId: string(),
19331
- modelId: string(),
19332
- format: ModelFormatSchema$1
19333
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
19334
- engine: PipelineEngineChoiceSchema.optional(),
19335
- steps: array(PipelineStepInputSchema).min(1),
19336
- frame: FrameInputSchema.optional(),
19337
- /**
19338
- * Process-local lazy frame. Valid only when caller and provider resolve
19339
- * in the same execution-group process; split/cross-node callers use
19340
- * `frame`/`image` inline compatibility instead.
19341
- */
19342
- frameRef: FrameRefSchema.optional(),
19343
- /**
19344
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
19345
- * the decoded pixels live in. One more member of the one-of
19346
- * frame/frameHandle/image/imageBase64/referenceImage group.
19347
- */
19348
- frameHandle: FrameHandleSchema.optional(),
19349
- imageBase64: string().optional(),
19350
- /**
19351
- * Binary JPEG bytes — preferred over `imageBase64` on internal
19352
- * hops (hub → forked worker via Moleculer MsgPack) because it
19353
- * skips the 33% base64 overhead + the per-call base64 decode on
19354
- * the detection-pipeline worker. Callers can pass either; exactly
19355
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
19356
- */
19357
- image: _instanceof(Uint8Array).optional(),
19358
- referenceImage: string().optional(),
19359
- deviceId: number().optional(),
19360
- sessionId: string().optional(),
19361
- /**
19362
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
19363
- * reference-image, and detail-subtree calls. 'frame' is the live
19364
- * per-frame dispatch: ONLY root-plane steps run; crop children
19365
- * (inputClasses ≠ null) are skipped and served per-track via
19366
- * pipelineRunner.runDetailSubtree (two-plane design).
19367
- */
19368
- plane: _enum(["full", "frame"]).optional(),
19369
- /**
19370
- * Inference-device selector (Phase 2 multi-device). Format
19371
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
19372
- * Omitted ⇒ the runner's default device (current single-engine
19373
- * behaviour). Selects WHICH device pool of the node runs the call.
19374
- */
19375
- deviceKey: string().optional(),
19376
- /**
19377
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
19378
- * when the parent crop was resolved from the frame's retained NATIVE
19379
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
19380
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
19381
- * resolution from that surface — the SAME quality path faces already
19382
- * had — instead of the downscaled parent tile. `handle` keys the native
19383
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
19384
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
19385
- * the executor's crop-normalized child ROI back into frame-normalized
19386
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
19387
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
19388
- * (today's behaviour on the fallback path).
19389
- */
19390
- nativeCropRef: NativeCropRefSchema.optional()
19391
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
19392
- engine: PipelineEngineChoiceSchema.optional(),
19393
- steps: array(PipelineStepInputSchema).min(1),
19394
- frames: array(FrameInputSchema).min(1).max(255),
19395
- deviceId: number().optional(),
19396
- sessionId: string().optional(),
19397
- /**
19398
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
19399
- * the batch to the Python pool's bench preprocess cache
19400
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
19401
- * preprocessed ONCE and every later inference is a pure-inference cache
19402
- * hit — the sustained-throughput run measures inference, not
19403
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
19404
- * full preprocess every call, correct). Fresh per sustained run;
19405
- * released via `uncacheFrame`.
19406
- */
19407
- frameId: number().int().nonnegative().optional(),
19408
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
19409
- deviceKey: string().optional()
19410
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
19411
- data: _instanceof(Uint8Array),
19412
- width: number().int().positive(),
19413
- height: number().int().positive(),
19414
- format: _enum([
19415
- "rgb",
19416
- "bgr",
19417
- "gray"
19418
- ])
19419
- }), object({
19420
- frameId: number(),
19421
- width: number(),
19422
- height: number()
19423
- }), { kind: "mutation" }), method(object({
19424
- stepId: string(),
19425
- frameId: number().int()
19426
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
19427
- batchMode: string(),
19428
- windowMs: number(),
19429
- maxBatchSize: number(),
19430
- concurrency: number()
19431
- })), method(_void(), array(object({
19432
- engineKey: string(),
19433
- engine: PipelineEngineChoiceSchema,
19434
- modelsLoaded: array(string()).readonly(),
19435
- inUseByCameras: array(number()).readonly(),
19436
- /**
19437
- * Origin of this resident factory.
19438
- * - `runtime` — main camera-serving engine (no idle TTL).
19439
- * - `warm-override` — benchmark/test override held in the warm
19440
- * cache; auto-disposed after the idle TTL.
19441
- * - `device-pool` — a concurrent per-device pool (Phase 2
19442
- * multi-device, keyed by `deviceKey`) resolved
19443
- * via `resolveDeviceFactory`. Runs alongside the
19444
- * `runtime` engine on a DIFFERENT accelerator
19445
- * (NPU / iGPU / Coral) — this is how the
19446
- * Engines tab shows all pools running at once.
19447
- */
19448
- kind: _enum([
19449
- "runtime",
19450
- "warm-override",
19451
- "device-pool"
19452
- ]),
19453
- /** Native pid of the underlying Python pool (null when no pool). */
19454
- poolPid: number().nullable(),
19455
- /** ms since this factory was last used (null when not warm-tracked). */
19456
- idleMs: number().nullable(),
19457
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
19458
- idleTtlMs: number().nullable()
19459
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
19460
- kind: "mutation",
19461
- auth: "admin"
19462
- }), method(object({
19463
- engine: PipelineEngineChoiceSchema,
19464
- force: boolean().optional()
19465
- }), object({
19466
- success: boolean(),
19467
- reason: string().optional()
19468
- }), {
19469
- kind: "mutation",
19470
- auth: "admin"
19471
- }), 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({
19472
- addonId: string(),
19473
- modelId: string(),
19474
- filename: string().optional(),
19475
- settings: record(string(), unknown()).optional()
19476
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
19477
- /**
19478
- * Per-stage gating mode applied to the zones a rule references.
19479
- *
19480
- * - `include`: the rule contributes to a **whitelist** for its stage.
19481
- * When at least one `include` rule fires for a stage, only entities
19482
- * inside one of those zones pass that stage.
19483
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
19484
- * Entities inside one of those zones are dropped at that stage.
19485
- *
19486
- * `monitor`-style observation (count without filtering) is not a rule
19487
- * mode — zones without any matching rule are observed naturally by
19488
- * `zone-analytics` (live snapshot + history), so an "I just want to
19489
- * count, not filter" use case needs no rule at all.
19490
- */
19491
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
19492
- /**
19493
- * Per-consumer rule that references existing zones (geometry) and
19494
- * defines how a specific pipeline stage should treat them. Each
19495
- * consumer addon owns its own `ZoneRule[]` array in its per-device
19496
- * settings:
19497
- *
19498
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
19499
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
19500
- * - future: notification rules, audio gating, etc.
19501
- *
19502
- * One rule applies to N zones (`zoneIds[]`) so the operator can
19503
- * express "ignore motion in ALL of {garden, street}" with a single
19504
- * rule. `classFilter` narrows the rule to specific object classes —
19505
- * "drop person detections in the street, but keep cars" is one
19506
- * `exclude` rule with `classFilter: ['person']`.
19507
- *
19508
- * `enabled` is a soft toggle — the operator can keep the rule
19509
- * configured but inert without deleting it.
19510
- */
19511
- var ZoneRuleSchema = object({
19512
- /** Stable rule id — survives edits, used by the UI for diffing. */
19513
- id: string(),
19514
- /** Optional human-readable label rendered in the rule editor. */
19515
- name: string().optional(),
19516
- /** Zones this rule targets. The rule's `mode` applies to ALL
19517
- * listed zones (OR-set: a detection in any one of them counts).
19518
- * At least one zone id required — a rule with no targets is a
19519
- * configuration mistake and the form validator rejects it. */
19520
- zoneIds: array(string()).min(1).readonly(),
19521
- mode: ZoneRuleModeEnum,
19522
- /**
19523
- * Class names this rule applies to. Empty / undefined ⇒ rule
19524
- * applies to every class. Class strings match the `macroClass`
19525
- * field on detections (e.g. `person`, `car`, `dog`).
19526
- */
19527
- classFilter: array(string()).readonly().optional(),
19528
- /**
19529
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
19530
- * required to consider an entity "in the zone". Defaults to the
19531
- * consumer's stage default when omitted. Kept for back-compat with
19532
- * existing per-rule overrides; new operators pick the value via
19533
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
19534
- * set, the lower-level engine reads it as a 0–1 fraction.
19535
- */
19536
- overlapThreshold: number().min(0).max(1).optional(),
19537
- /**
19538
- * Operator-friendly version of `overlapThreshold` — the percentage
19539
- * of the detection's bbox that must lie inside the zone for the
19540
- * rule to match. Documented default is 85%; the engine substitutes
19541
- * that when the field is omitted (kept optional so existing rules
19542
- * stored without it stay valid).
19543
- *
19544
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
19545
- * rule, the engine prefers `bboxInclusionPct` because it's the
19546
- * field exposed in the UI. Internally both feed the same gate.
19547
- */
19548
- bboxInclusionPct: number().min(0).max(100).optional(),
19549
- /**
19550
- * When `true` and a detection has a segmentation mask, use the
19551
- * mask for overlap instead of the bbox. Detection-stage only;
19552
- * motion rules ignore this field.
19553
- */
19554
- preferMask: boolean().optional(),
19555
- /**
19556
- * Soft-toggle: `false` disables the rule without deleting it.
19557
- * Defaults to `true` so operators creating a rule via the UI
19558
- * see it active immediately.
19559
- */
19560
- enabled: boolean().default(true)
19561
- });
19562
- array(ZoneRuleSchema).readonly();
19563
- /**
19564
- * Zone — pure geometry + identity. NO filtering behaviour.
19565
- *
19566
- * Zones describe **where** in the frame the operator wants to flag
19567
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
19568
- * each pipeline stage uses them. Splitting the two means a single
19569
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
19570
- * a detection-include rule on `['car']`, and an occupancy aggregate
19571
- * — without three duplicated polygons.
19572
- *
19573
- * Owned by the orchestrator addon (provider) and mirrored into the
19574
- * `zones` device-state slice on every mutation. Consumers
19575
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
19576
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
19577
- * mirror with `onChanged`).
19578
- *
19579
- * Coordinates are normalised fractions of the frame (0–1) so zones
19580
- * survive resolution changes and stream profile switches.
19581
- *
19582
- * `kind` discriminates between full polygons (closed regions used
19583
- * for intrusion / occupancy filters) and tripwires (open 2-point
19584
- * line segments used for cross events). Onboard / firmware-reported
19585
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
19586
- * task list.
19587
- */
19588
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
19589
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
19590
- var PolygonPointSchema = object({
19591
- x: number(),
19592
- y: number()
19593
- });
19594
- /** A camera detection zone — pure geometry/identity. */
19595
- var ZoneSchema = object({
19596
- id: string(),
19597
- name: string(),
19598
- kind: ZoneKindEnum.default("polygon"),
19599
- /** Polygon vertices, fraction of frame (0–1). */
19600
- polygon: array(PolygonPointSchema).readonly(),
19601
- /** Visual color for UI rendering. */
19602
- color: string().default("#3b82f6")
19603
- });
19604
- DeviceType.Camera, method(object({ deviceId: number() }), array(ZoneSchema).readonly()), method(object({
19605
- deviceId: number(),
19606
- zone: ZoneSchema
19607
- }), _void(), {
19608
- kind: "mutation",
19609
- auth: "admin"
19610
- }), method(object({
19611
- deviceId: number(),
19612
- zoneId: string()
19613
- }), _void(), {
19614
- kind: "mutation",
19615
- auth: "admin"
19616
- }), method(object({
19617
- deviceId: number(),
19618
- zone: ZoneSchema
19619
- }), _void(), {
19620
- kind: "mutation",
19621
- auth: "admin"
19622
- }), object({ zones: array(ZoneSchema).readonly() });
19911
+ * A model choice has a SCOPE, and a scope change has a workflow.
19912
+ *
19913
+ * ## The two scopes
19914
+ *
19915
+ * Almost every pipeline step's model is a **node** question: which build runs
19916
+ * fastest on THIS accelerator. Two nodes may legitimately answer differently —
19917
+ * a Coral runs the tflite SSD, a Mac runs the coreml YOLO — because the answers
19918
+ * are compared against nothing. They produce boxes, and a box is a box.
19919
+ *
19920
+ * Two steps are not like that. `face-embedding` and `clip-embedding` produce
19921
+ * **vectors that land in ONE shared index** (`identity_samples`,
19922
+ * `vec_object_clip`) and are ranked against each other by cosine similarity.
19923
+ * Cosine similarity between two encoders is not a weak signal, it is a
19924
+ * meaningless number — and nothing inside a vector can tell you it happened.
19925
+ * So for those two steps the model is a **cluster** question with exactly one
19926
+ * answer, stored in exactly one row.
19927
+ *
19928
+ * That is the same argument [D52](../../../../docs/decisions/adr-0052.md) makes
19929
+ * for the crop convention (`detail-crop.ts`), one level up: the crop decides
19930
+ * WHAT pixels the encoder sees, this decides WHICH encoder sees them. Both are
19931
+ * cluster-wide for the same reason and neither may become per-node.
19932
+ *
19933
+ * ## Why the registry lives here and not in the step catalog
19934
+ *
19935
+ * The scope itself is declared on the step, in
19936
+ * `detection-pipeline/registry/step-definitions.ts` (`StepDefinition.modelScope`)
19937
+ * — that is where a new step declares what kind of choice its model is. But the
19938
+ * catalog lives inside `addon-pipeline`, and three packages that must NOT
19939
+ * import an addon need to know the set: the orchestrator (which renders and
19940
+ * stores the row), post-analysis (which pins the row for a re-embed pass) and
19941
+ * admin-ui (which mirrors it). So the set is mirrored here, and
19942
+ * `scripts/check-cluster-model-scope.ts` fails the build when the two disagree.
19943
+ * A hand-copied key that stops matching is exactly how a setting silently stops
19944
+ * arriving while both sides still look correct.
19945
+ *
19946
+ * ## The defaults ARE today's behaviour
19947
+ *
19948
+ * {@link DEFAULT_CLUSTER_STEP_MODELS} reproduces the catalog `defaultModelId`
19949
+ * of both steps. Declaring the scope therefore changes nothing on the day it
19950
+ * ships: the cluster row starts out saying what every node was already doing.
19951
+ * Changing it is legitimate — that is what the knob is for — but it invalidates
19952
+ * the stored vectors of that surface, and must be followed by a re-embed pass
19953
+ * (`face-reembed-pass.ts`, `embedding-rebuild.ts`).
19954
+ */
19955
+ /**
19956
+ * Why the orchestrator cannot say which model the operator chose for a
19957
+ * cluster-scoped step (D651).
19958
+ */
19959
+ var CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS = [
19960
+ "owner-not-ready",
19961
+ "store-read-failed",
19962
+ "three-way-read-unavailable",
19963
+ "invalid-stored",
19964
+ "not-cluster-scoped"
19965
+ ];
19966
+ Object.freeze(Object.fromEntries([{
19967
+ stepId: "face-embedding",
19968
+ label: "Face recognition model",
19969
+ defaultModelId: "auraface-r100",
19970
+ indexName: "the enrolled face gallery",
19971
+ options: [
19972
+ {
19973
+ id: "auraface-r100",
19974
+ label: "AuraFace R100"
19975
+ },
19976
+ {
19977
+ id: "arcface-r100",
19978
+ label: "ArcFace (ResNet34)"
19979
+ },
19980
+ {
19981
+ id: "inception-resnet-v1",
19982
+ label: "Inception ResNet V1"
19983
+ }
19984
+ ]
19985
+ }, {
19986
+ stepId: "clip-embedding",
19987
+ label: "Semantic search model",
19988
+ defaultModelId: "mobileclip-s1",
19989
+ indexName: "the object semantic-search index",
19990
+ options: [
19991
+ {
19992
+ id: "mobileclip-s1",
19993
+ label: "MobileCLIP S1"
19994
+ },
19995
+ {
19996
+ id: "mobileclip-s2",
19997
+ label: "MobileCLIP S2"
19998
+ },
19999
+ {
20000
+ id: "siglip2-b16-224",
20001
+ label: "SigLIP2 B/16 (Apache-2.0)"
20002
+ }
20003
+ ]
20004
+ }].map((s) => [s.stepId, s.defaultModelId])));
20005
+ var CLUSTER_STEP_SETTING_FIELDS = [{
20006
+ stepId: "face-embedding",
20007
+ key: "minLandmarkFaceSize",
20008
+ label: "Min face size for recognition (detection px)",
20009
+ 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.",
20010
+ type: "slider",
20011
+ min: 0,
20012
+ max: 64,
20013
+ step: 2,
20014
+ default: 24
20015
+ }];
20016
+ function clusterStepSettingKey(stepId, fieldKey) {
20017
+ return `clusterStepSetting:${stepId}:${fieldKey}`;
20018
+ }
20019
+ var ClusterSettingNumberSchema = number().finite();
20020
+ function readClusterStepSettings(config) {
20021
+ const out = {};
20022
+ for (const field of CLUSTER_STEP_SETTING_FIELDS) {
20023
+ const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
20024
+ const value = parsed.success ? parsed.data : field.default;
20025
+ const existing = out[field.stepId] ?? {};
20026
+ out[field.stepId] = {
20027
+ ...existing,
20028
+ [field.key]: value
20029
+ };
20030
+ }
20031
+ return out;
20032
+ }
20033
+ readClusterStepSettings({});
19623
20034
  /**
19624
20035
  * pipeline-analytics — device-scoped wrapper cap. Refines raw
19625
20036
  * per-frame detections emitted by the pipeline runner into tracked
@@ -20191,6 +20602,22 @@ var TrackSchema = object({
20191
20602
  * omit it. Render nothing when absent.
20192
20603
  */
20193
20604
  previewMissReason: string().optional(),
20605
+ /**
20606
+ * The ROOT model that produced this track — the `FrameResult.rootModelId` of
20607
+ * the frame it was BORN on (D646). What a later replay compares against, so
20608
+ * "the original model" is named rather than assumed. A birth fact: never
20609
+ * rewritten by a later frame. **Absent ≠ unknown-model**: a row from before
20610
+ * the column, and a track the camera's own detector produced, carry none.
20611
+ */
20612
+ modelId: string().optional(),
20613
+ /**
20614
+ * Size (px) of the detection frame this track's `positions[].bbox` live in —
20615
+ * the frame it was born on, else the camera's latest analysis frame at
20616
+ * persist time. Divide a position by these to normalise it. Absent when the
20617
+ * size was never known.
20618
+ */
20619
+ frameWidth: number().optional(),
20620
+ frameHeight: number().optional(),
20194
20621
  ...TrackFlagFields,
20195
20622
  ...TrackRetrainFields
20196
20623
  });
@@ -20402,6 +20829,13 @@ var AudioEventSchema = object({
20402
20829
  originalClass: string().optional(),
20403
20830
  score: number()
20404
20831
  }).optional(),
20832
+ /**
20833
+ * Whether the classifier RAN on the window behind this row (D660). Absent
20834
+ * on rows written before D660 — unknown, NOT classified: until then a
20835
+ * window the analyzer's busy gate threw away was stored exactly like one
20836
+ * that heard nothing above the floor.
20837
+ */
20838
+ classifyOutcome: AudioClassifyOutcomeSchema.optional(),
20405
20839
  /** Populated by B5 (recording playback URL for this event). */
20406
20840
  mediaUrl: string().optional()
20407
20841
  });
@@ -20420,7 +20854,8 @@ var MediaFileKindEnum = _enum([
20420
20854
  "thumbnailSmall",
20421
20855
  "confirmationCrop",
20422
20856
  "debugCrop",
20423
- "sceneFrame"
20857
+ "sceneFrame",
20858
+ "lastSceneFrame"
20424
20859
  ]);
20425
20860
  /**
20426
20861
  * One media row ON THE WIRE: what it is, how big it is, and WHERE ITS BYTES
@@ -20972,7 +21407,23 @@ var SearchObjectEventsInput = object({
20972
21407
  until: number().optional(),
20973
21408
  classFilter: string().optional(),
20974
21409
  limit: number().default(50),
20975
- minScore: number().min(0).max(1).default(.2)
21410
+ /**
21411
+ * An ABSOLUTE cosine floor. Optional since D649: a floor is a property of the
21412
+ * model (0.2 kept 96% of matched pairs on MobileCLIP S1 and 2.7% on SigLIP2),
21413
+ * so an absent one resolves to the searched model's own `searchMinScore`
21414
+ * scaled by `strictness`. A number sent here is honoured verbatim.
21415
+ */
21416
+ minScore: number().min(0).max(1).optional(),
21417
+ /** Model-relative floor — see `resolveClipSearchMinScore`. Default `loose`. */
21418
+ strictness: ClipSearchStrictnessSchema.optional(),
21419
+ /**
21420
+ * Search THIS CLIP model's index instead of the cluster row's. Every index a
21421
+ * model ever wrote stays searchable until it is wiped (the MobileCLIP index
21422
+ * through a SigLIP2 cutover and its rollback window). An id with no CLIP
21423
+ * metadata is refused; an id other than the cluster row's is ADMIN-only
21424
+ * (`model-override-requires-admin`).
21425
+ */
21426
+ modelId: string().min(1).optional()
20976
21427
  });
20977
21428
  var TrackCascadeCountsSchema = object({
20978
21429
  /** Persisted track roots deleted (authoritative). */
@@ -21107,7 +21558,41 @@ var RebuildObjectEmbeddingsInput = object({
21107
21558
  * comparable, so wiping and rebuilding is the only way to be sure every vector
21108
21559
  * means the same thing.
21109
21560
  */
21110
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
21561
+ var WipeObjectEmbeddingsResultSchema = object({
21562
+ deleted: number(),
21563
+ /**
21564
+ * CLIP indexes that could NOT be emptied (unreachable, or refused at their
21565
+ * dimension) — not a clean slate. Additive and optional (D649).
21566
+ */
21567
+ failedIndexes: array(string()).optional()
21568
+ });
21569
+ /**
21570
+ * Why a rebuild did not start, BY NAME — ONE vocabulary for both gates in front
21571
+ * of a pass (D649 over D651). A bare `started: false` read the same for "the
21572
+ * stores are booting" and "the cluster row names a model with no CLIP
21573
+ * metadata", which need different fixes.
21574
+ * - `stores-unavailable` — the analytics stores or the API are not up yet.
21575
+ * - the owner's confirmation of the cluster model (D651, `ClusterPinConfirmer`):
21576
+ * a pass that rewrites an index needs two agreeing reads of the OWNER's
21577
+ * answer (`pipelineOrchestrator.getClusterModelChoice`) — a pass that cannot
21578
+ * name its model does not run (D54):
21579
+ * - the owner's own `unreadable` reasons (`owner-not-ready`,
21580
+ * `store-read-failed`, `three-way-read-unavailable`, `invalid-stored`,
21581
+ * `not-cluster-scoped`);
21582
+ * - `method-unavailable` — the orchestrator predates the method;
21583
+ * - `read-failed` — the call failed or answered something unparseable;
21584
+ * - `reads-disagree` — the two reads named different choices.
21585
+ * - `not-a-clip-model` — the CONFIRMED id has no CLIP metadata, so there is no
21586
+ * index to fill and no dimension to check against (D649).
21587
+ */
21588
+ var RebuildObjectEmbeddingsRefusalSchema = _enum([
21589
+ "stores-unavailable",
21590
+ ...CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS,
21591
+ "method-unavailable",
21592
+ "read-failed",
21593
+ "reads-disagree",
21594
+ "not-a-clip-model"
21595
+ ]);
21111
21596
  /**
21112
21597
  * Acknowledgement that a rebuild STARTED.
21113
21598
  *
@@ -21120,7 +21605,12 @@ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
21120
21605
  var RebuildObjectEmbeddingsResultSchema = object({
21121
21606
  started: boolean(),
21122
21607
  /** True when a pass was already running; the new request is ignored. */
21123
- alreadyRunning: boolean()
21608
+ alreadyRunning: boolean(),
21609
+ /** Present when the pass refused to start — see `RebuildObjectEmbeddingsRefusalSchema`. */
21610
+ refusal: RebuildObjectEmbeddingsRefusalSchema.optional(),
21611
+ /** The CLIP model the pass pinned, and the index it fills (when it started). */
21612
+ modelId: string().optional(),
21613
+ index: string().optional()
21124
21614
  });
21125
21615
  var RebuildStatusSchema = object({
21126
21616
  running: boolean(),
@@ -21154,7 +21644,11 @@ var RebuildStatusSchema = object({
21154
21644
  startedAtMs: number().nullable(),
21155
21645
  finishedAtMs: number().nullable(),
21156
21646
  /** Present when the pass ended by throwing. */
21157
- error: string().nullable()
21647
+ error: string().nullable(),
21648
+ /** The CLIP model the current / last pass pinned (D54), `null` before any. */
21649
+ modelId: string().nullable(),
21650
+ /** The index that pass fills — `ClipModelMeta.vectorIndex` of `modelId` (D649). */
21651
+ index: string().nullable()
21158
21652
  });
21159
21653
  /**
21160
21654
  * Acknowledgement that a debug-media reclaim STARTED.
@@ -21197,24 +21691,6 @@ var MediaReclaimStatusSchema = object({
21197
21691
  finishedAtMs: number().nullable(),
21198
21692
  error: string().nullable()
21199
21693
  });
21200
- var ReplayFrameInputSchema = object({
21201
- timestamp: number(),
21202
- frame: PipelineRunResultBridge
21203
- });
21204
- var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
21205
- className: string(),
21206
- firstSeenMs: number(),
21207
- lastSeenMs: number(),
21208
- /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
21209
- * frame — a representative box for the diff's `(className, window, IoU)`
21210
- * pairing (`replay-diff.ts`). A replay does not need the full per-frame
21211
- * trajectory production's `Track.positions` keeps. */
21212
- bbox: BoundingBoxSchema,
21213
- /** How many of the input frames this track matched a real detection on
21214
- * (never a coasted/extrapolated frame) — the replay's own signal for "how
21215
- * solid is this track", cheaper than re-deriving it from a trajectory. */
21216
- framesMatched: number().int()
21217
- })).readonly() });
21218
21694
  /**
21219
21695
  * The long-term series a camera produces. A closed union so a typo cannot
21220
21696
  * invent one, and the ONE declaration of it — the addon's `AnalyticsLtsSeries`
@@ -21445,16 +21921,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
21445
21921
  }), RetrainAssistResultSchema, {
21446
21922
  kind: "mutation",
21447
21923
  auth: "admin"
21448
- }), method(object({
21449
- deviceId: number(),
21450
- source: DetectionSourceSchema,
21451
- zones: array(ZoneSchema).readonly().optional(),
21452
- detectionRules: array(ZoneRuleSchema).readonly().optional(),
21453
- zoneMembershipMinOverlap: number().min(0).max(1).optional(),
21454
- frames: array(ReplayFrameInputSchema).min(1)
21455
- }), RunReplayFrameProcessorResultSchema, {
21456
- kind: "mutation",
21457
- auth: "admin"
21458
21924
  }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
21459
21925
  kind: "query",
21460
21926
  auth: "admin"
@@ -21503,7 +21969,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
21503
21969
  deviceId: number(),
21504
21970
  ownerKind: MediaPresenceOwnerKindSchema,
21505
21971
  ownerIds: array(string()).max(5e3)
21506
- }), array(string()).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
21972
+ }), array(string()).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly(), { caller: "required" }), method(object({}), WipeObjectEmbeddingsResultSchema, {
21507
21973
  kind: "mutation",
21508
21974
  auth: "admin"
21509
21975
  }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
@@ -21530,6 +21996,485 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
21530
21996
  eventId: string(),
21531
21997
  timestamp: number()
21532
21998
  });
21999
+ /**
22000
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
22001
+ * within the frame, so the executor can re-cut a leaf child ROI at native
22002
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
22003
+ */
22004
+ var NativeCropRefSchema = object({
22005
+ /** Handle keying the retained native surface (node-pinned to its owner). */
22006
+ handle: FrameHandleSchema,
22007
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
22008
+ cropFrameSpace: object({
22009
+ x: number(),
22010
+ y: number(),
22011
+ w: number(),
22012
+ h: number()
22013
+ })
22014
+ });
22015
+ object({
22016
+ crop: object({
22017
+ left: number(),
22018
+ top: number(),
22019
+ width: number().positive(),
22020
+ height: number().positive()
22021
+ }).optional(),
22022
+ content: object({
22023
+ width: number().int().positive(),
22024
+ height: number().int().positive()
22025
+ }),
22026
+ fit: _enum(["stretch", "contain"]),
22027
+ format: _enum([
22028
+ "rgb",
22029
+ "gray",
22030
+ "jpeg"
22031
+ ])
22032
+ });
22033
+ /**
22034
+ * Process-local frame identity. It is serializable so it can ride an in-process
22035
+ * capability call, but `registryId` deliberately prevents resolution in any
22036
+ * other process or execution group.
22037
+ */
22038
+ var FrameRefSchema = object({
22039
+ registryId: string().min(1),
22040
+ id: string().min(1),
22041
+ width: number().int().positive(),
22042
+ height: number().int().positive(),
22043
+ format: _enum(["rgb", "gray"]),
22044
+ timestamp: number(),
22045
+ capturedAt: number().optional()
22046
+ });
22047
+ var ModelFormatSchema$1 = _enum([
22048
+ "onnx",
22049
+ "coreml",
22050
+ "openvino",
22051
+ "tflite",
22052
+ "pt",
22053
+ "gguf"
22054
+ ]);
22055
+ var PipelineSlotSchema = _enum([
22056
+ "detector",
22057
+ "cropper",
22058
+ "classifier",
22059
+ "refiner",
22060
+ "audio-classifier"
22061
+ ]);
22062
+ var PipelineEngineChoiceSchema = object({
22063
+ runtime: literal("python"),
22064
+ backend: string(),
22065
+ format: ModelFormatSchema$1,
22066
+ device: string().optional()
22067
+ });
22068
+ /**
22069
+ * One pool's resolved provisioning (`getEffectiveTuning`). `numWorkers` is the
22070
+ * knob that lifts a saturated pool (`inference-devices.md`); `concurrency` is
22071
+ * per-worker in-flight requests. `deviceKey` echoes the pool asked about —
22072
+ * `null` for the node-default pool.
22073
+ */
22074
+ var EffectiveTuningSchema = object({
22075
+ deviceKey: string().nullable(),
22076
+ runtime: string(),
22077
+ batchMode: string(),
22078
+ windowMs: number(),
22079
+ maxBatchSize: number(),
22080
+ concurrency: number(),
22081
+ numWorkers: number()
22082
+ });
22083
+ var AvailableEngineSchema = object({
22084
+ engine: PipelineEngineChoiceSchema,
22085
+ devices: array(object({
22086
+ id: string(),
22087
+ label: string(),
22088
+ description: string().optional()
22089
+ })).readonly(),
22090
+ defaultDevice: string()
22091
+ });
22092
+ var PipelineDefaultStepSchema = lazy(() => object({
22093
+ addonId: string(),
22094
+ addonName: string(),
22095
+ slot: PipelineSlotSchema,
22096
+ inputClasses: array(string()).readonly(),
22097
+ outputClasses: array(string()).readonly(),
22098
+ enabled: boolean(),
22099
+ modelId: string(),
22100
+ children: array(PipelineDefaultStepSchema).readonly(),
22101
+ group: string().optional(),
22102
+ settings: record(string(), unknown()).optional()
22103
+ }));
22104
+ var PipelineTemplateStepSchema = lazy(() => object({
22105
+ addonId: string(),
22106
+ enabled: boolean(),
22107
+ modelId: string(),
22108
+ children: array(PipelineTemplateStepSchema).readonly(),
22109
+ settings: record(string(), unknown()).optional()
22110
+ }));
22111
+ var PipelineTemplateSchema$1 = object({
22112
+ id: string(),
22113
+ name: string(),
22114
+ createdAt: string(),
22115
+ updatedAt: string(),
22116
+ engine: PipelineEngineChoiceSchema,
22117
+ steps: array(PipelineTemplateStepSchema).readonly()
22118
+ });
22119
+ var PipelineModelOptionSchema = object({
22120
+ id: string(),
22121
+ name: string(),
22122
+ formats: record(string(), object({
22123
+ downloaded: boolean(),
22124
+ sizeMB: number()
22125
+ })),
22126
+ group: ModelVariantGroupSchema.optional(),
22127
+ legacy: boolean().optional(),
22128
+ provider: ModelProviderIdSchema.optional()
22129
+ });
22130
+ var ConfigFieldBridge = custom();
22131
+ var PipelineAddonSchemaSchema = object({
22132
+ id: string(),
22133
+ name: string(),
22134
+ slot: PipelineSlotSchema,
22135
+ inputClasses: array(string()).readonly(),
22136
+ outputClasses: array(string()).readonly(),
22137
+ childSlots: array(PipelineSlotSchema).readonly(),
22138
+ models: array(PipelineModelOptionSchema).readonly(),
22139
+ defaultModelId: string(),
22140
+ defaultModelIdByFormat: record(string(), string()).optional(),
22141
+ enabledByDefault: boolean().optional(),
22142
+ backfillIntoExistingOverrides: boolean().optional(),
22143
+ defaultConfidence: number(),
22144
+ group: string().optional(),
22145
+ configSchema: array(ConfigFieldBridge).readonly().optional()
22146
+ });
22147
+ var PipelineSlotSchemaSchema = object({
22148
+ id: PipelineSlotSchema,
22149
+ label: string(),
22150
+ priority: number(),
22151
+ parentSlot: PipelineSlotSchema.nullable(),
22152
+ addons: array(PipelineAddonSchemaSchema).readonly()
22153
+ });
22154
+ var PipelineSchemaSchema = object({
22155
+ availableEngines: array(AvailableEngineSchema).readonly(),
22156
+ selectedEngine: PipelineEngineChoiceSchema,
22157
+ slots: array(PipelineSlotSchemaSchema).readonly()
22158
+ });
22159
+ var EngineProvisioningSchema = object({
22160
+ runtimeId: _enum([
22161
+ "onnx",
22162
+ "openvino",
22163
+ "coreml",
22164
+ "edgetpu"
22165
+ ]).nullable(),
22166
+ device: string().nullable(),
22167
+ state: _enum([
22168
+ "idle",
22169
+ "installing",
22170
+ "verifying",
22171
+ "ready",
22172
+ "failed"
22173
+ ]),
22174
+ progress: number().optional(),
22175
+ error: string().optional(),
22176
+ nextRetryAt: number().optional(),
22177
+ /**
22178
+ * Gate A (config-correctness gate at engine change): human-readable
22179
+ * config issues surfaced EAGERLY when the node's engine changes — model
22180
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
22181
+ * has a <format> build"). Additive/optional: informational only, never
22182
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
22183
+ * Absent/empty when the node-default tree resolves cleanly.
22184
+ */
22185
+ configIssues: array(string()).optional()
22186
+ });
22187
+ var PipelineStepInputSchema = lazy(() => object({
22188
+ addonId: string(),
22189
+ modelId: string().optional(),
22190
+ enabled: boolean().default(true),
22191
+ children: array(PipelineStepInputSchema).optional(),
22192
+ settings: record(string(), unknown()).optional(),
22193
+ jumpDeviceKey: string().optional()
22194
+ }));
22195
+ var ModelSubstitutionSchema = object({
22196
+ addonId: string(),
22197
+ chosen: string(),
22198
+ running: string(),
22199
+ format: string()
22200
+ });
22201
+ var PipelineValidationIssueSchema = object({
22202
+ addonId: string(),
22203
+ kind: _enum([
22204
+ "unknown-addon",
22205
+ "no-format-build",
22206
+ "unknown-device"
22207
+ ]),
22208
+ detail: string()
22209
+ });
22210
+ var PipelineValidationResultSchema = object({
22211
+ ok: boolean(),
22212
+ issues: array(PipelineValidationIssueSchema).readonly(),
22213
+ substitutions: array(ModelSubstitutionSchema).readonly(),
22214
+ /** The node's `currentEngine.format` this validation ran against. */
22215
+ format: string()
22216
+ });
22217
+ var ReferenceImageEntrySchema = object({
22218
+ filename: string(),
22219
+ stepIds: array(string()).readonly().optional()
22220
+ });
22221
+ var ReferenceImageBodySchema = object({
22222
+ base64: string(),
22223
+ filename: string()
22224
+ });
22225
+ var ReferenceAudioEntrySchema = object({
22226
+ filename: string(),
22227
+ sizeKb: number()
22228
+ });
22229
+ var ReferenceAudioBodySchema = object({ base64: string() });
22230
+ var AudioBackendSchema = object({
22231
+ id: string(),
22232
+ name: string(),
22233
+ description: string(),
22234
+ available: boolean(),
22235
+ /**
22236
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
22237
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
22238
+ * the benchmark UI to populate the `enabledMicroClasses` filter
22239
+ * specific to the selected backend without a separate fetch.
22240
+ */
22241
+ rawLabels: array(string()).readonly().optional()
22242
+ });
22243
+ var AudioCapabilitiesSchema = object({
22244
+ activeBackend: string(),
22245
+ availableBackends: array(AudioBackendSchema).readonly(),
22246
+ sampleRate: number(),
22247
+ chunkDurationMs: number()
22248
+ });
22249
+ var DownloadModelResultSchema = object({
22250
+ filePath: string(),
22251
+ sizeMB: number(),
22252
+ durationMs: number()
22253
+ });
22254
+ /**
22255
+ * Wrapper carrying a single test run's result. Replaces the legacy
22256
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
22257
+ * canonical `AudioResult` from the Phase 6 output rework: one
22258
+ * `AudioDetection` per class above `minScore`, top-N candidates in
22259
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
22260
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
22261
+ * benchmark UI can still report a clean failure when the classifier
22262
+ * cap isn't available.
22263
+ */
22264
+ var AudioTestResultSchema = object({
22265
+ success: boolean(),
22266
+ error: string().optional(),
22267
+ frame: custom().optional()
22268
+ });
22269
+ var PipelineConfigBridge = custom();
22270
+ var ConfigUISchemaBridge = custom();
22271
+ var ConfigUISchemaNullableBridge = custom();
22272
+ var InferenceCapabilitiesBridge = custom();
22273
+ var ModelAvailabilityListBridge = custom();
22274
+ var PipelineRunResultBridge = custom();
22275
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
22276
+ modelId: string(),
22277
+ settings: record(string(), unknown()).readonly()
22278
+ }))), method(object({ steps: record(string(), object({
22279
+ modelId: string(),
22280
+ settings: record(string(), unknown()).readonly()
22281
+ })) }), object({ success: literal(true) }), {
22282
+ kind: "mutation",
22283
+ auth: "admin"
22284
+ }), method(object({ nodeId: string() }), object({
22285
+ success: literal(true),
22286
+ clearedDevices: number()
22287
+ }), {
22288
+ kind: "mutation",
22289
+ auth: "admin"
22290
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
22291
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
22292
+ deviceKey: string(),
22293
+ /**
22294
+ * `failed` — the per-device restart budget is exhausted; no pool
22295
+ * will be spawned until an operator re-arms it or the runner
22296
+ * respawns. `backoff` — under budget, waiting out the backoff (or
22297
+ * a cached pool observed dead and not yet condemned).
22298
+ */
22299
+ state: _enum(["failed", "backoff"]),
22300
+ /** Epoch ms of the death that produced this state. */
22301
+ since: number(),
22302
+ /** Pool deaths inside the current window. */
22303
+ deaths: number(),
22304
+ /** The last death's message. */
22305
+ lastError: string()
22306
+ })).readonly() })), method(object({
22307
+ nodeId: string(),
22308
+ deviceKey: string()
22309
+ }), object({ rearmed: boolean() }), {
22310
+ kind: "mutation",
22311
+ auth: "admin"
22312
+ }), method(_void(), PipelineSchemaSchema), method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()), method(_void(), PipelineConfigBridge), method(_void(), ConfigUISchemaBridge), method(object({
22313
+ steps: array(PipelineStepInputSchema),
22314
+ deviceKey: string().optional()
22315
+ }), PipelineValidationResultSchema), method(_void(), array(PipelineTemplateSchema$1).readonly()), method(object({
22316
+ name: string(),
22317
+ steps: array(PipelineTemplateStepSchema).readonly(),
22318
+ engine: PipelineEngineChoiceSchema
22319
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
22320
+ id: string(),
22321
+ name: string().optional(),
22322
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
22323
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
22324
+ addonId: string(),
22325
+ modelId: string(),
22326
+ format: ModelFormatSchema$1
22327
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
22328
+ addonId: string(),
22329
+ modelId: string(),
22330
+ format: ModelFormatSchema$1
22331
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
22332
+ steps: array(PipelineStepInputSchema).min(1),
22333
+ frame: FrameInputSchema.optional(),
22334
+ /**
22335
+ * Process-local lazy frame. Valid only when caller and provider resolve
22336
+ * in the same execution-group process; split/cross-node callers use
22337
+ * `frame`/`image` inline compatibility instead.
22338
+ */
22339
+ frameRef: FrameRefSchema.optional(),
22340
+ /**
22341
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
22342
+ * the decoded pixels live in. One more member of the one-of
22343
+ * frame/frameHandle/image/imageBase64/referenceImage group.
22344
+ */
22345
+ frameHandle: FrameHandleSchema.optional(),
22346
+ imageBase64: string().optional(),
22347
+ /**
22348
+ * Binary JPEG bytes — preferred over `imageBase64` on internal
22349
+ * hops (hub → forked worker via Moleculer MsgPack) because it
22350
+ * skips the 33% base64 overhead + the per-call base64 decode on
22351
+ * the detection-pipeline worker. Callers can pass either; exactly
22352
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
22353
+ */
22354
+ image: _instanceof(Uint8Array).optional(),
22355
+ referenceImage: string().optional(),
22356
+ deviceId: number().optional(),
22357
+ sessionId: string().optional(),
22358
+ /**
22359
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
22360
+ * reference-image, and detail-subtree calls. 'frame' is the live
22361
+ * per-frame dispatch: ONLY root-plane steps run; crop children
22362
+ * (inputClasses ≠ null) are skipped and served per-track via
22363
+ * pipelineRunner.runDetailSubtree (two-plane design).
22364
+ */
22365
+ plane: _enum(["full", "frame"]).optional(),
22366
+ /**
22367
+ * Inference-device selector (Phase 2 multi-device). Format
22368
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
22369
+ * Omitted ⇒ the runner's default device (current single-engine
22370
+ * behaviour). Selects WHICH device pool of the node runs the call.
22371
+ */
22372
+ deviceKey: string().optional(),
22373
+ /**
22374
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
22375
+ * when the parent crop was resolved from the frame's retained NATIVE
22376
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
22377
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
22378
+ * resolution from that surface — the SAME quality path faces already
22379
+ * had — instead of the downscaled parent tile. `handle` keys the native
22380
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
22381
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
22382
+ * the executor's crop-normalized child ROI back into frame-normalized
22383
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
22384
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
22385
+ * (today's behaviour on the fallback path).
22386
+ */
22387
+ nativeCropRef: NativeCropRefSchema.optional(),
22388
+ /**
22389
+ * Offline REPLAY of stored media for `deviceId` (D56, D646): the
22390
+ * camera's zone gate and overrides apply as live, every executing
22391
+ * step runs EXACTLY the model it names on the `deviceKey` pool it
22392
+ * names or the call refuses (`model-not-servable` /
22393
+ * `device-not-servable`), and nothing reaches the camera's live
22394
+ * trace stream. Absent ⇒ unchanged behaviour.
22395
+ */
22396
+ replay: literal(true).optional()
22397
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
22398
+ steps: array(PipelineStepInputSchema).min(1),
22399
+ frames: array(FrameInputSchema).min(1).max(255),
22400
+ deviceId: number().optional(),
22401
+ sessionId: string().optional(),
22402
+ /**
22403
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
22404
+ * the batch to the Python pool's bench preprocess cache
22405
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
22406
+ * preprocessed ONCE and every later inference is a pure-inference cache
22407
+ * hit — the sustained-throughput run measures inference, not
22408
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
22409
+ * full preprocess every call, correct). Fresh per sustained run;
22410
+ * released via `uncacheFrame`.
22411
+ */
22412
+ frameId: number().int().nonnegative().optional(),
22413
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
22414
+ deviceKey: string().optional()
22415
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
22416
+ data: _instanceof(Uint8Array),
22417
+ width: number().int().positive(),
22418
+ height: number().int().positive(),
22419
+ format: _enum([
22420
+ "rgb",
22421
+ "bgr",
22422
+ "gray"
22423
+ ])
22424
+ }), object({
22425
+ frameId: number(),
22426
+ width: number(),
22427
+ height: number()
22428
+ }), { kind: "mutation" }), method(object({
22429
+ stepId: string(),
22430
+ frameId: number().int(),
22431
+ /**
22432
+ * The model to time — REQUIRED (D658). Without it the pool answered the
22433
+ * step's ACTIVE variant (the first loaded after boot), so a benchmark
22434
+ * of model B silently timed model A. Callers pass the `rootModelId`
22435
+ * their warmup `runPipeline` reported: the model that actually ran.
22436
+ */
22437
+ modelId: string().min(1)
22438
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(object({ deviceKey: string().optional() }), EffectiveTuningSchema), method(_void(), array(object({
22439
+ engineKey: string(),
22440
+ engine: PipelineEngineChoiceSchema,
22441
+ modelsLoaded: array(string()).readonly(),
22442
+ inUseByCameras: array(number()).readonly(),
22443
+ /**
22444
+ * Origin of this resident factory.
22445
+ * - `runtime` — main camera-serving engine (no idle TTL).
22446
+ * - `device-pool` — a concurrent per-device pool (Phase 2
22447
+ * multi-device, keyed by `deviceKey`) resolved
22448
+ * via `resolveDeviceFactory`. Runs alongside the
22449
+ * `runtime` engine on a DIFFERENT accelerator
22450
+ * (NPU / iGPU / Coral) — this is how the
22451
+ * Engines tab shows all pools running at once.
22452
+ */
22453
+ kind: _enum(["runtime", "device-pool"]),
22454
+ /** Native pid of the underlying Python pool (null when no pool). */
22455
+ poolPid: number().nullable(),
22456
+ /** ms since this factory was last used (null when not warm-tracked). */
22457
+ idleMs: number().nullable(),
22458
+ /** Idle TTL after which the factory self-evicts (null when not applicable). */
22459
+ idleTtlMs: number().nullable()
22460
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
22461
+ kind: "mutation",
22462
+ auth: "admin"
22463
+ }), method(object({
22464
+ engine: PipelineEngineChoiceSchema,
22465
+ force: boolean().optional()
22466
+ }), object({
22467
+ success: boolean(),
22468
+ reason: string().optional()
22469
+ }), {
22470
+ kind: "mutation",
22471
+ auth: "admin"
22472
+ }), 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({
22473
+ addonId: string(),
22474
+ modelId: string(),
22475
+ filename: string().optional(),
22476
+ settings: record(string(), unknown()).optional()
22477
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
21533
22478
  object({
21534
22479
  activeCameras: number(),
21535
22480
  throttledCameras: number(),
@@ -21555,6 +22500,66 @@ var CameraMetricsSchema = object({
21555
22500
  });
21556
22501
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
21557
22502
  /**
22503
+ * Zone — pure geometry + identity. NO filtering behaviour.
22504
+ *
22505
+ * Zones describe **where** in the frame the operator wants to flag
22506
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
22507
+ * each pipeline stage uses them. Splitting the two means a single
22508
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
22509
+ * a detection-include rule on `['car']`, and an occupancy aggregate
22510
+ * — without three duplicated polygons.
22511
+ *
22512
+ * Owned by the orchestrator addon (provider) and mirrored into the
22513
+ * `zones` device-state slice on every mutation. Consumers
22514
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
22515
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
22516
+ * mirror with `onChanged`).
22517
+ *
22518
+ * Coordinates are normalised fractions of the frame (0–1) so zones
22519
+ * survive resolution changes and stream profile switches.
22520
+ *
22521
+ * `kind` discriminates between full polygons (closed regions used
22522
+ * for intrusion / occupancy filters) and tripwires (open 2-point
22523
+ * line segments used for cross events). Onboard / firmware-reported
22524
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
22525
+ * task list.
22526
+ */
22527
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
22528
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
22529
+ var PolygonPointSchema = object({
22530
+ x: number(),
22531
+ y: number()
22532
+ });
22533
+ /** A camera detection zone — pure geometry/identity. */
22534
+ var ZoneSchema = object({
22535
+ id: string(),
22536
+ name: string(),
22537
+ kind: ZoneKindEnum.default("polygon"),
22538
+ /** Polygon vertices, fraction of frame (0–1). */
22539
+ polygon: array(PolygonPointSchema).readonly(),
22540
+ /** Visual color for UI rendering. */
22541
+ color: string().default("#3b82f6")
22542
+ });
22543
+ DeviceType.Camera, method(object({ deviceId: number() }), array(ZoneSchema).readonly()), method(object({
22544
+ deviceId: number(),
22545
+ zone: ZoneSchema
22546
+ }), _void(), {
22547
+ kind: "mutation",
22548
+ auth: "admin"
22549
+ }), method(object({
22550
+ deviceId: number(),
22551
+ zoneId: string()
22552
+ }), _void(), {
22553
+ kind: "mutation",
22554
+ auth: "admin"
22555
+ }), method(object({
22556
+ deviceId: number(),
22557
+ zone: ZoneSchema
22558
+ }), _void(), {
22559
+ kind: "mutation",
22560
+ auth: "admin"
22561
+ }), object({ zones: array(ZoneSchema).readonly() });
22562
+ /**
21558
22563
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
21559
22564
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
21560
22565
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -21741,7 +22746,17 @@ var DetailResultSchema = object({
21741
22746
  /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
21742
22747
  * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
21743
22748
  * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
21744
- nativeFaceShortSidePx: number().optional()
22749
+ nativeFaceShortSidePx: number().optional(),
22750
+ /**
22751
+ * The five facial landmarks of a `face` detail, in the SAME frame space as
22752
+ * `bbox` (D644). Additive and optional: post-analysis stores them beside the
22753
+ * face's source frame so a future alignment can be re-derived exactly; a
22754
+ * runner that predates the field sends none and the face is stored without.
22755
+ */
22756
+ landmarks: array(object({
22757
+ x: number(),
22758
+ y: number()
22759
+ })).optional()
21745
22760
  });
21746
22761
  /**
21747
22762
  * Why an executing node REFUSED a stateless step run (`runStatelessStep`).
@@ -21996,6 +23011,17 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
21996
23011
  hubHostnameOverride: string().optional()
21997
23012
  })]).describe("Per-camera frame-source mode for the runner (P2c)");
21998
23013
  /**
23014
+ * What ONE step runs with on ONE roster device for THIS camera (D650): the
23015
+ * device's per-(node,device) base with the camera's override for that device
23016
+ * on top — the same `override ?? base` merge the orchestrator applies to the
23017
+ * elected device (`applyDeviceProvisioning`). Absent `modelId` ⇒ the executor
23018
+ * resolves the device format's default, exactly as on the elected device.
23019
+ */
23020
+ var RunnerJumpStepProvisioningSchema = object({
23021
+ modelId: string().optional(),
23022
+ settings: record(string(), unknown()).optional()
23023
+ });
23024
+ /**
21999
23025
  * One ENABLED inference device on the runner's node, as the step-tree
22000
23026
  * device-jump resolver sees it (phase 1). The orchestrator populates this
22001
23027
  * roster on the attach payload whenever the camera is elected onto a specific
@@ -22007,7 +23033,16 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
22007
23033
  var RunnerInferenceDeviceSchema = object({
22008
23034
  deviceKey: string(),
22009
23035
  weight: number().positive().default(1),
22010
- maxSessions: number().int().positive().nullable().default(null)
23036
+ maxSessions: number().int().positive().nullable().default(null),
23037
+ /**
23038
+ * Per-step provisioning for this camera on THIS device (D650), keyed by step
23039
+ * id. A step the runner jumps here runs with these fields, never with the
23040
+ * elected device's: `modelId` / `settings` are REPLACED on the jumped subtree
23041
+ * (a step absent from the map runs with neither — the target format default).
23042
+ * Absent field ⇒ an orchestrator that predates D650: the jumped step keeps
23043
+ * the elected device's provisioning, as before.
23044
+ */
23045
+ steps: record(string(), RunnerJumpStepProvisioningSchema).optional()
22011
23046
  });
22012
23047
  /**
22013
23048
  * Camera assignment payload sent by `addon-pipeline-orchestrator` to a
@@ -22882,6 +23917,28 @@ var NodeInferenceDeviceSchema = object({
22882
23917
  */
22883
23918
  exclusion: InferenceDeviceExclusionReasonSchema.nullable()
22884
23919
  });
23920
+ /**
23921
+ * The operator's model choice for one cluster-scoped step, answered by the
23922
+ * addon that OWNS the `clusterModel:*` settings (D651). Three answers, never
23923
+ * folded: a written choice, a key nobody wrote (the cluster runs the default
23924
+ * BY ABSENCE), or no answer. A caller that rewrites an index acts only on the
23925
+ * first two, read twice and agreeing.
23926
+ */
23927
+ var ClusterModelChoiceSchema = discriminatedUnion("kind", [
23928
+ object({
23929
+ kind: literal("stored"),
23930
+ modelId: string()
23931
+ }),
23932
+ object({
23933
+ kind: literal("absent"),
23934
+ defaultModelId: string()
23935
+ }),
23936
+ object({
23937
+ kind: literal("unreadable"),
23938
+ reason: _enum(CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS),
23939
+ error: string().optional()
23940
+ })
23941
+ ]);
22885
23942
  var NodeInferenceDevicesSchema = object({
22886
23943
  nodeId: string(),
22887
23944
  /** False when the node's platform-probe was unreachable (no live device set). */
@@ -22909,10 +23966,17 @@ method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
22909
23966
  }), object({ success: literal(true) }), {
22910
23967
  kind: "mutation",
22911
23968
  auth: "admin"
22912
- }), method(object({ deviceId: number() }), object({ deviceKey: string().nullable() })), method(_void(), object({ migrated: number() }), {
23969
+ }), method(object({ deviceId: number() }), object({ deviceKey: string().nullable() })), method(_void(), object({
23970
+ migrated: number(),
23971
+ skipped: array(object({
23972
+ deviceId: number(),
23973
+ targetNodeId: string(),
23974
+ reason: string()
23975
+ })).default([])
23976
+ }), {
22913
23977
  kind: "mutation",
22914
23978
  auth: "admin"
22915
- }), 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({
23979
+ }), 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({
22916
23980
  nodeId: string(),
22917
23981
  capName: string(),
22918
23982
  addonId: string()
@@ -23127,7 +24191,11 @@ function buildDescriptor(capName, kind) {
23127
24191
  icon: legacyIcon(t.iconId)
23128
24192
  };
23129
24193
  }
23130
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
24194
+ /**
24195
+ * Sensor / control cap name → static event-kind descriptor. A linked device
24196
+ * contributes one entry per bound cap present in this map.
24197
+ */
24198
+ var EVENT_KIND_BY_CAP = Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
23131
24199
  /**
23132
24200
  * server-management — per-NODE singleton capability for a node's ROOT
23133
24201
  * package lifecycle (runtime-updatable node packages).
@@ -25208,6 +26276,177 @@ DeviceType.Camera, method(object({
25208
26276
  auth: "protected"
25209
26277
  });
25210
26278
  /**
26279
+ * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
26280
+ * valutatore puro del suo FRONTE.
26281
+ *
26282
+ * Viveva dentro il builtin virtual-doorbell
26283
+ * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
26284
+ * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
26285
+ * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
26286
+ * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
26287
+ * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
26288
+ * SPOSTA qui e il doorbell la ri-esporta.
26289
+ *
26290
+ * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
26291
+ * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
26292
+ * regola" (e include `presence`, `cover`, `alarm-panel`), questa a "qual è il
26293
+ * booleano il cui FRONTE conta". Vocabolari deliberatamente diversi.
26294
+ */
26295
+ /**
26296
+ * Known binary / switch source caps → the boolean slice field whose
26297
+ * false→true rise counts as ACTIVE. Every entry is "fire on active".
26298
+ * Sensors whose "active" reading is not a plain boolean (presence's string
26299
+ * state, connectivity's connected flag) are deliberately excluded — a
26300
+ * reconnect is not a doorbell press, and it is not a recording either.
26301
+ */
26302
+ var SOURCE_CAP_ACTIVE_FIELD = {
26303
+ contact: "entryOpen",
26304
+ binary: "on",
26305
+ switch: "on",
26306
+ motion: "detected",
26307
+ flood: "flooded",
26308
+ gas: "detected",
26309
+ smoke: "detected",
26310
+ "carbon-monoxide": "detected",
26311
+ vibration: "detected",
26312
+ tamper: "tampered"
26313
+ };
26314
+ object({
26315
+ /** Ms epoch of the last press. null = never observed since this provider started. */
26316
+ lastPressedAt: number().nullable(),
26317
+ /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
26318
+ pressCountSinceStart: number()
26319
+ });
26320
+ object({
26321
+ deviceId: number(),
26322
+ timestamp: number()
26323
+ });
26324
+ /**
26325
+ * The `doorbell-source` extension slot's editable value (D648): the camera's
26326
+ * virtual-doorbell trigger devices, exactly what the wrapper's
26327
+ * `doorbellSources` persists (as `{ deviceId }` records).
26328
+ */
26329
+ var DoorbellSourceSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
26330
+ DeviceType.Camera;
26331
+ DeviceType.Button, DeviceType.Camera;
26332
+ var ExtensionSlotIdSchema = _enum(["doorbell-source", "linked-devices"]);
26333
+ DeviceType.Camera, DeviceType.Camera;
26334
+ /** A slot's editable value, discriminated on `slot`. */
26335
+ var ExtensionSlotValueSchema = discriminatedUnion("slot", [DoorbellSourceSlotValueSchema.extend({ slot: literal("doorbell-source") }), LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
26336
+ DeviceType.Camera;
26337
+ var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
26338
+ state: literal("unreachable"),
26339
+ reason: string()
26340
+ })]);
26341
+ /** One provider of slots — the D554 source-listing row. */
26342
+ var ExtensionSourceSchema = object({
26343
+ /** The routing prefix of every `slotRef` this provider serves. */
26344
+ source: string(),
26345
+ label: string(),
26346
+ /** Stamped by the dispatcher from the registry (D557). */
26347
+ addonId: string().optional(),
26348
+ availability: ExtensionSourceAvailabilitySchema
26349
+ });
26350
+ /**
26351
+ * How one picked source stands. `missing` — no such device (deleted, or an id
26352
+ * that never existed); `foreign` — a device the slot's owner cannot read from
26353
+ * (slice 2's cross-owner graft source); `unavailable` — it exists but is not a
26354
+ * valid source now (a container, which is never a pick). A source in any of
26355
+ * these states is SHOWN, never silently dropped or re-pointed.
26356
+ */
26357
+ var ExtensionSourceHealthSchema = _enum([
26358
+ "ok",
26359
+ "missing",
26360
+ "foreign",
26361
+ "unavailable"
26362
+ ]);
26363
+ var ExtensionSlotSourceSchema = object({
26364
+ deviceId: number().int(),
26365
+ /** The device's name, or null when it could not be resolved (`missing`). */
26366
+ name: string().nullable(),
26367
+ health: ExtensionSourceHealthSchema,
26368
+ detail: string().optional()
26369
+ });
26370
+ /**
26371
+ * A DIFFERENT authority that gates whether the slot's sources do anything —
26372
+ * reported read-only, named, never written through this contract (D62). The
26373
+ * virtual doorbell's sources ring only while the wrapper is bound to the
26374
+ * camera, and that binding belongs to `deviceManager.setWrapperActive`.
26375
+ * `unknown` means the gate could not be read; it is not "inactive" (D315).
26376
+ */
26377
+ var ExtensionSlotActivationSchema = object({
26378
+ state: _enum([
26379
+ "active",
26380
+ "inactive",
26381
+ "unknown"
26382
+ ]),
26383
+ authority: string(),
26384
+ detail: string().optional()
26385
+ });
26386
+ var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
26387
+ state: literal("ok"),
26388
+ /** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
26389
+ slotRef: string(),
26390
+ slot: ExtensionSlotIdSchema,
26391
+ /** Names the store written (D62), e.g. `virtual-doorbell:doorbellSources`. */
26392
+ authority: string(),
26393
+ /** graft: its switch. association: null — removing every source is "off". */
26394
+ enabled: boolean().nullable(),
26395
+ /** graft: the cap registered on the host. association: null. */
26396
+ projects: string().nullable(),
26397
+ activation: ExtensionSlotActivationSchema.nullable(),
26398
+ value: ExtensionSlotValueSchema,
26399
+ sources: array(ExtensionSlotSourceSchema),
26400
+ /**
26401
+ * Devices the owner links to the host ON ITS OWN, by structure, and that
26402
+ * are therefore not in `value` (D655): a camera's device-tree children, and
26403
+ * the child a picked container stands for (D356 — a container is never a
26404
+ * pick, its children are). Read-only; the editor shows them and may offer
26405
+ * per-device options on them (the linked-devices tracked-event opt-in).
26406
+ * Absent when the owner links nothing beyond the picks, and from an owner
26407
+ * older than D655.
26408
+ */
26409
+ impliedSources: array(ExtensionSlotSourceSchema).optional()
26410
+ }), object({
26411
+ state: literal("unreachable"),
26412
+ addonId: string(),
26413
+ reason: string()
26414
+ })]);
26415
+ var ExtensionCandidatesSchema = object({ candidates: array(object({
26416
+ deviceId: number().int(),
26417
+ name: string(),
26418
+ type: string(),
26419
+ location: string().nullable(),
26420
+ /** The container a child belongs to — "Spotlight 2" alone does not say which. */
26421
+ parentName: string().nullable(),
26422
+ /** Pre-marked by the owner's suggestion rule. NEVER saved on its own (D356). */
26423
+ suggested: boolean(),
26424
+ /** Why it is suggested ("same location"), null when it is not. */
26425
+ reason: string().nullable()
26426
+ })) });
26427
+ /**
26428
+ * What a write did. `none` — applied in place. `host` / `parent` — the owner
26429
+ * reloaded the host (or, for an accessory child, its parent) because the
26430
+ * write changed what the host REGISTERS (a graft switched on or off, slice 2).
26431
+ */
26432
+ var ExtensionSetResultSchema = object({
26433
+ applied: literal(true),
26434
+ reload: _enum([
26435
+ "none",
26436
+ "host",
26437
+ "parent"
26438
+ ])
26439
+ });
26440
+ var ExtensionSlotRefInputSchema = object({
26441
+ deviceId: number().int(),
26442
+ slotRef: string().min(1)
26443
+ });
26444
+ var ExtensionSetSlotInputSchema = ExtensionSlotRefInputSchema.extend({ value: ExtensionSlotValueSchema });
26445
+ method(object({ deviceId: number().int() }), array(ExtensionSourceSchema)), method(object({ deviceId: number().int() }), array(ExtensionSlotRowSchema)), method(ExtensionSlotRefInputSchema, ExtensionCandidatesSchema), method(ExtensionSetSlotInputSchema, ExtensionSetResultSchema, {
26446
+ kind: "mutation",
26447
+ auth: "admin"
26448
+ });
26449
+ /**
25211
26450
  * Optional client-side hints sent at session creation to help the provider
25212
26451
  * pick the best native source. All fields optional — a viewer that knows
25213
26452
  * nothing still gets a sane default. (Relocated from the retired `webrtc`
@@ -25309,7 +26548,67 @@ var WebrtcLadderDecisionSchema = object({
25309
26548
  serverSending: boolean().nullable(),
25310
26549
  /** Epoch ms. The overlay prints its age; a decision from 40 minutes ago
25311
26550
  * must not read like one from this second. */
25312
- at: number()
26551
+ at: number(),
26552
+ /** The broker's own cause when it is finer than `cause` can carry, e.g.
26553
+ * `trial-revert` (reported as `stall`/`loss` for older consumers). Optional:
26554
+ * an older server strips it instead of rejecting the answer. */
26555
+ causeDetail: string().optional()
26556
+ });
26557
+ var WebrtcClimbHoldSchema = object({
26558
+ /** `stall-building` — the client receives ≪ what is sent; `delivery` — the
26559
+ * current rung is not landing whole; `no-evidence` — no receiver feedback;
26560
+ * `warming` — healthy, accumulating the streak; `cooldown` — too soon after
26561
+ * a change; `capacity` — a MEASURED probe below the next rung's bar;
26562
+ * `try-unclean` — no capacity evidence, and the path is not clean enough to
26563
+ * try; `try-backoff` — a try reverted, waiting out its backoff; `trial` —
26564
+ * this rung IS a try, reverting if it does not land; `suspended` —
26565
+ * recorded playback on the track. */
26566
+ code: string(),
26567
+ /** The rung a climb would go to. */
26568
+ nextTier: CamProfileSchema,
26569
+ /** Bytes received ÷ bytes sent over the delivery window (≥ one GOP). */
26570
+ deliveryRatio: number().nullable(),
26571
+ deliveryWindowMs: number().nullable(),
26572
+ /** The ratio a climb requires. */
26573
+ climbDeliveryRatio: number(),
26574
+ /** The receiver's bandwidth estimate (REMB), kbps. Capped by what is sent. */
26575
+ capacityKbps: number().nullable(),
26576
+ /** The viewer's downlink probe for this session, kbps. */
26577
+ probeKbps: number().nullable(),
26578
+ /** The next rung's measured bitrate, kbps. */
26579
+ nextTierKbps: number().nullable(),
26580
+ capacityMargin: number(),
26581
+ /** The capacity a climb to `nextTier` needs, kbps (bitrate × margin, or the
26582
+ * client ladder threshold when the rung has measured nothing). */
26583
+ neededKbps: number().nullable(),
26584
+ /** For `try-unclean`: which clean-path condition failed (a `WebrtcTryBlocker`,
26585
+ * carried as a string for the same reason as `code`). */
26586
+ tryBlockedBy: string().nullable(),
26587
+ /** The delivery ratio and the loss ratio a try requires / must stay under.
26588
+ * Optional, like every field added to this schema after it first shipped:
26589
+ * the router validates output, so a REQUIRED new field makes a newer server
26590
+ * reject an older broker's whole answer (review m1). */
26591
+ tryDeliveryRatio: number().optional(),
26592
+ tryMaxLossRatio: number().optional(),
26593
+ /** For `try-backoff`: time until the next try, ms. */
26594
+ retryInMs: number().nullable(),
26595
+ /** The last try that reverted in this viewer session. */
26596
+ lastRevert: object({
26597
+ tier: CamProfileSchema,
26598
+ deliveryRatio: number().nullable(),
26599
+ stalled: boolean(),
26600
+ at: number()
26601
+ }).nullable(),
26602
+ /** For `trial`: how long this rung has been on trial, and for how long it must hold. */
26603
+ trialForMs: number().nullable(),
26604
+ trialMs: number().nullable(),
26605
+ healthyForMs: number().nullable(),
26606
+ requiredHealthyMs: number().nullable(),
26607
+ /** Epoch ms this hold's code began. */
26608
+ since: number(),
26609
+ /** The same one-line account the broker logs, e.g.
26610
+ * `held: delivery 0.97 over 4.0s ok, REMB 480 kbps < mid 1800 kbps × 1.2`. */
26611
+ summary: string()
25313
26612
  });
25314
26613
  /** Per-tier count of MEASURED downgrades this viewer session has suffered. */
25315
26614
  var WebrtcTierFailureSchema = object({
@@ -25373,7 +26672,12 @@ var WebrtcSessionDebugSchema = object({
25373
26672
  tierFailures: array(WebrtcTierFailureSchema),
25374
26673
  /** Successful promotions in this viewer session (drives the progressive
25375
26674
  * healthy timer). Null when no ladder is running. */
25376
- upgradeCount: number().nullable()
26675
+ upgradeCount: number().nullable(),
26676
+ /** Why the ladder is not climbing right now. Null when no ladder runs, it
26677
+ * is at the top rung, or it just moved. Optional because this output is
26678
+ * validated by the router: a server carrying this schema must still accept
26679
+ * the answer of a stream-broker deployed before the field existed. */
26680
+ climbHold: WebrtcClimbHoldSchema.nullable().optional()
25377
26681
  });
25378
26682
  DeviceType.Camera, method(object({ deviceId: number().int().nonnegative() }), array(WebrtcStreamChoiceSchema)), method(object({
25379
26683
  deviceId: number().int().nonnegative(),
@@ -26931,17 +28235,6 @@ object({
26931
28235
  deviceId: number(),
26932
28236
  status: DeviceStatusSchema
26933
28237
  });
26934
- object({
26935
- /** Ms epoch of the last press. null = never observed since this provider started. */
26936
- lastPressedAt: number().nullable(),
26937
- /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
26938
- pressCountSinceStart: number()
26939
- });
26940
- object({
26941
- deviceId: number(),
26942
- timestamp: number()
26943
- });
26944
- DeviceType.Button, DeviceType.Camera;
26945
28238
  /**
26946
28239
  * Enum-state sensor — a string value picked from a finite option set.
26947
28240
  * Drives HA `sensor` entries with `state_class: enum` (HVAC action
@@ -29065,6 +30358,11 @@ var ClientNetworkStatsSchema = object({
29065
30358
  jitterMs: number(),
29066
30359
  estimatedBandwidthKbps: number(),
29067
30360
  packetLossPercent: number().min(0).max(100),
30361
+ /** The viewer's latest `/adaptive-probe` reading, Mbps — whatever it read
30362
+ * (D635 I4). Absent when it never probed or the probe failed (unknown). */
30363
+ downlinkMbps: number().optional(),
30364
+ /** Age of that reading when this report was sent, ms. */
30365
+ downlinkAgeMs: number().optional(),
29068
30366
  lastUpdated: number()
29069
30367
  });
29070
30368
  var DeviceNetworkStatsSchema = object({
@@ -29077,7 +30375,11 @@ method(object({ deviceId: number() }), DeviceNetworkStatsSchema.nullable()), met
29077
30375
  rttMs: number().min(0).max(6e4),
29078
30376
  jitterMs: number().min(0).max(1e4),
29079
30377
  estimatedBandwidthKbps: number().min(0).max(1e6),
29080
- packetLossPercent: number().min(0).max(100)
30378
+ packetLossPercent: number().min(0).max(100),
30379
+ /** Latest downlink probe, Mbps, whatever it read; absent = never / failed. */
30380
+ downlinkMbps: number().min(0).max(1e5).optional(),
30381
+ /** Age of that probe when this report is sent, ms. */
30382
+ downlinkAgeMs: number().min(0).max(864e5).optional()
29081
30383
  }), _void(), { kind: "mutation" });
29082
30384
  /**
29083
30385
  * nodes — system-scoped singleton capability for cluster topology
@@ -29196,7 +30498,30 @@ var RenameNodeResultSchema = object({
29196
30498
  nodeId: string(),
29197
30499
  name: string()
29198
30500
  });
29199
- method(_void(), array(TopologyNodeSchema).readonly(), { auth: "admin" }), method(NodeAddonInputSchema, SuccessSchema, {
30501
+ /**
30502
+ * The cheap node list. A consumer's rule for a STORED node id (a rule's
30503
+ * `nodeIds`) that is missing from `nodes`, whatever `complete` says: render it
30504
+ * as a removable chip labelled unknown, never drop it (D49). Even a complete
30505
+ * list omits a node that joined and left between two history captures, so a
30506
+ * missing id means "not known to the hub", never "removed". Only the operator
30507
+ * removes it.
30508
+ *
30509
+ * `complete` changes only the WORDING: `false` = no history read has ever
30510
+ * answered, so the list may be missing offline nodes the hub does know (D315).
30511
+ *
30512
+ * `name` is the history row's name (≤ 30 s behind a rename), or the id when
30513
+ * the history has none.
30514
+ */
30515
+ var NodeDirectorySchema = object({
30516
+ nodes: array(object({
30517
+ id: string(),
30518
+ name: string(),
30519
+ isHub: boolean(),
30520
+ isOnline: boolean()
30521
+ })).readonly(),
30522
+ complete: boolean()
30523
+ });
30524
+ method(_void(), array(TopologyNodeSchema).readonly(), { auth: "admin" }), method(_void(), NodeDirectorySchema, { auth: "admin" }), method(NodeAddonInputSchema, SuccessSchema, {
29200
30525
  kind: "mutation",
29201
30526
  auth: "admin"
29202
30527
  }), method(NodeAddonInputSchema, SuccessSchema, {
@@ -29965,7 +31290,7 @@ var HardwareInfoSchema = object({
29965
31290
  coral: CoralInfoSchema.nullable().optional()
29966
31291
  });
29967
31292
  var PlatformScoreSchema = object({
29968
- runtime: _enum(["node", "python"]),
31293
+ runtime: literal("python"),
29969
31294
  backend: string(),
29970
31295
  format: _enum([
29971
31296
  "onnx",
@@ -30002,7 +31327,7 @@ var ModelRequirementSchema = object({
30002
31327
  });
30003
31328
  var ResolvedInferenceConfigSchema = object({
30004
31329
  modelId: string(),
30005
- runtime: _enum(["node", "python"]),
31330
+ runtime: literal("python"),
30006
31331
  backend: string(),
30007
31332
  format: ModelFormatSchema,
30008
31333
  reason: string()
@@ -32209,6 +33534,92 @@ DeviceType.Camera, method(object({ deviceId: number() }), SceneMonitorStatusSche
32209
33534
  kind: "mutation",
32210
33535
  auth: "admin"
32211
33536
  });
33537
+ /**
33538
+ * Per-stage gating mode applied to the zones a rule references.
33539
+ *
33540
+ * - `include`: the rule contributes to a **whitelist** for its stage.
33541
+ * When at least one `include` rule fires for a stage, only entities
33542
+ * inside one of those zones pass that stage.
33543
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
33544
+ * Entities inside one of those zones are dropped at that stage.
33545
+ *
33546
+ * `monitor`-style observation (count without filtering) is not a rule
33547
+ * mode — zones without any matching rule are observed naturally by
33548
+ * `zone-analytics` (live snapshot + history), so an "I just want to
33549
+ * count, not filter" use case needs no rule at all.
33550
+ */
33551
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
33552
+ /**
33553
+ * Per-consumer rule that references existing zones (geometry) and
33554
+ * defines how a specific pipeline stage should treat them. Each
33555
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
33556
+ * settings:
33557
+ *
33558
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
33559
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
33560
+ * - future: notification rules, audio gating, etc.
33561
+ *
33562
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
33563
+ * express "ignore motion in ALL of {garden, street}" with a single
33564
+ * rule. `classFilter` narrows the rule to specific object classes —
33565
+ * "drop person detections in the street, but keep cars" is one
33566
+ * `exclude` rule with `classFilter: ['person']`.
33567
+ *
33568
+ * `enabled` is a soft toggle — the operator can keep the rule
33569
+ * configured but inert without deleting it.
33570
+ */
33571
+ var ZoneRuleSchema = object({
33572
+ /** Stable rule id — survives edits, used by the UI for diffing. */
33573
+ id: string(),
33574
+ /** Optional human-readable label rendered in the rule editor. */
33575
+ name: string().optional(),
33576
+ /** Zones this rule targets. The rule's `mode` applies to ALL
33577
+ * listed zones (OR-set: a detection in any one of them counts).
33578
+ * At least one zone id required — a rule with no targets is a
33579
+ * configuration mistake and the form validator rejects it. */
33580
+ zoneIds: array(string()).min(1).readonly(),
33581
+ mode: ZoneRuleModeEnum,
33582
+ /**
33583
+ * Class names this rule applies to. Empty / undefined ⇒ rule
33584
+ * applies to every class. Class strings match the `macroClass`
33585
+ * field on detections (e.g. `person`, `car`, `dog`).
33586
+ */
33587
+ classFilter: array(string()).readonly().optional(),
33588
+ /**
33589
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
33590
+ * required to consider an entity "in the zone". Defaults to the
33591
+ * consumer's stage default when omitted. Kept for back-compat with
33592
+ * existing per-rule overrides; new operators pick the value via
33593
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
33594
+ * set, the lower-level engine reads it as a 0–1 fraction.
33595
+ */
33596
+ overlapThreshold: number().min(0).max(1).optional(),
33597
+ /**
33598
+ * Operator-friendly version of `overlapThreshold` — the percentage
33599
+ * of the detection's bbox that must lie inside the zone for the
33600
+ * rule to match. Documented default is 85%; the engine substitutes
33601
+ * that when the field is omitted (kept optional so existing rules
33602
+ * stored without it stay valid).
33603
+ *
33604
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
33605
+ * rule, the engine prefers `bboxInclusionPct` because it's the
33606
+ * field exposed in the UI. Internally both feed the same gate.
33607
+ */
33608
+ bboxInclusionPct: number().min(0).max(100).optional(),
33609
+ /**
33610
+ * When `true` and a detection has a segmentation mask, use the
33611
+ * mask for overlap instead of the bbox. Detection-stage only;
33612
+ * motion rules ignore this field.
33613
+ */
33614
+ preferMask: boolean().optional(),
33615
+ /**
33616
+ * Soft-toggle: `false` disables the rule without deleting it.
33617
+ * Defaults to `true` so operators creating a rule via the UI
33618
+ * see it active immediately.
33619
+ */
33620
+ enabled: boolean().default(true)
33621
+ });
33622
+ array(ZoneRuleSchema).readonly();
32212
33623
  object({
32213
33624
  /** Whether the script is currently executing. */
32214
33625
  isRunning: boolean(),
@@ -33589,6 +35000,38 @@ DeviceType.Camera, method(object({
33589
35000
  detection: array(ZoneRuleSchema).readonly(),
33590
35001
  package: array(ZoneRuleSchema).readonly()
33591
35002
  });
35003
+ var NUMBER = {
35004
+ kind: "fixed",
35005
+ result: ["number"]
35006
+ };
35007
+ var BOOLEAN = {
35008
+ kind: "fixed",
35009
+ result: ["boolean"]
35010
+ };
35011
+ Object.freeze({
35012
+ min: NUMBER,
35013
+ max: NUMBER,
35014
+ abs: NUMBER,
35015
+ floor: NUMBER,
35016
+ ceil: NUMBER,
35017
+ sqrt: NUMBER,
35018
+ round: NUMBER,
35019
+ pow: NUMBER,
35020
+ clamp: NUMBER,
35021
+ avg: NUMBER,
35022
+ sum: NUMBER,
35023
+ age: NUMBER,
35024
+ convert: NUMBER,
35025
+ coalesce: { kind: "coalesce" },
35026
+ any: BOOLEAN,
35027
+ all: BOOLEAN,
35028
+ within: BOOLEAN,
35029
+ latest: {
35030
+ kind: "fixed",
35031
+ result: ["number", "null"]
35032
+ }
35033
+ });
35034
+ `${COMPOSED_DEVICE_STABLE_ID_PREFIX}`;
33592
35035
  /**
33593
35036
  * Accessory device helpers — shared across drivers.
33594
35037
  *
@@ -35897,6 +37340,18 @@ Object.freeze({
35897
37340
  addonId: null,
35898
37341
  access: "create"
35899
37342
  },
37343
+ "composer.applyBlocks": {
37344
+ capName: "composer",
37345
+ capScope: "system",
37346
+ addonId: null,
37347
+ access: "create"
37348
+ },
37349
+ "composer.getStates": {
37350
+ capName: "composer",
37351
+ capScope: "system",
37352
+ addonId: null,
37353
+ access: "view"
37354
+ },
35900
37355
  "connectionTest.describeTest": {
35901
37356
  capName: "connection-test",
35902
37357
  capScope: "system",
@@ -35957,6 +37412,12 @@ Object.freeze({
35957
37412
  addonId: null,
35958
37413
  access: "create"
35959
37414
  },
37415
+ "coreBlocks.createComposition": {
37416
+ capName: "core-blocks",
37417
+ capScope: "system",
37418
+ addonId: null,
37419
+ access: "create"
37420
+ },
35960
37421
  "coreBlocks.delete": {
35961
37422
  capName: "core-blocks",
35962
37423
  capScope: "system",
@@ -35969,6 +37430,12 @@ Object.freeze({
35969
37430
  addonId: null,
35970
37431
  access: "view"
35971
37432
  },
37433
+ "coreBlocks.getComposition": {
37434
+ capName: "core-blocks",
37435
+ capScope: "system",
37436
+ addonId: null,
37437
+ access: "view"
37438
+ },
35972
37439
  "coreBlocks.getTypeDefs": {
35973
37440
  capName: "core-blocks",
35974
37441
  capScope: "system",
@@ -35981,6 +37448,12 @@ Object.freeze({
35981
37448
  addonId: null,
35982
37449
  access: "view"
35983
37450
  },
37451
+ "coreBlocks.listCompositions": {
37452
+ capName: "core-blocks",
37453
+ capScope: "system",
37454
+ addonId: null,
37455
+ access: "view"
37456
+ },
35984
37457
  "coreBlocks.restart": {
35985
37458
  capName: "core-blocks",
35986
37459
  capScope: "system",
@@ -35999,6 +37472,18 @@ Object.freeze({
35999
37472
  addonId: null,
36000
37473
  access: "create"
36001
37474
  },
37475
+ "coreBlocks.updateComposition": {
37476
+ capName: "core-blocks",
37477
+ capScope: "system",
37478
+ addonId: null,
37479
+ access: "create"
37480
+ },
37481
+ "coreBlocks.validateComposition": {
37482
+ capName: "core-blocks",
37483
+ capScope: "system",
37484
+ addonId: null,
37485
+ access: "view"
37486
+ },
36002
37487
  "cover.close": {
36003
37488
  capName: "cover",
36004
37489
  capScope: "device",
@@ -36389,6 +37874,30 @@ Object.freeze({
36389
37874
  addonId: null,
36390
37875
  access: "create"
36391
37876
  },
37877
+ "deviceExtension.listCandidates": {
37878
+ capName: "device-extension",
37879
+ capScope: "device",
37880
+ addonId: null,
37881
+ access: "view"
37882
+ },
37883
+ "deviceExtension.listSlots": {
37884
+ capName: "device-extension",
37885
+ capScope: "device",
37886
+ addonId: null,
37887
+ access: "view"
37888
+ },
37889
+ "deviceExtension.listSources": {
37890
+ capName: "device-extension",
37891
+ capScope: "device",
37892
+ addonId: null,
37893
+ access: "view"
37894
+ },
37895
+ "deviceExtension.setSlot": {
37896
+ capName: "device-extension",
37897
+ capScope: "device",
37898
+ addonId: null,
37899
+ access: "create"
37900
+ },
36392
37901
  "deviceManager.addLocation": {
36393
37902
  capName: "device-manager",
36394
37903
  capScope: "system",
@@ -36461,12 +37970,6 @@ Object.freeze({
36461
37970
  addonId: null,
36462
37971
  access: "create"
36463
37972
  },
36464
- "deviceManager.applyDeviceSettingsPatch": {
36465
- capName: "device-manager",
36466
- capScope: "system",
36467
- addonId: null,
36468
- access: "create"
36469
- },
36470
37973
  "deviceManager.applyInitialMeta": {
36471
37974
  capName: "device-manager",
36472
37975
  capScope: "system",
@@ -36569,12 +38072,6 @@ Object.freeze({
36569
38072
  addonId: null,
36570
38073
  access: "view"
36571
38074
  },
36572
- "deviceManager.getDeviceLiveContribution": {
36573
- capName: "device-manager",
36574
- capScope: "system",
36575
- addonId: null,
36576
- access: "view"
36577
- },
36578
38075
  "deviceManager.getDeviceLiveInfoAggregate": {
36579
38076
  capName: "device-manager",
36580
38077
  capScope: "system",
@@ -36587,12 +38084,6 @@ Object.freeze({
36587
38084
  addonId: null,
36588
38085
  access: "view"
36589
38086
  },
36590
- "deviceManager.getDeviceSettingsContribution": {
36591
- capName: "device-manager",
36592
- capScope: "system",
36593
- addonId: null,
36594
- access: "view"
36595
- },
36596
38087
  "deviceManager.getDeviceStatusAggregate": {
36597
38088
  capName: "device-manager",
36598
38089
  capScope: "system",
@@ -36659,6 +38150,12 @@ Object.freeze({
36659
38150
  addonId: null,
36660
38151
  access: "view"
36661
38152
  },
38153
+ "deviceManager.listDeviceIdsByCaps": {
38154
+ capName: "device-manager",
38155
+ capScope: "system",
38156
+ addonId: null,
38157
+ access: "view"
38158
+ },
36662
38159
  "deviceManager.listLocationDescriptions": {
36663
38160
  capName: "device-manager",
36664
38161
  capScope: "system",
@@ -37091,24 +38588,6 @@ Object.freeze({
37091
38588
  addonId: null,
37092
38589
  access: "view"
37093
38590
  },
37094
- "doorbell.applyDeviceSettingsPatch": {
37095
- capName: "doorbell",
37096
- capScope: "device",
37097
- addonId: null,
37098
- access: "create"
37099
- },
37100
- "doorbell.getDeviceLiveContribution": {
37101
- capName: "doorbell",
37102
- capScope: "device",
37103
- addonId: null,
37104
- access: "view"
37105
- },
37106
- "doorbell.getDeviceSettingsContribution": {
37107
- capName: "doorbell",
37108
- capScope: "device",
37109
- addonId: null,
37110
- access: "view"
37111
- },
37112
38591
  "doorbell.getStatus": {
37113
38592
  capName: "doorbell",
37114
38593
  capScope: "device",
@@ -37133,6 +38612,12 @@ Object.freeze({
37133
38612
  addonId: null,
37134
38613
  access: "view"
37135
38614
  },
38615
+ "embeddingEncoder.resetFailedModels": {
38616
+ capName: "embedding-encoder",
38617
+ capScope: "system",
38618
+ addonId: null,
38619
+ access: "delete"
38620
+ },
37136
38621
  "enumSensor.getStatus": {
37137
38622
  capName: "enum-sensor",
37138
38623
  capScope: "device",
@@ -37619,12 +39104,30 @@ Object.freeze({
37619
39104
  addonId: null,
37620
39105
  access: "create"
37621
39106
  },
39107
+ "llmRuntime.appleAvailability": {
39108
+ capName: "llm-runtime",
39109
+ capScope: "system",
39110
+ addonId: null,
39111
+ access: "view"
39112
+ },
39113
+ "llmRuntime.cancel": {
39114
+ capName: "llm-runtime",
39115
+ capScope: "system",
39116
+ addonId: null,
39117
+ access: "create"
39118
+ },
37622
39119
  "llmRuntime.complete": {
37623
39120
  capName: "llm-runtime",
37624
39121
  capScope: "system",
37625
39122
  addonId: null,
37626
39123
  access: "create"
37627
39124
  },
39125
+ "llmRuntime.completeApple": {
39126
+ capName: "llm-runtime",
39127
+ capScope: "system",
39128
+ addonId: null,
39129
+ access: "create"
39130
+ },
37628
39131
  "llmRuntime.deleteModel": {
37629
39132
  capName: "llm-runtime",
37630
39133
  capScope: "system",
@@ -38297,6 +39800,12 @@ Object.freeze({
38297
39800
  addonId: null,
38298
39801
  access: "create"
38299
39802
  },
39803
+ "nodes.directory": {
39804
+ capName: "nodes",
39805
+ capScope: "system",
39806
+ addonId: null,
39807
+ access: "view"
39808
+ },
38300
39809
  "nodes.executeQuery": {
38301
39810
  capName: "nodes",
38302
39811
  capScope: "system",
@@ -38465,6 +39974,12 @@ Object.freeze({
38465
39974
  addonId: null,
38466
39975
  access: "view"
38467
39976
  },
39977
+ "notificationRules.getRuleLastRuns": {
39978
+ capName: "notification-rules",
39979
+ capScope: "system",
39980
+ addonId: null,
39981
+ access: "view"
39982
+ },
38468
39983
  "notificationRules.getTemplateCatalog": {
38469
39984
  capName: "notification-rules",
38470
39985
  capScope: "system",
@@ -38489,6 +40004,12 @@ Object.freeze({
38489
40004
  addonId: null,
38490
40005
  access: "view"
38491
40006
  },
40007
+ "notificationRules.previewStateSummary": {
40008
+ capName: "notification-rules",
40009
+ capScope: "system",
40010
+ addonId: null,
40011
+ access: "view"
40012
+ },
38492
40013
  "notificationRules.previewTemplate": {
38493
40014
  capName: "notification-rules",
38494
40015
  capScope: "system",
@@ -39065,12 +40586,6 @@ Object.freeze({
39065
40586
  addonId: null,
39066
40587
  access: "create"
39067
40588
  },
39068
- "pipelineAnalytics.runReplayFrameProcessor": {
39069
- capName: "pipeline-analytics",
39070
- capScope: "device",
39071
- addonId: null,
39072
- access: "create"
39073
- },
39074
40589
  "pipelineAnalytics.saveRetrainAnnotations": {
39075
40590
  capName: "pipeline-analytics",
39076
40591
  capScope: "device",
@@ -39437,6 +40952,12 @@ Object.freeze({
39437
40952
  addonId: null,
39438
40953
  access: "view"
39439
40954
  },
40955
+ "pipelineOrchestrator.getClusterModelChoice": {
40956
+ capName: "pipeline-orchestrator",
40957
+ capScope: "system",
40958
+ addonId: null,
40959
+ access: "view"
40960
+ },
39440
40961
  "pipelineOrchestrator.getDeviceLiveContribution": {
39441
40962
  capName: "pipeline-orchestrator",
39442
40963
  capScope: "system",
@@ -42262,6 +43783,26 @@ Object.freeze({
42262
43783
  form: "single",
42263
43784
  optional: false
42264
43785
  }],
43786
+ "deviceExtension.listCandidates": [{
43787
+ name: "deviceId",
43788
+ form: "single",
43789
+ optional: false
43790
+ }],
43791
+ "deviceExtension.listSlots": [{
43792
+ name: "deviceId",
43793
+ form: "single",
43794
+ optional: false
43795
+ }],
43796
+ "deviceExtension.listSources": [{
43797
+ name: "deviceId",
43798
+ form: "single",
43799
+ optional: false
43800
+ }],
43801
+ "deviceExtension.setSlot": [{
43802
+ name: "deviceId",
43803
+ form: "single",
43804
+ optional: false
43805
+ }],
42265
43806
  "deviceManager.adoptionRelease": [{
42266
43807
  name: "camDeviceId",
42267
43808
  form: "single",
@@ -43168,11 +44709,6 @@ Object.freeze({
43168
44709
  form: "single",
43169
44710
  optional: false
43170
44711
  }],
43171
- "pipelineAnalytics.runReplayFrameProcessor": [{
43172
- name: "deviceId",
43173
- form: "single",
43174
- optional: false
43175
- }],
43176
44712
  "pipelineAnalytics.saveRetrainAnnotations": [{
43177
44713
  name: "deviceId",
43178
44714
  form: "single",
@@ -44268,11 +45804,232 @@ function prepareNotification(caps, n) {
44268
45804
  renderedAs
44269
45805
  };
44270
45806
  }
45807
+ /**
45808
+ * WHICH narrowing filter speaks about WHICH system-event kind — one predicate,
45809
+ * consumed by the rule ENGINE and by every rule EDITOR.
45810
+ *
45811
+ * ── The failure this file exists for ───────────────────────────────────────
45812
+ * `NcSystemEventConditionSchema` carries four optional narrowing lists
45813
+ * (`deviceIds`, `deviceTypes`, `nodeIds`, `packageNames`) beside a required
45814
+ * `kinds` gate. They are not four filters over one vocabulary: each belongs to
45815
+ * a FAMILY of kinds and is meaningless outside it. A node going away has no
45816
+ * device type; a completed export has no package; `stream-offline` deliberately
45817
+ * carries no device type at all (a stream belongs to a camera by construction).
45818
+ *
45819
+ * The engine applied all four to every kind, so a filter from one family failed
45820
+ * a kind from another family CLOSED. The operator's live rule "Eventi di
45821
+ * sistema" selected eleven kinds and set `deviceTypes: ['camera']` — the only
45822
+ * way to say "only my cameras" about the two liveness kinds — and NINE of the
45823
+ * eleven silently stopped being deliverable. Four days of history contained
45824
+ * `device-online` and `device-offline` and nothing else, across a window in
45825
+ * which agents were restarted and addons were updated.
45826
+ *
45827
+ * Both editors already computed this scoping, to decide which filter boxes to
45828
+ * render; the cap's own docblock already promised it ("Narrow a `device-*` kind
45829
+ * to these device TYPES"). Only the engine disagreed, and it disagreed in the
45830
+ * destructive direction. So the rule is stated ONCE, here, and the engine and
45831
+ * the editors are readers of it rather than three independent authors.
45832
+ *
45833
+ * ── The direction ─────────────────────────────────────────────────────────
45834
+ * Out of family ⇒ the filter is IGNORED, never fail-closed. An editor that
45835
+ * hides a box has already told the operator this filter does not speak about
45836
+ * these kinds, so honouring it as an exclusion contradicts the only
45837
+ * explanation the operator was ever given. Inside its family the filter still
45838
+ * narrows, and still fails CLOSED on a subject that cannot produce the identity
45839
+ * it tests (a device the mirror cannot name is not evidence of a camera).
45840
+ */
45841
+ /**
45842
+ * Every filter, for the callers that must cover all of them (guards, tests).
45843
+ *
45844
+ * `consumableLowPercent` (D642) is not a list but it is a filter in exactly
45845
+ * this sense: it belongs to a family of kinds (the consumable pair) and the
45846
+ * engine consults it only there. It differs in one way the readers must know —
45847
+ * its ABSENCE is not "no narrowing" but the default threshold, because a
45848
+ * consumable episode is always judged at SOME threshold.
45849
+ */
45850
+ var NC_SYSTEM_EVENT_FILTER_KEYS = [
45851
+ "deviceIds",
45852
+ "deviceTypes",
45853
+ "nodeIds",
45854
+ "packageNames",
45855
+ "consumableLowPercent"
45856
+ ];
45857
+ new Map(Object.entries({
45858
+ "device-online": "device-events",
45859
+ "device-offline": "device-events",
45860
+ "device-disabled": "device-events",
45861
+ "device-enabled": "device-events",
45862
+ "device-battery-low": "device-events",
45863
+ "device-battery-normal": "device-events",
45864
+ "device-consumable-low": "device-events",
45865
+ "device-consumable-normal": "device-events",
45866
+ "device-tank-low": "device-events",
45867
+ "device-tank-full": "device-events",
45868
+ "device-tank-normal": "device-events",
45869
+ "stream-online": "device-events",
45870
+ "stream-offline": "device-events",
45871
+ "detection-blind": "device-events",
45872
+ "node-online": "system",
45873
+ "node-offline": "system",
45874
+ "node-inference-unavailable": "system",
45875
+ "addon-crash-loop": "system",
45876
+ "addon-update-available": "system",
45877
+ "addon-updated": "system",
45878
+ "server-update-available": "system",
45879
+ "server-updated": "system",
45880
+ "wrapper-update-available": "system",
45881
+ "backup-completed": "system",
45882
+ "export-completed": "system",
45883
+ "alarm-triggered": "alarm",
45884
+ "alarm-armed": "alarm",
45885
+ "alarm-disarmed": "alarm",
45886
+ "alarm-arming": "alarm",
45887
+ "alarm-arm-refused": "alarm",
45888
+ "alarm-pending": "alarm",
45889
+ "alarm-rearmed": "alarm",
45890
+ "alarm-sensor-bypass": "alarm",
45891
+ "alarm-check-failed": "alarm",
45892
+ "camera-online": null,
45893
+ "camera-offline": null,
45894
+ "camera-disabled": null,
45895
+ "camera-enabled": null
45896
+ }));
45897
+ [...NC_SYSTEM_EVENT_FILTER_KEYS];
45898
+ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
45899
+ {
45900
+ id: "device-state",
45901
+ family: "device-events",
45902
+ label: "Device state",
45903
+ kinds: [
45904
+ "device-offline",
45905
+ "device-online",
45906
+ "device-disabled",
45907
+ "device-enabled"
45908
+ ]
45909
+ },
45910
+ {
45911
+ id: "streams",
45912
+ family: "device-events",
45913
+ label: "Streams",
45914
+ kinds: ["stream-offline", "stream-online"]
45915
+ },
45916
+ {
45917
+ id: "battery",
45918
+ family: "device-events",
45919
+ label: "Battery",
45920
+ kinds: ["device-battery-low", "device-battery-normal"]
45921
+ },
45922
+ {
45923
+ id: "consumables",
45924
+ family: "device-events",
45925
+ label: "Consumables",
45926
+ kinds: ["device-consumable-low", "device-consumable-normal"]
45927
+ },
45928
+ {
45929
+ id: "tanks",
45930
+ family: "device-events",
45931
+ label: "Tanks",
45932
+ kinds: [
45933
+ "device-tank-low",
45934
+ "device-tank-full",
45935
+ "device-tank-normal"
45936
+ ]
45937
+ },
45938
+ {
45939
+ id: "detection-blind",
45940
+ family: "device-events",
45941
+ label: "Detecting nothing",
45942
+ kinds: ["detection-blind"]
45943
+ },
45944
+ {
45945
+ id: "nodes",
45946
+ family: "system",
45947
+ label: "Nodes",
45948
+ kinds: [
45949
+ "node-offline",
45950
+ "node-online",
45951
+ "node-inference-unavailable"
45952
+ ]
45953
+ },
45954
+ {
45955
+ id: "addons",
45956
+ family: "system",
45957
+ label: "Addons",
45958
+ kinds: [
45959
+ "addon-crash-loop",
45960
+ "addon-update-available",
45961
+ "addon-updated"
45962
+ ]
45963
+ },
45964
+ {
45965
+ id: "updates",
45966
+ family: "system",
45967
+ label: "Server & container updates",
45968
+ kinds: [
45969
+ "server-update-available",
45970
+ "server-updated",
45971
+ "wrapper-update-available"
45972
+ ]
45973
+ },
45974
+ {
45975
+ id: "backups-exports",
45976
+ family: "system",
45977
+ label: "Backups & exports",
45978
+ kinds: ["backup-completed", "export-completed"]
45979
+ },
45980
+ {
45981
+ id: "alarm",
45982
+ family: "alarm",
45983
+ label: "Alarm",
45984
+ kinds: NC_ALARM_SYSTEM_EVENT_KINDS
45985
+ }
45986
+ ];
45987
+ function systemEventKindsOfFamily(family) {
45988
+ return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
45989
+ }
44271
45990
  NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
45991
+ /**
45992
+ * WHICH WAY A BOOLEAN SENSOR MOVED — read off the one slice a sensor event
45993
+ * persists (D640 "a sensor rule fires on the raise, the clear, or both").
45994
+ *
45995
+ * A device-event rule over a flood sensor notified on BOTH edges: water
45996
+ * detected, and back to dry. `NcConditions.sensorTransition` lets the rule
45997
+ * name one edge; this file answers, for one `SensorEvent`, which edge it is.
45998
+ *
45999
+ * NOT A SECOND TABLE. The "which boolean of this cap counts as HIGH" question
46000
+ * already has one answer, `SOURCE_CAP_ACTIVE_FIELD`
46001
+ * (`catalogs/sensor-active-state.ts`, the doorbell's and the recorder's edge
46002
+ * table), and a sensor event names its kind, not its cap. So the table here is
46003
+ * DERIVED: event kind → cap (`EVENT_KIND_BY_CAP`) → that cap's active field.
46004
+ * Only kinds whose taxonomy category is `sensor` take part — a switch has an
46005
+ * `on` boolean too, but "it triggers / it clears" is not a sentence about a
46006
+ * light, and offering it there would be a knob with a misleading label.
46007
+ * `presence` is a WORD (`home` / `not_home` / a zone), not a boolean, and is
46008
+ * absent from the source table, so it is absent here.
46009
+ *
46010
+ * `undefined` = never guessed: a kind with no raise (a doorbell press, a
46011
+ * button, a cover), or a slice whose field is missing or not a boolean. The
46012
+ * engine then does NOT filter — a flood alert must not go silent because one
46013
+ * read came back unreadable (the same stance as the alarm's `sensorEdgeOf`).
46014
+ *
46015
+ * Pure, RN-safe: the viewer imports the support rule from here.
46016
+ */
46017
+ /** Event kind → the boolean field of its cap slice that means "raised". */
46018
+ var NC_SENSOR_RAISED_FIELD_BY_KIND = Object.freeze(Object.fromEntries(Object.entries(EVENT_KIND_BY_CAP).flatMap(([capName, descriptor]) => {
46019
+ const field = SOURCE_CAP_ACTIVE_FIELD[capName];
46020
+ if (field === void 0 || descriptor.category !== "sensor") return [];
46021
+ return [[descriptor.kind, field]];
46022
+ })));
46023
+ Object.freeze(Object.keys(NC_SENSOR_RAISED_FIELD_BY_KIND));
44272
46024
  var RULE_BODY_ONLY = ["body"];
44273
46025
  var RULE_TEXT = ["title", "body"];
44274
46026
  var BATTERY = ["device-battery-low", "device-battery-normal"];
44275
46027
  var CONSUMABLE = ["device-consumable-low", "device-consumable-normal"];
46028
+ var TANK = [
46029
+ "device-tank-low",
46030
+ "device-tank-full",
46031
+ "device-tank-normal"
46032
+ ];
44276
46033
  var UPDATES = [
44277
46034
  "addon-update-available",
44278
46035
  "server-update-available",
@@ -44298,12 +46055,189 @@ var DEVICE_EVENTS = [
44298
46055
  "device-enabled",
44299
46056
  ...BATTERY,
44300
46057
  ...CONSUMABLE,
46058
+ ...TANK,
44301
46059
  "stream-online",
44302
46060
  "stream-offline",
44303
46061
  "detection-blind",
44304
46062
  ...ALARM
44305
46063
  ];
44306
- [...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];
46064
+ /** Every kind a summary may speak about — the two summarisable families. */
46065
+ var SUMMARISABLE = [...systemEventKindsOfFamily("device-events"), ...systemEventKindsOfFamily("system")];
46066
+ /** One per summary SECTION (`NC_STATE_SUMMARY_SECTIONS` in the notification
46067
+ * centre): the section's lines, offered when one of its kinds is selected. */
46068
+ var STATE_SUMMARY_SECTION_VARS = [
46069
+ {
46070
+ name: "summaryDevices",
46071
+ label: "Summary: devices offline / switched off",
46072
+ example: "Garage — offline since 07:12",
46073
+ kinds: [
46074
+ "device-offline",
46075
+ "device-online",
46076
+ "device-disabled",
46077
+ "device-enabled"
46078
+ ]
46079
+ },
46080
+ {
46081
+ name: "summaryStreams",
46082
+ label: "Summary: streams offline",
46083
+ example: "Ingresso (high) — since 06:40",
46084
+ kinds: ["stream-offline", "stream-online"]
46085
+ },
46086
+ {
46087
+ name: "summaryBattery",
46088
+ label: "Summary: low batteries",
46089
+ example: "Sensore porta — 8 %",
46090
+ kinds: BATTERY
46091
+ },
46092
+ {
46093
+ name: "summaryConsumables",
46094
+ label: "Summary: consumables",
46095
+ example: "Robot — filter 10 %",
46096
+ kinds: CONSUMABLE
46097
+ },
46098
+ {
46099
+ name: "summaryTanks",
46100
+ label: "Summary: tanks",
46101
+ example: "Robot — clean water low",
46102
+ kinds: TANK
46103
+ },
46104
+ {
46105
+ name: "summaryDetection",
46106
+ label: "Summary: cameras detecting nothing",
46107
+ example: "Ingresso — since 05:10",
46108
+ kinds: ["detection-blind"]
46109
+ },
46110
+ {
46111
+ name: "summaryNodes",
46112
+ label: "Summary: nodes",
46113
+ example: "little-unraid — offline since 03:00",
46114
+ kinds: [
46115
+ "node-offline",
46116
+ "node-online",
46117
+ "node-inference-unavailable"
46118
+ ]
46119
+ },
46120
+ {
46121
+ name: "summaryAddons",
46122
+ label: "Summary: addons",
46123
+ example: "@camstack/addon-recorder 1.2.3 → 1.2.4",
46124
+ kinds: [
46125
+ "addon-crash-loop",
46126
+ "addon-update-available",
46127
+ "addon-updated"
46128
+ ]
46129
+ },
46130
+ {
46131
+ name: "summaryUpdates",
46132
+ label: "Summary: server & container updates",
46133
+ example: "server 1.2.377 → 1.2.378",
46134
+ kinds: [
46135
+ "server-update-available",
46136
+ "server-updated",
46137
+ "wrapper-update-available"
46138
+ ]
46139
+ }
46140
+ ];
46141
+ var STATE_SUMMARY_VARS = [
46142
+ {
46143
+ name: "summaryText",
46144
+ label: "Summary: every section",
46145
+ description: "One block per section with something to report, one line per item.",
46146
+ example: "Batterie scariche: Sensore porta — 8 %",
46147
+ group: "system",
46148
+ families: ["rule"],
46149
+ fields: [...RULE_TEXT],
46150
+ kinds: ["system"],
46151
+ systemEventKinds: [...SUMMARISABLE],
46152
+ systemEventDeliveries: ["summary"]
46153
+ },
46154
+ {
46155
+ name: "summaryCount",
46156
+ label: "Summary: items reported",
46157
+ example: "3",
46158
+ group: "system",
46159
+ families: ["rule"],
46160
+ fields: [...RULE_TEXT],
46161
+ kinds: ["system"],
46162
+ systemEventKinds: [...SUMMARISABLE],
46163
+ systemEventDeliveries: ["summary"]
46164
+ },
46165
+ ...STATE_SUMMARY_SECTION_VARS.map((v) => ({
46166
+ name: v.name,
46167
+ label: v.label,
46168
+ example: v.example,
46169
+ group: "system",
46170
+ families: ["rule"],
46171
+ fields: [...RULE_TEXT],
46172
+ kinds: ["system"],
46173
+ systemEventKinds: [...v.kinds],
46174
+ systemEventDeliveries: ["summary"]
46175
+ }))
46176
+ ];
46177
+ [
46178
+ [...DEVICE_EVENTS],
46179
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
46180
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
46181
+ [...RULE_TEXT],
46182
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
46183
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
46184
+ [...RULE_TEXT],
46185
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
46186
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
46187
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
46188
+ [...RULE_TEXT],
46189
+ [...RULE_TEXT],
46190
+ [...RULE_TEXT],
46191
+ [...RULE_TEXT],
46192
+ [...RULE_TEXT],
46193
+ [...RULE_TEXT],
46194
+ [...RULE_TEXT],
46195
+ [...RULE_TEXT],
46196
+ [...RULE_BODY_ONLY],
46197
+ [...RULE_TEXT],
46198
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
46199
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
46200
+ ([...RULE_TEXT], [...BATTERY, ...CONSUMABLE]),
46201
+ ([...RULE_TEXT], [...CONSUMABLE]),
46202
+ ([...RULE_TEXT], [...TANK]),
46203
+ [...RULE_TEXT],
46204
+ ([...RULE_TEXT], [...UPDATES]),
46205
+ ([...RULE_TEXT], [...UPDATES]),
46206
+ [...RULE_TEXT],
46207
+ [...RULE_TEXT],
46208
+ [...RULE_TEXT],
46209
+ ([...RULE_TEXT], [...UPDATES]),
46210
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
46211
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
46212
+ ([...RULE_TEXT], [...UPDATES]),
46213
+ ([...RULE_TEXT], [...UPDATES]),
46214
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
46215
+ [...RULE_TEXT],
46216
+ [...RULE_TEXT],
46217
+ [...RULE_TEXT],
46218
+ [...RULE_TEXT],
46219
+ [...RULE_TEXT],
46220
+ [...RULE_TEXT],
46221
+ [...RULE_TEXT],
46222
+ [...RULE_TEXT],
46223
+ [...RULE_TEXT],
46224
+ [...RULE_TEXT],
46225
+ [...RULE_TEXT],
46226
+ [...RULE_TEXT],
46227
+ [...RULE_TEXT],
46228
+ [...RULE_TEXT],
46229
+ [...RULE_TEXT],
46230
+ [...RULE_TEXT],
46231
+ [...RULE_TEXT],
46232
+ [...RULE_TEXT],
46233
+ [...RULE_TEXT],
46234
+ [...RULE_TEXT],
46235
+ [...RULE_TEXT],
46236
+ [...RULE_TEXT],
46237
+ [...RULE_TEXT],
46238
+ [...RULE_TEXT],
46239
+ ...STATE_SUMMARY_VARS
46240
+ ];
44307
46241
  /**
44308
46242
  * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
44309
46243
  *
@@ -44535,68 +46469,6 @@ TimelapseRuleInputSchema.extend({
44535
46469
  createdAt: number(),
44536
46470
  updatedAt: number()
44537
46471
  });
44538
- Object.freeze(Object.fromEntries([{
44539
- stepId: "face-embedding",
44540
- label: "Face recognition model",
44541
- defaultModelId: "arcface-r100",
44542
- indexName: "the enrolled face gallery",
44543
- options: [
44544
- {
44545
- id: "arcface-r100",
44546
- label: "ArcFace (ResNet34)"
44547
- },
44548
- {
44549
- id: "auraface-r100",
44550
- label: "AuraFace R100"
44551
- },
44552
- {
44553
- id: "inception-resnet-v1",
44554
- label: "Inception ResNet V1"
44555
- }
44556
- ]
44557
- }, {
44558
- stepId: "clip-embedding",
44559
- label: "Semantic search model",
44560
- defaultModelId: "mobileclip-s1",
44561
- indexName: "the object semantic-search index",
44562
- options: [{
44563
- id: "mobileclip-s1",
44564
- label: "MobileCLIP S1"
44565
- }, {
44566
- id: "mobileclip-s2",
44567
- label: "MobileCLIP S2"
44568
- }]
44569
- }].map((s) => [s.stepId, s.defaultModelId])));
44570
- string().min(1);
44571
- var CLUSTER_STEP_SETTING_FIELDS = [{
44572
- stepId: "face-embedding",
44573
- key: "minLandmarkFaceSize",
44574
- label: "Min face size for recognition (detection px)",
44575
- 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.",
44576
- type: "slider",
44577
- min: 0,
44578
- max: 64,
44579
- step: 2,
44580
- default: 24
44581
- }];
44582
- function clusterStepSettingKey(stepId, fieldKey) {
44583
- return `clusterStepSetting:${stepId}:${fieldKey}`;
44584
- }
44585
- var ClusterSettingNumberSchema = number().finite();
44586
- function readClusterStepSettings(config) {
44587
- const out = {};
44588
- for (const field of CLUSTER_STEP_SETTING_FIELDS) {
44589
- const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
44590
- const value = parsed.success ? parsed.data : field.default;
44591
- const existing = out[field.stepId] ?? {};
44592
- out[field.stepId] = {
44593
- ...existing,
44594
- [field.key]: value
44595
- };
44596
- }
44597
- return out;
44598
- }
44599
- readClusterStepSettings({});
44600
46472
  object({
44601
46473
  /**
44602
46474
  * Fraction of the box's own size added on EACH side before cutting.
@@ -45170,14 +47042,6 @@ function configSchema$1() {
45170
47042
  key: "adminToken",
45171
47043
  label: "Client/Admin Token (optional)",
45172
47044
  description: "A client token used only for discovery (GET /application). Leave blank to add applications manually."
45173
- },
45174
- {
45175
- type: "boolean",
45176
- key: "verifyTls",
45177
- label: "Verify TLS certificate",
45178
- style: "switch",
45179
- default: true,
45180
- description: "Disable only for a self-hosted server with a self-signed certificate."
45181
47045
  }
45182
47046
  ]
45183
47047
  }, {
@@ -45279,7 +47143,7 @@ function buildExtras(prepared) {
45279
47143
  }
45280
47144
  var gotifyAdapter = {
45281
47145
  descriptor: gotifyDescriptor(),
45282
- destinationKeys: ["serverUrl", "verifyTls"],
47146
+ destinationKeys: ["serverUrl"],
45283
47147
  buildRequest: (config, prepared) => {
45284
47148
  const serverUrl = readString$3(config, "serverUrl");
45285
47149
  if (!serverUrl) throw new Error("gotify: serverUrl is required");