@camstack/addon-smtp-nodemailer 1.2.3 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,7 +34,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
34
34
  var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
35
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
36
36
  //#endregion
37
- //#region ../types/dist/event-category-D4HJq7Mw.mjs
37
+ //#region ../types/dist/event-category-BLcNejAE.mjs
38
38
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
39
39
  EventCategory["SystemBoot"] = "system.boot";
40
40
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -184,9 +184,6 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
184
184
  EventCategory["RecordingSegmentWritten"] = "recording.segment.written";
185
185
  EventCategory["RecordingPolicyFallback"] = "recording.policy.fallback";
186
186
  EventCategory["RecordingRetentionCompleted"] = "recording.retention.completed";
187
- /** Runner-sampled scrub thumbnail (~1/5 s/camera). Telemetry (D8): a lost
188
- * thumb is a scrub gap the recorder's keyframe backfill covers. */
189
- EventCategory["RecordingThumbSampled"] = "recording.thumb-sampled";
190
187
  /** Export render progress (0–100). Telemetry (D8): a lost tick is a stale
191
188
  * progress bar the client reconciles via `recordingExport.getExport`. */
192
189
  EventCategory["RecordingExportProgress"] = "recording.export.progress";
@@ -6851,7 +6848,6 @@ object({ deviceId: number() }), object({ deviceId: number() }), object({
6851
6848
  patch: record(string(), unknown())
6852
6849
  }), object({ success: literal(true) });
6853
6850
  object({ deviceId: number() }), unknown().nullable();
6854
- /** Shorthand to define a method schema */
6855
6851
  function method(input, output, options) {
6856
6852
  return {
6857
6853
  input,
@@ -6859,6 +6855,7 @@ function method(input, output, options) {
6859
6855
  kind: options?.kind ?? "query",
6860
6856
  auth: options?.auth ?? "protected",
6861
6857
  ...options?.access !== void 0 ? { access: options.access } : {},
6858
+ ...options?.caller !== void 0 ? { caller: options.caller } : {},
6862
6859
  timeoutMs: options?.timeoutMs
6863
6860
  };
6864
6861
  }
@@ -8212,6 +8209,59 @@ for (const l of AUDIO_MACRO_LABELS) {
8212
8209
  /** The complete taxonomy dictionary, keyed by kind. */
8213
8210
  var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
8214
8211
  /**
8212
+ * Notification-Center taxonomy — the fixed vocabulary the NC rule editor
8213
+ * offers as pickers instead of free text. Derived (never hand-listed) from the
8214
+ * single `EVENT_TAXONOMY` dictionary so it stays in lockstep with every other
8215
+ * taxonomy surface (timeline, filters, event page).
8216
+ *
8217
+ * Three buckets, mapped onto the rule editor's `stringList` conditions:
8218
+ * - `videoClasses` → detection classes (person / vehicle / animal + subs)
8219
+ * for the `classes` / `classesExclude` conditions.
8220
+ * - `audioKinds` → audio-analyzer sub kinds (`audio-scream`, …) shown in
8221
+ * the same class picker, grouped under an Audio header.
8222
+ * - `labels` → sensor + control taxonomy kinds (doorbell / contact /
8223
+ * lock / …) for the `sensorKinds` device-event condition.
8224
+ *
8225
+ * Each entry carries `parentKind` so the client can group video subs under
8226
+ * their macro and sensor/control kinds under their category. This surface is
8227
+ * served ADDITIVELY on the `nc.getConditionCatalog` bridge response — no cap
8228
+ * method, no codegen — so it ships train-free with an addon deploy.
8229
+ */
8230
+ /** One selectable taxonomy value: a stable kind id + display label + parent. */
8231
+ var NcTaxonomyEntrySchema = object({
8232
+ /** Stable kind id (e.g. 'person', 'car', 'audio-scream', 'doorbell'). */
8233
+ kind: string(),
8234
+ /** English fallback label (the UI translates via the event-kind i18n key). */
8235
+ label: string(),
8236
+ /** Macro/category parent for grouping ('car' → 'vehicle'); null for a top. */
8237
+ parentKind: string().nullable()
8238
+ });
8239
+ object({
8240
+ videoClasses: array(NcTaxonomyEntrySchema),
8241
+ audioKinds: array(NcTaxonomyEntrySchema),
8242
+ labels: array(NcTaxonomyEntrySchema)
8243
+ });
8244
+ function toEntry(kind, label, parentKind) {
8245
+ return {
8246
+ kind,
8247
+ label,
8248
+ parentKind
8249
+ };
8250
+ }
8251
+ /**
8252
+ * Build the NC taxonomy from `EVENT_TAXONOMY`. Insertion order is preserved
8253
+ * (macros before their subs), which the client relies on for stable grouping.
8254
+ */
8255
+ function buildNcTaxonomy() {
8256
+ const all = Object.values(EVENT_TAXONOMY);
8257
+ return {
8258
+ videoClasses: all.filter((e) => e.category === "detection").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8259
+ audioKinds: all.filter((e) => e.category === "audio" && e.level === "sub").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8260
+ labels: all.filter((e) => e.category === "sensor" || e.category === "control").map((e) => toEntry(e.kind, e.label, e.parentKind))
8261
+ };
8262
+ }
8263
+ Object.freeze(buildNcTaxonomy());
8264
+ /**
8215
8265
  * Error types for the safe expression engine. Two distinct classes so callers
8216
8266
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
8217
8267
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -10920,6 +10970,22 @@ var CameraMetricsSchema = object({
10920
10970
  ])
10921
10971
  });
10922
10972
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
10973
+ /**
10974
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
10975
+ * within the frame, so the executor can re-cut a leaf child ROI at native
10976
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
10977
+ */
10978
+ var NativeCropRefSchema = object({
10979
+ /** Handle keying the retained native surface (node-pinned to its owner). */
10980
+ handle: FrameHandleSchema,
10981
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
10982
+ cropFrameSpace: object({
10983
+ x: number(),
10984
+ y: number(),
10985
+ w: number(),
10986
+ h: number()
10987
+ })
10988
+ });
10923
10989
  var ModelFormatSchema$1 = _enum([
10924
10990
  "onnx",
10925
10991
  "coreml",
@@ -11195,7 +11261,22 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
11195
11261
  * Omitted ⇒ the runner's default device (current single-engine
11196
11262
  * behaviour). Selects WHICH device pool of the node runs the call.
11197
11263
  */
11198
- deviceKey: string().optional()
11264
+ deviceKey: string().optional(),
11265
+ /**
11266
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
11267
+ * when the parent crop was resolved from the frame's retained NATIVE
11268
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
11269
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
11270
+ * resolution from that surface — the SAME quality path faces already
11271
+ * had — instead of the downscaled parent tile. `handle` keys the native
11272
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
11273
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
11274
+ * the executor's crop-normalized child ROI back into frame-normalized
11275
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
11276
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
11277
+ * (today's behaviour on the fallback path).
11278
+ */
11279
+ nativeCropRef: NativeCropRefSchema.optional()
11199
11280
  }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
11200
11281
  engine: PipelineEngineChoiceSchema.optional(),
11201
11282
  steps: array(PipelineStepInputSchema).min(1),
@@ -11411,7 +11492,11 @@ var DetailResultSchema = object({
11411
11492
  bbox: NativeCropBboxSchema.optional(),
11412
11493
  embedding: string().optional(),
11413
11494
  label: string().optional(),
11414
- alignedCropJpeg: string().optional()
11495
+ alignedCropJpeg: string().optional(),
11496
+ /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
11497
+ * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
11498
+ * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
11499
+ nativeFaceShortSidePx: number().optional()
11415
11500
  });
11416
11501
  /**
11417
11502
  * Per-camera tunable ranges + defaults. Single source of truth used
@@ -11425,6 +11510,12 @@ var motionCooldownMsField = {
11425
11510
  default: 3e4,
11426
11511
  step: 500
11427
11512
  };
11513
+ var maxSessionHoldMsField = {
11514
+ min: 0,
11515
+ max: 6e5,
11516
+ default: 12e4,
11517
+ step: 5e3
11518
+ };
11428
11519
  var motionFpsField = {
11429
11520
  min: 1,
11430
11521
  max: 30,
@@ -11572,6 +11663,19 @@ var RunnerCameraConfigSchema = object({
11572
11663
  "on-motion"
11573
11664
  ]).default("always-on"),
11574
11665
  motionCooldownMs: number().min(motionCooldownMsField.min).default(motionCooldownMsField.default),
11666
+ /**
11667
+ * Orchestrator-side on-motion session-hold cap (ms). While an on-motion
11668
+ * detection session is active and ≥1 confirmed non-stationary track is
11669
+ * still live, the orchestrator keeps the session open past
11670
+ * `motionCooldownMs` (a slowly-moving subject can stop re-triggering the
11671
+ * camera's VMD yet is still being tracked frame-to-frame) — up to this many
11672
+ * ms since the session opened, after which it closes regardless. `0`
11673
+ * disables the hold (legacy cooldown-only teardown). Not consumed by the
11674
+ * runner itself — carried here so it shares the per-camera device-settings
11675
+ * surface with `motionCooldownMs`; the orchestrator reads it off the
11676
+ * resolved `CameraDetectionConfig`.
11677
+ */
11678
+ maxSessionHoldMs: number().min(maxSessionHoldMsField.min).max(maxSessionHoldMsField.max).optional(),
11575
11679
  motionFps: number().min(motionFpsField.min).max(motionFpsField.max).default(motionFpsField.default),
11576
11680
  detectionFps: number().min(detectionFpsField.min).max(detectionFpsField.max).default(detectionFpsField.default),
11577
11681
  motionStreamId: string(),
@@ -11661,7 +11765,7 @@ var RunnerCameraConfigSchema = object({
11661
11765
  */
11662
11766
  inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
11663
11767
  });
11664
- 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;
11768
+ 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;
11665
11769
  /**
11666
11770
  * Runtime load summary returned by `getLocalLoad`. Used by the orchestrator's
11667
11771
  * load-balancing levels (L2 capacity-based, L3 hardware-aware) to decide
@@ -13515,94 +13619,6 @@ var EnrichedWidgetMetadataSchema = WidgetMetadataSchema.extend({
13515
13619
  bundleUrl: string()
13516
13620
  });
13517
13621
  method(_void(), array(EnrichedWidgetMetadataSchema).readonly());
13518
- var NotificationRuleConditionsSchema = object({
13519
- deviceIds: array(number()).readonly().optional(),
13520
- classNames: array(string()).readonly().optional(),
13521
- zoneIds: array(string()).readonly().optional(),
13522
- minConfidence: number().optional(),
13523
- source: _enum([
13524
- "pipeline",
13525
- "onboard",
13526
- "any"
13527
- ]).optional(),
13528
- schedule: object({
13529
- days: array(number()).readonly(),
13530
- startHour: number(),
13531
- endHour: number()
13532
- }).optional(),
13533
- cooldownSeconds: number().optional(),
13534
- minDwellSeconds: number().optional(),
13535
- /** Match against `event.data.eventType` token (e.g. `'press_long'`). When non-empty, only events
13536
- * carrying a matching `data.eventType` string pass this condition. Rules without this field are
13537
- * unaffected (back-compat). Distinct from `rule.eventTypes` which holds EventCategory strings. */
13538
- eventTypeTokens: array(string()).readonly().optional(),
13539
- /** Match detections whose CLIP image embedding is semantically similar to this free-text
13540
- * description. Requires the embedding-encoder cap to have pre-warmed the text vector.
13541
- * `minSimilarity` is the cosine similarity threshold in [0, 1]. */
13542
- clipDescription: object({
13543
- text: string().min(1),
13544
- minSimilarity: number().min(0).max(1)
13545
- }).optional(),
13546
- /** Match events whose recognized-entity label (face identity name or plate
13547
- * vehicle name, propagated onto `event.data.label`) is one of these values.
13548
- * Empty/absent → unaffected (back-compat). Enables "notify me when <named
13549
- * vehicle/person> is seen". */
13550
- labels: array(string()).readonly().optional()
13551
- });
13552
- var NotificationRuleTemplateSchema = object({
13553
- title: string(),
13554
- body: string(),
13555
- imageMode: _enum([
13556
- "crop",
13557
- "annotated",
13558
- "full",
13559
- "none"
13560
- ])
13561
- });
13562
- var NotificationRuleSchema = object({
13563
- id: string(),
13564
- name: string(),
13565
- enabled: boolean(),
13566
- eventTypes: array(string()).readonly(),
13567
- conditions: NotificationRuleConditionsSchema,
13568
- outputs: array(string()).readonly(),
13569
- template: NotificationRuleTemplateSchema.optional(),
13570
- priority: _enum([
13571
- "low",
13572
- "normal",
13573
- "high",
13574
- "critical"
13575
- ])
13576
- });
13577
- var NotificationTestResultSchema = object({
13578
- ruleId: string(),
13579
- eventId: string(),
13580
- timestamp: number(),
13581
- wouldFire: boolean(),
13582
- reason: string().optional()
13583
- });
13584
- var NotificationHistoryEntrySchema = object({
13585
- id: string(),
13586
- ruleId: string(),
13587
- ruleName: string(),
13588
- eventId: string(),
13589
- timestamp: number(),
13590
- outputs: array(string()).readonly(),
13591
- success: boolean(),
13592
- error: string().optional(),
13593
- deviceId: number().optional()
13594
- });
13595
- var NotificationHistoryFilterSchema = object({
13596
- ruleId: string().optional(),
13597
- deviceId: number().optional(),
13598
- from: number().optional(),
13599
- to: number().optional(),
13600
- limit: number().optional()
13601
- });
13602
- 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({
13603
- ruleId: string(),
13604
- lookbackMinutes: number()
13605
- }), object({ results: array(NotificationTestResultSchema).readonly() }), { kind: "mutation" }), method(object({ filter: NotificationHistoryFilterSchema.optional() }), object({ entries: array(NotificationHistoryEntrySchema).readonly() }));
13606
13622
  /**
13607
13623
  * Alerts capability — collection-based internal alert system.
13608
13624
  *
@@ -13789,89 +13805,6 @@ method(object({
13789
13805
  password: string()
13790
13806
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
13791
13807
  /**
13792
- * `login-method` — collection cap through which auth addons contribute
13793
- * their pre-auth login surfaces to the login page. This is the SINGLE,
13794
- * generic mechanism that supersedes the dead `auth.listProviders` reader:
13795
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
13796
- * `login-method` provider and the PUBLIC `auth.listLoginMethods`
13797
- * procedure aggregates them for the unauthenticated login page.
13798
- *
13799
- * A contribution is a discriminated union on `kind`:
13800
- *
13801
- * - `redirect` — a declarative button. The login page renders a generic
13802
- * button that navigates to `startUrl` (an addon-owned HTTP route).
13803
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
13804
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
13805
- * login page needs NO change.
13806
- *
13807
- * - `widget` — a Module-Federation widget the login page mounts (via
13808
- * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
13809
- * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
13810
- * mechanism kept for future use; no shipped addon uses it on the login
13811
- * page (the passkey ceremony below runs natively in the shell instead).
13812
- *
13813
- * - `passkey` — a declarative WebAuthn ceremony the shell renders
13814
- * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
13815
- * a remotely-loaded bundle). Carries the addon's effective `rpId` /
13816
- * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
13817
- * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
13818
- * fetching any remote code pre-auth. Contribution stays unconditional —
13819
- * enrollment state is never leaked pre-auth; visibility is a shell
13820
- * decision.
13821
- *
13822
- * Every contribution carries a `stage`:
13823
- * - `primary` — shown on the first credentials screen (OIDC /
13824
- * magic-link buttons; a future usernameless passkey).
13825
- * - `second-factor` — shown AFTER the password leg, gated on the
13826
- * returned `factors` (passkey-as-2FA today).
13827
- *
13828
- * `mount: skip` — the cap is read server-side by the core auth router
13829
- * (`registry.getCollection('login-method')`), never mounted as its own
13830
- * tRPC router.
13831
- */
13832
- /** When a login method renders in the two-phase login flow. */
13833
- var LoginStageEnum = _enum(["primary", "second-factor"]);
13834
- /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
13835
- var LoginMethodContributionSchema = discriminatedUnion("kind", [
13836
- object({
13837
- kind: literal("redirect"),
13838
- /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
13839
- id: string(),
13840
- /** Operator-facing button label. */
13841
- label: string(),
13842
- /** lucide-react icon name. */
13843
- icon: string().optional(),
13844
- /** Addon-owned HTTP route the button navigates to (GET). */
13845
- startUrl: string(),
13846
- stage: LoginStageEnum
13847
- }),
13848
- object({
13849
- kind: literal("widget"),
13850
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
13851
- id: string(),
13852
- /** Owning addon id — drives the public bundle URL + the MF namespace. */
13853
- addonId: string(),
13854
- /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
13855
- bundle: string(),
13856
- /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
13857
- remote: WidgetRemoteSchema,
13858
- stage: LoginStageEnum
13859
- }),
13860
- object({
13861
- kind: literal("passkey"),
13862
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
13863
- id: string(),
13864
- /** Operator-facing button label. */
13865
- label: string(),
13866
- stage: LoginStageEnum,
13867
- /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
13868
- rpId: string(),
13869
- /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
13870
- origin: string().nullable()
13871
- })
13872
- ]);
13873
- method(_void(), array(LoginMethodContributionSchema).readonly());
13874
- /**
13875
13808
  * Orchestrator-side destination metadata. The orchestrator computes
13876
13809
  * `id = <addonId>:<subId>` from its provider lookup so consumers
13877
13810
  * (admin UI, restore flow) see one canonical key.
@@ -15215,48 +15148,423 @@ method(_void(), array(string()).readonly(), { auth: "admin" }), method(object({
15215
15148
  kind: "mutation",
15216
15149
  auth: "admin"
15217
15150
  });
15218
- var LogLevelSchema = _enum([
15219
- "debug",
15220
- "info",
15221
- "warn",
15222
- "error"
15151
+ /**
15152
+ * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
15153
+ * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15154
+ * caps stay wire-compatible without a circular cap→cap import.
15155
+ *
15156
+ * Errors are a discriminated-union RESULT, never thrown: the shape survives
15157
+ * every transport tier structurally, and failed calls still write usage rows.
15158
+ * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
15159
+ */
15160
+ var LlmUsageSchema = object({
15161
+ inputTokens: number(),
15162
+ outputTokens: number()
15163
+ });
15164
+ var LlmErrorCodeSchema = _enum([
15165
+ "timeout",
15166
+ "rate-limited",
15167
+ "auth",
15168
+ "refusal",
15169
+ "bad-request",
15170
+ "unavailable",
15171
+ "no-profile",
15172
+ "budget-exceeded",
15173
+ "adapter-error"
15223
15174
  ]);
15224
- var LogEntrySchema = object({
15225
- timestamp: date(),
15226
- level: LogLevelSchema,
15227
- scope: array(string()),
15175
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
15176
+ ok: literal(true),
15177
+ text: string(),
15178
+ model: string(),
15179
+ usage: LlmUsageSchema,
15180
+ truncated: boolean(),
15181
+ latencyMs: number()
15182
+ }), object({
15183
+ ok: literal(false),
15184
+ code: LlmErrorCodeSchema,
15228
15185
  message: string(),
15229
- meta: record(string(), unknown()).optional(),
15230
- tags: record(string(), string()).optional()
15231
- });
15232
- method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
15233
- scope: array(string()).optional(),
15234
- level: LogLevelSchema.optional(),
15235
- since: date().optional(),
15236
- until: date().optional(),
15237
- limit: number().optional(),
15238
- tags: record(string(), string()).optional()
15239
- }), array(LogEntrySchema).readonly());
15240
- var CpuBreakdownSchema = object({
15241
- total: number(),
15242
- user: number(),
15243
- system: number(),
15244
- irq: number(),
15245
- nice: number(),
15246
- loadAvg: tuple([
15247
- number(),
15248
- number(),
15249
- number()
15250
- ]),
15251
- cores: number()
15186
+ retryAfterMs: number().optional()
15187
+ })]);
15188
+ /**
15189
+ * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
15190
+ * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
15191
+ * notification-output.cap.ts:27-31 precedents).
15192
+ */
15193
+ var LlmImageSchema = object({
15194
+ bytes: _instanceof(Uint8Array),
15195
+ mimeType: string()
15252
15196
  });
15253
- var MemoryInfoSchema = object({
15254
- percent: number(),
15255
- totalBytes: number(),
15256
- usedBytes: number(),
15257
- availableBytes: number(),
15258
- swapUsedBytes: number(),
15259
- swapTotalBytes: number()
15197
+ var LlmGenerateBaseInputSchema = object({
15198
+ /** Collection routing (the notification-output posture). */
15199
+ addonId: string().optional(),
15200
+ /** Explicit profile; else the resolution chain (spec §3). */
15201
+ profileId: string().optional(),
15202
+ /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
15203
+ consumer: string(),
15204
+ system: string().optional(),
15205
+ /** v1: single-turn. `messages[]` is a v2 additive field. */
15206
+ prompt: string(),
15207
+ /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
15208
+ jsonSchema: record(string(), unknown()).optional(),
15209
+ /** Per-call override of the profile default. */
15210
+ maxTokens: number().int().positive().optional(),
15211
+ temperature: number().optional()
15212
+ });
15213
+ /**
15214
+ * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
15215
+ * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
15216
+ * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
15217
+ * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
15218
+ * this only through the `llm` cap's methods.
15219
+ *
15220
+ * One running llama-server child per node in v1 (models are RAM-heavy).
15221
+ * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
15222
+ * watchdog — operator decision #3).
15223
+ */
15224
+ var ManagedModelRefSchema = discriminatedUnion("kind", [
15225
+ object({
15226
+ kind: literal("catalog"),
15227
+ catalogId: string()
15228
+ }),
15229
+ object({
15230
+ kind: literal("url"),
15231
+ url: string(),
15232
+ sha256: string().optional()
15233
+ }),
15234
+ object({
15235
+ kind: literal("path"),
15236
+ path: string()
15237
+ })
15238
+ ]);
15239
+ var ManagedRuntimeConfigSchema = object({
15240
+ /** WHERE the runtime lives — hub or any agent. */
15241
+ nodeId: string(),
15242
+ /** Closed for v1; 'ollama' is a v2 candidate. */
15243
+ engine: _enum(["llama-cpp"]),
15244
+ model: ManagedModelRefSchema,
15245
+ contextSize: number().int().default(4096),
15246
+ /** 0 = CPU-only. */
15247
+ gpuLayers: number().int().default(0),
15248
+ /** Default: cpus-2, clamped ≥1 (resolved node-side). */
15249
+ threads: number().int().optional(),
15250
+ /** Concurrent slots. */
15251
+ parallel: number().int().default(1),
15252
+ /** Else lazy: first generate boots it. */
15253
+ autoStart: boolean().default(false),
15254
+ /** 0 = never; frees RAM after quiet periods. */
15255
+ idleStopMinutes: number().int().default(30)
15256
+ });
15257
+ var LlmRuntimeStatusSchema = object({
15258
+ /** Status is ALWAYS node-qualified. */
15259
+ nodeId: string(),
15260
+ state: _enum([
15261
+ "stopped",
15262
+ "downloading",
15263
+ "starting",
15264
+ "ready",
15265
+ "crashed",
15266
+ "failed"
15267
+ ]),
15268
+ pid: number().optional(),
15269
+ port: number().optional(),
15270
+ modelPath: string().optional(),
15271
+ modelId: string().optional(),
15272
+ downloadProgress: number().min(0).max(1).optional(),
15273
+ lastError: string().optional(),
15274
+ crashesInWindow: number(),
15275
+ /** Child RSS (sampled best-effort). */
15276
+ memoryBytes: number().optional(),
15277
+ vramBytes: number().optional()
15278
+ });
15279
+ var LlmNodeModelSchema = object({
15280
+ file: string(),
15281
+ sizeBytes: number(),
15282
+ catalogId: string().optional(),
15283
+ installedAt: number().optional()
15284
+ });
15285
+ var LlmRuntimeDiskUsageSchema = object({
15286
+ nodeId: string(),
15287
+ modelsBytes: number(),
15288
+ freeBytes: number().optional()
15289
+ });
15290
+ method(LlmGenerateBaseInputSchema.extend({
15291
+ images: array(LlmImageSchema).optional(),
15292
+ runtime: ManagedRuntimeConfigSchema,
15293
+ /** The managed profile's timeout, threaded by the hub provider. */
15294
+ timeoutMs: number().int().positive().optional()
15295
+ }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
15296
+ kind: "mutation",
15297
+ auth: "admin"
15298
+ }), method(object({}), _void(), {
15299
+ kind: "mutation",
15300
+ auth: "admin"
15301
+ }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
15302
+ kind: "mutation",
15303
+ auth: "admin"
15304
+ }), method(object({ file: string() }), _void(), {
15305
+ kind: "mutation",
15306
+ auth: "admin"
15307
+ }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
15308
+ /**
15309
+ * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
15310
+ * methods concat-fan across providers; single-row methods route to ONE
15311
+ * provider by the `addonId` in the call input (the notification-output
15312
+ * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
15313
+ * (hub-placed); the cap stays open for future providers.
15314
+ *
15315
+ * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
15316
+ * `apiKey` is a password field — providers REDACT it on read and merge on
15317
+ * write; a stored key NEVER round-trips to a client.
15318
+ */
15319
+ var LlmProfileKindSchema = _enum([
15320
+ "openai-compatible",
15321
+ "openai",
15322
+ "anthropic",
15323
+ "google",
15324
+ "managed-local"
15325
+ ]);
15326
+ var LlmProfileSchema = object({
15327
+ id: string(),
15328
+ name: string(),
15329
+ kind: LlmProfileKindSchema,
15330
+ /** Stamped by the provider — keeps the fanned catalog routable. */
15331
+ addonId: string(),
15332
+ enabled: boolean(),
15333
+ /** Vendor model id, or the managed runtime's loaded model. */
15334
+ model: string(),
15335
+ /** Required for openai-compatible; override for cloud kinds. */
15336
+ baseUrl: string().optional(),
15337
+ /** ConfigUISchema type:'password' — never round-trips (spec §5). */
15338
+ apiKey: string().optional(),
15339
+ supportsVision: boolean(),
15340
+ temperature: number().min(0).max(2).optional(),
15341
+ maxTokens: number().int().positive().optional(),
15342
+ timeoutMs: number().int().positive().default(6e4),
15343
+ extraHeaders: record(string(), string()).optional(),
15344
+ /** kind === 'managed-local' only (spec §4). */
15345
+ runtime: ManagedRuntimeConfigSchema.optional()
15346
+ });
15347
+ /** ConfigUISchema tree passed through untyped on the wire (the
15348
+ * notification-output `ConfigSchemaPassthrough` precedent at
15349
+ * notification-output.cap.ts:151); the exported TS type re-tightens it. */
15350
+ var ConfigSchemaPassthrough$1 = unknown();
15351
+ var LlmProfileKindDescriptorSchema = object({
15352
+ kind: LlmProfileKindSchema,
15353
+ label: string(),
15354
+ icon: string(),
15355
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
15356
+ addonId: string(),
15357
+ configSchema: ConfigSchemaPassthrough$1
15358
+ });
15359
+ var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
15360
+ var LlmDefaultSchema = object({
15361
+ selector: LlmDefaultSelectorSchema,
15362
+ profileId: string()
15363
+ });
15364
+ /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
15365
+ var LlmUsageRollupSchema = object({
15366
+ day: string(),
15367
+ consumer: string(),
15368
+ profileId: string(),
15369
+ calls: number(),
15370
+ okCalls: number(),
15371
+ errorCalls: number(),
15372
+ inputTokens: number(),
15373
+ outputTokens: number(),
15374
+ avgLatencyMs: number()
15375
+ });
15376
+ /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
15377
+ var ManagedModelCatalogEntrySchema = object({
15378
+ id: string(),
15379
+ label: string(),
15380
+ family: string(),
15381
+ purpose: _enum(["text", "vision"]),
15382
+ url: string(),
15383
+ sha256: string(),
15384
+ sizeBytes: number(),
15385
+ quantization: string(),
15386
+ /** Load-time guidance shown in the picker. */
15387
+ minRamBytes: number(),
15388
+ contextSizeDefault: number().int(),
15389
+ /** Vision models: companion projector file. */
15390
+ mmprojUrl: string().optional()
15391
+ });
15392
+ var LlmRuntimeNodeSchema = object({
15393
+ nodeId: string(),
15394
+ reachable: boolean(),
15395
+ status: LlmRuntimeStatusSchema.optional(),
15396
+ disk: LlmRuntimeDiskUsageSchema.optional(),
15397
+ error: string().optional()
15398
+ });
15399
+ var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
15400
+ var ProfileRefInputSchema = object({
15401
+ addonId: string(),
15402
+ profileId: string()
15403
+ });
15404
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
15405
+ kind: "mutation",
15406
+ auth: "admin"
15407
+ }), method(ProfileRefInputSchema, _void(), {
15408
+ kind: "mutation",
15409
+ auth: "admin"
15410
+ }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
15411
+ kind: "mutation",
15412
+ auth: "admin"
15413
+ }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
15414
+ selector: LlmDefaultSelectorSchema,
15415
+ profileId: string().nullable()
15416
+ }), _void(), {
15417
+ kind: "mutation",
15418
+ auth: "admin"
15419
+ }), method(object({
15420
+ since: number().optional(),
15421
+ until: number().optional(),
15422
+ consumer: string().optional(),
15423
+ profileId: string().optional()
15424
+ }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
15425
+ nodeId: string(),
15426
+ model: ManagedModelRefSchema
15427
+ }), _void(), {
15428
+ kind: "mutation",
15429
+ auth: "admin"
15430
+ }), method(object({
15431
+ nodeId: string(),
15432
+ file: string()
15433
+ }), _void(), {
15434
+ kind: "mutation",
15435
+ auth: "admin"
15436
+ }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
15437
+ kind: "mutation",
15438
+ auth: "admin"
15439
+ }), method(ProfileRefInputSchema, _void(), {
15440
+ kind: "mutation",
15441
+ auth: "admin"
15442
+ });
15443
+ var LogLevelSchema = _enum([
15444
+ "debug",
15445
+ "info",
15446
+ "warn",
15447
+ "error"
15448
+ ]);
15449
+ var LogEntrySchema = object({
15450
+ timestamp: date(),
15451
+ level: LogLevelSchema,
15452
+ scope: array(string()),
15453
+ message: string(),
15454
+ meta: record(string(), unknown()).optional(),
15455
+ tags: record(string(), string()).optional()
15456
+ });
15457
+ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
15458
+ scope: array(string()).optional(),
15459
+ level: LogLevelSchema.optional(),
15460
+ since: date().optional(),
15461
+ until: date().optional(),
15462
+ limit: number().optional(),
15463
+ tags: record(string(), string()).optional()
15464
+ }), array(LogEntrySchema).readonly());
15465
+ /**
15466
+ * `login-method` — collection cap through which auth addons contribute
15467
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
15468
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
15469
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
15470
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
15471
+ * procedure aggregates them for the unauthenticated login page.
15472
+ *
15473
+ * A contribution is a discriminated union on `kind`:
15474
+ *
15475
+ * - `redirect` — a declarative button. The login page renders a generic
15476
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
15477
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
15478
+ * ZERO shell-side JS. A future SSO addon plugs in the same way — the
15479
+ * login page needs NO change.
15480
+ *
15481
+ * - `widget` — a Module-Federation widget the login page mounts (via
15482
+ * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
15483
+ * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
15484
+ * mechanism kept for future use; no shipped addon uses it on the login
15485
+ * page (the passkey ceremony below runs natively in the shell instead).
15486
+ *
15487
+ * - `passkey` — a declarative WebAuthn ceremony the shell renders
15488
+ * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
15489
+ * a remotely-loaded bundle). Carries the addon's effective `rpId` /
15490
+ * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
15491
+ * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
15492
+ * fetching any remote code pre-auth. Contribution stays unconditional —
15493
+ * enrollment state is never leaked pre-auth; visibility is a shell
15494
+ * decision.
15495
+ *
15496
+ * Every contribution carries a `stage`:
15497
+ * - `primary` — shown on the first credentials screen (OIDC /
15498
+ * magic-link buttons; a future usernameless passkey).
15499
+ * - `second-factor` — shown AFTER the password leg, gated on the
15500
+ * returned `factors` (passkey-as-2FA today).
15501
+ *
15502
+ * `mount: skip` — the cap is read server-side by the core auth router
15503
+ * (`registry.getCollection('login-method')`), never mounted as its own
15504
+ * tRPC router.
15505
+ */
15506
+ /** When a login method renders in the two-phase login flow. */
15507
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
15508
+ /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
15509
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [
15510
+ object({
15511
+ kind: literal("redirect"),
15512
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
15513
+ id: string(),
15514
+ /** Operator-facing button label. */
15515
+ label: string(),
15516
+ /** lucide-react icon name. */
15517
+ icon: string().optional(),
15518
+ /** Addon-owned HTTP route the button navigates to (GET). */
15519
+ startUrl: string(),
15520
+ stage: LoginStageEnum
15521
+ }),
15522
+ object({
15523
+ kind: literal("widget"),
15524
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
15525
+ id: string(),
15526
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
15527
+ addonId: string(),
15528
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
15529
+ bundle: string(),
15530
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
15531
+ remote: WidgetRemoteSchema,
15532
+ stage: LoginStageEnum
15533
+ }),
15534
+ object({
15535
+ kind: literal("passkey"),
15536
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
15537
+ id: string(),
15538
+ /** Operator-facing button label. */
15539
+ label: string(),
15540
+ stage: LoginStageEnum,
15541
+ /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
15542
+ rpId: string(),
15543
+ /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
15544
+ origin: string().nullable()
15545
+ })
15546
+ ]);
15547
+ method(_void(), array(LoginMethodContributionSchema).readonly());
15548
+ var CpuBreakdownSchema = object({
15549
+ total: number(),
15550
+ user: number(),
15551
+ system: number(),
15552
+ irq: number(),
15553
+ nice: number(),
15554
+ loadAvg: tuple([
15555
+ number(),
15556
+ number(),
15557
+ number()
15558
+ ]),
15559
+ cores: number()
15560
+ });
15561
+ var MemoryInfoSchema = object({
15562
+ percent: number(),
15563
+ totalBytes: number(),
15564
+ usedBytes: number(),
15565
+ availableBytes: number(),
15566
+ swapUsedBytes: number(),
15567
+ swapTotalBytes: number()
15260
15568
  });
15261
15569
  var DiskIoSnapshotSchema = object({
15262
15570
  readBytes: number(),
@@ -15709,14 +16017,14 @@ var TargetKindCapsSchema = object({
15709
16017
  * the union is large and not meant for runtime validation here; the exported
15710
16018
  * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
15711
16019
  */
15712
- var ConfigSchemaPassthrough$1 = unknown();
16020
+ var ConfigSchemaPassthrough = unknown();
15713
16021
  var TargetKindSchema = object({
15714
16022
  kind: string(),
15715
16023
  label: string(),
15716
16024
  icon: string(),
15717
16025
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
15718
16026
  addonId: string(),
15719
- configSchema: ConfigSchemaPassthrough$1,
16027
+ configSchema: ConfigSchemaPassthrough,
15720
16028
  supportsDiscovery: boolean(),
15721
16029
  caps: TargetKindCapsSchema
15722
16030
  });
@@ -15769,297 +16077,493 @@ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSche
15769
16077
  enabled: boolean()
15770
16078
  }), _void(), { kind: "mutation" });
15771
16079
  /**
15772
- * Shared LLM generate contracts imported by BOTH `llm.cap.ts` (consumer
15773
- * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15774
- * caps stay wire-compatible without a circular cap→cap import.
16080
+ * notification-rules the Notification Center rule surface (P1 core).
15775
16081
  *
15776
- * Errors are a discriminated-union RESULT, never thrown: the shape survives
15777
- * every transport tier structurally, and failed calls still write usage rows.
15778
- * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
15779
- */
15780
- var LlmUsageSchema = object({
15781
- inputTokens: number(),
15782
- outputTokens: number()
15783
- });
15784
- var LlmErrorCodeSchema = _enum([
15785
- "timeout",
15786
- "rate-limited",
15787
- "auth",
15788
- "refusal",
15789
- "bad-request",
15790
- "unavailable",
15791
- "no-profile",
15792
- "budget-exceeded",
15793
- "adapter-error"
15794
- ]);
15795
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
15796
- ok: literal(true),
15797
- text: string(),
15798
- model: string(),
15799
- usage: LlmUsageSchema,
15800
- truncated: boolean(),
15801
- latencyMs: number()
15802
- }), object({
15803
- ok: literal(false),
15804
- code: LlmErrorCodeSchema,
15805
- message: string(),
15806
- retryAfterMs: number().optional()
15807
- })]);
16082
+ * Spec: `docs/superpowers/specs/2026-07-22-notification-center-requirements.md`
16083
+ * (operator decisions D-1/D-2/D-3 are binding):
16084
+ *
16085
+ * - D-2: rule EVALUATION lives in `addon-post-analysis` (the
16086
+ * `notification-center` module), hooked on the durable persistence
16087
+ * moments (object-event insert, TrackCloser.closeExpired) with a
16088
+ * persisted outbox + retry — never the lossy telemetry bus (D8).
16089
+ * - D-3: urgency belongs to the RULE. `delivery: 'immediate'` fires on the
16090
+ * FIRST persisted detection matching the conditions (per-track dedup,
16091
+ * `maxPerTrack` fixed at 1 — see {@link NC_MAX_PER_TRACK_IMMEDIATE});
16092
+ * `delivery: 'track-end'` evaluates the finalized track record at close.
16093
+ * - DISPATCH stays behind `notification-output` (rules reference targets
16094
+ * by id; per-backend params are a passthrough blob capped by the
16095
+ * target kind's own caps/degrade engine).
16096
+ *
16097
+ * P1 scope: admin-authored rules only (`createdBy` stamped from the
16098
+ * server-injected caller identity — the first `caller: 'required'`
16099
+ * adopter). The P1 condition subset is: devices, classes(+exclude),
16100
+ * minConfidence, admin zones (any/all + exclude), weekly schedule
16101
+ * windows, and the optional label/identity/plate matchers. User rules,
16102
+ * private zones, per-recipient fan-out and the wider condition table are
16103
+ * P2+ (see spec §7).
16104
+ *
16105
+ * All schemas here are the single source of truth — `NcRule` etc. are
16106
+ * `z.infer` exports; no duplicate interfaces (the advanced-notifier
16107
+ * schema/interface drift is explicitly not repeated).
16108
+ */
15808
16109
  /**
15809
- * `Uint8Array` is the sanctioned binary conventionsuperjson + the UDS
15810
- * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
15811
- * notification-output.cap.ts:27-31 precedents).
16110
+ * D-3: the trigger/urgency of a rule which persistence moment evaluates it.
16111
+ * The value maps 1:1 onto the evaluated record kind:
16112
+ * - `immediate` ↔ object-event persist (lowest-latency detection burst)
16113
+ * - `track-end` ↔ TrackCloser.closeExpired (finalized track record)
16114
+ * - `device-event` ↔ SensorEventStore insert (doorbell press / sensor state
16115
+ * change of a LINKED device, one row per linked camera)
16116
+ * - `package-event` ↔ PackageDropDetector object-event insert (a `package`
16117
+ * delivery / pick-up)
16118
+ *
16119
+ * `immediate`/`track-end` carry the D-3 urgency semantics; `device-event`/
16120
+ * `package-event` are pure trigger kinds (no urgency dimension). Extending
16121
+ * this one field keeps the schema additive — a rule still declares exactly
16122
+ * one trigger.
15812
16123
  */
15813
- var LlmImageSchema = object({
15814
- bytes: _instanceof(Uint8Array),
15815
- mimeType: string()
16124
+ var NcDeliverySchema = _enum([
16125
+ "immediate",
16126
+ "track-end",
16127
+ "device-event",
16128
+ "package-event"
16129
+ ]);
16130
+ /** Weekly schedule — OR of windows; absence on the rule = always active. */
16131
+ var NcScheduleSchema = object({
16132
+ windows: array(object({
16133
+ /** Days of week the window STARTS on (0 = Sunday … 6 = Saturday). */
16134
+ days: array(number().int().min(0).max(6)).min(1),
16135
+ startMinute: number().int().min(0).max(1439),
16136
+ endMinute: number().int().min(0).max(1439)
16137
+ })).min(1),
16138
+ /** IANA timezone; default = hub host timezone. */
16139
+ timezone: string().optional(),
16140
+ /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
16141
+ invert: boolean().optional()
15816
16142
  });
15817
- var LlmGenerateBaseInputSchema = object({
15818
- /** Collection routing (the notification-output posture). */
15819
- addonId: string().optional(),
15820
- /** Explicit profile; else the resolution chain (spec §3). */
15821
- profileId: string().optional(),
15822
- /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
15823
- consumer: string(),
15824
- system: string().optional(),
15825
- /** v1: single-turn. `messages[]` is a v2 additive field. */
15826
- prompt: string(),
15827
- /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
15828
- jsonSchema: record(string(), unknown()).optional(),
15829
- /** Per-call override of the profile default. */
15830
- maxTokens: number().int().positive().optional(),
15831
- temperature: number().optional()
16143
+ /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
16144
+ var NcPlateMatcherSchema = object({
16145
+ values: array(string().min(1)).min(1),
16146
+ /** Max Levenshtein distance after normalization (uppercase alphanumeric). */
16147
+ maxDistance: number().int().min(0).max(3).default(1)
15832
16148
  });
15833
16149
  /**
15834
- * `llm-runtime` node-side managed llama.cpp executor (spec §4). Registered
15835
- * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
15836
- * a specific node's runtime with `nodePin(profile.runtime.nodeId)` normal
15837
- * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
15838
- * this only through the `llm` cap's methods.
15839
- *
15840
- * One running llama-server child per node in v1 (models are RAM-heavy).
15841
- * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
15842
- * watchdog operator decision #3).
16150
+ * Occupancy condition (DEVICE-EVENT trigger). Fires on a ZoneAnalytics
16151
+ * occupancy edge for a device optionally narrowed to a single admin
16152
+ * `zoneId` and/or object `className`. `op` selects the edge/threshold:
16153
+ * - `became-occupied` (default) count crossed 0 `count`
16154
+ * - `became-free` — count crossed `count` below it
16155
+ * - `>=` / `<=` — count is at/over or at/under `count`
16156
+ * `sustainSeconds` requires the condition hold continuously that long
16157
+ * before firing (debounces flicker; 0 = fire on the first matching edge).
16158
+ * Fail-closed: no ZoneAnalytics snapshot / missing zone / null snapshot ⇒
16159
+ * the condition never matches. Confirmed edge-state survives addon restarts
16160
+ * (declared SQLite collection, reseeded on boot).
15843
16161
  */
15844
- var ManagedModelRefSchema = discriminatedUnion("kind", [
15845
- object({
15846
- kind: literal("catalog"),
15847
- catalogId: string()
15848
- }),
15849
- object({
15850
- kind: literal("url"),
15851
- url: string(),
15852
- sha256: string().optional()
15853
- }),
15854
- object({
15855
- kind: literal("path"),
15856
- path: string()
15857
- })
15858
- ]);
15859
- var ManagedRuntimeConfigSchema = object({
15860
- /** WHERE the runtime lives — hub or any agent. */
15861
- nodeId: string(),
15862
- /** Closed for v1; 'ollama' is a v2 candidate. */
15863
- engine: _enum(["llama-cpp"]),
15864
- model: ManagedModelRefSchema,
15865
- contextSize: number().int().default(4096),
15866
- /** 0 = CPU-only. */
15867
- gpuLayers: number().int().default(0),
15868
- /** Default: cpus-2, clamped ≥1 (resolved node-side). */
15869
- threads: number().int().optional(),
15870
- /** Concurrent slots. */
15871
- parallel: number().int().default(1),
15872
- /** Else lazy: first generate boots it. */
15873
- autoStart: boolean().default(false),
15874
- /** 0 = never; frees RAM after quiet periods. */
15875
- idleStopMinutes: number().int().default(30)
16162
+ var NcOccupancyConditionSchema = object({
16163
+ /** Admin zone id to scope the count to; absent = whole-frame occupancy. */
16164
+ zoneId: string().optional(),
16165
+ /** Object class to count; absent = any class. */
16166
+ className: string().optional(),
16167
+ op: _enum([
16168
+ "became-occupied",
16169
+ "became-free",
16170
+ ">=",
16171
+ "<="
16172
+ ]).default("became-occupied"),
16173
+ count: number().int().min(0).default(1),
16174
+ sustainSeconds: number().int().min(0).max(3600).default(15)
16175
+ });
16176
+ /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
16177
+ var NcZoneConditionSchema = object({
16178
+ ids: array(string().min(1)).min(1),
16179
+ /** Quantifier over `ids` — at least one / every one visited. */
16180
+ match: _enum(["any", "all"]).default("any")
15876
16181
  });
15877
- var LlmRuntimeStatusSchema = object({
15878
- /** Status is ALWAYS node-qualified. */
15879
- nodeId: string(),
15880
- state: _enum([
15881
- "stopped",
15882
- "downloading",
15883
- "starting",
15884
- "ready",
15885
- "crashed",
15886
- "failed"
15887
- ]),
15888
- pid: number().optional(),
15889
- port: number().optional(),
15890
- modelPath: string().optional(),
15891
- modelId: string().optional(),
15892
- downloadProgress: number().min(0).max(1).optional(),
15893
- lastError: string().optional(),
15894
- crashesInWindow: number(),
15895
- /** Child RSS (sampled best-effort). */
15896
- memoryBytes: number().optional(),
15897
- vramBytes: number().optional()
16182
+ /**
16183
+ * The P1 condition set — a flat AND of groups; absent group = pass;
16184
+ * membership lists are OR within the list (spec §2.3).
16185
+ */
16186
+ var NcConditionsSchema = object({
16187
+ /** Device scope — absent = all devices. */
16188
+ devices: array(number()).optional(),
16189
+ /** Detector class names (any overlap with the record's class set). */
16190
+ classes: array(string().min(1)).optional(),
16191
+ /** Veto classes — any overlap fails the rule. */
16192
+ classesExclude: array(string().min(1)).optional(),
16193
+ /** Minimum detection confidence 0–1 (fails when the record has none). */
16194
+ minConfidence: number().min(0).max(1).optional(),
16195
+ /** Admin zone membership over event `zones` / track `zonesVisited`. */
16196
+ zones: NcZoneConditionSchema.optional(),
16197
+ /** Veto zones — any hit fails the rule. */
16198
+ zonesExclude: array(string().min(1)).optional(),
16199
+ /**
16200
+ * Exact (case-insensitive) match on the record's collapsed `label`
16201
+ * (identity name / plate text / subclass).
16202
+ */
16203
+ labelEquals: array(string().min(1)).optional(),
16204
+ /**
16205
+ * Identity matcher. P1 boundary: matched against the record's collapsed
16206
+ * `label` (the identity display name propagated by the face pipeline) —
16207
+ * identity-ID matching rides in P2 when identity ids reach the record.
16208
+ */
16209
+ identities: array(string().min(1)).optional(),
16210
+ /** Fuzzy plate matcher against the record's `label` (plate text). */
16211
+ plates: NcPlateMatcherSchema.optional(),
16212
+ /**
16213
+ * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
16214
+ * Same P1 boundary: matched against the record's collapsed `label` (the
16215
+ * identity display name). A record with NO label passes (nothing to
16216
+ * exclude), unlike the include variant which fails on an absent label.
16217
+ */
16218
+ identitiesExclude: array(string().min(1)).optional(),
16219
+ /**
16220
+ * Minimum server-computed key-event importance in [0,1] (`Track.importance`).
16221
+ * TRACK-END only: importance is scored at track close, so it does not exist
16222
+ * at immediate / object-event evaluation time (see catalog `appliesTo`). At
16223
+ * close the value is threaded via the close-time info (the `Track` clone is
16224
+ * captured before the DB row is updated, so it would otherwise read stale).
16225
+ * Fails when the record carries no importance (never guess quality — the
16226
+ * `minConfidence` precedent). MVP cut: a single scalar threshold.
16227
+ */
16228
+ minImportance: number().min(0).max(1).optional(),
16229
+ /**
16230
+ * Minimum track dwell in SECONDS — `(lastSeen − firstSeen) / 1000`.
16231
+ * TRACK-END only: an `immediate` / object-event subject has no closed
16232
+ * lifespan, so a dwell condition never matches immediate delivery
16233
+ * (documented choice — the object-event record carries no `firstSeen`,
16234
+ * so dwell cannot be computed from what the subject actually carries).
16235
+ */
16236
+ minDwellSeconds: number().min(0).optional(),
16237
+ /**
16238
+ * Detection provenance filter. `any` (default / absent) matches every
16239
+ * source; otherwise the subject's source must equal it. Legacy records
16240
+ * with no stamped source are treated as `pipeline`. The union spans both
16241
+ * record kinds — object events carry `pipeline` | `onboard`, synthetic
16242
+ * tracks carry `sensor`.
16243
+ */
16244
+ source: _enum([
16245
+ "pipeline",
16246
+ "onboard",
16247
+ "sensor",
16248
+ "any"
16249
+ ]).optional(),
16250
+ /**
16251
+ * Minimum identity / plate MATCH confidence in [0,1] — DISTINCT from the
16252
+ * detector `minConfidence` (that gates the object-detection score; this
16253
+ * gates the recognition/OCR match score). Fails when the subject carries
16254
+ * no label-match confidence (never guess). TRACK-END only: the confidence
16255
+ * lives on the recognition result and reaches the subject at track close.
16256
+ *
16257
+ * What it measures precisely (plumbed at track close — the closer threads
16258
+ * the value into `NcTrackClosedInfo.labelConfidence`, the same seam as
16259
+ * `importance`): the BEST recognition match confidence observed for the
16260
+ * label the track carries at close — for a face, the peak cosine similarity
16261
+ * of the ASSIGNED identity (`FaceMatch.score`, reset on an identity switch);
16262
+ * for a plate, the peak OCR read score of the best-held plate
16263
+ * (`plateText.confidence`). When BOTH a face and a plate were recognized on
16264
+ * one track the higher of the two is used. A track that ended with no
16265
+ * confident identity/plate match carries no value, so the condition fails
16266
+ * closed for it (an un-recognized subject).
16267
+ */
16268
+ minLabelConfidence: number().min(0).max(1).optional(),
16269
+ /**
16270
+ * DEVICE-EVENT only. Raw device event-type tokens (`EventFire.eventType`,
16271
+ * e.g. a doorbell `press` / `press_long`) — matched case-insensitively
16272
+ * against the token carried on the device-event subject (extracted from the
16273
+ * event-emitter runtime slice's `lastEvent.eventType`). Fails when the
16274
+ * subject carries no token. Doorbell-pulse / passive-sensor kinds emit no
16275
+ * eventType, so gate those with {@link sensorKinds} instead.
16276
+ */
16277
+ eventTypeTokens: array(string().min(1)).optional(),
16278
+ /**
16279
+ * DEVICE-EVENT only. Sensor/control taxonomy kinds (e.g. `doorbell`,
16280
+ * `contact`, `button`, `device-event`) — matched against the persisted
16281
+ * `SensorEvent.kind` (see `sensor-event-kinds.ts`). Membership is OR.
16282
+ */
16283
+ sensorKinds: array(string().min(1)).optional(),
16284
+ /**
16285
+ * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
16286
+ * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
16287
+ * when the subject's phase does not match (a subject always carries a phase
16288
+ * on the package-event trigger).
16289
+ */
16290
+ packagePhase: _enum([
16291
+ "delivered",
16292
+ "picked-up",
16293
+ "both"
16294
+ ]).optional(),
16295
+ /**
16296
+ * PERSONAL-RULE custom zones (viewer-drawn). Inline normalized polygons
16297
+ * (MaskShape vocabulary). A record passes when its bbox overlaps ANY
16298
+ * listed polygon (ZoneEngine membership semantics). Evaluated only when
16299
+ * the subject carries a bbox; absent bbox ⇒ the condition FAILS.
16300
+ */
16301
+ customZones: array(MaskPolygonShapeSchema).optional(),
16302
+ /**
16303
+ * DEVICE-EVENT only. ZoneAnalytics occupancy edge — fires when a device's
16304
+ * (optionally zone/class-scoped) occupancy count crosses the configured
16305
+ * threshold and holds for `sustainSeconds`. Fail-closed on missing
16306
+ * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
16307
+ */
16308
+ occupancy: NcOccupancyConditionSchema.optional()
15898
16309
  });
15899
- var LlmNodeModelSchema = object({
15900
- file: string(),
15901
- sizeBytes: number(),
15902
- catalogId: string().optional(),
15903
- installedAt: number().optional()
16310
+ /** One delivery target: a `notification-output` Target ref + passthrough params. */
16311
+ var NcRuleTargetSchema = object({
16312
+ /** `notification-output` Target id. */
16313
+ targetId: string().min(1),
16314
+ /**
16315
+ * Per-backend passthrough. Recognized keys are mapped onto the canonical
16316
+ * Notification (`priority`, `level`, `sound`, `clickUrl`, `ttl`); the
16317
+ * degrade engine drops what the backend can't render.
16318
+ */
16319
+ params: record(string(), unknown()).optional()
15904
16320
  });
15905
- var LlmRuntimeDiskUsageSchema = object({
15906
- nodeId: string(),
15907
- modelsBytes: number(),
15908
- freeBytes: number().optional()
16321
+ /**
16322
+ * Media attachment policy (P1 still-image subset).
16323
+ * - `best` — the best AVAILABLE subject image at dispatch time (D-3).
16324
+ * - `best-matching` — the media that explains WHY the rule fired: a rule
16325
+ * matched on identities attaches the subject's `faceCrop`, one matched on
16326
+ * plates attaches the `plateCrop`; a rule with no identity/plate condition
16327
+ * (or when the specific crop is missing) degrades to `best`, then
16328
+ * `keyFrame`, then no attachment — never delaying the send. The matched
16329
+ * condition summary is frozen on the outbox row at enqueue (like the rule
16330
+ * name), so the choice never drifts from the record that fired it.
16331
+ * - `keyFrame` — the clean scene frame (no subject box).
16332
+ * - `none` — no attachment.
16333
+ */
16334
+ var NcMediaPolicySchema = object({ attach: _enum([
16335
+ "best",
16336
+ "best-matching",
16337
+ "keyFrame",
16338
+ "none"
16339
+ ]).default("best") });
16340
+ /** Throttle — cooldown survives restarts (rebuilt from the outbox on boot). */
16341
+ var NcThrottleSchema = object({
16342
+ cooldownSec: number().int().min(0).max(86400).default(60),
16343
+ /** `rule` = one shared cooldown; `rule-device` = per-camera cooldown. */
16344
+ scope: _enum(["rule", "rule-device"]).default("rule-device")
16345
+ });
16346
+ /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
16347
+ var NcRuleInputSchema = object({
16348
+ name: string().min(1).max(200),
16349
+ enabled: boolean().default(true),
16350
+ delivery: NcDeliverySchema,
16351
+ conditions: NcConditionsSchema.default({}),
16352
+ schedule: NcScheduleSchema.optional(),
16353
+ targets: array(NcRuleTargetSchema).min(1),
16354
+ media: NcMediaPolicySchema.default({ attach: "best" }),
16355
+ throttle: NcThrottleSchema.default({
16356
+ cooldownSec: 60,
16357
+ scope: "rule-device"
16358
+ }),
16359
+ /** `{{var}}` templating over camera/class/label/zones/confidence/time. */
16360
+ template: object({
16361
+ title: string().max(500).optional(),
16362
+ body: string().max(2e3).optional()
16363
+ }).optional(),
16364
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
16365
+ priority: number().int().min(1).max(5).default(3),
16366
+ /**
16367
+ * Ownership/visibility key. Absent = admin/global rule (unchanged legacy
16368
+ * behaviour, visible to all, read-only in the viewer). Present = personal
16369
+ * rule owned by this userId. Server-stamped; never trusted from a client.
16370
+ */
16371
+ ownerUserId: string().optional()
15909
16372
  });
15910
- method(LlmGenerateBaseInputSchema.extend({
15911
- images: array(LlmImageSchema).optional(),
15912
- runtime: ManagedRuntimeConfigSchema,
15913
- /** The managed profile's timeout, threaded by the hub provider. */
15914
- timeoutMs: number().int().positive().optional()
15915
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
15916
- kind: "mutation",
15917
- auth: "admin"
15918
- }), method(object({}), _void(), {
15919
- kind: "mutation",
15920
- auth: "admin"
15921
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
15922
- kind: "mutation",
15923
- auth: "admin"
15924
- }), method(object({ file: string() }), _void(), {
15925
- kind: "mutation",
15926
- auth: "admin"
15927
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
15928
16373
  /**
15929
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
15930
- * methods concat-fan across providers; single-row methods route to ONE
15931
- * provider by the `addonId` in the call input (the notification-output
15932
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
15933
- * (hub-placed); the cap stays open for future providers.
15934
- *
15935
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
15936
- * `apiKey` is a password field — providers REDACT it on read and merge on
15937
- * write; a stored key NEVER round-trips to a client.
16374
+ * Partial patch for `updateRule` — any subset of the input fields, plus the
16375
+ * persisted-only {@link NcRuleSchema} `disabledTargetIds` set. The latter is
16376
+ * NOT a client-authored input field (it lives on the persisted rule, not the
16377
+ * input), so it is added here explicitly to let the store's per-target opt-out
16378
+ * toggle round-trip through the shared `update` path. Viewer opt-out mutations
16379
+ * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
16380
+ * `updateRule` patch.
15938
16381
  */
15939
- var LlmProfileKindSchema = _enum([
15940
- "openai-compatible",
15941
- "openai",
15942
- "anthropic",
15943
- "google",
15944
- "managed-local"
15945
- ]);
15946
- var LlmProfileSchema = object({
16382
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
16383
+ /** A persisted rule. */
16384
+ var NcRuleSchema = NcRuleInputSchema.extend({
15947
16385
  id: string(),
15948
- name: string(),
15949
- kind: LlmProfileKindSchema,
15950
- /** Stamped by the provider — keeps the fanned catalog routable. */
15951
- addonId: string(),
15952
- enabled: boolean(),
15953
- /** Vendor model id, or the managed runtime's loaded model. */
15954
- model: string(),
15955
- /** Required for openai-compatible; override for cloud kinds. */
15956
- baseUrl: string().optional(),
15957
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
15958
- apiKey: string().optional(),
15959
- supportsVision: boolean(),
15960
- temperature: number().min(0).max(2).optional(),
15961
- maxTokens: number().int().positive().optional(),
15962
- timeoutMs: number().int().positive().default(6e4),
15963
- extraHeaders: record(string(), string()).optional(),
15964
- /** kind === 'managed-local' only (spec §4). */
15965
- runtime: ManagedRuntimeConfigSchema.optional()
15966
- });
15967
- /** ConfigUISchema tree passed through untyped on the wire (the
15968
- * notification-output `ConfigSchemaPassthrough` precedent at
15969
- * notification-output.cap.ts:151); the exported TS type re-tightens it. */
15970
- var ConfigSchemaPassthrough = unknown();
15971
- var LlmProfileKindDescriptorSchema = object({
15972
- kind: LlmProfileKindSchema,
15973
- label: string(),
15974
- icon: string(),
15975
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
15976
- addonId: string(),
15977
- configSchema: ConfigSchemaPassthrough
15978
- });
15979
- var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
15980
- var LlmDefaultSchema = object({
15981
- selector: LlmDefaultSelectorSchema,
15982
- profileId: string()
16386
+ /** userId of the admin who created the rule (server-stamped caller). */
16387
+ createdBy: string(),
16388
+ createdAt: number(),
16389
+ updatedAt: number(),
16390
+ /**
16391
+ * Per-target opt-out set. A targetId here is suppressed for THIS rule at
16392
+ * send time. Only a target's OWNER may add/remove its id (server-checked
16393
+ * in `nc.setRuleTargetEnabled`). Defaults to empty.
16394
+ */
16395
+ disabledTargetIds: array(string()).default([])
15983
16396
  });
15984
- /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
15985
- var LlmUsageRollupSchema = object({
15986
- day: string(),
15987
- consumer: string(),
15988
- profileId: string(),
15989
- calls: number(),
15990
- okCalls: number(),
15991
- errorCalls: number(),
15992
- inputTokens: number(),
15993
- outputTokens: number(),
15994
- avgLatencyMs: number()
16397
+ var NcTestResultSchema = object({
16398
+ recordId: string(),
16399
+ recordKind: _enum([
16400
+ "object-event",
16401
+ "track",
16402
+ "device-event",
16403
+ "package-event"
16404
+ ]),
16405
+ deviceId: number(),
16406
+ timestamp: number(),
16407
+ wouldFire: boolean(),
16408
+ /** Condition id that failed (first failing group), when `wouldFire` is false. */
16409
+ failedCondition: string().optional(),
16410
+ className: string().optional(),
16411
+ label: string().optional()
15995
16412
  });
15996
- /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
15997
- var ManagedModelCatalogEntrySchema = object({
16413
+ var NcConditionDescriptorSchema = object({
16414
+ /** Field id inside `NcConditions` (or `'schedule'` for the rule-level group). */
15998
16415
  id: string(),
16416
+ group: _enum([
16417
+ "scope",
16418
+ "class",
16419
+ "zones",
16420
+ "quality",
16421
+ "label",
16422
+ "schedule",
16423
+ "device",
16424
+ "package",
16425
+ "occupancy"
16426
+ ]),
15999
16427
  label: string(),
16000
- family: string(),
16001
- purpose: _enum(["text", "vision"]),
16002
- url: string(),
16003
- sha256: string(),
16004
- sizeBytes: number(),
16005
- quantization: string(),
16006
- /** Load-time guidance shown in the picker. */
16007
- minRamBytes: number(),
16008
- contextSizeDefault: number().int(),
16009
- /** Vision models: companion projector file. */
16010
- mmprojUrl: string().optional()
16428
+ /** Editor widget the UI renders — never hardcode per-condition forms. */
16429
+ valueType: _enum([
16430
+ "deviceIdList",
16431
+ "stringList",
16432
+ "number01",
16433
+ "number",
16434
+ "sourceSelect",
16435
+ "zoneSelection",
16436
+ "zoneIdList",
16437
+ "schedule",
16438
+ "plateMatcher",
16439
+ "packagePhase",
16440
+ "polygonDraw",
16441
+ "occupancy"
16442
+ ]),
16443
+ operator: _enum([
16444
+ "in",
16445
+ "notIn",
16446
+ "anyOf",
16447
+ "allOf",
16448
+ "gte",
16449
+ "fuzzyIn",
16450
+ "withinSchedule"
16451
+ ]),
16452
+ /** Which delivery kinds the condition applies to. */
16453
+ appliesTo: array(NcDeliverySchema),
16454
+ phase: string(),
16455
+ description: string().optional()
16011
16456
  });
16012
- var LlmRuntimeNodeSchema = object({
16013
- nodeId: string(),
16014
- reachable: boolean(),
16015
- status: LlmRuntimeStatusSchema.optional(),
16016
- disk: LlmRuntimeDiskUsageSchema.optional(),
16017
- error: string().optional()
16457
+ /**
16458
+ * The delivery lifecycle status of a history row — a straight read of the
16459
+ * durable outbox row's own status (single source of truth):
16460
+ * - `pending` — enqueued, in-flight or retrying with backoff
16461
+ * - `sent` — delivered (terminal)
16462
+ * - `dead` — dead-lettered after exhausting retries / a permanent
16463
+ * backend rejection / a deleted target (terminal; carries
16464
+ * the failure `error`)
16465
+ *
16466
+ * P1 has no `suppressed-quiet-hours` / `snoozed` states — those ride the P2
16467
+ * user dimension (quiet hours / snooze) and are additive when they land.
16468
+ */
16469
+ var NcHistoryStatusSchema = _enum([
16470
+ "pending",
16471
+ "sent",
16472
+ "dead"
16473
+ ]);
16474
+ /** The evaluated record kind a history row descends from (one per trigger). */
16475
+ var NcHistoryRecordKindSchema = _enum([
16476
+ "object-event",
16477
+ "track-end",
16478
+ "device-event",
16479
+ "package-event"
16480
+ ]);
16481
+ /** Subject summary frozen on the row at fire time (survives rule/record edits). */
16482
+ var NcHistorySubjectSchema = object({
16483
+ className: string(),
16484
+ label: string().optional(),
16485
+ confidence: number().optional(),
16486
+ zones: array(string()),
16487
+ timestamp: number()
16488
+ });
16489
+ /**
16490
+ * One delivery-history row. This is a read-only VIEW over the durable
16491
+ * outbox row (single source of truth — the same row the drain loop drives;
16492
+ * NO second write path, so history can never drift from delivery state).
16493
+ * The §3.2 fields map directly: `ruleId`/`targetId`/`deviceId` are columns,
16494
+ * `eventRef` is `recordKind`+`recordId`, `timestamps` are `createdAt`
16495
+ * (fire) / `updatedAt` (last transition), `status` + `error` are the
16496
+ * lifecycle. `ruleName` + `subject` are the intent snapshot frozen at
16497
+ * enqueue. `userId?` (per-recipient history) is P2 — no user dimension in
16498
+ * P1 (admin scope only).
16499
+ */
16500
+ var NcHistoryEntrySchema = object({
16501
+ /** Outbox row id — the stable dedup id `ruleId:dedupRef:targetId`. */
16502
+ id: string(),
16503
+ ruleId: string(),
16504
+ /** Rule name frozen at fire time (outlives a later rename / delete). */
16505
+ ruleName: string(),
16506
+ /** The rule urgency/trigger that produced this delivery. */
16507
+ delivery: NcDeliverySchema,
16508
+ targetId: string(),
16509
+ deviceId: number(),
16510
+ recordKind: NcHistoryRecordKindSchema,
16511
+ /** Event / track ref of the evaluated record (§3.2 `eventRef`). */
16512
+ recordId: string(),
16513
+ /** Present for track-scoped deliveries (object-event / track-end). */
16514
+ trackId: string().optional(),
16515
+ status: NcHistoryStatusSchema,
16516
+ /** Delivery attempts made so far. */
16517
+ attempts: number().int(),
16518
+ /** Fire time (outbox enqueue). */
16519
+ createdAt: number(),
16520
+ /** Last transition time (terminal for sent / dead). */
16521
+ updatedAt: number(),
16522
+ /** Failure detail — present on a `dead` row. */
16523
+ error: string().optional(),
16524
+ subject: NcHistorySubjectSchema
16018
16525
  });
16019
- var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
16020
- var ProfileRefInputSchema = object({
16021
- addonId: string(),
16022
- profileId: string()
16526
+ /**
16527
+ * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
16528
+ * AND; absent = unbounded on that axis. `since`/`until` bound the fire time
16529
+ * (`createdAt`, epoch ms, inclusive). `limit` is clamped to
16530
+ * {@link NC_HISTORY_LIMIT_MAX}. `userId` (per-recipient filtering) is P2.
16531
+ */
16532
+ var NcHistoryFilterSchema = object({
16533
+ ruleId: string().optional(),
16534
+ deviceId: number().optional(),
16535
+ status: NcHistoryStatusSchema.optional(),
16536
+ since: number().optional(),
16537
+ until: number().optional(),
16538
+ limit: number().int().min(1).max(500).default(100)
16023
16539
  });
16024
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
16025
- kind: "mutation",
16026
- auth: "admin"
16027
- }), method(ProfileRefInputSchema, _void(), {
16540
+ 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 }), {
16028
16541
  kind: "mutation",
16029
- auth: "admin"
16030
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
16542
+ auth: "admin",
16543
+ caller: "required"
16544
+ }), method(object({
16545
+ ruleId: string(),
16546
+ patch: NcRulePatchSchema
16547
+ }), object({ rule: NcRuleSchema }), {
16031
16548
  kind: "mutation",
16032
- auth: "admin"
16033
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
16034
- selector: LlmDefaultSelectorSchema,
16035
- profileId: string().nullable()
16036
- }), _void(), {
16549
+ auth: "admin",
16550
+ caller: "required"
16551
+ }), method(object({ ruleId: string() }), object({ success: literal(true) }), {
16037
16552
  kind: "mutation",
16038
16553
  auth: "admin"
16039
16554
  }), method(object({
16040
- since: number().optional(),
16041
- until: number().optional(),
16042
- consumer: string().optional(),
16043
- profileId: string().optional()
16044
- }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
16045
- nodeId: string(),
16046
- model: ManagedModelRefSchema
16047
- }), _void(), {
16555
+ ruleId: string(),
16556
+ enabled: boolean()
16557
+ }), object({ success: literal(true) }), {
16048
16558
  kind: "mutation",
16049
16559
  auth: "admin"
16050
16560
  }), method(object({
16051
- nodeId: string(),
16052
- file: string()
16053
- }), _void(), {
16054
- kind: "mutation",
16055
- auth: "admin"
16056
- }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
16057
- kind: "mutation",
16058
- auth: "admin"
16059
- }), method(ProfileRefInputSchema, _void(), {
16561
+ rule: NcRuleInputSchema,
16562
+ lookbackMinutes: number().int().min(1).max(1440).default(60)
16563
+ }), object({ results: array(NcTestResultSchema) }), {
16060
16564
  kind: "mutation",
16061
16565
  auth: "admin"
16062
- });
16566
+ }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
16063
16567
  /**
16064
16568
  * Zod schemas for persisted record types.
16065
16569
  *
@@ -16745,7 +17249,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
16745
17249
  }), method(object({
16746
17250
  eventId: string(),
16747
17251
  kind: MediaFileKindEnum.optional()
16748
- }), array(MediaFileSchema).readonly()), method(object({ trackId: string() }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
17252
+ }), array(MediaFileSchema).readonly()), method(object({
17253
+ trackId: string(),
17254
+ kinds: array(MediaFileKindEnum).optional()
17255
+ }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
16749
17256
  deviceId: number(),
16750
17257
  timestamp: number(),
16751
17258
  frameWidth: number(),
@@ -16766,76 +17273,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
16766
17273
  eventId: string(),
16767
17274
  timestamp: number()
16768
17275
  });
16769
- /**
16770
- * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
16771
- * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
16772
- * caps into per-camera event-kind descriptors.
16773
- *
16774
- * The descriptor DATA (color / iconId / labelKey / parentKind / category)
16775
- * is NOT duplicated here — every entry is derived from the single
16776
- * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
16777
- * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
16778
- * control cap means adding one line here (and a taxonomy entry); the anti-
16779
- * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
16780
- * eventful cap is missing.
16781
- */
16782
- /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
16783
- var LEGACY_ICON = {
16784
- motion: "motion",
16785
- audio: "audio",
16786
- person: "person",
16787
- vehicle: "vehicle",
16788
- animal: "animal",
16789
- package: "package",
16790
- door: "door",
16791
- pir: "pir",
16792
- smoke: "smoke",
16793
- water: "water",
16794
- button: "button",
16795
- generic: "generic",
16796
- gas: "smoke",
16797
- vibration: "generic",
16798
- tamper: "generic",
16799
- presence: "person",
16800
- lock: "generic",
16801
- siren: "generic",
16802
- switch: "generic",
16803
- doorbell: "button"
16804
- };
16805
- function legacyIcon(iconId) {
16806
- return LEGACY_ICON[iconId] ?? "generic";
16807
- }
16808
- /**
16809
- * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
16810
- * The anti-drift guard cross-checks this against the eventful caps declared
16811
- * in `packages/types/src/capabilities/*.cap.ts`.
16812
- */
16813
- var CAP_TO_KIND = {
16814
- contact: "contact",
16815
- motion: "motion-sensor",
16816
- smoke: "smoke",
16817
- flood: "flood",
16818
- gas: "gas",
16819
- "carbon-monoxide": "carbon-monoxide",
16820
- vibration: "vibration",
16821
- tamper: "tamper",
16822
- presence: "presence",
16823
- "enum-sensor": "enum-sensor",
16824
- "event-emitter": "device-event",
16825
- "lock-control": "lock",
16826
- switch: "switch",
16827
- button: "button",
16828
- doorbell: "doorbell"
16829
- };
16830
- function buildDescriptor(capName, kind) {
16831
- const t = EVENT_TAXONOMY[kind];
16832
- if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
16833
- return {
16834
- ...t,
16835
- icon: legacyIcon(t.iconId)
16836
- };
16837
- }
16838
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
16839
17276
  var CameraPipelineConfigSchema = object({
16840
17277
  engine: PipelineEngineChoiceSchema.optional(),
16841
17278
  steps: array(PipelineStepInputSchema).readonly(),
@@ -17321,6 +17758,76 @@ method(object({
17321
17758
  auth: "admin"
17322
17759
  });
17323
17760
  /**
17761
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
17762
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
17763
+ * caps into per-camera event-kind descriptors.
17764
+ *
17765
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
17766
+ * is NOT duplicated here — every entry is derived from the single
17767
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
17768
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
17769
+ * control cap means adding one line here (and a taxonomy entry); the anti-
17770
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
17771
+ * eventful cap is missing.
17772
+ */
17773
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
17774
+ var LEGACY_ICON = {
17775
+ motion: "motion",
17776
+ audio: "audio",
17777
+ person: "person",
17778
+ vehicle: "vehicle",
17779
+ animal: "animal",
17780
+ package: "package",
17781
+ door: "door",
17782
+ pir: "pir",
17783
+ smoke: "smoke",
17784
+ water: "water",
17785
+ button: "button",
17786
+ generic: "generic",
17787
+ gas: "smoke",
17788
+ vibration: "generic",
17789
+ tamper: "generic",
17790
+ presence: "person",
17791
+ lock: "generic",
17792
+ siren: "generic",
17793
+ switch: "generic",
17794
+ doorbell: "button"
17795
+ };
17796
+ function legacyIcon(iconId) {
17797
+ return LEGACY_ICON[iconId] ?? "generic";
17798
+ }
17799
+ /**
17800
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
17801
+ * The anti-drift guard cross-checks this against the eventful caps declared
17802
+ * in `packages/types/src/capabilities/*.cap.ts`.
17803
+ */
17804
+ var CAP_TO_KIND = {
17805
+ contact: "contact",
17806
+ motion: "motion-sensor",
17807
+ smoke: "smoke",
17808
+ flood: "flood",
17809
+ gas: "gas",
17810
+ "carbon-monoxide": "carbon-monoxide",
17811
+ vibration: "vibration",
17812
+ tamper: "tamper",
17813
+ presence: "presence",
17814
+ "enum-sensor": "enum-sensor",
17815
+ "event-emitter": "device-event",
17816
+ "lock-control": "lock",
17817
+ switch: "switch",
17818
+ button: "button",
17819
+ doorbell: "doorbell"
17820
+ };
17821
+ function buildDescriptor(capName, kind) {
17822
+ const t = EVENT_TAXONOMY[kind];
17823
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
17824
+ return {
17825
+ ...t,
17826
+ icon: legacyIcon(t.iconId)
17827
+ };
17828
+ }
17829
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
17830
+ /**
17324
17831
  * server-management — per-NODE singleton capability for a node's ROOT
17325
17832
  * package lifecycle (runtime-updatable node packages).
17326
17833
  *
@@ -18788,7 +19295,28 @@ var FaceInfoSchema = object({
18788
19295
  * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`). Absent when the
18789
19296
  * track produced no key frame (e.g. native/onboard source) — the UI falls
18790
19297
  * back to the inline `base64` face crop. */
18791
- keyFrameMediaKey: string().optional()
19298
+ keyFrameMediaKey: string().optional(),
19299
+ /** Winning identity-match cosine (0..1) for this face's track, when an
19300
+ * identity was auto-confirmed. Lets the UI surface WHY a face was assigned
19301
+ * (confidence badge / low-confidence audit). Absent on legacy rows and on
19302
+ * faces that were never auto-recognized. */
19303
+ bestMatchScore: number().optional(),
19304
+ /** Native-scale face short side (px) at recognition time, when the runner
19305
+ * measured it. Lets the UI flag low-resolution auto-assignments. Absent on
19306
+ * legacy rows / runners that reported no native measure. */
19307
+ nativeFaceShortSidePx: number().optional(),
19308
+ /** SUGGESTED identity for this face — a plausible-but-not-confident match that
19309
+ * MISSED auto-assignment (cosine in the suggestion band, or above threshold
19310
+ * but blocked only by the recognition size floor). Mutually exclusive with
19311
+ * `recognizedIdentityId` (a suggestion is NEVER an assignment): the face stays
19312
+ * UNASSIGNED and everything else keeps treating it as unrecognized — the UI
19313
+ * merely offers a one-tap "is this <name>?" confirm. Absent on legacy rows and
19314
+ * on faces that were auto-assigned or below the suggestion band. (2026-07-24) */
19315
+ suggestedIdentityId: string().optional(),
19316
+ /** Peak identity-match cosine (0..1) for `suggestedIdentityId`, captured at the
19317
+ * same moment as `bestMatchScore` (track peak, at close). Lets the UI rank /
19318
+ * badge suggestion confidence. Present iff `suggestedIdentityId` is. (2026-07-24) */
19319
+ suggestedMatchScore: number().optional()
18792
19320
  });
18793
19321
  var FaceFilterEnum = _enum([
18794
19322
  "unassigned",
@@ -20831,36 +21359,6 @@ Object.freeze({
20831
21359
  addonId: null,
20832
21360
  access: "view"
20833
21361
  },
20834
- "advancedNotifier.deleteRule": {
20835
- capName: "advanced-notifier",
20836
- capScope: "system",
20837
- addonId: null,
20838
- access: "delete"
20839
- },
20840
- "advancedNotifier.getHistory": {
20841
- capName: "advanced-notifier",
20842
- capScope: "system",
20843
- addonId: null,
20844
- access: "view"
20845
- },
20846
- "advancedNotifier.getRules": {
20847
- capName: "advanced-notifier",
20848
- capScope: "system",
20849
- addonId: null,
20850
- access: "view"
20851
- },
20852
- "advancedNotifier.testRule": {
20853
- capName: "advanced-notifier",
20854
- capScope: "system",
20855
- addonId: null,
20856
- access: "create"
20857
- },
20858
- "advancedNotifier.upsertRule": {
20859
- capName: "advanced-notifier",
20860
- capScope: "system",
20861
- addonId: null,
20862
- access: "create"
20863
- },
20864
21362
  "alarmPanel.arm": {
20865
21363
  capName: "alarm-panel",
20866
21364
  capScope: "device",
@@ -23165,6 +23663,60 @@ Object.freeze({
23165
23663
  addonId: null,
23166
23664
  access: "create"
23167
23665
  },
23666
+ "notificationRules.createRule": {
23667
+ capName: "notification-rules",
23668
+ capScope: "system",
23669
+ addonId: null,
23670
+ access: "create"
23671
+ },
23672
+ "notificationRules.deleteRule": {
23673
+ capName: "notification-rules",
23674
+ capScope: "system",
23675
+ addonId: null,
23676
+ access: "delete"
23677
+ },
23678
+ "notificationRules.getConditionCatalog": {
23679
+ capName: "notification-rules",
23680
+ capScope: "system",
23681
+ addonId: null,
23682
+ access: "view"
23683
+ },
23684
+ "notificationRules.getHistory": {
23685
+ capName: "notification-rules",
23686
+ capScope: "system",
23687
+ addonId: null,
23688
+ access: "view"
23689
+ },
23690
+ "notificationRules.getRule": {
23691
+ capName: "notification-rules",
23692
+ capScope: "system",
23693
+ addonId: null,
23694
+ access: "view"
23695
+ },
23696
+ "notificationRules.listRules": {
23697
+ capName: "notification-rules",
23698
+ capScope: "system",
23699
+ addonId: null,
23700
+ access: "view"
23701
+ },
23702
+ "notificationRules.setRuleEnabled": {
23703
+ capName: "notification-rules",
23704
+ capScope: "system",
23705
+ addonId: null,
23706
+ access: "create"
23707
+ },
23708
+ "notificationRules.testRule": {
23709
+ capName: "notification-rules",
23710
+ capScope: "system",
23711
+ addonId: null,
23712
+ access: "create"
23713
+ },
23714
+ "notificationRules.updateRule": {
23715
+ capName: "notification-rules",
23716
+ capScope: "system",
23717
+ addonId: null,
23718
+ access: "create"
23719
+ },
23168
23720
  "notifier.cancel": {
23169
23721
  capName: "notifier",
23170
23722
  capScope: "device",