@camstack/addon-provider-rtsp 1.2.4 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +1924 -1123
  2. package/dist/addon.mjs +1924 -1123
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -23,7 +23,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
23
  //#endregion
24
24
  let node_net = require("node:net");
25
25
  node_net = __toESM(node_net);
26
- //#region ../types/dist/event-category-D4HJq7Mw.mjs
26
+ //#region ../types/dist/event-category-BLcNejAE.mjs
27
27
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
28
28
  EventCategory["SystemBoot"] = "system.boot";
29
29
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -173,9 +173,6 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
173
173
  EventCategory["RecordingSegmentWritten"] = "recording.segment.written";
174
174
  EventCategory["RecordingPolicyFallback"] = "recording.policy.fallback";
175
175
  EventCategory["RecordingRetentionCompleted"] = "recording.retention.completed";
176
- /** Runner-sampled scrub thumbnail (~1/5 s/camera). Telemetry (D8): a lost
177
- * thumb is a scrub gap the recorder's keyframe backfill covers. */
178
- EventCategory["RecordingThumbSampled"] = "recording.thumb-sampled";
179
176
  /** Export render progress (0–100). Telemetry (D8): a lost tick is a stale
180
177
  * progress bar the client reconciles via `recordingExport.getExport`. */
181
178
  EventCategory["RecordingExportProgress"] = "recording.export.progress";
@@ -6854,7 +6851,6 @@ object({ deviceId: number() }), object({ deviceId: number() }), object({
6854
6851
  patch: record(string(), unknown())
6855
6852
  }), object({ success: literal(true) });
6856
6853
  object({ deviceId: number() }), unknown().nullable();
6857
- /** Shorthand to define a method schema */
6858
6854
  function method(input, output, options) {
6859
6855
  return {
6860
6856
  input,
@@ -6862,6 +6858,7 @@ function method(input, output, options) {
6862
6858
  kind: options?.kind ?? "query",
6863
6859
  auth: options?.auth ?? "protected",
6864
6860
  ...options?.access !== void 0 ? { access: options.access } : {},
6861
+ ...options?.caller !== void 0 ? { caller: options.caller } : {},
6865
6862
  timeoutMs: options?.timeoutMs
6866
6863
  };
6867
6864
  }
@@ -7547,16 +7544,23 @@ var StorageLocationDeclarationSchema = object({
7547
7544
  * Which node root the seeded `<id>:default` instance is placed under on a
7548
7545
  * FRESH install:
7549
7546
  * - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
7550
- * the appData volume. Right for small/durable data (backups, logs, models).
7547
+ * the appData volume. Right for small/durable data (logs, models).
7551
7548
  * - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
7552
7549
  * env is set, else falls back to the data root. Right for bulky, hot media
7553
7550
  * (recordings, event media) that should stay off the appData disk.
7551
+ * - `'backup'` — the dedicated backup volume (`CAMSTACK_BACKUP_ROOT`, default
7552
+ * `/backups` in the image) so archives live on their own mount rather than
7553
+ * filling the appData disk. Falls back to the data root when unset.
7554
7554
  *
7555
7555
  * Only affects the seeded default's `basePath`; operators can repoint any
7556
7556
  * location afterwards, and a `defaultsTo` slot inherits its parent's root
7557
7557
  * regardless of this field. Absent (the common case) is treated as `'data'`.
7558
7558
  */
7559
- defaultRoot: _enum(["data", "media"]).optional()
7559
+ defaultRoot: _enum([
7560
+ "data",
7561
+ "media",
7562
+ "backup"
7563
+ ]).optional()
7560
7564
  });
7561
7565
  /**
7562
7566
  * Compute pixel count for sorting. Returns w*h, or 0 if unknown.
@@ -8251,6 +8255,59 @@ for (const l of AUDIO_MACRO_LABELS) {
8251
8255
  /** The complete taxonomy dictionary, keyed by kind. */
8252
8256
  var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
8253
8257
  /**
8258
+ * Notification-Center taxonomy — the fixed vocabulary the NC rule editor
8259
+ * offers as pickers instead of free text. Derived (never hand-listed) from the
8260
+ * single `EVENT_TAXONOMY` dictionary so it stays in lockstep with every other
8261
+ * taxonomy surface (timeline, filters, event page).
8262
+ *
8263
+ * Three buckets, mapped onto the rule editor's `stringList` conditions:
8264
+ * - `videoClasses` → detection classes (person / vehicle / animal + subs)
8265
+ * for the `classes` / `classesExclude` conditions.
8266
+ * - `audioKinds` → audio-analyzer sub kinds (`audio-scream`, …) shown in
8267
+ * the same class picker, grouped under an Audio header.
8268
+ * - `labels` → sensor + control taxonomy kinds (doorbell / contact /
8269
+ * lock / …) for the `sensorKinds` device-event condition.
8270
+ *
8271
+ * Each entry carries `parentKind` so the client can group video subs under
8272
+ * their macro and sensor/control kinds under their category. This surface is
8273
+ * served ADDITIVELY on the `nc.getConditionCatalog` bridge response — no cap
8274
+ * method, no codegen — so it ships train-free with an addon deploy.
8275
+ */
8276
+ /** One selectable taxonomy value: a stable kind id + display label + parent. */
8277
+ var NcTaxonomyEntrySchema = object({
8278
+ /** Stable kind id (e.g. 'person', 'car', 'audio-scream', 'doorbell'). */
8279
+ kind: string(),
8280
+ /** English fallback label (the UI translates via the event-kind i18n key). */
8281
+ label: string(),
8282
+ /** Macro/category parent for grouping ('car' → 'vehicle'); null for a top. */
8283
+ parentKind: string().nullable()
8284
+ });
8285
+ object({
8286
+ videoClasses: array(NcTaxonomyEntrySchema),
8287
+ audioKinds: array(NcTaxonomyEntrySchema),
8288
+ labels: array(NcTaxonomyEntrySchema)
8289
+ });
8290
+ function toEntry(kind, label, parentKind) {
8291
+ return {
8292
+ kind,
8293
+ label,
8294
+ parentKind
8295
+ };
8296
+ }
8297
+ /**
8298
+ * Build the NC taxonomy from `EVENT_TAXONOMY`. Insertion order is preserved
8299
+ * (macros before their subs), which the client relies on for stable grouping.
8300
+ */
8301
+ function buildNcTaxonomy() {
8302
+ const all = Object.values(EVENT_TAXONOMY);
8303
+ return {
8304
+ videoClasses: all.filter((e) => e.category === "detection").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8305
+ audioKinds: all.filter((e) => e.category === "audio" && e.level === "sub").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8306
+ labels: all.filter((e) => e.category === "sensor" || e.category === "control").map((e) => toEntry(e.kind, e.label, e.parentKind))
8307
+ };
8308
+ }
8309
+ Object.freeze(buildNcTaxonomy());
8310
+ /**
8254
8311
  * Error types for the safe expression engine. Two distinct classes so callers
8255
8312
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
8256
8313
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -9195,6 +9252,644 @@ function startReachabilityPoll(options) {
9195
9252
  } };
9196
9253
  }
9197
9254
  /**
9255
+ * Shared geometry vocabulary for on-frame shape caps — privacy-mask,
9256
+ * motion-zones, and the detection zones/lines editor all speak this one
9257
+ * language so a single drawing-plane editor and the providers stay
9258
+ * decoupled from each cap's storage.
9259
+ *
9260
+ * All coordinates are normalized 0..1 of the camera frame (top-left
9261
+ * origin). Each cap composes the SUBSET of shape kinds it supports and
9262
+ * advertises it via `supportedShapes` in its `getOptions`.
9263
+ */
9264
+ /** A normalized 0..1 point (top-left origin). */
9265
+ var MaskPointSchema = object({
9266
+ x: number(),
9267
+ y: number()
9268
+ });
9269
+ /** Axis-aligned rectangle (normalized 0..1). */
9270
+ var MaskRectShapeSchema = object({
9271
+ kind: literal("rect"),
9272
+ x: number(),
9273
+ y: number(),
9274
+ width: number(),
9275
+ height: number()
9276
+ });
9277
+ /** Free polygon — an ordered list of normalized vertices (≥3). */
9278
+ var MaskPolygonShapeSchema = object({
9279
+ kind: literal("polygon"),
9280
+ points: array(MaskPointSchema)
9281
+ });
9282
+ /** Boolean cell grid — row-major, length === gridWidth*gridHeight. */
9283
+ var MaskGridShapeSchema = object({
9284
+ kind: literal("grid"),
9285
+ gridWidth: number(),
9286
+ gridHeight: number(),
9287
+ cells: array(boolean())
9288
+ });
9289
+ discriminatedUnion("kind", [
9290
+ MaskRectShapeSchema,
9291
+ MaskPolygonShapeSchema,
9292
+ MaskGridShapeSchema,
9293
+ object({
9294
+ kind: literal("line"),
9295
+ points: array(MaskPointSchema)
9296
+ })
9297
+ ]);
9298
+ /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
9299
+ var MaskShapeKindSchema = _enum([
9300
+ "rect",
9301
+ "polygon",
9302
+ "grid",
9303
+ "line"
9304
+ ]);
9305
+ /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
9306
+ var MaskPolygonVerticesSchema = object({
9307
+ min: number(),
9308
+ max: number()
9309
+ });
9310
+ /** Grid dimensions when a cap supports 'grid'. */
9311
+ var MaskGridDimsSchema = object({
9312
+ width: number(),
9313
+ height: number()
9314
+ });
9315
+ /**
9316
+ * notification-rules — the Notification Center rule surface (P1 core).
9317
+ *
9318
+ * Spec: `docs/superpowers/specs/2026-07-22-notification-center-requirements.md`
9319
+ * (operator decisions D-1/D-2/D-3 are binding):
9320
+ *
9321
+ * - D-2: rule EVALUATION lives in `addon-post-analysis` (the
9322
+ * `notification-center` module), hooked on the durable persistence
9323
+ * moments (object-event insert, TrackCloser.closeExpired) with a
9324
+ * persisted outbox + retry — never the lossy telemetry bus (D8).
9325
+ * - D-3: urgency belongs to the RULE. `delivery: 'immediate'` fires on the
9326
+ * FIRST persisted detection matching the conditions (per-track dedup,
9327
+ * `maxPerTrack` fixed at 1 — see {@link NC_MAX_PER_TRACK_IMMEDIATE});
9328
+ * `delivery: 'track-end'` evaluates the finalized track record at close.
9329
+ * - DISPATCH stays behind `notification-output` (rules reference targets
9330
+ * by id; per-backend params are a passthrough blob capped by the
9331
+ * target kind's own caps/degrade engine).
9332
+ *
9333
+ * P1 scope: admin-authored rules only (`createdBy` stamped from the
9334
+ * server-injected caller identity — the first `caller: 'required'`
9335
+ * adopter). The P1 condition subset is: devices, classes(+exclude),
9336
+ * minConfidence, admin zones (any/all + exclude), weekly schedule
9337
+ * windows, and the optional label/identity/plate matchers. User rules,
9338
+ * private zones, per-recipient fan-out and the wider condition table are
9339
+ * P2+ (see spec §7).
9340
+ *
9341
+ * All schemas here are the single source of truth — `NcRule` etc. are
9342
+ * `z.infer` exports; no duplicate interfaces (the advanced-notifier
9343
+ * schema/interface drift is explicitly not repeated).
9344
+ */
9345
+ /**
9346
+ * D-3: the trigger/urgency of a rule — which persistence moment evaluates it.
9347
+ * The value maps 1:1 onto the evaluated record kind:
9348
+ * - `immediate` ↔ object-event persist (lowest-latency detection burst)
9349
+ * - `track-end` ↔ TrackCloser.closeExpired (finalized track record)
9350
+ * - `device-event` ↔ SensorEventStore insert (doorbell press / sensor state
9351
+ * change of a LINKED device, one row per linked camera)
9352
+ * - `package-event` ↔ PackageDropDetector object-event insert (a `package`
9353
+ * delivery / pick-up)
9354
+ *
9355
+ * `immediate`/`track-end` carry the D-3 urgency semantics; `device-event`/
9356
+ * `package-event` are pure trigger kinds (no urgency dimension). Extending
9357
+ * this one field keeps the schema additive — a rule still declares exactly
9358
+ * one trigger.
9359
+ */
9360
+ var NcDeliverySchema = _enum([
9361
+ "immediate",
9362
+ "track-end",
9363
+ "device-event",
9364
+ "package-event"
9365
+ ]);
9366
+ /** Weekly schedule — OR of windows; absence on the rule = always active. */
9367
+ var NcScheduleSchema = object({
9368
+ windows: array(object({
9369
+ /** Days of week the window STARTS on (0 = Sunday … 6 = Saturday). */
9370
+ days: array(number().int().min(0).max(6)).min(1),
9371
+ startMinute: number().int().min(0).max(1439),
9372
+ endMinute: number().int().min(0).max(1439)
9373
+ })).min(1),
9374
+ /** IANA timezone; default = hub host timezone. */
9375
+ timezone: string().optional(),
9376
+ /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
9377
+ invert: boolean().optional()
9378
+ });
9379
+ /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
9380
+ var NcPlateMatcherSchema = object({
9381
+ values: array(string().min(1)).min(1),
9382
+ /** Max Levenshtein distance after normalization (uppercase alphanumeric). */
9383
+ maxDistance: number().int().min(0).max(3).default(1)
9384
+ });
9385
+ /**
9386
+ * Occupancy condition (DEVICE-EVENT trigger). Fires on a ZoneAnalytics
9387
+ * occupancy edge for a device — optionally narrowed to a single admin
9388
+ * `zoneId` and/or object `className`. `op` selects the edge/threshold:
9389
+ * - `became-occupied` (default) — count crossed 0 → ≥ `count`
9390
+ * - `became-free` — count crossed ≥ `count` → below it
9391
+ * - `>=` / `<=` — count is at/over or at/under `count`
9392
+ * `sustainSeconds` requires the condition hold continuously that long
9393
+ * before firing (debounces flicker; 0 = fire on the first matching edge).
9394
+ * Fail-closed: no ZoneAnalytics snapshot / missing zone / null snapshot ⇒
9395
+ * the condition never matches. Confirmed edge-state survives addon restarts
9396
+ * (declared SQLite collection, reseeded on boot).
9397
+ */
9398
+ var NcOccupancyConditionSchema = object({
9399
+ /** Admin zone id to scope the count to; absent = whole-frame occupancy. */
9400
+ zoneId: string().optional(),
9401
+ /** Object class to count; absent = any class. */
9402
+ className: string().optional(),
9403
+ op: _enum([
9404
+ "became-occupied",
9405
+ "became-free",
9406
+ ">=",
9407
+ "<="
9408
+ ]).default("became-occupied"),
9409
+ count: number().int().min(0).default(1),
9410
+ sustainSeconds: number().int().min(0).max(3600).default(15)
9411
+ });
9412
+ /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
9413
+ var NcZoneConditionSchema = object({
9414
+ ids: array(string().min(1)).min(1),
9415
+ /** Quantifier over `ids` — at least one / every one visited. */
9416
+ match: _enum(["any", "all"]).default("any")
9417
+ });
9418
+ /**
9419
+ * The P1 condition set — a flat AND of groups; absent group = pass;
9420
+ * membership lists are OR within the list (spec §2.3).
9421
+ */
9422
+ var NcConditionsSchema = object({
9423
+ /** Device scope — absent = all devices. */
9424
+ devices: array(number()).optional(),
9425
+ /** Detector class names (any overlap with the record's class set). */
9426
+ classes: array(string().min(1)).optional(),
9427
+ /** Veto classes — any overlap fails the rule. */
9428
+ classesExclude: array(string().min(1)).optional(),
9429
+ /** Minimum detection confidence 0–1 (fails when the record has none). */
9430
+ minConfidence: number().min(0).max(1).optional(),
9431
+ /** Admin zone membership over event `zones` / track `zonesVisited`. */
9432
+ zones: NcZoneConditionSchema.optional(),
9433
+ /** Veto zones — any hit fails the rule. */
9434
+ zonesExclude: array(string().min(1)).optional(),
9435
+ /**
9436
+ * Exact (case-insensitive) match on the record's collapsed `label`
9437
+ * (identity name / plate text / subclass).
9438
+ */
9439
+ labelEquals: array(string().min(1)).optional(),
9440
+ /**
9441
+ * Identity matcher. P1 boundary: matched against the record's collapsed
9442
+ * `label` (the identity display name propagated by the face pipeline) —
9443
+ * identity-ID matching rides in P2 when identity ids reach the record.
9444
+ */
9445
+ identities: array(string().min(1)).optional(),
9446
+ /** Fuzzy plate matcher against the record's `label` (plate text). */
9447
+ plates: NcPlateMatcherSchema.optional(),
9448
+ /**
9449
+ * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
9450
+ * Same P1 boundary: matched against the record's collapsed `label` (the
9451
+ * identity display name). A record with NO label passes (nothing to
9452
+ * exclude), unlike the include variant which fails on an absent label.
9453
+ */
9454
+ identitiesExclude: array(string().min(1)).optional(),
9455
+ /**
9456
+ * Minimum server-computed key-event importance in [0,1] (`Track.importance`).
9457
+ * TRACK-END only: importance is scored at track close, so it does not exist
9458
+ * at immediate / object-event evaluation time (see catalog `appliesTo`). At
9459
+ * close the value is threaded via the close-time info (the `Track` clone is
9460
+ * captured before the DB row is updated, so it would otherwise read stale).
9461
+ * Fails when the record carries no importance (never guess quality — the
9462
+ * `minConfidence` precedent). MVP cut: a single scalar threshold.
9463
+ */
9464
+ minImportance: number().min(0).max(1).optional(),
9465
+ /**
9466
+ * Minimum track dwell in SECONDS — `(lastSeen − firstSeen) / 1000`.
9467
+ * TRACK-END only: an `immediate` / object-event subject has no closed
9468
+ * lifespan, so a dwell condition never matches immediate delivery
9469
+ * (documented choice — the object-event record carries no `firstSeen`,
9470
+ * so dwell cannot be computed from what the subject actually carries).
9471
+ */
9472
+ minDwellSeconds: number().min(0).optional(),
9473
+ /**
9474
+ * Detection provenance filter. `any` (default / absent) matches every
9475
+ * source; otherwise the subject's source must equal it. Legacy records
9476
+ * with no stamped source are treated as `pipeline`. The union spans both
9477
+ * record kinds — object events carry `pipeline` | `onboard`, synthetic
9478
+ * tracks carry `sensor`.
9479
+ */
9480
+ source: _enum([
9481
+ "pipeline",
9482
+ "onboard",
9483
+ "sensor",
9484
+ "any"
9485
+ ]).optional(),
9486
+ /**
9487
+ * Minimum identity / plate MATCH confidence in [0,1] — DISTINCT from the
9488
+ * detector `minConfidence` (that gates the object-detection score; this
9489
+ * gates the recognition/OCR match score). Fails when the subject carries
9490
+ * no label-match confidence (never guess). TRACK-END only: the confidence
9491
+ * lives on the recognition result and reaches the subject at track close.
9492
+ *
9493
+ * What it measures precisely (plumbed at track close — the closer threads
9494
+ * the value into `NcTrackClosedInfo.labelConfidence`, the same seam as
9495
+ * `importance`): the BEST recognition match confidence observed for the
9496
+ * label the track carries at close — for a face, the peak cosine similarity
9497
+ * of the ASSIGNED identity (`FaceMatch.score`, reset on an identity switch);
9498
+ * for a plate, the peak OCR read score of the best-held plate
9499
+ * (`plateText.confidence`). When BOTH a face and a plate were recognized on
9500
+ * one track the higher of the two is used. A track that ended with no
9501
+ * confident identity/plate match carries no value, so the condition fails
9502
+ * closed for it (an un-recognized subject).
9503
+ */
9504
+ minLabelConfidence: number().min(0).max(1).optional(),
9505
+ /**
9506
+ * DEVICE-EVENT only. Raw device event-type tokens (`EventFire.eventType`,
9507
+ * e.g. a doorbell `press` / `press_long`) — matched case-insensitively
9508
+ * against the token carried on the device-event subject (extracted from the
9509
+ * event-emitter runtime slice's `lastEvent.eventType`). Fails when the
9510
+ * subject carries no token. Doorbell-pulse / passive-sensor kinds emit no
9511
+ * eventType, so gate those with {@link sensorKinds} instead.
9512
+ */
9513
+ eventTypeTokens: array(string().min(1)).optional(),
9514
+ /**
9515
+ * DEVICE-EVENT only. Sensor/control taxonomy kinds (e.g. `doorbell`,
9516
+ * `contact`, `button`, `device-event`) — matched against the persisted
9517
+ * `SensorEvent.kind` (see `sensor-event-kinds.ts`). Membership is OR.
9518
+ */
9519
+ sensorKinds: array(string().min(1)).optional(),
9520
+ /**
9521
+ * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
9522
+ * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
9523
+ * when the subject's phase does not match (a subject always carries a phase
9524
+ * on the package-event trigger).
9525
+ */
9526
+ packagePhase: _enum([
9527
+ "delivered",
9528
+ "picked-up",
9529
+ "both"
9530
+ ]).optional(),
9531
+ /**
9532
+ * PERSONAL-RULE custom zones (viewer-drawn). Inline normalized polygons
9533
+ * (MaskShape vocabulary). A record passes when its bbox overlaps ANY
9534
+ * listed polygon (ZoneEngine membership semantics). Evaluated only when
9535
+ * the subject carries a bbox; absent bbox ⇒ the condition FAILS.
9536
+ */
9537
+ customZones: array(MaskPolygonShapeSchema).optional(),
9538
+ /**
9539
+ * DEVICE-EVENT only. ZoneAnalytics occupancy edge — fires when a device's
9540
+ * (optionally zone/class-scoped) occupancy count crosses the configured
9541
+ * threshold and holds for `sustainSeconds`. Fail-closed on missing
9542
+ * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
9543
+ */
9544
+ occupancy: NcOccupancyConditionSchema.optional()
9545
+ });
9546
+ /** One delivery target: a `notification-output` Target ref + passthrough params. */
9547
+ var NcRuleTargetSchema = object({
9548
+ /** `notification-output` Target id. */
9549
+ targetId: string().min(1),
9550
+ /**
9551
+ * Per-backend passthrough. Recognized keys are mapped onto the canonical
9552
+ * Notification (`priority`, `level`, `sound`, `clickUrl`, `ttl`); the
9553
+ * degrade engine drops what the backend can't render.
9554
+ */
9555
+ params: record(string(), unknown()).optional()
9556
+ });
9557
+ /**
9558
+ * Media attachment policy (P1 still-image subset).
9559
+ * - `best` — the best AVAILABLE subject image at dispatch time (D-3).
9560
+ * - `best-matching` — the media that explains WHY the rule fired: a rule
9561
+ * matched on identities attaches the subject's `faceCrop`, one matched on
9562
+ * plates attaches the `plateCrop`; a rule with no identity/plate condition
9563
+ * (or when the specific crop is missing) degrades to `best`, then
9564
+ * `keyFrame`, then no attachment — never delaying the send. The matched
9565
+ * condition summary is frozen on the outbox row at enqueue (like the rule
9566
+ * name), so the choice never drifts from the record that fired it.
9567
+ * - `keyFrame` — the clean scene frame (no subject box).
9568
+ * - `none` — no attachment.
9569
+ */
9570
+ var NcMediaPolicySchema = object({ attach: _enum([
9571
+ "best",
9572
+ "best-matching",
9573
+ "keyFrame",
9574
+ "none"
9575
+ ]).default("best") });
9576
+ /** Throttle — cooldown survives restarts (rebuilt from the outbox on boot). */
9577
+ var NcThrottleSchema = object({
9578
+ cooldownSec: number().int().min(0).max(86400).default(60),
9579
+ /** `rule` = one shared cooldown; `rule-device` = per-camera cooldown. */
9580
+ scope: _enum(["rule", "rule-device"]).default("rule-device")
9581
+ });
9582
+ /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
9583
+ var NcRuleInputSchema = object({
9584
+ name: string().min(1).max(200),
9585
+ enabled: boolean().default(true),
9586
+ delivery: NcDeliverySchema,
9587
+ conditions: NcConditionsSchema.default({}),
9588
+ schedule: NcScheduleSchema.optional(),
9589
+ targets: array(NcRuleTargetSchema).min(1),
9590
+ media: NcMediaPolicySchema.default({ attach: "best" }),
9591
+ throttle: NcThrottleSchema.default({
9592
+ cooldownSec: 60,
9593
+ scope: "rule-device"
9594
+ }),
9595
+ /** `{{var}}` templating over camera/class/label/zones/confidence/time. */
9596
+ template: object({
9597
+ title: string().max(500).optional(),
9598
+ body: string().max(2e3).optional()
9599
+ }).optional(),
9600
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
9601
+ priority: number().int().min(1).max(5).default(3),
9602
+ /**
9603
+ * Ownership/visibility key. Absent = admin/global rule (unchanged legacy
9604
+ * behaviour, visible to all, read-only in the viewer). Present = personal
9605
+ * rule owned by this userId. Server-stamped; never trusted from a client.
9606
+ */
9607
+ ownerUserId: string().optional()
9608
+ });
9609
+ /**
9610
+ * Partial patch for `updateRule` — any subset of the input fields, plus the
9611
+ * persisted-only {@link NcRuleSchema} `disabledTargetIds` set. The latter is
9612
+ * NOT a client-authored input field (it lives on the persisted rule, not the
9613
+ * input), so it is added here explicitly to let the store's per-target opt-out
9614
+ * toggle round-trip through the shared `update` path. Viewer opt-out mutations
9615
+ * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
9616
+ * `updateRule` patch.
9617
+ */
9618
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
9619
+ /** A persisted rule. */
9620
+ var NcRuleSchema = NcRuleInputSchema.extend({
9621
+ id: string(),
9622
+ /** userId of the admin who created the rule (server-stamped caller). */
9623
+ createdBy: string(),
9624
+ createdAt: number(),
9625
+ updatedAt: number(),
9626
+ /**
9627
+ * Per-target opt-out set. A targetId here is suppressed for THIS rule at
9628
+ * send time. Only a target's OWNER may add/remove its id (server-checked
9629
+ * in `nc.setRuleTargetEnabled`). Defaults to empty.
9630
+ */
9631
+ disabledTargetIds: array(string()).default([])
9632
+ });
9633
+ var NcTestResultSchema = object({
9634
+ recordId: string(),
9635
+ recordKind: _enum([
9636
+ "object-event",
9637
+ "track",
9638
+ "device-event",
9639
+ "package-event"
9640
+ ]),
9641
+ deviceId: number(),
9642
+ timestamp: number(),
9643
+ wouldFire: boolean(),
9644
+ /** Condition id that failed (first failing group), when `wouldFire` is false. */
9645
+ failedCondition: string().optional(),
9646
+ className: string().optional(),
9647
+ label: string().optional()
9648
+ });
9649
+ var NcConditionDescriptorSchema = object({
9650
+ /** Field id inside `NcConditions` (or `'schedule'` for the rule-level group). */
9651
+ id: string(),
9652
+ group: _enum([
9653
+ "scope",
9654
+ "class",
9655
+ "zones",
9656
+ "quality",
9657
+ "label",
9658
+ "schedule",
9659
+ "device",
9660
+ "package",
9661
+ "occupancy"
9662
+ ]),
9663
+ label: string(),
9664
+ /** Editor widget the UI renders — never hardcode per-condition forms. */
9665
+ valueType: _enum([
9666
+ "deviceIdList",
9667
+ "stringList",
9668
+ "number01",
9669
+ "number",
9670
+ "sourceSelect",
9671
+ "zoneSelection",
9672
+ "zoneIdList",
9673
+ "schedule",
9674
+ "plateMatcher",
9675
+ "packagePhase",
9676
+ "polygonDraw",
9677
+ "occupancy"
9678
+ ]),
9679
+ operator: _enum([
9680
+ "in",
9681
+ "notIn",
9682
+ "anyOf",
9683
+ "allOf",
9684
+ "gte",
9685
+ "fuzzyIn",
9686
+ "withinSchedule"
9687
+ ]),
9688
+ /** Which delivery kinds the condition applies to. */
9689
+ appliesTo: array(NcDeliverySchema),
9690
+ phase: string(),
9691
+ description: string().optional()
9692
+ });
9693
+ /**
9694
+ * The delivery lifecycle status of a history row — a straight read of the
9695
+ * durable outbox row's own status (single source of truth):
9696
+ * - `pending` — enqueued, in-flight or retrying with backoff
9697
+ * - `sent` — delivered (terminal)
9698
+ * - `dead` — dead-lettered after exhausting retries / a permanent
9699
+ * backend rejection / a deleted target (terminal; carries
9700
+ * the failure `error`)
9701
+ *
9702
+ * P1 has no `suppressed-quiet-hours` / `snoozed` states — those ride the P2
9703
+ * user dimension (quiet hours / snooze) and are additive when they land.
9704
+ */
9705
+ var NcHistoryStatusSchema = _enum([
9706
+ "pending",
9707
+ "sent",
9708
+ "dead"
9709
+ ]);
9710
+ /** The evaluated record kind a history row descends from (one per trigger). */
9711
+ var NcHistoryRecordKindSchema = _enum([
9712
+ "object-event",
9713
+ "track-end",
9714
+ "device-event",
9715
+ "package-event"
9716
+ ]);
9717
+ /** Subject summary frozen on the row at fire time (survives rule/record edits). */
9718
+ var NcHistorySubjectSchema = object({
9719
+ className: string(),
9720
+ label: string().optional(),
9721
+ confidence: number().optional(),
9722
+ zones: array(string()),
9723
+ timestamp: number()
9724
+ });
9725
+ /**
9726
+ * One delivery-history row. This is a read-only VIEW over the durable
9727
+ * outbox row (single source of truth — the same row the drain loop drives;
9728
+ * NO second write path, so history can never drift from delivery state).
9729
+ * The §3.2 fields map directly: `ruleId`/`targetId`/`deviceId` are columns,
9730
+ * `eventRef` is `recordKind`+`recordId`, `timestamps` are `createdAt`
9731
+ * (fire) / `updatedAt` (last transition), `status` + `error` are the
9732
+ * lifecycle. `ruleName` + `subject` are the intent snapshot frozen at
9733
+ * enqueue. `userId?` (per-recipient history) is P2 — no user dimension in
9734
+ * P1 (admin scope only).
9735
+ */
9736
+ var NcHistoryEntrySchema = object({
9737
+ /** Outbox row id — the stable dedup id `ruleId:dedupRef:targetId`. */
9738
+ id: string(),
9739
+ ruleId: string(),
9740
+ /** Rule name frozen at fire time (outlives a later rename / delete). */
9741
+ ruleName: string(),
9742
+ /** The rule urgency/trigger that produced this delivery. */
9743
+ delivery: NcDeliverySchema,
9744
+ targetId: string(),
9745
+ deviceId: number(),
9746
+ recordKind: NcHistoryRecordKindSchema,
9747
+ /** Event / track ref of the evaluated record (§3.2 `eventRef`). */
9748
+ recordId: string(),
9749
+ /** Present for track-scoped deliveries (object-event / track-end). */
9750
+ trackId: string().optional(),
9751
+ status: NcHistoryStatusSchema,
9752
+ /** Delivery attempts made so far. */
9753
+ attempts: number().int(),
9754
+ /** Fire time (outbox enqueue). */
9755
+ createdAt: number(),
9756
+ /** Last transition time (terminal for sent / dead). */
9757
+ updatedAt: number(),
9758
+ /** Failure detail — present on a `dead` row. */
9759
+ error: string().optional(),
9760
+ subject: NcHistorySubjectSchema
9761
+ });
9762
+ /**
9763
+ * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
9764
+ * AND; absent = unbounded on that axis. `since`/`until` bound the fire time
9765
+ * (`createdAt`, epoch ms, inclusive). `limit` is clamped to
9766
+ * {@link NC_HISTORY_LIMIT_MAX}. `userId` (per-recipient filtering) is P2.
9767
+ */
9768
+ var NcHistoryFilterSchema = object({
9769
+ ruleId: string().optional(),
9770
+ deviceId: number().optional(),
9771
+ status: NcHistoryStatusSchema.optional(),
9772
+ since: number().optional(),
9773
+ until: number().optional(),
9774
+ limit: number().int().min(1).max(500).default(100)
9775
+ });
9776
+ 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 }), {
9777
+ kind: "mutation",
9778
+ auth: "admin",
9779
+ caller: "required"
9780
+ }), method(object({
9781
+ ruleId: string(),
9782
+ patch: NcRulePatchSchema
9783
+ }), object({ rule: NcRuleSchema }), {
9784
+ kind: "mutation",
9785
+ auth: "admin",
9786
+ caller: "required"
9787
+ }), method(object({ ruleId: string() }), object({ success: literal(true) }), {
9788
+ kind: "mutation",
9789
+ auth: "admin"
9790
+ }), method(object({
9791
+ ruleId: string(),
9792
+ enabled: boolean()
9793
+ }), object({ success: literal(true) }), {
9794
+ kind: "mutation",
9795
+ auth: "admin"
9796
+ }), method(object({
9797
+ rule: NcRuleInputSchema,
9798
+ lookbackMinutes: number().int().min(1).max(1440).default(60)
9799
+ }), object({ results: array(NcTestResultSchema) }), {
9800
+ kind: "mutation",
9801
+ auth: "admin"
9802
+ }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
9803
+ /**
9804
+ * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
9805
+ *
9806
+ * Spec: `docs/superpowers/specs/2026-07-24-nc-occupancy-timelapse-design.md`
9807
+ * §3.2/§3.3.
9808
+ *
9809
+ * Deliberately NOT a capability definition and NOT an `NcRule`:
9810
+ * - Every `NcDelivery` member is a *persisted-pipeline-record* trigger. A
9811
+ * timelapse fires on a SCHEDULE WINDOW BOUNDARY, evaluates no pipeline
9812
+ * record, and produces a video it assembled itself — so it rides no
9813
+ * delivery-enum member (the enum is frozen) and no cap method. This file is
9814
+ * a plain typed schema; it does NOT go through `npm run codegen`.
9815
+ * - It shares only the delivery leg (`notification-output.send`) and the
9816
+ * persistence/ownership patterns with the Notification Center, reusing
9817
+ * {@link NcScheduleSchema} (weekly windows, midnight-crossing, invertible)
9818
+ * and {@link NcRuleTargetSchema} (target ref + passthrough params).
9819
+ *
9820
+ * Ownership is SERVER-DERIVED. `ownerUserId` / `createdBy` / `createdAt` /
9821
+ * `updatedAt` / `id` / `lastGeneratedAt` live on the PERSISTED rule only —
9822
+ * {@link TimelapseRuleInputSchema} and {@link TimelapseRulePatchSchema} do not
9823
+ * carry them, so a forged client payload can never claim or re-own a rule
9824
+ * (Zod strips unknown keys). The store stamps them from the resolved caller.
9825
+ */
9826
+ /** `{{var}}` templating over camera/rule/time — same vocabulary as `NcRule`. */
9827
+ var TimelapseTemplateSchema = object({
9828
+ title: string().max(500).optional(),
9829
+ body: string().max(2e3).optional()
9830
+ });
9831
+ var NameField = string().min(1).max(200);
9832
+ var DeviceIdsField = array(number()).min(1);
9833
+ var CadenceSecField = number().int().min(2).max(3600);
9834
+ var FramerateField = number().int().min(1).max(60);
9835
+ var TargetsField = array(NcRuleTargetSchema).min(1);
9836
+ var PriorityField = number().int().min(1).max(5);
9837
+ /**
9838
+ * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
9839
+ * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
9840
+ * here (see the ownership note above).
9841
+ */
9842
+ var TimelapseRuleInputSchema = object({
9843
+ name: NameField,
9844
+ enabled: boolean().default(true),
9845
+ /** Cameras sampled by this rule — one scratch dir + one artifact per device. */
9846
+ deviceIds: DeviceIdsField,
9847
+ /**
9848
+ * Activation window(s). REQUIRED (unlike `NcRule`, where an absent schedule
9849
+ * means "always active"): a timelapse is defined by its window boundaries —
9850
+ * open clears the scratch, close assembles and delivers.
9851
+ */
9852
+ schedule: NcScheduleSchema,
9853
+ /** Force-snapshot cadence inside the window, seconds (predecessor parity). */
9854
+ cadenceSec: CadenceSecField.default(15),
9855
+ /** Output frames per second of the assembled mp4 (predecessor parity). */
9856
+ framerate: FramerateField.default(10),
9857
+ /** `notification-output` targets the finished video/thumbnail is sent to. */
9858
+ targets: TargetsField,
9859
+ template: TimelapseTemplateSchema.optional(),
9860
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
9861
+ priority: PriorityField.default(3)
9862
+ });
9863
+ object({
9864
+ name: NameField.optional(),
9865
+ enabled: boolean().optional(),
9866
+ deviceIds: DeviceIdsField.optional(),
9867
+ schedule: NcScheduleSchema.optional(),
9868
+ cadenceSec: CadenceSecField.optional(),
9869
+ framerate: FramerateField.optional(),
9870
+ targets: TargetsField.optional(),
9871
+ template: TimelapseTemplateSchema.nullable().optional(),
9872
+ priority: PriorityField.optional()
9873
+ });
9874
+ TimelapseRuleInputSchema.extend({
9875
+ id: string(),
9876
+ /**
9877
+ * Ownership/visibility key. Absent = admin/global rule (visible to all).
9878
+ * Present = personal rule owned by this userId. Server-stamped from the
9879
+ * resolved caller; never trusted from a client payload.
9880
+ */
9881
+ ownerUserId: string().optional(),
9882
+ /**
9883
+ * Epoch-ms of the last successful generation — the 1-hour re-generation
9884
+ * guard's durable state (predecessor parity). Absent = never generated.
9885
+ */
9886
+ lastGeneratedAt: number().optional(),
9887
+ /** userId of the caller who created the rule (server-stamped). */
9888
+ createdBy: string(),
9889
+ createdAt: number(),
9890
+ updatedAt: number()
9891
+ });
9892
+ /**
9198
9893
  * Generic device-level status snapshot. Auto-registered by `BaseDevice`
9199
9894
  * for every device, regardless of provider — the kernel needs a uniform
9200
9895
  * cap-keyed slice for the basic device flags every consumer expects to
@@ -12302,6 +12997,22 @@ var CameraMetricsSchema = object({
12302
12997
  ])
12303
12998
  });
12304
12999
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
13000
+ /**
13001
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
13002
+ * within the frame, so the executor can re-cut a leaf child ROI at native
13003
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
13004
+ */
13005
+ var NativeCropRefSchema = object({
13006
+ /** Handle keying the retained native surface (node-pinned to its owner). */
13007
+ handle: FrameHandleSchema,
13008
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
13009
+ cropFrameSpace: object({
13010
+ x: number(),
13011
+ y: number(),
13012
+ w: number(),
13013
+ h: number()
13014
+ })
13015
+ });
12305
13016
  var ModelFormatSchema$1 = _enum([
12306
13017
  "onnx",
12307
13018
  "coreml",
@@ -12577,7 +13288,22 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
12577
13288
  * Omitted ⇒ the runner's default device (current single-engine
12578
13289
  * behaviour). Selects WHICH device pool of the node runs the call.
12579
13290
  */
12580
- deviceKey: string().optional()
13291
+ deviceKey: string().optional(),
13292
+ /**
13293
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
13294
+ * when the parent crop was resolved from the frame's retained NATIVE
13295
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
13296
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
13297
+ * resolution from that surface — the SAME quality path faces already
13298
+ * had — instead of the downscaled parent tile. `handle` keys the native
13299
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
13300
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
13301
+ * the executor's crop-normalized child ROI back into frame-normalized
13302
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
13303
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
13304
+ * (today's behaviour on the fallback path).
13305
+ */
13306
+ nativeCropRef: NativeCropRefSchema.optional()
12581
13307
  }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
12582
13308
  engine: PipelineEngineChoiceSchema.optional(),
12583
13309
  steps: array(PipelineStepInputSchema).min(1),
@@ -12826,7 +13552,11 @@ var DetailResultSchema = object({
12826
13552
  bbox: NativeCropBboxSchema.optional(),
12827
13553
  embedding: string().optional(),
12828
13554
  label: string().optional(),
12829
- alignedCropJpeg: string().optional()
13555
+ alignedCropJpeg: string().optional(),
13556
+ /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
13557
+ * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
13558
+ * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
13559
+ nativeFaceShortSidePx: number().optional()
12830
13560
  });
12831
13561
  /**
12832
13562
  * Per-camera tunable ranges + defaults. Single source of truth used
@@ -12840,6 +13570,12 @@ var motionCooldownMsField = {
12840
13570
  default: 3e4,
12841
13571
  step: 500
12842
13572
  };
13573
+ var maxSessionHoldMsField = {
13574
+ min: 0,
13575
+ max: 6e5,
13576
+ default: 12e4,
13577
+ step: 5e3
13578
+ };
12843
13579
  var motionFpsField = {
12844
13580
  min: 1,
12845
13581
  max: 30,
@@ -12987,6 +13723,19 @@ var RunnerCameraConfigSchema = object({
12987
13723
  "on-motion"
12988
13724
  ]).default("always-on"),
12989
13725
  motionCooldownMs: number().min(motionCooldownMsField.min).default(motionCooldownMsField.default),
13726
+ /**
13727
+ * Orchestrator-side on-motion session-hold cap (ms). While an on-motion
13728
+ * detection session is active and ≥1 confirmed non-stationary track is
13729
+ * still live, the orchestrator keeps the session open past
13730
+ * `motionCooldownMs` (a slowly-moving subject can stop re-triggering the
13731
+ * camera's VMD yet is still being tracked frame-to-frame) — up to this many
13732
+ * ms since the session opened, after which it closes regardless. `0`
13733
+ * disables the hold (legacy cooldown-only teardown). Not consumed by the
13734
+ * runner itself — carried here so it shares the per-camera device-settings
13735
+ * surface with `motionCooldownMs`; the orchestrator reads it off the
13736
+ * resolved `CameraDetectionConfig`.
13737
+ */
13738
+ maxSessionHoldMs: number().min(maxSessionHoldMsField.min).max(maxSessionHoldMsField.max).optional(),
12990
13739
  motionFps: number().min(motionFpsField.min).max(motionFpsField.max).default(motionFpsField.default),
12991
13740
  detectionFps: number().min(detectionFpsField.min).max(detectionFpsField.max).default(detectionFpsField.default),
12992
13741
  motionStreamId: string(),
@@ -13076,7 +13825,7 @@ var RunnerCameraConfigSchema = object({
13076
13825
  */
13077
13826
  inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
13078
13827
  });
13079
- motionFpsField.min, motionFpsField.max, motionFpsField.step, motionFpsField.default, detectionFpsField.min, detectionFpsField.max, detectionFpsField.step, detectionFpsField.default, motionCooldownMsField.min, motionCooldownMsField.max, motionCooldownMsField.step, motionCooldownMsField.default, occupancyRecheckSecField.min, occupancyRecheckSecField.max, occupancyRecheckSecField.step, occupancyRecheckSecField.default, occupancyRecheckFramesField.min, occupancyRecheckFramesField.max, occupancyRecheckFramesField.step, occupancyRecheckFramesField.default;
13828
+ motionFpsField.min, motionFpsField.max, motionFpsField.step, motionFpsField.default, detectionFpsField.min, detectionFpsField.max, detectionFpsField.step, detectionFpsField.default, motionCooldownMsField.min, motionCooldownMsField.max, motionCooldownMsField.step, motionCooldownMsField.default, maxSessionHoldMsField.min, maxSessionHoldMsField.max, maxSessionHoldMsField.step, maxSessionHoldMsField.default, occupancyRecheckSecField.min, occupancyRecheckSecField.max, occupancyRecheckSecField.step, occupancyRecheckSecField.default, occupancyRecheckFramesField.min, occupancyRecheckFramesField.max, occupancyRecheckFramesField.step, occupancyRecheckFramesField.default;
13080
13829
  /**
13081
13830
  * Runtime load summary returned by `getLocalLoad`. Used by the orchestrator's
13082
13831
  * load-balancing levels (L2 capacity-based, L3 hardware-aware) to decide
@@ -13292,86 +14041,25 @@ var motionTriggerCapability = {
13292
14041
  runtimeState: MotionTriggerRuntimeStateSchema
13293
14042
  };
13294
14043
  /**
13295
- * Shared geometry vocabulary for on-frame shape caps privacy-mask,
13296
- * motion-zones, and the detection zones/lines editor all speak this one
13297
- * language so a single drawing-plane editor and the providers stay
13298
- * decoupled from each cap's storage.
13299
- *
13300
- * All coordinates are normalized 0..1 of the camera frame (top-left
13301
- * origin). Each cap composes the SUBSET of shape kinds it supports and
13302
- * advertises it via `supportedShapes` in its `getOptions`.
14044
+ * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
14045
+ * on-camera motion-detection mask is a single `grid` region (a row-major
14046
+ * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
14047
+ * a region keeps one drawing-plane model across all geometry caps.
13303
14048
  */
13304
- /** A normalized 0..1 point (top-left origin). */
13305
- var MaskPointSchema = object({
13306
- x: number(),
13307
- y: number()
13308
- });
13309
- /** Axis-aligned rectangle (normalized 0..1). */
13310
- var MaskRectShapeSchema = object({
13311
- kind: literal("rect"),
13312
- x: number(),
13313
- y: number(),
13314
- width: number(),
13315
- height: number()
14049
+ /** A motion-zone region exactly one boolean cell grid today. */
14050
+ var MotionZoneRegionSchema = object({
14051
+ id: number(),
14052
+ enabled: boolean(),
14053
+ shape: MaskGridShapeSchema
13316
14054
  });
13317
- /** Free polygon an ordered list of normalized vertices (≥3). */
13318
- var MaskPolygonShapeSchema = object({
13319
- kind: literal("polygon"),
13320
- points: array(MaskPointSchema)
13321
- });
13322
- /** Boolean cell grid row-major, length === gridWidth*gridHeight. */
13323
- var MaskGridShapeSchema = object({
13324
- kind: literal("grid"),
13325
- gridWidth: number(),
13326
- gridHeight: number(),
13327
- cells: array(boolean())
13328
- });
13329
- discriminatedUnion("kind", [
13330
- MaskRectShapeSchema,
13331
- MaskPolygonShapeSchema,
13332
- MaskGridShapeSchema,
13333
- object({
13334
- kind: literal("line"),
13335
- points: array(MaskPointSchema)
13336
- })
13337
- ]);
13338
- /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
13339
- var MaskShapeKindSchema = _enum([
13340
- "rect",
13341
- "polygon",
13342
- "grid",
13343
- "line"
13344
- ]);
13345
- /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
13346
- var MaskPolygonVerticesSchema = object({
13347
- min: number(),
13348
- max: number()
13349
- });
13350
- /** Grid dimensions when a cap supports 'grid'. */
13351
- var MaskGridDimsSchema = object({
13352
- width: number(),
13353
- height: number()
13354
- });
13355
- /**
13356
- * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
13357
- * on-camera motion-detection mask is a single `grid` region (a row-major
13358
- * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
13359
- * a region keeps one drawing-plane model across all geometry caps.
13360
- */
13361
- /** A motion-zone region — exactly one boolean cell grid today. */
13362
- var MotionZoneRegionSchema = object({
13363
- id: number(),
13364
- enabled: boolean(),
13365
- shape: MaskGridShapeSchema
13366
- });
13367
- /** Current on-camera motion-detection state — master enable + sensitivity +
13368
- * the grid region(s). */
13369
- var MotionZoneStatusSchema = object({
13370
- enabled: boolean(),
13371
- sensitivity: number(),
13372
- /** Grid region(s). Today exactly one `grid` shape. */
13373
- regions: array(MotionZoneRegionSchema),
13374
- lastFetchedAt: number()
14055
+ /** Current on-camera motion-detection state master enable + sensitivity +
14056
+ * the grid region(s). */
14057
+ var MotionZoneStatusSchema = object({
14058
+ enabled: boolean(),
14059
+ sensitivity: number(),
14060
+ /** Grid region(s). Today exactly one `grid` shape. */
14061
+ regions: array(MotionZoneRegionSchema),
14062
+ lastFetchedAt: number()
13375
14063
  });
13376
14064
  /** Per-camera availability — grid dims are fixed per camera model; the UI
13377
14065
  * sizes its editor from `grid`. */
@@ -16603,94 +17291,6 @@ var EnrichedWidgetMetadataSchema = WidgetMetadataSchema.extend({
16603
17291
  bundleUrl: string()
16604
17292
  });
16605
17293
  method(_void(), array(EnrichedWidgetMetadataSchema).readonly());
16606
- var NotificationRuleConditionsSchema = object({
16607
- deviceIds: array(number()).readonly().optional(),
16608
- classNames: array(string()).readonly().optional(),
16609
- zoneIds: array(string()).readonly().optional(),
16610
- minConfidence: number().optional(),
16611
- source: _enum([
16612
- "pipeline",
16613
- "onboard",
16614
- "any"
16615
- ]).optional(),
16616
- schedule: object({
16617
- days: array(number()).readonly(),
16618
- startHour: number(),
16619
- endHour: number()
16620
- }).optional(),
16621
- cooldownSeconds: number().optional(),
16622
- minDwellSeconds: number().optional(),
16623
- /** Match against `event.data.eventType` token (e.g. `'press_long'`). When non-empty, only events
16624
- * carrying a matching `data.eventType` string pass this condition. Rules without this field are
16625
- * unaffected (back-compat). Distinct from `rule.eventTypes` which holds EventCategory strings. */
16626
- eventTypeTokens: array(string()).readonly().optional(),
16627
- /** Match detections whose CLIP image embedding is semantically similar to this free-text
16628
- * description. Requires the embedding-encoder cap to have pre-warmed the text vector.
16629
- * `minSimilarity` is the cosine similarity threshold in [0, 1]. */
16630
- clipDescription: object({
16631
- text: string().min(1),
16632
- minSimilarity: number().min(0).max(1)
16633
- }).optional(),
16634
- /** Match events whose recognized-entity label (face identity name or plate
16635
- * vehicle name, propagated onto `event.data.label`) is one of these values.
16636
- * Empty/absent → unaffected (back-compat). Enables "notify me when <named
16637
- * vehicle/person> is seen". */
16638
- labels: array(string()).readonly().optional()
16639
- });
16640
- var NotificationRuleTemplateSchema = object({
16641
- title: string(),
16642
- body: string(),
16643
- imageMode: _enum([
16644
- "crop",
16645
- "annotated",
16646
- "full",
16647
- "none"
16648
- ])
16649
- });
16650
- var NotificationRuleSchema = object({
16651
- id: string(),
16652
- name: string(),
16653
- enabled: boolean(),
16654
- eventTypes: array(string()).readonly(),
16655
- conditions: NotificationRuleConditionsSchema,
16656
- outputs: array(string()).readonly(),
16657
- template: NotificationRuleTemplateSchema.optional(),
16658
- priority: _enum([
16659
- "low",
16660
- "normal",
16661
- "high",
16662
- "critical"
16663
- ])
16664
- });
16665
- var NotificationTestResultSchema = object({
16666
- ruleId: string(),
16667
- eventId: string(),
16668
- timestamp: number(),
16669
- wouldFire: boolean(),
16670
- reason: string().optional()
16671
- });
16672
- var NotificationHistoryEntrySchema = object({
16673
- id: string(),
16674
- ruleId: string(),
16675
- ruleName: string(),
16676
- eventId: string(),
16677
- timestamp: number(),
16678
- outputs: array(string()).readonly(),
16679
- success: boolean(),
16680
- error: string().optional(),
16681
- deviceId: number().optional()
16682
- });
16683
- var NotificationHistoryFilterSchema = object({
16684
- ruleId: string().optional(),
16685
- deviceId: number().optional(),
16686
- from: number().optional(),
16687
- to: number().optional(),
16688
- limit: number().optional()
16689
- });
16690
- 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({
16691
- ruleId: string(),
16692
- lookbackMinutes: number()
16693
- }), object({ results: array(NotificationTestResultSchema).readonly() }), { kind: "mutation" }), method(object({ filter: NotificationHistoryFilterSchema.optional() }), object({ entries: array(NotificationHistoryEntrySchema).readonly() }));
16694
17294
  /**
16695
17295
  * Alerts capability — collection-based internal alert system.
16696
17296
  *
@@ -16877,88 +17477,54 @@ method(object({
16877
17477
  password: string()
16878
17478
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
16879
17479
  /**
16880
- * `login-method` collection cap through which auth addons contribute
16881
- * their pre-auth login surfaces to the login page. This is the SINGLE,
16882
- * generic mechanism that supersedes the dead `auth.listProviders` reader:
16883
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
16884
- * `login-method` provider and the PUBLIC `auth.listLoginMethods`
16885
- * procedure aggregates them for the unauthenticated login page.
16886
- *
16887
- * A contribution is a discriminated union on `kind`:
16888
- *
16889
- * - `redirect` — a declarative button. The login page renders a generic
16890
- * button that navigates to `startUrl` (an addon-owned HTTP route).
16891
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
16892
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
16893
- * login page needs NO change.
16894
- *
16895
- * - `widget` — a Module-Federation widget the login page mounts (via
16896
- * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
16897
- * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
16898
- * mechanism kept for future use; no shipped addon uses it on the login
16899
- * page (the passkey ceremony below runs natively in the shell instead).
16900
- *
16901
- * - `passkey` — a declarative WebAuthn ceremony the shell renders
16902
- * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
16903
- * a remotely-loaded bundle). Carries the addon's effective `rpId` /
16904
- * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
16905
- * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
16906
- * fetching any remote code pre-auth. Contribution stays unconditional —
16907
- * enrollment state is never leaked pre-auth; visibility is a shell
16908
- * decision.
16909
- *
16910
- * Every contribution carries a `stage`:
16911
- * - `primary` — shown on the first credentials screen (OIDC /
16912
- * magic-link buttons; a future usernameless passkey).
16913
- * - `second-factor` — shown AFTER the password leg, gated on the
16914
- * returned `factors` (passkey-as-2FA today).
16915
- *
16916
- * `mount: skip` — the cap is read server-side by the core auth router
16917
- * (`registry.getCollection('login-method')`), never mounted as its own
16918
- * tRPC router.
17480
+ * A live terminal session hosted by the provider addon. Output and input do
17481
+ * NOT flow through the capability they use the addon data plane
17482
+ * (`GET /addon/terminal/<id>/out` SSE, `POST /addon/terminal/<id>/in`) because
17483
+ * terminal output must be ordered and lossless. The event bus is telemetry and
17484
+ * may drop chunks ([D8]), and a dropped chunk desynchronises the vt parser
17485
+ * permanently until a full repaint. The capability owns only lifecycle.
16919
17486
  */
16920
- /** When a login method renders in the two-phase login flow. */
16921
- var LoginStageEnum = _enum(["primary", "second-factor"]);
16922
- /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
16923
- var LoginMethodContributionSchema = discriminatedUnion("kind", [
16924
- object({
16925
- kind: literal("redirect"),
16926
- /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
16927
- id: string(),
16928
- /** Operator-facing button label. */
16929
- label: string(),
16930
- /** lucide-react icon name. */
16931
- icon: string().optional(),
16932
- /** Addon-owned HTTP route the button navigates to (GET). */
16933
- startUrl: string(),
16934
- stage: LoginStageEnum
16935
- }),
16936
- object({
16937
- kind: literal("widget"),
16938
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
16939
- id: string(),
16940
- /** Owning addon id — drives the public bundle URL + the MF namespace. */
16941
- addonId: string(),
16942
- /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
16943
- bundle: string(),
16944
- /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
16945
- remote: WidgetRemoteSchema,
16946
- stage: LoginStageEnum
16947
- }),
16948
- object({
16949
- kind: literal("passkey"),
16950
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
16951
- id: string(),
16952
- /** Operator-facing button label. */
16953
- label: string(),
16954
- stage: LoginStageEnum,
16955
- /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
16956
- rpId: string(),
16957
- /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
16958
- origin: string().nullable()
16959
- })
16960
- ]);
16961
- method(_void(), array(LoginMethodContributionSchema).readonly());
17487
+ var TerminalSessionInfoSchema = object({
17488
+ /** Opaque session id minted by the provider on `openSession`. */
17489
+ sessionId: string(),
17490
+ /** The pre-declared profile this session runs (never a free-form command). */
17491
+ profileId: string(),
17492
+ /** Human-readable profile label for the UI session list. */
17493
+ label: string(),
17494
+ cols: number().int().positive(),
17495
+ rows: number().int().positive(),
17496
+ /** ms-epoch the session's pty was spawned. */
17497
+ startedAt: number()
17498
+ });
17499
+ /**
17500
+ * A profile the operator may open — a pre-declared, allowlisted program
17501
+ * (`monitor` → `btm`). The capability accepts only these ids; a free-form
17502
+ * command string would be remote code execution as the server's user, so it is
17503
+ * deliberately not part of the contract.
17504
+ */
17505
+ var TerminalProfileInfoSchema = object({
17506
+ profileId: string(),
17507
+ label: string(),
17508
+ description: string().optional()
17509
+ });
17510
+ method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(TerminalSessionInfoSchema).readonly(), { auth: "admin" }), method(object({
17511
+ profileId: string(),
17512
+ cols: number().int().positive(),
17513
+ rows: number().int().positive()
17514
+ }), TerminalSessionInfoSchema, {
17515
+ kind: "mutation",
17516
+ auth: "admin"
17517
+ }), method(object({
17518
+ sessionId: string(),
17519
+ cols: number().int().positive(),
17520
+ rows: number().int().positive()
17521
+ }), _void(), {
17522
+ kind: "mutation",
17523
+ auth: "admin"
17524
+ }), method(object({ sessionId: string() }), _void(), {
17525
+ kind: "mutation",
17526
+ auth: "admin"
17527
+ });
16962
17528
  /**
16963
17529
  * Orchestrator-side destination metadata. The orchestrator computes
16964
17530
  * `id = <addonId>:<subId>` from its provider lookup so consumers
@@ -17060,11 +17626,53 @@ var LocationStatSchema = object({
17060
17626
  fileCount: number(),
17061
17627
  present: boolean()
17062
17628
  });
17629
+ /**
17630
+ * A backup schedule — the N:M "entry" that binds one cron cadence to a
17631
+ * SET of destination locations. Supersedes the per-location cron on
17632
+ * `BackupDestinationPolicy`: an operator creates a schedule, picks the
17633
+ * `backups` locations it should write to, and the orchestrator fans a
17634
+ * single archive out to all of them when the cron fires.
17635
+ *
17636
+ * `retentionCount` is per-schedule (D-decision 2026-07-28): every
17637
+ * location targeted by this schedule keeps this many archives from
17638
+ * this schedule's runs.
17639
+ *
17640
+ * `dataSources` optionally narrows which top-level state locations
17641
+ * (db, addons, tls, …) are archived; omitted = the orchestrator's
17642
+ * default full set.
17643
+ */
17644
+ var BackupScheduleSchema = object({
17645
+ /** Stable id. Generated by the orchestrator on first upsert if absent. */
17646
+ id: string(),
17647
+ /** Operator-facing display name. */
17648
+ label: string(),
17649
+ /** 5-field POSIX cron. Empty = disabled cadence (kept for editing). */
17650
+ cron: string(),
17651
+ /** Master on/off toggle for the whole schedule. */
17652
+ enabled: boolean(),
17653
+ /** `backups`-location ids this schedule writes to (fan-out set). */
17654
+ locationIds: array(string()).readonly(),
17655
+ /** Archives kept per targeted location for this schedule. */
17656
+ retentionCount: number().int().min(1).max(1e3),
17657
+ /** Optional subset of source locations to include; omitted = all. */
17658
+ dataSources: array(string()).readonly().optional(),
17659
+ /** ms-epoch of last successful run. */
17660
+ lastRunAt: number().optional(),
17661
+ /** ms-epoch of next computed firing (read-only, filled on list). */
17662
+ nextRunAt: number().optional()
17663
+ });
17063
17664
  method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }), method(object({
17064
17665
  /** Subset of registered `backup-destination` addon ids to write to. */
17065
17666
  destinations: array(string()).optional(),
17066
17667
  locations: array(string()).optional(),
17067
- label: string().optional()
17668
+ label: string().optional(),
17669
+ /**
17670
+ * Per-run retention override applied to every targeted
17671
+ * destination. Used by schedule-driven runs (per-entry
17672
+ * retention). Omitted = each destination's own policy
17673
+ * retention (manual runs).
17674
+ */
17675
+ retentionCount: number().int().min(1).max(1e3).optional()
17068
17676
  }).optional(), array(BackupEntrySchema).readonly(), {
17069
17677
  kind: "mutation",
17070
17678
  auth: "admin"
@@ -17113,7 +17721,21 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
17113
17721
  ok: boolean(),
17114
17722
  error: string().optional(),
17115
17723
  nextRuns: array(number()).readonly()
17116
- }));
17724
+ })), method(_void(), array(BackupScheduleSchema).readonly(), { auth: "admin" }), method(object({
17725
+ id: string().optional(),
17726
+ label: string(),
17727
+ cron: string(),
17728
+ enabled: boolean(),
17729
+ locationIds: array(string()).readonly(),
17730
+ retentionCount: number().int().min(1).max(1e3),
17731
+ dataSources: array(string()).readonly().optional()
17732
+ }), BackupScheduleSchema, {
17733
+ kind: "mutation",
17734
+ auth: "admin"
17735
+ }), method(object({ id: string() }), _void(), {
17736
+ kind: "mutation",
17737
+ auth: "admin"
17738
+ });
17117
17739
  /**
17118
17740
  * `broker` — unified pub/sub broker registry, system-scoped collection.
17119
17741
  *
@@ -18303,851 +18925,934 @@ method(_void(), array(string()).readonly(), { auth: "admin" }), method(object({
18303
18925
  kind: "mutation",
18304
18926
  auth: "admin"
18305
18927
  });
18306
- var LogLevelSchema = _enum([
18307
- "debug",
18308
- "info",
18309
- "warn",
18310
- "error"
18311
- ]);
18312
- var LogEntrySchema = object({
18313
- timestamp: date(),
18314
- level: LogLevelSchema,
18315
- scope: array(string()),
18316
- message: string(),
18317
- meta: record(string(), unknown()).optional(),
18318
- tags: record(string(), string()).optional()
18928
+ /**
18929
+ * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
18930
+ * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
18931
+ * caps stay wire-compatible without a circular cap→cap import.
18932
+ *
18933
+ * Errors are a discriminated-union RESULT, never thrown: the shape survives
18934
+ * every transport tier structurally, and failed calls still write usage rows.
18935
+ * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
18936
+ */
18937
+ var LlmUsageSchema = object({
18938
+ inputTokens: number(),
18939
+ outputTokens: number()
18319
18940
  });
18320
- method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18321
- scope: array(string()).optional(),
18322
- level: LogLevelSchema.optional(),
18323
- since: date().optional(),
18324
- until: date().optional(),
18325
- limit: number().optional(),
18326
- tags: record(string(), string()).optional()
18327
- }), array(LogEntrySchema).readonly());
18328
- var CpuBreakdownSchema = object({
18329
- total: number(),
18330
- user: number(),
18331
- system: number(),
18332
- irq: number(),
18333
- nice: number(),
18334
- loadAvg: tuple([
18335
- number(),
18336
- number(),
18337
- number()
18338
- ]),
18339
- cores: number()
18340
- });
18341
- var MemoryInfoSchema = object({
18342
- percent: number(),
18343
- totalBytes: number(),
18344
- usedBytes: number(),
18345
- availableBytes: number(),
18346
- swapUsedBytes: number(),
18347
- swapTotalBytes: number()
18348
- });
18349
- var DiskIoSnapshotSchema = object({
18350
- readBytes: number(),
18351
- writeBytes: number(),
18352
- readOps: number(),
18353
- writeOps: number(),
18354
- timestampMs: number()
18355
- });
18356
- var NetworkIoSnapshotSchema = object({
18357
- rxBytes: number(),
18358
- txBytes: number(),
18359
- rxPackets: number(),
18360
- txPackets: number(),
18361
- rxErrors: number(),
18362
- txErrors: number(),
18363
- timestampMs: number()
18364
- });
18365
- var MetricsGpuInfoSchema = object({
18366
- utilization: number(),
18941
+ var LlmErrorCodeSchema = _enum([
18942
+ "timeout",
18943
+ "rate-limited",
18944
+ "auth",
18945
+ "refusal",
18946
+ "bad-request",
18947
+ "unavailable",
18948
+ "no-profile",
18949
+ "budget-exceeded",
18950
+ "adapter-error"
18951
+ ]);
18952
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
18953
+ ok: literal(true),
18954
+ text: string(),
18367
18955
  model: string(),
18368
- memoryUsedBytes: number(),
18369
- memoryTotalBytes: number(),
18370
- temperature: number().nullable()
18371
- });
18372
- var ProcessResourceInfoSchema = object({
18373
- openFds: number(),
18374
- threadCount: number(),
18375
- activeHandles: number(),
18376
- activeRequests: number()
18377
- });
18378
- var PressureAvgsSchema = object({
18379
- avg10: number(),
18380
- avg60: number(),
18381
- avg300: number()
18956
+ usage: LlmUsageSchema,
18957
+ truncated: boolean(),
18958
+ latencyMs: number()
18959
+ }), object({
18960
+ ok: literal(false),
18961
+ code: LlmErrorCodeSchema,
18962
+ message: string(),
18963
+ retryAfterMs: number().optional()
18964
+ })]);
18965
+ /**
18966
+ * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
18967
+ * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
18968
+ * notification-output.cap.ts:27-31 precedents).
18969
+ */
18970
+ var LlmImageSchema = object({
18971
+ bytes: _instanceof(Uint8Array),
18972
+ mimeType: string()
18382
18973
  });
18383
- var PressureInfoSchema = object({
18384
- some: PressureAvgsSchema,
18385
- full: PressureAvgsSchema.nullable()
18974
+ var LlmGenerateBaseInputSchema = object({
18975
+ /** Collection routing (the notification-output posture). */
18976
+ addonId: string().optional(),
18977
+ /** Explicit profile; else the resolution chain (spec §3). */
18978
+ profileId: string().optional(),
18979
+ /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
18980
+ consumer: string(),
18981
+ system: string().optional(),
18982
+ /** v1: single-turn. `messages[]` is a v2 additive field. */
18983
+ prompt: string(),
18984
+ /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
18985
+ jsonSchema: record(string(), unknown()).optional(),
18986
+ /** Per-call override of the profile default. */
18987
+ maxTokens: number().int().positive().optional(),
18988
+ temperature: number().optional()
18386
18989
  });
18387
- var SystemResourceSnapshotSchema = object({
18388
- cpu: CpuBreakdownSchema,
18389
- memory: MemoryInfoSchema,
18390
- gpu: MetricsGpuInfoSchema.nullable(),
18391
- network: NetworkIoSnapshotSchema,
18392
- disk: DiskIoSnapshotSchema,
18393
- pressure: object({
18394
- cpu: PressureInfoSchema.nullable(),
18395
- memory: PressureInfoSchema.nullable(),
18396
- io: PressureInfoSchema.nullable()
18990
+ /**
18991
+ * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
18992
+ * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
18993
+ * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
18994
+ * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
18995
+ * this only through the `llm` cap's methods.
18996
+ *
18997
+ * One running llama-server child per node in v1 (models are RAM-heavy).
18998
+ * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
18999
+ * watchdog — operator decision #3).
19000
+ */
19001
+ var ManagedModelRefSchema = discriminatedUnion("kind", [
19002
+ object({
19003
+ kind: literal("catalog"),
19004
+ catalogId: string()
18397
19005
  }),
18398
- process: ProcessResourceInfoSchema,
18399
- cpuTemperature: number().nullable(),
18400
- timestampMs: number()
18401
- });
18402
- var DiskSpaceInfoSchema = object({
18403
- path: string(),
18404
- totalBytes: number(),
18405
- usedBytes: number(),
18406
- availableBytes: number(),
18407
- percent: number()
18408
- });
18409
- var PidResourceStatsSchema = object({
18410
- pid: number(),
18411
- cpu: number(),
18412
- memory: number(),
18413
- /**
18414
- * Private (anonymous) resident bytes — the per-process V8 heap + native
18415
- * allocations NOT shared with other processes (Linux RssAnon). This is the
18416
- * "real" per-runner cost; summing it across runners is meaningful, unlike
18417
- * `memory` (RSS), which double-counts the shared mmap'd framework code.
18418
- * Undefined where /proc is unavailable (e.g. macOS).
18419
- */
18420
- privateBytes: number().optional(),
18421
- /**
18422
- * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
18423
- * code shared copy-on-write across runners. Undefined on macOS.
18424
- */
18425
- sharedBytes: number().optional()
19006
+ object({
19007
+ kind: literal("url"),
19008
+ url: string(),
19009
+ sha256: string().optional()
19010
+ }),
19011
+ object({
19012
+ kind: literal("path"),
19013
+ path: string()
19014
+ })
19015
+ ]);
19016
+ var ManagedRuntimeConfigSchema = object({
19017
+ /** WHERE the runtime lives — hub or any agent. */
19018
+ nodeId: string(),
19019
+ /** Closed for v1; 'ollama' is a v2 candidate. */
19020
+ engine: _enum(["llama-cpp"]),
19021
+ model: ManagedModelRefSchema,
19022
+ contextSize: number().int().default(4096),
19023
+ /** 0 = CPU-only. */
19024
+ gpuLayers: number().int().default(0),
19025
+ /** Default: cpus-2, clamped ≥1 (resolved node-side). */
19026
+ threads: number().int().optional(),
19027
+ /** Concurrent slots. */
19028
+ parallel: number().int().default(1),
19029
+ /** Else lazy: first generate boots it. */
19030
+ autoStart: boolean().default(false),
19031
+ /** 0 = never; frees RAM after quiet periods. */
19032
+ idleStopMinutes: number().int().default(30)
18426
19033
  });
18427
- var AddonInstanceSchema = object({
18428
- addonId: string(),
19034
+ var LlmRuntimeStatusSchema = object({
19035
+ /** Status is ALWAYS node-qualified. */
18429
19036
  nodeId: string(),
18430
- role: _enum(["hub", "worker"]),
18431
- pid: number(),
18432
19037
  state: _enum([
18433
- "starting",
18434
- "running",
18435
- "stopping",
18436
19038
  "stopped",
18437
- "crashed"
18438
- ]),
18439
- uptimeSec: number()
18440
- });
18441
- var NodeProcessSchema = object({
18442
- pid: number(),
18443
- ppid: number(),
18444
- pgid: number(),
18445
- classification: _enum([
18446
- "root",
18447
- "managed",
18448
- "system",
18449
- "ghost"
19039
+ "downloading",
19040
+ "starting",
19041
+ "ready",
19042
+ "crashed",
19043
+ "failed"
18450
19044
  ]),
18451
- /** `$process` addon binding when `managed`, else null. */
18452
- addonId: string().nullable(),
18453
- /** Kernel-reported nodeId when the process is a known agent/worker. */
18454
- nodeId: string().nullable(),
18455
- /** Truncated command line. */
18456
- command: string(),
18457
- cpuPercent: number(),
18458
- memoryRssBytes: number(),
18459
- /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
18460
- uptimeSec: number(),
18461
- /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
18462
- orphaned: boolean()
18463
- });
18464
- var KillProcessInputSchema = object({
18465
- pid: number(),
18466
- /** Force = SIGKILL. Default is SIGTERM. */
18467
- force: boolean().optional()
19045
+ pid: number().optional(),
19046
+ port: number().optional(),
19047
+ modelPath: string().optional(),
19048
+ modelId: string().optional(),
19049
+ downloadProgress: number().min(0).max(1).optional(),
19050
+ lastError: string().optional(),
19051
+ crashesInWindow: number(),
19052
+ /** Child RSS (sampled best-effort). */
19053
+ memoryBytes: number().optional(),
19054
+ vramBytes: number().optional()
18468
19055
  });
18469
- var KillProcessResultSchema = object({
18470
- success: boolean(),
18471
- reason: string().optional(),
18472
- signal: _enum(["SIGTERM", "SIGKILL"]).optional()
19056
+ var LlmNodeModelSchema = object({
19057
+ file: string(),
19058
+ sizeBytes: number(),
19059
+ catalogId: string().optional(),
19060
+ installedAt: number().optional()
18473
19061
  });
18474
- var DumpHeapSnapshotInputSchema = object({
18475
- /** The addon whose runner should dump a heap snapshot. */
18476
- addonId: string() });
18477
- var DumpHeapSnapshotResultSchema = object({
18478
- success: boolean(),
18479
- /** Path of the written .heapsnapshot inside the runner's container/host. */
18480
- path: string().optional(),
18481
- /** Process pid that was signalled. */
18482
- pid: number().optional(),
18483
- reason: string().optional()
19062
+ var LlmRuntimeDiskUsageSchema = object({
19063
+ nodeId: string(),
19064
+ modelsBytes: number(),
19065
+ freeBytes: number().optional()
18484
19066
  });
18485
- var SystemMetricsSchema = object({
18486
- cpuPercent: number(),
18487
- memoryPercent: number(),
18488
- memoryUsedMB: number(),
18489
- memoryTotalMB: number(),
18490
- diskPercent: number().optional(),
18491
- temperature: number().optional(),
18492
- gpuPercent: number().optional(),
18493
- gpuMemoryPercent: number().optional()
18494
- });
18495
- 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, {
19067
+ method(LlmGenerateBaseInputSchema.extend({
19068
+ images: array(LlmImageSchema).optional(),
19069
+ runtime: ManagedRuntimeConfigSchema,
19070
+ /** The managed profile's timeout, threaded by the hub provider. */
19071
+ timeoutMs: number().int().positive().optional()
19072
+ }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
18496
19073
  kind: "mutation",
18497
19074
  auth: "admin"
18498
- }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
19075
+ }), method(object({}), _void(), {
18499
19076
  kind: "mutation",
18500
19077
  auth: "admin"
18501
- });
18502
- method(object({
18503
- sourceUrl: string(),
18504
- metadata: ModelConvertMetadataSchema,
18505
- targets: array(ConvertTargetSchema).min(1).readonly(),
18506
- calibrationRef: string().optional(),
18507
- sessionId: string().optional()
18508
- }), ConvertResultSchema, {
19078
+ }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
18509
19079
  kind: "mutation",
18510
- auth: "admin",
18511
- timeoutMs: 6e5
18512
- });
18513
- method(object({
18514
- nodeId: string(),
18515
- modelId: string(),
18516
- format: _enum(MODEL_FORMATS),
18517
- entry: ModelCatalogEntrySchema
18518
- }), object({
18519
- ok: boolean(),
18520
- /** sha256 of the staged tarball (empty for a hub-local no-op). */
18521
- sha256: string(),
18522
- bytes: number(),
18523
- /** The target node's modelsDir the artifact landed in. */
18524
- path: string()
18525
- }), {
19080
+ auth: "admin"
19081
+ }), method(object({ file: string() }), _void(), {
18526
19082
  kind: "mutation",
18527
19083
  auth: "admin"
18528
- });
18529
- /**
18530
- * `mqtt-broker` — broker-registry cap.
18531
- *
18532
- * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
18533
- * MQTT brokers (external + optionally an embedded `aedes`-backed one)
18534
- * and (b) the connection details a consumer addon needs to spin up
18535
- * its OWN `mqtt.js` client.
18536
- *
18537
- * Why: pub/sub routing over the system event-bus loses fidelity
18538
- * (callback shape, QoS guarantees, will/retain semantics) and adds
18539
- * refcount bookkeeping that addons would rather own themselves. The
18540
- * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
18541
- * features anyway — give it the connection config, get out of the way.
18542
- *
18543
- * Consumer flow:
18544
- * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
18545
- * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
18546
- * client.subscribe('zigbee2mqtt/+')
18547
- *
18548
- * Collection mode: multiple brokers (e.g. one local mosquitto + one
18549
- * cloud bridge). The "embedded" entry (when present) is just another
18550
- * broker in the registry — its lifecycle is owned by the addon that
18551
- * spawned it.
18552
- */
18553
- var BrokerKindSchema = _enum(["external", "embedded"]);
19084
+ }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
18554
19085
  /**
18555
- * Broker live-probe status.
19086
+ * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
19087
+ * methods concat-fan across providers; single-row methods route to ONE
19088
+ * provider by the `addonId` in the call input (the notification-output
19089
+ * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
19090
+ * (hub-placed); the cap stays open for future providers.
18556
19091
  *
18557
- * - `connected` last probe completed a clean CONNACK
18558
- * - `disconnected` — no probe has run yet (cold cache)
18559
- * - `auth-failed` CONNACK refused with auth error (RC 4 / 5)
18560
- * - `unreachable` — TCP connect timed out / refused
18561
- * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
19092
+ * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
19093
+ * `apiKey` is a password field providers REDACT it on read and merge on
19094
+ * write; a stored key NEVER round-trips to a client.
18562
19095
  */
18563
- var BrokerStatusSchema$1 = _enum([
18564
- "connected",
18565
- "disconnected",
18566
- "auth-failed",
18567
- "unreachable",
18568
- "tls-error"
19096
+ var LlmProfileKindSchema = _enum([
19097
+ "openai-compatible",
19098
+ "openai",
19099
+ "anthropic",
19100
+ "google",
19101
+ "managed-local"
18569
19102
  ]);
18570
- var BrokerInfoSchema = object({
19103
+ var LlmProfileSchema = object({
18571
19104
  id: string(),
18572
19105
  name: string(),
18573
- url: string(),
18574
- kind: BrokerKindSchema,
18575
- status: BrokerStatusSchema$1,
18576
- latencyMs: number().nullable(),
18577
- error: string().optional(),
18578
- /** Embedded brokers only: number of MQTT clients currently connected. */
18579
- connectedClients: number().int().nonnegative().optional(),
18580
- /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
18581
- lastCheckedAt: number().optional()
19106
+ kind: LlmProfileKindSchema,
19107
+ /** Stamped by the provider — keeps the fanned catalog routable. */
19108
+ addonId: string(),
19109
+ enabled: boolean(),
19110
+ /** Vendor model id, or the managed runtime's loaded model. */
19111
+ model: string(),
19112
+ /** Required for openai-compatible; override for cloud kinds. */
19113
+ baseUrl: string().optional(),
19114
+ /** ConfigUISchema type:'password' — never round-trips (spec §5). */
19115
+ apiKey: string().optional(),
19116
+ supportsVision: boolean(),
19117
+ temperature: number().min(0).max(2).optional(),
19118
+ maxTokens: number().int().positive().optional(),
19119
+ timeoutMs: number().int().positive().default(6e4),
19120
+ extraHeaders: record(string(), string()).optional(),
19121
+ /** kind === 'managed-local' only (spec §4). */
19122
+ runtime: ManagedRuntimeConfigSchema.optional()
18582
19123
  });
18583
- /**
18584
- * Connection details — what a consumer needs to call
18585
- * `mqtt.connect(url, options)`. We split URL + credentials so the
18586
- * consumer can pass them as `mqtt.connect(url, { username, password })`
18587
- * instead of stuffing creds into the URL (which leaks them into logs).
18588
- */
18589
- var BrokerConnectionDetailsSchema = object({
18590
- url: string(),
18591
- username: string().optional(),
18592
- password: string().optional(),
18593
- /**
18594
- * Suggested prefix for `clientId`. Each consumer should suffix this
18595
- * with its own discriminator (addon id, instance id) so reconnects
18596
- * don't kick each other off (MQTT spec: clientId must be unique per
18597
- * broker).
18598
- */
18599
- clientIdPrefix: string().optional()
19124
+ /** ConfigUISchema tree passed through untyped on the wire (the
19125
+ * notification-output `ConfigSchemaPassthrough` precedent at
19126
+ * notification-output.cap.ts:151); the exported TS type re-tightens it. */
19127
+ var ConfigSchemaPassthrough$1 = unknown();
19128
+ var LlmProfileKindDescriptorSchema = object({
19129
+ kind: LlmProfileKindSchema,
19130
+ label: string(),
19131
+ icon: string(),
19132
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
19133
+ addonId: string(),
19134
+ configSchema: ConfigSchemaPassthrough$1
18600
19135
  });
18601
- var AddBrokerInputSchema = object({
18602
- name: string().min(1),
18603
- url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
18604
- username: string().optional(),
18605
- password: string().optional(),
18606
- clientIdPrefix: string().optional()
19136
+ var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
19137
+ var LlmDefaultSchema = object({
19138
+ selector: LlmDefaultSelectorSchema,
19139
+ profileId: string()
18607
19140
  });
18608
- var AddBrokerResultSchema = object({ id: string() });
18609
- var IdInputSchema = object({ id: string() });
18610
- var TestResultSchema$1 = discriminatedUnion("ok", [object({
18611
- ok: literal(true),
18612
- latencyMs: number()
18613
- }), object({
18614
- ok: literal(false),
18615
- error: string()
18616
- })]);
18617
- var StartEmbeddedInputSchema = object({
18618
- port: number().int().min(1).max(65535).default(1883),
18619
- /** Allow anonymous connect (no username/password). Default: false. */
18620
- allowAnonymous: boolean().default(false),
18621
- /** Optional shared username/password for clients. */
18622
- username: string().optional(),
18623
- password: string().optional()
19141
+ /** Server-side rollup row getUsage never dumps raw call rows (spec §6). */
19142
+ var LlmUsageRollupSchema = object({
19143
+ day: string(),
19144
+ consumer: string(),
19145
+ profileId: string(),
19146
+ calls: number(),
19147
+ okCalls: number(),
19148
+ errorCalls: number(),
19149
+ inputTokens: number(),
19150
+ outputTokens: number(),
19151
+ avgLatencyMs: number()
18624
19152
  });
18625
- var StartEmbeddedResultSchema = object({
19153
+ /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
19154
+ var ManagedModelCatalogEntrySchema = object({
18626
19155
  id: string(),
18627
- url: string()
18628
- });
18629
- var StatusSchema = object({
18630
- brokerCount: number(),
18631
- embeddedRunning: boolean()
18632
- });
18633
- 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);
18634
- var NetworkEndpointSchema = object({
19156
+ label: string(),
19157
+ family: string(),
19158
+ purpose: _enum(["text", "vision"]),
18635
19159
  url: string(),
18636
- hostname: string(),
18637
- port: number(),
18638
- protocol: _enum(["http", "https"])
19160
+ sha256: string(),
19161
+ sizeBytes: number(),
19162
+ quantization: string(),
19163
+ /** Load-time guidance shown in the picker. */
19164
+ minRamBytes: number(),
19165
+ contextSizeDefault: number().int(),
19166
+ /** Vision models: companion projector file. */
19167
+ mmprojUrl: string().optional()
18639
19168
  });
18640
- var NetworkAccessStatusSchema = object({
18641
- connected: boolean(),
18642
- endpoint: NetworkEndpointSchema.nullable(),
19169
+ var LlmRuntimeNodeSchema = object({
19170
+ nodeId: string(),
19171
+ reachable: boolean(),
19172
+ status: LlmRuntimeStatusSchema.optional(),
19173
+ disk: LlmRuntimeDiskUsageSchema.optional(),
18643
19174
  error: string().optional()
18644
19175
  });
18645
- /**
18646
- * Optional, richer endpoint shape returned by providers that expose
18647
- * MORE than one ingress concurrently (Tailscale Ingress with mixed
18648
- * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
18649
- * the originating provider config (mode + sourcePort) so the
18650
- * orchestrator UI can label rows distinctly. Providers that expose only
18651
- * one endpoint just omit `listEndpoints` from their provider impl.
18652
- */
18653
- var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
18654
- /**
18655
- * Stable id within the provider — typically `<mode>-<sourcePort>` so
18656
- * the orchestrator can dedupe across `listEndpoints` polls.
18657
- */
18658
- id: string(),
18659
- /** Operator-facing label (mirrors `MeshEndpoint.label`). */
18660
- label: string(),
18661
- /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
18662
- mode: string().optional(),
18663
- /** Originating local port the ingress fronts (informational). */
18664
- sourcePort: number().optional()
19176
+ var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
19177
+ var ProfileRefInputSchema = object({
19178
+ addonId: string(),
19179
+ profileId: string()
18665
19180
  });
18666
- method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
18667
- /**
18668
- * notification-output — canonical, capability-gated notification delivery.
18669
- *
18670
- * Apprise-derived model (see
18671
- * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
18672
- * callers emit ONE canonical `Notification`; each provider declares a
18673
- * per-kind capability descriptor (`TargetKind`), and the pure degrade
18674
- * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
18675
- * message to what the kind supports — callers never special-case a service.
18676
- *
18677
- * DESIGN DECISIONS (locked):
18678
- * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
18679
- * `setTargetEnabled`), each provider persisting via the `settings-store`
18680
- * cap. Rationale: the admin UI needs one uniform surface across the
18681
- * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
18682
- * alternative would fork the UI per addon and cannot host the
18683
- * discovery→adopt flow.
18684
- * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
18685
- * the generated cap-mount auto-`concatCollection`-fans them across every
18686
- * registered provider (notifiers addon + HA addon) so one catalog is
18687
- * routable. `send` / `testTarget` / CRUD route to ONE provider by the
18688
- * `addonId` the generated collection router extracts from the call input.
18689
- * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
18690
- * transformer) + UDS MsgPack both round-trip typed arrays — already used by
18691
- * `storage` / `storage-provider` / `recording` caps over the same path. No
18692
- * base64 fallback needed.
18693
- *
18694
- * TODO (deferred, closed-set change — separate decision): add
18695
- * `providerKind: 'notify'` so notification providers surface on the unified
18696
- * admin "Integrations" page.
18697
- */
18698
- /**
18699
- * Zentik-derived typed-media enum — the superset across every kind. Each
18700
- * adapter picks what it supports and the degrade engine filters the rest.
18701
- */
18702
- var AttachmentMediaTypeSchema = _enum([
18703
- "image",
18704
- "video",
18705
- "gif",
18706
- "audio",
18707
- "icon"
19181
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
19182
+ kind: "mutation",
19183
+ auth: "admin"
19184
+ }), method(ProfileRefInputSchema, _void(), {
19185
+ kind: "mutation",
19186
+ auth: "admin"
19187
+ }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
19188
+ kind: "mutation",
19189
+ auth: "admin"
19190
+ }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
19191
+ selector: LlmDefaultSelectorSchema,
19192
+ profileId: string().nullable()
19193
+ }), _void(), {
19194
+ kind: "mutation",
19195
+ auth: "admin"
19196
+ }), method(object({
19197
+ since: number().optional(),
19198
+ until: number().optional(),
19199
+ consumer: string().optional(),
19200
+ profileId: string().optional()
19201
+ }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
19202
+ nodeId: string(),
19203
+ model: ManagedModelRefSchema
19204
+ }), _void(), {
19205
+ kind: "mutation",
19206
+ auth: "admin"
19207
+ }), method(object({
19208
+ nodeId: string(),
19209
+ file: string()
19210
+ }), _void(), {
19211
+ kind: "mutation",
19212
+ auth: "admin"
19213
+ }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
19214
+ kind: "mutation",
19215
+ auth: "admin"
19216
+ }), method(ProfileRefInputSchema, _void(), {
19217
+ kind: "mutation",
19218
+ auth: "admin"
19219
+ });
19220
+ var LogLevelSchema = _enum([
19221
+ "debug",
19222
+ "info",
19223
+ "warn",
19224
+ "error"
18708
19225
  ]);
19226
+ var LogEntrySchema = object({
19227
+ timestamp: date(),
19228
+ level: LogLevelSchema,
19229
+ scope: array(string()),
19230
+ message: string(),
19231
+ meta: record(string(), unknown()).optional(),
19232
+ tags: record(string(), string()).optional()
19233
+ });
19234
+ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
19235
+ scope: array(string()).optional(),
19236
+ level: LogLevelSchema.optional(),
19237
+ since: date().optional(),
19238
+ until: date().optional(),
19239
+ limit: number().optional(),
19240
+ tags: record(string(), string()).optional()
19241
+ }), array(LogEntrySchema).readonly());
18709
19242
  /**
18710
- * A single attachment. Exactly one of `url` (remote source, most adapters
18711
- * prefer this) or `bytes` (inline source; required for Pushover-style
18712
- * bytes-only kinds) MUST be present — the degrade engine expresses a
18713
- * url→bytes fetch as a `needsFetch` directive the adapter executes.
19243
+ * `login-method` collection cap through which auth addons contribute
19244
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
19245
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
19246
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
19247
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
19248
+ * procedure aggregates them for the unauthenticated login page.
19249
+ *
19250
+ * A contribution is a discriminated union on `kind`:
19251
+ *
19252
+ * - `redirect` — a declarative button. The login page renders a generic
19253
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
19254
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
19255
+ * ZERO shell-side JS. A future SSO addon plugs in the same way — the
19256
+ * login page needs NO change.
19257
+ *
19258
+ * - `widget` — a Module-Federation widget the login page mounts (via
19259
+ * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
19260
+ * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
19261
+ * mechanism kept for future use; no shipped addon uses it on the login
19262
+ * page (the passkey ceremony below runs natively in the shell instead).
19263
+ *
19264
+ * - `passkey` — a declarative WebAuthn ceremony the shell renders
19265
+ * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
19266
+ * a remotely-loaded bundle). Carries the addon's effective `rpId` /
19267
+ * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
19268
+ * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
19269
+ * fetching any remote code pre-auth. Contribution stays unconditional —
19270
+ * enrollment state is never leaked pre-auth; visibility is a shell
19271
+ * decision.
19272
+ *
19273
+ * Every contribution carries a `stage`:
19274
+ * - `primary` — shown on the first credentials screen (OIDC /
19275
+ * magic-link buttons; a future usernameless passkey).
19276
+ * - `second-factor` — shown AFTER the password leg, gated on the
19277
+ * returned `factors` (passkey-as-2FA today).
19278
+ *
19279
+ * `mount: skip` — the cap is read server-side by the core auth router
19280
+ * (`registry.getCollection('login-method')`), never mounted as its own
19281
+ * tRPC router.
18714
19282
  */
18715
- var AttachmentSchema = object({
18716
- mediaType: AttachmentMediaTypeSchema,
18717
- url: string().optional(),
18718
- bytes: _instanceof(Uint8Array).optional(),
18719
- mime: string().optional(),
18720
- name: string().optional()
18721
- }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
18722
- var NotificationFormatSchema = _enum([
18723
- "text",
18724
- "markdown",
18725
- "html"
19283
+ /** When a login method renders in the two-phase login flow. */
19284
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
19285
+ /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
19286
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [
19287
+ object({
19288
+ kind: literal("redirect"),
19289
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
19290
+ id: string(),
19291
+ /** Operator-facing button label. */
19292
+ label: string(),
19293
+ /** lucide-react icon name. */
19294
+ icon: string().optional(),
19295
+ /** Addon-owned HTTP route the button navigates to (GET). */
19296
+ startUrl: string(),
19297
+ stage: LoginStageEnum
19298
+ }),
19299
+ object({
19300
+ kind: literal("widget"),
19301
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
19302
+ id: string(),
19303
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
19304
+ addonId: string(),
19305
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
19306
+ bundle: string(),
19307
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
19308
+ remote: WidgetRemoteSchema,
19309
+ stage: LoginStageEnum
19310
+ }),
19311
+ object({
19312
+ kind: literal("passkey"),
19313
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
19314
+ id: string(),
19315
+ /** Operator-facing button label. */
19316
+ label: string(),
19317
+ stage: LoginStageEnum,
19318
+ /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
19319
+ rpId: string(),
19320
+ /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
19321
+ origin: string().nullable()
19322
+ })
18726
19323
  ]);
18727
- /** A single tap-through action button. */
18728
- var NotificationActionSchema = object({
18729
- id: string(),
18730
- label: string(),
18731
- url: string().optional()
19324
+ method(_void(), array(LoginMethodContributionSchema).readonly());
19325
+ var CpuBreakdownSchema = object({
19326
+ total: number(),
19327
+ user: number(),
19328
+ system: number(),
19329
+ irq: number(),
19330
+ nice: number(),
19331
+ loadAvg: tuple([
19332
+ number(),
19333
+ number(),
19334
+ number()
19335
+ ]),
19336
+ cores: number()
18732
19337
  });
18733
- /**
18734
- * The canonical notification. `body` is the only hard field (Apprise model).
18735
- * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
18736
- * NOT a fixed severity enum — each kind declares its own `caps.levels` and
18737
- * the adapter maps this ordinal onto its native level. `level?` is an
18738
- * optional kind-native level id (`emergency`, `silent`, …) that overrides
18739
- * `priority` for that one target.
18740
- */
18741
- var NotificationSchema = object({
18742
- body: string(),
18743
- title: string().optional(),
18744
- format: NotificationFormatSchema.default("text"),
18745
- priority: number().int().min(1).max(5).default(3),
18746
- level: string().optional(),
18747
- attachments: array(AttachmentSchema).optional(),
18748
- clickUrl: string().optional(),
18749
- actions: array(NotificationActionSchema).optional(),
18750
- sound: string().optional(),
18751
- ttl: number().optional(),
18752
- tag: string().optional(),
18753
- deviceId: number().optional(),
18754
- eventId: string().optional(),
18755
- metadata: record(string(), unknown()).optional()
19338
+ var MemoryInfoSchema = object({
19339
+ percent: number(),
19340
+ totalBytes: number(),
19341
+ usedBytes: number(),
19342
+ availableBytes: number(),
19343
+ swapUsedBytes: number(),
19344
+ swapTotalBytes: number()
19345
+ });
19346
+ var DiskIoSnapshotSchema = object({
19347
+ readBytes: number(),
19348
+ writeBytes: number(),
19349
+ readOps: number(),
19350
+ writeOps: number(),
19351
+ timestampMs: number()
19352
+ });
19353
+ var NetworkIoSnapshotSchema = object({
19354
+ rxBytes: number(),
19355
+ txBytes: number(),
19356
+ rxPackets: number(),
19357
+ txPackets: number(),
19358
+ rxErrors: number(),
19359
+ txErrors: number(),
19360
+ timestampMs: number()
19361
+ });
19362
+ var MetricsGpuInfoSchema = object({
19363
+ utilization: number(),
19364
+ model: string(),
19365
+ memoryUsedBytes: number(),
19366
+ memoryTotalBytes: number(),
19367
+ temperature: number().nullable()
19368
+ });
19369
+ var ProcessResourceInfoSchema = object({
19370
+ openFds: number(),
19371
+ threadCount: number(),
19372
+ activeHandles: number(),
19373
+ activeRequests: number()
18756
19374
  });
18757
- /** One declared native severity/priority level for a kind. */
18758
- var TargetKindLevelSchema = object({
18759
- id: string(),
18760
- label: string(),
18761
- /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
18762
- ordinal: number().int().min(1).max(5).nullable(),
18763
- flags: object({
18764
- critical: boolean().optional(),
18765
- silent: boolean().optional(),
18766
- noPush: boolean().optional()
18767
- }).optional(),
18768
- /** e.g. Pushover `emergency` requires `retry` / `expire`. */
18769
- requires: array(string()).optional(),
18770
- description: string().optional()
19375
+ var PressureAvgsSchema = object({
19376
+ avg10: number(),
19377
+ avg60: number(),
19378
+ avg300: number()
18771
19379
  });
18772
- /** The full capability block consulted before dispatch. */
18773
- var TargetKindCapsSchema = object({
18774
- attachments: object({
18775
- mediaTypes: array(AttachmentMediaTypeSchema),
18776
- mode: _enum([
18777
- "url",
18778
- "bytes",
18779
- "both"
18780
- ]),
18781
- max: number().int().nonnegative(),
18782
- maxBytes: number().int().positive().optional()
19380
+ var PressureInfoSchema = object({
19381
+ some: PressureAvgsSchema,
19382
+ full: PressureAvgsSchema.nullable()
19383
+ });
19384
+ var SystemResourceSnapshotSchema = object({
19385
+ cpu: CpuBreakdownSchema,
19386
+ memory: MemoryInfoSchema,
19387
+ gpu: MetricsGpuInfoSchema.nullable(),
19388
+ network: NetworkIoSnapshotSchema,
19389
+ disk: DiskIoSnapshotSchema,
19390
+ pressure: object({
19391
+ cpu: PressureInfoSchema.nullable(),
19392
+ memory: PressureInfoSchema.nullable(),
19393
+ io: PressureInfoSchema.nullable()
18783
19394
  }),
18784
- /** Max action buttons (0 = none). */
18785
- actions: number().int().nonnegative(),
18786
- levels: array(TargetKindLevelSchema),
18787
- format: array(NotificationFormatSchema),
18788
- clickUrl: boolean(),
18789
- sound: boolean(),
18790
- ttl: boolean(),
18791
- bodyMaxLen: number().int().positive()
19395
+ process: ProcessResourceInfoSchema,
19396
+ cpuTemperature: number().nullable(),
19397
+ timestampMs: number()
18792
19398
  });
18793
- /**
18794
- * `configSchema` is a `ConfigUISchema` tree passed through to the admin
18795
- * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
18796
- * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`)
18797
- * the union is large and not meant for runtime validation here; the exported
18798
- * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
18799
- */
18800
- var ConfigSchemaPassthrough$1 = unknown();
18801
- var TargetKindSchema = object({
18802
- kind: string(),
18803
- label: string(),
18804
- icon: string(),
18805
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
18806
- addonId: string(),
18807
- configSchema: ConfigSchemaPassthrough$1,
18808
- supportsDiscovery: boolean(),
18809
- caps: TargetKindCapsSchema
19399
+ var DiskSpaceInfoSchema = object({
19400
+ path: string(),
19401
+ totalBytes: number(),
19402
+ usedBytes: number(),
19403
+ availableBytes: number(),
19404
+ percent: number()
18810
19405
  });
18811
- /**
18812
- * A persisted target. `config` holds secrets; providers REDACT secret fields
18813
- * (return a presence marker only) when serving `listTargets` — never
18814
- * round-trip a stored secret to the UI.
18815
- */
18816
- var TargetSchema = object({
18817
- id: string(),
18818
- name: string(),
18819
- kind: string(),
19406
+ var PidResourceStatsSchema = object({
19407
+ pid: number(),
19408
+ cpu: number(),
19409
+ memory: number(),
19410
+ /**
19411
+ * Private (anonymous) resident bytes — the per-process V8 heap + native
19412
+ * allocations NOT shared with other processes (Linux RssAnon). This is the
19413
+ * "real" per-runner cost; summing it across runners is meaningful, unlike
19414
+ * `memory` (RSS), which double-counts the shared mmap'd framework code.
19415
+ * Undefined where /proc is unavailable (e.g. macOS).
19416
+ */
19417
+ privateBytes: number().optional(),
19418
+ /**
19419
+ * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
19420
+ * code shared copy-on-write across runners. Undefined on macOS.
19421
+ */
19422
+ sharedBytes: number().optional()
19423
+ });
19424
+ var AddonInstanceSchema = object({
18820
19425
  addonId: string(),
18821
- enabled: boolean(),
18822
- config: record(string(), unknown())
19426
+ nodeId: string(),
19427
+ role: _enum(["hub", "worker"]),
19428
+ pid: number(),
19429
+ state: _enum([
19430
+ "starting",
19431
+ "running",
19432
+ "stopping",
19433
+ "stopped",
19434
+ "crashed"
19435
+ ]),
19436
+ uptimeSec: number()
18823
19437
  });
18824
- /** A discovery-surfaced candidate (config is partial + non-secret). */
18825
- var DiscoveredTargetSchema = object({
18826
- kind: string(),
18827
- suggestedName: string(),
18828
- config: record(string(), unknown())
19438
+ var NodeProcessSchema = object({
19439
+ pid: number(),
19440
+ ppid: number(),
19441
+ pgid: number(),
19442
+ classification: _enum([
19443
+ "root",
19444
+ "managed",
19445
+ "system",
19446
+ "ghost"
19447
+ ]),
19448
+ /** `$process` addon binding when `managed`, else null. */
19449
+ addonId: string().nullable(),
19450
+ /** Kernel-reported nodeId when the process is a known agent/worker. */
19451
+ nodeId: string().nullable(),
19452
+ /** Truncated command line. */
19453
+ command: string(),
19454
+ cpuPercent: number(),
19455
+ memoryRssBytes: number(),
19456
+ /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
19457
+ uptimeSec: number(),
19458
+ /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
19459
+ orphaned: boolean()
18829
19460
  });
18830
- /** The degrade engine's report — what was resolved / dropped / degraded. */
18831
- var RenderedAsSchema = object({
18832
- level: string(),
18833
- format: NotificationFormatSchema,
18834
- attachmentsSent: number().int().nonnegative(),
18835
- actionsSent: number().int().nonnegative(),
18836
- truncated: boolean(),
18837
- dropped: array(string())
19461
+ var KillProcessInputSchema = object({
19462
+ pid: number(),
19463
+ /** Force = SIGKILL. Default is SIGTERM. */
19464
+ force: boolean().optional()
18838
19465
  });
18839
- var SendResultSchema = object({
19466
+ var KillProcessResultSchema = object({
19467
+ success: boolean(),
19468
+ reason: string().optional(),
19469
+ signal: _enum(["SIGTERM", "SIGKILL"]).optional()
19470
+ });
19471
+ var DumpHeapSnapshotInputSchema = object({
19472
+ /** The addon whose runner should dump a heap snapshot. */
19473
+ addonId: string() });
19474
+ var DumpHeapSnapshotResultSchema = object({
18840
19475
  success: boolean(),
19476
+ /** Path of the written .heapsnapshot inside the runner's container/host. */
19477
+ path: string().optional(),
19478
+ /** Process pid that was signalled. */
19479
+ pid: number().optional(),
19480
+ reason: string().optional()
19481
+ });
19482
+ var SystemMetricsSchema = object({
19483
+ cpuPercent: number(),
19484
+ memoryPercent: number(),
19485
+ memoryUsedMB: number(),
19486
+ memoryTotalMB: number(),
19487
+ diskPercent: number().optional(),
19488
+ temperature: number().optional(),
19489
+ gpuPercent: number().optional(),
19490
+ gpuMemoryPercent: number().optional()
19491
+ });
19492
+ 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, {
19493
+ kind: "mutation",
19494
+ auth: "admin"
19495
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
19496
+ kind: "mutation",
19497
+ auth: "admin"
19498
+ });
19499
+ method(object({
19500
+ sourceUrl: string(),
19501
+ metadata: ModelConvertMetadataSchema,
19502
+ targets: array(ConvertTargetSchema).min(1).readonly(),
19503
+ calibrationRef: string().optional(),
19504
+ sessionId: string().optional()
19505
+ }), ConvertResultSchema, {
19506
+ kind: "mutation",
19507
+ auth: "admin",
19508
+ timeoutMs: 6e5
19509
+ });
19510
+ method(object({
19511
+ nodeId: string(),
19512
+ modelId: string(),
19513
+ format: _enum(MODEL_FORMATS),
19514
+ entry: ModelCatalogEntrySchema
19515
+ }), object({
19516
+ ok: boolean(),
19517
+ /** sha256 of the staged tarball (empty for a hub-local no-op). */
19518
+ sha256: string(),
19519
+ bytes: number(),
19520
+ /** The target node's modelsDir the artifact landed in. */
19521
+ path: string()
19522
+ }), {
19523
+ kind: "mutation",
19524
+ auth: "admin"
19525
+ });
19526
+ /**
19527
+ * `mqtt-broker` — broker-registry cap.
19528
+ *
19529
+ * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
19530
+ * MQTT brokers (external + optionally an embedded `aedes`-backed one)
19531
+ * and (b) the connection details a consumer addon needs to spin up
19532
+ * its OWN `mqtt.js` client.
19533
+ *
19534
+ * Why: pub/sub routing over the system event-bus loses fidelity
19535
+ * (callback shape, QoS guarantees, will/retain semantics) and adds
19536
+ * refcount bookkeeping that addons would rather own themselves. The
19537
+ * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
19538
+ * features anyway — give it the connection config, get out of the way.
19539
+ *
19540
+ * Consumer flow:
19541
+ * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
19542
+ * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
19543
+ * client.subscribe('zigbee2mqtt/+')
19544
+ *
19545
+ * Collection mode: multiple brokers (e.g. one local mosquitto + one
19546
+ * cloud bridge). The "embedded" entry (when present) is just another
19547
+ * broker in the registry — its lifecycle is owned by the addon that
19548
+ * spawned it.
19549
+ */
19550
+ var BrokerKindSchema = _enum(["external", "embedded"]);
19551
+ /**
19552
+ * Broker live-probe status.
19553
+ *
19554
+ * - `connected` — last probe completed a clean CONNACK
19555
+ * - `disconnected` — no probe has run yet (cold cache)
19556
+ * - `auth-failed` — CONNACK refused with auth error (RC 4 / 5)
19557
+ * - `unreachable` — TCP connect timed out / refused
19558
+ * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
19559
+ */
19560
+ var BrokerStatusSchema$1 = _enum([
19561
+ "connected",
19562
+ "disconnected",
19563
+ "auth-failed",
19564
+ "unreachable",
19565
+ "tls-error"
19566
+ ]);
19567
+ var BrokerInfoSchema = object({
19568
+ id: string(),
19569
+ name: string(),
19570
+ url: string(),
19571
+ kind: BrokerKindSchema,
19572
+ status: BrokerStatusSchema$1,
19573
+ latencyMs: number().nullable(),
18841
19574
  error: string().optional(),
18842
- renderedAs: RenderedAsSchema.optional()
19575
+ /** Embedded brokers only: number of MQTT clients currently connected. */
19576
+ connectedClients: number().int().nonnegative().optional(),
19577
+ /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
19578
+ lastCheckedAt: number().optional()
18843
19579
  });
18844
- /** Same shape as SendResult — kept as a distinct name for the test panel. */
18845
- var TestResultSchema = SendResultSchema;
18846
- method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
18847
- kind: string(),
18848
- config: record(string(), unknown()).optional()
18849
- }), array(DiscoveredTargetSchema)), method(object({
18850
- targetId: string(),
18851
- notification: NotificationSchema
18852
- }), SendResultSchema, { kind: "mutation" }), method(object({
18853
- targetId: string(),
18854
- sample: NotificationSchema.optional()
18855
- }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
18856
- targetId: string(),
18857
- enabled: boolean()
18858
- }), _void(), { kind: "mutation" });
18859
19580
  /**
18860
- * Shared LLM generate contracts imported by BOTH `llm.cap.ts` (consumer
18861
- * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
18862
- * caps stay wire-compatible without a circular cap→cap import.
18863
- *
18864
- * Errors are a discriminated-union RESULT, never thrown: the shape survives
18865
- * every transport tier structurally, and failed calls still write usage rows.
18866
- * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
19581
+ * Connection details what a consumer needs to call
19582
+ * `mqtt.connect(url, options)`. We split URL + credentials so the
19583
+ * consumer can pass them as `mqtt.connect(url, { username, password })`
19584
+ * instead of stuffing creds into the URL (which leaks them into logs).
18867
19585
  */
18868
- var LlmUsageSchema = object({
18869
- inputTokens: number(),
18870
- outputTokens: number()
19586
+ var BrokerConnectionDetailsSchema = object({
19587
+ url: string(),
19588
+ username: string().optional(),
19589
+ password: string().optional(),
19590
+ /**
19591
+ * Suggested prefix for `clientId`. Each consumer should suffix this
19592
+ * with its own discriminator (addon id, instance id) so reconnects
19593
+ * don't kick each other off (MQTT spec: clientId must be unique per
19594
+ * broker).
19595
+ */
19596
+ clientIdPrefix: string().optional()
18871
19597
  });
18872
- var LlmErrorCodeSchema = _enum([
18873
- "timeout",
18874
- "rate-limited",
18875
- "auth",
18876
- "refusal",
18877
- "bad-request",
18878
- "unavailable",
18879
- "no-profile",
18880
- "budget-exceeded",
18881
- "adapter-error"
18882
- ]);
18883
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
19598
+ var AddBrokerInputSchema = object({
19599
+ name: string().min(1),
19600
+ url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
19601
+ username: string().optional(),
19602
+ password: string().optional(),
19603
+ clientIdPrefix: string().optional()
19604
+ });
19605
+ var AddBrokerResultSchema = object({ id: string() });
19606
+ var IdInputSchema = object({ id: string() });
19607
+ var TestResultSchema$1 = discriminatedUnion("ok", [object({
18884
19608
  ok: literal(true),
18885
- text: string(),
18886
- model: string(),
18887
- usage: LlmUsageSchema,
18888
- truncated: boolean(),
18889
19609
  latencyMs: number()
18890
19610
  }), object({
18891
19611
  ok: literal(false),
18892
- code: LlmErrorCodeSchema,
18893
- message: string(),
18894
- retryAfterMs: number().optional()
19612
+ error: string()
18895
19613
  })]);
18896
- /**
18897
- * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
18898
- * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
18899
- * notification-output.cap.ts:27-31 precedents).
18900
- */
18901
- var LlmImageSchema = object({
18902
- bytes: _instanceof(Uint8Array),
18903
- mimeType: string()
19614
+ var StartEmbeddedInputSchema = object({
19615
+ port: number().int().min(1).max(65535).default(1883),
19616
+ /** Allow anonymous connect (no username/password). Default: false. */
19617
+ allowAnonymous: boolean().default(false),
19618
+ /** Optional shared username/password for clients. */
19619
+ username: string().optional(),
19620
+ password: string().optional()
18904
19621
  });
18905
- var LlmGenerateBaseInputSchema = object({
18906
- /** Collection routing (the notification-output posture). */
18907
- addonId: string().optional(),
18908
- /** Explicit profile; else the resolution chain (spec §3). */
18909
- profileId: string().optional(),
18910
- /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
18911
- consumer: string(),
18912
- system: string().optional(),
18913
- /** v1: single-turn. `messages[]` is a v2 additive field. */
18914
- prompt: string(),
18915
- /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
18916
- jsonSchema: record(string(), unknown()).optional(),
18917
- /** Per-call override of the profile default. */
18918
- maxTokens: number().int().positive().optional(),
18919
- temperature: number().optional()
19622
+ var StartEmbeddedResultSchema = object({
19623
+ id: string(),
19624
+ url: string()
18920
19625
  });
18921
- /**
18922
- * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
18923
- * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
18924
- * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
18925
- * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
18926
- * this only through the `llm` cap's methods.
18927
- *
18928
- * One running llama-server child per node in v1 (models are RAM-heavy).
18929
- * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
18930
- * watchdog — operator decision #3).
18931
- */
18932
- var ManagedModelRefSchema = discriminatedUnion("kind", [
18933
- object({
18934
- kind: literal("catalog"),
18935
- catalogId: string()
18936
- }),
18937
- object({
18938
- kind: literal("url"),
18939
- url: string(),
18940
- sha256: string().optional()
18941
- }),
18942
- object({
18943
- kind: literal("path"),
18944
- path: string()
18945
- })
18946
- ]);
18947
- var ManagedRuntimeConfigSchema = object({
18948
- /** WHERE the runtime lives — hub or any agent. */
18949
- nodeId: string(),
18950
- /** Closed for v1; 'ollama' is a v2 candidate. */
18951
- engine: _enum(["llama-cpp"]),
18952
- model: ManagedModelRefSchema,
18953
- contextSize: number().int().default(4096),
18954
- /** 0 = CPU-only. */
18955
- gpuLayers: number().int().default(0),
18956
- /** Default: cpus-2, clamped ≥1 (resolved node-side). */
18957
- threads: number().int().optional(),
18958
- /** Concurrent slots. */
18959
- parallel: number().int().default(1),
18960
- /** Else lazy: first generate boots it. */
18961
- autoStart: boolean().default(false),
18962
- /** 0 = never; frees RAM after quiet periods. */
18963
- idleStopMinutes: number().int().default(30)
19626
+ var StatusSchema = object({
19627
+ brokerCount: number(),
19628
+ embeddedRunning: boolean()
18964
19629
  });
18965
- var LlmRuntimeStatusSchema = object({
18966
- /** Status is ALWAYS node-qualified. */
18967
- nodeId: string(),
18968
- state: _enum([
18969
- "stopped",
18970
- "downloading",
18971
- "starting",
18972
- "ready",
18973
- "crashed",
18974
- "failed"
18975
- ]),
18976
- pid: number().optional(),
18977
- port: number().optional(),
18978
- modelPath: string().optional(),
18979
- modelId: string().optional(),
18980
- downloadProgress: number().min(0).max(1).optional(),
18981
- lastError: string().optional(),
18982
- crashesInWindow: number(),
18983
- /** Child RSS (sampled best-effort). */
18984
- memoryBytes: number().optional(),
18985
- vramBytes: number().optional()
19630
+ 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);
19631
+ var NetworkEndpointSchema = object({
19632
+ url: string(),
19633
+ hostname: string(),
19634
+ port: number(),
19635
+ protocol: _enum(["http", "https"])
18986
19636
  });
18987
- var LlmNodeModelSchema = object({
18988
- file: string(),
18989
- sizeBytes: number(),
18990
- catalogId: string().optional(),
18991
- installedAt: number().optional()
19637
+ var NetworkAccessStatusSchema = object({
19638
+ connected: boolean(),
19639
+ endpoint: NetworkEndpointSchema.nullable(),
19640
+ error: string().optional()
18992
19641
  });
18993
- var LlmRuntimeDiskUsageSchema = object({
18994
- nodeId: string(),
18995
- modelsBytes: number(),
18996
- freeBytes: number().optional()
19642
+ /**
19643
+ * Optional, richer endpoint shape returned by providers that expose
19644
+ * MORE than one ingress concurrently (Tailscale Ingress with mixed
19645
+ * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
19646
+ * the originating provider config (mode + sourcePort) so the
19647
+ * orchestrator UI can label rows distinctly. Providers that expose only
19648
+ * one endpoint just omit `listEndpoints` from their provider impl.
19649
+ */
19650
+ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
19651
+ /**
19652
+ * Stable id within the provider — typically `<mode>-<sourcePort>` so
19653
+ * the orchestrator can dedupe across `listEndpoints` polls.
19654
+ */
19655
+ id: string(),
19656
+ /** Operator-facing label (mirrors `MeshEndpoint.label`). */
19657
+ label: string(),
19658
+ /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
19659
+ mode: string().optional(),
19660
+ /** Originating local port the ingress fronts (informational). */
19661
+ sourcePort: number().optional()
18997
19662
  });
18998
- method(LlmGenerateBaseInputSchema.extend({
18999
- images: array(LlmImageSchema).optional(),
19000
- runtime: ManagedRuntimeConfigSchema,
19001
- /** The managed profile's timeout, threaded by the hub provider. */
19002
- timeoutMs: number().int().positive().optional()
19003
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
19004
- kind: "mutation",
19005
- auth: "admin"
19006
- }), method(object({}), _void(), {
19007
- kind: "mutation",
19008
- auth: "admin"
19009
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
19010
- kind: "mutation",
19011
- auth: "admin"
19012
- }), method(object({ file: string() }), _void(), {
19013
- kind: "mutation",
19014
- auth: "admin"
19015
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
19663
+ method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
19016
19664
  /**
19017
- * `llm`consumer-facing LLM surface (spec §1-§3). Collection-mode: array
19018
- * methods concat-fan across providers; single-row methods route to ONE
19019
- * provider by the `addonId` in the call input (the notification-output
19020
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
19021
- * (hub-placed); the cap stays open for future providers.
19665
+ * notification-outputcanonical, capability-gated notification delivery.
19666
+ *
19667
+ * Apprise-derived model (see
19668
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
19669
+ * callers emit ONE canonical `Notification`; each provider declares a
19670
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
19671
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
19672
+ * message to what the kind supports — callers never special-case a service.
19673
+ *
19674
+ * DESIGN DECISIONS (locked):
19675
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
19676
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
19677
+ * cap. Rationale: the admin UI needs one uniform surface across the
19678
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
19679
+ * alternative would fork the UI per addon and cannot host the
19680
+ * discovery→adopt flow.
19681
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
19682
+ * the generated cap-mount auto-`concatCollection`-fans them across every
19683
+ * registered provider (notifiers addon + HA addon) so one catalog is
19684
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
19685
+ * `addonId` the generated collection router extracts from the call input.
19686
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
19687
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
19688
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
19689
+ * base64 fallback needed.
19022
19690
  *
19023
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
19024
- * `apiKey` is a password field — providers REDACT it on read and merge on
19025
- * write; a stored key NEVER round-trips to a client.
19691
+ * TODO (deferred, closed-set change separate decision): add
19692
+ * `providerKind: 'notify'` so notification providers surface on the unified
19693
+ * admin "Integrations" page.
19026
19694
  */
19027
- var LlmProfileKindSchema = _enum([
19028
- "openai-compatible",
19029
- "openai",
19030
- "anthropic",
19031
- "google",
19032
- "managed-local"
19695
+ /**
19696
+ * Zentik-derived typed-media enum — the superset across every kind. Each
19697
+ * adapter picks what it supports and the degrade engine filters the rest.
19698
+ */
19699
+ var AttachmentMediaTypeSchema = _enum([
19700
+ "image",
19701
+ "video",
19702
+ "gif",
19703
+ "audio",
19704
+ "icon"
19033
19705
  ]);
19034
- var LlmProfileSchema = object({
19706
+ /**
19707
+ * A single attachment. Exactly one of `url` (remote source, most adapters
19708
+ * prefer this) or `bytes` (inline source; required for Pushover-style
19709
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
19710
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
19711
+ */
19712
+ var AttachmentSchema = object({
19713
+ mediaType: AttachmentMediaTypeSchema,
19714
+ url: string().optional(),
19715
+ bytes: _instanceof(Uint8Array).optional(),
19716
+ mime: string().optional(),
19717
+ name: string().optional()
19718
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
19719
+ var NotificationFormatSchema = _enum([
19720
+ "text",
19721
+ "markdown",
19722
+ "html"
19723
+ ]);
19724
+ /** A single tap-through action button. */
19725
+ var NotificationActionSchema = object({
19035
19726
  id: string(),
19036
- name: string(),
19037
- kind: LlmProfileKindSchema,
19038
- /** Stamped by the provider — keeps the fanned catalog routable. */
19039
- addonId: string(),
19040
- enabled: boolean(),
19041
- /** Vendor model id, or the managed runtime's loaded model. */
19042
- model: string(),
19043
- /** Required for openai-compatible; override for cloud kinds. */
19044
- baseUrl: string().optional(),
19045
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
19046
- apiKey: string().optional(),
19047
- supportsVision: boolean(),
19048
- temperature: number().min(0).max(2).optional(),
19049
- maxTokens: number().int().positive().optional(),
19050
- timeoutMs: number().int().positive().default(6e4),
19051
- extraHeaders: record(string(), string()).optional(),
19052
- /** kind === 'managed-local' only (spec §4). */
19053
- runtime: ManagedRuntimeConfigSchema.optional()
19727
+ label: string(),
19728
+ url: string().optional()
19054
19729
  });
19055
- /** ConfigUISchema tree passed through untyped on the wire (the
19056
- * notification-output `ConfigSchemaPassthrough` precedent at
19057
- * notification-output.cap.ts:151); the exported TS type re-tightens it. */
19730
+ /**
19731
+ * The canonical notification. `body` is the only hard field (Apprise model).
19732
+ * `priority` is a 5-level ORDINAL (1=lowest 3=normal(default) 5=urgent),
19733
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
19734
+ * the adapter maps this ordinal onto its native level. `level?` is an
19735
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
19736
+ * `priority` for that one target.
19737
+ */
19738
+ var NotificationSchema = object({
19739
+ body: string(),
19740
+ title: string().optional(),
19741
+ format: NotificationFormatSchema.default("text"),
19742
+ priority: number().int().min(1).max(5).default(3),
19743
+ level: string().optional(),
19744
+ attachments: array(AttachmentSchema).optional(),
19745
+ clickUrl: string().optional(),
19746
+ actions: array(NotificationActionSchema).optional(),
19747
+ sound: string().optional(),
19748
+ ttl: number().optional(),
19749
+ tag: string().optional(),
19750
+ deviceId: number().optional(),
19751
+ eventId: string().optional(),
19752
+ metadata: record(string(), unknown()).optional()
19753
+ });
19754
+ /** One declared native severity/priority level for a kind. */
19755
+ var TargetKindLevelSchema = object({
19756
+ id: string(),
19757
+ label: string(),
19758
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
19759
+ ordinal: number().int().min(1).max(5).nullable(),
19760
+ flags: object({
19761
+ critical: boolean().optional(),
19762
+ silent: boolean().optional(),
19763
+ noPush: boolean().optional()
19764
+ }).optional(),
19765
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
19766
+ requires: array(string()).optional(),
19767
+ description: string().optional()
19768
+ });
19769
+ /** The full capability block consulted before dispatch. */
19770
+ var TargetKindCapsSchema = object({
19771
+ attachments: object({
19772
+ mediaTypes: array(AttachmentMediaTypeSchema),
19773
+ mode: _enum([
19774
+ "url",
19775
+ "bytes",
19776
+ "both"
19777
+ ]),
19778
+ max: number().int().nonnegative(),
19779
+ maxBytes: number().int().positive().optional()
19780
+ }),
19781
+ /** Max action buttons (0 = none). */
19782
+ actions: number().int().nonnegative(),
19783
+ levels: array(TargetKindLevelSchema),
19784
+ format: array(NotificationFormatSchema),
19785
+ clickUrl: boolean(),
19786
+ sound: boolean(),
19787
+ ttl: boolean(),
19788
+ bodyMaxLen: number().int().positive()
19789
+ });
19790
+ /**
19791
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
19792
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
19793
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
19794
+ * the union is large and not meant for runtime validation here; the exported
19795
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
19796
+ */
19058
19797
  var ConfigSchemaPassthrough = unknown();
19059
- var LlmProfileKindDescriptorSchema = object({
19060
- kind: LlmProfileKindSchema,
19798
+ var TargetKindSchema = object({
19799
+ kind: string(),
19061
19800
  label: string(),
19062
19801
  icon: string(),
19063
19802
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
19064
19803
  addonId: string(),
19065
- configSchema: ConfigSchemaPassthrough
19066
- });
19067
- var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
19068
- var LlmDefaultSchema = object({
19069
- selector: LlmDefaultSelectorSchema,
19070
- profileId: string()
19071
- });
19072
- /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
19073
- var LlmUsageRollupSchema = object({
19074
- day: string(),
19075
- consumer: string(),
19076
- profileId: string(),
19077
- calls: number(),
19078
- okCalls: number(),
19079
- errorCalls: number(),
19080
- inputTokens: number(),
19081
- outputTokens: number(),
19082
- avgLatencyMs: number()
19804
+ configSchema: ConfigSchemaPassthrough,
19805
+ supportsDiscovery: boolean(),
19806
+ caps: TargetKindCapsSchema
19083
19807
  });
19084
- /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
19085
- var ManagedModelCatalogEntrySchema = object({
19808
+ /**
19809
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
19810
+ * (return a presence marker only) when serving `listTargets` — never
19811
+ * round-trip a stored secret to the UI.
19812
+ */
19813
+ var TargetSchema = object({
19086
19814
  id: string(),
19087
- label: string(),
19088
- family: string(),
19089
- purpose: _enum(["text", "vision"]),
19090
- url: string(),
19091
- sha256: string(),
19092
- sizeBytes: number(),
19093
- quantization: string(),
19094
- /** Load-time guidance shown in the picker. */
19095
- minRamBytes: number(),
19096
- contextSizeDefault: number().int(),
19097
- /** Vision models: companion projector file. */
19098
- mmprojUrl: string().optional()
19099
- });
19100
- var LlmRuntimeNodeSchema = object({
19101
- nodeId: string(),
19102
- reachable: boolean(),
19103
- status: LlmRuntimeStatusSchema.optional(),
19104
- disk: LlmRuntimeDiskUsageSchema.optional(),
19105
- error: string().optional()
19106
- });
19107
- var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
19108
- var ProfileRefInputSchema = object({
19815
+ name: string(),
19816
+ kind: string(),
19109
19817
  addonId: string(),
19110
- profileId: string()
19818
+ enabled: boolean(),
19819
+ config: record(string(), unknown())
19111
19820
  });
19112
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
19113
- kind: "mutation",
19114
- auth: "admin"
19115
- }), method(ProfileRefInputSchema, _void(), {
19116
- kind: "mutation",
19117
- auth: "admin"
19118
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
19119
- kind: "mutation",
19120
- auth: "admin"
19121
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
19122
- selector: LlmDefaultSelectorSchema,
19123
- profileId: string().nullable()
19124
- }), _void(), {
19125
- kind: "mutation",
19126
- auth: "admin"
19127
- }), method(object({
19128
- since: number().optional(),
19129
- until: number().optional(),
19130
- consumer: string().optional(),
19131
- profileId: string().optional()
19132
- }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
19133
- nodeId: string(),
19134
- model: ManagedModelRefSchema
19135
- }), _void(), {
19136
- kind: "mutation",
19137
- auth: "admin"
19138
- }), method(object({
19139
- nodeId: string(),
19140
- file: string()
19141
- }), _void(), {
19142
- kind: "mutation",
19143
- auth: "admin"
19144
- }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
19145
- kind: "mutation",
19146
- auth: "admin"
19147
- }), method(ProfileRefInputSchema, _void(), {
19148
- kind: "mutation",
19149
- auth: "admin"
19821
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
19822
+ var DiscoveredTargetSchema = object({
19823
+ kind: string(),
19824
+ suggestedName: string(),
19825
+ config: record(string(), unknown())
19826
+ });
19827
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
19828
+ var RenderedAsSchema = object({
19829
+ level: string(),
19830
+ format: NotificationFormatSchema,
19831
+ attachmentsSent: number().int().nonnegative(),
19832
+ actionsSent: number().int().nonnegative(),
19833
+ truncated: boolean(),
19834
+ dropped: array(string())
19835
+ });
19836
+ var SendResultSchema = object({
19837
+ success: boolean(),
19838
+ error: string().optional(),
19839
+ renderedAs: RenderedAsSchema.optional()
19150
19840
  });
19841
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
19842
+ var TestResultSchema = SendResultSchema;
19843
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
19844
+ kind: string(),
19845
+ config: record(string(), unknown()).optional()
19846
+ }), array(DiscoveredTargetSchema)), method(object({
19847
+ targetId: string(),
19848
+ notification: NotificationSchema
19849
+ }), SendResultSchema, { kind: "mutation" }), method(object({
19850
+ targetId: string(),
19851
+ sample: NotificationSchema.optional()
19852
+ }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
19853
+ targetId: string(),
19854
+ enabled: boolean()
19855
+ }), _void(), { kind: "mutation" });
19151
19856
  /**
19152
19857
  * Zod schemas for persisted record types.
19153
19858
  *
@@ -19833,7 +20538,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19833
20538
  }), method(object({
19834
20539
  eventId: string(),
19835
20540
  kind: MediaFileKindEnum.optional()
19836
- }), array(MediaFileSchema).readonly()), method(object({ trackId: string() }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
20541
+ }), array(MediaFileSchema).readonly()), method(object({
20542
+ trackId: string(),
20543
+ kinds: array(MediaFileKindEnum).optional()
20544
+ }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
19837
20545
  deviceId: number(),
19838
20546
  timestamp: number(),
19839
20547
  frameWidth: number(),
@@ -19854,76 +20562,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19854
20562
  eventId: string(),
19855
20563
  timestamp: number()
19856
20564
  });
19857
- /**
19858
- * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
19859
- * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
19860
- * caps into per-camera event-kind descriptors.
19861
- *
19862
- * The descriptor DATA (color / iconId / labelKey / parentKind / category)
19863
- * is NOT duplicated here — every entry is derived from the single
19864
- * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
19865
- * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
19866
- * control cap means adding one line here (and a taxonomy entry); the anti-
19867
- * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
19868
- * eventful cap is missing.
19869
- */
19870
- /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
19871
- var LEGACY_ICON = {
19872
- motion: "motion",
19873
- audio: "audio",
19874
- person: "person",
19875
- vehicle: "vehicle",
19876
- animal: "animal",
19877
- package: "package",
19878
- door: "door",
19879
- pir: "pir",
19880
- smoke: "smoke",
19881
- water: "water",
19882
- button: "button",
19883
- generic: "generic",
19884
- gas: "smoke",
19885
- vibration: "generic",
19886
- tamper: "generic",
19887
- presence: "person",
19888
- lock: "generic",
19889
- siren: "generic",
19890
- switch: "generic",
19891
- doorbell: "button"
19892
- };
19893
- function legacyIcon(iconId) {
19894
- return LEGACY_ICON[iconId] ?? "generic";
19895
- }
19896
- /**
19897
- * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
19898
- * The anti-drift guard cross-checks this against the eventful caps declared
19899
- * in `packages/types/src/capabilities/*.cap.ts`.
19900
- */
19901
- var CAP_TO_KIND = {
19902
- contact: "contact",
19903
- motion: "motion-sensor",
19904
- smoke: "smoke",
19905
- flood: "flood",
19906
- gas: "gas",
19907
- "carbon-monoxide": "carbon-monoxide",
19908
- vibration: "vibration",
19909
- tamper: "tamper",
19910
- presence: "presence",
19911
- "enum-sensor": "enum-sensor",
19912
- "event-emitter": "device-event",
19913
- "lock-control": "lock",
19914
- switch: "switch",
19915
- button: "button",
19916
- doorbell: "doorbell"
19917
- };
19918
- function buildDescriptor(capName, kind) {
19919
- const t = EVENT_TAXONOMY[kind];
19920
- if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
19921
- return {
19922
- ...t,
19923
- icon: legacyIcon(t.iconId)
19924
- };
19925
- }
19926
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
19927
20565
  var CameraPipelineConfigSchema = object({
19928
20566
  engine: PipelineEngineChoiceSchema.optional(),
19929
20567
  steps: array(PipelineStepInputSchema).readonly(),
@@ -20409,6 +21047,76 @@ method(object({
20409
21047
  auth: "admin"
20410
21048
  });
20411
21049
  /**
21050
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
21051
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
21052
+ * caps into per-camera event-kind descriptors.
21053
+ *
21054
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
21055
+ * is NOT duplicated here — every entry is derived from the single
21056
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
21057
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
21058
+ * control cap means adding one line here (and a taxonomy entry); the anti-
21059
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
21060
+ * eventful cap is missing.
21061
+ */
21062
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
21063
+ var LEGACY_ICON = {
21064
+ motion: "motion",
21065
+ audio: "audio",
21066
+ person: "person",
21067
+ vehicle: "vehicle",
21068
+ animal: "animal",
21069
+ package: "package",
21070
+ door: "door",
21071
+ pir: "pir",
21072
+ smoke: "smoke",
21073
+ water: "water",
21074
+ button: "button",
21075
+ generic: "generic",
21076
+ gas: "smoke",
21077
+ vibration: "generic",
21078
+ tamper: "generic",
21079
+ presence: "person",
21080
+ lock: "generic",
21081
+ siren: "generic",
21082
+ switch: "generic",
21083
+ doorbell: "button"
21084
+ };
21085
+ function legacyIcon(iconId) {
21086
+ return LEGACY_ICON[iconId] ?? "generic";
21087
+ }
21088
+ /**
21089
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
21090
+ * The anti-drift guard cross-checks this against the eventful caps declared
21091
+ * in `packages/types/src/capabilities/*.cap.ts`.
21092
+ */
21093
+ var CAP_TO_KIND = {
21094
+ contact: "contact",
21095
+ motion: "motion-sensor",
21096
+ smoke: "smoke",
21097
+ flood: "flood",
21098
+ gas: "gas",
21099
+ "carbon-monoxide": "carbon-monoxide",
21100
+ vibration: "vibration",
21101
+ tamper: "tamper",
21102
+ presence: "presence",
21103
+ "enum-sensor": "enum-sensor",
21104
+ "event-emitter": "device-event",
21105
+ "lock-control": "lock",
21106
+ switch: "switch",
21107
+ button: "button",
21108
+ doorbell: "doorbell"
21109
+ };
21110
+ function buildDescriptor(capName, kind) {
21111
+ const t = EVENT_TAXONOMY[kind];
21112
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
21113
+ return {
21114
+ ...t,
21115
+ icon: legacyIcon(t.iconId)
21116
+ };
21117
+ }
21118
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
21119
+ /**
20412
21120
  * server-management — per-NODE singleton capability for a node's ROOT
20413
21121
  * package lifecycle (runtime-updatable node packages).
20414
21122
  *
@@ -21914,7 +22622,28 @@ var FaceInfoSchema = object({
21914
22622
  * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`). Absent when the
21915
22623
  * track produced no key frame (e.g. native/onboard source) — the UI falls
21916
22624
  * back to the inline `base64` face crop. */
21917
- keyFrameMediaKey: string().optional()
22625
+ keyFrameMediaKey: string().optional(),
22626
+ /** Winning identity-match cosine (0..1) for this face's track, when an
22627
+ * identity was auto-confirmed. Lets the UI surface WHY a face was assigned
22628
+ * (confidence badge / low-confidence audit). Absent on legacy rows and on
22629
+ * faces that were never auto-recognized. */
22630
+ bestMatchScore: number().optional(),
22631
+ /** Native-scale face short side (px) at recognition time, when the runner
22632
+ * measured it. Lets the UI flag low-resolution auto-assignments. Absent on
22633
+ * legacy rows / runners that reported no native measure. */
22634
+ nativeFaceShortSidePx: number().optional(),
22635
+ /** SUGGESTED identity for this face — a plausible-but-not-confident match that
22636
+ * MISSED auto-assignment (cosine in the suggestion band, or above threshold
22637
+ * but blocked only by the recognition size floor). Mutually exclusive with
22638
+ * `recognizedIdentityId` (a suggestion is NEVER an assignment): the face stays
22639
+ * UNASSIGNED and everything else keeps treating it as unrecognized — the UI
22640
+ * merely offers a one-tap "is this <name>?" confirm. Absent on legacy rows and
22641
+ * on faces that were auto-assigned or below the suggestion band. (2026-07-24) */
22642
+ suggestedIdentityId: string().optional(),
22643
+ /** Peak identity-match cosine (0..1) for `suggestedIdentityId`, captured at the
22644
+ * same moment as `bestMatchScore` (track peak, at close). Lets the UI rank /
22645
+ * badge suggestion confidence. Present iff `suggestedIdentityId` is. (2026-07-24) */
22646
+ suggestedMatchScore: number().optional()
21918
22647
  });
21919
22648
  var FaceFilterEnum = _enum([
21920
22649
  "unassigned",
@@ -23970,36 +24699,6 @@ Object.freeze({
23970
24699
  addonId: null,
23971
24700
  access: "view"
23972
24701
  },
23973
- "advancedNotifier.deleteRule": {
23974
- capName: "advanced-notifier",
23975
- capScope: "system",
23976
- addonId: null,
23977
- access: "delete"
23978
- },
23979
- "advancedNotifier.getHistory": {
23980
- capName: "advanced-notifier",
23981
- capScope: "system",
23982
- addonId: null,
23983
- access: "view"
23984
- },
23985
- "advancedNotifier.getRules": {
23986
- capName: "advanced-notifier",
23987
- capScope: "system",
23988
- addonId: null,
23989
- access: "view"
23990
- },
23991
- "advancedNotifier.testRule": {
23992
- capName: "advanced-notifier",
23993
- capScope: "system",
23994
- addonId: null,
23995
- access: "create"
23996
- },
23997
- "advancedNotifier.upsertRule": {
23998
- capName: "advanced-notifier",
23999
- capScope: "system",
24000
- addonId: null,
24001
- access: "create"
24002
- },
24003
24702
  "alarmPanel.arm": {
24004
24703
  capName: "alarm-panel",
24005
24704
  capScope: "device",
@@ -24222,6 +24921,12 @@ Object.freeze({
24222
24921
  addonId: null,
24223
24922
  access: "delete"
24224
24923
  },
24924
+ "backup.deleteSchedule": {
24925
+ capName: "backup",
24926
+ capScope: "system",
24927
+ addonId: null,
24928
+ access: "delete"
24929
+ },
24225
24930
  "backup.getEntries": {
24226
24931
  capName: "backup",
24227
24932
  capScope: "system",
@@ -24252,6 +24957,12 @@ Object.freeze({
24252
24957
  addonId: null,
24253
24958
  access: "view"
24254
24959
  },
24960
+ "backup.listSchedules": {
24961
+ capName: "backup",
24962
+ capScope: "system",
24963
+ addonId: null,
24964
+ access: "view"
24965
+ },
24255
24966
  "backup.previewSchedule": {
24256
24967
  capName: "backup",
24257
24968
  capScope: "system",
@@ -24276,6 +24987,12 @@ Object.freeze({
24276
24987
  addonId: null,
24277
24988
  access: "create"
24278
24989
  },
24990
+ "backup.upsertSchedule": {
24991
+ capName: "backup",
24992
+ capScope: "system",
24993
+ addonId: null,
24994
+ access: "create"
24995
+ },
24279
24996
  "battery.wakeForStream": {
24280
24997
  capName: "battery",
24281
24998
  capScope: "device",
@@ -26304,6 +27021,60 @@ Object.freeze({
26304
27021
  addonId: null,
26305
27022
  access: "create"
26306
27023
  },
27024
+ "notificationRules.createRule": {
27025
+ capName: "notification-rules",
27026
+ capScope: "system",
27027
+ addonId: null,
27028
+ access: "create"
27029
+ },
27030
+ "notificationRules.deleteRule": {
27031
+ capName: "notification-rules",
27032
+ capScope: "system",
27033
+ addonId: null,
27034
+ access: "delete"
27035
+ },
27036
+ "notificationRules.getConditionCatalog": {
27037
+ capName: "notification-rules",
27038
+ capScope: "system",
27039
+ addonId: null,
27040
+ access: "view"
27041
+ },
27042
+ "notificationRules.getHistory": {
27043
+ capName: "notification-rules",
27044
+ capScope: "system",
27045
+ addonId: null,
27046
+ access: "view"
27047
+ },
27048
+ "notificationRules.getRule": {
27049
+ capName: "notification-rules",
27050
+ capScope: "system",
27051
+ addonId: null,
27052
+ access: "view"
27053
+ },
27054
+ "notificationRules.listRules": {
27055
+ capName: "notification-rules",
27056
+ capScope: "system",
27057
+ addonId: null,
27058
+ access: "view"
27059
+ },
27060
+ "notificationRules.setRuleEnabled": {
27061
+ capName: "notification-rules",
27062
+ capScope: "system",
27063
+ addonId: null,
27064
+ access: "create"
27065
+ },
27066
+ "notificationRules.testRule": {
27067
+ capName: "notification-rules",
27068
+ capScope: "system",
27069
+ addonId: null,
27070
+ access: "create"
27071
+ },
27072
+ "notificationRules.updateRule": {
27073
+ capName: "notification-rules",
27074
+ capScope: "system",
27075
+ addonId: null,
27076
+ access: "create"
27077
+ },
26307
27078
  "notifier.cancel": {
26308
27079
  capName: "notifier",
26309
27080
  capScope: "device",
@@ -28056,6 +28827,36 @@ Object.freeze({
28056
28827
  addonId: null,
28057
28828
  access: "create"
28058
28829
  },
28830
+ "terminalSession.close": {
28831
+ capName: "terminal-session",
28832
+ capScope: "system",
28833
+ addonId: null,
28834
+ access: "create"
28835
+ },
28836
+ "terminalSession.listProfiles": {
28837
+ capName: "terminal-session",
28838
+ capScope: "system",
28839
+ addonId: null,
28840
+ access: "view"
28841
+ },
28842
+ "terminalSession.listSessions": {
28843
+ capName: "terminal-session",
28844
+ capScope: "system",
28845
+ addonId: null,
28846
+ access: "view"
28847
+ },
28848
+ "terminalSession.openSession": {
28849
+ capName: "terminal-session",
28850
+ capScope: "system",
28851
+ addonId: null,
28852
+ access: "create"
28853
+ },
28854
+ "terminalSession.resize": {
28855
+ capName: "terminal-session",
28856
+ capScope: "system",
28857
+ addonId: null,
28858
+ access: "create"
28859
+ },
28059
28860
  "toast.onToast": {
28060
28861
  capName: "toast",
28061
28862
  capScope: "system",