@camstack/addon-provider-dreo 0.2.4 → 0.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
@@ -36,7 +36,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
36
36
  var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
37
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
38
38
  //#endregion
39
- //#region ../types/dist/event-category-D4HJq7Mw.mjs
39
+ //#region ../types/dist/event-category-BLcNejAE.mjs
40
40
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
41
41
  EventCategory["SystemBoot"] = "system.boot";
42
42
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -186,9 +186,6 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
186
186
  EventCategory["RecordingSegmentWritten"] = "recording.segment.written";
187
187
  EventCategory["RecordingPolicyFallback"] = "recording.policy.fallback";
188
188
  EventCategory["RecordingRetentionCompleted"] = "recording.retention.completed";
189
- /** Runner-sampled scrub thumbnail (~1/5 s/camera). Telemetry (D8): a lost
190
- * thumb is a scrub gap the recorder's keyframe backfill covers. */
191
- EventCategory["RecordingThumbSampled"] = "recording.thumb-sampled";
192
189
  /** Export render progress (0–100). Telemetry (D8): a lost tick is a stale
193
190
  * progress bar the client reconciles via `recordingExport.getExport`. */
194
191
  EventCategory["RecordingExportProgress"] = "recording.export.progress";
@@ -6853,7 +6850,6 @@ object({ deviceId: number() }), object({ deviceId: number() }), object({
6853
6850
  patch: record(string(), unknown())
6854
6851
  }), object({ success: literal(true) });
6855
6852
  object({ deviceId: number() }), unknown().nullable();
6856
- /** Shorthand to define a method schema */
6857
6853
  function method(input, output, options) {
6858
6854
  return {
6859
6855
  input,
@@ -6861,6 +6857,7 @@ function method(input, output, options) {
6861
6857
  kind: options?.kind ?? "query",
6862
6858
  auth: options?.auth ?? "protected",
6863
6859
  ...options?.access !== void 0 ? { access: options.access } : {},
6860
+ ...options?.caller !== void 0 ? { caller: options.caller } : {},
6864
6861
  timeoutMs: options?.timeoutMs
6865
6862
  };
6866
6863
  }
@@ -7558,16 +7555,23 @@ var StorageLocationDeclarationSchema = object({
7558
7555
  * Which node root the seeded `<id>:default` instance is placed under on a
7559
7556
  * FRESH install:
7560
7557
  * - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
7561
- * the appData volume. Right for small/durable data (backups, logs, models).
7558
+ * the appData volume. Right for small/durable data (logs, models).
7562
7559
  * - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
7563
7560
  * env is set, else falls back to the data root. Right for bulky, hot media
7564
7561
  * (recordings, event media) that should stay off the appData disk.
7562
+ * - `'backup'` — the dedicated backup volume (`CAMSTACK_BACKUP_ROOT`, default
7563
+ * `/backups` in the image) so archives live on their own mount rather than
7564
+ * filling the appData disk. Falls back to the data root when unset.
7565
7565
  *
7566
7566
  * Only affects the seeded default's `basePath`; operators can repoint any
7567
7567
  * location afterwards, and a `defaultsTo` slot inherits its parent's root
7568
7568
  * regardless of this field. Absent (the common case) is treated as `'data'`.
7569
7569
  */
7570
- defaultRoot: _enum(["data", "media"]).optional()
7570
+ defaultRoot: _enum([
7571
+ "data",
7572
+ "media",
7573
+ "backup"
7574
+ ]).optional()
7571
7575
  });
7572
7576
  var DecoderStatsSchema = object({
7573
7577
  inputFps: number(),
@@ -8230,6 +8234,59 @@ for (const l of AUDIO_MACRO_LABELS) {
8230
8234
  /** The complete taxonomy dictionary, keyed by kind. */
8231
8235
  var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
8232
8236
  /**
8237
+ * Notification-Center taxonomy — the fixed vocabulary the NC rule editor
8238
+ * offers as pickers instead of free text. Derived (never hand-listed) from the
8239
+ * single `EVENT_TAXONOMY` dictionary so it stays in lockstep with every other
8240
+ * taxonomy surface (timeline, filters, event page).
8241
+ *
8242
+ * Three buckets, mapped onto the rule editor's `stringList` conditions:
8243
+ * - `videoClasses` → detection classes (person / vehicle / animal + subs)
8244
+ * for the `classes` / `classesExclude` conditions.
8245
+ * - `audioKinds` → audio-analyzer sub kinds (`audio-scream`, …) shown in
8246
+ * the same class picker, grouped under an Audio header.
8247
+ * - `labels` → sensor + control taxonomy kinds (doorbell / contact /
8248
+ * lock / …) for the `sensorKinds` device-event condition.
8249
+ *
8250
+ * Each entry carries `parentKind` so the client can group video subs under
8251
+ * their macro and sensor/control kinds under their category. This surface is
8252
+ * served ADDITIVELY on the `nc.getConditionCatalog` bridge response — no cap
8253
+ * method, no codegen — so it ships train-free with an addon deploy.
8254
+ */
8255
+ /** One selectable taxonomy value: a stable kind id + display label + parent. */
8256
+ var NcTaxonomyEntrySchema = object({
8257
+ /** Stable kind id (e.g. 'person', 'car', 'audio-scream', 'doorbell'). */
8258
+ kind: string(),
8259
+ /** English fallback label (the UI translates via the event-kind i18n key). */
8260
+ label: string(),
8261
+ /** Macro/category parent for grouping ('car' → 'vehicle'); null for a top. */
8262
+ parentKind: string().nullable()
8263
+ });
8264
+ object({
8265
+ videoClasses: array(NcTaxonomyEntrySchema),
8266
+ audioKinds: array(NcTaxonomyEntrySchema),
8267
+ labels: array(NcTaxonomyEntrySchema)
8268
+ });
8269
+ function toEntry(kind, label, parentKind) {
8270
+ return {
8271
+ kind,
8272
+ label,
8273
+ parentKind
8274
+ };
8275
+ }
8276
+ /**
8277
+ * Build the NC taxonomy from `EVENT_TAXONOMY`. Insertion order is preserved
8278
+ * (macros before their subs), which the client relies on for stable grouping.
8279
+ */
8280
+ function buildNcTaxonomy() {
8281
+ const all = Object.values(EVENT_TAXONOMY);
8282
+ return {
8283
+ videoClasses: all.filter((e) => e.category === "detection").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8284
+ audioKinds: all.filter((e) => e.category === "audio" && e.level === "sub").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8285
+ labels: all.filter((e) => e.category === "sensor" || e.category === "control").map((e) => toEntry(e.kind, e.label, e.parentKind))
8286
+ };
8287
+ }
8288
+ Object.freeze(buildNcTaxonomy());
8289
+ /**
8233
8290
  * Error types for the safe expression engine. Two distinct classes so callers
8234
8291
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
8235
8292
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -9108,6 +9165,644 @@ function shallowEqual(a, b) {
9108
9165
  return true;
9109
9166
  }
9110
9167
  /**
9168
+ * Shared geometry vocabulary for on-frame shape caps — privacy-mask,
9169
+ * motion-zones, and the detection zones/lines editor all speak this one
9170
+ * language so a single drawing-plane editor and the providers stay
9171
+ * decoupled from each cap's storage.
9172
+ *
9173
+ * All coordinates are normalized 0..1 of the camera frame (top-left
9174
+ * origin). Each cap composes the SUBSET of shape kinds it supports and
9175
+ * advertises it via `supportedShapes` in its `getOptions`.
9176
+ */
9177
+ /** A normalized 0..1 point (top-left origin). */
9178
+ var MaskPointSchema = object({
9179
+ x: number(),
9180
+ y: number()
9181
+ });
9182
+ /** Axis-aligned rectangle (normalized 0..1). */
9183
+ var MaskRectShapeSchema = object({
9184
+ kind: literal("rect"),
9185
+ x: number(),
9186
+ y: number(),
9187
+ width: number(),
9188
+ height: number()
9189
+ });
9190
+ /** Free polygon — an ordered list of normalized vertices (≥3). */
9191
+ var MaskPolygonShapeSchema = object({
9192
+ kind: literal("polygon"),
9193
+ points: array(MaskPointSchema)
9194
+ });
9195
+ /** Boolean cell grid — row-major, length === gridWidth*gridHeight. */
9196
+ var MaskGridShapeSchema = object({
9197
+ kind: literal("grid"),
9198
+ gridWidth: number(),
9199
+ gridHeight: number(),
9200
+ cells: array(boolean())
9201
+ });
9202
+ discriminatedUnion("kind", [
9203
+ MaskRectShapeSchema,
9204
+ MaskPolygonShapeSchema,
9205
+ MaskGridShapeSchema,
9206
+ object({
9207
+ kind: literal("line"),
9208
+ points: array(MaskPointSchema)
9209
+ })
9210
+ ]);
9211
+ /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
9212
+ var MaskShapeKindSchema = _enum([
9213
+ "rect",
9214
+ "polygon",
9215
+ "grid",
9216
+ "line"
9217
+ ]);
9218
+ /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
9219
+ var MaskPolygonVerticesSchema = object({
9220
+ min: number(),
9221
+ max: number()
9222
+ });
9223
+ /** Grid dimensions when a cap supports 'grid'. */
9224
+ var MaskGridDimsSchema = object({
9225
+ width: number(),
9226
+ height: number()
9227
+ });
9228
+ /**
9229
+ * notification-rules — the Notification Center rule surface (P1 core).
9230
+ *
9231
+ * Spec: `docs/superpowers/specs/2026-07-22-notification-center-requirements.md`
9232
+ * (operator decisions D-1/D-2/D-3 are binding):
9233
+ *
9234
+ * - D-2: rule EVALUATION lives in `addon-post-analysis` (the
9235
+ * `notification-center` module), hooked on the durable persistence
9236
+ * moments (object-event insert, TrackCloser.closeExpired) with a
9237
+ * persisted outbox + retry — never the lossy telemetry bus (D8).
9238
+ * - D-3: urgency belongs to the RULE. `delivery: 'immediate'` fires on the
9239
+ * FIRST persisted detection matching the conditions (per-track dedup,
9240
+ * `maxPerTrack` fixed at 1 — see {@link NC_MAX_PER_TRACK_IMMEDIATE});
9241
+ * `delivery: 'track-end'` evaluates the finalized track record at close.
9242
+ * - DISPATCH stays behind `notification-output` (rules reference targets
9243
+ * by id; per-backend params are a passthrough blob capped by the
9244
+ * target kind's own caps/degrade engine).
9245
+ *
9246
+ * P1 scope: admin-authored rules only (`createdBy` stamped from the
9247
+ * server-injected caller identity — the first `caller: 'required'`
9248
+ * adopter). The P1 condition subset is: devices, classes(+exclude),
9249
+ * minConfidence, admin zones (any/all + exclude), weekly schedule
9250
+ * windows, and the optional label/identity/plate matchers. User rules,
9251
+ * private zones, per-recipient fan-out and the wider condition table are
9252
+ * P2+ (see spec §7).
9253
+ *
9254
+ * All schemas here are the single source of truth — `NcRule` etc. are
9255
+ * `z.infer` exports; no duplicate interfaces (the advanced-notifier
9256
+ * schema/interface drift is explicitly not repeated).
9257
+ */
9258
+ /**
9259
+ * D-3: the trigger/urgency of a rule — which persistence moment evaluates it.
9260
+ * The value maps 1:1 onto the evaluated record kind:
9261
+ * - `immediate` ↔ object-event persist (lowest-latency detection burst)
9262
+ * - `track-end` ↔ TrackCloser.closeExpired (finalized track record)
9263
+ * - `device-event` ↔ SensorEventStore insert (doorbell press / sensor state
9264
+ * change of a LINKED device, one row per linked camera)
9265
+ * - `package-event` ↔ PackageDropDetector object-event insert (a `package`
9266
+ * delivery / pick-up)
9267
+ *
9268
+ * `immediate`/`track-end` carry the D-3 urgency semantics; `device-event`/
9269
+ * `package-event` are pure trigger kinds (no urgency dimension). Extending
9270
+ * this one field keeps the schema additive — a rule still declares exactly
9271
+ * one trigger.
9272
+ */
9273
+ var NcDeliverySchema = _enum([
9274
+ "immediate",
9275
+ "track-end",
9276
+ "device-event",
9277
+ "package-event"
9278
+ ]);
9279
+ /** Weekly schedule — OR of windows; absence on the rule = always active. */
9280
+ var NcScheduleSchema = object({
9281
+ windows: array(object({
9282
+ /** Days of week the window STARTS on (0 = Sunday … 6 = Saturday). */
9283
+ days: array(number().int().min(0).max(6)).min(1),
9284
+ startMinute: number().int().min(0).max(1439),
9285
+ endMinute: number().int().min(0).max(1439)
9286
+ })).min(1),
9287
+ /** IANA timezone; default = hub host timezone. */
9288
+ timezone: string().optional(),
9289
+ /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
9290
+ invert: boolean().optional()
9291
+ });
9292
+ /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
9293
+ var NcPlateMatcherSchema = object({
9294
+ values: array(string().min(1)).min(1),
9295
+ /** Max Levenshtein distance after normalization (uppercase alphanumeric). */
9296
+ maxDistance: number().int().min(0).max(3).default(1)
9297
+ });
9298
+ /**
9299
+ * Occupancy condition (DEVICE-EVENT trigger). Fires on a ZoneAnalytics
9300
+ * occupancy edge for a device — optionally narrowed to a single admin
9301
+ * `zoneId` and/or object `className`. `op` selects the edge/threshold:
9302
+ * - `became-occupied` (default) — count crossed 0 → ≥ `count`
9303
+ * - `became-free` — count crossed ≥ `count` → below it
9304
+ * - `>=` / `<=` — count is at/over or at/under `count`
9305
+ * `sustainSeconds` requires the condition hold continuously that long
9306
+ * before firing (debounces flicker; 0 = fire on the first matching edge).
9307
+ * Fail-closed: no ZoneAnalytics snapshot / missing zone / null snapshot ⇒
9308
+ * the condition never matches. Confirmed edge-state survives addon restarts
9309
+ * (declared SQLite collection, reseeded on boot).
9310
+ */
9311
+ var NcOccupancyConditionSchema = object({
9312
+ /** Admin zone id to scope the count to; absent = whole-frame occupancy. */
9313
+ zoneId: string().optional(),
9314
+ /** Object class to count; absent = any class. */
9315
+ className: string().optional(),
9316
+ op: _enum([
9317
+ "became-occupied",
9318
+ "became-free",
9319
+ ">=",
9320
+ "<="
9321
+ ]).default("became-occupied"),
9322
+ count: number().int().min(0).default(1),
9323
+ sustainSeconds: number().int().min(0).max(3600).default(15)
9324
+ });
9325
+ /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
9326
+ var NcZoneConditionSchema = object({
9327
+ ids: array(string().min(1)).min(1),
9328
+ /** Quantifier over `ids` — at least one / every one visited. */
9329
+ match: _enum(["any", "all"]).default("any")
9330
+ });
9331
+ /**
9332
+ * The P1 condition set — a flat AND of groups; absent group = pass;
9333
+ * membership lists are OR within the list (spec §2.3).
9334
+ */
9335
+ var NcConditionsSchema = object({
9336
+ /** Device scope — absent = all devices. */
9337
+ devices: array(number()).optional(),
9338
+ /** Detector class names (any overlap with the record's class set). */
9339
+ classes: array(string().min(1)).optional(),
9340
+ /** Veto classes — any overlap fails the rule. */
9341
+ classesExclude: array(string().min(1)).optional(),
9342
+ /** Minimum detection confidence 0–1 (fails when the record has none). */
9343
+ minConfidence: number().min(0).max(1).optional(),
9344
+ /** Admin zone membership over event `zones` / track `zonesVisited`. */
9345
+ zones: NcZoneConditionSchema.optional(),
9346
+ /** Veto zones — any hit fails the rule. */
9347
+ zonesExclude: array(string().min(1)).optional(),
9348
+ /**
9349
+ * Exact (case-insensitive) match on the record's collapsed `label`
9350
+ * (identity name / plate text / subclass).
9351
+ */
9352
+ labelEquals: array(string().min(1)).optional(),
9353
+ /**
9354
+ * Identity matcher. P1 boundary: matched against the record's collapsed
9355
+ * `label` (the identity display name propagated by the face pipeline) —
9356
+ * identity-ID matching rides in P2 when identity ids reach the record.
9357
+ */
9358
+ identities: array(string().min(1)).optional(),
9359
+ /** Fuzzy plate matcher against the record's `label` (plate text). */
9360
+ plates: NcPlateMatcherSchema.optional(),
9361
+ /**
9362
+ * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
9363
+ * Same P1 boundary: matched against the record's collapsed `label` (the
9364
+ * identity display name). A record with NO label passes (nothing to
9365
+ * exclude), unlike the include variant which fails on an absent label.
9366
+ */
9367
+ identitiesExclude: array(string().min(1)).optional(),
9368
+ /**
9369
+ * Minimum server-computed key-event importance in [0,1] (`Track.importance`).
9370
+ * TRACK-END only: importance is scored at track close, so it does not exist
9371
+ * at immediate / object-event evaluation time (see catalog `appliesTo`). At
9372
+ * close the value is threaded via the close-time info (the `Track` clone is
9373
+ * captured before the DB row is updated, so it would otherwise read stale).
9374
+ * Fails when the record carries no importance (never guess quality — the
9375
+ * `minConfidence` precedent). MVP cut: a single scalar threshold.
9376
+ */
9377
+ minImportance: number().min(0).max(1).optional(),
9378
+ /**
9379
+ * Minimum track dwell in SECONDS — `(lastSeen − firstSeen) / 1000`.
9380
+ * TRACK-END only: an `immediate` / object-event subject has no closed
9381
+ * lifespan, so a dwell condition never matches immediate delivery
9382
+ * (documented choice — the object-event record carries no `firstSeen`,
9383
+ * so dwell cannot be computed from what the subject actually carries).
9384
+ */
9385
+ minDwellSeconds: number().min(0).optional(),
9386
+ /**
9387
+ * Detection provenance filter. `any` (default / absent) matches every
9388
+ * source; otherwise the subject's source must equal it. Legacy records
9389
+ * with no stamped source are treated as `pipeline`. The union spans both
9390
+ * record kinds — object events carry `pipeline` | `onboard`, synthetic
9391
+ * tracks carry `sensor`.
9392
+ */
9393
+ source: _enum([
9394
+ "pipeline",
9395
+ "onboard",
9396
+ "sensor",
9397
+ "any"
9398
+ ]).optional(),
9399
+ /**
9400
+ * Minimum identity / plate MATCH confidence in [0,1] — DISTINCT from the
9401
+ * detector `minConfidence` (that gates the object-detection score; this
9402
+ * gates the recognition/OCR match score). Fails when the subject carries
9403
+ * no label-match confidence (never guess). TRACK-END only: the confidence
9404
+ * lives on the recognition result and reaches the subject at track close.
9405
+ *
9406
+ * What it measures precisely (plumbed at track close — the closer threads
9407
+ * the value into `NcTrackClosedInfo.labelConfidence`, the same seam as
9408
+ * `importance`): the BEST recognition match confidence observed for the
9409
+ * label the track carries at close — for a face, the peak cosine similarity
9410
+ * of the ASSIGNED identity (`FaceMatch.score`, reset on an identity switch);
9411
+ * for a plate, the peak OCR read score of the best-held plate
9412
+ * (`plateText.confidence`). When BOTH a face and a plate were recognized on
9413
+ * one track the higher of the two is used. A track that ended with no
9414
+ * confident identity/plate match carries no value, so the condition fails
9415
+ * closed for it (an un-recognized subject).
9416
+ */
9417
+ minLabelConfidence: number().min(0).max(1).optional(),
9418
+ /**
9419
+ * DEVICE-EVENT only. Raw device event-type tokens (`EventFire.eventType`,
9420
+ * e.g. a doorbell `press` / `press_long`) — matched case-insensitively
9421
+ * against the token carried on the device-event subject (extracted from the
9422
+ * event-emitter runtime slice's `lastEvent.eventType`). Fails when the
9423
+ * subject carries no token. Doorbell-pulse / passive-sensor kinds emit no
9424
+ * eventType, so gate those with {@link sensorKinds} instead.
9425
+ */
9426
+ eventTypeTokens: array(string().min(1)).optional(),
9427
+ /**
9428
+ * DEVICE-EVENT only. Sensor/control taxonomy kinds (e.g. `doorbell`,
9429
+ * `contact`, `button`, `device-event`) — matched against the persisted
9430
+ * `SensorEvent.kind` (see `sensor-event-kinds.ts`). Membership is OR.
9431
+ */
9432
+ sensorKinds: array(string().min(1)).optional(),
9433
+ /**
9434
+ * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
9435
+ * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
9436
+ * when the subject's phase does not match (a subject always carries a phase
9437
+ * on the package-event trigger).
9438
+ */
9439
+ packagePhase: _enum([
9440
+ "delivered",
9441
+ "picked-up",
9442
+ "both"
9443
+ ]).optional(),
9444
+ /**
9445
+ * PERSONAL-RULE custom zones (viewer-drawn). Inline normalized polygons
9446
+ * (MaskShape vocabulary). A record passes when its bbox overlaps ANY
9447
+ * listed polygon (ZoneEngine membership semantics). Evaluated only when
9448
+ * the subject carries a bbox; absent bbox ⇒ the condition FAILS.
9449
+ */
9450
+ customZones: array(MaskPolygonShapeSchema).optional(),
9451
+ /**
9452
+ * DEVICE-EVENT only. ZoneAnalytics occupancy edge — fires when a device's
9453
+ * (optionally zone/class-scoped) occupancy count crosses the configured
9454
+ * threshold and holds for `sustainSeconds`. Fail-closed on missing
9455
+ * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
9456
+ */
9457
+ occupancy: NcOccupancyConditionSchema.optional()
9458
+ });
9459
+ /** One delivery target: a `notification-output` Target ref + passthrough params. */
9460
+ var NcRuleTargetSchema = object({
9461
+ /** `notification-output` Target id. */
9462
+ targetId: string().min(1),
9463
+ /**
9464
+ * Per-backend passthrough. Recognized keys are mapped onto the canonical
9465
+ * Notification (`priority`, `level`, `sound`, `clickUrl`, `ttl`); the
9466
+ * degrade engine drops what the backend can't render.
9467
+ */
9468
+ params: record(string(), unknown()).optional()
9469
+ });
9470
+ /**
9471
+ * Media attachment policy (P1 still-image subset).
9472
+ * - `best` — the best AVAILABLE subject image at dispatch time (D-3).
9473
+ * - `best-matching` — the media that explains WHY the rule fired: a rule
9474
+ * matched on identities attaches the subject's `faceCrop`, one matched on
9475
+ * plates attaches the `plateCrop`; a rule with no identity/plate condition
9476
+ * (or when the specific crop is missing) degrades to `best`, then
9477
+ * `keyFrame`, then no attachment — never delaying the send. The matched
9478
+ * condition summary is frozen on the outbox row at enqueue (like the rule
9479
+ * name), so the choice never drifts from the record that fired it.
9480
+ * - `keyFrame` — the clean scene frame (no subject box).
9481
+ * - `none` — no attachment.
9482
+ */
9483
+ var NcMediaPolicySchema = object({ attach: _enum([
9484
+ "best",
9485
+ "best-matching",
9486
+ "keyFrame",
9487
+ "none"
9488
+ ]).default("best") });
9489
+ /** Throttle — cooldown survives restarts (rebuilt from the outbox on boot). */
9490
+ var NcThrottleSchema = object({
9491
+ cooldownSec: number().int().min(0).max(86400).default(60),
9492
+ /** `rule` = one shared cooldown; `rule-device` = per-camera cooldown. */
9493
+ scope: _enum(["rule", "rule-device"]).default("rule-device")
9494
+ });
9495
+ /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
9496
+ var NcRuleInputSchema = object({
9497
+ name: string().min(1).max(200),
9498
+ enabled: boolean().default(true),
9499
+ delivery: NcDeliverySchema,
9500
+ conditions: NcConditionsSchema.default({}),
9501
+ schedule: NcScheduleSchema.optional(),
9502
+ targets: array(NcRuleTargetSchema).min(1),
9503
+ media: NcMediaPolicySchema.default({ attach: "best" }),
9504
+ throttle: NcThrottleSchema.default({
9505
+ cooldownSec: 60,
9506
+ scope: "rule-device"
9507
+ }),
9508
+ /** `{{var}}` templating over camera/class/label/zones/confidence/time. */
9509
+ template: object({
9510
+ title: string().max(500).optional(),
9511
+ body: string().max(2e3).optional()
9512
+ }).optional(),
9513
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
9514
+ priority: number().int().min(1).max(5).default(3),
9515
+ /**
9516
+ * Ownership/visibility key. Absent = admin/global rule (unchanged legacy
9517
+ * behaviour, visible to all, read-only in the viewer). Present = personal
9518
+ * rule owned by this userId. Server-stamped; never trusted from a client.
9519
+ */
9520
+ ownerUserId: string().optional()
9521
+ });
9522
+ /**
9523
+ * Partial patch for `updateRule` — any subset of the input fields, plus the
9524
+ * persisted-only {@link NcRuleSchema} `disabledTargetIds` set. The latter is
9525
+ * NOT a client-authored input field (it lives on the persisted rule, not the
9526
+ * input), so it is added here explicitly to let the store's per-target opt-out
9527
+ * toggle round-trip through the shared `update` path. Viewer opt-out mutations
9528
+ * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
9529
+ * `updateRule` patch.
9530
+ */
9531
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
9532
+ /** A persisted rule. */
9533
+ var NcRuleSchema = NcRuleInputSchema.extend({
9534
+ id: string(),
9535
+ /** userId of the admin who created the rule (server-stamped caller). */
9536
+ createdBy: string(),
9537
+ createdAt: number(),
9538
+ updatedAt: number(),
9539
+ /**
9540
+ * Per-target opt-out set. A targetId here is suppressed for THIS rule at
9541
+ * send time. Only a target's OWNER may add/remove its id (server-checked
9542
+ * in `nc.setRuleTargetEnabled`). Defaults to empty.
9543
+ */
9544
+ disabledTargetIds: array(string()).default([])
9545
+ });
9546
+ var NcTestResultSchema = object({
9547
+ recordId: string(),
9548
+ recordKind: _enum([
9549
+ "object-event",
9550
+ "track",
9551
+ "device-event",
9552
+ "package-event"
9553
+ ]),
9554
+ deviceId: number(),
9555
+ timestamp: number(),
9556
+ wouldFire: boolean(),
9557
+ /** Condition id that failed (first failing group), when `wouldFire` is false. */
9558
+ failedCondition: string().optional(),
9559
+ className: string().optional(),
9560
+ label: string().optional()
9561
+ });
9562
+ var NcConditionDescriptorSchema = object({
9563
+ /** Field id inside `NcConditions` (or `'schedule'` for the rule-level group). */
9564
+ id: string(),
9565
+ group: _enum([
9566
+ "scope",
9567
+ "class",
9568
+ "zones",
9569
+ "quality",
9570
+ "label",
9571
+ "schedule",
9572
+ "device",
9573
+ "package",
9574
+ "occupancy"
9575
+ ]),
9576
+ label: string(),
9577
+ /** Editor widget the UI renders — never hardcode per-condition forms. */
9578
+ valueType: _enum([
9579
+ "deviceIdList",
9580
+ "stringList",
9581
+ "number01",
9582
+ "number",
9583
+ "sourceSelect",
9584
+ "zoneSelection",
9585
+ "zoneIdList",
9586
+ "schedule",
9587
+ "plateMatcher",
9588
+ "packagePhase",
9589
+ "polygonDraw",
9590
+ "occupancy"
9591
+ ]),
9592
+ operator: _enum([
9593
+ "in",
9594
+ "notIn",
9595
+ "anyOf",
9596
+ "allOf",
9597
+ "gte",
9598
+ "fuzzyIn",
9599
+ "withinSchedule"
9600
+ ]),
9601
+ /** Which delivery kinds the condition applies to. */
9602
+ appliesTo: array(NcDeliverySchema),
9603
+ phase: string(),
9604
+ description: string().optional()
9605
+ });
9606
+ /**
9607
+ * The delivery lifecycle status of a history row — a straight read of the
9608
+ * durable outbox row's own status (single source of truth):
9609
+ * - `pending` — enqueued, in-flight or retrying with backoff
9610
+ * - `sent` — delivered (terminal)
9611
+ * - `dead` — dead-lettered after exhausting retries / a permanent
9612
+ * backend rejection / a deleted target (terminal; carries
9613
+ * the failure `error`)
9614
+ *
9615
+ * P1 has no `suppressed-quiet-hours` / `snoozed` states — those ride the P2
9616
+ * user dimension (quiet hours / snooze) and are additive when they land.
9617
+ */
9618
+ var NcHistoryStatusSchema = _enum([
9619
+ "pending",
9620
+ "sent",
9621
+ "dead"
9622
+ ]);
9623
+ /** The evaluated record kind a history row descends from (one per trigger). */
9624
+ var NcHistoryRecordKindSchema = _enum([
9625
+ "object-event",
9626
+ "track-end",
9627
+ "device-event",
9628
+ "package-event"
9629
+ ]);
9630
+ /** Subject summary frozen on the row at fire time (survives rule/record edits). */
9631
+ var NcHistorySubjectSchema = object({
9632
+ className: string(),
9633
+ label: string().optional(),
9634
+ confidence: number().optional(),
9635
+ zones: array(string()),
9636
+ timestamp: number()
9637
+ });
9638
+ /**
9639
+ * One delivery-history row. This is a read-only VIEW over the durable
9640
+ * outbox row (single source of truth — the same row the drain loop drives;
9641
+ * NO second write path, so history can never drift from delivery state).
9642
+ * The §3.2 fields map directly: `ruleId`/`targetId`/`deviceId` are columns,
9643
+ * `eventRef` is `recordKind`+`recordId`, `timestamps` are `createdAt`
9644
+ * (fire) / `updatedAt` (last transition), `status` + `error` are the
9645
+ * lifecycle. `ruleName` + `subject` are the intent snapshot frozen at
9646
+ * enqueue. `userId?` (per-recipient history) is P2 — no user dimension in
9647
+ * P1 (admin scope only).
9648
+ */
9649
+ var NcHistoryEntrySchema = object({
9650
+ /** Outbox row id — the stable dedup id `ruleId:dedupRef:targetId`. */
9651
+ id: string(),
9652
+ ruleId: string(),
9653
+ /** Rule name frozen at fire time (outlives a later rename / delete). */
9654
+ ruleName: string(),
9655
+ /** The rule urgency/trigger that produced this delivery. */
9656
+ delivery: NcDeliverySchema,
9657
+ targetId: string(),
9658
+ deviceId: number(),
9659
+ recordKind: NcHistoryRecordKindSchema,
9660
+ /** Event / track ref of the evaluated record (§3.2 `eventRef`). */
9661
+ recordId: string(),
9662
+ /** Present for track-scoped deliveries (object-event / track-end). */
9663
+ trackId: string().optional(),
9664
+ status: NcHistoryStatusSchema,
9665
+ /** Delivery attempts made so far. */
9666
+ attempts: number().int(),
9667
+ /** Fire time (outbox enqueue). */
9668
+ createdAt: number(),
9669
+ /** Last transition time (terminal for sent / dead). */
9670
+ updatedAt: number(),
9671
+ /** Failure detail — present on a `dead` row. */
9672
+ error: string().optional(),
9673
+ subject: NcHistorySubjectSchema
9674
+ });
9675
+ /**
9676
+ * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
9677
+ * AND; absent = unbounded on that axis. `since`/`until` bound the fire time
9678
+ * (`createdAt`, epoch ms, inclusive). `limit` is clamped to
9679
+ * {@link NC_HISTORY_LIMIT_MAX}. `userId` (per-recipient filtering) is P2.
9680
+ */
9681
+ var NcHistoryFilterSchema = object({
9682
+ ruleId: string().optional(),
9683
+ deviceId: number().optional(),
9684
+ status: NcHistoryStatusSchema.optional(),
9685
+ since: number().optional(),
9686
+ until: number().optional(),
9687
+ limit: number().int().min(1).max(500).default(100)
9688
+ });
9689
+ 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 }), {
9690
+ kind: "mutation",
9691
+ auth: "admin",
9692
+ caller: "required"
9693
+ }), method(object({
9694
+ ruleId: string(),
9695
+ patch: NcRulePatchSchema
9696
+ }), object({ rule: NcRuleSchema }), {
9697
+ kind: "mutation",
9698
+ auth: "admin",
9699
+ caller: "required"
9700
+ }), method(object({ ruleId: string() }), object({ success: literal(true) }), {
9701
+ kind: "mutation",
9702
+ auth: "admin"
9703
+ }), method(object({
9704
+ ruleId: string(),
9705
+ enabled: boolean()
9706
+ }), object({ success: literal(true) }), {
9707
+ kind: "mutation",
9708
+ auth: "admin"
9709
+ }), method(object({
9710
+ rule: NcRuleInputSchema,
9711
+ lookbackMinutes: number().int().min(1).max(1440).default(60)
9712
+ }), object({ results: array(NcTestResultSchema) }), {
9713
+ kind: "mutation",
9714
+ auth: "admin"
9715
+ }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
9716
+ /**
9717
+ * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
9718
+ *
9719
+ * Spec: `docs/superpowers/specs/2026-07-24-nc-occupancy-timelapse-design.md`
9720
+ * §3.2/§3.3.
9721
+ *
9722
+ * Deliberately NOT a capability definition and NOT an `NcRule`:
9723
+ * - Every `NcDelivery` member is a *persisted-pipeline-record* trigger. A
9724
+ * timelapse fires on a SCHEDULE WINDOW BOUNDARY, evaluates no pipeline
9725
+ * record, and produces a video it assembled itself — so it rides no
9726
+ * delivery-enum member (the enum is frozen) and no cap method. This file is
9727
+ * a plain typed schema; it does NOT go through `npm run codegen`.
9728
+ * - It shares only the delivery leg (`notification-output.send`) and the
9729
+ * persistence/ownership patterns with the Notification Center, reusing
9730
+ * {@link NcScheduleSchema} (weekly windows, midnight-crossing, invertible)
9731
+ * and {@link NcRuleTargetSchema} (target ref + passthrough params).
9732
+ *
9733
+ * Ownership is SERVER-DERIVED. `ownerUserId` / `createdBy` / `createdAt` /
9734
+ * `updatedAt` / `id` / `lastGeneratedAt` live on the PERSISTED rule only —
9735
+ * {@link TimelapseRuleInputSchema} and {@link TimelapseRulePatchSchema} do not
9736
+ * carry them, so a forged client payload can never claim or re-own a rule
9737
+ * (Zod strips unknown keys). The store stamps them from the resolved caller.
9738
+ */
9739
+ /** `{{var}}` templating over camera/rule/time — same vocabulary as `NcRule`. */
9740
+ var TimelapseTemplateSchema = object({
9741
+ title: string().max(500).optional(),
9742
+ body: string().max(2e3).optional()
9743
+ });
9744
+ var NameField = string().min(1).max(200);
9745
+ var DeviceIdsField = array(number()).min(1);
9746
+ var CadenceSecField = number().int().min(2).max(3600);
9747
+ var FramerateField = number().int().min(1).max(60);
9748
+ var TargetsField = array(NcRuleTargetSchema).min(1);
9749
+ var PriorityField = number().int().min(1).max(5);
9750
+ /**
9751
+ * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
9752
+ * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
9753
+ * here (see the ownership note above).
9754
+ */
9755
+ var TimelapseRuleInputSchema = object({
9756
+ name: NameField,
9757
+ enabled: boolean().default(true),
9758
+ /** Cameras sampled by this rule — one scratch dir + one artifact per device. */
9759
+ deviceIds: DeviceIdsField,
9760
+ /**
9761
+ * Activation window(s). REQUIRED (unlike `NcRule`, where an absent schedule
9762
+ * means "always active"): a timelapse is defined by its window boundaries —
9763
+ * open clears the scratch, close assembles and delivers.
9764
+ */
9765
+ schedule: NcScheduleSchema,
9766
+ /** Force-snapshot cadence inside the window, seconds (predecessor parity). */
9767
+ cadenceSec: CadenceSecField.default(15),
9768
+ /** Output frames per second of the assembled mp4 (predecessor parity). */
9769
+ framerate: FramerateField.default(10),
9770
+ /** `notification-output` targets the finished video/thumbnail is sent to. */
9771
+ targets: TargetsField,
9772
+ template: TimelapseTemplateSchema.optional(),
9773
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
9774
+ priority: PriorityField.default(3)
9775
+ });
9776
+ object({
9777
+ name: NameField.optional(),
9778
+ enabled: boolean().optional(),
9779
+ deviceIds: DeviceIdsField.optional(),
9780
+ schedule: NcScheduleSchema.optional(),
9781
+ cadenceSec: CadenceSecField.optional(),
9782
+ framerate: FramerateField.optional(),
9783
+ targets: TargetsField.optional(),
9784
+ template: TimelapseTemplateSchema.nullable().optional(),
9785
+ priority: PriorityField.optional()
9786
+ });
9787
+ TimelapseRuleInputSchema.extend({
9788
+ id: string(),
9789
+ /**
9790
+ * Ownership/visibility key. Absent = admin/global rule (visible to all).
9791
+ * Present = personal rule owned by this userId. Server-stamped from the
9792
+ * resolved caller; never trusted from a client payload.
9793
+ */
9794
+ ownerUserId: string().optional(),
9795
+ /**
9796
+ * Epoch-ms of the last successful generation — the 1-hour re-generation
9797
+ * guard's durable state (predecessor parity). Absent = never generated.
9798
+ */
9799
+ lastGeneratedAt: number().optional(),
9800
+ /** userId of the caller who created the rule (server-stamped). */
9801
+ createdBy: string(),
9802
+ createdAt: number(),
9803
+ updatedAt: number()
9804
+ });
9805
+ /**
9111
9806
  * Generic device-level status snapshot. Auto-registered by `BaseDevice`
9112
9807
  * for every device, regardless of provider — the kernel needs a uniform
9113
9808
  * cap-keyed slice for the basic device flags every consumer expects to
@@ -12215,6 +12910,22 @@ var CameraMetricsSchema = object({
12215
12910
  ])
12216
12911
  });
12217
12912
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
12913
+ /**
12914
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
12915
+ * within the frame, so the executor can re-cut a leaf child ROI at native
12916
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
12917
+ */
12918
+ var NativeCropRefSchema = object({
12919
+ /** Handle keying the retained native surface (node-pinned to its owner). */
12920
+ handle: FrameHandleSchema,
12921
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
12922
+ cropFrameSpace: object({
12923
+ x: number(),
12924
+ y: number(),
12925
+ w: number(),
12926
+ h: number()
12927
+ })
12928
+ });
12218
12929
  var ModelFormatSchema$1 = _enum([
12219
12930
  "onnx",
12220
12931
  "coreml",
@@ -12490,7 +13201,22 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
12490
13201
  * Omitted ⇒ the runner's default device (current single-engine
12491
13202
  * behaviour). Selects WHICH device pool of the node runs the call.
12492
13203
  */
12493
- deviceKey: string().optional()
13204
+ deviceKey: string().optional(),
13205
+ /**
13206
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
13207
+ * when the parent crop was resolved from the frame's retained NATIVE
13208
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
13209
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
13210
+ * resolution from that surface — the SAME quality path faces already
13211
+ * had — instead of the downscaled parent tile. `handle` keys the native
13212
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
13213
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
13214
+ * the executor's crop-normalized child ROI back into frame-normalized
13215
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
13216
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
13217
+ * (today's behaviour on the fallback path).
13218
+ */
13219
+ nativeCropRef: NativeCropRefSchema.optional()
12494
13220
  }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
12495
13221
  engine: PipelineEngineChoiceSchema.optional(),
12496
13222
  steps: array(PipelineStepInputSchema).min(1),
@@ -12739,7 +13465,11 @@ var DetailResultSchema = object({
12739
13465
  bbox: NativeCropBboxSchema.optional(),
12740
13466
  embedding: string().optional(),
12741
13467
  label: string().optional(),
12742
- alignedCropJpeg: string().optional()
13468
+ alignedCropJpeg: string().optional(),
13469
+ /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
13470
+ * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
13471
+ * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
13472
+ nativeFaceShortSidePx: number().optional()
12743
13473
  });
12744
13474
  /**
12745
13475
  * Per-camera tunable ranges + defaults. Single source of truth used
@@ -12753,6 +13483,12 @@ var motionCooldownMsField = {
12753
13483
  default: 3e4,
12754
13484
  step: 500
12755
13485
  };
13486
+ var maxSessionHoldMsField = {
13487
+ min: 0,
13488
+ max: 6e5,
13489
+ default: 12e4,
13490
+ step: 5e3
13491
+ };
12756
13492
  var motionFpsField = {
12757
13493
  min: 1,
12758
13494
  max: 30,
@@ -12900,6 +13636,19 @@ var RunnerCameraConfigSchema = object({
12900
13636
  "on-motion"
12901
13637
  ]).default("always-on"),
12902
13638
  motionCooldownMs: number().min(motionCooldownMsField.min).default(motionCooldownMsField.default),
13639
+ /**
13640
+ * Orchestrator-side on-motion session-hold cap (ms). While an on-motion
13641
+ * detection session is active and ≥1 confirmed non-stationary track is
13642
+ * still live, the orchestrator keeps the session open past
13643
+ * `motionCooldownMs` (a slowly-moving subject can stop re-triggering the
13644
+ * camera's VMD yet is still being tracked frame-to-frame) — up to this many
13645
+ * ms since the session opened, after which it closes regardless. `0`
13646
+ * disables the hold (legacy cooldown-only teardown). Not consumed by the
13647
+ * runner itself — carried here so it shares the per-camera device-settings
13648
+ * surface with `motionCooldownMs`; the orchestrator reads it off the
13649
+ * resolved `CameraDetectionConfig`.
13650
+ */
13651
+ maxSessionHoldMs: number().min(maxSessionHoldMsField.min).max(maxSessionHoldMsField.max).optional(),
12903
13652
  motionFps: number().min(motionFpsField.min).max(motionFpsField.max).default(motionFpsField.default),
12904
13653
  detectionFps: number().min(detectionFpsField.min).max(detectionFpsField.max).default(detectionFpsField.default),
12905
13654
  motionStreamId: string(),
@@ -12989,7 +13738,7 @@ var RunnerCameraConfigSchema = object({
12989
13738
  */
12990
13739
  inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
12991
13740
  });
12992
- 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;
13741
+ 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;
12993
13742
  /**
12994
13743
  * Runtime load summary returned by `getLocalLoad`. Used by the orchestrator's
12995
13744
  * load-balancing levels (L2 capacity-based, L3 hardware-aware) to decide
@@ -13205,86 +13954,25 @@ var motionTriggerCapability = {
13205
13954
  runtimeState: MotionTriggerRuntimeStateSchema
13206
13955
  };
13207
13956
  /**
13208
- * Shared geometry vocabulary for on-frame shape caps privacy-mask,
13209
- * motion-zones, and the detection zones/lines editor all speak this one
13210
- * language so a single drawing-plane editor and the providers stay
13211
- * decoupled from each cap's storage.
13212
- *
13213
- * All coordinates are normalized 0..1 of the camera frame (top-left
13214
- * origin). Each cap composes the SUBSET of shape kinds it supports and
13215
- * advertises it via `supportedShapes` in its `getOptions`.
13957
+ * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
13958
+ * on-camera motion-detection mask is a single `grid` region (a row-major
13959
+ * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
13960
+ * a region keeps one drawing-plane model across all geometry caps.
13216
13961
  */
13217
- /** A normalized 0..1 point (top-left origin). */
13218
- var MaskPointSchema = object({
13219
- x: number(),
13220
- y: number()
13221
- });
13222
- /** Axis-aligned rectangle (normalized 0..1). */
13223
- var MaskRectShapeSchema = object({
13224
- kind: literal("rect"),
13225
- x: number(),
13226
- y: number(),
13227
- width: number(),
13228
- height: number()
13962
+ /** A motion-zone region exactly one boolean cell grid today. */
13963
+ var MotionZoneRegionSchema = object({
13964
+ id: number(),
13965
+ enabled: boolean(),
13966
+ shape: MaskGridShapeSchema
13229
13967
  });
13230
- /** Free polygon an ordered list of normalized vertices (≥3). */
13231
- var MaskPolygonShapeSchema = object({
13232
- kind: literal("polygon"),
13233
- points: array(MaskPointSchema)
13234
- });
13235
- /** Boolean cell grid row-major, length === gridWidth*gridHeight. */
13236
- var MaskGridShapeSchema = object({
13237
- kind: literal("grid"),
13238
- gridWidth: number(),
13239
- gridHeight: number(),
13240
- cells: array(boolean())
13241
- });
13242
- discriminatedUnion("kind", [
13243
- MaskRectShapeSchema,
13244
- MaskPolygonShapeSchema,
13245
- MaskGridShapeSchema,
13246
- object({
13247
- kind: literal("line"),
13248
- points: array(MaskPointSchema)
13249
- })
13250
- ]);
13251
- /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
13252
- var MaskShapeKindSchema = _enum([
13253
- "rect",
13254
- "polygon",
13255
- "grid",
13256
- "line"
13257
- ]);
13258
- /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
13259
- var MaskPolygonVerticesSchema = object({
13260
- min: number(),
13261
- max: number()
13262
- });
13263
- /** Grid dimensions when a cap supports 'grid'. */
13264
- var MaskGridDimsSchema = object({
13265
- width: number(),
13266
- height: number()
13267
- });
13268
- /**
13269
- * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
13270
- * on-camera motion-detection mask is a single `grid` region (a row-major
13271
- * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
13272
- * a region keeps one drawing-plane model across all geometry caps.
13273
- */
13274
- /** A motion-zone region — exactly one boolean cell grid today. */
13275
- var MotionZoneRegionSchema = object({
13276
- id: number(),
13277
- enabled: boolean(),
13278
- shape: MaskGridShapeSchema
13279
- });
13280
- /** Current on-camera motion-detection state — master enable + sensitivity +
13281
- * the grid region(s). */
13282
- var MotionZoneStatusSchema = object({
13283
- enabled: boolean(),
13284
- sensitivity: number(),
13285
- /** Grid region(s). Today exactly one `grid` shape. */
13286
- regions: array(MotionZoneRegionSchema),
13287
- lastFetchedAt: number()
13968
+ /** Current on-camera motion-detection state master enable + sensitivity +
13969
+ * the grid region(s). */
13970
+ var MotionZoneStatusSchema = object({
13971
+ enabled: boolean(),
13972
+ sensitivity: number(),
13973
+ /** Grid region(s). Today exactly one `grid` shape. */
13974
+ regions: array(MotionZoneRegionSchema),
13975
+ lastFetchedAt: number()
13288
13976
  });
13289
13977
  /** Per-camera availability — grid dims are fixed per camera model; the UI
13290
13978
  * sizes its editor from `grid`. */
@@ -16516,94 +17204,6 @@ var EnrichedWidgetMetadataSchema = WidgetMetadataSchema.extend({
16516
17204
  bundleUrl: string()
16517
17205
  });
16518
17206
  method(_void(), array(EnrichedWidgetMetadataSchema).readonly());
16519
- var NotificationRuleConditionsSchema = object({
16520
- deviceIds: array(number()).readonly().optional(),
16521
- classNames: array(string()).readonly().optional(),
16522
- zoneIds: array(string()).readonly().optional(),
16523
- minConfidence: number().optional(),
16524
- source: _enum([
16525
- "pipeline",
16526
- "onboard",
16527
- "any"
16528
- ]).optional(),
16529
- schedule: object({
16530
- days: array(number()).readonly(),
16531
- startHour: number(),
16532
- endHour: number()
16533
- }).optional(),
16534
- cooldownSeconds: number().optional(),
16535
- minDwellSeconds: number().optional(),
16536
- /** Match against `event.data.eventType` token (e.g. `'press_long'`). When non-empty, only events
16537
- * carrying a matching `data.eventType` string pass this condition. Rules without this field are
16538
- * unaffected (back-compat). Distinct from `rule.eventTypes` which holds EventCategory strings. */
16539
- eventTypeTokens: array(string()).readonly().optional(),
16540
- /** Match detections whose CLIP image embedding is semantically similar to this free-text
16541
- * description. Requires the embedding-encoder cap to have pre-warmed the text vector.
16542
- * `minSimilarity` is the cosine similarity threshold in [0, 1]. */
16543
- clipDescription: object({
16544
- text: string().min(1),
16545
- minSimilarity: number().min(0).max(1)
16546
- }).optional(),
16547
- /** Match events whose recognized-entity label (face identity name or plate
16548
- * vehicle name, propagated onto `event.data.label`) is one of these values.
16549
- * Empty/absent → unaffected (back-compat). Enables "notify me when <named
16550
- * vehicle/person> is seen". */
16551
- labels: array(string()).readonly().optional()
16552
- });
16553
- var NotificationRuleTemplateSchema = object({
16554
- title: string(),
16555
- body: string(),
16556
- imageMode: _enum([
16557
- "crop",
16558
- "annotated",
16559
- "full",
16560
- "none"
16561
- ])
16562
- });
16563
- var NotificationRuleSchema = object({
16564
- id: string(),
16565
- name: string(),
16566
- enabled: boolean(),
16567
- eventTypes: array(string()).readonly(),
16568
- conditions: NotificationRuleConditionsSchema,
16569
- outputs: array(string()).readonly(),
16570
- template: NotificationRuleTemplateSchema.optional(),
16571
- priority: _enum([
16572
- "low",
16573
- "normal",
16574
- "high",
16575
- "critical"
16576
- ])
16577
- });
16578
- var NotificationTestResultSchema = object({
16579
- ruleId: string(),
16580
- eventId: string(),
16581
- timestamp: number(),
16582
- wouldFire: boolean(),
16583
- reason: string().optional()
16584
- });
16585
- var NotificationHistoryEntrySchema = object({
16586
- id: string(),
16587
- ruleId: string(),
16588
- ruleName: string(),
16589
- eventId: string(),
16590
- timestamp: number(),
16591
- outputs: array(string()).readonly(),
16592
- success: boolean(),
16593
- error: string().optional(),
16594
- deviceId: number().optional()
16595
- });
16596
- var NotificationHistoryFilterSchema = object({
16597
- ruleId: string().optional(),
16598
- deviceId: number().optional(),
16599
- from: number().optional(),
16600
- to: number().optional(),
16601
- limit: number().optional()
16602
- });
16603
- 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({
16604
- ruleId: string(),
16605
- lookbackMinutes: number()
16606
- }), object({ results: array(NotificationTestResultSchema).readonly() }), { kind: "mutation" }), method(object({ filter: NotificationHistoryFilterSchema.optional() }), object({ entries: array(NotificationHistoryEntrySchema).readonly() }));
16607
17207
  /**
16608
17208
  * Alerts capability — collection-based internal alert system.
16609
17209
  *
@@ -16790,88 +17390,54 @@ method(object({
16790
17390
  password: string()
16791
17391
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
16792
17392
  /**
16793
- * `login-method` collection cap through which auth addons contribute
16794
- * their pre-auth login surfaces to the login page. This is the SINGLE,
16795
- * generic mechanism that supersedes the dead `auth.listProviders` reader:
16796
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
16797
- * `login-method` provider and the PUBLIC `auth.listLoginMethods`
16798
- * procedure aggregates them for the unauthenticated login page.
16799
- *
16800
- * A contribution is a discriminated union on `kind`:
16801
- *
16802
- * - `redirect` — a declarative button. The login page renders a generic
16803
- * button that navigates to `startUrl` (an addon-owned HTTP route).
16804
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
16805
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
16806
- * login page needs NO change.
16807
- *
16808
- * - `widget` — a Module-Federation widget the login page mounts (via
16809
- * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
16810
- * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
16811
- * mechanism kept for future use; no shipped addon uses it on the login
16812
- * page (the passkey ceremony below runs natively in the shell instead).
16813
- *
16814
- * - `passkey` — a declarative WebAuthn ceremony the shell renders
16815
- * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
16816
- * a remotely-loaded bundle). Carries the addon's effective `rpId` /
16817
- * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
16818
- * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
16819
- * fetching any remote code pre-auth. Contribution stays unconditional —
16820
- * enrollment state is never leaked pre-auth; visibility is a shell
16821
- * decision.
16822
- *
16823
- * Every contribution carries a `stage`:
16824
- * - `primary` — shown on the first credentials screen (OIDC /
16825
- * magic-link buttons; a future usernameless passkey).
16826
- * - `second-factor` — shown AFTER the password leg, gated on the
16827
- * returned `factors` (passkey-as-2FA today).
16828
- *
16829
- * `mount: skip` — the cap is read server-side by the core auth router
16830
- * (`registry.getCollection('login-method')`), never mounted as its own
16831
- * tRPC router.
17393
+ * A live terminal session hosted by the provider addon. Output and input do
17394
+ * NOT flow through the capability they use the addon data plane
17395
+ * (`GET /addon/terminal/<id>/out` SSE, `POST /addon/terminal/<id>/in`) because
17396
+ * terminal output must be ordered and lossless. The event bus is telemetry and
17397
+ * may drop chunks ([D8]), and a dropped chunk desynchronises the vt parser
17398
+ * permanently until a full repaint. The capability owns only lifecycle.
16832
17399
  */
16833
- /** When a login method renders in the two-phase login flow. */
16834
- var LoginStageEnum = _enum(["primary", "second-factor"]);
16835
- /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
16836
- var LoginMethodContributionSchema = discriminatedUnion("kind", [
16837
- object({
16838
- kind: literal("redirect"),
16839
- /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
16840
- id: string(),
16841
- /** Operator-facing button label. */
16842
- label: string(),
16843
- /** lucide-react icon name. */
16844
- icon: string().optional(),
16845
- /** Addon-owned HTTP route the button navigates to (GET). */
16846
- startUrl: string(),
16847
- stage: LoginStageEnum
16848
- }),
16849
- object({
16850
- kind: literal("widget"),
16851
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
16852
- id: string(),
16853
- /** Owning addon id — drives the public bundle URL + the MF namespace. */
16854
- addonId: string(),
16855
- /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
16856
- bundle: string(),
16857
- /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
16858
- remote: WidgetRemoteSchema,
16859
- stage: LoginStageEnum
16860
- }),
16861
- object({
16862
- kind: literal("passkey"),
16863
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
16864
- id: string(),
16865
- /** Operator-facing button label. */
16866
- label: string(),
16867
- stage: LoginStageEnum,
16868
- /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
16869
- rpId: string(),
16870
- /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
16871
- origin: string().nullable()
16872
- })
16873
- ]);
16874
- method(_void(), array(LoginMethodContributionSchema).readonly());
17400
+ var TerminalSessionInfoSchema = object({
17401
+ /** Opaque session id minted by the provider on `openSession`. */
17402
+ sessionId: string(),
17403
+ /** The pre-declared profile this session runs (never a free-form command). */
17404
+ profileId: string(),
17405
+ /** Human-readable profile label for the UI session list. */
17406
+ label: string(),
17407
+ cols: number().int().positive(),
17408
+ rows: number().int().positive(),
17409
+ /** ms-epoch the session's pty was spawned. */
17410
+ startedAt: number()
17411
+ });
17412
+ /**
17413
+ * A profile the operator may open — a pre-declared, allowlisted program
17414
+ * (`monitor` → `btm`). The capability accepts only these ids; a free-form
17415
+ * command string would be remote code execution as the server's user, so it is
17416
+ * deliberately not part of the contract.
17417
+ */
17418
+ var TerminalProfileInfoSchema = object({
17419
+ profileId: string(),
17420
+ label: string(),
17421
+ description: string().optional()
17422
+ });
17423
+ method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(TerminalSessionInfoSchema).readonly(), { auth: "admin" }), method(object({
17424
+ profileId: string(),
17425
+ cols: number().int().positive(),
17426
+ rows: number().int().positive()
17427
+ }), TerminalSessionInfoSchema, {
17428
+ kind: "mutation",
17429
+ auth: "admin"
17430
+ }), method(object({
17431
+ sessionId: string(),
17432
+ cols: number().int().positive(),
17433
+ rows: number().int().positive()
17434
+ }), _void(), {
17435
+ kind: "mutation",
17436
+ auth: "admin"
17437
+ }), method(object({ sessionId: string() }), _void(), {
17438
+ kind: "mutation",
17439
+ auth: "admin"
17440
+ });
16875
17441
  /**
16876
17442
  * Orchestrator-side destination metadata. The orchestrator computes
16877
17443
  * `id = <addonId>:<subId>` from its provider lookup so consumers
@@ -16973,11 +17539,53 @@ var LocationStatSchema = object({
16973
17539
  fileCount: number(),
16974
17540
  present: boolean()
16975
17541
  });
17542
+ /**
17543
+ * A backup schedule — the N:M "entry" that binds one cron cadence to a
17544
+ * SET of destination locations. Supersedes the per-location cron on
17545
+ * `BackupDestinationPolicy`: an operator creates a schedule, picks the
17546
+ * `backups` locations it should write to, and the orchestrator fans a
17547
+ * single archive out to all of them when the cron fires.
17548
+ *
17549
+ * `retentionCount` is per-schedule (D-decision 2026-07-28): every
17550
+ * location targeted by this schedule keeps this many archives from
17551
+ * this schedule's runs.
17552
+ *
17553
+ * `dataSources` optionally narrows which top-level state locations
17554
+ * (db, addons, tls, …) are archived; omitted = the orchestrator's
17555
+ * default full set.
17556
+ */
17557
+ var BackupScheduleSchema = object({
17558
+ /** Stable id. Generated by the orchestrator on first upsert if absent. */
17559
+ id: string(),
17560
+ /** Operator-facing display name. */
17561
+ label: string(),
17562
+ /** 5-field POSIX cron. Empty = disabled cadence (kept for editing). */
17563
+ cron: string(),
17564
+ /** Master on/off toggle for the whole schedule. */
17565
+ enabled: boolean(),
17566
+ /** `backups`-location ids this schedule writes to (fan-out set). */
17567
+ locationIds: array(string()).readonly(),
17568
+ /** Archives kept per targeted location for this schedule. */
17569
+ retentionCount: number().int().min(1).max(1e3),
17570
+ /** Optional subset of source locations to include; omitted = all. */
17571
+ dataSources: array(string()).readonly().optional(),
17572
+ /** ms-epoch of last successful run. */
17573
+ lastRunAt: number().optional(),
17574
+ /** ms-epoch of next computed firing (read-only, filled on list). */
17575
+ nextRunAt: number().optional()
17576
+ });
16976
17577
  method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }), method(object({
16977
17578
  /** Subset of registered `backup-destination` addon ids to write to. */
16978
17579
  destinations: array(string()).optional(),
16979
17580
  locations: array(string()).optional(),
16980
- label: string().optional()
17581
+ label: string().optional(),
17582
+ /**
17583
+ * Per-run retention override applied to every targeted
17584
+ * destination. Used by schedule-driven runs (per-entry
17585
+ * retention). Omitted = each destination's own policy
17586
+ * retention (manual runs).
17587
+ */
17588
+ retentionCount: number().int().min(1).max(1e3).optional()
16981
17589
  }).optional(), array(BackupEntrySchema).readonly(), {
16982
17590
  kind: "mutation",
16983
17591
  auth: "admin"
@@ -17026,7 +17634,21 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
17026
17634
  ok: boolean(),
17027
17635
  error: string().optional(),
17028
17636
  nextRuns: array(number()).readonly()
17029
- }));
17637
+ })), method(_void(), array(BackupScheduleSchema).readonly(), { auth: "admin" }), method(object({
17638
+ id: string().optional(),
17639
+ label: string(),
17640
+ cron: string(),
17641
+ enabled: boolean(),
17642
+ locationIds: array(string()).readonly(),
17643
+ retentionCount: number().int().min(1).max(1e3),
17644
+ dataSources: array(string()).readonly().optional()
17645
+ }), BackupScheduleSchema, {
17646
+ kind: "mutation",
17647
+ auth: "admin"
17648
+ }), method(object({ id: string() }), _void(), {
17649
+ kind: "mutation",
17650
+ auth: "admin"
17651
+ });
17030
17652
  /**
17031
17653
  * `broker` — unified pub/sub broker registry, system-scoped collection.
17032
17654
  *
@@ -18233,851 +18855,934 @@ method(_void(), array(string()).readonly(), { auth: "admin" }), method(object({
18233
18855
  kind: "mutation",
18234
18856
  auth: "admin"
18235
18857
  });
18236
- var LogLevelSchema = _enum([
18237
- "debug",
18238
- "info",
18239
- "warn",
18240
- "error"
18241
- ]);
18242
- var LogEntrySchema = object({
18243
- timestamp: date(),
18244
- level: LogLevelSchema,
18245
- scope: array(string()),
18246
- message: string(),
18247
- meta: record(string(), unknown()).optional(),
18248
- tags: record(string(), string()).optional()
18858
+ /**
18859
+ * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
18860
+ * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
18861
+ * caps stay wire-compatible without a circular cap→cap import.
18862
+ *
18863
+ * Errors are a discriminated-union RESULT, never thrown: the shape survives
18864
+ * every transport tier structurally, and failed calls still write usage rows.
18865
+ * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
18866
+ */
18867
+ var LlmUsageSchema = object({
18868
+ inputTokens: number(),
18869
+ outputTokens: number()
18249
18870
  });
18250
- method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18251
- scope: array(string()).optional(),
18252
- level: LogLevelSchema.optional(),
18253
- since: date().optional(),
18254
- until: date().optional(),
18255
- limit: number().optional(),
18256
- tags: record(string(), string()).optional()
18257
- }), array(LogEntrySchema).readonly());
18258
- var CpuBreakdownSchema = object({
18259
- total: number(),
18260
- user: number(),
18261
- system: number(),
18262
- irq: number(),
18263
- nice: number(),
18264
- loadAvg: tuple([
18265
- number(),
18266
- number(),
18267
- number()
18268
- ]),
18269
- cores: number()
18270
- });
18271
- var MemoryInfoSchema = object({
18272
- percent: number(),
18273
- totalBytes: number(),
18274
- usedBytes: number(),
18275
- availableBytes: number(),
18276
- swapUsedBytes: number(),
18277
- swapTotalBytes: number()
18278
- });
18279
- var DiskIoSnapshotSchema = object({
18280
- readBytes: number(),
18281
- writeBytes: number(),
18282
- readOps: number(),
18283
- writeOps: number(),
18284
- timestampMs: number()
18285
- });
18286
- var NetworkIoSnapshotSchema = object({
18287
- rxBytes: number(),
18288
- txBytes: number(),
18289
- rxPackets: number(),
18290
- txPackets: number(),
18291
- rxErrors: number(),
18292
- txErrors: number(),
18293
- timestampMs: number()
18294
- });
18295
- var MetricsGpuInfoSchema = object({
18296
- utilization: number(),
18871
+ var LlmErrorCodeSchema = _enum([
18872
+ "timeout",
18873
+ "rate-limited",
18874
+ "auth",
18875
+ "refusal",
18876
+ "bad-request",
18877
+ "unavailable",
18878
+ "no-profile",
18879
+ "budget-exceeded",
18880
+ "adapter-error"
18881
+ ]);
18882
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
18883
+ ok: literal(true),
18884
+ text: string(),
18297
18885
  model: string(),
18298
- memoryUsedBytes: number(),
18299
- memoryTotalBytes: number(),
18300
- temperature: number().nullable()
18301
- });
18302
- var ProcessResourceInfoSchema = object({
18303
- openFds: number(),
18304
- threadCount: number(),
18305
- activeHandles: number(),
18306
- activeRequests: number()
18307
- });
18308
- var PressureAvgsSchema = object({
18309
- avg10: number(),
18310
- avg60: number(),
18311
- avg300: number()
18886
+ usage: LlmUsageSchema,
18887
+ truncated: boolean(),
18888
+ latencyMs: number()
18889
+ }), object({
18890
+ ok: literal(false),
18891
+ code: LlmErrorCodeSchema,
18892
+ message: string(),
18893
+ retryAfterMs: number().optional()
18894
+ })]);
18895
+ /**
18896
+ * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
18897
+ * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
18898
+ * notification-output.cap.ts:27-31 precedents).
18899
+ */
18900
+ var LlmImageSchema = object({
18901
+ bytes: _instanceof(Uint8Array),
18902
+ mimeType: string()
18312
18903
  });
18313
- var PressureInfoSchema = object({
18314
- some: PressureAvgsSchema,
18315
- full: PressureAvgsSchema.nullable()
18904
+ var LlmGenerateBaseInputSchema = object({
18905
+ /** Collection routing (the notification-output posture). */
18906
+ addonId: string().optional(),
18907
+ /** Explicit profile; else the resolution chain (spec §3). */
18908
+ profileId: string().optional(),
18909
+ /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
18910
+ consumer: string(),
18911
+ system: string().optional(),
18912
+ /** v1: single-turn. `messages[]` is a v2 additive field. */
18913
+ prompt: string(),
18914
+ /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
18915
+ jsonSchema: record(string(), unknown()).optional(),
18916
+ /** Per-call override of the profile default. */
18917
+ maxTokens: number().int().positive().optional(),
18918
+ temperature: number().optional()
18316
18919
  });
18317
- var SystemResourceSnapshotSchema = object({
18318
- cpu: CpuBreakdownSchema,
18319
- memory: MemoryInfoSchema,
18320
- gpu: MetricsGpuInfoSchema.nullable(),
18321
- network: NetworkIoSnapshotSchema,
18322
- disk: DiskIoSnapshotSchema,
18323
- pressure: object({
18324
- cpu: PressureInfoSchema.nullable(),
18325
- memory: PressureInfoSchema.nullable(),
18326
- io: PressureInfoSchema.nullable()
18920
+ /**
18921
+ * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
18922
+ * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
18923
+ * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
18924
+ * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
18925
+ * this only through the `llm` cap's methods.
18926
+ *
18927
+ * One running llama-server child per node in v1 (models are RAM-heavy).
18928
+ * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
18929
+ * watchdog — operator decision #3).
18930
+ */
18931
+ var ManagedModelRefSchema = discriminatedUnion("kind", [
18932
+ object({
18933
+ kind: literal("catalog"),
18934
+ catalogId: string()
18327
18935
  }),
18328
- process: ProcessResourceInfoSchema,
18329
- cpuTemperature: number().nullable(),
18330
- timestampMs: number()
18331
- });
18332
- var DiskSpaceInfoSchema = object({
18333
- path: string(),
18334
- totalBytes: number(),
18335
- usedBytes: number(),
18336
- availableBytes: number(),
18337
- percent: number()
18338
- });
18339
- var PidResourceStatsSchema = object({
18340
- pid: number(),
18341
- cpu: number(),
18342
- memory: number(),
18343
- /**
18344
- * Private (anonymous) resident bytes — the per-process V8 heap + native
18345
- * allocations NOT shared with other processes (Linux RssAnon). This is the
18346
- * "real" per-runner cost; summing it across runners is meaningful, unlike
18347
- * `memory` (RSS), which double-counts the shared mmap'd framework code.
18348
- * Undefined where /proc is unavailable (e.g. macOS).
18349
- */
18350
- privateBytes: number().optional(),
18351
- /**
18352
- * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
18353
- * code shared copy-on-write across runners. Undefined on macOS.
18354
- */
18355
- sharedBytes: number().optional()
18936
+ object({
18937
+ kind: literal("url"),
18938
+ url: string(),
18939
+ sha256: string().optional()
18940
+ }),
18941
+ object({
18942
+ kind: literal("path"),
18943
+ path: string()
18944
+ })
18945
+ ]);
18946
+ var ManagedRuntimeConfigSchema = object({
18947
+ /** WHERE the runtime lives — hub or any agent. */
18948
+ nodeId: string(),
18949
+ /** Closed for v1; 'ollama' is a v2 candidate. */
18950
+ engine: _enum(["llama-cpp"]),
18951
+ model: ManagedModelRefSchema,
18952
+ contextSize: number().int().default(4096),
18953
+ /** 0 = CPU-only. */
18954
+ gpuLayers: number().int().default(0),
18955
+ /** Default: cpus-2, clamped ≥1 (resolved node-side). */
18956
+ threads: number().int().optional(),
18957
+ /** Concurrent slots. */
18958
+ parallel: number().int().default(1),
18959
+ /** Else lazy: first generate boots it. */
18960
+ autoStart: boolean().default(false),
18961
+ /** 0 = never; frees RAM after quiet periods. */
18962
+ idleStopMinutes: number().int().default(30)
18356
18963
  });
18357
- var AddonInstanceSchema = object({
18358
- addonId: string(),
18964
+ var LlmRuntimeStatusSchema = object({
18965
+ /** Status is ALWAYS node-qualified. */
18359
18966
  nodeId: string(),
18360
- role: _enum(["hub", "worker"]),
18361
- pid: number(),
18362
18967
  state: _enum([
18363
- "starting",
18364
- "running",
18365
- "stopping",
18366
18968
  "stopped",
18367
- "crashed"
18368
- ]),
18369
- uptimeSec: number()
18370
- });
18371
- var NodeProcessSchema = object({
18372
- pid: number(),
18373
- ppid: number(),
18374
- pgid: number(),
18375
- classification: _enum([
18376
- "root",
18377
- "managed",
18378
- "system",
18379
- "ghost"
18969
+ "downloading",
18970
+ "starting",
18971
+ "ready",
18972
+ "crashed",
18973
+ "failed"
18380
18974
  ]),
18381
- /** `$process` addon binding when `managed`, else null. */
18382
- addonId: string().nullable(),
18383
- /** Kernel-reported nodeId when the process is a known agent/worker. */
18384
- nodeId: string().nullable(),
18385
- /** Truncated command line. */
18386
- command: string(),
18387
- cpuPercent: number(),
18388
- memoryRssBytes: number(),
18389
- /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
18390
- uptimeSec: number(),
18391
- /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
18392
- orphaned: boolean()
18393
- });
18394
- var KillProcessInputSchema = object({
18395
- pid: number(),
18396
- /** Force = SIGKILL. Default is SIGTERM. */
18397
- force: boolean().optional()
18975
+ pid: number().optional(),
18976
+ port: number().optional(),
18977
+ modelPath: string().optional(),
18978
+ modelId: string().optional(),
18979
+ downloadProgress: number().min(0).max(1).optional(),
18980
+ lastError: string().optional(),
18981
+ crashesInWindow: number(),
18982
+ /** Child RSS (sampled best-effort). */
18983
+ memoryBytes: number().optional(),
18984
+ vramBytes: number().optional()
18398
18985
  });
18399
- var KillProcessResultSchema = object({
18400
- success: boolean(),
18401
- reason: string().optional(),
18402
- signal: _enum(["SIGTERM", "SIGKILL"]).optional()
18986
+ var LlmNodeModelSchema = object({
18987
+ file: string(),
18988
+ sizeBytes: number(),
18989
+ catalogId: string().optional(),
18990
+ installedAt: number().optional()
18403
18991
  });
18404
- var DumpHeapSnapshotInputSchema = object({
18405
- /** The addon whose runner should dump a heap snapshot. */
18406
- addonId: string() });
18407
- var DumpHeapSnapshotResultSchema = object({
18408
- success: boolean(),
18409
- /** Path of the written .heapsnapshot inside the runner's container/host. */
18410
- path: string().optional(),
18411
- /** Process pid that was signalled. */
18412
- pid: number().optional(),
18413
- reason: string().optional()
18992
+ var LlmRuntimeDiskUsageSchema = object({
18993
+ nodeId: string(),
18994
+ modelsBytes: number(),
18995
+ freeBytes: number().optional()
18414
18996
  });
18415
- var SystemMetricsSchema = object({
18416
- cpuPercent: number(),
18417
- memoryPercent: number(),
18418
- memoryUsedMB: number(),
18419
- memoryTotalMB: number(),
18420
- diskPercent: number().optional(),
18421
- temperature: number().optional(),
18422
- gpuPercent: number().optional(),
18423
- gpuMemoryPercent: number().optional()
18424
- });
18425
- 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, {
18997
+ method(LlmGenerateBaseInputSchema.extend({
18998
+ images: array(LlmImageSchema).optional(),
18999
+ runtime: ManagedRuntimeConfigSchema,
19000
+ /** The managed profile's timeout, threaded by the hub provider. */
19001
+ timeoutMs: number().int().positive().optional()
19002
+ }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
18426
19003
  kind: "mutation",
18427
19004
  auth: "admin"
18428
- }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
19005
+ }), method(object({}), _void(), {
18429
19006
  kind: "mutation",
18430
19007
  auth: "admin"
18431
- });
18432
- method(object({
18433
- sourceUrl: string(),
18434
- metadata: ModelConvertMetadataSchema,
18435
- targets: array(ConvertTargetSchema).min(1).readonly(),
18436
- calibrationRef: string().optional(),
18437
- sessionId: string().optional()
18438
- }), ConvertResultSchema, {
19008
+ }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
18439
19009
  kind: "mutation",
18440
- auth: "admin",
18441
- timeoutMs: 6e5
18442
- });
18443
- method(object({
18444
- nodeId: string(),
18445
- modelId: string(),
18446
- format: _enum(MODEL_FORMATS),
18447
- entry: ModelCatalogEntrySchema
18448
- }), object({
18449
- ok: boolean(),
18450
- /** sha256 of the staged tarball (empty for a hub-local no-op). */
18451
- sha256: string(),
18452
- bytes: number(),
18453
- /** The target node's modelsDir the artifact landed in. */
18454
- path: string()
18455
- }), {
19010
+ auth: "admin"
19011
+ }), method(object({ file: string() }), _void(), {
18456
19012
  kind: "mutation",
18457
19013
  auth: "admin"
18458
- });
18459
- /**
18460
- * `mqtt-broker` — broker-registry cap.
18461
- *
18462
- * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
18463
- * MQTT brokers (external + optionally an embedded `aedes`-backed one)
18464
- * and (b) the connection details a consumer addon needs to spin up
18465
- * its OWN `mqtt.js` client.
18466
- *
18467
- * Why: pub/sub routing over the system event-bus loses fidelity
18468
- * (callback shape, QoS guarantees, will/retain semantics) and adds
18469
- * refcount bookkeeping that addons would rather own themselves. The
18470
- * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
18471
- * features anyway — give it the connection config, get out of the way.
18472
- *
18473
- * Consumer flow:
18474
- * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
18475
- * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
18476
- * client.subscribe('zigbee2mqtt/+')
18477
- *
18478
- * Collection mode: multiple brokers (e.g. one local mosquitto + one
18479
- * cloud bridge). The "embedded" entry (when present) is just another
18480
- * broker in the registry — its lifecycle is owned by the addon that
18481
- * spawned it.
18482
- */
18483
- var BrokerKindSchema = _enum(["external", "embedded"]);
19014
+ }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
18484
19015
  /**
18485
- * Broker live-probe status.
19016
+ * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
19017
+ * methods concat-fan across providers; single-row methods route to ONE
19018
+ * provider by the `addonId` in the call input (the notification-output
19019
+ * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
19020
+ * (hub-placed); the cap stays open for future providers.
18486
19021
  *
18487
- * - `connected` last probe completed a clean CONNACK
18488
- * - `disconnected` — no probe has run yet (cold cache)
18489
- * - `auth-failed` CONNACK refused with auth error (RC 4 / 5)
18490
- * - `unreachable` — TCP connect timed out / refused
18491
- * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
19022
+ * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
19023
+ * `apiKey` is a password field providers REDACT it on read and merge on
19024
+ * write; a stored key NEVER round-trips to a client.
18492
19025
  */
18493
- var BrokerStatusSchema$1 = _enum([
18494
- "connected",
18495
- "disconnected",
18496
- "auth-failed",
18497
- "unreachable",
18498
- "tls-error"
19026
+ var LlmProfileKindSchema = _enum([
19027
+ "openai-compatible",
19028
+ "openai",
19029
+ "anthropic",
19030
+ "google",
19031
+ "managed-local"
18499
19032
  ]);
18500
- var BrokerInfoSchema = object({
19033
+ var LlmProfileSchema = object({
18501
19034
  id: string(),
18502
19035
  name: string(),
18503
- url: string(),
18504
- kind: BrokerKindSchema,
18505
- status: BrokerStatusSchema$1,
18506
- latencyMs: number().nullable(),
18507
- error: string().optional(),
18508
- /** Embedded brokers only: number of MQTT clients currently connected. */
18509
- connectedClients: number().int().nonnegative().optional(),
18510
- /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
18511
- lastCheckedAt: number().optional()
19036
+ kind: LlmProfileKindSchema,
19037
+ /** Stamped by the provider — keeps the fanned catalog routable. */
19038
+ addonId: string(),
19039
+ enabled: boolean(),
19040
+ /** Vendor model id, or the managed runtime's loaded model. */
19041
+ model: string(),
19042
+ /** Required for openai-compatible; override for cloud kinds. */
19043
+ baseUrl: string().optional(),
19044
+ /** ConfigUISchema type:'password' — never round-trips (spec §5). */
19045
+ apiKey: string().optional(),
19046
+ supportsVision: boolean(),
19047
+ temperature: number().min(0).max(2).optional(),
19048
+ maxTokens: number().int().positive().optional(),
19049
+ timeoutMs: number().int().positive().default(6e4),
19050
+ extraHeaders: record(string(), string()).optional(),
19051
+ /** kind === 'managed-local' only (spec §4). */
19052
+ runtime: ManagedRuntimeConfigSchema.optional()
18512
19053
  });
18513
- /**
18514
- * Connection details — what a consumer needs to call
18515
- * `mqtt.connect(url, options)`. We split URL + credentials so the
18516
- * consumer can pass them as `mqtt.connect(url, { username, password })`
18517
- * instead of stuffing creds into the URL (which leaks them into logs).
18518
- */
18519
- var BrokerConnectionDetailsSchema = object({
18520
- url: string(),
18521
- username: string().optional(),
18522
- password: string().optional(),
18523
- /**
18524
- * Suggested prefix for `clientId`. Each consumer should suffix this
18525
- * with its own discriminator (addon id, instance id) so reconnects
18526
- * don't kick each other off (MQTT spec: clientId must be unique per
18527
- * broker).
18528
- */
18529
- clientIdPrefix: string().optional()
19054
+ /** ConfigUISchema tree passed through untyped on the wire (the
19055
+ * notification-output `ConfigSchemaPassthrough` precedent at
19056
+ * notification-output.cap.ts:151); the exported TS type re-tightens it. */
19057
+ var ConfigSchemaPassthrough$1 = unknown();
19058
+ var LlmProfileKindDescriptorSchema = object({
19059
+ kind: LlmProfileKindSchema,
19060
+ label: string(),
19061
+ icon: string(),
19062
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
19063
+ addonId: string(),
19064
+ configSchema: ConfigSchemaPassthrough$1
18530
19065
  });
18531
- var AddBrokerInputSchema = object({
18532
- name: string().min(1),
18533
- url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
18534
- username: string().optional(),
18535
- password: string().optional(),
18536
- clientIdPrefix: string().optional()
19066
+ var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
19067
+ var LlmDefaultSchema = object({
19068
+ selector: LlmDefaultSelectorSchema,
19069
+ profileId: string()
18537
19070
  });
18538
- var AddBrokerResultSchema = object({ id: string() });
18539
- var IdInputSchema = object({ id: string() });
18540
- var TestResultSchema$1 = discriminatedUnion("ok", [object({
18541
- ok: literal(true),
18542
- latencyMs: number()
18543
- }), object({
18544
- ok: literal(false),
18545
- error: string()
18546
- })]);
18547
- var StartEmbeddedInputSchema = object({
18548
- port: number().int().min(1).max(65535).default(1883),
18549
- /** Allow anonymous connect (no username/password). Default: false. */
18550
- allowAnonymous: boolean().default(false),
18551
- /** Optional shared username/password for clients. */
18552
- username: string().optional(),
18553
- password: string().optional()
19071
+ /** Server-side rollup row getUsage never dumps raw call rows (spec §6). */
19072
+ var LlmUsageRollupSchema = object({
19073
+ day: string(),
19074
+ consumer: string(),
19075
+ profileId: string(),
19076
+ calls: number(),
19077
+ okCalls: number(),
19078
+ errorCalls: number(),
19079
+ inputTokens: number(),
19080
+ outputTokens: number(),
19081
+ avgLatencyMs: number()
18554
19082
  });
18555
- var StartEmbeddedResultSchema = object({
19083
+ /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
19084
+ var ManagedModelCatalogEntrySchema = object({
18556
19085
  id: string(),
18557
- url: string()
18558
- });
18559
- var StatusSchema = object({
18560
- brokerCount: number(),
18561
- embeddedRunning: boolean()
18562
- });
18563
- 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);
18564
- var NetworkEndpointSchema = object({
19086
+ label: string(),
19087
+ family: string(),
19088
+ purpose: _enum(["text", "vision"]),
18565
19089
  url: string(),
18566
- hostname: string(),
18567
- port: number(),
18568
- protocol: _enum(["http", "https"])
19090
+ sha256: string(),
19091
+ sizeBytes: number(),
19092
+ quantization: string(),
19093
+ /** Load-time guidance shown in the picker. */
19094
+ minRamBytes: number(),
19095
+ contextSizeDefault: number().int(),
19096
+ /** Vision models: companion projector file. */
19097
+ mmprojUrl: string().optional()
18569
19098
  });
18570
- var NetworkAccessStatusSchema = object({
18571
- connected: boolean(),
18572
- endpoint: NetworkEndpointSchema.nullable(),
19099
+ var LlmRuntimeNodeSchema = object({
19100
+ nodeId: string(),
19101
+ reachable: boolean(),
19102
+ status: LlmRuntimeStatusSchema.optional(),
19103
+ disk: LlmRuntimeDiskUsageSchema.optional(),
18573
19104
  error: string().optional()
18574
19105
  });
18575
- /**
18576
- * Optional, richer endpoint shape returned by providers that expose
18577
- * MORE than one ingress concurrently (Tailscale Ingress with mixed
18578
- * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
18579
- * the originating provider config (mode + sourcePort) so the
18580
- * orchestrator UI can label rows distinctly. Providers that expose only
18581
- * one endpoint just omit `listEndpoints` from their provider impl.
18582
- */
18583
- var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
18584
- /**
18585
- * Stable id within the provider — typically `<mode>-<sourcePort>` so
18586
- * the orchestrator can dedupe across `listEndpoints` polls.
18587
- */
18588
- id: string(),
18589
- /** Operator-facing label (mirrors `MeshEndpoint.label`). */
18590
- label: string(),
18591
- /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
18592
- mode: string().optional(),
18593
- /** Originating local port the ingress fronts (informational). */
18594
- sourcePort: number().optional()
19106
+ var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
19107
+ var ProfileRefInputSchema = object({
19108
+ addonId: string(),
19109
+ profileId: string()
18595
19110
  });
18596
- method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
18597
- /**
18598
- * notification-output — canonical, capability-gated notification delivery.
18599
- *
18600
- * Apprise-derived model (see
18601
- * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
18602
- * callers emit ONE canonical `Notification`; each provider declares a
18603
- * per-kind capability descriptor (`TargetKind`), and the pure degrade
18604
- * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
18605
- * message to what the kind supports — callers never special-case a service.
18606
- *
18607
- * DESIGN DECISIONS (locked):
18608
- * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
18609
- * `setTargetEnabled`), each provider persisting via the `settings-store`
18610
- * cap. Rationale: the admin UI needs one uniform surface across the
18611
- * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
18612
- * alternative would fork the UI per addon and cannot host the
18613
- * discovery→adopt flow.
18614
- * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
18615
- * the generated cap-mount auto-`concatCollection`-fans them across every
18616
- * registered provider (notifiers addon + HA addon) so one catalog is
18617
- * routable. `send` / `testTarget` / CRUD route to ONE provider by the
18618
- * `addonId` the generated collection router extracts from the call input.
18619
- * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
18620
- * transformer) + UDS MsgPack both round-trip typed arrays — already used by
18621
- * `storage` / `storage-provider` / `recording` caps over the same path. No
18622
- * base64 fallback needed.
18623
- *
18624
- * TODO (deferred, closed-set change — separate decision): add
18625
- * `providerKind: 'notify'` so notification providers surface on the unified
18626
- * admin "Integrations" page.
18627
- */
18628
- /**
18629
- * Zentik-derived typed-media enum — the superset across every kind. Each
18630
- * adapter picks what it supports and the degrade engine filters the rest.
18631
- */
18632
- var AttachmentMediaTypeSchema = _enum([
18633
- "image",
18634
- "video",
18635
- "gif",
18636
- "audio",
18637
- "icon"
19111
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
19112
+ kind: "mutation",
19113
+ auth: "admin"
19114
+ }), method(ProfileRefInputSchema, _void(), {
19115
+ kind: "mutation",
19116
+ auth: "admin"
19117
+ }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
19118
+ kind: "mutation",
19119
+ auth: "admin"
19120
+ }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
19121
+ selector: LlmDefaultSelectorSchema,
19122
+ profileId: string().nullable()
19123
+ }), _void(), {
19124
+ kind: "mutation",
19125
+ auth: "admin"
19126
+ }), method(object({
19127
+ since: number().optional(),
19128
+ until: number().optional(),
19129
+ consumer: string().optional(),
19130
+ profileId: string().optional()
19131
+ }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
19132
+ nodeId: string(),
19133
+ model: ManagedModelRefSchema
19134
+ }), _void(), {
19135
+ kind: "mutation",
19136
+ auth: "admin"
19137
+ }), method(object({
19138
+ nodeId: string(),
19139
+ file: string()
19140
+ }), _void(), {
19141
+ kind: "mutation",
19142
+ auth: "admin"
19143
+ }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
19144
+ kind: "mutation",
19145
+ auth: "admin"
19146
+ }), method(ProfileRefInputSchema, _void(), {
19147
+ kind: "mutation",
19148
+ auth: "admin"
19149
+ });
19150
+ var LogLevelSchema = _enum([
19151
+ "debug",
19152
+ "info",
19153
+ "warn",
19154
+ "error"
18638
19155
  ]);
19156
+ var LogEntrySchema = object({
19157
+ timestamp: date(),
19158
+ level: LogLevelSchema,
19159
+ scope: array(string()),
19160
+ message: string(),
19161
+ meta: record(string(), unknown()).optional(),
19162
+ tags: record(string(), string()).optional()
19163
+ });
19164
+ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
19165
+ scope: array(string()).optional(),
19166
+ level: LogLevelSchema.optional(),
19167
+ since: date().optional(),
19168
+ until: date().optional(),
19169
+ limit: number().optional(),
19170
+ tags: record(string(), string()).optional()
19171
+ }), array(LogEntrySchema).readonly());
18639
19172
  /**
18640
- * A single attachment. Exactly one of `url` (remote source, most adapters
18641
- * prefer this) or `bytes` (inline source; required for Pushover-style
18642
- * bytes-only kinds) MUST be present — the degrade engine expresses a
18643
- * url→bytes fetch as a `needsFetch` directive the adapter executes.
19173
+ * `login-method` collection cap through which auth addons contribute
19174
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
19175
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
19176
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
19177
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
19178
+ * procedure aggregates them for the unauthenticated login page.
19179
+ *
19180
+ * A contribution is a discriminated union on `kind`:
19181
+ *
19182
+ * - `redirect` — a declarative button. The login page renders a generic
19183
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
19184
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
19185
+ * ZERO shell-side JS. A future SSO addon plugs in the same way — the
19186
+ * login page needs NO change.
19187
+ *
19188
+ * - `widget` — a Module-Federation widget the login page mounts (via
19189
+ * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
19190
+ * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
19191
+ * mechanism kept for future use; no shipped addon uses it on the login
19192
+ * page (the passkey ceremony below runs natively in the shell instead).
19193
+ *
19194
+ * - `passkey` — a declarative WebAuthn ceremony the shell renders
19195
+ * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
19196
+ * a remotely-loaded bundle). Carries the addon's effective `rpId` /
19197
+ * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
19198
+ * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
19199
+ * fetching any remote code pre-auth. Contribution stays unconditional —
19200
+ * enrollment state is never leaked pre-auth; visibility is a shell
19201
+ * decision.
19202
+ *
19203
+ * Every contribution carries a `stage`:
19204
+ * - `primary` — shown on the first credentials screen (OIDC /
19205
+ * magic-link buttons; a future usernameless passkey).
19206
+ * - `second-factor` — shown AFTER the password leg, gated on the
19207
+ * returned `factors` (passkey-as-2FA today).
19208
+ *
19209
+ * `mount: skip` — the cap is read server-side by the core auth router
19210
+ * (`registry.getCollection('login-method')`), never mounted as its own
19211
+ * tRPC router.
18644
19212
  */
18645
- var AttachmentSchema = object({
18646
- mediaType: AttachmentMediaTypeSchema,
18647
- url: string().optional(),
18648
- bytes: _instanceof(Uint8Array).optional(),
18649
- mime: string().optional(),
18650
- name: string().optional()
18651
- }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
18652
- var NotificationFormatSchema = _enum([
18653
- "text",
18654
- "markdown",
18655
- "html"
19213
+ /** When a login method renders in the two-phase login flow. */
19214
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
19215
+ /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
19216
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [
19217
+ object({
19218
+ kind: literal("redirect"),
19219
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
19220
+ id: string(),
19221
+ /** Operator-facing button label. */
19222
+ label: string(),
19223
+ /** lucide-react icon name. */
19224
+ icon: string().optional(),
19225
+ /** Addon-owned HTTP route the button navigates to (GET). */
19226
+ startUrl: string(),
19227
+ stage: LoginStageEnum
19228
+ }),
19229
+ object({
19230
+ kind: literal("widget"),
19231
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
19232
+ id: string(),
19233
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
19234
+ addonId: string(),
19235
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
19236
+ bundle: string(),
19237
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
19238
+ remote: WidgetRemoteSchema,
19239
+ stage: LoginStageEnum
19240
+ }),
19241
+ object({
19242
+ kind: literal("passkey"),
19243
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
19244
+ id: string(),
19245
+ /** Operator-facing button label. */
19246
+ label: string(),
19247
+ stage: LoginStageEnum,
19248
+ /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
19249
+ rpId: string(),
19250
+ /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
19251
+ origin: string().nullable()
19252
+ })
18656
19253
  ]);
18657
- /** A single tap-through action button. */
18658
- var NotificationActionSchema = object({
18659
- id: string(),
18660
- label: string(),
18661
- url: string().optional()
19254
+ method(_void(), array(LoginMethodContributionSchema).readonly());
19255
+ var CpuBreakdownSchema = object({
19256
+ total: number(),
19257
+ user: number(),
19258
+ system: number(),
19259
+ irq: number(),
19260
+ nice: number(),
19261
+ loadAvg: tuple([
19262
+ number(),
19263
+ number(),
19264
+ number()
19265
+ ]),
19266
+ cores: number()
18662
19267
  });
18663
- /**
18664
- * The canonical notification. `body` is the only hard field (Apprise model).
18665
- * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
18666
- * NOT a fixed severity enum — each kind declares its own `caps.levels` and
18667
- * the adapter maps this ordinal onto its native level. `level?` is an
18668
- * optional kind-native level id (`emergency`, `silent`, …) that overrides
18669
- * `priority` for that one target.
18670
- */
18671
- var NotificationSchema = object({
18672
- body: string(),
18673
- title: string().optional(),
18674
- format: NotificationFormatSchema.default("text"),
18675
- priority: number().int().min(1).max(5).default(3),
18676
- level: string().optional(),
18677
- attachments: array(AttachmentSchema).optional(),
18678
- clickUrl: string().optional(),
18679
- actions: array(NotificationActionSchema).optional(),
18680
- sound: string().optional(),
18681
- ttl: number().optional(),
18682
- tag: string().optional(),
18683
- deviceId: number().optional(),
18684
- eventId: string().optional(),
18685
- metadata: record(string(), unknown()).optional()
19268
+ var MemoryInfoSchema = object({
19269
+ percent: number(),
19270
+ totalBytes: number(),
19271
+ usedBytes: number(),
19272
+ availableBytes: number(),
19273
+ swapUsedBytes: number(),
19274
+ swapTotalBytes: number()
19275
+ });
19276
+ var DiskIoSnapshotSchema = object({
19277
+ readBytes: number(),
19278
+ writeBytes: number(),
19279
+ readOps: number(),
19280
+ writeOps: number(),
19281
+ timestampMs: number()
19282
+ });
19283
+ var NetworkIoSnapshotSchema = object({
19284
+ rxBytes: number(),
19285
+ txBytes: number(),
19286
+ rxPackets: number(),
19287
+ txPackets: number(),
19288
+ rxErrors: number(),
19289
+ txErrors: number(),
19290
+ timestampMs: number()
19291
+ });
19292
+ var MetricsGpuInfoSchema = object({
19293
+ utilization: number(),
19294
+ model: string(),
19295
+ memoryUsedBytes: number(),
19296
+ memoryTotalBytes: number(),
19297
+ temperature: number().nullable()
19298
+ });
19299
+ var ProcessResourceInfoSchema = object({
19300
+ openFds: number(),
19301
+ threadCount: number(),
19302
+ activeHandles: number(),
19303
+ activeRequests: number()
18686
19304
  });
18687
- /** One declared native severity/priority level for a kind. */
18688
- var TargetKindLevelSchema = object({
18689
- id: string(),
18690
- label: string(),
18691
- /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
18692
- ordinal: number().int().min(1).max(5).nullable(),
18693
- flags: object({
18694
- critical: boolean().optional(),
18695
- silent: boolean().optional(),
18696
- noPush: boolean().optional()
18697
- }).optional(),
18698
- /** e.g. Pushover `emergency` requires `retry` / `expire`. */
18699
- requires: array(string()).optional(),
18700
- description: string().optional()
19305
+ var PressureAvgsSchema = object({
19306
+ avg10: number(),
19307
+ avg60: number(),
19308
+ avg300: number()
18701
19309
  });
18702
- /** The full capability block consulted before dispatch. */
18703
- var TargetKindCapsSchema = object({
18704
- attachments: object({
18705
- mediaTypes: array(AttachmentMediaTypeSchema),
18706
- mode: _enum([
18707
- "url",
18708
- "bytes",
18709
- "both"
18710
- ]),
18711
- max: number().int().nonnegative(),
18712
- maxBytes: number().int().positive().optional()
19310
+ var PressureInfoSchema = object({
19311
+ some: PressureAvgsSchema,
19312
+ full: PressureAvgsSchema.nullable()
19313
+ });
19314
+ var SystemResourceSnapshotSchema = object({
19315
+ cpu: CpuBreakdownSchema,
19316
+ memory: MemoryInfoSchema,
19317
+ gpu: MetricsGpuInfoSchema.nullable(),
19318
+ network: NetworkIoSnapshotSchema,
19319
+ disk: DiskIoSnapshotSchema,
19320
+ pressure: object({
19321
+ cpu: PressureInfoSchema.nullable(),
19322
+ memory: PressureInfoSchema.nullable(),
19323
+ io: PressureInfoSchema.nullable()
18713
19324
  }),
18714
- /** Max action buttons (0 = none). */
18715
- actions: number().int().nonnegative(),
18716
- levels: array(TargetKindLevelSchema),
18717
- format: array(NotificationFormatSchema),
18718
- clickUrl: boolean(),
18719
- sound: boolean(),
18720
- ttl: boolean(),
18721
- bodyMaxLen: number().int().positive()
19325
+ process: ProcessResourceInfoSchema,
19326
+ cpuTemperature: number().nullable(),
19327
+ timestampMs: number()
18722
19328
  });
18723
- /**
18724
- * `configSchema` is a `ConfigUISchema` tree passed through to the admin
18725
- * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
18726
- * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`)
18727
- * the union is large and not meant for runtime validation here; the exported
18728
- * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
18729
- */
18730
- var ConfigSchemaPassthrough$1 = unknown();
18731
- var TargetKindSchema = object({
18732
- kind: string(),
18733
- label: string(),
18734
- icon: string(),
18735
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
18736
- addonId: string(),
18737
- configSchema: ConfigSchemaPassthrough$1,
18738
- supportsDiscovery: boolean(),
18739
- caps: TargetKindCapsSchema
19329
+ var DiskSpaceInfoSchema = object({
19330
+ path: string(),
19331
+ totalBytes: number(),
19332
+ usedBytes: number(),
19333
+ availableBytes: number(),
19334
+ percent: number()
18740
19335
  });
18741
- /**
18742
- * A persisted target. `config` holds secrets; providers REDACT secret fields
18743
- * (return a presence marker only) when serving `listTargets` — never
18744
- * round-trip a stored secret to the UI.
18745
- */
18746
- var TargetSchema = object({
18747
- id: string(),
18748
- name: string(),
18749
- kind: string(),
19336
+ var PidResourceStatsSchema = object({
19337
+ pid: number(),
19338
+ cpu: number(),
19339
+ memory: number(),
19340
+ /**
19341
+ * Private (anonymous) resident bytes — the per-process V8 heap + native
19342
+ * allocations NOT shared with other processes (Linux RssAnon). This is the
19343
+ * "real" per-runner cost; summing it across runners is meaningful, unlike
19344
+ * `memory` (RSS), which double-counts the shared mmap'd framework code.
19345
+ * Undefined where /proc is unavailable (e.g. macOS).
19346
+ */
19347
+ privateBytes: number().optional(),
19348
+ /**
19349
+ * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
19350
+ * code shared copy-on-write across runners. Undefined on macOS.
19351
+ */
19352
+ sharedBytes: number().optional()
19353
+ });
19354
+ var AddonInstanceSchema = object({
18750
19355
  addonId: string(),
18751
- enabled: boolean(),
18752
- config: record(string(), unknown())
19356
+ nodeId: string(),
19357
+ role: _enum(["hub", "worker"]),
19358
+ pid: number(),
19359
+ state: _enum([
19360
+ "starting",
19361
+ "running",
19362
+ "stopping",
19363
+ "stopped",
19364
+ "crashed"
19365
+ ]),
19366
+ uptimeSec: number()
18753
19367
  });
18754
- /** A discovery-surfaced candidate (config is partial + non-secret). */
18755
- var DiscoveredTargetSchema = object({
18756
- kind: string(),
18757
- suggestedName: string(),
18758
- config: record(string(), unknown())
19368
+ var NodeProcessSchema = object({
19369
+ pid: number(),
19370
+ ppid: number(),
19371
+ pgid: number(),
19372
+ classification: _enum([
19373
+ "root",
19374
+ "managed",
19375
+ "system",
19376
+ "ghost"
19377
+ ]),
19378
+ /** `$process` addon binding when `managed`, else null. */
19379
+ addonId: string().nullable(),
19380
+ /** Kernel-reported nodeId when the process is a known agent/worker. */
19381
+ nodeId: string().nullable(),
19382
+ /** Truncated command line. */
19383
+ command: string(),
19384
+ cpuPercent: number(),
19385
+ memoryRssBytes: number(),
19386
+ /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
19387
+ uptimeSec: number(),
19388
+ /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
19389
+ orphaned: boolean()
18759
19390
  });
18760
- /** The degrade engine's report — what was resolved / dropped / degraded. */
18761
- var RenderedAsSchema = object({
18762
- level: string(),
18763
- format: NotificationFormatSchema,
18764
- attachmentsSent: number().int().nonnegative(),
18765
- actionsSent: number().int().nonnegative(),
18766
- truncated: boolean(),
18767
- dropped: array(string())
19391
+ var KillProcessInputSchema = object({
19392
+ pid: number(),
19393
+ /** Force = SIGKILL. Default is SIGTERM. */
19394
+ force: boolean().optional()
18768
19395
  });
18769
- var SendResultSchema = object({
19396
+ var KillProcessResultSchema = object({
19397
+ success: boolean(),
19398
+ reason: string().optional(),
19399
+ signal: _enum(["SIGTERM", "SIGKILL"]).optional()
19400
+ });
19401
+ var DumpHeapSnapshotInputSchema = object({
19402
+ /** The addon whose runner should dump a heap snapshot. */
19403
+ addonId: string() });
19404
+ var DumpHeapSnapshotResultSchema = object({
18770
19405
  success: boolean(),
19406
+ /** Path of the written .heapsnapshot inside the runner's container/host. */
19407
+ path: string().optional(),
19408
+ /** Process pid that was signalled. */
19409
+ pid: number().optional(),
19410
+ reason: string().optional()
19411
+ });
19412
+ var SystemMetricsSchema = object({
19413
+ cpuPercent: number(),
19414
+ memoryPercent: number(),
19415
+ memoryUsedMB: number(),
19416
+ memoryTotalMB: number(),
19417
+ diskPercent: number().optional(),
19418
+ temperature: number().optional(),
19419
+ gpuPercent: number().optional(),
19420
+ gpuMemoryPercent: number().optional()
19421
+ });
19422
+ 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, {
19423
+ kind: "mutation",
19424
+ auth: "admin"
19425
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
19426
+ kind: "mutation",
19427
+ auth: "admin"
19428
+ });
19429
+ method(object({
19430
+ sourceUrl: string(),
19431
+ metadata: ModelConvertMetadataSchema,
19432
+ targets: array(ConvertTargetSchema).min(1).readonly(),
19433
+ calibrationRef: string().optional(),
19434
+ sessionId: string().optional()
19435
+ }), ConvertResultSchema, {
19436
+ kind: "mutation",
19437
+ auth: "admin",
19438
+ timeoutMs: 6e5
19439
+ });
19440
+ method(object({
19441
+ nodeId: string(),
19442
+ modelId: string(),
19443
+ format: _enum(MODEL_FORMATS),
19444
+ entry: ModelCatalogEntrySchema
19445
+ }), object({
19446
+ ok: boolean(),
19447
+ /** sha256 of the staged tarball (empty for a hub-local no-op). */
19448
+ sha256: string(),
19449
+ bytes: number(),
19450
+ /** The target node's modelsDir the artifact landed in. */
19451
+ path: string()
19452
+ }), {
19453
+ kind: "mutation",
19454
+ auth: "admin"
19455
+ });
19456
+ /**
19457
+ * `mqtt-broker` — broker-registry cap.
19458
+ *
19459
+ * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
19460
+ * MQTT brokers (external + optionally an embedded `aedes`-backed one)
19461
+ * and (b) the connection details a consumer addon needs to spin up
19462
+ * its OWN `mqtt.js` client.
19463
+ *
19464
+ * Why: pub/sub routing over the system event-bus loses fidelity
19465
+ * (callback shape, QoS guarantees, will/retain semantics) and adds
19466
+ * refcount bookkeeping that addons would rather own themselves. The
19467
+ * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
19468
+ * features anyway — give it the connection config, get out of the way.
19469
+ *
19470
+ * Consumer flow:
19471
+ * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
19472
+ * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
19473
+ * client.subscribe('zigbee2mqtt/+')
19474
+ *
19475
+ * Collection mode: multiple brokers (e.g. one local mosquitto + one
19476
+ * cloud bridge). The "embedded" entry (when present) is just another
19477
+ * broker in the registry — its lifecycle is owned by the addon that
19478
+ * spawned it.
19479
+ */
19480
+ var BrokerKindSchema = _enum(["external", "embedded"]);
19481
+ /**
19482
+ * Broker live-probe status.
19483
+ *
19484
+ * - `connected` — last probe completed a clean CONNACK
19485
+ * - `disconnected` — no probe has run yet (cold cache)
19486
+ * - `auth-failed` — CONNACK refused with auth error (RC 4 / 5)
19487
+ * - `unreachable` — TCP connect timed out / refused
19488
+ * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
19489
+ */
19490
+ var BrokerStatusSchema$1 = _enum([
19491
+ "connected",
19492
+ "disconnected",
19493
+ "auth-failed",
19494
+ "unreachable",
19495
+ "tls-error"
19496
+ ]);
19497
+ var BrokerInfoSchema = object({
19498
+ id: string(),
19499
+ name: string(),
19500
+ url: string(),
19501
+ kind: BrokerKindSchema,
19502
+ status: BrokerStatusSchema$1,
19503
+ latencyMs: number().nullable(),
18771
19504
  error: string().optional(),
18772
- renderedAs: RenderedAsSchema.optional()
19505
+ /** Embedded brokers only: number of MQTT clients currently connected. */
19506
+ connectedClients: number().int().nonnegative().optional(),
19507
+ /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
19508
+ lastCheckedAt: number().optional()
18773
19509
  });
18774
- /** Same shape as SendResult — kept as a distinct name for the test panel. */
18775
- var TestResultSchema = SendResultSchema;
18776
- method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
18777
- kind: string(),
18778
- config: record(string(), unknown()).optional()
18779
- }), array(DiscoveredTargetSchema)), method(object({
18780
- targetId: string(),
18781
- notification: NotificationSchema
18782
- }), SendResultSchema, { kind: "mutation" }), method(object({
18783
- targetId: string(),
18784
- sample: NotificationSchema.optional()
18785
- }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
18786
- targetId: string(),
18787
- enabled: boolean()
18788
- }), _void(), { kind: "mutation" });
18789
19510
  /**
18790
- * Shared LLM generate contracts imported by BOTH `llm.cap.ts` (consumer
18791
- * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
18792
- * caps stay wire-compatible without a circular cap→cap import.
18793
- *
18794
- * Errors are a discriminated-union RESULT, never thrown: the shape survives
18795
- * every transport tier structurally, and failed calls still write usage rows.
18796
- * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
19511
+ * Connection details what a consumer needs to call
19512
+ * `mqtt.connect(url, options)`. We split URL + credentials so the
19513
+ * consumer can pass them as `mqtt.connect(url, { username, password })`
19514
+ * instead of stuffing creds into the URL (which leaks them into logs).
18797
19515
  */
18798
- var LlmUsageSchema = object({
18799
- inputTokens: number(),
18800
- outputTokens: number()
19516
+ var BrokerConnectionDetailsSchema = object({
19517
+ url: string(),
19518
+ username: string().optional(),
19519
+ password: string().optional(),
19520
+ /**
19521
+ * Suggested prefix for `clientId`. Each consumer should suffix this
19522
+ * with its own discriminator (addon id, instance id) so reconnects
19523
+ * don't kick each other off (MQTT spec: clientId must be unique per
19524
+ * broker).
19525
+ */
19526
+ clientIdPrefix: string().optional()
18801
19527
  });
18802
- var LlmErrorCodeSchema = _enum([
18803
- "timeout",
18804
- "rate-limited",
18805
- "auth",
18806
- "refusal",
18807
- "bad-request",
18808
- "unavailable",
18809
- "no-profile",
18810
- "budget-exceeded",
18811
- "adapter-error"
18812
- ]);
18813
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
19528
+ var AddBrokerInputSchema = object({
19529
+ name: string().min(1),
19530
+ url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
19531
+ username: string().optional(),
19532
+ password: string().optional(),
19533
+ clientIdPrefix: string().optional()
19534
+ });
19535
+ var AddBrokerResultSchema = object({ id: string() });
19536
+ var IdInputSchema = object({ id: string() });
19537
+ var TestResultSchema$1 = discriminatedUnion("ok", [object({
18814
19538
  ok: literal(true),
18815
- text: string(),
18816
- model: string(),
18817
- usage: LlmUsageSchema,
18818
- truncated: boolean(),
18819
19539
  latencyMs: number()
18820
19540
  }), object({
18821
19541
  ok: literal(false),
18822
- code: LlmErrorCodeSchema,
18823
- message: string(),
18824
- retryAfterMs: number().optional()
19542
+ error: string()
18825
19543
  })]);
18826
- /**
18827
- * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
18828
- * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
18829
- * notification-output.cap.ts:27-31 precedents).
18830
- */
18831
- var LlmImageSchema = object({
18832
- bytes: _instanceof(Uint8Array),
18833
- mimeType: string()
19544
+ var StartEmbeddedInputSchema = object({
19545
+ port: number().int().min(1).max(65535).default(1883),
19546
+ /** Allow anonymous connect (no username/password). Default: false. */
19547
+ allowAnonymous: boolean().default(false),
19548
+ /** Optional shared username/password for clients. */
19549
+ username: string().optional(),
19550
+ password: string().optional()
18834
19551
  });
18835
- var LlmGenerateBaseInputSchema = object({
18836
- /** Collection routing (the notification-output posture). */
18837
- addonId: string().optional(),
18838
- /** Explicit profile; else the resolution chain (spec §3). */
18839
- profileId: string().optional(),
18840
- /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
18841
- consumer: string(),
18842
- system: string().optional(),
18843
- /** v1: single-turn. `messages[]` is a v2 additive field. */
18844
- prompt: string(),
18845
- /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
18846
- jsonSchema: record(string(), unknown()).optional(),
18847
- /** Per-call override of the profile default. */
18848
- maxTokens: number().int().positive().optional(),
18849
- temperature: number().optional()
19552
+ var StartEmbeddedResultSchema = object({
19553
+ id: string(),
19554
+ url: string()
18850
19555
  });
18851
- /**
18852
- * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
18853
- * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
18854
- * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
18855
- * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
18856
- * this only through the `llm` cap's methods.
18857
- *
18858
- * One running llama-server child per node in v1 (models are RAM-heavy).
18859
- * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
18860
- * watchdog — operator decision #3).
18861
- */
18862
- var ManagedModelRefSchema = discriminatedUnion("kind", [
18863
- object({
18864
- kind: literal("catalog"),
18865
- catalogId: string()
18866
- }),
18867
- object({
18868
- kind: literal("url"),
18869
- url: string(),
18870
- sha256: string().optional()
18871
- }),
18872
- object({
18873
- kind: literal("path"),
18874
- path: string()
18875
- })
18876
- ]);
18877
- var ManagedRuntimeConfigSchema = object({
18878
- /** WHERE the runtime lives — hub or any agent. */
18879
- nodeId: string(),
18880
- /** Closed for v1; 'ollama' is a v2 candidate. */
18881
- engine: _enum(["llama-cpp"]),
18882
- model: ManagedModelRefSchema,
18883
- contextSize: number().int().default(4096),
18884
- /** 0 = CPU-only. */
18885
- gpuLayers: number().int().default(0),
18886
- /** Default: cpus-2, clamped ≥1 (resolved node-side). */
18887
- threads: number().int().optional(),
18888
- /** Concurrent slots. */
18889
- parallel: number().int().default(1),
18890
- /** Else lazy: first generate boots it. */
18891
- autoStart: boolean().default(false),
18892
- /** 0 = never; frees RAM after quiet periods. */
18893
- idleStopMinutes: number().int().default(30)
19556
+ var StatusSchema = object({
19557
+ brokerCount: number(),
19558
+ embeddedRunning: boolean()
18894
19559
  });
18895
- var LlmRuntimeStatusSchema = object({
18896
- /** Status is ALWAYS node-qualified. */
18897
- nodeId: string(),
18898
- state: _enum([
18899
- "stopped",
18900
- "downloading",
18901
- "starting",
18902
- "ready",
18903
- "crashed",
18904
- "failed"
18905
- ]),
18906
- pid: number().optional(),
18907
- port: number().optional(),
18908
- modelPath: string().optional(),
18909
- modelId: string().optional(),
18910
- downloadProgress: number().min(0).max(1).optional(),
18911
- lastError: string().optional(),
18912
- crashesInWindow: number(),
18913
- /** Child RSS (sampled best-effort). */
18914
- memoryBytes: number().optional(),
18915
- vramBytes: number().optional()
19560
+ 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);
19561
+ var NetworkEndpointSchema = object({
19562
+ url: string(),
19563
+ hostname: string(),
19564
+ port: number(),
19565
+ protocol: _enum(["http", "https"])
18916
19566
  });
18917
- var LlmNodeModelSchema = object({
18918
- file: string(),
18919
- sizeBytes: number(),
18920
- catalogId: string().optional(),
18921
- installedAt: number().optional()
19567
+ var NetworkAccessStatusSchema = object({
19568
+ connected: boolean(),
19569
+ endpoint: NetworkEndpointSchema.nullable(),
19570
+ error: string().optional()
18922
19571
  });
18923
- var LlmRuntimeDiskUsageSchema = object({
18924
- nodeId: string(),
18925
- modelsBytes: number(),
18926
- freeBytes: number().optional()
19572
+ /**
19573
+ * Optional, richer endpoint shape returned by providers that expose
19574
+ * MORE than one ingress concurrently (Tailscale Ingress with mixed
19575
+ * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
19576
+ * the originating provider config (mode + sourcePort) so the
19577
+ * orchestrator UI can label rows distinctly. Providers that expose only
19578
+ * one endpoint just omit `listEndpoints` from their provider impl.
19579
+ */
19580
+ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
19581
+ /**
19582
+ * Stable id within the provider — typically `<mode>-<sourcePort>` so
19583
+ * the orchestrator can dedupe across `listEndpoints` polls.
19584
+ */
19585
+ id: string(),
19586
+ /** Operator-facing label (mirrors `MeshEndpoint.label`). */
19587
+ label: string(),
19588
+ /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
19589
+ mode: string().optional(),
19590
+ /** Originating local port the ingress fronts (informational). */
19591
+ sourcePort: number().optional()
18927
19592
  });
18928
- method(LlmGenerateBaseInputSchema.extend({
18929
- images: array(LlmImageSchema).optional(),
18930
- runtime: ManagedRuntimeConfigSchema,
18931
- /** The managed profile's timeout, threaded by the hub provider. */
18932
- timeoutMs: number().int().positive().optional()
18933
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
18934
- kind: "mutation",
18935
- auth: "admin"
18936
- }), method(object({}), _void(), {
18937
- kind: "mutation",
18938
- auth: "admin"
18939
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
18940
- kind: "mutation",
18941
- auth: "admin"
18942
- }), method(object({ file: string() }), _void(), {
18943
- kind: "mutation",
18944
- auth: "admin"
18945
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
19593
+ method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
18946
19594
  /**
18947
- * `llm`consumer-facing LLM surface (spec §1-§3). Collection-mode: array
18948
- * methods concat-fan across providers; single-row methods route to ONE
18949
- * provider by the `addonId` in the call input (the notification-output
18950
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
18951
- * (hub-placed); the cap stays open for future providers.
19595
+ * notification-outputcanonical, capability-gated notification delivery.
19596
+ *
19597
+ * Apprise-derived model (see
19598
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
19599
+ * callers emit ONE canonical `Notification`; each provider declares a
19600
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
19601
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
19602
+ * message to what the kind supports — callers never special-case a service.
19603
+ *
19604
+ * DESIGN DECISIONS (locked):
19605
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
19606
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
19607
+ * cap. Rationale: the admin UI needs one uniform surface across the
19608
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
19609
+ * alternative would fork the UI per addon and cannot host the
19610
+ * discovery→adopt flow.
19611
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
19612
+ * the generated cap-mount auto-`concatCollection`-fans them across every
19613
+ * registered provider (notifiers addon + HA addon) so one catalog is
19614
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
19615
+ * `addonId` the generated collection router extracts from the call input.
19616
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
19617
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
19618
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
19619
+ * base64 fallback needed.
18952
19620
  *
18953
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
18954
- * `apiKey` is a password field — providers REDACT it on read and merge on
18955
- * write; a stored key NEVER round-trips to a client.
19621
+ * TODO (deferred, closed-set change separate decision): add
19622
+ * `providerKind: 'notify'` so notification providers surface on the unified
19623
+ * admin "Integrations" page.
18956
19624
  */
18957
- var LlmProfileKindSchema = _enum([
18958
- "openai-compatible",
18959
- "openai",
18960
- "anthropic",
18961
- "google",
18962
- "managed-local"
19625
+ /**
19626
+ * Zentik-derived typed-media enum — the superset across every kind. Each
19627
+ * adapter picks what it supports and the degrade engine filters the rest.
19628
+ */
19629
+ var AttachmentMediaTypeSchema = _enum([
19630
+ "image",
19631
+ "video",
19632
+ "gif",
19633
+ "audio",
19634
+ "icon"
18963
19635
  ]);
18964
- var LlmProfileSchema = object({
19636
+ /**
19637
+ * A single attachment. Exactly one of `url` (remote source, most adapters
19638
+ * prefer this) or `bytes` (inline source; required for Pushover-style
19639
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
19640
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
19641
+ */
19642
+ var AttachmentSchema = object({
19643
+ mediaType: AttachmentMediaTypeSchema,
19644
+ url: string().optional(),
19645
+ bytes: _instanceof(Uint8Array).optional(),
19646
+ mime: string().optional(),
19647
+ name: string().optional()
19648
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
19649
+ var NotificationFormatSchema = _enum([
19650
+ "text",
19651
+ "markdown",
19652
+ "html"
19653
+ ]);
19654
+ /** A single tap-through action button. */
19655
+ var NotificationActionSchema = object({
18965
19656
  id: string(),
18966
- name: string(),
18967
- kind: LlmProfileKindSchema,
18968
- /** Stamped by the provider — keeps the fanned catalog routable. */
18969
- addonId: string(),
18970
- enabled: boolean(),
18971
- /** Vendor model id, or the managed runtime's loaded model. */
18972
- model: string(),
18973
- /** Required for openai-compatible; override for cloud kinds. */
18974
- baseUrl: string().optional(),
18975
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
18976
- apiKey: string().optional(),
18977
- supportsVision: boolean(),
18978
- temperature: number().min(0).max(2).optional(),
18979
- maxTokens: number().int().positive().optional(),
18980
- timeoutMs: number().int().positive().default(6e4),
18981
- extraHeaders: record(string(), string()).optional(),
18982
- /** kind === 'managed-local' only (spec §4). */
18983
- runtime: ManagedRuntimeConfigSchema.optional()
19657
+ label: string(),
19658
+ url: string().optional()
18984
19659
  });
18985
- /** ConfigUISchema tree passed through untyped on the wire (the
18986
- * notification-output `ConfigSchemaPassthrough` precedent at
18987
- * notification-output.cap.ts:151); the exported TS type re-tightens it. */
19660
+ /**
19661
+ * The canonical notification. `body` is the only hard field (Apprise model).
19662
+ * `priority` is a 5-level ORDINAL (1=lowest 3=normal(default) 5=urgent),
19663
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
19664
+ * the adapter maps this ordinal onto its native level. `level?` is an
19665
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
19666
+ * `priority` for that one target.
19667
+ */
19668
+ var NotificationSchema = object({
19669
+ body: string(),
19670
+ title: string().optional(),
19671
+ format: NotificationFormatSchema.default("text"),
19672
+ priority: number().int().min(1).max(5).default(3),
19673
+ level: string().optional(),
19674
+ attachments: array(AttachmentSchema).optional(),
19675
+ clickUrl: string().optional(),
19676
+ actions: array(NotificationActionSchema).optional(),
19677
+ sound: string().optional(),
19678
+ ttl: number().optional(),
19679
+ tag: string().optional(),
19680
+ deviceId: number().optional(),
19681
+ eventId: string().optional(),
19682
+ metadata: record(string(), unknown()).optional()
19683
+ });
19684
+ /** One declared native severity/priority level for a kind. */
19685
+ var TargetKindLevelSchema = object({
19686
+ id: string(),
19687
+ label: string(),
19688
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
19689
+ ordinal: number().int().min(1).max(5).nullable(),
19690
+ flags: object({
19691
+ critical: boolean().optional(),
19692
+ silent: boolean().optional(),
19693
+ noPush: boolean().optional()
19694
+ }).optional(),
19695
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
19696
+ requires: array(string()).optional(),
19697
+ description: string().optional()
19698
+ });
19699
+ /** The full capability block consulted before dispatch. */
19700
+ var TargetKindCapsSchema = object({
19701
+ attachments: object({
19702
+ mediaTypes: array(AttachmentMediaTypeSchema),
19703
+ mode: _enum([
19704
+ "url",
19705
+ "bytes",
19706
+ "both"
19707
+ ]),
19708
+ max: number().int().nonnegative(),
19709
+ maxBytes: number().int().positive().optional()
19710
+ }),
19711
+ /** Max action buttons (0 = none). */
19712
+ actions: number().int().nonnegative(),
19713
+ levels: array(TargetKindLevelSchema),
19714
+ format: array(NotificationFormatSchema),
19715
+ clickUrl: boolean(),
19716
+ sound: boolean(),
19717
+ ttl: boolean(),
19718
+ bodyMaxLen: number().int().positive()
19719
+ });
19720
+ /**
19721
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
19722
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
19723
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
19724
+ * the union is large and not meant for runtime validation here; the exported
19725
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
19726
+ */
18988
19727
  var ConfigSchemaPassthrough = unknown();
18989
- var LlmProfileKindDescriptorSchema = object({
18990
- kind: LlmProfileKindSchema,
19728
+ var TargetKindSchema = object({
19729
+ kind: string(),
18991
19730
  label: string(),
18992
19731
  icon: string(),
18993
19732
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
18994
19733
  addonId: string(),
18995
- configSchema: ConfigSchemaPassthrough
18996
- });
18997
- var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
18998
- var LlmDefaultSchema = object({
18999
- selector: LlmDefaultSelectorSchema,
19000
- profileId: string()
19001
- });
19002
- /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
19003
- var LlmUsageRollupSchema = object({
19004
- day: string(),
19005
- consumer: string(),
19006
- profileId: string(),
19007
- calls: number(),
19008
- okCalls: number(),
19009
- errorCalls: number(),
19010
- inputTokens: number(),
19011
- outputTokens: number(),
19012
- avgLatencyMs: number()
19734
+ configSchema: ConfigSchemaPassthrough,
19735
+ supportsDiscovery: boolean(),
19736
+ caps: TargetKindCapsSchema
19013
19737
  });
19014
- /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
19015
- var ManagedModelCatalogEntrySchema = object({
19738
+ /**
19739
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
19740
+ * (return a presence marker only) when serving `listTargets` — never
19741
+ * round-trip a stored secret to the UI.
19742
+ */
19743
+ var TargetSchema = object({
19016
19744
  id: string(),
19017
- label: string(),
19018
- family: string(),
19019
- purpose: _enum(["text", "vision"]),
19020
- url: string(),
19021
- sha256: string(),
19022
- sizeBytes: number(),
19023
- quantization: string(),
19024
- /** Load-time guidance shown in the picker. */
19025
- minRamBytes: number(),
19026
- contextSizeDefault: number().int(),
19027
- /** Vision models: companion projector file. */
19028
- mmprojUrl: string().optional()
19029
- });
19030
- var LlmRuntimeNodeSchema = object({
19031
- nodeId: string(),
19032
- reachable: boolean(),
19033
- status: LlmRuntimeStatusSchema.optional(),
19034
- disk: LlmRuntimeDiskUsageSchema.optional(),
19035
- error: string().optional()
19036
- });
19037
- var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
19038
- var ProfileRefInputSchema = object({
19745
+ name: string(),
19746
+ kind: string(),
19039
19747
  addonId: string(),
19040
- profileId: string()
19748
+ enabled: boolean(),
19749
+ config: record(string(), unknown())
19041
19750
  });
19042
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
19043
- kind: "mutation",
19044
- auth: "admin"
19045
- }), method(ProfileRefInputSchema, _void(), {
19046
- kind: "mutation",
19047
- auth: "admin"
19048
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
19049
- kind: "mutation",
19050
- auth: "admin"
19051
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
19052
- selector: LlmDefaultSelectorSchema,
19053
- profileId: string().nullable()
19054
- }), _void(), {
19055
- kind: "mutation",
19056
- auth: "admin"
19057
- }), method(object({
19058
- since: number().optional(),
19059
- until: number().optional(),
19060
- consumer: string().optional(),
19061
- profileId: string().optional()
19062
- }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
19063
- nodeId: string(),
19064
- model: ManagedModelRefSchema
19065
- }), _void(), {
19066
- kind: "mutation",
19067
- auth: "admin"
19068
- }), method(object({
19069
- nodeId: string(),
19070
- file: string()
19071
- }), _void(), {
19072
- kind: "mutation",
19073
- auth: "admin"
19074
- }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
19075
- kind: "mutation",
19076
- auth: "admin"
19077
- }), method(ProfileRefInputSchema, _void(), {
19078
- kind: "mutation",
19079
- auth: "admin"
19751
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
19752
+ var DiscoveredTargetSchema = object({
19753
+ kind: string(),
19754
+ suggestedName: string(),
19755
+ config: record(string(), unknown())
19756
+ });
19757
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
19758
+ var RenderedAsSchema = object({
19759
+ level: string(),
19760
+ format: NotificationFormatSchema,
19761
+ attachmentsSent: number().int().nonnegative(),
19762
+ actionsSent: number().int().nonnegative(),
19763
+ truncated: boolean(),
19764
+ dropped: array(string())
19765
+ });
19766
+ var SendResultSchema = object({
19767
+ success: boolean(),
19768
+ error: string().optional(),
19769
+ renderedAs: RenderedAsSchema.optional()
19080
19770
  });
19771
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
19772
+ var TestResultSchema = SendResultSchema;
19773
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
19774
+ kind: string(),
19775
+ config: record(string(), unknown()).optional()
19776
+ }), array(DiscoveredTargetSchema)), method(object({
19777
+ targetId: string(),
19778
+ notification: NotificationSchema
19779
+ }), SendResultSchema, { kind: "mutation" }), method(object({
19780
+ targetId: string(),
19781
+ sample: NotificationSchema.optional()
19782
+ }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
19783
+ targetId: string(),
19784
+ enabled: boolean()
19785
+ }), _void(), { kind: "mutation" });
19081
19786
  /**
19082
19787
  * Zod schemas for persisted record types.
19083
19788
  *
@@ -19763,7 +20468,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19763
20468
  }), method(object({
19764
20469
  eventId: string(),
19765
20470
  kind: MediaFileKindEnum.optional()
19766
- }), array(MediaFileSchema).readonly()), method(object({ trackId: string() }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
20471
+ }), array(MediaFileSchema).readonly()), method(object({
20472
+ trackId: string(),
20473
+ kinds: array(MediaFileKindEnum).optional()
20474
+ }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
19767
20475
  deviceId: number(),
19768
20476
  timestamp: number(),
19769
20477
  frameWidth: number(),
@@ -19784,76 +20492,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19784
20492
  eventId: string(),
19785
20493
  timestamp: number()
19786
20494
  });
19787
- /**
19788
- * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
19789
- * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
19790
- * caps into per-camera event-kind descriptors.
19791
- *
19792
- * The descriptor DATA (color / iconId / labelKey / parentKind / category)
19793
- * is NOT duplicated here — every entry is derived from the single
19794
- * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
19795
- * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
19796
- * control cap means adding one line here (and a taxonomy entry); the anti-
19797
- * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
19798
- * eventful cap is missing.
19799
- */
19800
- /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
19801
- var LEGACY_ICON = {
19802
- motion: "motion",
19803
- audio: "audio",
19804
- person: "person",
19805
- vehicle: "vehicle",
19806
- animal: "animal",
19807
- package: "package",
19808
- door: "door",
19809
- pir: "pir",
19810
- smoke: "smoke",
19811
- water: "water",
19812
- button: "button",
19813
- generic: "generic",
19814
- gas: "smoke",
19815
- vibration: "generic",
19816
- tamper: "generic",
19817
- presence: "person",
19818
- lock: "generic",
19819
- siren: "generic",
19820
- switch: "generic",
19821
- doorbell: "button"
19822
- };
19823
- function legacyIcon(iconId) {
19824
- return LEGACY_ICON[iconId] ?? "generic";
19825
- }
19826
- /**
19827
- * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
19828
- * The anti-drift guard cross-checks this against the eventful caps declared
19829
- * in `packages/types/src/capabilities/*.cap.ts`.
19830
- */
19831
- var CAP_TO_KIND = {
19832
- contact: "contact",
19833
- motion: "motion-sensor",
19834
- smoke: "smoke",
19835
- flood: "flood",
19836
- gas: "gas",
19837
- "carbon-monoxide": "carbon-monoxide",
19838
- vibration: "vibration",
19839
- tamper: "tamper",
19840
- presence: "presence",
19841
- "enum-sensor": "enum-sensor",
19842
- "event-emitter": "device-event",
19843
- "lock-control": "lock",
19844
- switch: "switch",
19845
- button: "button",
19846
- doorbell: "doorbell"
19847
- };
19848
- function buildDescriptor(capName, kind) {
19849
- const t = EVENT_TAXONOMY[kind];
19850
- if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
19851
- return {
19852
- ...t,
19853
- icon: legacyIcon(t.iconId)
19854
- };
19855
- }
19856
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
19857
20495
  var CameraPipelineConfigSchema = object({
19858
20496
  engine: PipelineEngineChoiceSchema.optional(),
19859
20497
  steps: array(PipelineStepInputSchema).readonly(),
@@ -20339,6 +20977,76 @@ method(object({
20339
20977
  auth: "admin"
20340
20978
  });
20341
20979
  /**
20980
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
20981
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
20982
+ * caps into per-camera event-kind descriptors.
20983
+ *
20984
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
20985
+ * is NOT duplicated here — every entry is derived from the single
20986
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
20987
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
20988
+ * control cap means adding one line here (and a taxonomy entry); the anti-
20989
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
20990
+ * eventful cap is missing.
20991
+ */
20992
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
20993
+ var LEGACY_ICON = {
20994
+ motion: "motion",
20995
+ audio: "audio",
20996
+ person: "person",
20997
+ vehicle: "vehicle",
20998
+ animal: "animal",
20999
+ package: "package",
21000
+ door: "door",
21001
+ pir: "pir",
21002
+ smoke: "smoke",
21003
+ water: "water",
21004
+ button: "button",
21005
+ generic: "generic",
21006
+ gas: "smoke",
21007
+ vibration: "generic",
21008
+ tamper: "generic",
21009
+ presence: "person",
21010
+ lock: "generic",
21011
+ siren: "generic",
21012
+ switch: "generic",
21013
+ doorbell: "button"
21014
+ };
21015
+ function legacyIcon(iconId) {
21016
+ return LEGACY_ICON[iconId] ?? "generic";
21017
+ }
21018
+ /**
21019
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
21020
+ * The anti-drift guard cross-checks this against the eventful caps declared
21021
+ * in `packages/types/src/capabilities/*.cap.ts`.
21022
+ */
21023
+ var CAP_TO_KIND = {
21024
+ contact: "contact",
21025
+ motion: "motion-sensor",
21026
+ smoke: "smoke",
21027
+ flood: "flood",
21028
+ gas: "gas",
21029
+ "carbon-monoxide": "carbon-monoxide",
21030
+ vibration: "vibration",
21031
+ tamper: "tamper",
21032
+ presence: "presence",
21033
+ "enum-sensor": "enum-sensor",
21034
+ "event-emitter": "device-event",
21035
+ "lock-control": "lock",
21036
+ switch: "switch",
21037
+ button: "button",
21038
+ doorbell: "doorbell"
21039
+ };
21040
+ function buildDescriptor(capName, kind) {
21041
+ const t = EVENT_TAXONOMY[kind];
21042
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
21043
+ return {
21044
+ ...t,
21045
+ icon: legacyIcon(t.iconId)
21046
+ };
21047
+ }
21048
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
21049
+ /**
20342
21050
  * server-management — per-NODE singleton capability for a node's ROOT
20343
21051
  * package lifecycle (runtime-updatable node packages).
20344
21052
  *
@@ -21793,7 +22501,28 @@ var FaceInfoSchema = object({
21793
22501
  * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`). Absent when the
21794
22502
  * track produced no key frame (e.g. native/onboard source) — the UI falls
21795
22503
  * back to the inline `base64` face crop. */
21796
- keyFrameMediaKey: string().optional()
22504
+ keyFrameMediaKey: string().optional(),
22505
+ /** Winning identity-match cosine (0..1) for this face's track, when an
22506
+ * identity was auto-confirmed. Lets the UI surface WHY a face was assigned
22507
+ * (confidence badge / low-confidence audit). Absent on legacy rows and on
22508
+ * faces that were never auto-recognized. */
22509
+ bestMatchScore: number().optional(),
22510
+ /** Native-scale face short side (px) at recognition time, when the runner
22511
+ * measured it. Lets the UI flag low-resolution auto-assignments. Absent on
22512
+ * legacy rows / runners that reported no native measure. */
22513
+ nativeFaceShortSidePx: number().optional(),
22514
+ /** SUGGESTED identity for this face — a plausible-but-not-confident match that
22515
+ * MISSED auto-assignment (cosine in the suggestion band, or above threshold
22516
+ * but blocked only by the recognition size floor). Mutually exclusive with
22517
+ * `recognizedIdentityId` (a suggestion is NEVER an assignment): the face stays
22518
+ * UNASSIGNED and everything else keeps treating it as unrecognized — the UI
22519
+ * merely offers a one-tap "is this <name>?" confirm. Absent on legacy rows and
22520
+ * on faces that were auto-assigned or below the suggestion band. (2026-07-24) */
22521
+ suggestedIdentityId: string().optional(),
22522
+ /** Peak identity-match cosine (0..1) for `suggestedIdentityId`, captured at the
22523
+ * same moment as `bestMatchScore` (track peak, at close). Lets the UI rank /
22524
+ * badge suggestion confidence. Present iff `suggestedIdentityId` is. (2026-07-24) */
22525
+ suggestedMatchScore: number().optional()
21797
22526
  });
21798
22527
  var FaceFilterEnum = _enum([
21799
22528
  "unassigned",
@@ -23836,36 +24565,6 @@ Object.freeze({
23836
24565
  addonId: null,
23837
24566
  access: "view"
23838
24567
  },
23839
- "advancedNotifier.deleteRule": {
23840
- capName: "advanced-notifier",
23841
- capScope: "system",
23842
- addonId: null,
23843
- access: "delete"
23844
- },
23845
- "advancedNotifier.getHistory": {
23846
- capName: "advanced-notifier",
23847
- capScope: "system",
23848
- addonId: null,
23849
- access: "view"
23850
- },
23851
- "advancedNotifier.getRules": {
23852
- capName: "advanced-notifier",
23853
- capScope: "system",
23854
- addonId: null,
23855
- access: "view"
23856
- },
23857
- "advancedNotifier.testRule": {
23858
- capName: "advanced-notifier",
23859
- capScope: "system",
23860
- addonId: null,
23861
- access: "create"
23862
- },
23863
- "advancedNotifier.upsertRule": {
23864
- capName: "advanced-notifier",
23865
- capScope: "system",
23866
- addonId: null,
23867
- access: "create"
23868
- },
23869
24568
  "alarmPanel.arm": {
23870
24569
  capName: "alarm-panel",
23871
24570
  capScope: "device",
@@ -24088,6 +24787,12 @@ Object.freeze({
24088
24787
  addonId: null,
24089
24788
  access: "delete"
24090
24789
  },
24790
+ "backup.deleteSchedule": {
24791
+ capName: "backup",
24792
+ capScope: "system",
24793
+ addonId: null,
24794
+ access: "delete"
24795
+ },
24091
24796
  "backup.getEntries": {
24092
24797
  capName: "backup",
24093
24798
  capScope: "system",
@@ -24118,6 +24823,12 @@ Object.freeze({
24118
24823
  addonId: null,
24119
24824
  access: "view"
24120
24825
  },
24826
+ "backup.listSchedules": {
24827
+ capName: "backup",
24828
+ capScope: "system",
24829
+ addonId: null,
24830
+ access: "view"
24831
+ },
24121
24832
  "backup.previewSchedule": {
24122
24833
  capName: "backup",
24123
24834
  capScope: "system",
@@ -24142,6 +24853,12 @@ Object.freeze({
24142
24853
  addonId: null,
24143
24854
  access: "create"
24144
24855
  },
24856
+ "backup.upsertSchedule": {
24857
+ capName: "backup",
24858
+ capScope: "system",
24859
+ addonId: null,
24860
+ access: "create"
24861
+ },
24145
24862
  "battery.wakeForStream": {
24146
24863
  capName: "battery",
24147
24864
  capScope: "device",
@@ -26170,6 +26887,60 @@ Object.freeze({
26170
26887
  addonId: null,
26171
26888
  access: "create"
26172
26889
  },
26890
+ "notificationRules.createRule": {
26891
+ capName: "notification-rules",
26892
+ capScope: "system",
26893
+ addonId: null,
26894
+ access: "create"
26895
+ },
26896
+ "notificationRules.deleteRule": {
26897
+ capName: "notification-rules",
26898
+ capScope: "system",
26899
+ addonId: null,
26900
+ access: "delete"
26901
+ },
26902
+ "notificationRules.getConditionCatalog": {
26903
+ capName: "notification-rules",
26904
+ capScope: "system",
26905
+ addonId: null,
26906
+ access: "view"
26907
+ },
26908
+ "notificationRules.getHistory": {
26909
+ capName: "notification-rules",
26910
+ capScope: "system",
26911
+ addonId: null,
26912
+ access: "view"
26913
+ },
26914
+ "notificationRules.getRule": {
26915
+ capName: "notification-rules",
26916
+ capScope: "system",
26917
+ addonId: null,
26918
+ access: "view"
26919
+ },
26920
+ "notificationRules.listRules": {
26921
+ capName: "notification-rules",
26922
+ capScope: "system",
26923
+ addonId: null,
26924
+ access: "view"
26925
+ },
26926
+ "notificationRules.setRuleEnabled": {
26927
+ capName: "notification-rules",
26928
+ capScope: "system",
26929
+ addonId: null,
26930
+ access: "create"
26931
+ },
26932
+ "notificationRules.testRule": {
26933
+ capName: "notification-rules",
26934
+ capScope: "system",
26935
+ addonId: null,
26936
+ access: "create"
26937
+ },
26938
+ "notificationRules.updateRule": {
26939
+ capName: "notification-rules",
26940
+ capScope: "system",
26941
+ addonId: null,
26942
+ access: "create"
26943
+ },
26173
26944
  "notifier.cancel": {
26174
26945
  capName: "notifier",
26175
26946
  capScope: "device",
@@ -27922,6 +28693,36 @@ Object.freeze({
27922
28693
  addonId: null,
27923
28694
  access: "create"
27924
28695
  },
28696
+ "terminalSession.close": {
28697
+ capName: "terminal-session",
28698
+ capScope: "system",
28699
+ addonId: null,
28700
+ access: "create"
28701
+ },
28702
+ "terminalSession.listProfiles": {
28703
+ capName: "terminal-session",
28704
+ capScope: "system",
28705
+ addonId: null,
28706
+ access: "view"
28707
+ },
28708
+ "terminalSession.listSessions": {
28709
+ capName: "terminal-session",
28710
+ capScope: "system",
28711
+ addonId: null,
28712
+ access: "view"
28713
+ },
28714
+ "terminalSession.openSession": {
28715
+ capName: "terminal-session",
28716
+ capScope: "system",
28717
+ addonId: null,
28718
+ access: "create"
28719
+ },
28720
+ "terminalSession.resize": {
28721
+ capName: "terminal-session",
28722
+ capScope: "system",
28723
+ addonId: null,
28724
+ access: "create"
28725
+ },
27925
28726
  "toast.onToast": {
27926
28727
  capName: "toast",
27927
28728
  capScope: "system",