@camstack/addon-export-ha-mqtt 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";
@@ -6865,7 +6862,6 @@ object({ deviceId: number$1() }), object({ deviceId: number$1() }), object({
6865
6862
  patch: record(string(), unknown())
6866
6863
  }), object({ success: literal(true) });
6867
6864
  object({ deviceId: number$1() }), unknown().nullable();
6868
- /** Shorthand to define a method schema */
6869
6865
  function method(input, output, options) {
6870
6866
  return {
6871
6867
  input,
@@ -6873,6 +6869,7 @@ function method(input, output, options) {
6873
6869
  kind: options?.kind ?? "query",
6874
6870
  auth: options?.auth ?? "protected",
6875
6871
  ...options?.access !== void 0 ? { access: options.access } : {},
6872
+ ...options?.caller !== void 0 ? { caller: options.caller } : {},
6876
6873
  timeoutMs: options?.timeoutMs
6877
6874
  };
6878
6875
  }
@@ -8226,6 +8223,59 @@ for (const l of AUDIO_MACRO_LABELS) {
8226
8223
  /** The complete taxonomy dictionary, keyed by kind. */
8227
8224
  var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
8228
8225
  /**
8226
+ * Notification-Center taxonomy — the fixed vocabulary the NC rule editor
8227
+ * offers as pickers instead of free text. Derived (never hand-listed) from the
8228
+ * single `EVENT_TAXONOMY` dictionary so it stays in lockstep with every other
8229
+ * taxonomy surface (timeline, filters, event page).
8230
+ *
8231
+ * Three buckets, mapped onto the rule editor's `stringList` conditions:
8232
+ * - `videoClasses` → detection classes (person / vehicle / animal + subs)
8233
+ * for the `classes` / `classesExclude` conditions.
8234
+ * - `audioKinds` → audio-analyzer sub kinds (`audio-scream`, …) shown in
8235
+ * the same class picker, grouped under an Audio header.
8236
+ * - `labels` → sensor + control taxonomy kinds (doorbell / contact /
8237
+ * lock / …) for the `sensorKinds` device-event condition.
8238
+ *
8239
+ * Each entry carries `parentKind` so the client can group video subs under
8240
+ * their macro and sensor/control kinds under their category. This surface is
8241
+ * served ADDITIVELY on the `nc.getConditionCatalog` bridge response — no cap
8242
+ * method, no codegen — so it ships train-free with an addon deploy.
8243
+ */
8244
+ /** One selectable taxonomy value: a stable kind id + display label + parent. */
8245
+ var NcTaxonomyEntrySchema = object({
8246
+ /** Stable kind id (e.g. 'person', 'car', 'audio-scream', 'doorbell'). */
8247
+ kind: string(),
8248
+ /** English fallback label (the UI translates via the event-kind i18n key). */
8249
+ label: string(),
8250
+ /** Macro/category parent for grouping ('car' → 'vehicle'); null for a top. */
8251
+ parentKind: string().nullable()
8252
+ });
8253
+ object({
8254
+ videoClasses: array(NcTaxonomyEntrySchema),
8255
+ audioKinds: array(NcTaxonomyEntrySchema),
8256
+ labels: array(NcTaxonomyEntrySchema)
8257
+ });
8258
+ function toEntry(kind, label, parentKind) {
8259
+ return {
8260
+ kind,
8261
+ label,
8262
+ parentKind
8263
+ };
8264
+ }
8265
+ /**
8266
+ * Build the NC taxonomy from `EVENT_TAXONOMY`. Insertion order is preserved
8267
+ * (macros before their subs), which the client relies on for stable grouping.
8268
+ */
8269
+ function buildNcTaxonomy() {
8270
+ const all = Object.values(EVENT_TAXONOMY);
8271
+ return {
8272
+ videoClasses: all.filter((e) => e.category === "detection").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8273
+ audioKinds: all.filter((e) => e.category === "audio" && e.level === "sub").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8274
+ labels: all.filter((e) => e.category === "sensor" || e.category === "control").map((e) => toEntry(e.kind, e.label, e.parentKind))
8275
+ };
8276
+ }
8277
+ Object.freeze(buildNcTaxonomy());
8278
+ /**
8229
8279
  * Error types for the safe expression engine. Two distinct classes so callers
8230
8280
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
8231
8281
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -10934,6 +10984,22 @@ var CameraMetricsSchema = object({
10934
10984
  ])
10935
10985
  });
10936
10986
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number$1() });
10987
+ /**
10988
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
10989
+ * within the frame, so the executor can re-cut a leaf child ROI at native
10990
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
10991
+ */
10992
+ var NativeCropRefSchema = object({
10993
+ /** Handle keying the retained native surface (node-pinned to its owner). */
10994
+ handle: FrameHandleSchema,
10995
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
10996
+ cropFrameSpace: object({
10997
+ x: number$1(),
10998
+ y: number$1(),
10999
+ w: number$1(),
11000
+ h: number$1()
11001
+ })
11002
+ });
10937
11003
  var ModelFormatSchema$1 = _enum([
10938
11004
  "onnx",
10939
11005
  "coreml",
@@ -11209,7 +11275,22 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
11209
11275
  * Omitted ⇒ the runner's default device (current single-engine
11210
11276
  * behaviour). Selects WHICH device pool of the node runs the call.
11211
11277
  */
11212
- deviceKey: string().optional()
11278
+ deviceKey: string().optional(),
11279
+ /**
11280
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
11281
+ * when the parent crop was resolved from the frame's retained NATIVE
11282
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
11283
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
11284
+ * resolution from that surface — the SAME quality path faces already
11285
+ * had — instead of the downscaled parent tile. `handle` keys the native
11286
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
11287
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
11288
+ * the executor's crop-normalized child ROI back into frame-normalized
11289
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
11290
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
11291
+ * (today's behaviour on the fallback path).
11292
+ */
11293
+ nativeCropRef: NativeCropRefSchema.optional()
11213
11294
  }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
11214
11295
  engine: PipelineEngineChoiceSchema.optional(),
11215
11296
  steps: array(PipelineStepInputSchema).min(1),
@@ -11425,7 +11506,11 @@ var DetailResultSchema = object({
11425
11506
  bbox: NativeCropBboxSchema.optional(),
11426
11507
  embedding: string().optional(),
11427
11508
  label: string().optional(),
11428
- alignedCropJpeg: string().optional()
11509
+ alignedCropJpeg: string().optional(),
11510
+ /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
11511
+ * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
11512
+ * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
11513
+ nativeFaceShortSidePx: number$1().optional()
11429
11514
  });
11430
11515
  /**
11431
11516
  * Per-camera tunable ranges + defaults. Single source of truth used
@@ -11439,6 +11524,12 @@ var motionCooldownMsField = {
11439
11524
  default: 3e4,
11440
11525
  step: 500
11441
11526
  };
11527
+ var maxSessionHoldMsField = {
11528
+ min: 0,
11529
+ max: 6e5,
11530
+ default: 12e4,
11531
+ step: 5e3
11532
+ };
11442
11533
  var motionFpsField = {
11443
11534
  min: 1,
11444
11535
  max: 30,
@@ -11586,6 +11677,19 @@ var RunnerCameraConfigSchema = object({
11586
11677
  "on-motion"
11587
11678
  ]).default("always-on"),
11588
11679
  motionCooldownMs: number$1().min(motionCooldownMsField.min).default(motionCooldownMsField.default),
11680
+ /**
11681
+ * Orchestrator-side on-motion session-hold cap (ms). While an on-motion
11682
+ * detection session is active and ≥1 confirmed non-stationary track is
11683
+ * still live, the orchestrator keeps the session open past
11684
+ * `motionCooldownMs` (a slowly-moving subject can stop re-triggering the
11685
+ * camera's VMD yet is still being tracked frame-to-frame) — up to this many
11686
+ * ms since the session opened, after which it closes regardless. `0`
11687
+ * disables the hold (legacy cooldown-only teardown). Not consumed by the
11688
+ * runner itself — carried here so it shares the per-camera device-settings
11689
+ * surface with `motionCooldownMs`; the orchestrator reads it off the
11690
+ * resolved `CameraDetectionConfig`.
11691
+ */
11692
+ maxSessionHoldMs: number$1().min(maxSessionHoldMsField.min).max(maxSessionHoldMsField.max).optional(),
11589
11693
  motionFps: number$1().min(motionFpsField.min).max(motionFpsField.max).default(motionFpsField.default),
11590
11694
  detectionFps: number$1().min(detectionFpsField.min).max(detectionFpsField.max).default(detectionFpsField.default),
11591
11695
  motionStreamId: string(),
@@ -11675,7 +11779,7 @@ var RunnerCameraConfigSchema = object({
11675
11779
  */
11676
11780
  inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
11677
11781
  });
11678
- 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;
11782
+ 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;
11679
11783
  /**
11680
11784
  * Runtime load summary returned by `getLocalLoad`. Used by the orchestrator's
11681
11785
  * load-balancing levels (L2 capacity-based, L3 hardware-aware) to decide
@@ -13529,94 +13633,6 @@ var EnrichedWidgetMetadataSchema = WidgetMetadataSchema.extend({
13529
13633
  bundleUrl: string()
13530
13634
  });
13531
13635
  method(_void(), array(EnrichedWidgetMetadataSchema).readonly());
13532
- var NotificationRuleConditionsSchema = object({
13533
- deviceIds: array(number$1()).readonly().optional(),
13534
- classNames: array(string()).readonly().optional(),
13535
- zoneIds: array(string()).readonly().optional(),
13536
- minConfidence: number$1().optional(),
13537
- source: _enum([
13538
- "pipeline",
13539
- "onboard",
13540
- "any"
13541
- ]).optional(),
13542
- schedule: object({
13543
- days: array(number$1()).readonly(),
13544
- startHour: number$1(),
13545
- endHour: number$1()
13546
- }).optional(),
13547
- cooldownSeconds: number$1().optional(),
13548
- minDwellSeconds: number$1().optional(),
13549
- /** Match against `event.data.eventType` token (e.g. `'press_long'`). When non-empty, only events
13550
- * carrying a matching `data.eventType` string pass this condition. Rules without this field are
13551
- * unaffected (back-compat). Distinct from `rule.eventTypes` which holds EventCategory strings. */
13552
- eventTypeTokens: array(string()).readonly().optional(),
13553
- /** Match detections whose CLIP image embedding is semantically similar to this free-text
13554
- * description. Requires the embedding-encoder cap to have pre-warmed the text vector.
13555
- * `minSimilarity` is the cosine similarity threshold in [0, 1]. */
13556
- clipDescription: object({
13557
- text: string().min(1),
13558
- minSimilarity: number$1().min(0).max(1)
13559
- }).optional(),
13560
- /** Match events whose recognized-entity label (face identity name or plate
13561
- * vehicle name, propagated onto `event.data.label`) is one of these values.
13562
- * Empty/absent → unaffected (back-compat). Enables "notify me when <named
13563
- * vehicle/person> is seen". */
13564
- labels: array(string()).readonly().optional()
13565
- });
13566
- var NotificationRuleTemplateSchema = object({
13567
- title: string(),
13568
- body: string(),
13569
- imageMode: _enum([
13570
- "crop",
13571
- "annotated",
13572
- "full",
13573
- "none"
13574
- ])
13575
- });
13576
- var NotificationRuleSchema = object({
13577
- id: string(),
13578
- name: string(),
13579
- enabled: boolean(),
13580
- eventTypes: array(string()).readonly(),
13581
- conditions: NotificationRuleConditionsSchema,
13582
- outputs: array(string()).readonly(),
13583
- template: NotificationRuleTemplateSchema.optional(),
13584
- priority: _enum([
13585
- "low",
13586
- "normal",
13587
- "high",
13588
- "critical"
13589
- ])
13590
- });
13591
- var NotificationTestResultSchema = object({
13592
- ruleId: string(),
13593
- eventId: string(),
13594
- timestamp: number$1(),
13595
- wouldFire: boolean(),
13596
- reason: string().optional()
13597
- });
13598
- var NotificationHistoryEntrySchema = object({
13599
- id: string(),
13600
- ruleId: string(),
13601
- ruleName: string(),
13602
- eventId: string(),
13603
- timestamp: number$1(),
13604
- outputs: array(string()).readonly(),
13605
- success: boolean(),
13606
- error: string().optional(),
13607
- deviceId: number$1().optional()
13608
- });
13609
- var NotificationHistoryFilterSchema = object({
13610
- ruleId: string().optional(),
13611
- deviceId: number$1().optional(),
13612
- from: number$1().optional(),
13613
- to: number$1().optional(),
13614
- limit: number$1().optional()
13615
- });
13616
- 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({
13617
- ruleId: string(),
13618
- lookbackMinutes: number$1()
13619
- }), object({ results: array(NotificationTestResultSchema).readonly() }), { kind: "mutation" }), method(object({ filter: NotificationHistoryFilterSchema.optional() }), object({ entries: array(NotificationHistoryEntrySchema).readonly() }));
13620
13636
  /**
13621
13637
  * Alerts capability — collection-based internal alert system.
13622
13638
  *
@@ -13803,89 +13819,6 @@ method(object({
13803
13819
  password: string()
13804
13820
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
13805
13821
  /**
13806
- * `login-method` — collection cap through which auth addons contribute
13807
- * their pre-auth login surfaces to the login page. This is the SINGLE,
13808
- * generic mechanism that supersedes the dead `auth.listProviders` reader:
13809
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
13810
- * `login-method` provider and the PUBLIC `auth.listLoginMethods`
13811
- * procedure aggregates them for the unauthenticated login page.
13812
- *
13813
- * A contribution is a discriminated union on `kind`:
13814
- *
13815
- * - `redirect` — a declarative button. The login page renders a generic
13816
- * button that navigates to `startUrl` (an addon-owned HTTP route).
13817
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
13818
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
13819
- * login page needs NO change.
13820
- *
13821
- * - `widget` — a Module-Federation widget the login page mounts (via
13822
- * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
13823
- * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
13824
- * mechanism kept for future use; no shipped addon uses it on the login
13825
- * page (the passkey ceremony below runs natively in the shell instead).
13826
- *
13827
- * - `passkey` — a declarative WebAuthn ceremony the shell renders
13828
- * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
13829
- * a remotely-loaded bundle). Carries the addon's effective `rpId` /
13830
- * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
13831
- * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
13832
- * fetching any remote code pre-auth. Contribution stays unconditional —
13833
- * enrollment state is never leaked pre-auth; visibility is a shell
13834
- * decision.
13835
- *
13836
- * Every contribution carries a `stage`:
13837
- * - `primary` — shown on the first credentials screen (OIDC /
13838
- * magic-link buttons; a future usernameless passkey).
13839
- * - `second-factor` — shown AFTER the password leg, gated on the
13840
- * returned `factors` (passkey-as-2FA today).
13841
- *
13842
- * `mount: skip` — the cap is read server-side by the core auth router
13843
- * (`registry.getCollection('login-method')`), never mounted as its own
13844
- * tRPC router.
13845
- */
13846
- /** When a login method renders in the two-phase login flow. */
13847
- var LoginStageEnum = _enum(["primary", "second-factor"]);
13848
- /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
13849
- var LoginMethodContributionSchema = discriminatedUnion("kind", [
13850
- object({
13851
- kind: literal("redirect"),
13852
- /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
13853
- id: string(),
13854
- /** Operator-facing button label. */
13855
- label: string(),
13856
- /** lucide-react icon name. */
13857
- icon: string().optional(),
13858
- /** Addon-owned HTTP route the button navigates to (GET). */
13859
- startUrl: string(),
13860
- stage: LoginStageEnum
13861
- }),
13862
- object({
13863
- kind: literal("widget"),
13864
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
13865
- id: string(),
13866
- /** Owning addon id — drives the public bundle URL + the MF namespace. */
13867
- addonId: string(),
13868
- /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
13869
- bundle: string(),
13870
- /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
13871
- remote: WidgetRemoteSchema,
13872
- stage: LoginStageEnum
13873
- }),
13874
- object({
13875
- kind: literal("passkey"),
13876
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
13877
- id: string(),
13878
- /** Operator-facing button label. */
13879
- label: string(),
13880
- stage: LoginStageEnum,
13881
- /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
13882
- rpId: string(),
13883
- /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
13884
- origin: string().nullable()
13885
- })
13886
- ]);
13887
- method(_void(), array(LoginMethodContributionSchema).readonly());
13888
- /**
13889
13822
  * Orchestrator-side destination metadata. The orchestrator computes
13890
13823
  * `id = <addonId>:<subId>` from its provider lookup so consumers
13891
13824
  * (admin UI, restore flow) see one canonical key.
@@ -15254,48 +15187,423 @@ method(_void(), array(string()).readonly(), { auth: "admin" }), method(object({
15254
15187
  kind: "mutation",
15255
15188
  auth: "admin"
15256
15189
  });
15257
- var LogLevelSchema = _enum([
15258
- "debug",
15259
- "info",
15260
- "warn",
15261
- "error"
15190
+ /**
15191
+ * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
15192
+ * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15193
+ * caps stay wire-compatible without a circular cap→cap import.
15194
+ *
15195
+ * Errors are a discriminated-union RESULT, never thrown: the shape survives
15196
+ * every transport tier structurally, and failed calls still write usage rows.
15197
+ * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
15198
+ */
15199
+ var LlmUsageSchema = object({
15200
+ inputTokens: number$1(),
15201
+ outputTokens: number$1()
15202
+ });
15203
+ var LlmErrorCodeSchema = _enum([
15204
+ "timeout",
15205
+ "rate-limited",
15206
+ "auth",
15207
+ "refusal",
15208
+ "bad-request",
15209
+ "unavailable",
15210
+ "no-profile",
15211
+ "budget-exceeded",
15212
+ "adapter-error"
15262
15213
  ]);
15263
- var LogEntrySchema = object({
15264
- timestamp: date(),
15265
- level: LogLevelSchema,
15266
- scope: array(string()),
15214
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
15215
+ ok: literal(true),
15216
+ text: string(),
15217
+ model: string(),
15218
+ usage: LlmUsageSchema,
15219
+ truncated: boolean(),
15220
+ latencyMs: number$1()
15221
+ }), object({
15222
+ ok: literal(false),
15223
+ code: LlmErrorCodeSchema,
15267
15224
  message: string(),
15268
- meta: record(string(), unknown()).optional(),
15269
- tags: record(string(), string()).optional()
15270
- });
15271
- method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
15272
- scope: array(string()).optional(),
15273
- level: LogLevelSchema.optional(),
15274
- since: date().optional(),
15275
- until: date().optional(),
15276
- limit: number$1().optional(),
15277
- tags: record(string(), string()).optional()
15278
- }), array(LogEntrySchema).readonly());
15279
- var CpuBreakdownSchema = object({
15280
- total: number$1(),
15281
- user: number$1(),
15282
- system: number$1(),
15283
- irq: number$1(),
15284
- nice: number$1(),
15285
- loadAvg: tuple([
15286
- number$1(),
15287
- number$1(),
15288
- number$1()
15289
- ]),
15290
- cores: number$1()
15225
+ retryAfterMs: number$1().optional()
15226
+ })]);
15227
+ /**
15228
+ * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
15229
+ * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
15230
+ * notification-output.cap.ts:27-31 precedents).
15231
+ */
15232
+ var LlmImageSchema = object({
15233
+ bytes: _instanceof(Uint8Array),
15234
+ mimeType: string()
15291
15235
  });
15292
- var MemoryInfoSchema = object({
15293
- percent: number$1(),
15294
- totalBytes: number$1(),
15295
- usedBytes: number$1(),
15296
- availableBytes: number$1(),
15297
- swapUsedBytes: number$1(),
15298
- swapTotalBytes: number$1()
15236
+ var LlmGenerateBaseInputSchema = object({
15237
+ /** Collection routing (the notification-output posture). */
15238
+ addonId: string().optional(),
15239
+ /** Explicit profile; else the resolution chain (spec §3). */
15240
+ profileId: string().optional(),
15241
+ /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
15242
+ consumer: string(),
15243
+ system: string().optional(),
15244
+ /** v1: single-turn. `messages[]` is a v2 additive field. */
15245
+ prompt: string(),
15246
+ /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
15247
+ jsonSchema: record(string(), unknown()).optional(),
15248
+ /** Per-call override of the profile default. */
15249
+ maxTokens: number$1().int().positive().optional(),
15250
+ temperature: number$1().optional()
15251
+ });
15252
+ /**
15253
+ * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
15254
+ * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
15255
+ * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
15256
+ * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
15257
+ * this only through the `llm` cap's methods.
15258
+ *
15259
+ * One running llama-server child per node in v1 (models are RAM-heavy).
15260
+ * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
15261
+ * watchdog — operator decision #3).
15262
+ */
15263
+ var ManagedModelRefSchema = discriminatedUnion("kind", [
15264
+ object({
15265
+ kind: literal("catalog"),
15266
+ catalogId: string()
15267
+ }),
15268
+ object({
15269
+ kind: literal("url"),
15270
+ url: string(),
15271
+ sha256: string().optional()
15272
+ }),
15273
+ object({
15274
+ kind: literal("path"),
15275
+ path: string()
15276
+ })
15277
+ ]);
15278
+ var ManagedRuntimeConfigSchema = object({
15279
+ /** WHERE the runtime lives — hub or any agent. */
15280
+ nodeId: string(),
15281
+ /** Closed for v1; 'ollama' is a v2 candidate. */
15282
+ engine: _enum(["llama-cpp"]),
15283
+ model: ManagedModelRefSchema,
15284
+ contextSize: number$1().int().default(4096),
15285
+ /** 0 = CPU-only. */
15286
+ gpuLayers: number$1().int().default(0),
15287
+ /** Default: cpus-2, clamped ≥1 (resolved node-side). */
15288
+ threads: number$1().int().optional(),
15289
+ /** Concurrent slots. */
15290
+ parallel: number$1().int().default(1),
15291
+ /** Else lazy: first generate boots it. */
15292
+ autoStart: boolean().default(false),
15293
+ /** 0 = never; frees RAM after quiet periods. */
15294
+ idleStopMinutes: number$1().int().default(30)
15295
+ });
15296
+ var LlmRuntimeStatusSchema = object({
15297
+ /** Status is ALWAYS node-qualified. */
15298
+ nodeId: string(),
15299
+ state: _enum([
15300
+ "stopped",
15301
+ "downloading",
15302
+ "starting",
15303
+ "ready",
15304
+ "crashed",
15305
+ "failed"
15306
+ ]),
15307
+ pid: number$1().optional(),
15308
+ port: number$1().optional(),
15309
+ modelPath: string().optional(),
15310
+ modelId: string().optional(),
15311
+ downloadProgress: number$1().min(0).max(1).optional(),
15312
+ lastError: string().optional(),
15313
+ crashesInWindow: number$1(),
15314
+ /** Child RSS (sampled best-effort). */
15315
+ memoryBytes: number$1().optional(),
15316
+ vramBytes: number$1().optional()
15317
+ });
15318
+ var LlmNodeModelSchema = object({
15319
+ file: string(),
15320
+ sizeBytes: number$1(),
15321
+ catalogId: string().optional(),
15322
+ installedAt: number$1().optional()
15323
+ });
15324
+ var LlmRuntimeDiskUsageSchema = object({
15325
+ nodeId: string(),
15326
+ modelsBytes: number$1(),
15327
+ freeBytes: number$1().optional()
15328
+ });
15329
+ method(LlmGenerateBaseInputSchema.extend({
15330
+ images: array(LlmImageSchema).optional(),
15331
+ runtime: ManagedRuntimeConfigSchema,
15332
+ /** The managed profile's timeout, threaded by the hub provider. */
15333
+ timeoutMs: number$1().int().positive().optional()
15334
+ }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
15335
+ kind: "mutation",
15336
+ auth: "admin"
15337
+ }), method(object({}), _void(), {
15338
+ kind: "mutation",
15339
+ auth: "admin"
15340
+ }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
15341
+ kind: "mutation",
15342
+ auth: "admin"
15343
+ }), method(object({ file: string() }), _void(), {
15344
+ kind: "mutation",
15345
+ auth: "admin"
15346
+ }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
15347
+ /**
15348
+ * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
15349
+ * methods concat-fan across providers; single-row methods route to ONE
15350
+ * provider by the `addonId` in the call input (the notification-output
15351
+ * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
15352
+ * (hub-placed); the cap stays open for future providers.
15353
+ *
15354
+ * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
15355
+ * `apiKey` is a password field — providers REDACT it on read and merge on
15356
+ * write; a stored key NEVER round-trips to a client.
15357
+ */
15358
+ var LlmProfileKindSchema = _enum([
15359
+ "openai-compatible",
15360
+ "openai",
15361
+ "anthropic",
15362
+ "google",
15363
+ "managed-local"
15364
+ ]);
15365
+ var LlmProfileSchema = object({
15366
+ id: string(),
15367
+ name: string(),
15368
+ kind: LlmProfileKindSchema,
15369
+ /** Stamped by the provider — keeps the fanned catalog routable. */
15370
+ addonId: string(),
15371
+ enabled: boolean(),
15372
+ /** Vendor model id, or the managed runtime's loaded model. */
15373
+ model: string(),
15374
+ /** Required for openai-compatible; override for cloud kinds. */
15375
+ baseUrl: string().optional(),
15376
+ /** ConfigUISchema type:'password' — never round-trips (spec §5). */
15377
+ apiKey: string().optional(),
15378
+ supportsVision: boolean(),
15379
+ temperature: number$1().min(0).max(2).optional(),
15380
+ maxTokens: number$1().int().positive().optional(),
15381
+ timeoutMs: number$1().int().positive().default(6e4),
15382
+ extraHeaders: record(string(), string()).optional(),
15383
+ /** kind === 'managed-local' only (spec §4). */
15384
+ runtime: ManagedRuntimeConfigSchema.optional()
15385
+ });
15386
+ /** ConfigUISchema tree passed through untyped on the wire (the
15387
+ * notification-output `ConfigSchemaPassthrough` precedent at
15388
+ * notification-output.cap.ts:151); the exported TS type re-tightens it. */
15389
+ var ConfigSchemaPassthrough$1 = unknown();
15390
+ var LlmProfileKindDescriptorSchema = object({
15391
+ kind: LlmProfileKindSchema,
15392
+ label: string(),
15393
+ icon: string(),
15394
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
15395
+ addonId: string(),
15396
+ configSchema: ConfigSchemaPassthrough$1
15397
+ });
15398
+ var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
15399
+ var LlmDefaultSchema = object({
15400
+ selector: LlmDefaultSelectorSchema,
15401
+ profileId: string()
15402
+ });
15403
+ /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
15404
+ var LlmUsageRollupSchema = object({
15405
+ day: string(),
15406
+ consumer: string(),
15407
+ profileId: string(),
15408
+ calls: number$1(),
15409
+ okCalls: number$1(),
15410
+ errorCalls: number$1(),
15411
+ inputTokens: number$1(),
15412
+ outputTokens: number$1(),
15413
+ avgLatencyMs: number$1()
15414
+ });
15415
+ /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
15416
+ var ManagedModelCatalogEntrySchema = object({
15417
+ id: string(),
15418
+ label: string(),
15419
+ family: string(),
15420
+ purpose: _enum(["text", "vision"]),
15421
+ url: string(),
15422
+ sha256: string(),
15423
+ sizeBytes: number$1(),
15424
+ quantization: string(),
15425
+ /** Load-time guidance shown in the picker. */
15426
+ minRamBytes: number$1(),
15427
+ contextSizeDefault: number$1().int(),
15428
+ /** Vision models: companion projector file. */
15429
+ mmprojUrl: string().optional()
15430
+ });
15431
+ var LlmRuntimeNodeSchema = object({
15432
+ nodeId: string(),
15433
+ reachable: boolean(),
15434
+ status: LlmRuntimeStatusSchema.optional(),
15435
+ disk: LlmRuntimeDiskUsageSchema.optional(),
15436
+ error: string().optional()
15437
+ });
15438
+ var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
15439
+ var ProfileRefInputSchema = object({
15440
+ addonId: string(),
15441
+ profileId: string()
15442
+ });
15443
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
15444
+ kind: "mutation",
15445
+ auth: "admin"
15446
+ }), method(ProfileRefInputSchema, _void(), {
15447
+ kind: "mutation",
15448
+ auth: "admin"
15449
+ }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
15450
+ kind: "mutation",
15451
+ auth: "admin"
15452
+ }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
15453
+ selector: LlmDefaultSelectorSchema,
15454
+ profileId: string().nullable()
15455
+ }), _void(), {
15456
+ kind: "mutation",
15457
+ auth: "admin"
15458
+ }), method(object({
15459
+ since: number$1().optional(),
15460
+ until: number$1().optional(),
15461
+ consumer: string().optional(),
15462
+ profileId: string().optional()
15463
+ }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
15464
+ nodeId: string(),
15465
+ model: ManagedModelRefSchema
15466
+ }), _void(), {
15467
+ kind: "mutation",
15468
+ auth: "admin"
15469
+ }), method(object({
15470
+ nodeId: string(),
15471
+ file: string()
15472
+ }), _void(), {
15473
+ kind: "mutation",
15474
+ auth: "admin"
15475
+ }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
15476
+ kind: "mutation",
15477
+ auth: "admin"
15478
+ }), method(ProfileRefInputSchema, _void(), {
15479
+ kind: "mutation",
15480
+ auth: "admin"
15481
+ });
15482
+ var LogLevelSchema = _enum([
15483
+ "debug",
15484
+ "info",
15485
+ "warn",
15486
+ "error"
15487
+ ]);
15488
+ var LogEntrySchema = object({
15489
+ timestamp: date(),
15490
+ level: LogLevelSchema,
15491
+ scope: array(string()),
15492
+ message: string(),
15493
+ meta: record(string(), unknown()).optional(),
15494
+ tags: record(string(), string()).optional()
15495
+ });
15496
+ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
15497
+ scope: array(string()).optional(),
15498
+ level: LogLevelSchema.optional(),
15499
+ since: date().optional(),
15500
+ until: date().optional(),
15501
+ limit: number$1().optional(),
15502
+ tags: record(string(), string()).optional()
15503
+ }), array(LogEntrySchema).readonly());
15504
+ /**
15505
+ * `login-method` — collection cap through which auth addons contribute
15506
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
15507
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
15508
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
15509
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
15510
+ * procedure aggregates them for the unauthenticated login page.
15511
+ *
15512
+ * A contribution is a discriminated union on `kind`:
15513
+ *
15514
+ * - `redirect` — a declarative button. The login page renders a generic
15515
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
15516
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
15517
+ * ZERO shell-side JS. A future SSO addon plugs in the same way — the
15518
+ * login page needs NO change.
15519
+ *
15520
+ * - `widget` — a Module-Federation widget the login page mounts (via
15521
+ * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
15522
+ * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
15523
+ * mechanism kept for future use; no shipped addon uses it on the login
15524
+ * page (the passkey ceremony below runs natively in the shell instead).
15525
+ *
15526
+ * - `passkey` — a declarative WebAuthn ceremony the shell renders
15527
+ * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
15528
+ * a remotely-loaded bundle). Carries the addon's effective `rpId` /
15529
+ * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
15530
+ * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
15531
+ * fetching any remote code pre-auth. Contribution stays unconditional —
15532
+ * enrollment state is never leaked pre-auth; visibility is a shell
15533
+ * decision.
15534
+ *
15535
+ * Every contribution carries a `stage`:
15536
+ * - `primary` — shown on the first credentials screen (OIDC /
15537
+ * magic-link buttons; a future usernameless passkey).
15538
+ * - `second-factor` — shown AFTER the password leg, gated on the
15539
+ * returned `factors` (passkey-as-2FA today).
15540
+ *
15541
+ * `mount: skip` — the cap is read server-side by the core auth router
15542
+ * (`registry.getCollection('login-method')`), never mounted as its own
15543
+ * tRPC router.
15544
+ */
15545
+ /** When a login method renders in the two-phase login flow. */
15546
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
15547
+ /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
15548
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [
15549
+ object({
15550
+ kind: literal("redirect"),
15551
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
15552
+ id: string(),
15553
+ /** Operator-facing button label. */
15554
+ label: string(),
15555
+ /** lucide-react icon name. */
15556
+ icon: string().optional(),
15557
+ /** Addon-owned HTTP route the button navigates to (GET). */
15558
+ startUrl: string(),
15559
+ stage: LoginStageEnum
15560
+ }),
15561
+ object({
15562
+ kind: literal("widget"),
15563
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
15564
+ id: string(),
15565
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
15566
+ addonId: string(),
15567
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
15568
+ bundle: string(),
15569
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
15570
+ remote: WidgetRemoteSchema,
15571
+ stage: LoginStageEnum
15572
+ }),
15573
+ object({
15574
+ kind: literal("passkey"),
15575
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
15576
+ id: string(),
15577
+ /** Operator-facing button label. */
15578
+ label: string(),
15579
+ stage: LoginStageEnum,
15580
+ /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
15581
+ rpId: string(),
15582
+ /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
15583
+ origin: string().nullable()
15584
+ })
15585
+ ]);
15586
+ method(_void(), array(LoginMethodContributionSchema).readonly());
15587
+ var CpuBreakdownSchema = object({
15588
+ total: number$1(),
15589
+ user: number$1(),
15590
+ system: number$1(),
15591
+ irq: number$1(),
15592
+ nice: number$1(),
15593
+ loadAvg: tuple([
15594
+ number$1(),
15595
+ number$1(),
15596
+ number$1()
15597
+ ]),
15598
+ cores: number$1()
15599
+ });
15600
+ var MemoryInfoSchema = object({
15601
+ percent: number$1(),
15602
+ totalBytes: number$1(),
15603
+ usedBytes: number$1(),
15604
+ availableBytes: number$1(),
15605
+ swapUsedBytes: number$1(),
15606
+ swapTotalBytes: number$1()
15299
15607
  });
15300
15608
  var DiskIoSnapshotSchema = object({
15301
15609
  readBytes: number$1(),
@@ -15748,14 +16056,14 @@ var TargetKindCapsSchema = object({
15748
16056
  * the union is large and not meant for runtime validation here; the exported
15749
16057
  * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
15750
16058
  */
15751
- var ConfigSchemaPassthrough$1 = unknown();
16059
+ var ConfigSchemaPassthrough = unknown();
15752
16060
  var TargetKindSchema = object({
15753
16061
  kind: string(),
15754
16062
  label: string(),
15755
16063
  icon: string(),
15756
16064
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
15757
16065
  addonId: string(),
15758
- configSchema: ConfigSchemaPassthrough$1,
16066
+ configSchema: ConfigSchemaPassthrough,
15759
16067
  supportsDiscovery: boolean(),
15760
16068
  caps: TargetKindCapsSchema
15761
16069
  });
@@ -15808,297 +16116,493 @@ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSche
15808
16116
  enabled: boolean()
15809
16117
  }), _void(), { kind: "mutation" });
15810
16118
  /**
15811
- * Shared LLM generate contracts imported by BOTH `llm.cap.ts` (consumer
15812
- * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15813
- * caps stay wire-compatible without a circular cap→cap import.
16119
+ * notification-rules the Notification Center rule surface (P1 core).
15814
16120
  *
15815
- * Errors are a discriminated-union RESULT, never thrown: the shape survives
15816
- * every transport tier structurally, and failed calls still write usage rows.
15817
- * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
15818
- */
15819
- var LlmUsageSchema = object({
15820
- inputTokens: number$1(),
15821
- outputTokens: number$1()
15822
- });
15823
- var LlmErrorCodeSchema = _enum([
15824
- "timeout",
15825
- "rate-limited",
15826
- "auth",
15827
- "refusal",
15828
- "bad-request",
15829
- "unavailable",
15830
- "no-profile",
15831
- "budget-exceeded",
15832
- "adapter-error"
15833
- ]);
15834
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
15835
- ok: literal(true),
15836
- text: string(),
15837
- model: string(),
15838
- usage: LlmUsageSchema,
15839
- truncated: boolean(),
15840
- latencyMs: number$1()
15841
- }), object({
15842
- ok: literal(false),
15843
- code: LlmErrorCodeSchema,
15844
- message: string(),
15845
- retryAfterMs: number$1().optional()
15846
- })]);
16121
+ * Spec: `docs/superpowers/specs/2026-07-22-notification-center-requirements.md`
16122
+ * (operator decisions D-1/D-2/D-3 are binding):
16123
+ *
16124
+ * - D-2: rule EVALUATION lives in `addon-post-analysis` (the
16125
+ * `notification-center` module), hooked on the durable persistence
16126
+ * moments (object-event insert, TrackCloser.closeExpired) with a
16127
+ * persisted outbox + retry — never the lossy telemetry bus (D8).
16128
+ * - D-3: urgency belongs to the RULE. `delivery: 'immediate'` fires on the
16129
+ * FIRST persisted detection matching the conditions (per-track dedup,
16130
+ * `maxPerTrack` fixed at 1 — see {@link NC_MAX_PER_TRACK_IMMEDIATE});
16131
+ * `delivery: 'track-end'` evaluates the finalized track record at close.
16132
+ * - DISPATCH stays behind `notification-output` (rules reference targets
16133
+ * by id; per-backend params are a passthrough blob capped by the
16134
+ * target kind's own caps/degrade engine).
16135
+ *
16136
+ * P1 scope: admin-authored rules only (`createdBy` stamped from the
16137
+ * server-injected caller identity — the first `caller: 'required'`
16138
+ * adopter). The P1 condition subset is: devices, classes(+exclude),
16139
+ * minConfidence, admin zones (any/all + exclude), weekly schedule
16140
+ * windows, and the optional label/identity/plate matchers. User rules,
16141
+ * private zones, per-recipient fan-out and the wider condition table are
16142
+ * P2+ (see spec §7).
16143
+ *
16144
+ * All schemas here are the single source of truth — `NcRule` etc. are
16145
+ * `z.infer` exports; no duplicate interfaces (the advanced-notifier
16146
+ * schema/interface drift is explicitly not repeated).
16147
+ */
15847
16148
  /**
15848
- * `Uint8Array` is the sanctioned binary conventionsuperjson + the UDS
15849
- * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
15850
- * notification-output.cap.ts:27-31 precedents).
16149
+ * D-3: the trigger/urgency of a rule which persistence moment evaluates it.
16150
+ * The value maps 1:1 onto the evaluated record kind:
16151
+ * - `immediate` ↔ object-event persist (lowest-latency detection burst)
16152
+ * - `track-end` ↔ TrackCloser.closeExpired (finalized track record)
16153
+ * - `device-event` ↔ SensorEventStore insert (doorbell press / sensor state
16154
+ * change of a LINKED device, one row per linked camera)
16155
+ * - `package-event` ↔ PackageDropDetector object-event insert (a `package`
16156
+ * delivery / pick-up)
16157
+ *
16158
+ * `immediate`/`track-end` carry the D-3 urgency semantics; `device-event`/
16159
+ * `package-event` are pure trigger kinds (no urgency dimension). Extending
16160
+ * this one field keeps the schema additive — a rule still declares exactly
16161
+ * one trigger.
15851
16162
  */
15852
- var LlmImageSchema = object({
15853
- bytes: _instanceof(Uint8Array),
15854
- mimeType: string()
16163
+ var NcDeliverySchema = _enum([
16164
+ "immediate",
16165
+ "track-end",
16166
+ "device-event",
16167
+ "package-event"
16168
+ ]);
16169
+ /** Weekly schedule — OR of windows; absence on the rule = always active. */
16170
+ var NcScheduleSchema = object({
16171
+ windows: array(object({
16172
+ /** Days of week the window STARTS on (0 = Sunday … 6 = Saturday). */
16173
+ days: array(number$1().int().min(0).max(6)).min(1),
16174
+ startMinute: number$1().int().min(0).max(1439),
16175
+ endMinute: number$1().int().min(0).max(1439)
16176
+ })).min(1),
16177
+ /** IANA timezone; default = hub host timezone. */
16178
+ timezone: string().optional(),
16179
+ /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
16180
+ invert: boolean().optional()
15855
16181
  });
15856
- var LlmGenerateBaseInputSchema = object({
15857
- /** Collection routing (the notification-output posture). */
15858
- addonId: string().optional(),
15859
- /** Explicit profile; else the resolution chain (spec §3). */
15860
- profileId: string().optional(),
15861
- /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
15862
- consumer: string(),
15863
- system: string().optional(),
15864
- /** v1: single-turn. `messages[]` is a v2 additive field. */
15865
- prompt: string(),
15866
- /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
15867
- jsonSchema: record(string(), unknown()).optional(),
15868
- /** Per-call override of the profile default. */
15869
- maxTokens: number$1().int().positive().optional(),
15870
- temperature: number$1().optional()
16182
+ /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
16183
+ var NcPlateMatcherSchema = object({
16184
+ values: array(string().min(1)).min(1),
16185
+ /** Max Levenshtein distance after normalization (uppercase alphanumeric). */
16186
+ maxDistance: number$1().int().min(0).max(3).default(1)
15871
16187
  });
15872
16188
  /**
15873
- * `llm-runtime` node-side managed llama.cpp executor (spec §4). Registered
15874
- * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
15875
- * a specific node's runtime with `nodePin(profile.runtime.nodeId)` normal
15876
- * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
15877
- * this only through the `llm` cap's methods.
15878
- *
15879
- * One running llama-server child per node in v1 (models are RAM-heavy).
15880
- * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
15881
- * watchdog operator decision #3).
16189
+ * Occupancy condition (DEVICE-EVENT trigger). Fires on a ZoneAnalytics
16190
+ * occupancy edge for a device optionally narrowed to a single admin
16191
+ * `zoneId` and/or object `className`. `op` selects the edge/threshold:
16192
+ * - `became-occupied` (default) count crossed 0 `count`
16193
+ * - `became-free` — count crossed `count` below it
16194
+ * - `>=` / `<=` — count is at/over or at/under `count`
16195
+ * `sustainSeconds` requires the condition hold continuously that long
16196
+ * before firing (debounces flicker; 0 = fire on the first matching edge).
16197
+ * Fail-closed: no ZoneAnalytics snapshot / missing zone / null snapshot ⇒
16198
+ * the condition never matches. Confirmed edge-state survives addon restarts
16199
+ * (declared SQLite collection, reseeded on boot).
15882
16200
  */
15883
- var ManagedModelRefSchema = discriminatedUnion("kind", [
15884
- object({
15885
- kind: literal("catalog"),
15886
- catalogId: string()
15887
- }),
15888
- object({
15889
- kind: literal("url"),
15890
- url: string(),
15891
- sha256: string().optional()
15892
- }),
15893
- object({
15894
- kind: literal("path"),
15895
- path: string()
15896
- })
15897
- ]);
15898
- var ManagedRuntimeConfigSchema = object({
15899
- /** WHERE the runtime lives — hub or any agent. */
15900
- nodeId: string(),
15901
- /** Closed for v1; 'ollama' is a v2 candidate. */
15902
- engine: _enum(["llama-cpp"]),
15903
- model: ManagedModelRefSchema,
15904
- contextSize: number$1().int().default(4096),
15905
- /** 0 = CPU-only. */
15906
- gpuLayers: number$1().int().default(0),
15907
- /** Default: cpus-2, clamped ≥1 (resolved node-side). */
15908
- threads: number$1().int().optional(),
15909
- /** Concurrent slots. */
15910
- parallel: number$1().int().default(1),
15911
- /** Else lazy: first generate boots it. */
15912
- autoStart: boolean().default(false),
15913
- /** 0 = never; frees RAM after quiet periods. */
15914
- idleStopMinutes: number$1().int().default(30)
16201
+ var NcOccupancyConditionSchema = object({
16202
+ /** Admin zone id to scope the count to; absent = whole-frame occupancy. */
16203
+ zoneId: string().optional(),
16204
+ /** Object class to count; absent = any class. */
16205
+ className: string().optional(),
16206
+ op: _enum([
16207
+ "became-occupied",
16208
+ "became-free",
16209
+ ">=",
16210
+ "<="
16211
+ ]).default("became-occupied"),
16212
+ count: number$1().int().min(0).default(1),
16213
+ sustainSeconds: number$1().int().min(0).max(3600).default(15)
16214
+ });
16215
+ /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
16216
+ var NcZoneConditionSchema = object({
16217
+ ids: array(string().min(1)).min(1),
16218
+ /** Quantifier over `ids` — at least one / every one visited. */
16219
+ match: _enum(["any", "all"]).default("any")
15915
16220
  });
15916
- var LlmRuntimeStatusSchema = object({
15917
- /** Status is ALWAYS node-qualified. */
15918
- nodeId: string(),
15919
- state: _enum([
15920
- "stopped",
15921
- "downloading",
15922
- "starting",
15923
- "ready",
15924
- "crashed",
15925
- "failed"
15926
- ]),
15927
- pid: number$1().optional(),
15928
- port: number$1().optional(),
15929
- modelPath: string().optional(),
15930
- modelId: string().optional(),
15931
- downloadProgress: number$1().min(0).max(1).optional(),
15932
- lastError: string().optional(),
15933
- crashesInWindow: number$1(),
15934
- /** Child RSS (sampled best-effort). */
15935
- memoryBytes: number$1().optional(),
15936
- vramBytes: number$1().optional()
16221
+ /**
16222
+ * The P1 condition set — a flat AND of groups; absent group = pass;
16223
+ * membership lists are OR within the list (spec §2.3).
16224
+ */
16225
+ var NcConditionsSchema = object({
16226
+ /** Device scope — absent = all devices. */
16227
+ devices: array(number$1()).optional(),
16228
+ /** Detector class names (any overlap with the record's class set). */
16229
+ classes: array(string().min(1)).optional(),
16230
+ /** Veto classes — any overlap fails the rule. */
16231
+ classesExclude: array(string().min(1)).optional(),
16232
+ /** Minimum detection confidence 0–1 (fails when the record has none). */
16233
+ minConfidence: number$1().min(0).max(1).optional(),
16234
+ /** Admin zone membership over event `zones` / track `zonesVisited`. */
16235
+ zones: NcZoneConditionSchema.optional(),
16236
+ /** Veto zones — any hit fails the rule. */
16237
+ zonesExclude: array(string().min(1)).optional(),
16238
+ /**
16239
+ * Exact (case-insensitive) match on the record's collapsed `label`
16240
+ * (identity name / plate text / subclass).
16241
+ */
16242
+ labelEquals: array(string().min(1)).optional(),
16243
+ /**
16244
+ * Identity matcher. P1 boundary: matched against the record's collapsed
16245
+ * `label` (the identity display name propagated by the face pipeline) —
16246
+ * identity-ID matching rides in P2 when identity ids reach the record.
16247
+ */
16248
+ identities: array(string().min(1)).optional(),
16249
+ /** Fuzzy plate matcher against the record's `label` (plate text). */
16250
+ plates: NcPlateMatcherSchema.optional(),
16251
+ /**
16252
+ * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
16253
+ * Same P1 boundary: matched against the record's collapsed `label` (the
16254
+ * identity display name). A record with NO label passes (nothing to
16255
+ * exclude), unlike the include variant which fails on an absent label.
16256
+ */
16257
+ identitiesExclude: array(string().min(1)).optional(),
16258
+ /**
16259
+ * Minimum server-computed key-event importance in [0,1] (`Track.importance`).
16260
+ * TRACK-END only: importance is scored at track close, so it does not exist
16261
+ * at immediate / object-event evaluation time (see catalog `appliesTo`). At
16262
+ * close the value is threaded via the close-time info (the `Track` clone is
16263
+ * captured before the DB row is updated, so it would otherwise read stale).
16264
+ * Fails when the record carries no importance (never guess quality — the
16265
+ * `minConfidence` precedent). MVP cut: a single scalar threshold.
16266
+ */
16267
+ minImportance: number$1().min(0).max(1).optional(),
16268
+ /**
16269
+ * Minimum track dwell in SECONDS — `(lastSeen − firstSeen) / 1000`.
16270
+ * TRACK-END only: an `immediate` / object-event subject has no closed
16271
+ * lifespan, so a dwell condition never matches immediate delivery
16272
+ * (documented choice — the object-event record carries no `firstSeen`,
16273
+ * so dwell cannot be computed from what the subject actually carries).
16274
+ */
16275
+ minDwellSeconds: number$1().min(0).optional(),
16276
+ /**
16277
+ * Detection provenance filter. `any` (default / absent) matches every
16278
+ * source; otherwise the subject's source must equal it. Legacy records
16279
+ * with no stamped source are treated as `pipeline`. The union spans both
16280
+ * record kinds — object events carry `pipeline` | `onboard`, synthetic
16281
+ * tracks carry `sensor`.
16282
+ */
16283
+ source: _enum([
16284
+ "pipeline",
16285
+ "onboard",
16286
+ "sensor",
16287
+ "any"
16288
+ ]).optional(),
16289
+ /**
16290
+ * Minimum identity / plate MATCH confidence in [0,1] — DISTINCT from the
16291
+ * detector `minConfidence` (that gates the object-detection score; this
16292
+ * gates the recognition/OCR match score). Fails when the subject carries
16293
+ * no label-match confidence (never guess). TRACK-END only: the confidence
16294
+ * lives on the recognition result and reaches the subject at track close.
16295
+ *
16296
+ * What it measures precisely (plumbed at track close — the closer threads
16297
+ * the value into `NcTrackClosedInfo.labelConfidence`, the same seam as
16298
+ * `importance`): the BEST recognition match confidence observed for the
16299
+ * label the track carries at close — for a face, the peak cosine similarity
16300
+ * of the ASSIGNED identity (`FaceMatch.score`, reset on an identity switch);
16301
+ * for a plate, the peak OCR read score of the best-held plate
16302
+ * (`plateText.confidence`). When BOTH a face and a plate were recognized on
16303
+ * one track the higher of the two is used. A track that ended with no
16304
+ * confident identity/plate match carries no value, so the condition fails
16305
+ * closed for it (an un-recognized subject).
16306
+ */
16307
+ minLabelConfidence: number$1().min(0).max(1).optional(),
16308
+ /**
16309
+ * DEVICE-EVENT only. Raw device event-type tokens (`EventFire.eventType`,
16310
+ * e.g. a doorbell `press` / `press_long`) — matched case-insensitively
16311
+ * against the token carried on the device-event subject (extracted from the
16312
+ * event-emitter runtime slice's `lastEvent.eventType`). Fails when the
16313
+ * subject carries no token. Doorbell-pulse / passive-sensor kinds emit no
16314
+ * eventType, so gate those with {@link sensorKinds} instead.
16315
+ */
16316
+ eventTypeTokens: array(string().min(1)).optional(),
16317
+ /**
16318
+ * DEVICE-EVENT only. Sensor/control taxonomy kinds (e.g. `doorbell`,
16319
+ * `contact`, `button`, `device-event`) — matched against the persisted
16320
+ * `SensorEvent.kind` (see `sensor-event-kinds.ts`). Membership is OR.
16321
+ */
16322
+ sensorKinds: array(string().min(1)).optional(),
16323
+ /**
16324
+ * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
16325
+ * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
16326
+ * when the subject's phase does not match (a subject always carries a phase
16327
+ * on the package-event trigger).
16328
+ */
16329
+ packagePhase: _enum([
16330
+ "delivered",
16331
+ "picked-up",
16332
+ "both"
16333
+ ]).optional(),
16334
+ /**
16335
+ * PERSONAL-RULE custom zones (viewer-drawn). Inline normalized polygons
16336
+ * (MaskShape vocabulary). A record passes when its bbox overlaps ANY
16337
+ * listed polygon (ZoneEngine membership semantics). Evaluated only when
16338
+ * the subject carries a bbox; absent bbox ⇒ the condition FAILS.
16339
+ */
16340
+ customZones: array(MaskPolygonShapeSchema).optional(),
16341
+ /**
16342
+ * DEVICE-EVENT only. ZoneAnalytics occupancy edge — fires when a device's
16343
+ * (optionally zone/class-scoped) occupancy count crosses the configured
16344
+ * threshold and holds for `sustainSeconds`. Fail-closed on missing
16345
+ * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
16346
+ */
16347
+ occupancy: NcOccupancyConditionSchema.optional()
15937
16348
  });
15938
- var LlmNodeModelSchema = object({
15939
- file: string(),
15940
- sizeBytes: number$1(),
15941
- catalogId: string().optional(),
15942
- installedAt: number$1().optional()
16349
+ /** One delivery target: a `notification-output` Target ref + passthrough params. */
16350
+ var NcRuleTargetSchema = object({
16351
+ /** `notification-output` Target id. */
16352
+ targetId: string().min(1),
16353
+ /**
16354
+ * Per-backend passthrough. Recognized keys are mapped onto the canonical
16355
+ * Notification (`priority`, `level`, `sound`, `clickUrl`, `ttl`); the
16356
+ * degrade engine drops what the backend can't render.
16357
+ */
16358
+ params: record(string(), unknown()).optional()
15943
16359
  });
15944
- var LlmRuntimeDiskUsageSchema = object({
15945
- nodeId: string(),
15946
- modelsBytes: number$1(),
15947
- freeBytes: number$1().optional()
16360
+ /**
16361
+ * Media attachment policy (P1 still-image subset).
16362
+ * - `best` — the best AVAILABLE subject image at dispatch time (D-3).
16363
+ * - `best-matching` — the media that explains WHY the rule fired: a rule
16364
+ * matched on identities attaches the subject's `faceCrop`, one matched on
16365
+ * plates attaches the `plateCrop`; a rule with no identity/plate condition
16366
+ * (or when the specific crop is missing) degrades to `best`, then
16367
+ * `keyFrame`, then no attachment — never delaying the send. The matched
16368
+ * condition summary is frozen on the outbox row at enqueue (like the rule
16369
+ * name), so the choice never drifts from the record that fired it.
16370
+ * - `keyFrame` — the clean scene frame (no subject box).
16371
+ * - `none` — no attachment.
16372
+ */
16373
+ var NcMediaPolicySchema = object({ attach: _enum([
16374
+ "best",
16375
+ "best-matching",
16376
+ "keyFrame",
16377
+ "none"
16378
+ ]).default("best") });
16379
+ /** Throttle — cooldown survives restarts (rebuilt from the outbox on boot). */
16380
+ var NcThrottleSchema = object({
16381
+ cooldownSec: number$1().int().min(0).max(86400).default(60),
16382
+ /** `rule` = one shared cooldown; `rule-device` = per-camera cooldown. */
16383
+ scope: _enum(["rule", "rule-device"]).default("rule-device")
16384
+ });
16385
+ /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
16386
+ var NcRuleInputSchema = object({
16387
+ name: string().min(1).max(200),
16388
+ enabled: boolean().default(true),
16389
+ delivery: NcDeliverySchema,
16390
+ conditions: NcConditionsSchema.default({}),
16391
+ schedule: NcScheduleSchema.optional(),
16392
+ targets: array(NcRuleTargetSchema).min(1),
16393
+ media: NcMediaPolicySchema.default({ attach: "best" }),
16394
+ throttle: NcThrottleSchema.default({
16395
+ cooldownSec: 60,
16396
+ scope: "rule-device"
16397
+ }),
16398
+ /** `{{var}}` templating over camera/class/label/zones/confidence/time. */
16399
+ template: object({
16400
+ title: string().max(500).optional(),
16401
+ body: string().max(2e3).optional()
16402
+ }).optional(),
16403
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
16404
+ priority: number$1().int().min(1).max(5).default(3),
16405
+ /**
16406
+ * Ownership/visibility key. Absent = admin/global rule (unchanged legacy
16407
+ * behaviour, visible to all, read-only in the viewer). Present = personal
16408
+ * rule owned by this userId. Server-stamped; never trusted from a client.
16409
+ */
16410
+ ownerUserId: string().optional()
15948
16411
  });
15949
- method(LlmGenerateBaseInputSchema.extend({
15950
- images: array(LlmImageSchema).optional(),
15951
- runtime: ManagedRuntimeConfigSchema,
15952
- /** The managed profile's timeout, threaded by the hub provider. */
15953
- timeoutMs: number$1().int().positive().optional()
15954
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
15955
- kind: "mutation",
15956
- auth: "admin"
15957
- }), method(object({}), _void(), {
15958
- kind: "mutation",
15959
- auth: "admin"
15960
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
15961
- kind: "mutation",
15962
- auth: "admin"
15963
- }), method(object({ file: string() }), _void(), {
15964
- kind: "mutation",
15965
- auth: "admin"
15966
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
15967
16412
  /**
15968
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
15969
- * methods concat-fan across providers; single-row methods route to ONE
15970
- * provider by the `addonId` in the call input (the notification-output
15971
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
15972
- * (hub-placed); the cap stays open for future providers.
15973
- *
15974
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
15975
- * `apiKey` is a password field — providers REDACT it on read and merge on
15976
- * write; a stored key NEVER round-trips to a client.
16413
+ * Partial patch for `updateRule` — any subset of the input fields, plus the
16414
+ * persisted-only {@link NcRuleSchema} `disabledTargetIds` set. The latter is
16415
+ * NOT a client-authored input field (it lives on the persisted rule, not the
16416
+ * input), so it is added here explicitly to let the store's per-target opt-out
16417
+ * toggle round-trip through the shared `update` path. Viewer opt-out mutations
16418
+ * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
16419
+ * `updateRule` patch.
15977
16420
  */
15978
- var LlmProfileKindSchema = _enum([
15979
- "openai-compatible",
15980
- "openai",
15981
- "anthropic",
15982
- "google",
15983
- "managed-local"
15984
- ]);
15985
- var LlmProfileSchema = object({
16421
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
16422
+ /** A persisted rule. */
16423
+ var NcRuleSchema = NcRuleInputSchema.extend({
15986
16424
  id: string(),
15987
- name: string(),
15988
- kind: LlmProfileKindSchema,
15989
- /** Stamped by the provider — keeps the fanned catalog routable. */
15990
- addonId: string(),
15991
- enabled: boolean(),
15992
- /** Vendor model id, or the managed runtime's loaded model. */
15993
- model: string(),
15994
- /** Required for openai-compatible; override for cloud kinds. */
15995
- baseUrl: string().optional(),
15996
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
15997
- apiKey: string().optional(),
15998
- supportsVision: boolean(),
15999
- temperature: number$1().min(0).max(2).optional(),
16000
- maxTokens: number$1().int().positive().optional(),
16001
- timeoutMs: number$1().int().positive().default(6e4),
16002
- extraHeaders: record(string(), string()).optional(),
16003
- /** kind === 'managed-local' only (spec §4). */
16004
- runtime: ManagedRuntimeConfigSchema.optional()
16005
- });
16006
- /** ConfigUISchema tree passed through untyped on the wire (the
16007
- * notification-output `ConfigSchemaPassthrough` precedent at
16008
- * notification-output.cap.ts:151); the exported TS type re-tightens it. */
16009
- var ConfigSchemaPassthrough = unknown();
16010
- var LlmProfileKindDescriptorSchema = object({
16011
- kind: LlmProfileKindSchema,
16012
- label: string(),
16013
- icon: string(),
16014
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
16015
- addonId: string(),
16016
- configSchema: ConfigSchemaPassthrough
16017
- });
16018
- var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
16019
- var LlmDefaultSchema = object({
16020
- selector: LlmDefaultSelectorSchema,
16021
- profileId: string()
16425
+ /** userId of the admin who created the rule (server-stamped caller). */
16426
+ createdBy: string(),
16427
+ createdAt: number$1(),
16428
+ updatedAt: number$1(),
16429
+ /**
16430
+ * Per-target opt-out set. A targetId here is suppressed for THIS rule at
16431
+ * send time. Only a target's OWNER may add/remove its id (server-checked
16432
+ * in `nc.setRuleTargetEnabled`). Defaults to empty.
16433
+ */
16434
+ disabledTargetIds: array(string()).default([])
16022
16435
  });
16023
- /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
16024
- var LlmUsageRollupSchema = object({
16025
- day: string(),
16026
- consumer: string(),
16027
- profileId: string(),
16028
- calls: number$1(),
16029
- okCalls: number$1(),
16030
- errorCalls: number$1(),
16031
- inputTokens: number$1(),
16032
- outputTokens: number$1(),
16033
- avgLatencyMs: number$1()
16436
+ var NcTestResultSchema = object({
16437
+ recordId: string(),
16438
+ recordKind: _enum([
16439
+ "object-event",
16440
+ "track",
16441
+ "device-event",
16442
+ "package-event"
16443
+ ]),
16444
+ deviceId: number$1(),
16445
+ timestamp: number$1(),
16446
+ wouldFire: boolean(),
16447
+ /** Condition id that failed (first failing group), when `wouldFire` is false. */
16448
+ failedCondition: string().optional(),
16449
+ className: string().optional(),
16450
+ label: string().optional()
16034
16451
  });
16035
- /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
16036
- var ManagedModelCatalogEntrySchema = object({
16452
+ var NcConditionDescriptorSchema = object({
16453
+ /** Field id inside `NcConditions` (or `'schedule'` for the rule-level group). */
16037
16454
  id: string(),
16455
+ group: _enum([
16456
+ "scope",
16457
+ "class",
16458
+ "zones",
16459
+ "quality",
16460
+ "label",
16461
+ "schedule",
16462
+ "device",
16463
+ "package",
16464
+ "occupancy"
16465
+ ]),
16038
16466
  label: string(),
16039
- family: string(),
16040
- purpose: _enum(["text", "vision"]),
16041
- url: string(),
16042
- sha256: string(),
16043
- sizeBytes: number$1(),
16044
- quantization: string(),
16045
- /** Load-time guidance shown in the picker. */
16046
- minRamBytes: number$1(),
16047
- contextSizeDefault: number$1().int(),
16048
- /** Vision models: companion projector file. */
16049
- mmprojUrl: string().optional()
16467
+ /** Editor widget the UI renders — never hardcode per-condition forms. */
16468
+ valueType: _enum([
16469
+ "deviceIdList",
16470
+ "stringList",
16471
+ "number01",
16472
+ "number",
16473
+ "sourceSelect",
16474
+ "zoneSelection",
16475
+ "zoneIdList",
16476
+ "schedule",
16477
+ "plateMatcher",
16478
+ "packagePhase",
16479
+ "polygonDraw",
16480
+ "occupancy"
16481
+ ]),
16482
+ operator: _enum([
16483
+ "in",
16484
+ "notIn",
16485
+ "anyOf",
16486
+ "allOf",
16487
+ "gte",
16488
+ "fuzzyIn",
16489
+ "withinSchedule"
16490
+ ]),
16491
+ /** Which delivery kinds the condition applies to. */
16492
+ appliesTo: array(NcDeliverySchema),
16493
+ phase: string(),
16494
+ description: string().optional()
16050
16495
  });
16051
- var LlmRuntimeNodeSchema = object({
16052
- nodeId: string(),
16053
- reachable: boolean(),
16054
- status: LlmRuntimeStatusSchema.optional(),
16055
- disk: LlmRuntimeDiskUsageSchema.optional(),
16056
- error: string().optional()
16496
+ /**
16497
+ * The delivery lifecycle status of a history row — a straight read of the
16498
+ * durable outbox row's own status (single source of truth):
16499
+ * - `pending` — enqueued, in-flight or retrying with backoff
16500
+ * - `sent` — delivered (terminal)
16501
+ * - `dead` — dead-lettered after exhausting retries / a permanent
16502
+ * backend rejection / a deleted target (terminal; carries
16503
+ * the failure `error`)
16504
+ *
16505
+ * P1 has no `suppressed-quiet-hours` / `snoozed` states — those ride the P2
16506
+ * user dimension (quiet hours / snooze) and are additive when they land.
16507
+ */
16508
+ var NcHistoryStatusSchema = _enum([
16509
+ "pending",
16510
+ "sent",
16511
+ "dead"
16512
+ ]);
16513
+ /** The evaluated record kind a history row descends from (one per trigger). */
16514
+ var NcHistoryRecordKindSchema = _enum([
16515
+ "object-event",
16516
+ "track-end",
16517
+ "device-event",
16518
+ "package-event"
16519
+ ]);
16520
+ /** Subject summary frozen on the row at fire time (survives rule/record edits). */
16521
+ var NcHistorySubjectSchema = object({
16522
+ className: string(),
16523
+ label: string().optional(),
16524
+ confidence: number$1().optional(),
16525
+ zones: array(string()),
16526
+ timestamp: number$1()
16527
+ });
16528
+ /**
16529
+ * One delivery-history row. This is a read-only VIEW over the durable
16530
+ * outbox row (single source of truth — the same row the drain loop drives;
16531
+ * NO second write path, so history can never drift from delivery state).
16532
+ * The §3.2 fields map directly: `ruleId`/`targetId`/`deviceId` are columns,
16533
+ * `eventRef` is `recordKind`+`recordId`, `timestamps` are `createdAt`
16534
+ * (fire) / `updatedAt` (last transition), `status` + `error` are the
16535
+ * lifecycle. `ruleName` + `subject` are the intent snapshot frozen at
16536
+ * enqueue. `userId?` (per-recipient history) is P2 — no user dimension in
16537
+ * P1 (admin scope only).
16538
+ */
16539
+ var NcHistoryEntrySchema = object({
16540
+ /** Outbox row id — the stable dedup id `ruleId:dedupRef:targetId`. */
16541
+ id: string(),
16542
+ ruleId: string(),
16543
+ /** Rule name frozen at fire time (outlives a later rename / delete). */
16544
+ ruleName: string(),
16545
+ /** The rule urgency/trigger that produced this delivery. */
16546
+ delivery: NcDeliverySchema,
16547
+ targetId: string(),
16548
+ deviceId: number$1(),
16549
+ recordKind: NcHistoryRecordKindSchema,
16550
+ /** Event / track ref of the evaluated record (§3.2 `eventRef`). */
16551
+ recordId: string(),
16552
+ /** Present for track-scoped deliveries (object-event / track-end). */
16553
+ trackId: string().optional(),
16554
+ status: NcHistoryStatusSchema,
16555
+ /** Delivery attempts made so far. */
16556
+ attempts: number$1().int(),
16557
+ /** Fire time (outbox enqueue). */
16558
+ createdAt: number$1(),
16559
+ /** Last transition time (terminal for sent / dead). */
16560
+ updatedAt: number$1(),
16561
+ /** Failure detail — present on a `dead` row. */
16562
+ error: string().optional(),
16563
+ subject: NcHistorySubjectSchema
16057
16564
  });
16058
- var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
16059
- var ProfileRefInputSchema = object({
16060
- addonId: string(),
16061
- profileId: string()
16565
+ /**
16566
+ * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
16567
+ * AND; absent = unbounded on that axis. `since`/`until` bound the fire time
16568
+ * (`createdAt`, epoch ms, inclusive). `limit` is clamped to
16569
+ * {@link NC_HISTORY_LIMIT_MAX}. `userId` (per-recipient filtering) is P2.
16570
+ */
16571
+ var NcHistoryFilterSchema = object({
16572
+ ruleId: string().optional(),
16573
+ deviceId: number$1().optional(),
16574
+ status: NcHistoryStatusSchema.optional(),
16575
+ since: number$1().optional(),
16576
+ until: number$1().optional(),
16577
+ limit: number$1().int().min(1).max(500).default(100)
16062
16578
  });
16063
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
16064
- kind: "mutation",
16065
- auth: "admin"
16066
- }), method(ProfileRefInputSchema, _void(), {
16579
+ 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 }), {
16067
16580
  kind: "mutation",
16068
- auth: "admin"
16069
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
16581
+ auth: "admin",
16582
+ caller: "required"
16583
+ }), method(object({
16584
+ ruleId: string(),
16585
+ patch: NcRulePatchSchema
16586
+ }), object({ rule: NcRuleSchema }), {
16070
16587
  kind: "mutation",
16071
- auth: "admin"
16072
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
16073
- selector: LlmDefaultSelectorSchema,
16074
- profileId: string().nullable()
16075
- }), _void(), {
16588
+ auth: "admin",
16589
+ caller: "required"
16590
+ }), method(object({ ruleId: string() }), object({ success: literal(true) }), {
16076
16591
  kind: "mutation",
16077
16592
  auth: "admin"
16078
16593
  }), method(object({
16079
- since: number$1().optional(),
16080
- until: number$1().optional(),
16081
- consumer: string().optional(),
16082
- profileId: string().optional()
16083
- }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
16084
- nodeId: string(),
16085
- model: ManagedModelRefSchema
16086
- }), _void(), {
16594
+ ruleId: string(),
16595
+ enabled: boolean()
16596
+ }), object({ success: literal(true) }), {
16087
16597
  kind: "mutation",
16088
16598
  auth: "admin"
16089
16599
  }), method(object({
16090
- nodeId: string(),
16091
- file: string()
16092
- }), _void(), {
16093
- kind: "mutation",
16094
- auth: "admin"
16095
- }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
16096
- kind: "mutation",
16097
- auth: "admin"
16098
- }), method(ProfileRefInputSchema, _void(), {
16600
+ rule: NcRuleInputSchema,
16601
+ lookbackMinutes: number$1().int().min(1).max(1440).default(60)
16602
+ }), object({ results: array(NcTestResultSchema) }), {
16099
16603
  kind: "mutation",
16100
16604
  auth: "admin"
16101
- });
16605
+ }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
16102
16606
  /**
16103
16607
  * Zod schemas for persisted record types.
16104
16608
  *
@@ -16784,7 +17288,10 @@ DeviceType.Camera, method(object({ deviceId: number$1() }), array(TrackSchema).r
16784
17288
  }), method(object({
16785
17289
  eventId: string(),
16786
17290
  kind: MediaFileKindEnum.optional()
16787
- }), array(MediaFileSchema).readonly()), method(object({ trackId: string() }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
17291
+ }), array(MediaFileSchema).readonly()), method(object({
17292
+ trackId: string(),
17293
+ kinds: array(MediaFileKindEnum).optional()
17294
+ }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
16788
17295
  deviceId: number$1(),
16789
17296
  timestamp: number$1(),
16790
17297
  frameWidth: number$1(),
@@ -16805,76 +17312,6 @@ DeviceType.Camera, method(object({ deviceId: number$1() }), array(TrackSchema).r
16805
17312
  eventId: string(),
16806
17313
  timestamp: number$1()
16807
17314
  });
16808
- /**
16809
- * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
16810
- * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
16811
- * caps into per-camera event-kind descriptors.
16812
- *
16813
- * The descriptor DATA (color / iconId / labelKey / parentKind / category)
16814
- * is NOT duplicated here — every entry is derived from the single
16815
- * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
16816
- * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
16817
- * control cap means adding one line here (and a taxonomy entry); the anti-
16818
- * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
16819
- * eventful cap is missing.
16820
- */
16821
- /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
16822
- var LEGACY_ICON = {
16823
- motion: "motion",
16824
- audio: "audio",
16825
- person: "person",
16826
- vehicle: "vehicle",
16827
- animal: "animal",
16828
- package: "package",
16829
- door: "door",
16830
- pir: "pir",
16831
- smoke: "smoke",
16832
- water: "water",
16833
- button: "button",
16834
- generic: "generic",
16835
- gas: "smoke",
16836
- vibration: "generic",
16837
- tamper: "generic",
16838
- presence: "person",
16839
- lock: "generic",
16840
- siren: "generic",
16841
- switch: "generic",
16842
- doorbell: "button"
16843
- };
16844
- function legacyIcon(iconId) {
16845
- return LEGACY_ICON[iconId] ?? "generic";
16846
- }
16847
- /**
16848
- * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
16849
- * The anti-drift guard cross-checks this against the eventful caps declared
16850
- * in `packages/types/src/capabilities/*.cap.ts`.
16851
- */
16852
- var CAP_TO_KIND = {
16853
- contact: "contact",
16854
- motion: "motion-sensor",
16855
- smoke: "smoke",
16856
- flood: "flood",
16857
- gas: "gas",
16858
- "carbon-monoxide": "carbon-monoxide",
16859
- vibration: "vibration",
16860
- tamper: "tamper",
16861
- presence: "presence",
16862
- "enum-sensor": "enum-sensor",
16863
- "event-emitter": "device-event",
16864
- "lock-control": "lock",
16865
- switch: "switch",
16866
- button: "button",
16867
- doorbell: "doorbell"
16868
- };
16869
- function buildDescriptor(capName, kind) {
16870
- const t = EVENT_TAXONOMY[kind];
16871
- if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
16872
- return {
16873
- ...t,
16874
- icon: legacyIcon(t.iconId)
16875
- };
16876
- }
16877
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
16878
17315
  var CameraPipelineConfigSchema = object({
16879
17316
  engine: PipelineEngineChoiceSchema.optional(),
16880
17317
  steps: array(PipelineStepInputSchema).readonly(),
@@ -17360,6 +17797,76 @@ method(object({
17360
17797
  auth: "admin"
17361
17798
  });
17362
17799
  /**
17800
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
17801
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
17802
+ * caps into per-camera event-kind descriptors.
17803
+ *
17804
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
17805
+ * is NOT duplicated here — every entry is derived from the single
17806
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
17807
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
17808
+ * control cap means adding one line here (and a taxonomy entry); the anti-
17809
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
17810
+ * eventful cap is missing.
17811
+ */
17812
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
17813
+ var LEGACY_ICON = {
17814
+ motion: "motion",
17815
+ audio: "audio",
17816
+ person: "person",
17817
+ vehicle: "vehicle",
17818
+ animal: "animal",
17819
+ package: "package",
17820
+ door: "door",
17821
+ pir: "pir",
17822
+ smoke: "smoke",
17823
+ water: "water",
17824
+ button: "button",
17825
+ generic: "generic",
17826
+ gas: "smoke",
17827
+ vibration: "generic",
17828
+ tamper: "generic",
17829
+ presence: "person",
17830
+ lock: "generic",
17831
+ siren: "generic",
17832
+ switch: "generic",
17833
+ doorbell: "button"
17834
+ };
17835
+ function legacyIcon(iconId) {
17836
+ return LEGACY_ICON[iconId] ?? "generic";
17837
+ }
17838
+ /**
17839
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
17840
+ * The anti-drift guard cross-checks this against the eventful caps declared
17841
+ * in `packages/types/src/capabilities/*.cap.ts`.
17842
+ */
17843
+ var CAP_TO_KIND = {
17844
+ contact: "contact",
17845
+ motion: "motion-sensor",
17846
+ smoke: "smoke",
17847
+ flood: "flood",
17848
+ gas: "gas",
17849
+ "carbon-monoxide": "carbon-monoxide",
17850
+ vibration: "vibration",
17851
+ tamper: "tamper",
17852
+ presence: "presence",
17853
+ "enum-sensor": "enum-sensor",
17854
+ "event-emitter": "device-event",
17855
+ "lock-control": "lock",
17856
+ switch: "switch",
17857
+ button: "button",
17858
+ doorbell: "doorbell"
17859
+ };
17860
+ function buildDescriptor(capName, kind) {
17861
+ const t = EVENT_TAXONOMY[kind];
17862
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
17863
+ return {
17864
+ ...t,
17865
+ icon: legacyIcon(t.iconId)
17866
+ };
17867
+ }
17868
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
17869
+ /**
17363
17870
  * server-management — per-NODE singleton capability for a node's ROOT
17364
17871
  * package lifecycle (runtime-updatable node packages).
17365
17872
  *
@@ -18814,7 +19321,28 @@ var FaceInfoSchema = object({
18814
19321
  * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`). Absent when the
18815
19322
  * track produced no key frame (e.g. native/onboard source) — the UI falls
18816
19323
  * back to the inline `base64` face crop. */
18817
- keyFrameMediaKey: string().optional()
19324
+ keyFrameMediaKey: string().optional(),
19325
+ /** Winning identity-match cosine (0..1) for this face's track, when an
19326
+ * identity was auto-confirmed. Lets the UI surface WHY a face was assigned
19327
+ * (confidence badge / low-confidence audit). Absent on legacy rows and on
19328
+ * faces that were never auto-recognized. */
19329
+ bestMatchScore: number$1().optional(),
19330
+ /** Native-scale face short side (px) at recognition time, when the runner
19331
+ * measured it. Lets the UI flag low-resolution auto-assignments. Absent on
19332
+ * legacy rows / runners that reported no native measure. */
19333
+ nativeFaceShortSidePx: number$1().optional(),
19334
+ /** SUGGESTED identity for this face — a plausible-but-not-confident match that
19335
+ * MISSED auto-assignment (cosine in the suggestion band, or above threshold
19336
+ * but blocked only by the recognition size floor). Mutually exclusive with
19337
+ * `recognizedIdentityId` (a suggestion is NEVER an assignment): the face stays
19338
+ * UNASSIGNED and everything else keeps treating it as unrecognized — the UI
19339
+ * merely offers a one-tap "is this <name>?" confirm. Absent on legacy rows and
19340
+ * on faces that were auto-assigned or below the suggestion band. (2026-07-24) */
19341
+ suggestedIdentityId: string().optional(),
19342
+ /** Peak identity-match cosine (0..1) for `suggestedIdentityId`, captured at the
19343
+ * same moment as `bestMatchScore` (track peak, at close). Lets the UI rank /
19344
+ * badge suggestion confidence. Present iff `suggestedIdentityId` is. (2026-07-24) */
19345
+ suggestedMatchScore: number$1().optional()
18818
19346
  });
18819
19347
  var FaceFilterEnum = _enum([
18820
19348
  "unassigned",
@@ -20857,36 +21385,6 @@ Object.freeze({
20857
21385
  addonId: null,
20858
21386
  access: "view"
20859
21387
  },
20860
- "advancedNotifier.deleteRule": {
20861
- capName: "advanced-notifier",
20862
- capScope: "system",
20863
- addonId: null,
20864
- access: "delete"
20865
- },
20866
- "advancedNotifier.getHistory": {
20867
- capName: "advanced-notifier",
20868
- capScope: "system",
20869
- addonId: null,
20870
- access: "view"
20871
- },
20872
- "advancedNotifier.getRules": {
20873
- capName: "advanced-notifier",
20874
- capScope: "system",
20875
- addonId: null,
20876
- access: "view"
20877
- },
20878
- "advancedNotifier.testRule": {
20879
- capName: "advanced-notifier",
20880
- capScope: "system",
20881
- addonId: null,
20882
- access: "create"
20883
- },
20884
- "advancedNotifier.upsertRule": {
20885
- capName: "advanced-notifier",
20886
- capScope: "system",
20887
- addonId: null,
20888
- access: "create"
20889
- },
20890
21388
  "alarmPanel.arm": {
20891
21389
  capName: "alarm-panel",
20892
21390
  capScope: "device",
@@ -23191,6 +23689,60 @@ Object.freeze({
23191
23689
  addonId: null,
23192
23690
  access: "create"
23193
23691
  },
23692
+ "notificationRules.createRule": {
23693
+ capName: "notification-rules",
23694
+ capScope: "system",
23695
+ addonId: null,
23696
+ access: "create"
23697
+ },
23698
+ "notificationRules.deleteRule": {
23699
+ capName: "notification-rules",
23700
+ capScope: "system",
23701
+ addonId: null,
23702
+ access: "delete"
23703
+ },
23704
+ "notificationRules.getConditionCatalog": {
23705
+ capName: "notification-rules",
23706
+ capScope: "system",
23707
+ addonId: null,
23708
+ access: "view"
23709
+ },
23710
+ "notificationRules.getHistory": {
23711
+ capName: "notification-rules",
23712
+ capScope: "system",
23713
+ addonId: null,
23714
+ access: "view"
23715
+ },
23716
+ "notificationRules.getRule": {
23717
+ capName: "notification-rules",
23718
+ capScope: "system",
23719
+ addonId: null,
23720
+ access: "view"
23721
+ },
23722
+ "notificationRules.listRules": {
23723
+ capName: "notification-rules",
23724
+ capScope: "system",
23725
+ addonId: null,
23726
+ access: "view"
23727
+ },
23728
+ "notificationRules.setRuleEnabled": {
23729
+ capName: "notification-rules",
23730
+ capScope: "system",
23731
+ addonId: null,
23732
+ access: "create"
23733
+ },
23734
+ "notificationRules.testRule": {
23735
+ capName: "notification-rules",
23736
+ capScope: "system",
23737
+ addonId: null,
23738
+ access: "create"
23739
+ },
23740
+ "notificationRules.updateRule": {
23741
+ capName: "notification-rules",
23742
+ capScope: "system",
23743
+ addonId: null,
23744
+ access: "create"
23745
+ },
23194
23746
  "notifier.cancel": {
23195
23747
  capName: "notifier",
23196
23748
  capScope: "device",