@camstack/addon-export-alexa 1.2.4 → 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.
@@ -1,6 +1,6 @@
1
1
  import * as crypto$1 from "node:crypto";
2
2
  import { createHash } from "node:crypto";
3
- //#region ../types/dist/event-category-D4HJq7Mw.mjs
3
+ //#region ../types/dist/event-category-BLcNejAE.mjs
4
4
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
5
5
  EventCategory["SystemBoot"] = "system.boot";
6
6
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -150,9 +150,6 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
150
150
  EventCategory["RecordingSegmentWritten"] = "recording.segment.written";
151
151
  EventCategory["RecordingPolicyFallback"] = "recording.policy.fallback";
152
152
  EventCategory["RecordingRetentionCompleted"] = "recording.retention.completed";
153
- /** Runner-sampled scrub thumbnail (~1/5 s/camera). Telemetry (D8): a lost
154
- * thumb is a scrub gap the recorder's keyframe backfill covers. */
155
- EventCategory["RecordingThumbSampled"] = "recording.thumb-sampled";
156
153
  /** Export render progress (0–100). Telemetry (D8): a lost tick is a stale
157
154
  * progress bar the client reconciles via `recordingExport.getExport`. */
158
155
  EventCategory["RecordingExportProgress"] = "recording.export.progress";
@@ -6828,7 +6825,6 @@ object({ deviceId: number() }), object({ deviceId: number() }), object({
6828
6825
  patch: record(string(), unknown())
6829
6826
  }), object({ success: literal(true) });
6830
6827
  object({ deviceId: number() }), unknown().nullable();
6831
- /** Shorthand to define a method schema */
6832
6828
  function method(input, output, options) {
6833
6829
  return {
6834
6830
  input,
@@ -6836,6 +6832,7 @@ function method(input, output, options) {
6836
6832
  kind: options?.kind ?? "query",
6837
6833
  auth: options?.auth ?? "protected",
6838
6834
  ...options?.access !== void 0 ? { access: options.access } : {},
6835
+ ...options?.caller !== void 0 ? { caller: options.caller } : {},
6839
6836
  timeoutMs: options?.timeoutMs
6840
6837
  };
6841
6838
  }
@@ -8372,6 +8369,59 @@ for (const l of AUDIO_MACRO_LABELS) {
8372
8369
  /** The complete taxonomy dictionary, keyed by kind. */
8373
8370
  var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
8374
8371
  /**
8372
+ * Notification-Center taxonomy — the fixed vocabulary the NC rule editor
8373
+ * offers as pickers instead of free text. Derived (never hand-listed) from the
8374
+ * single `EVENT_TAXONOMY` dictionary so it stays in lockstep with every other
8375
+ * taxonomy surface (timeline, filters, event page).
8376
+ *
8377
+ * Three buckets, mapped onto the rule editor's `stringList` conditions:
8378
+ * - `videoClasses` → detection classes (person / vehicle / animal + subs)
8379
+ * for the `classes` / `classesExclude` conditions.
8380
+ * - `audioKinds` → audio-analyzer sub kinds (`audio-scream`, …) shown in
8381
+ * the same class picker, grouped under an Audio header.
8382
+ * - `labels` → sensor + control taxonomy kinds (doorbell / contact /
8383
+ * lock / …) for the `sensorKinds` device-event condition.
8384
+ *
8385
+ * Each entry carries `parentKind` so the client can group video subs under
8386
+ * their macro and sensor/control kinds under their category. This surface is
8387
+ * served ADDITIVELY on the `nc.getConditionCatalog` bridge response — no cap
8388
+ * method, no codegen — so it ships train-free with an addon deploy.
8389
+ */
8390
+ /** One selectable taxonomy value: a stable kind id + display label + parent. */
8391
+ var NcTaxonomyEntrySchema = object({
8392
+ /** Stable kind id (e.g. 'person', 'car', 'audio-scream', 'doorbell'). */
8393
+ kind: string(),
8394
+ /** English fallback label (the UI translates via the event-kind i18n key). */
8395
+ label: string(),
8396
+ /** Macro/category parent for grouping ('car' → 'vehicle'); null for a top. */
8397
+ parentKind: string().nullable()
8398
+ });
8399
+ object({
8400
+ videoClasses: array(NcTaxonomyEntrySchema),
8401
+ audioKinds: array(NcTaxonomyEntrySchema),
8402
+ labels: array(NcTaxonomyEntrySchema)
8403
+ });
8404
+ function toEntry(kind, label, parentKind) {
8405
+ return {
8406
+ kind,
8407
+ label,
8408
+ parentKind
8409
+ };
8410
+ }
8411
+ /**
8412
+ * Build the NC taxonomy from `EVENT_TAXONOMY`. Insertion order is preserved
8413
+ * (macros before their subs), which the client relies on for stable grouping.
8414
+ */
8415
+ function buildNcTaxonomy() {
8416
+ const all = Object.values(EVENT_TAXONOMY);
8417
+ return {
8418
+ videoClasses: all.filter((e) => e.category === "detection").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8419
+ audioKinds: all.filter((e) => e.category === "audio" && e.level === "sub").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8420
+ labels: all.filter((e) => e.category === "sensor" || e.category === "control").map((e) => toEntry(e.kind, e.label, e.parentKind))
8421
+ };
8422
+ }
8423
+ Object.freeze(buildNcTaxonomy());
8424
+ /**
8375
8425
  * Error types for the safe expression engine. Two distinct classes so callers
8376
8426
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
8377
8427
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -11080,6 +11130,22 @@ var CameraMetricsSchema = object({
11080
11130
  ])
11081
11131
  });
11082
11132
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
11133
+ /**
11134
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
11135
+ * within the frame, so the executor can re-cut a leaf child ROI at native
11136
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
11137
+ */
11138
+ var NativeCropRefSchema = object({
11139
+ /** Handle keying the retained native surface (node-pinned to its owner). */
11140
+ handle: FrameHandleSchema,
11141
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
11142
+ cropFrameSpace: object({
11143
+ x: number(),
11144
+ y: number(),
11145
+ w: number(),
11146
+ h: number()
11147
+ })
11148
+ });
11083
11149
  var ModelFormatSchema$1 = _enum([
11084
11150
  "onnx",
11085
11151
  "coreml",
@@ -11355,7 +11421,22 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
11355
11421
  * Omitted ⇒ the runner's default device (current single-engine
11356
11422
  * behaviour). Selects WHICH device pool of the node runs the call.
11357
11423
  */
11358
- deviceKey: string().optional()
11424
+ deviceKey: string().optional(),
11425
+ /**
11426
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
11427
+ * when the parent crop was resolved from the frame's retained NATIVE
11428
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
11429
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
11430
+ * resolution from that surface — the SAME quality path faces already
11431
+ * had — instead of the downscaled parent tile. `handle` keys the native
11432
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
11433
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
11434
+ * the executor's crop-normalized child ROI back into frame-normalized
11435
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
11436
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
11437
+ * (today's behaviour on the fallback path).
11438
+ */
11439
+ nativeCropRef: NativeCropRefSchema.optional()
11359
11440
  }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
11360
11441
  engine: PipelineEngineChoiceSchema.optional(),
11361
11442
  steps: array(PipelineStepInputSchema).min(1),
@@ -11571,7 +11652,11 @@ var DetailResultSchema = object({
11571
11652
  bbox: NativeCropBboxSchema.optional(),
11572
11653
  embedding: string().optional(),
11573
11654
  label: string().optional(),
11574
- alignedCropJpeg: string().optional()
11655
+ alignedCropJpeg: string().optional(),
11656
+ /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
11657
+ * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
11658
+ * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
11659
+ nativeFaceShortSidePx: number().optional()
11575
11660
  });
11576
11661
  /**
11577
11662
  * Per-camera tunable ranges + defaults. Single source of truth used
@@ -11585,6 +11670,12 @@ var motionCooldownMsField = {
11585
11670
  default: 3e4,
11586
11671
  step: 500
11587
11672
  };
11673
+ var maxSessionHoldMsField = {
11674
+ min: 0,
11675
+ max: 6e5,
11676
+ default: 12e4,
11677
+ step: 5e3
11678
+ };
11588
11679
  var motionFpsField = {
11589
11680
  min: 1,
11590
11681
  max: 30,
@@ -11732,6 +11823,19 @@ var RunnerCameraConfigSchema = object({
11732
11823
  "on-motion"
11733
11824
  ]).default("always-on"),
11734
11825
  motionCooldownMs: number().min(motionCooldownMsField.min).default(motionCooldownMsField.default),
11826
+ /**
11827
+ * Orchestrator-side on-motion session-hold cap (ms). While an on-motion
11828
+ * detection session is active and ≥1 confirmed non-stationary track is
11829
+ * still live, the orchestrator keeps the session open past
11830
+ * `motionCooldownMs` (a slowly-moving subject can stop re-triggering the
11831
+ * camera's VMD yet is still being tracked frame-to-frame) — up to this many
11832
+ * ms since the session opened, after which it closes regardless. `0`
11833
+ * disables the hold (legacy cooldown-only teardown). Not consumed by the
11834
+ * runner itself — carried here so it shares the per-camera device-settings
11835
+ * surface with `motionCooldownMs`; the orchestrator reads it off the
11836
+ * resolved `CameraDetectionConfig`.
11837
+ */
11838
+ maxSessionHoldMs: number().min(maxSessionHoldMsField.min).max(maxSessionHoldMsField.max).optional(),
11735
11839
  motionFps: number().min(motionFpsField.min).max(motionFpsField.max).default(motionFpsField.default),
11736
11840
  detectionFps: number().min(detectionFpsField.min).max(detectionFpsField.max).default(detectionFpsField.default),
11737
11841
  motionStreamId: string(),
@@ -11821,7 +11925,7 @@ var RunnerCameraConfigSchema = object({
11821
11925
  */
11822
11926
  inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
11823
11927
  });
11824
- 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;
11928
+ 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;
11825
11929
  /**
11826
11930
  * Runtime load summary returned by `getLocalLoad`. Used by the orchestrator's
11827
11931
  * load-balancing levels (L2 capacity-based, L3 hardware-aware) to decide
@@ -13694,94 +13798,6 @@ var EnrichedWidgetMetadataSchema = WidgetMetadataSchema.extend({
13694
13798
  bundleUrl: string()
13695
13799
  });
13696
13800
  method(_void(), array(EnrichedWidgetMetadataSchema).readonly());
13697
- var NotificationRuleConditionsSchema = object({
13698
- deviceIds: array(number()).readonly().optional(),
13699
- classNames: array(string()).readonly().optional(),
13700
- zoneIds: array(string()).readonly().optional(),
13701
- minConfidence: number().optional(),
13702
- source: _enum([
13703
- "pipeline",
13704
- "onboard",
13705
- "any"
13706
- ]).optional(),
13707
- schedule: object({
13708
- days: array(number()).readonly(),
13709
- startHour: number(),
13710
- endHour: number()
13711
- }).optional(),
13712
- cooldownSeconds: number().optional(),
13713
- minDwellSeconds: number().optional(),
13714
- /** Match against `event.data.eventType` token (e.g. `'press_long'`). When non-empty, only events
13715
- * carrying a matching `data.eventType` string pass this condition. Rules without this field are
13716
- * unaffected (back-compat). Distinct from `rule.eventTypes` which holds EventCategory strings. */
13717
- eventTypeTokens: array(string()).readonly().optional(),
13718
- /** Match detections whose CLIP image embedding is semantically similar to this free-text
13719
- * description. Requires the embedding-encoder cap to have pre-warmed the text vector.
13720
- * `minSimilarity` is the cosine similarity threshold in [0, 1]. */
13721
- clipDescription: object({
13722
- text: string().min(1),
13723
- minSimilarity: number().min(0).max(1)
13724
- }).optional(),
13725
- /** Match events whose recognized-entity label (face identity name or plate
13726
- * vehicle name, propagated onto `event.data.label`) is one of these values.
13727
- * Empty/absent → unaffected (back-compat). Enables "notify me when <named
13728
- * vehicle/person> is seen". */
13729
- labels: array(string()).readonly().optional()
13730
- });
13731
- var NotificationRuleTemplateSchema = object({
13732
- title: string(),
13733
- body: string(),
13734
- imageMode: _enum([
13735
- "crop",
13736
- "annotated",
13737
- "full",
13738
- "none"
13739
- ])
13740
- });
13741
- var NotificationRuleSchema = object({
13742
- id: string(),
13743
- name: string(),
13744
- enabled: boolean(),
13745
- eventTypes: array(string()).readonly(),
13746
- conditions: NotificationRuleConditionsSchema,
13747
- outputs: array(string()).readonly(),
13748
- template: NotificationRuleTemplateSchema.optional(),
13749
- priority: _enum([
13750
- "low",
13751
- "normal",
13752
- "high",
13753
- "critical"
13754
- ])
13755
- });
13756
- var NotificationTestResultSchema = object({
13757
- ruleId: string(),
13758
- eventId: string(),
13759
- timestamp: number(),
13760
- wouldFire: boolean(),
13761
- reason: string().optional()
13762
- });
13763
- var NotificationHistoryEntrySchema = object({
13764
- id: string(),
13765
- ruleId: string(),
13766
- ruleName: string(),
13767
- eventId: string(),
13768
- timestamp: number(),
13769
- outputs: array(string()).readonly(),
13770
- success: boolean(),
13771
- error: string().optional(),
13772
- deviceId: number().optional()
13773
- });
13774
- var NotificationHistoryFilterSchema = object({
13775
- ruleId: string().optional(),
13776
- deviceId: number().optional(),
13777
- from: number().optional(),
13778
- to: number().optional(),
13779
- limit: number().optional()
13780
- });
13781
- 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({
13782
- ruleId: string(),
13783
- lookbackMinutes: number()
13784
- }), object({ results: array(NotificationTestResultSchema).readonly() }), { kind: "mutation" }), method(object({ filter: NotificationHistoryFilterSchema.optional() }), object({ entries: array(NotificationHistoryEntrySchema).readonly() }));
13785
13801
  /**
13786
13802
  * Alerts capability — collection-based internal alert system.
13787
13803
  *
@@ -13968,89 +13984,6 @@ method(object({
13968
13984
  password: string()
13969
13985
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
13970
13986
  /**
13971
- * `login-method` — collection cap through which auth addons contribute
13972
- * their pre-auth login surfaces to the login page. This is the SINGLE,
13973
- * generic mechanism that supersedes the dead `auth.listProviders` reader:
13974
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
13975
- * `login-method` provider and the PUBLIC `auth.listLoginMethods`
13976
- * procedure aggregates them for the unauthenticated login page.
13977
- *
13978
- * A contribution is a discriminated union on `kind`:
13979
- *
13980
- * - `redirect` — a declarative button. The login page renders a generic
13981
- * button that navigates to `startUrl` (an addon-owned HTTP route).
13982
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
13983
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
13984
- * login page needs NO change.
13985
- *
13986
- * - `widget` — a Module-Federation widget the login page mounts (via
13987
- * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
13988
- * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
13989
- * mechanism kept for future use; no shipped addon uses it on the login
13990
- * page (the passkey ceremony below runs natively in the shell instead).
13991
- *
13992
- * - `passkey` — a declarative WebAuthn ceremony the shell renders
13993
- * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
13994
- * a remotely-loaded bundle). Carries the addon's effective `rpId` /
13995
- * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
13996
- * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
13997
- * fetching any remote code pre-auth. Contribution stays unconditional —
13998
- * enrollment state is never leaked pre-auth; visibility is a shell
13999
- * decision.
14000
- *
14001
- * Every contribution carries a `stage`:
14002
- * - `primary` — shown on the first credentials screen (OIDC /
14003
- * magic-link buttons; a future usernameless passkey).
14004
- * - `second-factor` — shown AFTER the password leg, gated on the
14005
- * returned `factors` (passkey-as-2FA today).
14006
- *
14007
- * `mount: skip` — the cap is read server-side by the core auth router
14008
- * (`registry.getCollection('login-method')`), never mounted as its own
14009
- * tRPC router.
14010
- */
14011
- /** When a login method renders in the two-phase login flow. */
14012
- var LoginStageEnum = _enum(["primary", "second-factor"]);
14013
- /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
14014
- var LoginMethodContributionSchema = discriminatedUnion("kind", [
14015
- object({
14016
- kind: literal("redirect"),
14017
- /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
14018
- id: string(),
14019
- /** Operator-facing button label. */
14020
- label: string(),
14021
- /** lucide-react icon name. */
14022
- icon: string().optional(),
14023
- /** Addon-owned HTTP route the button navigates to (GET). */
14024
- startUrl: string(),
14025
- stage: LoginStageEnum
14026
- }),
14027
- object({
14028
- kind: literal("widget"),
14029
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
14030
- id: string(),
14031
- /** Owning addon id — drives the public bundle URL + the MF namespace. */
14032
- addonId: string(),
14033
- /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
14034
- bundle: string(),
14035
- /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
14036
- remote: WidgetRemoteSchema,
14037
- stage: LoginStageEnum
14038
- }),
14039
- object({
14040
- kind: literal("passkey"),
14041
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
14042
- id: string(),
14043
- /** Operator-facing button label. */
14044
- label: string(),
14045
- stage: LoginStageEnum,
14046
- /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
14047
- rpId: string(),
14048
- /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
14049
- origin: string().nullable()
14050
- })
14051
- ]);
14052
- method(_void(), array(LoginMethodContributionSchema).readonly());
14053
- /**
14054
13987
  * Orchestrator-side destination metadata. The orchestrator computes
14055
13988
  * `id = <addonId>:<subId>` from its provider lookup so consumers
14056
13989
  * (admin UI, restore flow) see one canonical key.
@@ -14424,7 +14357,8 @@ function customAction(input, output, options) {
14424
14357
  output,
14425
14358
  kind: options?.kind ?? "query",
14426
14359
  auth: options?.auth ?? "protected",
14427
- scope: options?.scope ?? { kind: "system" }
14360
+ scope: options?.scope ?? { kind: "system" },
14361
+ ...options?.caller ? { caller: "required" } : {}
14428
14362
  };
14429
14363
  }
14430
14364
  /**
@@ -15440,369 +15374,744 @@ method(_void(), array(string()).readonly(), { auth: "admin" }), method(object({
15440
15374
  kind: "mutation",
15441
15375
  auth: "admin"
15442
15376
  });
15443
- var LogLevelSchema = _enum([
15444
- "debug",
15445
- "info",
15446
- "warn",
15447
- "error"
15377
+ /**
15378
+ * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
15379
+ * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15380
+ * caps stay wire-compatible without a circular cap→cap import.
15381
+ *
15382
+ * Errors are a discriminated-union RESULT, never thrown: the shape survives
15383
+ * every transport tier structurally, and failed calls still write usage rows.
15384
+ * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
15385
+ */
15386
+ var LlmUsageSchema = object({
15387
+ inputTokens: number(),
15388
+ outputTokens: number()
15389
+ });
15390
+ var LlmErrorCodeSchema = _enum([
15391
+ "timeout",
15392
+ "rate-limited",
15393
+ "auth",
15394
+ "refusal",
15395
+ "bad-request",
15396
+ "unavailable",
15397
+ "no-profile",
15398
+ "budget-exceeded",
15399
+ "adapter-error"
15448
15400
  ]);
15449
- var LogEntrySchema = object({
15450
- timestamp: date(),
15451
- level: LogLevelSchema,
15452
- scope: array(string()),
15401
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
15402
+ ok: literal(true),
15403
+ text: string(),
15404
+ model: string(),
15405
+ usage: LlmUsageSchema,
15406
+ truncated: boolean(),
15407
+ latencyMs: number()
15408
+ }), object({
15409
+ ok: literal(false),
15410
+ code: LlmErrorCodeSchema,
15453
15411
  message: string(),
15454
- meta: record(string(), unknown()).optional(),
15455
- tags: record(string(), string()).optional()
15456
- });
15457
- method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
15458
- scope: array(string()).optional(),
15459
- level: LogLevelSchema.optional(),
15460
- since: date().optional(),
15461
- until: date().optional(),
15462
- limit: number().optional(),
15463
- tags: record(string(), string()).optional()
15464
- }), array(LogEntrySchema).readonly());
15465
- var CpuBreakdownSchema = object({
15466
- total: number(),
15467
- user: number(),
15468
- system: number(),
15469
- irq: number(),
15470
- nice: number(),
15471
- loadAvg: tuple([
15472
- number(),
15473
- number(),
15474
- number()
15475
- ]),
15476
- cores: number()
15412
+ retryAfterMs: number().optional()
15413
+ })]);
15414
+ /**
15415
+ * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
15416
+ * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
15417
+ * notification-output.cap.ts:27-31 precedents).
15418
+ */
15419
+ var LlmImageSchema = object({
15420
+ bytes: _instanceof(Uint8Array),
15421
+ mimeType: string()
15477
15422
  });
15478
- var MemoryInfoSchema = object({
15479
- percent: number(),
15480
- totalBytes: number(),
15481
- usedBytes: number(),
15482
- availableBytes: number(),
15483
- swapUsedBytes: number(),
15484
- swapTotalBytes: number()
15423
+ var LlmGenerateBaseInputSchema = object({
15424
+ /** Collection routing (the notification-output posture). */
15425
+ addonId: string().optional(),
15426
+ /** Explicit profile; else the resolution chain (spec §3). */
15427
+ profileId: string().optional(),
15428
+ /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
15429
+ consumer: string(),
15430
+ system: string().optional(),
15431
+ /** v1: single-turn. `messages[]` is a v2 additive field. */
15432
+ prompt: string(),
15433
+ /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
15434
+ jsonSchema: record(string(), unknown()).optional(),
15435
+ /** Per-call override of the profile default. */
15436
+ maxTokens: number().int().positive().optional(),
15437
+ temperature: number().optional()
15485
15438
  });
15486
- var DiskIoSnapshotSchema = object({
15487
- readBytes: number(),
15488
- writeBytes: number(),
15489
- readOps: number(),
15490
- writeOps: number(),
15491
- timestampMs: number()
15492
- });
15493
- var NetworkIoSnapshotSchema = object({
15494
- rxBytes: number(),
15495
- txBytes: number(),
15496
- rxPackets: number(),
15497
- txPackets: number(),
15498
- rxErrors: number(),
15499
- txErrors: number(),
15500
- timestampMs: number()
15501
- });
15502
- var MetricsGpuInfoSchema = object({
15503
- utilization: number(),
15504
- model: string(),
15505
- memoryUsedBytes: number(),
15506
- memoryTotalBytes: number(),
15507
- temperature: number().nullable()
15508
- });
15509
- var ProcessResourceInfoSchema = object({
15510
- openFds: number(),
15511
- threadCount: number(),
15512
- activeHandles: number(),
15513
- activeRequests: number()
15514
- });
15515
- var PressureAvgsSchema = object({
15516
- avg10: number(),
15517
- avg60: number(),
15518
- avg300: number()
15519
- });
15520
- var PressureInfoSchema = object({
15521
- some: PressureAvgsSchema,
15522
- full: PressureAvgsSchema.nullable()
15523
- });
15524
- var SystemResourceSnapshotSchema = object({
15525
- cpu: CpuBreakdownSchema,
15526
- memory: MemoryInfoSchema,
15527
- gpu: MetricsGpuInfoSchema.nullable(),
15528
- network: NetworkIoSnapshotSchema,
15529
- disk: DiskIoSnapshotSchema,
15530
- pressure: object({
15531
- cpu: PressureInfoSchema.nullable(),
15532
- memory: PressureInfoSchema.nullable(),
15533
- io: PressureInfoSchema.nullable()
15439
+ /**
15440
+ * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
15441
+ * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
15442
+ * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
15443
+ * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
15444
+ * this only through the `llm` cap's methods.
15445
+ *
15446
+ * One running llama-server child per node in v1 (models are RAM-heavy).
15447
+ * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
15448
+ * watchdog — operator decision #3).
15449
+ */
15450
+ var ManagedModelRefSchema = discriminatedUnion("kind", [
15451
+ object({
15452
+ kind: literal("catalog"),
15453
+ catalogId: string()
15534
15454
  }),
15535
- process: ProcessResourceInfoSchema,
15536
- cpuTemperature: number().nullable(),
15537
- timestampMs: number()
15538
- });
15539
- var DiskSpaceInfoSchema = object({
15540
- path: string(),
15541
- totalBytes: number(),
15542
- usedBytes: number(),
15543
- availableBytes: number(),
15544
- percent: number()
15545
- });
15546
- var PidResourceStatsSchema = object({
15547
- pid: number(),
15548
- cpu: number(),
15549
- memory: number(),
15550
- /**
15551
- * Private (anonymous) resident bytes — the per-process V8 heap + native
15552
- * allocations NOT shared with other processes (Linux RssAnon). This is the
15553
- * "real" per-runner cost; summing it across runners is meaningful, unlike
15554
- * `memory` (RSS), which double-counts the shared mmap'd framework code.
15555
- * Undefined where /proc is unavailable (e.g. macOS).
15556
- */
15557
- privateBytes: number().optional(),
15558
- /**
15559
- * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
15560
- * code shared copy-on-write across runners. Undefined on macOS.
15561
- */
15562
- sharedBytes: number().optional()
15455
+ object({
15456
+ kind: literal("url"),
15457
+ url: string(),
15458
+ sha256: string().optional()
15459
+ }),
15460
+ object({
15461
+ kind: literal("path"),
15462
+ path: string()
15463
+ })
15464
+ ]);
15465
+ var ManagedRuntimeConfigSchema = object({
15466
+ /** WHERE the runtime lives — hub or any agent. */
15467
+ nodeId: string(),
15468
+ /** Closed for v1; 'ollama' is a v2 candidate. */
15469
+ engine: _enum(["llama-cpp"]),
15470
+ model: ManagedModelRefSchema,
15471
+ contextSize: number().int().default(4096),
15472
+ /** 0 = CPU-only. */
15473
+ gpuLayers: number().int().default(0),
15474
+ /** Default: cpus-2, clamped ≥1 (resolved node-side). */
15475
+ threads: number().int().optional(),
15476
+ /** Concurrent slots. */
15477
+ parallel: number().int().default(1),
15478
+ /** Else lazy: first generate boots it. */
15479
+ autoStart: boolean().default(false),
15480
+ /** 0 = never; frees RAM after quiet periods. */
15481
+ idleStopMinutes: number().int().default(30)
15563
15482
  });
15564
- var AddonInstanceSchema = object({
15565
- addonId: string(),
15483
+ var LlmRuntimeStatusSchema = object({
15484
+ /** Status is ALWAYS node-qualified. */
15566
15485
  nodeId: string(),
15567
- role: _enum(["hub", "worker"]),
15568
- pid: number(),
15569
15486
  state: _enum([
15570
- "starting",
15571
- "running",
15572
- "stopping",
15573
15487
  "stopped",
15574
- "crashed"
15575
- ]),
15576
- uptimeSec: number()
15577
- });
15578
- var NodeProcessSchema = object({
15579
- pid: number(),
15580
- ppid: number(),
15581
- pgid: number(),
15582
- classification: _enum([
15583
- "root",
15584
- "managed",
15585
- "system",
15586
- "ghost"
15488
+ "downloading",
15489
+ "starting",
15490
+ "ready",
15491
+ "crashed",
15492
+ "failed"
15587
15493
  ]),
15588
- /** `$process` addon binding when `managed`, else null. */
15589
- addonId: string().nullable(),
15590
- /** Kernel-reported nodeId when the process is a known agent/worker. */
15591
- nodeId: string().nullable(),
15592
- /** Truncated command line. */
15593
- command: string(),
15594
- cpuPercent: number(),
15595
- memoryRssBytes: number(),
15596
- /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
15597
- uptimeSec: number(),
15598
- /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
15599
- orphaned: boolean()
15600
- });
15601
- var KillProcessInputSchema = object({
15602
- pid: number(),
15603
- /** Force = SIGKILL. Default is SIGTERM. */
15604
- force: boolean().optional()
15605
- });
15606
- var KillProcessResultSchema = object({
15607
- success: boolean(),
15608
- reason: string().optional(),
15609
- signal: _enum(["SIGTERM", "SIGKILL"]).optional()
15610
- });
15611
- var DumpHeapSnapshotInputSchema = object({
15612
- /** The addon whose runner should dump a heap snapshot. */
15613
- addonId: string() });
15614
- var DumpHeapSnapshotResultSchema = object({
15615
- success: boolean(),
15616
- /** Path of the written .heapsnapshot inside the runner's container/host. */
15617
- path: string().optional(),
15618
- /** Process pid that was signalled. */
15619
15494
  pid: number().optional(),
15620
- reason: string().optional()
15495
+ port: number().optional(),
15496
+ modelPath: string().optional(),
15497
+ modelId: string().optional(),
15498
+ downloadProgress: number().min(0).max(1).optional(),
15499
+ lastError: string().optional(),
15500
+ crashesInWindow: number(),
15501
+ /** Child RSS (sampled best-effort). */
15502
+ memoryBytes: number().optional(),
15503
+ vramBytes: number().optional()
15621
15504
  });
15622
- var SystemMetricsSchema = object({
15623
- cpuPercent: number(),
15624
- memoryPercent: number(),
15625
- memoryUsedMB: number(),
15626
- memoryTotalMB: number(),
15627
- diskPercent: number().optional(),
15628
- temperature: number().optional(),
15629
- gpuPercent: number().optional(),
15630
- gpuMemoryPercent: number().optional()
15505
+ var LlmNodeModelSchema = object({
15506
+ file: string(),
15507
+ sizeBytes: number(),
15508
+ catalogId: string().optional(),
15509
+ installedAt: number().optional()
15631
15510
  });
15632
- 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, {
15511
+ var LlmRuntimeDiskUsageSchema = object({
15512
+ nodeId: string(),
15513
+ modelsBytes: number(),
15514
+ freeBytes: number().optional()
15515
+ });
15516
+ method(LlmGenerateBaseInputSchema.extend({
15517
+ images: array(LlmImageSchema).optional(),
15518
+ runtime: ManagedRuntimeConfigSchema,
15519
+ /** The managed profile's timeout, threaded by the hub provider. */
15520
+ timeoutMs: number().int().positive().optional()
15521
+ }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
15633
15522
  kind: "mutation",
15634
15523
  auth: "admin"
15635
- }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
15524
+ }), method(object({}), _void(), {
15636
15525
  kind: "mutation",
15637
15526
  auth: "admin"
15638
- });
15639
- method(object({
15640
- sourceUrl: string(),
15641
- metadata: ModelConvertMetadataSchema,
15642
- targets: array(ConvertTargetSchema).min(1).readonly(),
15643
- calibrationRef: string().optional(),
15644
- sessionId: string().optional()
15645
- }), ConvertResultSchema, {
15527
+ }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
15646
15528
  kind: "mutation",
15647
- auth: "admin",
15648
- timeoutMs: 6e5
15649
- });
15650
- method(object({
15651
- nodeId: string(),
15652
- modelId: string(),
15653
- format: _enum(MODEL_FORMATS),
15654
- entry: ModelCatalogEntrySchema
15655
- }), object({
15656
- ok: boolean(),
15657
- /** sha256 of the staged tarball (empty for a hub-local no-op). */
15658
- sha256: string(),
15659
- bytes: number(),
15660
- /** The target node's modelsDir the artifact landed in. */
15661
- path: string()
15662
- }), {
15529
+ auth: "admin"
15530
+ }), method(object({ file: string() }), _void(), {
15663
15531
  kind: "mutation",
15664
15532
  auth: "admin"
15665
- });
15533
+ }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
15666
15534
  /**
15667
- * `mqtt-broker` — broker-registry cap.
15668
- *
15669
- * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
15670
- * MQTT brokers (external + optionally an embedded `aedes`-backed one)
15671
- * and (b) the connection details a consumer addon needs to spin up
15672
- * its OWN `mqtt.js` client.
15535
+ * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
15536
+ * methods concat-fan across providers; single-row methods route to ONE
15537
+ * provider by the `addonId` in the call input (the notification-output
15538
+ * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
15539
+ * (hub-placed); the cap stays open for future providers.
15673
15540
  *
15674
- * Why: pub/sub routing over the system event-bus loses fidelity
15675
- * (callback shape, QoS guarantees, will/retain semantics) and adds
15676
- * refcount bookkeeping that addons would rather own themselves. The
15677
- * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
15678
- * features anyway — give it the connection config, get out of the way.
15679
- *
15680
- * Consumer flow:
15681
- * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
15682
- * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
15683
- * client.subscribe('zigbee2mqtt/+')
15684
- *
15685
- * Collection mode: multiple brokers (e.g. one local mosquitto + one
15686
- * cloud bridge). The "embedded" entry (when present) is just another
15687
- * broker in the registry — its lifecycle is owned by the addon that
15688
- * spawned it.
15689
- */
15690
- var BrokerKindSchema = _enum(["external", "embedded"]);
15691
- /**
15692
- * Broker live-probe status.
15693
- *
15694
- * - `connected` — last probe completed a clean CONNACK
15695
- * - `disconnected` — no probe has run yet (cold cache)
15696
- * - `auth-failed` — CONNACK refused with auth error (RC 4 / 5)
15697
- * - `unreachable` — TCP connect timed out / refused
15698
- * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
15541
+ * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
15542
+ * `apiKey` is a password field providers REDACT it on read and merge on
15543
+ * write; a stored key NEVER round-trips to a client.
15699
15544
  */
15700
- var BrokerStatusSchema$1 = _enum([
15701
- "connected",
15702
- "disconnected",
15703
- "auth-failed",
15704
- "unreachable",
15705
- "tls-error"
15545
+ var LlmProfileKindSchema = _enum([
15546
+ "openai-compatible",
15547
+ "openai",
15548
+ "anthropic",
15549
+ "google",
15550
+ "managed-local"
15706
15551
  ]);
15707
- var BrokerInfoSchema = object({
15552
+ var LlmProfileSchema = object({
15708
15553
  id: string(),
15709
15554
  name: string(),
15710
- url: string(),
15711
- kind: BrokerKindSchema,
15712
- status: BrokerStatusSchema$1,
15713
- latencyMs: number().nullable(),
15714
- error: string().optional(),
15715
- /** Embedded brokers only: number of MQTT clients currently connected. */
15716
- connectedClients: number().int().nonnegative().optional(),
15717
- /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
15718
- lastCheckedAt: number().optional()
15555
+ kind: LlmProfileKindSchema,
15556
+ /** Stamped by the provider — keeps the fanned catalog routable. */
15557
+ addonId: string(),
15558
+ enabled: boolean(),
15559
+ /** Vendor model id, or the managed runtime's loaded model. */
15560
+ model: string(),
15561
+ /** Required for openai-compatible; override for cloud kinds. */
15562
+ baseUrl: string().optional(),
15563
+ /** ConfigUISchema type:'password' — never round-trips (spec §5). */
15564
+ apiKey: string().optional(),
15565
+ supportsVision: boolean(),
15566
+ temperature: number().min(0).max(2).optional(),
15567
+ maxTokens: number().int().positive().optional(),
15568
+ timeoutMs: number().int().positive().default(6e4),
15569
+ extraHeaders: record(string(), string()).optional(),
15570
+ /** kind === 'managed-local' only (spec §4). */
15571
+ runtime: ManagedRuntimeConfigSchema.optional()
15719
15572
  });
15720
- /**
15721
- * Connection details — what a consumer needs to call
15722
- * `mqtt.connect(url, options)`. We split URL + credentials so the
15723
- * consumer can pass them as `mqtt.connect(url, { username, password })`
15724
- * instead of stuffing creds into the URL (which leaks them into logs).
15725
- */
15726
- var BrokerConnectionDetailsSchema = object({
15727
- url: string(),
15728
- username: string().optional(),
15729
- password: string().optional(),
15730
- /**
15731
- * Suggested prefix for `clientId`. Each consumer should suffix this
15732
- * with its own discriminator (addon id, instance id) so reconnects
15733
- * don't kick each other off (MQTT spec: clientId must be unique per
15734
- * broker).
15735
- */
15736
- clientIdPrefix: string().optional()
15573
+ /** ConfigUISchema tree passed through untyped on the wire (the
15574
+ * notification-output `ConfigSchemaPassthrough` precedent at
15575
+ * notification-output.cap.ts:151); the exported TS type re-tightens it. */
15576
+ var ConfigSchemaPassthrough$1 = unknown();
15577
+ var LlmProfileKindDescriptorSchema = object({
15578
+ kind: LlmProfileKindSchema,
15579
+ label: string(),
15580
+ icon: string(),
15581
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
15582
+ addonId: string(),
15583
+ configSchema: ConfigSchemaPassthrough$1
15737
15584
  });
15738
- var AddBrokerInputSchema = object({
15739
- name: string().min(1),
15740
- url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
15741
- username: string().optional(),
15742
- password: string().optional(),
15743
- clientIdPrefix: string().optional()
15585
+ var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
15586
+ var LlmDefaultSchema = object({
15587
+ selector: LlmDefaultSelectorSchema,
15588
+ profileId: string()
15744
15589
  });
15745
- var AddBrokerResultSchema = object({ id: string() });
15746
- var IdInputSchema = object({ id: string() });
15747
- var TestResultSchema$1 = discriminatedUnion("ok", [object({
15748
- ok: literal(true),
15749
- latencyMs: number()
15750
- }), object({
15751
- ok: literal(false),
15752
- error: string()
15753
- })]);
15754
- var StartEmbeddedInputSchema = object({
15755
- port: number().int().min(1).max(65535).default(1883),
15756
- /** Allow anonymous connect (no username/password). Default: false. */
15757
- allowAnonymous: boolean().default(false),
15758
- /** Optional shared username/password for clients. */
15759
- username: string().optional(),
15760
- password: string().optional()
15590
+ /** Server-side rollup row getUsage never dumps raw call rows (spec §6). */
15591
+ var LlmUsageRollupSchema = object({
15592
+ day: string(),
15593
+ consumer: string(),
15594
+ profileId: string(),
15595
+ calls: number(),
15596
+ okCalls: number(),
15597
+ errorCalls: number(),
15598
+ inputTokens: number(),
15599
+ outputTokens: number(),
15600
+ avgLatencyMs: number()
15761
15601
  });
15762
- var StartEmbeddedResultSchema = object({
15602
+ /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
15603
+ var ManagedModelCatalogEntrySchema = object({
15763
15604
  id: string(),
15764
- url: string()
15765
- });
15766
- var StatusSchema = object({
15767
- brokerCount: number(),
15768
- embeddedRunning: boolean()
15769
- });
15770
- 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);
15771
- var NetworkEndpointSchema = object({
15605
+ label: string(),
15606
+ family: string(),
15607
+ purpose: _enum(["text", "vision"]),
15772
15608
  url: string(),
15773
- hostname: string(),
15774
- port: number(),
15775
- protocol: _enum(["http", "https"])
15609
+ sha256: string(),
15610
+ sizeBytes: number(),
15611
+ quantization: string(),
15612
+ /** Load-time guidance shown in the picker. */
15613
+ minRamBytes: number(),
15614
+ contextSizeDefault: number().int(),
15615
+ /** Vision models: companion projector file. */
15616
+ mmprojUrl: string().optional()
15776
15617
  });
15777
- var NetworkAccessStatusSchema = object({
15778
- connected: boolean(),
15779
- endpoint: NetworkEndpointSchema.nullable(),
15618
+ var LlmRuntimeNodeSchema = object({
15619
+ nodeId: string(),
15620
+ reachable: boolean(),
15621
+ status: LlmRuntimeStatusSchema.optional(),
15622
+ disk: LlmRuntimeDiskUsageSchema.optional(),
15780
15623
  error: string().optional()
15781
15624
  });
15782
- /**
15783
- * Optional, richer endpoint shape returned by providers that expose
15784
- * MORE than one ingress concurrently (Tailscale Ingress with mixed
15785
- * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
15786
- * the originating provider config (mode + sourcePort) so the
15787
- * orchestrator UI can label rows distinctly. Providers that expose only
15788
- * one endpoint just omit `listEndpoints` from their provider impl.
15789
- */
15790
- var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
15791
- /**
15792
- * Stable id within the provider — typically `<mode>-<sourcePort>` so
15793
- * the orchestrator can dedupe across `listEndpoints` polls.
15794
- */
15795
- id: string(),
15796
- /** Operator-facing label (mirrors `MeshEndpoint.label`). */
15797
- label: string(),
15798
- /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
15799
- mode: string().optional(),
15800
- /** Originating local port the ingress fronts (informational). */
15801
- sourcePort: number().optional()
15625
+ var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
15626
+ var ProfileRefInputSchema = object({
15627
+ addonId: string(),
15628
+ profileId: string()
15802
15629
  });
15803
- method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
15630
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
15631
+ kind: "mutation",
15632
+ auth: "admin"
15633
+ }), method(ProfileRefInputSchema, _void(), {
15634
+ kind: "mutation",
15635
+ auth: "admin"
15636
+ }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
15637
+ kind: "mutation",
15638
+ auth: "admin"
15639
+ }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
15640
+ selector: LlmDefaultSelectorSchema,
15641
+ profileId: string().nullable()
15642
+ }), _void(), {
15643
+ kind: "mutation",
15644
+ auth: "admin"
15645
+ }), method(object({
15646
+ since: number().optional(),
15647
+ until: number().optional(),
15648
+ consumer: string().optional(),
15649
+ profileId: string().optional()
15650
+ }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
15651
+ nodeId: string(),
15652
+ model: ManagedModelRefSchema
15653
+ }), _void(), {
15654
+ kind: "mutation",
15655
+ auth: "admin"
15656
+ }), method(object({
15657
+ nodeId: string(),
15658
+ file: string()
15659
+ }), _void(), {
15660
+ kind: "mutation",
15661
+ auth: "admin"
15662
+ }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
15663
+ kind: "mutation",
15664
+ auth: "admin"
15665
+ }), method(ProfileRefInputSchema, _void(), {
15666
+ kind: "mutation",
15667
+ auth: "admin"
15668
+ });
15669
+ var LogLevelSchema = _enum([
15670
+ "debug",
15671
+ "info",
15672
+ "warn",
15673
+ "error"
15674
+ ]);
15675
+ var LogEntrySchema = object({
15676
+ timestamp: date(),
15677
+ level: LogLevelSchema,
15678
+ scope: array(string()),
15679
+ message: string(),
15680
+ meta: record(string(), unknown()).optional(),
15681
+ tags: record(string(), string()).optional()
15682
+ });
15683
+ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
15684
+ scope: array(string()).optional(),
15685
+ level: LogLevelSchema.optional(),
15686
+ since: date().optional(),
15687
+ until: date().optional(),
15688
+ limit: number().optional(),
15689
+ tags: record(string(), string()).optional()
15690
+ }), array(LogEntrySchema).readonly());
15804
15691
  /**
15805
- * notification-outputcanonical, capability-gated notification delivery.
15692
+ * `login-method`collection cap through which auth addons contribute
15693
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
15694
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
15695
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
15696
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
15697
+ * procedure aggregates them for the unauthenticated login page.
15698
+ *
15699
+ * A contribution is a discriminated union on `kind`:
15700
+ *
15701
+ * - `redirect` — a declarative button. The login page renders a generic
15702
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
15703
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
15704
+ * ZERO shell-side JS. A future SSO addon plugs in the same way — the
15705
+ * login page needs NO change.
15706
+ *
15707
+ * - `widget` — a Module-Federation widget the login page mounts (via
15708
+ * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
15709
+ * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
15710
+ * mechanism kept for future use; no shipped addon uses it on the login
15711
+ * page (the passkey ceremony below runs natively in the shell instead).
15712
+ *
15713
+ * - `passkey` — a declarative WebAuthn ceremony the shell renders
15714
+ * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
15715
+ * a remotely-loaded bundle). Carries the addon's effective `rpId` /
15716
+ * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
15717
+ * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
15718
+ * fetching any remote code pre-auth. Contribution stays unconditional —
15719
+ * enrollment state is never leaked pre-auth; visibility is a shell
15720
+ * decision.
15721
+ *
15722
+ * Every contribution carries a `stage`:
15723
+ * - `primary` — shown on the first credentials screen (OIDC /
15724
+ * magic-link buttons; a future usernameless passkey).
15725
+ * - `second-factor` — shown AFTER the password leg, gated on the
15726
+ * returned `factors` (passkey-as-2FA today).
15727
+ *
15728
+ * `mount: skip` — the cap is read server-side by the core auth router
15729
+ * (`registry.getCollection('login-method')`), never mounted as its own
15730
+ * tRPC router.
15731
+ */
15732
+ /** When a login method renders in the two-phase login flow. */
15733
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
15734
+ /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
15735
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [
15736
+ object({
15737
+ kind: literal("redirect"),
15738
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
15739
+ id: string(),
15740
+ /** Operator-facing button label. */
15741
+ label: string(),
15742
+ /** lucide-react icon name. */
15743
+ icon: string().optional(),
15744
+ /** Addon-owned HTTP route the button navigates to (GET). */
15745
+ startUrl: string(),
15746
+ stage: LoginStageEnum
15747
+ }),
15748
+ object({
15749
+ kind: literal("widget"),
15750
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
15751
+ id: string(),
15752
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
15753
+ addonId: string(),
15754
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
15755
+ bundle: string(),
15756
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
15757
+ remote: WidgetRemoteSchema,
15758
+ stage: LoginStageEnum
15759
+ }),
15760
+ object({
15761
+ kind: literal("passkey"),
15762
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
15763
+ id: string(),
15764
+ /** Operator-facing button label. */
15765
+ label: string(),
15766
+ stage: LoginStageEnum,
15767
+ /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
15768
+ rpId: string(),
15769
+ /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
15770
+ origin: string().nullable()
15771
+ })
15772
+ ]);
15773
+ method(_void(), array(LoginMethodContributionSchema).readonly());
15774
+ var CpuBreakdownSchema = object({
15775
+ total: number(),
15776
+ user: number(),
15777
+ system: number(),
15778
+ irq: number(),
15779
+ nice: number(),
15780
+ loadAvg: tuple([
15781
+ number(),
15782
+ number(),
15783
+ number()
15784
+ ]),
15785
+ cores: number()
15786
+ });
15787
+ var MemoryInfoSchema = object({
15788
+ percent: number(),
15789
+ totalBytes: number(),
15790
+ usedBytes: number(),
15791
+ availableBytes: number(),
15792
+ swapUsedBytes: number(),
15793
+ swapTotalBytes: number()
15794
+ });
15795
+ var DiskIoSnapshotSchema = object({
15796
+ readBytes: number(),
15797
+ writeBytes: number(),
15798
+ readOps: number(),
15799
+ writeOps: number(),
15800
+ timestampMs: number()
15801
+ });
15802
+ var NetworkIoSnapshotSchema = object({
15803
+ rxBytes: number(),
15804
+ txBytes: number(),
15805
+ rxPackets: number(),
15806
+ txPackets: number(),
15807
+ rxErrors: number(),
15808
+ txErrors: number(),
15809
+ timestampMs: number()
15810
+ });
15811
+ var MetricsGpuInfoSchema = object({
15812
+ utilization: number(),
15813
+ model: string(),
15814
+ memoryUsedBytes: number(),
15815
+ memoryTotalBytes: number(),
15816
+ temperature: number().nullable()
15817
+ });
15818
+ var ProcessResourceInfoSchema = object({
15819
+ openFds: number(),
15820
+ threadCount: number(),
15821
+ activeHandles: number(),
15822
+ activeRequests: number()
15823
+ });
15824
+ var PressureAvgsSchema = object({
15825
+ avg10: number(),
15826
+ avg60: number(),
15827
+ avg300: number()
15828
+ });
15829
+ var PressureInfoSchema = object({
15830
+ some: PressureAvgsSchema,
15831
+ full: PressureAvgsSchema.nullable()
15832
+ });
15833
+ var SystemResourceSnapshotSchema = object({
15834
+ cpu: CpuBreakdownSchema,
15835
+ memory: MemoryInfoSchema,
15836
+ gpu: MetricsGpuInfoSchema.nullable(),
15837
+ network: NetworkIoSnapshotSchema,
15838
+ disk: DiskIoSnapshotSchema,
15839
+ pressure: object({
15840
+ cpu: PressureInfoSchema.nullable(),
15841
+ memory: PressureInfoSchema.nullable(),
15842
+ io: PressureInfoSchema.nullable()
15843
+ }),
15844
+ process: ProcessResourceInfoSchema,
15845
+ cpuTemperature: number().nullable(),
15846
+ timestampMs: number()
15847
+ });
15848
+ var DiskSpaceInfoSchema = object({
15849
+ path: string(),
15850
+ totalBytes: number(),
15851
+ usedBytes: number(),
15852
+ availableBytes: number(),
15853
+ percent: number()
15854
+ });
15855
+ var PidResourceStatsSchema = object({
15856
+ pid: number(),
15857
+ cpu: number(),
15858
+ memory: number(),
15859
+ /**
15860
+ * Private (anonymous) resident bytes — the per-process V8 heap + native
15861
+ * allocations NOT shared with other processes (Linux RssAnon). This is the
15862
+ * "real" per-runner cost; summing it across runners is meaningful, unlike
15863
+ * `memory` (RSS), which double-counts the shared mmap'd framework code.
15864
+ * Undefined where /proc is unavailable (e.g. macOS).
15865
+ */
15866
+ privateBytes: number().optional(),
15867
+ /**
15868
+ * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
15869
+ * code shared copy-on-write across runners. Undefined on macOS.
15870
+ */
15871
+ sharedBytes: number().optional()
15872
+ });
15873
+ var AddonInstanceSchema = object({
15874
+ addonId: string(),
15875
+ nodeId: string(),
15876
+ role: _enum(["hub", "worker"]),
15877
+ pid: number(),
15878
+ state: _enum([
15879
+ "starting",
15880
+ "running",
15881
+ "stopping",
15882
+ "stopped",
15883
+ "crashed"
15884
+ ]),
15885
+ uptimeSec: number()
15886
+ });
15887
+ var NodeProcessSchema = object({
15888
+ pid: number(),
15889
+ ppid: number(),
15890
+ pgid: number(),
15891
+ classification: _enum([
15892
+ "root",
15893
+ "managed",
15894
+ "system",
15895
+ "ghost"
15896
+ ]),
15897
+ /** `$process` addon binding when `managed`, else null. */
15898
+ addonId: string().nullable(),
15899
+ /** Kernel-reported nodeId when the process is a known agent/worker. */
15900
+ nodeId: string().nullable(),
15901
+ /** Truncated command line. */
15902
+ command: string(),
15903
+ cpuPercent: number(),
15904
+ memoryRssBytes: number(),
15905
+ /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
15906
+ uptimeSec: number(),
15907
+ /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
15908
+ orphaned: boolean()
15909
+ });
15910
+ var KillProcessInputSchema = object({
15911
+ pid: number(),
15912
+ /** Force = SIGKILL. Default is SIGTERM. */
15913
+ force: boolean().optional()
15914
+ });
15915
+ var KillProcessResultSchema = object({
15916
+ success: boolean(),
15917
+ reason: string().optional(),
15918
+ signal: _enum(["SIGTERM", "SIGKILL"]).optional()
15919
+ });
15920
+ var DumpHeapSnapshotInputSchema = object({
15921
+ /** The addon whose runner should dump a heap snapshot. */
15922
+ addonId: string() });
15923
+ var DumpHeapSnapshotResultSchema = object({
15924
+ success: boolean(),
15925
+ /** Path of the written .heapsnapshot inside the runner's container/host. */
15926
+ path: string().optional(),
15927
+ /** Process pid that was signalled. */
15928
+ pid: number().optional(),
15929
+ reason: string().optional()
15930
+ });
15931
+ var SystemMetricsSchema = object({
15932
+ cpuPercent: number(),
15933
+ memoryPercent: number(),
15934
+ memoryUsedMB: number(),
15935
+ memoryTotalMB: number(),
15936
+ diskPercent: number().optional(),
15937
+ temperature: number().optional(),
15938
+ gpuPercent: number().optional(),
15939
+ gpuMemoryPercent: number().optional()
15940
+ });
15941
+ 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, {
15942
+ kind: "mutation",
15943
+ auth: "admin"
15944
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
15945
+ kind: "mutation",
15946
+ auth: "admin"
15947
+ });
15948
+ method(object({
15949
+ sourceUrl: string(),
15950
+ metadata: ModelConvertMetadataSchema,
15951
+ targets: array(ConvertTargetSchema).min(1).readonly(),
15952
+ calibrationRef: string().optional(),
15953
+ sessionId: string().optional()
15954
+ }), ConvertResultSchema, {
15955
+ kind: "mutation",
15956
+ auth: "admin",
15957
+ timeoutMs: 6e5
15958
+ });
15959
+ method(object({
15960
+ nodeId: string(),
15961
+ modelId: string(),
15962
+ format: _enum(MODEL_FORMATS),
15963
+ entry: ModelCatalogEntrySchema
15964
+ }), object({
15965
+ ok: boolean(),
15966
+ /** sha256 of the staged tarball (empty for a hub-local no-op). */
15967
+ sha256: string(),
15968
+ bytes: number(),
15969
+ /** The target node's modelsDir the artifact landed in. */
15970
+ path: string()
15971
+ }), {
15972
+ kind: "mutation",
15973
+ auth: "admin"
15974
+ });
15975
+ /**
15976
+ * `mqtt-broker` — broker-registry cap.
15977
+ *
15978
+ * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
15979
+ * MQTT brokers (external + optionally an embedded `aedes`-backed one)
15980
+ * and (b) the connection details a consumer addon needs to spin up
15981
+ * its OWN `mqtt.js` client.
15982
+ *
15983
+ * Why: pub/sub routing over the system event-bus loses fidelity
15984
+ * (callback shape, QoS guarantees, will/retain semantics) and adds
15985
+ * refcount bookkeeping that addons would rather own themselves. The
15986
+ * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
15987
+ * features anyway — give it the connection config, get out of the way.
15988
+ *
15989
+ * Consumer flow:
15990
+ * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
15991
+ * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
15992
+ * client.subscribe('zigbee2mqtt/+')
15993
+ *
15994
+ * Collection mode: multiple brokers (e.g. one local mosquitto + one
15995
+ * cloud bridge). The "embedded" entry (when present) is just another
15996
+ * broker in the registry — its lifecycle is owned by the addon that
15997
+ * spawned it.
15998
+ */
15999
+ var BrokerKindSchema = _enum(["external", "embedded"]);
16000
+ /**
16001
+ * Broker live-probe status.
16002
+ *
16003
+ * - `connected` — last probe completed a clean CONNACK
16004
+ * - `disconnected` — no probe has run yet (cold cache)
16005
+ * - `auth-failed` — CONNACK refused with auth error (RC 4 / 5)
16006
+ * - `unreachable` — TCP connect timed out / refused
16007
+ * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
16008
+ */
16009
+ var BrokerStatusSchema$1 = _enum([
16010
+ "connected",
16011
+ "disconnected",
16012
+ "auth-failed",
16013
+ "unreachable",
16014
+ "tls-error"
16015
+ ]);
16016
+ var BrokerInfoSchema = object({
16017
+ id: string(),
16018
+ name: string(),
16019
+ url: string(),
16020
+ kind: BrokerKindSchema,
16021
+ status: BrokerStatusSchema$1,
16022
+ latencyMs: number().nullable(),
16023
+ error: string().optional(),
16024
+ /** Embedded brokers only: number of MQTT clients currently connected. */
16025
+ connectedClients: number().int().nonnegative().optional(),
16026
+ /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
16027
+ lastCheckedAt: number().optional()
16028
+ });
16029
+ /**
16030
+ * Connection details — what a consumer needs to call
16031
+ * `mqtt.connect(url, options)`. We split URL + credentials so the
16032
+ * consumer can pass them as `mqtt.connect(url, { username, password })`
16033
+ * instead of stuffing creds into the URL (which leaks them into logs).
16034
+ */
16035
+ var BrokerConnectionDetailsSchema = object({
16036
+ url: string(),
16037
+ username: string().optional(),
16038
+ password: string().optional(),
16039
+ /**
16040
+ * Suggested prefix for `clientId`. Each consumer should suffix this
16041
+ * with its own discriminator (addon id, instance id) so reconnects
16042
+ * don't kick each other off (MQTT spec: clientId must be unique per
16043
+ * broker).
16044
+ */
16045
+ clientIdPrefix: string().optional()
16046
+ });
16047
+ var AddBrokerInputSchema = object({
16048
+ name: string().min(1),
16049
+ url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
16050
+ username: string().optional(),
16051
+ password: string().optional(),
16052
+ clientIdPrefix: string().optional()
16053
+ });
16054
+ var AddBrokerResultSchema = object({ id: string() });
16055
+ var IdInputSchema = object({ id: string() });
16056
+ var TestResultSchema$1 = discriminatedUnion("ok", [object({
16057
+ ok: literal(true),
16058
+ latencyMs: number()
16059
+ }), object({
16060
+ ok: literal(false),
16061
+ error: string()
16062
+ })]);
16063
+ var StartEmbeddedInputSchema = object({
16064
+ port: number().int().min(1).max(65535).default(1883),
16065
+ /** Allow anonymous connect (no username/password). Default: false. */
16066
+ allowAnonymous: boolean().default(false),
16067
+ /** Optional shared username/password for clients. */
16068
+ username: string().optional(),
16069
+ password: string().optional()
16070
+ });
16071
+ var StartEmbeddedResultSchema = object({
16072
+ id: string(),
16073
+ url: string()
16074
+ });
16075
+ var StatusSchema = object({
16076
+ brokerCount: number(),
16077
+ embeddedRunning: boolean()
16078
+ });
16079
+ 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);
16080
+ var NetworkEndpointSchema = object({
16081
+ url: string(),
16082
+ hostname: string(),
16083
+ port: number(),
16084
+ protocol: _enum(["http", "https"])
16085
+ });
16086
+ var NetworkAccessStatusSchema = object({
16087
+ connected: boolean(),
16088
+ endpoint: NetworkEndpointSchema.nullable(),
16089
+ error: string().optional()
16090
+ });
16091
+ /**
16092
+ * Optional, richer endpoint shape returned by providers that expose
16093
+ * MORE than one ingress concurrently (Tailscale Ingress with mixed
16094
+ * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
16095
+ * the originating provider config (mode + sourcePort) so the
16096
+ * orchestrator UI can label rows distinctly. Providers that expose only
16097
+ * one endpoint just omit `listEndpoints` from their provider impl.
16098
+ */
16099
+ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
16100
+ /**
16101
+ * Stable id within the provider — typically `<mode>-<sourcePort>` so
16102
+ * the orchestrator can dedupe across `listEndpoints` polls.
16103
+ */
16104
+ id: string(),
16105
+ /** Operator-facing label (mirrors `MeshEndpoint.label`). */
16106
+ label: string(),
16107
+ /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
16108
+ mode: string().optional(),
16109
+ /** Originating local port the ingress fronts (informational). */
16110
+ sourcePort: number().optional()
16111
+ });
16112
+ method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
16113
+ /**
16114
+ * notification-output — canonical, capability-gated notification delivery.
15806
16115
  *
15807
16116
  * Apprise-derived model (see
15808
16117
  * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
@@ -15912,379 +16221,575 @@ var TargetKindCapsSchema = object({
15912
16221
  mediaTypes: array(AttachmentMediaTypeSchema),
15913
16222
  mode: _enum([
15914
16223
  "url",
15915
- "bytes",
15916
- "both"
15917
- ]),
15918
- max: number().int().nonnegative(),
15919
- maxBytes: number().int().positive().optional()
15920
- }),
15921
- /** Max action buttons (0 = none). */
15922
- actions: number().int().nonnegative(),
15923
- levels: array(TargetKindLevelSchema),
15924
- format: array(NotificationFormatSchema),
15925
- clickUrl: boolean(),
15926
- sound: boolean(),
15927
- ttl: boolean(),
15928
- bodyMaxLen: number().int().positive()
15929
- });
15930
- /**
15931
- * `configSchema` is a `ConfigUISchema` tree passed through to the admin
15932
- * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
15933
- * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
15934
- * the union is large and not meant for runtime validation here; the exported
15935
- * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
15936
- */
15937
- var ConfigSchemaPassthrough$1 = unknown();
15938
- var TargetKindSchema = object({
15939
- kind: string(),
15940
- label: string(),
15941
- icon: string(),
15942
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
15943
- addonId: string(),
15944
- configSchema: ConfigSchemaPassthrough$1,
15945
- supportsDiscovery: boolean(),
15946
- caps: TargetKindCapsSchema
15947
- });
15948
- /**
15949
- * A persisted target. `config` holds secrets; providers REDACT secret fields
15950
- * (return a presence marker only) when serving `listTargets` — never
15951
- * round-trip a stored secret to the UI.
15952
- */
15953
- var TargetSchema = object({
15954
- id: string(),
15955
- name: string(),
15956
- kind: string(),
15957
- addonId: string(),
15958
- enabled: boolean(),
15959
- config: record(string(), unknown())
15960
- });
15961
- /** A discovery-surfaced candidate (config is partial + non-secret). */
15962
- var DiscoveredTargetSchema = object({
15963
- kind: string(),
15964
- suggestedName: string(),
15965
- config: record(string(), unknown())
15966
- });
15967
- /** The degrade engine's report — what was resolved / dropped / degraded. */
15968
- var RenderedAsSchema = object({
15969
- level: string(),
15970
- format: NotificationFormatSchema,
15971
- attachmentsSent: number().int().nonnegative(),
15972
- actionsSent: number().int().nonnegative(),
15973
- truncated: boolean(),
15974
- dropped: array(string())
15975
- });
15976
- var SendResultSchema = object({
15977
- success: boolean(),
15978
- error: string().optional(),
15979
- renderedAs: RenderedAsSchema.optional()
15980
- });
15981
- /** Same shape as SendResult — kept as a distinct name for the test panel. */
15982
- var TestResultSchema = SendResultSchema;
15983
- method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
15984
- kind: string(),
15985
- config: record(string(), unknown()).optional()
15986
- }), array(DiscoveredTargetSchema)), method(object({
15987
- targetId: string(),
15988
- notification: NotificationSchema
15989
- }), SendResultSchema, { kind: "mutation" }), method(object({
15990
- targetId: string(),
15991
- sample: NotificationSchema.optional()
15992
- }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
15993
- targetId: string(),
15994
- enabled: boolean()
15995
- }), _void(), { kind: "mutation" });
15996
- /**
15997
- * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
15998
- * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15999
- * caps stay wire-compatible without a circular cap→cap import.
16000
- *
16001
- * Errors are a discriminated-union RESULT, never thrown: the shape survives
16002
- * every transport tier structurally, and failed calls still write usage rows.
16003
- * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
16004
- */
16005
- var LlmUsageSchema = object({
16006
- inputTokens: number(),
16007
- outputTokens: number()
16008
- });
16009
- var LlmErrorCodeSchema = _enum([
16010
- "timeout",
16011
- "rate-limited",
16012
- "auth",
16013
- "refusal",
16014
- "bad-request",
16015
- "unavailable",
16016
- "no-profile",
16017
- "budget-exceeded",
16018
- "adapter-error"
16019
- ]);
16020
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
16021
- ok: literal(true),
16022
- text: string(),
16023
- model: string(),
16024
- usage: LlmUsageSchema,
16025
- truncated: boolean(),
16026
- latencyMs: number()
16027
- }), object({
16028
- ok: literal(false),
16029
- code: LlmErrorCodeSchema,
16030
- message: string(),
16031
- retryAfterMs: number().optional()
16032
- })]);
16033
- /**
16034
- * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
16035
- * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
16036
- * notification-output.cap.ts:27-31 precedents).
16037
- */
16038
- var LlmImageSchema = object({
16039
- bytes: _instanceof(Uint8Array),
16040
- mimeType: string()
16041
- });
16042
- var LlmGenerateBaseInputSchema = object({
16043
- /** Collection routing (the notification-output posture). */
16044
- addonId: string().optional(),
16045
- /** Explicit profile; else the resolution chain (spec §3). */
16046
- profileId: string().optional(),
16047
- /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
16048
- consumer: string(),
16049
- system: string().optional(),
16050
- /** v1: single-turn. `messages[]` is a v2 additive field. */
16051
- prompt: string(),
16052
- /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
16053
- jsonSchema: record(string(), unknown()).optional(),
16054
- /** Per-call override of the profile default. */
16055
- maxTokens: number().int().positive().optional(),
16056
- temperature: number().optional()
16057
- });
16058
- /**
16059
- * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
16060
- * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
16061
- * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
16062
- * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
16063
- * this only through the `llm` cap's methods.
16064
- *
16065
- * One running llama-server child per node in v1 (models are RAM-heavy).
16066
- * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
16067
- * watchdog — operator decision #3).
16068
- */
16069
- var ManagedModelRefSchema = discriminatedUnion("kind", [
16070
- object({
16071
- kind: literal("catalog"),
16072
- catalogId: string()
16073
- }),
16074
- object({
16075
- kind: literal("url"),
16076
- url: string(),
16077
- sha256: string().optional()
16078
- }),
16079
- object({
16080
- kind: literal("path"),
16081
- path: string()
16082
- })
16083
- ]);
16084
- var ManagedRuntimeConfigSchema = object({
16085
- /** WHERE the runtime lives — hub or any agent. */
16086
- nodeId: string(),
16087
- /** Closed for v1; 'ollama' is a v2 candidate. */
16088
- engine: _enum(["llama-cpp"]),
16089
- model: ManagedModelRefSchema,
16090
- contextSize: number().int().default(4096),
16091
- /** 0 = CPU-only. */
16092
- gpuLayers: number().int().default(0),
16093
- /** Default: cpus-2, clamped ≥1 (resolved node-side). */
16094
- threads: number().int().optional(),
16095
- /** Concurrent slots. */
16096
- parallel: number().int().default(1),
16097
- /** Else lazy: first generate boots it. */
16098
- autoStart: boolean().default(false),
16099
- /** 0 = never; frees RAM after quiet periods. */
16100
- idleStopMinutes: number().int().default(30)
16101
- });
16102
- var LlmRuntimeStatusSchema = object({
16103
- /** Status is ALWAYS node-qualified. */
16104
- nodeId: string(),
16105
- state: _enum([
16106
- "stopped",
16107
- "downloading",
16108
- "starting",
16109
- "ready",
16110
- "crashed",
16111
- "failed"
16112
- ]),
16113
- pid: number().optional(),
16114
- port: number().optional(),
16115
- modelPath: string().optional(),
16116
- modelId: string().optional(),
16117
- downloadProgress: number().min(0).max(1).optional(),
16118
- lastError: string().optional(),
16119
- crashesInWindow: number(),
16120
- /** Child RSS (sampled best-effort). */
16121
- memoryBytes: number().optional(),
16122
- vramBytes: number().optional()
16123
- });
16124
- var LlmNodeModelSchema = object({
16125
- file: string(),
16126
- sizeBytes: number(),
16127
- catalogId: string().optional(),
16128
- installedAt: number().optional()
16224
+ "bytes",
16225
+ "both"
16226
+ ]),
16227
+ max: number().int().nonnegative(),
16228
+ maxBytes: number().int().positive().optional()
16229
+ }),
16230
+ /** Max action buttons (0 = none). */
16231
+ actions: number().int().nonnegative(),
16232
+ levels: array(TargetKindLevelSchema),
16233
+ format: array(NotificationFormatSchema),
16234
+ clickUrl: boolean(),
16235
+ sound: boolean(),
16236
+ ttl: boolean(),
16237
+ bodyMaxLen: number().int().positive()
16129
16238
  });
16130
- var LlmRuntimeDiskUsageSchema = object({
16131
- nodeId: string(),
16132
- modelsBytes: number(),
16133
- freeBytes: number().optional()
16239
+ /**
16240
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
16241
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
16242
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`)
16243
+ * the union is large and not meant for runtime validation here; the exported
16244
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
16245
+ */
16246
+ var ConfigSchemaPassthrough = unknown();
16247
+ var TargetKindSchema = object({
16248
+ kind: string(),
16249
+ label: string(),
16250
+ icon: string(),
16251
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
16252
+ addonId: string(),
16253
+ configSchema: ConfigSchemaPassthrough,
16254
+ supportsDiscovery: boolean(),
16255
+ caps: TargetKindCapsSchema
16134
16256
  });
16135
- method(LlmGenerateBaseInputSchema.extend({
16136
- images: array(LlmImageSchema).optional(),
16137
- runtime: ManagedRuntimeConfigSchema,
16138
- /** The managed profile's timeout, threaded by the hub provider. */
16139
- timeoutMs: number().int().positive().optional()
16140
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
16141
- kind: "mutation",
16142
- auth: "admin"
16143
- }), method(object({}), _void(), {
16144
- kind: "mutation",
16145
- auth: "admin"
16146
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
16147
- kind: "mutation",
16148
- auth: "admin"
16149
- }), method(object({ file: string() }), _void(), {
16150
- kind: "mutation",
16151
- auth: "admin"
16152
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
16153
16257
  /**
16154
- * `llm` consumer-facing LLM surface (spec §1-§3). Collection-mode: array
16155
- * methods concat-fan across providers; single-row methods route to ONE
16156
- * provider by the `addonId` in the call input (the notification-output
16157
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
16158
- * (hub-placed); the cap stays open for future providers.
16159
- *
16160
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
16161
- * `apiKey` is a password field — providers REDACT it on read and merge on
16162
- * write; a stored key NEVER round-trips to a client.
16258
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
16259
+ * (return a presence marker only) when serving `listTargets` — never
16260
+ * round-trip a stored secret to the UI.
16163
16261
  */
16164
- var LlmProfileKindSchema = _enum([
16165
- "openai-compatible",
16166
- "openai",
16167
- "anthropic",
16168
- "google",
16169
- "managed-local"
16170
- ]);
16171
- var LlmProfileSchema = object({
16262
+ var TargetSchema = object({
16172
16263
  id: string(),
16173
16264
  name: string(),
16174
- kind: LlmProfileKindSchema,
16175
- /** Stamped by the provider — keeps the fanned catalog routable. */
16265
+ kind: string(),
16176
16266
  addonId: string(),
16177
16267
  enabled: boolean(),
16178
- /** Vendor model id, or the managed runtime's loaded model. */
16179
- model: string(),
16180
- /** Required for openai-compatible; override for cloud kinds. */
16181
- baseUrl: string().optional(),
16182
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
16183
- apiKey: string().optional(),
16184
- supportsVision: boolean(),
16185
- temperature: number().min(0).max(2).optional(),
16186
- maxTokens: number().int().positive().optional(),
16187
- timeoutMs: number().int().positive().default(6e4),
16188
- extraHeaders: record(string(), string()).optional(),
16189
- /** kind === 'managed-local' only (spec §4). */
16190
- runtime: ManagedRuntimeConfigSchema.optional()
16268
+ config: record(string(), unknown())
16191
16269
  });
16192
- /** ConfigUISchema tree passed through untyped on the wire (the
16193
- * notification-output `ConfigSchemaPassthrough` precedent at
16194
- * notification-output.cap.ts:151); the exported TS type re-tightens it. */
16195
- var ConfigSchemaPassthrough = unknown();
16196
- var LlmProfileKindDescriptorSchema = object({
16197
- kind: LlmProfileKindSchema,
16198
- label: string(),
16199
- icon: string(),
16200
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
16201
- addonId: string(),
16202
- configSchema: ConfigSchemaPassthrough
16270
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
16271
+ var DiscoveredTargetSchema = object({
16272
+ kind: string(),
16273
+ suggestedName: string(),
16274
+ config: record(string(), unknown())
16203
16275
  });
16204
- var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
16205
- var LlmDefaultSchema = object({
16206
- selector: LlmDefaultSelectorSchema,
16207
- profileId: string()
16276
+ /** The degrade engine's report what was resolved / dropped / degraded. */
16277
+ var RenderedAsSchema = object({
16278
+ level: string(),
16279
+ format: NotificationFormatSchema,
16280
+ attachmentsSent: number().int().nonnegative(),
16281
+ actionsSent: number().int().nonnegative(),
16282
+ truncated: boolean(),
16283
+ dropped: array(string())
16208
16284
  });
16209
- /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
16210
- var LlmUsageRollupSchema = object({
16211
- day: string(),
16212
- consumer: string(),
16213
- profileId: string(),
16214
- calls: number(),
16215
- okCalls: number(),
16216
- errorCalls: number(),
16217
- inputTokens: number(),
16218
- outputTokens: number(),
16219
- avgLatencyMs: number()
16285
+ var SendResultSchema = object({
16286
+ success: boolean(),
16287
+ error: string().optional(),
16288
+ renderedAs: RenderedAsSchema.optional()
16220
16289
  });
16221
- /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
16222
- var ManagedModelCatalogEntrySchema = object({
16290
+ /** Same shape as SendResult kept as a distinct name for the test panel. */
16291
+ var TestResultSchema = SendResultSchema;
16292
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
16293
+ kind: string(),
16294
+ config: record(string(), unknown()).optional()
16295
+ }), array(DiscoveredTargetSchema)), method(object({
16296
+ targetId: string(),
16297
+ notification: NotificationSchema
16298
+ }), SendResultSchema, { kind: "mutation" }), method(object({
16299
+ targetId: string(),
16300
+ sample: NotificationSchema.optional()
16301
+ }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
16302
+ targetId: string(),
16303
+ enabled: boolean()
16304
+ }), _void(), { kind: "mutation" });
16305
+ /**
16306
+ * notification-rules — the Notification Center rule surface (P1 core).
16307
+ *
16308
+ * Spec: `docs/superpowers/specs/2026-07-22-notification-center-requirements.md`
16309
+ * (operator decisions D-1/D-2/D-3 are binding):
16310
+ *
16311
+ * - D-2: rule EVALUATION lives in `addon-post-analysis` (the
16312
+ * `notification-center` module), hooked on the durable persistence
16313
+ * moments (object-event insert, TrackCloser.closeExpired) with a
16314
+ * persisted outbox + retry — never the lossy telemetry bus (D8).
16315
+ * - D-3: urgency belongs to the RULE. `delivery: 'immediate'` fires on the
16316
+ * FIRST persisted detection matching the conditions (per-track dedup,
16317
+ * `maxPerTrack` fixed at 1 — see {@link NC_MAX_PER_TRACK_IMMEDIATE});
16318
+ * `delivery: 'track-end'` evaluates the finalized track record at close.
16319
+ * - DISPATCH stays behind `notification-output` (rules reference targets
16320
+ * by id; per-backend params are a passthrough blob capped by the
16321
+ * target kind's own caps/degrade engine).
16322
+ *
16323
+ * P1 scope: admin-authored rules only (`createdBy` stamped from the
16324
+ * server-injected caller identity — the first `caller: 'required'`
16325
+ * adopter). The P1 condition subset is: devices, classes(+exclude),
16326
+ * minConfidence, admin zones (any/all + exclude), weekly schedule
16327
+ * windows, and the optional label/identity/plate matchers. User rules,
16328
+ * private zones, per-recipient fan-out and the wider condition table are
16329
+ * P2+ (see spec §7).
16330
+ *
16331
+ * All schemas here are the single source of truth — `NcRule` etc. are
16332
+ * `z.infer` exports; no duplicate interfaces (the advanced-notifier
16333
+ * schema/interface drift is explicitly not repeated).
16334
+ */
16335
+ /**
16336
+ * D-3: the trigger/urgency of a rule — which persistence moment evaluates it.
16337
+ * The value maps 1:1 onto the evaluated record kind:
16338
+ * - `immediate` ↔ object-event persist (lowest-latency detection burst)
16339
+ * - `track-end` ↔ TrackCloser.closeExpired (finalized track record)
16340
+ * - `device-event` ↔ SensorEventStore insert (doorbell press / sensor state
16341
+ * change of a LINKED device, one row per linked camera)
16342
+ * - `package-event` ↔ PackageDropDetector object-event insert (a `package`
16343
+ * delivery / pick-up)
16344
+ *
16345
+ * `immediate`/`track-end` carry the D-3 urgency semantics; `device-event`/
16346
+ * `package-event` are pure trigger kinds (no urgency dimension). Extending
16347
+ * this one field keeps the schema additive — a rule still declares exactly
16348
+ * one trigger.
16349
+ */
16350
+ var NcDeliverySchema = _enum([
16351
+ "immediate",
16352
+ "track-end",
16353
+ "device-event",
16354
+ "package-event"
16355
+ ]);
16356
+ /** Weekly schedule — OR of windows; absence on the rule = always active. */
16357
+ var NcScheduleSchema = object({
16358
+ windows: array(object({
16359
+ /** Days of week the window STARTS on (0 = Sunday … 6 = Saturday). */
16360
+ days: array(number().int().min(0).max(6)).min(1),
16361
+ startMinute: number().int().min(0).max(1439),
16362
+ endMinute: number().int().min(0).max(1439)
16363
+ })).min(1),
16364
+ /** IANA timezone; default = hub host timezone. */
16365
+ timezone: string().optional(),
16366
+ /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
16367
+ invert: boolean().optional()
16368
+ });
16369
+ /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
16370
+ var NcPlateMatcherSchema = object({
16371
+ values: array(string().min(1)).min(1),
16372
+ /** Max Levenshtein distance after normalization (uppercase alphanumeric). */
16373
+ maxDistance: number().int().min(0).max(3).default(1)
16374
+ });
16375
+ /**
16376
+ * Occupancy condition (DEVICE-EVENT trigger). Fires on a ZoneAnalytics
16377
+ * occupancy edge for a device — optionally narrowed to a single admin
16378
+ * `zoneId` and/or object `className`. `op` selects the edge/threshold:
16379
+ * - `became-occupied` (default) — count crossed 0 → ≥ `count`
16380
+ * - `became-free` — count crossed ≥ `count` → below it
16381
+ * - `>=` / `<=` — count is at/over or at/under `count`
16382
+ * `sustainSeconds` requires the condition hold continuously that long
16383
+ * before firing (debounces flicker; 0 = fire on the first matching edge).
16384
+ * Fail-closed: no ZoneAnalytics snapshot / missing zone / null snapshot ⇒
16385
+ * the condition never matches. Confirmed edge-state survives addon restarts
16386
+ * (declared SQLite collection, reseeded on boot).
16387
+ */
16388
+ var NcOccupancyConditionSchema = object({
16389
+ /** Admin zone id to scope the count to; absent = whole-frame occupancy. */
16390
+ zoneId: string().optional(),
16391
+ /** Object class to count; absent = any class. */
16392
+ className: string().optional(),
16393
+ op: _enum([
16394
+ "became-occupied",
16395
+ "became-free",
16396
+ ">=",
16397
+ "<="
16398
+ ]).default("became-occupied"),
16399
+ count: number().int().min(0).default(1),
16400
+ sustainSeconds: number().int().min(0).max(3600).default(15)
16401
+ });
16402
+ /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
16403
+ var NcZoneConditionSchema = object({
16404
+ ids: array(string().min(1)).min(1),
16405
+ /** Quantifier over `ids` — at least one / every one visited. */
16406
+ match: _enum(["any", "all"]).default("any")
16407
+ });
16408
+ /**
16409
+ * The P1 condition set — a flat AND of groups; absent group = pass;
16410
+ * membership lists are OR within the list (spec §2.3).
16411
+ */
16412
+ var NcConditionsSchema = object({
16413
+ /** Device scope — absent = all devices. */
16414
+ devices: array(number()).optional(),
16415
+ /** Detector class names (any overlap with the record's class set). */
16416
+ classes: array(string().min(1)).optional(),
16417
+ /** Veto classes — any overlap fails the rule. */
16418
+ classesExclude: array(string().min(1)).optional(),
16419
+ /** Minimum detection confidence 0–1 (fails when the record has none). */
16420
+ minConfidence: number().min(0).max(1).optional(),
16421
+ /** Admin zone membership over event `zones` / track `zonesVisited`. */
16422
+ zones: NcZoneConditionSchema.optional(),
16423
+ /** Veto zones — any hit fails the rule. */
16424
+ zonesExclude: array(string().min(1)).optional(),
16425
+ /**
16426
+ * Exact (case-insensitive) match on the record's collapsed `label`
16427
+ * (identity name / plate text / subclass).
16428
+ */
16429
+ labelEquals: array(string().min(1)).optional(),
16430
+ /**
16431
+ * Identity matcher. P1 boundary: matched against the record's collapsed
16432
+ * `label` (the identity display name propagated by the face pipeline) —
16433
+ * identity-ID matching rides in P2 when identity ids reach the record.
16434
+ */
16435
+ identities: array(string().min(1)).optional(),
16436
+ /** Fuzzy plate matcher against the record's `label` (plate text). */
16437
+ plates: NcPlateMatcherSchema.optional(),
16438
+ /**
16439
+ * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
16440
+ * Same P1 boundary: matched against the record's collapsed `label` (the
16441
+ * identity display name). A record with NO label passes (nothing to
16442
+ * exclude), unlike the include variant which fails on an absent label.
16443
+ */
16444
+ identitiesExclude: array(string().min(1)).optional(),
16445
+ /**
16446
+ * Minimum server-computed key-event importance in [0,1] (`Track.importance`).
16447
+ * TRACK-END only: importance is scored at track close, so it does not exist
16448
+ * at immediate / object-event evaluation time (see catalog `appliesTo`). At
16449
+ * close the value is threaded via the close-time info (the `Track` clone is
16450
+ * captured before the DB row is updated, so it would otherwise read stale).
16451
+ * Fails when the record carries no importance (never guess quality — the
16452
+ * `minConfidence` precedent). MVP cut: a single scalar threshold.
16453
+ */
16454
+ minImportance: number().min(0).max(1).optional(),
16455
+ /**
16456
+ * Minimum track dwell in SECONDS — `(lastSeen − firstSeen) / 1000`.
16457
+ * TRACK-END only: an `immediate` / object-event subject has no closed
16458
+ * lifespan, so a dwell condition never matches immediate delivery
16459
+ * (documented choice — the object-event record carries no `firstSeen`,
16460
+ * so dwell cannot be computed from what the subject actually carries).
16461
+ */
16462
+ minDwellSeconds: number().min(0).optional(),
16463
+ /**
16464
+ * Detection provenance filter. `any` (default / absent) matches every
16465
+ * source; otherwise the subject's source must equal it. Legacy records
16466
+ * with no stamped source are treated as `pipeline`. The union spans both
16467
+ * record kinds — object events carry `pipeline` | `onboard`, synthetic
16468
+ * tracks carry `sensor`.
16469
+ */
16470
+ source: _enum([
16471
+ "pipeline",
16472
+ "onboard",
16473
+ "sensor",
16474
+ "any"
16475
+ ]).optional(),
16476
+ /**
16477
+ * Minimum identity / plate MATCH confidence in [0,1] — DISTINCT from the
16478
+ * detector `minConfidence` (that gates the object-detection score; this
16479
+ * gates the recognition/OCR match score). Fails when the subject carries
16480
+ * no label-match confidence (never guess). TRACK-END only: the confidence
16481
+ * lives on the recognition result and reaches the subject at track close.
16482
+ *
16483
+ * What it measures precisely (plumbed at track close — the closer threads
16484
+ * the value into `NcTrackClosedInfo.labelConfidence`, the same seam as
16485
+ * `importance`): the BEST recognition match confidence observed for the
16486
+ * label the track carries at close — for a face, the peak cosine similarity
16487
+ * of the ASSIGNED identity (`FaceMatch.score`, reset on an identity switch);
16488
+ * for a plate, the peak OCR read score of the best-held plate
16489
+ * (`plateText.confidence`). When BOTH a face and a plate were recognized on
16490
+ * one track the higher of the two is used. A track that ended with no
16491
+ * confident identity/plate match carries no value, so the condition fails
16492
+ * closed for it (an un-recognized subject).
16493
+ */
16494
+ minLabelConfidence: number().min(0).max(1).optional(),
16495
+ /**
16496
+ * DEVICE-EVENT only. Raw device event-type tokens (`EventFire.eventType`,
16497
+ * e.g. a doorbell `press` / `press_long`) — matched case-insensitively
16498
+ * against the token carried on the device-event subject (extracted from the
16499
+ * event-emitter runtime slice's `lastEvent.eventType`). Fails when the
16500
+ * subject carries no token. Doorbell-pulse / passive-sensor kinds emit no
16501
+ * eventType, so gate those with {@link sensorKinds} instead.
16502
+ */
16503
+ eventTypeTokens: array(string().min(1)).optional(),
16504
+ /**
16505
+ * DEVICE-EVENT only. Sensor/control taxonomy kinds (e.g. `doorbell`,
16506
+ * `contact`, `button`, `device-event`) — matched against the persisted
16507
+ * `SensorEvent.kind` (see `sensor-event-kinds.ts`). Membership is OR.
16508
+ */
16509
+ sensorKinds: array(string().min(1)).optional(),
16510
+ /**
16511
+ * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
16512
+ * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
16513
+ * when the subject's phase does not match (a subject always carries a phase
16514
+ * on the package-event trigger).
16515
+ */
16516
+ packagePhase: _enum([
16517
+ "delivered",
16518
+ "picked-up",
16519
+ "both"
16520
+ ]).optional(),
16521
+ /**
16522
+ * PERSONAL-RULE custom zones (viewer-drawn). Inline normalized polygons
16523
+ * (MaskShape vocabulary). A record passes when its bbox overlaps ANY
16524
+ * listed polygon (ZoneEngine membership semantics). Evaluated only when
16525
+ * the subject carries a bbox; absent bbox ⇒ the condition FAILS.
16526
+ */
16527
+ customZones: array(MaskPolygonShapeSchema).optional(),
16528
+ /**
16529
+ * DEVICE-EVENT only. ZoneAnalytics occupancy edge — fires when a device's
16530
+ * (optionally zone/class-scoped) occupancy count crosses the configured
16531
+ * threshold and holds for `sustainSeconds`. Fail-closed on missing
16532
+ * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
16533
+ */
16534
+ occupancy: NcOccupancyConditionSchema.optional()
16535
+ });
16536
+ /** One delivery target: a `notification-output` Target ref + passthrough params. */
16537
+ var NcRuleTargetSchema = object({
16538
+ /** `notification-output` Target id. */
16539
+ targetId: string().min(1),
16540
+ /**
16541
+ * Per-backend passthrough. Recognized keys are mapped onto the canonical
16542
+ * Notification (`priority`, `level`, `sound`, `clickUrl`, `ttl`); the
16543
+ * degrade engine drops what the backend can't render.
16544
+ */
16545
+ params: record(string(), unknown()).optional()
16546
+ });
16547
+ /**
16548
+ * Media attachment policy (P1 still-image subset).
16549
+ * - `best` — the best AVAILABLE subject image at dispatch time (D-3).
16550
+ * - `best-matching` — the media that explains WHY the rule fired: a rule
16551
+ * matched on identities attaches the subject's `faceCrop`, one matched on
16552
+ * plates attaches the `plateCrop`; a rule with no identity/plate condition
16553
+ * (or when the specific crop is missing) degrades to `best`, then
16554
+ * `keyFrame`, then no attachment — never delaying the send. The matched
16555
+ * condition summary is frozen on the outbox row at enqueue (like the rule
16556
+ * name), so the choice never drifts from the record that fired it.
16557
+ * - `keyFrame` — the clean scene frame (no subject box).
16558
+ * - `none` — no attachment.
16559
+ */
16560
+ var NcMediaPolicySchema = object({ attach: _enum([
16561
+ "best",
16562
+ "best-matching",
16563
+ "keyFrame",
16564
+ "none"
16565
+ ]).default("best") });
16566
+ /** Throttle — cooldown survives restarts (rebuilt from the outbox on boot). */
16567
+ var NcThrottleSchema = object({
16568
+ cooldownSec: number().int().min(0).max(86400).default(60),
16569
+ /** `rule` = one shared cooldown; `rule-device` = per-camera cooldown. */
16570
+ scope: _enum(["rule", "rule-device"]).default("rule-device")
16571
+ });
16572
+ /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
16573
+ var NcRuleInputSchema = object({
16574
+ name: string().min(1).max(200),
16575
+ enabled: boolean().default(true),
16576
+ delivery: NcDeliverySchema,
16577
+ conditions: NcConditionsSchema.default({}),
16578
+ schedule: NcScheduleSchema.optional(),
16579
+ targets: array(NcRuleTargetSchema).min(1),
16580
+ media: NcMediaPolicySchema.default({ attach: "best" }),
16581
+ throttle: NcThrottleSchema.default({
16582
+ cooldownSec: 60,
16583
+ scope: "rule-device"
16584
+ }),
16585
+ /** `{{var}}` templating over camera/class/label/zones/confidence/time. */
16586
+ template: object({
16587
+ title: string().max(500).optional(),
16588
+ body: string().max(2e3).optional()
16589
+ }).optional(),
16590
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
16591
+ priority: number().int().min(1).max(5).default(3),
16592
+ /**
16593
+ * Ownership/visibility key. Absent = admin/global rule (unchanged legacy
16594
+ * behaviour, visible to all, read-only in the viewer). Present = personal
16595
+ * rule owned by this userId. Server-stamped; never trusted from a client.
16596
+ */
16597
+ ownerUserId: string().optional()
16598
+ });
16599
+ /**
16600
+ * Partial patch for `updateRule` — any subset of the input fields, plus the
16601
+ * persisted-only {@link NcRuleSchema} `disabledTargetIds` set. The latter is
16602
+ * NOT a client-authored input field (it lives on the persisted rule, not the
16603
+ * input), so it is added here explicitly to let the store's per-target opt-out
16604
+ * toggle round-trip through the shared `update` path. Viewer opt-out mutations
16605
+ * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
16606
+ * `updateRule` patch.
16607
+ */
16608
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
16609
+ /** A persisted rule. */
16610
+ var NcRuleSchema = NcRuleInputSchema.extend({
16611
+ id: string(),
16612
+ /** userId of the admin who created the rule (server-stamped caller). */
16613
+ createdBy: string(),
16614
+ createdAt: number(),
16615
+ updatedAt: number(),
16616
+ /**
16617
+ * Per-target opt-out set. A targetId here is suppressed for THIS rule at
16618
+ * send time. Only a target's OWNER may add/remove its id (server-checked
16619
+ * in `nc.setRuleTargetEnabled`). Defaults to empty.
16620
+ */
16621
+ disabledTargetIds: array(string()).default([])
16622
+ });
16623
+ var NcTestResultSchema = object({
16624
+ recordId: string(),
16625
+ recordKind: _enum([
16626
+ "object-event",
16627
+ "track",
16628
+ "device-event",
16629
+ "package-event"
16630
+ ]),
16631
+ deviceId: number(),
16632
+ timestamp: number(),
16633
+ wouldFire: boolean(),
16634
+ /** Condition id that failed (first failing group), when `wouldFire` is false. */
16635
+ failedCondition: string().optional(),
16636
+ className: string().optional(),
16637
+ label: string().optional()
16638
+ });
16639
+ var NcConditionDescriptorSchema = object({
16640
+ /** Field id inside `NcConditions` (or `'schedule'` for the rule-level group). */
16223
16641
  id: string(),
16642
+ group: _enum([
16643
+ "scope",
16644
+ "class",
16645
+ "zones",
16646
+ "quality",
16647
+ "label",
16648
+ "schedule",
16649
+ "device",
16650
+ "package",
16651
+ "occupancy"
16652
+ ]),
16224
16653
  label: string(),
16225
- family: string(),
16226
- purpose: _enum(["text", "vision"]),
16227
- url: string(),
16228
- sha256: string(),
16229
- sizeBytes: number(),
16230
- quantization: string(),
16231
- /** Load-time guidance shown in the picker. */
16232
- minRamBytes: number(),
16233
- contextSizeDefault: number().int(),
16234
- /** Vision models: companion projector file. */
16235
- mmprojUrl: string().optional()
16654
+ /** Editor widget the UI renders — never hardcode per-condition forms. */
16655
+ valueType: _enum([
16656
+ "deviceIdList",
16657
+ "stringList",
16658
+ "number01",
16659
+ "number",
16660
+ "sourceSelect",
16661
+ "zoneSelection",
16662
+ "zoneIdList",
16663
+ "schedule",
16664
+ "plateMatcher",
16665
+ "packagePhase",
16666
+ "polygonDraw",
16667
+ "occupancy"
16668
+ ]),
16669
+ operator: _enum([
16670
+ "in",
16671
+ "notIn",
16672
+ "anyOf",
16673
+ "allOf",
16674
+ "gte",
16675
+ "fuzzyIn",
16676
+ "withinSchedule"
16677
+ ]),
16678
+ /** Which delivery kinds the condition applies to. */
16679
+ appliesTo: array(NcDeliverySchema),
16680
+ phase: string(),
16681
+ description: string().optional()
16236
16682
  });
16237
- var LlmRuntimeNodeSchema = object({
16238
- nodeId: string(),
16239
- reachable: boolean(),
16240
- status: LlmRuntimeStatusSchema.optional(),
16241
- disk: LlmRuntimeDiskUsageSchema.optional(),
16242
- error: string().optional()
16683
+ /**
16684
+ * The delivery lifecycle status of a history row — a straight read of the
16685
+ * durable outbox row's own status (single source of truth):
16686
+ * - `pending` — enqueued, in-flight or retrying with backoff
16687
+ * - `sent` — delivered (terminal)
16688
+ * - `dead` — dead-lettered after exhausting retries / a permanent
16689
+ * backend rejection / a deleted target (terminal; carries
16690
+ * the failure `error`)
16691
+ *
16692
+ * P1 has no `suppressed-quiet-hours` / `snoozed` states — those ride the P2
16693
+ * user dimension (quiet hours / snooze) and are additive when they land.
16694
+ */
16695
+ var NcHistoryStatusSchema = _enum([
16696
+ "pending",
16697
+ "sent",
16698
+ "dead"
16699
+ ]);
16700
+ /** The evaluated record kind a history row descends from (one per trigger). */
16701
+ var NcHistoryRecordKindSchema = _enum([
16702
+ "object-event",
16703
+ "track-end",
16704
+ "device-event",
16705
+ "package-event"
16706
+ ]);
16707
+ /** Subject summary frozen on the row at fire time (survives rule/record edits). */
16708
+ var NcHistorySubjectSchema = object({
16709
+ className: string(),
16710
+ label: string().optional(),
16711
+ confidence: number().optional(),
16712
+ zones: array(string()),
16713
+ timestamp: number()
16714
+ });
16715
+ /**
16716
+ * One delivery-history row. This is a read-only VIEW over the durable
16717
+ * outbox row (single source of truth — the same row the drain loop drives;
16718
+ * NO second write path, so history can never drift from delivery state).
16719
+ * The §3.2 fields map directly: `ruleId`/`targetId`/`deviceId` are columns,
16720
+ * `eventRef` is `recordKind`+`recordId`, `timestamps` are `createdAt`
16721
+ * (fire) / `updatedAt` (last transition), `status` + `error` are the
16722
+ * lifecycle. `ruleName` + `subject` are the intent snapshot frozen at
16723
+ * enqueue. `userId?` (per-recipient history) is P2 — no user dimension in
16724
+ * P1 (admin scope only).
16725
+ */
16726
+ var NcHistoryEntrySchema = object({
16727
+ /** Outbox row id — the stable dedup id `ruleId:dedupRef:targetId`. */
16728
+ id: string(),
16729
+ ruleId: string(),
16730
+ /** Rule name frozen at fire time (outlives a later rename / delete). */
16731
+ ruleName: string(),
16732
+ /** The rule urgency/trigger that produced this delivery. */
16733
+ delivery: NcDeliverySchema,
16734
+ targetId: string(),
16735
+ deviceId: number(),
16736
+ recordKind: NcHistoryRecordKindSchema,
16737
+ /** Event / track ref of the evaluated record (§3.2 `eventRef`). */
16738
+ recordId: string(),
16739
+ /** Present for track-scoped deliveries (object-event / track-end). */
16740
+ trackId: string().optional(),
16741
+ status: NcHistoryStatusSchema,
16742
+ /** Delivery attempts made so far. */
16743
+ attempts: number().int(),
16744
+ /** Fire time (outbox enqueue). */
16745
+ createdAt: number(),
16746
+ /** Last transition time (terminal for sent / dead). */
16747
+ updatedAt: number(),
16748
+ /** Failure detail — present on a `dead` row. */
16749
+ error: string().optional(),
16750
+ subject: NcHistorySubjectSchema
16243
16751
  });
16244
- var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
16245
- var ProfileRefInputSchema = object({
16246
- addonId: string(),
16247
- profileId: string()
16752
+ /**
16753
+ * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
16754
+ * AND; absent = unbounded on that axis. `since`/`until` bound the fire time
16755
+ * (`createdAt`, epoch ms, inclusive). `limit` is clamped to
16756
+ * {@link NC_HISTORY_LIMIT_MAX}. `userId` (per-recipient filtering) is P2.
16757
+ */
16758
+ var NcHistoryFilterSchema = object({
16759
+ ruleId: string().optional(),
16760
+ deviceId: number().optional(),
16761
+ status: NcHistoryStatusSchema.optional(),
16762
+ since: number().optional(),
16763
+ until: number().optional(),
16764
+ limit: number().int().min(1).max(500).default(100)
16248
16765
  });
16249
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
16250
- kind: "mutation",
16251
- auth: "admin"
16252
- }), method(ProfileRefInputSchema, _void(), {
16766
+ 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 }), {
16253
16767
  kind: "mutation",
16254
- auth: "admin"
16255
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
16768
+ auth: "admin",
16769
+ caller: "required"
16770
+ }), method(object({
16771
+ ruleId: string(),
16772
+ patch: NcRulePatchSchema
16773
+ }), object({ rule: NcRuleSchema }), {
16256
16774
  kind: "mutation",
16257
- auth: "admin"
16258
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
16259
- selector: LlmDefaultSelectorSchema,
16260
- profileId: string().nullable()
16261
- }), _void(), {
16775
+ auth: "admin",
16776
+ caller: "required"
16777
+ }), method(object({ ruleId: string() }), object({ success: literal(true) }), {
16262
16778
  kind: "mutation",
16263
16779
  auth: "admin"
16264
16780
  }), method(object({
16265
- since: number().optional(),
16266
- until: number().optional(),
16267
- consumer: string().optional(),
16268
- profileId: string().optional()
16269
- }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
16270
- nodeId: string(),
16271
- model: ManagedModelRefSchema
16272
- }), _void(), {
16781
+ ruleId: string(),
16782
+ enabled: boolean()
16783
+ }), object({ success: literal(true) }), {
16273
16784
  kind: "mutation",
16274
16785
  auth: "admin"
16275
16786
  }), method(object({
16276
- nodeId: string(),
16277
- file: string()
16278
- }), _void(), {
16279
- kind: "mutation",
16280
- auth: "admin"
16281
- }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
16282
- kind: "mutation",
16283
- auth: "admin"
16284
- }), method(ProfileRefInputSchema, _void(), {
16787
+ rule: NcRuleInputSchema,
16788
+ lookbackMinutes: number().int().min(1).max(1440).default(60)
16789
+ }), object({ results: array(NcTestResultSchema) }), {
16285
16790
  kind: "mutation",
16286
16791
  auth: "admin"
16287
- });
16792
+ }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
16288
16793
  /**
16289
16794
  * Zod schemas for persisted record types.
16290
16795
  *
@@ -16976,7 +17481,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
16976
17481
  }), method(object({
16977
17482
  eventId: string(),
16978
17483
  kind: MediaFileKindEnum.optional()
16979
- }), array(MediaFileSchema).readonly()), method(object({ trackId: string() }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
17484
+ }), array(MediaFileSchema).readonly()), method(object({
17485
+ trackId: string(),
17486
+ kinds: array(MediaFileKindEnum).optional()
17487
+ }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
16980
17488
  deviceId: number(),
16981
17489
  timestamp: number(),
16982
17490
  frameWidth: number(),
@@ -16997,76 +17505,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
16997
17505
  eventId: string(),
16998
17506
  timestamp: number()
16999
17507
  });
17000
- /**
17001
- * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
17002
- * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
17003
- * caps into per-camera event-kind descriptors.
17004
- *
17005
- * The descriptor DATA (color / iconId / labelKey / parentKind / category)
17006
- * is NOT duplicated here — every entry is derived from the single
17007
- * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
17008
- * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
17009
- * control cap means adding one line here (and a taxonomy entry); the anti-
17010
- * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
17011
- * eventful cap is missing.
17012
- */
17013
- /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
17014
- var LEGACY_ICON = {
17015
- motion: "motion",
17016
- audio: "audio",
17017
- person: "person",
17018
- vehicle: "vehicle",
17019
- animal: "animal",
17020
- package: "package",
17021
- door: "door",
17022
- pir: "pir",
17023
- smoke: "smoke",
17024
- water: "water",
17025
- button: "button",
17026
- generic: "generic",
17027
- gas: "smoke",
17028
- vibration: "generic",
17029
- tamper: "generic",
17030
- presence: "person",
17031
- lock: "generic",
17032
- siren: "generic",
17033
- switch: "generic",
17034
- doorbell: "button"
17035
- };
17036
- function legacyIcon(iconId) {
17037
- return LEGACY_ICON[iconId] ?? "generic";
17038
- }
17039
- /**
17040
- * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
17041
- * The anti-drift guard cross-checks this against the eventful caps declared
17042
- * in `packages/types/src/capabilities/*.cap.ts`.
17043
- */
17044
- var CAP_TO_KIND = {
17045
- contact: "contact",
17046
- motion: "motion-sensor",
17047
- smoke: "smoke",
17048
- flood: "flood",
17049
- gas: "gas",
17050
- "carbon-monoxide": "carbon-monoxide",
17051
- vibration: "vibration",
17052
- tamper: "tamper",
17053
- presence: "presence",
17054
- "enum-sensor": "enum-sensor",
17055
- "event-emitter": "device-event",
17056
- "lock-control": "lock",
17057
- switch: "switch",
17058
- button: "button",
17059
- doorbell: "doorbell"
17060
- };
17061
- function buildDescriptor(capName, kind) {
17062
- const t = EVENT_TAXONOMY[kind];
17063
- if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
17064
- return {
17065
- ...t,
17066
- icon: legacyIcon(t.iconId)
17067
- };
17068
- }
17069
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
17070
17508
  var CameraPipelineConfigSchema = object({
17071
17509
  engine: PipelineEngineChoiceSchema.optional(),
17072
17510
  steps: array(PipelineStepInputSchema).readonly(),
@@ -17552,6 +17990,76 @@ method(object({
17552
17990
  auth: "admin"
17553
17991
  });
17554
17992
  /**
17993
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
17994
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
17995
+ * caps into per-camera event-kind descriptors.
17996
+ *
17997
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
17998
+ * is NOT duplicated here — every entry is derived from the single
17999
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
18000
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
18001
+ * control cap means adding one line here (and a taxonomy entry); the anti-
18002
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
18003
+ * eventful cap is missing.
18004
+ */
18005
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
18006
+ var LEGACY_ICON = {
18007
+ motion: "motion",
18008
+ audio: "audio",
18009
+ person: "person",
18010
+ vehicle: "vehicle",
18011
+ animal: "animal",
18012
+ package: "package",
18013
+ door: "door",
18014
+ pir: "pir",
18015
+ smoke: "smoke",
18016
+ water: "water",
18017
+ button: "button",
18018
+ generic: "generic",
18019
+ gas: "smoke",
18020
+ vibration: "generic",
18021
+ tamper: "generic",
18022
+ presence: "person",
18023
+ lock: "generic",
18024
+ siren: "generic",
18025
+ switch: "generic",
18026
+ doorbell: "button"
18027
+ };
18028
+ function legacyIcon(iconId) {
18029
+ return LEGACY_ICON[iconId] ?? "generic";
18030
+ }
18031
+ /**
18032
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
18033
+ * The anti-drift guard cross-checks this against the eventful caps declared
18034
+ * in `packages/types/src/capabilities/*.cap.ts`.
18035
+ */
18036
+ var CAP_TO_KIND = {
18037
+ contact: "contact",
18038
+ motion: "motion-sensor",
18039
+ smoke: "smoke",
18040
+ flood: "flood",
18041
+ gas: "gas",
18042
+ "carbon-monoxide": "carbon-monoxide",
18043
+ vibration: "vibration",
18044
+ tamper: "tamper",
18045
+ presence: "presence",
18046
+ "enum-sensor": "enum-sensor",
18047
+ "event-emitter": "device-event",
18048
+ "lock-control": "lock",
18049
+ switch: "switch",
18050
+ button: "button",
18051
+ doorbell: "doorbell"
18052
+ };
18053
+ function buildDescriptor(capName, kind) {
18054
+ const t = EVENT_TAXONOMY[kind];
18055
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
18056
+ return {
18057
+ ...t,
18058
+ icon: legacyIcon(t.iconId)
18059
+ };
18060
+ }
18061
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
18062
+ /**
17555
18063
  * server-management — per-NODE singleton capability for a node's ROOT
17556
18064
  * package lifecycle (runtime-updatable node packages).
17557
18065
  *
@@ -19006,7 +19514,28 @@ var FaceInfoSchema = object({
19006
19514
  * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`). Absent when the
19007
19515
  * track produced no key frame (e.g. native/onboard source) — the UI falls
19008
19516
  * back to the inline `base64` face crop. */
19009
- keyFrameMediaKey: string().optional()
19517
+ keyFrameMediaKey: string().optional(),
19518
+ /** Winning identity-match cosine (0..1) for this face's track, when an
19519
+ * identity was auto-confirmed. Lets the UI surface WHY a face was assigned
19520
+ * (confidence badge / low-confidence audit). Absent on legacy rows and on
19521
+ * faces that were never auto-recognized. */
19522
+ bestMatchScore: number().optional(),
19523
+ /** Native-scale face short side (px) at recognition time, when the runner
19524
+ * measured it. Lets the UI flag low-resolution auto-assignments. Absent on
19525
+ * legacy rows / runners that reported no native measure. */
19526
+ nativeFaceShortSidePx: number().optional(),
19527
+ /** SUGGESTED identity for this face — a plausible-but-not-confident match that
19528
+ * MISSED auto-assignment (cosine in the suggestion band, or above threshold
19529
+ * but blocked only by the recognition size floor). Mutually exclusive with
19530
+ * `recognizedIdentityId` (a suggestion is NEVER an assignment): the face stays
19531
+ * UNASSIGNED and everything else keeps treating it as unrecognized — the UI
19532
+ * merely offers a one-tap "is this <name>?" confirm. Absent on legacy rows and
19533
+ * on faces that were auto-assigned or below the suggestion band. (2026-07-24) */
19534
+ suggestedIdentityId: string().optional(),
19535
+ /** Peak identity-match cosine (0..1) for `suggestedIdentityId`, captured at the
19536
+ * same moment as `bestMatchScore` (track peak, at close). Lets the UI rank /
19537
+ * badge suggestion confidence. Present iff `suggestedIdentityId` is. (2026-07-24) */
19538
+ suggestedMatchScore: number().optional()
19010
19539
  });
19011
19540
  var FaceFilterEnum = _enum([
19012
19541
  "unassigned",
@@ -21049,36 +21578,6 @@ Object.freeze({
21049
21578
  addonId: null,
21050
21579
  access: "view"
21051
21580
  },
21052
- "advancedNotifier.deleteRule": {
21053
- capName: "advanced-notifier",
21054
- capScope: "system",
21055
- addonId: null,
21056
- access: "delete"
21057
- },
21058
- "advancedNotifier.getHistory": {
21059
- capName: "advanced-notifier",
21060
- capScope: "system",
21061
- addonId: null,
21062
- access: "view"
21063
- },
21064
- "advancedNotifier.getRules": {
21065
- capName: "advanced-notifier",
21066
- capScope: "system",
21067
- addonId: null,
21068
- access: "view"
21069
- },
21070
- "advancedNotifier.testRule": {
21071
- capName: "advanced-notifier",
21072
- capScope: "system",
21073
- addonId: null,
21074
- access: "create"
21075
- },
21076
- "advancedNotifier.upsertRule": {
21077
- capName: "advanced-notifier",
21078
- capScope: "system",
21079
- addonId: null,
21080
- access: "create"
21081
- },
21082
21581
  "alarmPanel.arm": {
21083
21582
  capName: "alarm-panel",
21084
21583
  capScope: "device",
@@ -23383,6 +23882,60 @@ Object.freeze({
23383
23882
  addonId: null,
23384
23883
  access: "create"
23385
23884
  },
23885
+ "notificationRules.createRule": {
23886
+ capName: "notification-rules",
23887
+ capScope: "system",
23888
+ addonId: null,
23889
+ access: "create"
23890
+ },
23891
+ "notificationRules.deleteRule": {
23892
+ capName: "notification-rules",
23893
+ capScope: "system",
23894
+ addonId: null,
23895
+ access: "delete"
23896
+ },
23897
+ "notificationRules.getConditionCatalog": {
23898
+ capName: "notification-rules",
23899
+ capScope: "system",
23900
+ addonId: null,
23901
+ access: "view"
23902
+ },
23903
+ "notificationRules.getHistory": {
23904
+ capName: "notification-rules",
23905
+ capScope: "system",
23906
+ addonId: null,
23907
+ access: "view"
23908
+ },
23909
+ "notificationRules.getRule": {
23910
+ capName: "notification-rules",
23911
+ capScope: "system",
23912
+ addonId: null,
23913
+ access: "view"
23914
+ },
23915
+ "notificationRules.listRules": {
23916
+ capName: "notification-rules",
23917
+ capScope: "system",
23918
+ addonId: null,
23919
+ access: "view"
23920
+ },
23921
+ "notificationRules.setRuleEnabled": {
23922
+ capName: "notification-rules",
23923
+ capScope: "system",
23924
+ addonId: null,
23925
+ access: "create"
23926
+ },
23927
+ "notificationRules.testRule": {
23928
+ capName: "notification-rules",
23929
+ capScope: "system",
23930
+ addonId: null,
23931
+ access: "create"
23932
+ },
23933
+ "notificationRules.updateRule": {
23934
+ capName: "notification-rules",
23935
+ capScope: "system",
23936
+ addonId: null,
23937
+ access: "create"
23938
+ },
23386
23939
  "notifier.cancel": {
23387
23940
  capName: "notifier",
23388
23941
  capScope: "device",