@camstack/addon-admin-ui 1.2.5 → 1.2.7

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