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