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