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