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