@camstack/addon-provider-hikvision 1.2.5 → 1.2.7

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