@camstack/addon-remote-storage 1.2.3 → 1.2.5

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