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