@camstack/addon-provider-hikvision 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 (3) hide show
  1. package/dist/addon.js +1900 -1121
  2. package/dist/addon.mjs +1900 -1121
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -7,7 +7,7 @@ import { networkInterfaces } from "node:os";
7
7
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
8
8
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
9
9
  //#endregion
10
- //#region ../types/dist/event-category-D4HJq7Mw.mjs
10
+ //#region ../types/dist/event-category-BLcNejAE.mjs
11
11
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
12
12
  EventCategory["SystemBoot"] = "system.boot";
13
13
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -157,9 +157,6 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
157
157
  EventCategory["RecordingSegmentWritten"] = "recording.segment.written";
158
158
  EventCategory["RecordingPolicyFallback"] = "recording.policy.fallback";
159
159
  EventCategory["RecordingRetentionCompleted"] = "recording.retention.completed";
160
- /** Runner-sampled scrub thumbnail (~1/5 s/camera). Telemetry (D8): a lost
161
- * thumb is a scrub gap the recorder's keyframe backfill covers. */
162
- EventCategory["RecordingThumbSampled"] = "recording.thumb-sampled";
163
160
  /** Export render progress (0–100). Telemetry (D8): a lost tick is a stale
164
161
  * progress bar the client reconciles via `recordingExport.getExport`. */
165
162
  EventCategory["RecordingExportProgress"] = "recording.export.progress";
@@ -6824,7 +6821,6 @@ object({ deviceId: number() }), object({ deviceId: number() }), object({
6824
6821
  patch: record(string(), unknown())
6825
6822
  }), object({ success: literal(true) });
6826
6823
  object({ deviceId: number() }), unknown().nullable();
6827
- /** Shorthand to define a method schema */
6828
6824
  function method(input, output, options) {
6829
6825
  return {
6830
6826
  input,
@@ -6832,6 +6828,7 @@ function method(input, output, options) {
6832
6828
  kind: options?.kind ?? "query",
6833
6829
  auth: options?.auth ?? "protected",
6834
6830
  ...options?.access !== void 0 ? { access: options.access } : {},
6831
+ ...options?.caller !== void 0 ? { caller: options.caller } : {},
6835
6832
  timeoutMs: options?.timeoutMs
6836
6833
  };
6837
6834
  }
@@ -7692,16 +7689,23 @@ var StorageLocationDeclarationSchema = object({
7692
7689
  * Which node root the seeded `<id>:default` instance is placed under on a
7693
7690
  * FRESH install:
7694
7691
  * - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
7695
- * the appData volume. Right for small/durable data (backups, logs, models).
7692
+ * the appData volume. Right for small/durable data (logs, models).
7696
7693
  * - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
7697
7694
  * env is set, else falls back to the data root. Right for bulky, hot media
7698
7695
  * (recordings, event media) that should stay off the appData disk.
7696
+ * - `'backup'` — the dedicated backup volume (`CAMSTACK_BACKUP_ROOT`, default
7697
+ * `/backups` in the image) so archives live on their own mount rather than
7698
+ * filling the appData disk. Falls back to the data root when unset.
7699
7699
  *
7700
7700
  * Only affects the seeded default's `basePath`; operators can repoint any
7701
7701
  * location afterwards, and a `defaultsTo` slot inherits its parent's root
7702
7702
  * regardless of this field. Absent (the common case) is treated as `'data'`.
7703
7703
  */
7704
- defaultRoot: _enum(["data", "media"]).optional()
7704
+ defaultRoot: _enum([
7705
+ "data",
7706
+ "media",
7707
+ "backup"
7708
+ ]).optional()
7705
7709
  });
7706
7710
  var DecoderStatsSchema = object({
7707
7711
  inputFps: number(),
@@ -8364,6 +8368,59 @@ for (const l of AUDIO_MACRO_LABELS) {
8364
8368
  /** The complete taxonomy dictionary, keyed by kind. */
8365
8369
  var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
8366
8370
  /**
8371
+ * Notification-Center taxonomy — the fixed vocabulary the NC rule editor
8372
+ * offers as pickers instead of free text. Derived (never hand-listed) from the
8373
+ * single `EVENT_TAXONOMY` dictionary so it stays in lockstep with every other
8374
+ * taxonomy surface (timeline, filters, event page).
8375
+ *
8376
+ * Three buckets, mapped onto the rule editor's `stringList` conditions:
8377
+ * - `videoClasses` → detection classes (person / vehicle / animal + subs)
8378
+ * for the `classes` / `classesExclude` conditions.
8379
+ * - `audioKinds` → audio-analyzer sub kinds (`audio-scream`, …) shown in
8380
+ * the same class picker, grouped under an Audio header.
8381
+ * - `labels` → sensor + control taxonomy kinds (doorbell / contact /
8382
+ * lock / …) for the `sensorKinds` device-event condition.
8383
+ *
8384
+ * Each entry carries `parentKind` so the client can group video subs under
8385
+ * their macro and sensor/control kinds under their category. This surface is
8386
+ * served ADDITIVELY on the `nc.getConditionCatalog` bridge response — no cap
8387
+ * method, no codegen — so it ships train-free with an addon deploy.
8388
+ */
8389
+ /** One selectable taxonomy value: a stable kind id + display label + parent. */
8390
+ var NcTaxonomyEntrySchema = object({
8391
+ /** Stable kind id (e.g. 'person', 'car', 'audio-scream', 'doorbell'). */
8392
+ kind: string(),
8393
+ /** English fallback label (the UI translates via the event-kind i18n key). */
8394
+ label: string(),
8395
+ /** Macro/category parent for grouping ('car' → 'vehicle'); null for a top. */
8396
+ parentKind: string().nullable()
8397
+ });
8398
+ object({
8399
+ videoClasses: array(NcTaxonomyEntrySchema),
8400
+ audioKinds: array(NcTaxonomyEntrySchema),
8401
+ labels: array(NcTaxonomyEntrySchema)
8402
+ });
8403
+ function toEntry(kind, label, parentKind) {
8404
+ return {
8405
+ kind,
8406
+ label,
8407
+ parentKind
8408
+ };
8409
+ }
8410
+ /**
8411
+ * Build the NC taxonomy from `EVENT_TAXONOMY`. Insertion order is preserved
8412
+ * (macros before their subs), which the client relies on for stable grouping.
8413
+ */
8414
+ function buildNcTaxonomy() {
8415
+ const all = Object.values(EVENT_TAXONOMY);
8416
+ return {
8417
+ videoClasses: all.filter((e) => e.category === "detection").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8418
+ audioKinds: all.filter((e) => e.category === "audio" && e.level === "sub").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8419
+ labels: all.filter((e) => e.category === "sensor" || e.category === "control").map((e) => toEntry(e.kind, e.label, e.parentKind))
8420
+ };
8421
+ }
8422
+ Object.freeze(buildNcTaxonomy());
8423
+ /**
8367
8424
  * Error types for the safe expression engine. Two distinct classes so callers
8368
8425
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
8369
8426
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -9347,6 +9404,644 @@ function startReachabilityPoll(options) {
9347
9404
  } };
9348
9405
  }
9349
9406
  /**
9407
+ * Shared geometry vocabulary for on-frame shape caps — privacy-mask,
9408
+ * motion-zones, and the detection zones/lines editor all speak this one
9409
+ * language so a single drawing-plane editor and the providers stay
9410
+ * decoupled from each cap's storage.
9411
+ *
9412
+ * All coordinates are normalized 0..1 of the camera frame (top-left
9413
+ * origin). Each cap composes the SUBSET of shape kinds it supports and
9414
+ * advertises it via `supportedShapes` in its `getOptions`.
9415
+ */
9416
+ /** A normalized 0..1 point (top-left origin). */
9417
+ var MaskPointSchema = object({
9418
+ x: number(),
9419
+ y: number()
9420
+ });
9421
+ /** Axis-aligned rectangle (normalized 0..1). */
9422
+ var MaskRectShapeSchema = object({
9423
+ kind: literal("rect"),
9424
+ x: number(),
9425
+ y: number(),
9426
+ width: number(),
9427
+ height: number()
9428
+ });
9429
+ /** Free polygon — an ordered list of normalized vertices (≥3). */
9430
+ var MaskPolygonShapeSchema = object({
9431
+ kind: literal("polygon"),
9432
+ points: array(MaskPointSchema)
9433
+ });
9434
+ /** Boolean cell grid — row-major, length === gridWidth*gridHeight. */
9435
+ var MaskGridShapeSchema = object({
9436
+ kind: literal("grid"),
9437
+ gridWidth: number(),
9438
+ gridHeight: number(),
9439
+ cells: array(boolean())
9440
+ });
9441
+ discriminatedUnion("kind", [
9442
+ MaskRectShapeSchema,
9443
+ MaskPolygonShapeSchema,
9444
+ MaskGridShapeSchema,
9445
+ object({
9446
+ kind: literal("line"),
9447
+ points: array(MaskPointSchema)
9448
+ })
9449
+ ]);
9450
+ /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
9451
+ var MaskShapeKindSchema = _enum([
9452
+ "rect",
9453
+ "polygon",
9454
+ "grid",
9455
+ "line"
9456
+ ]);
9457
+ /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
9458
+ var MaskPolygonVerticesSchema = object({
9459
+ min: number(),
9460
+ max: number()
9461
+ });
9462
+ /** Grid dimensions when a cap supports 'grid'. */
9463
+ var MaskGridDimsSchema = object({
9464
+ width: number(),
9465
+ height: number()
9466
+ });
9467
+ /**
9468
+ * notification-rules — the Notification Center rule surface (P1 core).
9469
+ *
9470
+ * Spec: `docs/superpowers/specs/2026-07-22-notification-center-requirements.md`
9471
+ * (operator decisions D-1/D-2/D-3 are binding):
9472
+ *
9473
+ * - D-2: rule EVALUATION lives in `addon-post-analysis` (the
9474
+ * `notification-center` module), hooked on the durable persistence
9475
+ * moments (object-event insert, TrackCloser.closeExpired) with a
9476
+ * persisted outbox + retry — never the lossy telemetry bus (D8).
9477
+ * - D-3: urgency belongs to the RULE. `delivery: 'immediate'` fires on the
9478
+ * FIRST persisted detection matching the conditions (per-track dedup,
9479
+ * `maxPerTrack` fixed at 1 — see {@link NC_MAX_PER_TRACK_IMMEDIATE});
9480
+ * `delivery: 'track-end'` evaluates the finalized track record at close.
9481
+ * - DISPATCH stays behind `notification-output` (rules reference targets
9482
+ * by id; per-backend params are a passthrough blob capped by the
9483
+ * target kind's own caps/degrade engine).
9484
+ *
9485
+ * P1 scope: admin-authored rules only (`createdBy` stamped from the
9486
+ * server-injected caller identity — the first `caller: 'required'`
9487
+ * adopter). The P1 condition subset is: devices, classes(+exclude),
9488
+ * minConfidence, admin zones (any/all + exclude), weekly schedule
9489
+ * windows, and the optional label/identity/plate matchers. User rules,
9490
+ * private zones, per-recipient fan-out and the wider condition table are
9491
+ * P2+ (see spec §7).
9492
+ *
9493
+ * All schemas here are the single source of truth — `NcRule` etc. are
9494
+ * `z.infer` exports; no duplicate interfaces (the advanced-notifier
9495
+ * schema/interface drift is explicitly not repeated).
9496
+ */
9497
+ /**
9498
+ * D-3: the trigger/urgency of a rule — which persistence moment evaluates it.
9499
+ * The value maps 1:1 onto the evaluated record kind:
9500
+ * - `immediate` ↔ object-event persist (lowest-latency detection burst)
9501
+ * - `track-end` ↔ TrackCloser.closeExpired (finalized track record)
9502
+ * - `device-event` ↔ SensorEventStore insert (doorbell press / sensor state
9503
+ * change of a LINKED device, one row per linked camera)
9504
+ * - `package-event` ↔ PackageDropDetector object-event insert (a `package`
9505
+ * delivery / pick-up)
9506
+ *
9507
+ * `immediate`/`track-end` carry the D-3 urgency semantics; `device-event`/
9508
+ * `package-event` are pure trigger kinds (no urgency dimension). Extending
9509
+ * this one field keeps the schema additive — a rule still declares exactly
9510
+ * one trigger.
9511
+ */
9512
+ var NcDeliverySchema = _enum([
9513
+ "immediate",
9514
+ "track-end",
9515
+ "device-event",
9516
+ "package-event"
9517
+ ]);
9518
+ /** Weekly schedule — OR of windows; absence on the rule = always active. */
9519
+ var NcScheduleSchema = object({
9520
+ windows: array(object({
9521
+ /** Days of week the window STARTS on (0 = Sunday … 6 = Saturday). */
9522
+ days: array(number().int().min(0).max(6)).min(1),
9523
+ startMinute: number().int().min(0).max(1439),
9524
+ endMinute: number().int().min(0).max(1439)
9525
+ })).min(1),
9526
+ /** IANA timezone; default = hub host timezone. */
9527
+ timezone: string().optional(),
9528
+ /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
9529
+ invert: boolean().optional()
9530
+ });
9531
+ /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
9532
+ var NcPlateMatcherSchema = object({
9533
+ values: array(string().min(1)).min(1),
9534
+ /** Max Levenshtein distance after normalization (uppercase alphanumeric). */
9535
+ maxDistance: number().int().min(0).max(3).default(1)
9536
+ });
9537
+ /**
9538
+ * Occupancy condition (DEVICE-EVENT trigger). Fires on a ZoneAnalytics
9539
+ * occupancy edge for a device — optionally narrowed to a single admin
9540
+ * `zoneId` and/or object `className`. `op` selects the edge/threshold:
9541
+ * - `became-occupied` (default) — count crossed 0 → ≥ `count`
9542
+ * - `became-free` — count crossed ≥ `count` → below it
9543
+ * - `>=` / `<=` — count is at/over or at/under `count`
9544
+ * `sustainSeconds` requires the condition hold continuously that long
9545
+ * before firing (debounces flicker; 0 = fire on the first matching edge).
9546
+ * Fail-closed: no ZoneAnalytics snapshot / missing zone / null snapshot ⇒
9547
+ * the condition never matches. Confirmed edge-state survives addon restarts
9548
+ * (declared SQLite collection, reseeded on boot).
9549
+ */
9550
+ var NcOccupancyConditionSchema = object({
9551
+ /** Admin zone id to scope the count to; absent = whole-frame occupancy. */
9552
+ zoneId: string().optional(),
9553
+ /** Object class to count; absent = any class. */
9554
+ className: string().optional(),
9555
+ op: _enum([
9556
+ "became-occupied",
9557
+ "became-free",
9558
+ ">=",
9559
+ "<="
9560
+ ]).default("became-occupied"),
9561
+ count: number().int().min(0).default(1),
9562
+ sustainSeconds: number().int().min(0).max(3600).default(15)
9563
+ });
9564
+ /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
9565
+ var NcZoneConditionSchema = object({
9566
+ ids: array(string().min(1)).min(1),
9567
+ /** Quantifier over `ids` — at least one / every one visited. */
9568
+ match: _enum(["any", "all"]).default("any")
9569
+ });
9570
+ /**
9571
+ * The P1 condition set — a flat AND of groups; absent group = pass;
9572
+ * membership lists are OR within the list (spec §2.3).
9573
+ */
9574
+ var NcConditionsSchema = object({
9575
+ /** Device scope — absent = all devices. */
9576
+ devices: array(number()).optional(),
9577
+ /** Detector class names (any overlap with the record's class set). */
9578
+ classes: array(string().min(1)).optional(),
9579
+ /** Veto classes — any overlap fails the rule. */
9580
+ classesExclude: array(string().min(1)).optional(),
9581
+ /** Minimum detection confidence 0–1 (fails when the record has none). */
9582
+ minConfidence: number().min(0).max(1).optional(),
9583
+ /** Admin zone membership over event `zones` / track `zonesVisited`. */
9584
+ zones: NcZoneConditionSchema.optional(),
9585
+ /** Veto zones — any hit fails the rule. */
9586
+ zonesExclude: array(string().min(1)).optional(),
9587
+ /**
9588
+ * Exact (case-insensitive) match on the record's collapsed `label`
9589
+ * (identity name / plate text / subclass).
9590
+ */
9591
+ labelEquals: array(string().min(1)).optional(),
9592
+ /**
9593
+ * Identity matcher. P1 boundary: matched against the record's collapsed
9594
+ * `label` (the identity display name propagated by the face pipeline) —
9595
+ * identity-ID matching rides in P2 when identity ids reach the record.
9596
+ */
9597
+ identities: array(string().min(1)).optional(),
9598
+ /** Fuzzy plate matcher against the record's `label` (plate text). */
9599
+ plates: NcPlateMatcherSchema.optional(),
9600
+ /**
9601
+ * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
9602
+ * Same P1 boundary: matched against the record's collapsed `label` (the
9603
+ * identity display name). A record with NO label passes (nothing to
9604
+ * exclude), unlike the include variant which fails on an absent label.
9605
+ */
9606
+ identitiesExclude: array(string().min(1)).optional(),
9607
+ /**
9608
+ * Minimum server-computed key-event importance in [0,1] (`Track.importance`).
9609
+ * TRACK-END only: importance is scored at track close, so it does not exist
9610
+ * at immediate / object-event evaluation time (see catalog `appliesTo`). At
9611
+ * close the value is threaded via the close-time info (the `Track` clone is
9612
+ * captured before the DB row is updated, so it would otherwise read stale).
9613
+ * Fails when the record carries no importance (never guess quality — the
9614
+ * `minConfidence` precedent). MVP cut: a single scalar threshold.
9615
+ */
9616
+ minImportance: number().min(0).max(1).optional(),
9617
+ /**
9618
+ * Minimum track dwell in SECONDS — `(lastSeen − firstSeen) / 1000`.
9619
+ * TRACK-END only: an `immediate` / object-event subject has no closed
9620
+ * lifespan, so a dwell condition never matches immediate delivery
9621
+ * (documented choice — the object-event record carries no `firstSeen`,
9622
+ * so dwell cannot be computed from what the subject actually carries).
9623
+ */
9624
+ minDwellSeconds: number().min(0).optional(),
9625
+ /**
9626
+ * Detection provenance filter. `any` (default / absent) matches every
9627
+ * source; otherwise the subject's source must equal it. Legacy records
9628
+ * with no stamped source are treated as `pipeline`. The union spans both
9629
+ * record kinds — object events carry `pipeline` | `onboard`, synthetic
9630
+ * tracks carry `sensor`.
9631
+ */
9632
+ source: _enum([
9633
+ "pipeline",
9634
+ "onboard",
9635
+ "sensor",
9636
+ "any"
9637
+ ]).optional(),
9638
+ /**
9639
+ * Minimum identity / plate MATCH confidence in [0,1] — DISTINCT from the
9640
+ * detector `minConfidence` (that gates the object-detection score; this
9641
+ * gates the recognition/OCR match score). Fails when the subject carries
9642
+ * no label-match confidence (never guess). TRACK-END only: the confidence
9643
+ * lives on the recognition result and reaches the subject at track close.
9644
+ *
9645
+ * What it measures precisely (plumbed at track close — the closer threads
9646
+ * the value into `NcTrackClosedInfo.labelConfidence`, the same seam as
9647
+ * `importance`): the BEST recognition match confidence observed for the
9648
+ * label the track carries at close — for a face, the peak cosine similarity
9649
+ * of the ASSIGNED identity (`FaceMatch.score`, reset on an identity switch);
9650
+ * for a plate, the peak OCR read score of the best-held plate
9651
+ * (`plateText.confidence`). When BOTH a face and a plate were recognized on
9652
+ * one track the higher of the two is used. A track that ended with no
9653
+ * confident identity/plate match carries no value, so the condition fails
9654
+ * closed for it (an un-recognized subject).
9655
+ */
9656
+ minLabelConfidence: number().min(0).max(1).optional(),
9657
+ /**
9658
+ * DEVICE-EVENT only. Raw device event-type tokens (`EventFire.eventType`,
9659
+ * e.g. a doorbell `press` / `press_long`) — matched case-insensitively
9660
+ * against the token carried on the device-event subject (extracted from the
9661
+ * event-emitter runtime slice's `lastEvent.eventType`). Fails when the
9662
+ * subject carries no token. Doorbell-pulse / passive-sensor kinds emit no
9663
+ * eventType, so gate those with {@link sensorKinds} instead.
9664
+ */
9665
+ eventTypeTokens: array(string().min(1)).optional(),
9666
+ /**
9667
+ * DEVICE-EVENT only. Sensor/control taxonomy kinds (e.g. `doorbell`,
9668
+ * `contact`, `button`, `device-event`) — matched against the persisted
9669
+ * `SensorEvent.kind` (see `sensor-event-kinds.ts`). Membership is OR.
9670
+ */
9671
+ sensorKinds: array(string().min(1)).optional(),
9672
+ /**
9673
+ * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
9674
+ * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
9675
+ * when the subject's phase does not match (a subject always carries a phase
9676
+ * on the package-event trigger).
9677
+ */
9678
+ packagePhase: _enum([
9679
+ "delivered",
9680
+ "picked-up",
9681
+ "both"
9682
+ ]).optional(),
9683
+ /**
9684
+ * PERSONAL-RULE custom zones (viewer-drawn). Inline normalized polygons
9685
+ * (MaskShape vocabulary). A record passes when its bbox overlaps ANY
9686
+ * listed polygon (ZoneEngine membership semantics). Evaluated only when
9687
+ * the subject carries a bbox; absent bbox ⇒ the condition FAILS.
9688
+ */
9689
+ customZones: array(MaskPolygonShapeSchema).optional(),
9690
+ /**
9691
+ * DEVICE-EVENT only. ZoneAnalytics occupancy edge — fires when a device's
9692
+ * (optionally zone/class-scoped) occupancy count crosses the configured
9693
+ * threshold and holds for `sustainSeconds`. Fail-closed on missing
9694
+ * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
9695
+ */
9696
+ occupancy: NcOccupancyConditionSchema.optional()
9697
+ });
9698
+ /** One delivery target: a `notification-output` Target ref + passthrough params. */
9699
+ var NcRuleTargetSchema = object({
9700
+ /** `notification-output` Target id. */
9701
+ targetId: string().min(1),
9702
+ /**
9703
+ * Per-backend passthrough. Recognized keys are mapped onto the canonical
9704
+ * Notification (`priority`, `level`, `sound`, `clickUrl`, `ttl`); the
9705
+ * degrade engine drops what the backend can't render.
9706
+ */
9707
+ params: record(string(), unknown()).optional()
9708
+ });
9709
+ /**
9710
+ * Media attachment policy (P1 still-image subset).
9711
+ * - `best` — the best AVAILABLE subject image at dispatch time (D-3).
9712
+ * - `best-matching` — the media that explains WHY the rule fired: a rule
9713
+ * matched on identities attaches the subject's `faceCrop`, one matched on
9714
+ * plates attaches the `plateCrop`; a rule with no identity/plate condition
9715
+ * (or when the specific crop is missing) degrades to `best`, then
9716
+ * `keyFrame`, then no attachment — never delaying the send. The matched
9717
+ * condition summary is frozen on the outbox row at enqueue (like the rule
9718
+ * name), so the choice never drifts from the record that fired it.
9719
+ * - `keyFrame` — the clean scene frame (no subject box).
9720
+ * - `none` — no attachment.
9721
+ */
9722
+ var NcMediaPolicySchema = object({ attach: _enum([
9723
+ "best",
9724
+ "best-matching",
9725
+ "keyFrame",
9726
+ "none"
9727
+ ]).default("best") });
9728
+ /** Throttle — cooldown survives restarts (rebuilt from the outbox on boot). */
9729
+ var NcThrottleSchema = object({
9730
+ cooldownSec: number().int().min(0).max(86400).default(60),
9731
+ /** `rule` = one shared cooldown; `rule-device` = per-camera cooldown. */
9732
+ scope: _enum(["rule", "rule-device"]).default("rule-device")
9733
+ });
9734
+ /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
9735
+ var NcRuleInputSchema = object({
9736
+ name: string().min(1).max(200),
9737
+ enabled: boolean().default(true),
9738
+ delivery: NcDeliverySchema,
9739
+ conditions: NcConditionsSchema.default({}),
9740
+ schedule: NcScheduleSchema.optional(),
9741
+ targets: array(NcRuleTargetSchema).min(1),
9742
+ media: NcMediaPolicySchema.default({ attach: "best" }),
9743
+ throttle: NcThrottleSchema.default({
9744
+ cooldownSec: 60,
9745
+ scope: "rule-device"
9746
+ }),
9747
+ /** `{{var}}` templating over camera/class/label/zones/confidence/time. */
9748
+ template: object({
9749
+ title: string().max(500).optional(),
9750
+ body: string().max(2e3).optional()
9751
+ }).optional(),
9752
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
9753
+ priority: number().int().min(1).max(5).default(3),
9754
+ /**
9755
+ * Ownership/visibility key. Absent = admin/global rule (unchanged legacy
9756
+ * behaviour, visible to all, read-only in the viewer). Present = personal
9757
+ * rule owned by this userId. Server-stamped; never trusted from a client.
9758
+ */
9759
+ ownerUserId: string().optional()
9760
+ });
9761
+ /**
9762
+ * Partial patch for `updateRule` — any subset of the input fields, plus the
9763
+ * persisted-only {@link NcRuleSchema} `disabledTargetIds` set. The latter is
9764
+ * NOT a client-authored input field (it lives on the persisted rule, not the
9765
+ * input), so it is added here explicitly to let the store's per-target opt-out
9766
+ * toggle round-trip through the shared `update` path. Viewer opt-out mutations
9767
+ * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
9768
+ * `updateRule` patch.
9769
+ */
9770
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
9771
+ /** A persisted rule. */
9772
+ var NcRuleSchema = NcRuleInputSchema.extend({
9773
+ id: string(),
9774
+ /** userId of the admin who created the rule (server-stamped caller). */
9775
+ createdBy: string(),
9776
+ createdAt: number(),
9777
+ updatedAt: number(),
9778
+ /**
9779
+ * Per-target opt-out set. A targetId here is suppressed for THIS rule at
9780
+ * send time. Only a target's OWNER may add/remove its id (server-checked
9781
+ * in `nc.setRuleTargetEnabled`). Defaults to empty.
9782
+ */
9783
+ disabledTargetIds: array(string()).default([])
9784
+ });
9785
+ var NcTestResultSchema = object({
9786
+ recordId: string(),
9787
+ recordKind: _enum([
9788
+ "object-event",
9789
+ "track",
9790
+ "device-event",
9791
+ "package-event"
9792
+ ]),
9793
+ deviceId: number(),
9794
+ timestamp: number(),
9795
+ wouldFire: boolean(),
9796
+ /** Condition id that failed (first failing group), when `wouldFire` is false. */
9797
+ failedCondition: string().optional(),
9798
+ className: string().optional(),
9799
+ label: string().optional()
9800
+ });
9801
+ var NcConditionDescriptorSchema = object({
9802
+ /** Field id inside `NcConditions` (or `'schedule'` for the rule-level group). */
9803
+ id: string(),
9804
+ group: _enum([
9805
+ "scope",
9806
+ "class",
9807
+ "zones",
9808
+ "quality",
9809
+ "label",
9810
+ "schedule",
9811
+ "device",
9812
+ "package",
9813
+ "occupancy"
9814
+ ]),
9815
+ label: string(),
9816
+ /** Editor widget the UI renders — never hardcode per-condition forms. */
9817
+ valueType: _enum([
9818
+ "deviceIdList",
9819
+ "stringList",
9820
+ "number01",
9821
+ "number",
9822
+ "sourceSelect",
9823
+ "zoneSelection",
9824
+ "zoneIdList",
9825
+ "schedule",
9826
+ "plateMatcher",
9827
+ "packagePhase",
9828
+ "polygonDraw",
9829
+ "occupancy"
9830
+ ]),
9831
+ operator: _enum([
9832
+ "in",
9833
+ "notIn",
9834
+ "anyOf",
9835
+ "allOf",
9836
+ "gte",
9837
+ "fuzzyIn",
9838
+ "withinSchedule"
9839
+ ]),
9840
+ /** Which delivery kinds the condition applies to. */
9841
+ appliesTo: array(NcDeliverySchema),
9842
+ phase: string(),
9843
+ description: string().optional()
9844
+ });
9845
+ /**
9846
+ * The delivery lifecycle status of a history row — a straight read of the
9847
+ * durable outbox row's own status (single source of truth):
9848
+ * - `pending` — enqueued, in-flight or retrying with backoff
9849
+ * - `sent` — delivered (terminal)
9850
+ * - `dead` — dead-lettered after exhausting retries / a permanent
9851
+ * backend rejection / a deleted target (terminal; carries
9852
+ * the failure `error`)
9853
+ *
9854
+ * P1 has no `suppressed-quiet-hours` / `snoozed` states — those ride the P2
9855
+ * user dimension (quiet hours / snooze) and are additive when they land.
9856
+ */
9857
+ var NcHistoryStatusSchema = _enum([
9858
+ "pending",
9859
+ "sent",
9860
+ "dead"
9861
+ ]);
9862
+ /** The evaluated record kind a history row descends from (one per trigger). */
9863
+ var NcHistoryRecordKindSchema = _enum([
9864
+ "object-event",
9865
+ "track-end",
9866
+ "device-event",
9867
+ "package-event"
9868
+ ]);
9869
+ /** Subject summary frozen on the row at fire time (survives rule/record edits). */
9870
+ var NcHistorySubjectSchema = object({
9871
+ className: string(),
9872
+ label: string().optional(),
9873
+ confidence: number().optional(),
9874
+ zones: array(string()),
9875
+ timestamp: number()
9876
+ });
9877
+ /**
9878
+ * One delivery-history row. This is a read-only VIEW over the durable
9879
+ * outbox row (single source of truth — the same row the drain loop drives;
9880
+ * NO second write path, so history can never drift from delivery state).
9881
+ * The §3.2 fields map directly: `ruleId`/`targetId`/`deviceId` are columns,
9882
+ * `eventRef` is `recordKind`+`recordId`, `timestamps` are `createdAt`
9883
+ * (fire) / `updatedAt` (last transition), `status` + `error` are the
9884
+ * lifecycle. `ruleName` + `subject` are the intent snapshot frozen at
9885
+ * enqueue. `userId?` (per-recipient history) is P2 — no user dimension in
9886
+ * P1 (admin scope only).
9887
+ */
9888
+ var NcHistoryEntrySchema = object({
9889
+ /** Outbox row id — the stable dedup id `ruleId:dedupRef:targetId`. */
9890
+ id: string(),
9891
+ ruleId: string(),
9892
+ /** Rule name frozen at fire time (outlives a later rename / delete). */
9893
+ ruleName: string(),
9894
+ /** The rule urgency/trigger that produced this delivery. */
9895
+ delivery: NcDeliverySchema,
9896
+ targetId: string(),
9897
+ deviceId: number(),
9898
+ recordKind: NcHistoryRecordKindSchema,
9899
+ /** Event / track ref of the evaluated record (§3.2 `eventRef`). */
9900
+ recordId: string(),
9901
+ /** Present for track-scoped deliveries (object-event / track-end). */
9902
+ trackId: string().optional(),
9903
+ status: NcHistoryStatusSchema,
9904
+ /** Delivery attempts made so far. */
9905
+ attempts: number().int(),
9906
+ /** Fire time (outbox enqueue). */
9907
+ createdAt: number(),
9908
+ /** Last transition time (terminal for sent / dead). */
9909
+ updatedAt: number(),
9910
+ /** Failure detail — present on a `dead` row. */
9911
+ error: string().optional(),
9912
+ subject: NcHistorySubjectSchema
9913
+ });
9914
+ /**
9915
+ * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
9916
+ * AND; absent = unbounded on that axis. `since`/`until` bound the fire time
9917
+ * (`createdAt`, epoch ms, inclusive). `limit` is clamped to
9918
+ * {@link NC_HISTORY_LIMIT_MAX}. `userId` (per-recipient filtering) is P2.
9919
+ */
9920
+ var NcHistoryFilterSchema = object({
9921
+ ruleId: string().optional(),
9922
+ deviceId: number().optional(),
9923
+ status: NcHistoryStatusSchema.optional(),
9924
+ since: number().optional(),
9925
+ until: number().optional(),
9926
+ limit: number().int().min(1).max(500).default(100)
9927
+ });
9928
+ 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 }), {
9929
+ kind: "mutation",
9930
+ auth: "admin",
9931
+ caller: "required"
9932
+ }), method(object({
9933
+ ruleId: string(),
9934
+ patch: NcRulePatchSchema
9935
+ }), object({ rule: NcRuleSchema }), {
9936
+ kind: "mutation",
9937
+ auth: "admin",
9938
+ caller: "required"
9939
+ }), method(object({ ruleId: string() }), object({ success: literal(true) }), {
9940
+ kind: "mutation",
9941
+ auth: "admin"
9942
+ }), method(object({
9943
+ ruleId: string(),
9944
+ enabled: boolean()
9945
+ }), object({ success: literal(true) }), {
9946
+ kind: "mutation",
9947
+ auth: "admin"
9948
+ }), method(object({
9949
+ rule: NcRuleInputSchema,
9950
+ lookbackMinutes: number().int().min(1).max(1440).default(60)
9951
+ }), object({ results: array(NcTestResultSchema) }), {
9952
+ kind: "mutation",
9953
+ auth: "admin"
9954
+ }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
9955
+ /**
9956
+ * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
9957
+ *
9958
+ * Spec: `docs/superpowers/specs/2026-07-24-nc-occupancy-timelapse-design.md`
9959
+ * §3.2/§3.3.
9960
+ *
9961
+ * Deliberately NOT a capability definition and NOT an `NcRule`:
9962
+ * - Every `NcDelivery` member is a *persisted-pipeline-record* trigger. A
9963
+ * timelapse fires on a SCHEDULE WINDOW BOUNDARY, evaluates no pipeline
9964
+ * record, and produces a video it assembled itself — so it rides no
9965
+ * delivery-enum member (the enum is frozen) and no cap method. This file is
9966
+ * a plain typed schema; it does NOT go through `npm run codegen`.
9967
+ * - It shares only the delivery leg (`notification-output.send`) and the
9968
+ * persistence/ownership patterns with the Notification Center, reusing
9969
+ * {@link NcScheduleSchema} (weekly windows, midnight-crossing, invertible)
9970
+ * and {@link NcRuleTargetSchema} (target ref + passthrough params).
9971
+ *
9972
+ * Ownership is SERVER-DERIVED. `ownerUserId` / `createdBy` / `createdAt` /
9973
+ * `updatedAt` / `id` / `lastGeneratedAt` live on the PERSISTED rule only —
9974
+ * {@link TimelapseRuleInputSchema} and {@link TimelapseRulePatchSchema} do not
9975
+ * carry them, so a forged client payload can never claim or re-own a rule
9976
+ * (Zod strips unknown keys). The store stamps them from the resolved caller.
9977
+ */
9978
+ /** `{{var}}` templating over camera/rule/time — same vocabulary as `NcRule`. */
9979
+ var TimelapseTemplateSchema = object({
9980
+ title: string().max(500).optional(),
9981
+ body: string().max(2e3).optional()
9982
+ });
9983
+ var NameField = string().min(1).max(200);
9984
+ var DeviceIdsField = array(number()).min(1);
9985
+ var CadenceSecField = number().int().min(2).max(3600);
9986
+ var FramerateField = number().int().min(1).max(60);
9987
+ var TargetsField = array(NcRuleTargetSchema).min(1);
9988
+ var PriorityField = number().int().min(1).max(5);
9989
+ /**
9990
+ * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
9991
+ * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
9992
+ * here (see the ownership note above).
9993
+ */
9994
+ var TimelapseRuleInputSchema = object({
9995
+ name: NameField,
9996
+ enabled: boolean().default(true),
9997
+ /** Cameras sampled by this rule — one scratch dir + one artifact per device. */
9998
+ deviceIds: DeviceIdsField,
9999
+ /**
10000
+ * Activation window(s). REQUIRED (unlike `NcRule`, where an absent schedule
10001
+ * means "always active"): a timelapse is defined by its window boundaries —
10002
+ * open clears the scratch, close assembles and delivers.
10003
+ */
10004
+ schedule: NcScheduleSchema,
10005
+ /** Force-snapshot cadence inside the window, seconds (predecessor parity). */
10006
+ cadenceSec: CadenceSecField.default(15),
10007
+ /** Output frames per second of the assembled mp4 (predecessor parity). */
10008
+ framerate: FramerateField.default(10),
10009
+ /** `notification-output` targets the finished video/thumbnail is sent to. */
10010
+ targets: TargetsField,
10011
+ template: TimelapseTemplateSchema.optional(),
10012
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
10013
+ priority: PriorityField.default(3)
10014
+ });
10015
+ object({
10016
+ name: NameField.optional(),
10017
+ enabled: boolean().optional(),
10018
+ deviceIds: DeviceIdsField.optional(),
10019
+ schedule: NcScheduleSchema.optional(),
10020
+ cadenceSec: CadenceSecField.optional(),
10021
+ framerate: FramerateField.optional(),
10022
+ targets: TargetsField.optional(),
10023
+ template: TimelapseTemplateSchema.nullable().optional(),
10024
+ priority: PriorityField.optional()
10025
+ });
10026
+ TimelapseRuleInputSchema.extend({
10027
+ id: string(),
10028
+ /**
10029
+ * Ownership/visibility key. Absent = admin/global rule (visible to all).
10030
+ * Present = personal rule owned by this userId. Server-stamped from the
10031
+ * resolved caller; never trusted from a client payload.
10032
+ */
10033
+ ownerUserId: string().optional(),
10034
+ /**
10035
+ * Epoch-ms of the last successful generation — the 1-hour re-generation
10036
+ * guard's durable state (predecessor parity). Absent = never generated.
10037
+ */
10038
+ lastGeneratedAt: number().optional(),
10039
+ /** userId of the caller who created the rule (server-stamped). */
10040
+ createdBy: string(),
10041
+ createdAt: number(),
10042
+ updatedAt: number()
10043
+ });
10044
+ /**
9350
10045
  * Generic device-level status snapshot. Auto-registered by `BaseDevice`
9351
10046
  * for every device, regardless of provider — the kernel needs a uniform
9352
10047
  * cap-keyed slice for the basic device flags every consumer expects to
@@ -12454,6 +13149,22 @@ var CameraMetricsSchema = object({
12454
13149
  ])
12455
13150
  });
12456
13151
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
13152
+ /**
13153
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
13154
+ * within the frame, so the executor can re-cut a leaf child ROI at native
13155
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
13156
+ */
13157
+ var NativeCropRefSchema = object({
13158
+ /** Handle keying the retained native surface (node-pinned to its owner). */
13159
+ handle: FrameHandleSchema,
13160
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
13161
+ cropFrameSpace: object({
13162
+ x: number(),
13163
+ y: number(),
13164
+ w: number(),
13165
+ h: number()
13166
+ })
13167
+ });
12457
13168
  var ModelFormatSchema$1 = _enum([
12458
13169
  "onnx",
12459
13170
  "coreml",
@@ -12729,7 +13440,22 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
12729
13440
  * Omitted ⇒ the runner's default device (current single-engine
12730
13441
  * behaviour). Selects WHICH device pool of the node runs the call.
12731
13442
  */
12732
- deviceKey: string().optional()
13443
+ deviceKey: string().optional(),
13444
+ /**
13445
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
13446
+ * when the parent crop was resolved from the frame's retained NATIVE
13447
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
13448
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
13449
+ * resolution from that surface — the SAME quality path faces already
13450
+ * had — instead of the downscaled parent tile. `handle` keys the native
13451
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
13452
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
13453
+ * the executor's crop-normalized child ROI back into frame-normalized
13454
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
13455
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
13456
+ * (today's behaviour on the fallback path).
13457
+ */
13458
+ nativeCropRef: NativeCropRefSchema.optional()
12733
13459
  }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
12734
13460
  engine: PipelineEngineChoiceSchema.optional(),
12735
13461
  steps: array(PipelineStepInputSchema).min(1),
@@ -12978,7 +13704,11 @@ var DetailResultSchema = object({
12978
13704
  bbox: NativeCropBboxSchema.optional(),
12979
13705
  embedding: string().optional(),
12980
13706
  label: string().optional(),
12981
- alignedCropJpeg: string().optional()
13707
+ alignedCropJpeg: string().optional(),
13708
+ /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
13709
+ * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
13710
+ * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
13711
+ nativeFaceShortSidePx: number().optional()
12982
13712
  });
12983
13713
  /**
12984
13714
  * Per-camera tunable ranges + defaults. Single source of truth used
@@ -13463,86 +14193,25 @@ var motionTriggerCapability = {
13463
14193
  runtimeState: MotionTriggerRuntimeStateSchema
13464
14194
  };
13465
14195
  /**
13466
- * Shared geometry vocabulary for on-frame shape caps privacy-mask,
13467
- * motion-zones, and the detection zones/lines editor all speak this one
13468
- * language so a single drawing-plane editor and the providers stay
13469
- * decoupled from each cap's storage.
13470
- *
13471
- * All coordinates are normalized 0..1 of the camera frame (top-left
13472
- * origin). Each cap composes the SUBSET of shape kinds it supports and
13473
- * advertises it via `supportedShapes` in its `getOptions`.
14196
+ * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
14197
+ * on-camera motion-detection mask is a single `grid` region (a row-major
14198
+ * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
14199
+ * a region keeps one drawing-plane model across all geometry caps.
13474
14200
  */
13475
- /** A normalized 0..1 point (top-left origin). */
13476
- var MaskPointSchema = object({
13477
- x: number(),
13478
- y: number()
13479
- });
13480
- /** Axis-aligned rectangle (normalized 0..1). */
13481
- var MaskRectShapeSchema = object({
13482
- kind: literal("rect"),
13483
- x: number(),
13484
- y: number(),
13485
- width: number(),
13486
- height: number()
13487
- });
13488
- /** Free polygon — an ordered list of normalized vertices (≥3). */
13489
- var MaskPolygonShapeSchema = object({
13490
- kind: literal("polygon"),
13491
- points: array(MaskPointSchema)
14201
+ /** A motion-zone region exactly one boolean cell grid today. */
14202
+ var MotionZoneRegionSchema = object({
14203
+ id: number(),
14204
+ enabled: boolean(),
14205
+ shape: MaskGridShapeSchema
13492
14206
  });
13493
- /** Boolean cell gridrow-major, length === gridWidth*gridHeight. */
13494
- var MaskGridShapeSchema = object({
13495
- kind: literal("grid"),
13496
- gridWidth: number(),
13497
- gridHeight: number(),
13498
- cells: array(boolean())
13499
- });
13500
- discriminatedUnion("kind", [
13501
- MaskRectShapeSchema,
13502
- MaskPolygonShapeSchema,
13503
- MaskGridShapeSchema,
13504
- object({
13505
- kind: literal("line"),
13506
- points: array(MaskPointSchema)
13507
- })
13508
- ]);
13509
- /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
13510
- var MaskShapeKindSchema = _enum([
13511
- "rect",
13512
- "polygon",
13513
- "grid",
13514
- "line"
13515
- ]);
13516
- /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
13517
- var MaskPolygonVerticesSchema = object({
13518
- min: number(),
13519
- max: number()
13520
- });
13521
- /** Grid dimensions when a cap supports 'grid'. */
13522
- var MaskGridDimsSchema = object({
13523
- width: number(),
13524
- height: number()
13525
- });
13526
- /**
13527
- * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
13528
- * on-camera motion-detection mask is a single `grid` region (a row-major
13529
- * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
13530
- * a region keeps one drawing-plane model across all geometry caps.
13531
- */
13532
- /** A motion-zone region — exactly one boolean cell grid today. */
13533
- var MotionZoneRegionSchema = object({
13534
- id: number(),
13535
- enabled: boolean(),
13536
- shape: MaskGridShapeSchema
13537
- });
13538
- /** Current on-camera motion-detection state — master enable + sensitivity +
13539
- * the grid region(s). */
13540
- var MotionZoneStatusSchema = object({
13541
- enabled: boolean(),
13542
- sensitivity: number(),
13543
- /** Grid region(s). Today exactly one `grid` shape. */
13544
- regions: array(MotionZoneRegionSchema),
13545
- lastFetchedAt: number()
14207
+ /** Current on-camera motion-detection state master enable + sensitivity +
14208
+ * the grid region(s). */
14209
+ var MotionZoneStatusSchema = object({
14210
+ enabled: boolean(),
14211
+ sensitivity: number(),
14212
+ /** Grid region(s). Today exactly one `grid` shape. */
14213
+ regions: array(MotionZoneRegionSchema),
14214
+ lastFetchedAt: number()
13546
14215
  });
13547
14216
  /** Per-camera availability — grid dims are fixed per camera model; the UI
13548
14217
  * sizes its editor from `grid`. */
@@ -16774,94 +17443,6 @@ var EnrichedWidgetMetadataSchema = WidgetMetadataSchema.extend({
16774
17443
  bundleUrl: string()
16775
17444
  });
16776
17445
  method(_void(), array(EnrichedWidgetMetadataSchema).readonly());
16777
- var NotificationRuleConditionsSchema = object({
16778
- deviceIds: array(number()).readonly().optional(),
16779
- classNames: array(string()).readonly().optional(),
16780
- zoneIds: array(string()).readonly().optional(),
16781
- minConfidence: number().optional(),
16782
- source: _enum([
16783
- "pipeline",
16784
- "onboard",
16785
- "any"
16786
- ]).optional(),
16787
- schedule: object({
16788
- days: array(number()).readonly(),
16789
- startHour: number(),
16790
- endHour: number()
16791
- }).optional(),
16792
- cooldownSeconds: number().optional(),
16793
- minDwellSeconds: number().optional(),
16794
- /** Match against `event.data.eventType` token (e.g. `'press_long'`). When non-empty, only events
16795
- * carrying a matching `data.eventType` string pass this condition. Rules without this field are
16796
- * unaffected (back-compat). Distinct from `rule.eventTypes` which holds EventCategory strings. */
16797
- eventTypeTokens: array(string()).readonly().optional(),
16798
- /** Match detections whose CLIP image embedding is semantically similar to this free-text
16799
- * description. Requires the embedding-encoder cap to have pre-warmed the text vector.
16800
- * `minSimilarity` is the cosine similarity threshold in [0, 1]. */
16801
- clipDescription: object({
16802
- text: string().min(1),
16803
- minSimilarity: number().min(0).max(1)
16804
- }).optional(),
16805
- /** Match events whose recognized-entity label (face identity name or plate
16806
- * vehicle name, propagated onto `event.data.label`) is one of these values.
16807
- * Empty/absent → unaffected (back-compat). Enables "notify me when <named
16808
- * vehicle/person> is seen". */
16809
- labels: array(string()).readonly().optional()
16810
- });
16811
- var NotificationRuleTemplateSchema = object({
16812
- title: string(),
16813
- body: string(),
16814
- imageMode: _enum([
16815
- "crop",
16816
- "annotated",
16817
- "full",
16818
- "none"
16819
- ])
16820
- });
16821
- var NotificationRuleSchema = object({
16822
- id: string(),
16823
- name: string(),
16824
- enabled: boolean(),
16825
- eventTypes: array(string()).readonly(),
16826
- conditions: NotificationRuleConditionsSchema,
16827
- outputs: array(string()).readonly(),
16828
- template: NotificationRuleTemplateSchema.optional(),
16829
- priority: _enum([
16830
- "low",
16831
- "normal",
16832
- "high",
16833
- "critical"
16834
- ])
16835
- });
16836
- var NotificationTestResultSchema = object({
16837
- ruleId: string(),
16838
- eventId: string(),
16839
- timestamp: number(),
16840
- wouldFire: boolean(),
16841
- reason: string().optional()
16842
- });
16843
- var NotificationHistoryEntrySchema = object({
16844
- id: string(),
16845
- ruleId: string(),
16846
- ruleName: string(),
16847
- eventId: string(),
16848
- timestamp: number(),
16849
- outputs: array(string()).readonly(),
16850
- success: boolean(),
16851
- error: string().optional(),
16852
- deviceId: number().optional()
16853
- });
16854
- var NotificationHistoryFilterSchema = object({
16855
- ruleId: string().optional(),
16856
- deviceId: number().optional(),
16857
- from: number().optional(),
16858
- to: number().optional(),
16859
- limit: number().optional()
16860
- });
16861
- 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({
16862
- ruleId: string(),
16863
- lookbackMinutes: number()
16864
- }), object({ results: array(NotificationTestResultSchema).readonly() }), { kind: "mutation" }), method(object({ filter: NotificationHistoryFilterSchema.optional() }), object({ entries: array(NotificationHistoryEntrySchema).readonly() }));
16865
17446
  /**
16866
17447
  * Alerts capability — collection-based internal alert system.
16867
17448
  *
@@ -17048,88 +17629,54 @@ method(object({
17048
17629
  password: string()
17049
17630
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
17050
17631
  /**
17051
- * `login-method` collection cap through which auth addons contribute
17052
- * their pre-auth login surfaces to the login page. This is the SINGLE,
17053
- * generic mechanism that supersedes the dead `auth.listProviders` reader:
17054
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
17055
- * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17056
- * procedure aggregates them for the unauthenticated login page.
17057
- *
17058
- * A contribution is a discriminated union on `kind`:
17059
- *
17060
- * - `redirect` — a declarative button. The login page renders a generic
17061
- * button that navigates to `startUrl` (an addon-owned HTTP route).
17062
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17063
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
17064
- * login page needs NO change.
17065
- *
17066
- * - `widget` — a Module-Federation widget the login page mounts (via
17067
- * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
17068
- * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
17069
- * mechanism kept for future use; no shipped addon uses it on the login
17070
- * page (the passkey ceremony below runs natively in the shell instead).
17071
- *
17072
- * - `passkey` — a declarative WebAuthn ceremony the shell renders
17073
- * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
17074
- * a remotely-loaded bundle). Carries the addon's effective `rpId` /
17075
- * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
17076
- * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
17077
- * fetching any remote code pre-auth. Contribution stays unconditional —
17078
- * enrollment state is never leaked pre-auth; visibility is a shell
17079
- * decision.
17080
- *
17081
- * Every contribution carries a `stage`:
17082
- * - `primary` — shown on the first credentials screen (OIDC /
17083
- * magic-link buttons; a future usernameless passkey).
17084
- * - `second-factor` — shown AFTER the password leg, gated on the
17085
- * returned `factors` (passkey-as-2FA today).
17086
- *
17087
- * `mount: skip` — the cap is read server-side by the core auth router
17088
- * (`registry.getCollection('login-method')`), never mounted as its own
17089
- * tRPC router.
17632
+ * A live terminal session hosted by the provider addon. Output and input do
17633
+ * NOT flow through the capability they use the addon data plane
17634
+ * (`GET /addon/terminal/<id>/out` SSE, `POST /addon/terminal/<id>/in`) because
17635
+ * terminal output must be ordered and lossless. The event bus is telemetry and
17636
+ * may drop chunks ([D8]), and a dropped chunk desynchronises the vt parser
17637
+ * permanently until a full repaint. The capability owns only lifecycle.
17090
17638
  */
17091
- /** When a login method renders in the two-phase login flow. */
17092
- var LoginStageEnum = _enum(["primary", "second-factor"]);
17093
- /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
17094
- var LoginMethodContributionSchema = discriminatedUnion("kind", [
17095
- object({
17096
- kind: literal("redirect"),
17097
- /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
17098
- id: string(),
17099
- /** Operator-facing button label. */
17100
- label: string(),
17101
- /** lucide-react icon name. */
17102
- icon: string().optional(),
17103
- /** Addon-owned HTTP route the button navigates to (GET). */
17104
- startUrl: string(),
17105
- stage: LoginStageEnum
17106
- }),
17107
- object({
17108
- kind: literal("widget"),
17109
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
17110
- id: string(),
17111
- /** Owning addon id — drives the public bundle URL + the MF namespace. */
17112
- addonId: string(),
17113
- /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
17114
- bundle: string(),
17115
- /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
17116
- remote: WidgetRemoteSchema,
17117
- stage: LoginStageEnum
17118
- }),
17119
- object({
17120
- kind: literal("passkey"),
17121
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
17122
- id: string(),
17123
- /** Operator-facing button label. */
17124
- label: string(),
17125
- stage: LoginStageEnum,
17126
- /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
17127
- rpId: string(),
17128
- /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
17129
- origin: string().nullable()
17130
- })
17131
- ]);
17132
- method(_void(), array(LoginMethodContributionSchema).readonly());
17639
+ var TerminalSessionInfoSchema = object({
17640
+ /** Opaque session id minted by the provider on `openSession`. */
17641
+ sessionId: string(),
17642
+ /** The pre-declared profile this session runs (never a free-form command). */
17643
+ profileId: string(),
17644
+ /** Human-readable profile label for the UI session list. */
17645
+ label: string(),
17646
+ cols: number().int().positive(),
17647
+ rows: number().int().positive(),
17648
+ /** ms-epoch the session's pty was spawned. */
17649
+ startedAt: number()
17650
+ });
17651
+ /**
17652
+ * A profile the operator may open — a pre-declared, allowlisted program
17653
+ * (`monitor` → `btm`). The capability accepts only these ids; a free-form
17654
+ * command string would be remote code execution as the server's user, so it is
17655
+ * deliberately not part of the contract.
17656
+ */
17657
+ var TerminalProfileInfoSchema = object({
17658
+ profileId: string(),
17659
+ label: string(),
17660
+ description: string().optional()
17661
+ });
17662
+ method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(TerminalSessionInfoSchema).readonly(), { auth: "admin" }), method(object({
17663
+ profileId: string(),
17664
+ cols: number().int().positive(),
17665
+ rows: number().int().positive()
17666
+ }), TerminalSessionInfoSchema, {
17667
+ kind: "mutation",
17668
+ auth: "admin"
17669
+ }), method(object({
17670
+ sessionId: string(),
17671
+ cols: number().int().positive(),
17672
+ rows: number().int().positive()
17673
+ }), _void(), {
17674
+ kind: "mutation",
17675
+ auth: "admin"
17676
+ }), method(object({ sessionId: string() }), _void(), {
17677
+ kind: "mutation",
17678
+ auth: "admin"
17679
+ });
17133
17680
  /**
17134
17681
  * Orchestrator-side destination metadata. The orchestrator computes
17135
17682
  * `id = <addonId>:<subId>` from its provider lookup so consumers
@@ -17231,11 +17778,53 @@ var LocationStatSchema = object({
17231
17778
  fileCount: number(),
17232
17779
  present: boolean()
17233
17780
  });
17781
+ /**
17782
+ * A backup schedule — the N:M "entry" that binds one cron cadence to a
17783
+ * SET of destination locations. Supersedes the per-location cron on
17784
+ * `BackupDestinationPolicy`: an operator creates a schedule, picks the
17785
+ * `backups` locations it should write to, and the orchestrator fans a
17786
+ * single archive out to all of them when the cron fires.
17787
+ *
17788
+ * `retentionCount` is per-schedule (D-decision 2026-07-28): every
17789
+ * location targeted by this schedule keeps this many archives from
17790
+ * this schedule's runs.
17791
+ *
17792
+ * `dataSources` optionally narrows which top-level state locations
17793
+ * (db, addons, tls, …) are archived; omitted = the orchestrator's
17794
+ * default full set.
17795
+ */
17796
+ var BackupScheduleSchema = object({
17797
+ /** Stable id. Generated by the orchestrator on first upsert if absent. */
17798
+ id: string(),
17799
+ /** Operator-facing display name. */
17800
+ label: string(),
17801
+ /** 5-field POSIX cron. Empty = disabled cadence (kept for editing). */
17802
+ cron: string(),
17803
+ /** Master on/off toggle for the whole schedule. */
17804
+ enabled: boolean(),
17805
+ /** `backups`-location ids this schedule writes to (fan-out set). */
17806
+ locationIds: array(string()).readonly(),
17807
+ /** Archives kept per targeted location for this schedule. */
17808
+ retentionCount: number().int().min(1).max(1e3),
17809
+ /** Optional subset of source locations to include; omitted = all. */
17810
+ dataSources: array(string()).readonly().optional(),
17811
+ /** ms-epoch of last successful run. */
17812
+ lastRunAt: number().optional(),
17813
+ /** ms-epoch of next computed firing (read-only, filled on list). */
17814
+ nextRunAt: number().optional()
17815
+ });
17234
17816
  method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }), method(object({
17235
17817
  /** Subset of registered `backup-destination` addon ids to write to. */
17236
17818
  destinations: array(string()).optional(),
17237
17819
  locations: array(string()).optional(),
17238
- label: string().optional()
17820
+ label: string().optional(),
17821
+ /**
17822
+ * Per-run retention override applied to every targeted
17823
+ * destination. Used by schedule-driven runs (per-entry
17824
+ * retention). Omitted = each destination's own policy
17825
+ * retention (manual runs).
17826
+ */
17827
+ retentionCount: number().int().min(1).max(1e3).optional()
17239
17828
  }).optional(), array(BackupEntrySchema).readonly(), {
17240
17829
  kind: "mutation",
17241
17830
  auth: "admin"
@@ -17284,7 +17873,21 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
17284
17873
  ok: boolean(),
17285
17874
  error: string().optional(),
17286
17875
  nextRuns: array(number()).readonly()
17287
- }));
17876
+ })), method(_void(), array(BackupScheduleSchema).readonly(), { auth: "admin" }), method(object({
17877
+ id: string().optional(),
17878
+ label: string(),
17879
+ cron: string(),
17880
+ enabled: boolean(),
17881
+ locationIds: array(string()).readonly(),
17882
+ retentionCount: number().int().min(1).max(1e3),
17883
+ dataSources: array(string()).readonly().optional()
17884
+ }), BackupScheduleSchema, {
17885
+ kind: "mutation",
17886
+ auth: "admin"
17887
+ }), method(object({ id: string() }), _void(), {
17888
+ kind: "mutation",
17889
+ auth: "admin"
17890
+ });
17288
17891
  /**
17289
17892
  * `broker` — unified pub/sub broker registry, system-scoped collection.
17290
17893
  *
@@ -18486,851 +19089,934 @@ method(_void(), array(string()).readonly(), { auth: "admin" }), method(object({
18486
19089
  kind: "mutation",
18487
19090
  auth: "admin"
18488
19091
  });
18489
- var LogLevelSchema = _enum([
18490
- "debug",
18491
- "info",
18492
- "warn",
18493
- "error"
18494
- ]);
18495
- var LogEntrySchema = object({
18496
- timestamp: date(),
18497
- level: LogLevelSchema,
18498
- scope: array(string()),
18499
- message: string(),
18500
- meta: record(string(), unknown()).optional(),
18501
- tags: record(string(), string()).optional()
19092
+ /**
19093
+ * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
19094
+ * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
19095
+ * caps stay wire-compatible without a circular cap→cap import.
19096
+ *
19097
+ * Errors are a discriminated-union RESULT, never thrown: the shape survives
19098
+ * every transport tier structurally, and failed calls still write usage rows.
19099
+ * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
19100
+ */
19101
+ var LlmUsageSchema = object({
19102
+ inputTokens: number(),
19103
+ outputTokens: number()
18502
19104
  });
18503
- method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18504
- scope: array(string()).optional(),
18505
- level: LogLevelSchema.optional(),
18506
- since: date().optional(),
18507
- until: date().optional(),
18508
- limit: number().optional(),
18509
- tags: record(string(), string()).optional()
18510
- }), array(LogEntrySchema).readonly());
18511
- var CpuBreakdownSchema = object({
18512
- total: number(),
18513
- user: number(),
18514
- system: number(),
18515
- irq: number(),
18516
- nice: number(),
18517
- loadAvg: tuple([
18518
- number(),
18519
- number(),
18520
- number()
18521
- ]),
18522
- cores: number()
18523
- });
18524
- var MemoryInfoSchema = object({
18525
- percent: number(),
18526
- totalBytes: number(),
18527
- usedBytes: number(),
18528
- availableBytes: number(),
18529
- swapUsedBytes: number(),
18530
- swapTotalBytes: number()
18531
- });
18532
- var DiskIoSnapshotSchema = object({
18533
- readBytes: number(),
18534
- writeBytes: number(),
18535
- readOps: number(),
18536
- writeOps: number(),
18537
- timestampMs: number()
18538
- });
18539
- var NetworkIoSnapshotSchema = object({
18540
- rxBytes: number(),
18541
- txBytes: number(),
18542
- rxPackets: number(),
18543
- txPackets: number(),
18544
- rxErrors: number(),
18545
- txErrors: number(),
18546
- timestampMs: number()
18547
- });
18548
- var MetricsGpuInfoSchema = object({
18549
- utilization: number(),
19105
+ var LlmErrorCodeSchema = _enum([
19106
+ "timeout",
19107
+ "rate-limited",
19108
+ "auth",
19109
+ "refusal",
19110
+ "bad-request",
19111
+ "unavailable",
19112
+ "no-profile",
19113
+ "budget-exceeded",
19114
+ "adapter-error"
19115
+ ]);
19116
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
19117
+ ok: literal(true),
19118
+ text: string(),
18550
19119
  model: string(),
18551
- memoryUsedBytes: number(),
18552
- memoryTotalBytes: number(),
18553
- temperature: number().nullable()
18554
- });
18555
- var ProcessResourceInfoSchema = object({
18556
- openFds: number(),
18557
- threadCount: number(),
18558
- activeHandles: number(),
18559
- activeRequests: number()
18560
- });
18561
- var PressureAvgsSchema = object({
18562
- avg10: number(),
18563
- avg60: number(),
18564
- avg300: number()
19120
+ usage: LlmUsageSchema,
19121
+ truncated: boolean(),
19122
+ latencyMs: number()
19123
+ }), object({
19124
+ ok: literal(false),
19125
+ code: LlmErrorCodeSchema,
19126
+ message: string(),
19127
+ retryAfterMs: number().optional()
19128
+ })]);
19129
+ /**
19130
+ * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
19131
+ * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
19132
+ * notification-output.cap.ts:27-31 precedents).
19133
+ */
19134
+ var LlmImageSchema = object({
19135
+ bytes: _instanceof(Uint8Array),
19136
+ mimeType: string()
18565
19137
  });
18566
- var PressureInfoSchema = object({
18567
- some: PressureAvgsSchema,
18568
- full: PressureAvgsSchema.nullable()
19138
+ var LlmGenerateBaseInputSchema = object({
19139
+ /** Collection routing (the notification-output posture). */
19140
+ addonId: string().optional(),
19141
+ /** Explicit profile; else the resolution chain (spec §3). */
19142
+ profileId: string().optional(),
19143
+ /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
19144
+ consumer: string(),
19145
+ system: string().optional(),
19146
+ /** v1: single-turn. `messages[]` is a v2 additive field. */
19147
+ prompt: string(),
19148
+ /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
19149
+ jsonSchema: record(string(), unknown()).optional(),
19150
+ /** Per-call override of the profile default. */
19151
+ maxTokens: number().int().positive().optional(),
19152
+ temperature: number().optional()
18569
19153
  });
18570
- var SystemResourceSnapshotSchema = object({
18571
- cpu: CpuBreakdownSchema,
18572
- memory: MemoryInfoSchema,
18573
- gpu: MetricsGpuInfoSchema.nullable(),
18574
- network: NetworkIoSnapshotSchema,
18575
- disk: DiskIoSnapshotSchema,
18576
- pressure: object({
18577
- cpu: PressureInfoSchema.nullable(),
18578
- memory: PressureInfoSchema.nullable(),
18579
- io: PressureInfoSchema.nullable()
19154
+ /**
19155
+ * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
19156
+ * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
19157
+ * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
19158
+ * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
19159
+ * this only through the `llm` cap's methods.
19160
+ *
19161
+ * One running llama-server child per node in v1 (models are RAM-heavy).
19162
+ * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
19163
+ * watchdog — operator decision #3).
19164
+ */
19165
+ var ManagedModelRefSchema = discriminatedUnion("kind", [
19166
+ object({
19167
+ kind: literal("catalog"),
19168
+ catalogId: string()
18580
19169
  }),
18581
- process: ProcessResourceInfoSchema,
18582
- cpuTemperature: number().nullable(),
18583
- timestampMs: number()
18584
- });
18585
- var DiskSpaceInfoSchema = object({
18586
- path: string(),
18587
- totalBytes: number(),
18588
- usedBytes: number(),
18589
- availableBytes: number(),
18590
- percent: number()
18591
- });
18592
- var PidResourceStatsSchema = object({
18593
- pid: number(),
18594
- cpu: number(),
18595
- memory: number(),
18596
- /**
18597
- * Private (anonymous) resident bytes — the per-process V8 heap + native
18598
- * allocations NOT shared with other processes (Linux RssAnon). This is the
18599
- * "real" per-runner cost; summing it across runners is meaningful, unlike
18600
- * `memory` (RSS), which double-counts the shared mmap'd framework code.
18601
- * Undefined where /proc is unavailable (e.g. macOS).
18602
- */
18603
- privateBytes: number().optional(),
18604
- /**
18605
- * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
18606
- * code shared copy-on-write across runners. Undefined on macOS.
18607
- */
18608
- sharedBytes: number().optional()
19170
+ object({
19171
+ kind: literal("url"),
19172
+ url: string(),
19173
+ sha256: string().optional()
19174
+ }),
19175
+ object({
19176
+ kind: literal("path"),
19177
+ path: string()
19178
+ })
19179
+ ]);
19180
+ var ManagedRuntimeConfigSchema = object({
19181
+ /** WHERE the runtime lives — hub or any agent. */
19182
+ nodeId: string(),
19183
+ /** Closed for v1; 'ollama' is a v2 candidate. */
19184
+ engine: _enum(["llama-cpp"]),
19185
+ model: ManagedModelRefSchema,
19186
+ contextSize: number().int().default(4096),
19187
+ /** 0 = CPU-only. */
19188
+ gpuLayers: number().int().default(0),
19189
+ /** Default: cpus-2, clamped ≥1 (resolved node-side). */
19190
+ threads: number().int().optional(),
19191
+ /** Concurrent slots. */
19192
+ parallel: number().int().default(1),
19193
+ /** Else lazy: first generate boots it. */
19194
+ autoStart: boolean().default(false),
19195
+ /** 0 = never; frees RAM after quiet periods. */
19196
+ idleStopMinutes: number().int().default(30)
18609
19197
  });
18610
- var AddonInstanceSchema = object({
18611
- addonId: string(),
19198
+ var LlmRuntimeStatusSchema = object({
19199
+ /** Status is ALWAYS node-qualified. */
18612
19200
  nodeId: string(),
18613
- role: _enum(["hub", "worker"]),
18614
- pid: number(),
18615
19201
  state: _enum([
18616
- "starting",
18617
- "running",
18618
- "stopping",
18619
19202
  "stopped",
18620
- "crashed"
18621
- ]),
18622
- uptimeSec: number()
18623
- });
18624
- var NodeProcessSchema = object({
18625
- pid: number(),
18626
- ppid: number(),
18627
- pgid: number(),
18628
- classification: _enum([
18629
- "root",
18630
- "managed",
18631
- "system",
18632
- "ghost"
19203
+ "downloading",
19204
+ "starting",
19205
+ "ready",
19206
+ "crashed",
19207
+ "failed"
18633
19208
  ]),
18634
- /** `$process` addon binding when `managed`, else null. */
18635
- addonId: string().nullable(),
18636
- /** Kernel-reported nodeId when the process is a known agent/worker. */
18637
- nodeId: string().nullable(),
18638
- /** Truncated command line. */
18639
- command: string(),
18640
- cpuPercent: number(),
18641
- memoryRssBytes: number(),
18642
- /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
18643
- uptimeSec: number(),
18644
- /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
18645
- orphaned: boolean()
18646
- });
18647
- var KillProcessInputSchema = object({
18648
- pid: number(),
18649
- /** Force = SIGKILL. Default is SIGTERM. */
18650
- force: boolean().optional()
19209
+ pid: number().optional(),
19210
+ port: number().optional(),
19211
+ modelPath: string().optional(),
19212
+ modelId: string().optional(),
19213
+ downloadProgress: number().min(0).max(1).optional(),
19214
+ lastError: string().optional(),
19215
+ crashesInWindow: number(),
19216
+ /** Child RSS (sampled best-effort). */
19217
+ memoryBytes: number().optional(),
19218
+ vramBytes: number().optional()
18651
19219
  });
18652
- var KillProcessResultSchema = object({
18653
- success: boolean(),
18654
- reason: string().optional(),
18655
- signal: _enum(["SIGTERM", "SIGKILL"]).optional()
19220
+ var LlmNodeModelSchema = object({
19221
+ file: string(),
19222
+ sizeBytes: number(),
19223
+ catalogId: string().optional(),
19224
+ installedAt: number().optional()
18656
19225
  });
18657
- var DumpHeapSnapshotInputSchema = object({
18658
- /** The addon whose runner should dump a heap snapshot. */
18659
- addonId: string() });
18660
- var DumpHeapSnapshotResultSchema = object({
18661
- success: boolean(),
18662
- /** Path of the written .heapsnapshot inside the runner's container/host. */
18663
- path: string().optional(),
18664
- /** Process pid that was signalled. */
18665
- pid: number().optional(),
18666
- reason: string().optional()
19226
+ var LlmRuntimeDiskUsageSchema = object({
19227
+ nodeId: string(),
19228
+ modelsBytes: number(),
19229
+ freeBytes: number().optional()
18667
19230
  });
18668
- var SystemMetricsSchema = object({
18669
- cpuPercent: number(),
18670
- memoryPercent: number(),
18671
- memoryUsedMB: number(),
18672
- memoryTotalMB: number(),
18673
- diskPercent: number().optional(),
18674
- temperature: number().optional(),
18675
- gpuPercent: number().optional(),
18676
- gpuMemoryPercent: number().optional()
18677
- });
18678
- 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, {
19231
+ method(LlmGenerateBaseInputSchema.extend({
19232
+ images: array(LlmImageSchema).optional(),
19233
+ runtime: ManagedRuntimeConfigSchema,
19234
+ /** The managed profile's timeout, threaded by the hub provider. */
19235
+ timeoutMs: number().int().positive().optional()
19236
+ }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
18679
19237
  kind: "mutation",
18680
19238
  auth: "admin"
18681
- }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
19239
+ }), method(object({}), _void(), {
18682
19240
  kind: "mutation",
18683
19241
  auth: "admin"
18684
- });
18685
- method(object({
18686
- sourceUrl: string(),
18687
- metadata: ModelConvertMetadataSchema,
18688
- targets: array(ConvertTargetSchema).min(1).readonly(),
18689
- calibrationRef: string().optional(),
18690
- sessionId: string().optional()
18691
- }), ConvertResultSchema, {
19242
+ }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
18692
19243
  kind: "mutation",
18693
- auth: "admin",
18694
- timeoutMs: 6e5
18695
- });
18696
- method(object({
18697
- nodeId: string(),
18698
- modelId: string(),
18699
- format: _enum(MODEL_FORMATS),
18700
- entry: ModelCatalogEntrySchema
18701
- }), object({
18702
- ok: boolean(),
18703
- /** sha256 of the staged tarball (empty for a hub-local no-op). */
18704
- sha256: string(),
18705
- bytes: number(),
18706
- /** The target node's modelsDir the artifact landed in. */
18707
- path: string()
18708
- }), {
19244
+ auth: "admin"
19245
+ }), method(object({ file: string() }), _void(), {
18709
19246
  kind: "mutation",
18710
19247
  auth: "admin"
18711
- });
18712
- /**
18713
- * `mqtt-broker` — broker-registry cap.
18714
- *
18715
- * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
18716
- * MQTT brokers (external + optionally an embedded `aedes`-backed one)
18717
- * and (b) the connection details a consumer addon needs to spin up
18718
- * its OWN `mqtt.js` client.
18719
- *
18720
- * Why: pub/sub routing over the system event-bus loses fidelity
18721
- * (callback shape, QoS guarantees, will/retain semantics) and adds
18722
- * refcount bookkeeping that addons would rather own themselves. The
18723
- * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
18724
- * features anyway — give it the connection config, get out of the way.
18725
- *
18726
- * Consumer flow:
18727
- * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
18728
- * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
18729
- * client.subscribe('zigbee2mqtt/+')
18730
- *
18731
- * Collection mode: multiple brokers (e.g. one local mosquitto + one
18732
- * cloud bridge). The "embedded" entry (when present) is just another
18733
- * broker in the registry — its lifecycle is owned by the addon that
18734
- * spawned it.
18735
- */
18736
- var BrokerKindSchema = _enum(["external", "embedded"]);
19248
+ }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
18737
19249
  /**
18738
- * Broker live-probe status.
19250
+ * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
19251
+ * methods concat-fan across providers; single-row methods route to ONE
19252
+ * provider by the `addonId` in the call input (the notification-output
19253
+ * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
19254
+ * (hub-placed); the cap stays open for future providers.
18739
19255
  *
18740
- * - `connected` last probe completed a clean CONNACK
18741
- * - `disconnected` — no probe has run yet (cold cache)
18742
- * - `auth-failed` CONNACK refused with auth error (RC 4 / 5)
18743
- * - `unreachable` — TCP connect timed out / refused
18744
- * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
19256
+ * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
19257
+ * `apiKey` is a password field providers REDACT it on read and merge on
19258
+ * write; a stored key NEVER round-trips to a client.
18745
19259
  */
18746
- var BrokerStatusSchema$1 = _enum([
18747
- "connected",
18748
- "disconnected",
18749
- "auth-failed",
18750
- "unreachable",
18751
- "tls-error"
19260
+ var LlmProfileKindSchema = _enum([
19261
+ "openai-compatible",
19262
+ "openai",
19263
+ "anthropic",
19264
+ "google",
19265
+ "managed-local"
18752
19266
  ]);
18753
- var BrokerInfoSchema = object({
19267
+ var LlmProfileSchema = object({
18754
19268
  id: string(),
18755
19269
  name: string(),
18756
- url: string(),
18757
- kind: BrokerKindSchema,
18758
- status: BrokerStatusSchema$1,
18759
- latencyMs: number().nullable(),
18760
- error: string().optional(),
18761
- /** Embedded brokers only: number of MQTT clients currently connected. */
18762
- connectedClients: number().int().nonnegative().optional(),
18763
- /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
18764
- lastCheckedAt: number().optional()
19270
+ kind: LlmProfileKindSchema,
19271
+ /** Stamped by the provider — keeps the fanned catalog routable. */
19272
+ addonId: string(),
19273
+ enabled: boolean(),
19274
+ /** Vendor model id, or the managed runtime's loaded model. */
19275
+ model: string(),
19276
+ /** Required for openai-compatible; override for cloud kinds. */
19277
+ baseUrl: string().optional(),
19278
+ /** ConfigUISchema type:'password' — never round-trips (spec §5). */
19279
+ apiKey: string().optional(),
19280
+ supportsVision: boolean(),
19281
+ temperature: number().min(0).max(2).optional(),
19282
+ maxTokens: number().int().positive().optional(),
19283
+ timeoutMs: number().int().positive().default(6e4),
19284
+ extraHeaders: record(string(), string()).optional(),
19285
+ /** kind === 'managed-local' only (spec §4). */
19286
+ runtime: ManagedRuntimeConfigSchema.optional()
18765
19287
  });
18766
- /**
18767
- * Connection details — what a consumer needs to call
18768
- * `mqtt.connect(url, options)`. We split URL + credentials so the
18769
- * consumer can pass them as `mqtt.connect(url, { username, password })`
18770
- * instead of stuffing creds into the URL (which leaks them into logs).
18771
- */
18772
- var BrokerConnectionDetailsSchema = object({
18773
- url: string(),
18774
- username: string().optional(),
18775
- password: string().optional(),
18776
- /**
18777
- * Suggested prefix for `clientId`. Each consumer should suffix this
18778
- * with its own discriminator (addon id, instance id) so reconnects
18779
- * don't kick each other off (MQTT spec: clientId must be unique per
18780
- * broker).
18781
- */
18782
- clientIdPrefix: string().optional()
19288
+ /** ConfigUISchema tree passed through untyped on the wire (the
19289
+ * notification-output `ConfigSchemaPassthrough` precedent at
19290
+ * notification-output.cap.ts:151); the exported TS type re-tightens it. */
19291
+ var ConfigSchemaPassthrough$1 = unknown();
19292
+ var LlmProfileKindDescriptorSchema = object({
19293
+ kind: LlmProfileKindSchema,
19294
+ label: string(),
19295
+ icon: string(),
19296
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
19297
+ addonId: string(),
19298
+ configSchema: ConfigSchemaPassthrough$1
18783
19299
  });
18784
- var AddBrokerInputSchema = object({
18785
- name: string().min(1),
18786
- url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
18787
- username: string().optional(),
18788
- password: string().optional(),
18789
- clientIdPrefix: string().optional()
19300
+ var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
19301
+ var LlmDefaultSchema = object({
19302
+ selector: LlmDefaultSelectorSchema,
19303
+ profileId: string()
18790
19304
  });
18791
- var AddBrokerResultSchema = object({ id: string() });
18792
- var IdInputSchema = object({ id: string() });
18793
- var TestResultSchema$1 = discriminatedUnion("ok", [object({
18794
- ok: literal(true),
18795
- latencyMs: number()
18796
- }), object({
18797
- ok: literal(false),
18798
- error: string()
18799
- })]);
18800
- var StartEmbeddedInputSchema = object({
18801
- port: number().int().min(1).max(65535).default(1883),
18802
- /** Allow anonymous connect (no username/password). Default: false. */
18803
- allowAnonymous: boolean().default(false),
18804
- /** Optional shared username/password for clients. */
18805
- username: string().optional(),
18806
- password: string().optional()
19305
+ /** Server-side rollup row getUsage never dumps raw call rows (spec §6). */
19306
+ var LlmUsageRollupSchema = object({
19307
+ day: string(),
19308
+ consumer: string(),
19309
+ profileId: string(),
19310
+ calls: number(),
19311
+ okCalls: number(),
19312
+ errorCalls: number(),
19313
+ inputTokens: number(),
19314
+ outputTokens: number(),
19315
+ avgLatencyMs: number()
18807
19316
  });
18808
- var StartEmbeddedResultSchema = object({
19317
+ /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
19318
+ var ManagedModelCatalogEntrySchema = object({
18809
19319
  id: string(),
18810
- url: string()
18811
- });
18812
- var StatusSchema = object({
18813
- brokerCount: number(),
18814
- embeddedRunning: boolean()
18815
- });
18816
- method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema), method(AddBrokerInputSchema, AddBrokerResultSchema, { kind: "mutation" }), method(IdInputSchema, _void(), { kind: "mutation" }), method(IdInputSchema, TestResultSchema$1, { kind: "mutation" }), method(StartEmbeddedInputSchema, StartEmbeddedResultSchema, { kind: "mutation" }), method(IdInputSchema, _void(), { kind: "mutation" }), method(_void(), StatusSchema);
18817
- var NetworkEndpointSchema = object({
19320
+ label: string(),
19321
+ family: string(),
19322
+ purpose: _enum(["text", "vision"]),
18818
19323
  url: string(),
18819
- hostname: string(),
18820
- port: number(),
18821
- protocol: _enum(["http", "https"])
19324
+ sha256: string(),
19325
+ sizeBytes: number(),
19326
+ quantization: string(),
19327
+ /** Load-time guidance shown in the picker. */
19328
+ minRamBytes: number(),
19329
+ contextSizeDefault: number().int(),
19330
+ /** Vision models: companion projector file. */
19331
+ mmprojUrl: string().optional()
18822
19332
  });
18823
- var NetworkAccessStatusSchema = object({
18824
- connected: boolean(),
18825
- endpoint: NetworkEndpointSchema.nullable(),
19333
+ var LlmRuntimeNodeSchema = object({
19334
+ nodeId: string(),
19335
+ reachable: boolean(),
19336
+ status: LlmRuntimeStatusSchema.optional(),
19337
+ disk: LlmRuntimeDiskUsageSchema.optional(),
18826
19338
  error: string().optional()
18827
19339
  });
18828
- /**
18829
- * Optional, richer endpoint shape returned by providers that expose
18830
- * MORE than one ingress concurrently (Tailscale Ingress with mixed
18831
- * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
18832
- * the originating provider config (mode + sourcePort) so the
18833
- * orchestrator UI can label rows distinctly. Providers that expose only
18834
- * one endpoint just omit `listEndpoints` from their provider impl.
18835
- */
18836
- var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
18837
- /**
18838
- * Stable id within the provider — typically `<mode>-<sourcePort>` so
18839
- * the orchestrator can dedupe across `listEndpoints` polls.
18840
- */
18841
- id: string(),
18842
- /** Operator-facing label (mirrors `MeshEndpoint.label`). */
18843
- label: string(),
18844
- /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
18845
- mode: string().optional(),
18846
- /** Originating local port the ingress fronts (informational). */
18847
- sourcePort: number().optional()
19340
+ var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
19341
+ var ProfileRefInputSchema = object({
19342
+ addonId: string(),
19343
+ profileId: string()
18848
19344
  });
18849
- method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
18850
- /**
18851
- * notification-output — canonical, capability-gated notification delivery.
18852
- *
18853
- * Apprise-derived model (see
18854
- * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
18855
- * callers emit ONE canonical `Notification`; each provider declares a
18856
- * per-kind capability descriptor (`TargetKind`), and the pure degrade
18857
- * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
18858
- * message to what the kind supports — callers never special-case a service.
18859
- *
18860
- * DESIGN DECISIONS (locked):
18861
- * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
18862
- * `setTargetEnabled`), each provider persisting via the `settings-store`
18863
- * cap. Rationale: the admin UI needs one uniform surface across the
18864
- * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
18865
- * alternative would fork the UI per addon and cannot host the
18866
- * discovery→adopt flow.
18867
- * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
18868
- * the generated cap-mount auto-`concatCollection`-fans them across every
18869
- * registered provider (notifiers addon + HA addon) so one catalog is
18870
- * routable. `send` / `testTarget` / CRUD route to ONE provider by the
18871
- * `addonId` the generated collection router extracts from the call input.
18872
- * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
18873
- * transformer) + UDS MsgPack both round-trip typed arrays — already used by
18874
- * `storage` / `storage-provider` / `recording` caps over the same path. No
18875
- * base64 fallback needed.
18876
- *
18877
- * TODO (deferred, closed-set change — separate decision): add
18878
- * `providerKind: 'notify'` so notification providers surface on the unified
18879
- * admin "Integrations" page.
18880
- */
18881
- /**
18882
- * Zentik-derived typed-media enum — the superset across every kind. Each
18883
- * adapter picks what it supports and the degrade engine filters the rest.
18884
- */
18885
- var AttachmentMediaTypeSchema = _enum([
18886
- "image",
18887
- "video",
18888
- "gif",
18889
- "audio",
18890
- "icon"
19345
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
19346
+ kind: "mutation",
19347
+ auth: "admin"
19348
+ }), method(ProfileRefInputSchema, _void(), {
19349
+ kind: "mutation",
19350
+ auth: "admin"
19351
+ }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
19352
+ kind: "mutation",
19353
+ auth: "admin"
19354
+ }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
19355
+ selector: LlmDefaultSelectorSchema,
19356
+ profileId: string().nullable()
19357
+ }), _void(), {
19358
+ kind: "mutation",
19359
+ auth: "admin"
19360
+ }), method(object({
19361
+ since: number().optional(),
19362
+ until: number().optional(),
19363
+ consumer: string().optional(),
19364
+ profileId: string().optional()
19365
+ }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
19366
+ nodeId: string(),
19367
+ model: ManagedModelRefSchema
19368
+ }), _void(), {
19369
+ kind: "mutation",
19370
+ auth: "admin"
19371
+ }), method(object({
19372
+ nodeId: string(),
19373
+ file: string()
19374
+ }), _void(), {
19375
+ kind: "mutation",
19376
+ auth: "admin"
19377
+ }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
19378
+ kind: "mutation",
19379
+ auth: "admin"
19380
+ }), method(ProfileRefInputSchema, _void(), {
19381
+ kind: "mutation",
19382
+ auth: "admin"
19383
+ });
19384
+ var LogLevelSchema = _enum([
19385
+ "debug",
19386
+ "info",
19387
+ "warn",
19388
+ "error"
18891
19389
  ]);
19390
+ var LogEntrySchema = object({
19391
+ timestamp: date(),
19392
+ level: LogLevelSchema,
19393
+ scope: array(string()),
19394
+ message: string(),
19395
+ meta: record(string(), unknown()).optional(),
19396
+ tags: record(string(), string()).optional()
19397
+ });
19398
+ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
19399
+ scope: array(string()).optional(),
19400
+ level: LogLevelSchema.optional(),
19401
+ since: date().optional(),
19402
+ until: date().optional(),
19403
+ limit: number().optional(),
19404
+ tags: record(string(), string()).optional()
19405
+ }), array(LogEntrySchema).readonly());
18892
19406
  /**
18893
- * A single attachment. Exactly one of `url` (remote source, most adapters
18894
- * prefer this) or `bytes` (inline source; required for Pushover-style
18895
- * bytes-only kinds) MUST be present — the degrade engine expresses a
18896
- * url→bytes fetch as a `needsFetch` directive the adapter executes.
19407
+ * `login-method` collection cap through which auth addons contribute
19408
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
19409
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
19410
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
19411
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
19412
+ * procedure aggregates them for the unauthenticated login page.
19413
+ *
19414
+ * A contribution is a discriminated union on `kind`:
19415
+ *
19416
+ * - `redirect` — a declarative button. The login page renders a generic
19417
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
19418
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
19419
+ * ZERO shell-side JS. A future SSO addon plugs in the same way — the
19420
+ * login page needs NO change.
19421
+ *
19422
+ * - `widget` — a Module-Federation widget the login page mounts (via
19423
+ * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
19424
+ * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
19425
+ * mechanism kept for future use; no shipped addon uses it on the login
19426
+ * page (the passkey ceremony below runs natively in the shell instead).
19427
+ *
19428
+ * - `passkey` — a declarative WebAuthn ceremony the shell renders
19429
+ * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
19430
+ * a remotely-loaded bundle). Carries the addon's effective `rpId` /
19431
+ * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
19432
+ * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
19433
+ * fetching any remote code pre-auth. Contribution stays unconditional —
19434
+ * enrollment state is never leaked pre-auth; visibility is a shell
19435
+ * decision.
19436
+ *
19437
+ * Every contribution carries a `stage`:
19438
+ * - `primary` — shown on the first credentials screen (OIDC /
19439
+ * magic-link buttons; a future usernameless passkey).
19440
+ * - `second-factor` — shown AFTER the password leg, gated on the
19441
+ * returned `factors` (passkey-as-2FA today).
19442
+ *
19443
+ * `mount: skip` — the cap is read server-side by the core auth router
19444
+ * (`registry.getCollection('login-method')`), never mounted as its own
19445
+ * tRPC router.
18897
19446
  */
18898
- var AttachmentSchema = object({
18899
- mediaType: AttachmentMediaTypeSchema,
18900
- url: string().optional(),
18901
- bytes: _instanceof(Uint8Array).optional(),
18902
- mime: string().optional(),
18903
- name: string().optional()
18904
- }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
18905
- var NotificationFormatSchema = _enum([
18906
- "text",
18907
- "markdown",
18908
- "html"
19447
+ /** When a login method renders in the two-phase login flow. */
19448
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
19449
+ /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
19450
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [
19451
+ object({
19452
+ kind: literal("redirect"),
19453
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
19454
+ id: string(),
19455
+ /** Operator-facing button label. */
19456
+ label: string(),
19457
+ /** lucide-react icon name. */
19458
+ icon: string().optional(),
19459
+ /** Addon-owned HTTP route the button navigates to (GET). */
19460
+ startUrl: string(),
19461
+ stage: LoginStageEnum
19462
+ }),
19463
+ object({
19464
+ kind: literal("widget"),
19465
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
19466
+ id: string(),
19467
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
19468
+ addonId: string(),
19469
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
19470
+ bundle: string(),
19471
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
19472
+ remote: WidgetRemoteSchema,
19473
+ stage: LoginStageEnum
19474
+ }),
19475
+ object({
19476
+ kind: literal("passkey"),
19477
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
19478
+ id: string(),
19479
+ /** Operator-facing button label. */
19480
+ label: string(),
19481
+ stage: LoginStageEnum,
19482
+ /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
19483
+ rpId: string(),
19484
+ /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
19485
+ origin: string().nullable()
19486
+ })
18909
19487
  ]);
18910
- /** A single tap-through action button. */
18911
- var NotificationActionSchema = object({
18912
- id: string(),
18913
- label: string(),
18914
- url: string().optional()
19488
+ method(_void(), array(LoginMethodContributionSchema).readonly());
19489
+ var CpuBreakdownSchema = object({
19490
+ total: number(),
19491
+ user: number(),
19492
+ system: number(),
19493
+ irq: number(),
19494
+ nice: number(),
19495
+ loadAvg: tuple([
19496
+ number(),
19497
+ number(),
19498
+ number()
19499
+ ]),
19500
+ cores: number()
18915
19501
  });
18916
- /**
18917
- * The canonical notification. `body` is the only hard field (Apprise model).
18918
- * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
18919
- * NOT a fixed severity enum — each kind declares its own `caps.levels` and
18920
- * the adapter maps this ordinal onto its native level. `level?` is an
18921
- * optional kind-native level id (`emergency`, `silent`, …) that overrides
18922
- * `priority` for that one target.
18923
- */
18924
- var NotificationSchema = object({
18925
- body: string(),
18926
- title: string().optional(),
18927
- format: NotificationFormatSchema.default("text"),
18928
- priority: number().int().min(1).max(5).default(3),
18929
- level: string().optional(),
18930
- attachments: array(AttachmentSchema).optional(),
18931
- clickUrl: string().optional(),
18932
- actions: array(NotificationActionSchema).optional(),
18933
- sound: string().optional(),
18934
- ttl: number().optional(),
18935
- tag: string().optional(),
18936
- deviceId: number().optional(),
18937
- eventId: string().optional(),
18938
- metadata: record(string(), unknown()).optional()
19502
+ var MemoryInfoSchema = object({
19503
+ percent: number(),
19504
+ totalBytes: number(),
19505
+ usedBytes: number(),
19506
+ availableBytes: number(),
19507
+ swapUsedBytes: number(),
19508
+ swapTotalBytes: number()
19509
+ });
19510
+ var DiskIoSnapshotSchema = object({
19511
+ readBytes: number(),
19512
+ writeBytes: number(),
19513
+ readOps: number(),
19514
+ writeOps: number(),
19515
+ timestampMs: number()
19516
+ });
19517
+ var NetworkIoSnapshotSchema = object({
19518
+ rxBytes: number(),
19519
+ txBytes: number(),
19520
+ rxPackets: number(),
19521
+ txPackets: number(),
19522
+ rxErrors: number(),
19523
+ txErrors: number(),
19524
+ timestampMs: number()
19525
+ });
19526
+ var MetricsGpuInfoSchema = object({
19527
+ utilization: number(),
19528
+ model: string(),
19529
+ memoryUsedBytes: number(),
19530
+ memoryTotalBytes: number(),
19531
+ temperature: number().nullable()
19532
+ });
19533
+ var ProcessResourceInfoSchema = object({
19534
+ openFds: number(),
19535
+ threadCount: number(),
19536
+ activeHandles: number(),
19537
+ activeRequests: number()
18939
19538
  });
18940
- /** One declared native severity/priority level for a kind. */
18941
- var TargetKindLevelSchema = object({
18942
- id: string(),
18943
- label: string(),
18944
- /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
18945
- ordinal: number().int().min(1).max(5).nullable(),
18946
- flags: object({
18947
- critical: boolean().optional(),
18948
- silent: boolean().optional(),
18949
- noPush: boolean().optional()
18950
- }).optional(),
18951
- /** e.g. Pushover `emergency` requires `retry` / `expire`. */
18952
- requires: array(string()).optional(),
18953
- description: string().optional()
19539
+ var PressureAvgsSchema = object({
19540
+ avg10: number(),
19541
+ avg60: number(),
19542
+ avg300: number()
18954
19543
  });
18955
- /** The full capability block consulted before dispatch. */
18956
- var TargetKindCapsSchema = object({
18957
- attachments: object({
18958
- mediaTypes: array(AttachmentMediaTypeSchema),
18959
- mode: _enum([
18960
- "url",
18961
- "bytes",
18962
- "both"
18963
- ]),
18964
- max: number().int().nonnegative(),
18965
- maxBytes: number().int().positive().optional()
19544
+ var PressureInfoSchema = object({
19545
+ some: PressureAvgsSchema,
19546
+ full: PressureAvgsSchema.nullable()
19547
+ });
19548
+ var SystemResourceSnapshotSchema = object({
19549
+ cpu: CpuBreakdownSchema,
19550
+ memory: MemoryInfoSchema,
19551
+ gpu: MetricsGpuInfoSchema.nullable(),
19552
+ network: NetworkIoSnapshotSchema,
19553
+ disk: DiskIoSnapshotSchema,
19554
+ pressure: object({
19555
+ cpu: PressureInfoSchema.nullable(),
19556
+ memory: PressureInfoSchema.nullable(),
19557
+ io: PressureInfoSchema.nullable()
18966
19558
  }),
18967
- /** Max action buttons (0 = none). */
18968
- actions: number().int().nonnegative(),
18969
- levels: array(TargetKindLevelSchema),
18970
- format: array(NotificationFormatSchema),
18971
- clickUrl: boolean(),
18972
- sound: boolean(),
18973
- ttl: boolean(),
18974
- bodyMaxLen: number().int().positive()
19559
+ process: ProcessResourceInfoSchema,
19560
+ cpuTemperature: number().nullable(),
19561
+ timestampMs: number()
18975
19562
  });
18976
- /**
18977
- * `configSchema` is a `ConfigUISchema` tree passed through to the admin
18978
- * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
18979
- * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`)
18980
- * the union is large and not meant for runtime validation here; the exported
18981
- * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
18982
- */
18983
- var ConfigSchemaPassthrough$1 = unknown();
18984
- var TargetKindSchema = object({
18985
- kind: string(),
18986
- label: string(),
18987
- icon: string(),
18988
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
18989
- addonId: string(),
18990
- configSchema: ConfigSchemaPassthrough$1,
18991
- supportsDiscovery: boolean(),
18992
- caps: TargetKindCapsSchema
19563
+ var DiskSpaceInfoSchema = object({
19564
+ path: string(),
19565
+ totalBytes: number(),
19566
+ usedBytes: number(),
19567
+ availableBytes: number(),
19568
+ percent: number()
18993
19569
  });
18994
- /**
18995
- * A persisted target. `config` holds secrets; providers REDACT secret fields
18996
- * (return a presence marker only) when serving `listTargets` — never
18997
- * round-trip a stored secret to the UI.
18998
- */
18999
- var TargetSchema = object({
19000
- id: string(),
19001
- name: string(),
19002
- kind: string(),
19570
+ var PidResourceStatsSchema = object({
19571
+ pid: number(),
19572
+ cpu: number(),
19573
+ memory: number(),
19574
+ /**
19575
+ * Private (anonymous) resident bytes — the per-process V8 heap + native
19576
+ * allocations NOT shared with other processes (Linux RssAnon). This is the
19577
+ * "real" per-runner cost; summing it across runners is meaningful, unlike
19578
+ * `memory` (RSS), which double-counts the shared mmap'd framework code.
19579
+ * Undefined where /proc is unavailable (e.g. macOS).
19580
+ */
19581
+ privateBytes: number().optional(),
19582
+ /**
19583
+ * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
19584
+ * code shared copy-on-write across runners. Undefined on macOS.
19585
+ */
19586
+ sharedBytes: number().optional()
19587
+ });
19588
+ var AddonInstanceSchema = object({
19003
19589
  addonId: string(),
19004
- enabled: boolean(),
19005
- config: record(string(), unknown())
19590
+ nodeId: string(),
19591
+ role: _enum(["hub", "worker"]),
19592
+ pid: number(),
19593
+ state: _enum([
19594
+ "starting",
19595
+ "running",
19596
+ "stopping",
19597
+ "stopped",
19598
+ "crashed"
19599
+ ]),
19600
+ uptimeSec: number()
19006
19601
  });
19007
- /** A discovery-surfaced candidate (config is partial + non-secret). */
19008
- var DiscoveredTargetSchema = object({
19009
- kind: string(),
19010
- suggestedName: string(),
19011
- config: record(string(), unknown())
19602
+ var NodeProcessSchema = object({
19603
+ pid: number(),
19604
+ ppid: number(),
19605
+ pgid: number(),
19606
+ classification: _enum([
19607
+ "root",
19608
+ "managed",
19609
+ "system",
19610
+ "ghost"
19611
+ ]),
19612
+ /** `$process` addon binding when `managed`, else null. */
19613
+ addonId: string().nullable(),
19614
+ /** Kernel-reported nodeId when the process is a known agent/worker. */
19615
+ nodeId: string().nullable(),
19616
+ /** Truncated command line. */
19617
+ command: string(),
19618
+ cpuPercent: number(),
19619
+ memoryRssBytes: number(),
19620
+ /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
19621
+ uptimeSec: number(),
19622
+ /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
19623
+ orphaned: boolean()
19012
19624
  });
19013
- /** The degrade engine's report — what was resolved / dropped / degraded. */
19014
- var RenderedAsSchema = object({
19015
- level: string(),
19016
- format: NotificationFormatSchema,
19017
- attachmentsSent: number().int().nonnegative(),
19018
- actionsSent: number().int().nonnegative(),
19019
- truncated: boolean(),
19020
- dropped: array(string())
19625
+ var KillProcessInputSchema = object({
19626
+ pid: number(),
19627
+ /** Force = SIGKILL. Default is SIGTERM. */
19628
+ force: boolean().optional()
19021
19629
  });
19022
- var SendResultSchema = object({
19630
+ var KillProcessResultSchema = object({
19631
+ success: boolean(),
19632
+ reason: string().optional(),
19633
+ signal: _enum(["SIGTERM", "SIGKILL"]).optional()
19634
+ });
19635
+ var DumpHeapSnapshotInputSchema = object({
19636
+ /** The addon whose runner should dump a heap snapshot. */
19637
+ addonId: string() });
19638
+ var DumpHeapSnapshotResultSchema = object({
19023
19639
  success: boolean(),
19640
+ /** Path of the written .heapsnapshot inside the runner's container/host. */
19641
+ path: string().optional(),
19642
+ /** Process pid that was signalled. */
19643
+ pid: number().optional(),
19644
+ reason: string().optional()
19645
+ });
19646
+ var SystemMetricsSchema = object({
19647
+ cpuPercent: number(),
19648
+ memoryPercent: number(),
19649
+ memoryUsedMB: number(),
19650
+ memoryTotalMB: number(),
19651
+ diskPercent: number().optional(),
19652
+ temperature: number().optional(),
19653
+ gpuPercent: number().optional(),
19654
+ gpuMemoryPercent: number().optional()
19655
+ });
19656
+ 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, {
19657
+ kind: "mutation",
19658
+ auth: "admin"
19659
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
19660
+ kind: "mutation",
19661
+ auth: "admin"
19662
+ });
19663
+ method(object({
19664
+ sourceUrl: string(),
19665
+ metadata: ModelConvertMetadataSchema,
19666
+ targets: array(ConvertTargetSchema).min(1).readonly(),
19667
+ calibrationRef: string().optional(),
19668
+ sessionId: string().optional()
19669
+ }), ConvertResultSchema, {
19670
+ kind: "mutation",
19671
+ auth: "admin",
19672
+ timeoutMs: 6e5
19673
+ });
19674
+ method(object({
19675
+ nodeId: string(),
19676
+ modelId: string(),
19677
+ format: _enum(MODEL_FORMATS),
19678
+ entry: ModelCatalogEntrySchema
19679
+ }), object({
19680
+ ok: boolean(),
19681
+ /** sha256 of the staged tarball (empty for a hub-local no-op). */
19682
+ sha256: string(),
19683
+ bytes: number(),
19684
+ /** The target node's modelsDir the artifact landed in. */
19685
+ path: string()
19686
+ }), {
19687
+ kind: "mutation",
19688
+ auth: "admin"
19689
+ });
19690
+ /**
19691
+ * `mqtt-broker` — broker-registry cap.
19692
+ *
19693
+ * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
19694
+ * MQTT brokers (external + optionally an embedded `aedes`-backed one)
19695
+ * and (b) the connection details a consumer addon needs to spin up
19696
+ * its OWN `mqtt.js` client.
19697
+ *
19698
+ * Why: pub/sub routing over the system event-bus loses fidelity
19699
+ * (callback shape, QoS guarantees, will/retain semantics) and adds
19700
+ * refcount bookkeeping that addons would rather own themselves. The
19701
+ * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
19702
+ * features anyway — give it the connection config, get out of the way.
19703
+ *
19704
+ * Consumer flow:
19705
+ * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
19706
+ * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
19707
+ * client.subscribe('zigbee2mqtt/+')
19708
+ *
19709
+ * Collection mode: multiple brokers (e.g. one local mosquitto + one
19710
+ * cloud bridge). The "embedded" entry (when present) is just another
19711
+ * broker in the registry — its lifecycle is owned by the addon that
19712
+ * spawned it.
19713
+ */
19714
+ var BrokerKindSchema = _enum(["external", "embedded"]);
19715
+ /**
19716
+ * Broker live-probe status.
19717
+ *
19718
+ * - `connected` — last probe completed a clean CONNACK
19719
+ * - `disconnected` — no probe has run yet (cold cache)
19720
+ * - `auth-failed` — CONNACK refused with auth error (RC 4 / 5)
19721
+ * - `unreachable` — TCP connect timed out / refused
19722
+ * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
19723
+ */
19724
+ var BrokerStatusSchema$1 = _enum([
19725
+ "connected",
19726
+ "disconnected",
19727
+ "auth-failed",
19728
+ "unreachable",
19729
+ "tls-error"
19730
+ ]);
19731
+ var BrokerInfoSchema = object({
19732
+ id: string(),
19733
+ name: string(),
19734
+ url: string(),
19735
+ kind: BrokerKindSchema,
19736
+ status: BrokerStatusSchema$1,
19737
+ latencyMs: number().nullable(),
19024
19738
  error: string().optional(),
19025
- renderedAs: RenderedAsSchema.optional()
19739
+ /** Embedded brokers only: number of MQTT clients currently connected. */
19740
+ connectedClients: number().int().nonnegative().optional(),
19741
+ /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
19742
+ lastCheckedAt: number().optional()
19026
19743
  });
19027
- /** Same shape as SendResult — kept as a distinct name for the test panel. */
19028
- var TestResultSchema = SendResultSchema;
19029
- method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
19030
- kind: string(),
19031
- config: record(string(), unknown()).optional()
19032
- }), array(DiscoveredTargetSchema)), method(object({
19033
- targetId: string(),
19034
- notification: NotificationSchema
19035
- }), SendResultSchema, { kind: "mutation" }), method(object({
19036
- targetId: string(),
19037
- sample: NotificationSchema.optional()
19038
- }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
19039
- targetId: string(),
19040
- enabled: boolean()
19041
- }), _void(), { kind: "mutation" });
19042
19744
  /**
19043
- * Shared LLM generate contracts imported by BOTH `llm.cap.ts` (consumer
19044
- * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
19045
- * caps stay wire-compatible without a circular cap→cap import.
19046
- *
19047
- * Errors are a discriminated-union RESULT, never thrown: the shape survives
19048
- * every transport tier structurally, and failed calls still write usage rows.
19049
- * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
19745
+ * Connection details what a consumer needs to call
19746
+ * `mqtt.connect(url, options)`. We split URL + credentials so the
19747
+ * consumer can pass them as `mqtt.connect(url, { username, password })`
19748
+ * instead of stuffing creds into the URL (which leaks them into logs).
19050
19749
  */
19051
- var LlmUsageSchema = object({
19052
- inputTokens: number(),
19053
- outputTokens: number()
19750
+ var BrokerConnectionDetailsSchema = object({
19751
+ url: string(),
19752
+ username: string().optional(),
19753
+ password: string().optional(),
19754
+ /**
19755
+ * Suggested prefix for `clientId`. Each consumer should suffix this
19756
+ * with its own discriminator (addon id, instance id) so reconnects
19757
+ * don't kick each other off (MQTT spec: clientId must be unique per
19758
+ * broker).
19759
+ */
19760
+ clientIdPrefix: string().optional()
19054
19761
  });
19055
- var LlmErrorCodeSchema = _enum([
19056
- "timeout",
19057
- "rate-limited",
19058
- "auth",
19059
- "refusal",
19060
- "bad-request",
19061
- "unavailable",
19062
- "no-profile",
19063
- "budget-exceeded",
19064
- "adapter-error"
19065
- ]);
19066
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
19762
+ var AddBrokerInputSchema = object({
19763
+ name: string().min(1),
19764
+ url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
19765
+ username: string().optional(),
19766
+ password: string().optional(),
19767
+ clientIdPrefix: string().optional()
19768
+ });
19769
+ var AddBrokerResultSchema = object({ id: string() });
19770
+ var IdInputSchema = object({ id: string() });
19771
+ var TestResultSchema$1 = discriminatedUnion("ok", [object({
19067
19772
  ok: literal(true),
19068
- text: string(),
19069
- model: string(),
19070
- usage: LlmUsageSchema,
19071
- truncated: boolean(),
19072
19773
  latencyMs: number()
19073
19774
  }), object({
19074
19775
  ok: literal(false),
19075
- code: LlmErrorCodeSchema,
19076
- message: string(),
19077
- retryAfterMs: number().optional()
19776
+ error: string()
19078
19777
  })]);
19079
- /**
19080
- * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
19081
- * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
19082
- * notification-output.cap.ts:27-31 precedents).
19083
- */
19084
- var LlmImageSchema = object({
19085
- bytes: _instanceof(Uint8Array),
19086
- mimeType: string()
19778
+ var StartEmbeddedInputSchema = object({
19779
+ port: number().int().min(1).max(65535).default(1883),
19780
+ /** Allow anonymous connect (no username/password). Default: false. */
19781
+ allowAnonymous: boolean().default(false),
19782
+ /** Optional shared username/password for clients. */
19783
+ username: string().optional(),
19784
+ password: string().optional()
19087
19785
  });
19088
- var LlmGenerateBaseInputSchema = object({
19089
- /** Collection routing (the notification-output posture). */
19090
- addonId: string().optional(),
19091
- /** Explicit profile; else the resolution chain (spec §3). */
19092
- profileId: string().optional(),
19093
- /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
19094
- consumer: string(),
19095
- system: string().optional(),
19096
- /** v1: single-turn. `messages[]` is a v2 additive field. */
19097
- prompt: string(),
19098
- /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
19099
- jsonSchema: record(string(), unknown()).optional(),
19100
- /** Per-call override of the profile default. */
19101
- maxTokens: number().int().positive().optional(),
19102
- temperature: number().optional()
19786
+ var StartEmbeddedResultSchema = object({
19787
+ id: string(),
19788
+ url: string()
19103
19789
  });
19104
- /**
19105
- * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
19106
- * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
19107
- * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
19108
- * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
19109
- * this only through the `llm` cap's methods.
19110
- *
19111
- * One running llama-server child per node in v1 (models are RAM-heavy).
19112
- * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
19113
- * watchdog — operator decision #3).
19114
- */
19115
- var ManagedModelRefSchema = discriminatedUnion("kind", [
19116
- object({
19117
- kind: literal("catalog"),
19118
- catalogId: string()
19119
- }),
19120
- object({
19121
- kind: literal("url"),
19122
- url: string(),
19123
- sha256: string().optional()
19124
- }),
19125
- object({
19126
- kind: literal("path"),
19127
- path: string()
19128
- })
19129
- ]);
19130
- var ManagedRuntimeConfigSchema = object({
19131
- /** WHERE the runtime lives — hub or any agent. */
19132
- nodeId: string(),
19133
- /** Closed for v1; 'ollama' is a v2 candidate. */
19134
- engine: _enum(["llama-cpp"]),
19135
- model: ManagedModelRefSchema,
19136
- contextSize: number().int().default(4096),
19137
- /** 0 = CPU-only. */
19138
- gpuLayers: number().int().default(0),
19139
- /** Default: cpus-2, clamped ≥1 (resolved node-side). */
19140
- threads: number().int().optional(),
19141
- /** Concurrent slots. */
19142
- parallel: number().int().default(1),
19143
- /** Else lazy: first generate boots it. */
19144
- autoStart: boolean().default(false),
19145
- /** 0 = never; frees RAM after quiet periods. */
19146
- idleStopMinutes: number().int().default(30)
19790
+ var StatusSchema = object({
19791
+ brokerCount: number(),
19792
+ embeddedRunning: boolean()
19147
19793
  });
19148
- var LlmRuntimeStatusSchema = object({
19149
- /** Status is ALWAYS node-qualified. */
19150
- nodeId: string(),
19151
- state: _enum([
19152
- "stopped",
19153
- "downloading",
19154
- "starting",
19155
- "ready",
19156
- "crashed",
19157
- "failed"
19158
- ]),
19159
- pid: number().optional(),
19160
- port: number().optional(),
19161
- modelPath: string().optional(),
19162
- modelId: string().optional(),
19163
- downloadProgress: number().min(0).max(1).optional(),
19164
- lastError: string().optional(),
19165
- crashesInWindow: number(),
19166
- /** Child RSS (sampled best-effort). */
19167
- memoryBytes: number().optional(),
19168
- vramBytes: number().optional()
19794
+ method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema), method(AddBrokerInputSchema, AddBrokerResultSchema, { kind: "mutation" }), method(IdInputSchema, _void(), { kind: "mutation" }), method(IdInputSchema, TestResultSchema$1, { kind: "mutation" }), method(StartEmbeddedInputSchema, StartEmbeddedResultSchema, { kind: "mutation" }), method(IdInputSchema, _void(), { kind: "mutation" }), method(_void(), StatusSchema);
19795
+ var NetworkEndpointSchema = object({
19796
+ url: string(),
19797
+ hostname: string(),
19798
+ port: number(),
19799
+ protocol: _enum(["http", "https"])
19169
19800
  });
19170
- var LlmNodeModelSchema = object({
19171
- file: string(),
19172
- sizeBytes: number(),
19173
- catalogId: string().optional(),
19174
- installedAt: number().optional()
19801
+ var NetworkAccessStatusSchema = object({
19802
+ connected: boolean(),
19803
+ endpoint: NetworkEndpointSchema.nullable(),
19804
+ error: string().optional()
19175
19805
  });
19176
- var LlmRuntimeDiskUsageSchema = object({
19177
- nodeId: string(),
19178
- modelsBytes: number(),
19179
- freeBytes: number().optional()
19806
+ /**
19807
+ * Optional, richer endpoint shape returned by providers that expose
19808
+ * MORE than one ingress concurrently (Tailscale Ingress with mixed
19809
+ * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
19810
+ * the originating provider config (mode + sourcePort) so the
19811
+ * orchestrator UI can label rows distinctly. Providers that expose only
19812
+ * one endpoint just omit `listEndpoints` from their provider impl.
19813
+ */
19814
+ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
19815
+ /**
19816
+ * Stable id within the provider — typically `<mode>-<sourcePort>` so
19817
+ * the orchestrator can dedupe across `listEndpoints` polls.
19818
+ */
19819
+ id: string(),
19820
+ /** Operator-facing label (mirrors `MeshEndpoint.label`). */
19821
+ label: string(),
19822
+ /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
19823
+ mode: string().optional(),
19824
+ /** Originating local port the ingress fronts (informational). */
19825
+ sourcePort: number().optional()
19180
19826
  });
19181
- method(LlmGenerateBaseInputSchema.extend({
19182
- images: array(LlmImageSchema).optional(),
19183
- runtime: ManagedRuntimeConfigSchema,
19184
- /** The managed profile's timeout, threaded by the hub provider. */
19185
- timeoutMs: number().int().positive().optional()
19186
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
19187
- kind: "mutation",
19188
- auth: "admin"
19189
- }), method(object({}), _void(), {
19190
- kind: "mutation",
19191
- auth: "admin"
19192
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
19193
- kind: "mutation",
19194
- auth: "admin"
19195
- }), method(object({ file: string() }), _void(), {
19196
- kind: "mutation",
19197
- auth: "admin"
19198
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
19827
+ method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
19199
19828
  /**
19200
- * `llm`consumer-facing LLM surface (spec §1-§3). Collection-mode: array
19201
- * methods concat-fan across providers; single-row methods route to ONE
19202
- * provider by the `addonId` in the call input (the notification-output
19203
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
19204
- * (hub-placed); the cap stays open for future providers.
19829
+ * notification-outputcanonical, capability-gated notification delivery.
19830
+ *
19831
+ * Apprise-derived model (see
19832
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
19833
+ * callers emit ONE canonical `Notification`; each provider declares a
19834
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
19835
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
19836
+ * message to what the kind supports — callers never special-case a service.
19837
+ *
19838
+ * DESIGN DECISIONS (locked):
19839
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
19840
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
19841
+ * cap. Rationale: the admin UI needs one uniform surface across the
19842
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
19843
+ * alternative would fork the UI per addon and cannot host the
19844
+ * discovery→adopt flow.
19845
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
19846
+ * the generated cap-mount auto-`concatCollection`-fans them across every
19847
+ * registered provider (notifiers addon + HA addon) so one catalog is
19848
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
19849
+ * `addonId` the generated collection router extracts from the call input.
19850
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
19851
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
19852
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
19853
+ * base64 fallback needed.
19205
19854
  *
19206
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
19207
- * `apiKey` is a password field — providers REDACT it on read and merge on
19208
- * write; a stored key NEVER round-trips to a client.
19855
+ * TODO (deferred, closed-set change separate decision): add
19856
+ * `providerKind: 'notify'` so notification providers surface on the unified
19857
+ * admin "Integrations" page.
19209
19858
  */
19210
- var LlmProfileKindSchema = _enum([
19211
- "openai-compatible",
19212
- "openai",
19213
- "anthropic",
19214
- "google",
19215
- "managed-local"
19859
+ /**
19860
+ * Zentik-derived typed-media enum — the superset across every kind. Each
19861
+ * adapter picks what it supports and the degrade engine filters the rest.
19862
+ */
19863
+ var AttachmentMediaTypeSchema = _enum([
19864
+ "image",
19865
+ "video",
19866
+ "gif",
19867
+ "audio",
19868
+ "icon"
19216
19869
  ]);
19217
- var LlmProfileSchema = object({
19870
+ /**
19871
+ * A single attachment. Exactly one of `url` (remote source, most adapters
19872
+ * prefer this) or `bytes` (inline source; required for Pushover-style
19873
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
19874
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
19875
+ */
19876
+ var AttachmentSchema = object({
19877
+ mediaType: AttachmentMediaTypeSchema,
19878
+ url: string().optional(),
19879
+ bytes: _instanceof(Uint8Array).optional(),
19880
+ mime: string().optional(),
19881
+ name: string().optional()
19882
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
19883
+ var NotificationFormatSchema = _enum([
19884
+ "text",
19885
+ "markdown",
19886
+ "html"
19887
+ ]);
19888
+ /** A single tap-through action button. */
19889
+ var NotificationActionSchema = object({
19218
19890
  id: string(),
19219
- name: string(),
19220
- kind: LlmProfileKindSchema,
19221
- /** Stamped by the provider — keeps the fanned catalog routable. */
19222
- addonId: string(),
19223
- enabled: boolean(),
19224
- /** Vendor model id, or the managed runtime's loaded model. */
19225
- model: string(),
19226
- /** Required for openai-compatible; override for cloud kinds. */
19227
- baseUrl: string().optional(),
19228
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
19229
- apiKey: string().optional(),
19230
- supportsVision: boolean(),
19231
- temperature: number().min(0).max(2).optional(),
19232
- maxTokens: number().int().positive().optional(),
19233
- timeoutMs: number().int().positive().default(6e4),
19234
- extraHeaders: record(string(), string()).optional(),
19235
- /** kind === 'managed-local' only (spec §4). */
19236
- runtime: ManagedRuntimeConfigSchema.optional()
19891
+ label: string(),
19892
+ url: string().optional()
19237
19893
  });
19238
- /** ConfigUISchema tree passed through untyped on the wire (the
19239
- * notification-output `ConfigSchemaPassthrough` precedent at
19240
- * notification-output.cap.ts:151); the exported TS type re-tightens it. */
19894
+ /**
19895
+ * The canonical notification. `body` is the only hard field (Apprise model).
19896
+ * `priority` is a 5-level ORDINAL (1=lowest 3=normal(default) 5=urgent),
19897
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
19898
+ * the adapter maps this ordinal onto its native level. `level?` is an
19899
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
19900
+ * `priority` for that one target.
19901
+ */
19902
+ var NotificationSchema = object({
19903
+ body: string(),
19904
+ title: string().optional(),
19905
+ format: NotificationFormatSchema.default("text"),
19906
+ priority: number().int().min(1).max(5).default(3),
19907
+ level: string().optional(),
19908
+ attachments: array(AttachmentSchema).optional(),
19909
+ clickUrl: string().optional(),
19910
+ actions: array(NotificationActionSchema).optional(),
19911
+ sound: string().optional(),
19912
+ ttl: number().optional(),
19913
+ tag: string().optional(),
19914
+ deviceId: number().optional(),
19915
+ eventId: string().optional(),
19916
+ metadata: record(string(), unknown()).optional()
19917
+ });
19918
+ /** One declared native severity/priority level for a kind. */
19919
+ var TargetKindLevelSchema = object({
19920
+ id: string(),
19921
+ label: string(),
19922
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
19923
+ ordinal: number().int().min(1).max(5).nullable(),
19924
+ flags: object({
19925
+ critical: boolean().optional(),
19926
+ silent: boolean().optional(),
19927
+ noPush: boolean().optional()
19928
+ }).optional(),
19929
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
19930
+ requires: array(string()).optional(),
19931
+ description: string().optional()
19932
+ });
19933
+ /** The full capability block consulted before dispatch. */
19934
+ var TargetKindCapsSchema = object({
19935
+ attachments: object({
19936
+ mediaTypes: array(AttachmentMediaTypeSchema),
19937
+ mode: _enum([
19938
+ "url",
19939
+ "bytes",
19940
+ "both"
19941
+ ]),
19942
+ max: number().int().nonnegative(),
19943
+ maxBytes: number().int().positive().optional()
19944
+ }),
19945
+ /** Max action buttons (0 = none). */
19946
+ actions: number().int().nonnegative(),
19947
+ levels: array(TargetKindLevelSchema),
19948
+ format: array(NotificationFormatSchema),
19949
+ clickUrl: boolean(),
19950
+ sound: boolean(),
19951
+ ttl: boolean(),
19952
+ bodyMaxLen: number().int().positive()
19953
+ });
19954
+ /**
19955
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
19956
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
19957
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
19958
+ * the union is large and not meant for runtime validation here; the exported
19959
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
19960
+ */
19241
19961
  var ConfigSchemaPassthrough = unknown();
19242
- var LlmProfileKindDescriptorSchema = object({
19243
- kind: LlmProfileKindSchema,
19962
+ var TargetKindSchema = object({
19963
+ kind: string(),
19244
19964
  label: string(),
19245
19965
  icon: string(),
19246
19966
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
19247
19967
  addonId: string(),
19248
- configSchema: ConfigSchemaPassthrough
19249
- });
19250
- var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
19251
- var LlmDefaultSchema = object({
19252
- selector: LlmDefaultSelectorSchema,
19253
- profileId: string()
19254
- });
19255
- /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
19256
- var LlmUsageRollupSchema = object({
19257
- day: string(),
19258
- consumer: string(),
19259
- profileId: string(),
19260
- calls: number(),
19261
- okCalls: number(),
19262
- errorCalls: number(),
19263
- inputTokens: number(),
19264
- outputTokens: number(),
19265
- avgLatencyMs: number()
19968
+ configSchema: ConfigSchemaPassthrough,
19969
+ supportsDiscovery: boolean(),
19970
+ caps: TargetKindCapsSchema
19266
19971
  });
19267
- /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
19268
- var ManagedModelCatalogEntrySchema = object({
19972
+ /**
19973
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
19974
+ * (return a presence marker only) when serving `listTargets` — never
19975
+ * round-trip a stored secret to the UI.
19976
+ */
19977
+ var TargetSchema = object({
19269
19978
  id: string(),
19270
- label: string(),
19271
- family: string(),
19272
- purpose: _enum(["text", "vision"]),
19273
- url: string(),
19274
- sha256: string(),
19275
- sizeBytes: number(),
19276
- quantization: string(),
19277
- /** Load-time guidance shown in the picker. */
19278
- minRamBytes: number(),
19279
- contextSizeDefault: number().int(),
19280
- /** Vision models: companion projector file. */
19281
- mmprojUrl: string().optional()
19282
- });
19283
- var LlmRuntimeNodeSchema = object({
19284
- nodeId: string(),
19285
- reachable: boolean(),
19286
- status: LlmRuntimeStatusSchema.optional(),
19287
- disk: LlmRuntimeDiskUsageSchema.optional(),
19288
- error: string().optional()
19289
- });
19290
- var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
19291
- var ProfileRefInputSchema = object({
19979
+ name: string(),
19980
+ kind: string(),
19292
19981
  addonId: string(),
19293
- profileId: string()
19982
+ enabled: boolean(),
19983
+ config: record(string(), unknown())
19294
19984
  });
19295
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
19296
- kind: "mutation",
19297
- auth: "admin"
19298
- }), method(ProfileRefInputSchema, _void(), {
19299
- kind: "mutation",
19300
- auth: "admin"
19301
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
19302
- kind: "mutation",
19303
- auth: "admin"
19304
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
19305
- selector: LlmDefaultSelectorSchema,
19306
- profileId: string().nullable()
19307
- }), _void(), {
19308
- kind: "mutation",
19309
- auth: "admin"
19310
- }), method(object({
19311
- since: number().optional(),
19312
- until: number().optional(),
19313
- consumer: string().optional(),
19314
- profileId: string().optional()
19315
- }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
19316
- nodeId: string(),
19317
- model: ManagedModelRefSchema
19318
- }), _void(), {
19319
- kind: "mutation",
19320
- auth: "admin"
19321
- }), method(object({
19322
- nodeId: string(),
19323
- file: string()
19324
- }), _void(), {
19325
- kind: "mutation",
19326
- auth: "admin"
19327
- }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
19328
- kind: "mutation",
19329
- auth: "admin"
19330
- }), method(ProfileRefInputSchema, _void(), {
19331
- kind: "mutation",
19332
- auth: "admin"
19985
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
19986
+ var DiscoveredTargetSchema = object({
19987
+ kind: string(),
19988
+ suggestedName: string(),
19989
+ config: record(string(), unknown())
19990
+ });
19991
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
19992
+ var RenderedAsSchema = object({
19993
+ level: string(),
19994
+ format: NotificationFormatSchema,
19995
+ attachmentsSent: number().int().nonnegative(),
19996
+ actionsSent: number().int().nonnegative(),
19997
+ truncated: boolean(),
19998
+ dropped: array(string())
19999
+ });
20000
+ var SendResultSchema = object({
20001
+ success: boolean(),
20002
+ error: string().optional(),
20003
+ renderedAs: RenderedAsSchema.optional()
19333
20004
  });
20005
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
20006
+ var TestResultSchema = SendResultSchema;
20007
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
20008
+ kind: string(),
20009
+ config: record(string(), unknown()).optional()
20010
+ }), array(DiscoveredTargetSchema)), method(object({
20011
+ targetId: string(),
20012
+ notification: NotificationSchema
20013
+ }), SendResultSchema, { kind: "mutation" }), method(object({
20014
+ targetId: string(),
20015
+ sample: NotificationSchema.optional()
20016
+ }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
20017
+ targetId: string(),
20018
+ enabled: boolean()
20019
+ }), _void(), { kind: "mutation" });
19334
20020
  /**
19335
20021
  * Zod schemas for persisted record types.
19336
20022
  *
@@ -20040,76 +20726,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
20040
20726
  eventId: string(),
20041
20727
  timestamp: number()
20042
20728
  });
20043
- /**
20044
- * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
20045
- * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
20046
- * caps into per-camera event-kind descriptors.
20047
- *
20048
- * The descriptor DATA (color / iconId / labelKey / parentKind / category)
20049
- * is NOT duplicated here — every entry is derived from the single
20050
- * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
20051
- * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
20052
- * control cap means adding one line here (and a taxonomy entry); the anti-
20053
- * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
20054
- * eventful cap is missing.
20055
- */
20056
- /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
20057
- var LEGACY_ICON = {
20058
- motion: "motion",
20059
- audio: "audio",
20060
- person: "person",
20061
- vehicle: "vehicle",
20062
- animal: "animal",
20063
- package: "package",
20064
- door: "door",
20065
- pir: "pir",
20066
- smoke: "smoke",
20067
- water: "water",
20068
- button: "button",
20069
- generic: "generic",
20070
- gas: "smoke",
20071
- vibration: "generic",
20072
- tamper: "generic",
20073
- presence: "person",
20074
- lock: "generic",
20075
- siren: "generic",
20076
- switch: "generic",
20077
- doorbell: "button"
20078
- };
20079
- function legacyIcon(iconId) {
20080
- return LEGACY_ICON[iconId] ?? "generic";
20081
- }
20082
- /**
20083
- * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
20084
- * The anti-drift guard cross-checks this against the eventful caps declared
20085
- * in `packages/types/src/capabilities/*.cap.ts`.
20086
- */
20087
- var CAP_TO_KIND = {
20088
- contact: "contact",
20089
- motion: "motion-sensor",
20090
- smoke: "smoke",
20091
- flood: "flood",
20092
- gas: "gas",
20093
- "carbon-monoxide": "carbon-monoxide",
20094
- vibration: "vibration",
20095
- tamper: "tamper",
20096
- presence: "presence",
20097
- "enum-sensor": "enum-sensor",
20098
- "event-emitter": "device-event",
20099
- "lock-control": "lock",
20100
- switch: "switch",
20101
- button: "button",
20102
- doorbell: "doorbell"
20103
- };
20104
- function buildDescriptor(capName, kind) {
20105
- const t = EVENT_TAXONOMY[kind];
20106
- if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
20107
- return {
20108
- ...t,
20109
- icon: legacyIcon(t.iconId)
20110
- };
20111
- }
20112
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
20113
20729
  var CameraPipelineConfigSchema = object({
20114
20730
  engine: PipelineEngineChoiceSchema.optional(),
20115
20731
  steps: array(PipelineStepInputSchema).readonly(),
@@ -20595,6 +21211,76 @@ method(object({
20595
21211
  auth: "admin"
20596
21212
  });
20597
21213
  /**
21214
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
21215
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
21216
+ * caps into per-camera event-kind descriptors.
21217
+ *
21218
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
21219
+ * is NOT duplicated here — every entry is derived from the single
21220
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
21221
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
21222
+ * control cap means adding one line here (and a taxonomy entry); the anti-
21223
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
21224
+ * eventful cap is missing.
21225
+ */
21226
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
21227
+ var LEGACY_ICON = {
21228
+ motion: "motion",
21229
+ audio: "audio",
21230
+ person: "person",
21231
+ vehicle: "vehicle",
21232
+ animal: "animal",
21233
+ package: "package",
21234
+ door: "door",
21235
+ pir: "pir",
21236
+ smoke: "smoke",
21237
+ water: "water",
21238
+ button: "button",
21239
+ generic: "generic",
21240
+ gas: "smoke",
21241
+ vibration: "generic",
21242
+ tamper: "generic",
21243
+ presence: "person",
21244
+ lock: "generic",
21245
+ siren: "generic",
21246
+ switch: "generic",
21247
+ doorbell: "button"
21248
+ };
21249
+ function legacyIcon(iconId) {
21250
+ return LEGACY_ICON[iconId] ?? "generic";
21251
+ }
21252
+ /**
21253
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
21254
+ * The anti-drift guard cross-checks this against the eventful caps declared
21255
+ * in `packages/types/src/capabilities/*.cap.ts`.
21256
+ */
21257
+ var CAP_TO_KIND = {
21258
+ contact: "contact",
21259
+ motion: "motion-sensor",
21260
+ smoke: "smoke",
21261
+ flood: "flood",
21262
+ gas: "gas",
21263
+ "carbon-monoxide": "carbon-monoxide",
21264
+ vibration: "vibration",
21265
+ tamper: "tamper",
21266
+ presence: "presence",
21267
+ "enum-sensor": "enum-sensor",
21268
+ "event-emitter": "device-event",
21269
+ "lock-control": "lock",
21270
+ switch: "switch",
21271
+ button: "button",
21272
+ doorbell: "doorbell"
21273
+ };
21274
+ function buildDescriptor(capName, kind) {
21275
+ const t = EVENT_TAXONOMY[kind];
21276
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
21277
+ return {
21278
+ ...t,
21279
+ icon: legacyIcon(t.iconId)
21280
+ };
21281
+ }
21282
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
21283
+ /**
20598
21284
  * server-management — per-NODE singleton capability for a node's ROOT
20599
21285
  * package lifecycle (runtime-updatable node packages).
20600
21286
  *
@@ -22100,7 +22786,28 @@ var FaceInfoSchema = object({
22100
22786
  * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`). Absent when the
22101
22787
  * track produced no key frame (e.g. native/onboard source) — the UI falls
22102
22788
  * back to the inline `base64` face crop. */
22103
- keyFrameMediaKey: string().optional()
22789
+ keyFrameMediaKey: string().optional(),
22790
+ /** Winning identity-match cosine (0..1) for this face's track, when an
22791
+ * identity was auto-confirmed. Lets the UI surface WHY a face was assigned
22792
+ * (confidence badge / low-confidence audit). Absent on legacy rows and on
22793
+ * faces that were never auto-recognized. */
22794
+ bestMatchScore: number().optional(),
22795
+ /** Native-scale face short side (px) at recognition time, when the runner
22796
+ * measured it. Lets the UI flag low-resolution auto-assignments. Absent on
22797
+ * legacy rows / runners that reported no native measure. */
22798
+ nativeFaceShortSidePx: number().optional(),
22799
+ /** SUGGESTED identity for this face — a plausible-but-not-confident match that
22800
+ * MISSED auto-assignment (cosine in the suggestion band, or above threshold
22801
+ * but blocked only by the recognition size floor). Mutually exclusive with
22802
+ * `recognizedIdentityId` (a suggestion is NEVER an assignment): the face stays
22803
+ * UNASSIGNED and everything else keeps treating it as unrecognized — the UI
22804
+ * merely offers a one-tap "is this <name>?" confirm. Absent on legacy rows and
22805
+ * on faces that were auto-assigned or below the suggestion band. (2026-07-24) */
22806
+ suggestedIdentityId: string().optional(),
22807
+ /** Peak identity-match cosine (0..1) for `suggestedIdentityId`, captured at the
22808
+ * same moment as `bestMatchScore` (track peak, at close). Lets the UI rank /
22809
+ * badge suggestion confidence. Present iff `suggestedIdentityId` is. (2026-07-24) */
22810
+ suggestedMatchScore: number().optional()
22104
22811
  });
22105
22812
  var FaceFilterEnum = _enum([
22106
22813
  "unassigned",
@@ -24518,36 +25225,6 @@ Object.freeze({
24518
25225
  addonId: null,
24519
25226
  access: "view"
24520
25227
  },
24521
- "advancedNotifier.deleteRule": {
24522
- capName: "advanced-notifier",
24523
- capScope: "system",
24524
- addonId: null,
24525
- access: "delete"
24526
- },
24527
- "advancedNotifier.getHistory": {
24528
- capName: "advanced-notifier",
24529
- capScope: "system",
24530
- addonId: null,
24531
- access: "view"
24532
- },
24533
- "advancedNotifier.getRules": {
24534
- capName: "advanced-notifier",
24535
- capScope: "system",
24536
- addonId: null,
24537
- access: "view"
24538
- },
24539
- "advancedNotifier.testRule": {
24540
- capName: "advanced-notifier",
24541
- capScope: "system",
24542
- addonId: null,
24543
- access: "create"
24544
- },
24545
- "advancedNotifier.upsertRule": {
24546
- capName: "advanced-notifier",
24547
- capScope: "system",
24548
- addonId: null,
24549
- access: "create"
24550
- },
24551
25228
  "alarmPanel.arm": {
24552
25229
  capName: "alarm-panel",
24553
25230
  capScope: "device",
@@ -24770,6 +25447,12 @@ Object.freeze({
24770
25447
  addonId: null,
24771
25448
  access: "delete"
24772
25449
  },
25450
+ "backup.deleteSchedule": {
25451
+ capName: "backup",
25452
+ capScope: "system",
25453
+ addonId: null,
25454
+ access: "delete"
25455
+ },
24773
25456
  "backup.getEntries": {
24774
25457
  capName: "backup",
24775
25458
  capScope: "system",
@@ -24800,6 +25483,12 @@ Object.freeze({
24800
25483
  addonId: null,
24801
25484
  access: "view"
24802
25485
  },
25486
+ "backup.listSchedules": {
25487
+ capName: "backup",
25488
+ capScope: "system",
25489
+ addonId: null,
25490
+ access: "view"
25491
+ },
24803
25492
  "backup.previewSchedule": {
24804
25493
  capName: "backup",
24805
25494
  capScope: "system",
@@ -24824,6 +25513,12 @@ Object.freeze({
24824
25513
  addonId: null,
24825
25514
  access: "create"
24826
25515
  },
25516
+ "backup.upsertSchedule": {
25517
+ capName: "backup",
25518
+ capScope: "system",
25519
+ addonId: null,
25520
+ access: "create"
25521
+ },
24827
25522
  "battery.wakeForStream": {
24828
25523
  capName: "battery",
24829
25524
  capScope: "device",
@@ -26852,6 +27547,60 @@ Object.freeze({
26852
27547
  addonId: null,
26853
27548
  access: "create"
26854
27549
  },
27550
+ "notificationRules.createRule": {
27551
+ capName: "notification-rules",
27552
+ capScope: "system",
27553
+ addonId: null,
27554
+ access: "create"
27555
+ },
27556
+ "notificationRules.deleteRule": {
27557
+ capName: "notification-rules",
27558
+ capScope: "system",
27559
+ addonId: null,
27560
+ access: "delete"
27561
+ },
27562
+ "notificationRules.getConditionCatalog": {
27563
+ capName: "notification-rules",
27564
+ capScope: "system",
27565
+ addonId: null,
27566
+ access: "view"
27567
+ },
27568
+ "notificationRules.getHistory": {
27569
+ capName: "notification-rules",
27570
+ capScope: "system",
27571
+ addonId: null,
27572
+ access: "view"
27573
+ },
27574
+ "notificationRules.getRule": {
27575
+ capName: "notification-rules",
27576
+ capScope: "system",
27577
+ addonId: null,
27578
+ access: "view"
27579
+ },
27580
+ "notificationRules.listRules": {
27581
+ capName: "notification-rules",
27582
+ capScope: "system",
27583
+ addonId: null,
27584
+ access: "view"
27585
+ },
27586
+ "notificationRules.setRuleEnabled": {
27587
+ capName: "notification-rules",
27588
+ capScope: "system",
27589
+ addonId: null,
27590
+ access: "create"
27591
+ },
27592
+ "notificationRules.testRule": {
27593
+ capName: "notification-rules",
27594
+ capScope: "system",
27595
+ addonId: null,
27596
+ access: "create"
27597
+ },
27598
+ "notificationRules.updateRule": {
27599
+ capName: "notification-rules",
27600
+ capScope: "system",
27601
+ addonId: null,
27602
+ access: "create"
27603
+ },
26855
27604
  "notifier.cancel": {
26856
27605
  capName: "notifier",
26857
27606
  capScope: "device",
@@ -28604,6 +29353,36 @@ Object.freeze({
28604
29353
  addonId: null,
28605
29354
  access: "create"
28606
29355
  },
29356
+ "terminalSession.close": {
29357
+ capName: "terminal-session",
29358
+ capScope: "system",
29359
+ addonId: null,
29360
+ access: "create"
29361
+ },
29362
+ "terminalSession.listProfiles": {
29363
+ capName: "terminal-session",
29364
+ capScope: "system",
29365
+ addonId: null,
29366
+ access: "view"
29367
+ },
29368
+ "terminalSession.listSessions": {
29369
+ capName: "terminal-session",
29370
+ capScope: "system",
29371
+ addonId: null,
29372
+ access: "view"
29373
+ },
29374
+ "terminalSession.openSession": {
29375
+ capName: "terminal-session",
29376
+ capScope: "system",
29377
+ addonId: null,
29378
+ access: "create"
29379
+ },
29380
+ "terminalSession.resize": {
29381
+ capName: "terminal-session",
29382
+ capScope: "system",
29383
+ addonId: null,
29384
+ access: "create"
29385
+ },
28607
29386
  "toast.onToast": {
28608
29387
  capName: "toast",
28609
29388
  capScope: "system",