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