@camstack/addon-cloudflare 1.2.4 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- //#region ../types/dist/event-category-D4HJq7Mw.mjs
1
+ //#region ../types/dist/event-category-BLcNejAE.mjs
2
2
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
3
3
  EventCategory["SystemBoot"] = "system.boot";
4
4
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -148,9 +148,6 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
148
148
  EventCategory["RecordingSegmentWritten"] = "recording.segment.written";
149
149
  EventCategory["RecordingPolicyFallback"] = "recording.policy.fallback";
150
150
  EventCategory["RecordingRetentionCompleted"] = "recording.retention.completed";
151
- /** Runner-sampled scrub thumbnail (~1/5 s/camera). Telemetry (D8): a lost
152
- * thumb is a scrub gap the recorder's keyframe backfill covers. */
153
- EventCategory["RecordingThumbSampled"] = "recording.thumb-sampled";
154
151
  /** Export render progress (0–100). Telemetry (D8): a lost tick is a stale
155
152
  * progress bar the client reconciles via `recordingExport.getExport`. */
156
153
  EventCategory["RecordingExportProgress"] = "recording.export.progress";
@@ -6815,7 +6812,6 @@ object({ deviceId: number() }), object({ deviceId: number() }), object({
6815
6812
  patch: record(string(), unknown())
6816
6813
  }), object({ success: literal(true) });
6817
6814
  object({ deviceId: number() }), unknown().nullable();
6818
- /** Shorthand to define a method schema */
6819
6815
  function method(input, output, options) {
6820
6816
  return {
6821
6817
  input,
@@ -6823,6 +6819,7 @@ function method(input, output, options) {
6823
6819
  kind: options?.kind ?? "query",
6824
6820
  auth: options?.auth ?? "protected",
6825
6821
  ...options?.access !== void 0 ? { access: options.access } : {},
6822
+ ...options?.caller !== void 0 ? { caller: options.caller } : {},
6826
6823
  timeoutMs: options?.timeoutMs
6827
6824
  };
6828
6825
  }
@@ -8176,6 +8173,59 @@ for (const l of AUDIO_MACRO_LABELS) {
8176
8173
  /** The complete taxonomy dictionary, keyed by kind. */
8177
8174
  var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
8178
8175
  /**
8176
+ * Notification-Center taxonomy — the fixed vocabulary the NC rule editor
8177
+ * offers as pickers instead of free text. Derived (never hand-listed) from the
8178
+ * single `EVENT_TAXONOMY` dictionary so it stays in lockstep with every other
8179
+ * taxonomy surface (timeline, filters, event page).
8180
+ *
8181
+ * Three buckets, mapped onto the rule editor's `stringList` conditions:
8182
+ * - `videoClasses` → detection classes (person / vehicle / animal + subs)
8183
+ * for the `classes` / `classesExclude` conditions.
8184
+ * - `audioKinds` → audio-analyzer sub kinds (`audio-scream`, …) shown in
8185
+ * the same class picker, grouped under an Audio header.
8186
+ * - `labels` → sensor + control taxonomy kinds (doorbell / contact /
8187
+ * lock / …) for the `sensorKinds` device-event condition.
8188
+ *
8189
+ * Each entry carries `parentKind` so the client can group video subs under
8190
+ * their macro and sensor/control kinds under their category. This surface is
8191
+ * served ADDITIVELY on the `nc.getConditionCatalog` bridge response — no cap
8192
+ * method, no codegen — so it ships train-free with an addon deploy.
8193
+ */
8194
+ /** One selectable taxonomy value: a stable kind id + display label + parent. */
8195
+ var NcTaxonomyEntrySchema = object({
8196
+ /** Stable kind id (e.g. 'person', 'car', 'audio-scream', 'doorbell'). */
8197
+ kind: string(),
8198
+ /** English fallback label (the UI translates via the event-kind i18n key). */
8199
+ label: string(),
8200
+ /** Macro/category parent for grouping ('car' → 'vehicle'); null for a top. */
8201
+ parentKind: string().nullable()
8202
+ });
8203
+ object({
8204
+ videoClasses: array(NcTaxonomyEntrySchema),
8205
+ audioKinds: array(NcTaxonomyEntrySchema),
8206
+ labels: array(NcTaxonomyEntrySchema)
8207
+ });
8208
+ function toEntry(kind, label, parentKind) {
8209
+ return {
8210
+ kind,
8211
+ label,
8212
+ parentKind
8213
+ };
8214
+ }
8215
+ /**
8216
+ * Build the NC taxonomy from `EVENT_TAXONOMY`. Insertion order is preserved
8217
+ * (macros before their subs), which the client relies on for stable grouping.
8218
+ */
8219
+ function buildNcTaxonomy() {
8220
+ const all = Object.values(EVENT_TAXONOMY);
8221
+ return {
8222
+ videoClasses: all.filter((e) => e.category === "detection").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8223
+ audioKinds: all.filter((e) => e.category === "audio" && e.level === "sub").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8224
+ labels: all.filter((e) => e.category === "sensor" || e.category === "control").map((e) => toEntry(e.kind, e.label, e.parentKind))
8225
+ };
8226
+ }
8227
+ Object.freeze(buildNcTaxonomy());
8228
+ /**
8179
8229
  * Error types for the safe expression engine. Two distinct classes so callers
8180
8230
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
8181
8231
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -10884,6 +10934,22 @@ var CameraMetricsSchema = object({
10884
10934
  ])
10885
10935
  });
10886
10936
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
10937
+ /**
10938
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
10939
+ * within the frame, so the executor can re-cut a leaf child ROI at native
10940
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
10941
+ */
10942
+ var NativeCropRefSchema = object({
10943
+ /** Handle keying the retained native surface (node-pinned to its owner). */
10944
+ handle: FrameHandleSchema,
10945
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
10946
+ cropFrameSpace: object({
10947
+ x: number(),
10948
+ y: number(),
10949
+ w: number(),
10950
+ h: number()
10951
+ })
10952
+ });
10887
10953
  var ModelFormatSchema$1 = _enum([
10888
10954
  "onnx",
10889
10955
  "coreml",
@@ -11159,7 +11225,22 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
11159
11225
  * Omitted ⇒ the runner's default device (current single-engine
11160
11226
  * behaviour). Selects WHICH device pool of the node runs the call.
11161
11227
  */
11162
- deviceKey: string().optional()
11228
+ deviceKey: string().optional(),
11229
+ /**
11230
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
11231
+ * when the parent crop was resolved from the frame's retained NATIVE
11232
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
11233
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
11234
+ * resolution from that surface — the SAME quality path faces already
11235
+ * had — instead of the downscaled parent tile. `handle` keys the native
11236
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
11237
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
11238
+ * the executor's crop-normalized child ROI back into frame-normalized
11239
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
11240
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
11241
+ * (today's behaviour on the fallback path).
11242
+ */
11243
+ nativeCropRef: NativeCropRefSchema.optional()
11163
11244
  }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
11164
11245
  engine: PipelineEngineChoiceSchema.optional(),
11165
11246
  steps: array(PipelineStepInputSchema).min(1),
@@ -11375,7 +11456,11 @@ var DetailResultSchema = object({
11375
11456
  bbox: NativeCropBboxSchema.optional(),
11376
11457
  embedding: string().optional(),
11377
11458
  label: string().optional(),
11378
- alignedCropJpeg: string().optional()
11459
+ alignedCropJpeg: string().optional(),
11460
+ /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
11461
+ * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
11462
+ * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
11463
+ nativeFaceShortSidePx: number().optional()
11379
11464
  });
11380
11465
  /**
11381
11466
  * Per-camera tunable ranges + defaults. Single source of truth used
@@ -11389,6 +11474,12 @@ var motionCooldownMsField = {
11389
11474
  default: 3e4,
11390
11475
  step: 500
11391
11476
  };
11477
+ var maxSessionHoldMsField = {
11478
+ min: 0,
11479
+ max: 6e5,
11480
+ default: 12e4,
11481
+ step: 5e3
11482
+ };
11392
11483
  var motionFpsField = {
11393
11484
  min: 1,
11394
11485
  max: 30,
@@ -11536,6 +11627,19 @@ var RunnerCameraConfigSchema = object({
11536
11627
  "on-motion"
11537
11628
  ]).default("always-on"),
11538
11629
  motionCooldownMs: number().min(motionCooldownMsField.min).default(motionCooldownMsField.default),
11630
+ /**
11631
+ * Orchestrator-side on-motion session-hold cap (ms). While an on-motion
11632
+ * detection session is active and ≥1 confirmed non-stationary track is
11633
+ * still live, the orchestrator keeps the session open past
11634
+ * `motionCooldownMs` (a slowly-moving subject can stop re-triggering the
11635
+ * camera's VMD yet is still being tracked frame-to-frame) — up to this many
11636
+ * ms since the session opened, after which it closes regardless. `0`
11637
+ * disables the hold (legacy cooldown-only teardown). Not consumed by the
11638
+ * runner itself — carried here so it shares the per-camera device-settings
11639
+ * surface with `motionCooldownMs`; the orchestrator reads it off the
11640
+ * resolved `CameraDetectionConfig`.
11641
+ */
11642
+ maxSessionHoldMs: number().min(maxSessionHoldMsField.min).max(maxSessionHoldMsField.max).optional(),
11539
11643
  motionFps: number().min(motionFpsField.min).max(motionFpsField.max).default(motionFpsField.default),
11540
11644
  detectionFps: number().min(detectionFpsField.min).max(detectionFpsField.max).default(detectionFpsField.default),
11541
11645
  motionStreamId: string(),
@@ -11625,7 +11729,7 @@ var RunnerCameraConfigSchema = object({
11625
11729
  */
11626
11730
  inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
11627
11731
  });
11628
- 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;
11732
+ 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;
11629
11733
  /**
11630
11734
  * Runtime load summary returned by `getLocalLoad`. Used by the orchestrator's
11631
11735
  * load-balancing levels (L2 capacity-based, L3 hardware-aware) to decide
@@ -13479,94 +13583,6 @@ var EnrichedWidgetMetadataSchema = WidgetMetadataSchema.extend({
13479
13583
  bundleUrl: string()
13480
13584
  });
13481
13585
  method(_void(), array(EnrichedWidgetMetadataSchema).readonly());
13482
- var NotificationRuleConditionsSchema = object({
13483
- deviceIds: array(number()).readonly().optional(),
13484
- classNames: array(string()).readonly().optional(),
13485
- zoneIds: array(string()).readonly().optional(),
13486
- minConfidence: number().optional(),
13487
- source: _enum([
13488
- "pipeline",
13489
- "onboard",
13490
- "any"
13491
- ]).optional(),
13492
- schedule: object({
13493
- days: array(number()).readonly(),
13494
- startHour: number(),
13495
- endHour: number()
13496
- }).optional(),
13497
- cooldownSeconds: number().optional(),
13498
- minDwellSeconds: number().optional(),
13499
- /** Match against `event.data.eventType` token (e.g. `'press_long'`). When non-empty, only events
13500
- * carrying a matching `data.eventType` string pass this condition. Rules without this field are
13501
- * unaffected (back-compat). Distinct from `rule.eventTypes` which holds EventCategory strings. */
13502
- eventTypeTokens: array(string()).readonly().optional(),
13503
- /** Match detections whose CLIP image embedding is semantically similar to this free-text
13504
- * description. Requires the embedding-encoder cap to have pre-warmed the text vector.
13505
- * `minSimilarity` is the cosine similarity threshold in [0, 1]. */
13506
- clipDescription: object({
13507
- text: string().min(1),
13508
- minSimilarity: number().min(0).max(1)
13509
- }).optional(),
13510
- /** Match events whose recognized-entity label (face identity name or plate
13511
- * vehicle name, propagated onto `event.data.label`) is one of these values.
13512
- * Empty/absent → unaffected (back-compat). Enables "notify me when <named
13513
- * vehicle/person> is seen". */
13514
- labels: array(string()).readonly().optional()
13515
- });
13516
- var NotificationRuleTemplateSchema = object({
13517
- title: string(),
13518
- body: string(),
13519
- imageMode: _enum([
13520
- "crop",
13521
- "annotated",
13522
- "full",
13523
- "none"
13524
- ])
13525
- });
13526
- var NotificationRuleSchema = object({
13527
- id: string(),
13528
- name: string(),
13529
- enabled: boolean(),
13530
- eventTypes: array(string()).readonly(),
13531
- conditions: NotificationRuleConditionsSchema,
13532
- outputs: array(string()).readonly(),
13533
- template: NotificationRuleTemplateSchema.optional(),
13534
- priority: _enum([
13535
- "low",
13536
- "normal",
13537
- "high",
13538
- "critical"
13539
- ])
13540
- });
13541
- var NotificationTestResultSchema = object({
13542
- ruleId: string(),
13543
- eventId: string(),
13544
- timestamp: number(),
13545
- wouldFire: boolean(),
13546
- reason: string().optional()
13547
- });
13548
- var NotificationHistoryEntrySchema = object({
13549
- id: string(),
13550
- ruleId: string(),
13551
- ruleName: string(),
13552
- eventId: string(),
13553
- timestamp: number(),
13554
- outputs: array(string()).readonly(),
13555
- success: boolean(),
13556
- error: string().optional(),
13557
- deviceId: number().optional()
13558
- });
13559
- var NotificationHistoryFilterSchema = object({
13560
- ruleId: string().optional(),
13561
- deviceId: number().optional(),
13562
- from: number().optional(),
13563
- to: number().optional(),
13564
- limit: number().optional()
13565
- });
13566
- 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({
13567
- ruleId: string(),
13568
- lookbackMinutes: number()
13569
- }), object({ results: array(NotificationTestResultSchema).readonly() }), { kind: "mutation" }), method(object({ filter: NotificationHistoryFilterSchema.optional() }), object({ entries: array(NotificationHistoryEntrySchema).readonly() }));
13570
13586
  /**
13571
13587
  * Alerts capability — collection-based internal alert system.
13572
13588
  *
@@ -13753,89 +13769,6 @@ method(object({
13753
13769
  password: string()
13754
13770
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
13755
13771
  /**
13756
- * `login-method` — collection cap through which auth addons contribute
13757
- * their pre-auth login surfaces to the login page. This is the SINGLE,
13758
- * generic mechanism that supersedes the dead `auth.listProviders` reader:
13759
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
13760
- * `login-method` provider and the PUBLIC `auth.listLoginMethods`
13761
- * procedure aggregates them for the unauthenticated login page.
13762
- *
13763
- * A contribution is a discriminated union on `kind`:
13764
- *
13765
- * - `redirect` — a declarative button. The login page renders a generic
13766
- * button that navigates to `startUrl` (an addon-owned HTTP route).
13767
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
13768
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
13769
- * login page needs NO change.
13770
- *
13771
- * - `widget` — a Module-Federation widget the login page mounts (via
13772
- * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
13773
- * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
13774
- * mechanism kept for future use; no shipped addon uses it on the login
13775
- * page (the passkey ceremony below runs natively in the shell instead).
13776
- *
13777
- * - `passkey` — a declarative WebAuthn ceremony the shell renders
13778
- * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
13779
- * a remotely-loaded bundle). Carries the addon's effective `rpId` /
13780
- * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
13781
- * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
13782
- * fetching any remote code pre-auth. Contribution stays unconditional —
13783
- * enrollment state is never leaked pre-auth; visibility is a shell
13784
- * decision.
13785
- *
13786
- * Every contribution carries a `stage`:
13787
- * - `primary` — shown on the first credentials screen (OIDC /
13788
- * magic-link buttons; a future usernameless passkey).
13789
- * - `second-factor` — shown AFTER the password leg, gated on the
13790
- * returned `factors` (passkey-as-2FA today).
13791
- *
13792
- * `mount: skip` — the cap is read server-side by the core auth router
13793
- * (`registry.getCollection('login-method')`), never mounted as its own
13794
- * tRPC router.
13795
- */
13796
- /** When a login method renders in the two-phase login flow. */
13797
- var LoginStageEnum = _enum(["primary", "second-factor"]);
13798
- /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
13799
- var LoginMethodContributionSchema = discriminatedUnion("kind", [
13800
- object({
13801
- kind: literal("redirect"),
13802
- /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
13803
- id: string(),
13804
- /** Operator-facing button label. */
13805
- label: string(),
13806
- /** lucide-react icon name. */
13807
- icon: string().optional(),
13808
- /** Addon-owned HTTP route the button navigates to (GET). */
13809
- startUrl: string(),
13810
- stage: LoginStageEnum
13811
- }),
13812
- object({
13813
- kind: literal("widget"),
13814
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
13815
- id: string(),
13816
- /** Owning addon id — drives the public bundle URL + the MF namespace. */
13817
- addonId: string(),
13818
- /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
13819
- bundle: string(),
13820
- /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
13821
- remote: WidgetRemoteSchema,
13822
- stage: LoginStageEnum
13823
- }),
13824
- object({
13825
- kind: literal("passkey"),
13826
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
13827
- id: string(),
13828
- /** Operator-facing button label. */
13829
- label: string(),
13830
- stage: LoginStageEnum,
13831
- /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
13832
- rpId: string(),
13833
- /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
13834
- origin: string().nullable()
13835
- })
13836
- ]);
13837
- method(_void(), array(LoginMethodContributionSchema).readonly());
13838
- /**
13839
13772
  * Orchestrator-side destination metadata. The orchestrator computes
13840
13773
  * `id = <addonId>:<subId>` from its provider lookup so consumers
13841
13774
  * (admin UI, restore flow) see one canonical key.
@@ -14209,7 +14142,8 @@ function customAction(input, output, options) {
14209
14142
  output,
14210
14143
  kind: options?.kind ?? "query",
14211
14144
  auth: options?.auth ?? "protected",
14212
- scope: options?.scope ?? { kind: "system" }
14145
+ scope: options?.scope ?? { kind: "system" },
14146
+ ...options?.caller ? { caller: "required" } : {}
14213
14147
  };
14214
14148
  }
14215
14149
  /**
@@ -15200,236 +15134,611 @@ method(_void(), array(string()).readonly(), { auth: "admin" }), method(object({
15200
15134
  kind: "mutation",
15201
15135
  auth: "admin"
15202
15136
  });
15203
- var LogLevelSchema = _enum([
15204
- "debug",
15205
- "info",
15206
- "warn",
15207
- "error"
15137
+ /**
15138
+ * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
15139
+ * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15140
+ * caps stay wire-compatible without a circular cap→cap import.
15141
+ *
15142
+ * Errors are a discriminated-union RESULT, never thrown: the shape survives
15143
+ * every transport tier structurally, and failed calls still write usage rows.
15144
+ * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
15145
+ */
15146
+ var LlmUsageSchema = object({
15147
+ inputTokens: number(),
15148
+ outputTokens: number()
15149
+ });
15150
+ var LlmErrorCodeSchema = _enum([
15151
+ "timeout",
15152
+ "rate-limited",
15153
+ "auth",
15154
+ "refusal",
15155
+ "bad-request",
15156
+ "unavailable",
15157
+ "no-profile",
15158
+ "budget-exceeded",
15159
+ "adapter-error"
15208
15160
  ]);
15209
- var LogEntrySchema = object({
15210
- timestamp: date(),
15211
- level: LogLevelSchema,
15212
- scope: array(string()),
15161
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
15162
+ ok: literal(true),
15163
+ text: string(),
15164
+ model: string(),
15165
+ usage: LlmUsageSchema,
15166
+ truncated: boolean(),
15167
+ latencyMs: number()
15168
+ }), object({
15169
+ ok: literal(false),
15170
+ code: LlmErrorCodeSchema,
15213
15171
  message: string(),
15214
- meta: record(string(), unknown()).optional(),
15215
- tags: record(string(), string()).optional()
15172
+ retryAfterMs: number().optional()
15173
+ })]);
15174
+ /**
15175
+ * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
15176
+ * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
15177
+ * notification-output.cap.ts:27-31 precedents).
15178
+ */
15179
+ var LlmImageSchema = object({
15180
+ bytes: _instanceof(Uint8Array),
15181
+ mimeType: string()
15216
15182
  });
15217
- method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
15218
- scope: array(string()).optional(),
15219
- level: LogLevelSchema.optional(),
15220
- since: date().optional(),
15221
- until: date().optional(),
15222
- limit: number().optional(),
15223
- tags: record(string(), string()).optional()
15224
- }), array(LogEntrySchema).readonly());
15225
- var CpuBreakdownSchema = object({
15226
- total: number(),
15227
- user: number(),
15228
- system: number(),
15229
- irq: number(),
15230
- nice: number(),
15231
- loadAvg: tuple([
15232
- number(),
15233
- number(),
15234
- number()
15235
- ]),
15236
- cores: number()
15183
+ var LlmGenerateBaseInputSchema = object({
15184
+ /** Collection routing (the notification-output posture). */
15185
+ addonId: string().optional(),
15186
+ /** Explicit profile; else the resolution chain (spec §3). */
15187
+ profileId: string().optional(),
15188
+ /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
15189
+ consumer: string(),
15190
+ system: string().optional(),
15191
+ /** v1: single-turn. `messages[]` is a v2 additive field. */
15192
+ prompt: string(),
15193
+ /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
15194
+ jsonSchema: record(string(), unknown()).optional(),
15195
+ /** Per-call override of the profile default. */
15196
+ maxTokens: number().int().positive().optional(),
15197
+ temperature: number().optional()
15237
15198
  });
15238
- var MemoryInfoSchema = object({
15239
- percent: number(),
15240
- totalBytes: number(),
15241
- usedBytes: number(),
15242
- availableBytes: number(),
15243
- swapUsedBytes: number(),
15244
- swapTotalBytes: number()
15245
- });
15246
- var DiskIoSnapshotSchema = object({
15247
- readBytes: number(),
15248
- writeBytes: number(),
15249
- readOps: number(),
15250
- writeOps: number(),
15251
- timestampMs: number()
15252
- });
15253
- var NetworkIoSnapshotSchema = object({
15254
- rxBytes: number(),
15255
- txBytes: number(),
15256
- rxPackets: number(),
15257
- txPackets: number(),
15258
- rxErrors: number(),
15259
- txErrors: number(),
15260
- timestampMs: number()
15261
- });
15262
- var MetricsGpuInfoSchema = object({
15263
- utilization: number(),
15264
- model: string(),
15265
- memoryUsedBytes: number(),
15266
- memoryTotalBytes: number(),
15267
- temperature: number().nullable()
15268
- });
15269
- var ProcessResourceInfoSchema = object({
15270
- openFds: number(),
15271
- threadCount: number(),
15272
- activeHandles: number(),
15273
- activeRequests: number()
15274
- });
15275
- var PressureAvgsSchema = object({
15276
- avg10: number(),
15277
- avg60: number(),
15278
- avg300: number()
15279
- });
15280
- var PressureInfoSchema = object({
15281
- some: PressureAvgsSchema,
15282
- full: PressureAvgsSchema.nullable()
15283
- });
15284
- var SystemResourceSnapshotSchema = object({
15285
- cpu: CpuBreakdownSchema,
15286
- memory: MemoryInfoSchema,
15287
- gpu: MetricsGpuInfoSchema.nullable(),
15288
- network: NetworkIoSnapshotSchema,
15289
- disk: DiskIoSnapshotSchema,
15290
- pressure: object({
15291
- cpu: PressureInfoSchema.nullable(),
15292
- memory: PressureInfoSchema.nullable(),
15293
- io: PressureInfoSchema.nullable()
15199
+ /**
15200
+ * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
15201
+ * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
15202
+ * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
15203
+ * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
15204
+ * this only through the `llm` cap's methods.
15205
+ *
15206
+ * One running llama-server child per node in v1 (models are RAM-heavy).
15207
+ * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
15208
+ * watchdog — operator decision #3).
15209
+ */
15210
+ var ManagedModelRefSchema = discriminatedUnion("kind", [
15211
+ object({
15212
+ kind: literal("catalog"),
15213
+ catalogId: string()
15294
15214
  }),
15295
- process: ProcessResourceInfoSchema,
15296
- cpuTemperature: number().nullable(),
15297
- timestampMs: number()
15298
- });
15299
- var DiskSpaceInfoSchema = object({
15300
- path: string(),
15301
- totalBytes: number(),
15302
- usedBytes: number(),
15303
- availableBytes: number(),
15304
- percent: number()
15305
- });
15306
- var PidResourceStatsSchema = object({
15307
- pid: number(),
15308
- cpu: number(),
15309
- memory: number(),
15310
- /**
15311
- * Private (anonymous) resident bytes — the per-process V8 heap + native
15312
- * allocations NOT shared with other processes (Linux RssAnon). This is the
15313
- * "real" per-runner cost; summing it across runners is meaningful, unlike
15314
- * `memory` (RSS), which double-counts the shared mmap'd framework code.
15315
- * Undefined where /proc is unavailable (e.g. macOS).
15316
- */
15317
- privateBytes: number().optional(),
15318
- /**
15319
- * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
15320
- * code shared copy-on-write across runners. Undefined on macOS.
15321
- */
15322
- sharedBytes: number().optional()
15215
+ object({
15216
+ kind: literal("url"),
15217
+ url: string(),
15218
+ sha256: string().optional()
15219
+ }),
15220
+ object({
15221
+ kind: literal("path"),
15222
+ path: string()
15223
+ })
15224
+ ]);
15225
+ var ManagedRuntimeConfigSchema = object({
15226
+ /** WHERE the runtime lives — hub or any agent. */
15227
+ nodeId: string(),
15228
+ /** Closed for v1; 'ollama' is a v2 candidate. */
15229
+ engine: _enum(["llama-cpp"]),
15230
+ model: ManagedModelRefSchema,
15231
+ contextSize: number().int().default(4096),
15232
+ /** 0 = CPU-only. */
15233
+ gpuLayers: number().int().default(0),
15234
+ /** Default: cpus-2, clamped ≥1 (resolved node-side). */
15235
+ threads: number().int().optional(),
15236
+ /** Concurrent slots. */
15237
+ parallel: number().int().default(1),
15238
+ /** Else lazy: first generate boots it. */
15239
+ autoStart: boolean().default(false),
15240
+ /** 0 = never; frees RAM after quiet periods. */
15241
+ idleStopMinutes: number().int().default(30)
15323
15242
  });
15324
- var AddonInstanceSchema = object({
15325
- addonId: string(),
15243
+ var LlmRuntimeStatusSchema = object({
15244
+ /** Status is ALWAYS node-qualified. */
15326
15245
  nodeId: string(),
15327
- role: _enum(["hub", "worker"]),
15328
- pid: number(),
15329
15246
  state: _enum([
15330
- "starting",
15331
- "running",
15332
- "stopping",
15333
15247
  "stopped",
15334
- "crashed"
15335
- ]),
15336
- uptimeSec: number()
15337
- });
15338
- var NodeProcessSchema = object({
15339
- pid: number(),
15340
- ppid: number(),
15341
- pgid: number(),
15342
- classification: _enum([
15343
- "root",
15344
- "managed",
15345
- "system",
15346
- "ghost"
15248
+ "downloading",
15249
+ "starting",
15250
+ "ready",
15251
+ "crashed",
15252
+ "failed"
15347
15253
  ]),
15348
- /** `$process` addon binding when `managed`, else null. */
15349
- addonId: string().nullable(),
15350
- /** Kernel-reported nodeId when the process is a known agent/worker. */
15351
- nodeId: string().nullable(),
15352
- /** Truncated command line. */
15353
- command: string(),
15354
- cpuPercent: number(),
15355
- memoryRssBytes: number(),
15356
- /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
15357
- uptimeSec: number(),
15358
- /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
15359
- orphaned: boolean()
15360
- });
15361
- var KillProcessInputSchema = object({
15362
- pid: number(),
15363
- /** Force = SIGKILL. Default is SIGTERM. */
15364
- force: boolean().optional()
15365
- });
15366
- var KillProcessResultSchema = object({
15367
- success: boolean(),
15368
- reason: string().optional(),
15369
- signal: _enum(["SIGTERM", "SIGKILL"]).optional()
15370
- });
15371
- var DumpHeapSnapshotInputSchema = object({
15372
- /** The addon whose runner should dump a heap snapshot. */
15373
- addonId: string() });
15374
- var DumpHeapSnapshotResultSchema = object({
15375
- success: boolean(),
15376
- /** Path of the written .heapsnapshot inside the runner's container/host. */
15377
- path: string().optional(),
15378
- /** Process pid that was signalled. */
15379
15254
  pid: number().optional(),
15380
- reason: string().optional()
15255
+ port: number().optional(),
15256
+ modelPath: string().optional(),
15257
+ modelId: string().optional(),
15258
+ downloadProgress: number().min(0).max(1).optional(),
15259
+ lastError: string().optional(),
15260
+ crashesInWindow: number(),
15261
+ /** Child RSS (sampled best-effort). */
15262
+ memoryBytes: number().optional(),
15263
+ vramBytes: number().optional()
15381
15264
  });
15382
- var SystemMetricsSchema = object({
15383
- cpuPercent: number(),
15384
- memoryPercent: number(),
15385
- memoryUsedMB: number(),
15386
- memoryTotalMB: number(),
15387
- diskPercent: number().optional(),
15388
- temperature: number().optional(),
15389
- gpuPercent: number().optional(),
15390
- gpuMemoryPercent: number().optional()
15265
+ var LlmNodeModelSchema = object({
15266
+ file: string(),
15267
+ sizeBytes: number(),
15268
+ catalogId: string().optional(),
15269
+ installedAt: number().optional()
15391
15270
  });
15392
- method(_void(), SystemResourceSnapshotSchema), method(_void(), SystemResourceSnapshotSchema.nullable()), method(_void(), SystemMetricsSchema), method(object({ dirPath: string() }), DiskSpaceInfoSchema), method(_void(), MetricsGpuInfoSchema.nullable()), method(_void(), number().nullable()), method(object({ pids: array(number()) }), array(PidResourceStatsSchema)), method(_void(), array(AddonInstanceSchema).readonly()), method(object({ addonId: string() }), PidResourceStatsSchema.nullable()), method(_void(), array(NodeProcessSchema).readonly()), method(KillProcessInputSchema, KillProcessResultSchema, {
15271
+ var LlmRuntimeDiskUsageSchema = object({
15272
+ nodeId: string(),
15273
+ modelsBytes: number(),
15274
+ freeBytes: number().optional()
15275
+ });
15276
+ method(LlmGenerateBaseInputSchema.extend({
15277
+ images: array(LlmImageSchema).optional(),
15278
+ runtime: ManagedRuntimeConfigSchema,
15279
+ /** The managed profile's timeout, threaded by the hub provider. */
15280
+ timeoutMs: number().int().positive().optional()
15281
+ }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
15393
15282
  kind: "mutation",
15394
15283
  auth: "admin"
15395
- }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
15284
+ }), method(object({}), _void(), {
15396
15285
  kind: "mutation",
15397
15286
  auth: "admin"
15398
- });
15399
- method(object({
15400
- sourceUrl: string(),
15401
- metadata: ModelConvertMetadataSchema,
15402
- targets: array(ConvertTargetSchema).min(1).readonly(),
15403
- calibrationRef: string().optional(),
15404
- sessionId: string().optional()
15405
- }), ConvertResultSchema, {
15287
+ }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
15406
15288
  kind: "mutation",
15407
- auth: "admin",
15408
- timeoutMs: 6e5
15409
- });
15410
- method(object({
15411
- nodeId: string(),
15412
- modelId: string(),
15413
- format: _enum(MODEL_FORMATS),
15414
- entry: ModelCatalogEntrySchema
15415
- }), object({
15416
- ok: boolean(),
15417
- /** sha256 of the staged tarball (empty for a hub-local no-op). */
15418
- sha256: string(),
15419
- bytes: number(),
15420
- /** The target node's modelsDir the artifact landed in. */
15421
- path: string()
15422
- }), {
15289
+ auth: "admin"
15290
+ }), method(object({ file: string() }), _void(), {
15423
15291
  kind: "mutation",
15424
15292
  auth: "admin"
15425
- });
15293
+ }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
15426
15294
  /**
15427
- * `mqtt-broker` — broker-registry cap.
15428
- *
15429
- * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
15430
- * MQTT brokers (external + optionally an embedded `aedes`-backed one)
15431
- * and (b) the connection details a consumer addon needs to spin up
15432
- * its OWN `mqtt.js` client.
15295
+ * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
15296
+ * methods concat-fan across providers; single-row methods route to ONE
15297
+ * provider by the `addonId` in the call input (the notification-output
15298
+ * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
15299
+ * (hub-placed); the cap stays open for future providers.
15300
+ *
15301
+ * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
15302
+ * `apiKey` is a password field — providers REDACT it on read and merge on
15303
+ * write; a stored key NEVER round-trips to a client.
15304
+ */
15305
+ var LlmProfileKindSchema = _enum([
15306
+ "openai-compatible",
15307
+ "openai",
15308
+ "anthropic",
15309
+ "google",
15310
+ "managed-local"
15311
+ ]);
15312
+ var LlmProfileSchema = object({
15313
+ id: string(),
15314
+ name: string(),
15315
+ kind: LlmProfileKindSchema,
15316
+ /** Stamped by the provider — keeps the fanned catalog routable. */
15317
+ addonId: string(),
15318
+ enabled: boolean(),
15319
+ /** Vendor model id, or the managed runtime's loaded model. */
15320
+ model: string(),
15321
+ /** Required for openai-compatible; override for cloud kinds. */
15322
+ baseUrl: string().optional(),
15323
+ /** ConfigUISchema type:'password' — never round-trips (spec §5). */
15324
+ apiKey: string().optional(),
15325
+ supportsVision: boolean(),
15326
+ temperature: number().min(0).max(2).optional(),
15327
+ maxTokens: number().int().positive().optional(),
15328
+ timeoutMs: number().int().positive().default(6e4),
15329
+ extraHeaders: record(string(), string()).optional(),
15330
+ /** kind === 'managed-local' only (spec §4). */
15331
+ runtime: ManagedRuntimeConfigSchema.optional()
15332
+ });
15333
+ /** ConfigUISchema tree passed through untyped on the wire (the
15334
+ * notification-output `ConfigSchemaPassthrough` precedent at
15335
+ * notification-output.cap.ts:151); the exported TS type re-tightens it. */
15336
+ var ConfigSchemaPassthrough$1 = unknown();
15337
+ var LlmProfileKindDescriptorSchema = object({
15338
+ kind: LlmProfileKindSchema,
15339
+ label: string(),
15340
+ icon: string(),
15341
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
15342
+ addonId: string(),
15343
+ configSchema: ConfigSchemaPassthrough$1
15344
+ });
15345
+ var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
15346
+ var LlmDefaultSchema = object({
15347
+ selector: LlmDefaultSelectorSchema,
15348
+ profileId: string()
15349
+ });
15350
+ /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
15351
+ var LlmUsageRollupSchema = object({
15352
+ day: string(),
15353
+ consumer: string(),
15354
+ profileId: string(),
15355
+ calls: number(),
15356
+ okCalls: number(),
15357
+ errorCalls: number(),
15358
+ inputTokens: number(),
15359
+ outputTokens: number(),
15360
+ avgLatencyMs: number()
15361
+ });
15362
+ /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
15363
+ var ManagedModelCatalogEntrySchema = object({
15364
+ id: string(),
15365
+ label: string(),
15366
+ family: string(),
15367
+ purpose: _enum(["text", "vision"]),
15368
+ url: string(),
15369
+ sha256: string(),
15370
+ sizeBytes: number(),
15371
+ quantization: string(),
15372
+ /** Load-time guidance shown in the picker. */
15373
+ minRamBytes: number(),
15374
+ contextSizeDefault: number().int(),
15375
+ /** Vision models: companion projector file. */
15376
+ mmprojUrl: string().optional()
15377
+ });
15378
+ var LlmRuntimeNodeSchema = object({
15379
+ nodeId: string(),
15380
+ reachable: boolean(),
15381
+ status: LlmRuntimeStatusSchema.optional(),
15382
+ disk: LlmRuntimeDiskUsageSchema.optional(),
15383
+ error: string().optional()
15384
+ });
15385
+ var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
15386
+ var ProfileRefInputSchema = object({
15387
+ addonId: string(),
15388
+ profileId: string()
15389
+ });
15390
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
15391
+ kind: "mutation",
15392
+ auth: "admin"
15393
+ }), method(ProfileRefInputSchema, _void(), {
15394
+ kind: "mutation",
15395
+ auth: "admin"
15396
+ }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
15397
+ kind: "mutation",
15398
+ auth: "admin"
15399
+ }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
15400
+ selector: LlmDefaultSelectorSchema,
15401
+ profileId: string().nullable()
15402
+ }), _void(), {
15403
+ kind: "mutation",
15404
+ auth: "admin"
15405
+ }), method(object({
15406
+ since: number().optional(),
15407
+ until: number().optional(),
15408
+ consumer: string().optional(),
15409
+ profileId: string().optional()
15410
+ }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
15411
+ nodeId: string(),
15412
+ model: ManagedModelRefSchema
15413
+ }), _void(), {
15414
+ kind: "mutation",
15415
+ auth: "admin"
15416
+ }), method(object({
15417
+ nodeId: string(),
15418
+ file: string()
15419
+ }), _void(), {
15420
+ kind: "mutation",
15421
+ auth: "admin"
15422
+ }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
15423
+ kind: "mutation",
15424
+ auth: "admin"
15425
+ }), method(ProfileRefInputSchema, _void(), {
15426
+ kind: "mutation",
15427
+ auth: "admin"
15428
+ });
15429
+ var LogLevelSchema = _enum([
15430
+ "debug",
15431
+ "info",
15432
+ "warn",
15433
+ "error"
15434
+ ]);
15435
+ var LogEntrySchema = object({
15436
+ timestamp: date(),
15437
+ level: LogLevelSchema,
15438
+ scope: array(string()),
15439
+ message: string(),
15440
+ meta: record(string(), unknown()).optional(),
15441
+ tags: record(string(), string()).optional()
15442
+ });
15443
+ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
15444
+ scope: array(string()).optional(),
15445
+ level: LogLevelSchema.optional(),
15446
+ since: date().optional(),
15447
+ until: date().optional(),
15448
+ limit: number().optional(),
15449
+ tags: record(string(), string()).optional()
15450
+ }), array(LogEntrySchema).readonly());
15451
+ /**
15452
+ * `login-method` — collection cap through which auth addons contribute
15453
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
15454
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
15455
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
15456
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
15457
+ * procedure aggregates them for the unauthenticated login page.
15458
+ *
15459
+ * A contribution is a discriminated union on `kind`:
15460
+ *
15461
+ * - `redirect` — a declarative button. The login page renders a generic
15462
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
15463
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
15464
+ * ZERO shell-side JS. A future SSO addon plugs in the same way — the
15465
+ * login page needs NO change.
15466
+ *
15467
+ * - `widget` — a Module-Federation widget the login page mounts (via
15468
+ * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
15469
+ * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
15470
+ * mechanism kept for future use; no shipped addon uses it on the login
15471
+ * page (the passkey ceremony below runs natively in the shell instead).
15472
+ *
15473
+ * - `passkey` — a declarative WebAuthn ceremony the shell renders
15474
+ * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
15475
+ * a remotely-loaded bundle). Carries the addon's effective `rpId` /
15476
+ * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
15477
+ * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
15478
+ * fetching any remote code pre-auth. Contribution stays unconditional —
15479
+ * enrollment state is never leaked pre-auth; visibility is a shell
15480
+ * decision.
15481
+ *
15482
+ * Every contribution carries a `stage`:
15483
+ * - `primary` — shown on the first credentials screen (OIDC /
15484
+ * magic-link buttons; a future usernameless passkey).
15485
+ * - `second-factor` — shown AFTER the password leg, gated on the
15486
+ * returned `factors` (passkey-as-2FA today).
15487
+ *
15488
+ * `mount: skip` — the cap is read server-side by the core auth router
15489
+ * (`registry.getCollection('login-method')`), never mounted as its own
15490
+ * tRPC router.
15491
+ */
15492
+ /** When a login method renders in the two-phase login flow. */
15493
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
15494
+ /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
15495
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [
15496
+ object({
15497
+ kind: literal("redirect"),
15498
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
15499
+ id: string(),
15500
+ /** Operator-facing button label. */
15501
+ label: string(),
15502
+ /** lucide-react icon name. */
15503
+ icon: string().optional(),
15504
+ /** Addon-owned HTTP route the button navigates to (GET). */
15505
+ startUrl: string(),
15506
+ stage: LoginStageEnum
15507
+ }),
15508
+ object({
15509
+ kind: literal("widget"),
15510
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
15511
+ id: string(),
15512
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
15513
+ addonId: string(),
15514
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
15515
+ bundle: string(),
15516
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
15517
+ remote: WidgetRemoteSchema,
15518
+ stage: LoginStageEnum
15519
+ }),
15520
+ object({
15521
+ kind: literal("passkey"),
15522
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
15523
+ id: string(),
15524
+ /** Operator-facing button label. */
15525
+ label: string(),
15526
+ stage: LoginStageEnum,
15527
+ /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
15528
+ rpId: string(),
15529
+ /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
15530
+ origin: string().nullable()
15531
+ })
15532
+ ]);
15533
+ method(_void(), array(LoginMethodContributionSchema).readonly());
15534
+ var CpuBreakdownSchema = object({
15535
+ total: number(),
15536
+ user: number(),
15537
+ system: number(),
15538
+ irq: number(),
15539
+ nice: number(),
15540
+ loadAvg: tuple([
15541
+ number(),
15542
+ number(),
15543
+ number()
15544
+ ]),
15545
+ cores: number()
15546
+ });
15547
+ var MemoryInfoSchema = object({
15548
+ percent: number(),
15549
+ totalBytes: number(),
15550
+ usedBytes: number(),
15551
+ availableBytes: number(),
15552
+ swapUsedBytes: number(),
15553
+ swapTotalBytes: number()
15554
+ });
15555
+ var DiskIoSnapshotSchema = object({
15556
+ readBytes: number(),
15557
+ writeBytes: number(),
15558
+ readOps: number(),
15559
+ writeOps: number(),
15560
+ timestampMs: number()
15561
+ });
15562
+ var NetworkIoSnapshotSchema = object({
15563
+ rxBytes: number(),
15564
+ txBytes: number(),
15565
+ rxPackets: number(),
15566
+ txPackets: number(),
15567
+ rxErrors: number(),
15568
+ txErrors: number(),
15569
+ timestampMs: number()
15570
+ });
15571
+ var MetricsGpuInfoSchema = object({
15572
+ utilization: number(),
15573
+ model: string(),
15574
+ memoryUsedBytes: number(),
15575
+ memoryTotalBytes: number(),
15576
+ temperature: number().nullable()
15577
+ });
15578
+ var ProcessResourceInfoSchema = object({
15579
+ openFds: number(),
15580
+ threadCount: number(),
15581
+ activeHandles: number(),
15582
+ activeRequests: number()
15583
+ });
15584
+ var PressureAvgsSchema = object({
15585
+ avg10: number(),
15586
+ avg60: number(),
15587
+ avg300: number()
15588
+ });
15589
+ var PressureInfoSchema = object({
15590
+ some: PressureAvgsSchema,
15591
+ full: PressureAvgsSchema.nullable()
15592
+ });
15593
+ var SystemResourceSnapshotSchema = object({
15594
+ cpu: CpuBreakdownSchema,
15595
+ memory: MemoryInfoSchema,
15596
+ gpu: MetricsGpuInfoSchema.nullable(),
15597
+ network: NetworkIoSnapshotSchema,
15598
+ disk: DiskIoSnapshotSchema,
15599
+ pressure: object({
15600
+ cpu: PressureInfoSchema.nullable(),
15601
+ memory: PressureInfoSchema.nullable(),
15602
+ io: PressureInfoSchema.nullable()
15603
+ }),
15604
+ process: ProcessResourceInfoSchema,
15605
+ cpuTemperature: number().nullable(),
15606
+ timestampMs: number()
15607
+ });
15608
+ var DiskSpaceInfoSchema = object({
15609
+ path: string(),
15610
+ totalBytes: number(),
15611
+ usedBytes: number(),
15612
+ availableBytes: number(),
15613
+ percent: number()
15614
+ });
15615
+ var PidResourceStatsSchema = object({
15616
+ pid: number(),
15617
+ cpu: number(),
15618
+ memory: number(),
15619
+ /**
15620
+ * Private (anonymous) resident bytes — the per-process V8 heap + native
15621
+ * allocations NOT shared with other processes (Linux RssAnon). This is the
15622
+ * "real" per-runner cost; summing it across runners is meaningful, unlike
15623
+ * `memory` (RSS), which double-counts the shared mmap'd framework code.
15624
+ * Undefined where /proc is unavailable (e.g. macOS).
15625
+ */
15626
+ privateBytes: number().optional(),
15627
+ /**
15628
+ * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
15629
+ * code shared copy-on-write across runners. Undefined on macOS.
15630
+ */
15631
+ sharedBytes: number().optional()
15632
+ });
15633
+ var AddonInstanceSchema = object({
15634
+ addonId: string(),
15635
+ nodeId: string(),
15636
+ role: _enum(["hub", "worker"]),
15637
+ pid: number(),
15638
+ state: _enum([
15639
+ "starting",
15640
+ "running",
15641
+ "stopping",
15642
+ "stopped",
15643
+ "crashed"
15644
+ ]),
15645
+ uptimeSec: number()
15646
+ });
15647
+ var NodeProcessSchema = object({
15648
+ pid: number(),
15649
+ ppid: number(),
15650
+ pgid: number(),
15651
+ classification: _enum([
15652
+ "root",
15653
+ "managed",
15654
+ "system",
15655
+ "ghost"
15656
+ ]),
15657
+ /** `$process` addon binding when `managed`, else null. */
15658
+ addonId: string().nullable(),
15659
+ /** Kernel-reported nodeId when the process is a known agent/worker. */
15660
+ nodeId: string().nullable(),
15661
+ /** Truncated command line. */
15662
+ command: string(),
15663
+ cpuPercent: number(),
15664
+ memoryRssBytes: number(),
15665
+ /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
15666
+ uptimeSec: number(),
15667
+ /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
15668
+ orphaned: boolean()
15669
+ });
15670
+ var KillProcessInputSchema = object({
15671
+ pid: number(),
15672
+ /** Force = SIGKILL. Default is SIGTERM. */
15673
+ force: boolean().optional()
15674
+ });
15675
+ var KillProcessResultSchema = object({
15676
+ success: boolean(),
15677
+ reason: string().optional(),
15678
+ signal: _enum(["SIGTERM", "SIGKILL"]).optional()
15679
+ });
15680
+ var DumpHeapSnapshotInputSchema = object({
15681
+ /** The addon whose runner should dump a heap snapshot. */
15682
+ addonId: string() });
15683
+ var DumpHeapSnapshotResultSchema = object({
15684
+ success: boolean(),
15685
+ /** Path of the written .heapsnapshot inside the runner's container/host. */
15686
+ path: string().optional(),
15687
+ /** Process pid that was signalled. */
15688
+ pid: number().optional(),
15689
+ reason: string().optional()
15690
+ });
15691
+ var SystemMetricsSchema = object({
15692
+ cpuPercent: number(),
15693
+ memoryPercent: number(),
15694
+ memoryUsedMB: number(),
15695
+ memoryTotalMB: number(),
15696
+ diskPercent: number().optional(),
15697
+ temperature: number().optional(),
15698
+ gpuPercent: number().optional(),
15699
+ gpuMemoryPercent: number().optional()
15700
+ });
15701
+ method(_void(), SystemResourceSnapshotSchema), method(_void(), SystemResourceSnapshotSchema.nullable()), method(_void(), SystemMetricsSchema), method(object({ dirPath: string() }), DiskSpaceInfoSchema), method(_void(), MetricsGpuInfoSchema.nullable()), method(_void(), number().nullable()), method(object({ pids: array(number()) }), array(PidResourceStatsSchema)), method(_void(), array(AddonInstanceSchema).readonly()), method(object({ addonId: string() }), PidResourceStatsSchema.nullable()), method(_void(), array(NodeProcessSchema).readonly()), method(KillProcessInputSchema, KillProcessResultSchema, {
15702
+ kind: "mutation",
15703
+ auth: "admin"
15704
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
15705
+ kind: "mutation",
15706
+ auth: "admin"
15707
+ });
15708
+ method(object({
15709
+ sourceUrl: string(),
15710
+ metadata: ModelConvertMetadataSchema,
15711
+ targets: array(ConvertTargetSchema).min(1).readonly(),
15712
+ calibrationRef: string().optional(),
15713
+ sessionId: string().optional()
15714
+ }), ConvertResultSchema, {
15715
+ kind: "mutation",
15716
+ auth: "admin",
15717
+ timeoutMs: 6e5
15718
+ });
15719
+ method(object({
15720
+ nodeId: string(),
15721
+ modelId: string(),
15722
+ format: _enum(MODEL_FORMATS),
15723
+ entry: ModelCatalogEntrySchema
15724
+ }), object({
15725
+ ok: boolean(),
15726
+ /** sha256 of the staged tarball (empty for a hub-local no-op). */
15727
+ sha256: string(),
15728
+ bytes: number(),
15729
+ /** The target node's modelsDir the artifact landed in. */
15730
+ path: string()
15731
+ }), {
15732
+ kind: "mutation",
15733
+ auth: "admin"
15734
+ });
15735
+ /**
15736
+ * `mqtt-broker` — broker-registry cap.
15737
+ *
15738
+ * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
15739
+ * MQTT brokers (external + optionally an embedded `aedes`-backed one)
15740
+ * and (b) the connection details a consumer addon needs to spin up
15741
+ * its OWN `mqtt.js` client.
15433
15742
  *
15434
15743
  * Why: pub/sub routing over the system event-bus loses fidelity
15435
15744
  * (callback shape, QoS guarantees, will/retain semantics) and adds
@@ -15711,14 +16020,14 @@ var TargetKindCapsSchema = object({
15711
16020
  * the union is large and not meant for runtime validation here; the exported
15712
16021
  * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
15713
16022
  */
15714
- var ConfigSchemaPassthrough$1 = unknown();
16023
+ var ConfigSchemaPassthrough = unknown();
15715
16024
  var TargetKindSchema = object({
15716
16025
  kind: string(),
15717
16026
  label: string(),
15718
16027
  icon: string(),
15719
16028
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
15720
16029
  addonId: string(),
15721
- configSchema: ConfigSchemaPassthrough$1,
16030
+ configSchema: ConfigSchemaPassthrough,
15722
16031
  supportsDiscovery: boolean(),
15723
16032
  caps: TargetKindCapsSchema
15724
16033
  });
@@ -15765,303 +16074,499 @@ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSche
15765
16074
  notification: NotificationSchema
15766
16075
  }), SendResultSchema, { kind: "mutation" }), method(object({
15767
16076
  targetId: string(),
15768
- sample: NotificationSchema.optional()
15769
- }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
15770
- targetId: string(),
15771
- enabled: boolean()
15772
- }), _void(), { kind: "mutation" });
15773
- /**
15774
- * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
15775
- * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15776
- * caps stay wire-compatible without a circular cap→cap import.
15777
- *
15778
- * Errors are a discriminated-union RESULT, never thrown: the shape survives
15779
- * every transport tier structurally, and failed calls still write usage rows.
15780
- * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
15781
- */
15782
- var LlmUsageSchema = object({
15783
- inputTokens: number(),
15784
- outputTokens: number()
15785
- });
15786
- var LlmErrorCodeSchema = _enum([
15787
- "timeout",
15788
- "rate-limited",
15789
- "auth",
15790
- "refusal",
15791
- "bad-request",
15792
- "unavailable",
15793
- "no-profile",
15794
- "budget-exceeded",
15795
- "adapter-error"
15796
- ]);
15797
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
15798
- ok: literal(true),
15799
- text: string(),
15800
- model: string(),
15801
- usage: LlmUsageSchema,
15802
- truncated: boolean(),
15803
- latencyMs: number()
15804
- }), object({
15805
- ok: literal(false),
15806
- code: LlmErrorCodeSchema,
15807
- message: string(),
15808
- retryAfterMs: number().optional()
15809
- })]);
15810
- /**
15811
- * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
15812
- * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
15813
- * notification-output.cap.ts:27-31 precedents).
15814
- */
15815
- var LlmImageSchema = object({
15816
- bytes: _instanceof(Uint8Array),
15817
- mimeType: string()
15818
- });
15819
- var LlmGenerateBaseInputSchema = object({
15820
- /** Collection routing (the notification-output posture). */
15821
- addonId: string().optional(),
15822
- /** Explicit profile; else the resolution chain (spec §3). */
15823
- profileId: string().optional(),
15824
- /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
15825
- consumer: string(),
15826
- system: string().optional(),
15827
- /** v1: single-turn. `messages[]` is a v2 additive field. */
15828
- prompt: string(),
15829
- /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
15830
- jsonSchema: record(string(), unknown()).optional(),
15831
- /** Per-call override of the profile default. */
15832
- maxTokens: number().int().positive().optional(),
15833
- temperature: number().optional()
15834
- });
16077
+ sample: NotificationSchema.optional()
16078
+ }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
16079
+ targetId: string(),
16080
+ enabled: boolean()
16081
+ }), _void(), { kind: "mutation" });
15835
16082
  /**
15836
- * `llm-runtime`node-side managed llama.cpp executor (spec §4). Registered
15837
- * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
15838
- * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
15839
- * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
15840
- * this only through the `llm` cap's methods.
16083
+ * notification-rulesthe Notification Center rule surface (P1 core).
15841
16084
  *
15842
- * One running llama-server child per node in v1 (models are RAM-heavy).
15843
- * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
15844
- * watchdog — operator decision #3).
16085
+ * Spec: `docs/superpowers/specs/2026-07-22-notification-center-requirements.md`
16086
+ * (operator decisions D-1/D-2/D-3 are binding):
16087
+ *
16088
+ * - D-2: rule EVALUATION lives in `addon-post-analysis` (the
16089
+ * `notification-center` module), hooked on the durable persistence
16090
+ * moments (object-event insert, TrackCloser.closeExpired) with a
16091
+ * persisted outbox + retry — never the lossy telemetry bus (D8).
16092
+ * - D-3: urgency belongs to the RULE. `delivery: 'immediate'` fires on the
16093
+ * FIRST persisted detection matching the conditions (per-track dedup,
16094
+ * `maxPerTrack` fixed at 1 — see {@link NC_MAX_PER_TRACK_IMMEDIATE});
16095
+ * `delivery: 'track-end'` evaluates the finalized track record at close.
16096
+ * - DISPATCH stays behind `notification-output` (rules reference targets
16097
+ * by id; per-backend params are a passthrough blob capped by the
16098
+ * target kind's own caps/degrade engine).
16099
+ *
16100
+ * P1 scope: admin-authored rules only (`createdBy` stamped from the
16101
+ * server-injected caller identity — the first `caller: 'required'`
16102
+ * adopter). The P1 condition subset is: devices, classes(+exclude),
16103
+ * minConfidence, admin zones (any/all + exclude), weekly schedule
16104
+ * windows, and the optional label/identity/plate matchers. User rules,
16105
+ * private zones, per-recipient fan-out and the wider condition table are
16106
+ * P2+ (see spec §7).
16107
+ *
16108
+ * All schemas here are the single source of truth — `NcRule` etc. are
16109
+ * `z.infer` exports; no duplicate interfaces (the advanced-notifier
16110
+ * schema/interface drift is explicitly not repeated).
15845
16111
  */
15846
- var ManagedModelRefSchema = discriminatedUnion("kind", [
15847
- object({
15848
- kind: literal("catalog"),
15849
- catalogId: string()
15850
- }),
15851
- object({
15852
- kind: literal("url"),
15853
- url: string(),
15854
- sha256: string().optional()
15855
- }),
15856
- object({
15857
- kind: literal("path"),
15858
- path: string()
15859
- })
16112
+ /**
16113
+ * D-3: the trigger/urgency of a rule — which persistence moment evaluates it.
16114
+ * The value maps 1:1 onto the evaluated record kind:
16115
+ * - `immediate` ↔ object-event persist (lowest-latency detection burst)
16116
+ * - `track-end` ↔ TrackCloser.closeExpired (finalized track record)
16117
+ * - `device-event` ↔ SensorEventStore insert (doorbell press / sensor state
16118
+ * change of a LINKED device, one row per linked camera)
16119
+ * - `package-event` ↔ PackageDropDetector object-event insert (a `package`
16120
+ * delivery / pick-up)
16121
+ *
16122
+ * `immediate`/`track-end` carry the D-3 urgency semantics; `device-event`/
16123
+ * `package-event` are pure trigger kinds (no urgency dimension). Extending
16124
+ * this one field keeps the schema additive — a rule still declares exactly
16125
+ * one trigger.
16126
+ */
16127
+ var NcDeliverySchema = _enum([
16128
+ "immediate",
16129
+ "track-end",
16130
+ "device-event",
16131
+ "package-event"
15860
16132
  ]);
15861
- var ManagedRuntimeConfigSchema = object({
15862
- /** WHERE the runtime lives — hub or any agent. */
15863
- nodeId: string(),
15864
- /** Closed for v1; 'ollama' is a v2 candidate. */
15865
- engine: _enum(["llama-cpp"]),
15866
- model: ManagedModelRefSchema,
15867
- contextSize: number().int().default(4096),
15868
- /** 0 = CPU-only. */
15869
- gpuLayers: number().int().default(0),
15870
- /** Default: cpus-2, clamped ≥1 (resolved node-side). */
15871
- threads: number().int().optional(),
15872
- /** Concurrent slots. */
15873
- parallel: number().int().default(1),
15874
- /** Else lazy: first generate boots it. */
15875
- autoStart: boolean().default(false),
15876
- /** 0 = never; frees RAM after quiet periods. */
15877
- idleStopMinutes: number().int().default(30)
15878
- });
15879
- var LlmRuntimeStatusSchema = object({
15880
- /** Status is ALWAYS node-qualified. */
15881
- nodeId: string(),
15882
- state: _enum([
15883
- "stopped",
15884
- "downloading",
15885
- "starting",
15886
- "ready",
15887
- "crashed",
15888
- "failed"
15889
- ]),
15890
- pid: number().optional(),
15891
- port: number().optional(),
15892
- modelPath: string().optional(),
15893
- modelId: string().optional(),
15894
- downloadProgress: number().min(0).max(1).optional(),
15895
- lastError: string().optional(),
15896
- crashesInWindow: number(),
15897
- /** Child RSS (sampled best-effort). */
15898
- memoryBytes: number().optional(),
15899
- vramBytes: number().optional()
16133
+ /** Weekly schedule — OR of windows; absence on the rule = always active. */
16134
+ var NcScheduleSchema = object({
16135
+ windows: array(object({
16136
+ /** Days of week the window STARTS on (0 = Sunday … 6 = Saturday). */
16137
+ days: array(number().int().min(0).max(6)).min(1),
16138
+ startMinute: number().int().min(0).max(1439),
16139
+ endMinute: number().int().min(0).max(1439)
16140
+ })).min(1),
16141
+ /** IANA timezone; default = hub host timezone. */
16142
+ timezone: string().optional(),
16143
+ /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
16144
+ invert: boolean().optional()
15900
16145
  });
15901
- var LlmNodeModelSchema = object({
15902
- file: string(),
15903
- sizeBytes: number(),
15904
- catalogId: string().optional(),
15905
- installedAt: number().optional()
16146
+ /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
16147
+ var NcPlateMatcherSchema = object({
16148
+ values: array(string().min(1)).min(1),
16149
+ /** Max Levenshtein distance after normalization (uppercase alphanumeric). */
16150
+ maxDistance: number().int().min(0).max(3).default(1)
15906
16151
  });
15907
- var LlmRuntimeDiskUsageSchema = object({
15908
- nodeId: string(),
15909
- modelsBytes: number(),
15910
- freeBytes: number().optional()
16152
+ /**
16153
+ * Occupancy condition (DEVICE-EVENT trigger). Fires on a ZoneAnalytics
16154
+ * occupancy edge for a device — optionally narrowed to a single admin
16155
+ * `zoneId` and/or object `className`. `op` selects the edge/threshold:
16156
+ * - `became-occupied` (default) — count crossed 0 → ≥ `count`
16157
+ * - `became-free` — count crossed ≥ `count` → below it
16158
+ * - `>=` / `<=` — count is at/over or at/under `count`
16159
+ * `sustainSeconds` requires the condition hold continuously that long
16160
+ * before firing (debounces flicker; 0 = fire on the first matching edge).
16161
+ * Fail-closed: no ZoneAnalytics snapshot / missing zone / null snapshot ⇒
16162
+ * the condition never matches. Confirmed edge-state survives addon restarts
16163
+ * (declared SQLite collection, reseeded on boot).
16164
+ */
16165
+ var NcOccupancyConditionSchema = object({
16166
+ /** Admin zone id to scope the count to; absent = whole-frame occupancy. */
16167
+ zoneId: string().optional(),
16168
+ /** Object class to count; absent = any class. */
16169
+ className: string().optional(),
16170
+ op: _enum([
16171
+ "became-occupied",
16172
+ "became-free",
16173
+ ">=",
16174
+ "<="
16175
+ ]).default("became-occupied"),
16176
+ count: number().int().min(0).default(1),
16177
+ sustainSeconds: number().int().min(0).max(3600).default(15)
16178
+ });
16179
+ /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
16180
+ var NcZoneConditionSchema = object({
16181
+ ids: array(string().min(1)).min(1),
16182
+ /** Quantifier over `ids` — at least one / every one visited. */
16183
+ match: _enum(["any", "all"]).default("any")
15911
16184
  });
15912
- method(LlmGenerateBaseInputSchema.extend({
15913
- images: array(LlmImageSchema).optional(),
15914
- runtime: ManagedRuntimeConfigSchema,
15915
- /** The managed profile's timeout, threaded by the hub provider. */
15916
- timeoutMs: number().int().positive().optional()
15917
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
15918
- kind: "mutation",
15919
- auth: "admin"
15920
- }), method(object({}), _void(), {
15921
- kind: "mutation",
15922
- auth: "admin"
15923
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
15924
- kind: "mutation",
15925
- auth: "admin"
15926
- }), method(object({ file: string() }), _void(), {
15927
- kind: "mutation",
15928
- auth: "admin"
15929
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
15930
16185
  /**
15931
- * `llm`consumer-facing LLM surface (spec §1-§3). Collection-mode: array
15932
- * methods concat-fan across providers; single-row methods route to ONE
15933
- * provider by the `addonId` in the call input (the notification-output
15934
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
15935
- * (hub-placed); the cap stays open for future providers.
15936
- *
15937
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
15938
- * `apiKey` is a password field — providers REDACT it on read and merge on
15939
- * write; a stored key NEVER round-trips to a client.
16186
+ * The P1 condition set a flat AND of groups; absent group = pass;
16187
+ * membership lists are OR within the list (spec §2.3).
15940
16188
  */
15941
- var LlmProfileKindSchema = _enum([
15942
- "openai-compatible",
15943
- "openai",
15944
- "anthropic",
15945
- "google",
15946
- "managed-local"
15947
- ]);
15948
- var LlmProfileSchema = object({
15949
- id: string(),
15950
- name: string(),
15951
- kind: LlmProfileKindSchema,
15952
- /** Stamped by the provider keeps the fanned catalog routable. */
15953
- addonId: string(),
15954
- enabled: boolean(),
15955
- /** Vendor model id, or the managed runtime's loaded model. */
15956
- model: string(),
15957
- /** Required for openai-compatible; override for cloud kinds. */
15958
- baseUrl: string().optional(),
15959
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
15960
- apiKey: string().optional(),
15961
- supportsVision: boolean(),
15962
- temperature: number().min(0).max(2).optional(),
15963
- maxTokens: number().int().positive().optional(),
15964
- timeoutMs: number().int().positive().default(6e4),
15965
- extraHeaders: record(string(), string()).optional(),
15966
- /** kind === 'managed-local' only (spec §4). */
15967
- runtime: ManagedRuntimeConfigSchema.optional()
16189
+ var NcConditionsSchema = object({
16190
+ /** Device scope — absent = all devices. */
16191
+ devices: array(number()).optional(),
16192
+ /** Detector class names (any overlap with the record's class set). */
16193
+ classes: array(string().min(1)).optional(),
16194
+ /** Veto classes — any overlap fails the rule. */
16195
+ classesExclude: array(string().min(1)).optional(),
16196
+ /** Minimum detection confidence 0–1 (fails when the record has none). */
16197
+ minConfidence: number().min(0).max(1).optional(),
16198
+ /** Admin zone membership over event `zones` / track `zonesVisited`. */
16199
+ zones: NcZoneConditionSchema.optional(),
16200
+ /** Veto zones any hit fails the rule. */
16201
+ zonesExclude: array(string().min(1)).optional(),
16202
+ /**
16203
+ * Exact (case-insensitive) match on the record's collapsed `label`
16204
+ * (identity name / plate text / subclass).
16205
+ */
16206
+ labelEquals: array(string().min(1)).optional(),
16207
+ /**
16208
+ * Identity matcher. P1 boundary: matched against the record's collapsed
16209
+ * `label` (the identity display name propagated by the face pipeline)
16210
+ * identity-ID matching rides in P2 when identity ids reach the record.
16211
+ */
16212
+ identities: array(string().min(1)).optional(),
16213
+ /** Fuzzy plate matcher against the record's `label` (plate text). */
16214
+ plates: NcPlateMatcherSchema.optional(),
16215
+ /**
16216
+ * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
16217
+ * Same P1 boundary: matched against the record's collapsed `label` (the
16218
+ * identity display name). A record with NO label passes (nothing to
16219
+ * exclude), unlike the include variant which fails on an absent label.
16220
+ */
16221
+ identitiesExclude: array(string().min(1)).optional(),
16222
+ /**
16223
+ * Minimum server-computed key-event importance in [0,1] (`Track.importance`).
16224
+ * TRACK-END only: importance is scored at track close, so it does not exist
16225
+ * at immediate / object-event evaluation time (see catalog `appliesTo`). At
16226
+ * close the value is threaded via the close-time info (the `Track` clone is
16227
+ * captured before the DB row is updated, so it would otherwise read stale).
16228
+ * Fails when the record carries no importance (never guess quality — the
16229
+ * `minConfidence` precedent). MVP cut: a single scalar threshold.
16230
+ */
16231
+ minImportance: number().min(0).max(1).optional(),
16232
+ /**
16233
+ * Minimum track dwell in SECONDS — `(lastSeen − firstSeen) / 1000`.
16234
+ * TRACK-END only: an `immediate` / object-event subject has no closed
16235
+ * lifespan, so a dwell condition never matches immediate delivery
16236
+ * (documented choice — the object-event record carries no `firstSeen`,
16237
+ * so dwell cannot be computed from what the subject actually carries).
16238
+ */
16239
+ minDwellSeconds: number().min(0).optional(),
16240
+ /**
16241
+ * Detection provenance filter. `any` (default / absent) matches every
16242
+ * source; otherwise the subject's source must equal it. Legacy records
16243
+ * with no stamped source are treated as `pipeline`. The union spans both
16244
+ * record kinds — object events carry `pipeline` | `onboard`, synthetic
16245
+ * tracks carry `sensor`.
16246
+ */
16247
+ source: _enum([
16248
+ "pipeline",
16249
+ "onboard",
16250
+ "sensor",
16251
+ "any"
16252
+ ]).optional(),
16253
+ /**
16254
+ * Minimum identity / plate MATCH confidence in [0,1] — DISTINCT from the
16255
+ * detector `minConfidence` (that gates the object-detection score; this
16256
+ * gates the recognition/OCR match score). Fails when the subject carries
16257
+ * no label-match confidence (never guess). TRACK-END only: the confidence
16258
+ * lives on the recognition result and reaches the subject at track close.
16259
+ *
16260
+ * What it measures precisely (plumbed at track close — the closer threads
16261
+ * the value into `NcTrackClosedInfo.labelConfidence`, the same seam as
16262
+ * `importance`): the BEST recognition match confidence observed for the
16263
+ * label the track carries at close — for a face, the peak cosine similarity
16264
+ * of the ASSIGNED identity (`FaceMatch.score`, reset on an identity switch);
16265
+ * for a plate, the peak OCR read score of the best-held plate
16266
+ * (`plateText.confidence`). When BOTH a face and a plate were recognized on
16267
+ * one track the higher of the two is used. A track that ended with no
16268
+ * confident identity/plate match carries no value, so the condition fails
16269
+ * closed for it (an un-recognized subject).
16270
+ */
16271
+ minLabelConfidence: number().min(0).max(1).optional(),
16272
+ /**
16273
+ * DEVICE-EVENT only. Raw device event-type tokens (`EventFire.eventType`,
16274
+ * e.g. a doorbell `press` / `press_long`) — matched case-insensitively
16275
+ * against the token carried on the device-event subject (extracted from the
16276
+ * event-emitter runtime slice's `lastEvent.eventType`). Fails when the
16277
+ * subject carries no token. Doorbell-pulse / passive-sensor kinds emit no
16278
+ * eventType, so gate those with {@link sensorKinds} instead.
16279
+ */
16280
+ eventTypeTokens: array(string().min(1)).optional(),
16281
+ /**
16282
+ * DEVICE-EVENT only. Sensor/control taxonomy kinds (e.g. `doorbell`,
16283
+ * `contact`, `button`, `device-event`) — matched against the persisted
16284
+ * `SensorEvent.kind` (see `sensor-event-kinds.ts`). Membership is OR.
16285
+ */
16286
+ sensorKinds: array(string().min(1)).optional(),
16287
+ /**
16288
+ * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
16289
+ * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
16290
+ * when the subject's phase does not match (a subject always carries a phase
16291
+ * on the package-event trigger).
16292
+ */
16293
+ packagePhase: _enum([
16294
+ "delivered",
16295
+ "picked-up",
16296
+ "both"
16297
+ ]).optional(),
16298
+ /**
16299
+ * PERSONAL-RULE custom zones (viewer-drawn). Inline normalized polygons
16300
+ * (MaskShape vocabulary). A record passes when its bbox overlaps ANY
16301
+ * listed polygon (ZoneEngine membership semantics). Evaluated only when
16302
+ * the subject carries a bbox; absent bbox ⇒ the condition FAILS.
16303
+ */
16304
+ customZones: array(MaskPolygonShapeSchema).optional(),
16305
+ /**
16306
+ * DEVICE-EVENT only. ZoneAnalytics occupancy edge — fires when a device's
16307
+ * (optionally zone/class-scoped) occupancy count crosses the configured
16308
+ * threshold and holds for `sustainSeconds`. Fail-closed on missing
16309
+ * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
16310
+ */
16311
+ occupancy: NcOccupancyConditionSchema.optional()
15968
16312
  });
15969
- /** ConfigUISchema tree passed through untyped on the wire (the
15970
- * notification-output `ConfigSchemaPassthrough` precedent at
15971
- * notification-output.cap.ts:151); the exported TS type re-tightens it. */
15972
- var ConfigSchemaPassthrough = unknown();
15973
- var LlmProfileKindDescriptorSchema = object({
15974
- kind: LlmProfileKindSchema,
15975
- label: string(),
15976
- icon: string(),
15977
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
15978
- addonId: string(),
15979
- configSchema: ConfigSchemaPassthrough
16313
+ /** One delivery target: a `notification-output` Target ref + passthrough params. */
16314
+ var NcRuleTargetSchema = object({
16315
+ /** `notification-output` Target id. */
16316
+ targetId: string().min(1),
16317
+ /**
16318
+ * Per-backend passthrough. Recognized keys are mapped onto the canonical
16319
+ * Notification (`priority`, `level`, `sound`, `clickUrl`, `ttl`); the
16320
+ * degrade engine drops what the backend can't render.
16321
+ */
16322
+ params: record(string(), unknown()).optional()
15980
16323
  });
15981
- var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
15982
- var LlmDefaultSchema = object({
15983
- selector: LlmDefaultSelectorSchema,
15984
- profileId: string()
16324
+ /**
16325
+ * Media attachment policy (P1 still-image subset).
16326
+ * - `best` — the best AVAILABLE subject image at dispatch time (D-3).
16327
+ * - `best-matching` — the media that explains WHY the rule fired: a rule
16328
+ * matched on identities attaches the subject's `faceCrop`, one matched on
16329
+ * plates attaches the `plateCrop`; a rule with no identity/plate condition
16330
+ * (or when the specific crop is missing) degrades to `best`, then
16331
+ * `keyFrame`, then no attachment — never delaying the send. The matched
16332
+ * condition summary is frozen on the outbox row at enqueue (like the rule
16333
+ * name), so the choice never drifts from the record that fired it.
16334
+ * - `keyFrame` — the clean scene frame (no subject box).
16335
+ * - `none` — no attachment.
16336
+ */
16337
+ var NcMediaPolicySchema = object({ attach: _enum([
16338
+ "best",
16339
+ "best-matching",
16340
+ "keyFrame",
16341
+ "none"
16342
+ ]).default("best") });
16343
+ /** Throttle — cooldown survives restarts (rebuilt from the outbox on boot). */
16344
+ var NcThrottleSchema = object({
16345
+ cooldownSec: number().int().min(0).max(86400).default(60),
16346
+ /** `rule` = one shared cooldown; `rule-device` = per-camera cooldown. */
16347
+ scope: _enum(["rule", "rule-device"]).default("rule-device")
16348
+ });
16349
+ /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
16350
+ var NcRuleInputSchema = object({
16351
+ name: string().min(1).max(200),
16352
+ enabled: boolean().default(true),
16353
+ delivery: NcDeliverySchema,
16354
+ conditions: NcConditionsSchema.default({}),
16355
+ schedule: NcScheduleSchema.optional(),
16356
+ targets: array(NcRuleTargetSchema).min(1),
16357
+ media: NcMediaPolicySchema.default({ attach: "best" }),
16358
+ throttle: NcThrottleSchema.default({
16359
+ cooldownSec: 60,
16360
+ scope: "rule-device"
16361
+ }),
16362
+ /** `{{var}}` templating over camera/class/label/zones/confidence/time. */
16363
+ template: object({
16364
+ title: string().max(500).optional(),
16365
+ body: string().max(2e3).optional()
16366
+ }).optional(),
16367
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
16368
+ priority: number().int().min(1).max(5).default(3),
16369
+ /**
16370
+ * Ownership/visibility key. Absent = admin/global rule (unchanged legacy
16371
+ * behaviour, visible to all, read-only in the viewer). Present = personal
16372
+ * rule owned by this userId. Server-stamped; never trusted from a client.
16373
+ */
16374
+ ownerUserId: string().optional()
15985
16375
  });
15986
- /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
15987
- var LlmUsageRollupSchema = object({
15988
- day: string(),
15989
- consumer: string(),
15990
- profileId: string(),
15991
- calls: number(),
15992
- okCalls: number(),
15993
- errorCalls: number(),
15994
- inputTokens: number(),
15995
- outputTokens: number(),
15996
- avgLatencyMs: number()
16376
+ /**
16377
+ * Partial patch for `updateRule` — any subset of the input fields, plus the
16378
+ * persisted-only {@link NcRuleSchema} `disabledTargetIds` set. The latter is
16379
+ * NOT a client-authored input field (it lives on the persisted rule, not the
16380
+ * input), so it is added here explicitly to let the store's per-target opt-out
16381
+ * toggle round-trip through the shared `update` path. Viewer opt-out mutations
16382
+ * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
16383
+ * `updateRule` patch.
16384
+ */
16385
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
16386
+ /** A persisted rule. */
16387
+ var NcRuleSchema = NcRuleInputSchema.extend({
16388
+ id: string(),
16389
+ /** userId of the admin who created the rule (server-stamped caller). */
16390
+ createdBy: string(),
16391
+ createdAt: number(),
16392
+ updatedAt: number(),
16393
+ /**
16394
+ * Per-target opt-out set. A targetId here is suppressed for THIS rule at
16395
+ * send time. Only a target's OWNER may add/remove its id (server-checked
16396
+ * in `nc.setRuleTargetEnabled`). Defaults to empty.
16397
+ */
16398
+ disabledTargetIds: array(string()).default([])
16399
+ });
16400
+ var NcTestResultSchema = object({
16401
+ recordId: string(),
16402
+ recordKind: _enum([
16403
+ "object-event",
16404
+ "track",
16405
+ "device-event",
16406
+ "package-event"
16407
+ ]),
16408
+ deviceId: number(),
16409
+ timestamp: number(),
16410
+ wouldFire: boolean(),
16411
+ /** Condition id that failed (first failing group), when `wouldFire` is false. */
16412
+ failedCondition: string().optional(),
16413
+ className: string().optional(),
16414
+ label: string().optional()
15997
16415
  });
15998
- /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
15999
- var ManagedModelCatalogEntrySchema = object({
16416
+ var NcConditionDescriptorSchema = object({
16417
+ /** Field id inside `NcConditions` (or `'schedule'` for the rule-level group). */
16000
16418
  id: string(),
16419
+ group: _enum([
16420
+ "scope",
16421
+ "class",
16422
+ "zones",
16423
+ "quality",
16424
+ "label",
16425
+ "schedule",
16426
+ "device",
16427
+ "package",
16428
+ "occupancy"
16429
+ ]),
16001
16430
  label: string(),
16002
- family: string(),
16003
- purpose: _enum(["text", "vision"]),
16004
- url: string(),
16005
- sha256: string(),
16006
- sizeBytes: number(),
16007
- quantization: string(),
16008
- /** Load-time guidance shown in the picker. */
16009
- minRamBytes: number(),
16010
- contextSizeDefault: number().int(),
16011
- /** Vision models: companion projector file. */
16012
- mmprojUrl: string().optional()
16431
+ /** Editor widget the UI renders — never hardcode per-condition forms. */
16432
+ valueType: _enum([
16433
+ "deviceIdList",
16434
+ "stringList",
16435
+ "number01",
16436
+ "number",
16437
+ "sourceSelect",
16438
+ "zoneSelection",
16439
+ "zoneIdList",
16440
+ "schedule",
16441
+ "plateMatcher",
16442
+ "packagePhase",
16443
+ "polygonDraw",
16444
+ "occupancy"
16445
+ ]),
16446
+ operator: _enum([
16447
+ "in",
16448
+ "notIn",
16449
+ "anyOf",
16450
+ "allOf",
16451
+ "gte",
16452
+ "fuzzyIn",
16453
+ "withinSchedule"
16454
+ ]),
16455
+ /** Which delivery kinds the condition applies to. */
16456
+ appliesTo: array(NcDeliverySchema),
16457
+ phase: string(),
16458
+ description: string().optional()
16013
16459
  });
16014
- var LlmRuntimeNodeSchema = object({
16015
- nodeId: string(),
16016
- reachable: boolean(),
16017
- status: LlmRuntimeStatusSchema.optional(),
16018
- disk: LlmRuntimeDiskUsageSchema.optional(),
16019
- error: string().optional()
16460
+ /**
16461
+ * The delivery lifecycle status of a history row — a straight read of the
16462
+ * durable outbox row's own status (single source of truth):
16463
+ * - `pending` — enqueued, in-flight or retrying with backoff
16464
+ * - `sent` — delivered (terminal)
16465
+ * - `dead` — dead-lettered after exhausting retries / a permanent
16466
+ * backend rejection / a deleted target (terminal; carries
16467
+ * the failure `error`)
16468
+ *
16469
+ * P1 has no `suppressed-quiet-hours` / `snoozed` states — those ride the P2
16470
+ * user dimension (quiet hours / snooze) and are additive when they land.
16471
+ */
16472
+ var NcHistoryStatusSchema = _enum([
16473
+ "pending",
16474
+ "sent",
16475
+ "dead"
16476
+ ]);
16477
+ /** The evaluated record kind a history row descends from (one per trigger). */
16478
+ var NcHistoryRecordKindSchema = _enum([
16479
+ "object-event",
16480
+ "track-end",
16481
+ "device-event",
16482
+ "package-event"
16483
+ ]);
16484
+ /** Subject summary frozen on the row at fire time (survives rule/record edits). */
16485
+ var NcHistorySubjectSchema = object({
16486
+ className: string(),
16487
+ label: string().optional(),
16488
+ confidence: number().optional(),
16489
+ zones: array(string()),
16490
+ timestamp: number()
16491
+ });
16492
+ /**
16493
+ * One delivery-history row. This is a read-only VIEW over the durable
16494
+ * outbox row (single source of truth — the same row the drain loop drives;
16495
+ * NO second write path, so history can never drift from delivery state).
16496
+ * The §3.2 fields map directly: `ruleId`/`targetId`/`deviceId` are columns,
16497
+ * `eventRef` is `recordKind`+`recordId`, `timestamps` are `createdAt`
16498
+ * (fire) / `updatedAt` (last transition), `status` + `error` are the
16499
+ * lifecycle. `ruleName` + `subject` are the intent snapshot frozen at
16500
+ * enqueue. `userId?` (per-recipient history) is P2 — no user dimension in
16501
+ * P1 (admin scope only).
16502
+ */
16503
+ var NcHistoryEntrySchema = object({
16504
+ /** Outbox row id — the stable dedup id `ruleId:dedupRef:targetId`. */
16505
+ id: string(),
16506
+ ruleId: string(),
16507
+ /** Rule name frozen at fire time (outlives a later rename / delete). */
16508
+ ruleName: string(),
16509
+ /** The rule urgency/trigger that produced this delivery. */
16510
+ delivery: NcDeliverySchema,
16511
+ targetId: string(),
16512
+ deviceId: number(),
16513
+ recordKind: NcHistoryRecordKindSchema,
16514
+ /** Event / track ref of the evaluated record (§3.2 `eventRef`). */
16515
+ recordId: string(),
16516
+ /** Present for track-scoped deliveries (object-event / track-end). */
16517
+ trackId: string().optional(),
16518
+ status: NcHistoryStatusSchema,
16519
+ /** Delivery attempts made so far. */
16520
+ attempts: number().int(),
16521
+ /** Fire time (outbox enqueue). */
16522
+ createdAt: number(),
16523
+ /** Last transition time (terminal for sent / dead). */
16524
+ updatedAt: number(),
16525
+ /** Failure detail — present on a `dead` row. */
16526
+ error: string().optional(),
16527
+ subject: NcHistorySubjectSchema
16020
16528
  });
16021
- var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
16022
- var ProfileRefInputSchema = object({
16023
- addonId: string(),
16024
- profileId: string()
16529
+ /**
16530
+ * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
16531
+ * AND; absent = unbounded on that axis. `since`/`until` bound the fire time
16532
+ * (`createdAt`, epoch ms, inclusive). `limit` is clamped to
16533
+ * {@link NC_HISTORY_LIMIT_MAX}. `userId` (per-recipient filtering) is P2.
16534
+ */
16535
+ var NcHistoryFilterSchema = object({
16536
+ ruleId: string().optional(),
16537
+ deviceId: number().optional(),
16538
+ status: NcHistoryStatusSchema.optional(),
16539
+ since: number().optional(),
16540
+ until: number().optional(),
16541
+ limit: number().int().min(1).max(500).default(100)
16025
16542
  });
16026
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
16027
- kind: "mutation",
16028
- auth: "admin"
16029
- }), method(ProfileRefInputSchema, _void(), {
16543
+ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), method(object({ ruleId: string() }), object({ rule: NcRuleSchema.nullable() }), { auth: "admin" }), method(object({ rule: NcRuleInputSchema }), object({ rule: NcRuleSchema }), {
16030
16544
  kind: "mutation",
16031
- auth: "admin"
16032
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
16545
+ auth: "admin",
16546
+ caller: "required"
16547
+ }), method(object({
16548
+ ruleId: string(),
16549
+ patch: NcRulePatchSchema
16550
+ }), object({ rule: NcRuleSchema }), {
16033
16551
  kind: "mutation",
16034
- auth: "admin"
16035
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
16036
- selector: LlmDefaultSelectorSchema,
16037
- profileId: string().nullable()
16038
- }), _void(), {
16552
+ auth: "admin",
16553
+ caller: "required"
16554
+ }), method(object({ ruleId: string() }), object({ success: literal(true) }), {
16039
16555
  kind: "mutation",
16040
16556
  auth: "admin"
16041
16557
  }), method(object({
16042
- since: number().optional(),
16043
- until: number().optional(),
16044
- consumer: string().optional(),
16045
- profileId: string().optional()
16046
- }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
16047
- nodeId: string(),
16048
- model: ManagedModelRefSchema
16049
- }), _void(), {
16558
+ ruleId: string(),
16559
+ enabled: boolean()
16560
+ }), object({ success: literal(true) }), {
16050
16561
  kind: "mutation",
16051
16562
  auth: "admin"
16052
16563
  }), method(object({
16053
- nodeId: string(),
16054
- file: string()
16055
- }), _void(), {
16056
- kind: "mutation",
16057
- auth: "admin"
16058
- }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
16059
- kind: "mutation",
16060
- auth: "admin"
16061
- }), method(ProfileRefInputSchema, _void(), {
16564
+ rule: NcRuleInputSchema,
16565
+ lookbackMinutes: number().int().min(1).max(1440).default(60)
16566
+ }), object({ results: array(NcTestResultSchema) }), {
16062
16567
  kind: "mutation",
16063
16568
  auth: "admin"
16064
- });
16569
+ }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
16065
16570
  /**
16066
16571
  * Zod schemas for persisted record types.
16067
16572
  *
@@ -16747,7 +17252,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
16747
17252
  }), method(object({
16748
17253
  eventId: string(),
16749
17254
  kind: MediaFileKindEnum.optional()
16750
- }), array(MediaFileSchema).readonly()), method(object({ trackId: string() }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
17255
+ }), array(MediaFileSchema).readonly()), method(object({
17256
+ trackId: string(),
17257
+ kinds: array(MediaFileKindEnum).optional()
17258
+ }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
16751
17259
  deviceId: number(),
16752
17260
  timestamp: number(),
16753
17261
  frameWidth: number(),
@@ -16768,76 +17276,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
16768
17276
  eventId: string(),
16769
17277
  timestamp: number()
16770
17278
  });
16771
- /**
16772
- * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
16773
- * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
16774
- * caps into per-camera event-kind descriptors.
16775
- *
16776
- * The descriptor DATA (color / iconId / labelKey / parentKind / category)
16777
- * is NOT duplicated here — every entry is derived from the single
16778
- * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
16779
- * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
16780
- * control cap means adding one line here (and a taxonomy entry); the anti-
16781
- * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
16782
- * eventful cap is missing.
16783
- */
16784
- /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
16785
- var LEGACY_ICON = {
16786
- motion: "motion",
16787
- audio: "audio",
16788
- person: "person",
16789
- vehicle: "vehicle",
16790
- animal: "animal",
16791
- package: "package",
16792
- door: "door",
16793
- pir: "pir",
16794
- smoke: "smoke",
16795
- water: "water",
16796
- button: "button",
16797
- generic: "generic",
16798
- gas: "smoke",
16799
- vibration: "generic",
16800
- tamper: "generic",
16801
- presence: "person",
16802
- lock: "generic",
16803
- siren: "generic",
16804
- switch: "generic",
16805
- doorbell: "button"
16806
- };
16807
- function legacyIcon(iconId) {
16808
- return LEGACY_ICON[iconId] ?? "generic";
16809
- }
16810
- /**
16811
- * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
16812
- * The anti-drift guard cross-checks this against the eventful caps declared
16813
- * in `packages/types/src/capabilities/*.cap.ts`.
16814
- */
16815
- var CAP_TO_KIND = {
16816
- contact: "contact",
16817
- motion: "motion-sensor",
16818
- smoke: "smoke",
16819
- flood: "flood",
16820
- gas: "gas",
16821
- "carbon-monoxide": "carbon-monoxide",
16822
- vibration: "vibration",
16823
- tamper: "tamper",
16824
- presence: "presence",
16825
- "enum-sensor": "enum-sensor",
16826
- "event-emitter": "device-event",
16827
- "lock-control": "lock",
16828
- switch: "switch",
16829
- button: "button",
16830
- doorbell: "doorbell"
16831
- };
16832
- function buildDescriptor(capName, kind) {
16833
- const t = EVENT_TAXONOMY[kind];
16834
- if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
16835
- return {
16836
- ...t,
16837
- icon: legacyIcon(t.iconId)
16838
- };
16839
- }
16840
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
16841
17279
  var CameraPipelineConfigSchema = object({
16842
17280
  engine: PipelineEngineChoiceSchema.optional(),
16843
17281
  steps: array(PipelineStepInputSchema).readonly(),
@@ -17323,6 +17761,76 @@ method(object({
17323
17761
  auth: "admin"
17324
17762
  });
17325
17763
  /**
17764
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
17765
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
17766
+ * caps into per-camera event-kind descriptors.
17767
+ *
17768
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
17769
+ * is NOT duplicated here — every entry is derived from the single
17770
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
17771
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
17772
+ * control cap means adding one line here (and a taxonomy entry); the anti-
17773
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
17774
+ * eventful cap is missing.
17775
+ */
17776
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
17777
+ var LEGACY_ICON = {
17778
+ motion: "motion",
17779
+ audio: "audio",
17780
+ person: "person",
17781
+ vehicle: "vehicle",
17782
+ animal: "animal",
17783
+ package: "package",
17784
+ door: "door",
17785
+ pir: "pir",
17786
+ smoke: "smoke",
17787
+ water: "water",
17788
+ button: "button",
17789
+ generic: "generic",
17790
+ gas: "smoke",
17791
+ vibration: "generic",
17792
+ tamper: "generic",
17793
+ presence: "person",
17794
+ lock: "generic",
17795
+ siren: "generic",
17796
+ switch: "generic",
17797
+ doorbell: "button"
17798
+ };
17799
+ function legacyIcon(iconId) {
17800
+ return LEGACY_ICON[iconId] ?? "generic";
17801
+ }
17802
+ /**
17803
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
17804
+ * The anti-drift guard cross-checks this against the eventful caps declared
17805
+ * in `packages/types/src/capabilities/*.cap.ts`.
17806
+ */
17807
+ var CAP_TO_KIND = {
17808
+ contact: "contact",
17809
+ motion: "motion-sensor",
17810
+ smoke: "smoke",
17811
+ flood: "flood",
17812
+ gas: "gas",
17813
+ "carbon-monoxide": "carbon-monoxide",
17814
+ vibration: "vibration",
17815
+ tamper: "tamper",
17816
+ presence: "presence",
17817
+ "enum-sensor": "enum-sensor",
17818
+ "event-emitter": "device-event",
17819
+ "lock-control": "lock",
17820
+ switch: "switch",
17821
+ button: "button",
17822
+ doorbell: "doorbell"
17823
+ };
17824
+ function buildDescriptor(capName, kind) {
17825
+ const t = EVENT_TAXONOMY[kind];
17826
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
17827
+ return {
17828
+ ...t,
17829
+ icon: legacyIcon(t.iconId)
17830
+ };
17831
+ }
17832
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
17833
+ /**
17326
17834
  * server-management — per-NODE singleton capability for a node's ROOT
17327
17835
  * package lifecycle (runtime-updatable node packages).
17328
17836
  *
@@ -18800,7 +19308,28 @@ var FaceInfoSchema = object({
18800
19308
  * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`). Absent when the
18801
19309
  * track produced no key frame (e.g. native/onboard source) — the UI falls
18802
19310
  * back to the inline `base64` face crop. */
18803
- keyFrameMediaKey: string().optional()
19311
+ keyFrameMediaKey: string().optional(),
19312
+ /** Winning identity-match cosine (0..1) for this face's track, when an
19313
+ * identity was auto-confirmed. Lets the UI surface WHY a face was assigned
19314
+ * (confidence badge / low-confidence audit). Absent on legacy rows and on
19315
+ * faces that were never auto-recognized. */
19316
+ bestMatchScore: number().optional(),
19317
+ /** Native-scale face short side (px) at recognition time, when the runner
19318
+ * measured it. Lets the UI flag low-resolution auto-assignments. Absent on
19319
+ * legacy rows / runners that reported no native measure. */
19320
+ nativeFaceShortSidePx: number().optional(),
19321
+ /** SUGGESTED identity for this face — a plausible-but-not-confident match that
19322
+ * MISSED auto-assignment (cosine in the suggestion band, or above threshold
19323
+ * but blocked only by the recognition size floor). Mutually exclusive with
19324
+ * `recognizedIdentityId` (a suggestion is NEVER an assignment): the face stays
19325
+ * UNASSIGNED and everything else keeps treating it as unrecognized — the UI
19326
+ * merely offers a one-tap "is this <name>?" confirm. Absent on legacy rows and
19327
+ * on faces that were auto-assigned or below the suggestion band. (2026-07-24) */
19328
+ suggestedIdentityId: string().optional(),
19329
+ /** Peak identity-match cosine (0..1) for `suggestedIdentityId`, captured at the
19330
+ * same moment as `bestMatchScore` (track peak, at close). Lets the UI rank /
19331
+ * badge suggestion confidence. Present iff `suggestedIdentityId` is. (2026-07-24) */
19332
+ suggestedMatchScore: number().optional()
18804
19333
  });
18805
19334
  var FaceFilterEnum = _enum([
18806
19335
  "unassigned",
@@ -20843,36 +21372,6 @@ Object.freeze({
20843
21372
  addonId: null,
20844
21373
  access: "view"
20845
21374
  },
20846
- "advancedNotifier.deleteRule": {
20847
- capName: "advanced-notifier",
20848
- capScope: "system",
20849
- addonId: null,
20850
- access: "delete"
20851
- },
20852
- "advancedNotifier.getHistory": {
20853
- capName: "advanced-notifier",
20854
- capScope: "system",
20855
- addonId: null,
20856
- access: "view"
20857
- },
20858
- "advancedNotifier.getRules": {
20859
- capName: "advanced-notifier",
20860
- capScope: "system",
20861
- addonId: null,
20862
- access: "view"
20863
- },
20864
- "advancedNotifier.testRule": {
20865
- capName: "advanced-notifier",
20866
- capScope: "system",
20867
- addonId: null,
20868
- access: "create"
20869
- },
20870
- "advancedNotifier.upsertRule": {
20871
- capName: "advanced-notifier",
20872
- capScope: "system",
20873
- addonId: null,
20874
- access: "create"
20875
- },
20876
21375
  "alarmPanel.arm": {
20877
21376
  capName: "alarm-panel",
20878
21377
  capScope: "device",
@@ -23177,6 +23676,60 @@ Object.freeze({
23177
23676
  addonId: null,
23178
23677
  access: "create"
23179
23678
  },
23679
+ "notificationRules.createRule": {
23680
+ capName: "notification-rules",
23681
+ capScope: "system",
23682
+ addonId: null,
23683
+ access: "create"
23684
+ },
23685
+ "notificationRules.deleteRule": {
23686
+ capName: "notification-rules",
23687
+ capScope: "system",
23688
+ addonId: null,
23689
+ access: "delete"
23690
+ },
23691
+ "notificationRules.getConditionCatalog": {
23692
+ capName: "notification-rules",
23693
+ capScope: "system",
23694
+ addonId: null,
23695
+ access: "view"
23696
+ },
23697
+ "notificationRules.getHistory": {
23698
+ capName: "notification-rules",
23699
+ capScope: "system",
23700
+ addonId: null,
23701
+ access: "view"
23702
+ },
23703
+ "notificationRules.getRule": {
23704
+ capName: "notification-rules",
23705
+ capScope: "system",
23706
+ addonId: null,
23707
+ access: "view"
23708
+ },
23709
+ "notificationRules.listRules": {
23710
+ capName: "notification-rules",
23711
+ capScope: "system",
23712
+ addonId: null,
23713
+ access: "view"
23714
+ },
23715
+ "notificationRules.setRuleEnabled": {
23716
+ capName: "notification-rules",
23717
+ capScope: "system",
23718
+ addonId: null,
23719
+ access: "create"
23720
+ },
23721
+ "notificationRules.testRule": {
23722
+ capName: "notification-rules",
23723
+ capScope: "system",
23724
+ addonId: null,
23725
+ access: "create"
23726
+ },
23727
+ "notificationRules.updateRule": {
23728
+ capName: "notification-rules",
23729
+ capScope: "system",
23730
+ addonId: null,
23731
+ access: "create"
23732
+ },
23180
23733
  "notifier.cancel": {
23181
23734
  capName: "notifier",
23182
23735
  capScope: "device",