@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.mjs CHANGED
@@ -5363,7 +5363,7 @@ var ZodIssueCode = {
5363
5363
  var ZodFirstPartyTypeKind;
5364
5364
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5365
5365
  //#endregion
5366
- //#region ../types/dist/sleep-D_4W7xuQ.mjs
5366
+ //#region ../types/dist/sleep-DC-wdyeS.mjs
5367
5367
  /**
5368
5368
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5369
5369
  * window to float samples (D455).
@@ -6148,6 +6148,40 @@ var BaseAddon = class {
6148
6148
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6149
6149
  return keys.size > 0 ? projectStore(raw, keys, node) : raw;
6150
6150
  }
6151
+ /**
6152
+ * Whether ONE global key of this addon's store was written, read three-way
6153
+ * (D651). For a question a hydrated view cannot answer: `getGlobalSettings`
6154
+ * reports `value ?? default`, so "the operator chose the default" and "nobody
6155
+ * chose" look the same, and a failed read looks like both. A `perNode` key is
6156
+ * not supported here: its stored name is scoped.
6157
+ */
6158
+ async readStoredGlobalKey(key) {
6159
+ const read = this._ctx?.settings?.readAddonStoreResult;
6160
+ if (read === void 0) return {
6161
+ kind: "unreadable",
6162
+ reason: "three-way-read-unavailable"
6163
+ };
6164
+ let result;
6165
+ try {
6166
+ result = await read.call(this._ctx?.settings);
6167
+ } catch (err) {
6168
+ return {
6169
+ kind: "unreadable",
6170
+ reason: "store-read-failed",
6171
+ error: err instanceof Error ? err.message : String(err)
6172
+ };
6173
+ }
6174
+ if (result.kind === "failed") return {
6175
+ kind: "unreadable",
6176
+ reason: "store-read-failed",
6177
+ error: result.error
6178
+ };
6179
+ if (result.kind === "missing" || !Object.prototype.hasOwnProperty.call(result.value, key)) return { kind: "absent" };
6180
+ return {
6181
+ kind: "present",
6182
+ value: result.value[key]
6183
+ };
6184
+ }
6151
6185
  async updateGlobalSettings(patch, nodeId) {
6152
6186
  const keys = this.perNodeKeys();
6153
6187
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
@@ -9529,6 +9563,43 @@ var LogChannelWindowSchema = object({
9529
9563
  /** `null` = every camera. A non-empty list narrows to those numeric ids. */
9530
9564
  deviceIds: array(number().int()).readonly().nullable()
9531
9565
  });
9566
+ var ClipModelMetaSchema = object({
9567
+ /** The paired text encoder's catalog id (the embedding-encoder's text catalog). */
9568
+ textModelId: string().min(1),
9569
+ /** Output dimension of BOTH towers. A vector of any other length is refused. */
9570
+ embeddingDim: number().int().positive(),
9571
+ /**
9572
+ * The `vector-store` index this model's vectors live in. ONE feature space
9573
+ * per index: two models share an index only when their vectors are ranked
9574
+ * against each other, which for CLIP means never across families. MobileCLIP
9575
+ * S1 and S2 share `object-clip` for history (separated by the row's
9576
+ * `modelId`); any other model gets its own.
9577
+ */
9578
+ vectorIndex: string().regex(/^object-clip(-[a-z0-9][a-z0-9-]*)?$/),
9579
+ /**
9580
+ * The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
9581
+ * must be unique per tokenizer: every model's siblings land in ONE flat
9582
+ * models directory, so two different tokenizers under the same name would
9583
+ * silently overwrite each other (whichever model downloaded last wins, and
9584
+ * the other one tokenises with the wrong vocabulary).
9585
+ */
9586
+ tokenizerFile: string().min(1),
9587
+ /** Token window the text graph takes (SigLIP2: 64; CLIP BPE: 77). */
9588
+ contextLength: number().int().positive(),
9589
+ /** Id the tokenizer pads with. */
9590
+ padId: number().int().nonnegative(),
9591
+ /**
9592
+ * The search cosine floor at `strictness: 'loose'` — calibrated per model,
9593
+ * because cosine bands are a property of the model: 0.2 keeps 96% of matched
9594
+ * COCO caption-image pairs on MobileCLIP S1 and 2.7% on SigLIP2.
9595
+ */
9596
+ searchMinScore: number().min(0).max(1)
9597
+ });
9598
+ var ClipSearchStrictnessSchema = _enum([
9599
+ "loose",
9600
+ "balanced",
9601
+ "strict"
9602
+ ]);
9532
9603
  var MODEL_FORMATS = [
9533
9604
  "onnx",
9534
9605
  "coreml",
@@ -9557,7 +9628,7 @@ var ModelFormatEntrySchema = object({
9557
9628
  /** Multi-file payload (directory members or sibling files). */
9558
9629
  files: array(string()).readonly().optional(),
9559
9630
  /** Runtime(s) that can use this format. If omitted, inferred from ModelFormat key */
9560
- runtimes: array(_enum(["node", "python"])).readonly().optional()
9631
+ runtimes: array(_enum(["python"])).readonly().optional()
9561
9632
  });
9562
9633
  /**
9563
9634
  * Extra file that must be downloaded alongside the model (e.g., labels JSON, dict.txt).
@@ -9618,6 +9689,48 @@ var ModelProviderIdSchema = _enum([
9618
9689
  "scrypted",
9619
9690
  "custom"
9620
9691
  ]);
9692
+ /**
9693
+ * The licence of a model, as a record rather than a bare SPDX string: a
9694
+ * permissive CODE licence routinely sits on top of restrictive WEIGHTS or
9695
+ * DATA, and the obligations (attribution, modification notices, source offers)
9696
+ * are per upstream. A persisted custom-model row written when this field was a
9697
+ * string still parses — the string is lifted into `{ weights }`.
9698
+ *
9699
+ * Every licence surface (the admin "Models and licenses" page,
9700
+ * `THIRD_PARTY_MODELS.md`, the Hugging Face model table) is GENERATED from
9701
+ * these records by `scripts/gen-model-licenses.ts` (D661).
9702
+ */
9703
+ var ModelLicenseSchema = preprocess((value) => typeof value === "string" ? { weights: value } : value, object({
9704
+ /** SPDX id of the WEIGHTS' terms, a `LicenseRef-*` for non-SPDX terms, or `UNKNOWN`. */
9705
+ weights: string().min(1),
9706
+ /** SPDX id of the upstream code that defines / trained the network. */
9707
+ code: string().min(1).optional(),
9708
+ /** Training data whose terms add obligations (attribution, non-commercial). */
9709
+ data: object({
9710
+ name: string().min(1),
9711
+ terms: string().min(1),
9712
+ url: string().url().optional()
9713
+ }).optional(),
9714
+ /** The project the weights come from. Required on built-in entries (guard). */
9715
+ upstream: object({
9716
+ name: string().min(1),
9717
+ url: string().url()
9718
+ }).optional(),
9719
+ /** Where the licence text governing the weights is published. */
9720
+ url: string().url().optional(),
9721
+ /** Attribution the licence REQUIRES, verbatim. */
9722
+ attribution: string().min(1).optional(),
9723
+ /** What CamStack changed. Required when `hosting` is `camstack-hf` (guard). */
9724
+ modifications: string().min(1).optional(),
9725
+ /** Who serves the file a node downloads. */
9726
+ hosting: _enum([
9727
+ "camstack-hf",
9728
+ "third-party",
9729
+ "built-in"
9730
+ ]).optional(),
9731
+ /** True when the weights or their data forbid commercial use. */
9732
+ nonCommercial: boolean().optional()
9733
+ }));
9621
9734
  var ModelCatalogEntrySchema = object({
9622
9735
  id: string(),
9623
9736
  name: string(),
@@ -9638,10 +9751,17 @@ var ModelCatalogEntrySchema = object({
9638
9751
  inputChannels: number().int().positive().optional(),
9639
9752
  labels: array(LabelDefinitionSchema).readonly(),
9640
9753
  inputLayout: _enum(["nchw", "nhwc"]).optional(),
9754
+ /**
9755
+ * `'scrfd'` applies InsightFace's SCRFD input contract, `(x - 127.5) / 128`
9756
+ * (upstream `insightface/model_zoo/scrfd.py`), instead of the historical
9757
+ * plain `/255`. Measured against COCO GT: 188 → 196 faces found on the
9758
+ * `scrfd-2.5g` catalog entry (2026-09-26 model-replacement spike, §2.4-2).
9759
+ */
9641
9760
  inputNormalization: _enum([
9642
9761
  "zero-one",
9643
9762
  "imagenet",
9644
- "none"
9763
+ "none",
9764
+ "scrfd"
9645
9765
  ]).optional(),
9646
9766
  /**
9647
9767
  * The model already applies softmax IN-GRAPH — its raw output is a
@@ -9699,11 +9819,11 @@ var ModelCatalogEntrySchema = object({
9699
9819
  p95LatencyMs: record(string(), number()).optional()
9700
9820
  }).optional(),
9701
9821
  /**
9702
- * SPDX-ish license id of the model weights (e.g. `AGPL-3.0` for Ultralytics
9703
- * YOLO26, `GPL-3.0` for YOLOv9, `Apache-2.0` for D-FINE/RF-DETR). Matters for
9704
- * the retraining addon and any future commercial distribution.
9822
+ * The model's licence record — see {@link ModelLicenseSchema}. Optional in
9823
+ * the schema (a custom model's author may state none); REQUIRED and complete
9824
+ * on every built-in catalog entry (`scripts/check-catalog-licence.ts`).
9705
9825
  */
9706
- license: string().optional(),
9826
+ license: ModelLicenseSchema.optional(),
9707
9827
  /**
9708
9828
  * Variant-selector grouping. The UI groups models by `family` + `tier` and
9709
9829
  * offers `precision` / `optimization` as variant axes WITHIN a tier — so all
@@ -9725,7 +9845,14 @@ var ModelCatalogEntrySchema = object({
9725
9845
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
9726
9846
  * labels already ARE the CamStack macros (Scrypted identity map).
9727
9847
  */
9728
- classMap: DetectionCatalogClassMapSchema.optional()
9848
+ classMap: DetectionCatalogClassMapSchema.optional(),
9849
+ /**
9850
+ * The model's CLIP feature-space contract (text encoder, dimension, vector
9851
+ * index, token window, search floor) — see `clip-model.ts`. Present ONLY on a
9852
+ * CLIP image encoder; its absence is what "not a CLIP model" means to the
9853
+ * embedding encoder and the semantic-search store (D649).
9854
+ */
9855
+ clip: ClipModelMetaSchema.optional()
9729
9856
  });
9730
9857
  var ConvertTargetSchema = discriminatedUnion("format", [object({
9731
9858
  format: literal("openvino"),
@@ -9743,7 +9870,8 @@ var ModelConvertMetadataSchema = object({
9743
9870
  inputNormalization: _enum([
9744
9871
  "zero-one",
9745
9872
  "imagenet",
9746
- "none"
9873
+ "none",
9874
+ "scrfd"
9747
9875
  ]).optional(),
9748
9876
  preprocessMode: _enum(["letterbox", "resize"]).optional(),
9749
9877
  outputFormat: _enum([
@@ -9790,23 +9918,6 @@ var ExpressionEvalError = class extends Error {
9790
9918
  this.name = "ExpressionEvalError";
9791
9919
  }
9792
9920
  };
9793
- /**
9794
- * Frozen, null-prototype builtin function table for the expression engine
9795
- * (spec §4 rule 4). The table is the SOLE surface of callable functions: the
9796
- * parser rejects any callee not in it, and the evaluator gates each call on an
9797
- * own-property check against it.
9798
- *
9799
- * Because the object has a NULL prototype AND is `Object.freeze`d:
9800
- * - it cannot be polluted (no `__proto__` / `constructor` write reaches it);
9801
- * - a lookup for `toString` / `hasOwnProperty` / `constructor` finds NOTHING
9802
- * (there is no `Object.prototype` in the chain), so those names are not
9803
- * callable — they are simply "unknown function" at parse time.
9804
- *
9805
- * Every numeric argument is validated as a finite number and every numeric
9806
- * RESULT is re-checked finite, so `/0`, `sqrt(-1)` (→ NaN) and overflow
9807
- * (`pow(10,400)` → Infinity) all raise `ExpressionEvalError` and fail the link
9808
- * closed rather than emitting a garbage value.
9809
- */
9810
9921
  function asFiniteNumber(value, name, index) {
9811
9922
  if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
9812
9923
  return value;
@@ -9822,6 +9933,10 @@ function finiteResult(value, name) {
9822
9933
  function allFiniteNumbers(args, name) {
9823
9934
  return args.map((a, idx) => asFiniteNumber(a, name, idx));
9824
9935
  }
9936
+ function asBoolean$1(value, name, index) {
9937
+ if (typeof value !== "boolean") throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a boolean`);
9938
+ return value;
9939
+ }
9825
9940
  var INF = Number.POSITIVE_INFINITY;
9826
9941
  var table = {
9827
9942
  min: {
@@ -9922,6 +10037,40 @@ var table = {
9922
10037
  if (from === to) return x;
9923
10038
  throw new ExpressionEvalError("convert: unit conversion table not installed");
9924
10039
  }
10040
+ },
10041
+ any: {
10042
+ minArgs: 1,
10043
+ maxArgs: INF,
10044
+ apply: (args) => args.map((a, i) => asBoolean$1(a, "any", i)).some((b) => b)
10045
+ },
10046
+ all: {
10047
+ minArgs: 1,
10048
+ maxArgs: INF,
10049
+ apply: (args) => args.map((a, i) => asBoolean$1(a, "all", i)).every((b) => b)
10050
+ },
10051
+ within: {
10052
+ minArgs: 2,
10053
+ maxArgs: 2,
10054
+ apply: (args, hooks) => {
10055
+ const windowMs = asFiniteNumber(args[1], "within", 1);
10056
+ if (windowMs < 0) throw new ExpressionEvalError("within: the window must not be negative");
10057
+ const at = args[0];
10058
+ if (at === null) return false;
10059
+ const ts = asFiniteNumber(at, "within", 0);
10060
+ const now = hooks.now;
10061
+ if (now === void 0 || !Number.isFinite(now)) throw new ExpressionEvalError("within: no clock was supplied to this evaluation");
10062
+ const inside = now - ts <= windowMs;
10063
+ if (inside) hooks.noteDeadline?.(ts + windowMs + 1);
10064
+ return inside;
10065
+ }
10066
+ },
10067
+ latest: {
10068
+ minArgs: 1,
10069
+ maxArgs: INF,
10070
+ apply: (args) => {
10071
+ const present = args.flatMap((a, i) => a === null ? [] : [asFiniteNumber(a, "latest", i)]);
10072
+ return present.length === 0 ? null : finiteResult(Math.max(...present), "latest");
10073
+ }
9925
10074
  }
9926
10075
  };
9927
10076
  Object.freeze(Object.assign(Object.create(null), table));
@@ -10536,7 +10685,7 @@ var AutomationActionSchema = discriminatedUnion("kind", [
10536
10685
  code: string().min(1).max(2e4)
10537
10686
  })
10538
10687
  ]);
10539
- object({
10688
+ var AutomationRecipeSchema = object({
10540
10689
  triggers: array(AutomationTriggerSchema),
10541
10690
  conditions: AutomationConditionSchema.optional(),
10542
10691
  actions: array(AutomationActionSchema)
@@ -11023,12 +11172,32 @@ var AudioClassificationLabelSchema = object({
11023
11172
  originalClass: string().optional(),
11024
11173
  score: number()
11025
11174
  });
11175
+ /**
11176
+ * Did the classifier RUN on this window? (D660)
11177
+ *
11178
+ * `classified` with no labels means the model heard nothing above the
11179
+ * camera's floor. `not-classified` means nobody listened — and until D660 the
11180
+ * two were the same shape (`classification` absent), so a window the global
11181
+ * busy gate threw away read downstream exactly like a quiet one (D393).
11182
+ */
11183
+ var AudioClassifyOutcomeSchema = discriminatedUnion("state", [object({ state: literal("classified") }), object({
11184
+ state: literal("not-classified"),
11185
+ reason: _enum([
11186
+ "superseded",
11187
+ "error",
11188
+ "timeout",
11189
+ "disposed"
11190
+ ])
11191
+ })]);
11026
11192
  var AudioAnalysisResultSchema = object({
11027
11193
  level: AudioLevelSchema,
11194
+ /** Labels at or above the camera's floor. Absent = none — read `classifyOutcome` to know whether the model ran at all. */
11028
11195
  classification: object({
11029
11196
  labels: array(AudioClassificationLabelSchema).readonly(),
11030
11197
  inferenceMs: number()
11031
11198
  }).optional(),
11199
+ /** Whether the classifier ran on this window (D660). */
11200
+ classifyOutcome: AudioClassifyOutcomeSchema,
11032
11201
  timestamp: number()
11033
11202
  });
11034
11203
  var AudioAnalysisSettingsSchema = object({
@@ -12586,6 +12755,195 @@ DeviceType.Camera, method(object({ deviceId: number().int().nonnegative() }), ar
12586
12755
  }),
12587
12756
  lastChangedAt: number()
12588
12757
  });
12758
+ /** A composed device's stableId is this prefix plus the block id. */
12759
+ var COMPOSED_DEVICE_STABLE_ID_PREFIX = "composed-";
12760
+ /** Longest snippet a `code` source may carry (slice 4). */
12761
+ var MAX_COMPOSITION_CODE_LENGTH = 2e4;
12762
+ var CompositionSourceRefSchema = object({
12763
+ /** The owning addon; `stableId` is unique only within it. */
12764
+ addonId: string().min(1),
12765
+ stableId: string().min(1)
12766
+ });
12767
+ /** One field of one capability of one source device. */
12768
+ var CompositionFieldReadSchema = object({
12769
+ source: CompositionSourceRefSchema,
12770
+ cap: string().min(1),
12771
+ /** Dotted path into the source cap's runtime-state slice. */
12772
+ fieldPath: string().min(1)
12773
+ });
12774
+ /** `from`: copy one source field verbatim. It is also an expression's `from` binding. */
12775
+ var CompositionFromSourceSchema = CompositionFieldReadSchema.extend({ kind: literal("from") });
12776
+ var CompositionBindingSchema = discriminatedUnion("kind", [CompositionFromSourceSchema, object({
12777
+ kind: literal("literal"),
12778
+ value: union([
12779
+ string(),
12780
+ number(),
12781
+ boolean(),
12782
+ _null()
12783
+ ])
12784
+ })]);
12785
+ /**
12786
+ * `expression`: a formula over named bindings, in the salvaged expression
12787
+ * engine. Validated at parse by the SAME function every other consumer runs,
12788
+ * so the editor and the store cannot disagree.
12789
+ */
12790
+ var CompositionExpressionSourceSchema = object({
12791
+ kind: literal("expression"),
12792
+ expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
12793
+ bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), CompositionBindingSchema)
12794
+ }).superRefine((src, ctx) => {
12795
+ const err = validateExpressionSource(src);
12796
+ if (err !== null) ctx.addIssue({
12797
+ code: "custom",
12798
+ message: err,
12799
+ path: ["expr"]
12800
+ });
12801
+ });
12802
+ /** `code`: RESERVED for slice 4 (own runner, one-way eject). */
12803
+ var CompositionCodeSourceSchema = object({
12804
+ kind: literal("code"),
12805
+ code: string().min(1).max(MAX_COMPOSITION_CODE_LENGTH)
12806
+ });
12807
+ var CompositionFieldSourceSchema = discriminatedUnion("kind", [
12808
+ CompositionFromSourceSchema,
12809
+ CompositionExpressionSourceSchema,
12810
+ CompositionCodeSourceSchema
12811
+ ]);
12812
+ var CompositionCommandTargetSchema = discriminatedUnion("kind", [object({
12813
+ kind: literal("forward"),
12814
+ source: CompositionSourceRefSchema,
12815
+ cap: string().min(1),
12816
+ method: string().min(1)
12817
+ }), CompositionCodeSourceSchema]);
12818
+ var CompositionFeatureSchema = discriminatedUnion("kind", [object({
12819
+ kind: literal("fields"),
12820
+ cap: string().min(1),
12821
+ fields: record(string().min(1), CompositionFieldSourceSchema).refine((fields) => Object.keys(fields).length <= 32, { message: `at most 32 fields per capability` }),
12822
+ /** RESERVED for slice 3; refused by the validator when non-empty. */
12823
+ commands: record(string().min(1), CompositionCommandTargetSchema).optional()
12824
+ }), object({
12825
+ kind: literal("passthrough"),
12826
+ cap: string().min(1),
12827
+ source: CompositionSourceRefSchema
12828
+ })]);
12829
+ var CompositionSchema = object({
12830
+ target: discriminatedUnion("kind", [object({
12831
+ kind: literal("new"),
12832
+ type: _enum(DeviceType),
12833
+ role: _enum(DeviceRole).optional()
12834
+ }), object({
12835
+ kind: literal("existing"),
12836
+ device: CompositionSourceRefSchema
12837
+ })]),
12838
+ features: array(CompositionFeatureSchema).min(1).max(16)
12839
+ }).superRefine((composition, ctx) => {
12840
+ const seen = /* @__PURE__ */ new Set();
12841
+ composition.features.forEach((feature, index) => {
12842
+ if (seen.has(feature.cap)) ctx.addIssue({
12843
+ code: "custom",
12844
+ message: `capability \`${feature.cap}\` is composed twice — one feature per capability`,
12845
+ path: [
12846
+ "features",
12847
+ index,
12848
+ "cap"
12849
+ ]
12850
+ });
12851
+ seen.add(feature.cap);
12852
+ });
12853
+ });
12854
+ /** One refusal, named (D391). `path` points into the composition, e.g. `features[0].fields.celsius`. */
12855
+ var CompositionProblemSchema = object({
12856
+ code: _enum([
12857
+ "reserved-variant",
12858
+ "unknown-capability",
12859
+ "not-composable",
12860
+ "wrong-device-type",
12861
+ "has-commands",
12862
+ "unknown-field",
12863
+ "nested-field",
12864
+ "missing-field",
12865
+ "kind-mismatch",
12866
+ "may-be-null",
12867
+ "source-missing",
12868
+ "source-unreadable",
12869
+ "source-capability-missing",
12870
+ "source-field-unknown",
12871
+ "expression-invalid",
12872
+ "cycle",
12873
+ "duplicate-target"
12874
+ ]),
12875
+ path: string(),
12876
+ message: string()
12877
+ });
12878
+ var CompositionFieldKindSchema = _enum([
12879
+ "string",
12880
+ "number",
12881
+ "boolean",
12882
+ "enum"
12883
+ ]);
12884
+ /** How a field says "unavailable": `null` when its schema allows it, else the device goes offline (D393). */
12885
+ var CompositionUnavailableModeSchema = _enum(["null", "offline"]);
12886
+ /**
12887
+ * `derived` reads a source · `clock` reads only `now`, recomputed when a sibling
12888
+ * field of its cap changes value · `constant` reads nothing, computed once.
12889
+ */
12890
+ var CompositionFieldRoleSchema = _enum([
12891
+ "derived",
12892
+ "clock",
12893
+ "constant"
12894
+ ]);
12895
+ var CompositionFieldPlanSchema = object({
12896
+ cap: string(),
12897
+ path: string(),
12898
+ /** Index into `composition.features` this field's capability came from —
12899
+ * lets a source/cycle problem name its path as `features[N].fields.<path>`
12900
+ * (the same convention `planComposition`'s own problems already use). */
12901
+ featureIndex: number().int().nonnegative(),
12902
+ kind: CompositionFieldKindSchema,
12903
+ nullable: boolean(),
12904
+ required: boolean(),
12905
+ unavailable: CompositionUnavailableModeSchema,
12906
+ role: CompositionFieldRoleSchema,
12907
+ source: CompositionFieldSourceSchema,
12908
+ reads: array(CompositionFieldReadSchema)
12909
+ });
12910
+ var CompositionValidationSchema = object({
12911
+ ok: boolean(),
12912
+ problems: array(CompositionProblemSchema),
12913
+ fields: array(CompositionFieldPlanSchema)
12914
+ });
12915
+ /** Mirrors `CoreBlockStatus`, pinned by `core-blocks-source.spec.ts` (Task 11). */
12916
+ var CompositionRunStatusSchema = _enum([
12917
+ "stopped",
12918
+ "starting",
12919
+ "running",
12920
+ "failed"
12921
+ ]);
12922
+ var CompositionFieldStateKindSchema = _enum([
12923
+ "fresh",
12924
+ "stale",
12925
+ "unavailable"
12926
+ ]);
12927
+ var CompositionFieldStateSchema = object({
12928
+ cap: string(),
12929
+ path: string(),
12930
+ state: CompositionFieldStateKindSchema,
12931
+ /** `null` whenever `state === 'unavailable'`; never a plausible stand-in (D393). */
12932
+ value: union([
12933
+ string(),
12934
+ number(),
12935
+ boolean(),
12936
+ _null()
12937
+ ]),
12938
+ reason: string().optional()
12939
+ });
12940
+ var CompositionBlockStateSchema = object({
12941
+ blockId: string(),
12942
+ deviceId: number().nullable(),
12943
+ status: CompositionRunStatusSchema,
12944
+ reason: string().optional(),
12945
+ fields: array(CompositionFieldStateSchema)
12946
+ });
12589
12947
  /** Where a block runs. The operator chooses — a block driving a device on an
12590
12948
  * agent is the reason placement is not fixed to the hub. */
12591
12949
  var CoreBlockPlacementSchema = union([literal("hub"), string().min(1)]);
@@ -12612,6 +12970,30 @@ var CoreBlockInputSchema = object({
12612
12970
  */
12613
12971
  integrationId: string().optional()
12614
12972
  });
12973
+ /**
12974
+ * What a block IS (D659). Absent means `code` — every row stored before this
12975
+ * union keeps working unchanged.
12976
+ * - `code`: the TypeScript in `code`, compiled and run in its own runner;
12977
+ * - `recipe`: RESERVED (automations), stored shape only; refused at run by name;
12978
+ * - `composition`: declarative, run by the shared `composer`; `code` is `''`.
12979
+ */
12980
+ var CoreBlockSourceSchema = discriminatedUnion("kind", [
12981
+ object({ kind: literal("code") }),
12982
+ object({
12983
+ kind: literal("recipe"),
12984
+ recipe: AutomationRecipeSchema
12985
+ }),
12986
+ object({
12987
+ kind: literal("composition"),
12988
+ composition: CompositionSchema
12989
+ })
12990
+ ]);
12991
+ /** The client-authored half of a composition block. No `code`, no placement (hub-only; Phase 7). */
12992
+ var CompositionBlockInputSchema = object({
12993
+ name: string().min(1).max(120),
12994
+ enabled: boolean(),
12995
+ composition: CompositionSchema
12996
+ });
12615
12997
  /** A stored block. */
12616
12998
  var CoreBlockSchema = CoreBlockInputSchema.extend({
12617
12999
  id: string(),
@@ -12627,8 +13009,38 @@ var CoreBlockSchema = CoreBlockInputSchema.extend({
12627
13009
  */
12628
13010
  lastError: string().optional(),
12629
13011
  /** Ms epoch of the last state change. */
12630
- lastChangedAt: number()
13012
+ lastChangedAt: number(),
13013
+ /** What the block is. Absent means `code` (D659). */
13014
+ source: CoreBlockSourceSchema.optional()
13015
+ });
13016
+ /** A stored composition block and what the composer says about it. */
13017
+ var CompositionViewSchema = object({
13018
+ block: CoreBlockSchema,
13019
+ state: discriminatedUnion("kind", [object({
13020
+ kind: literal("answered"),
13021
+ state: CompositionBlockStateSchema.nullable()
13022
+ }), object({
13023
+ kind: literal("unreachable"),
13024
+ error: string()
13025
+ })])
13026
+ });
13027
+ /**
13028
+ * A read of the stored compositions. `not-loaded` while the `core_blocks`
13029
+ * table has not been READ: an empty answer then would make "not yet known"
13030
+ * look like "none", and invite the operator to recreate what exists (D315).
13031
+ */
13032
+ var CompositionsNotLoadedSchema = object({
13033
+ state: literal("not-loaded"),
13034
+ reason: string()
12631
13035
  });
13036
+ var CompositionListReadSchema = discriminatedUnion("state", [object({
13037
+ state: literal("loaded"),
13038
+ views: array(CompositionViewSchema)
13039
+ }), CompositionsNotLoadedSchema]);
13040
+ var CompositionGetReadSchema = discriminatedUnion("state", [object({
13041
+ state: literal("loaded"),
13042
+ view: CompositionViewSchema.nullable()
13043
+ }), CompositionsNotLoadedSchema]);
12632
13044
  /** What a compile attempt produced. */
12633
13045
  var CoreBlockCompileResultSchema = object({
12634
13046
  ok: boolean(),
@@ -12666,7 +13078,72 @@ method(object({}), object({ blocks: array(CoreBlockSchema) }), { auth: "admin" }
12666
13078
  }), method(object({}), object({ libs: array(object({
12667
13079
  filePath: string(),
12668
13080
  content: string()
12669
- })) }), { auth: "admin" });
13081
+ })) }), { auth: "admin" }), method(object({ block: CompositionBlockInputSchema }), object({ block: CoreBlockSchema }), {
13082
+ kind: "mutation",
13083
+ auth: "admin",
13084
+ caller: "required"
13085
+ }), method(object({
13086
+ blockId: string(),
13087
+ expectedUpdatedAt: number(),
13088
+ block: CompositionBlockInputSchema.partial()
13089
+ }), object({ block: CoreBlockSchema }), {
13090
+ kind: "mutation",
13091
+ auth: "admin",
13092
+ caller: "required"
13093
+ }), method(object({ blockId: string() }), CompositionGetReadSchema, { auth: "admin" }), method(object({}), CompositionListReadSchema, { auth: "admin" }), method(object({
13094
+ composition: CompositionSchema,
13095
+ blockId: string().optional()
13096
+ }), CompositionValidationSchema, {
13097
+ kind: "mutation",
13098
+ auth: "admin",
13099
+ access: "view"
13100
+ });
13101
+ var ComposerBlockSchema = object({
13102
+ id: string().min(1),
13103
+ name: string().min(1).max(120),
13104
+ enabled: boolean(),
13105
+ updatedAt: number(),
13106
+ composition: CompositionSchema
13107
+ });
13108
+ /**
13109
+ * A stored composition row that no longer PARSES — a schema a release
13110
+ * tightened, a row written by a newer build. Sent by id so the composer keeps
13111
+ * its device as a placeholder and reports the block `failed` naming the parse
13112
+ * error. Leaving it out would read, twice, exactly like a delete (D49).
13113
+ */
13114
+ var ComposerUnreadableBlockSchema = object({
13115
+ id: string().min(1),
13116
+ /** The row's stored name column; null when even that is unreadable (the device keeps the name it has). */
13117
+ name: string().nullable(),
13118
+ /** The parse error, in the operator's words. */
13119
+ error: string()
13120
+ });
13121
+ method(object({
13122
+ /** The shared Blocks integration; null until `core-blocks` has reconciled it. */
13123
+ integrationId: string().nullable(),
13124
+ /** False when the `core_blocks` read failed: then nothing may be withdrawn (D49). */
13125
+ storeLoaded: boolean(),
13126
+ blocks: array(ComposerBlockSchema),
13127
+ /** Operator restarts: rebuild these runtimes and re-resolve their sources. Stores nothing (D62). */
13128
+ restartBlockIds: array(string()),
13129
+ /** Composition rows that exist but do not parse: held, never withdrawn, reported failed. */
13130
+ unreadableBlocks: array(ComposerUnreadableBlockSchema)
13131
+ }), object({
13132
+ blocks: array(object({
13133
+ blockId: string(),
13134
+ status: CompositionRunStatusSchema,
13135
+ reason: string().optional()
13136
+ })),
13137
+ /**
13138
+ * False when the composer declared and withdrew NOTHING (store not loaded,
13139
+ * integration unknown, its own rows unread or read empty once). An empty
13140
+ * apply the caller owes is paid off only by one the composer acted on (D49).
13141
+ */
13142
+ acted: boolean()
13143
+ }), {
13144
+ kind: "mutation",
13145
+ auth: "admin"
13146
+ }), method(object({ blockIds: array(string()) }), object({ states: array(CompositionBlockStateSchema) }), { auth: "admin" });
12670
13147
  /**
12671
13148
  * `custom-model-registry` — collection cap exposing operator-registered
12672
13149
  * custom detection models. Each provider (today: `addon-model-studio`)
@@ -13961,6 +14438,27 @@ var LinkedDeviceSchema = object({
13961
14438
  features: array(string()),
13962
14439
  producesTrackedEvents: boolean().optional()
13963
14440
  });
14441
+ /**
14442
+ * The `linked-devices` extension slot's editable value (D648): the operator's
14443
+ * pick list, exactly what `_linkedDeviceIds` persists. Tree children are NOT
14444
+ * in it — they are always linked and are not a pick.
14445
+ *
14446
+ * `trackedDeviceIds` (D655) is the tracked-event opt-in, exactly what
14447
+ * `_linkedDeviceTrackedIds` persists: which linked devices materialize a
14448
+ * synthetic tracked event on the camera. A read always carries it AS STORED
14449
+ * (an absent key reads as `[]`, which is what the resolver makes of it —
14450
+ * NONE). On a write it is optional: absent leaves the opt-in untouched, so a
14451
+ * card built before D655 cannot erase it by saving the pick list. A present
14452
+ * list REPLACES the opt-in; each id must be a pick, a device the camera links
14453
+ * by structure (the row's `impliedSources`: tree children, a picked
14454
+ * container's child) or already stored — so what was read can always be
14455
+ * written back unchanged, and a NEW opt-in outside the linked set is refused.
14456
+ */
14457
+ var LinkedDevicesSlotValueSchema = object({
14458
+ deviceIds: array(number().int().positive()),
14459
+ trackedDeviceIds: array(number().int().positive()).optional()
14460
+ });
14461
+ DeviceType.Camera;
13964
14462
  /** One camera's resolved linked set, tagged with the camera it belongs to.
13965
14463
  * The batch answer needs the tag; the single-device answer already has it
13966
14464
  * from the input, which is why `getLinkedDevices` keeps the untagged shape. */
@@ -14324,7 +14822,7 @@ method(object({
14324
14822
  }), method(object({ deviceId: number() }), array(StreamProbeResultSchema), {
14325
14823
  kind: "mutation",
14326
14824
  auth: "admin"
14327
- }), method(object({ deviceId: number() }), DeviceBindingsForDeviceSchema), method(object({ deviceIds: array(number()) }), array(DeviceBindingsForDeviceSchema)), method(object({}), array(DeviceBindingsForDeviceSchema)), method(object({
14825
+ }), 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({
14328
14826
  deviceId: number(),
14329
14827
  capName: string(),
14330
14828
  wrapperAddonId: string(),
@@ -14486,16 +14984,101 @@ var EmbeddingResultSchema = object({
14486
14984
  embedding: array(number()),
14487
14985
  inferenceMs: number()
14488
14986
  });
14987
+ /** The two CLIP towers the encoder runs; a crash budget is kept per tower. */
14988
+ var EmbeddingTowerSchema = _enum(["image", "text"]);
14989
+ /**
14990
+ * A tower in the terminal `failed` state (D649, D6): it crashed or failed to
14991
+ * load `crashes` times within `windowMs`, and is refused by name until an
14992
+ * operator `resetFailedModels` or a model change — never on a timer.
14993
+ *
14994
+ * `nodeId` is the node whose tower failed. The state lives in THAT node's
14995
+ * encoder process (in memory — a runner respawn clears it), and one node's
14996
+ * answer says nothing about another's.
14997
+ */
14998
+ var EmbeddingFailedModelSchema = object({
14999
+ modelId: string(),
15000
+ tower: EmbeddingTowerSchema,
15001
+ nodeId: string(),
15002
+ crashes: number(),
15003
+ windowMs: number(),
15004
+ sinceMs: number(),
15005
+ lastReason: string()
15006
+ });
15007
+ /**
15008
+ * A model whose REQUIREMENTS can never be met on this node (D649 round 5):
15009
+ * an id the catalog does not know, a model URL answering 404/410, a declared
15010
+ * sibling (the tokenizer) that is not there. After `attempts` failed builds
15011
+ * it is terminally `requirements-failed`, refused by name until an operator
15012
+ * `resetFailedModels` or a model change — the same exits as a crashed tower.
15013
+ */
15014
+ var EmbeddingFailedRequirementSchema = object({
15015
+ modelId: string(),
15016
+ tower: EmbeddingTowerSchema,
15017
+ nodeId: string(),
15018
+ attempts: number(),
15019
+ sinceMs: number(),
15020
+ lastReason: string()
15021
+ });
14489
15022
  var EmbeddingInfoSchema = object({
14490
15023
  modelId: string(),
14491
15024
  embeddingDim: number(),
14492
- ready: boolean()
14493
- });
15025
+ ready: boolean(),
15026
+ /**
15027
+ * The node that answered. Absent only from an encoder older than D649's
15028
+ * crash budget — whose `failedModels` is then UNKNOWN (D315), never "none".
15029
+ */
15030
+ nodeId: string().optional(),
15031
+ /**
15032
+ * Towers in `failed` on the answering node, each row naming it. `undefined`
15033
+ * means the node could not say (pre-budget encoder); a node that has the
15034
+ * budget always answers an array, empty included.
15035
+ */
15036
+ failedModels: array(EmbeddingFailedModelSchema).optional(),
15037
+ /** Models terminally `requirements-failed` on the answering node; same reading as above. */
15038
+ failedRequirements: array(EmbeddingFailedRequirementSchema).optional()
15039
+ });
15040
+ /**
15041
+ * The THREE codes an encoder refusal can carry (D649, D6). Same shape as
15042
+ * `VECTOR_INDEX_DIM_CONFLICT`: the code rides in the MESSAGE, because an
15043
+ * Error's own properties do not survive the UDS/tRPC hop and its message does,
15044
+ * and both sides go through the helpers below — the encoder builds the
15045
+ * refusal, the live detail plane classifies on it to count refusals per
15046
+ * camera instead of logging one warning per track. The bracketed token
15047
+ * carries the code, the model, the tower and the node so a consumer never
15048
+ * parses prose.
15049
+ *
15050
+ * - `EMBEDDING_MODEL_FAILED`: the tower crashed / failed to load past the crash
15051
+ * budget — terminal until `resetFailedModels` or a model change.
15052
+ * - `EMBEDDING_REQUIREMENTS_UNAVAILABLE`: files or runtime not there right now
15053
+ * (a download or Python that failed, or the cooldown after one) — the next
15054
+ * request past the cooldown tries again.
15055
+ * - `EMBEDDING_REQUIREMENTS_FAILED`: the requirements can never be met (unknown
15056
+ * id, 404/410, missing sibling) and the bounded attempts are spent —
15057
+ * terminal, same exits as a crashed tower.
15058
+ */
15059
+ var EMBEDDING_MODEL_FAILED = "embedding-model-failed";
15060
+ var EMBEDDING_REQUIREMENTS_UNAVAILABLE = "embedding-requirements-unavailable";
15061
+ var EMBEDDING_REQUIREMENTS_FAILED = "embedding-requirements-failed";
15062
+ _enum([
15063
+ EMBEDDING_MODEL_FAILED,
15064
+ EMBEDDING_REQUIREMENTS_UNAVAILABLE,
15065
+ EMBEDDING_REQUIREMENTS_FAILED
15066
+ ]);
15067
+ new RegExp(`\\[(${EMBEDDING_MODEL_FAILED}|${EMBEDDING_REQUIREMENTS_UNAVAILABLE}|${EMBEDDING_REQUIREMENTS_FAILED}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);
14494
15068
  method(object({
14495
15069
  crop: _instanceof(Uint8Array),
14496
15070
  width: number(),
14497
15071
  height: number()
14498
- }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
15072
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({
15073
+ text: string(),
15074
+ modelId: string().min(1).optional()
15075
+ }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" }), method(object({ modelId: string().min(1).optional() }), object({
15076
+ cleared: array(string()),
15077
+ nodeId: string()
15078
+ }), {
15079
+ kind: "mutation",
15080
+ auth: "admin"
15081
+ });
14499
15082
  /**
14500
15083
  * `failure-contribution` — the capability an addon reports its OWN losses
14501
15084
  * through, per camera, with the denominator attached. It stores nothing.
@@ -14679,18 +15262,30 @@ var LlmErrorCodeSchema = _enum([
14679
15262
  "budget-exceeded",
14680
15263
  "adapter-error"
14681
15264
  ]);
14682
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
15265
+ var LlmGenerateOkSchema = object({
14683
15266
  ok: literal(true),
14684
15267
  text: string(),
14685
15268
  model: string(),
14686
15269
  usage: LlmUsageSchema,
14687
15270
  truncated: boolean(),
14688
15271
  latencyMs: number()
14689
- }), object({
15272
+ });
15273
+ /**
15274
+ * WHO refused, on a `refusal`. `guardrail` = a safety filter in front of the
15275
+ * model rejected the request before it answered (Apple Foundation Models
15276
+ * refuses surveillance-framed prompts in 0.1 s); `model` = the model itself
15277
+ * declined. They are different faults: a guardrail refusal is a property of
15278
+ * the BACKEND, so the provider falls back to the next profile; a model refusal
15279
+ * is an answer. Absent on every other code, and on a refusal a wire cannot
15280
+ * attribute.
15281
+ */
15282
+ var LlmRefusalSourceSchema = _enum(["guardrail", "model"]);
15283
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [LlmGenerateOkSchema, object({
14690
15284
  ok: literal(false),
14691
15285
  code: LlmErrorCodeSchema,
14692
15286
  message: string(),
14693
- retryAfterMs: number().optional()
15287
+ retryAfterMs: number().optional(),
15288
+ refusalSource: LlmRefusalSourceSchema.optional()
14694
15289
  })]);
14695
15290
  /**
14696
15291
  * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
@@ -14920,12 +15515,78 @@ var LlmRuntimeDiskUsageSchema = object({
14920
15515
  modelsBytes: number(),
14921
15516
  freeBytes: number().optional()
14922
15517
  });
14923
- method(LlmGenerateBaseInputSchema.extend({
15518
+ var LlmRuntimeCompleteInputSchema = LlmGenerateBaseInputSchema.extend({
14924
15519
  images: array(LlmImageSchema).optional(),
14925
15520
  runtime: ManagedRuntimeConfigSchema,
14926
15521
  /** The managed profile's timeout, threaded by the hub provider. */
14927
15522
  timeoutMs: number().int().positive().optional()
14928
- }), LlmGenerateResultSchema, {
15523
+ });
15524
+ /**
15525
+ * Why Apple Foundation Models cannot run on a node that has it in principle.
15526
+ * The first three are Apple's own `UnavailableReason`s, verbatim; the rest are
15527
+ * ours: the OS predates the framework (macOS < 26), the helper binary is not
15528
+ * in the installed addon, or it crashed past the respawn bound.
15529
+ */
15530
+ var AppleFmUnavailableReasonSchema = _enum([
15531
+ "deviceNotEligible",
15532
+ "appleIntelligenceNotEnabled",
15533
+ "modelNotReady",
15534
+ "osTooOld",
15535
+ "helperMissing",
15536
+ "helperCrashed"
15537
+ ]);
15538
+ /**
15539
+ * Apple Foundation Models on ONE node — four states, never a boolean (D315).
15540
+ *
15541
+ * - `available` — the helper probed it; what it CAN do is reported
15542
+ * here (`imageInput`, `contextSize`, languages),
15543
+ * never typed by an operator.
15544
+ * - `unavailable` — a known absence, with the reason to act on.
15545
+ * - `unsupported-platform` — not a Mac; there is nothing to enable.
15546
+ * - `unknown` — the probe did not answer (not yet run, timed
15547
+ * out, helper crashed mid-probe). A failed
15548
+ * measurement is NEVER `unavailable` (D393).
15549
+ */
15550
+ var AppleFmAvailabilitySchema = discriminatedUnion("state", [
15551
+ object({
15552
+ state: literal("available"),
15553
+ osVersion: string(),
15554
+ /** Tokens, as the framework reports it. Read at runtime, never assumed. */
15555
+ contextSize: number().int().positive(),
15556
+ /** BCP-47-ish tags (`it-IT`) of the languages the model supports. */
15557
+ languages: array(string()),
15558
+ /** Whether prompts may carry images. `false` on a macOS 26 build. */
15559
+ imageInput: boolean()
15560
+ }),
15561
+ object({
15562
+ state: literal("unavailable"),
15563
+ reason: AppleFmUnavailableReasonSchema,
15564
+ osVersion: string().nullable(),
15565
+ detail: string()
15566
+ }),
15567
+ object({
15568
+ state: literal("unsupported-platform"),
15569
+ platform: string()
15570
+ }),
15571
+ object({
15572
+ state: literal("unknown"),
15573
+ error: string()
15574
+ })
15575
+ ]);
15576
+ /**
15577
+ * A generation on the node's Apple Foundation Models helper. A separate verb
15578
+ * from `complete`, whose `runtime` is a llama.cpp config: overloading it would
15579
+ * drag a GGUF model reference into a backend that has none. `images` is part
15580
+ * of the contract so vision needs no cap change later; a node whose model has
15581
+ * no image input REFUSES them (`unavailable`), never drops them.
15582
+ */
15583
+ var LlmRuntimeAppleCompleteInputSchema = LlmGenerateBaseInputSchema.extend({
15584
+ images: array(LlmImageSchema).optional(),
15585
+ /** The profile's timeout, threaded by the hub provider. */
15586
+ timeoutMs: number().int().positive().optional()
15587
+ });
15588
+ var LlmRuntimeCancelInputSchema = object({ requestId: string() });
15589
+ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
14929
15590
  kind: "mutation",
14930
15591
  auth: "admin",
14931
15592
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
@@ -14943,7 +15604,14 @@ method(LlmGenerateBaseInputSchema.extend({
14943
15604
  }), method(object({ file: string() }), _void(), {
14944
15605
  kind: "mutation",
14945
15606
  auth: "admin"
14946
- }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" });
15607
+ }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" }), method(LlmRuntimeCancelInputSchema, _void(), {
15608
+ kind: "mutation",
15609
+ auth: "admin"
15610
+ }), method(object({}), AppleFmAvailabilitySchema, { auth: "admin" }), method(LlmRuntimeAppleCompleteInputSchema, LlmGenerateResultSchema, {
15611
+ kind: "mutation",
15612
+ auth: "admin",
15613
+ timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
15614
+ });
14947
15615
  /**
14948
15616
  * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
14949
15617
  * methods concat-fan across providers; single-row methods route to ONE
@@ -14960,7 +15628,8 @@ var LlmProfileKindSchema = _enum([
14960
15628
  "openai",
14961
15629
  "anthropic",
14962
15630
  "google",
14963
- "managed-local"
15631
+ "managed-local",
15632
+ "apple-foundation"
14964
15633
  ]);
14965
15634
  var LlmProfileSchema = object({
14966
15635
  id: string(),
@@ -15018,7 +15687,14 @@ var LlmProfileSchema = object({
15018
15687
  toolsEnabled: boolean().default(false),
15019
15688
  extraHeaders: record(string(), string()).optional(),
15020
15689
  /** kind === 'managed-local' only (spec §4). */
15021
- runtime: ManagedRuntimeConfigSchema.optional()
15690
+ runtime: ManagedRuntimeConfigSchema.optional(),
15691
+ /**
15692
+ * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
15693
+ * to configure (no key, no URL, no download; `model` is `apple-system`).
15694
+ * `supportsVision` on such a row is stamped by the provider from the node's
15695
+ * reported `imageInput`, never taken from the operator (D62).
15696
+ */
15697
+ appleFoundation: object({ nodeId: string() }).optional()
15022
15698
  });
15023
15699
  /** ConfigUISchema tree passed through untyped on the wire (the
15024
15700
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -15100,7 +15776,9 @@ var LlmRuntimeNodeSchema = object({
15100
15776
  reachable: boolean(),
15101
15777
  status: LlmRuntimeStatusSchema.optional(),
15102
15778
  disk: LlmRuntimeDiskUsageSchema.optional(),
15103
- error: string().optional()
15779
+ error: string().optional(),
15780
+ /** Absent = the node did not answer the question (render as unknown). */
15781
+ apple: AppleFmAvailabilitySchema.optional()
15104
15782
  });
15105
15783
  var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
15106
15784
  var ProfileRefInputSchema = object({
@@ -17059,6 +17737,9 @@ var NcSystemEventKindSchema = _enum([
17059
17737
  "device-battery-normal",
17060
17738
  "device-consumable-low",
17061
17739
  "device-consumable-normal",
17740
+ "device-tank-low",
17741
+ "device-tank-full",
17742
+ "device-tank-normal",
17062
17743
  "stream-online",
17063
17744
  "stream-offline",
17064
17745
  "node-online",
@@ -17096,6 +17777,29 @@ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
17096
17777
  ]);
17097
17778
  NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
17098
17779
  /**
17780
+ * The panel's transitions, as ONE list.
17781
+ *
17782
+ * Named here rather than spelled out at each of the four sites that need them
17783
+ * (the emitter, the intake, the editor group, the combined-notification gate),
17784
+ * because a transition added to the enum and forgotten at one of them is an
17785
+ * alarm state nobody can be notified about. That is exactly what this list
17786
+ * failed to prevent while it held three: `alarm-arming` was the fourth.
17787
+ *
17788
+ * In LIFECYCLE order, which is the order an editor lists them in and the order
17789
+ * a person experiences them — not the order they were added.
17790
+ */
17791
+ var NC_ALARM_SYSTEM_EVENT_KINDS = [
17792
+ "alarm-arm-refused",
17793
+ "alarm-check-failed",
17794
+ "alarm-arming",
17795
+ "alarm-armed",
17796
+ "alarm-pending",
17797
+ "alarm-triggered",
17798
+ "alarm-rearmed",
17799
+ "alarm-sensor-bypass",
17800
+ "alarm-disarmed"
17801
+ ];
17802
+ /**
17099
17803
  * One coherent system-event condition. `kinds` is the required opt-in safety
17100
17804
  * gate; the remaining lists are optional narrowing filters relevant to the
17101
17805
  * selected kinds.
@@ -17115,8 +17819,36 @@ var NcSystemEventConditionSchema = object({
17115
17819
  * does not carry) matches no `deviceTypes` list.
17116
17820
  */
17117
17821
  deviceTypes: array(string().min(1)).min(1).optional(),
17822
+ /**
17823
+ * Devices this rule NEVER speaks about, whatever else matched. Scoped to the
17824
+ * same kind family as `deviceIds` (`systemEventFilterApplies(kind,
17825
+ * 'deviceIds')`) and applied AFTER it: include first, then exclude. A
17826
+ * consumable subject (`consumable:<id>:<key>`) is excluded by its device id.
17827
+ *
17828
+ * It never fails closed: a subject that carries no device id is not in the
17829
+ * list, so it is not excluded. "Every battery except the one thermometer that
17830
+ * reads 0 % forever" is the question this answers — expressed as an include
17831
+ * list it would have to name every other battery device, and every device
17832
+ * adopted later would be silently left out (D636).
17833
+ */
17834
+ excludeDeviceIds: array(number().int()).min(1).optional(),
17118
17835
  nodeIds: array(string().min(1)).min(1).optional(),
17119
- packageNames: array(string().min(1)).min(1).optional()
17836
+ packageNames: array(string().min(1)).min(1).optional(),
17837
+ /**
17838
+ * At or below this remaining-life %, a consumable is LOW for THIS rule
17839
+ * (D642). Absent = {@link NC_CONSUMABLE_LOW_PERCENT_DEFAULT}; at most
17840
+ * {@link NC_CONSUMABLE_LOW_PERCENT_MAX}, so every episode can recover. Scoped to the
17841
+ * consumable kinds (`systemEventFilterApplies`) and to the device-events
17842
+ * family; ignored on every other kind.
17843
+ *
17844
+ * It is a property of the RULE because the operator decided so: a rule at
17845
+ * 25 must be told about a filter at 20 %, a rule at 10 must not. The hub
17846
+ * keeps one episode per (threshold, device, item) — its own hysteresis, its
17847
+ * own reminder — and a rule hears only the episode judged at ITS threshold,
17848
+ * exactly as an occupancy rule hears only the edge of its own count. A
17849
+ * provider's own `replace` verdict is low at every threshold.
17850
+ */
17851
+ consumableLowPercent: number().int().min(1).max(95).optional()
17120
17852
  });
17121
17853
  /** Hard ceiling on a window (24h). A snooze that could not expire would be an
17122
17854
  * outage the operator asked for once and forgot. */
@@ -17134,6 +17866,25 @@ var NcScheduleSchema = object({
17134
17866
  /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
17135
17867
  invert: boolean().optional()
17136
17868
  });
17869
+ /**
17870
+ * How a system-event rule of the `device-events` or `system` family speaks
17871
+ * (D647): at once, per event (`instant`, the only behaviour before D647), or
17872
+ * as a STATE SUMMARY at the end of each window of `schedule`.
17873
+ */
17874
+ var NcSystemEventDeliveryModeSchema = _enum(["instant", "summary"]);
17875
+ /**
17876
+ * `summary`: the rule sends NOTHING per event. When a window of `schedule`
17877
+ * CLOSES, it sends one notification with the current state of its kinds
17878
+ * (low batteries, consumables to replace, devices offline, updates
17879
+ * available, ...), after its own filters. Nothing to report sends nothing.
17880
+ * The schedule is the ordinary `NcSchedule` (weekly windows, IANA timezone,
17881
+ * midnight crossing); the send time is each window's END. Refused on the
17882
+ * `alarm` family, which stays instant (`systemEventDeliveryProblems`).
17883
+ */
17884
+ var NcSystemEventDeliverySchema = discriminatedUnion("mode", [object({ mode: literal("instant") }), object({
17885
+ mode: literal("summary"),
17886
+ schedule: NcScheduleSchema
17887
+ })]);
17137
17888
  /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
17138
17889
  var NcPlateMatcherSchema = object({
17139
17890
  /**
@@ -17259,6 +18010,16 @@ var NcCrossingSchema = _enum([
17259
18010
  "exit",
17260
18011
  "any"
17261
18012
  ]);
18013
+ /**
18014
+ * Which edge of a BOOLEAN sensor fires a device-event rule (D640).
18015
+ * - `raised` — the sensor went high: water detected, smoke, open, tampered.
18016
+ * - `cleared` — it went back: dry, clear, closed.
18017
+ * - absent — both edges, which is what every rule authored before this did.
18018
+ *
18019
+ * There is no third member for "both": absence already says it, and a value
18020
+ * that means the same as absence is a second way to write one rule.
18021
+ */
18022
+ var NcSensorTransitionSchema = _enum(["raised", "cleared"]);
17262
18023
  /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
17263
18024
  var NcZoneConditionSchema = object({
17264
18025
  ids: array(string().min(1)).min(1),
@@ -17448,6 +18209,20 @@ var NcConditionsSchema = object({
17448
18209
  scene: NcSceneConditionSchema.optional(),
17449
18210
  /** Device scope — absent = all devices. */
17450
18211
  devices: array(number()).optional(),
18212
+ /**
18213
+ * Device EXCLUSION (D641) — "every device except these". Judged on the SAME
18214
+ * subject ids {@link devices} is judged on (the camera, the sensor that
18215
+ * fired, a linked set's sensor and row cameras), so a sensor fanned out per
18216
+ * linked camera is excluded exactly where an include would have tested it.
18217
+ * `min(1)`: an empty exclusion excludes nothing and is written as absent.
18218
+ *
18219
+ * Not for `system-event` rules — those carry their own
18220
+ * `systemEvent.excludeDeviceIds` (D636), and the hub refuses this key there.
18221
+ * Editors present the two lists as ONE field (All | Only these | All except
18222
+ * these); the engine evaluates each independently, so a legacy rule
18223
+ * carrying both still means "these, minus those".
18224
+ */
18225
+ devicesExclude: array(number()).min(1).optional(),
17451
18226
  /** Detector class names (any overlap with the record's class set). */
17452
18227
  classes: array(string().min(1)).optional(),
17453
18228
  /** Veto classes — any overlap fails the rule. */
@@ -17581,6 +18356,16 @@ var NcConditionsSchema = object({
17581
18356
  */
17582
18357
  sensorKinds: array(string().min(1)).optional(),
17583
18358
  /**
18359
+ * DEVICE-EVENT only (D640). Fire on one edge of a boolean sensor —
18360
+ * {@link NcSensorTransitionSchema}. Which field of the slice means "raised"
18361
+ * is `@camstack/types` → `notification/sensor-raised.ts`. A reading the
18362
+ * engine cannot place (a kind with no raise, an unreadable slice) PASSES:
18363
+ * the condition fails open towards notifying, never towards silence. Editors
18364
+ * offer it only when every chosen {@link sensorKinds} member has a raise
18365
+ * (`sensorTransitionOffered`), and the hub refuses it on any other delivery.
18366
+ */
18367
+ sensorTransition: NcSensorTransitionSchema.optional(),
18368
+ /**
17584
18369
  * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
17585
18370
  * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
17586
18371
  * when the subject's phase does not match (a subject always carries a phase
@@ -17713,7 +18498,12 @@ var NcMediaPolicySchema = object({
17713
18498
  * the degrade engine, which drops the video and keeps the still.
17714
18499
  */
17715
18500
  clip: boolean().optional(),
17716
- /** Seconds of footage BEFORE / AFTER the event instant. Defaults 3 / 7. */
18501
+ /**
18502
+ * Seconds of footage BEFORE / AFTER the event instant. Absent =
18503
+ * {@link NC_CLIP_PRE_ROLL_DEFAULT_SEC} / {@link NC_CLIP_POST_ROLL_DEFAULT_SEC}
18504
+ * (4 / 6), resolved by the Notification Center at dispatch — deliberately not
18505
+ * a Zod default, so a rule that never chose keeps following the hub's.
18506
+ */
17717
18507
  clipPreRollSec: number().int().min(0).max(30).optional(),
17718
18508
  clipPostRollSec: number().int().min(0).max(30).optional(),
17719
18509
  /**
@@ -17835,6 +18625,16 @@ var NcRuleInputSchema = object({
17835
18625
  delivery: NcDeliverySchema,
17836
18626
  conditions: NcConditionsSchema.default({}),
17837
18627
  schedule: NcScheduleSchema.optional(),
18628
+ /**
18629
+ * A `device-events` / `system` rule's delivery (D647): absent or `instant`
18630
+ * is a notification per event; `summary` is one state summary per closed
18631
+ * window of its schedule. `.optional()` and never defaulted: absent must
18632
+ * keep meaning what every rule authored before D647 meant, with no
18633
+ * migration. Top-level rather than inside `conditions.systemEvent`, so a
18634
+ * client that does not know it (an older viewer re-sending `conditions`
18635
+ * whole) leaves it standing through the store's patch merge.
18636
+ */
18637
+ systemEventDelivery: NcSystemEventDeliverySchema.optional(),
17838
18638
  /** May be empty when `targetUsers` addresses at least one user — the
17839
18639
  * "at least one addressee" invariant is enforced by the provider, because
17840
18640
  * a cross-field refine here would break `NcRulePatchSchema.partial()`. */
@@ -18063,6 +18863,28 @@ var NcRuleSchema = NcRuleInputSchema.extend({
18063
18863
  */
18064
18864
  disabledTargetIds: array(string()).default([])
18065
18865
  });
18866
+ /** One section of a previewed state summary. `unavailable` = its state could not be read. */
18867
+ var NcStateSummaryPreviewSectionSchema = object({
18868
+ id: string(),
18869
+ status: _enum(["read", "unavailable"]),
18870
+ items: number().int().nonnegative(),
18871
+ reason: string().optional()
18872
+ });
18873
+ /**
18874
+ * The summary a rule would send now. `empty` = nothing to report and every
18875
+ * section read: such a summary is NOT sent. `dropped` counts the open states
18876
+ * the rule's own filters (or a camera mute) left out, by reason.
18877
+ * `excludedGroups` names the kind groups selected that have no state to report
18878
+ * (backups & exports).
18879
+ */
18880
+ var NcStateSummaryPreviewSchema = object({
18881
+ empty: boolean(),
18882
+ count: number().int().nonnegative(),
18883
+ text: string(),
18884
+ sections: array(NcStateSummaryPreviewSectionSchema),
18885
+ dropped: record(string(), number().int().nonnegative()),
18886
+ excludedGroups: array(string())
18887
+ });
18066
18888
  var NcTestResultSchema = object({
18067
18889
  recordId: string(),
18068
18890
  recordKind: _enum([
@@ -18080,9 +18902,29 @@ var NcTestResultSchema = object({
18080
18902
  className: string().optional(),
18081
18903
  label: string().optional()
18082
18904
  });
18083
- /** The five rule kinds, as data. `NcRuleKind` in `notification/rule-kinds.ts`
18084
- * is the same union; the template-vars spec pins the two together. */
18905
+ /** The rule kinds, as data. `NcRuleKind` in `notification/rule-kinds.ts` is
18906
+ * `z.infer` of this schema — one shape, no twin. `mixed` is DERIVED
18907
+ * (a stored system rule whose kinds span families, D637) and never authored. */
18085
18908
  var NcRuleKindSchema = _enum([
18909
+ "detection",
18910
+ "sensor",
18911
+ "occupancy",
18912
+ "sound",
18913
+ "device-events",
18914
+ "system",
18915
+ "alarm",
18916
+ "mixed"
18917
+ ]);
18918
+ /**
18919
+ * The kinds a SERVED template-variable descriptor may name: the five that
18920
+ * existed before D637, frozen. `getTemplateCatalog` ships `kinds` to every
18921
+ * installed viewer, and a viewer at `@camstack/types` 1.2.25x parses them with a
18922
+ * strict five-member enum — one `device-events` in one descriptor fails the
18923
+ * whole catalog parse. So the WIRE says `system`, and the MATCH widens it:
18924
+ * `templateVarKindApplies` reads a `system` descriptor as applying to every
18925
+ * system rule kind (`device-events`, `system`, `alarm`, `mixed`).
18926
+ */
18927
+ var NcTemplateVarKindSchema = _enum([
18086
18928
  "detection",
18087
18929
  "sensor",
18088
18930
  "occupancy",
@@ -18120,7 +18962,7 @@ var NcTemplateVarGroupSchema = _enum([
18120
18962
  *
18121
18963
  * `families` / `fields` / `kinds` / `deliveries` / `systemEventKinds` say WHERE
18122
18964
  * it has a value; absent = no restriction on that axis. `systemEventKinds` is
18123
- * read only for a `system` rule. `dynamic` declares a FAMILY of names
18965
+ * read only for a system-event rule (any family, or `mixed`). `dynamic` declares a FAMILY of names
18124
18966
  * (`count_<class>`): the descriptor's `name` is the example member.
18125
18967
  */
18126
18968
  var NcTemplateVarDescriptorSchema = object({
@@ -18131,9 +18973,16 @@ var NcTemplateVarDescriptorSchema = object({
18131
18973
  group: NcTemplateVarGroupSchema,
18132
18974
  families: array(NcTemplateFamilySchema).min(1),
18133
18975
  fields: array(NcTemplateFieldSchema).optional(),
18134
- kinds: array(NcRuleKindSchema).optional(),
18976
+ kinds: array(NcTemplateVarKindSchema).optional(),
18135
18977
  deliveries: array(NcDeliverySchema).optional(),
18136
18978
  systemEventKinds: array(NcSystemEventKindSchema).optional(),
18979
+ /**
18980
+ * Which system-event DELIVERY has a value for it (D647). Absent = an
18981
+ * instant row only when the descriptor names `systemEventKinds` (a
18982
+ * per-event fact: a summary row has no single device), and both otherwise.
18983
+ * `['summary']` marks the state-summary vocabulary (`{{summaryText}}`, ...).
18984
+ */
18985
+ systemEventDeliveries: array(NcSystemEventDeliveryModeSchema).optional(),
18137
18986
  dynamic: object({
18138
18987
  prefix: literal("count_"),
18139
18988
  from: literal("classes")
@@ -18146,7 +18995,9 @@ var NcTemplatePreviewInputSchema = object({
18146
18995
  field: NcTemplateFieldSchema,
18147
18996
  kind: NcRuleKindSchema.optional(),
18148
18997
  delivery: NcDeliverySchema.optional(),
18149
- systemEventKinds: array(NcSystemEventKindSchema).optional()
18998
+ systemEventKinds: array(NcSystemEventKindSchema).optional(),
18999
+ /** The rule's system-event delivery (D647); absent = instant. */
19000
+ systemEventDelivery: NcSystemEventDeliveryModeSchema.optional()
18150
19001
  }),
18151
19002
  template: object({
18152
19003
  title: string().max(500).optional(),
@@ -18179,6 +19030,7 @@ var NcConditionDescriptorSchema = object({
18179
19030
  /** Editor widget the UI renders — never hardcode per-condition forms. */
18180
19031
  valueType: _enum([
18181
19032
  "deviceIdList",
19033
+ "deviceIdExcludeList",
18182
19034
  "stringList",
18183
19035
  "number01",
18184
19036
  "number",
@@ -18189,6 +19041,7 @@ var NcConditionDescriptorSchema = object({
18189
19041
  "plateMatcher",
18190
19042
  "packagePhase",
18191
19043
  "crossingSelect",
19044
+ "sensorTransition",
18192
19045
  "polygonDraw",
18193
19046
  "occupancy",
18194
19047
  "audio",
@@ -18339,6 +19192,28 @@ var NcHistoryFilterSchema = object({
18339
19192
  limit: number().int().min(1).max(500).default(100)
18340
19193
  });
18341
19194
  /**
19195
+ * Every rule's last run, in one answer.
19196
+ *
19197
+ * A rule ABSENT from `runs` produced no delivery inside `horizonMs` — how far
19198
+ * back this answer looked, in ms before the hub's now. It is the outbox prune
19199
+ * window (7 days by default, operator-configurable), NARROWED when the read hit
19200
+ * its row bound: the answer never claims a window it did not read. `null` means
19201
+ * the operator keeps the outbox forever AND the read reached its end, so absent
19202
+ * means "never on record". A UI derives its "not in the last N days" from this
19203
+ * value, never from a constant — and only when the call ANSWERED (D315).
19204
+ */
19205
+ var NcRuleLastRunsSchema = object({
19206
+ runs: array(object({
19207
+ ruleId: string(),
19208
+ /** Fire time of the newest row (`createdAt`, epoch ms). */
19209
+ lastAt: number(),
19210
+ status: NcHistoryStatusSchema,
19211
+ /** The camera/device of that row (a digest row files under its first camera). */
19212
+ deviceId: number()
19213
+ })),
19214
+ horizonMs: number().nonnegative().nullable()
19215
+ });
19216
+ /**
18342
19217
  * What a snooze covers. Broader scopes win when several overlap, so one window
18343
19218
  * leaves ONE digest rather than a rule snooze and a whole-feed snooze both
18344
19219
  * summarising the same silence.
@@ -18519,6 +19394,14 @@ var NcAlarmModeCoverageSchema = object({
18519
19394
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
18520
19395
  deviceIds: array(number().int()),
18521
19396
  /**
19397
+ * D641: the ids NOT covered although `allDevices` is true — every unscoped
19398
+ * covering rule EXCLUDES them (`conditions.devicesExclude`) and no named rule
19399
+ * covers them. Always `[]` when `allDevices` is false. Excluded by the rules,
19400
+ * which is not the same as skipped by a switch: never in `skippedDevices`.
19401
+ * Defaulted so an answer computed before this field parses as "none".
19402
+ */
19403
+ allDevicesExcept: array(number().int()).default([]),
19404
+ /**
18522
19405
  * Devices this mode NAMES but cannot actually arm, each with the switch that
18523
19406
  * excludes it.
18524
19407
  *
@@ -18648,13 +19531,17 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
18648
19531
  }), object({ results: array(NcTestResultSchema) }), {
18649
19532
  kind: "mutation",
18650
19533
  auth: "admin"
19534
+ }), method(object({ rule: NcRuleInputSchema }), NcStateSummaryPreviewSchema, {
19535
+ kind: "mutation",
19536
+ auth: "admin",
19537
+ access: "view"
18651
19538
  }), method(object({}), object({
18652
19539
  catalog: array(NcConditionDescriptorSchema),
18653
19540
  taxonomy: NcTaxonomySchema.optional()
18654
19541
  })), method(object({}), object({ vars: array(NcTemplateVarDescriptorSchema) })), method(NcTemplatePreviewInputSchema, NcTemplatePreviewSchema, {
18655
19542
  kind: "mutation",
18656
19543
  access: "view"
18657
- }), 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 }), {
19544
+ }), 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 }), {
18658
19545
  kind: "mutation",
18659
19546
  caller: "required"
18660
19547
  }), method(object({ snoozeId: string() }), object({ success: literal(true) }), {
@@ -18994,605 +19881,129 @@ var OauthIntegrationDescriptorSchema = object({
18994
19881
  });
18995
19882
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
18996
19883
  /**
18997
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
18998
- * within the frame, so the executor can re-cut a leaf child ROI at native
18999
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
19000
- */
19001
- var NativeCropRefSchema = object({
19002
- /** Handle keying the retained native surface (node-pinned to its owner). */
19003
- handle: FrameHandleSchema,
19004
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
19005
- cropFrameSpace: object({
19006
- x: number(),
19007
- y: number(),
19008
- w: number(),
19009
- h: number()
19010
- })
19011
- });
19012
- object({
19013
- crop: object({
19014
- left: number(),
19015
- top: number(),
19016
- width: number().positive(),
19017
- height: number().positive()
19018
- }).optional(),
19019
- content: object({
19020
- width: number().int().positive(),
19021
- height: number().int().positive()
19022
- }),
19023
- fit: _enum(["stretch", "contain"]),
19024
- format: _enum([
19025
- "rgb",
19026
- "gray",
19027
- "jpeg"
19028
- ])
19029
- });
19030
- /**
19031
- * Process-local frame identity. It is serializable so it can ride an in-process
19032
- * capability call, but `registryId` deliberately prevents resolution in any
19033
- * other process or execution group.
19034
- */
19035
- var FrameRefSchema = object({
19036
- registryId: string().min(1),
19037
- id: string().min(1),
19038
- width: number().int().positive(),
19039
- height: number().int().positive(),
19040
- format: _enum(["rgb", "gray"]),
19041
- timestamp: number(),
19042
- capturedAt: number().optional()
19043
- });
19044
- var ModelFormatSchema$1 = _enum([
19045
- "onnx",
19046
- "coreml",
19047
- "openvino",
19048
- "tflite",
19049
- "pt",
19050
- "gguf"
19051
- ]);
19052
- var PipelineSlotSchema = _enum([
19053
- "detector",
19054
- "cropper",
19055
- "classifier",
19056
- "refiner",
19057
- "audio-classifier"
19058
- ]);
19059
- var PipelineEngineChoiceSchema = object({
19060
- runtime: _enum(["node", "python"]),
19061
- backend: string(),
19062
- format: ModelFormatSchema$1,
19063
- device: string().optional()
19064
- });
19065
- var AvailableEngineSchema = object({
19066
- engine: PipelineEngineChoiceSchema,
19067
- devices: array(object({
19068
- id: string(),
19069
- label: string(),
19070
- description: string().optional()
19071
- })).readonly(),
19072
- defaultDevice: string()
19073
- });
19074
- var PipelineDefaultStepSchema = lazy(() => object({
19075
- addonId: string(),
19076
- addonName: string(),
19077
- slot: PipelineSlotSchema,
19078
- inputClasses: array(string()).readonly(),
19079
- outputClasses: array(string()).readonly(),
19080
- enabled: boolean(),
19081
- modelId: string(),
19082
- children: array(PipelineDefaultStepSchema).readonly(),
19083
- group: string().optional(),
19084
- settings: record(string(), unknown()).optional()
19085
- }));
19086
- var PipelineTemplateStepSchema = lazy(() => object({
19087
- addonId: string(),
19088
- enabled: boolean(),
19089
- modelId: string(),
19090
- children: array(PipelineTemplateStepSchema).readonly(),
19091
- settings: record(string(), unknown()).optional()
19092
- }));
19093
- var PipelineTemplateSchema$1 = object({
19094
- id: string(),
19095
- name: string(),
19096
- createdAt: string(),
19097
- updatedAt: string(),
19098
- engine: PipelineEngineChoiceSchema,
19099
- steps: array(PipelineTemplateStepSchema).readonly()
19100
- });
19101
- var PipelineModelOptionSchema = object({
19102
- id: string(),
19103
- name: string(),
19104
- formats: record(string(), object({
19105
- downloaded: boolean(),
19106
- sizeMB: number()
19107
- })),
19108
- group: ModelVariantGroupSchema.optional(),
19109
- legacy: boolean().optional(),
19110
- provider: ModelProviderIdSchema.optional()
19111
- });
19112
- var ConfigFieldBridge = custom();
19113
- var PipelineAddonSchemaSchema = object({
19114
- id: string(),
19115
- name: string(),
19116
- slot: PipelineSlotSchema,
19117
- inputClasses: array(string()).readonly(),
19118
- outputClasses: array(string()).readonly(),
19119
- childSlots: array(PipelineSlotSchema).readonly(),
19120
- models: array(PipelineModelOptionSchema).readonly(),
19121
- defaultModelId: string(),
19122
- defaultModelIdByFormat: record(string(), string()).optional(),
19123
- enabledByDefault: boolean().optional(),
19124
- backfillIntoExistingOverrides: boolean().optional(),
19125
- defaultConfidence: number(),
19126
- group: string().optional(),
19127
- configSchema: array(ConfigFieldBridge).readonly().optional()
19128
- });
19129
- var PipelineSlotSchemaSchema = object({
19130
- id: PipelineSlotSchema,
19131
- label: string(),
19132
- priority: number(),
19133
- parentSlot: PipelineSlotSchema.nullable(),
19134
- addons: array(PipelineAddonSchemaSchema).readonly()
19135
- });
19136
- var PipelineSchemaSchema = object({
19137
- availableEngines: array(AvailableEngineSchema).readonly(),
19138
- selectedEngine: PipelineEngineChoiceSchema,
19139
- slots: array(PipelineSlotSchemaSchema).readonly()
19140
- });
19141
- var EngineProvisioningSchema = object({
19142
- runtimeId: _enum([
19143
- "onnx",
19144
- "openvino",
19145
- "coreml",
19146
- "edgetpu"
19147
- ]).nullable(),
19148
- device: string().nullable(),
19149
- state: _enum([
19150
- "idle",
19151
- "installing",
19152
- "verifying",
19153
- "ready",
19154
- "failed"
19155
- ]),
19156
- progress: number().optional(),
19157
- error: string().optional(),
19158
- nextRetryAt: number().optional(),
19159
- /**
19160
- * Gate A (config-correctness gate at engine change): human-readable
19161
- * config issues surfaced EAGERLY when the node's engine changes — model
19162
- * substitutions ("chose X, running Y") and zero-build steps ("no model
19163
- * has a <format> build"). Additive/optional: informational only, never
19164
- * enforced here — `assertEngineReady` (readiness) still gates inference.
19165
- * Absent/empty when the node-default tree resolves cleanly.
19166
- */
19167
- configIssues: array(string()).optional()
19168
- });
19169
- var PipelineStepInputSchema = lazy(() => object({
19170
- addonId: string(),
19171
- modelId: string().optional(),
19172
- enabled: boolean().default(true),
19173
- children: array(PipelineStepInputSchema).optional(),
19174
- settings: record(string(), unknown()).optional(),
19175
- jumpDeviceKey: string().optional()
19176
- }));
19177
- var ModelSubstitutionSchema = object({
19178
- addonId: string(),
19179
- chosen: string(),
19180
- running: string(),
19181
- format: string()
19182
- });
19183
- var PipelineValidationIssueSchema = object({
19184
- addonId: string(),
19185
- kind: _enum(["unknown-addon", "no-format-build"]),
19186
- detail: string()
19187
- });
19188
- var PipelineValidationResultSchema = object({
19189
- ok: boolean(),
19190
- issues: array(PipelineValidationIssueSchema).readonly(),
19191
- substitutions: array(ModelSubstitutionSchema).readonly(),
19192
- /** The node's `currentEngine.format` this validation ran against. */
19193
- format: string()
19194
- });
19195
- var ReferenceImageEntrySchema = object({
19196
- filename: string(),
19197
- stepIds: array(string()).readonly().optional()
19198
- });
19199
- var ReferenceImageBodySchema = object({
19200
- base64: string(),
19201
- filename: string()
19202
- });
19203
- var ReferenceAudioEntrySchema = object({
19204
- filename: string(),
19205
- sizeKb: number()
19206
- });
19207
- var ReferenceAudioBodySchema = object({ base64: string() });
19208
- var AudioBackendSchema = object({
19209
- id: string(),
19210
- name: string(),
19211
- description: string(),
19212
- available: boolean(),
19213
- /**
19214
- * Raw classifier labels this backend can emit (e.g. YAMNet's
19215
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
19216
- * the benchmark UI to populate the `enabledMicroClasses` filter
19217
- * specific to the selected backend without a separate fetch.
19218
- */
19219
- rawLabels: array(string()).readonly().optional()
19220
- });
19221
- var AudioCapabilitiesSchema = object({
19222
- activeBackend: string(),
19223
- availableBackends: array(AudioBackendSchema).readonly(),
19224
- sampleRate: number(),
19225
- chunkDurationMs: number()
19226
- });
19227
- var DownloadModelResultSchema = object({
19228
- filePath: string(),
19229
- sizeMB: number(),
19230
- durationMs: number()
19231
- });
19232
- /**
19233
- * Wrapper carrying a single test run's result. Replaces the legacy
19234
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
19235
- * canonical `AudioResult` from the Phase 6 output rework: one
19236
- * `AudioDetection` per class above `minScore`, top-N candidates in
19237
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
19238
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
19239
- * benchmark UI can still report a clean failure when the classifier
19240
- * cap isn't available.
19241
- */
19242
- var AudioTestResultSchema = object({
19243
- success: boolean(),
19244
- error: string().optional(),
19245
- frame: custom().optional()
19246
- });
19247
- var PipelineConfigBridge = custom();
19248
- var ConfigUISchemaBridge = custom();
19249
- var ConfigUISchemaNullableBridge = custom();
19250
- var InferenceCapabilitiesBridge = custom();
19251
- var ModelAvailabilityListBridge = custom();
19252
- var PipelineRunResultBridge = custom();
19253
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
19254
- modelId: string(),
19255
- settings: record(string(), unknown()).readonly()
19256
- }))), method(object({ steps: record(string(), object({
19257
- modelId: string(),
19258
- settings: record(string(), unknown()).readonly()
19259
- })) }), object({ success: literal(true) }), {
19260
- kind: "mutation",
19261
- auth: "admin"
19262
- }), method(object({ nodeId: string() }), object({
19263
- success: literal(true),
19264
- clearedDevices: number()
19265
- }), {
19266
- kind: "mutation",
19267
- auth: "admin"
19268
- }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
19269
- /** `<backend>:<device>`, e.g. `openvino:gpu`. */
19270
- deviceKey: string(),
19271
- /**
19272
- * `failed` — the per-device restart budget is exhausted; no pool
19273
- * will be spawned until an operator re-arms it or the runner
19274
- * respawns. `backoff` — under budget, waiting out the backoff (or
19275
- * a cached pool observed dead and not yet condemned).
19276
- */
19277
- state: _enum(["failed", "backoff"]),
19278
- /** Epoch ms of the death that produced this state. */
19279
- since: number(),
19280
- /** Pool deaths inside the current window. */
19281
- deaths: number(),
19282
- /** The last death's message. */
19283
- lastError: string()
19284
- })).readonly() })), method(object({
19285
- nodeId: string(),
19286
- deviceKey: string()
19287
- }), object({ rearmed: boolean() }), {
19288
- kind: "mutation",
19289
- auth: "admin"
19290
- }), 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({
19291
- name: string(),
19292
- steps: array(PipelineTemplateStepSchema).readonly(),
19293
- engine: PipelineEngineChoiceSchema
19294
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
19295
- id: string(),
19296
- name: string().optional(),
19297
- steps: array(PipelineTemplateStepSchema).readonly().optional()
19298
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
19299
- addonId: string(),
19300
- modelId: string(),
19301
- format: ModelFormatSchema$1
19302
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
19303
- addonId: string(),
19304
- modelId: string(),
19305
- format: ModelFormatSchema$1
19306
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
19307
- engine: PipelineEngineChoiceSchema.optional(),
19308
- steps: array(PipelineStepInputSchema).min(1),
19309
- frame: FrameInputSchema.optional(),
19310
- /**
19311
- * Process-local lazy frame. Valid only when caller and provider resolve
19312
- * in the same execution-group process; split/cross-node callers use
19313
- * `frame`/`image` inline compatibility instead.
19314
- */
19315
- frameRef: FrameRefSchema.optional(),
19316
- /**
19317
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
19318
- * the decoded pixels live in. One more member of the one-of
19319
- * frame/frameHandle/image/imageBase64/referenceImage group.
19320
- */
19321
- frameHandle: FrameHandleSchema.optional(),
19322
- imageBase64: string().optional(),
19323
- /**
19324
- * Binary JPEG bytes — preferred over `imageBase64` on internal
19325
- * hops (hub → forked worker via Moleculer MsgPack) because it
19326
- * skips the 33% base64 overhead + the per-call base64 decode on
19327
- * the detection-pipeline worker. Callers can pass either; exactly
19328
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
19329
- */
19330
- image: _instanceof(Uint8Array).optional(),
19331
- referenceImage: string().optional(),
19332
- deviceId: number().optional(),
19333
- sessionId: string().optional(),
19334
- /**
19335
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
19336
- * reference-image, and detail-subtree calls. 'frame' is the live
19337
- * per-frame dispatch: ONLY root-plane steps run; crop children
19338
- * (inputClasses ≠ null) are skipped and served per-track via
19339
- * pipelineRunner.runDetailSubtree (two-plane design).
19340
- */
19341
- plane: _enum(["full", "frame"]).optional(),
19342
- /**
19343
- * Inference-device selector (Phase 2 multi-device). Format
19344
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
19345
- * Omitted ⇒ the runner's default device (current single-engine
19346
- * behaviour). Selects WHICH device pool of the node runs the call.
19347
- */
19348
- deviceKey: string().optional(),
19349
- /**
19350
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
19351
- * when the parent crop was resolved from the frame's retained NATIVE
19352
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
19353
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
19354
- * resolution from that surface — the SAME quality path faces already
19355
- * had — instead of the downscaled parent tile. `handle` keys the native
19356
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
19357
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
19358
- * the executor's crop-normalized child ROI back into frame-normalized
19359
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
19360
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
19361
- * (today's behaviour on the fallback path).
19362
- */
19363
- nativeCropRef: NativeCropRefSchema.optional()
19364
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
19365
- engine: PipelineEngineChoiceSchema.optional(),
19366
- steps: array(PipelineStepInputSchema).min(1),
19367
- frames: array(FrameInputSchema).min(1).max(255),
19368
- deviceId: number().optional(),
19369
- sessionId: string().optional(),
19370
- /**
19371
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
19372
- * the batch to the Python pool's bench preprocess cache
19373
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
19374
- * preprocessed ONCE and every later inference is a pure-inference cache
19375
- * hit — the sustained-throughput run measures inference, not
19376
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
19377
- * full preprocess every call, correct). Fresh per sustained run;
19378
- * released via `uncacheFrame`.
19379
- */
19380
- frameId: number().int().nonnegative().optional(),
19381
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
19382
- deviceKey: string().optional()
19383
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
19384
- data: _instanceof(Uint8Array),
19385
- width: number().int().positive(),
19386
- height: number().int().positive(),
19387
- format: _enum([
19388
- "rgb",
19389
- "bgr",
19390
- "gray"
19391
- ])
19392
- }), object({
19393
- frameId: number(),
19394
- width: number(),
19395
- height: number()
19396
- }), { kind: "mutation" }), method(object({
19397
- stepId: string(),
19398
- frameId: number().int()
19399
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
19400
- batchMode: string(),
19401
- windowMs: number(),
19402
- maxBatchSize: number(),
19403
- concurrency: number()
19404
- })), method(_void(), array(object({
19405
- engineKey: string(),
19406
- engine: PipelineEngineChoiceSchema,
19407
- modelsLoaded: array(string()).readonly(),
19408
- inUseByCameras: array(number()).readonly(),
19409
- /**
19410
- * Origin of this resident factory.
19411
- * - `runtime` — main camera-serving engine (no idle TTL).
19412
- * - `warm-override` — benchmark/test override held in the warm
19413
- * cache; auto-disposed after the idle TTL.
19414
- * - `device-pool` — a concurrent per-device pool (Phase 2
19415
- * multi-device, keyed by `deviceKey`) resolved
19416
- * via `resolveDeviceFactory`. Runs alongside the
19417
- * `runtime` engine on a DIFFERENT accelerator
19418
- * (NPU / iGPU / Coral) — this is how the
19419
- * Engines tab shows all pools running at once.
19420
- */
19421
- kind: _enum([
19422
- "runtime",
19423
- "warm-override",
19424
- "device-pool"
19425
- ]),
19426
- /** Native pid of the underlying Python pool (null when no pool). */
19427
- poolPid: number().nullable(),
19428
- /** ms since this factory was last used (null when not warm-tracked). */
19429
- idleMs: number().nullable(),
19430
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
19431
- idleTtlMs: number().nullable()
19432
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
19433
- kind: "mutation",
19434
- auth: "admin"
19435
- }), method(object({
19436
- engine: PipelineEngineChoiceSchema,
19437
- force: boolean().optional()
19438
- }), object({
19439
- success: boolean(),
19440
- reason: string().optional()
19441
- }), {
19442
- kind: "mutation",
19443
- auth: "admin"
19444
- }), 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({
19445
- addonId: string(),
19446
- modelId: string(),
19447
- filename: string().optional(),
19448
- settings: record(string(), unknown()).optional()
19449
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
19450
- /**
19451
- * Per-stage gating mode applied to the zones a rule references.
19452
- *
19453
- * - `include`: the rule contributes to a **whitelist** for its stage.
19454
- * When at least one `include` rule fires for a stage, only entities
19455
- * inside one of those zones pass that stage.
19456
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
19457
- * Entities inside one of those zones are dropped at that stage.
19458
- *
19459
- * `monitor`-style observation (count without filtering) is not a rule
19460
- * mode — zones without any matching rule are observed naturally by
19461
- * `zone-analytics` (live snapshot + history), so an "I just want to
19462
- * count, not filter" use case needs no rule at all.
19463
- */
19464
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
19465
- /**
19466
- * Per-consumer rule that references existing zones (geometry) and
19467
- * defines how a specific pipeline stage should treat them. Each
19468
- * consumer addon owns its own `ZoneRule[]` array in its per-device
19469
- * settings:
19470
- *
19471
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
19472
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
19473
- * - future: notification rules, audio gating, etc.
19474
- *
19475
- * One rule applies to N zones (`zoneIds[]`) so the operator can
19476
- * express "ignore motion in ALL of {garden, street}" with a single
19477
- * rule. `classFilter` narrows the rule to specific object classes —
19478
- * "drop person detections in the street, but keep cars" is one
19479
- * `exclude` rule with `classFilter: ['person']`.
19480
- *
19481
- * `enabled` is a soft toggle — the operator can keep the rule
19482
- * configured but inert without deleting it.
19483
- */
19484
- var ZoneRuleSchema = object({
19485
- /** Stable rule id — survives edits, used by the UI for diffing. */
19486
- id: string(),
19487
- /** Optional human-readable label rendered in the rule editor. */
19488
- name: string().optional(),
19489
- /** Zones this rule targets. The rule's `mode` applies to ALL
19490
- * listed zones (OR-set: a detection in any one of them counts).
19491
- * At least one zone id required — a rule with no targets is a
19492
- * configuration mistake and the form validator rejects it. */
19493
- zoneIds: array(string()).min(1).readonly(),
19494
- mode: ZoneRuleModeEnum,
19495
- /**
19496
- * Class names this rule applies to. Empty / undefined ⇒ rule
19497
- * applies to every class. Class strings match the `macroClass`
19498
- * field on detections (e.g. `person`, `car`, `dog`).
19499
- */
19500
- classFilter: array(string()).readonly().optional(),
19501
- /**
19502
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
19503
- * required to consider an entity "in the zone". Defaults to the
19504
- * consumer's stage default when omitted. Kept for back-compat with
19505
- * existing per-rule overrides; new operators pick the value via
19506
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
19507
- * set, the lower-level engine reads it as a 0–1 fraction.
19508
- */
19509
- overlapThreshold: number().min(0).max(1).optional(),
19510
- /**
19511
- * Operator-friendly version of `overlapThreshold` — the percentage
19512
- * of the detection's bbox that must lie inside the zone for the
19513
- * rule to match. Documented default is 85%; the engine substitutes
19514
- * that when the field is omitted (kept optional so existing rules
19515
- * stored without it stay valid).
19516
- *
19517
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
19518
- * rule, the engine prefers `bboxInclusionPct` because it's the
19519
- * field exposed in the UI. Internally both feed the same gate.
19520
- */
19521
- bboxInclusionPct: number().min(0).max(100).optional(),
19522
- /**
19523
- * When `true` and a detection has a segmentation mask, use the
19524
- * mask for overlap instead of the bbox. Detection-stage only;
19525
- * motion rules ignore this field.
19526
- */
19527
- preferMask: boolean().optional(),
19528
- /**
19529
- * Soft-toggle: `false` disables the rule without deleting it.
19530
- * Defaults to `true` so operators creating a rule via the UI
19531
- * see it active immediately.
19532
- */
19533
- enabled: boolean().default(true)
19534
- });
19535
- array(ZoneRuleSchema).readonly();
19536
- /**
19537
- * Zone — pure geometry + identity. NO filtering behaviour.
19538
- *
19539
- * Zones describe **where** in the frame the operator wants to flag
19540
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
19541
- * each pipeline stage uses them. Splitting the two means a single
19542
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
19543
- * a detection-include rule on `['car']`, and an occupancy aggregate
19544
- * — without three duplicated polygons.
19545
- *
19546
- * Owned by the orchestrator addon (provider) and mirrored into the
19547
- * `zones` device-state slice on every mutation. Consumers
19548
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
19549
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
19550
- * mirror with `onChanged`).
19551
- *
19552
- * Coordinates are normalised fractions of the frame (0–1) so zones
19553
- * survive resolution changes and stream profile switches.
19554
- *
19555
- * `kind` discriminates between full polygons (closed regions used
19556
- * for intrusion / occupancy filters) and tripwires (open 2-point
19557
- * line segments used for cross events). Onboard / firmware-reported
19558
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
19559
- * task list.
19560
- */
19561
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
19562
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
19563
- var PolygonPointSchema = object({
19564
- x: number(),
19565
- y: number()
19566
- });
19567
- /** A camera detection zone — pure geometry/identity. */
19568
- var ZoneSchema = object({
19569
- id: string(),
19570
- name: string(),
19571
- kind: ZoneKindEnum.default("polygon"),
19572
- /** Polygon vertices, fraction of frame (0–1). */
19573
- polygon: array(PolygonPointSchema).readonly(),
19574
- /** Visual color for UI rendering. */
19575
- color: string().default("#3b82f6")
19576
- });
19577
- DeviceType.Camera, method(object({ deviceId: number() }), array(ZoneSchema).readonly()), method(object({
19578
- deviceId: number(),
19579
- zone: ZoneSchema
19580
- }), _void(), {
19581
- kind: "mutation",
19582
- auth: "admin"
19583
- }), method(object({
19584
- deviceId: number(),
19585
- zoneId: string()
19586
- }), _void(), {
19587
- kind: "mutation",
19588
- auth: "admin"
19589
- }), method(object({
19590
- deviceId: number(),
19591
- zone: ZoneSchema
19592
- }), _void(), {
19593
- kind: "mutation",
19594
- auth: "admin"
19595
- }), object({ zones: array(ZoneSchema).readonly() });
19884
+ * A model choice has a SCOPE, and a scope change has a workflow.
19885
+ *
19886
+ * ## The two scopes
19887
+ *
19888
+ * Almost every pipeline step's model is a **node** question: which build runs
19889
+ * fastest on THIS accelerator. Two nodes may legitimately answer differently —
19890
+ * a Coral runs the tflite SSD, a Mac runs the coreml YOLO — because the answers
19891
+ * are compared against nothing. They produce boxes, and a box is a box.
19892
+ *
19893
+ * Two steps are not like that. `face-embedding` and `clip-embedding` produce
19894
+ * **vectors that land in ONE shared index** (`identity_samples`,
19895
+ * `vec_object_clip`) and are ranked against each other by cosine similarity.
19896
+ * Cosine similarity between two encoders is not a weak signal, it is a
19897
+ * meaningless number — and nothing inside a vector can tell you it happened.
19898
+ * So for those two steps the model is a **cluster** question with exactly one
19899
+ * answer, stored in exactly one row.
19900
+ *
19901
+ * That is the same argument [D52](../../../../docs/decisions/adr-0052.md) makes
19902
+ * for the crop convention (`detail-crop.ts`), one level up: the crop decides
19903
+ * WHAT pixels the encoder sees, this decides WHICH encoder sees them. Both are
19904
+ * cluster-wide for the same reason and neither may become per-node.
19905
+ *
19906
+ * ## Why the registry lives here and not in the step catalog
19907
+ *
19908
+ * The scope itself is declared on the step, in
19909
+ * `detection-pipeline/registry/step-definitions.ts` (`StepDefinition.modelScope`)
19910
+ * — that is where a new step declares what kind of choice its model is. But the
19911
+ * catalog lives inside `addon-pipeline`, and three packages that must NOT
19912
+ * import an addon need to know the set: the orchestrator (which renders and
19913
+ * stores the row), post-analysis (which pins the row for a re-embed pass) and
19914
+ * admin-ui (which mirrors it). So the set is mirrored here, and
19915
+ * `scripts/check-cluster-model-scope.ts` fails the build when the two disagree.
19916
+ * A hand-copied key that stops matching is exactly how a setting silently stops
19917
+ * arriving while both sides still look correct.
19918
+ *
19919
+ * ## The defaults ARE today's behaviour
19920
+ *
19921
+ * {@link DEFAULT_CLUSTER_STEP_MODELS} reproduces the catalog `defaultModelId`
19922
+ * of both steps. Declaring the scope therefore changes nothing on the day it
19923
+ * ships: the cluster row starts out saying what every node was already doing.
19924
+ * Changing it is legitimate — that is what the knob is for — but it invalidates
19925
+ * the stored vectors of that surface, and must be followed by a re-embed pass
19926
+ * (`face-reembed-pass.ts`, `embedding-rebuild.ts`).
19927
+ */
19928
+ /**
19929
+ * Why the orchestrator cannot say which model the operator chose for a
19930
+ * cluster-scoped step (D651).
19931
+ */
19932
+ var CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS = [
19933
+ "owner-not-ready",
19934
+ "store-read-failed",
19935
+ "three-way-read-unavailable",
19936
+ "invalid-stored",
19937
+ "not-cluster-scoped"
19938
+ ];
19939
+ Object.freeze(Object.fromEntries([{
19940
+ stepId: "face-embedding",
19941
+ label: "Face recognition model",
19942
+ defaultModelId: "auraface-r100",
19943
+ indexName: "the enrolled face gallery",
19944
+ options: [
19945
+ {
19946
+ id: "auraface-r100",
19947
+ label: "AuraFace R100"
19948
+ },
19949
+ {
19950
+ id: "arcface-r100",
19951
+ label: "ArcFace (ResNet34)"
19952
+ },
19953
+ {
19954
+ id: "inception-resnet-v1",
19955
+ label: "Inception ResNet V1"
19956
+ }
19957
+ ]
19958
+ }, {
19959
+ stepId: "clip-embedding",
19960
+ label: "Semantic search model",
19961
+ defaultModelId: "mobileclip-s1",
19962
+ indexName: "the object semantic-search index",
19963
+ options: [
19964
+ {
19965
+ id: "mobileclip-s1",
19966
+ label: "MobileCLIP S1"
19967
+ },
19968
+ {
19969
+ id: "mobileclip-s2",
19970
+ label: "MobileCLIP S2"
19971
+ },
19972
+ {
19973
+ id: "siglip2-b16-224",
19974
+ label: "SigLIP2 B/16 (Apache-2.0)"
19975
+ }
19976
+ ]
19977
+ }].map((s) => [s.stepId, s.defaultModelId])));
19978
+ var CLUSTER_STEP_SETTING_FIELDS = [{
19979
+ stepId: "face-embedding",
19980
+ key: "minLandmarkFaceSize",
19981
+ label: "Min face size for recognition (detection px)",
19982
+ 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.",
19983
+ type: "slider",
19984
+ min: 0,
19985
+ max: 64,
19986
+ step: 2,
19987
+ default: 24
19988
+ }];
19989
+ function clusterStepSettingKey(stepId, fieldKey) {
19990
+ return `clusterStepSetting:${stepId}:${fieldKey}`;
19991
+ }
19992
+ var ClusterSettingNumberSchema = number().finite();
19993
+ function readClusterStepSettings(config) {
19994
+ const out = {};
19995
+ for (const field of CLUSTER_STEP_SETTING_FIELDS) {
19996
+ const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
19997
+ const value = parsed.success ? parsed.data : field.default;
19998
+ const existing = out[field.stepId] ?? {};
19999
+ out[field.stepId] = {
20000
+ ...existing,
20001
+ [field.key]: value
20002
+ };
20003
+ }
20004
+ return out;
20005
+ }
20006
+ readClusterStepSettings({});
19596
20007
  /**
19597
20008
  * pipeline-analytics — device-scoped wrapper cap. Refines raw
19598
20009
  * per-frame detections emitted by the pipeline runner into tracked
@@ -20164,6 +20575,22 @@ var TrackSchema = object({
20164
20575
  * omit it. Render nothing when absent.
20165
20576
  */
20166
20577
  previewMissReason: string().optional(),
20578
+ /**
20579
+ * The ROOT model that produced this track — the `FrameResult.rootModelId` of
20580
+ * the frame it was BORN on (D646). What a later replay compares against, so
20581
+ * "the original model" is named rather than assumed. A birth fact: never
20582
+ * rewritten by a later frame. **Absent ≠ unknown-model**: a row from before
20583
+ * the column, and a track the camera's own detector produced, carry none.
20584
+ */
20585
+ modelId: string().optional(),
20586
+ /**
20587
+ * Size (px) of the detection frame this track's `positions[].bbox` live in —
20588
+ * the frame it was born on, else the camera's latest analysis frame at
20589
+ * persist time. Divide a position by these to normalise it. Absent when the
20590
+ * size was never known.
20591
+ */
20592
+ frameWidth: number().optional(),
20593
+ frameHeight: number().optional(),
20167
20594
  ...TrackFlagFields,
20168
20595
  ...TrackRetrainFields
20169
20596
  });
@@ -20375,6 +20802,13 @@ var AudioEventSchema = object({
20375
20802
  originalClass: string().optional(),
20376
20803
  score: number()
20377
20804
  }).optional(),
20805
+ /**
20806
+ * Whether the classifier RAN on the window behind this row (D660). Absent
20807
+ * on rows written before D660 — unknown, NOT classified: until then a
20808
+ * window the analyzer's busy gate threw away was stored exactly like one
20809
+ * that heard nothing above the floor.
20810
+ */
20811
+ classifyOutcome: AudioClassifyOutcomeSchema.optional(),
20378
20812
  /** Populated by B5 (recording playback URL for this event). */
20379
20813
  mediaUrl: string().optional()
20380
20814
  });
@@ -20393,7 +20827,8 @@ var MediaFileKindEnum = _enum([
20393
20827
  "thumbnailSmall",
20394
20828
  "confirmationCrop",
20395
20829
  "debugCrop",
20396
- "sceneFrame"
20830
+ "sceneFrame",
20831
+ "lastSceneFrame"
20397
20832
  ]);
20398
20833
  /**
20399
20834
  * One media row ON THE WIRE: what it is, how big it is, and WHERE ITS BYTES
@@ -20945,7 +21380,23 @@ var SearchObjectEventsInput = object({
20945
21380
  until: number().optional(),
20946
21381
  classFilter: string().optional(),
20947
21382
  limit: number().default(50),
20948
- minScore: number().min(0).max(1).default(.2)
21383
+ /**
21384
+ * An ABSOLUTE cosine floor. Optional since D649: a floor is a property of the
21385
+ * model (0.2 kept 96% of matched pairs on MobileCLIP S1 and 2.7% on SigLIP2),
21386
+ * so an absent one resolves to the searched model's own `searchMinScore`
21387
+ * scaled by `strictness`. A number sent here is honoured verbatim.
21388
+ */
21389
+ minScore: number().min(0).max(1).optional(),
21390
+ /** Model-relative floor — see `resolveClipSearchMinScore`. Default `loose`. */
21391
+ strictness: ClipSearchStrictnessSchema.optional(),
21392
+ /**
21393
+ * Search THIS CLIP model's index instead of the cluster row's. Every index a
21394
+ * model ever wrote stays searchable until it is wiped (the MobileCLIP index
21395
+ * through a SigLIP2 cutover and its rollback window). An id with no CLIP
21396
+ * metadata is refused; an id other than the cluster row's is ADMIN-only
21397
+ * (`model-override-requires-admin`).
21398
+ */
21399
+ modelId: string().min(1).optional()
20949
21400
  });
20950
21401
  var TrackCascadeCountsSchema = object({
20951
21402
  /** Persisted track roots deleted (authoritative). */
@@ -21080,7 +21531,41 @@ var RebuildObjectEmbeddingsInput = object({
21080
21531
  * comparable, so wiping and rebuilding is the only way to be sure every vector
21081
21532
  * means the same thing.
21082
21533
  */
21083
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
21534
+ var WipeObjectEmbeddingsResultSchema = object({
21535
+ deleted: number(),
21536
+ /**
21537
+ * CLIP indexes that could NOT be emptied (unreachable, or refused at their
21538
+ * dimension) — not a clean slate. Additive and optional (D649).
21539
+ */
21540
+ failedIndexes: array(string()).optional()
21541
+ });
21542
+ /**
21543
+ * Why a rebuild did not start, BY NAME — ONE vocabulary for both gates in front
21544
+ * of a pass (D649 over D651). A bare `started: false` read the same for "the
21545
+ * stores are booting" and "the cluster row names a model with no CLIP
21546
+ * metadata", which need different fixes.
21547
+ * - `stores-unavailable` — the analytics stores or the API are not up yet.
21548
+ * - the owner's confirmation of the cluster model (D651, `ClusterPinConfirmer`):
21549
+ * a pass that rewrites an index needs two agreeing reads of the OWNER's
21550
+ * answer (`pipelineOrchestrator.getClusterModelChoice`) — a pass that cannot
21551
+ * name its model does not run (D54):
21552
+ * - the owner's own `unreadable` reasons (`owner-not-ready`,
21553
+ * `store-read-failed`, `three-way-read-unavailable`, `invalid-stored`,
21554
+ * `not-cluster-scoped`);
21555
+ * - `method-unavailable` — the orchestrator predates the method;
21556
+ * - `read-failed` — the call failed or answered something unparseable;
21557
+ * - `reads-disagree` — the two reads named different choices.
21558
+ * - `not-a-clip-model` — the CONFIRMED id has no CLIP metadata, so there is no
21559
+ * index to fill and no dimension to check against (D649).
21560
+ */
21561
+ var RebuildObjectEmbeddingsRefusalSchema = _enum([
21562
+ "stores-unavailable",
21563
+ ...CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS,
21564
+ "method-unavailable",
21565
+ "read-failed",
21566
+ "reads-disagree",
21567
+ "not-a-clip-model"
21568
+ ]);
21084
21569
  /**
21085
21570
  * Acknowledgement that a rebuild STARTED.
21086
21571
  *
@@ -21093,7 +21578,12 @@ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
21093
21578
  var RebuildObjectEmbeddingsResultSchema = object({
21094
21579
  started: boolean(),
21095
21580
  /** True when a pass was already running; the new request is ignored. */
21096
- alreadyRunning: boolean()
21581
+ alreadyRunning: boolean(),
21582
+ /** Present when the pass refused to start — see `RebuildObjectEmbeddingsRefusalSchema`. */
21583
+ refusal: RebuildObjectEmbeddingsRefusalSchema.optional(),
21584
+ /** The CLIP model the pass pinned, and the index it fills (when it started). */
21585
+ modelId: string().optional(),
21586
+ index: string().optional()
21097
21587
  });
21098
21588
  var RebuildStatusSchema = object({
21099
21589
  running: boolean(),
@@ -21127,7 +21617,11 @@ var RebuildStatusSchema = object({
21127
21617
  startedAtMs: number().nullable(),
21128
21618
  finishedAtMs: number().nullable(),
21129
21619
  /** Present when the pass ended by throwing. */
21130
- error: string().nullable()
21620
+ error: string().nullable(),
21621
+ /** The CLIP model the current / last pass pinned (D54), `null` before any. */
21622
+ modelId: string().nullable(),
21623
+ /** The index that pass fills — `ClipModelMeta.vectorIndex` of `modelId` (D649). */
21624
+ index: string().nullable()
21131
21625
  });
21132
21626
  /**
21133
21627
  * Acknowledgement that a debug-media reclaim STARTED.
@@ -21170,24 +21664,6 @@ var MediaReclaimStatusSchema = object({
21170
21664
  finishedAtMs: number().nullable(),
21171
21665
  error: string().nullable()
21172
21666
  });
21173
- var ReplayFrameInputSchema = object({
21174
- timestamp: number(),
21175
- frame: PipelineRunResultBridge
21176
- });
21177
- var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
21178
- className: string(),
21179
- firstSeenMs: number(),
21180
- lastSeenMs: number(),
21181
- /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
21182
- * frame — a representative box for the diff's `(className, window, IoU)`
21183
- * pairing (`replay-diff.ts`). A replay does not need the full per-frame
21184
- * trajectory production's `Track.positions` keeps. */
21185
- bbox: BoundingBoxSchema,
21186
- /** How many of the input frames this track matched a real detection on
21187
- * (never a coasted/extrapolated frame) — the replay's own signal for "how
21188
- * solid is this track", cheaper than re-deriving it from a trajectory. */
21189
- framesMatched: number().int()
21190
- })).readonly() });
21191
21667
  /**
21192
21668
  * The long-term series a camera produces. A closed union so a typo cannot
21193
21669
  * invent one, and the ONE declaration of it — the addon's `AnalyticsLtsSeries`
@@ -21418,16 +21894,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
21418
21894
  }), RetrainAssistResultSchema, {
21419
21895
  kind: "mutation",
21420
21896
  auth: "admin"
21421
- }), method(object({
21422
- deviceId: number(),
21423
- source: DetectionSourceSchema,
21424
- zones: array(ZoneSchema).readonly().optional(),
21425
- detectionRules: array(ZoneRuleSchema).readonly().optional(),
21426
- zoneMembershipMinOverlap: number().min(0).max(1).optional(),
21427
- frames: array(ReplayFrameInputSchema).min(1)
21428
- }), RunReplayFrameProcessorResultSchema, {
21429
- kind: "mutation",
21430
- auth: "admin"
21431
21897
  }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
21432
21898
  kind: "query",
21433
21899
  auth: "admin"
@@ -21476,7 +21942,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
21476
21942
  deviceId: number(),
21477
21943
  ownerKind: MediaPresenceOwnerKindSchema,
21478
21944
  ownerIds: array(string()).max(5e3)
21479
- }), array(string()).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
21945
+ }), array(string()).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly(), { caller: "required" }), method(object({}), WipeObjectEmbeddingsResultSchema, {
21480
21946
  kind: "mutation",
21481
21947
  auth: "admin"
21482
21948
  }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
@@ -21503,6 +21969,485 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
21503
21969
  eventId: string(),
21504
21970
  timestamp: number()
21505
21971
  });
21972
+ /**
21973
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
21974
+ * within the frame, so the executor can re-cut a leaf child ROI at native
21975
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
21976
+ */
21977
+ var NativeCropRefSchema = object({
21978
+ /** Handle keying the retained native surface (node-pinned to its owner). */
21979
+ handle: FrameHandleSchema,
21980
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
21981
+ cropFrameSpace: object({
21982
+ x: number(),
21983
+ y: number(),
21984
+ w: number(),
21985
+ h: number()
21986
+ })
21987
+ });
21988
+ object({
21989
+ crop: object({
21990
+ left: number(),
21991
+ top: number(),
21992
+ width: number().positive(),
21993
+ height: number().positive()
21994
+ }).optional(),
21995
+ content: object({
21996
+ width: number().int().positive(),
21997
+ height: number().int().positive()
21998
+ }),
21999
+ fit: _enum(["stretch", "contain"]),
22000
+ format: _enum([
22001
+ "rgb",
22002
+ "gray",
22003
+ "jpeg"
22004
+ ])
22005
+ });
22006
+ /**
22007
+ * Process-local frame identity. It is serializable so it can ride an in-process
22008
+ * capability call, but `registryId` deliberately prevents resolution in any
22009
+ * other process or execution group.
22010
+ */
22011
+ var FrameRefSchema = object({
22012
+ registryId: string().min(1),
22013
+ id: string().min(1),
22014
+ width: number().int().positive(),
22015
+ height: number().int().positive(),
22016
+ format: _enum(["rgb", "gray"]),
22017
+ timestamp: number(),
22018
+ capturedAt: number().optional()
22019
+ });
22020
+ var ModelFormatSchema$1 = _enum([
22021
+ "onnx",
22022
+ "coreml",
22023
+ "openvino",
22024
+ "tflite",
22025
+ "pt",
22026
+ "gguf"
22027
+ ]);
22028
+ var PipelineSlotSchema = _enum([
22029
+ "detector",
22030
+ "cropper",
22031
+ "classifier",
22032
+ "refiner",
22033
+ "audio-classifier"
22034
+ ]);
22035
+ var PipelineEngineChoiceSchema = object({
22036
+ runtime: literal("python"),
22037
+ backend: string(),
22038
+ format: ModelFormatSchema$1,
22039
+ device: string().optional()
22040
+ });
22041
+ /**
22042
+ * One pool's resolved provisioning (`getEffectiveTuning`). `numWorkers` is the
22043
+ * knob that lifts a saturated pool (`inference-devices.md`); `concurrency` is
22044
+ * per-worker in-flight requests. `deviceKey` echoes the pool asked about —
22045
+ * `null` for the node-default pool.
22046
+ */
22047
+ var EffectiveTuningSchema = object({
22048
+ deviceKey: string().nullable(),
22049
+ runtime: string(),
22050
+ batchMode: string(),
22051
+ windowMs: number(),
22052
+ maxBatchSize: number(),
22053
+ concurrency: number(),
22054
+ numWorkers: number()
22055
+ });
22056
+ var AvailableEngineSchema = object({
22057
+ engine: PipelineEngineChoiceSchema,
22058
+ devices: array(object({
22059
+ id: string(),
22060
+ label: string(),
22061
+ description: string().optional()
22062
+ })).readonly(),
22063
+ defaultDevice: string()
22064
+ });
22065
+ var PipelineDefaultStepSchema = lazy(() => object({
22066
+ addonId: string(),
22067
+ addonName: string(),
22068
+ slot: PipelineSlotSchema,
22069
+ inputClasses: array(string()).readonly(),
22070
+ outputClasses: array(string()).readonly(),
22071
+ enabled: boolean(),
22072
+ modelId: string(),
22073
+ children: array(PipelineDefaultStepSchema).readonly(),
22074
+ group: string().optional(),
22075
+ settings: record(string(), unknown()).optional()
22076
+ }));
22077
+ var PipelineTemplateStepSchema = lazy(() => object({
22078
+ addonId: string(),
22079
+ enabled: boolean(),
22080
+ modelId: string(),
22081
+ children: array(PipelineTemplateStepSchema).readonly(),
22082
+ settings: record(string(), unknown()).optional()
22083
+ }));
22084
+ var PipelineTemplateSchema$1 = object({
22085
+ id: string(),
22086
+ name: string(),
22087
+ createdAt: string(),
22088
+ updatedAt: string(),
22089
+ engine: PipelineEngineChoiceSchema,
22090
+ steps: array(PipelineTemplateStepSchema).readonly()
22091
+ });
22092
+ var PipelineModelOptionSchema = object({
22093
+ id: string(),
22094
+ name: string(),
22095
+ formats: record(string(), object({
22096
+ downloaded: boolean(),
22097
+ sizeMB: number()
22098
+ })),
22099
+ group: ModelVariantGroupSchema.optional(),
22100
+ legacy: boolean().optional(),
22101
+ provider: ModelProviderIdSchema.optional()
22102
+ });
22103
+ var ConfigFieldBridge = custom();
22104
+ var PipelineAddonSchemaSchema = object({
22105
+ id: string(),
22106
+ name: string(),
22107
+ slot: PipelineSlotSchema,
22108
+ inputClasses: array(string()).readonly(),
22109
+ outputClasses: array(string()).readonly(),
22110
+ childSlots: array(PipelineSlotSchema).readonly(),
22111
+ models: array(PipelineModelOptionSchema).readonly(),
22112
+ defaultModelId: string(),
22113
+ defaultModelIdByFormat: record(string(), string()).optional(),
22114
+ enabledByDefault: boolean().optional(),
22115
+ backfillIntoExistingOverrides: boolean().optional(),
22116
+ defaultConfidence: number(),
22117
+ group: string().optional(),
22118
+ configSchema: array(ConfigFieldBridge).readonly().optional()
22119
+ });
22120
+ var PipelineSlotSchemaSchema = object({
22121
+ id: PipelineSlotSchema,
22122
+ label: string(),
22123
+ priority: number(),
22124
+ parentSlot: PipelineSlotSchema.nullable(),
22125
+ addons: array(PipelineAddonSchemaSchema).readonly()
22126
+ });
22127
+ var PipelineSchemaSchema = object({
22128
+ availableEngines: array(AvailableEngineSchema).readonly(),
22129
+ selectedEngine: PipelineEngineChoiceSchema,
22130
+ slots: array(PipelineSlotSchemaSchema).readonly()
22131
+ });
22132
+ var EngineProvisioningSchema = object({
22133
+ runtimeId: _enum([
22134
+ "onnx",
22135
+ "openvino",
22136
+ "coreml",
22137
+ "edgetpu"
22138
+ ]).nullable(),
22139
+ device: string().nullable(),
22140
+ state: _enum([
22141
+ "idle",
22142
+ "installing",
22143
+ "verifying",
22144
+ "ready",
22145
+ "failed"
22146
+ ]),
22147
+ progress: number().optional(),
22148
+ error: string().optional(),
22149
+ nextRetryAt: number().optional(),
22150
+ /**
22151
+ * Gate A (config-correctness gate at engine change): human-readable
22152
+ * config issues surfaced EAGERLY when the node's engine changes — model
22153
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
22154
+ * has a <format> build"). Additive/optional: informational only, never
22155
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
22156
+ * Absent/empty when the node-default tree resolves cleanly.
22157
+ */
22158
+ configIssues: array(string()).optional()
22159
+ });
22160
+ var PipelineStepInputSchema = lazy(() => object({
22161
+ addonId: string(),
22162
+ modelId: string().optional(),
22163
+ enabled: boolean().default(true),
22164
+ children: array(PipelineStepInputSchema).optional(),
22165
+ settings: record(string(), unknown()).optional(),
22166
+ jumpDeviceKey: string().optional()
22167
+ }));
22168
+ var ModelSubstitutionSchema = object({
22169
+ addonId: string(),
22170
+ chosen: string(),
22171
+ running: string(),
22172
+ format: string()
22173
+ });
22174
+ var PipelineValidationIssueSchema = object({
22175
+ addonId: string(),
22176
+ kind: _enum([
22177
+ "unknown-addon",
22178
+ "no-format-build",
22179
+ "unknown-device"
22180
+ ]),
22181
+ detail: string()
22182
+ });
22183
+ var PipelineValidationResultSchema = object({
22184
+ ok: boolean(),
22185
+ issues: array(PipelineValidationIssueSchema).readonly(),
22186
+ substitutions: array(ModelSubstitutionSchema).readonly(),
22187
+ /** The node's `currentEngine.format` this validation ran against. */
22188
+ format: string()
22189
+ });
22190
+ var ReferenceImageEntrySchema = object({
22191
+ filename: string(),
22192
+ stepIds: array(string()).readonly().optional()
22193
+ });
22194
+ var ReferenceImageBodySchema = object({
22195
+ base64: string(),
22196
+ filename: string()
22197
+ });
22198
+ var ReferenceAudioEntrySchema = object({
22199
+ filename: string(),
22200
+ sizeKb: number()
22201
+ });
22202
+ var ReferenceAudioBodySchema = object({ base64: string() });
22203
+ var AudioBackendSchema = object({
22204
+ id: string(),
22205
+ name: string(),
22206
+ description: string(),
22207
+ available: boolean(),
22208
+ /**
22209
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
22210
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
22211
+ * the benchmark UI to populate the `enabledMicroClasses` filter
22212
+ * specific to the selected backend without a separate fetch.
22213
+ */
22214
+ rawLabels: array(string()).readonly().optional()
22215
+ });
22216
+ var AudioCapabilitiesSchema = object({
22217
+ activeBackend: string(),
22218
+ availableBackends: array(AudioBackendSchema).readonly(),
22219
+ sampleRate: number(),
22220
+ chunkDurationMs: number()
22221
+ });
22222
+ var DownloadModelResultSchema = object({
22223
+ filePath: string(),
22224
+ sizeMB: number(),
22225
+ durationMs: number()
22226
+ });
22227
+ /**
22228
+ * Wrapper carrying a single test run's result. Replaces the legacy
22229
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
22230
+ * canonical `AudioResult` from the Phase 6 output rework: one
22231
+ * `AudioDetection` per class above `minScore`, top-N candidates in
22232
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
22233
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
22234
+ * benchmark UI can still report a clean failure when the classifier
22235
+ * cap isn't available.
22236
+ */
22237
+ var AudioTestResultSchema = object({
22238
+ success: boolean(),
22239
+ error: string().optional(),
22240
+ frame: custom().optional()
22241
+ });
22242
+ var PipelineConfigBridge = custom();
22243
+ var ConfigUISchemaBridge = custom();
22244
+ var ConfigUISchemaNullableBridge = custom();
22245
+ var InferenceCapabilitiesBridge = custom();
22246
+ var ModelAvailabilityListBridge = custom();
22247
+ var PipelineRunResultBridge = custom();
22248
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
22249
+ modelId: string(),
22250
+ settings: record(string(), unknown()).readonly()
22251
+ }))), method(object({ steps: record(string(), object({
22252
+ modelId: string(),
22253
+ settings: record(string(), unknown()).readonly()
22254
+ })) }), object({ success: literal(true) }), {
22255
+ kind: "mutation",
22256
+ auth: "admin"
22257
+ }), method(object({ nodeId: string() }), object({
22258
+ success: literal(true),
22259
+ clearedDevices: number()
22260
+ }), {
22261
+ kind: "mutation",
22262
+ auth: "admin"
22263
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
22264
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
22265
+ deviceKey: string(),
22266
+ /**
22267
+ * `failed` — the per-device restart budget is exhausted; no pool
22268
+ * will be spawned until an operator re-arms it or the runner
22269
+ * respawns. `backoff` — under budget, waiting out the backoff (or
22270
+ * a cached pool observed dead and not yet condemned).
22271
+ */
22272
+ state: _enum(["failed", "backoff"]),
22273
+ /** Epoch ms of the death that produced this state. */
22274
+ since: number(),
22275
+ /** Pool deaths inside the current window. */
22276
+ deaths: number(),
22277
+ /** The last death's message. */
22278
+ lastError: string()
22279
+ })).readonly() })), method(object({
22280
+ nodeId: string(),
22281
+ deviceKey: string()
22282
+ }), object({ rearmed: boolean() }), {
22283
+ kind: "mutation",
22284
+ auth: "admin"
22285
+ }), method(_void(), PipelineSchemaSchema), method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()), method(_void(), PipelineConfigBridge), method(_void(), ConfigUISchemaBridge), method(object({
22286
+ steps: array(PipelineStepInputSchema),
22287
+ deviceKey: string().optional()
22288
+ }), PipelineValidationResultSchema), method(_void(), array(PipelineTemplateSchema$1).readonly()), method(object({
22289
+ name: string(),
22290
+ steps: array(PipelineTemplateStepSchema).readonly(),
22291
+ engine: PipelineEngineChoiceSchema
22292
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
22293
+ id: string(),
22294
+ name: string().optional(),
22295
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
22296
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
22297
+ addonId: string(),
22298
+ modelId: string(),
22299
+ format: ModelFormatSchema$1
22300
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
22301
+ addonId: string(),
22302
+ modelId: string(),
22303
+ format: ModelFormatSchema$1
22304
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
22305
+ steps: array(PipelineStepInputSchema).min(1),
22306
+ frame: FrameInputSchema.optional(),
22307
+ /**
22308
+ * Process-local lazy frame. Valid only when caller and provider resolve
22309
+ * in the same execution-group process; split/cross-node callers use
22310
+ * `frame`/`image` inline compatibility instead.
22311
+ */
22312
+ frameRef: FrameRefSchema.optional(),
22313
+ /**
22314
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
22315
+ * the decoded pixels live in. One more member of the one-of
22316
+ * frame/frameHandle/image/imageBase64/referenceImage group.
22317
+ */
22318
+ frameHandle: FrameHandleSchema.optional(),
22319
+ imageBase64: string().optional(),
22320
+ /**
22321
+ * Binary JPEG bytes — preferred over `imageBase64` on internal
22322
+ * hops (hub → forked worker via Moleculer MsgPack) because it
22323
+ * skips the 33% base64 overhead + the per-call base64 decode on
22324
+ * the detection-pipeline worker. Callers can pass either; exactly
22325
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
22326
+ */
22327
+ image: _instanceof(Uint8Array).optional(),
22328
+ referenceImage: string().optional(),
22329
+ deviceId: number().optional(),
22330
+ sessionId: string().optional(),
22331
+ /**
22332
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
22333
+ * reference-image, and detail-subtree calls. 'frame' is the live
22334
+ * per-frame dispatch: ONLY root-plane steps run; crop children
22335
+ * (inputClasses ≠ null) are skipped and served per-track via
22336
+ * pipelineRunner.runDetailSubtree (two-plane design).
22337
+ */
22338
+ plane: _enum(["full", "frame"]).optional(),
22339
+ /**
22340
+ * Inference-device selector (Phase 2 multi-device). Format
22341
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
22342
+ * Omitted ⇒ the runner's default device (current single-engine
22343
+ * behaviour). Selects WHICH device pool of the node runs the call.
22344
+ */
22345
+ deviceKey: string().optional(),
22346
+ /**
22347
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
22348
+ * when the parent crop was resolved from the frame's retained NATIVE
22349
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
22350
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
22351
+ * resolution from that surface — the SAME quality path faces already
22352
+ * had — instead of the downscaled parent tile. `handle` keys the native
22353
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
22354
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
22355
+ * the executor's crop-normalized child ROI back into frame-normalized
22356
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
22357
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
22358
+ * (today's behaviour on the fallback path).
22359
+ */
22360
+ nativeCropRef: NativeCropRefSchema.optional(),
22361
+ /**
22362
+ * Offline REPLAY of stored media for `deviceId` (D56, D646): the
22363
+ * camera's zone gate and overrides apply as live, every executing
22364
+ * step runs EXACTLY the model it names on the `deviceKey` pool it
22365
+ * names or the call refuses (`model-not-servable` /
22366
+ * `device-not-servable`), and nothing reaches the camera's live
22367
+ * trace stream. Absent ⇒ unchanged behaviour.
22368
+ */
22369
+ replay: literal(true).optional()
22370
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
22371
+ steps: array(PipelineStepInputSchema).min(1),
22372
+ frames: array(FrameInputSchema).min(1).max(255),
22373
+ deviceId: number().optional(),
22374
+ sessionId: string().optional(),
22375
+ /**
22376
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
22377
+ * the batch to the Python pool's bench preprocess cache
22378
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
22379
+ * preprocessed ONCE and every later inference is a pure-inference cache
22380
+ * hit — the sustained-throughput run measures inference, not
22381
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
22382
+ * full preprocess every call, correct). Fresh per sustained run;
22383
+ * released via `uncacheFrame`.
22384
+ */
22385
+ frameId: number().int().nonnegative().optional(),
22386
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
22387
+ deviceKey: string().optional()
22388
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
22389
+ data: _instanceof(Uint8Array),
22390
+ width: number().int().positive(),
22391
+ height: number().int().positive(),
22392
+ format: _enum([
22393
+ "rgb",
22394
+ "bgr",
22395
+ "gray"
22396
+ ])
22397
+ }), object({
22398
+ frameId: number(),
22399
+ width: number(),
22400
+ height: number()
22401
+ }), { kind: "mutation" }), method(object({
22402
+ stepId: string(),
22403
+ frameId: number().int(),
22404
+ /**
22405
+ * The model to time — REQUIRED (D658). Without it the pool answered the
22406
+ * step's ACTIVE variant (the first loaded after boot), so a benchmark
22407
+ * of model B silently timed model A. Callers pass the `rootModelId`
22408
+ * their warmup `runPipeline` reported: the model that actually ran.
22409
+ */
22410
+ modelId: string().min(1)
22411
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(object({ deviceKey: string().optional() }), EffectiveTuningSchema), method(_void(), array(object({
22412
+ engineKey: string(),
22413
+ engine: PipelineEngineChoiceSchema,
22414
+ modelsLoaded: array(string()).readonly(),
22415
+ inUseByCameras: array(number()).readonly(),
22416
+ /**
22417
+ * Origin of this resident factory.
22418
+ * - `runtime` — main camera-serving engine (no idle TTL).
22419
+ * - `device-pool` — a concurrent per-device pool (Phase 2
22420
+ * multi-device, keyed by `deviceKey`) resolved
22421
+ * via `resolveDeviceFactory`. Runs alongside the
22422
+ * `runtime` engine on a DIFFERENT accelerator
22423
+ * (NPU / iGPU / Coral) — this is how the
22424
+ * Engines tab shows all pools running at once.
22425
+ */
22426
+ kind: _enum(["runtime", "device-pool"]),
22427
+ /** Native pid of the underlying Python pool (null when no pool). */
22428
+ poolPid: number().nullable(),
22429
+ /** ms since this factory was last used (null when not warm-tracked). */
22430
+ idleMs: number().nullable(),
22431
+ /** Idle TTL after which the factory self-evicts (null when not applicable). */
22432
+ idleTtlMs: number().nullable()
22433
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
22434
+ kind: "mutation",
22435
+ auth: "admin"
22436
+ }), method(object({
22437
+ engine: PipelineEngineChoiceSchema,
22438
+ force: boolean().optional()
22439
+ }), object({
22440
+ success: boolean(),
22441
+ reason: string().optional()
22442
+ }), {
22443
+ kind: "mutation",
22444
+ auth: "admin"
22445
+ }), 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({
22446
+ addonId: string(),
22447
+ modelId: string(),
22448
+ filename: string().optional(),
22449
+ settings: record(string(), unknown()).optional()
22450
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
21506
22451
  object({
21507
22452
  activeCameras: number(),
21508
22453
  throttledCameras: number(),
@@ -21528,6 +22473,66 @@ var CameraMetricsSchema = object({
21528
22473
  });
21529
22474
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
21530
22475
  /**
22476
+ * Zone — pure geometry + identity. NO filtering behaviour.
22477
+ *
22478
+ * Zones describe **where** in the frame the operator wants to flag
22479
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
22480
+ * each pipeline stage uses them. Splitting the two means a single
22481
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
22482
+ * a detection-include rule on `['car']`, and an occupancy aggregate
22483
+ * — without three duplicated polygons.
22484
+ *
22485
+ * Owned by the orchestrator addon (provider) and mirrored into the
22486
+ * `zones` device-state slice on every mutation. Consumers
22487
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
22488
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
22489
+ * mirror with `onChanged`).
22490
+ *
22491
+ * Coordinates are normalised fractions of the frame (0–1) so zones
22492
+ * survive resolution changes and stream profile switches.
22493
+ *
22494
+ * `kind` discriminates between full polygons (closed regions used
22495
+ * for intrusion / occupancy filters) and tripwires (open 2-point
22496
+ * line segments used for cross events). Onboard / firmware-reported
22497
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
22498
+ * task list.
22499
+ */
22500
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
22501
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
22502
+ var PolygonPointSchema = object({
22503
+ x: number(),
22504
+ y: number()
22505
+ });
22506
+ /** A camera detection zone — pure geometry/identity. */
22507
+ var ZoneSchema = object({
22508
+ id: string(),
22509
+ name: string(),
22510
+ kind: ZoneKindEnum.default("polygon"),
22511
+ /** Polygon vertices, fraction of frame (0–1). */
22512
+ polygon: array(PolygonPointSchema).readonly(),
22513
+ /** Visual color for UI rendering. */
22514
+ color: string().default("#3b82f6")
22515
+ });
22516
+ DeviceType.Camera, method(object({ deviceId: number() }), array(ZoneSchema).readonly()), method(object({
22517
+ deviceId: number(),
22518
+ zone: ZoneSchema
22519
+ }), _void(), {
22520
+ kind: "mutation",
22521
+ auth: "admin"
22522
+ }), method(object({
22523
+ deviceId: number(),
22524
+ zoneId: string()
22525
+ }), _void(), {
22526
+ kind: "mutation",
22527
+ auth: "admin"
22528
+ }), method(object({
22529
+ deviceId: number(),
22530
+ zone: ZoneSchema
22531
+ }), _void(), {
22532
+ kind: "mutation",
22533
+ auth: "admin"
22534
+ }), object({ zones: array(ZoneSchema).readonly() });
22535
+ /**
21531
22536
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
21532
22537
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
21533
22538
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -21714,7 +22719,17 @@ var DetailResultSchema = object({
21714
22719
  /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
21715
22720
  * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
21716
22721
  * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
21717
- nativeFaceShortSidePx: number().optional()
22722
+ nativeFaceShortSidePx: number().optional(),
22723
+ /**
22724
+ * The five facial landmarks of a `face` detail, in the SAME frame space as
22725
+ * `bbox` (D644). Additive and optional: post-analysis stores them beside the
22726
+ * face's source frame so a future alignment can be re-derived exactly; a
22727
+ * runner that predates the field sends none and the face is stored without.
22728
+ */
22729
+ landmarks: array(object({
22730
+ x: number(),
22731
+ y: number()
22732
+ })).optional()
21718
22733
  });
21719
22734
  /**
21720
22735
  * Why an executing node REFUSED a stateless step run (`runStatelessStep`).
@@ -21969,6 +22984,17 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
21969
22984
  hubHostnameOverride: string().optional()
21970
22985
  })]).describe("Per-camera frame-source mode for the runner (P2c)");
21971
22986
  /**
22987
+ * What ONE step runs with on ONE roster device for THIS camera (D650): the
22988
+ * device's per-(node,device) base with the camera's override for that device
22989
+ * on top — the same `override ?? base` merge the orchestrator applies to the
22990
+ * elected device (`applyDeviceProvisioning`). Absent `modelId` ⇒ the executor
22991
+ * resolves the device format's default, exactly as on the elected device.
22992
+ */
22993
+ var RunnerJumpStepProvisioningSchema = object({
22994
+ modelId: string().optional(),
22995
+ settings: record(string(), unknown()).optional()
22996
+ });
22997
+ /**
21972
22998
  * One ENABLED inference device on the runner's node, as the step-tree
21973
22999
  * device-jump resolver sees it (phase 1). The orchestrator populates this
21974
23000
  * roster on the attach payload whenever the camera is elected onto a specific
@@ -21980,7 +23006,16 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
21980
23006
  var RunnerInferenceDeviceSchema = object({
21981
23007
  deviceKey: string(),
21982
23008
  weight: number().positive().default(1),
21983
- maxSessions: number().int().positive().nullable().default(null)
23009
+ maxSessions: number().int().positive().nullable().default(null),
23010
+ /**
23011
+ * Per-step provisioning for this camera on THIS device (D650), keyed by step
23012
+ * id. A step the runner jumps here runs with these fields, never with the
23013
+ * elected device's: `modelId` / `settings` are REPLACED on the jumped subtree
23014
+ * (a step absent from the map runs with neither — the target format default).
23015
+ * Absent field ⇒ an orchestrator that predates D650: the jumped step keeps
23016
+ * the elected device's provisioning, as before.
23017
+ */
23018
+ steps: record(string(), RunnerJumpStepProvisioningSchema).optional()
21984
23019
  });
21985
23020
  /**
21986
23021
  * Camera assignment payload sent by `addon-pipeline-orchestrator` to a
@@ -22855,6 +23890,28 @@ var NodeInferenceDeviceSchema = object({
22855
23890
  */
22856
23891
  exclusion: InferenceDeviceExclusionReasonSchema.nullable()
22857
23892
  });
23893
+ /**
23894
+ * The operator's model choice for one cluster-scoped step, answered by the
23895
+ * addon that OWNS the `clusterModel:*` settings (D651). Three answers, never
23896
+ * folded: a written choice, a key nobody wrote (the cluster runs the default
23897
+ * BY ABSENCE), or no answer. A caller that rewrites an index acts only on the
23898
+ * first two, read twice and agreeing.
23899
+ */
23900
+ var ClusterModelChoiceSchema = discriminatedUnion("kind", [
23901
+ object({
23902
+ kind: literal("stored"),
23903
+ modelId: string()
23904
+ }),
23905
+ object({
23906
+ kind: literal("absent"),
23907
+ defaultModelId: string()
23908
+ }),
23909
+ object({
23910
+ kind: literal("unreadable"),
23911
+ reason: _enum(CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS),
23912
+ error: string().optional()
23913
+ })
23914
+ ]);
22858
23915
  var NodeInferenceDevicesSchema = object({
22859
23916
  nodeId: string(),
22860
23917
  /** False when the node's platform-probe was unreachable (no live device set). */
@@ -22882,10 +23939,17 @@ method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
22882
23939
  }), object({ success: literal(true) }), {
22883
23940
  kind: "mutation",
22884
23941
  auth: "admin"
22885
- }), method(object({ deviceId: number() }), object({ deviceKey: string().nullable() })), method(_void(), object({ migrated: number() }), {
23942
+ }), method(object({ deviceId: number() }), object({ deviceKey: string().nullable() })), method(_void(), object({
23943
+ migrated: number(),
23944
+ skipped: array(object({
23945
+ deviceId: number(),
23946
+ targetNodeId: string(),
23947
+ reason: string()
23948
+ })).default([])
23949
+ }), {
22886
23950
  kind: "mutation",
22887
23951
  auth: "admin"
22888
- }), 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({
23952
+ }), 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({
22889
23953
  nodeId: string(),
22890
23954
  capName: string(),
22891
23955
  addonId: string()
@@ -23100,7 +24164,11 @@ function buildDescriptor(capName, kind) {
23100
24164
  icon: legacyIcon(t.iconId)
23101
24165
  };
23102
24166
  }
23103
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
24167
+ /**
24168
+ * Sensor / control cap name → static event-kind descriptor. A linked device
24169
+ * contributes one entry per bound cap present in this map.
24170
+ */
24171
+ var EVENT_KIND_BY_CAP = Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
23104
24172
  /**
23105
24173
  * server-management — per-NODE singleton capability for a node's ROOT
23106
24174
  * package lifecycle (runtime-updatable node packages).
@@ -25181,6 +26249,177 @@ DeviceType.Camera, method(object({
25181
26249
  auth: "protected"
25182
26250
  });
25183
26251
  /**
26252
+ * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
26253
+ * valutatore puro del suo FRONTE.
26254
+ *
26255
+ * Viveva dentro il builtin virtual-doorbell
26256
+ * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
26257
+ * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
26258
+ * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
26259
+ * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
26260
+ * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
26261
+ * SPOSTA qui e il doorbell la ri-esporta.
26262
+ *
26263
+ * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
26264
+ * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
26265
+ * regola" (e include `presence`, `cover`, `alarm-panel`), questa a "qual è il
26266
+ * booleano il cui FRONTE conta". Vocabolari deliberatamente diversi.
26267
+ */
26268
+ /**
26269
+ * Known binary / switch source caps → the boolean slice field whose
26270
+ * false→true rise counts as ACTIVE. Every entry is "fire on active".
26271
+ * Sensors whose "active" reading is not a plain boolean (presence's string
26272
+ * state, connectivity's connected flag) are deliberately excluded — a
26273
+ * reconnect is not a doorbell press, and it is not a recording either.
26274
+ */
26275
+ var SOURCE_CAP_ACTIVE_FIELD = {
26276
+ contact: "entryOpen",
26277
+ binary: "on",
26278
+ switch: "on",
26279
+ motion: "detected",
26280
+ flood: "flooded",
26281
+ gas: "detected",
26282
+ smoke: "detected",
26283
+ "carbon-monoxide": "detected",
26284
+ vibration: "detected",
26285
+ tamper: "tampered"
26286
+ };
26287
+ object({
26288
+ /** Ms epoch of the last press. null = never observed since this provider started. */
26289
+ lastPressedAt: number().nullable(),
26290
+ /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
26291
+ pressCountSinceStart: number()
26292
+ });
26293
+ object({
26294
+ deviceId: number(),
26295
+ timestamp: number()
26296
+ });
26297
+ /**
26298
+ * The `doorbell-source` extension slot's editable value (D648): the camera's
26299
+ * virtual-doorbell trigger devices, exactly what the wrapper's
26300
+ * `doorbellSources` persists (as `{ deviceId }` records).
26301
+ */
26302
+ var DoorbellSourceSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
26303
+ DeviceType.Camera;
26304
+ DeviceType.Button, DeviceType.Camera;
26305
+ var ExtensionSlotIdSchema = _enum(["doorbell-source", "linked-devices"]);
26306
+ DeviceType.Camera, DeviceType.Camera;
26307
+ /** A slot's editable value, discriminated on `slot`. */
26308
+ var ExtensionSlotValueSchema = discriminatedUnion("slot", [DoorbellSourceSlotValueSchema.extend({ slot: literal("doorbell-source") }), LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
26309
+ DeviceType.Camera;
26310
+ var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
26311
+ state: literal("unreachable"),
26312
+ reason: string()
26313
+ })]);
26314
+ /** One provider of slots — the D554 source-listing row. */
26315
+ var ExtensionSourceSchema = object({
26316
+ /** The routing prefix of every `slotRef` this provider serves. */
26317
+ source: string(),
26318
+ label: string(),
26319
+ /** Stamped by the dispatcher from the registry (D557). */
26320
+ addonId: string().optional(),
26321
+ availability: ExtensionSourceAvailabilitySchema
26322
+ });
26323
+ /**
26324
+ * How one picked source stands. `missing` — no such device (deleted, or an id
26325
+ * that never existed); `foreign` — a device the slot's owner cannot read from
26326
+ * (slice 2's cross-owner graft source); `unavailable` — it exists but is not a
26327
+ * valid source now (a container, which is never a pick). A source in any of
26328
+ * these states is SHOWN, never silently dropped or re-pointed.
26329
+ */
26330
+ var ExtensionSourceHealthSchema = _enum([
26331
+ "ok",
26332
+ "missing",
26333
+ "foreign",
26334
+ "unavailable"
26335
+ ]);
26336
+ var ExtensionSlotSourceSchema = object({
26337
+ deviceId: number().int(),
26338
+ /** The device's name, or null when it could not be resolved (`missing`). */
26339
+ name: string().nullable(),
26340
+ health: ExtensionSourceHealthSchema,
26341
+ detail: string().optional()
26342
+ });
26343
+ /**
26344
+ * A DIFFERENT authority that gates whether the slot's sources do anything —
26345
+ * reported read-only, named, never written through this contract (D62). The
26346
+ * virtual doorbell's sources ring only while the wrapper is bound to the
26347
+ * camera, and that binding belongs to `deviceManager.setWrapperActive`.
26348
+ * `unknown` means the gate could not be read; it is not "inactive" (D315).
26349
+ */
26350
+ var ExtensionSlotActivationSchema = object({
26351
+ state: _enum([
26352
+ "active",
26353
+ "inactive",
26354
+ "unknown"
26355
+ ]),
26356
+ authority: string(),
26357
+ detail: string().optional()
26358
+ });
26359
+ var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
26360
+ state: literal("ok"),
26361
+ /** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
26362
+ slotRef: string(),
26363
+ slot: ExtensionSlotIdSchema,
26364
+ /** Names the store written (D62), e.g. `virtual-doorbell:doorbellSources`. */
26365
+ authority: string(),
26366
+ /** graft: its switch. association: null — removing every source is "off". */
26367
+ enabled: boolean().nullable(),
26368
+ /** graft: the cap registered on the host. association: null. */
26369
+ projects: string().nullable(),
26370
+ activation: ExtensionSlotActivationSchema.nullable(),
26371
+ value: ExtensionSlotValueSchema,
26372
+ sources: array(ExtensionSlotSourceSchema),
26373
+ /**
26374
+ * Devices the owner links to the host ON ITS OWN, by structure, and that
26375
+ * are therefore not in `value` (D655): a camera's device-tree children, and
26376
+ * the child a picked container stands for (D356 — a container is never a
26377
+ * pick, its children are). Read-only; the editor shows them and may offer
26378
+ * per-device options on them (the linked-devices tracked-event opt-in).
26379
+ * Absent when the owner links nothing beyond the picks, and from an owner
26380
+ * older than D655.
26381
+ */
26382
+ impliedSources: array(ExtensionSlotSourceSchema).optional()
26383
+ }), object({
26384
+ state: literal("unreachable"),
26385
+ addonId: string(),
26386
+ reason: string()
26387
+ })]);
26388
+ var ExtensionCandidatesSchema = object({ candidates: array(object({
26389
+ deviceId: number().int(),
26390
+ name: string(),
26391
+ type: string(),
26392
+ location: string().nullable(),
26393
+ /** The container a child belongs to — "Spotlight 2" alone does not say which. */
26394
+ parentName: string().nullable(),
26395
+ /** Pre-marked by the owner's suggestion rule. NEVER saved on its own (D356). */
26396
+ suggested: boolean(),
26397
+ /** Why it is suggested ("same location"), null when it is not. */
26398
+ reason: string().nullable()
26399
+ })) });
26400
+ /**
26401
+ * What a write did. `none` — applied in place. `host` / `parent` — the owner
26402
+ * reloaded the host (or, for an accessory child, its parent) because the
26403
+ * write changed what the host REGISTERS (a graft switched on or off, slice 2).
26404
+ */
26405
+ var ExtensionSetResultSchema = object({
26406
+ applied: literal(true),
26407
+ reload: _enum([
26408
+ "none",
26409
+ "host",
26410
+ "parent"
26411
+ ])
26412
+ });
26413
+ var ExtensionSlotRefInputSchema = object({
26414
+ deviceId: number().int(),
26415
+ slotRef: string().min(1)
26416
+ });
26417
+ var ExtensionSetSlotInputSchema = ExtensionSlotRefInputSchema.extend({ value: ExtensionSlotValueSchema });
26418
+ method(object({ deviceId: number().int() }), array(ExtensionSourceSchema)), method(object({ deviceId: number().int() }), array(ExtensionSlotRowSchema)), method(ExtensionSlotRefInputSchema, ExtensionCandidatesSchema), method(ExtensionSetSlotInputSchema, ExtensionSetResultSchema, {
26419
+ kind: "mutation",
26420
+ auth: "admin"
26421
+ });
26422
+ /**
25184
26423
  * Optional client-side hints sent at session creation to help the provider
25185
26424
  * pick the best native source. All fields optional — a viewer that knows
25186
26425
  * nothing still gets a sane default. (Relocated from the retired `webrtc`
@@ -25282,7 +26521,67 @@ var WebrtcLadderDecisionSchema = object({
25282
26521
  serverSending: boolean().nullable(),
25283
26522
  /** Epoch ms. The overlay prints its age; a decision from 40 minutes ago
25284
26523
  * must not read like one from this second. */
25285
- at: number()
26524
+ at: number(),
26525
+ /** The broker's own cause when it is finer than `cause` can carry, e.g.
26526
+ * `trial-revert` (reported as `stall`/`loss` for older consumers). Optional:
26527
+ * an older server strips it instead of rejecting the answer. */
26528
+ causeDetail: string().optional()
26529
+ });
26530
+ var WebrtcClimbHoldSchema = object({
26531
+ /** `stall-building` — the client receives ≪ what is sent; `delivery` — the
26532
+ * current rung is not landing whole; `no-evidence` — no receiver feedback;
26533
+ * `warming` — healthy, accumulating the streak; `cooldown` — too soon after
26534
+ * a change; `capacity` — a MEASURED probe below the next rung's bar;
26535
+ * `try-unclean` — no capacity evidence, and the path is not clean enough to
26536
+ * try; `try-backoff` — a try reverted, waiting out its backoff; `trial` —
26537
+ * this rung IS a try, reverting if it does not land; `suspended` —
26538
+ * recorded playback on the track. */
26539
+ code: string(),
26540
+ /** The rung a climb would go to. */
26541
+ nextTier: CamProfileSchema,
26542
+ /** Bytes received ÷ bytes sent over the delivery window (≥ one GOP). */
26543
+ deliveryRatio: number().nullable(),
26544
+ deliveryWindowMs: number().nullable(),
26545
+ /** The ratio a climb requires. */
26546
+ climbDeliveryRatio: number(),
26547
+ /** The receiver's bandwidth estimate (REMB), kbps. Capped by what is sent. */
26548
+ capacityKbps: number().nullable(),
26549
+ /** The viewer's downlink probe for this session, kbps. */
26550
+ probeKbps: number().nullable(),
26551
+ /** The next rung's measured bitrate, kbps. */
26552
+ nextTierKbps: number().nullable(),
26553
+ capacityMargin: number(),
26554
+ /** The capacity a climb to `nextTier` needs, kbps (bitrate × margin, or the
26555
+ * client ladder threshold when the rung has measured nothing). */
26556
+ neededKbps: number().nullable(),
26557
+ /** For `try-unclean`: which clean-path condition failed (a `WebrtcTryBlocker`,
26558
+ * carried as a string for the same reason as `code`). */
26559
+ tryBlockedBy: string().nullable(),
26560
+ /** The delivery ratio and the loss ratio a try requires / must stay under.
26561
+ * Optional, like every field added to this schema after it first shipped:
26562
+ * the router validates output, so a REQUIRED new field makes a newer server
26563
+ * reject an older broker's whole answer (review m1). */
26564
+ tryDeliveryRatio: number().optional(),
26565
+ tryMaxLossRatio: number().optional(),
26566
+ /** For `try-backoff`: time until the next try, ms. */
26567
+ retryInMs: number().nullable(),
26568
+ /** The last try that reverted in this viewer session. */
26569
+ lastRevert: object({
26570
+ tier: CamProfileSchema,
26571
+ deliveryRatio: number().nullable(),
26572
+ stalled: boolean(),
26573
+ at: number()
26574
+ }).nullable(),
26575
+ /** For `trial`: how long this rung has been on trial, and for how long it must hold. */
26576
+ trialForMs: number().nullable(),
26577
+ trialMs: number().nullable(),
26578
+ healthyForMs: number().nullable(),
26579
+ requiredHealthyMs: number().nullable(),
26580
+ /** Epoch ms this hold's code began. */
26581
+ since: number(),
26582
+ /** The same one-line account the broker logs, e.g.
26583
+ * `held: delivery 0.97 over 4.0s ok, REMB 480 kbps < mid 1800 kbps × 1.2`. */
26584
+ summary: string()
25286
26585
  });
25287
26586
  /** Per-tier count of MEASURED downgrades this viewer session has suffered. */
25288
26587
  var WebrtcTierFailureSchema = object({
@@ -25346,7 +26645,12 @@ var WebrtcSessionDebugSchema = object({
25346
26645
  tierFailures: array(WebrtcTierFailureSchema),
25347
26646
  /** Successful promotions in this viewer session (drives the progressive
25348
26647
  * healthy timer). Null when no ladder is running. */
25349
- upgradeCount: number().nullable()
26648
+ upgradeCount: number().nullable(),
26649
+ /** Why the ladder is not climbing right now. Null when no ladder runs, it
26650
+ * is at the top rung, or it just moved. Optional because this output is
26651
+ * validated by the router: a server carrying this schema must still accept
26652
+ * the answer of a stream-broker deployed before the field existed. */
26653
+ climbHold: WebrtcClimbHoldSchema.nullable().optional()
25350
26654
  });
25351
26655
  DeviceType.Camera, method(object({ deviceId: number().int().nonnegative() }), array(WebrtcStreamChoiceSchema)), method(object({
25352
26656
  deviceId: number().int().nonnegative(),
@@ -26904,17 +28208,6 @@ object({
26904
28208
  deviceId: number(),
26905
28209
  status: DeviceStatusSchema
26906
28210
  });
26907
- object({
26908
- /** Ms epoch of the last press. null = never observed since this provider started. */
26909
- lastPressedAt: number().nullable(),
26910
- /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
26911
- pressCountSinceStart: number()
26912
- });
26913
- object({
26914
- deviceId: number(),
26915
- timestamp: number()
26916
- });
26917
- DeviceType.Button, DeviceType.Camera;
26918
28211
  /**
26919
28212
  * Enum-state sensor — a string value picked from a finite option set.
26920
28213
  * Drives HA `sensor` entries with `state_class: enum` (HVAC action
@@ -29038,6 +30331,11 @@ var ClientNetworkStatsSchema = object({
29038
30331
  jitterMs: number(),
29039
30332
  estimatedBandwidthKbps: number(),
29040
30333
  packetLossPercent: number().min(0).max(100),
30334
+ /** The viewer's latest `/adaptive-probe` reading, Mbps — whatever it read
30335
+ * (D635 I4). Absent when it never probed or the probe failed (unknown). */
30336
+ downlinkMbps: number().optional(),
30337
+ /** Age of that reading when this report was sent, ms. */
30338
+ downlinkAgeMs: number().optional(),
29041
30339
  lastUpdated: number()
29042
30340
  });
29043
30341
  var DeviceNetworkStatsSchema = object({
@@ -29050,7 +30348,11 @@ method(object({ deviceId: number() }), DeviceNetworkStatsSchema.nullable()), met
29050
30348
  rttMs: number().min(0).max(6e4),
29051
30349
  jitterMs: number().min(0).max(1e4),
29052
30350
  estimatedBandwidthKbps: number().min(0).max(1e6),
29053
- packetLossPercent: number().min(0).max(100)
30351
+ packetLossPercent: number().min(0).max(100),
30352
+ /** Latest downlink probe, Mbps, whatever it read; absent = never / failed. */
30353
+ downlinkMbps: number().min(0).max(1e5).optional(),
30354
+ /** Age of that probe when this report is sent, ms. */
30355
+ downlinkAgeMs: number().min(0).max(864e5).optional()
29054
30356
  }), _void(), { kind: "mutation" });
29055
30357
  /**
29056
30358
  * nodes — system-scoped singleton capability for cluster topology
@@ -29169,7 +30471,30 @@ var RenameNodeResultSchema = object({
29169
30471
  nodeId: string(),
29170
30472
  name: string()
29171
30473
  });
29172
- method(_void(), array(TopologyNodeSchema).readonly(), { auth: "admin" }), method(NodeAddonInputSchema, SuccessSchema, {
30474
+ /**
30475
+ * The cheap node list. A consumer's rule for a STORED node id (a rule's
30476
+ * `nodeIds`) that is missing from `nodes`, whatever `complete` says: render it
30477
+ * as a removable chip labelled unknown, never drop it (D49). Even a complete
30478
+ * list omits a node that joined and left between two history captures, so a
30479
+ * missing id means "not known to the hub", never "removed". Only the operator
30480
+ * removes it.
30481
+ *
30482
+ * `complete` changes only the WORDING: `false` = no history read has ever
30483
+ * answered, so the list may be missing offline nodes the hub does know (D315).
30484
+ *
30485
+ * `name` is the history row's name (≤ 30 s behind a rename), or the id when
30486
+ * the history has none.
30487
+ */
30488
+ var NodeDirectorySchema = object({
30489
+ nodes: array(object({
30490
+ id: string(),
30491
+ name: string(),
30492
+ isHub: boolean(),
30493
+ isOnline: boolean()
30494
+ })).readonly(),
30495
+ complete: boolean()
30496
+ });
30497
+ method(_void(), array(TopologyNodeSchema).readonly(), { auth: "admin" }), method(_void(), NodeDirectorySchema, { auth: "admin" }), method(NodeAddonInputSchema, SuccessSchema, {
29173
30498
  kind: "mutation",
29174
30499
  auth: "admin"
29175
30500
  }), method(NodeAddonInputSchema, SuccessSchema, {
@@ -29938,7 +31263,7 @@ var HardwareInfoSchema = object({
29938
31263
  coral: CoralInfoSchema.nullable().optional()
29939
31264
  });
29940
31265
  var PlatformScoreSchema = object({
29941
- runtime: _enum(["node", "python"]),
31266
+ runtime: literal("python"),
29942
31267
  backend: string(),
29943
31268
  format: _enum([
29944
31269
  "onnx",
@@ -29975,7 +31300,7 @@ var ModelRequirementSchema = object({
29975
31300
  });
29976
31301
  var ResolvedInferenceConfigSchema = object({
29977
31302
  modelId: string(),
29978
- runtime: _enum(["node", "python"]),
31303
+ runtime: literal("python"),
29979
31304
  backend: string(),
29980
31305
  format: ModelFormatSchema,
29981
31306
  reason: string()
@@ -32182,6 +33507,92 @@ DeviceType.Camera, method(object({ deviceId: number() }), SceneMonitorStatusSche
32182
33507
  kind: "mutation",
32183
33508
  auth: "admin"
32184
33509
  });
33510
+ /**
33511
+ * Per-stage gating mode applied to the zones a rule references.
33512
+ *
33513
+ * - `include`: the rule contributes to a **whitelist** for its stage.
33514
+ * When at least one `include` rule fires for a stage, only entities
33515
+ * inside one of those zones pass that stage.
33516
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
33517
+ * Entities inside one of those zones are dropped at that stage.
33518
+ *
33519
+ * `monitor`-style observation (count without filtering) is not a rule
33520
+ * mode — zones without any matching rule are observed naturally by
33521
+ * `zone-analytics` (live snapshot + history), so an "I just want to
33522
+ * count, not filter" use case needs no rule at all.
33523
+ */
33524
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
33525
+ /**
33526
+ * Per-consumer rule that references existing zones (geometry) and
33527
+ * defines how a specific pipeline stage should treat them. Each
33528
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
33529
+ * settings:
33530
+ *
33531
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
33532
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
33533
+ * - future: notification rules, audio gating, etc.
33534
+ *
33535
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
33536
+ * express "ignore motion in ALL of {garden, street}" with a single
33537
+ * rule. `classFilter` narrows the rule to specific object classes —
33538
+ * "drop person detections in the street, but keep cars" is one
33539
+ * `exclude` rule with `classFilter: ['person']`.
33540
+ *
33541
+ * `enabled` is a soft toggle — the operator can keep the rule
33542
+ * configured but inert without deleting it.
33543
+ */
33544
+ var ZoneRuleSchema = object({
33545
+ /** Stable rule id — survives edits, used by the UI for diffing. */
33546
+ id: string(),
33547
+ /** Optional human-readable label rendered in the rule editor. */
33548
+ name: string().optional(),
33549
+ /** Zones this rule targets. The rule's `mode` applies to ALL
33550
+ * listed zones (OR-set: a detection in any one of them counts).
33551
+ * At least one zone id required — a rule with no targets is a
33552
+ * configuration mistake and the form validator rejects it. */
33553
+ zoneIds: array(string()).min(1).readonly(),
33554
+ mode: ZoneRuleModeEnum,
33555
+ /**
33556
+ * Class names this rule applies to. Empty / undefined ⇒ rule
33557
+ * applies to every class. Class strings match the `macroClass`
33558
+ * field on detections (e.g. `person`, `car`, `dog`).
33559
+ */
33560
+ classFilter: array(string()).readonly().optional(),
33561
+ /**
33562
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
33563
+ * required to consider an entity "in the zone". Defaults to the
33564
+ * consumer's stage default when omitted. Kept for back-compat with
33565
+ * existing per-rule overrides; new operators pick the value via
33566
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
33567
+ * set, the lower-level engine reads it as a 0–1 fraction.
33568
+ */
33569
+ overlapThreshold: number().min(0).max(1).optional(),
33570
+ /**
33571
+ * Operator-friendly version of `overlapThreshold` — the percentage
33572
+ * of the detection's bbox that must lie inside the zone for the
33573
+ * rule to match. Documented default is 85%; the engine substitutes
33574
+ * that when the field is omitted (kept optional so existing rules
33575
+ * stored without it stay valid).
33576
+ *
33577
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
33578
+ * rule, the engine prefers `bboxInclusionPct` because it's the
33579
+ * field exposed in the UI. Internally both feed the same gate.
33580
+ */
33581
+ bboxInclusionPct: number().min(0).max(100).optional(),
33582
+ /**
33583
+ * When `true` and a detection has a segmentation mask, use the
33584
+ * mask for overlap instead of the bbox. Detection-stage only;
33585
+ * motion rules ignore this field.
33586
+ */
33587
+ preferMask: boolean().optional(),
33588
+ /**
33589
+ * Soft-toggle: `false` disables the rule without deleting it.
33590
+ * Defaults to `true` so operators creating a rule via the UI
33591
+ * see it active immediately.
33592
+ */
33593
+ enabled: boolean().default(true)
33594
+ });
33595
+ array(ZoneRuleSchema).readonly();
32185
33596
  object({
32186
33597
  /** Whether the script is currently executing. */
32187
33598
  isRunning: boolean(),
@@ -33562,6 +34973,38 @@ DeviceType.Camera, method(object({
33562
34973
  detection: array(ZoneRuleSchema).readonly(),
33563
34974
  package: array(ZoneRuleSchema).readonly()
33564
34975
  });
34976
+ var NUMBER = {
34977
+ kind: "fixed",
34978
+ result: ["number"]
34979
+ };
34980
+ var BOOLEAN = {
34981
+ kind: "fixed",
34982
+ result: ["boolean"]
34983
+ };
34984
+ Object.freeze({
34985
+ min: NUMBER,
34986
+ max: NUMBER,
34987
+ abs: NUMBER,
34988
+ floor: NUMBER,
34989
+ ceil: NUMBER,
34990
+ sqrt: NUMBER,
34991
+ round: NUMBER,
34992
+ pow: NUMBER,
34993
+ clamp: NUMBER,
34994
+ avg: NUMBER,
34995
+ sum: NUMBER,
34996
+ age: NUMBER,
34997
+ convert: NUMBER,
34998
+ coalesce: { kind: "coalesce" },
34999
+ any: BOOLEAN,
35000
+ all: BOOLEAN,
35001
+ within: BOOLEAN,
35002
+ latest: {
35003
+ kind: "fixed",
35004
+ result: ["number", "null"]
35005
+ }
35006
+ });
35007
+ `${COMPOSED_DEVICE_STABLE_ID_PREFIX}`;
33565
35008
  /**
33566
35009
  * Accessory device helpers — shared across drivers.
33567
35010
  *
@@ -35870,6 +37313,18 @@ Object.freeze({
35870
37313
  addonId: null,
35871
37314
  access: "create"
35872
37315
  },
37316
+ "composer.applyBlocks": {
37317
+ capName: "composer",
37318
+ capScope: "system",
37319
+ addonId: null,
37320
+ access: "create"
37321
+ },
37322
+ "composer.getStates": {
37323
+ capName: "composer",
37324
+ capScope: "system",
37325
+ addonId: null,
37326
+ access: "view"
37327
+ },
35873
37328
  "connectionTest.describeTest": {
35874
37329
  capName: "connection-test",
35875
37330
  capScope: "system",
@@ -35930,6 +37385,12 @@ Object.freeze({
35930
37385
  addonId: null,
35931
37386
  access: "create"
35932
37387
  },
37388
+ "coreBlocks.createComposition": {
37389
+ capName: "core-blocks",
37390
+ capScope: "system",
37391
+ addonId: null,
37392
+ access: "create"
37393
+ },
35933
37394
  "coreBlocks.delete": {
35934
37395
  capName: "core-blocks",
35935
37396
  capScope: "system",
@@ -35942,6 +37403,12 @@ Object.freeze({
35942
37403
  addonId: null,
35943
37404
  access: "view"
35944
37405
  },
37406
+ "coreBlocks.getComposition": {
37407
+ capName: "core-blocks",
37408
+ capScope: "system",
37409
+ addonId: null,
37410
+ access: "view"
37411
+ },
35945
37412
  "coreBlocks.getTypeDefs": {
35946
37413
  capName: "core-blocks",
35947
37414
  capScope: "system",
@@ -35954,6 +37421,12 @@ Object.freeze({
35954
37421
  addonId: null,
35955
37422
  access: "view"
35956
37423
  },
37424
+ "coreBlocks.listCompositions": {
37425
+ capName: "core-blocks",
37426
+ capScope: "system",
37427
+ addonId: null,
37428
+ access: "view"
37429
+ },
35957
37430
  "coreBlocks.restart": {
35958
37431
  capName: "core-blocks",
35959
37432
  capScope: "system",
@@ -35972,6 +37445,18 @@ Object.freeze({
35972
37445
  addonId: null,
35973
37446
  access: "create"
35974
37447
  },
37448
+ "coreBlocks.updateComposition": {
37449
+ capName: "core-blocks",
37450
+ capScope: "system",
37451
+ addonId: null,
37452
+ access: "create"
37453
+ },
37454
+ "coreBlocks.validateComposition": {
37455
+ capName: "core-blocks",
37456
+ capScope: "system",
37457
+ addonId: null,
37458
+ access: "view"
37459
+ },
35975
37460
  "cover.close": {
35976
37461
  capName: "cover",
35977
37462
  capScope: "device",
@@ -36362,6 +37847,30 @@ Object.freeze({
36362
37847
  addonId: null,
36363
37848
  access: "create"
36364
37849
  },
37850
+ "deviceExtension.listCandidates": {
37851
+ capName: "device-extension",
37852
+ capScope: "device",
37853
+ addonId: null,
37854
+ access: "view"
37855
+ },
37856
+ "deviceExtension.listSlots": {
37857
+ capName: "device-extension",
37858
+ capScope: "device",
37859
+ addonId: null,
37860
+ access: "view"
37861
+ },
37862
+ "deviceExtension.listSources": {
37863
+ capName: "device-extension",
37864
+ capScope: "device",
37865
+ addonId: null,
37866
+ access: "view"
37867
+ },
37868
+ "deviceExtension.setSlot": {
37869
+ capName: "device-extension",
37870
+ capScope: "device",
37871
+ addonId: null,
37872
+ access: "create"
37873
+ },
36365
37874
  "deviceManager.addLocation": {
36366
37875
  capName: "device-manager",
36367
37876
  capScope: "system",
@@ -36434,12 +37943,6 @@ Object.freeze({
36434
37943
  addonId: null,
36435
37944
  access: "create"
36436
37945
  },
36437
- "deviceManager.applyDeviceSettingsPatch": {
36438
- capName: "device-manager",
36439
- capScope: "system",
36440
- addonId: null,
36441
- access: "create"
36442
- },
36443
37946
  "deviceManager.applyInitialMeta": {
36444
37947
  capName: "device-manager",
36445
37948
  capScope: "system",
@@ -36542,12 +38045,6 @@ Object.freeze({
36542
38045
  addonId: null,
36543
38046
  access: "view"
36544
38047
  },
36545
- "deviceManager.getDeviceLiveContribution": {
36546
- capName: "device-manager",
36547
- capScope: "system",
36548
- addonId: null,
36549
- access: "view"
36550
- },
36551
38048
  "deviceManager.getDeviceLiveInfoAggregate": {
36552
38049
  capName: "device-manager",
36553
38050
  capScope: "system",
@@ -36560,12 +38057,6 @@ Object.freeze({
36560
38057
  addonId: null,
36561
38058
  access: "view"
36562
38059
  },
36563
- "deviceManager.getDeviceSettingsContribution": {
36564
- capName: "device-manager",
36565
- capScope: "system",
36566
- addonId: null,
36567
- access: "view"
36568
- },
36569
38060
  "deviceManager.getDeviceStatusAggregate": {
36570
38061
  capName: "device-manager",
36571
38062
  capScope: "system",
@@ -36632,6 +38123,12 @@ Object.freeze({
36632
38123
  addonId: null,
36633
38124
  access: "view"
36634
38125
  },
38126
+ "deviceManager.listDeviceIdsByCaps": {
38127
+ capName: "device-manager",
38128
+ capScope: "system",
38129
+ addonId: null,
38130
+ access: "view"
38131
+ },
36635
38132
  "deviceManager.listLocationDescriptions": {
36636
38133
  capName: "device-manager",
36637
38134
  capScope: "system",
@@ -37064,24 +38561,6 @@ Object.freeze({
37064
38561
  addonId: null,
37065
38562
  access: "view"
37066
38563
  },
37067
- "doorbell.applyDeviceSettingsPatch": {
37068
- capName: "doorbell",
37069
- capScope: "device",
37070
- addonId: null,
37071
- access: "create"
37072
- },
37073
- "doorbell.getDeviceLiveContribution": {
37074
- capName: "doorbell",
37075
- capScope: "device",
37076
- addonId: null,
37077
- access: "view"
37078
- },
37079
- "doorbell.getDeviceSettingsContribution": {
37080
- capName: "doorbell",
37081
- capScope: "device",
37082
- addonId: null,
37083
- access: "view"
37084
- },
37085
38564
  "doorbell.getStatus": {
37086
38565
  capName: "doorbell",
37087
38566
  capScope: "device",
@@ -37106,6 +38585,12 @@ Object.freeze({
37106
38585
  addonId: null,
37107
38586
  access: "view"
37108
38587
  },
38588
+ "embeddingEncoder.resetFailedModels": {
38589
+ capName: "embedding-encoder",
38590
+ capScope: "system",
38591
+ addonId: null,
38592
+ access: "delete"
38593
+ },
37109
38594
  "enumSensor.getStatus": {
37110
38595
  capName: "enum-sensor",
37111
38596
  capScope: "device",
@@ -37592,12 +39077,30 @@ Object.freeze({
37592
39077
  addonId: null,
37593
39078
  access: "create"
37594
39079
  },
39080
+ "llmRuntime.appleAvailability": {
39081
+ capName: "llm-runtime",
39082
+ capScope: "system",
39083
+ addonId: null,
39084
+ access: "view"
39085
+ },
39086
+ "llmRuntime.cancel": {
39087
+ capName: "llm-runtime",
39088
+ capScope: "system",
39089
+ addonId: null,
39090
+ access: "create"
39091
+ },
37595
39092
  "llmRuntime.complete": {
37596
39093
  capName: "llm-runtime",
37597
39094
  capScope: "system",
37598
39095
  addonId: null,
37599
39096
  access: "create"
37600
39097
  },
39098
+ "llmRuntime.completeApple": {
39099
+ capName: "llm-runtime",
39100
+ capScope: "system",
39101
+ addonId: null,
39102
+ access: "create"
39103
+ },
37601
39104
  "llmRuntime.deleteModel": {
37602
39105
  capName: "llm-runtime",
37603
39106
  capScope: "system",
@@ -38270,6 +39773,12 @@ Object.freeze({
38270
39773
  addonId: null,
38271
39774
  access: "create"
38272
39775
  },
39776
+ "nodes.directory": {
39777
+ capName: "nodes",
39778
+ capScope: "system",
39779
+ addonId: null,
39780
+ access: "view"
39781
+ },
38273
39782
  "nodes.executeQuery": {
38274
39783
  capName: "nodes",
38275
39784
  capScope: "system",
@@ -38438,6 +39947,12 @@ Object.freeze({
38438
39947
  addonId: null,
38439
39948
  access: "view"
38440
39949
  },
39950
+ "notificationRules.getRuleLastRuns": {
39951
+ capName: "notification-rules",
39952
+ capScope: "system",
39953
+ addonId: null,
39954
+ access: "view"
39955
+ },
38441
39956
  "notificationRules.getTemplateCatalog": {
38442
39957
  capName: "notification-rules",
38443
39958
  capScope: "system",
@@ -38462,6 +39977,12 @@ Object.freeze({
38462
39977
  addonId: null,
38463
39978
  access: "view"
38464
39979
  },
39980
+ "notificationRules.previewStateSummary": {
39981
+ capName: "notification-rules",
39982
+ capScope: "system",
39983
+ addonId: null,
39984
+ access: "view"
39985
+ },
38465
39986
  "notificationRules.previewTemplate": {
38466
39987
  capName: "notification-rules",
38467
39988
  capScope: "system",
@@ -39038,12 +40559,6 @@ Object.freeze({
39038
40559
  addonId: null,
39039
40560
  access: "create"
39040
40561
  },
39041
- "pipelineAnalytics.runReplayFrameProcessor": {
39042
- capName: "pipeline-analytics",
39043
- capScope: "device",
39044
- addonId: null,
39045
- access: "create"
39046
- },
39047
40562
  "pipelineAnalytics.saveRetrainAnnotations": {
39048
40563
  capName: "pipeline-analytics",
39049
40564
  capScope: "device",
@@ -39410,6 +40925,12 @@ Object.freeze({
39410
40925
  addonId: null,
39411
40926
  access: "view"
39412
40927
  },
40928
+ "pipelineOrchestrator.getClusterModelChoice": {
40929
+ capName: "pipeline-orchestrator",
40930
+ capScope: "system",
40931
+ addonId: null,
40932
+ access: "view"
40933
+ },
39413
40934
  "pipelineOrchestrator.getDeviceLiveContribution": {
39414
40935
  capName: "pipeline-orchestrator",
39415
40936
  capScope: "system",
@@ -42235,6 +43756,26 @@ Object.freeze({
42235
43756
  form: "single",
42236
43757
  optional: false
42237
43758
  }],
43759
+ "deviceExtension.listCandidates": [{
43760
+ name: "deviceId",
43761
+ form: "single",
43762
+ optional: false
43763
+ }],
43764
+ "deviceExtension.listSlots": [{
43765
+ name: "deviceId",
43766
+ form: "single",
43767
+ optional: false
43768
+ }],
43769
+ "deviceExtension.listSources": [{
43770
+ name: "deviceId",
43771
+ form: "single",
43772
+ optional: false
43773
+ }],
43774
+ "deviceExtension.setSlot": [{
43775
+ name: "deviceId",
43776
+ form: "single",
43777
+ optional: false
43778
+ }],
42238
43779
  "deviceManager.adoptionRelease": [{
42239
43780
  name: "camDeviceId",
42240
43781
  form: "single",
@@ -43141,11 +44682,6 @@ Object.freeze({
43141
44682
  form: "single",
43142
44683
  optional: false
43143
44684
  }],
43144
- "pipelineAnalytics.runReplayFrameProcessor": [{
43145
- name: "deviceId",
43146
- form: "single",
43147
- optional: false
43148
- }],
43149
44685
  "pipelineAnalytics.saveRetrainAnnotations": [{
43150
44686
  name: "deviceId",
43151
44687
  form: "single",
@@ -44241,11 +45777,232 @@ function prepareNotification(caps, n) {
44241
45777
  renderedAs
44242
45778
  };
44243
45779
  }
45780
+ /**
45781
+ * WHICH narrowing filter speaks about WHICH system-event kind — one predicate,
45782
+ * consumed by the rule ENGINE and by every rule EDITOR.
45783
+ *
45784
+ * ── The failure this file exists for ───────────────────────────────────────
45785
+ * `NcSystemEventConditionSchema` carries four optional narrowing lists
45786
+ * (`deviceIds`, `deviceTypes`, `nodeIds`, `packageNames`) beside a required
45787
+ * `kinds` gate. They are not four filters over one vocabulary: each belongs to
45788
+ * a FAMILY of kinds and is meaningless outside it. A node going away has no
45789
+ * device type; a completed export has no package; `stream-offline` deliberately
45790
+ * carries no device type at all (a stream belongs to a camera by construction).
45791
+ *
45792
+ * The engine applied all four to every kind, so a filter from one family failed
45793
+ * a kind from another family CLOSED. The operator's live rule "Eventi di
45794
+ * sistema" selected eleven kinds and set `deviceTypes: ['camera']` — the only
45795
+ * way to say "only my cameras" about the two liveness kinds — and NINE of the
45796
+ * eleven silently stopped being deliverable. Four days of history contained
45797
+ * `device-online` and `device-offline` and nothing else, across a window in
45798
+ * which agents were restarted and addons were updated.
45799
+ *
45800
+ * Both editors already computed this scoping, to decide which filter boxes to
45801
+ * render; the cap's own docblock already promised it ("Narrow a `device-*` kind
45802
+ * to these device TYPES"). Only the engine disagreed, and it disagreed in the
45803
+ * destructive direction. So the rule is stated ONCE, here, and the engine and
45804
+ * the editors are readers of it rather than three independent authors.
45805
+ *
45806
+ * ── The direction ─────────────────────────────────────────────────────────
45807
+ * Out of family ⇒ the filter is IGNORED, never fail-closed. An editor that
45808
+ * hides a box has already told the operator this filter does not speak about
45809
+ * these kinds, so honouring it as an exclusion contradicts the only
45810
+ * explanation the operator was ever given. Inside its family the filter still
45811
+ * narrows, and still fails CLOSED on a subject that cannot produce the identity
45812
+ * it tests (a device the mirror cannot name is not evidence of a camera).
45813
+ */
45814
+ /**
45815
+ * Every filter, for the callers that must cover all of them (guards, tests).
45816
+ *
45817
+ * `consumableLowPercent` (D642) is not a list but it is a filter in exactly
45818
+ * this sense: it belongs to a family of kinds (the consumable pair) and the
45819
+ * engine consults it only there. It differs in one way the readers must know —
45820
+ * its ABSENCE is not "no narrowing" but the default threshold, because a
45821
+ * consumable episode is always judged at SOME threshold.
45822
+ */
45823
+ var NC_SYSTEM_EVENT_FILTER_KEYS = [
45824
+ "deviceIds",
45825
+ "deviceTypes",
45826
+ "nodeIds",
45827
+ "packageNames",
45828
+ "consumableLowPercent"
45829
+ ];
45830
+ new Map(Object.entries({
45831
+ "device-online": "device-events",
45832
+ "device-offline": "device-events",
45833
+ "device-disabled": "device-events",
45834
+ "device-enabled": "device-events",
45835
+ "device-battery-low": "device-events",
45836
+ "device-battery-normal": "device-events",
45837
+ "device-consumable-low": "device-events",
45838
+ "device-consumable-normal": "device-events",
45839
+ "device-tank-low": "device-events",
45840
+ "device-tank-full": "device-events",
45841
+ "device-tank-normal": "device-events",
45842
+ "stream-online": "device-events",
45843
+ "stream-offline": "device-events",
45844
+ "detection-blind": "device-events",
45845
+ "node-online": "system",
45846
+ "node-offline": "system",
45847
+ "node-inference-unavailable": "system",
45848
+ "addon-crash-loop": "system",
45849
+ "addon-update-available": "system",
45850
+ "addon-updated": "system",
45851
+ "server-update-available": "system",
45852
+ "server-updated": "system",
45853
+ "wrapper-update-available": "system",
45854
+ "backup-completed": "system",
45855
+ "export-completed": "system",
45856
+ "alarm-triggered": "alarm",
45857
+ "alarm-armed": "alarm",
45858
+ "alarm-disarmed": "alarm",
45859
+ "alarm-arming": "alarm",
45860
+ "alarm-arm-refused": "alarm",
45861
+ "alarm-pending": "alarm",
45862
+ "alarm-rearmed": "alarm",
45863
+ "alarm-sensor-bypass": "alarm",
45864
+ "alarm-check-failed": "alarm",
45865
+ "camera-online": null,
45866
+ "camera-offline": null,
45867
+ "camera-disabled": null,
45868
+ "camera-enabled": null
45869
+ }));
45870
+ [...NC_SYSTEM_EVENT_FILTER_KEYS];
45871
+ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
45872
+ {
45873
+ id: "device-state",
45874
+ family: "device-events",
45875
+ label: "Device state",
45876
+ kinds: [
45877
+ "device-offline",
45878
+ "device-online",
45879
+ "device-disabled",
45880
+ "device-enabled"
45881
+ ]
45882
+ },
45883
+ {
45884
+ id: "streams",
45885
+ family: "device-events",
45886
+ label: "Streams",
45887
+ kinds: ["stream-offline", "stream-online"]
45888
+ },
45889
+ {
45890
+ id: "battery",
45891
+ family: "device-events",
45892
+ label: "Battery",
45893
+ kinds: ["device-battery-low", "device-battery-normal"]
45894
+ },
45895
+ {
45896
+ id: "consumables",
45897
+ family: "device-events",
45898
+ label: "Consumables",
45899
+ kinds: ["device-consumable-low", "device-consumable-normal"]
45900
+ },
45901
+ {
45902
+ id: "tanks",
45903
+ family: "device-events",
45904
+ label: "Tanks",
45905
+ kinds: [
45906
+ "device-tank-low",
45907
+ "device-tank-full",
45908
+ "device-tank-normal"
45909
+ ]
45910
+ },
45911
+ {
45912
+ id: "detection-blind",
45913
+ family: "device-events",
45914
+ label: "Detecting nothing",
45915
+ kinds: ["detection-blind"]
45916
+ },
45917
+ {
45918
+ id: "nodes",
45919
+ family: "system",
45920
+ label: "Nodes",
45921
+ kinds: [
45922
+ "node-offline",
45923
+ "node-online",
45924
+ "node-inference-unavailable"
45925
+ ]
45926
+ },
45927
+ {
45928
+ id: "addons",
45929
+ family: "system",
45930
+ label: "Addons",
45931
+ kinds: [
45932
+ "addon-crash-loop",
45933
+ "addon-update-available",
45934
+ "addon-updated"
45935
+ ]
45936
+ },
45937
+ {
45938
+ id: "updates",
45939
+ family: "system",
45940
+ label: "Server & container updates",
45941
+ kinds: [
45942
+ "server-update-available",
45943
+ "server-updated",
45944
+ "wrapper-update-available"
45945
+ ]
45946
+ },
45947
+ {
45948
+ id: "backups-exports",
45949
+ family: "system",
45950
+ label: "Backups & exports",
45951
+ kinds: ["backup-completed", "export-completed"]
45952
+ },
45953
+ {
45954
+ id: "alarm",
45955
+ family: "alarm",
45956
+ label: "Alarm",
45957
+ kinds: NC_ALARM_SYSTEM_EVENT_KINDS
45958
+ }
45959
+ ];
45960
+ function systemEventKindsOfFamily(family) {
45961
+ return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
45962
+ }
44244
45963
  NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
45964
+ /**
45965
+ * WHICH WAY A BOOLEAN SENSOR MOVED — read off the one slice a sensor event
45966
+ * persists (D640 "a sensor rule fires on the raise, the clear, or both").
45967
+ *
45968
+ * A device-event rule over a flood sensor notified on BOTH edges: water
45969
+ * detected, and back to dry. `NcConditions.sensorTransition` lets the rule
45970
+ * name one edge; this file answers, for one `SensorEvent`, which edge it is.
45971
+ *
45972
+ * NOT A SECOND TABLE. The "which boolean of this cap counts as HIGH" question
45973
+ * already has one answer, `SOURCE_CAP_ACTIVE_FIELD`
45974
+ * (`catalogs/sensor-active-state.ts`, the doorbell's and the recorder's edge
45975
+ * table), and a sensor event names its kind, not its cap. So the table here is
45976
+ * DERIVED: event kind → cap (`EVENT_KIND_BY_CAP`) → that cap's active field.
45977
+ * Only kinds whose taxonomy category is `sensor` take part — a switch has an
45978
+ * `on` boolean too, but "it triggers / it clears" is not a sentence about a
45979
+ * light, and offering it there would be a knob with a misleading label.
45980
+ * `presence` is a WORD (`home` / `not_home` / a zone), not a boolean, and is
45981
+ * absent from the source table, so it is absent here.
45982
+ *
45983
+ * `undefined` = never guessed: a kind with no raise (a doorbell press, a
45984
+ * button, a cover), or a slice whose field is missing or not a boolean. The
45985
+ * engine then does NOT filter — a flood alert must not go silent because one
45986
+ * read came back unreadable (the same stance as the alarm's `sensorEdgeOf`).
45987
+ *
45988
+ * Pure, RN-safe: the viewer imports the support rule from here.
45989
+ */
45990
+ /** Event kind → the boolean field of its cap slice that means "raised". */
45991
+ var NC_SENSOR_RAISED_FIELD_BY_KIND = Object.freeze(Object.fromEntries(Object.entries(EVENT_KIND_BY_CAP).flatMap(([capName, descriptor]) => {
45992
+ const field = SOURCE_CAP_ACTIVE_FIELD[capName];
45993
+ if (field === void 0 || descriptor.category !== "sensor") return [];
45994
+ return [[descriptor.kind, field]];
45995
+ })));
45996
+ Object.freeze(Object.keys(NC_SENSOR_RAISED_FIELD_BY_KIND));
44245
45997
  var RULE_BODY_ONLY = ["body"];
44246
45998
  var RULE_TEXT = ["title", "body"];
44247
45999
  var BATTERY = ["device-battery-low", "device-battery-normal"];
44248
46000
  var CONSUMABLE = ["device-consumable-low", "device-consumable-normal"];
46001
+ var TANK = [
46002
+ "device-tank-low",
46003
+ "device-tank-full",
46004
+ "device-tank-normal"
46005
+ ];
44249
46006
  var UPDATES = [
44250
46007
  "addon-update-available",
44251
46008
  "server-update-available",
@@ -44271,12 +46028,189 @@ var DEVICE_EVENTS = [
44271
46028
  "device-enabled",
44272
46029
  ...BATTERY,
44273
46030
  ...CONSUMABLE,
46031
+ ...TANK,
44274
46032
  "stream-online",
44275
46033
  "stream-offline",
44276
46034
  "detection-blind",
44277
46035
  ...ALARM
44278
46036
  ];
44279
- [...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];
46037
+ /** Every kind a summary may speak about — the two summarisable families. */
46038
+ var SUMMARISABLE = [...systemEventKindsOfFamily("device-events"), ...systemEventKindsOfFamily("system")];
46039
+ /** One per summary SECTION (`NC_STATE_SUMMARY_SECTIONS` in the notification
46040
+ * centre): the section's lines, offered when one of its kinds is selected. */
46041
+ var STATE_SUMMARY_SECTION_VARS = [
46042
+ {
46043
+ name: "summaryDevices",
46044
+ label: "Summary: devices offline / switched off",
46045
+ example: "Garage — offline since 07:12",
46046
+ kinds: [
46047
+ "device-offline",
46048
+ "device-online",
46049
+ "device-disabled",
46050
+ "device-enabled"
46051
+ ]
46052
+ },
46053
+ {
46054
+ name: "summaryStreams",
46055
+ label: "Summary: streams offline",
46056
+ example: "Ingresso (high) — since 06:40",
46057
+ kinds: ["stream-offline", "stream-online"]
46058
+ },
46059
+ {
46060
+ name: "summaryBattery",
46061
+ label: "Summary: low batteries",
46062
+ example: "Sensore porta — 8 %",
46063
+ kinds: BATTERY
46064
+ },
46065
+ {
46066
+ name: "summaryConsumables",
46067
+ label: "Summary: consumables",
46068
+ example: "Robot — filter 10 %",
46069
+ kinds: CONSUMABLE
46070
+ },
46071
+ {
46072
+ name: "summaryTanks",
46073
+ label: "Summary: tanks",
46074
+ example: "Robot — clean water low",
46075
+ kinds: TANK
46076
+ },
46077
+ {
46078
+ name: "summaryDetection",
46079
+ label: "Summary: cameras detecting nothing",
46080
+ example: "Ingresso — since 05:10",
46081
+ kinds: ["detection-blind"]
46082
+ },
46083
+ {
46084
+ name: "summaryNodes",
46085
+ label: "Summary: nodes",
46086
+ example: "little-unraid — offline since 03:00",
46087
+ kinds: [
46088
+ "node-offline",
46089
+ "node-online",
46090
+ "node-inference-unavailable"
46091
+ ]
46092
+ },
46093
+ {
46094
+ name: "summaryAddons",
46095
+ label: "Summary: addons",
46096
+ example: "@camstack/addon-recorder 1.2.3 → 1.2.4",
46097
+ kinds: [
46098
+ "addon-crash-loop",
46099
+ "addon-update-available",
46100
+ "addon-updated"
46101
+ ]
46102
+ },
46103
+ {
46104
+ name: "summaryUpdates",
46105
+ label: "Summary: server & container updates",
46106
+ example: "server 1.2.377 → 1.2.378",
46107
+ kinds: [
46108
+ "server-update-available",
46109
+ "server-updated",
46110
+ "wrapper-update-available"
46111
+ ]
46112
+ }
46113
+ ];
46114
+ var STATE_SUMMARY_VARS = [
46115
+ {
46116
+ name: "summaryText",
46117
+ label: "Summary: every section",
46118
+ description: "One block per section with something to report, one line per item.",
46119
+ example: "Batterie scariche: Sensore porta — 8 %",
46120
+ group: "system",
46121
+ families: ["rule"],
46122
+ fields: [...RULE_TEXT],
46123
+ kinds: ["system"],
46124
+ systemEventKinds: [...SUMMARISABLE],
46125
+ systemEventDeliveries: ["summary"]
46126
+ },
46127
+ {
46128
+ name: "summaryCount",
46129
+ label: "Summary: items reported",
46130
+ example: "3",
46131
+ group: "system",
46132
+ families: ["rule"],
46133
+ fields: [...RULE_TEXT],
46134
+ kinds: ["system"],
46135
+ systemEventKinds: [...SUMMARISABLE],
46136
+ systemEventDeliveries: ["summary"]
46137
+ },
46138
+ ...STATE_SUMMARY_SECTION_VARS.map((v) => ({
46139
+ name: v.name,
46140
+ label: v.label,
46141
+ example: v.example,
46142
+ group: "system",
46143
+ families: ["rule"],
46144
+ fields: [...RULE_TEXT],
46145
+ kinds: ["system"],
46146
+ systemEventKinds: [...v.kinds],
46147
+ systemEventDeliveries: ["summary"]
46148
+ }))
46149
+ ];
46150
+ [
46151
+ [...DEVICE_EVENTS],
46152
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
46153
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
46154
+ [...RULE_TEXT],
46155
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
46156
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
46157
+ [...RULE_TEXT],
46158
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
46159
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
46160
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
46161
+ [...RULE_TEXT],
46162
+ [...RULE_TEXT],
46163
+ [...RULE_TEXT],
46164
+ [...RULE_TEXT],
46165
+ [...RULE_TEXT],
46166
+ [...RULE_TEXT],
46167
+ [...RULE_TEXT],
46168
+ [...RULE_TEXT],
46169
+ [...RULE_BODY_ONLY],
46170
+ [...RULE_TEXT],
46171
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
46172
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
46173
+ ([...RULE_TEXT], [...BATTERY, ...CONSUMABLE]),
46174
+ ([...RULE_TEXT], [...CONSUMABLE]),
46175
+ ([...RULE_TEXT], [...TANK]),
46176
+ [...RULE_TEXT],
46177
+ ([...RULE_TEXT], [...UPDATES]),
46178
+ ([...RULE_TEXT], [...UPDATES]),
46179
+ [...RULE_TEXT],
46180
+ [...RULE_TEXT],
46181
+ [...RULE_TEXT],
46182
+ ([...RULE_TEXT], [...UPDATES]),
46183
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
46184
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
46185
+ ([...RULE_TEXT], [...UPDATES]),
46186
+ ([...RULE_TEXT], [...UPDATES]),
46187
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
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_TEXT],
46197
+ [...RULE_TEXT],
46198
+ [...RULE_TEXT],
46199
+ [...RULE_TEXT],
46200
+ [...RULE_TEXT],
46201
+ [...RULE_TEXT],
46202
+ [...RULE_TEXT],
46203
+ [...RULE_TEXT],
46204
+ [...RULE_TEXT],
46205
+ [...RULE_TEXT],
46206
+ [...RULE_TEXT],
46207
+ [...RULE_TEXT],
46208
+ [...RULE_TEXT],
46209
+ [...RULE_TEXT],
46210
+ [...RULE_TEXT],
46211
+ [...RULE_TEXT],
46212
+ ...STATE_SUMMARY_VARS
46213
+ ];
44280
46214
  /**
44281
46215
  * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
44282
46216
  *
@@ -44508,68 +46442,6 @@ TimelapseRuleInputSchema.extend({
44508
46442
  createdAt: number(),
44509
46443
  updatedAt: number()
44510
46444
  });
44511
- Object.freeze(Object.fromEntries([{
44512
- stepId: "face-embedding",
44513
- label: "Face recognition model",
44514
- defaultModelId: "arcface-r100",
44515
- indexName: "the enrolled face gallery",
44516
- options: [
44517
- {
44518
- id: "arcface-r100",
44519
- label: "ArcFace (ResNet34)"
44520
- },
44521
- {
44522
- id: "auraface-r100",
44523
- label: "AuraFace R100"
44524
- },
44525
- {
44526
- id: "inception-resnet-v1",
44527
- label: "Inception ResNet V1"
44528
- }
44529
- ]
44530
- }, {
44531
- stepId: "clip-embedding",
44532
- label: "Semantic search model",
44533
- defaultModelId: "mobileclip-s1",
44534
- indexName: "the object semantic-search index",
44535
- options: [{
44536
- id: "mobileclip-s1",
44537
- label: "MobileCLIP S1"
44538
- }, {
44539
- id: "mobileclip-s2",
44540
- label: "MobileCLIP S2"
44541
- }]
44542
- }].map((s) => [s.stepId, s.defaultModelId])));
44543
- string().min(1);
44544
- var CLUSTER_STEP_SETTING_FIELDS = [{
44545
- stepId: "face-embedding",
44546
- key: "minLandmarkFaceSize",
44547
- label: "Min face size for recognition (detection px)",
44548
- 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.",
44549
- type: "slider",
44550
- min: 0,
44551
- max: 64,
44552
- step: 2,
44553
- default: 24
44554
- }];
44555
- function clusterStepSettingKey(stepId, fieldKey) {
44556
- return `clusterStepSetting:${stepId}:${fieldKey}`;
44557
- }
44558
- var ClusterSettingNumberSchema = number().finite();
44559
- function readClusterStepSettings(config) {
44560
- const out = {};
44561
- for (const field of CLUSTER_STEP_SETTING_FIELDS) {
44562
- const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
44563
- const value = parsed.success ? parsed.data : field.default;
44564
- const existing = out[field.stepId] ?? {};
44565
- out[field.stepId] = {
44566
- ...existing,
44567
- [field.key]: value
44568
- };
44569
- }
44570
- return out;
44571
- }
44572
- readClusterStepSettings({});
44573
46445
  object({
44574
46446
  /**
44575
46447
  * Fraction of the box's own size added on EACH side before cutting.
@@ -45143,14 +47015,6 @@ function configSchema$1() {
45143
47015
  key: "adminToken",
45144
47016
  label: "Client/Admin Token (optional)",
45145
47017
  description: "A client token used only for discovery (GET /application). Leave blank to add applications manually."
45146
- },
45147
- {
45148
- type: "boolean",
45149
- key: "verifyTls",
45150
- label: "Verify TLS certificate",
45151
- style: "switch",
45152
- default: true,
45153
- description: "Disable only for a self-hosted server with a self-signed certificate."
45154
47018
  }
45155
47019
  ]
45156
47020
  }, {
@@ -45252,7 +47116,7 @@ function buildExtras(prepared) {
45252
47116
  }
45253
47117
  var gotifyAdapter = {
45254
47118
  descriptor: gotifyDescriptor(),
45255
- destinationKeys: ["serverUrl", "verifyTls"],
47119
+ destinationKeys: ["serverUrl"],
45256
47120
  buildRequest: (config, prepared) => {
45257
47121
  const serverUrl = readString$3(config, "serverUrl");
45258
47122
  if (!serverUrl) throw new Error("gotify: serverUrl is required");