@camstack/addon-tailscale 1.2.4 → 1.2.5

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