@camstack/addon-provider-homeassistant 1.2.3 → 1.2.5

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 +1532 -980
  2. package/dist/addon.mjs +1532 -980
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { brotliCompressSync, deflateSync, gzipSync } from "node:zlib";
3
- //#region ../types/dist/event-category-D4HJq7Mw.mjs
3
+ //#region ../types/dist/event-category-BLcNejAE.mjs
4
4
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
5
5
  EventCategory["SystemBoot"] = "system.boot";
6
6
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -150,9 +150,6 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
150
150
  EventCategory["RecordingSegmentWritten"] = "recording.segment.written";
151
151
  EventCategory["RecordingPolicyFallback"] = "recording.policy.fallback";
152
152
  EventCategory["RecordingRetentionCompleted"] = "recording.retention.completed";
153
- /** Runner-sampled scrub thumbnail (~1/5 s/camera). Telemetry (D8): a lost
154
- * thumb is a scrub gap the recorder's keyframe backfill covers. */
155
- EventCategory["RecordingThumbSampled"] = "recording.thumb-sampled";
156
153
  /** Export render progress (0–100). Telemetry (D8): a lost tick is a stale
157
154
  * progress bar the client reconciles via `recordingExport.getExport`. */
158
155
  EventCategory["RecordingExportProgress"] = "recording.export.progress";
@@ -6817,7 +6814,6 @@ object({ deviceId: number() }), object({ deviceId: number() }), object({
6817
6814
  patch: record(string(), unknown())
6818
6815
  }), object({ success: literal(true) });
6819
6816
  object({ deviceId: number() }), unknown().nullable();
6820
- /** Shorthand to define a method schema */
6821
6817
  function method(input, output, options) {
6822
6818
  return {
6823
6819
  input,
@@ -6825,6 +6821,7 @@ function method(input, output, options) {
6825
6821
  kind: options?.kind ?? "query",
6826
6822
  auth: options?.auth ?? "protected",
6827
6823
  ...options?.access !== void 0 ? { access: options.access } : {},
6824
+ ...options?.caller !== void 0 ? { caller: options.caller } : {},
6828
6825
  timeoutMs: options?.timeoutMs
6829
6826
  };
6830
6827
  }
@@ -8311,6 +8308,59 @@ for (const l of AUDIO_MACRO_LABELS) {
8311
8308
  /** The complete taxonomy dictionary, keyed by kind. */
8312
8309
  var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
8313
8310
  /**
8311
+ * Notification-Center taxonomy — the fixed vocabulary the NC rule editor
8312
+ * offers as pickers instead of free text. Derived (never hand-listed) from the
8313
+ * single `EVENT_TAXONOMY` dictionary so it stays in lockstep with every other
8314
+ * taxonomy surface (timeline, filters, event page).
8315
+ *
8316
+ * Three buckets, mapped onto the rule editor's `stringList` conditions:
8317
+ * - `videoClasses` → detection classes (person / vehicle / animal + subs)
8318
+ * for the `classes` / `classesExclude` conditions.
8319
+ * - `audioKinds` → audio-analyzer sub kinds (`audio-scream`, …) shown in
8320
+ * the same class picker, grouped under an Audio header.
8321
+ * - `labels` → sensor + control taxonomy kinds (doorbell / contact /
8322
+ * lock / …) for the `sensorKinds` device-event condition.
8323
+ *
8324
+ * Each entry carries `parentKind` so the client can group video subs under
8325
+ * their macro and sensor/control kinds under their category. This surface is
8326
+ * served ADDITIVELY on the `nc.getConditionCatalog` bridge response — no cap
8327
+ * method, no codegen — so it ships train-free with an addon deploy.
8328
+ */
8329
+ /** One selectable taxonomy value: a stable kind id + display label + parent. */
8330
+ var NcTaxonomyEntrySchema = object({
8331
+ /** Stable kind id (e.g. 'person', 'car', 'audio-scream', 'doorbell'). */
8332
+ kind: string(),
8333
+ /** English fallback label (the UI translates via the event-kind i18n key). */
8334
+ label: string(),
8335
+ /** Macro/category parent for grouping ('car' → 'vehicle'); null for a top. */
8336
+ parentKind: string().nullable()
8337
+ });
8338
+ object({
8339
+ videoClasses: array(NcTaxonomyEntrySchema),
8340
+ audioKinds: array(NcTaxonomyEntrySchema),
8341
+ labels: array(NcTaxonomyEntrySchema)
8342
+ });
8343
+ function toEntry(kind, label, parentKind) {
8344
+ return {
8345
+ kind,
8346
+ label,
8347
+ parentKind
8348
+ };
8349
+ }
8350
+ /**
8351
+ * Build the NC taxonomy from `EVENT_TAXONOMY`. Insertion order is preserved
8352
+ * (macros before their subs), which the client relies on for stable grouping.
8353
+ */
8354
+ function buildNcTaxonomy() {
8355
+ const all = Object.values(EVENT_TAXONOMY);
8356
+ return {
8357
+ videoClasses: all.filter((e) => e.category === "detection").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8358
+ audioKinds: all.filter((e) => e.category === "audio" && e.level === "sub").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8359
+ labels: all.filter((e) => e.category === "sensor" || e.category === "control").map((e) => toEntry(e.kind, e.label, e.parentKind))
8360
+ };
8361
+ }
8362
+ Object.freeze(buildNcTaxonomy());
8363
+ /**
8314
8364
  * Error types for the safe expression engine. Two distinct classes so callers
8315
8365
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
8316
8366
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -12534,6 +12584,22 @@ var CameraMetricsSchema = object({
12534
12584
  ])
12535
12585
  });
12536
12586
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
12587
+ /**
12588
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
12589
+ * within the frame, so the executor can re-cut a leaf child ROI at native
12590
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
12591
+ */
12592
+ var NativeCropRefSchema = object({
12593
+ /** Handle keying the retained native surface (node-pinned to its owner). */
12594
+ handle: FrameHandleSchema,
12595
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
12596
+ cropFrameSpace: object({
12597
+ x: number(),
12598
+ y: number(),
12599
+ w: number(),
12600
+ h: number()
12601
+ })
12602
+ });
12537
12603
  var ModelFormatSchema$1 = _enum([
12538
12604
  "onnx",
12539
12605
  "coreml",
@@ -12809,7 +12875,22 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
12809
12875
  * Omitted ⇒ the runner's default device (current single-engine
12810
12876
  * behaviour). Selects WHICH device pool of the node runs the call.
12811
12877
  */
12812
- deviceKey: string().optional()
12878
+ deviceKey: string().optional(),
12879
+ /**
12880
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
12881
+ * when the parent crop was resolved from the frame's retained NATIVE
12882
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
12883
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
12884
+ * resolution from that surface — the SAME quality path faces already
12885
+ * had — instead of the downscaled parent tile. `handle` keys the native
12886
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
12887
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
12888
+ * the executor's crop-normalized child ROI back into frame-normalized
12889
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
12890
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
12891
+ * (today's behaviour on the fallback path).
12892
+ */
12893
+ nativeCropRef: NativeCropRefSchema.optional()
12813
12894
  }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
12814
12895
  engine: PipelineEngineChoiceSchema.optional(),
12815
12896
  steps: array(PipelineStepInputSchema).min(1),
@@ -13058,7 +13139,11 @@ var DetailResultSchema = object({
13058
13139
  bbox: NativeCropBboxSchema.optional(),
13059
13140
  embedding: string().optional(),
13060
13141
  label: string().optional(),
13061
- alignedCropJpeg: string().optional()
13142
+ alignedCropJpeg: string().optional(),
13143
+ /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
13144
+ * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
13145
+ * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
13146
+ nativeFaceShortSidePx: number().optional()
13062
13147
  });
13063
13148
  /**
13064
13149
  * Per-camera tunable ranges + defaults. Single source of truth used
@@ -13072,6 +13157,12 @@ var motionCooldownMsField = {
13072
13157
  default: 3e4,
13073
13158
  step: 500
13074
13159
  };
13160
+ var maxSessionHoldMsField = {
13161
+ min: 0,
13162
+ max: 6e5,
13163
+ default: 12e4,
13164
+ step: 5e3
13165
+ };
13075
13166
  var motionFpsField = {
13076
13167
  min: 1,
13077
13168
  max: 30,
@@ -13219,6 +13310,19 @@ var RunnerCameraConfigSchema = object({
13219
13310
  "on-motion"
13220
13311
  ]).default("always-on"),
13221
13312
  motionCooldownMs: number().min(motionCooldownMsField.min).default(motionCooldownMsField.default),
13313
+ /**
13314
+ * Orchestrator-side on-motion session-hold cap (ms). While an on-motion
13315
+ * detection session is active and ≥1 confirmed non-stationary track is
13316
+ * still live, the orchestrator keeps the session open past
13317
+ * `motionCooldownMs` (a slowly-moving subject can stop re-triggering the
13318
+ * camera's VMD yet is still being tracked frame-to-frame) — up to this many
13319
+ * ms since the session opened, after which it closes regardless. `0`
13320
+ * disables the hold (legacy cooldown-only teardown). Not consumed by the
13321
+ * runner itself — carried here so it shares the per-camera device-settings
13322
+ * surface with `motionCooldownMs`; the orchestrator reads it off the
13323
+ * resolved `CameraDetectionConfig`.
13324
+ */
13325
+ maxSessionHoldMs: number().min(maxSessionHoldMsField.min).max(maxSessionHoldMsField.max).optional(),
13222
13326
  motionFps: number().min(motionFpsField.min).max(motionFpsField.max).default(motionFpsField.default),
13223
13327
  detectionFps: number().min(detectionFpsField.min).max(detectionFpsField.max).default(detectionFpsField.default),
13224
13328
  motionStreamId: string(),
@@ -13308,7 +13412,7 @@ var RunnerCameraConfigSchema = object({
13308
13412
  */
13309
13413
  inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
13310
13414
  });
13311
- motionFpsField.min, motionFpsField.max, motionFpsField.step, motionFpsField.default, detectionFpsField.min, detectionFpsField.max, detectionFpsField.step, detectionFpsField.default, motionCooldownMsField.min, motionCooldownMsField.max, motionCooldownMsField.step, motionCooldownMsField.default, occupancyRecheckSecField.min, occupancyRecheckSecField.max, occupancyRecheckSecField.step, occupancyRecheckSecField.default, occupancyRecheckFramesField.min, occupancyRecheckFramesField.max, occupancyRecheckFramesField.step, occupancyRecheckFramesField.default;
13415
+ motionFpsField.min, motionFpsField.max, motionFpsField.step, motionFpsField.default, detectionFpsField.min, detectionFpsField.max, detectionFpsField.step, detectionFpsField.default, motionCooldownMsField.min, motionCooldownMsField.max, motionCooldownMsField.step, motionCooldownMsField.default, maxSessionHoldMsField.min, maxSessionHoldMsField.max, maxSessionHoldMsField.step, maxSessionHoldMsField.default, occupancyRecheckSecField.min, occupancyRecheckSecField.max, occupancyRecheckSecField.step, occupancyRecheckSecField.default, occupancyRecheckFramesField.min, occupancyRecheckFramesField.max, occupancyRecheckFramesField.step, occupancyRecheckFramesField.default;
13312
13416
  /**
13313
13417
  * Runtime load summary returned by `getLocalLoad`. Used by the orchestrator's
13314
13418
  * load-balancing levels (L2 capacity-based, L3 hardware-aware) to decide
@@ -16854,94 +16958,6 @@ var EnrichedWidgetMetadataSchema = WidgetMetadataSchema.extend({
16854
16958
  bundleUrl: string()
16855
16959
  });
16856
16960
  method(_void(), array(EnrichedWidgetMetadataSchema).readonly());
16857
- var NotificationRuleConditionsSchema = object({
16858
- deviceIds: array(number()).readonly().optional(),
16859
- classNames: array(string()).readonly().optional(),
16860
- zoneIds: array(string()).readonly().optional(),
16861
- minConfidence: number().optional(),
16862
- source: _enum([
16863
- "pipeline",
16864
- "onboard",
16865
- "any"
16866
- ]).optional(),
16867
- schedule: object({
16868
- days: array(number()).readonly(),
16869
- startHour: number(),
16870
- endHour: number()
16871
- }).optional(),
16872
- cooldownSeconds: number().optional(),
16873
- minDwellSeconds: number().optional(),
16874
- /** Match against `event.data.eventType` token (e.g. `'press_long'`). When non-empty, only events
16875
- * carrying a matching `data.eventType` string pass this condition. Rules without this field are
16876
- * unaffected (back-compat). Distinct from `rule.eventTypes` which holds EventCategory strings. */
16877
- eventTypeTokens: array(string()).readonly().optional(),
16878
- /** Match detections whose CLIP image embedding is semantically similar to this free-text
16879
- * description. Requires the embedding-encoder cap to have pre-warmed the text vector.
16880
- * `minSimilarity` is the cosine similarity threshold in [0, 1]. */
16881
- clipDescription: object({
16882
- text: string().min(1),
16883
- minSimilarity: number().min(0).max(1)
16884
- }).optional(),
16885
- /** Match events whose recognized-entity label (face identity name or plate
16886
- * vehicle name, propagated onto `event.data.label`) is one of these values.
16887
- * Empty/absent → unaffected (back-compat). Enables "notify me when <named
16888
- * vehicle/person> is seen". */
16889
- labels: array(string()).readonly().optional()
16890
- });
16891
- var NotificationRuleTemplateSchema = object({
16892
- title: string(),
16893
- body: string(),
16894
- imageMode: _enum([
16895
- "crop",
16896
- "annotated",
16897
- "full",
16898
- "none"
16899
- ])
16900
- });
16901
- var NotificationRuleSchema = object({
16902
- id: string(),
16903
- name: string(),
16904
- enabled: boolean(),
16905
- eventTypes: array(string()).readonly(),
16906
- conditions: NotificationRuleConditionsSchema,
16907
- outputs: array(string()).readonly(),
16908
- template: NotificationRuleTemplateSchema.optional(),
16909
- priority: _enum([
16910
- "low",
16911
- "normal",
16912
- "high",
16913
- "critical"
16914
- ])
16915
- });
16916
- var NotificationTestResultSchema = object({
16917
- ruleId: string(),
16918
- eventId: string(),
16919
- timestamp: number(),
16920
- wouldFire: boolean(),
16921
- reason: string().optional()
16922
- });
16923
- var NotificationHistoryEntrySchema = object({
16924
- id: string(),
16925
- ruleId: string(),
16926
- ruleName: string(),
16927
- eventId: string(),
16928
- timestamp: number(),
16929
- outputs: array(string()).readonly(),
16930
- success: boolean(),
16931
- error: string().optional(),
16932
- deviceId: number().optional()
16933
- });
16934
- var NotificationHistoryFilterSchema = object({
16935
- ruleId: string().optional(),
16936
- deviceId: number().optional(),
16937
- from: number().optional(),
16938
- to: number().optional(),
16939
- limit: number().optional()
16940
- });
16941
- method(_void(), object({ rules: array(NotificationRuleSchema).readonly() })), method(object({ rule: NotificationRuleSchema }), object({ success: literal(true) }), { kind: "mutation" }), method(object({ ruleId: string() }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
16942
- ruleId: string(),
16943
- lookbackMinutes: number()
16944
- }), object({ results: array(NotificationTestResultSchema).readonly() }), { kind: "mutation" }), method(object({ filter: NotificationHistoryFilterSchema.optional() }), object({ entries: array(NotificationHistoryEntrySchema).readonly() }));
16945
16961
  /**
16946
16962
  * Alerts capability — collection-based internal alert system.
16947
16963
  *
@@ -17128,89 +17144,6 @@ method(object({
17128
17144
  password: string()
17129
17145
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
17130
17146
  /**
17131
- * `login-method` — collection cap through which auth addons contribute
17132
- * their pre-auth login surfaces to the login page. This is the SINGLE,
17133
- * generic mechanism that supersedes the dead `auth.listProviders` reader:
17134
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
17135
- * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17136
- * procedure aggregates them for the unauthenticated login page.
17137
- *
17138
- * A contribution is a discriminated union on `kind`:
17139
- *
17140
- * - `redirect` — a declarative button. The login page renders a generic
17141
- * button that navigates to `startUrl` (an addon-owned HTTP route).
17142
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17143
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
17144
- * login page needs NO change.
17145
- *
17146
- * - `widget` — a Module-Federation widget the login page mounts (via
17147
- * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
17148
- * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
17149
- * mechanism kept for future use; no shipped addon uses it on the login
17150
- * page (the passkey ceremony below runs natively in the shell instead).
17151
- *
17152
- * - `passkey` — a declarative WebAuthn ceremony the shell renders
17153
- * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
17154
- * a remotely-loaded bundle). Carries the addon's effective `rpId` /
17155
- * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
17156
- * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
17157
- * fetching any remote code pre-auth. Contribution stays unconditional —
17158
- * enrollment state is never leaked pre-auth; visibility is a shell
17159
- * decision.
17160
- *
17161
- * Every contribution carries a `stage`:
17162
- * - `primary` — shown on the first credentials screen (OIDC /
17163
- * magic-link buttons; a future usernameless passkey).
17164
- * - `second-factor` — shown AFTER the password leg, gated on the
17165
- * returned `factors` (passkey-as-2FA today).
17166
- *
17167
- * `mount: skip` — the cap is read server-side by the core auth router
17168
- * (`registry.getCollection('login-method')`), never mounted as its own
17169
- * tRPC router.
17170
- */
17171
- /** When a login method renders in the two-phase login flow. */
17172
- var LoginStageEnum = _enum(["primary", "second-factor"]);
17173
- /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
17174
- var LoginMethodContributionSchema = discriminatedUnion("kind", [
17175
- object({
17176
- kind: literal("redirect"),
17177
- /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
17178
- id: string(),
17179
- /** Operator-facing button label. */
17180
- label: string(),
17181
- /** lucide-react icon name. */
17182
- icon: string().optional(),
17183
- /** Addon-owned HTTP route the button navigates to (GET). */
17184
- startUrl: string(),
17185
- stage: LoginStageEnum
17186
- }),
17187
- object({
17188
- kind: literal("widget"),
17189
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
17190
- id: string(),
17191
- /** Owning addon id — drives the public bundle URL + the MF namespace. */
17192
- addonId: string(),
17193
- /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
17194
- bundle: string(),
17195
- /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
17196
- remote: WidgetRemoteSchema,
17197
- stage: LoginStageEnum
17198
- }),
17199
- object({
17200
- kind: literal("passkey"),
17201
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
17202
- id: string(),
17203
- /** Operator-facing button label. */
17204
- label: string(),
17205
- stage: LoginStageEnum,
17206
- /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
17207
- rpId: string(),
17208
- /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
17209
- origin: string().nullable()
17210
- })
17211
- ]);
17212
- method(_void(), array(LoginMethodContributionSchema).readonly());
17213
- /**
17214
17147
  * Orchestrator-side destination metadata. The orchestrator computes
17215
17148
  * `id = <addonId>:<subId>` from its provider lookup so consumers
17216
17149
  * (admin UI, restore flow) see one canonical key.
@@ -18620,373 +18553,748 @@ method(_void(), array(string()).readonly(), { auth: "admin" }), method(object({
18620
18553
  kind: "mutation",
18621
18554
  auth: "admin"
18622
18555
  });
18623
- var LogLevelSchema = _enum([
18624
- "debug",
18625
- "info",
18626
- "warn",
18627
- "error"
18556
+ /**
18557
+ * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
18558
+ * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
18559
+ * caps stay wire-compatible without a circular cap→cap import.
18560
+ *
18561
+ * Errors are a discriminated-union RESULT, never thrown: the shape survives
18562
+ * every transport tier structurally, and failed calls still write usage rows.
18563
+ * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
18564
+ */
18565
+ var LlmUsageSchema = object({
18566
+ inputTokens: number(),
18567
+ outputTokens: number()
18568
+ });
18569
+ var LlmErrorCodeSchema = _enum([
18570
+ "timeout",
18571
+ "rate-limited",
18572
+ "auth",
18573
+ "refusal",
18574
+ "bad-request",
18575
+ "unavailable",
18576
+ "no-profile",
18577
+ "budget-exceeded",
18578
+ "adapter-error"
18628
18579
  ]);
18629
- var LogEntrySchema = object({
18630
- timestamp: date(),
18631
- level: LogLevelSchema,
18632
- scope: array(string()),
18580
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
18581
+ ok: literal(true),
18582
+ text: string(),
18583
+ model: string(),
18584
+ usage: LlmUsageSchema,
18585
+ truncated: boolean(),
18586
+ latencyMs: number()
18587
+ }), object({
18588
+ ok: literal(false),
18589
+ code: LlmErrorCodeSchema,
18633
18590
  message: string(),
18634
- meta: record(string(), unknown()).optional(),
18635
- tags: record(string(), string()).optional()
18636
- });
18637
- method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18638
- scope: array(string()).optional(),
18639
- level: LogLevelSchema.optional(),
18640
- since: date().optional(),
18641
- until: date().optional(),
18642
- limit: number().optional(),
18643
- tags: record(string(), string()).optional()
18644
- }), array(LogEntrySchema).readonly());
18645
- var CpuBreakdownSchema = object({
18646
- total: number(),
18647
- user: number(),
18648
- system: number(),
18649
- irq: number(),
18650
- nice: number(),
18651
- loadAvg: tuple([
18652
- number(),
18653
- number(),
18654
- number()
18655
- ]),
18656
- cores: number()
18591
+ retryAfterMs: number().optional()
18592
+ })]);
18593
+ /**
18594
+ * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
18595
+ * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
18596
+ * notification-output.cap.ts:27-31 precedents).
18597
+ */
18598
+ var LlmImageSchema = object({
18599
+ bytes: _instanceof(Uint8Array),
18600
+ mimeType: string()
18657
18601
  });
18658
- var MemoryInfoSchema = object({
18659
- percent: number(),
18660
- totalBytes: number(),
18661
- usedBytes: number(),
18662
- availableBytes: number(),
18663
- swapUsedBytes: number(),
18664
- swapTotalBytes: number()
18602
+ var LlmGenerateBaseInputSchema = object({
18603
+ /** Collection routing (the notification-output posture). */
18604
+ addonId: string().optional(),
18605
+ /** Explicit profile; else the resolution chain (spec §3). */
18606
+ profileId: string().optional(),
18607
+ /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
18608
+ consumer: string(),
18609
+ system: string().optional(),
18610
+ /** v1: single-turn. `messages[]` is a v2 additive field. */
18611
+ prompt: string(),
18612
+ /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
18613
+ jsonSchema: record(string(), unknown()).optional(),
18614
+ /** Per-call override of the profile default. */
18615
+ maxTokens: number().int().positive().optional(),
18616
+ temperature: number().optional()
18665
18617
  });
18666
- var DiskIoSnapshotSchema = object({
18667
- readBytes: number(),
18668
- writeBytes: number(),
18669
- readOps: number(),
18670
- writeOps: number(),
18671
- timestampMs: number()
18672
- });
18673
- var NetworkIoSnapshotSchema = object({
18674
- rxBytes: number(),
18675
- txBytes: number(),
18676
- rxPackets: number(),
18677
- txPackets: number(),
18678
- rxErrors: number(),
18679
- txErrors: number(),
18680
- timestampMs: number()
18681
- });
18682
- var MetricsGpuInfoSchema = object({
18683
- utilization: number(),
18684
- model: string(),
18685
- memoryUsedBytes: number(),
18686
- memoryTotalBytes: number(),
18687
- temperature: number().nullable()
18688
- });
18689
- var ProcessResourceInfoSchema = object({
18690
- openFds: number(),
18691
- threadCount: number(),
18692
- activeHandles: number(),
18693
- activeRequests: number()
18694
- });
18695
- var PressureAvgsSchema = object({
18696
- avg10: number(),
18697
- avg60: number(),
18698
- avg300: number()
18699
- });
18700
- var PressureInfoSchema = object({
18701
- some: PressureAvgsSchema,
18702
- full: PressureAvgsSchema.nullable()
18703
- });
18704
- var SystemResourceSnapshotSchema = object({
18705
- cpu: CpuBreakdownSchema,
18706
- memory: MemoryInfoSchema,
18707
- gpu: MetricsGpuInfoSchema.nullable(),
18708
- network: NetworkIoSnapshotSchema,
18709
- disk: DiskIoSnapshotSchema,
18710
- pressure: object({
18711
- cpu: PressureInfoSchema.nullable(),
18712
- memory: PressureInfoSchema.nullable(),
18713
- io: PressureInfoSchema.nullable()
18618
+ /**
18619
+ * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
18620
+ * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
18621
+ * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
18622
+ * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
18623
+ * this only through the `llm` cap's methods.
18624
+ *
18625
+ * One running llama-server child per node in v1 (models are RAM-heavy).
18626
+ * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
18627
+ * watchdog — operator decision #3).
18628
+ */
18629
+ var ManagedModelRefSchema = discriminatedUnion("kind", [
18630
+ object({
18631
+ kind: literal("catalog"),
18632
+ catalogId: string()
18714
18633
  }),
18715
- process: ProcessResourceInfoSchema,
18716
- cpuTemperature: number().nullable(),
18717
- timestampMs: number()
18718
- });
18719
- var DiskSpaceInfoSchema = object({
18720
- path: string(),
18721
- totalBytes: number(),
18722
- usedBytes: number(),
18723
- availableBytes: number(),
18724
- percent: number()
18725
- });
18726
- var PidResourceStatsSchema = object({
18727
- pid: number(),
18728
- cpu: number(),
18729
- memory: number(),
18730
- /**
18731
- * Private (anonymous) resident bytes — the per-process V8 heap + native
18732
- * allocations NOT shared with other processes (Linux RssAnon). This is the
18733
- * "real" per-runner cost; summing it across runners is meaningful, unlike
18734
- * `memory` (RSS), which double-counts the shared mmap'd framework code.
18735
- * Undefined where /proc is unavailable (e.g. macOS).
18736
- */
18737
- privateBytes: number().optional(),
18738
- /**
18739
- * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
18740
- * code shared copy-on-write across runners. Undefined on macOS.
18741
- */
18742
- sharedBytes: number().optional()
18634
+ object({
18635
+ kind: literal("url"),
18636
+ url: string(),
18637
+ sha256: string().optional()
18638
+ }),
18639
+ object({
18640
+ kind: literal("path"),
18641
+ path: string()
18642
+ })
18643
+ ]);
18644
+ var ManagedRuntimeConfigSchema = object({
18645
+ /** WHERE the runtime lives — hub or any agent. */
18646
+ nodeId: string(),
18647
+ /** Closed for v1; 'ollama' is a v2 candidate. */
18648
+ engine: _enum(["llama-cpp"]),
18649
+ model: ManagedModelRefSchema,
18650
+ contextSize: number().int().default(4096),
18651
+ /** 0 = CPU-only. */
18652
+ gpuLayers: number().int().default(0),
18653
+ /** Default: cpus-2, clamped ≥1 (resolved node-side). */
18654
+ threads: number().int().optional(),
18655
+ /** Concurrent slots. */
18656
+ parallel: number().int().default(1),
18657
+ /** Else lazy: first generate boots it. */
18658
+ autoStart: boolean().default(false),
18659
+ /** 0 = never; frees RAM after quiet periods. */
18660
+ idleStopMinutes: number().int().default(30)
18743
18661
  });
18744
- var AddonInstanceSchema = object({
18745
- addonId: string(),
18662
+ var LlmRuntimeStatusSchema = object({
18663
+ /** Status is ALWAYS node-qualified. */
18746
18664
  nodeId: string(),
18747
- role: _enum(["hub", "worker"]),
18748
- pid: number(),
18749
18665
  state: _enum([
18750
- "starting",
18751
- "running",
18752
- "stopping",
18753
18666
  "stopped",
18754
- "crashed"
18755
- ]),
18756
- uptimeSec: number()
18757
- });
18758
- var NodeProcessSchema = object({
18759
- pid: number(),
18760
- ppid: number(),
18761
- pgid: number(),
18762
- classification: _enum([
18763
- "root",
18764
- "managed",
18765
- "system",
18766
- "ghost"
18667
+ "downloading",
18668
+ "starting",
18669
+ "ready",
18670
+ "crashed",
18671
+ "failed"
18767
18672
  ]),
18768
- /** `$process` addon binding when `managed`, else null. */
18769
- addonId: string().nullable(),
18770
- /** Kernel-reported nodeId when the process is a known agent/worker. */
18771
- nodeId: string().nullable(),
18772
- /** Truncated command line. */
18773
- command: string(),
18774
- cpuPercent: number(),
18775
- memoryRssBytes: number(),
18776
- /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
18777
- uptimeSec: number(),
18778
- /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
18779
- orphaned: boolean()
18780
- });
18781
- var KillProcessInputSchema = object({
18782
- pid: number(),
18783
- /** Force = SIGKILL. Default is SIGTERM. */
18784
- force: boolean().optional()
18785
- });
18786
- var KillProcessResultSchema = object({
18787
- success: boolean(),
18788
- reason: string().optional(),
18789
- signal: _enum(["SIGTERM", "SIGKILL"]).optional()
18790
- });
18791
- var DumpHeapSnapshotInputSchema = object({
18792
- /** The addon whose runner should dump a heap snapshot. */
18793
- addonId: string() });
18794
- var DumpHeapSnapshotResultSchema = object({
18795
- success: boolean(),
18796
- /** Path of the written .heapsnapshot inside the runner's container/host. */
18797
- path: string().optional(),
18798
- /** Process pid that was signalled. */
18799
18673
  pid: number().optional(),
18800
- reason: string().optional()
18674
+ port: number().optional(),
18675
+ modelPath: string().optional(),
18676
+ modelId: string().optional(),
18677
+ downloadProgress: number().min(0).max(1).optional(),
18678
+ lastError: string().optional(),
18679
+ crashesInWindow: number(),
18680
+ /** Child RSS (sampled best-effort). */
18681
+ memoryBytes: number().optional(),
18682
+ vramBytes: number().optional()
18801
18683
  });
18802
- var SystemMetricsSchema = object({
18803
- cpuPercent: number(),
18804
- memoryPercent: number(),
18805
- memoryUsedMB: number(),
18806
- memoryTotalMB: number(),
18807
- diskPercent: number().optional(),
18808
- temperature: number().optional(),
18809
- gpuPercent: number().optional(),
18810
- gpuMemoryPercent: number().optional()
18684
+ var LlmNodeModelSchema = object({
18685
+ file: string(),
18686
+ sizeBytes: number(),
18687
+ catalogId: string().optional(),
18688
+ installedAt: number().optional()
18811
18689
  });
18812
- method(_void(), SystemResourceSnapshotSchema), method(_void(), SystemResourceSnapshotSchema.nullable()), method(_void(), SystemMetricsSchema), method(object({ dirPath: string() }), DiskSpaceInfoSchema), method(_void(), MetricsGpuInfoSchema.nullable()), method(_void(), number().nullable()), method(object({ pids: array(number()) }), array(PidResourceStatsSchema)), method(_void(), array(AddonInstanceSchema).readonly()), method(object({ addonId: string() }), PidResourceStatsSchema.nullable()), method(_void(), array(NodeProcessSchema).readonly()), method(KillProcessInputSchema, KillProcessResultSchema, {
18690
+ var LlmRuntimeDiskUsageSchema = object({
18691
+ nodeId: string(),
18692
+ modelsBytes: number(),
18693
+ freeBytes: number().optional()
18694
+ });
18695
+ method(LlmGenerateBaseInputSchema.extend({
18696
+ images: array(LlmImageSchema).optional(),
18697
+ runtime: ManagedRuntimeConfigSchema,
18698
+ /** The managed profile's timeout, threaded by the hub provider. */
18699
+ timeoutMs: number().int().positive().optional()
18700
+ }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
18813
18701
  kind: "mutation",
18814
18702
  auth: "admin"
18815
- }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
18703
+ }), method(object({}), _void(), {
18816
18704
  kind: "mutation",
18817
18705
  auth: "admin"
18818
- });
18819
- method(object({
18820
- sourceUrl: string(),
18821
- metadata: ModelConvertMetadataSchema,
18822
- targets: array(ConvertTargetSchema).min(1).readonly(),
18823
- calibrationRef: string().optional(),
18824
- sessionId: string().optional()
18825
- }), ConvertResultSchema, {
18706
+ }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
18826
18707
  kind: "mutation",
18827
- auth: "admin",
18828
- timeoutMs: 6e5
18829
- });
18830
- method(object({
18831
- nodeId: string(),
18832
- modelId: string(),
18833
- format: _enum(MODEL_FORMATS),
18834
- entry: ModelCatalogEntrySchema
18835
- }), object({
18836
- ok: boolean(),
18837
- /** sha256 of the staged tarball (empty for a hub-local no-op). */
18838
- sha256: string(),
18839
- bytes: number(),
18840
- /** The target node's modelsDir the artifact landed in. */
18841
- path: string()
18842
- }), {
18708
+ auth: "admin"
18709
+ }), method(object({ file: string() }), _void(), {
18843
18710
  kind: "mutation",
18844
18711
  auth: "admin"
18845
- });
18712
+ }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
18846
18713
  /**
18847
- * `mqtt-broker` — broker-registry cap.
18848
- *
18849
- * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
18850
- * MQTT brokers (external + optionally an embedded `aedes`-backed one)
18851
- * and (b) the connection details a consumer addon needs to spin up
18852
- * its OWN `mqtt.js` client.
18714
+ * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
18715
+ * methods concat-fan across providers; single-row methods route to ONE
18716
+ * provider by the `addonId` in the call input (the notification-output
18717
+ * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
18718
+ * (hub-placed); the cap stays open for future providers.
18853
18719
  *
18854
- * Why: pub/sub routing over the system event-bus loses fidelity
18855
- * (callback shape, QoS guarantees, will/retain semantics) and adds
18856
- * refcount bookkeeping that addons would rather own themselves. The
18857
- * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
18858
- * features anyway — give it the connection config, get out of the way.
18859
- *
18860
- * Consumer flow:
18861
- * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
18862
- * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
18863
- * client.subscribe('zigbee2mqtt/+')
18864
- *
18865
- * Collection mode: multiple brokers (e.g. one local mosquitto + one
18866
- * cloud bridge). The "embedded" entry (when present) is just another
18867
- * broker in the registry — its lifecycle is owned by the addon that
18868
- * spawned it.
18869
- */
18870
- var BrokerKindSchema = _enum(["external", "embedded"]);
18871
- /**
18872
- * Broker live-probe status.
18873
- *
18874
- * - `connected` — last probe completed a clean CONNACK
18875
- * - `disconnected` — no probe has run yet (cold cache)
18876
- * - `auth-failed` — CONNACK refused with auth error (RC 4 / 5)
18877
- * - `unreachable` — TCP connect timed out / refused
18878
- * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
18720
+ * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
18721
+ * `apiKey` is a password field providers REDACT it on read and merge on
18722
+ * write; a stored key NEVER round-trips to a client.
18879
18723
  */
18880
- var BrokerStatusSchema$1 = _enum([
18881
- "connected",
18882
- "disconnected",
18883
- "auth-failed",
18884
- "unreachable",
18885
- "tls-error"
18724
+ var LlmProfileKindSchema = _enum([
18725
+ "openai-compatible",
18726
+ "openai",
18727
+ "anthropic",
18728
+ "google",
18729
+ "managed-local"
18886
18730
  ]);
18887
- var BrokerInfoSchema = object({
18731
+ var LlmProfileSchema = object({
18888
18732
  id: string(),
18889
18733
  name: string(),
18890
- url: string(),
18891
- kind: BrokerKindSchema,
18892
- status: BrokerStatusSchema$1,
18893
- latencyMs: number().nullable(),
18894
- error: string().optional(),
18895
- /** Embedded brokers only: number of MQTT clients currently connected. */
18896
- connectedClients: number().int().nonnegative().optional(),
18897
- /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
18898
- lastCheckedAt: number().optional()
18734
+ kind: LlmProfileKindSchema,
18735
+ /** Stamped by the provider — keeps the fanned catalog routable. */
18736
+ addonId: string(),
18737
+ enabled: boolean(),
18738
+ /** Vendor model id, or the managed runtime's loaded model. */
18739
+ model: string(),
18740
+ /** Required for openai-compatible; override for cloud kinds. */
18741
+ baseUrl: string().optional(),
18742
+ /** ConfigUISchema type:'password' — never round-trips (spec §5). */
18743
+ apiKey: string().optional(),
18744
+ supportsVision: boolean(),
18745
+ temperature: number().min(0).max(2).optional(),
18746
+ maxTokens: number().int().positive().optional(),
18747
+ timeoutMs: number().int().positive().default(6e4),
18748
+ extraHeaders: record(string(), string()).optional(),
18749
+ /** kind === 'managed-local' only (spec §4). */
18750
+ runtime: ManagedRuntimeConfigSchema.optional()
18899
18751
  });
18900
- /**
18901
- * Connection details — what a consumer needs to call
18902
- * `mqtt.connect(url, options)`. We split URL + credentials so the
18903
- * consumer can pass them as `mqtt.connect(url, { username, password })`
18904
- * instead of stuffing creds into the URL (which leaks them into logs).
18905
- */
18906
- var BrokerConnectionDetailsSchema = object({
18907
- url: string(),
18908
- username: string().optional(),
18909
- password: string().optional(),
18910
- /**
18911
- * Suggested prefix for `clientId`. Each consumer should suffix this
18912
- * with its own discriminator (addon id, instance id) so reconnects
18913
- * don't kick each other off (MQTT spec: clientId must be unique per
18914
- * broker).
18915
- */
18916
- clientIdPrefix: string().optional()
18752
+ /** ConfigUISchema tree passed through untyped on the wire (the
18753
+ * notification-output `ConfigSchemaPassthrough` precedent at
18754
+ * notification-output.cap.ts:151); the exported TS type re-tightens it. */
18755
+ var ConfigSchemaPassthrough$1 = unknown();
18756
+ var LlmProfileKindDescriptorSchema = object({
18757
+ kind: LlmProfileKindSchema,
18758
+ label: string(),
18759
+ icon: string(),
18760
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
18761
+ addonId: string(),
18762
+ configSchema: ConfigSchemaPassthrough$1
18917
18763
  });
18918
- var AddBrokerInputSchema = object({
18919
- name: string().min(1),
18920
- url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
18921
- username: string().optional(),
18922
- password: string().optional(),
18923
- clientIdPrefix: string().optional()
18764
+ var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
18765
+ var LlmDefaultSchema = object({
18766
+ selector: LlmDefaultSelectorSchema,
18767
+ profileId: string()
18924
18768
  });
18925
- var AddBrokerResultSchema = object({ id: string() });
18926
- var IdInputSchema = object({ id: string() });
18927
- var TestResultSchema$1 = discriminatedUnion("ok", [object({
18928
- ok: literal(true),
18929
- latencyMs: number()
18930
- }), object({
18931
- ok: literal(false),
18932
- error: string()
18933
- })]);
18934
- var StartEmbeddedInputSchema = object({
18935
- port: number().int().min(1).max(65535).default(1883),
18936
- /** Allow anonymous connect (no username/password). Default: false. */
18937
- allowAnonymous: boolean().default(false),
18938
- /** Optional shared username/password for clients. */
18939
- username: string().optional(),
18940
- password: string().optional()
18769
+ /** Server-side rollup row getUsage never dumps raw call rows (spec §6). */
18770
+ var LlmUsageRollupSchema = object({
18771
+ day: string(),
18772
+ consumer: string(),
18773
+ profileId: string(),
18774
+ calls: number(),
18775
+ okCalls: number(),
18776
+ errorCalls: number(),
18777
+ inputTokens: number(),
18778
+ outputTokens: number(),
18779
+ avgLatencyMs: number()
18941
18780
  });
18942
- var StartEmbeddedResultSchema = object({
18781
+ /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
18782
+ var ManagedModelCatalogEntrySchema = object({
18943
18783
  id: string(),
18944
- url: string()
18945
- });
18946
- var StatusSchema = object({
18947
- brokerCount: number(),
18948
- embeddedRunning: boolean()
18949
- });
18950
- method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema), method(AddBrokerInputSchema, AddBrokerResultSchema, { kind: "mutation" }), method(IdInputSchema, _void(), { kind: "mutation" }), method(IdInputSchema, TestResultSchema$1, { kind: "mutation" }), method(StartEmbeddedInputSchema, StartEmbeddedResultSchema, { kind: "mutation" }), method(IdInputSchema, _void(), { kind: "mutation" }), method(_void(), StatusSchema);
18951
- var NetworkEndpointSchema = object({
18784
+ label: string(),
18785
+ family: string(),
18786
+ purpose: _enum(["text", "vision"]),
18952
18787
  url: string(),
18953
- hostname: string(),
18954
- port: number(),
18955
- protocol: _enum(["http", "https"])
18788
+ sha256: string(),
18789
+ sizeBytes: number(),
18790
+ quantization: string(),
18791
+ /** Load-time guidance shown in the picker. */
18792
+ minRamBytes: number(),
18793
+ contextSizeDefault: number().int(),
18794
+ /** Vision models: companion projector file. */
18795
+ mmprojUrl: string().optional()
18956
18796
  });
18957
- var NetworkAccessStatusSchema = object({
18958
- connected: boolean(),
18959
- endpoint: NetworkEndpointSchema.nullable(),
18797
+ var LlmRuntimeNodeSchema = object({
18798
+ nodeId: string(),
18799
+ reachable: boolean(),
18800
+ status: LlmRuntimeStatusSchema.optional(),
18801
+ disk: LlmRuntimeDiskUsageSchema.optional(),
18960
18802
  error: string().optional()
18961
18803
  });
18962
- /**
18963
- * Optional, richer endpoint shape returned by providers that expose
18964
- * MORE than one ingress concurrently (Tailscale Ingress with mixed
18965
- * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
18966
- * the originating provider config (mode + sourcePort) so the
18967
- * orchestrator UI can label rows distinctly. Providers that expose only
18968
- * one endpoint just omit `listEndpoints` from their provider impl.
18969
- */
18970
- var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
18971
- /**
18972
- * Stable id within the provider — typically `<mode>-<sourcePort>` so
18973
- * the orchestrator can dedupe across `listEndpoints` polls.
18974
- */
18975
- id: string(),
18976
- /** Operator-facing label (mirrors `MeshEndpoint.label`). */
18977
- label: string(),
18978
- /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
18979
- mode: string().optional(),
18980
- /** Originating local port the ingress fronts (informational). */
18981
- sourcePort: number().optional()
18804
+ var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
18805
+ var ProfileRefInputSchema = object({
18806
+ addonId: string(),
18807
+ profileId: string()
18982
18808
  });
18983
- method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
18809
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
18810
+ kind: "mutation",
18811
+ auth: "admin"
18812
+ }), method(ProfileRefInputSchema, _void(), {
18813
+ kind: "mutation",
18814
+ auth: "admin"
18815
+ }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
18816
+ kind: "mutation",
18817
+ auth: "admin"
18818
+ }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
18819
+ selector: LlmDefaultSelectorSchema,
18820
+ profileId: string().nullable()
18821
+ }), _void(), {
18822
+ kind: "mutation",
18823
+ auth: "admin"
18824
+ }), method(object({
18825
+ since: number().optional(),
18826
+ until: number().optional(),
18827
+ consumer: string().optional(),
18828
+ profileId: string().optional()
18829
+ }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
18830
+ nodeId: string(),
18831
+ model: ManagedModelRefSchema
18832
+ }), _void(), {
18833
+ kind: "mutation",
18834
+ auth: "admin"
18835
+ }), method(object({
18836
+ nodeId: string(),
18837
+ file: string()
18838
+ }), _void(), {
18839
+ kind: "mutation",
18840
+ auth: "admin"
18841
+ }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
18842
+ kind: "mutation",
18843
+ auth: "admin"
18844
+ }), method(ProfileRefInputSchema, _void(), {
18845
+ kind: "mutation",
18846
+ auth: "admin"
18847
+ });
18848
+ var LogLevelSchema = _enum([
18849
+ "debug",
18850
+ "info",
18851
+ "warn",
18852
+ "error"
18853
+ ]);
18854
+ var LogEntrySchema = object({
18855
+ timestamp: date(),
18856
+ level: LogLevelSchema,
18857
+ scope: array(string()),
18858
+ message: string(),
18859
+ meta: record(string(), unknown()).optional(),
18860
+ tags: record(string(), string()).optional()
18861
+ });
18862
+ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18863
+ scope: array(string()).optional(),
18864
+ level: LogLevelSchema.optional(),
18865
+ since: date().optional(),
18866
+ until: date().optional(),
18867
+ limit: number().optional(),
18868
+ tags: record(string(), string()).optional()
18869
+ }), array(LogEntrySchema).readonly());
18984
18870
  /**
18985
- * notification-outputcanonical, capability-gated notification delivery.
18871
+ * `login-method`collection cap through which auth addons contribute
18872
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
18873
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
18874
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18875
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
18876
+ * procedure aggregates them for the unauthenticated login page.
18986
18877
  *
18987
- * Apprise-derived model (see
18988
- * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
18989
- * callers emit ONE canonical `Notification`; each provider declares a
18878
+ * A contribution is a discriminated union on `kind`:
18879
+ *
18880
+ * - `redirect` a declarative button. The login page renders a generic
18881
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
18882
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
18883
+ * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18884
+ * login page needs NO change.
18885
+ *
18886
+ * - `widget` — a Module-Federation widget the login page mounts (via
18887
+ * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
18888
+ * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
18889
+ * mechanism kept for future use; no shipped addon uses it on the login
18890
+ * page (the passkey ceremony below runs natively in the shell instead).
18891
+ *
18892
+ * - `passkey` — a declarative WebAuthn ceremony the shell renders
18893
+ * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
18894
+ * a remotely-loaded bundle). Carries the addon's effective `rpId` /
18895
+ * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
18896
+ * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
18897
+ * fetching any remote code pre-auth. Contribution stays unconditional —
18898
+ * enrollment state is never leaked pre-auth; visibility is a shell
18899
+ * decision.
18900
+ *
18901
+ * Every contribution carries a `stage`:
18902
+ * - `primary` — shown on the first credentials screen (OIDC /
18903
+ * magic-link buttons; a future usernameless passkey).
18904
+ * - `second-factor` — shown AFTER the password leg, gated on the
18905
+ * returned `factors` (passkey-as-2FA today).
18906
+ *
18907
+ * `mount: skip` — the cap is read server-side by the core auth router
18908
+ * (`registry.getCollection('login-method')`), never mounted as its own
18909
+ * tRPC router.
18910
+ */
18911
+ /** When a login method renders in the two-phase login flow. */
18912
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
18913
+ /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
18914
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [
18915
+ object({
18916
+ kind: literal("redirect"),
18917
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
18918
+ id: string(),
18919
+ /** Operator-facing button label. */
18920
+ label: string(),
18921
+ /** lucide-react icon name. */
18922
+ icon: string().optional(),
18923
+ /** Addon-owned HTTP route the button navigates to (GET). */
18924
+ startUrl: string(),
18925
+ stage: LoginStageEnum
18926
+ }),
18927
+ object({
18928
+ kind: literal("widget"),
18929
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
18930
+ id: string(),
18931
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
18932
+ addonId: string(),
18933
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
18934
+ bundle: string(),
18935
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
18936
+ remote: WidgetRemoteSchema,
18937
+ stage: LoginStageEnum
18938
+ }),
18939
+ object({
18940
+ kind: literal("passkey"),
18941
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
18942
+ id: string(),
18943
+ /** Operator-facing button label. */
18944
+ label: string(),
18945
+ stage: LoginStageEnum,
18946
+ /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
18947
+ rpId: string(),
18948
+ /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
18949
+ origin: string().nullable()
18950
+ })
18951
+ ]);
18952
+ method(_void(), array(LoginMethodContributionSchema).readonly());
18953
+ var CpuBreakdownSchema = object({
18954
+ total: number(),
18955
+ user: number(),
18956
+ system: number(),
18957
+ irq: number(),
18958
+ nice: number(),
18959
+ loadAvg: tuple([
18960
+ number(),
18961
+ number(),
18962
+ number()
18963
+ ]),
18964
+ cores: number()
18965
+ });
18966
+ var MemoryInfoSchema = object({
18967
+ percent: number(),
18968
+ totalBytes: number(),
18969
+ usedBytes: number(),
18970
+ availableBytes: number(),
18971
+ swapUsedBytes: number(),
18972
+ swapTotalBytes: number()
18973
+ });
18974
+ var DiskIoSnapshotSchema = object({
18975
+ readBytes: number(),
18976
+ writeBytes: number(),
18977
+ readOps: number(),
18978
+ writeOps: number(),
18979
+ timestampMs: number()
18980
+ });
18981
+ var NetworkIoSnapshotSchema = object({
18982
+ rxBytes: number(),
18983
+ txBytes: number(),
18984
+ rxPackets: number(),
18985
+ txPackets: number(),
18986
+ rxErrors: number(),
18987
+ txErrors: number(),
18988
+ timestampMs: number()
18989
+ });
18990
+ var MetricsGpuInfoSchema = object({
18991
+ utilization: number(),
18992
+ model: string(),
18993
+ memoryUsedBytes: number(),
18994
+ memoryTotalBytes: number(),
18995
+ temperature: number().nullable()
18996
+ });
18997
+ var ProcessResourceInfoSchema = object({
18998
+ openFds: number(),
18999
+ threadCount: number(),
19000
+ activeHandles: number(),
19001
+ activeRequests: number()
19002
+ });
19003
+ var PressureAvgsSchema = object({
19004
+ avg10: number(),
19005
+ avg60: number(),
19006
+ avg300: number()
19007
+ });
19008
+ var PressureInfoSchema = object({
19009
+ some: PressureAvgsSchema,
19010
+ full: PressureAvgsSchema.nullable()
19011
+ });
19012
+ var SystemResourceSnapshotSchema = object({
19013
+ cpu: CpuBreakdownSchema,
19014
+ memory: MemoryInfoSchema,
19015
+ gpu: MetricsGpuInfoSchema.nullable(),
19016
+ network: NetworkIoSnapshotSchema,
19017
+ disk: DiskIoSnapshotSchema,
19018
+ pressure: object({
19019
+ cpu: PressureInfoSchema.nullable(),
19020
+ memory: PressureInfoSchema.nullable(),
19021
+ io: PressureInfoSchema.nullable()
19022
+ }),
19023
+ process: ProcessResourceInfoSchema,
19024
+ cpuTemperature: number().nullable(),
19025
+ timestampMs: number()
19026
+ });
19027
+ var DiskSpaceInfoSchema = object({
19028
+ path: string(),
19029
+ totalBytes: number(),
19030
+ usedBytes: number(),
19031
+ availableBytes: number(),
19032
+ percent: number()
19033
+ });
19034
+ var PidResourceStatsSchema = object({
19035
+ pid: number(),
19036
+ cpu: number(),
19037
+ memory: number(),
19038
+ /**
19039
+ * Private (anonymous) resident bytes — the per-process V8 heap + native
19040
+ * allocations NOT shared with other processes (Linux RssAnon). This is the
19041
+ * "real" per-runner cost; summing it across runners is meaningful, unlike
19042
+ * `memory` (RSS), which double-counts the shared mmap'd framework code.
19043
+ * Undefined where /proc is unavailable (e.g. macOS).
19044
+ */
19045
+ privateBytes: number().optional(),
19046
+ /**
19047
+ * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
19048
+ * code shared copy-on-write across runners. Undefined on macOS.
19049
+ */
19050
+ sharedBytes: number().optional()
19051
+ });
19052
+ var AddonInstanceSchema = object({
19053
+ addonId: string(),
19054
+ nodeId: string(),
19055
+ role: _enum(["hub", "worker"]),
19056
+ pid: number(),
19057
+ state: _enum([
19058
+ "starting",
19059
+ "running",
19060
+ "stopping",
19061
+ "stopped",
19062
+ "crashed"
19063
+ ]),
19064
+ uptimeSec: number()
19065
+ });
19066
+ var NodeProcessSchema = object({
19067
+ pid: number(),
19068
+ ppid: number(),
19069
+ pgid: number(),
19070
+ classification: _enum([
19071
+ "root",
19072
+ "managed",
19073
+ "system",
19074
+ "ghost"
19075
+ ]),
19076
+ /** `$process` addon binding when `managed`, else null. */
19077
+ addonId: string().nullable(),
19078
+ /** Kernel-reported nodeId when the process is a known agent/worker. */
19079
+ nodeId: string().nullable(),
19080
+ /** Truncated command line. */
19081
+ command: string(),
19082
+ cpuPercent: number(),
19083
+ memoryRssBytes: number(),
19084
+ /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
19085
+ uptimeSec: number(),
19086
+ /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
19087
+ orphaned: boolean()
19088
+ });
19089
+ var KillProcessInputSchema = object({
19090
+ pid: number(),
19091
+ /** Force = SIGKILL. Default is SIGTERM. */
19092
+ force: boolean().optional()
19093
+ });
19094
+ var KillProcessResultSchema = object({
19095
+ success: boolean(),
19096
+ reason: string().optional(),
19097
+ signal: _enum(["SIGTERM", "SIGKILL"]).optional()
19098
+ });
19099
+ var DumpHeapSnapshotInputSchema = object({
19100
+ /** The addon whose runner should dump a heap snapshot. */
19101
+ addonId: string() });
19102
+ var DumpHeapSnapshotResultSchema = object({
19103
+ success: boolean(),
19104
+ /** Path of the written .heapsnapshot inside the runner's container/host. */
19105
+ path: string().optional(),
19106
+ /** Process pid that was signalled. */
19107
+ pid: number().optional(),
19108
+ reason: string().optional()
19109
+ });
19110
+ var SystemMetricsSchema = object({
19111
+ cpuPercent: number(),
19112
+ memoryPercent: number(),
19113
+ memoryUsedMB: number(),
19114
+ memoryTotalMB: number(),
19115
+ diskPercent: number().optional(),
19116
+ temperature: number().optional(),
19117
+ gpuPercent: number().optional(),
19118
+ gpuMemoryPercent: number().optional()
19119
+ });
19120
+ method(_void(), SystemResourceSnapshotSchema), method(_void(), SystemResourceSnapshotSchema.nullable()), method(_void(), SystemMetricsSchema), method(object({ dirPath: string() }), DiskSpaceInfoSchema), method(_void(), MetricsGpuInfoSchema.nullable()), method(_void(), number().nullable()), method(object({ pids: array(number()) }), array(PidResourceStatsSchema)), method(_void(), array(AddonInstanceSchema).readonly()), method(object({ addonId: string() }), PidResourceStatsSchema.nullable()), method(_void(), array(NodeProcessSchema).readonly()), method(KillProcessInputSchema, KillProcessResultSchema, {
19121
+ kind: "mutation",
19122
+ auth: "admin"
19123
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
19124
+ kind: "mutation",
19125
+ auth: "admin"
19126
+ });
19127
+ method(object({
19128
+ sourceUrl: string(),
19129
+ metadata: ModelConvertMetadataSchema,
19130
+ targets: array(ConvertTargetSchema).min(1).readonly(),
19131
+ calibrationRef: string().optional(),
19132
+ sessionId: string().optional()
19133
+ }), ConvertResultSchema, {
19134
+ kind: "mutation",
19135
+ auth: "admin",
19136
+ timeoutMs: 6e5
19137
+ });
19138
+ method(object({
19139
+ nodeId: string(),
19140
+ modelId: string(),
19141
+ format: _enum(MODEL_FORMATS),
19142
+ entry: ModelCatalogEntrySchema
19143
+ }), object({
19144
+ ok: boolean(),
19145
+ /** sha256 of the staged tarball (empty for a hub-local no-op). */
19146
+ sha256: string(),
19147
+ bytes: number(),
19148
+ /** The target node's modelsDir the artifact landed in. */
19149
+ path: string()
19150
+ }), {
19151
+ kind: "mutation",
19152
+ auth: "admin"
19153
+ });
19154
+ /**
19155
+ * `mqtt-broker` — broker-registry cap.
19156
+ *
19157
+ * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
19158
+ * MQTT brokers (external + optionally an embedded `aedes`-backed one)
19159
+ * and (b) the connection details a consumer addon needs to spin up
19160
+ * its OWN `mqtt.js` client.
19161
+ *
19162
+ * Why: pub/sub routing over the system event-bus loses fidelity
19163
+ * (callback shape, QoS guarantees, will/retain semantics) and adds
19164
+ * refcount bookkeeping that addons would rather own themselves. The
19165
+ * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
19166
+ * features anyway — give it the connection config, get out of the way.
19167
+ *
19168
+ * Consumer flow:
19169
+ * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
19170
+ * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
19171
+ * client.subscribe('zigbee2mqtt/+')
19172
+ *
19173
+ * Collection mode: multiple brokers (e.g. one local mosquitto + one
19174
+ * cloud bridge). The "embedded" entry (when present) is just another
19175
+ * broker in the registry — its lifecycle is owned by the addon that
19176
+ * spawned it.
19177
+ */
19178
+ var BrokerKindSchema = _enum(["external", "embedded"]);
19179
+ /**
19180
+ * Broker live-probe status.
19181
+ *
19182
+ * - `connected` — last probe completed a clean CONNACK
19183
+ * - `disconnected` — no probe has run yet (cold cache)
19184
+ * - `auth-failed` — CONNACK refused with auth error (RC 4 / 5)
19185
+ * - `unreachable` — TCP connect timed out / refused
19186
+ * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
19187
+ */
19188
+ var BrokerStatusSchema$1 = _enum([
19189
+ "connected",
19190
+ "disconnected",
19191
+ "auth-failed",
19192
+ "unreachable",
19193
+ "tls-error"
19194
+ ]);
19195
+ var BrokerInfoSchema = object({
19196
+ id: string(),
19197
+ name: string(),
19198
+ url: string(),
19199
+ kind: BrokerKindSchema,
19200
+ status: BrokerStatusSchema$1,
19201
+ latencyMs: number().nullable(),
19202
+ error: string().optional(),
19203
+ /** Embedded brokers only: number of MQTT clients currently connected. */
19204
+ connectedClients: number().int().nonnegative().optional(),
19205
+ /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
19206
+ lastCheckedAt: number().optional()
19207
+ });
19208
+ /**
19209
+ * Connection details — what a consumer needs to call
19210
+ * `mqtt.connect(url, options)`. We split URL + credentials so the
19211
+ * consumer can pass them as `mqtt.connect(url, { username, password })`
19212
+ * instead of stuffing creds into the URL (which leaks them into logs).
19213
+ */
19214
+ var BrokerConnectionDetailsSchema = object({
19215
+ url: string(),
19216
+ username: string().optional(),
19217
+ password: string().optional(),
19218
+ /**
19219
+ * Suggested prefix for `clientId`. Each consumer should suffix this
19220
+ * with its own discriminator (addon id, instance id) so reconnects
19221
+ * don't kick each other off (MQTT spec: clientId must be unique per
19222
+ * broker).
19223
+ */
19224
+ clientIdPrefix: string().optional()
19225
+ });
19226
+ var AddBrokerInputSchema = object({
19227
+ name: string().min(1),
19228
+ url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
19229
+ username: string().optional(),
19230
+ password: string().optional(),
19231
+ clientIdPrefix: string().optional()
19232
+ });
19233
+ var AddBrokerResultSchema = object({ id: string() });
19234
+ var IdInputSchema = object({ id: string() });
19235
+ var TestResultSchema$1 = discriminatedUnion("ok", [object({
19236
+ ok: literal(true),
19237
+ latencyMs: number()
19238
+ }), object({
19239
+ ok: literal(false),
19240
+ error: string()
19241
+ })]);
19242
+ var StartEmbeddedInputSchema = object({
19243
+ port: number().int().min(1).max(65535).default(1883),
19244
+ /** Allow anonymous connect (no username/password). Default: false. */
19245
+ allowAnonymous: boolean().default(false),
19246
+ /** Optional shared username/password for clients. */
19247
+ username: string().optional(),
19248
+ password: string().optional()
19249
+ });
19250
+ var StartEmbeddedResultSchema = object({
19251
+ id: string(),
19252
+ url: string()
19253
+ });
19254
+ var StatusSchema = object({
19255
+ brokerCount: number(),
19256
+ embeddedRunning: boolean()
19257
+ });
19258
+ method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema), method(AddBrokerInputSchema, AddBrokerResultSchema, { kind: "mutation" }), method(IdInputSchema, _void(), { kind: "mutation" }), method(IdInputSchema, TestResultSchema$1, { kind: "mutation" }), method(StartEmbeddedInputSchema, StartEmbeddedResultSchema, { kind: "mutation" }), method(IdInputSchema, _void(), { kind: "mutation" }), method(_void(), StatusSchema);
19259
+ var NetworkEndpointSchema = object({
19260
+ url: string(),
19261
+ hostname: string(),
19262
+ port: number(),
19263
+ protocol: _enum(["http", "https"])
19264
+ });
19265
+ var NetworkAccessStatusSchema = object({
19266
+ connected: boolean(),
19267
+ endpoint: NetworkEndpointSchema.nullable(),
19268
+ error: string().optional()
19269
+ });
19270
+ /**
19271
+ * Optional, richer endpoint shape returned by providers that expose
19272
+ * MORE than one ingress concurrently (Tailscale Ingress with mixed
19273
+ * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
19274
+ * the originating provider config (mode + sourcePort) so the
19275
+ * orchestrator UI can label rows distinctly. Providers that expose only
19276
+ * one endpoint just omit `listEndpoints` from their provider impl.
19277
+ */
19278
+ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
19279
+ /**
19280
+ * Stable id within the provider — typically `<mode>-<sourcePort>` so
19281
+ * the orchestrator can dedupe across `listEndpoints` polls.
19282
+ */
19283
+ id: string(),
19284
+ /** Operator-facing label (mirrors `MeshEndpoint.label`). */
19285
+ label: string(),
19286
+ /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
19287
+ mode: string().optional(),
19288
+ /** Originating local port the ingress fronts (informational). */
19289
+ sourcePort: number().optional()
19290
+ });
19291
+ method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
19292
+ /**
19293
+ * notification-output — canonical, capability-gated notification delivery.
19294
+ *
19295
+ * Apprise-derived model (see
19296
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
19297
+ * callers emit ONE canonical `Notification`; each provider declares a
18990
19298
  * per-kind capability descriptor (`TargetKind`), and the pure degrade
18991
19299
  * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
18992
19300
  * message to what the kind supports — callers never special-case a service.
@@ -19082,403 +19390,599 @@ var TargetKindLevelSchema = object({
19082
19390
  silent: boolean().optional(),
19083
19391
  noPush: boolean().optional()
19084
19392
  }).optional(),
19085
- /** e.g. Pushover `emergency` requires `retry` / `expire`. */
19086
- requires: array(string()).optional(),
19087
- description: string().optional()
19088
- });
19089
- /** The full capability block consulted before dispatch. */
19090
- var TargetKindCapsSchema = object({
19091
- attachments: object({
19092
- mediaTypes: array(AttachmentMediaTypeSchema),
19093
- mode: _enum([
19094
- "url",
19095
- "bytes",
19096
- "both"
19097
- ]),
19098
- max: number().int().nonnegative(),
19099
- maxBytes: number().int().positive().optional()
19100
- }),
19101
- /** Max action buttons (0 = none). */
19102
- actions: number().int().nonnegative(),
19103
- levels: array(TargetKindLevelSchema),
19104
- format: array(NotificationFormatSchema),
19105
- clickUrl: boolean(),
19106
- sound: boolean(),
19107
- ttl: boolean(),
19108
- bodyMaxLen: number().int().positive()
19109
- });
19110
- /**
19111
- * `configSchema` is a `ConfigUISchema` tree passed through to the admin
19112
- * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
19113
- * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
19114
- * the union is large and not meant for runtime validation here; the exported
19115
- * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
19116
- */
19117
- var ConfigSchemaPassthrough$1 = unknown();
19118
- var TargetKindSchema = object({
19119
- kind: string(),
19120
- label: string(),
19121
- icon: string(),
19122
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
19123
- addonId: string(),
19124
- configSchema: ConfigSchemaPassthrough$1,
19125
- supportsDiscovery: boolean(),
19126
- caps: TargetKindCapsSchema
19127
- });
19128
- /**
19129
- * A persisted target. `config` holds secrets; providers REDACT secret fields
19130
- * (return a presence marker only) when serving `listTargets` — never
19131
- * round-trip a stored secret to the UI.
19132
- */
19133
- var TargetSchema = object({
19134
- id: string(),
19135
- name: string(),
19136
- kind: string(),
19137
- addonId: string(),
19138
- enabled: boolean(),
19139
- config: record(string(), unknown())
19140
- });
19141
- /** A discovery-surfaced candidate (config is partial + non-secret). */
19142
- var DiscoveredTargetSchema = object({
19143
- kind: string(),
19144
- suggestedName: string(),
19145
- config: record(string(), unknown())
19146
- });
19147
- /** The degrade engine's report — what was resolved / dropped / degraded. */
19148
- var RenderedAsSchema = object({
19149
- level: string(),
19150
- format: NotificationFormatSchema,
19151
- attachmentsSent: number().int().nonnegative(),
19152
- actionsSent: number().int().nonnegative(),
19153
- truncated: boolean(),
19154
- dropped: array(string())
19155
- });
19156
- var SendResultSchema = object({
19157
- success: boolean(),
19158
- error: string().optional(),
19159
- renderedAs: RenderedAsSchema.optional()
19160
- });
19161
- /** Same shape as SendResult — kept as a distinct name for the test panel. */
19162
- var TestResultSchema = SendResultSchema;
19163
- var notificationOutputCapability = {
19164
- name: "notification-output",
19165
- scope: "system",
19166
- mode: "collection",
19167
- methods: {
19168
- listTargetKinds: method(object({}), array(TargetKindSchema)),
19169
- listTargets: method(object({}), array(TargetSchema)),
19170
- discoverTargets: method(object({
19171
- kind: string(),
19172
- config: record(string(), unknown()).optional()
19173
- }), array(DiscoveredTargetSchema)),
19174
- send: method(object({
19175
- targetId: string(),
19176
- notification: NotificationSchema
19177
- }), SendResultSchema, { kind: "mutation" }),
19178
- testTarget: method(object({
19179
- targetId: string(),
19180
- sample: NotificationSchema.optional()
19181
- }), TestResultSchema, { kind: "mutation" }),
19182
- upsertTarget: method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }),
19183
- deleteTarget: method(object({ targetId: string() }), _void(), { kind: "mutation" }),
19184
- setTargetEnabled: method(object({
19185
- targetId: string(),
19186
- enabled: boolean()
19187
- }), _void(), { kind: "mutation" })
19188
- }
19189
- };
19190
- /**
19191
- * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
19192
- * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
19193
- * caps stay wire-compatible without a circular cap→cap import.
19194
- *
19195
- * Errors are a discriminated-union RESULT, never thrown: the shape survives
19196
- * every transport tier structurally, and failed calls still write usage rows.
19197
- * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
19198
- */
19199
- var LlmUsageSchema = object({
19200
- inputTokens: number(),
19201
- outputTokens: number()
19202
- });
19203
- var LlmErrorCodeSchema = _enum([
19204
- "timeout",
19205
- "rate-limited",
19206
- "auth",
19207
- "refusal",
19208
- "bad-request",
19209
- "unavailable",
19210
- "no-profile",
19211
- "budget-exceeded",
19212
- "adapter-error"
19213
- ]);
19214
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
19215
- ok: literal(true),
19216
- text: string(),
19217
- model: string(),
19218
- usage: LlmUsageSchema,
19219
- truncated: boolean(),
19220
- latencyMs: number()
19221
- }), object({
19222
- ok: literal(false),
19223
- code: LlmErrorCodeSchema,
19224
- message: string(),
19225
- retryAfterMs: number().optional()
19226
- })]);
19227
- /**
19228
- * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
19229
- * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
19230
- * notification-output.cap.ts:27-31 precedents).
19231
- */
19232
- var LlmImageSchema = object({
19233
- bytes: _instanceof(Uint8Array),
19234
- mimeType: string()
19235
- });
19236
- var LlmGenerateBaseInputSchema = object({
19237
- /** Collection routing (the notification-output posture). */
19238
- addonId: string().optional(),
19239
- /** Explicit profile; else the resolution chain (spec §3). */
19240
- profileId: string().optional(),
19241
- /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
19242
- consumer: string(),
19243
- system: string().optional(),
19244
- /** v1: single-turn. `messages[]` is a v2 additive field. */
19245
- prompt: string(),
19246
- /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
19247
- jsonSchema: record(string(), unknown()).optional(),
19248
- /** Per-call override of the profile default. */
19249
- maxTokens: number().int().positive().optional(),
19250
- temperature: number().optional()
19251
- });
19252
- /**
19253
- * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
19254
- * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
19255
- * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
19256
- * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
19257
- * this only through the `llm` cap's methods.
19258
- *
19259
- * One running llama-server child per node in v1 (models are RAM-heavy).
19260
- * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
19261
- * watchdog — operator decision #3).
19262
- */
19263
- var ManagedModelRefSchema = discriminatedUnion("kind", [
19264
- object({
19265
- kind: literal("catalog"),
19266
- catalogId: string()
19267
- }),
19268
- object({
19269
- kind: literal("url"),
19270
- url: string(),
19271
- sha256: string().optional()
19272
- }),
19273
- object({
19274
- kind: literal("path"),
19275
- path: string()
19276
- })
19277
- ]);
19278
- var ManagedRuntimeConfigSchema = object({
19279
- /** WHERE the runtime lives — hub or any agent. */
19280
- nodeId: string(),
19281
- /** Closed for v1; 'ollama' is a v2 candidate. */
19282
- engine: _enum(["llama-cpp"]),
19283
- model: ManagedModelRefSchema,
19284
- contextSize: number().int().default(4096),
19285
- /** 0 = CPU-only. */
19286
- gpuLayers: number().int().default(0),
19287
- /** Default: cpus-2, clamped ≥1 (resolved node-side). */
19288
- threads: number().int().optional(),
19289
- /** Concurrent slots. */
19290
- parallel: number().int().default(1),
19291
- /** Else lazy: first generate boots it. */
19292
- autoStart: boolean().default(false),
19293
- /** 0 = never; frees RAM after quiet periods. */
19294
- idleStopMinutes: number().int().default(30)
19295
- });
19296
- var LlmRuntimeStatusSchema = object({
19297
- /** Status is ALWAYS node-qualified. */
19298
- nodeId: string(),
19299
- state: _enum([
19300
- "stopped",
19301
- "downloading",
19302
- "starting",
19303
- "ready",
19304
- "crashed",
19305
- "failed"
19306
- ]),
19307
- pid: number().optional(),
19308
- port: number().optional(),
19309
- modelPath: string().optional(),
19310
- modelId: string().optional(),
19311
- downloadProgress: number().min(0).max(1).optional(),
19312
- lastError: string().optional(),
19313
- crashesInWindow: number(),
19314
- /** Child RSS (sampled best-effort). */
19315
- memoryBytes: number().optional(),
19316
- vramBytes: number().optional()
19317
- });
19318
- var LlmNodeModelSchema = object({
19319
- file: string(),
19320
- sizeBytes: number(),
19321
- catalogId: string().optional(),
19322
- installedAt: number().optional()
19393
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
19394
+ requires: array(string()).optional(),
19395
+ description: string().optional()
19323
19396
  });
19324
- var LlmRuntimeDiskUsageSchema = object({
19325
- nodeId: string(),
19326
- modelsBytes: number(),
19327
- freeBytes: number().optional()
19397
+ /** The full capability block consulted before dispatch. */
19398
+ var TargetKindCapsSchema = object({
19399
+ attachments: object({
19400
+ mediaTypes: array(AttachmentMediaTypeSchema),
19401
+ mode: _enum([
19402
+ "url",
19403
+ "bytes",
19404
+ "both"
19405
+ ]),
19406
+ max: number().int().nonnegative(),
19407
+ maxBytes: number().int().positive().optional()
19408
+ }),
19409
+ /** Max action buttons (0 = none). */
19410
+ actions: number().int().nonnegative(),
19411
+ levels: array(TargetKindLevelSchema),
19412
+ format: array(NotificationFormatSchema),
19413
+ clickUrl: boolean(),
19414
+ sound: boolean(),
19415
+ ttl: boolean(),
19416
+ bodyMaxLen: number().int().positive()
19328
19417
  });
19329
- method(LlmGenerateBaseInputSchema.extend({
19330
- images: array(LlmImageSchema).optional(),
19331
- runtime: ManagedRuntimeConfigSchema,
19332
- /** The managed profile's timeout, threaded by the hub provider. */
19333
- timeoutMs: number().int().positive().optional()
19334
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
19335
- kind: "mutation",
19336
- auth: "admin"
19337
- }), method(object({}), _void(), {
19338
- kind: "mutation",
19339
- auth: "admin"
19340
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
19341
- kind: "mutation",
19342
- auth: "admin"
19343
- }), method(object({ file: string() }), _void(), {
19344
- kind: "mutation",
19345
- auth: "admin"
19346
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
19347
19418
  /**
19348
- * `llm` consumer-facing LLM surface (spec §1-§3). Collection-mode: array
19349
- * methods concat-fan across providers; single-row methods route to ONE
19350
- * provider by the `addonId` in the call input (the notification-output
19351
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
19352
- * (hub-placed); the cap stays open for future providers.
19353
- *
19354
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
19355
- * `apiKey` is a password field — providers REDACT it on read and merge on
19356
- * write; a stored key NEVER round-trips to a client.
19419
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
19420
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
19421
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`)
19422
+ * the union is large and not meant for runtime validation here; the exported
19423
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
19357
19424
  */
19358
- var LlmProfileKindSchema = _enum([
19359
- "openai-compatible",
19360
- "openai",
19361
- "anthropic",
19362
- "google",
19363
- "managed-local"
19364
- ]);
19365
- var LlmProfileSchema = object({
19366
- id: string(),
19367
- name: string(),
19368
- kind: LlmProfileKindSchema,
19369
- /** Stamped by the provider — keeps the fanned catalog routable. */
19370
- addonId: string(),
19371
- enabled: boolean(),
19372
- /** Vendor model id, or the managed runtime's loaded model. */
19373
- model: string(),
19374
- /** Required for openai-compatible; override for cloud kinds. */
19375
- baseUrl: string().optional(),
19376
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
19377
- apiKey: string().optional(),
19378
- supportsVision: boolean(),
19379
- temperature: number().min(0).max(2).optional(),
19380
- maxTokens: number().int().positive().optional(),
19381
- timeoutMs: number().int().positive().default(6e4),
19382
- extraHeaders: record(string(), string()).optional(),
19383
- /** kind === 'managed-local' only (spec §4). */
19384
- runtime: ManagedRuntimeConfigSchema.optional()
19385
- });
19386
- /** ConfigUISchema tree passed through untyped on the wire (the
19387
- * notification-output `ConfigSchemaPassthrough` precedent at
19388
- * notification-output.cap.ts:151); the exported TS type re-tightens it. */
19389
19425
  var ConfigSchemaPassthrough = unknown();
19390
- var LlmProfileKindDescriptorSchema = object({
19391
- kind: LlmProfileKindSchema,
19426
+ var TargetKindSchema = object({
19427
+ kind: string(),
19392
19428
  label: string(),
19393
19429
  icon: string(),
19394
19430
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
19395
19431
  addonId: string(),
19396
- configSchema: ConfigSchemaPassthrough
19432
+ configSchema: ConfigSchemaPassthrough,
19433
+ supportsDiscovery: boolean(),
19434
+ caps: TargetKindCapsSchema
19397
19435
  });
19398
- var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
19399
- var LlmDefaultSchema = object({
19400
- selector: LlmDefaultSelectorSchema,
19401
- profileId: string()
19436
+ /**
19437
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
19438
+ * (return a presence marker only) when serving `listTargets` — never
19439
+ * round-trip a stored secret to the UI.
19440
+ */
19441
+ var TargetSchema = object({
19442
+ id: string(),
19443
+ name: string(),
19444
+ kind: string(),
19445
+ addonId: string(),
19446
+ enabled: boolean(),
19447
+ config: record(string(), unknown())
19402
19448
  });
19403
- /** Server-side rollup row getUsage never dumps raw call rows (spec §6). */
19404
- var LlmUsageRollupSchema = object({
19405
- day: string(),
19406
- consumer: string(),
19407
- profileId: string(),
19408
- calls: number(),
19409
- okCalls: number(),
19410
- errorCalls: number(),
19411
- inputTokens: number(),
19412
- outputTokens: number(),
19413
- avgLatencyMs: number()
19449
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
19450
+ var DiscoveredTargetSchema = object({
19451
+ kind: string(),
19452
+ suggestedName: string(),
19453
+ config: record(string(), unknown())
19414
19454
  });
19415
- /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
19416
- var ManagedModelCatalogEntrySchema = object({
19455
+ /** The degrade engine's report what was resolved / dropped / degraded. */
19456
+ var RenderedAsSchema = object({
19457
+ level: string(),
19458
+ format: NotificationFormatSchema,
19459
+ attachmentsSent: number().int().nonnegative(),
19460
+ actionsSent: number().int().nonnegative(),
19461
+ truncated: boolean(),
19462
+ dropped: array(string())
19463
+ });
19464
+ var SendResultSchema = object({
19465
+ success: boolean(),
19466
+ error: string().optional(),
19467
+ renderedAs: RenderedAsSchema.optional()
19468
+ });
19469
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
19470
+ var TestResultSchema = SendResultSchema;
19471
+ var notificationOutputCapability = {
19472
+ name: "notification-output",
19473
+ scope: "system",
19474
+ mode: "collection",
19475
+ methods: {
19476
+ listTargetKinds: method(object({}), array(TargetKindSchema)),
19477
+ listTargets: method(object({}), array(TargetSchema)),
19478
+ discoverTargets: method(object({
19479
+ kind: string(),
19480
+ config: record(string(), unknown()).optional()
19481
+ }), array(DiscoveredTargetSchema)),
19482
+ send: method(object({
19483
+ targetId: string(),
19484
+ notification: NotificationSchema
19485
+ }), SendResultSchema, { kind: "mutation" }),
19486
+ testTarget: method(object({
19487
+ targetId: string(),
19488
+ sample: NotificationSchema.optional()
19489
+ }), TestResultSchema, { kind: "mutation" }),
19490
+ upsertTarget: method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }),
19491
+ deleteTarget: method(object({ targetId: string() }), _void(), { kind: "mutation" }),
19492
+ setTargetEnabled: method(object({
19493
+ targetId: string(),
19494
+ enabled: boolean()
19495
+ }), _void(), { kind: "mutation" })
19496
+ }
19497
+ };
19498
+ /**
19499
+ * notification-rules — the Notification Center rule surface (P1 core).
19500
+ *
19501
+ * Spec: `docs/superpowers/specs/2026-07-22-notification-center-requirements.md`
19502
+ * (operator decisions D-1/D-2/D-3 are binding):
19503
+ *
19504
+ * - D-2: rule EVALUATION lives in `addon-post-analysis` (the
19505
+ * `notification-center` module), hooked on the durable persistence
19506
+ * moments (object-event insert, TrackCloser.closeExpired) with a
19507
+ * persisted outbox + retry — never the lossy telemetry bus (D8).
19508
+ * - D-3: urgency belongs to the RULE. `delivery: 'immediate'` fires on the
19509
+ * FIRST persisted detection matching the conditions (per-track dedup,
19510
+ * `maxPerTrack` fixed at 1 — see {@link NC_MAX_PER_TRACK_IMMEDIATE});
19511
+ * `delivery: 'track-end'` evaluates the finalized track record at close.
19512
+ * - DISPATCH stays behind `notification-output` (rules reference targets
19513
+ * by id; per-backend params are a passthrough blob capped by the
19514
+ * target kind's own caps/degrade engine).
19515
+ *
19516
+ * P1 scope: admin-authored rules only (`createdBy` stamped from the
19517
+ * server-injected caller identity — the first `caller: 'required'`
19518
+ * adopter). The P1 condition subset is: devices, classes(+exclude),
19519
+ * minConfidence, admin zones (any/all + exclude), weekly schedule
19520
+ * windows, and the optional label/identity/plate matchers. User rules,
19521
+ * private zones, per-recipient fan-out and the wider condition table are
19522
+ * P2+ (see spec §7).
19523
+ *
19524
+ * All schemas here are the single source of truth — `NcRule` etc. are
19525
+ * `z.infer` exports; no duplicate interfaces (the advanced-notifier
19526
+ * schema/interface drift is explicitly not repeated).
19527
+ */
19528
+ /**
19529
+ * D-3: the trigger/urgency of a rule — which persistence moment evaluates it.
19530
+ * The value maps 1:1 onto the evaluated record kind:
19531
+ * - `immediate` ↔ object-event persist (lowest-latency detection burst)
19532
+ * - `track-end` ↔ TrackCloser.closeExpired (finalized track record)
19533
+ * - `device-event` ↔ SensorEventStore insert (doorbell press / sensor state
19534
+ * change of a LINKED device, one row per linked camera)
19535
+ * - `package-event` ↔ PackageDropDetector object-event insert (a `package`
19536
+ * delivery / pick-up)
19537
+ *
19538
+ * `immediate`/`track-end` carry the D-3 urgency semantics; `device-event`/
19539
+ * `package-event` are pure trigger kinds (no urgency dimension). Extending
19540
+ * this one field keeps the schema additive — a rule still declares exactly
19541
+ * one trigger.
19542
+ */
19543
+ var NcDeliverySchema = _enum([
19544
+ "immediate",
19545
+ "track-end",
19546
+ "device-event",
19547
+ "package-event"
19548
+ ]);
19549
+ /** Weekly schedule — OR of windows; absence on the rule = always active. */
19550
+ var NcScheduleSchema = object({
19551
+ windows: array(object({
19552
+ /** Days of week the window STARTS on (0 = Sunday … 6 = Saturday). */
19553
+ days: array(number().int().min(0).max(6)).min(1),
19554
+ startMinute: number().int().min(0).max(1439),
19555
+ endMinute: number().int().min(0).max(1439)
19556
+ })).min(1),
19557
+ /** IANA timezone; default = hub host timezone. */
19558
+ timezone: string().optional(),
19559
+ /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
19560
+ invert: boolean().optional()
19561
+ });
19562
+ /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
19563
+ var NcPlateMatcherSchema = object({
19564
+ values: array(string().min(1)).min(1),
19565
+ /** Max Levenshtein distance after normalization (uppercase alphanumeric). */
19566
+ maxDistance: number().int().min(0).max(3).default(1)
19567
+ });
19568
+ /**
19569
+ * Occupancy condition (DEVICE-EVENT trigger). Fires on a ZoneAnalytics
19570
+ * occupancy edge for a device — optionally narrowed to a single admin
19571
+ * `zoneId` and/or object `className`. `op` selects the edge/threshold:
19572
+ * - `became-occupied` (default) — count crossed 0 → ≥ `count`
19573
+ * - `became-free` — count crossed ≥ `count` → below it
19574
+ * - `>=` / `<=` — count is at/over or at/under `count`
19575
+ * `sustainSeconds` requires the condition hold continuously that long
19576
+ * before firing (debounces flicker; 0 = fire on the first matching edge).
19577
+ * Fail-closed: no ZoneAnalytics snapshot / missing zone / null snapshot ⇒
19578
+ * the condition never matches. Confirmed edge-state survives addon restarts
19579
+ * (declared SQLite collection, reseeded on boot).
19580
+ */
19581
+ var NcOccupancyConditionSchema = object({
19582
+ /** Admin zone id to scope the count to; absent = whole-frame occupancy. */
19583
+ zoneId: string().optional(),
19584
+ /** Object class to count; absent = any class. */
19585
+ className: string().optional(),
19586
+ op: _enum([
19587
+ "became-occupied",
19588
+ "became-free",
19589
+ ">=",
19590
+ "<="
19591
+ ]).default("became-occupied"),
19592
+ count: number().int().min(0).default(1),
19593
+ sustainSeconds: number().int().min(0).max(3600).default(15)
19594
+ });
19595
+ /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
19596
+ var NcZoneConditionSchema = object({
19597
+ ids: array(string().min(1)).min(1),
19598
+ /** Quantifier over `ids` — at least one / every one visited. */
19599
+ match: _enum(["any", "all"]).default("any")
19600
+ });
19601
+ /**
19602
+ * The P1 condition set — a flat AND of groups; absent group = pass;
19603
+ * membership lists are OR within the list (spec §2.3).
19604
+ */
19605
+ var NcConditionsSchema = object({
19606
+ /** Device scope — absent = all devices. */
19607
+ devices: array(number()).optional(),
19608
+ /** Detector class names (any overlap with the record's class set). */
19609
+ classes: array(string().min(1)).optional(),
19610
+ /** Veto classes — any overlap fails the rule. */
19611
+ classesExclude: array(string().min(1)).optional(),
19612
+ /** Minimum detection confidence 0–1 (fails when the record has none). */
19613
+ minConfidence: number().min(0).max(1).optional(),
19614
+ /** Admin zone membership over event `zones` / track `zonesVisited`. */
19615
+ zones: NcZoneConditionSchema.optional(),
19616
+ /** Veto zones — any hit fails the rule. */
19617
+ zonesExclude: array(string().min(1)).optional(),
19618
+ /**
19619
+ * Exact (case-insensitive) match on the record's collapsed `label`
19620
+ * (identity name / plate text / subclass).
19621
+ */
19622
+ labelEquals: array(string().min(1)).optional(),
19623
+ /**
19624
+ * Identity matcher. P1 boundary: matched against the record's collapsed
19625
+ * `label` (the identity display name propagated by the face pipeline) —
19626
+ * identity-ID matching rides in P2 when identity ids reach the record.
19627
+ */
19628
+ identities: array(string().min(1)).optional(),
19629
+ /** Fuzzy plate matcher against the record's `label` (plate text). */
19630
+ plates: NcPlateMatcherSchema.optional(),
19631
+ /**
19632
+ * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
19633
+ * Same P1 boundary: matched against the record's collapsed `label` (the
19634
+ * identity display name). A record with NO label passes (nothing to
19635
+ * exclude), unlike the include variant which fails on an absent label.
19636
+ */
19637
+ identitiesExclude: array(string().min(1)).optional(),
19638
+ /**
19639
+ * Minimum server-computed key-event importance in [0,1] (`Track.importance`).
19640
+ * TRACK-END only: importance is scored at track close, so it does not exist
19641
+ * at immediate / object-event evaluation time (see catalog `appliesTo`). At
19642
+ * close the value is threaded via the close-time info (the `Track` clone is
19643
+ * captured before the DB row is updated, so it would otherwise read stale).
19644
+ * Fails when the record carries no importance (never guess quality — the
19645
+ * `minConfidence` precedent). MVP cut: a single scalar threshold.
19646
+ */
19647
+ minImportance: number().min(0).max(1).optional(),
19648
+ /**
19649
+ * Minimum track dwell in SECONDS — `(lastSeen − firstSeen) / 1000`.
19650
+ * TRACK-END only: an `immediate` / object-event subject has no closed
19651
+ * lifespan, so a dwell condition never matches immediate delivery
19652
+ * (documented choice — the object-event record carries no `firstSeen`,
19653
+ * so dwell cannot be computed from what the subject actually carries).
19654
+ */
19655
+ minDwellSeconds: number().min(0).optional(),
19656
+ /**
19657
+ * Detection provenance filter. `any` (default / absent) matches every
19658
+ * source; otherwise the subject's source must equal it. Legacy records
19659
+ * with no stamped source are treated as `pipeline`. The union spans both
19660
+ * record kinds — object events carry `pipeline` | `onboard`, synthetic
19661
+ * tracks carry `sensor`.
19662
+ */
19663
+ source: _enum([
19664
+ "pipeline",
19665
+ "onboard",
19666
+ "sensor",
19667
+ "any"
19668
+ ]).optional(),
19669
+ /**
19670
+ * Minimum identity / plate MATCH confidence in [0,1] — DISTINCT from the
19671
+ * detector `minConfidence` (that gates the object-detection score; this
19672
+ * gates the recognition/OCR match score). Fails when the subject carries
19673
+ * no label-match confidence (never guess). TRACK-END only: the confidence
19674
+ * lives on the recognition result and reaches the subject at track close.
19675
+ *
19676
+ * What it measures precisely (plumbed at track close — the closer threads
19677
+ * the value into `NcTrackClosedInfo.labelConfidence`, the same seam as
19678
+ * `importance`): the BEST recognition match confidence observed for the
19679
+ * label the track carries at close — for a face, the peak cosine similarity
19680
+ * of the ASSIGNED identity (`FaceMatch.score`, reset on an identity switch);
19681
+ * for a plate, the peak OCR read score of the best-held plate
19682
+ * (`plateText.confidence`). When BOTH a face and a plate were recognized on
19683
+ * one track the higher of the two is used. A track that ended with no
19684
+ * confident identity/plate match carries no value, so the condition fails
19685
+ * closed for it (an un-recognized subject).
19686
+ */
19687
+ minLabelConfidence: number().min(0).max(1).optional(),
19688
+ /**
19689
+ * DEVICE-EVENT only. Raw device event-type tokens (`EventFire.eventType`,
19690
+ * e.g. a doorbell `press` / `press_long`) — matched case-insensitively
19691
+ * against the token carried on the device-event subject (extracted from the
19692
+ * event-emitter runtime slice's `lastEvent.eventType`). Fails when the
19693
+ * subject carries no token. Doorbell-pulse / passive-sensor kinds emit no
19694
+ * eventType, so gate those with {@link sensorKinds} instead.
19695
+ */
19696
+ eventTypeTokens: array(string().min(1)).optional(),
19697
+ /**
19698
+ * DEVICE-EVENT only. Sensor/control taxonomy kinds (e.g. `doorbell`,
19699
+ * `contact`, `button`, `device-event`) — matched against the persisted
19700
+ * `SensorEvent.kind` (see `sensor-event-kinds.ts`). Membership is OR.
19701
+ */
19702
+ sensorKinds: array(string().min(1)).optional(),
19703
+ /**
19704
+ * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
19705
+ * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
19706
+ * when the subject's phase does not match (a subject always carries a phase
19707
+ * on the package-event trigger).
19708
+ */
19709
+ packagePhase: _enum([
19710
+ "delivered",
19711
+ "picked-up",
19712
+ "both"
19713
+ ]).optional(),
19714
+ /**
19715
+ * PERSONAL-RULE custom zones (viewer-drawn). Inline normalized polygons
19716
+ * (MaskShape vocabulary). A record passes when its bbox overlaps ANY
19717
+ * listed polygon (ZoneEngine membership semantics). Evaluated only when
19718
+ * the subject carries a bbox; absent bbox ⇒ the condition FAILS.
19719
+ */
19720
+ customZones: array(MaskPolygonShapeSchema).optional(),
19721
+ /**
19722
+ * DEVICE-EVENT only. ZoneAnalytics occupancy edge — fires when a device's
19723
+ * (optionally zone/class-scoped) occupancy count crosses the configured
19724
+ * threshold and holds for `sustainSeconds`. Fail-closed on missing
19725
+ * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
19726
+ */
19727
+ occupancy: NcOccupancyConditionSchema.optional()
19728
+ });
19729
+ /** One delivery target: a `notification-output` Target ref + passthrough params. */
19730
+ var NcRuleTargetSchema = object({
19731
+ /** `notification-output` Target id. */
19732
+ targetId: string().min(1),
19733
+ /**
19734
+ * Per-backend passthrough. Recognized keys are mapped onto the canonical
19735
+ * Notification (`priority`, `level`, `sound`, `clickUrl`, `ttl`); the
19736
+ * degrade engine drops what the backend can't render.
19737
+ */
19738
+ params: record(string(), unknown()).optional()
19739
+ });
19740
+ /**
19741
+ * Media attachment policy (P1 still-image subset).
19742
+ * - `best` — the best AVAILABLE subject image at dispatch time (D-3).
19743
+ * - `best-matching` — the media that explains WHY the rule fired: a rule
19744
+ * matched on identities attaches the subject's `faceCrop`, one matched on
19745
+ * plates attaches the `plateCrop`; a rule with no identity/plate condition
19746
+ * (or when the specific crop is missing) degrades to `best`, then
19747
+ * `keyFrame`, then no attachment — never delaying the send. The matched
19748
+ * condition summary is frozen on the outbox row at enqueue (like the rule
19749
+ * name), so the choice never drifts from the record that fired it.
19750
+ * - `keyFrame` — the clean scene frame (no subject box).
19751
+ * - `none` — no attachment.
19752
+ */
19753
+ var NcMediaPolicySchema = object({ attach: _enum([
19754
+ "best",
19755
+ "best-matching",
19756
+ "keyFrame",
19757
+ "none"
19758
+ ]).default("best") });
19759
+ /** Throttle — cooldown survives restarts (rebuilt from the outbox on boot). */
19760
+ var NcThrottleSchema = object({
19761
+ cooldownSec: number().int().min(0).max(86400).default(60),
19762
+ /** `rule` = one shared cooldown; `rule-device` = per-camera cooldown. */
19763
+ scope: _enum(["rule", "rule-device"]).default("rule-device")
19764
+ });
19765
+ /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
19766
+ var NcRuleInputSchema = object({
19767
+ name: string().min(1).max(200),
19768
+ enabled: boolean().default(true),
19769
+ delivery: NcDeliverySchema,
19770
+ conditions: NcConditionsSchema.default({}),
19771
+ schedule: NcScheduleSchema.optional(),
19772
+ targets: array(NcRuleTargetSchema).min(1),
19773
+ media: NcMediaPolicySchema.default({ attach: "best" }),
19774
+ throttle: NcThrottleSchema.default({
19775
+ cooldownSec: 60,
19776
+ scope: "rule-device"
19777
+ }),
19778
+ /** `{{var}}` templating over camera/class/label/zones/confidence/time. */
19779
+ template: object({
19780
+ title: string().max(500).optional(),
19781
+ body: string().max(2e3).optional()
19782
+ }).optional(),
19783
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
19784
+ priority: number().int().min(1).max(5).default(3),
19785
+ /**
19786
+ * Ownership/visibility key. Absent = admin/global rule (unchanged legacy
19787
+ * behaviour, visible to all, read-only in the viewer). Present = personal
19788
+ * rule owned by this userId. Server-stamped; never trusted from a client.
19789
+ */
19790
+ ownerUserId: string().optional()
19791
+ });
19792
+ /**
19793
+ * Partial patch for `updateRule` — any subset of the input fields, plus the
19794
+ * persisted-only {@link NcRuleSchema} `disabledTargetIds` set. The latter is
19795
+ * NOT a client-authored input field (it lives on the persisted rule, not the
19796
+ * input), so it is added here explicitly to let the store's per-target opt-out
19797
+ * toggle round-trip through the shared `update` path. Viewer opt-out mutations
19798
+ * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
19799
+ * `updateRule` patch.
19800
+ */
19801
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
19802
+ /** A persisted rule. */
19803
+ var NcRuleSchema = NcRuleInputSchema.extend({
19804
+ id: string(),
19805
+ /** userId of the admin who created the rule (server-stamped caller). */
19806
+ createdBy: string(),
19807
+ createdAt: number(),
19808
+ updatedAt: number(),
19809
+ /**
19810
+ * Per-target opt-out set. A targetId here is suppressed for THIS rule at
19811
+ * send time. Only a target's OWNER may add/remove its id (server-checked
19812
+ * in `nc.setRuleTargetEnabled`). Defaults to empty.
19813
+ */
19814
+ disabledTargetIds: array(string()).default([])
19815
+ });
19816
+ var NcTestResultSchema = object({
19817
+ recordId: string(),
19818
+ recordKind: _enum([
19819
+ "object-event",
19820
+ "track",
19821
+ "device-event",
19822
+ "package-event"
19823
+ ]),
19824
+ deviceId: number(),
19825
+ timestamp: number(),
19826
+ wouldFire: boolean(),
19827
+ /** Condition id that failed (first failing group), when `wouldFire` is false. */
19828
+ failedCondition: string().optional(),
19829
+ className: string().optional(),
19830
+ label: string().optional()
19831
+ });
19832
+ var NcConditionDescriptorSchema = object({
19833
+ /** Field id inside `NcConditions` (or `'schedule'` for the rule-level group). */
19417
19834
  id: string(),
19835
+ group: _enum([
19836
+ "scope",
19837
+ "class",
19838
+ "zones",
19839
+ "quality",
19840
+ "label",
19841
+ "schedule",
19842
+ "device",
19843
+ "package",
19844
+ "occupancy"
19845
+ ]),
19418
19846
  label: string(),
19419
- family: string(),
19420
- purpose: _enum(["text", "vision"]),
19421
- url: string(),
19422
- sha256: string(),
19423
- sizeBytes: number(),
19424
- quantization: string(),
19425
- /** Load-time guidance shown in the picker. */
19426
- minRamBytes: number(),
19427
- contextSizeDefault: number().int(),
19428
- /** Vision models: companion projector file. */
19429
- mmprojUrl: string().optional()
19847
+ /** Editor widget the UI renders — never hardcode per-condition forms. */
19848
+ valueType: _enum([
19849
+ "deviceIdList",
19850
+ "stringList",
19851
+ "number01",
19852
+ "number",
19853
+ "sourceSelect",
19854
+ "zoneSelection",
19855
+ "zoneIdList",
19856
+ "schedule",
19857
+ "plateMatcher",
19858
+ "packagePhase",
19859
+ "polygonDraw",
19860
+ "occupancy"
19861
+ ]),
19862
+ operator: _enum([
19863
+ "in",
19864
+ "notIn",
19865
+ "anyOf",
19866
+ "allOf",
19867
+ "gte",
19868
+ "fuzzyIn",
19869
+ "withinSchedule"
19870
+ ]),
19871
+ /** Which delivery kinds the condition applies to. */
19872
+ appliesTo: array(NcDeliverySchema),
19873
+ phase: string(),
19874
+ description: string().optional()
19430
19875
  });
19431
- var LlmRuntimeNodeSchema = object({
19432
- nodeId: string(),
19433
- reachable: boolean(),
19434
- status: LlmRuntimeStatusSchema.optional(),
19435
- disk: LlmRuntimeDiskUsageSchema.optional(),
19436
- error: string().optional()
19876
+ /**
19877
+ * The delivery lifecycle status of a history row — a straight read of the
19878
+ * durable outbox row's own status (single source of truth):
19879
+ * - `pending` — enqueued, in-flight or retrying with backoff
19880
+ * - `sent` — delivered (terminal)
19881
+ * - `dead` — dead-lettered after exhausting retries / a permanent
19882
+ * backend rejection / a deleted target (terminal; carries
19883
+ * the failure `error`)
19884
+ *
19885
+ * P1 has no `suppressed-quiet-hours` / `snoozed` states — those ride the P2
19886
+ * user dimension (quiet hours / snooze) and are additive when they land.
19887
+ */
19888
+ var NcHistoryStatusSchema = _enum([
19889
+ "pending",
19890
+ "sent",
19891
+ "dead"
19892
+ ]);
19893
+ /** The evaluated record kind a history row descends from (one per trigger). */
19894
+ var NcHistoryRecordKindSchema = _enum([
19895
+ "object-event",
19896
+ "track-end",
19897
+ "device-event",
19898
+ "package-event"
19899
+ ]);
19900
+ /** Subject summary frozen on the row at fire time (survives rule/record edits). */
19901
+ var NcHistorySubjectSchema = object({
19902
+ className: string(),
19903
+ label: string().optional(),
19904
+ confidence: number().optional(),
19905
+ zones: array(string()),
19906
+ timestamp: number()
19437
19907
  });
19438
- var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
19439
- var ProfileRefInputSchema = object({
19440
- addonId: string(),
19441
- profileId: string()
19908
+ /**
19909
+ * One delivery-history row. This is a read-only VIEW over the durable
19910
+ * outbox row (single source of truth — the same row the drain loop drives;
19911
+ * NO second write path, so history can never drift from delivery state).
19912
+ * The §3.2 fields map directly: `ruleId`/`targetId`/`deviceId` are columns,
19913
+ * `eventRef` is `recordKind`+`recordId`, `timestamps` are `createdAt`
19914
+ * (fire) / `updatedAt` (last transition), `status` + `error` are the
19915
+ * lifecycle. `ruleName` + `subject` are the intent snapshot frozen at
19916
+ * enqueue. `userId?` (per-recipient history) is P2 — no user dimension in
19917
+ * P1 (admin scope only).
19918
+ */
19919
+ var NcHistoryEntrySchema = object({
19920
+ /** Outbox row id — the stable dedup id `ruleId:dedupRef:targetId`. */
19921
+ id: string(),
19922
+ ruleId: string(),
19923
+ /** Rule name frozen at fire time (outlives a later rename / delete). */
19924
+ ruleName: string(),
19925
+ /** The rule urgency/trigger that produced this delivery. */
19926
+ delivery: NcDeliverySchema,
19927
+ targetId: string(),
19928
+ deviceId: number(),
19929
+ recordKind: NcHistoryRecordKindSchema,
19930
+ /** Event / track ref of the evaluated record (§3.2 `eventRef`). */
19931
+ recordId: string(),
19932
+ /** Present for track-scoped deliveries (object-event / track-end). */
19933
+ trackId: string().optional(),
19934
+ status: NcHistoryStatusSchema,
19935
+ /** Delivery attempts made so far. */
19936
+ attempts: number().int(),
19937
+ /** Fire time (outbox enqueue). */
19938
+ createdAt: number(),
19939
+ /** Last transition time (terminal for sent / dead). */
19940
+ updatedAt: number(),
19941
+ /** Failure detail — present on a `dead` row. */
19942
+ error: string().optional(),
19943
+ subject: NcHistorySubjectSchema
19442
19944
  });
19443
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
19444
- kind: "mutation",
19445
- auth: "admin"
19446
- }), method(ProfileRefInputSchema, _void(), {
19447
- kind: "mutation",
19448
- auth: "admin"
19449
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
19450
- kind: "mutation",
19451
- auth: "admin"
19452
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
19453
- selector: LlmDefaultSelectorSchema,
19454
- profileId: string().nullable()
19455
- }), _void(), {
19456
- kind: "mutation",
19457
- auth: "admin"
19458
- }), method(object({
19945
+ /**
19946
+ * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
19947
+ * AND; absent = unbounded on that axis. `since`/`until` bound the fire time
19948
+ * (`createdAt`, epoch ms, inclusive). `limit` is clamped to
19949
+ * {@link NC_HISTORY_LIMIT_MAX}. `userId` (per-recipient filtering) is P2.
19950
+ */
19951
+ var NcHistoryFilterSchema = object({
19952
+ ruleId: string().optional(),
19953
+ deviceId: number().optional(),
19954
+ status: NcHistoryStatusSchema.optional(),
19459
19955
  since: number().optional(),
19460
19956
  until: number().optional(),
19461
- consumer: string().optional(),
19462
- profileId: string().optional()
19463
- }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
19464
- nodeId: string(),
19465
- model: ManagedModelRefSchema
19466
- }), _void(), {
19957
+ limit: number().int().min(1).max(500).default(100)
19958
+ });
19959
+ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), method(object({ ruleId: string() }), object({ rule: NcRuleSchema.nullable() }), { auth: "admin" }), method(object({ rule: NcRuleInputSchema }), object({ rule: NcRuleSchema }), {
19467
19960
  kind: "mutation",
19468
- auth: "admin"
19961
+ auth: "admin",
19962
+ caller: "required"
19469
19963
  }), method(object({
19470
- nodeId: string(),
19471
- file: string()
19472
- }), _void(), {
19964
+ ruleId: string(),
19965
+ patch: NcRulePatchSchema
19966
+ }), object({ rule: NcRuleSchema }), {
19967
+ kind: "mutation",
19968
+ auth: "admin",
19969
+ caller: "required"
19970
+ }), method(object({ ruleId: string() }), object({ success: literal(true) }), {
19473
19971
  kind: "mutation",
19474
19972
  auth: "admin"
19475
- }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
19973
+ }), method(object({
19974
+ ruleId: string(),
19975
+ enabled: boolean()
19976
+ }), object({ success: literal(true) }), {
19476
19977
  kind: "mutation",
19477
19978
  auth: "admin"
19478
- }), method(ProfileRefInputSchema, _void(), {
19979
+ }), method(object({
19980
+ rule: NcRuleInputSchema,
19981
+ lookbackMinutes: number().int().min(1).max(1440).default(60)
19982
+ }), object({ results: array(NcTestResultSchema) }), {
19479
19983
  kind: "mutation",
19480
19984
  auth: "admin"
19481
- });
19985
+ }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
19482
19986
  /**
19483
19987
  * Zod schemas for persisted record types.
19484
19988
  *
@@ -20164,7 +20668,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
20164
20668
  }), method(object({
20165
20669
  eventId: string(),
20166
20670
  kind: MediaFileKindEnum.optional()
20167
- }), array(MediaFileSchema).readonly()), method(object({ trackId: string() }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
20671
+ }), array(MediaFileSchema).readonly()), method(object({
20672
+ trackId: string(),
20673
+ kinds: array(MediaFileKindEnum).optional()
20674
+ }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
20168
20675
  deviceId: number(),
20169
20676
  timestamp: number(),
20170
20677
  frameWidth: number(),
@@ -20185,76 +20692,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
20185
20692
  eventId: string(),
20186
20693
  timestamp: number()
20187
20694
  });
20188
- /**
20189
- * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
20190
- * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
20191
- * caps into per-camera event-kind descriptors.
20192
- *
20193
- * The descriptor DATA (color / iconId / labelKey / parentKind / category)
20194
- * is NOT duplicated here — every entry is derived from the single
20195
- * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
20196
- * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
20197
- * control cap means adding one line here (and a taxonomy entry); the anti-
20198
- * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
20199
- * eventful cap is missing.
20200
- */
20201
- /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
20202
- var LEGACY_ICON = {
20203
- motion: "motion",
20204
- audio: "audio",
20205
- person: "person",
20206
- vehicle: "vehicle",
20207
- animal: "animal",
20208
- package: "package",
20209
- door: "door",
20210
- pir: "pir",
20211
- smoke: "smoke",
20212
- water: "water",
20213
- button: "button",
20214
- generic: "generic",
20215
- gas: "smoke",
20216
- vibration: "generic",
20217
- tamper: "generic",
20218
- presence: "person",
20219
- lock: "generic",
20220
- siren: "generic",
20221
- switch: "generic",
20222
- doorbell: "button"
20223
- };
20224
- function legacyIcon(iconId) {
20225
- return LEGACY_ICON[iconId] ?? "generic";
20226
- }
20227
- /**
20228
- * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
20229
- * The anti-drift guard cross-checks this against the eventful caps declared
20230
- * in `packages/types/src/capabilities/*.cap.ts`.
20231
- */
20232
- var CAP_TO_KIND = {
20233
- contact: "contact",
20234
- motion: "motion-sensor",
20235
- smoke: "smoke",
20236
- flood: "flood",
20237
- gas: "gas",
20238
- "carbon-monoxide": "carbon-monoxide",
20239
- vibration: "vibration",
20240
- tamper: "tamper",
20241
- presence: "presence",
20242
- "enum-sensor": "enum-sensor",
20243
- "event-emitter": "device-event",
20244
- "lock-control": "lock",
20245
- switch: "switch",
20246
- button: "button",
20247
- doorbell: "doorbell"
20248
- };
20249
- function buildDescriptor(capName, kind) {
20250
- const t = EVENT_TAXONOMY[kind];
20251
- if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
20252
- return {
20253
- ...t,
20254
- icon: legacyIcon(t.iconId)
20255
- };
20256
- }
20257
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
20258
20695
  var CameraPipelineConfigSchema = object({
20259
20696
  engine: PipelineEngineChoiceSchema.optional(),
20260
20697
  steps: array(PipelineStepInputSchema).readonly(),
@@ -20740,6 +21177,76 @@ method(object({
20740
21177
  auth: "admin"
20741
21178
  });
20742
21179
  /**
21180
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
21181
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
21182
+ * caps into per-camera event-kind descriptors.
21183
+ *
21184
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
21185
+ * is NOT duplicated here — every entry is derived from the single
21186
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
21187
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
21188
+ * control cap means adding one line here (and a taxonomy entry); the anti-
21189
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
21190
+ * eventful cap is missing.
21191
+ */
21192
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
21193
+ var LEGACY_ICON = {
21194
+ motion: "motion",
21195
+ audio: "audio",
21196
+ person: "person",
21197
+ vehicle: "vehicle",
21198
+ animal: "animal",
21199
+ package: "package",
21200
+ door: "door",
21201
+ pir: "pir",
21202
+ smoke: "smoke",
21203
+ water: "water",
21204
+ button: "button",
21205
+ generic: "generic",
21206
+ gas: "smoke",
21207
+ vibration: "generic",
21208
+ tamper: "generic",
21209
+ presence: "person",
21210
+ lock: "generic",
21211
+ siren: "generic",
21212
+ switch: "generic",
21213
+ doorbell: "button"
21214
+ };
21215
+ function legacyIcon(iconId) {
21216
+ return LEGACY_ICON[iconId] ?? "generic";
21217
+ }
21218
+ /**
21219
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
21220
+ * The anti-drift guard cross-checks this against the eventful caps declared
21221
+ * in `packages/types/src/capabilities/*.cap.ts`.
21222
+ */
21223
+ var CAP_TO_KIND = {
21224
+ contact: "contact",
21225
+ motion: "motion-sensor",
21226
+ smoke: "smoke",
21227
+ flood: "flood",
21228
+ gas: "gas",
21229
+ "carbon-monoxide": "carbon-monoxide",
21230
+ vibration: "vibration",
21231
+ tamper: "tamper",
21232
+ presence: "presence",
21233
+ "enum-sensor": "enum-sensor",
21234
+ "event-emitter": "device-event",
21235
+ "lock-control": "lock",
21236
+ switch: "switch",
21237
+ button: "button",
21238
+ doorbell: "doorbell"
21239
+ };
21240
+ function buildDescriptor(capName, kind) {
21241
+ const t = EVENT_TAXONOMY[kind];
21242
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
21243
+ return {
21244
+ ...t,
21245
+ icon: legacyIcon(t.iconId)
21246
+ };
21247
+ }
21248
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
21249
+ /**
20743
21250
  * server-management — per-NODE singleton capability for a node's ROOT
20744
21251
  * package lifecycle (runtime-updatable node packages).
20745
21252
  *
@@ -22283,7 +22790,28 @@ var FaceInfoSchema = object({
22283
22790
  * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`). Absent when the
22284
22791
  * track produced no key frame (e.g. native/onboard source) — the UI falls
22285
22792
  * back to the inline `base64` face crop. */
22286
- keyFrameMediaKey: string().optional()
22793
+ keyFrameMediaKey: string().optional(),
22794
+ /** Winning identity-match cosine (0..1) for this face's track, when an
22795
+ * identity was auto-confirmed. Lets the UI surface WHY a face was assigned
22796
+ * (confidence badge / low-confidence audit). Absent on legacy rows and on
22797
+ * faces that were never auto-recognized. */
22798
+ bestMatchScore: number().optional(),
22799
+ /** Native-scale face short side (px) at recognition time, when the runner
22800
+ * measured it. Lets the UI flag low-resolution auto-assignments. Absent on
22801
+ * legacy rows / runners that reported no native measure. */
22802
+ nativeFaceShortSidePx: number().optional(),
22803
+ /** SUGGESTED identity for this face — a plausible-but-not-confident match that
22804
+ * MISSED auto-assignment (cosine in the suggestion band, or above threshold
22805
+ * but blocked only by the recognition size floor). Mutually exclusive with
22806
+ * `recognizedIdentityId` (a suggestion is NEVER an assignment): the face stays
22807
+ * UNASSIGNED and everything else keeps treating it as unrecognized — the UI
22808
+ * merely offers a one-tap "is this <name>?" confirm. Absent on legacy rows and
22809
+ * on faces that were auto-assigned or below the suggestion band. (2026-07-24) */
22810
+ suggestedIdentityId: string().optional(),
22811
+ /** Peak identity-match cosine (0..1) for `suggestedIdentityId`, captured at the
22812
+ * same moment as `bestMatchScore` (track peak, at close). Lets the UI rank /
22813
+ * badge suggestion confidence. Present iff `suggestedIdentityId` is. (2026-07-24) */
22814
+ suggestedMatchScore: number().optional()
22287
22815
  });
22288
22816
  var FaceFilterEnum = _enum([
22289
22817
  "unassigned",
@@ -24326,36 +24854,6 @@ Object.freeze({
24326
24854
  addonId: null,
24327
24855
  access: "view"
24328
24856
  },
24329
- "advancedNotifier.deleteRule": {
24330
- capName: "advanced-notifier",
24331
- capScope: "system",
24332
- addonId: null,
24333
- access: "delete"
24334
- },
24335
- "advancedNotifier.getHistory": {
24336
- capName: "advanced-notifier",
24337
- capScope: "system",
24338
- addonId: null,
24339
- access: "view"
24340
- },
24341
- "advancedNotifier.getRules": {
24342
- capName: "advanced-notifier",
24343
- capScope: "system",
24344
- addonId: null,
24345
- access: "view"
24346
- },
24347
- "advancedNotifier.testRule": {
24348
- capName: "advanced-notifier",
24349
- capScope: "system",
24350
- addonId: null,
24351
- access: "create"
24352
- },
24353
- "advancedNotifier.upsertRule": {
24354
- capName: "advanced-notifier",
24355
- capScope: "system",
24356
- addonId: null,
24357
- access: "create"
24358
- },
24359
24857
  "alarmPanel.arm": {
24360
24858
  capName: "alarm-panel",
24361
24859
  capScope: "device",
@@ -26660,6 +27158,60 @@ Object.freeze({
26660
27158
  addonId: null,
26661
27159
  access: "create"
26662
27160
  },
27161
+ "notificationRules.createRule": {
27162
+ capName: "notification-rules",
27163
+ capScope: "system",
27164
+ addonId: null,
27165
+ access: "create"
27166
+ },
27167
+ "notificationRules.deleteRule": {
27168
+ capName: "notification-rules",
27169
+ capScope: "system",
27170
+ addonId: null,
27171
+ access: "delete"
27172
+ },
27173
+ "notificationRules.getConditionCatalog": {
27174
+ capName: "notification-rules",
27175
+ capScope: "system",
27176
+ addonId: null,
27177
+ access: "view"
27178
+ },
27179
+ "notificationRules.getHistory": {
27180
+ capName: "notification-rules",
27181
+ capScope: "system",
27182
+ addonId: null,
27183
+ access: "view"
27184
+ },
27185
+ "notificationRules.getRule": {
27186
+ capName: "notification-rules",
27187
+ capScope: "system",
27188
+ addonId: null,
27189
+ access: "view"
27190
+ },
27191
+ "notificationRules.listRules": {
27192
+ capName: "notification-rules",
27193
+ capScope: "system",
27194
+ addonId: null,
27195
+ access: "view"
27196
+ },
27197
+ "notificationRules.setRuleEnabled": {
27198
+ capName: "notification-rules",
27199
+ capScope: "system",
27200
+ addonId: null,
27201
+ access: "create"
27202
+ },
27203
+ "notificationRules.testRule": {
27204
+ capName: "notification-rules",
27205
+ capScope: "system",
27206
+ addonId: null,
27207
+ access: "create"
27208
+ },
27209
+ "notificationRules.updateRule": {
27210
+ capName: "notification-rules",
27211
+ capScope: "system",
27212
+ addonId: null,
27213
+ access: "create"
27214
+ },
26663
27215
  "notifier.cancel": {
26664
27216
  capName: "notifier",
26665
27217
  capScope: "device",