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