@camstack/addon-provider-homeassistant 1.2.4 → 1.2.6

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 +1938 -1137
  2. package/dist/addon.mjs +1938 -1137
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { brotliCompressSync, deflateSync, gzipSync } from "node:zlib";
3
- //#region ../types/dist/event-category-D4HJq7Mw.mjs
3
+ //#region ../types/dist/event-category-BLcNejAE.mjs
4
4
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
5
5
  EventCategory["SystemBoot"] = "system.boot";
6
6
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -150,9 +150,6 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
150
150
  EventCategory["RecordingSegmentWritten"] = "recording.segment.written";
151
151
  EventCategory["RecordingPolicyFallback"] = "recording.policy.fallback";
152
152
  EventCategory["RecordingRetentionCompleted"] = "recording.retention.completed";
153
- /** Runner-sampled scrub thumbnail (~1/5 s/camera). Telemetry (D8): a lost
154
- * thumb is a scrub gap the recorder's keyframe backfill covers. */
155
- EventCategory["RecordingThumbSampled"] = "recording.thumb-sampled";
156
153
  /** Export render progress (0–100). Telemetry (D8): a lost tick is a stale
157
154
  * progress bar the client reconciles via `recordingExport.getExport`. */
158
155
  EventCategory["RecordingExportProgress"] = "recording.export.progress";
@@ -6817,7 +6814,6 @@ object({ deviceId: number() }), object({ deviceId: number() }), object({
6817
6814
  patch: record(string(), unknown())
6818
6815
  }), object({ success: literal(true) });
6819
6816
  object({ deviceId: number() }), unknown().nullable();
6820
- /** Shorthand to define a method schema */
6821
6817
  function method(input, output, options) {
6822
6818
  return {
6823
6819
  input,
@@ -6825,6 +6821,7 @@ function method(input, output, options) {
6825
6821
  kind: options?.kind ?? "query",
6826
6822
  auth: options?.auth ?? "protected",
6827
6823
  ...options?.access !== void 0 ? { access: options.access } : {},
6824
+ ...options?.caller !== void 0 ? { caller: options.caller } : {},
6828
6825
  timeoutMs: options?.timeoutMs
6829
6826
  };
6830
6827
  }
@@ -7639,16 +7636,23 @@ var StorageLocationDeclarationSchema = object({
7639
7636
  * Which node root the seeded `<id>:default` instance is placed under on a
7640
7637
  * FRESH install:
7641
7638
  * - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
7642
- * the appData volume. Right for small/durable data (backups, logs, models).
7639
+ * the appData volume. Right for small/durable data (logs, models).
7643
7640
  * - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
7644
7641
  * env is set, else falls back to the data root. Right for bulky, hot media
7645
7642
  * (recordings, event media) that should stay off the appData disk.
7643
+ * - `'backup'` — the dedicated backup volume (`CAMSTACK_BACKUP_ROOT`, default
7644
+ * `/backups` in the image) so archives live on their own mount rather than
7645
+ * filling the appData disk. Falls back to the data root when unset.
7646
7646
  *
7647
7647
  * Only affects the seeded default's `basePath`; operators can repoint any
7648
7648
  * location afterwards, and a `defaultsTo` slot inherits its parent's root
7649
7649
  * regardless of this field. Absent (the common case) is treated as `'data'`.
7650
7650
  */
7651
- defaultRoot: _enum(["data", "media"]).optional()
7651
+ defaultRoot: _enum([
7652
+ "data",
7653
+ "media",
7654
+ "backup"
7655
+ ]).optional()
7652
7656
  });
7653
7657
  var DecoderStatsSchema = object({
7654
7658
  inputFps: number(),
@@ -8311,6 +8315,59 @@ for (const l of AUDIO_MACRO_LABELS) {
8311
8315
  /** The complete taxonomy dictionary, keyed by kind. */
8312
8316
  var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
8313
8317
  /**
8318
+ * Notification-Center taxonomy — the fixed vocabulary the NC rule editor
8319
+ * offers as pickers instead of free text. Derived (never hand-listed) from the
8320
+ * single `EVENT_TAXONOMY` dictionary so it stays in lockstep with every other
8321
+ * taxonomy surface (timeline, filters, event page).
8322
+ *
8323
+ * Three buckets, mapped onto the rule editor's `stringList` conditions:
8324
+ * - `videoClasses` → detection classes (person / vehicle / animal + subs)
8325
+ * for the `classes` / `classesExclude` conditions.
8326
+ * - `audioKinds` → audio-analyzer sub kinds (`audio-scream`, …) shown in
8327
+ * the same class picker, grouped under an Audio header.
8328
+ * - `labels` → sensor + control taxonomy kinds (doorbell / contact /
8329
+ * lock / …) for the `sensorKinds` device-event condition.
8330
+ *
8331
+ * Each entry carries `parentKind` so the client can group video subs under
8332
+ * their macro and sensor/control kinds under their category. This surface is
8333
+ * served ADDITIVELY on the `nc.getConditionCatalog` bridge response — no cap
8334
+ * method, no codegen — so it ships train-free with an addon deploy.
8335
+ */
8336
+ /** One selectable taxonomy value: a stable kind id + display label + parent. */
8337
+ var NcTaxonomyEntrySchema = object({
8338
+ /** Stable kind id (e.g. 'person', 'car', 'audio-scream', 'doorbell'). */
8339
+ kind: string(),
8340
+ /** English fallback label (the UI translates via the event-kind i18n key). */
8341
+ label: string(),
8342
+ /** Macro/category parent for grouping ('car' → 'vehicle'); null for a top. */
8343
+ parentKind: string().nullable()
8344
+ });
8345
+ object({
8346
+ videoClasses: array(NcTaxonomyEntrySchema),
8347
+ audioKinds: array(NcTaxonomyEntrySchema),
8348
+ labels: array(NcTaxonomyEntrySchema)
8349
+ });
8350
+ function toEntry(kind, label, parentKind) {
8351
+ return {
8352
+ kind,
8353
+ label,
8354
+ parentKind
8355
+ };
8356
+ }
8357
+ /**
8358
+ * Build the NC taxonomy from `EVENT_TAXONOMY`. Insertion order is preserved
8359
+ * (macros before their subs), which the client relies on for stable grouping.
8360
+ */
8361
+ function buildNcTaxonomy() {
8362
+ const all = Object.values(EVENT_TAXONOMY);
8363
+ return {
8364
+ videoClasses: all.filter((e) => e.category === "detection").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8365
+ audioKinds: all.filter((e) => e.category === "audio" && e.level === "sub").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8366
+ labels: all.filter((e) => e.category === "sensor" || e.category === "control").map((e) => toEntry(e.kind, e.label, e.parentKind))
8367
+ };
8368
+ }
8369
+ Object.freeze(buildNcTaxonomy());
8370
+ /**
8314
8371
  * Error types for the safe expression engine. Two distinct classes so callers
8315
8372
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
8316
8373
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -9382,6 +9439,644 @@ function prepareNotification(caps, n) {
9382
9439
  };
9383
9440
  }
9384
9441
  /**
9442
+ * Shared geometry vocabulary for on-frame shape caps — privacy-mask,
9443
+ * motion-zones, and the detection zones/lines editor all speak this one
9444
+ * language so a single drawing-plane editor and the providers stay
9445
+ * decoupled from each cap's storage.
9446
+ *
9447
+ * All coordinates are normalized 0..1 of the camera frame (top-left
9448
+ * origin). Each cap composes the SUBSET of shape kinds it supports and
9449
+ * advertises it via `supportedShapes` in its `getOptions`.
9450
+ */
9451
+ /** A normalized 0..1 point (top-left origin). */
9452
+ var MaskPointSchema = object({
9453
+ x: number(),
9454
+ y: number()
9455
+ });
9456
+ /** Axis-aligned rectangle (normalized 0..1). */
9457
+ var MaskRectShapeSchema = object({
9458
+ kind: literal("rect"),
9459
+ x: number(),
9460
+ y: number(),
9461
+ width: number(),
9462
+ height: number()
9463
+ });
9464
+ /** Free polygon — an ordered list of normalized vertices (≥3). */
9465
+ var MaskPolygonShapeSchema = object({
9466
+ kind: literal("polygon"),
9467
+ points: array(MaskPointSchema)
9468
+ });
9469
+ /** Boolean cell grid — row-major, length === gridWidth*gridHeight. */
9470
+ var MaskGridShapeSchema = object({
9471
+ kind: literal("grid"),
9472
+ gridWidth: number(),
9473
+ gridHeight: number(),
9474
+ cells: array(boolean())
9475
+ });
9476
+ discriminatedUnion("kind", [
9477
+ MaskRectShapeSchema,
9478
+ MaskPolygonShapeSchema,
9479
+ MaskGridShapeSchema,
9480
+ object({
9481
+ kind: literal("line"),
9482
+ points: array(MaskPointSchema)
9483
+ })
9484
+ ]);
9485
+ /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
9486
+ var MaskShapeKindSchema = _enum([
9487
+ "rect",
9488
+ "polygon",
9489
+ "grid",
9490
+ "line"
9491
+ ]);
9492
+ /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
9493
+ var MaskPolygonVerticesSchema = object({
9494
+ min: number(),
9495
+ max: number()
9496
+ });
9497
+ /** Grid dimensions when a cap supports 'grid'. */
9498
+ var MaskGridDimsSchema = object({
9499
+ width: number(),
9500
+ height: number()
9501
+ });
9502
+ /**
9503
+ * notification-rules — the Notification Center rule surface (P1 core).
9504
+ *
9505
+ * Spec: `docs/superpowers/specs/2026-07-22-notification-center-requirements.md`
9506
+ * (operator decisions D-1/D-2/D-3 are binding):
9507
+ *
9508
+ * - D-2: rule EVALUATION lives in `addon-post-analysis` (the
9509
+ * `notification-center` module), hooked on the durable persistence
9510
+ * moments (object-event insert, TrackCloser.closeExpired) with a
9511
+ * persisted outbox + retry — never the lossy telemetry bus (D8).
9512
+ * - D-3: urgency belongs to the RULE. `delivery: 'immediate'` fires on the
9513
+ * FIRST persisted detection matching the conditions (per-track dedup,
9514
+ * `maxPerTrack` fixed at 1 — see {@link NC_MAX_PER_TRACK_IMMEDIATE});
9515
+ * `delivery: 'track-end'` evaluates the finalized track record at close.
9516
+ * - DISPATCH stays behind `notification-output` (rules reference targets
9517
+ * by id; per-backend params are a passthrough blob capped by the
9518
+ * target kind's own caps/degrade engine).
9519
+ *
9520
+ * P1 scope: admin-authored rules only (`createdBy` stamped from the
9521
+ * server-injected caller identity — the first `caller: 'required'`
9522
+ * adopter). The P1 condition subset is: devices, classes(+exclude),
9523
+ * minConfidence, admin zones (any/all + exclude), weekly schedule
9524
+ * windows, and the optional label/identity/plate matchers. User rules,
9525
+ * private zones, per-recipient fan-out and the wider condition table are
9526
+ * P2+ (see spec §7).
9527
+ *
9528
+ * All schemas here are the single source of truth — `NcRule` etc. are
9529
+ * `z.infer` exports; no duplicate interfaces (the advanced-notifier
9530
+ * schema/interface drift is explicitly not repeated).
9531
+ */
9532
+ /**
9533
+ * D-3: the trigger/urgency of a rule — which persistence moment evaluates it.
9534
+ * The value maps 1:1 onto the evaluated record kind:
9535
+ * - `immediate` ↔ object-event persist (lowest-latency detection burst)
9536
+ * - `track-end` ↔ TrackCloser.closeExpired (finalized track record)
9537
+ * - `device-event` ↔ SensorEventStore insert (doorbell press / sensor state
9538
+ * change of a LINKED device, one row per linked camera)
9539
+ * - `package-event` ↔ PackageDropDetector object-event insert (a `package`
9540
+ * delivery / pick-up)
9541
+ *
9542
+ * `immediate`/`track-end` carry the D-3 urgency semantics; `device-event`/
9543
+ * `package-event` are pure trigger kinds (no urgency dimension). Extending
9544
+ * this one field keeps the schema additive — a rule still declares exactly
9545
+ * one trigger.
9546
+ */
9547
+ var NcDeliverySchema = _enum([
9548
+ "immediate",
9549
+ "track-end",
9550
+ "device-event",
9551
+ "package-event"
9552
+ ]);
9553
+ /** Weekly schedule — OR of windows; absence on the rule = always active. */
9554
+ var NcScheduleSchema = object({
9555
+ windows: array(object({
9556
+ /** Days of week the window STARTS on (0 = Sunday … 6 = Saturday). */
9557
+ days: array(number().int().min(0).max(6)).min(1),
9558
+ startMinute: number().int().min(0).max(1439),
9559
+ endMinute: number().int().min(0).max(1439)
9560
+ })).min(1),
9561
+ /** IANA timezone; default = hub host timezone. */
9562
+ timezone: string().optional(),
9563
+ /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
9564
+ invert: boolean().optional()
9565
+ });
9566
+ /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
9567
+ var NcPlateMatcherSchema = object({
9568
+ values: array(string().min(1)).min(1),
9569
+ /** Max Levenshtein distance after normalization (uppercase alphanumeric). */
9570
+ maxDistance: number().int().min(0).max(3).default(1)
9571
+ });
9572
+ /**
9573
+ * Occupancy condition (DEVICE-EVENT trigger). Fires on a ZoneAnalytics
9574
+ * occupancy edge for a device — optionally narrowed to a single admin
9575
+ * `zoneId` and/or object `className`. `op` selects the edge/threshold:
9576
+ * - `became-occupied` (default) — count crossed 0 → ≥ `count`
9577
+ * - `became-free` — count crossed ≥ `count` → below it
9578
+ * - `>=` / `<=` — count is at/over or at/under `count`
9579
+ * `sustainSeconds` requires the condition hold continuously that long
9580
+ * before firing (debounces flicker; 0 = fire on the first matching edge).
9581
+ * Fail-closed: no ZoneAnalytics snapshot / missing zone / null snapshot ⇒
9582
+ * the condition never matches. Confirmed edge-state survives addon restarts
9583
+ * (declared SQLite collection, reseeded on boot).
9584
+ */
9585
+ var NcOccupancyConditionSchema = object({
9586
+ /** Admin zone id to scope the count to; absent = whole-frame occupancy. */
9587
+ zoneId: string().optional(),
9588
+ /** Object class to count; absent = any class. */
9589
+ className: string().optional(),
9590
+ op: _enum([
9591
+ "became-occupied",
9592
+ "became-free",
9593
+ ">=",
9594
+ "<="
9595
+ ]).default("became-occupied"),
9596
+ count: number().int().min(0).default(1),
9597
+ sustainSeconds: number().int().min(0).max(3600).default(15)
9598
+ });
9599
+ /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
9600
+ var NcZoneConditionSchema = object({
9601
+ ids: array(string().min(1)).min(1),
9602
+ /** Quantifier over `ids` — at least one / every one visited. */
9603
+ match: _enum(["any", "all"]).default("any")
9604
+ });
9605
+ /**
9606
+ * The P1 condition set — a flat AND of groups; absent group = pass;
9607
+ * membership lists are OR within the list (spec §2.3).
9608
+ */
9609
+ var NcConditionsSchema = object({
9610
+ /** Device scope — absent = all devices. */
9611
+ devices: array(number()).optional(),
9612
+ /** Detector class names (any overlap with the record's class set). */
9613
+ classes: array(string().min(1)).optional(),
9614
+ /** Veto classes — any overlap fails the rule. */
9615
+ classesExclude: array(string().min(1)).optional(),
9616
+ /** Minimum detection confidence 0–1 (fails when the record has none). */
9617
+ minConfidence: number().min(0).max(1).optional(),
9618
+ /** Admin zone membership over event `zones` / track `zonesVisited`. */
9619
+ zones: NcZoneConditionSchema.optional(),
9620
+ /** Veto zones — any hit fails the rule. */
9621
+ zonesExclude: array(string().min(1)).optional(),
9622
+ /**
9623
+ * Exact (case-insensitive) match on the record's collapsed `label`
9624
+ * (identity name / plate text / subclass).
9625
+ */
9626
+ labelEquals: array(string().min(1)).optional(),
9627
+ /**
9628
+ * Identity matcher. P1 boundary: matched against the record's collapsed
9629
+ * `label` (the identity display name propagated by the face pipeline) —
9630
+ * identity-ID matching rides in P2 when identity ids reach the record.
9631
+ */
9632
+ identities: array(string().min(1)).optional(),
9633
+ /** Fuzzy plate matcher against the record's `label` (plate text). */
9634
+ plates: NcPlateMatcherSchema.optional(),
9635
+ /**
9636
+ * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
9637
+ * Same P1 boundary: matched against the record's collapsed `label` (the
9638
+ * identity display name). A record with NO label passes (nothing to
9639
+ * exclude), unlike the include variant which fails on an absent label.
9640
+ */
9641
+ identitiesExclude: array(string().min(1)).optional(),
9642
+ /**
9643
+ * Minimum server-computed key-event importance in [0,1] (`Track.importance`).
9644
+ * TRACK-END only: importance is scored at track close, so it does not exist
9645
+ * at immediate / object-event evaluation time (see catalog `appliesTo`). At
9646
+ * close the value is threaded via the close-time info (the `Track` clone is
9647
+ * captured before the DB row is updated, so it would otherwise read stale).
9648
+ * Fails when the record carries no importance (never guess quality — the
9649
+ * `minConfidence` precedent). MVP cut: a single scalar threshold.
9650
+ */
9651
+ minImportance: number().min(0).max(1).optional(),
9652
+ /**
9653
+ * Minimum track dwell in SECONDS — `(lastSeen − firstSeen) / 1000`.
9654
+ * TRACK-END only: an `immediate` / object-event subject has no closed
9655
+ * lifespan, so a dwell condition never matches immediate delivery
9656
+ * (documented choice — the object-event record carries no `firstSeen`,
9657
+ * so dwell cannot be computed from what the subject actually carries).
9658
+ */
9659
+ minDwellSeconds: number().min(0).optional(),
9660
+ /**
9661
+ * Detection provenance filter. `any` (default / absent) matches every
9662
+ * source; otherwise the subject's source must equal it. Legacy records
9663
+ * with no stamped source are treated as `pipeline`. The union spans both
9664
+ * record kinds — object events carry `pipeline` | `onboard`, synthetic
9665
+ * tracks carry `sensor`.
9666
+ */
9667
+ source: _enum([
9668
+ "pipeline",
9669
+ "onboard",
9670
+ "sensor",
9671
+ "any"
9672
+ ]).optional(),
9673
+ /**
9674
+ * Minimum identity / plate MATCH confidence in [0,1] — DISTINCT from the
9675
+ * detector `minConfidence` (that gates the object-detection score; this
9676
+ * gates the recognition/OCR match score). Fails when the subject carries
9677
+ * no label-match confidence (never guess). TRACK-END only: the confidence
9678
+ * lives on the recognition result and reaches the subject at track close.
9679
+ *
9680
+ * What it measures precisely (plumbed at track close — the closer threads
9681
+ * the value into `NcTrackClosedInfo.labelConfidence`, the same seam as
9682
+ * `importance`): the BEST recognition match confidence observed for the
9683
+ * label the track carries at close — for a face, the peak cosine similarity
9684
+ * of the ASSIGNED identity (`FaceMatch.score`, reset on an identity switch);
9685
+ * for a plate, the peak OCR read score of the best-held plate
9686
+ * (`plateText.confidence`). When BOTH a face and a plate were recognized on
9687
+ * one track the higher of the two is used. A track that ended with no
9688
+ * confident identity/plate match carries no value, so the condition fails
9689
+ * closed for it (an un-recognized subject).
9690
+ */
9691
+ minLabelConfidence: number().min(0).max(1).optional(),
9692
+ /**
9693
+ * DEVICE-EVENT only. Raw device event-type tokens (`EventFire.eventType`,
9694
+ * e.g. a doorbell `press` / `press_long`) — matched case-insensitively
9695
+ * against the token carried on the device-event subject (extracted from the
9696
+ * event-emitter runtime slice's `lastEvent.eventType`). Fails when the
9697
+ * subject carries no token. Doorbell-pulse / passive-sensor kinds emit no
9698
+ * eventType, so gate those with {@link sensorKinds} instead.
9699
+ */
9700
+ eventTypeTokens: array(string().min(1)).optional(),
9701
+ /**
9702
+ * DEVICE-EVENT only. Sensor/control taxonomy kinds (e.g. `doorbell`,
9703
+ * `contact`, `button`, `device-event`) — matched against the persisted
9704
+ * `SensorEvent.kind` (see `sensor-event-kinds.ts`). Membership is OR.
9705
+ */
9706
+ sensorKinds: array(string().min(1)).optional(),
9707
+ /**
9708
+ * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
9709
+ * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
9710
+ * when the subject's phase does not match (a subject always carries a phase
9711
+ * on the package-event trigger).
9712
+ */
9713
+ packagePhase: _enum([
9714
+ "delivered",
9715
+ "picked-up",
9716
+ "both"
9717
+ ]).optional(),
9718
+ /**
9719
+ * PERSONAL-RULE custom zones (viewer-drawn). Inline normalized polygons
9720
+ * (MaskShape vocabulary). A record passes when its bbox overlaps ANY
9721
+ * listed polygon (ZoneEngine membership semantics). Evaluated only when
9722
+ * the subject carries a bbox; absent bbox ⇒ the condition FAILS.
9723
+ */
9724
+ customZones: array(MaskPolygonShapeSchema).optional(),
9725
+ /**
9726
+ * DEVICE-EVENT only. ZoneAnalytics occupancy edge — fires when a device's
9727
+ * (optionally zone/class-scoped) occupancy count crosses the configured
9728
+ * threshold and holds for `sustainSeconds`. Fail-closed on missing
9729
+ * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
9730
+ */
9731
+ occupancy: NcOccupancyConditionSchema.optional()
9732
+ });
9733
+ /** One delivery target: a `notification-output` Target ref + passthrough params. */
9734
+ var NcRuleTargetSchema = object({
9735
+ /** `notification-output` Target id. */
9736
+ targetId: string().min(1),
9737
+ /**
9738
+ * Per-backend passthrough. Recognized keys are mapped onto the canonical
9739
+ * Notification (`priority`, `level`, `sound`, `clickUrl`, `ttl`); the
9740
+ * degrade engine drops what the backend can't render.
9741
+ */
9742
+ params: record(string(), unknown()).optional()
9743
+ });
9744
+ /**
9745
+ * Media attachment policy (P1 still-image subset).
9746
+ * - `best` — the best AVAILABLE subject image at dispatch time (D-3).
9747
+ * - `best-matching` — the media that explains WHY the rule fired: a rule
9748
+ * matched on identities attaches the subject's `faceCrop`, one matched on
9749
+ * plates attaches the `plateCrop`; a rule with no identity/plate condition
9750
+ * (or when the specific crop is missing) degrades to `best`, then
9751
+ * `keyFrame`, then no attachment — never delaying the send. The matched
9752
+ * condition summary is frozen on the outbox row at enqueue (like the rule
9753
+ * name), so the choice never drifts from the record that fired it.
9754
+ * - `keyFrame` — the clean scene frame (no subject box).
9755
+ * - `none` — no attachment.
9756
+ */
9757
+ var NcMediaPolicySchema = object({ attach: _enum([
9758
+ "best",
9759
+ "best-matching",
9760
+ "keyFrame",
9761
+ "none"
9762
+ ]).default("best") });
9763
+ /** Throttle — cooldown survives restarts (rebuilt from the outbox on boot). */
9764
+ var NcThrottleSchema = object({
9765
+ cooldownSec: number().int().min(0).max(86400).default(60),
9766
+ /** `rule` = one shared cooldown; `rule-device` = per-camera cooldown. */
9767
+ scope: _enum(["rule", "rule-device"]).default("rule-device")
9768
+ });
9769
+ /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
9770
+ var NcRuleInputSchema = object({
9771
+ name: string().min(1).max(200),
9772
+ enabled: boolean().default(true),
9773
+ delivery: NcDeliverySchema,
9774
+ conditions: NcConditionsSchema.default({}),
9775
+ schedule: NcScheduleSchema.optional(),
9776
+ targets: array(NcRuleTargetSchema).min(1),
9777
+ media: NcMediaPolicySchema.default({ attach: "best" }),
9778
+ throttle: NcThrottleSchema.default({
9779
+ cooldownSec: 60,
9780
+ scope: "rule-device"
9781
+ }),
9782
+ /** `{{var}}` templating over camera/class/label/zones/confidence/time. */
9783
+ template: object({
9784
+ title: string().max(500).optional(),
9785
+ body: string().max(2e3).optional()
9786
+ }).optional(),
9787
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
9788
+ priority: number().int().min(1).max(5).default(3),
9789
+ /**
9790
+ * Ownership/visibility key. Absent = admin/global rule (unchanged legacy
9791
+ * behaviour, visible to all, read-only in the viewer). Present = personal
9792
+ * rule owned by this userId. Server-stamped; never trusted from a client.
9793
+ */
9794
+ ownerUserId: string().optional()
9795
+ });
9796
+ /**
9797
+ * Partial patch for `updateRule` — any subset of the input fields, plus the
9798
+ * persisted-only {@link NcRuleSchema} `disabledTargetIds` set. The latter is
9799
+ * NOT a client-authored input field (it lives on the persisted rule, not the
9800
+ * input), so it is added here explicitly to let the store's per-target opt-out
9801
+ * toggle round-trip through the shared `update` path. Viewer opt-out mutations
9802
+ * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
9803
+ * `updateRule` patch.
9804
+ */
9805
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
9806
+ /** A persisted rule. */
9807
+ var NcRuleSchema = NcRuleInputSchema.extend({
9808
+ id: string(),
9809
+ /** userId of the admin who created the rule (server-stamped caller). */
9810
+ createdBy: string(),
9811
+ createdAt: number(),
9812
+ updatedAt: number(),
9813
+ /**
9814
+ * Per-target opt-out set. A targetId here is suppressed for THIS rule at
9815
+ * send time. Only a target's OWNER may add/remove its id (server-checked
9816
+ * in `nc.setRuleTargetEnabled`). Defaults to empty.
9817
+ */
9818
+ disabledTargetIds: array(string()).default([])
9819
+ });
9820
+ var NcTestResultSchema = object({
9821
+ recordId: string(),
9822
+ recordKind: _enum([
9823
+ "object-event",
9824
+ "track",
9825
+ "device-event",
9826
+ "package-event"
9827
+ ]),
9828
+ deviceId: number(),
9829
+ timestamp: number(),
9830
+ wouldFire: boolean(),
9831
+ /** Condition id that failed (first failing group), when `wouldFire` is false. */
9832
+ failedCondition: string().optional(),
9833
+ className: string().optional(),
9834
+ label: string().optional()
9835
+ });
9836
+ var NcConditionDescriptorSchema = object({
9837
+ /** Field id inside `NcConditions` (or `'schedule'` for the rule-level group). */
9838
+ id: string(),
9839
+ group: _enum([
9840
+ "scope",
9841
+ "class",
9842
+ "zones",
9843
+ "quality",
9844
+ "label",
9845
+ "schedule",
9846
+ "device",
9847
+ "package",
9848
+ "occupancy"
9849
+ ]),
9850
+ label: string(),
9851
+ /** Editor widget the UI renders — never hardcode per-condition forms. */
9852
+ valueType: _enum([
9853
+ "deviceIdList",
9854
+ "stringList",
9855
+ "number01",
9856
+ "number",
9857
+ "sourceSelect",
9858
+ "zoneSelection",
9859
+ "zoneIdList",
9860
+ "schedule",
9861
+ "plateMatcher",
9862
+ "packagePhase",
9863
+ "polygonDraw",
9864
+ "occupancy"
9865
+ ]),
9866
+ operator: _enum([
9867
+ "in",
9868
+ "notIn",
9869
+ "anyOf",
9870
+ "allOf",
9871
+ "gte",
9872
+ "fuzzyIn",
9873
+ "withinSchedule"
9874
+ ]),
9875
+ /** Which delivery kinds the condition applies to. */
9876
+ appliesTo: array(NcDeliverySchema),
9877
+ phase: string(),
9878
+ description: string().optional()
9879
+ });
9880
+ /**
9881
+ * The delivery lifecycle status of a history row — a straight read of the
9882
+ * durable outbox row's own status (single source of truth):
9883
+ * - `pending` — enqueued, in-flight or retrying with backoff
9884
+ * - `sent` — delivered (terminal)
9885
+ * - `dead` — dead-lettered after exhausting retries / a permanent
9886
+ * backend rejection / a deleted target (terminal; carries
9887
+ * the failure `error`)
9888
+ *
9889
+ * P1 has no `suppressed-quiet-hours` / `snoozed` states — those ride the P2
9890
+ * user dimension (quiet hours / snooze) and are additive when they land.
9891
+ */
9892
+ var NcHistoryStatusSchema = _enum([
9893
+ "pending",
9894
+ "sent",
9895
+ "dead"
9896
+ ]);
9897
+ /** The evaluated record kind a history row descends from (one per trigger). */
9898
+ var NcHistoryRecordKindSchema = _enum([
9899
+ "object-event",
9900
+ "track-end",
9901
+ "device-event",
9902
+ "package-event"
9903
+ ]);
9904
+ /** Subject summary frozen on the row at fire time (survives rule/record edits). */
9905
+ var NcHistorySubjectSchema = object({
9906
+ className: string(),
9907
+ label: string().optional(),
9908
+ confidence: number().optional(),
9909
+ zones: array(string()),
9910
+ timestamp: number()
9911
+ });
9912
+ /**
9913
+ * One delivery-history row. This is a read-only VIEW over the durable
9914
+ * outbox row (single source of truth — the same row the drain loop drives;
9915
+ * NO second write path, so history can never drift from delivery state).
9916
+ * The §3.2 fields map directly: `ruleId`/`targetId`/`deviceId` are columns,
9917
+ * `eventRef` is `recordKind`+`recordId`, `timestamps` are `createdAt`
9918
+ * (fire) / `updatedAt` (last transition), `status` + `error` are the
9919
+ * lifecycle. `ruleName` + `subject` are the intent snapshot frozen at
9920
+ * enqueue. `userId?` (per-recipient history) is P2 — no user dimension in
9921
+ * P1 (admin scope only).
9922
+ */
9923
+ var NcHistoryEntrySchema = object({
9924
+ /** Outbox row id — the stable dedup id `ruleId:dedupRef:targetId`. */
9925
+ id: string(),
9926
+ ruleId: string(),
9927
+ /** Rule name frozen at fire time (outlives a later rename / delete). */
9928
+ ruleName: string(),
9929
+ /** The rule urgency/trigger that produced this delivery. */
9930
+ delivery: NcDeliverySchema,
9931
+ targetId: string(),
9932
+ deviceId: number(),
9933
+ recordKind: NcHistoryRecordKindSchema,
9934
+ /** Event / track ref of the evaluated record (§3.2 `eventRef`). */
9935
+ recordId: string(),
9936
+ /** Present for track-scoped deliveries (object-event / track-end). */
9937
+ trackId: string().optional(),
9938
+ status: NcHistoryStatusSchema,
9939
+ /** Delivery attempts made so far. */
9940
+ attempts: number().int(),
9941
+ /** Fire time (outbox enqueue). */
9942
+ createdAt: number(),
9943
+ /** Last transition time (terminal for sent / dead). */
9944
+ updatedAt: number(),
9945
+ /** Failure detail — present on a `dead` row. */
9946
+ error: string().optional(),
9947
+ subject: NcHistorySubjectSchema
9948
+ });
9949
+ /**
9950
+ * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
9951
+ * AND; absent = unbounded on that axis. `since`/`until` bound the fire time
9952
+ * (`createdAt`, epoch ms, inclusive). `limit` is clamped to
9953
+ * {@link NC_HISTORY_LIMIT_MAX}. `userId` (per-recipient filtering) is P2.
9954
+ */
9955
+ var NcHistoryFilterSchema = object({
9956
+ ruleId: string().optional(),
9957
+ deviceId: number().optional(),
9958
+ status: NcHistoryStatusSchema.optional(),
9959
+ since: number().optional(),
9960
+ until: number().optional(),
9961
+ limit: number().int().min(1).max(500).default(100)
9962
+ });
9963
+ 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 }), {
9964
+ kind: "mutation",
9965
+ auth: "admin",
9966
+ caller: "required"
9967
+ }), method(object({
9968
+ ruleId: string(),
9969
+ patch: NcRulePatchSchema
9970
+ }), object({ rule: NcRuleSchema }), {
9971
+ kind: "mutation",
9972
+ auth: "admin",
9973
+ caller: "required"
9974
+ }), method(object({ ruleId: string() }), object({ success: literal(true) }), {
9975
+ kind: "mutation",
9976
+ auth: "admin"
9977
+ }), method(object({
9978
+ ruleId: string(),
9979
+ enabled: boolean()
9980
+ }), object({ success: literal(true) }), {
9981
+ kind: "mutation",
9982
+ auth: "admin"
9983
+ }), method(object({
9984
+ rule: NcRuleInputSchema,
9985
+ lookbackMinutes: number().int().min(1).max(1440).default(60)
9986
+ }), object({ results: array(NcTestResultSchema) }), {
9987
+ kind: "mutation",
9988
+ auth: "admin"
9989
+ }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
9990
+ /**
9991
+ * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
9992
+ *
9993
+ * Spec: `docs/superpowers/specs/2026-07-24-nc-occupancy-timelapse-design.md`
9994
+ * §3.2/§3.3.
9995
+ *
9996
+ * Deliberately NOT a capability definition and NOT an `NcRule`:
9997
+ * - Every `NcDelivery` member is a *persisted-pipeline-record* trigger. A
9998
+ * timelapse fires on a SCHEDULE WINDOW BOUNDARY, evaluates no pipeline
9999
+ * record, and produces a video it assembled itself — so it rides no
10000
+ * delivery-enum member (the enum is frozen) and no cap method. This file is
10001
+ * a plain typed schema; it does NOT go through `npm run codegen`.
10002
+ * - It shares only the delivery leg (`notification-output.send`) and the
10003
+ * persistence/ownership patterns with the Notification Center, reusing
10004
+ * {@link NcScheduleSchema} (weekly windows, midnight-crossing, invertible)
10005
+ * and {@link NcRuleTargetSchema} (target ref + passthrough params).
10006
+ *
10007
+ * Ownership is SERVER-DERIVED. `ownerUserId` / `createdBy` / `createdAt` /
10008
+ * `updatedAt` / `id` / `lastGeneratedAt` live on the PERSISTED rule only —
10009
+ * {@link TimelapseRuleInputSchema} and {@link TimelapseRulePatchSchema} do not
10010
+ * carry them, so a forged client payload can never claim or re-own a rule
10011
+ * (Zod strips unknown keys). The store stamps them from the resolved caller.
10012
+ */
10013
+ /** `{{var}}` templating over camera/rule/time — same vocabulary as `NcRule`. */
10014
+ var TimelapseTemplateSchema = object({
10015
+ title: string().max(500).optional(),
10016
+ body: string().max(2e3).optional()
10017
+ });
10018
+ var NameField = string().min(1).max(200);
10019
+ var DeviceIdsField = array(number()).min(1);
10020
+ var CadenceSecField = number().int().min(2).max(3600);
10021
+ var FramerateField = number().int().min(1).max(60);
10022
+ var TargetsField = array(NcRuleTargetSchema).min(1);
10023
+ var PriorityField = number().int().min(1).max(5);
10024
+ /**
10025
+ * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
10026
+ * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
10027
+ * here (see the ownership note above).
10028
+ */
10029
+ var TimelapseRuleInputSchema = object({
10030
+ name: NameField,
10031
+ enabled: boolean().default(true),
10032
+ /** Cameras sampled by this rule — one scratch dir + one artifact per device. */
10033
+ deviceIds: DeviceIdsField,
10034
+ /**
10035
+ * Activation window(s). REQUIRED (unlike `NcRule`, where an absent schedule
10036
+ * means "always active"): a timelapse is defined by its window boundaries —
10037
+ * open clears the scratch, close assembles and delivers.
10038
+ */
10039
+ schedule: NcScheduleSchema,
10040
+ /** Force-snapshot cadence inside the window, seconds (predecessor parity). */
10041
+ cadenceSec: CadenceSecField.default(15),
10042
+ /** Output frames per second of the assembled mp4 (predecessor parity). */
10043
+ framerate: FramerateField.default(10),
10044
+ /** `notification-output` targets the finished video/thumbnail is sent to. */
10045
+ targets: TargetsField,
10046
+ template: TimelapseTemplateSchema.optional(),
10047
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
10048
+ priority: PriorityField.default(3)
10049
+ });
10050
+ object({
10051
+ name: NameField.optional(),
10052
+ enabled: boolean().optional(),
10053
+ deviceIds: DeviceIdsField.optional(),
10054
+ schedule: NcScheduleSchema.optional(),
10055
+ cadenceSec: CadenceSecField.optional(),
10056
+ framerate: FramerateField.optional(),
10057
+ targets: TargetsField.optional(),
10058
+ template: TimelapseTemplateSchema.nullable().optional(),
10059
+ priority: PriorityField.optional()
10060
+ });
10061
+ TimelapseRuleInputSchema.extend({
10062
+ id: string(),
10063
+ /**
10064
+ * Ownership/visibility key. Absent = admin/global rule (visible to all).
10065
+ * Present = personal rule owned by this userId. Server-stamped from the
10066
+ * resolved caller; never trusted from a client payload.
10067
+ */
10068
+ ownerUserId: string().optional(),
10069
+ /**
10070
+ * Epoch-ms of the last successful generation — the 1-hour re-generation
10071
+ * guard's durable state (predecessor parity). Absent = never generated.
10072
+ */
10073
+ lastGeneratedAt: number().optional(),
10074
+ /** userId of the caller who created the rule (server-stamped). */
10075
+ createdBy: string(),
10076
+ createdAt: number(),
10077
+ updatedAt: number()
10078
+ });
10079
+ /**
9385
10080
  * Generic device-level status snapshot. Auto-registered by `BaseDevice`
9386
10081
  * for every device, regardless of provider — the kernel needs a uniform
9387
10082
  * cap-keyed slice for the basic device flags every consumer expects to
@@ -12534,6 +13229,22 @@ var CameraMetricsSchema = object({
12534
13229
  ])
12535
13230
  });
12536
13231
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
13232
+ /**
13233
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
13234
+ * within the frame, so the executor can re-cut a leaf child ROI at native
13235
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
13236
+ */
13237
+ var NativeCropRefSchema = object({
13238
+ /** Handle keying the retained native surface (node-pinned to its owner). */
13239
+ handle: FrameHandleSchema,
13240
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
13241
+ cropFrameSpace: object({
13242
+ x: number(),
13243
+ y: number(),
13244
+ w: number(),
13245
+ h: number()
13246
+ })
13247
+ });
12537
13248
  var ModelFormatSchema$1 = _enum([
12538
13249
  "onnx",
12539
13250
  "coreml",
@@ -12809,7 +13520,22 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
12809
13520
  * Omitted ⇒ the runner's default device (current single-engine
12810
13521
  * behaviour). Selects WHICH device pool of the node runs the call.
12811
13522
  */
12812
- deviceKey: string().optional()
13523
+ deviceKey: string().optional(),
13524
+ /**
13525
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
13526
+ * when the parent crop was resolved from the frame's retained NATIVE
13527
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
13528
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
13529
+ * resolution from that surface — the SAME quality path faces already
13530
+ * had — instead of the downscaled parent tile. `handle` keys the native
13531
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
13532
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
13533
+ * the executor's crop-normalized child ROI back into frame-normalized
13534
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
13535
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
13536
+ * (today's behaviour on the fallback path).
13537
+ */
13538
+ nativeCropRef: NativeCropRefSchema.optional()
12813
13539
  }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
12814
13540
  engine: PipelineEngineChoiceSchema.optional(),
12815
13541
  steps: array(PipelineStepInputSchema).min(1),
@@ -13058,7 +13784,11 @@ var DetailResultSchema = object({
13058
13784
  bbox: NativeCropBboxSchema.optional(),
13059
13785
  embedding: string().optional(),
13060
13786
  label: string().optional(),
13061
- alignedCropJpeg: string().optional()
13787
+ alignedCropJpeg: string().optional(),
13788
+ /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
13789
+ * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
13790
+ * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
13791
+ nativeFaceShortSidePx: number().optional()
13062
13792
  });
13063
13793
  /**
13064
13794
  * Per-camera tunable ranges + defaults. Single source of truth used
@@ -13072,6 +13802,12 @@ var motionCooldownMsField = {
13072
13802
  default: 3e4,
13073
13803
  step: 500
13074
13804
  };
13805
+ var maxSessionHoldMsField = {
13806
+ min: 0,
13807
+ max: 6e5,
13808
+ default: 12e4,
13809
+ step: 5e3
13810
+ };
13075
13811
  var motionFpsField = {
13076
13812
  min: 1,
13077
13813
  max: 30,
@@ -13219,6 +13955,19 @@ var RunnerCameraConfigSchema = object({
13219
13955
  "on-motion"
13220
13956
  ]).default("always-on"),
13221
13957
  motionCooldownMs: number().min(motionCooldownMsField.min).default(motionCooldownMsField.default),
13958
+ /**
13959
+ * Orchestrator-side on-motion session-hold cap (ms). While an on-motion
13960
+ * detection session is active and ≥1 confirmed non-stationary track is
13961
+ * still live, the orchestrator keeps the session open past
13962
+ * `motionCooldownMs` (a slowly-moving subject can stop re-triggering the
13963
+ * camera's VMD yet is still being tracked frame-to-frame) — up to this many
13964
+ * ms since the session opened, after which it closes regardless. `0`
13965
+ * disables the hold (legacy cooldown-only teardown). Not consumed by the
13966
+ * runner itself — carried here so it shares the per-camera device-settings
13967
+ * surface with `motionCooldownMs`; the orchestrator reads it off the
13968
+ * resolved `CameraDetectionConfig`.
13969
+ */
13970
+ maxSessionHoldMs: number().min(maxSessionHoldMsField.min).max(maxSessionHoldMsField.max).optional(),
13222
13971
  motionFps: number().min(motionFpsField.min).max(motionFpsField.max).default(motionFpsField.default),
13223
13972
  detectionFps: number().min(detectionFpsField.min).max(detectionFpsField.max).default(detectionFpsField.default),
13224
13973
  motionStreamId: string(),
@@ -13308,7 +14057,7 @@ var RunnerCameraConfigSchema = object({
13308
14057
  */
13309
14058
  inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
13310
14059
  });
13311
- motionFpsField.min, motionFpsField.max, motionFpsField.step, motionFpsField.default, detectionFpsField.min, detectionFpsField.max, detectionFpsField.step, detectionFpsField.default, motionCooldownMsField.min, motionCooldownMsField.max, motionCooldownMsField.step, motionCooldownMsField.default, occupancyRecheckSecField.min, occupancyRecheckSecField.max, occupancyRecheckSecField.step, occupancyRecheckSecField.default, occupancyRecheckFramesField.min, occupancyRecheckFramesField.max, occupancyRecheckFramesField.step, occupancyRecheckFramesField.default;
14060
+ motionFpsField.min, motionFpsField.max, motionFpsField.step, motionFpsField.default, detectionFpsField.min, detectionFpsField.max, detectionFpsField.step, detectionFpsField.default, motionCooldownMsField.min, motionCooldownMsField.max, motionCooldownMsField.step, motionCooldownMsField.default, maxSessionHoldMsField.min, maxSessionHoldMsField.max, maxSessionHoldMsField.step, maxSessionHoldMsField.default, occupancyRecheckSecField.min, occupancyRecheckSecField.max, occupancyRecheckSecField.step, occupancyRecheckSecField.default, occupancyRecheckFramesField.min, occupancyRecheckFramesField.max, occupancyRecheckFramesField.step, occupancyRecheckFramesField.default;
13312
14061
  /**
13313
14062
  * Runtime load summary returned by `getLocalLoad`. Used by the orchestrator's
13314
14063
  * load-balancing levels (L2 capacity-based, L3 hardware-aware) to decide
@@ -13524,86 +14273,25 @@ var motionTriggerCapability = {
13524
14273
  runtimeState: MotionTriggerRuntimeStateSchema
13525
14274
  };
13526
14275
  /**
13527
- * Shared geometry vocabulary for on-frame shape caps privacy-mask,
13528
- * motion-zones, and the detection zones/lines editor all speak this one
13529
- * language so a single drawing-plane editor and the providers stay
13530
- * decoupled from each cap's storage.
13531
- *
13532
- * All coordinates are normalized 0..1 of the camera frame (top-left
13533
- * origin). Each cap composes the SUBSET of shape kinds it supports and
13534
- * advertises it via `supportedShapes` in its `getOptions`.
14276
+ * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
14277
+ * on-camera motion-detection mask is a single `grid` region (a row-major
14278
+ * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
14279
+ * a region keeps one drawing-plane model across all geometry caps.
13535
14280
  */
13536
- /** A normalized 0..1 point (top-left origin). */
13537
- var MaskPointSchema = object({
13538
- x: number(),
13539
- y: number()
13540
- });
13541
- /** Axis-aligned rectangle (normalized 0..1). */
13542
- var MaskRectShapeSchema = object({
13543
- kind: literal("rect"),
13544
- x: number(),
13545
- y: number(),
13546
- width: number(),
13547
- height: number()
14281
+ /** A motion-zone region exactly one boolean cell grid today. */
14282
+ var MotionZoneRegionSchema = object({
14283
+ id: number(),
14284
+ enabled: boolean(),
14285
+ shape: MaskGridShapeSchema
13548
14286
  });
13549
- /** Free polygon an ordered list of normalized vertices (≥3). */
13550
- var MaskPolygonShapeSchema = object({
13551
- kind: literal("polygon"),
13552
- points: array(MaskPointSchema)
13553
- });
13554
- /** Boolean cell grid row-major, length === gridWidth*gridHeight. */
13555
- var MaskGridShapeSchema = object({
13556
- kind: literal("grid"),
13557
- gridWidth: number(),
13558
- gridHeight: number(),
13559
- cells: array(boolean())
13560
- });
13561
- discriminatedUnion("kind", [
13562
- MaskRectShapeSchema,
13563
- MaskPolygonShapeSchema,
13564
- MaskGridShapeSchema,
13565
- object({
13566
- kind: literal("line"),
13567
- points: array(MaskPointSchema)
13568
- })
13569
- ]);
13570
- /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
13571
- var MaskShapeKindSchema = _enum([
13572
- "rect",
13573
- "polygon",
13574
- "grid",
13575
- "line"
13576
- ]);
13577
- /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
13578
- var MaskPolygonVerticesSchema = object({
13579
- min: number(),
13580
- max: number()
13581
- });
13582
- /** Grid dimensions when a cap supports 'grid'. */
13583
- var MaskGridDimsSchema = object({
13584
- width: number(),
13585
- height: number()
13586
- });
13587
- /**
13588
- * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
13589
- * on-camera motion-detection mask is a single `grid` region (a row-major
13590
- * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
13591
- * a region keeps one drawing-plane model across all geometry caps.
13592
- */
13593
- /** A motion-zone region — exactly one boolean cell grid today. */
13594
- var MotionZoneRegionSchema = object({
13595
- id: number(),
13596
- enabled: boolean(),
13597
- shape: MaskGridShapeSchema
13598
- });
13599
- /** Current on-camera motion-detection state — master enable + sensitivity +
13600
- * the grid region(s). */
13601
- var MotionZoneStatusSchema = object({
13602
- enabled: boolean(),
13603
- sensitivity: number(),
13604
- /** Grid region(s). Today exactly one `grid` shape. */
13605
- regions: array(MotionZoneRegionSchema),
13606
- lastFetchedAt: number()
14287
+ /** Current on-camera motion-detection state master enable + sensitivity +
14288
+ * the grid region(s). */
14289
+ var MotionZoneStatusSchema = object({
14290
+ enabled: boolean(),
14291
+ sensitivity: number(),
14292
+ /** Grid region(s). Today exactly one `grid` shape. */
14293
+ regions: array(MotionZoneRegionSchema),
14294
+ lastFetchedAt: number()
13607
14295
  });
13608
14296
  /** Per-camera availability — grid dims are fixed per camera model; the UI
13609
14297
  * sizes its editor from `grid`. */
@@ -16854,94 +17542,6 @@ var EnrichedWidgetMetadataSchema = WidgetMetadataSchema.extend({
16854
17542
  bundleUrl: string()
16855
17543
  });
16856
17544
  method(_void(), array(EnrichedWidgetMetadataSchema).readonly());
16857
- var NotificationRuleConditionsSchema = object({
16858
- deviceIds: array(number()).readonly().optional(),
16859
- classNames: array(string()).readonly().optional(),
16860
- zoneIds: array(string()).readonly().optional(),
16861
- minConfidence: number().optional(),
16862
- source: _enum([
16863
- "pipeline",
16864
- "onboard",
16865
- "any"
16866
- ]).optional(),
16867
- schedule: object({
16868
- days: array(number()).readonly(),
16869
- startHour: number(),
16870
- endHour: number()
16871
- }).optional(),
16872
- cooldownSeconds: number().optional(),
16873
- minDwellSeconds: number().optional(),
16874
- /** Match against `event.data.eventType` token (e.g. `'press_long'`). When non-empty, only events
16875
- * carrying a matching `data.eventType` string pass this condition. Rules without this field are
16876
- * unaffected (back-compat). Distinct from `rule.eventTypes` which holds EventCategory strings. */
16877
- eventTypeTokens: array(string()).readonly().optional(),
16878
- /** Match detections whose CLIP image embedding is semantically similar to this free-text
16879
- * description. Requires the embedding-encoder cap to have pre-warmed the text vector.
16880
- * `minSimilarity` is the cosine similarity threshold in [0, 1]. */
16881
- clipDescription: object({
16882
- text: string().min(1),
16883
- minSimilarity: number().min(0).max(1)
16884
- }).optional(),
16885
- /** Match events whose recognized-entity label (face identity name or plate
16886
- * vehicle name, propagated onto `event.data.label`) is one of these values.
16887
- * Empty/absent → unaffected (back-compat). Enables "notify me when <named
16888
- * vehicle/person> is seen". */
16889
- labels: array(string()).readonly().optional()
16890
- });
16891
- var NotificationRuleTemplateSchema = object({
16892
- title: string(),
16893
- body: string(),
16894
- imageMode: _enum([
16895
- "crop",
16896
- "annotated",
16897
- "full",
16898
- "none"
16899
- ])
16900
- });
16901
- var NotificationRuleSchema = object({
16902
- id: string(),
16903
- name: string(),
16904
- enabled: boolean(),
16905
- eventTypes: array(string()).readonly(),
16906
- conditions: NotificationRuleConditionsSchema,
16907
- outputs: array(string()).readonly(),
16908
- template: NotificationRuleTemplateSchema.optional(),
16909
- priority: _enum([
16910
- "low",
16911
- "normal",
16912
- "high",
16913
- "critical"
16914
- ])
16915
- });
16916
- var NotificationTestResultSchema = object({
16917
- ruleId: string(),
16918
- eventId: string(),
16919
- timestamp: number(),
16920
- wouldFire: boolean(),
16921
- reason: string().optional()
16922
- });
16923
- var NotificationHistoryEntrySchema = object({
16924
- id: string(),
16925
- ruleId: string(),
16926
- ruleName: string(),
16927
- eventId: string(),
16928
- timestamp: number(),
16929
- outputs: array(string()).readonly(),
16930
- success: boolean(),
16931
- error: string().optional(),
16932
- deviceId: number().optional()
16933
- });
16934
- var NotificationHistoryFilterSchema = object({
16935
- ruleId: string().optional(),
16936
- deviceId: number().optional(),
16937
- from: number().optional(),
16938
- to: number().optional(),
16939
- limit: number().optional()
16940
- });
16941
- 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({
16942
- ruleId: string(),
16943
- lookbackMinutes: number()
16944
- }), object({ results: array(NotificationTestResultSchema).readonly() }), { kind: "mutation" }), method(object({ filter: NotificationHistoryFilterSchema.optional() }), object({ entries: array(NotificationHistoryEntrySchema).readonly() }));
16945
17545
  /**
16946
17546
  * Alerts capability — collection-based internal alert system.
16947
17547
  *
@@ -17128,88 +17728,54 @@ method(object({
17128
17728
  password: string()
17129
17729
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
17130
17730
  /**
17131
- * `login-method` collection cap through which auth addons contribute
17132
- * their pre-auth login surfaces to the login page. This is the SINGLE,
17133
- * generic mechanism that supersedes the dead `auth.listProviders` reader:
17134
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
17135
- * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17136
- * procedure aggregates them for the unauthenticated login page.
17137
- *
17138
- * A contribution is a discriminated union on `kind`:
17139
- *
17140
- * - `redirect` — a declarative button. The login page renders a generic
17141
- * button that navigates to `startUrl` (an addon-owned HTTP route).
17142
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17143
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
17144
- * login page needs NO change.
17145
- *
17146
- * - `widget` — a Module-Federation widget the login page mounts (via
17147
- * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
17148
- * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
17149
- * mechanism kept for future use; no shipped addon uses it on the login
17150
- * page (the passkey ceremony below runs natively in the shell instead).
17151
- *
17152
- * - `passkey` — a declarative WebAuthn ceremony the shell renders
17153
- * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
17154
- * a remotely-loaded bundle). Carries the addon's effective `rpId` /
17155
- * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
17156
- * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
17157
- * fetching any remote code pre-auth. Contribution stays unconditional —
17158
- * enrollment state is never leaked pre-auth; visibility is a shell
17159
- * decision.
17160
- *
17161
- * Every contribution carries a `stage`:
17162
- * - `primary` — shown on the first credentials screen (OIDC /
17163
- * magic-link buttons; a future usernameless passkey).
17164
- * - `second-factor` — shown AFTER the password leg, gated on the
17165
- * returned `factors` (passkey-as-2FA today).
17166
- *
17167
- * `mount: skip` — the cap is read server-side by the core auth router
17168
- * (`registry.getCollection('login-method')`), never mounted as its own
17169
- * tRPC router.
17731
+ * A live terminal session hosted by the provider addon. Output and input do
17732
+ * NOT flow through the capability they use the addon data plane
17733
+ * (`GET /addon/terminal/<id>/out` SSE, `POST /addon/terminal/<id>/in`) because
17734
+ * terminal output must be ordered and lossless. The event bus is telemetry and
17735
+ * may drop chunks ([D8]), and a dropped chunk desynchronises the vt parser
17736
+ * permanently until a full repaint. The capability owns only lifecycle.
17170
17737
  */
17171
- /** When a login method renders in the two-phase login flow. */
17172
- var LoginStageEnum = _enum(["primary", "second-factor"]);
17173
- /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
17174
- var LoginMethodContributionSchema = discriminatedUnion("kind", [
17175
- object({
17176
- kind: literal("redirect"),
17177
- /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
17178
- id: string(),
17179
- /** Operator-facing button label. */
17180
- label: string(),
17181
- /** lucide-react icon name. */
17182
- icon: string().optional(),
17183
- /** Addon-owned HTTP route the button navigates to (GET). */
17184
- startUrl: string(),
17185
- stage: LoginStageEnum
17186
- }),
17187
- object({
17188
- kind: literal("widget"),
17189
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
17190
- id: string(),
17191
- /** Owning addon id — drives the public bundle URL + the MF namespace. */
17192
- addonId: string(),
17193
- /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
17194
- bundle: string(),
17195
- /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
17196
- remote: WidgetRemoteSchema,
17197
- stage: LoginStageEnum
17198
- }),
17199
- object({
17200
- kind: literal("passkey"),
17201
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
17202
- id: string(),
17203
- /** Operator-facing button label. */
17204
- label: string(),
17205
- stage: LoginStageEnum,
17206
- /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
17207
- rpId: string(),
17208
- /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
17209
- origin: string().nullable()
17210
- })
17211
- ]);
17212
- method(_void(), array(LoginMethodContributionSchema).readonly());
17738
+ var TerminalSessionInfoSchema = object({
17739
+ /** Opaque session id minted by the provider on `openSession`. */
17740
+ sessionId: string(),
17741
+ /** The pre-declared profile this session runs (never a free-form command). */
17742
+ profileId: string(),
17743
+ /** Human-readable profile label for the UI session list. */
17744
+ label: string(),
17745
+ cols: number().int().positive(),
17746
+ rows: number().int().positive(),
17747
+ /** ms-epoch the session's pty was spawned. */
17748
+ startedAt: number()
17749
+ });
17750
+ /**
17751
+ * A profile the operator may open — a pre-declared, allowlisted program
17752
+ * (`monitor` → `btm`). The capability accepts only these ids; a free-form
17753
+ * command string would be remote code execution as the server's user, so it is
17754
+ * deliberately not part of the contract.
17755
+ */
17756
+ var TerminalProfileInfoSchema = object({
17757
+ profileId: string(),
17758
+ label: string(),
17759
+ description: string().optional()
17760
+ });
17761
+ method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(TerminalSessionInfoSchema).readonly(), { auth: "admin" }), method(object({
17762
+ profileId: string(),
17763
+ cols: number().int().positive(),
17764
+ rows: number().int().positive()
17765
+ }), TerminalSessionInfoSchema, {
17766
+ kind: "mutation",
17767
+ auth: "admin"
17768
+ }), method(object({
17769
+ sessionId: string(),
17770
+ cols: number().int().positive(),
17771
+ rows: number().int().positive()
17772
+ }), _void(), {
17773
+ kind: "mutation",
17774
+ auth: "admin"
17775
+ }), method(object({ sessionId: string() }), _void(), {
17776
+ kind: "mutation",
17777
+ auth: "admin"
17778
+ });
17213
17779
  /**
17214
17780
  * Orchestrator-side destination metadata. The orchestrator computes
17215
17781
  * `id = <addonId>:<subId>` from its provider lookup so consumers
@@ -17311,11 +17877,53 @@ var LocationStatSchema = object({
17311
17877
  fileCount: number(),
17312
17878
  present: boolean()
17313
17879
  });
17880
+ /**
17881
+ * A backup schedule — the N:M "entry" that binds one cron cadence to a
17882
+ * SET of destination locations. Supersedes the per-location cron on
17883
+ * `BackupDestinationPolicy`: an operator creates a schedule, picks the
17884
+ * `backups` locations it should write to, and the orchestrator fans a
17885
+ * single archive out to all of them when the cron fires.
17886
+ *
17887
+ * `retentionCount` is per-schedule (D-decision 2026-07-28): every
17888
+ * location targeted by this schedule keeps this many archives from
17889
+ * this schedule's runs.
17890
+ *
17891
+ * `dataSources` optionally narrows which top-level state locations
17892
+ * (db, addons, tls, …) are archived; omitted = the orchestrator's
17893
+ * default full set.
17894
+ */
17895
+ var BackupScheduleSchema = object({
17896
+ /** Stable id. Generated by the orchestrator on first upsert if absent. */
17897
+ id: string(),
17898
+ /** Operator-facing display name. */
17899
+ label: string(),
17900
+ /** 5-field POSIX cron. Empty = disabled cadence (kept for editing). */
17901
+ cron: string(),
17902
+ /** Master on/off toggle for the whole schedule. */
17903
+ enabled: boolean(),
17904
+ /** `backups`-location ids this schedule writes to (fan-out set). */
17905
+ locationIds: array(string()).readonly(),
17906
+ /** Archives kept per targeted location for this schedule. */
17907
+ retentionCount: number().int().min(1).max(1e3),
17908
+ /** Optional subset of source locations to include; omitted = all. */
17909
+ dataSources: array(string()).readonly().optional(),
17910
+ /** ms-epoch of last successful run. */
17911
+ lastRunAt: number().optional(),
17912
+ /** ms-epoch of next computed firing (read-only, filled on list). */
17913
+ nextRunAt: number().optional()
17914
+ });
17314
17915
  method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }), method(object({
17315
17916
  /** Subset of registered `backup-destination` addon ids to write to. */
17316
17917
  destinations: array(string()).optional(),
17317
17918
  locations: array(string()).optional(),
17318
- label: string().optional()
17919
+ label: string().optional(),
17920
+ /**
17921
+ * Per-run retention override applied to every targeted
17922
+ * destination. Used by schedule-driven runs (per-entry
17923
+ * retention). Omitted = each destination's own policy
17924
+ * retention (manual runs).
17925
+ */
17926
+ retentionCount: number().int().min(1).max(1e3).optional()
17319
17927
  }).optional(), array(BackupEntrySchema).readonly(), {
17320
17928
  kind: "mutation",
17321
17929
  auth: "admin"
@@ -17364,7 +17972,21 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
17364
17972
  ok: boolean(),
17365
17973
  error: string().optional(),
17366
17974
  nextRuns: array(number()).readonly()
17367
- }));
17975
+ })), method(_void(), array(BackupScheduleSchema).readonly(), { auth: "admin" }), method(object({
17976
+ id: string().optional(),
17977
+ label: string(),
17978
+ cron: string(),
17979
+ enabled: boolean(),
17980
+ locationIds: array(string()).readonly(),
17981
+ retentionCount: number().int().min(1).max(1e3),
17982
+ dataSources: array(string()).readonly().optional()
17983
+ }), BackupScheduleSchema, {
17984
+ kind: "mutation",
17985
+ auth: "admin"
17986
+ }), method(object({ id: string() }), _void(), {
17987
+ kind: "mutation",
17988
+ auth: "admin"
17989
+ });
17368
17990
  /**
17369
17991
  * `broker` — unified pub/sub broker registry, system-scoped collection.
17370
17992
  *
@@ -18620,865 +19242,948 @@ method(_void(), array(string()).readonly(), { auth: "admin" }), method(object({
18620
19242
  kind: "mutation",
18621
19243
  auth: "admin"
18622
19244
  });
18623
- var LogLevelSchema = _enum([
18624
- "debug",
18625
- "info",
18626
- "warn",
18627
- "error"
18628
- ]);
18629
- var LogEntrySchema = object({
18630
- timestamp: date(),
18631
- level: LogLevelSchema,
18632
- scope: array(string()),
18633
- message: string(),
18634
- meta: record(string(), unknown()).optional(),
18635
- tags: record(string(), string()).optional()
19245
+ /**
19246
+ * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
19247
+ * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
19248
+ * caps stay wire-compatible without a circular cap→cap import.
19249
+ *
19250
+ * Errors are a discriminated-union RESULT, never thrown: the shape survives
19251
+ * every transport tier structurally, and failed calls still write usage rows.
19252
+ * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
19253
+ */
19254
+ var LlmUsageSchema = object({
19255
+ inputTokens: number(),
19256
+ outputTokens: number()
18636
19257
  });
18637
- method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18638
- scope: array(string()).optional(),
18639
- level: LogLevelSchema.optional(),
18640
- since: date().optional(),
18641
- until: date().optional(),
18642
- limit: number().optional(),
18643
- tags: record(string(), string()).optional()
18644
- }), array(LogEntrySchema).readonly());
18645
- var CpuBreakdownSchema = object({
18646
- total: number(),
18647
- user: number(),
18648
- system: number(),
18649
- irq: number(),
18650
- nice: number(),
18651
- loadAvg: tuple([
18652
- number(),
18653
- number(),
18654
- number()
18655
- ]),
18656
- cores: number()
18657
- });
18658
- var MemoryInfoSchema = object({
18659
- percent: number(),
18660
- totalBytes: number(),
18661
- usedBytes: number(),
18662
- availableBytes: number(),
18663
- swapUsedBytes: number(),
18664
- swapTotalBytes: number()
18665
- });
18666
- var DiskIoSnapshotSchema = object({
18667
- readBytes: number(),
18668
- writeBytes: number(),
18669
- readOps: number(),
18670
- writeOps: number(),
18671
- timestampMs: number()
18672
- });
18673
- var NetworkIoSnapshotSchema = object({
18674
- rxBytes: number(),
18675
- txBytes: number(),
18676
- rxPackets: number(),
18677
- txPackets: number(),
18678
- rxErrors: number(),
18679
- txErrors: number(),
18680
- timestampMs: number()
18681
- });
18682
- var MetricsGpuInfoSchema = object({
18683
- utilization: number(),
19258
+ var LlmErrorCodeSchema = _enum([
19259
+ "timeout",
19260
+ "rate-limited",
19261
+ "auth",
19262
+ "refusal",
19263
+ "bad-request",
19264
+ "unavailable",
19265
+ "no-profile",
19266
+ "budget-exceeded",
19267
+ "adapter-error"
19268
+ ]);
19269
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
19270
+ ok: literal(true),
19271
+ text: string(),
18684
19272
  model: string(),
18685
- memoryUsedBytes: number(),
18686
- memoryTotalBytes: number(),
18687
- temperature: number().nullable()
18688
- });
18689
- var ProcessResourceInfoSchema = object({
18690
- openFds: number(),
18691
- threadCount: number(),
18692
- activeHandles: number(),
18693
- activeRequests: number()
18694
- });
18695
- var PressureAvgsSchema = object({
18696
- avg10: number(),
18697
- avg60: number(),
18698
- avg300: number()
19273
+ usage: LlmUsageSchema,
19274
+ truncated: boolean(),
19275
+ latencyMs: number()
19276
+ }), object({
19277
+ ok: literal(false),
19278
+ code: LlmErrorCodeSchema,
19279
+ message: string(),
19280
+ retryAfterMs: number().optional()
19281
+ })]);
19282
+ /**
19283
+ * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
19284
+ * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
19285
+ * notification-output.cap.ts:27-31 precedents).
19286
+ */
19287
+ var LlmImageSchema = object({
19288
+ bytes: _instanceof(Uint8Array),
19289
+ mimeType: string()
18699
19290
  });
18700
- var PressureInfoSchema = object({
18701
- some: PressureAvgsSchema,
18702
- full: PressureAvgsSchema.nullable()
19291
+ var LlmGenerateBaseInputSchema = object({
19292
+ /** Collection routing (the notification-output posture). */
19293
+ addonId: string().optional(),
19294
+ /** Explicit profile; else the resolution chain (spec §3). */
19295
+ profileId: string().optional(),
19296
+ /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
19297
+ consumer: string(),
19298
+ system: string().optional(),
19299
+ /** v1: single-turn. `messages[]` is a v2 additive field. */
19300
+ prompt: string(),
19301
+ /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
19302
+ jsonSchema: record(string(), unknown()).optional(),
19303
+ /** Per-call override of the profile default. */
19304
+ maxTokens: number().int().positive().optional(),
19305
+ temperature: number().optional()
18703
19306
  });
18704
- var SystemResourceSnapshotSchema = object({
18705
- cpu: CpuBreakdownSchema,
18706
- memory: MemoryInfoSchema,
18707
- gpu: MetricsGpuInfoSchema.nullable(),
18708
- network: NetworkIoSnapshotSchema,
18709
- disk: DiskIoSnapshotSchema,
18710
- pressure: object({
18711
- cpu: PressureInfoSchema.nullable(),
18712
- memory: PressureInfoSchema.nullable(),
18713
- io: PressureInfoSchema.nullable()
19307
+ /**
19308
+ * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
19309
+ * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
19310
+ * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
19311
+ * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
19312
+ * this only through the `llm` cap's methods.
19313
+ *
19314
+ * One running llama-server child per node in v1 (models are RAM-heavy).
19315
+ * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
19316
+ * watchdog — operator decision #3).
19317
+ */
19318
+ var ManagedModelRefSchema = discriminatedUnion("kind", [
19319
+ object({
19320
+ kind: literal("catalog"),
19321
+ catalogId: string()
18714
19322
  }),
18715
- process: ProcessResourceInfoSchema,
18716
- cpuTemperature: number().nullable(),
18717
- timestampMs: number()
18718
- });
18719
- var DiskSpaceInfoSchema = object({
18720
- path: string(),
18721
- totalBytes: number(),
18722
- usedBytes: number(),
18723
- availableBytes: number(),
18724
- percent: number()
18725
- });
18726
- var PidResourceStatsSchema = object({
18727
- pid: number(),
18728
- cpu: number(),
18729
- memory: number(),
18730
- /**
18731
- * Private (anonymous) resident bytes — the per-process V8 heap + native
18732
- * allocations NOT shared with other processes (Linux RssAnon). This is the
18733
- * "real" per-runner cost; summing it across runners is meaningful, unlike
18734
- * `memory` (RSS), which double-counts the shared mmap'd framework code.
18735
- * Undefined where /proc is unavailable (e.g. macOS).
18736
- */
18737
- privateBytes: number().optional(),
18738
- /**
18739
- * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
18740
- * code shared copy-on-write across runners. Undefined on macOS.
18741
- */
18742
- sharedBytes: number().optional()
19323
+ object({
19324
+ kind: literal("url"),
19325
+ url: string(),
19326
+ sha256: string().optional()
19327
+ }),
19328
+ object({
19329
+ kind: literal("path"),
19330
+ path: string()
19331
+ })
19332
+ ]);
19333
+ var ManagedRuntimeConfigSchema = object({
19334
+ /** WHERE the runtime lives — hub or any agent. */
19335
+ nodeId: string(),
19336
+ /** Closed for v1; 'ollama' is a v2 candidate. */
19337
+ engine: _enum(["llama-cpp"]),
19338
+ model: ManagedModelRefSchema,
19339
+ contextSize: number().int().default(4096),
19340
+ /** 0 = CPU-only. */
19341
+ gpuLayers: number().int().default(0),
19342
+ /** Default: cpus-2, clamped ≥1 (resolved node-side). */
19343
+ threads: number().int().optional(),
19344
+ /** Concurrent slots. */
19345
+ parallel: number().int().default(1),
19346
+ /** Else lazy: first generate boots it. */
19347
+ autoStart: boolean().default(false),
19348
+ /** 0 = never; frees RAM after quiet periods. */
19349
+ idleStopMinutes: number().int().default(30)
18743
19350
  });
18744
- var AddonInstanceSchema = object({
18745
- addonId: string(),
19351
+ var LlmRuntimeStatusSchema = object({
19352
+ /** Status is ALWAYS node-qualified. */
18746
19353
  nodeId: string(),
18747
- role: _enum(["hub", "worker"]),
18748
- pid: number(),
18749
19354
  state: _enum([
18750
- "starting",
18751
- "running",
18752
- "stopping",
18753
19355
  "stopped",
18754
- "crashed"
18755
- ]),
18756
- uptimeSec: number()
18757
- });
18758
- var NodeProcessSchema = object({
18759
- pid: number(),
18760
- ppid: number(),
18761
- pgid: number(),
18762
- classification: _enum([
18763
- "root",
18764
- "managed",
18765
- "system",
18766
- "ghost"
19356
+ "downloading",
19357
+ "starting",
19358
+ "ready",
19359
+ "crashed",
19360
+ "failed"
18767
19361
  ]),
18768
- /** `$process` addon binding when `managed`, else null. */
18769
- addonId: string().nullable(),
18770
- /** Kernel-reported nodeId when the process is a known agent/worker. */
18771
- nodeId: string().nullable(),
18772
- /** Truncated command line. */
18773
- command: string(),
18774
- cpuPercent: number(),
18775
- memoryRssBytes: number(),
18776
- /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
18777
- uptimeSec: number(),
18778
- /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
18779
- orphaned: boolean()
18780
- });
18781
- var KillProcessInputSchema = object({
18782
- pid: number(),
18783
- /** Force = SIGKILL. Default is SIGTERM. */
18784
- force: boolean().optional()
19362
+ pid: number().optional(),
19363
+ port: number().optional(),
19364
+ modelPath: string().optional(),
19365
+ modelId: string().optional(),
19366
+ downloadProgress: number().min(0).max(1).optional(),
19367
+ lastError: string().optional(),
19368
+ crashesInWindow: number(),
19369
+ /** Child RSS (sampled best-effort). */
19370
+ memoryBytes: number().optional(),
19371
+ vramBytes: number().optional()
18785
19372
  });
18786
- var KillProcessResultSchema = object({
18787
- success: boolean(),
18788
- reason: string().optional(),
18789
- signal: _enum(["SIGTERM", "SIGKILL"]).optional()
19373
+ var LlmNodeModelSchema = object({
19374
+ file: string(),
19375
+ sizeBytes: number(),
19376
+ catalogId: string().optional(),
19377
+ installedAt: number().optional()
18790
19378
  });
18791
- var DumpHeapSnapshotInputSchema = object({
18792
- /** The addon whose runner should dump a heap snapshot. */
18793
- addonId: string() });
18794
- var DumpHeapSnapshotResultSchema = object({
18795
- success: boolean(),
18796
- /** Path of the written .heapsnapshot inside the runner's container/host. */
18797
- path: string().optional(),
18798
- /** Process pid that was signalled. */
18799
- pid: number().optional(),
18800
- reason: string().optional()
19379
+ var LlmRuntimeDiskUsageSchema = object({
19380
+ nodeId: string(),
19381
+ modelsBytes: number(),
19382
+ freeBytes: number().optional()
18801
19383
  });
18802
- var SystemMetricsSchema = object({
18803
- cpuPercent: number(),
18804
- memoryPercent: number(),
18805
- memoryUsedMB: number(),
18806
- memoryTotalMB: number(),
18807
- diskPercent: number().optional(),
18808
- temperature: number().optional(),
18809
- gpuPercent: number().optional(),
18810
- gpuMemoryPercent: number().optional()
18811
- });
18812
- 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, {
19384
+ method(LlmGenerateBaseInputSchema.extend({
19385
+ images: array(LlmImageSchema).optional(),
19386
+ runtime: ManagedRuntimeConfigSchema,
19387
+ /** The managed profile's timeout, threaded by the hub provider. */
19388
+ timeoutMs: number().int().positive().optional()
19389
+ }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
18813
19390
  kind: "mutation",
18814
19391
  auth: "admin"
18815
- }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
19392
+ }), method(object({}), _void(), {
18816
19393
  kind: "mutation",
18817
19394
  auth: "admin"
18818
- });
18819
- method(object({
18820
- sourceUrl: string(),
18821
- metadata: ModelConvertMetadataSchema,
18822
- targets: array(ConvertTargetSchema).min(1).readonly(),
18823
- calibrationRef: string().optional(),
18824
- sessionId: string().optional()
18825
- }), ConvertResultSchema, {
19395
+ }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
18826
19396
  kind: "mutation",
18827
- auth: "admin",
18828
- timeoutMs: 6e5
18829
- });
18830
- method(object({
18831
- nodeId: string(),
18832
- modelId: string(),
18833
- format: _enum(MODEL_FORMATS),
18834
- entry: ModelCatalogEntrySchema
18835
- }), object({
18836
- ok: boolean(),
18837
- /** sha256 of the staged tarball (empty for a hub-local no-op). */
18838
- sha256: string(),
18839
- bytes: number(),
18840
- /** The target node's modelsDir the artifact landed in. */
18841
- path: string()
18842
- }), {
19397
+ auth: "admin"
19398
+ }), method(object({ file: string() }), _void(), {
18843
19399
  kind: "mutation",
18844
19400
  auth: "admin"
18845
- });
18846
- /**
18847
- * `mqtt-broker` — broker-registry cap.
18848
- *
18849
- * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
18850
- * MQTT brokers (external + optionally an embedded `aedes`-backed one)
18851
- * and (b) the connection details a consumer addon needs to spin up
18852
- * its OWN `mqtt.js` client.
18853
- *
18854
- * Why: pub/sub routing over the system event-bus loses fidelity
18855
- * (callback shape, QoS guarantees, will/retain semantics) and adds
18856
- * refcount bookkeeping that addons would rather own themselves. The
18857
- * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
18858
- * features anyway — give it the connection config, get out of the way.
18859
- *
18860
- * Consumer flow:
18861
- * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
18862
- * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
18863
- * client.subscribe('zigbee2mqtt/+')
18864
- *
18865
- * Collection mode: multiple brokers (e.g. one local mosquitto + one
18866
- * cloud bridge). The "embedded" entry (when present) is just another
18867
- * broker in the registry — its lifecycle is owned by the addon that
18868
- * spawned it.
18869
- */
18870
- var BrokerKindSchema = _enum(["external", "embedded"]);
19401
+ }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
18871
19402
  /**
18872
- * Broker live-probe status.
19403
+ * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
19404
+ * methods concat-fan across providers; single-row methods route to ONE
19405
+ * provider by the `addonId` in the call input (the notification-output
19406
+ * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
19407
+ * (hub-placed); the cap stays open for future providers.
18873
19408
  *
18874
- * - `connected` last probe completed a clean CONNACK
18875
- * - `disconnected` — no probe has run yet (cold cache)
18876
- * - `auth-failed` CONNACK refused with auth error (RC 4 / 5)
18877
- * - `unreachable` — TCP connect timed out / refused
18878
- * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
19409
+ * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
19410
+ * `apiKey` is a password field providers REDACT it on read and merge on
19411
+ * write; a stored key NEVER round-trips to a client.
18879
19412
  */
18880
- var BrokerStatusSchema$1 = _enum([
18881
- "connected",
18882
- "disconnected",
18883
- "auth-failed",
18884
- "unreachable",
18885
- "tls-error"
19413
+ var LlmProfileKindSchema = _enum([
19414
+ "openai-compatible",
19415
+ "openai",
19416
+ "anthropic",
19417
+ "google",
19418
+ "managed-local"
18886
19419
  ]);
18887
- var BrokerInfoSchema = object({
19420
+ var LlmProfileSchema = object({
18888
19421
  id: string(),
18889
19422
  name: string(),
18890
- url: string(),
18891
- kind: BrokerKindSchema,
18892
- status: BrokerStatusSchema$1,
18893
- latencyMs: number().nullable(),
18894
- error: string().optional(),
18895
- /** Embedded brokers only: number of MQTT clients currently connected. */
18896
- connectedClients: number().int().nonnegative().optional(),
18897
- /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
18898
- lastCheckedAt: number().optional()
19423
+ kind: LlmProfileKindSchema,
19424
+ /** Stamped by the provider — keeps the fanned catalog routable. */
19425
+ addonId: string(),
19426
+ enabled: boolean(),
19427
+ /** Vendor model id, or the managed runtime's loaded model. */
19428
+ model: string(),
19429
+ /** Required for openai-compatible; override for cloud kinds. */
19430
+ baseUrl: string().optional(),
19431
+ /** ConfigUISchema type:'password' — never round-trips (spec §5). */
19432
+ apiKey: string().optional(),
19433
+ supportsVision: boolean(),
19434
+ temperature: number().min(0).max(2).optional(),
19435
+ maxTokens: number().int().positive().optional(),
19436
+ timeoutMs: number().int().positive().default(6e4),
19437
+ extraHeaders: record(string(), string()).optional(),
19438
+ /** kind === 'managed-local' only (spec §4). */
19439
+ runtime: ManagedRuntimeConfigSchema.optional()
18899
19440
  });
18900
- /**
18901
- * Connection details — what a consumer needs to call
18902
- * `mqtt.connect(url, options)`. We split URL + credentials so the
18903
- * consumer can pass them as `mqtt.connect(url, { username, password })`
18904
- * instead of stuffing creds into the URL (which leaks them into logs).
18905
- */
18906
- var BrokerConnectionDetailsSchema = object({
18907
- url: string(),
18908
- username: string().optional(),
18909
- password: string().optional(),
18910
- /**
18911
- * Suggested prefix for `clientId`. Each consumer should suffix this
18912
- * with its own discriminator (addon id, instance id) so reconnects
18913
- * don't kick each other off (MQTT spec: clientId must be unique per
18914
- * broker).
18915
- */
18916
- clientIdPrefix: string().optional()
19441
+ /** ConfigUISchema tree passed through untyped on the wire (the
19442
+ * notification-output `ConfigSchemaPassthrough` precedent at
19443
+ * notification-output.cap.ts:151); the exported TS type re-tightens it. */
19444
+ var ConfigSchemaPassthrough$1 = unknown();
19445
+ var LlmProfileKindDescriptorSchema = object({
19446
+ kind: LlmProfileKindSchema,
19447
+ label: string(),
19448
+ icon: string(),
19449
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
19450
+ addonId: string(),
19451
+ configSchema: ConfigSchemaPassthrough$1
18917
19452
  });
18918
- var AddBrokerInputSchema = object({
18919
- name: string().min(1),
18920
- url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
18921
- username: string().optional(),
18922
- password: string().optional(),
18923
- clientIdPrefix: string().optional()
19453
+ var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
19454
+ var LlmDefaultSchema = object({
19455
+ selector: LlmDefaultSelectorSchema,
19456
+ profileId: string()
18924
19457
  });
18925
- var AddBrokerResultSchema = object({ id: string() });
18926
- var IdInputSchema = object({ id: string() });
18927
- var TestResultSchema$1 = discriminatedUnion("ok", [object({
18928
- ok: literal(true),
18929
- latencyMs: number()
18930
- }), object({
18931
- ok: literal(false),
18932
- error: string()
18933
- })]);
18934
- var StartEmbeddedInputSchema = object({
18935
- port: number().int().min(1).max(65535).default(1883),
18936
- /** Allow anonymous connect (no username/password). Default: false. */
18937
- allowAnonymous: boolean().default(false),
18938
- /** Optional shared username/password for clients. */
18939
- username: string().optional(),
18940
- password: string().optional()
19458
+ /** Server-side rollup row getUsage never dumps raw call rows (spec §6). */
19459
+ var LlmUsageRollupSchema = object({
19460
+ day: string(),
19461
+ consumer: string(),
19462
+ profileId: string(),
19463
+ calls: number(),
19464
+ okCalls: number(),
19465
+ errorCalls: number(),
19466
+ inputTokens: number(),
19467
+ outputTokens: number(),
19468
+ avgLatencyMs: number()
18941
19469
  });
18942
- var StartEmbeddedResultSchema = object({
19470
+ /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
19471
+ var ManagedModelCatalogEntrySchema = object({
18943
19472
  id: string(),
18944
- url: string()
18945
- });
18946
- var StatusSchema = object({
18947
- brokerCount: number(),
18948
- embeddedRunning: boolean()
18949
- });
18950
- 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);
18951
- var NetworkEndpointSchema = object({
19473
+ label: string(),
19474
+ family: string(),
19475
+ purpose: _enum(["text", "vision"]),
18952
19476
  url: string(),
18953
- hostname: string(),
18954
- port: number(),
18955
- protocol: _enum(["http", "https"])
19477
+ sha256: string(),
19478
+ sizeBytes: number(),
19479
+ quantization: string(),
19480
+ /** Load-time guidance shown in the picker. */
19481
+ minRamBytes: number(),
19482
+ contextSizeDefault: number().int(),
19483
+ /** Vision models: companion projector file. */
19484
+ mmprojUrl: string().optional()
18956
19485
  });
18957
- var NetworkAccessStatusSchema = object({
18958
- connected: boolean(),
18959
- endpoint: NetworkEndpointSchema.nullable(),
19486
+ var LlmRuntimeNodeSchema = object({
19487
+ nodeId: string(),
19488
+ reachable: boolean(),
19489
+ status: LlmRuntimeStatusSchema.optional(),
19490
+ disk: LlmRuntimeDiskUsageSchema.optional(),
18960
19491
  error: string().optional()
18961
19492
  });
18962
- /**
18963
- * Optional, richer endpoint shape returned by providers that expose
18964
- * MORE than one ingress concurrently (Tailscale Ingress with mixed
18965
- * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
18966
- * the originating provider config (mode + sourcePort) so the
18967
- * orchestrator UI can label rows distinctly. Providers that expose only
18968
- * one endpoint just omit `listEndpoints` from their provider impl.
18969
- */
18970
- var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
18971
- /**
18972
- * Stable id within the provider — typically `<mode>-<sourcePort>` so
18973
- * the orchestrator can dedupe across `listEndpoints` polls.
18974
- */
18975
- id: string(),
18976
- /** Operator-facing label (mirrors `MeshEndpoint.label`). */
18977
- label: string(),
18978
- /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
18979
- mode: string().optional(),
18980
- /** Originating local port the ingress fronts (informational). */
18981
- sourcePort: number().optional()
19493
+ var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
19494
+ var ProfileRefInputSchema = object({
19495
+ addonId: string(),
19496
+ profileId: string()
18982
19497
  });
18983
- method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
18984
- /**
18985
- * notification-output — canonical, capability-gated notification delivery.
18986
- *
18987
- * Apprise-derived model (see
18988
- * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
18989
- * callers emit ONE canonical `Notification`; each provider declares a
18990
- * per-kind capability descriptor (`TargetKind`), and the pure degrade
18991
- * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
18992
- * message to what the kind supports — callers never special-case a service.
18993
- *
18994
- * DESIGN DECISIONS (locked):
18995
- * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
18996
- * `setTargetEnabled`), each provider persisting via the `settings-store`
18997
- * cap. Rationale: the admin UI needs one uniform surface across the
18998
- * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
18999
- * alternative would fork the UI per addon and cannot host the
19000
- * discovery→adopt flow.
19001
- * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
19002
- * the generated cap-mount auto-`concatCollection`-fans them across every
19003
- * registered provider (notifiers addon + HA addon) so one catalog is
19004
- * routable. `send` / `testTarget` / CRUD route to ONE provider by the
19005
- * `addonId` the generated collection router extracts from the call input.
19006
- * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
19007
- * transformer) + UDS MsgPack both round-trip typed arrays — already used by
19008
- * `storage` / `storage-provider` / `recording` caps over the same path. No
19009
- * base64 fallback needed.
19010
- *
19011
- * TODO (deferred, closed-set change — separate decision): add
19012
- * `providerKind: 'notify'` so notification providers surface on the unified
19013
- * admin "Integrations" page.
19014
- */
19015
- /**
19016
- * Zentik-derived typed-media enum — the superset across every kind. Each
19017
- * adapter picks what it supports and the degrade engine filters the rest.
19018
- */
19019
- var AttachmentMediaTypeSchema = _enum([
19020
- "image",
19021
- "video",
19022
- "gif",
19023
- "audio",
19024
- "icon"
19498
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
19499
+ kind: "mutation",
19500
+ auth: "admin"
19501
+ }), method(ProfileRefInputSchema, _void(), {
19502
+ kind: "mutation",
19503
+ auth: "admin"
19504
+ }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
19505
+ kind: "mutation",
19506
+ auth: "admin"
19507
+ }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
19508
+ selector: LlmDefaultSelectorSchema,
19509
+ profileId: string().nullable()
19510
+ }), _void(), {
19511
+ kind: "mutation",
19512
+ auth: "admin"
19513
+ }), method(object({
19514
+ since: number().optional(),
19515
+ until: number().optional(),
19516
+ consumer: string().optional(),
19517
+ profileId: string().optional()
19518
+ }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
19519
+ nodeId: string(),
19520
+ model: ManagedModelRefSchema
19521
+ }), _void(), {
19522
+ kind: "mutation",
19523
+ auth: "admin"
19524
+ }), method(object({
19525
+ nodeId: string(),
19526
+ file: string()
19527
+ }), _void(), {
19528
+ kind: "mutation",
19529
+ auth: "admin"
19530
+ }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
19531
+ kind: "mutation",
19532
+ auth: "admin"
19533
+ }), method(ProfileRefInputSchema, _void(), {
19534
+ kind: "mutation",
19535
+ auth: "admin"
19536
+ });
19537
+ var LogLevelSchema = _enum([
19538
+ "debug",
19539
+ "info",
19540
+ "warn",
19541
+ "error"
19025
19542
  ]);
19543
+ var LogEntrySchema = object({
19544
+ timestamp: date(),
19545
+ level: LogLevelSchema,
19546
+ scope: array(string()),
19547
+ message: string(),
19548
+ meta: record(string(), unknown()).optional(),
19549
+ tags: record(string(), string()).optional()
19550
+ });
19551
+ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
19552
+ scope: array(string()).optional(),
19553
+ level: LogLevelSchema.optional(),
19554
+ since: date().optional(),
19555
+ until: date().optional(),
19556
+ limit: number().optional(),
19557
+ tags: record(string(), string()).optional()
19558
+ }), array(LogEntrySchema).readonly());
19026
19559
  /**
19027
- * A single attachment. Exactly one of `url` (remote source, most adapters
19028
- * prefer this) or `bytes` (inline source; required for Pushover-style
19029
- * bytes-only kinds) MUST be present — the degrade engine expresses a
19030
- * url→bytes fetch as a `needsFetch` directive the adapter executes.
19560
+ * `login-method` collection cap through which auth addons contribute
19561
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
19562
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
19563
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
19564
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
19565
+ * procedure aggregates them for the unauthenticated login page.
19566
+ *
19567
+ * A contribution is a discriminated union on `kind`:
19568
+ *
19569
+ * - `redirect` — a declarative button. The login page renders a generic
19570
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
19571
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
19572
+ * ZERO shell-side JS. A future SSO addon plugs in the same way — the
19573
+ * login page needs NO change.
19574
+ *
19575
+ * - `widget` — a Module-Federation widget the login page mounts (via
19576
+ * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
19577
+ * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
19578
+ * mechanism kept for future use; no shipped addon uses it on the login
19579
+ * page (the passkey ceremony below runs natively in the shell instead).
19580
+ *
19581
+ * - `passkey` — a declarative WebAuthn ceremony the shell renders
19582
+ * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
19583
+ * a remotely-loaded bundle). Carries the addon's effective `rpId` /
19584
+ * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
19585
+ * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
19586
+ * fetching any remote code pre-auth. Contribution stays unconditional —
19587
+ * enrollment state is never leaked pre-auth; visibility is a shell
19588
+ * decision.
19589
+ *
19590
+ * Every contribution carries a `stage`:
19591
+ * - `primary` — shown on the first credentials screen (OIDC /
19592
+ * magic-link buttons; a future usernameless passkey).
19593
+ * - `second-factor` — shown AFTER the password leg, gated on the
19594
+ * returned `factors` (passkey-as-2FA today).
19595
+ *
19596
+ * `mount: skip` — the cap is read server-side by the core auth router
19597
+ * (`registry.getCollection('login-method')`), never mounted as its own
19598
+ * tRPC router.
19031
19599
  */
19032
- var AttachmentSchema = object({
19033
- mediaType: AttachmentMediaTypeSchema,
19034
- url: string().optional(),
19035
- bytes: _instanceof(Uint8Array).optional(),
19036
- mime: string().optional(),
19037
- name: string().optional()
19038
- }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
19039
- var NotificationFormatSchema = _enum([
19040
- "text",
19041
- "markdown",
19042
- "html"
19600
+ /** When a login method renders in the two-phase login flow. */
19601
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
19602
+ /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
19603
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [
19604
+ object({
19605
+ kind: literal("redirect"),
19606
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
19607
+ id: string(),
19608
+ /** Operator-facing button label. */
19609
+ label: string(),
19610
+ /** lucide-react icon name. */
19611
+ icon: string().optional(),
19612
+ /** Addon-owned HTTP route the button navigates to (GET). */
19613
+ startUrl: string(),
19614
+ stage: LoginStageEnum
19615
+ }),
19616
+ object({
19617
+ kind: literal("widget"),
19618
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
19619
+ id: string(),
19620
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
19621
+ addonId: string(),
19622
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
19623
+ bundle: string(),
19624
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
19625
+ remote: WidgetRemoteSchema,
19626
+ stage: LoginStageEnum
19627
+ }),
19628
+ object({
19629
+ kind: literal("passkey"),
19630
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
19631
+ id: string(),
19632
+ /** Operator-facing button label. */
19633
+ label: string(),
19634
+ stage: LoginStageEnum,
19635
+ /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
19636
+ rpId: string(),
19637
+ /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
19638
+ origin: string().nullable()
19639
+ })
19043
19640
  ]);
19044
- /** A single tap-through action button. */
19045
- var NotificationActionSchema = object({
19046
- id: string(),
19047
- label: string(),
19048
- url: string().optional()
19641
+ method(_void(), array(LoginMethodContributionSchema).readonly());
19642
+ var CpuBreakdownSchema = object({
19643
+ total: number(),
19644
+ user: number(),
19645
+ system: number(),
19646
+ irq: number(),
19647
+ nice: number(),
19648
+ loadAvg: tuple([
19649
+ number(),
19650
+ number(),
19651
+ number()
19652
+ ]),
19653
+ cores: number()
19049
19654
  });
19050
- /**
19051
- * The canonical notification. `body` is the only hard field (Apprise model).
19052
- * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
19053
- * NOT a fixed severity enum — each kind declares its own `caps.levels` and
19054
- * the adapter maps this ordinal onto its native level. `level?` is an
19055
- * optional kind-native level id (`emergency`, `silent`, …) that overrides
19056
- * `priority` for that one target.
19057
- */
19058
- var NotificationSchema = object({
19059
- body: string(),
19060
- title: string().optional(),
19061
- format: NotificationFormatSchema.default("text"),
19062
- priority: number().int().min(1).max(5).default(3),
19063
- level: string().optional(),
19064
- attachments: array(AttachmentSchema).optional(),
19065
- clickUrl: string().optional(),
19066
- actions: array(NotificationActionSchema).optional(),
19067
- sound: string().optional(),
19068
- ttl: number().optional(),
19069
- tag: string().optional(),
19070
- deviceId: number().optional(),
19071
- eventId: string().optional(),
19072
- metadata: record(string(), unknown()).optional()
19655
+ var MemoryInfoSchema = object({
19656
+ percent: number(),
19657
+ totalBytes: number(),
19658
+ usedBytes: number(),
19659
+ availableBytes: number(),
19660
+ swapUsedBytes: number(),
19661
+ swapTotalBytes: number()
19073
19662
  });
19074
- /** One declared native severity/priority level for a kind. */
19075
- var TargetKindLevelSchema = object({
19076
- id: string(),
19077
- label: string(),
19078
- /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
19079
- ordinal: number().int().min(1).max(5).nullable(),
19080
- flags: object({
19081
- critical: boolean().optional(),
19082
- silent: boolean().optional(),
19083
- noPush: boolean().optional()
19084
- }).optional(),
19085
- /** e.g. Pushover `emergency` requires `retry` / `expire`. */
19086
- requires: array(string()).optional(),
19087
- description: string().optional()
19663
+ var DiskIoSnapshotSchema = object({
19664
+ readBytes: number(),
19665
+ writeBytes: number(),
19666
+ readOps: number(),
19667
+ writeOps: number(),
19668
+ timestampMs: number()
19088
19669
  });
19089
- /** The full capability block consulted before dispatch. */
19090
- var TargetKindCapsSchema = object({
19091
- attachments: object({
19092
- mediaTypes: array(AttachmentMediaTypeSchema),
19093
- mode: _enum([
19094
- "url",
19095
- "bytes",
19096
- "both"
19097
- ]),
19098
- max: number().int().nonnegative(),
19099
- maxBytes: number().int().positive().optional()
19670
+ var NetworkIoSnapshotSchema = object({
19671
+ rxBytes: number(),
19672
+ txBytes: number(),
19673
+ rxPackets: number(),
19674
+ txPackets: number(),
19675
+ rxErrors: number(),
19676
+ txErrors: number(),
19677
+ timestampMs: number()
19678
+ });
19679
+ var MetricsGpuInfoSchema = object({
19680
+ utilization: number(),
19681
+ model: string(),
19682
+ memoryUsedBytes: number(),
19683
+ memoryTotalBytes: number(),
19684
+ temperature: number().nullable()
19685
+ });
19686
+ var ProcessResourceInfoSchema = object({
19687
+ openFds: number(),
19688
+ threadCount: number(),
19689
+ activeHandles: number(),
19690
+ activeRequests: number()
19691
+ });
19692
+ var PressureAvgsSchema = object({
19693
+ avg10: number(),
19694
+ avg60: number(),
19695
+ avg300: number()
19696
+ });
19697
+ var PressureInfoSchema = object({
19698
+ some: PressureAvgsSchema,
19699
+ full: PressureAvgsSchema.nullable()
19700
+ });
19701
+ var SystemResourceSnapshotSchema = object({
19702
+ cpu: CpuBreakdownSchema,
19703
+ memory: MemoryInfoSchema,
19704
+ gpu: MetricsGpuInfoSchema.nullable(),
19705
+ network: NetworkIoSnapshotSchema,
19706
+ disk: DiskIoSnapshotSchema,
19707
+ pressure: object({
19708
+ cpu: PressureInfoSchema.nullable(),
19709
+ memory: PressureInfoSchema.nullable(),
19710
+ io: PressureInfoSchema.nullable()
19100
19711
  }),
19101
- /** Max action buttons (0 = none). */
19102
- actions: number().int().nonnegative(),
19103
- levels: array(TargetKindLevelSchema),
19104
- format: array(NotificationFormatSchema),
19105
- clickUrl: boolean(),
19106
- sound: boolean(),
19107
- ttl: boolean(),
19108
- bodyMaxLen: number().int().positive()
19712
+ process: ProcessResourceInfoSchema,
19713
+ cpuTemperature: number().nullable(),
19714
+ timestampMs: number()
19109
19715
  });
19110
- /**
19111
- * `configSchema` is a `ConfigUISchema` tree passed through to the admin
19112
- * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
19113
- * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`)
19114
- * the union is large and not meant for runtime validation here; the exported
19115
- * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
19116
- */
19117
- var ConfigSchemaPassthrough$1 = unknown();
19118
- var TargetKindSchema = object({
19119
- kind: string(),
19120
- label: string(),
19121
- icon: string(),
19122
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
19123
- addonId: string(),
19124
- configSchema: ConfigSchemaPassthrough$1,
19125
- supportsDiscovery: boolean(),
19126
- caps: TargetKindCapsSchema
19716
+ var DiskSpaceInfoSchema = object({
19717
+ path: string(),
19718
+ totalBytes: number(),
19719
+ usedBytes: number(),
19720
+ availableBytes: number(),
19721
+ percent: number()
19127
19722
  });
19128
- /**
19129
- * A persisted target. `config` holds secrets; providers REDACT secret fields
19130
- * (return a presence marker only) when serving `listTargets` — never
19131
- * round-trip a stored secret to the UI.
19132
- */
19133
- var TargetSchema = object({
19134
- id: string(),
19135
- name: string(),
19136
- kind: string(),
19723
+ var PidResourceStatsSchema = object({
19724
+ pid: number(),
19725
+ cpu: number(),
19726
+ memory: number(),
19727
+ /**
19728
+ * Private (anonymous) resident bytes — the per-process V8 heap + native
19729
+ * allocations NOT shared with other processes (Linux RssAnon). This is the
19730
+ * "real" per-runner cost; summing it across runners is meaningful, unlike
19731
+ * `memory` (RSS), which double-counts the shared mmap'd framework code.
19732
+ * Undefined where /proc is unavailable (e.g. macOS).
19733
+ */
19734
+ privateBytes: number().optional(),
19735
+ /**
19736
+ * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
19737
+ * code shared copy-on-write across runners. Undefined on macOS.
19738
+ */
19739
+ sharedBytes: number().optional()
19740
+ });
19741
+ var AddonInstanceSchema = object({
19137
19742
  addonId: string(),
19138
- enabled: boolean(),
19139
- config: record(string(), unknown())
19743
+ nodeId: string(),
19744
+ role: _enum(["hub", "worker"]),
19745
+ pid: number(),
19746
+ state: _enum([
19747
+ "starting",
19748
+ "running",
19749
+ "stopping",
19750
+ "stopped",
19751
+ "crashed"
19752
+ ]),
19753
+ uptimeSec: number()
19140
19754
  });
19141
- /** A discovery-surfaced candidate (config is partial + non-secret). */
19142
- var DiscoveredTargetSchema = object({
19143
- kind: string(),
19144
- suggestedName: string(),
19145
- config: record(string(), unknown())
19755
+ var NodeProcessSchema = object({
19756
+ pid: number(),
19757
+ ppid: number(),
19758
+ pgid: number(),
19759
+ classification: _enum([
19760
+ "root",
19761
+ "managed",
19762
+ "system",
19763
+ "ghost"
19764
+ ]),
19765
+ /** `$process` addon binding when `managed`, else null. */
19766
+ addonId: string().nullable(),
19767
+ /** Kernel-reported nodeId when the process is a known agent/worker. */
19768
+ nodeId: string().nullable(),
19769
+ /** Truncated command line. */
19770
+ command: string(),
19771
+ cpuPercent: number(),
19772
+ memoryRssBytes: number(),
19773
+ /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
19774
+ uptimeSec: number(),
19775
+ /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
19776
+ orphaned: boolean()
19146
19777
  });
19147
- /** The degrade engine's report — what was resolved / dropped / degraded. */
19148
- var RenderedAsSchema = object({
19149
- level: string(),
19150
- format: NotificationFormatSchema,
19151
- attachmentsSent: number().int().nonnegative(),
19152
- actionsSent: number().int().nonnegative(),
19153
- truncated: boolean(),
19154
- dropped: array(string())
19778
+ var KillProcessInputSchema = object({
19779
+ pid: number(),
19780
+ /** Force = SIGKILL. Default is SIGTERM. */
19781
+ force: boolean().optional()
19155
19782
  });
19156
- var SendResultSchema = object({
19783
+ var KillProcessResultSchema = object({
19157
19784
  success: boolean(),
19158
- error: string().optional(),
19159
- renderedAs: RenderedAsSchema.optional()
19785
+ reason: string().optional(),
19786
+ signal: _enum(["SIGTERM", "SIGKILL"]).optional()
19787
+ });
19788
+ var DumpHeapSnapshotInputSchema = object({
19789
+ /** The addon whose runner should dump a heap snapshot. */
19790
+ addonId: string() });
19791
+ var DumpHeapSnapshotResultSchema = object({
19792
+ success: boolean(),
19793
+ /** Path of the written .heapsnapshot inside the runner's container/host. */
19794
+ path: string().optional(),
19795
+ /** Process pid that was signalled. */
19796
+ pid: number().optional(),
19797
+ reason: string().optional()
19798
+ });
19799
+ var SystemMetricsSchema = object({
19800
+ cpuPercent: number(),
19801
+ memoryPercent: number(),
19802
+ memoryUsedMB: number(),
19803
+ memoryTotalMB: number(),
19804
+ diskPercent: number().optional(),
19805
+ temperature: number().optional(),
19806
+ gpuPercent: number().optional(),
19807
+ gpuMemoryPercent: number().optional()
19808
+ });
19809
+ 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, {
19810
+ kind: "mutation",
19811
+ auth: "admin"
19812
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
19813
+ kind: "mutation",
19814
+ auth: "admin"
19815
+ });
19816
+ method(object({
19817
+ sourceUrl: string(),
19818
+ metadata: ModelConvertMetadataSchema,
19819
+ targets: array(ConvertTargetSchema).min(1).readonly(),
19820
+ calibrationRef: string().optional(),
19821
+ sessionId: string().optional()
19822
+ }), ConvertResultSchema, {
19823
+ kind: "mutation",
19824
+ auth: "admin",
19825
+ timeoutMs: 6e5
19826
+ });
19827
+ method(object({
19828
+ nodeId: string(),
19829
+ modelId: string(),
19830
+ format: _enum(MODEL_FORMATS),
19831
+ entry: ModelCatalogEntrySchema
19832
+ }), object({
19833
+ ok: boolean(),
19834
+ /** sha256 of the staged tarball (empty for a hub-local no-op). */
19835
+ sha256: string(),
19836
+ bytes: number(),
19837
+ /** The target node's modelsDir the artifact landed in. */
19838
+ path: string()
19839
+ }), {
19840
+ kind: "mutation",
19841
+ auth: "admin"
19842
+ });
19843
+ /**
19844
+ * `mqtt-broker` — broker-registry cap.
19845
+ *
19846
+ * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
19847
+ * MQTT brokers (external + optionally an embedded `aedes`-backed one)
19848
+ * and (b) the connection details a consumer addon needs to spin up
19849
+ * its OWN `mqtt.js` client.
19850
+ *
19851
+ * Why: pub/sub routing over the system event-bus loses fidelity
19852
+ * (callback shape, QoS guarantees, will/retain semantics) and adds
19853
+ * refcount bookkeeping that addons would rather own themselves. The
19854
+ * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
19855
+ * features anyway — give it the connection config, get out of the way.
19856
+ *
19857
+ * Consumer flow:
19858
+ * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
19859
+ * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
19860
+ * client.subscribe('zigbee2mqtt/+')
19861
+ *
19862
+ * Collection mode: multiple brokers (e.g. one local mosquitto + one
19863
+ * cloud bridge). The "embedded" entry (when present) is just another
19864
+ * broker in the registry — its lifecycle is owned by the addon that
19865
+ * spawned it.
19866
+ */
19867
+ var BrokerKindSchema = _enum(["external", "embedded"]);
19868
+ /**
19869
+ * Broker live-probe status.
19870
+ *
19871
+ * - `connected` — last probe completed a clean CONNACK
19872
+ * - `disconnected` — no probe has run yet (cold cache)
19873
+ * - `auth-failed` — CONNACK refused with auth error (RC 4 / 5)
19874
+ * - `unreachable` — TCP connect timed out / refused
19875
+ * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
19876
+ */
19877
+ var BrokerStatusSchema$1 = _enum([
19878
+ "connected",
19879
+ "disconnected",
19880
+ "auth-failed",
19881
+ "unreachable",
19882
+ "tls-error"
19883
+ ]);
19884
+ var BrokerInfoSchema = object({
19885
+ id: string(),
19886
+ name: string(),
19887
+ url: string(),
19888
+ kind: BrokerKindSchema,
19889
+ status: BrokerStatusSchema$1,
19890
+ latencyMs: number().nullable(),
19891
+ error: string().optional(),
19892
+ /** Embedded brokers only: number of MQTT clients currently connected. */
19893
+ connectedClients: number().int().nonnegative().optional(),
19894
+ /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
19895
+ lastCheckedAt: number().optional()
19160
19896
  });
19161
- /** Same shape as SendResult — kept as a distinct name for the test panel. */
19162
- var TestResultSchema = SendResultSchema;
19163
- var notificationOutputCapability = {
19164
- name: "notification-output",
19165
- scope: "system",
19166
- mode: "collection",
19167
- methods: {
19168
- listTargetKinds: method(object({}), array(TargetKindSchema)),
19169
- listTargets: method(object({}), array(TargetSchema)),
19170
- discoverTargets: method(object({
19171
- kind: string(),
19172
- config: record(string(), unknown()).optional()
19173
- }), array(DiscoveredTargetSchema)),
19174
- send: method(object({
19175
- targetId: string(),
19176
- notification: NotificationSchema
19177
- }), SendResultSchema, { kind: "mutation" }),
19178
- testTarget: method(object({
19179
- targetId: string(),
19180
- sample: NotificationSchema.optional()
19181
- }), TestResultSchema, { kind: "mutation" }),
19182
- upsertTarget: method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }),
19183
- deleteTarget: method(object({ targetId: string() }), _void(), { kind: "mutation" }),
19184
- setTargetEnabled: method(object({
19185
- targetId: string(),
19186
- enabled: boolean()
19187
- }), _void(), { kind: "mutation" })
19188
- }
19189
- };
19190
19897
  /**
19191
- * Shared LLM generate contracts imported by BOTH `llm.cap.ts` (consumer
19192
- * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
19193
- * caps stay wire-compatible without a circular cap→cap import.
19194
- *
19195
- * Errors are a discriminated-union RESULT, never thrown: the shape survives
19196
- * every transport tier structurally, and failed calls still write usage rows.
19197
- * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
19898
+ * Connection details what a consumer needs to call
19899
+ * `mqtt.connect(url, options)`. We split URL + credentials so the
19900
+ * consumer can pass them as `mqtt.connect(url, { username, password })`
19901
+ * instead of stuffing creds into the URL (which leaks them into logs).
19198
19902
  */
19199
- var LlmUsageSchema = object({
19200
- inputTokens: number(),
19201
- outputTokens: number()
19903
+ var BrokerConnectionDetailsSchema = object({
19904
+ url: string(),
19905
+ username: string().optional(),
19906
+ password: string().optional(),
19907
+ /**
19908
+ * Suggested prefix for `clientId`. Each consumer should suffix this
19909
+ * with its own discriminator (addon id, instance id) so reconnects
19910
+ * don't kick each other off (MQTT spec: clientId must be unique per
19911
+ * broker).
19912
+ */
19913
+ clientIdPrefix: string().optional()
19202
19914
  });
19203
- var LlmErrorCodeSchema = _enum([
19204
- "timeout",
19205
- "rate-limited",
19206
- "auth",
19207
- "refusal",
19208
- "bad-request",
19209
- "unavailable",
19210
- "no-profile",
19211
- "budget-exceeded",
19212
- "adapter-error"
19213
- ]);
19214
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
19915
+ var AddBrokerInputSchema = object({
19916
+ name: string().min(1),
19917
+ url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
19918
+ username: string().optional(),
19919
+ password: string().optional(),
19920
+ clientIdPrefix: string().optional()
19921
+ });
19922
+ var AddBrokerResultSchema = object({ id: string() });
19923
+ var IdInputSchema = object({ id: string() });
19924
+ var TestResultSchema$1 = discriminatedUnion("ok", [object({
19215
19925
  ok: literal(true),
19216
- text: string(),
19217
- model: string(),
19218
- usage: LlmUsageSchema,
19219
- truncated: boolean(),
19220
19926
  latencyMs: number()
19221
19927
  }), object({
19222
19928
  ok: literal(false),
19223
- code: LlmErrorCodeSchema,
19224
- message: string(),
19225
- retryAfterMs: number().optional()
19929
+ error: string()
19226
19930
  })]);
19227
- /**
19228
- * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
19229
- * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
19230
- * notification-output.cap.ts:27-31 precedents).
19231
- */
19232
- var LlmImageSchema = object({
19233
- bytes: _instanceof(Uint8Array),
19234
- mimeType: string()
19931
+ var StartEmbeddedInputSchema = object({
19932
+ port: number().int().min(1).max(65535).default(1883),
19933
+ /** Allow anonymous connect (no username/password). Default: false. */
19934
+ allowAnonymous: boolean().default(false),
19935
+ /** Optional shared username/password for clients. */
19936
+ username: string().optional(),
19937
+ password: string().optional()
19235
19938
  });
19236
- var LlmGenerateBaseInputSchema = object({
19237
- /** Collection routing (the notification-output posture). */
19238
- addonId: string().optional(),
19239
- /** Explicit profile; else the resolution chain (spec §3). */
19240
- profileId: string().optional(),
19241
- /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
19242
- consumer: string(),
19243
- system: string().optional(),
19244
- /** v1: single-turn. `messages[]` is a v2 additive field. */
19245
- prompt: string(),
19246
- /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
19247
- jsonSchema: record(string(), unknown()).optional(),
19248
- /** Per-call override of the profile default. */
19249
- maxTokens: number().int().positive().optional(),
19250
- temperature: number().optional()
19939
+ var StartEmbeddedResultSchema = object({
19940
+ id: string(),
19941
+ url: string()
19251
19942
  });
19252
- /**
19253
- * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
19254
- * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
19255
- * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
19256
- * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
19257
- * this only through the `llm` cap's methods.
19258
- *
19259
- * One running llama-server child per node in v1 (models are RAM-heavy).
19260
- * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
19261
- * watchdog — operator decision #3).
19262
- */
19263
- var ManagedModelRefSchema = discriminatedUnion("kind", [
19264
- object({
19265
- kind: literal("catalog"),
19266
- catalogId: string()
19267
- }),
19268
- object({
19269
- kind: literal("url"),
19270
- url: string(),
19271
- sha256: string().optional()
19272
- }),
19273
- object({
19274
- kind: literal("path"),
19275
- path: string()
19276
- })
19277
- ]);
19278
- var ManagedRuntimeConfigSchema = object({
19279
- /** WHERE the runtime lives — hub or any agent. */
19280
- nodeId: string(),
19281
- /** Closed for v1; 'ollama' is a v2 candidate. */
19282
- engine: _enum(["llama-cpp"]),
19283
- model: ManagedModelRefSchema,
19284
- contextSize: number().int().default(4096),
19285
- /** 0 = CPU-only. */
19286
- gpuLayers: number().int().default(0),
19287
- /** Default: cpus-2, clamped ≥1 (resolved node-side). */
19288
- threads: number().int().optional(),
19289
- /** Concurrent slots. */
19290
- parallel: number().int().default(1),
19291
- /** Else lazy: first generate boots it. */
19292
- autoStart: boolean().default(false),
19293
- /** 0 = never; frees RAM after quiet periods. */
19294
- idleStopMinutes: number().int().default(30)
19943
+ var StatusSchema = object({
19944
+ brokerCount: number(),
19945
+ embeddedRunning: boolean()
19295
19946
  });
19296
- var LlmRuntimeStatusSchema = object({
19297
- /** Status is ALWAYS node-qualified. */
19298
- nodeId: string(),
19299
- state: _enum([
19300
- "stopped",
19301
- "downloading",
19302
- "starting",
19303
- "ready",
19304
- "crashed",
19305
- "failed"
19306
- ]),
19307
- pid: number().optional(),
19308
- port: number().optional(),
19309
- modelPath: string().optional(),
19310
- modelId: string().optional(),
19311
- downloadProgress: number().min(0).max(1).optional(),
19312
- lastError: string().optional(),
19313
- crashesInWindow: number(),
19314
- /** Child RSS (sampled best-effort). */
19315
- memoryBytes: number().optional(),
19316
- vramBytes: number().optional()
19947
+ 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);
19948
+ var NetworkEndpointSchema = object({
19949
+ url: string(),
19950
+ hostname: string(),
19951
+ port: number(),
19952
+ protocol: _enum(["http", "https"])
19317
19953
  });
19318
- var LlmNodeModelSchema = object({
19319
- file: string(),
19320
- sizeBytes: number(),
19321
- catalogId: string().optional(),
19322
- installedAt: number().optional()
19954
+ var NetworkAccessStatusSchema = object({
19955
+ connected: boolean(),
19956
+ endpoint: NetworkEndpointSchema.nullable(),
19957
+ error: string().optional()
19323
19958
  });
19324
- var LlmRuntimeDiskUsageSchema = object({
19325
- nodeId: string(),
19326
- modelsBytes: number(),
19327
- freeBytes: number().optional()
19959
+ /**
19960
+ * Optional, richer endpoint shape returned by providers that expose
19961
+ * MORE than one ingress concurrently (Tailscale Ingress with mixed
19962
+ * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
19963
+ * the originating provider config (mode + sourcePort) so the
19964
+ * orchestrator UI can label rows distinctly. Providers that expose only
19965
+ * one endpoint just omit `listEndpoints` from their provider impl.
19966
+ */
19967
+ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
19968
+ /**
19969
+ * Stable id within the provider — typically `<mode>-<sourcePort>` so
19970
+ * the orchestrator can dedupe across `listEndpoints` polls.
19971
+ */
19972
+ id: string(),
19973
+ /** Operator-facing label (mirrors `MeshEndpoint.label`). */
19974
+ label: string(),
19975
+ /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
19976
+ mode: string().optional(),
19977
+ /** Originating local port the ingress fronts (informational). */
19978
+ sourcePort: number().optional()
19328
19979
  });
19329
- method(LlmGenerateBaseInputSchema.extend({
19330
- images: array(LlmImageSchema).optional(),
19331
- runtime: ManagedRuntimeConfigSchema,
19332
- /** The managed profile's timeout, threaded by the hub provider. */
19333
- timeoutMs: number().int().positive().optional()
19334
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
19335
- kind: "mutation",
19336
- auth: "admin"
19337
- }), method(object({}), _void(), {
19338
- kind: "mutation",
19339
- auth: "admin"
19340
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
19341
- kind: "mutation",
19342
- auth: "admin"
19343
- }), method(object({ file: string() }), _void(), {
19344
- kind: "mutation",
19345
- auth: "admin"
19346
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
19980
+ method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
19347
19981
  /**
19348
- * `llm`consumer-facing LLM surface (spec §1-§3). Collection-mode: array
19349
- * methods concat-fan across providers; single-row methods route to ONE
19350
- * provider by the `addonId` in the call input (the notification-output
19351
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
19352
- * (hub-placed); the cap stays open for future providers.
19982
+ * notification-outputcanonical, capability-gated notification delivery.
19983
+ *
19984
+ * Apprise-derived model (see
19985
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
19986
+ * callers emit ONE canonical `Notification`; each provider declares a
19987
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
19988
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
19989
+ * message to what the kind supports — callers never special-case a service.
19990
+ *
19991
+ * DESIGN DECISIONS (locked):
19992
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
19993
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
19994
+ * cap. Rationale: the admin UI needs one uniform surface across the
19995
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
19996
+ * alternative would fork the UI per addon and cannot host the
19997
+ * discovery→adopt flow.
19998
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
19999
+ * the generated cap-mount auto-`concatCollection`-fans them across every
20000
+ * registered provider (notifiers addon + HA addon) so one catalog is
20001
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
20002
+ * `addonId` the generated collection router extracts from the call input.
20003
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
20004
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
20005
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
20006
+ * base64 fallback needed.
19353
20007
  *
19354
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
19355
- * `apiKey` is a password field — providers REDACT it on read and merge on
19356
- * write; a stored key NEVER round-trips to a client.
20008
+ * TODO (deferred, closed-set change separate decision): add
20009
+ * `providerKind: 'notify'` so notification providers surface on the unified
20010
+ * admin "Integrations" page.
19357
20011
  */
19358
- var LlmProfileKindSchema = _enum([
19359
- "openai-compatible",
19360
- "openai",
19361
- "anthropic",
19362
- "google",
19363
- "managed-local"
20012
+ /**
20013
+ * Zentik-derived typed-media enum — the superset across every kind. Each
20014
+ * adapter picks what it supports and the degrade engine filters the rest.
20015
+ */
20016
+ var AttachmentMediaTypeSchema = _enum([
20017
+ "image",
20018
+ "video",
20019
+ "gif",
20020
+ "audio",
20021
+ "icon"
19364
20022
  ]);
19365
- var LlmProfileSchema = object({
20023
+ /**
20024
+ * A single attachment. Exactly one of `url` (remote source, most adapters
20025
+ * prefer this) or `bytes` (inline source; required for Pushover-style
20026
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
20027
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
20028
+ */
20029
+ var AttachmentSchema = object({
20030
+ mediaType: AttachmentMediaTypeSchema,
20031
+ url: string().optional(),
20032
+ bytes: _instanceof(Uint8Array).optional(),
20033
+ mime: string().optional(),
20034
+ name: string().optional()
20035
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
20036
+ var NotificationFormatSchema = _enum([
20037
+ "text",
20038
+ "markdown",
20039
+ "html"
20040
+ ]);
20041
+ /** A single tap-through action button. */
20042
+ var NotificationActionSchema = object({
19366
20043
  id: string(),
19367
- name: string(),
19368
- kind: LlmProfileKindSchema,
19369
- /** Stamped by the provider — keeps the fanned catalog routable. */
19370
- addonId: string(),
19371
- enabled: boolean(),
19372
- /** Vendor model id, or the managed runtime's loaded model. */
19373
- model: string(),
19374
- /** Required for openai-compatible; override for cloud kinds. */
19375
- baseUrl: string().optional(),
19376
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
19377
- apiKey: string().optional(),
19378
- supportsVision: boolean(),
19379
- temperature: number().min(0).max(2).optional(),
19380
- maxTokens: number().int().positive().optional(),
19381
- timeoutMs: number().int().positive().default(6e4),
19382
- extraHeaders: record(string(), string()).optional(),
19383
- /** kind === 'managed-local' only (spec §4). */
19384
- runtime: ManagedRuntimeConfigSchema.optional()
20044
+ label: string(),
20045
+ url: string().optional()
19385
20046
  });
19386
- /** ConfigUISchema tree passed through untyped on the wire (the
19387
- * notification-output `ConfigSchemaPassthrough` precedent at
19388
- * notification-output.cap.ts:151); the exported TS type re-tightens it. */
20047
+ /**
20048
+ * The canonical notification. `body` is the only hard field (Apprise model).
20049
+ * `priority` is a 5-level ORDINAL (1=lowest 3=normal(default) 5=urgent),
20050
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
20051
+ * the adapter maps this ordinal onto its native level. `level?` is an
20052
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
20053
+ * `priority` for that one target.
20054
+ */
20055
+ var NotificationSchema = object({
20056
+ body: string(),
20057
+ title: string().optional(),
20058
+ format: NotificationFormatSchema.default("text"),
20059
+ priority: number().int().min(1).max(5).default(3),
20060
+ level: string().optional(),
20061
+ attachments: array(AttachmentSchema).optional(),
20062
+ clickUrl: string().optional(),
20063
+ actions: array(NotificationActionSchema).optional(),
20064
+ sound: string().optional(),
20065
+ ttl: number().optional(),
20066
+ tag: string().optional(),
20067
+ deviceId: number().optional(),
20068
+ eventId: string().optional(),
20069
+ metadata: record(string(), unknown()).optional()
20070
+ });
20071
+ /** One declared native severity/priority level for a kind. */
20072
+ var TargetKindLevelSchema = object({
20073
+ id: string(),
20074
+ label: string(),
20075
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
20076
+ ordinal: number().int().min(1).max(5).nullable(),
20077
+ flags: object({
20078
+ critical: boolean().optional(),
20079
+ silent: boolean().optional(),
20080
+ noPush: boolean().optional()
20081
+ }).optional(),
20082
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
20083
+ requires: array(string()).optional(),
20084
+ description: string().optional()
20085
+ });
20086
+ /** The full capability block consulted before dispatch. */
20087
+ var TargetKindCapsSchema = object({
20088
+ attachments: object({
20089
+ mediaTypes: array(AttachmentMediaTypeSchema),
20090
+ mode: _enum([
20091
+ "url",
20092
+ "bytes",
20093
+ "both"
20094
+ ]),
20095
+ max: number().int().nonnegative(),
20096
+ maxBytes: number().int().positive().optional()
20097
+ }),
20098
+ /** Max action buttons (0 = none). */
20099
+ actions: number().int().nonnegative(),
20100
+ levels: array(TargetKindLevelSchema),
20101
+ format: array(NotificationFormatSchema),
20102
+ clickUrl: boolean(),
20103
+ sound: boolean(),
20104
+ ttl: boolean(),
20105
+ bodyMaxLen: number().int().positive()
20106
+ });
20107
+ /**
20108
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
20109
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
20110
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
20111
+ * the union is large and not meant for runtime validation here; the exported
20112
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
20113
+ */
19389
20114
  var ConfigSchemaPassthrough = unknown();
19390
- var LlmProfileKindDescriptorSchema = object({
19391
- kind: LlmProfileKindSchema,
20115
+ var TargetKindSchema = object({
20116
+ kind: string(),
19392
20117
  label: string(),
19393
20118
  icon: string(),
19394
20119
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
19395
20120
  addonId: string(),
19396
- configSchema: ConfigSchemaPassthrough
19397
- });
19398
- var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
19399
- var LlmDefaultSchema = object({
19400
- selector: LlmDefaultSelectorSchema,
19401
- profileId: string()
19402
- });
19403
- /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
19404
- var LlmUsageRollupSchema = object({
19405
- day: string(),
19406
- consumer: string(),
19407
- profileId: string(),
19408
- calls: number(),
19409
- okCalls: number(),
19410
- errorCalls: number(),
19411
- inputTokens: number(),
19412
- outputTokens: number(),
19413
- avgLatencyMs: number()
20121
+ configSchema: ConfigSchemaPassthrough,
20122
+ supportsDiscovery: boolean(),
20123
+ caps: TargetKindCapsSchema
19414
20124
  });
19415
- /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
19416
- var ManagedModelCatalogEntrySchema = object({
20125
+ /**
20126
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
20127
+ * (return a presence marker only) when serving `listTargets` — never
20128
+ * round-trip a stored secret to the UI.
20129
+ */
20130
+ var TargetSchema = object({
19417
20131
  id: string(),
19418
- label: string(),
19419
- family: string(),
19420
- purpose: _enum(["text", "vision"]),
19421
- url: string(),
19422
- sha256: string(),
19423
- sizeBytes: number(),
19424
- quantization: string(),
19425
- /** Load-time guidance shown in the picker. */
19426
- minRamBytes: number(),
19427
- contextSizeDefault: number().int(),
19428
- /** Vision models: companion projector file. */
19429
- mmprojUrl: string().optional()
20132
+ name: string(),
20133
+ kind: string(),
20134
+ addonId: string(),
20135
+ enabled: boolean(),
20136
+ config: record(string(), unknown())
19430
20137
  });
19431
- var LlmRuntimeNodeSchema = object({
19432
- nodeId: string(),
19433
- reachable: boolean(),
19434
- status: LlmRuntimeStatusSchema.optional(),
19435
- disk: LlmRuntimeDiskUsageSchema.optional(),
19436
- error: string().optional()
20138
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
20139
+ var DiscoveredTargetSchema = object({
20140
+ kind: string(),
20141
+ suggestedName: string(),
20142
+ config: record(string(), unknown())
19437
20143
  });
19438
- var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
19439
- var ProfileRefInputSchema = object({
19440
- addonId: string(),
19441
- profileId: string()
20144
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
20145
+ var RenderedAsSchema = object({
20146
+ level: string(),
20147
+ format: NotificationFormatSchema,
20148
+ attachmentsSent: number().int().nonnegative(),
20149
+ actionsSent: number().int().nonnegative(),
20150
+ truncated: boolean(),
20151
+ dropped: array(string())
19442
20152
  });
19443
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
19444
- kind: "mutation",
19445
- auth: "admin"
19446
- }), method(ProfileRefInputSchema, _void(), {
19447
- kind: "mutation",
19448
- auth: "admin"
19449
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
19450
- kind: "mutation",
19451
- auth: "admin"
19452
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
19453
- selector: LlmDefaultSelectorSchema,
19454
- profileId: string().nullable()
19455
- }), _void(), {
19456
- kind: "mutation",
19457
- auth: "admin"
19458
- }), method(object({
19459
- since: number().optional(),
19460
- until: number().optional(),
19461
- consumer: string().optional(),
19462
- profileId: string().optional()
19463
- }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
19464
- nodeId: string(),
19465
- model: ManagedModelRefSchema
19466
- }), _void(), {
19467
- kind: "mutation",
19468
- auth: "admin"
19469
- }), method(object({
19470
- nodeId: string(),
19471
- file: string()
19472
- }), _void(), {
19473
- kind: "mutation",
19474
- auth: "admin"
19475
- }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
19476
- kind: "mutation",
19477
- auth: "admin"
19478
- }), method(ProfileRefInputSchema, _void(), {
19479
- kind: "mutation",
19480
- auth: "admin"
20153
+ var SendResultSchema = object({
20154
+ success: boolean(),
20155
+ error: string().optional(),
20156
+ renderedAs: RenderedAsSchema.optional()
19481
20157
  });
20158
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
20159
+ var TestResultSchema = SendResultSchema;
20160
+ var notificationOutputCapability = {
20161
+ name: "notification-output",
20162
+ scope: "system",
20163
+ mode: "collection",
20164
+ methods: {
20165
+ listTargetKinds: method(object({}), array(TargetKindSchema)),
20166
+ listTargets: method(object({}), array(TargetSchema)),
20167
+ discoverTargets: method(object({
20168
+ kind: string(),
20169
+ config: record(string(), unknown()).optional()
20170
+ }), array(DiscoveredTargetSchema)),
20171
+ send: method(object({
20172
+ targetId: string(),
20173
+ notification: NotificationSchema
20174
+ }), SendResultSchema, { kind: "mutation" }),
20175
+ testTarget: method(object({
20176
+ targetId: string(),
20177
+ sample: NotificationSchema.optional()
20178
+ }), TestResultSchema, { kind: "mutation" }),
20179
+ upsertTarget: method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }),
20180
+ deleteTarget: method(object({ targetId: string() }), _void(), { kind: "mutation" }),
20181
+ setTargetEnabled: method(object({
20182
+ targetId: string(),
20183
+ enabled: boolean()
20184
+ }), _void(), { kind: "mutation" })
20185
+ }
20186
+ };
19482
20187
  /**
19483
20188
  * Zod schemas for persisted record types.
19484
20189
  *
@@ -20164,7 +20869,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
20164
20869
  }), method(object({
20165
20870
  eventId: string(),
20166
20871
  kind: MediaFileKindEnum.optional()
20167
- }), array(MediaFileSchema).readonly()), method(object({ trackId: string() }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
20872
+ }), array(MediaFileSchema).readonly()), method(object({
20873
+ trackId: string(),
20874
+ kinds: array(MediaFileKindEnum).optional()
20875
+ }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
20168
20876
  deviceId: number(),
20169
20877
  timestamp: number(),
20170
20878
  frameWidth: number(),
@@ -20185,76 +20893,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
20185
20893
  eventId: string(),
20186
20894
  timestamp: number()
20187
20895
  });
20188
- /**
20189
- * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
20190
- * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
20191
- * caps into per-camera event-kind descriptors.
20192
- *
20193
- * The descriptor DATA (color / iconId / labelKey / parentKind / category)
20194
- * is NOT duplicated here — every entry is derived from the single
20195
- * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
20196
- * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
20197
- * control cap means adding one line here (and a taxonomy entry); the anti-
20198
- * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
20199
- * eventful cap is missing.
20200
- */
20201
- /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
20202
- var LEGACY_ICON = {
20203
- motion: "motion",
20204
- audio: "audio",
20205
- person: "person",
20206
- vehicle: "vehicle",
20207
- animal: "animal",
20208
- package: "package",
20209
- door: "door",
20210
- pir: "pir",
20211
- smoke: "smoke",
20212
- water: "water",
20213
- button: "button",
20214
- generic: "generic",
20215
- gas: "smoke",
20216
- vibration: "generic",
20217
- tamper: "generic",
20218
- presence: "person",
20219
- lock: "generic",
20220
- siren: "generic",
20221
- switch: "generic",
20222
- doorbell: "button"
20223
- };
20224
- function legacyIcon(iconId) {
20225
- return LEGACY_ICON[iconId] ?? "generic";
20226
- }
20227
- /**
20228
- * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
20229
- * The anti-drift guard cross-checks this against the eventful caps declared
20230
- * in `packages/types/src/capabilities/*.cap.ts`.
20231
- */
20232
- var CAP_TO_KIND = {
20233
- contact: "contact",
20234
- motion: "motion-sensor",
20235
- smoke: "smoke",
20236
- flood: "flood",
20237
- gas: "gas",
20238
- "carbon-monoxide": "carbon-monoxide",
20239
- vibration: "vibration",
20240
- tamper: "tamper",
20241
- presence: "presence",
20242
- "enum-sensor": "enum-sensor",
20243
- "event-emitter": "device-event",
20244
- "lock-control": "lock",
20245
- switch: "switch",
20246
- button: "button",
20247
- doorbell: "doorbell"
20248
- };
20249
- function buildDescriptor(capName, kind) {
20250
- const t = EVENT_TAXONOMY[kind];
20251
- if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
20252
- return {
20253
- ...t,
20254
- icon: legacyIcon(t.iconId)
20255
- };
20256
- }
20257
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
20258
20896
  var CameraPipelineConfigSchema = object({
20259
20897
  engine: PipelineEngineChoiceSchema.optional(),
20260
20898
  steps: array(PipelineStepInputSchema).readonly(),
@@ -20740,6 +21378,76 @@ method(object({
20740
21378
  auth: "admin"
20741
21379
  });
20742
21380
  /**
21381
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
21382
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
21383
+ * caps into per-camera event-kind descriptors.
21384
+ *
21385
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
21386
+ * is NOT duplicated here — every entry is derived from the single
21387
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
21388
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
21389
+ * control cap means adding one line here (and a taxonomy entry); the anti-
21390
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
21391
+ * eventful cap is missing.
21392
+ */
21393
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
21394
+ var LEGACY_ICON = {
21395
+ motion: "motion",
21396
+ audio: "audio",
21397
+ person: "person",
21398
+ vehicle: "vehicle",
21399
+ animal: "animal",
21400
+ package: "package",
21401
+ door: "door",
21402
+ pir: "pir",
21403
+ smoke: "smoke",
21404
+ water: "water",
21405
+ button: "button",
21406
+ generic: "generic",
21407
+ gas: "smoke",
21408
+ vibration: "generic",
21409
+ tamper: "generic",
21410
+ presence: "person",
21411
+ lock: "generic",
21412
+ siren: "generic",
21413
+ switch: "generic",
21414
+ doorbell: "button"
21415
+ };
21416
+ function legacyIcon(iconId) {
21417
+ return LEGACY_ICON[iconId] ?? "generic";
21418
+ }
21419
+ /**
21420
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
21421
+ * The anti-drift guard cross-checks this against the eventful caps declared
21422
+ * in `packages/types/src/capabilities/*.cap.ts`.
21423
+ */
21424
+ var CAP_TO_KIND = {
21425
+ contact: "contact",
21426
+ motion: "motion-sensor",
21427
+ smoke: "smoke",
21428
+ flood: "flood",
21429
+ gas: "gas",
21430
+ "carbon-monoxide": "carbon-monoxide",
21431
+ vibration: "vibration",
21432
+ tamper: "tamper",
21433
+ presence: "presence",
21434
+ "enum-sensor": "enum-sensor",
21435
+ "event-emitter": "device-event",
21436
+ "lock-control": "lock",
21437
+ switch: "switch",
21438
+ button: "button",
21439
+ doorbell: "doorbell"
21440
+ };
21441
+ function buildDescriptor(capName, kind) {
21442
+ const t = EVENT_TAXONOMY[kind];
21443
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
21444
+ return {
21445
+ ...t,
21446
+ icon: legacyIcon(t.iconId)
21447
+ };
21448
+ }
21449
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
21450
+ /**
20743
21451
  * server-management — per-NODE singleton capability for a node's ROOT
20744
21452
  * package lifecycle (runtime-updatable node packages).
20745
21453
  *
@@ -22283,7 +22991,28 @@ var FaceInfoSchema = object({
22283
22991
  * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`). Absent when the
22284
22992
  * track produced no key frame (e.g. native/onboard source) — the UI falls
22285
22993
  * back to the inline `base64` face crop. */
22286
- keyFrameMediaKey: string().optional()
22994
+ keyFrameMediaKey: string().optional(),
22995
+ /** Winning identity-match cosine (0..1) for this face's track, when an
22996
+ * identity was auto-confirmed. Lets the UI surface WHY a face was assigned
22997
+ * (confidence badge / low-confidence audit). Absent on legacy rows and on
22998
+ * faces that were never auto-recognized. */
22999
+ bestMatchScore: number().optional(),
23000
+ /** Native-scale face short side (px) at recognition time, when the runner
23001
+ * measured it. Lets the UI flag low-resolution auto-assignments. Absent on
23002
+ * legacy rows / runners that reported no native measure. */
23003
+ nativeFaceShortSidePx: number().optional(),
23004
+ /** SUGGESTED identity for this face — a plausible-but-not-confident match that
23005
+ * MISSED auto-assignment (cosine in the suggestion band, or above threshold
23006
+ * but blocked only by the recognition size floor). Mutually exclusive with
23007
+ * `recognizedIdentityId` (a suggestion is NEVER an assignment): the face stays
23008
+ * UNASSIGNED and everything else keeps treating it as unrecognized — the UI
23009
+ * merely offers a one-tap "is this <name>?" confirm. Absent on legacy rows and
23010
+ * on faces that were auto-assigned or below the suggestion band. (2026-07-24) */
23011
+ suggestedIdentityId: string().optional(),
23012
+ /** Peak identity-match cosine (0..1) for `suggestedIdentityId`, captured at the
23013
+ * same moment as `bestMatchScore` (track peak, at close). Lets the UI rank /
23014
+ * badge suggestion confidence. Present iff `suggestedIdentityId` is. (2026-07-24) */
23015
+ suggestedMatchScore: number().optional()
22287
23016
  });
22288
23017
  var FaceFilterEnum = _enum([
22289
23018
  "unassigned",
@@ -24326,36 +25055,6 @@ Object.freeze({
24326
25055
  addonId: null,
24327
25056
  access: "view"
24328
25057
  },
24329
- "advancedNotifier.deleteRule": {
24330
- capName: "advanced-notifier",
24331
- capScope: "system",
24332
- addonId: null,
24333
- access: "delete"
24334
- },
24335
- "advancedNotifier.getHistory": {
24336
- capName: "advanced-notifier",
24337
- capScope: "system",
24338
- addonId: null,
24339
- access: "view"
24340
- },
24341
- "advancedNotifier.getRules": {
24342
- capName: "advanced-notifier",
24343
- capScope: "system",
24344
- addonId: null,
24345
- access: "view"
24346
- },
24347
- "advancedNotifier.testRule": {
24348
- capName: "advanced-notifier",
24349
- capScope: "system",
24350
- addonId: null,
24351
- access: "create"
24352
- },
24353
- "advancedNotifier.upsertRule": {
24354
- capName: "advanced-notifier",
24355
- capScope: "system",
24356
- addonId: null,
24357
- access: "create"
24358
- },
24359
25058
  "alarmPanel.arm": {
24360
25059
  capName: "alarm-panel",
24361
25060
  capScope: "device",
@@ -24578,6 +25277,12 @@ Object.freeze({
24578
25277
  addonId: null,
24579
25278
  access: "delete"
24580
25279
  },
25280
+ "backup.deleteSchedule": {
25281
+ capName: "backup",
25282
+ capScope: "system",
25283
+ addonId: null,
25284
+ access: "delete"
25285
+ },
24581
25286
  "backup.getEntries": {
24582
25287
  capName: "backup",
24583
25288
  capScope: "system",
@@ -24608,6 +25313,12 @@ Object.freeze({
24608
25313
  addonId: null,
24609
25314
  access: "view"
24610
25315
  },
25316
+ "backup.listSchedules": {
25317
+ capName: "backup",
25318
+ capScope: "system",
25319
+ addonId: null,
25320
+ access: "view"
25321
+ },
24611
25322
  "backup.previewSchedule": {
24612
25323
  capName: "backup",
24613
25324
  capScope: "system",
@@ -24632,6 +25343,12 @@ Object.freeze({
24632
25343
  addonId: null,
24633
25344
  access: "create"
24634
25345
  },
25346
+ "backup.upsertSchedule": {
25347
+ capName: "backup",
25348
+ capScope: "system",
25349
+ addonId: null,
25350
+ access: "create"
25351
+ },
24635
25352
  "battery.wakeForStream": {
24636
25353
  capName: "battery",
24637
25354
  capScope: "device",
@@ -26660,6 +27377,60 @@ Object.freeze({
26660
27377
  addonId: null,
26661
27378
  access: "create"
26662
27379
  },
27380
+ "notificationRules.createRule": {
27381
+ capName: "notification-rules",
27382
+ capScope: "system",
27383
+ addonId: null,
27384
+ access: "create"
27385
+ },
27386
+ "notificationRules.deleteRule": {
27387
+ capName: "notification-rules",
27388
+ capScope: "system",
27389
+ addonId: null,
27390
+ access: "delete"
27391
+ },
27392
+ "notificationRules.getConditionCatalog": {
27393
+ capName: "notification-rules",
27394
+ capScope: "system",
27395
+ addonId: null,
27396
+ access: "view"
27397
+ },
27398
+ "notificationRules.getHistory": {
27399
+ capName: "notification-rules",
27400
+ capScope: "system",
27401
+ addonId: null,
27402
+ access: "view"
27403
+ },
27404
+ "notificationRules.getRule": {
27405
+ capName: "notification-rules",
27406
+ capScope: "system",
27407
+ addonId: null,
27408
+ access: "view"
27409
+ },
27410
+ "notificationRules.listRules": {
27411
+ capName: "notification-rules",
27412
+ capScope: "system",
27413
+ addonId: null,
27414
+ access: "view"
27415
+ },
27416
+ "notificationRules.setRuleEnabled": {
27417
+ capName: "notification-rules",
27418
+ capScope: "system",
27419
+ addonId: null,
27420
+ access: "create"
27421
+ },
27422
+ "notificationRules.testRule": {
27423
+ capName: "notification-rules",
27424
+ capScope: "system",
27425
+ addonId: null,
27426
+ access: "create"
27427
+ },
27428
+ "notificationRules.updateRule": {
27429
+ capName: "notification-rules",
27430
+ capScope: "system",
27431
+ addonId: null,
27432
+ access: "create"
27433
+ },
26663
27434
  "notifier.cancel": {
26664
27435
  capName: "notifier",
26665
27436
  capScope: "device",
@@ -28412,6 +29183,36 @@ Object.freeze({
28412
29183
  addonId: null,
28413
29184
  access: "create"
28414
29185
  },
29186
+ "terminalSession.close": {
29187
+ capName: "terminal-session",
29188
+ capScope: "system",
29189
+ addonId: null,
29190
+ access: "create"
29191
+ },
29192
+ "terminalSession.listProfiles": {
29193
+ capName: "terminal-session",
29194
+ capScope: "system",
29195
+ addonId: null,
29196
+ access: "view"
29197
+ },
29198
+ "terminalSession.listSessions": {
29199
+ capName: "terminal-session",
29200
+ capScope: "system",
29201
+ addonId: null,
29202
+ access: "view"
29203
+ },
29204
+ "terminalSession.openSession": {
29205
+ capName: "terminal-session",
29206
+ capScope: "system",
29207
+ addonId: null,
29208
+ access: "create"
29209
+ },
29210
+ "terminalSession.resize": {
29211
+ capName: "terminal-session",
29212
+ capScope: "system",
29213
+ addonId: null,
29214
+ access: "create"
29215
+ },
28415
29216
  "toast.onToast": {
28416
29217
  capName: "toast",
28417
29218
  capScope: "system",