@camstack/addon-provider-rademacher 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.js CHANGED
@@ -984,7 +984,7 @@ var Rademacher = class {
984
984
  }
985
985
  };
986
986
  //#endregion
987
- //#region ../types/dist/event-category-D4HJq7Mw.mjs
987
+ //#region ../types/dist/event-category-BLcNejAE.mjs
988
988
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
989
989
  EventCategory["SystemBoot"] = "system.boot";
990
990
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -1134,9 +1134,6 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
1134
1134
  EventCategory["RecordingSegmentWritten"] = "recording.segment.written";
1135
1135
  EventCategory["RecordingPolicyFallback"] = "recording.policy.fallback";
1136
1136
  EventCategory["RecordingRetentionCompleted"] = "recording.retention.completed";
1137
- /** Runner-sampled scrub thumbnail (~1/5 s/camera). Telemetry (D8): a lost
1138
- * thumb is a scrub gap the recorder's keyframe backfill covers. */
1139
- EventCategory["RecordingThumbSampled"] = "recording.thumb-sampled";
1140
1137
  /** Export render progress (0–100). Telemetry (D8): a lost tick is a stale
1141
1138
  * progress bar the client reconciles via `recordingExport.getExport`. */
1142
1139
  EventCategory["RecordingExportProgress"] = "recording.export.progress";
@@ -7815,7 +7812,6 @@ object({ deviceId: number() }), object({ deviceId: number() }), object({
7815
7812
  patch: record(string(), unknown())
7816
7813
  }), object({ success: literal(true) });
7817
7814
  object({ deviceId: number() }), unknown().nullable();
7818
- /** Shorthand to define a method schema */
7819
7815
  function method(input, output, options) {
7820
7816
  return {
7821
7817
  input,
@@ -7823,6 +7819,7 @@ function method(input, output, options) {
7823
7819
  kind: options?.kind ?? "query",
7824
7820
  auth: options?.auth ?? "protected",
7825
7821
  ...options?.access !== void 0 ? { access: options.access } : {},
7822
+ ...options?.caller !== void 0 ? { caller: options.caller } : {},
7826
7823
  timeoutMs: options?.timeoutMs
7827
7824
  };
7828
7825
  }
@@ -8520,16 +8517,23 @@ var StorageLocationDeclarationSchema = object({
8520
8517
  * Which node root the seeded `<id>:default` instance is placed under on a
8521
8518
  * FRESH install:
8522
8519
  * - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
8523
- * the appData volume. Right for small/durable data (backups, logs, models).
8520
+ * the appData volume. Right for small/durable data (logs, models).
8524
8521
  * - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
8525
8522
  * env is set, else falls back to the data root. Right for bulky, hot media
8526
8523
  * (recordings, event media) that should stay off the appData disk.
8524
+ * - `'backup'` — the dedicated backup volume (`CAMSTACK_BACKUP_ROOT`, default
8525
+ * `/backups` in the image) so archives live on their own mount rather than
8526
+ * filling the appData disk. Falls back to the data root when unset.
8527
8527
  *
8528
8528
  * Only affects the seeded default's `basePath`; operators can repoint any
8529
8529
  * location afterwards, and a `defaultsTo` slot inherits its parent's root
8530
8530
  * regardless of this field. Absent (the common case) is treated as `'data'`.
8531
8531
  */
8532
- defaultRoot: _enum(["data", "media"]).optional()
8532
+ defaultRoot: _enum([
8533
+ "data",
8534
+ "media",
8535
+ "backup"
8536
+ ]).optional()
8533
8537
  });
8534
8538
  var DecoderStatsSchema = object({
8535
8539
  inputFps: number(),
@@ -9192,6 +9196,59 @@ for (const l of AUDIO_MACRO_LABELS) {
9192
9196
  /** The complete taxonomy dictionary, keyed by kind. */
9193
9197
  var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
9194
9198
  /**
9199
+ * Notification-Center taxonomy — the fixed vocabulary the NC rule editor
9200
+ * offers as pickers instead of free text. Derived (never hand-listed) from the
9201
+ * single `EVENT_TAXONOMY` dictionary so it stays in lockstep with every other
9202
+ * taxonomy surface (timeline, filters, event page).
9203
+ *
9204
+ * Three buckets, mapped onto the rule editor's `stringList` conditions:
9205
+ * - `videoClasses` → detection classes (person / vehicle / animal + subs)
9206
+ * for the `classes` / `classesExclude` conditions.
9207
+ * - `audioKinds` → audio-analyzer sub kinds (`audio-scream`, …) shown in
9208
+ * the same class picker, grouped under an Audio header.
9209
+ * - `labels` → sensor + control taxonomy kinds (doorbell / contact /
9210
+ * lock / …) for the `sensorKinds` device-event condition.
9211
+ *
9212
+ * Each entry carries `parentKind` so the client can group video subs under
9213
+ * their macro and sensor/control kinds under their category. This surface is
9214
+ * served ADDITIVELY on the `nc.getConditionCatalog` bridge response — no cap
9215
+ * method, no codegen — so it ships train-free with an addon deploy.
9216
+ */
9217
+ /** One selectable taxonomy value: a stable kind id + display label + parent. */
9218
+ var NcTaxonomyEntrySchema = object({
9219
+ /** Stable kind id (e.g. 'person', 'car', 'audio-scream', 'doorbell'). */
9220
+ kind: string(),
9221
+ /** English fallback label (the UI translates via the event-kind i18n key). */
9222
+ label: string(),
9223
+ /** Macro/category parent for grouping ('car' → 'vehicle'); null for a top. */
9224
+ parentKind: string().nullable()
9225
+ });
9226
+ object({
9227
+ videoClasses: array(NcTaxonomyEntrySchema),
9228
+ audioKinds: array(NcTaxonomyEntrySchema),
9229
+ labels: array(NcTaxonomyEntrySchema)
9230
+ });
9231
+ function toEntry(kind, label, parentKind) {
9232
+ return {
9233
+ kind,
9234
+ label,
9235
+ parentKind
9236
+ };
9237
+ }
9238
+ /**
9239
+ * Build the NC taxonomy from `EVENT_TAXONOMY`. Insertion order is preserved
9240
+ * (macros before their subs), which the client relies on for stable grouping.
9241
+ */
9242
+ function buildNcTaxonomy() {
9243
+ const all = Object.values(EVENT_TAXONOMY);
9244
+ return {
9245
+ videoClasses: all.filter((e) => e.category === "detection").map((e) => toEntry(e.kind, e.label, e.parentKind)),
9246
+ audioKinds: all.filter((e) => e.category === "audio" && e.level === "sub").map((e) => toEntry(e.kind, e.label, e.parentKind)),
9247
+ labels: all.filter((e) => e.category === "sensor" || e.category === "control").map((e) => toEntry(e.kind, e.label, e.parentKind))
9248
+ };
9249
+ }
9250
+ Object.freeze(buildNcTaxonomy());
9251
+ /**
9195
9252
  * Error types for the safe expression engine. Two distinct classes so callers
9196
9253
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
9197
9254
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -10070,6 +10127,644 @@ function shallowEqual(a, b) {
10070
10127
  return true;
10071
10128
  }
10072
10129
  /**
10130
+ * Shared geometry vocabulary for on-frame shape caps — privacy-mask,
10131
+ * motion-zones, and the detection zones/lines editor all speak this one
10132
+ * language so a single drawing-plane editor and the providers stay
10133
+ * decoupled from each cap's storage.
10134
+ *
10135
+ * All coordinates are normalized 0..1 of the camera frame (top-left
10136
+ * origin). Each cap composes the SUBSET of shape kinds it supports and
10137
+ * advertises it via `supportedShapes` in its `getOptions`.
10138
+ */
10139
+ /** A normalized 0..1 point (top-left origin). */
10140
+ var MaskPointSchema = object({
10141
+ x: number(),
10142
+ y: number()
10143
+ });
10144
+ /** Axis-aligned rectangle (normalized 0..1). */
10145
+ var MaskRectShapeSchema = object({
10146
+ kind: literal("rect"),
10147
+ x: number(),
10148
+ y: number(),
10149
+ width: number(),
10150
+ height: number()
10151
+ });
10152
+ /** Free polygon — an ordered list of normalized vertices (≥3). */
10153
+ var MaskPolygonShapeSchema = object({
10154
+ kind: literal("polygon"),
10155
+ points: array(MaskPointSchema)
10156
+ });
10157
+ /** Boolean cell grid — row-major, length === gridWidth*gridHeight. */
10158
+ var MaskGridShapeSchema = object({
10159
+ kind: literal("grid"),
10160
+ gridWidth: number(),
10161
+ gridHeight: number(),
10162
+ cells: array(boolean())
10163
+ });
10164
+ discriminatedUnion("kind", [
10165
+ MaskRectShapeSchema,
10166
+ MaskPolygonShapeSchema,
10167
+ MaskGridShapeSchema,
10168
+ object({
10169
+ kind: literal("line"),
10170
+ points: array(MaskPointSchema)
10171
+ })
10172
+ ]);
10173
+ /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
10174
+ var MaskShapeKindSchema = _enum([
10175
+ "rect",
10176
+ "polygon",
10177
+ "grid",
10178
+ "line"
10179
+ ]);
10180
+ /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
10181
+ var MaskPolygonVerticesSchema = object({
10182
+ min: number(),
10183
+ max: number()
10184
+ });
10185
+ /** Grid dimensions when a cap supports 'grid'. */
10186
+ var MaskGridDimsSchema = object({
10187
+ width: number(),
10188
+ height: number()
10189
+ });
10190
+ /**
10191
+ * notification-rules — the Notification Center rule surface (P1 core).
10192
+ *
10193
+ * Spec: `docs/superpowers/specs/2026-07-22-notification-center-requirements.md`
10194
+ * (operator decisions D-1/D-2/D-3 are binding):
10195
+ *
10196
+ * - D-2: rule EVALUATION lives in `addon-post-analysis` (the
10197
+ * `notification-center` module), hooked on the durable persistence
10198
+ * moments (object-event insert, TrackCloser.closeExpired) with a
10199
+ * persisted outbox + retry — never the lossy telemetry bus (D8).
10200
+ * - D-3: urgency belongs to the RULE. `delivery: 'immediate'` fires on the
10201
+ * FIRST persisted detection matching the conditions (per-track dedup,
10202
+ * `maxPerTrack` fixed at 1 — see {@link NC_MAX_PER_TRACK_IMMEDIATE});
10203
+ * `delivery: 'track-end'` evaluates the finalized track record at close.
10204
+ * - DISPATCH stays behind `notification-output` (rules reference targets
10205
+ * by id; per-backend params are a passthrough blob capped by the
10206
+ * target kind's own caps/degrade engine).
10207
+ *
10208
+ * P1 scope: admin-authored rules only (`createdBy` stamped from the
10209
+ * server-injected caller identity — the first `caller: 'required'`
10210
+ * adopter). The P1 condition subset is: devices, classes(+exclude),
10211
+ * minConfidence, admin zones (any/all + exclude), weekly schedule
10212
+ * windows, and the optional label/identity/plate matchers. User rules,
10213
+ * private zones, per-recipient fan-out and the wider condition table are
10214
+ * P2+ (see spec §7).
10215
+ *
10216
+ * All schemas here are the single source of truth — `NcRule` etc. are
10217
+ * `z.infer` exports; no duplicate interfaces (the advanced-notifier
10218
+ * schema/interface drift is explicitly not repeated).
10219
+ */
10220
+ /**
10221
+ * D-3: the trigger/urgency of a rule — which persistence moment evaluates it.
10222
+ * The value maps 1:1 onto the evaluated record kind:
10223
+ * - `immediate` ↔ object-event persist (lowest-latency detection burst)
10224
+ * - `track-end` ↔ TrackCloser.closeExpired (finalized track record)
10225
+ * - `device-event` ↔ SensorEventStore insert (doorbell press / sensor state
10226
+ * change of a LINKED device, one row per linked camera)
10227
+ * - `package-event` ↔ PackageDropDetector object-event insert (a `package`
10228
+ * delivery / pick-up)
10229
+ *
10230
+ * `immediate`/`track-end` carry the D-3 urgency semantics; `device-event`/
10231
+ * `package-event` are pure trigger kinds (no urgency dimension). Extending
10232
+ * this one field keeps the schema additive — a rule still declares exactly
10233
+ * one trigger.
10234
+ */
10235
+ var NcDeliverySchema = _enum([
10236
+ "immediate",
10237
+ "track-end",
10238
+ "device-event",
10239
+ "package-event"
10240
+ ]);
10241
+ /** Weekly schedule — OR of windows; absence on the rule = always active. */
10242
+ var NcScheduleSchema = object({
10243
+ windows: array(object({
10244
+ /** Days of week the window STARTS on (0 = Sunday … 6 = Saturday). */
10245
+ days: array(number().int().min(0).max(6)).min(1),
10246
+ startMinute: number().int().min(0).max(1439),
10247
+ endMinute: number().int().min(0).max(1439)
10248
+ })).min(1),
10249
+ /** IANA timezone; default = hub host timezone. */
10250
+ timezone: string().optional(),
10251
+ /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
10252
+ invert: boolean().optional()
10253
+ });
10254
+ /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
10255
+ var NcPlateMatcherSchema = object({
10256
+ values: array(string().min(1)).min(1),
10257
+ /** Max Levenshtein distance after normalization (uppercase alphanumeric). */
10258
+ maxDistance: number().int().min(0).max(3).default(1)
10259
+ });
10260
+ /**
10261
+ * Occupancy condition (DEVICE-EVENT trigger). Fires on a ZoneAnalytics
10262
+ * occupancy edge for a device — optionally narrowed to a single admin
10263
+ * `zoneId` and/or object `className`. `op` selects the edge/threshold:
10264
+ * - `became-occupied` (default) — count crossed 0 → ≥ `count`
10265
+ * - `became-free` — count crossed ≥ `count` → below it
10266
+ * - `>=` / `<=` — count is at/over or at/under `count`
10267
+ * `sustainSeconds` requires the condition hold continuously that long
10268
+ * before firing (debounces flicker; 0 = fire on the first matching edge).
10269
+ * Fail-closed: no ZoneAnalytics snapshot / missing zone / null snapshot ⇒
10270
+ * the condition never matches. Confirmed edge-state survives addon restarts
10271
+ * (declared SQLite collection, reseeded on boot).
10272
+ */
10273
+ var NcOccupancyConditionSchema = object({
10274
+ /** Admin zone id to scope the count to; absent = whole-frame occupancy. */
10275
+ zoneId: string().optional(),
10276
+ /** Object class to count; absent = any class. */
10277
+ className: string().optional(),
10278
+ op: _enum([
10279
+ "became-occupied",
10280
+ "became-free",
10281
+ ">=",
10282
+ "<="
10283
+ ]).default("became-occupied"),
10284
+ count: number().int().min(0).default(1),
10285
+ sustainSeconds: number().int().min(0).max(3600).default(15)
10286
+ });
10287
+ /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
10288
+ var NcZoneConditionSchema = object({
10289
+ ids: array(string().min(1)).min(1),
10290
+ /** Quantifier over `ids` — at least one / every one visited. */
10291
+ match: _enum(["any", "all"]).default("any")
10292
+ });
10293
+ /**
10294
+ * The P1 condition set — a flat AND of groups; absent group = pass;
10295
+ * membership lists are OR within the list (spec §2.3).
10296
+ */
10297
+ var NcConditionsSchema = object({
10298
+ /** Device scope — absent = all devices. */
10299
+ devices: array(number()).optional(),
10300
+ /** Detector class names (any overlap with the record's class set). */
10301
+ classes: array(string().min(1)).optional(),
10302
+ /** Veto classes — any overlap fails the rule. */
10303
+ classesExclude: array(string().min(1)).optional(),
10304
+ /** Minimum detection confidence 0–1 (fails when the record has none). */
10305
+ minConfidence: number().min(0).max(1).optional(),
10306
+ /** Admin zone membership over event `zones` / track `zonesVisited`. */
10307
+ zones: NcZoneConditionSchema.optional(),
10308
+ /** Veto zones — any hit fails the rule. */
10309
+ zonesExclude: array(string().min(1)).optional(),
10310
+ /**
10311
+ * Exact (case-insensitive) match on the record's collapsed `label`
10312
+ * (identity name / plate text / subclass).
10313
+ */
10314
+ labelEquals: array(string().min(1)).optional(),
10315
+ /**
10316
+ * Identity matcher. P1 boundary: matched against the record's collapsed
10317
+ * `label` (the identity display name propagated by the face pipeline) —
10318
+ * identity-ID matching rides in P2 when identity ids reach the record.
10319
+ */
10320
+ identities: array(string().min(1)).optional(),
10321
+ /** Fuzzy plate matcher against the record's `label` (plate text). */
10322
+ plates: NcPlateMatcherSchema.optional(),
10323
+ /**
10324
+ * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
10325
+ * Same P1 boundary: matched against the record's collapsed `label` (the
10326
+ * identity display name). A record with NO label passes (nothing to
10327
+ * exclude), unlike the include variant which fails on an absent label.
10328
+ */
10329
+ identitiesExclude: array(string().min(1)).optional(),
10330
+ /**
10331
+ * Minimum server-computed key-event importance in [0,1] (`Track.importance`).
10332
+ * TRACK-END only: importance is scored at track close, so it does not exist
10333
+ * at immediate / object-event evaluation time (see catalog `appliesTo`). At
10334
+ * close the value is threaded via the close-time info (the `Track` clone is
10335
+ * captured before the DB row is updated, so it would otherwise read stale).
10336
+ * Fails when the record carries no importance (never guess quality — the
10337
+ * `minConfidence` precedent). MVP cut: a single scalar threshold.
10338
+ */
10339
+ minImportance: number().min(0).max(1).optional(),
10340
+ /**
10341
+ * Minimum track dwell in SECONDS — `(lastSeen − firstSeen) / 1000`.
10342
+ * TRACK-END only: an `immediate` / object-event subject has no closed
10343
+ * lifespan, so a dwell condition never matches immediate delivery
10344
+ * (documented choice — the object-event record carries no `firstSeen`,
10345
+ * so dwell cannot be computed from what the subject actually carries).
10346
+ */
10347
+ minDwellSeconds: number().min(0).optional(),
10348
+ /**
10349
+ * Detection provenance filter. `any` (default / absent) matches every
10350
+ * source; otherwise the subject's source must equal it. Legacy records
10351
+ * with no stamped source are treated as `pipeline`. The union spans both
10352
+ * record kinds — object events carry `pipeline` | `onboard`, synthetic
10353
+ * tracks carry `sensor`.
10354
+ */
10355
+ source: _enum([
10356
+ "pipeline",
10357
+ "onboard",
10358
+ "sensor",
10359
+ "any"
10360
+ ]).optional(),
10361
+ /**
10362
+ * Minimum identity / plate MATCH confidence in [0,1] — DISTINCT from the
10363
+ * detector `minConfidence` (that gates the object-detection score; this
10364
+ * gates the recognition/OCR match score). Fails when the subject carries
10365
+ * no label-match confidence (never guess). TRACK-END only: the confidence
10366
+ * lives on the recognition result and reaches the subject at track close.
10367
+ *
10368
+ * What it measures precisely (plumbed at track close — the closer threads
10369
+ * the value into `NcTrackClosedInfo.labelConfidence`, the same seam as
10370
+ * `importance`): the BEST recognition match confidence observed for the
10371
+ * label the track carries at close — for a face, the peak cosine similarity
10372
+ * of the ASSIGNED identity (`FaceMatch.score`, reset on an identity switch);
10373
+ * for a plate, the peak OCR read score of the best-held plate
10374
+ * (`plateText.confidence`). When BOTH a face and a plate were recognized on
10375
+ * one track the higher of the two is used. A track that ended with no
10376
+ * confident identity/plate match carries no value, so the condition fails
10377
+ * closed for it (an un-recognized subject).
10378
+ */
10379
+ minLabelConfidence: number().min(0).max(1).optional(),
10380
+ /**
10381
+ * DEVICE-EVENT only. Raw device event-type tokens (`EventFire.eventType`,
10382
+ * e.g. a doorbell `press` / `press_long`) — matched case-insensitively
10383
+ * against the token carried on the device-event subject (extracted from the
10384
+ * event-emitter runtime slice's `lastEvent.eventType`). Fails when the
10385
+ * subject carries no token. Doorbell-pulse / passive-sensor kinds emit no
10386
+ * eventType, so gate those with {@link sensorKinds} instead.
10387
+ */
10388
+ eventTypeTokens: array(string().min(1)).optional(),
10389
+ /**
10390
+ * DEVICE-EVENT only. Sensor/control taxonomy kinds (e.g. `doorbell`,
10391
+ * `contact`, `button`, `device-event`) — matched against the persisted
10392
+ * `SensorEvent.kind` (see `sensor-event-kinds.ts`). Membership is OR.
10393
+ */
10394
+ sensorKinds: array(string().min(1)).optional(),
10395
+ /**
10396
+ * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
10397
+ * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
10398
+ * when the subject's phase does not match (a subject always carries a phase
10399
+ * on the package-event trigger).
10400
+ */
10401
+ packagePhase: _enum([
10402
+ "delivered",
10403
+ "picked-up",
10404
+ "both"
10405
+ ]).optional(),
10406
+ /**
10407
+ * PERSONAL-RULE custom zones (viewer-drawn). Inline normalized polygons
10408
+ * (MaskShape vocabulary). A record passes when its bbox overlaps ANY
10409
+ * listed polygon (ZoneEngine membership semantics). Evaluated only when
10410
+ * the subject carries a bbox; absent bbox ⇒ the condition FAILS.
10411
+ */
10412
+ customZones: array(MaskPolygonShapeSchema).optional(),
10413
+ /**
10414
+ * DEVICE-EVENT only. ZoneAnalytics occupancy edge — fires when a device's
10415
+ * (optionally zone/class-scoped) occupancy count crosses the configured
10416
+ * threshold and holds for `sustainSeconds`. Fail-closed on missing
10417
+ * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
10418
+ */
10419
+ occupancy: NcOccupancyConditionSchema.optional()
10420
+ });
10421
+ /** One delivery target: a `notification-output` Target ref + passthrough params. */
10422
+ var NcRuleTargetSchema = object({
10423
+ /** `notification-output` Target id. */
10424
+ targetId: string().min(1),
10425
+ /**
10426
+ * Per-backend passthrough. Recognized keys are mapped onto the canonical
10427
+ * Notification (`priority`, `level`, `sound`, `clickUrl`, `ttl`); the
10428
+ * degrade engine drops what the backend can't render.
10429
+ */
10430
+ params: record(string(), unknown()).optional()
10431
+ });
10432
+ /**
10433
+ * Media attachment policy (P1 still-image subset).
10434
+ * - `best` — the best AVAILABLE subject image at dispatch time (D-3).
10435
+ * - `best-matching` — the media that explains WHY the rule fired: a rule
10436
+ * matched on identities attaches the subject's `faceCrop`, one matched on
10437
+ * plates attaches the `plateCrop`; a rule with no identity/plate condition
10438
+ * (or when the specific crop is missing) degrades to `best`, then
10439
+ * `keyFrame`, then no attachment — never delaying the send. The matched
10440
+ * condition summary is frozen on the outbox row at enqueue (like the rule
10441
+ * name), so the choice never drifts from the record that fired it.
10442
+ * - `keyFrame` — the clean scene frame (no subject box).
10443
+ * - `none` — no attachment.
10444
+ */
10445
+ var NcMediaPolicySchema = object({ attach: _enum([
10446
+ "best",
10447
+ "best-matching",
10448
+ "keyFrame",
10449
+ "none"
10450
+ ]).default("best") });
10451
+ /** Throttle — cooldown survives restarts (rebuilt from the outbox on boot). */
10452
+ var NcThrottleSchema = object({
10453
+ cooldownSec: number().int().min(0).max(86400).default(60),
10454
+ /** `rule` = one shared cooldown; `rule-device` = per-camera cooldown. */
10455
+ scope: _enum(["rule", "rule-device"]).default("rule-device")
10456
+ });
10457
+ /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
10458
+ var NcRuleInputSchema = object({
10459
+ name: string().min(1).max(200),
10460
+ enabled: boolean().default(true),
10461
+ delivery: NcDeliverySchema,
10462
+ conditions: NcConditionsSchema.default({}),
10463
+ schedule: NcScheduleSchema.optional(),
10464
+ targets: array(NcRuleTargetSchema).min(1),
10465
+ media: NcMediaPolicySchema.default({ attach: "best" }),
10466
+ throttle: NcThrottleSchema.default({
10467
+ cooldownSec: 60,
10468
+ scope: "rule-device"
10469
+ }),
10470
+ /** `{{var}}` templating over camera/class/label/zones/confidence/time. */
10471
+ template: object({
10472
+ title: string().max(500).optional(),
10473
+ body: string().max(2e3).optional()
10474
+ }).optional(),
10475
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
10476
+ priority: number().int().min(1).max(5).default(3),
10477
+ /**
10478
+ * Ownership/visibility key. Absent = admin/global rule (unchanged legacy
10479
+ * behaviour, visible to all, read-only in the viewer). Present = personal
10480
+ * rule owned by this userId. Server-stamped; never trusted from a client.
10481
+ */
10482
+ ownerUserId: string().optional()
10483
+ });
10484
+ /**
10485
+ * Partial patch for `updateRule` — any subset of the input fields, plus the
10486
+ * persisted-only {@link NcRuleSchema} `disabledTargetIds` set. The latter is
10487
+ * NOT a client-authored input field (it lives on the persisted rule, not the
10488
+ * input), so it is added here explicitly to let the store's per-target opt-out
10489
+ * toggle round-trip through the shared `update` path. Viewer opt-out mutations
10490
+ * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
10491
+ * `updateRule` patch.
10492
+ */
10493
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
10494
+ /** A persisted rule. */
10495
+ var NcRuleSchema = NcRuleInputSchema.extend({
10496
+ id: string(),
10497
+ /** userId of the admin who created the rule (server-stamped caller). */
10498
+ createdBy: string(),
10499
+ createdAt: number(),
10500
+ updatedAt: number(),
10501
+ /**
10502
+ * Per-target opt-out set. A targetId here is suppressed for THIS rule at
10503
+ * send time. Only a target's OWNER may add/remove its id (server-checked
10504
+ * in `nc.setRuleTargetEnabled`). Defaults to empty.
10505
+ */
10506
+ disabledTargetIds: array(string()).default([])
10507
+ });
10508
+ var NcTestResultSchema = object({
10509
+ recordId: string(),
10510
+ recordKind: _enum([
10511
+ "object-event",
10512
+ "track",
10513
+ "device-event",
10514
+ "package-event"
10515
+ ]),
10516
+ deviceId: number(),
10517
+ timestamp: number(),
10518
+ wouldFire: boolean(),
10519
+ /** Condition id that failed (first failing group), when `wouldFire` is false. */
10520
+ failedCondition: string().optional(),
10521
+ className: string().optional(),
10522
+ label: string().optional()
10523
+ });
10524
+ var NcConditionDescriptorSchema = object({
10525
+ /** Field id inside `NcConditions` (or `'schedule'` for the rule-level group). */
10526
+ id: string(),
10527
+ group: _enum([
10528
+ "scope",
10529
+ "class",
10530
+ "zones",
10531
+ "quality",
10532
+ "label",
10533
+ "schedule",
10534
+ "device",
10535
+ "package",
10536
+ "occupancy"
10537
+ ]),
10538
+ label: string(),
10539
+ /** Editor widget the UI renders — never hardcode per-condition forms. */
10540
+ valueType: _enum([
10541
+ "deviceIdList",
10542
+ "stringList",
10543
+ "number01",
10544
+ "number",
10545
+ "sourceSelect",
10546
+ "zoneSelection",
10547
+ "zoneIdList",
10548
+ "schedule",
10549
+ "plateMatcher",
10550
+ "packagePhase",
10551
+ "polygonDraw",
10552
+ "occupancy"
10553
+ ]),
10554
+ operator: _enum([
10555
+ "in",
10556
+ "notIn",
10557
+ "anyOf",
10558
+ "allOf",
10559
+ "gte",
10560
+ "fuzzyIn",
10561
+ "withinSchedule"
10562
+ ]),
10563
+ /** Which delivery kinds the condition applies to. */
10564
+ appliesTo: array(NcDeliverySchema),
10565
+ phase: string(),
10566
+ description: string().optional()
10567
+ });
10568
+ /**
10569
+ * The delivery lifecycle status of a history row — a straight read of the
10570
+ * durable outbox row's own status (single source of truth):
10571
+ * - `pending` — enqueued, in-flight or retrying with backoff
10572
+ * - `sent` — delivered (terminal)
10573
+ * - `dead` — dead-lettered after exhausting retries / a permanent
10574
+ * backend rejection / a deleted target (terminal; carries
10575
+ * the failure `error`)
10576
+ *
10577
+ * P1 has no `suppressed-quiet-hours` / `snoozed` states — those ride the P2
10578
+ * user dimension (quiet hours / snooze) and are additive when they land.
10579
+ */
10580
+ var NcHistoryStatusSchema = _enum([
10581
+ "pending",
10582
+ "sent",
10583
+ "dead"
10584
+ ]);
10585
+ /** The evaluated record kind a history row descends from (one per trigger). */
10586
+ var NcHistoryRecordKindSchema = _enum([
10587
+ "object-event",
10588
+ "track-end",
10589
+ "device-event",
10590
+ "package-event"
10591
+ ]);
10592
+ /** Subject summary frozen on the row at fire time (survives rule/record edits). */
10593
+ var NcHistorySubjectSchema = object({
10594
+ className: string(),
10595
+ label: string().optional(),
10596
+ confidence: number().optional(),
10597
+ zones: array(string()),
10598
+ timestamp: number()
10599
+ });
10600
+ /**
10601
+ * One delivery-history row. This is a read-only VIEW over the durable
10602
+ * outbox row (single source of truth — the same row the drain loop drives;
10603
+ * NO second write path, so history can never drift from delivery state).
10604
+ * The §3.2 fields map directly: `ruleId`/`targetId`/`deviceId` are columns,
10605
+ * `eventRef` is `recordKind`+`recordId`, `timestamps` are `createdAt`
10606
+ * (fire) / `updatedAt` (last transition), `status` + `error` are the
10607
+ * lifecycle. `ruleName` + `subject` are the intent snapshot frozen at
10608
+ * enqueue. `userId?` (per-recipient history) is P2 — no user dimension in
10609
+ * P1 (admin scope only).
10610
+ */
10611
+ var NcHistoryEntrySchema = object({
10612
+ /** Outbox row id — the stable dedup id `ruleId:dedupRef:targetId`. */
10613
+ id: string(),
10614
+ ruleId: string(),
10615
+ /** Rule name frozen at fire time (outlives a later rename / delete). */
10616
+ ruleName: string(),
10617
+ /** The rule urgency/trigger that produced this delivery. */
10618
+ delivery: NcDeliverySchema,
10619
+ targetId: string(),
10620
+ deviceId: number(),
10621
+ recordKind: NcHistoryRecordKindSchema,
10622
+ /** Event / track ref of the evaluated record (§3.2 `eventRef`). */
10623
+ recordId: string(),
10624
+ /** Present for track-scoped deliveries (object-event / track-end). */
10625
+ trackId: string().optional(),
10626
+ status: NcHistoryStatusSchema,
10627
+ /** Delivery attempts made so far. */
10628
+ attempts: number().int(),
10629
+ /** Fire time (outbox enqueue). */
10630
+ createdAt: number(),
10631
+ /** Last transition time (terminal for sent / dead). */
10632
+ updatedAt: number(),
10633
+ /** Failure detail — present on a `dead` row. */
10634
+ error: string().optional(),
10635
+ subject: NcHistorySubjectSchema
10636
+ });
10637
+ /**
10638
+ * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
10639
+ * AND; absent = unbounded on that axis. `since`/`until` bound the fire time
10640
+ * (`createdAt`, epoch ms, inclusive). `limit` is clamped to
10641
+ * {@link NC_HISTORY_LIMIT_MAX}. `userId` (per-recipient filtering) is P2.
10642
+ */
10643
+ var NcHistoryFilterSchema = object({
10644
+ ruleId: string().optional(),
10645
+ deviceId: number().optional(),
10646
+ status: NcHistoryStatusSchema.optional(),
10647
+ since: number().optional(),
10648
+ until: number().optional(),
10649
+ limit: number().int().min(1).max(500).default(100)
10650
+ });
10651
+ 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 }), {
10652
+ kind: "mutation",
10653
+ auth: "admin",
10654
+ caller: "required"
10655
+ }), method(object({
10656
+ ruleId: string(),
10657
+ patch: NcRulePatchSchema
10658
+ }), object({ rule: NcRuleSchema }), {
10659
+ kind: "mutation",
10660
+ auth: "admin",
10661
+ caller: "required"
10662
+ }), method(object({ ruleId: string() }), object({ success: literal(true) }), {
10663
+ kind: "mutation",
10664
+ auth: "admin"
10665
+ }), method(object({
10666
+ ruleId: string(),
10667
+ enabled: boolean()
10668
+ }), object({ success: literal(true) }), {
10669
+ kind: "mutation",
10670
+ auth: "admin"
10671
+ }), method(object({
10672
+ rule: NcRuleInputSchema,
10673
+ lookbackMinutes: number().int().min(1).max(1440).default(60)
10674
+ }), object({ results: array(NcTestResultSchema) }), {
10675
+ kind: "mutation",
10676
+ auth: "admin"
10677
+ }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
10678
+ /**
10679
+ * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
10680
+ *
10681
+ * Spec: `docs/superpowers/specs/2026-07-24-nc-occupancy-timelapse-design.md`
10682
+ * §3.2/§3.3.
10683
+ *
10684
+ * Deliberately NOT a capability definition and NOT an `NcRule`:
10685
+ * - Every `NcDelivery` member is a *persisted-pipeline-record* trigger. A
10686
+ * timelapse fires on a SCHEDULE WINDOW BOUNDARY, evaluates no pipeline
10687
+ * record, and produces a video it assembled itself — so it rides no
10688
+ * delivery-enum member (the enum is frozen) and no cap method. This file is
10689
+ * a plain typed schema; it does NOT go through `npm run codegen`.
10690
+ * - It shares only the delivery leg (`notification-output.send`) and the
10691
+ * persistence/ownership patterns with the Notification Center, reusing
10692
+ * {@link NcScheduleSchema} (weekly windows, midnight-crossing, invertible)
10693
+ * and {@link NcRuleTargetSchema} (target ref + passthrough params).
10694
+ *
10695
+ * Ownership is SERVER-DERIVED. `ownerUserId` / `createdBy` / `createdAt` /
10696
+ * `updatedAt` / `id` / `lastGeneratedAt` live on the PERSISTED rule only —
10697
+ * {@link TimelapseRuleInputSchema} and {@link TimelapseRulePatchSchema} do not
10698
+ * carry them, so a forged client payload can never claim or re-own a rule
10699
+ * (Zod strips unknown keys). The store stamps them from the resolved caller.
10700
+ */
10701
+ /** `{{var}}` templating over camera/rule/time — same vocabulary as `NcRule`. */
10702
+ var TimelapseTemplateSchema = object({
10703
+ title: string().max(500).optional(),
10704
+ body: string().max(2e3).optional()
10705
+ });
10706
+ var NameField = string().min(1).max(200);
10707
+ var DeviceIdsField = array(number()).min(1);
10708
+ var CadenceSecField = number().int().min(2).max(3600);
10709
+ var FramerateField = number().int().min(1).max(60);
10710
+ var TargetsField = array(NcRuleTargetSchema).min(1);
10711
+ var PriorityField = number().int().min(1).max(5);
10712
+ /**
10713
+ * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
10714
+ * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
10715
+ * here (see the ownership note above).
10716
+ */
10717
+ var TimelapseRuleInputSchema = object({
10718
+ name: NameField,
10719
+ enabled: boolean().default(true),
10720
+ /** Cameras sampled by this rule — one scratch dir + one artifact per device. */
10721
+ deviceIds: DeviceIdsField,
10722
+ /**
10723
+ * Activation window(s). REQUIRED (unlike `NcRule`, where an absent schedule
10724
+ * means "always active"): a timelapse is defined by its window boundaries —
10725
+ * open clears the scratch, close assembles and delivers.
10726
+ */
10727
+ schedule: NcScheduleSchema,
10728
+ /** Force-snapshot cadence inside the window, seconds (predecessor parity). */
10729
+ cadenceSec: CadenceSecField.default(15),
10730
+ /** Output frames per second of the assembled mp4 (predecessor parity). */
10731
+ framerate: FramerateField.default(10),
10732
+ /** `notification-output` targets the finished video/thumbnail is sent to. */
10733
+ targets: TargetsField,
10734
+ template: TimelapseTemplateSchema.optional(),
10735
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
10736
+ priority: PriorityField.default(3)
10737
+ });
10738
+ object({
10739
+ name: NameField.optional(),
10740
+ enabled: boolean().optional(),
10741
+ deviceIds: DeviceIdsField.optional(),
10742
+ schedule: NcScheduleSchema.optional(),
10743
+ cadenceSec: CadenceSecField.optional(),
10744
+ framerate: FramerateField.optional(),
10745
+ targets: TargetsField.optional(),
10746
+ template: TimelapseTemplateSchema.nullable().optional(),
10747
+ priority: PriorityField.optional()
10748
+ });
10749
+ TimelapseRuleInputSchema.extend({
10750
+ id: string(),
10751
+ /**
10752
+ * Ownership/visibility key. Absent = admin/global rule (visible to all).
10753
+ * Present = personal rule owned by this userId. Server-stamped from the
10754
+ * resolved caller; never trusted from a client payload.
10755
+ */
10756
+ ownerUserId: string().optional(),
10757
+ /**
10758
+ * Epoch-ms of the last successful generation — the 1-hour re-generation
10759
+ * guard's durable state (predecessor parity). Absent = never generated.
10760
+ */
10761
+ lastGeneratedAt: number().optional(),
10762
+ /** userId of the caller who created the rule (server-stamped). */
10763
+ createdBy: string(),
10764
+ createdAt: number(),
10765
+ updatedAt: number()
10766
+ });
10767
+ /**
10073
10768
  * Generic device-level status snapshot. Auto-registered by `BaseDevice`
10074
10769
  * for every device, regardless of provider — the kernel needs a uniform
10075
10770
  * cap-keyed slice for the basic device flags every consumer expects to
@@ -13177,6 +13872,22 @@ var CameraMetricsSchema = object({
13177
13872
  ])
13178
13873
  });
13179
13874
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
13875
+ /**
13876
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
13877
+ * within the frame, so the executor can re-cut a leaf child ROI at native
13878
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
13879
+ */
13880
+ var NativeCropRefSchema = object({
13881
+ /** Handle keying the retained native surface (node-pinned to its owner). */
13882
+ handle: FrameHandleSchema,
13883
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
13884
+ cropFrameSpace: object({
13885
+ x: number(),
13886
+ y: number(),
13887
+ w: number(),
13888
+ h: number()
13889
+ })
13890
+ });
13180
13891
  var ModelFormatSchema$1 = _enum([
13181
13892
  "onnx",
13182
13893
  "coreml",
@@ -13452,7 +14163,22 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
13452
14163
  * Omitted ⇒ the runner's default device (current single-engine
13453
14164
  * behaviour). Selects WHICH device pool of the node runs the call.
13454
14165
  */
13455
- deviceKey: string().optional()
14166
+ deviceKey: string().optional(),
14167
+ /**
14168
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
14169
+ * when the parent crop was resolved from the frame's retained NATIVE
14170
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
14171
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
14172
+ * resolution from that surface — the SAME quality path faces already
14173
+ * had — instead of the downscaled parent tile. `handle` keys the native
14174
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
14175
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
14176
+ * the executor's crop-normalized child ROI back into frame-normalized
14177
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
14178
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
14179
+ * (today's behaviour on the fallback path).
14180
+ */
14181
+ nativeCropRef: NativeCropRefSchema.optional()
13456
14182
  }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
13457
14183
  engine: PipelineEngineChoiceSchema.optional(),
13458
14184
  steps: array(PipelineStepInputSchema).min(1),
@@ -13701,7 +14427,11 @@ var DetailResultSchema = object({
13701
14427
  bbox: NativeCropBboxSchema.optional(),
13702
14428
  embedding: string().optional(),
13703
14429
  label: string().optional(),
13704
- alignedCropJpeg: string().optional()
14430
+ alignedCropJpeg: string().optional(),
14431
+ /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
14432
+ * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
14433
+ * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
14434
+ nativeFaceShortSidePx: number().optional()
13705
14435
  });
13706
14436
  /**
13707
14437
  * Per-camera tunable ranges + defaults. Single source of truth used
@@ -13715,6 +14445,12 @@ var motionCooldownMsField = {
13715
14445
  default: 3e4,
13716
14446
  step: 500
13717
14447
  };
14448
+ var maxSessionHoldMsField = {
14449
+ min: 0,
14450
+ max: 6e5,
14451
+ default: 12e4,
14452
+ step: 5e3
14453
+ };
13718
14454
  var motionFpsField = {
13719
14455
  min: 1,
13720
14456
  max: 30,
@@ -13862,6 +14598,19 @@ var RunnerCameraConfigSchema = object({
13862
14598
  "on-motion"
13863
14599
  ]).default("always-on"),
13864
14600
  motionCooldownMs: number().min(motionCooldownMsField.min).default(motionCooldownMsField.default),
14601
+ /**
14602
+ * Orchestrator-side on-motion session-hold cap (ms). While an on-motion
14603
+ * detection session is active and ≥1 confirmed non-stationary track is
14604
+ * still live, the orchestrator keeps the session open past
14605
+ * `motionCooldownMs` (a slowly-moving subject can stop re-triggering the
14606
+ * camera's VMD yet is still being tracked frame-to-frame) — up to this many
14607
+ * ms since the session opened, after which it closes regardless. `0`
14608
+ * disables the hold (legacy cooldown-only teardown). Not consumed by the
14609
+ * runner itself — carried here so it shares the per-camera device-settings
14610
+ * surface with `motionCooldownMs`; the orchestrator reads it off the
14611
+ * resolved `CameraDetectionConfig`.
14612
+ */
14613
+ maxSessionHoldMs: number().min(maxSessionHoldMsField.min).max(maxSessionHoldMsField.max).optional(),
13865
14614
  motionFps: number().min(motionFpsField.min).max(motionFpsField.max).default(motionFpsField.default),
13866
14615
  detectionFps: number().min(detectionFpsField.min).max(detectionFpsField.max).default(detectionFpsField.default),
13867
14616
  motionStreamId: string(),
@@ -13951,7 +14700,7 @@ var RunnerCameraConfigSchema = object({
13951
14700
  */
13952
14701
  inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
13953
14702
  });
13954
- 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;
14703
+ 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;
13955
14704
  /**
13956
14705
  * Runtime load summary returned by `getLocalLoad`. Used by the orchestrator's
13957
14706
  * load-balancing levels (L2 capacity-based, L3 hardware-aware) to decide
@@ -14167,86 +14916,25 @@ var motionTriggerCapability = {
14167
14916
  runtimeState: MotionTriggerRuntimeStateSchema
14168
14917
  };
14169
14918
  /**
14170
- * Shared geometry vocabulary for on-frame shape caps privacy-mask,
14171
- * motion-zones, and the detection zones/lines editor all speak this one
14172
- * language so a single drawing-plane editor and the providers stay
14173
- * decoupled from each cap's storage.
14174
- *
14175
- * All coordinates are normalized 0..1 of the camera frame (top-left
14176
- * origin). Each cap composes the SUBSET of shape kinds it supports and
14177
- * advertises it via `supportedShapes` in its `getOptions`.
14919
+ * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
14920
+ * on-camera motion-detection mask is a single `grid` region (a row-major
14921
+ * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
14922
+ * a region keeps one drawing-plane model across all geometry caps.
14178
14923
  */
14179
- /** A normalized 0..1 point (top-left origin). */
14180
- var MaskPointSchema = object({
14181
- x: number(),
14182
- y: number()
14183
- });
14184
- /** Axis-aligned rectangle (normalized 0..1). */
14185
- var MaskRectShapeSchema = object({
14186
- kind: literal("rect"),
14187
- x: number(),
14188
- y: number(),
14189
- width: number(),
14190
- height: number()
14924
+ /** A motion-zone region exactly one boolean cell grid today. */
14925
+ var MotionZoneRegionSchema = object({
14926
+ id: number(),
14927
+ enabled: boolean(),
14928
+ shape: MaskGridShapeSchema
14191
14929
  });
14192
- /** Free polygon an ordered list of normalized vertices (≥3). */
14193
- var MaskPolygonShapeSchema = object({
14194
- kind: literal("polygon"),
14195
- points: array(MaskPointSchema)
14196
- });
14197
- /** Boolean cell grid row-major, length === gridWidth*gridHeight. */
14198
- var MaskGridShapeSchema = object({
14199
- kind: literal("grid"),
14200
- gridWidth: number(),
14201
- gridHeight: number(),
14202
- cells: array(boolean())
14203
- });
14204
- discriminatedUnion("kind", [
14205
- MaskRectShapeSchema,
14206
- MaskPolygonShapeSchema,
14207
- MaskGridShapeSchema,
14208
- object({
14209
- kind: literal("line"),
14210
- points: array(MaskPointSchema)
14211
- })
14212
- ]);
14213
- /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
14214
- var MaskShapeKindSchema = _enum([
14215
- "rect",
14216
- "polygon",
14217
- "grid",
14218
- "line"
14219
- ]);
14220
- /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
14221
- var MaskPolygonVerticesSchema = object({
14222
- min: number(),
14223
- max: number()
14224
- });
14225
- /** Grid dimensions when a cap supports 'grid'. */
14226
- var MaskGridDimsSchema = object({
14227
- width: number(),
14228
- height: number()
14229
- });
14230
- /**
14231
- * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
14232
- * on-camera motion-detection mask is a single `grid` region (a row-major
14233
- * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
14234
- * a region keeps one drawing-plane model across all geometry caps.
14235
- */
14236
- /** A motion-zone region — exactly one boolean cell grid today. */
14237
- var MotionZoneRegionSchema = object({
14238
- id: number(),
14239
- enabled: boolean(),
14240
- shape: MaskGridShapeSchema
14241
- });
14242
- /** Current on-camera motion-detection state — master enable + sensitivity +
14243
- * the grid region(s). */
14244
- var MotionZoneStatusSchema = object({
14245
- enabled: boolean(),
14246
- sensitivity: number(),
14247
- /** Grid region(s). Today exactly one `grid` shape. */
14248
- regions: array(MotionZoneRegionSchema),
14249
- lastFetchedAt: number()
14930
+ /** Current on-camera motion-detection state master enable + sensitivity +
14931
+ * the grid region(s). */
14932
+ var MotionZoneStatusSchema = object({
14933
+ enabled: boolean(),
14934
+ sensitivity: number(),
14935
+ /** Grid region(s). Today exactly one `grid` shape. */
14936
+ regions: array(MotionZoneRegionSchema),
14937
+ lastFetchedAt: number()
14250
14938
  });
14251
14939
  /** Per-camera availability — grid dims are fixed per camera model; the UI
14252
14940
  * sizes its editor from `grid`. */
@@ -17478,94 +18166,6 @@ var EnrichedWidgetMetadataSchema = WidgetMetadataSchema.extend({
17478
18166
  bundleUrl: string()
17479
18167
  });
17480
18168
  method(_void(), array(EnrichedWidgetMetadataSchema).readonly());
17481
- var NotificationRuleConditionsSchema = object({
17482
- deviceIds: array(number()).readonly().optional(),
17483
- classNames: array(string()).readonly().optional(),
17484
- zoneIds: array(string()).readonly().optional(),
17485
- minConfidence: number().optional(),
17486
- source: _enum([
17487
- "pipeline",
17488
- "onboard",
17489
- "any"
17490
- ]).optional(),
17491
- schedule: object({
17492
- days: array(number()).readonly(),
17493
- startHour: number(),
17494
- endHour: number()
17495
- }).optional(),
17496
- cooldownSeconds: number().optional(),
17497
- minDwellSeconds: number().optional(),
17498
- /** Match against `event.data.eventType` token (e.g. `'press_long'`). When non-empty, only events
17499
- * carrying a matching `data.eventType` string pass this condition. Rules without this field are
17500
- * unaffected (back-compat). Distinct from `rule.eventTypes` which holds EventCategory strings. */
17501
- eventTypeTokens: array(string()).readonly().optional(),
17502
- /** Match detections whose CLIP image embedding is semantically similar to this free-text
17503
- * description. Requires the embedding-encoder cap to have pre-warmed the text vector.
17504
- * `minSimilarity` is the cosine similarity threshold in [0, 1]. */
17505
- clipDescription: object({
17506
- text: string().min(1),
17507
- minSimilarity: number().min(0).max(1)
17508
- }).optional(),
17509
- /** Match events whose recognized-entity label (face identity name or plate
17510
- * vehicle name, propagated onto `event.data.label`) is one of these values.
17511
- * Empty/absent → unaffected (back-compat). Enables "notify me when <named
17512
- * vehicle/person> is seen". */
17513
- labels: array(string()).readonly().optional()
17514
- });
17515
- var NotificationRuleTemplateSchema = object({
17516
- title: string(),
17517
- body: string(),
17518
- imageMode: _enum([
17519
- "crop",
17520
- "annotated",
17521
- "full",
17522
- "none"
17523
- ])
17524
- });
17525
- var NotificationRuleSchema = object({
17526
- id: string(),
17527
- name: string(),
17528
- enabled: boolean(),
17529
- eventTypes: array(string()).readonly(),
17530
- conditions: NotificationRuleConditionsSchema,
17531
- outputs: array(string()).readonly(),
17532
- template: NotificationRuleTemplateSchema.optional(),
17533
- priority: _enum([
17534
- "low",
17535
- "normal",
17536
- "high",
17537
- "critical"
17538
- ])
17539
- });
17540
- var NotificationTestResultSchema = object({
17541
- ruleId: string(),
17542
- eventId: string(),
17543
- timestamp: number(),
17544
- wouldFire: boolean(),
17545
- reason: string().optional()
17546
- });
17547
- var NotificationHistoryEntrySchema = object({
17548
- id: string(),
17549
- ruleId: string(),
17550
- ruleName: string(),
17551
- eventId: string(),
17552
- timestamp: number(),
17553
- outputs: array(string()).readonly(),
17554
- success: boolean(),
17555
- error: string().optional(),
17556
- deviceId: number().optional()
17557
- });
17558
- var NotificationHistoryFilterSchema = object({
17559
- ruleId: string().optional(),
17560
- deviceId: number().optional(),
17561
- from: number().optional(),
17562
- to: number().optional(),
17563
- limit: number().optional()
17564
- });
17565
- 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({
17566
- ruleId: string(),
17567
- lookbackMinutes: number()
17568
- }), object({ results: array(NotificationTestResultSchema).readonly() }), { kind: "mutation" }), method(object({ filter: NotificationHistoryFilterSchema.optional() }), object({ entries: array(NotificationHistoryEntrySchema).readonly() }));
17569
18169
  /**
17570
18170
  * Alerts capability — collection-based internal alert system.
17571
18171
  *
@@ -17752,88 +18352,54 @@ method(object({
17752
18352
  password: string()
17753
18353
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
17754
18354
  /**
17755
- * `login-method` collection cap through which auth addons contribute
17756
- * their pre-auth login surfaces to the login page. This is the SINGLE,
17757
- * generic mechanism that supersedes the dead `auth.listProviders` reader:
17758
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
17759
- * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17760
- * procedure aggregates them for the unauthenticated login page.
17761
- *
17762
- * A contribution is a discriminated union on `kind`:
17763
- *
17764
- * - `redirect` — a declarative button. The login page renders a generic
17765
- * button that navigates to `startUrl` (an addon-owned HTTP route).
17766
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17767
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
17768
- * login page needs NO change.
17769
- *
17770
- * - `widget` — a Module-Federation widget the login page mounts (via
17771
- * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
17772
- * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
17773
- * mechanism kept for future use; no shipped addon uses it on the login
17774
- * page (the passkey ceremony below runs natively in the shell instead).
17775
- *
17776
- * - `passkey` — a declarative WebAuthn ceremony the shell renders
17777
- * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
17778
- * a remotely-loaded bundle). Carries the addon's effective `rpId` /
17779
- * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
17780
- * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
17781
- * fetching any remote code pre-auth. Contribution stays unconditional —
17782
- * enrollment state is never leaked pre-auth; visibility is a shell
17783
- * decision.
17784
- *
17785
- * Every contribution carries a `stage`:
17786
- * - `primary` — shown on the first credentials screen (OIDC /
17787
- * magic-link buttons; a future usernameless passkey).
17788
- * - `second-factor` — shown AFTER the password leg, gated on the
17789
- * returned `factors` (passkey-as-2FA today).
17790
- *
17791
- * `mount: skip` — the cap is read server-side by the core auth router
17792
- * (`registry.getCollection('login-method')`), never mounted as its own
17793
- * tRPC router.
18355
+ * A live terminal session hosted by the provider addon. Output and input do
18356
+ * NOT flow through the capability they use the addon data plane
18357
+ * (`GET /addon/terminal/<id>/out` SSE, `POST /addon/terminal/<id>/in`) because
18358
+ * terminal output must be ordered and lossless. The event bus is telemetry and
18359
+ * may drop chunks ([D8]), and a dropped chunk desynchronises the vt parser
18360
+ * permanently until a full repaint. The capability owns only lifecycle.
17794
18361
  */
17795
- /** When a login method renders in the two-phase login flow. */
17796
- var LoginStageEnum = _enum(["primary", "second-factor"]);
17797
- /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
17798
- var LoginMethodContributionSchema = discriminatedUnion("kind", [
17799
- object({
17800
- kind: literal("redirect"),
17801
- /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
17802
- id: string(),
17803
- /** Operator-facing button label. */
17804
- label: string(),
17805
- /** lucide-react icon name. */
17806
- icon: string().optional(),
17807
- /** Addon-owned HTTP route the button navigates to (GET). */
17808
- startUrl: string(),
17809
- stage: LoginStageEnum
17810
- }),
17811
- object({
17812
- kind: literal("widget"),
17813
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
17814
- id: string(),
17815
- /** Owning addon id — drives the public bundle URL + the MF namespace. */
17816
- addonId: string(),
17817
- /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
17818
- bundle: string(),
17819
- /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
17820
- remote: WidgetRemoteSchema,
17821
- stage: LoginStageEnum
17822
- }),
17823
- object({
17824
- kind: literal("passkey"),
17825
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
17826
- id: string(),
17827
- /** Operator-facing button label. */
17828
- label: string(),
17829
- stage: LoginStageEnum,
17830
- /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
17831
- rpId: string(),
17832
- /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
17833
- origin: string().nullable()
17834
- })
17835
- ]);
17836
- method(_void(), array(LoginMethodContributionSchema).readonly());
18362
+ var TerminalSessionInfoSchema = object({
18363
+ /** Opaque session id minted by the provider on `openSession`. */
18364
+ sessionId: string(),
18365
+ /** The pre-declared profile this session runs (never a free-form command). */
18366
+ profileId: string(),
18367
+ /** Human-readable profile label for the UI session list. */
18368
+ label: string(),
18369
+ cols: number().int().positive(),
18370
+ rows: number().int().positive(),
18371
+ /** ms-epoch the session's pty was spawned. */
18372
+ startedAt: number()
18373
+ });
18374
+ /**
18375
+ * A profile the operator may open — a pre-declared, allowlisted program
18376
+ * (`monitor` → `btm`). The capability accepts only these ids; a free-form
18377
+ * command string would be remote code execution as the server's user, so it is
18378
+ * deliberately not part of the contract.
18379
+ */
18380
+ var TerminalProfileInfoSchema = object({
18381
+ profileId: string(),
18382
+ label: string(),
18383
+ description: string().optional()
18384
+ });
18385
+ method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(TerminalSessionInfoSchema).readonly(), { auth: "admin" }), method(object({
18386
+ profileId: string(),
18387
+ cols: number().int().positive(),
18388
+ rows: number().int().positive()
18389
+ }), TerminalSessionInfoSchema, {
18390
+ kind: "mutation",
18391
+ auth: "admin"
18392
+ }), method(object({
18393
+ sessionId: string(),
18394
+ cols: number().int().positive(),
18395
+ rows: number().int().positive()
18396
+ }), _void(), {
18397
+ kind: "mutation",
18398
+ auth: "admin"
18399
+ }), method(object({ sessionId: string() }), _void(), {
18400
+ kind: "mutation",
18401
+ auth: "admin"
18402
+ });
17837
18403
  /**
17838
18404
  * Orchestrator-side destination metadata. The orchestrator computes
17839
18405
  * `id = <addonId>:<subId>` from its provider lookup so consumers
@@ -17935,11 +18501,53 @@ var LocationStatSchema = object({
17935
18501
  fileCount: number(),
17936
18502
  present: boolean()
17937
18503
  });
18504
+ /**
18505
+ * A backup schedule — the N:M "entry" that binds one cron cadence to a
18506
+ * SET of destination locations. Supersedes the per-location cron on
18507
+ * `BackupDestinationPolicy`: an operator creates a schedule, picks the
18508
+ * `backups` locations it should write to, and the orchestrator fans a
18509
+ * single archive out to all of them when the cron fires.
18510
+ *
18511
+ * `retentionCount` is per-schedule (D-decision 2026-07-28): every
18512
+ * location targeted by this schedule keeps this many archives from
18513
+ * this schedule's runs.
18514
+ *
18515
+ * `dataSources` optionally narrows which top-level state locations
18516
+ * (db, addons, tls, …) are archived; omitted = the orchestrator's
18517
+ * default full set.
18518
+ */
18519
+ var BackupScheduleSchema = object({
18520
+ /** Stable id. Generated by the orchestrator on first upsert if absent. */
18521
+ id: string(),
18522
+ /** Operator-facing display name. */
18523
+ label: string(),
18524
+ /** 5-field POSIX cron. Empty = disabled cadence (kept for editing). */
18525
+ cron: string(),
18526
+ /** Master on/off toggle for the whole schedule. */
18527
+ enabled: boolean(),
18528
+ /** `backups`-location ids this schedule writes to (fan-out set). */
18529
+ locationIds: array(string()).readonly(),
18530
+ /** Archives kept per targeted location for this schedule. */
18531
+ retentionCount: number().int().min(1).max(1e3),
18532
+ /** Optional subset of source locations to include; omitted = all. */
18533
+ dataSources: array(string()).readonly().optional(),
18534
+ /** ms-epoch of last successful run. */
18535
+ lastRunAt: number().optional(),
18536
+ /** ms-epoch of next computed firing (read-only, filled on list). */
18537
+ nextRunAt: number().optional()
18538
+ });
17938
18539
  method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }), method(object({
17939
18540
  /** Subset of registered `backup-destination` addon ids to write to. */
17940
18541
  destinations: array(string()).optional(),
17941
18542
  locations: array(string()).optional(),
17942
- label: string().optional()
18543
+ label: string().optional(),
18544
+ /**
18545
+ * Per-run retention override applied to every targeted
18546
+ * destination. Used by schedule-driven runs (per-entry
18547
+ * retention). Omitted = each destination's own policy
18548
+ * retention (manual runs).
18549
+ */
18550
+ retentionCount: number().int().min(1).max(1e3).optional()
17943
18551
  }).optional(), array(BackupEntrySchema).readonly(), {
17944
18552
  kind: "mutation",
17945
18553
  auth: "admin"
@@ -17988,7 +18596,21 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
17988
18596
  ok: boolean(),
17989
18597
  error: string().optional(),
17990
18598
  nextRuns: array(number()).readonly()
17991
- }));
18599
+ })), method(_void(), array(BackupScheduleSchema).readonly(), { auth: "admin" }), method(object({
18600
+ id: string().optional(),
18601
+ label: string(),
18602
+ cron: string(),
18603
+ enabled: boolean(),
18604
+ locationIds: array(string()).readonly(),
18605
+ retentionCount: number().int().min(1).max(1e3),
18606
+ dataSources: array(string()).readonly().optional()
18607
+ }), BackupScheduleSchema, {
18608
+ kind: "mutation",
18609
+ auth: "admin"
18610
+ }), method(object({ id: string() }), _void(), {
18611
+ kind: "mutation",
18612
+ auth: "admin"
18613
+ });
17992
18614
  /**
17993
18615
  * `broker` — unified pub/sub broker registry, system-scoped collection.
17994
18616
  *
@@ -19178,851 +19800,934 @@ method(_void(), array(string()).readonly(), { auth: "admin" }), method(object({
19178
19800
  kind: "mutation",
19179
19801
  auth: "admin"
19180
19802
  });
19181
- var LogLevelSchema = _enum([
19182
- "debug",
19183
- "info",
19184
- "warn",
19185
- "error"
19186
- ]);
19187
- var LogEntrySchema = object({
19188
- timestamp: date(),
19189
- level: LogLevelSchema,
19190
- scope: array(string()),
19191
- message: string(),
19192
- meta: record(string(), unknown()).optional(),
19193
- tags: record(string(), string()).optional()
19803
+ /**
19804
+ * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
19805
+ * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
19806
+ * caps stay wire-compatible without a circular cap→cap import.
19807
+ *
19808
+ * Errors are a discriminated-union RESULT, never thrown: the shape survives
19809
+ * every transport tier structurally, and failed calls still write usage rows.
19810
+ * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
19811
+ */
19812
+ var LlmUsageSchema = object({
19813
+ inputTokens: number(),
19814
+ outputTokens: number()
19194
19815
  });
19195
- method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
19196
- scope: array(string()).optional(),
19197
- level: LogLevelSchema.optional(),
19198
- since: date().optional(),
19199
- until: date().optional(),
19200
- limit: number().optional(),
19201
- tags: record(string(), string()).optional()
19202
- }), array(LogEntrySchema).readonly());
19203
- var CpuBreakdownSchema = object({
19204
- total: number(),
19205
- user: number(),
19206
- system: number(),
19207
- irq: number(),
19208
- nice: number(),
19209
- loadAvg: tuple([
19210
- number(),
19211
- number(),
19212
- number()
19213
- ]),
19214
- cores: number()
19215
- });
19216
- var MemoryInfoSchema = object({
19217
- percent: number(),
19218
- totalBytes: number(),
19219
- usedBytes: number(),
19220
- availableBytes: number(),
19221
- swapUsedBytes: number(),
19222
- swapTotalBytes: number()
19223
- });
19224
- var DiskIoSnapshotSchema = object({
19225
- readBytes: number(),
19226
- writeBytes: number(),
19227
- readOps: number(),
19228
- writeOps: number(),
19229
- timestampMs: number()
19230
- });
19231
- var NetworkIoSnapshotSchema = object({
19232
- rxBytes: number(),
19233
- txBytes: number(),
19234
- rxPackets: number(),
19235
- txPackets: number(),
19236
- rxErrors: number(),
19237
- txErrors: number(),
19238
- timestampMs: number()
19239
- });
19240
- var MetricsGpuInfoSchema = object({
19241
- utilization: number(),
19816
+ var LlmErrorCodeSchema = _enum([
19817
+ "timeout",
19818
+ "rate-limited",
19819
+ "auth",
19820
+ "refusal",
19821
+ "bad-request",
19822
+ "unavailable",
19823
+ "no-profile",
19824
+ "budget-exceeded",
19825
+ "adapter-error"
19826
+ ]);
19827
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
19828
+ ok: literal(true),
19829
+ text: string(),
19242
19830
  model: string(),
19243
- memoryUsedBytes: number(),
19244
- memoryTotalBytes: number(),
19245
- temperature: number().nullable()
19246
- });
19247
- var ProcessResourceInfoSchema = object({
19248
- openFds: number(),
19249
- threadCount: number(),
19250
- activeHandles: number(),
19251
- activeRequests: number()
19252
- });
19253
- var PressureAvgsSchema = object({
19254
- avg10: number(),
19255
- avg60: number(),
19256
- avg300: number()
19831
+ usage: LlmUsageSchema,
19832
+ truncated: boolean(),
19833
+ latencyMs: number()
19834
+ }), object({
19835
+ ok: literal(false),
19836
+ code: LlmErrorCodeSchema,
19837
+ message: string(),
19838
+ retryAfterMs: number().optional()
19839
+ })]);
19840
+ /**
19841
+ * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
19842
+ * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
19843
+ * notification-output.cap.ts:27-31 precedents).
19844
+ */
19845
+ var LlmImageSchema = object({
19846
+ bytes: _instanceof(Uint8Array),
19847
+ mimeType: string()
19257
19848
  });
19258
- var PressureInfoSchema = object({
19259
- some: PressureAvgsSchema,
19260
- full: PressureAvgsSchema.nullable()
19849
+ var LlmGenerateBaseInputSchema = object({
19850
+ /** Collection routing (the notification-output posture). */
19851
+ addonId: string().optional(),
19852
+ /** Explicit profile; else the resolution chain (spec §3). */
19853
+ profileId: string().optional(),
19854
+ /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
19855
+ consumer: string(),
19856
+ system: string().optional(),
19857
+ /** v1: single-turn. `messages[]` is a v2 additive field. */
19858
+ prompt: string(),
19859
+ /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
19860
+ jsonSchema: record(string(), unknown()).optional(),
19861
+ /** Per-call override of the profile default. */
19862
+ maxTokens: number().int().positive().optional(),
19863
+ temperature: number().optional()
19261
19864
  });
19262
- var SystemResourceSnapshotSchema = object({
19263
- cpu: CpuBreakdownSchema,
19264
- memory: MemoryInfoSchema,
19265
- gpu: MetricsGpuInfoSchema.nullable(),
19266
- network: NetworkIoSnapshotSchema,
19267
- disk: DiskIoSnapshotSchema,
19268
- pressure: object({
19269
- cpu: PressureInfoSchema.nullable(),
19270
- memory: PressureInfoSchema.nullable(),
19271
- io: PressureInfoSchema.nullable()
19865
+ /**
19866
+ * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
19867
+ * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
19868
+ * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
19869
+ * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
19870
+ * this only through the `llm` cap's methods.
19871
+ *
19872
+ * One running llama-server child per node in v1 (models are RAM-heavy).
19873
+ * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
19874
+ * watchdog — operator decision #3).
19875
+ */
19876
+ var ManagedModelRefSchema = discriminatedUnion("kind", [
19877
+ object({
19878
+ kind: literal("catalog"),
19879
+ catalogId: string()
19272
19880
  }),
19273
- process: ProcessResourceInfoSchema,
19274
- cpuTemperature: number().nullable(),
19275
- timestampMs: number()
19276
- });
19277
- var DiskSpaceInfoSchema = object({
19278
- path: string(),
19279
- totalBytes: number(),
19280
- usedBytes: number(),
19281
- availableBytes: number(),
19282
- percent: number()
19283
- });
19284
- var PidResourceStatsSchema = object({
19285
- pid: number(),
19286
- cpu: number(),
19287
- memory: number(),
19288
- /**
19289
- * Private (anonymous) resident bytes — the per-process V8 heap + native
19290
- * allocations NOT shared with other processes (Linux RssAnon). This is the
19291
- * "real" per-runner cost; summing it across runners is meaningful, unlike
19292
- * `memory` (RSS), which double-counts the shared mmap'd framework code.
19293
- * Undefined where /proc is unavailable (e.g. macOS).
19294
- */
19295
- privateBytes: number().optional(),
19296
- /**
19297
- * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
19298
- * code shared copy-on-write across runners. Undefined on macOS.
19299
- */
19300
- sharedBytes: number().optional()
19881
+ object({
19882
+ kind: literal("url"),
19883
+ url: string(),
19884
+ sha256: string().optional()
19885
+ }),
19886
+ object({
19887
+ kind: literal("path"),
19888
+ path: string()
19889
+ })
19890
+ ]);
19891
+ var ManagedRuntimeConfigSchema = object({
19892
+ /** WHERE the runtime lives — hub or any agent. */
19893
+ nodeId: string(),
19894
+ /** Closed for v1; 'ollama' is a v2 candidate. */
19895
+ engine: _enum(["llama-cpp"]),
19896
+ model: ManagedModelRefSchema,
19897
+ contextSize: number().int().default(4096),
19898
+ /** 0 = CPU-only. */
19899
+ gpuLayers: number().int().default(0),
19900
+ /** Default: cpus-2, clamped ≥1 (resolved node-side). */
19901
+ threads: number().int().optional(),
19902
+ /** Concurrent slots. */
19903
+ parallel: number().int().default(1),
19904
+ /** Else lazy: first generate boots it. */
19905
+ autoStart: boolean().default(false),
19906
+ /** 0 = never; frees RAM after quiet periods. */
19907
+ idleStopMinutes: number().int().default(30)
19301
19908
  });
19302
- var AddonInstanceSchema = object({
19303
- addonId: string(),
19909
+ var LlmRuntimeStatusSchema = object({
19910
+ /** Status is ALWAYS node-qualified. */
19304
19911
  nodeId: string(),
19305
- role: _enum(["hub", "worker"]),
19306
- pid: number(),
19307
19912
  state: _enum([
19308
- "starting",
19309
- "running",
19310
- "stopping",
19311
19913
  "stopped",
19312
- "crashed"
19313
- ]),
19314
- uptimeSec: number()
19315
- });
19316
- var NodeProcessSchema = object({
19317
- pid: number(),
19318
- ppid: number(),
19319
- pgid: number(),
19320
- classification: _enum([
19321
- "root",
19322
- "managed",
19323
- "system",
19324
- "ghost"
19914
+ "downloading",
19915
+ "starting",
19916
+ "ready",
19917
+ "crashed",
19918
+ "failed"
19325
19919
  ]),
19326
- /** `$process` addon binding when `managed`, else null. */
19327
- addonId: string().nullable(),
19328
- /** Kernel-reported nodeId when the process is a known agent/worker. */
19329
- nodeId: string().nullable(),
19330
- /** Truncated command line. */
19331
- command: string(),
19332
- cpuPercent: number(),
19333
- memoryRssBytes: number(),
19334
- /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
19335
- uptimeSec: number(),
19336
- /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
19337
- orphaned: boolean()
19338
- });
19339
- var KillProcessInputSchema = object({
19340
- pid: number(),
19341
- /** Force = SIGKILL. Default is SIGTERM. */
19342
- force: boolean().optional()
19920
+ pid: number().optional(),
19921
+ port: number().optional(),
19922
+ modelPath: string().optional(),
19923
+ modelId: string().optional(),
19924
+ downloadProgress: number().min(0).max(1).optional(),
19925
+ lastError: string().optional(),
19926
+ crashesInWindow: number(),
19927
+ /** Child RSS (sampled best-effort). */
19928
+ memoryBytes: number().optional(),
19929
+ vramBytes: number().optional()
19343
19930
  });
19344
- var KillProcessResultSchema = object({
19345
- success: boolean(),
19346
- reason: string().optional(),
19347
- signal: _enum(["SIGTERM", "SIGKILL"]).optional()
19931
+ var LlmNodeModelSchema = object({
19932
+ file: string(),
19933
+ sizeBytes: number(),
19934
+ catalogId: string().optional(),
19935
+ installedAt: number().optional()
19348
19936
  });
19349
- var DumpHeapSnapshotInputSchema = object({
19350
- /** The addon whose runner should dump a heap snapshot. */
19351
- addonId: string() });
19352
- var DumpHeapSnapshotResultSchema = object({
19353
- success: boolean(),
19354
- /** Path of the written .heapsnapshot inside the runner's container/host. */
19355
- path: string().optional(),
19356
- /** Process pid that was signalled. */
19357
- pid: number().optional(),
19358
- reason: string().optional()
19937
+ var LlmRuntimeDiskUsageSchema = object({
19938
+ nodeId: string(),
19939
+ modelsBytes: number(),
19940
+ freeBytes: number().optional()
19359
19941
  });
19360
- var SystemMetricsSchema = object({
19361
- cpuPercent: number(),
19362
- memoryPercent: number(),
19363
- memoryUsedMB: number(),
19364
- memoryTotalMB: number(),
19365
- diskPercent: number().optional(),
19366
- temperature: number().optional(),
19367
- gpuPercent: number().optional(),
19368
- gpuMemoryPercent: number().optional()
19369
- });
19370
- 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, {
19942
+ method(LlmGenerateBaseInputSchema.extend({
19943
+ images: array(LlmImageSchema).optional(),
19944
+ runtime: ManagedRuntimeConfigSchema,
19945
+ /** The managed profile's timeout, threaded by the hub provider. */
19946
+ timeoutMs: number().int().positive().optional()
19947
+ }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
19371
19948
  kind: "mutation",
19372
19949
  auth: "admin"
19373
- }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
19950
+ }), method(object({}), _void(), {
19374
19951
  kind: "mutation",
19375
19952
  auth: "admin"
19376
- });
19377
- method(object({
19378
- sourceUrl: string(),
19379
- metadata: ModelConvertMetadataSchema,
19380
- targets: array(ConvertTargetSchema).min(1).readonly(),
19381
- calibrationRef: string().optional(),
19382
- sessionId: string().optional()
19383
- }), ConvertResultSchema, {
19953
+ }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
19384
19954
  kind: "mutation",
19385
- auth: "admin",
19386
- timeoutMs: 6e5
19387
- });
19388
- method(object({
19389
- nodeId: string(),
19390
- modelId: string(),
19391
- format: _enum(MODEL_FORMATS),
19392
- entry: ModelCatalogEntrySchema
19393
- }), object({
19394
- ok: boolean(),
19395
- /** sha256 of the staged tarball (empty for a hub-local no-op). */
19396
- sha256: string(),
19397
- bytes: number(),
19398
- /** The target node's modelsDir the artifact landed in. */
19399
- path: string()
19400
- }), {
19955
+ auth: "admin"
19956
+ }), method(object({ file: string() }), _void(), {
19401
19957
  kind: "mutation",
19402
19958
  auth: "admin"
19403
- });
19404
- /**
19405
- * `mqtt-broker` — broker-registry cap.
19406
- *
19407
- * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
19408
- * MQTT brokers (external + optionally an embedded `aedes`-backed one)
19409
- * and (b) the connection details a consumer addon needs to spin up
19410
- * its OWN `mqtt.js` client.
19411
- *
19412
- * Why: pub/sub routing over the system event-bus loses fidelity
19413
- * (callback shape, QoS guarantees, will/retain semantics) and adds
19414
- * refcount bookkeeping that addons would rather own themselves. The
19415
- * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
19416
- * features anyway — give it the connection config, get out of the way.
19417
- *
19418
- * Consumer flow:
19419
- * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
19420
- * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
19421
- * client.subscribe('zigbee2mqtt/+')
19422
- *
19423
- * Collection mode: multiple brokers (e.g. one local mosquitto + one
19424
- * cloud bridge). The "embedded" entry (when present) is just another
19425
- * broker in the registry — its lifecycle is owned by the addon that
19426
- * spawned it.
19427
- */
19428
- var BrokerKindSchema = _enum(["external", "embedded"]);
19959
+ }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
19429
19960
  /**
19430
- * Broker live-probe status.
19961
+ * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
19962
+ * methods concat-fan across providers; single-row methods route to ONE
19963
+ * provider by the `addonId` in the call input (the notification-output
19964
+ * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
19965
+ * (hub-placed); the cap stays open for future providers.
19431
19966
  *
19432
- * - `connected` last probe completed a clean CONNACK
19433
- * - `disconnected` — no probe has run yet (cold cache)
19434
- * - `auth-failed` CONNACK refused with auth error (RC 4 / 5)
19435
- * - `unreachable` — TCP connect timed out / refused
19436
- * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
19967
+ * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
19968
+ * `apiKey` is a password field providers REDACT it on read and merge on
19969
+ * write; a stored key NEVER round-trips to a client.
19437
19970
  */
19438
- var BrokerStatusSchema$1 = _enum([
19439
- "connected",
19440
- "disconnected",
19441
- "auth-failed",
19442
- "unreachable",
19443
- "tls-error"
19971
+ var LlmProfileKindSchema = _enum([
19972
+ "openai-compatible",
19973
+ "openai",
19974
+ "anthropic",
19975
+ "google",
19976
+ "managed-local"
19444
19977
  ]);
19445
- var BrokerInfoSchema = object({
19978
+ var LlmProfileSchema = object({
19446
19979
  id: string(),
19447
19980
  name: string(),
19448
- url: string(),
19449
- kind: BrokerKindSchema,
19450
- status: BrokerStatusSchema$1,
19451
- latencyMs: number().nullable(),
19452
- error: string().optional(),
19453
- /** Embedded brokers only: number of MQTT clients currently connected. */
19454
- connectedClients: number().int().nonnegative().optional(),
19455
- /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
19456
- lastCheckedAt: number().optional()
19981
+ kind: LlmProfileKindSchema,
19982
+ /** Stamped by the provider — keeps the fanned catalog routable. */
19983
+ addonId: string(),
19984
+ enabled: boolean(),
19985
+ /** Vendor model id, or the managed runtime's loaded model. */
19986
+ model: string(),
19987
+ /** Required for openai-compatible; override for cloud kinds. */
19988
+ baseUrl: string().optional(),
19989
+ /** ConfigUISchema type:'password' — never round-trips (spec §5). */
19990
+ apiKey: string().optional(),
19991
+ supportsVision: boolean(),
19992
+ temperature: number().min(0).max(2).optional(),
19993
+ maxTokens: number().int().positive().optional(),
19994
+ timeoutMs: number().int().positive().default(6e4),
19995
+ extraHeaders: record(string(), string()).optional(),
19996
+ /** kind === 'managed-local' only (spec §4). */
19997
+ runtime: ManagedRuntimeConfigSchema.optional()
19457
19998
  });
19458
- /**
19459
- * Connection details — what a consumer needs to call
19460
- * `mqtt.connect(url, options)`. We split URL + credentials so the
19461
- * consumer can pass them as `mqtt.connect(url, { username, password })`
19462
- * instead of stuffing creds into the URL (which leaks them into logs).
19463
- */
19464
- var BrokerConnectionDetailsSchema = object({
19465
- url: string(),
19466
- username: string().optional(),
19467
- password: string().optional(),
19468
- /**
19469
- * Suggested prefix for `clientId`. Each consumer should suffix this
19470
- * with its own discriminator (addon id, instance id) so reconnects
19471
- * don't kick each other off (MQTT spec: clientId must be unique per
19472
- * broker).
19473
- */
19474
- clientIdPrefix: string().optional()
19999
+ /** ConfigUISchema tree passed through untyped on the wire (the
20000
+ * notification-output `ConfigSchemaPassthrough` precedent at
20001
+ * notification-output.cap.ts:151); the exported TS type re-tightens it. */
20002
+ var ConfigSchemaPassthrough$1 = unknown();
20003
+ var LlmProfileKindDescriptorSchema = object({
20004
+ kind: LlmProfileKindSchema,
20005
+ label: string(),
20006
+ icon: string(),
20007
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
20008
+ addonId: string(),
20009
+ configSchema: ConfigSchemaPassthrough$1
19475
20010
  });
19476
- var AddBrokerInputSchema = object({
19477
- name: string().min(1),
19478
- url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
19479
- username: string().optional(),
19480
- password: string().optional(),
19481
- clientIdPrefix: string().optional()
20011
+ var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
20012
+ var LlmDefaultSchema = object({
20013
+ selector: LlmDefaultSelectorSchema,
20014
+ profileId: string()
19482
20015
  });
19483
- var AddBrokerResultSchema = object({ id: string() });
19484
- var IdInputSchema = object({ id: string() });
19485
- var TestResultSchema$1 = discriminatedUnion("ok", [object({
19486
- ok: literal(true),
19487
- latencyMs: number()
19488
- }), object({
19489
- ok: literal(false),
19490
- error: string()
19491
- })]);
19492
- var StartEmbeddedInputSchema = object({
19493
- port: number().int().min(1).max(65535).default(1883),
19494
- /** Allow anonymous connect (no username/password). Default: false. */
19495
- allowAnonymous: boolean().default(false),
19496
- /** Optional shared username/password for clients. */
19497
- username: string().optional(),
19498
- password: string().optional()
20016
+ /** Server-side rollup row getUsage never dumps raw call rows (spec §6). */
20017
+ var LlmUsageRollupSchema = object({
20018
+ day: string(),
20019
+ consumer: string(),
20020
+ profileId: string(),
20021
+ calls: number(),
20022
+ okCalls: number(),
20023
+ errorCalls: number(),
20024
+ inputTokens: number(),
20025
+ outputTokens: number(),
20026
+ avgLatencyMs: number()
19499
20027
  });
19500
- var StartEmbeddedResultSchema = object({
20028
+ /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
20029
+ var ManagedModelCatalogEntrySchema = object({
19501
20030
  id: string(),
19502
- url: string()
19503
- });
19504
- var StatusSchema = object({
19505
- brokerCount: number(),
19506
- embeddedRunning: boolean()
19507
- });
19508
- 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);
19509
- var NetworkEndpointSchema = object({
20031
+ label: string(),
20032
+ family: string(),
20033
+ purpose: _enum(["text", "vision"]),
19510
20034
  url: string(),
19511
- hostname: string(),
19512
- port: number(),
19513
- protocol: _enum(["http", "https"])
20035
+ sha256: string(),
20036
+ sizeBytes: number(),
20037
+ quantization: string(),
20038
+ /** Load-time guidance shown in the picker. */
20039
+ minRamBytes: number(),
20040
+ contextSizeDefault: number().int(),
20041
+ /** Vision models: companion projector file. */
20042
+ mmprojUrl: string().optional()
19514
20043
  });
19515
- var NetworkAccessStatusSchema = object({
19516
- connected: boolean(),
19517
- endpoint: NetworkEndpointSchema.nullable(),
20044
+ var LlmRuntimeNodeSchema = object({
20045
+ nodeId: string(),
20046
+ reachable: boolean(),
20047
+ status: LlmRuntimeStatusSchema.optional(),
20048
+ disk: LlmRuntimeDiskUsageSchema.optional(),
19518
20049
  error: string().optional()
19519
20050
  });
19520
- /**
19521
- * Optional, richer endpoint shape returned by providers that expose
19522
- * MORE than one ingress concurrently (Tailscale Ingress with mixed
19523
- * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
19524
- * the originating provider config (mode + sourcePort) so the
19525
- * orchestrator UI can label rows distinctly. Providers that expose only
19526
- * one endpoint just omit `listEndpoints` from their provider impl.
19527
- */
19528
- var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
19529
- /**
19530
- * Stable id within the provider — typically `<mode>-<sourcePort>` so
19531
- * the orchestrator can dedupe across `listEndpoints` polls.
19532
- */
19533
- id: string(),
19534
- /** Operator-facing label (mirrors `MeshEndpoint.label`). */
19535
- label: string(),
19536
- /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
19537
- mode: string().optional(),
19538
- /** Originating local port the ingress fronts (informational). */
19539
- sourcePort: number().optional()
20051
+ var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
20052
+ var ProfileRefInputSchema = object({
20053
+ addonId: string(),
20054
+ profileId: string()
19540
20055
  });
19541
- method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
19542
- /**
19543
- * notification-output — canonical, capability-gated notification delivery.
19544
- *
19545
- * Apprise-derived model (see
19546
- * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
19547
- * callers emit ONE canonical `Notification`; each provider declares a
19548
- * per-kind capability descriptor (`TargetKind`), and the pure degrade
19549
- * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
19550
- * message to what the kind supports — callers never special-case a service.
19551
- *
19552
- * DESIGN DECISIONS (locked):
19553
- * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
19554
- * `setTargetEnabled`), each provider persisting via the `settings-store`
19555
- * cap. Rationale: the admin UI needs one uniform surface across the
19556
- * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
19557
- * alternative would fork the UI per addon and cannot host the
19558
- * discovery→adopt flow.
19559
- * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
19560
- * the generated cap-mount auto-`concatCollection`-fans them across every
19561
- * registered provider (notifiers addon + HA addon) so one catalog is
19562
- * routable. `send` / `testTarget` / CRUD route to ONE provider by the
19563
- * `addonId` the generated collection router extracts from the call input.
19564
- * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
19565
- * transformer) + UDS MsgPack both round-trip typed arrays — already used by
19566
- * `storage` / `storage-provider` / `recording` caps over the same path. No
19567
- * base64 fallback needed.
19568
- *
19569
- * TODO (deferred, closed-set change — separate decision): add
19570
- * `providerKind: 'notify'` so notification providers surface on the unified
19571
- * admin "Integrations" page.
19572
- */
19573
- /**
19574
- * Zentik-derived typed-media enum — the superset across every kind. Each
19575
- * adapter picks what it supports and the degrade engine filters the rest.
19576
- */
19577
- var AttachmentMediaTypeSchema = _enum([
19578
- "image",
19579
- "video",
19580
- "gif",
19581
- "audio",
19582
- "icon"
20056
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
20057
+ kind: "mutation",
20058
+ auth: "admin"
20059
+ }), method(ProfileRefInputSchema, _void(), {
20060
+ kind: "mutation",
20061
+ auth: "admin"
20062
+ }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
20063
+ kind: "mutation",
20064
+ auth: "admin"
20065
+ }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
20066
+ selector: LlmDefaultSelectorSchema,
20067
+ profileId: string().nullable()
20068
+ }), _void(), {
20069
+ kind: "mutation",
20070
+ auth: "admin"
20071
+ }), method(object({
20072
+ since: number().optional(),
20073
+ until: number().optional(),
20074
+ consumer: string().optional(),
20075
+ profileId: string().optional()
20076
+ }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
20077
+ nodeId: string(),
20078
+ model: ManagedModelRefSchema
20079
+ }), _void(), {
20080
+ kind: "mutation",
20081
+ auth: "admin"
20082
+ }), method(object({
20083
+ nodeId: string(),
20084
+ file: string()
20085
+ }), _void(), {
20086
+ kind: "mutation",
20087
+ auth: "admin"
20088
+ }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
20089
+ kind: "mutation",
20090
+ auth: "admin"
20091
+ }), method(ProfileRefInputSchema, _void(), {
20092
+ kind: "mutation",
20093
+ auth: "admin"
20094
+ });
20095
+ var LogLevelSchema = _enum([
20096
+ "debug",
20097
+ "info",
20098
+ "warn",
20099
+ "error"
19583
20100
  ]);
20101
+ var LogEntrySchema = object({
20102
+ timestamp: date(),
20103
+ level: LogLevelSchema,
20104
+ scope: array(string()),
20105
+ message: string(),
20106
+ meta: record(string(), unknown()).optional(),
20107
+ tags: record(string(), string()).optional()
20108
+ });
20109
+ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
20110
+ scope: array(string()).optional(),
20111
+ level: LogLevelSchema.optional(),
20112
+ since: date().optional(),
20113
+ until: date().optional(),
20114
+ limit: number().optional(),
20115
+ tags: record(string(), string()).optional()
20116
+ }), array(LogEntrySchema).readonly());
19584
20117
  /**
19585
- * A single attachment. Exactly one of `url` (remote source, most adapters
19586
- * prefer this) or `bytes` (inline source; required for Pushover-style
19587
- * bytes-only kinds) MUST be present — the degrade engine expresses a
19588
- * url→bytes fetch as a `needsFetch` directive the adapter executes.
20118
+ * `login-method` collection cap through which auth addons contribute
20119
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
20120
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
20121
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
20122
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
20123
+ * procedure aggregates them for the unauthenticated login page.
20124
+ *
20125
+ * A contribution is a discriminated union on `kind`:
20126
+ *
20127
+ * - `redirect` — a declarative button. The login page renders a generic
20128
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
20129
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
20130
+ * ZERO shell-side JS. A future SSO addon plugs in the same way — the
20131
+ * login page needs NO change.
20132
+ *
20133
+ * - `widget` — a Module-Federation widget the login page mounts (via
20134
+ * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
20135
+ * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
20136
+ * mechanism kept for future use; no shipped addon uses it on the login
20137
+ * page (the passkey ceremony below runs natively in the shell instead).
20138
+ *
20139
+ * - `passkey` — a declarative WebAuthn ceremony the shell renders
20140
+ * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
20141
+ * a remotely-loaded bundle). Carries the addon's effective `rpId` /
20142
+ * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
20143
+ * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
20144
+ * fetching any remote code pre-auth. Contribution stays unconditional —
20145
+ * enrollment state is never leaked pre-auth; visibility is a shell
20146
+ * decision.
20147
+ *
20148
+ * Every contribution carries a `stage`:
20149
+ * - `primary` — shown on the first credentials screen (OIDC /
20150
+ * magic-link buttons; a future usernameless passkey).
20151
+ * - `second-factor` — shown AFTER the password leg, gated on the
20152
+ * returned `factors` (passkey-as-2FA today).
20153
+ *
20154
+ * `mount: skip` — the cap is read server-side by the core auth router
20155
+ * (`registry.getCollection('login-method')`), never mounted as its own
20156
+ * tRPC router.
19589
20157
  */
19590
- var AttachmentSchema = object({
19591
- mediaType: AttachmentMediaTypeSchema,
19592
- url: string().optional(),
19593
- bytes: _instanceof(Uint8Array).optional(),
19594
- mime: string().optional(),
19595
- name: string().optional()
19596
- }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
19597
- var NotificationFormatSchema = _enum([
19598
- "text",
19599
- "markdown",
19600
- "html"
20158
+ /** When a login method renders in the two-phase login flow. */
20159
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
20160
+ /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
20161
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [
20162
+ object({
20163
+ kind: literal("redirect"),
20164
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
20165
+ id: string(),
20166
+ /** Operator-facing button label. */
20167
+ label: string(),
20168
+ /** lucide-react icon name. */
20169
+ icon: string().optional(),
20170
+ /** Addon-owned HTTP route the button navigates to (GET). */
20171
+ startUrl: string(),
20172
+ stage: LoginStageEnum
20173
+ }),
20174
+ object({
20175
+ kind: literal("widget"),
20176
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
20177
+ id: string(),
20178
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
20179
+ addonId: string(),
20180
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
20181
+ bundle: string(),
20182
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
20183
+ remote: WidgetRemoteSchema,
20184
+ stage: LoginStageEnum
20185
+ }),
20186
+ object({
20187
+ kind: literal("passkey"),
20188
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
20189
+ id: string(),
20190
+ /** Operator-facing button label. */
20191
+ label: string(),
20192
+ stage: LoginStageEnum,
20193
+ /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
20194
+ rpId: string(),
20195
+ /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
20196
+ origin: string().nullable()
20197
+ })
19601
20198
  ]);
19602
- /** A single tap-through action button. */
19603
- var NotificationActionSchema = object({
19604
- id: string(),
19605
- label: string(),
19606
- url: string().optional()
20199
+ method(_void(), array(LoginMethodContributionSchema).readonly());
20200
+ var CpuBreakdownSchema = object({
20201
+ total: number(),
20202
+ user: number(),
20203
+ system: number(),
20204
+ irq: number(),
20205
+ nice: number(),
20206
+ loadAvg: tuple([
20207
+ number(),
20208
+ number(),
20209
+ number()
20210
+ ]),
20211
+ cores: number()
19607
20212
  });
19608
- /**
19609
- * The canonical notification. `body` is the only hard field (Apprise model).
19610
- * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
19611
- * NOT a fixed severity enum — each kind declares its own `caps.levels` and
19612
- * the adapter maps this ordinal onto its native level. `level?` is an
19613
- * optional kind-native level id (`emergency`, `silent`, …) that overrides
19614
- * `priority` for that one target.
19615
- */
19616
- var NotificationSchema = object({
19617
- body: string(),
19618
- title: string().optional(),
19619
- format: NotificationFormatSchema.default("text"),
19620
- priority: number().int().min(1).max(5).default(3),
19621
- level: string().optional(),
19622
- attachments: array(AttachmentSchema).optional(),
19623
- clickUrl: string().optional(),
19624
- actions: array(NotificationActionSchema).optional(),
19625
- sound: string().optional(),
19626
- ttl: number().optional(),
19627
- tag: string().optional(),
19628
- deviceId: number().optional(),
19629
- eventId: string().optional(),
19630
- metadata: record(string(), unknown()).optional()
20213
+ var MemoryInfoSchema = object({
20214
+ percent: number(),
20215
+ totalBytes: number(),
20216
+ usedBytes: number(),
20217
+ availableBytes: number(),
20218
+ swapUsedBytes: number(),
20219
+ swapTotalBytes: number()
20220
+ });
20221
+ var DiskIoSnapshotSchema = object({
20222
+ readBytes: number(),
20223
+ writeBytes: number(),
20224
+ readOps: number(),
20225
+ writeOps: number(),
20226
+ timestampMs: number()
20227
+ });
20228
+ var NetworkIoSnapshotSchema = object({
20229
+ rxBytes: number(),
20230
+ txBytes: number(),
20231
+ rxPackets: number(),
20232
+ txPackets: number(),
20233
+ rxErrors: number(),
20234
+ txErrors: number(),
20235
+ timestampMs: number()
20236
+ });
20237
+ var MetricsGpuInfoSchema = object({
20238
+ utilization: number(),
20239
+ model: string(),
20240
+ memoryUsedBytes: number(),
20241
+ memoryTotalBytes: number(),
20242
+ temperature: number().nullable()
20243
+ });
20244
+ var ProcessResourceInfoSchema = object({
20245
+ openFds: number(),
20246
+ threadCount: number(),
20247
+ activeHandles: number(),
20248
+ activeRequests: number()
19631
20249
  });
19632
- /** One declared native severity/priority level for a kind. */
19633
- var TargetKindLevelSchema = object({
19634
- id: string(),
19635
- label: string(),
19636
- /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
19637
- ordinal: number().int().min(1).max(5).nullable(),
19638
- flags: object({
19639
- critical: boolean().optional(),
19640
- silent: boolean().optional(),
19641
- noPush: boolean().optional()
19642
- }).optional(),
19643
- /** e.g. Pushover `emergency` requires `retry` / `expire`. */
19644
- requires: array(string()).optional(),
19645
- description: string().optional()
20250
+ var PressureAvgsSchema = object({
20251
+ avg10: number(),
20252
+ avg60: number(),
20253
+ avg300: number()
19646
20254
  });
19647
- /** The full capability block consulted before dispatch. */
19648
- var TargetKindCapsSchema = object({
19649
- attachments: object({
19650
- mediaTypes: array(AttachmentMediaTypeSchema),
19651
- mode: _enum([
19652
- "url",
19653
- "bytes",
19654
- "both"
19655
- ]),
19656
- max: number().int().nonnegative(),
19657
- maxBytes: number().int().positive().optional()
20255
+ var PressureInfoSchema = object({
20256
+ some: PressureAvgsSchema,
20257
+ full: PressureAvgsSchema.nullable()
20258
+ });
20259
+ var SystemResourceSnapshotSchema = object({
20260
+ cpu: CpuBreakdownSchema,
20261
+ memory: MemoryInfoSchema,
20262
+ gpu: MetricsGpuInfoSchema.nullable(),
20263
+ network: NetworkIoSnapshotSchema,
20264
+ disk: DiskIoSnapshotSchema,
20265
+ pressure: object({
20266
+ cpu: PressureInfoSchema.nullable(),
20267
+ memory: PressureInfoSchema.nullable(),
20268
+ io: PressureInfoSchema.nullable()
19658
20269
  }),
19659
- /** Max action buttons (0 = none). */
19660
- actions: number().int().nonnegative(),
19661
- levels: array(TargetKindLevelSchema),
19662
- format: array(NotificationFormatSchema),
19663
- clickUrl: boolean(),
19664
- sound: boolean(),
19665
- ttl: boolean(),
19666
- bodyMaxLen: number().int().positive()
20270
+ process: ProcessResourceInfoSchema,
20271
+ cpuTemperature: number().nullable(),
20272
+ timestampMs: number()
19667
20273
  });
19668
- /**
19669
- * `configSchema` is a `ConfigUISchema` tree passed through to the admin
19670
- * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
19671
- * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`)
19672
- * the union is large and not meant for runtime validation here; the exported
19673
- * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
19674
- */
19675
- var ConfigSchemaPassthrough$1 = unknown();
19676
- var TargetKindSchema = object({
19677
- kind: string(),
19678
- label: string(),
19679
- icon: string(),
19680
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
19681
- addonId: string(),
19682
- configSchema: ConfigSchemaPassthrough$1,
19683
- supportsDiscovery: boolean(),
19684
- caps: TargetKindCapsSchema
20274
+ var DiskSpaceInfoSchema = object({
20275
+ path: string(),
20276
+ totalBytes: number(),
20277
+ usedBytes: number(),
20278
+ availableBytes: number(),
20279
+ percent: number()
19685
20280
  });
19686
- /**
19687
- * A persisted target. `config` holds secrets; providers REDACT secret fields
19688
- * (return a presence marker only) when serving `listTargets` — never
19689
- * round-trip a stored secret to the UI.
19690
- */
19691
- var TargetSchema = object({
19692
- id: string(),
19693
- name: string(),
19694
- kind: string(),
20281
+ var PidResourceStatsSchema = object({
20282
+ pid: number(),
20283
+ cpu: number(),
20284
+ memory: number(),
20285
+ /**
20286
+ * Private (anonymous) resident bytes — the per-process V8 heap + native
20287
+ * allocations NOT shared with other processes (Linux RssAnon). This is the
20288
+ * "real" per-runner cost; summing it across runners is meaningful, unlike
20289
+ * `memory` (RSS), which double-counts the shared mmap'd framework code.
20290
+ * Undefined where /proc is unavailable (e.g. macOS).
20291
+ */
20292
+ privateBytes: number().optional(),
20293
+ /**
20294
+ * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
20295
+ * code shared copy-on-write across runners. Undefined on macOS.
20296
+ */
20297
+ sharedBytes: number().optional()
20298
+ });
20299
+ var AddonInstanceSchema = object({
19695
20300
  addonId: string(),
19696
- enabled: boolean(),
19697
- config: record(string(), unknown())
20301
+ nodeId: string(),
20302
+ role: _enum(["hub", "worker"]),
20303
+ pid: number(),
20304
+ state: _enum([
20305
+ "starting",
20306
+ "running",
20307
+ "stopping",
20308
+ "stopped",
20309
+ "crashed"
20310
+ ]),
20311
+ uptimeSec: number()
19698
20312
  });
19699
- /** A discovery-surfaced candidate (config is partial + non-secret). */
19700
- var DiscoveredTargetSchema = object({
19701
- kind: string(),
19702
- suggestedName: string(),
19703
- config: record(string(), unknown())
20313
+ var NodeProcessSchema = object({
20314
+ pid: number(),
20315
+ ppid: number(),
20316
+ pgid: number(),
20317
+ classification: _enum([
20318
+ "root",
20319
+ "managed",
20320
+ "system",
20321
+ "ghost"
20322
+ ]),
20323
+ /** `$process` addon binding when `managed`, else null. */
20324
+ addonId: string().nullable(),
20325
+ /** Kernel-reported nodeId when the process is a known agent/worker. */
20326
+ nodeId: string().nullable(),
20327
+ /** Truncated command line. */
20328
+ command: string(),
20329
+ cpuPercent: number(),
20330
+ memoryRssBytes: number(),
20331
+ /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
20332
+ uptimeSec: number(),
20333
+ /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
20334
+ orphaned: boolean()
19704
20335
  });
19705
- /** The degrade engine's report — what was resolved / dropped / degraded. */
19706
- var RenderedAsSchema = object({
19707
- level: string(),
19708
- format: NotificationFormatSchema,
19709
- attachmentsSent: number().int().nonnegative(),
19710
- actionsSent: number().int().nonnegative(),
19711
- truncated: boolean(),
19712
- dropped: array(string())
20336
+ var KillProcessInputSchema = object({
20337
+ pid: number(),
20338
+ /** Force = SIGKILL. Default is SIGTERM. */
20339
+ force: boolean().optional()
19713
20340
  });
19714
- var SendResultSchema = object({
20341
+ var KillProcessResultSchema = object({
20342
+ success: boolean(),
20343
+ reason: string().optional(),
20344
+ signal: _enum(["SIGTERM", "SIGKILL"]).optional()
20345
+ });
20346
+ var DumpHeapSnapshotInputSchema = object({
20347
+ /** The addon whose runner should dump a heap snapshot. */
20348
+ addonId: string() });
20349
+ var DumpHeapSnapshotResultSchema = object({
19715
20350
  success: boolean(),
20351
+ /** Path of the written .heapsnapshot inside the runner's container/host. */
20352
+ path: string().optional(),
20353
+ /** Process pid that was signalled. */
20354
+ pid: number().optional(),
20355
+ reason: string().optional()
20356
+ });
20357
+ var SystemMetricsSchema = object({
20358
+ cpuPercent: number(),
20359
+ memoryPercent: number(),
20360
+ memoryUsedMB: number(),
20361
+ memoryTotalMB: number(),
20362
+ diskPercent: number().optional(),
20363
+ temperature: number().optional(),
20364
+ gpuPercent: number().optional(),
20365
+ gpuMemoryPercent: number().optional()
20366
+ });
20367
+ 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, {
20368
+ kind: "mutation",
20369
+ auth: "admin"
20370
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
20371
+ kind: "mutation",
20372
+ auth: "admin"
20373
+ });
20374
+ method(object({
20375
+ sourceUrl: string(),
20376
+ metadata: ModelConvertMetadataSchema,
20377
+ targets: array(ConvertTargetSchema).min(1).readonly(),
20378
+ calibrationRef: string().optional(),
20379
+ sessionId: string().optional()
20380
+ }), ConvertResultSchema, {
20381
+ kind: "mutation",
20382
+ auth: "admin",
20383
+ timeoutMs: 6e5
20384
+ });
20385
+ method(object({
20386
+ nodeId: string(),
20387
+ modelId: string(),
20388
+ format: _enum(MODEL_FORMATS),
20389
+ entry: ModelCatalogEntrySchema
20390
+ }), object({
20391
+ ok: boolean(),
20392
+ /** sha256 of the staged tarball (empty for a hub-local no-op). */
20393
+ sha256: string(),
20394
+ bytes: number(),
20395
+ /** The target node's modelsDir the artifact landed in. */
20396
+ path: string()
20397
+ }), {
20398
+ kind: "mutation",
20399
+ auth: "admin"
20400
+ });
20401
+ /**
20402
+ * `mqtt-broker` — broker-registry cap.
20403
+ *
20404
+ * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
20405
+ * MQTT brokers (external + optionally an embedded `aedes`-backed one)
20406
+ * and (b) the connection details a consumer addon needs to spin up
20407
+ * its OWN `mqtt.js` client.
20408
+ *
20409
+ * Why: pub/sub routing over the system event-bus loses fidelity
20410
+ * (callback shape, QoS guarantees, will/retain semantics) and adds
20411
+ * refcount bookkeeping that addons would rather own themselves. The
20412
+ * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
20413
+ * features anyway — give it the connection config, get out of the way.
20414
+ *
20415
+ * Consumer flow:
20416
+ * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
20417
+ * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
20418
+ * client.subscribe('zigbee2mqtt/+')
20419
+ *
20420
+ * Collection mode: multiple brokers (e.g. one local mosquitto + one
20421
+ * cloud bridge). The "embedded" entry (when present) is just another
20422
+ * broker in the registry — its lifecycle is owned by the addon that
20423
+ * spawned it.
20424
+ */
20425
+ var BrokerKindSchema = _enum(["external", "embedded"]);
20426
+ /**
20427
+ * Broker live-probe status.
20428
+ *
20429
+ * - `connected` — last probe completed a clean CONNACK
20430
+ * - `disconnected` — no probe has run yet (cold cache)
20431
+ * - `auth-failed` — CONNACK refused with auth error (RC 4 / 5)
20432
+ * - `unreachable` — TCP connect timed out / refused
20433
+ * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
20434
+ */
20435
+ var BrokerStatusSchema$1 = _enum([
20436
+ "connected",
20437
+ "disconnected",
20438
+ "auth-failed",
20439
+ "unreachable",
20440
+ "tls-error"
20441
+ ]);
20442
+ var BrokerInfoSchema = object({
20443
+ id: string(),
20444
+ name: string(),
20445
+ url: string(),
20446
+ kind: BrokerKindSchema,
20447
+ status: BrokerStatusSchema$1,
20448
+ latencyMs: number().nullable(),
19716
20449
  error: string().optional(),
19717
- renderedAs: RenderedAsSchema.optional()
20450
+ /** Embedded brokers only: number of MQTT clients currently connected. */
20451
+ connectedClients: number().int().nonnegative().optional(),
20452
+ /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
20453
+ lastCheckedAt: number().optional()
19718
20454
  });
19719
- /** Same shape as SendResult — kept as a distinct name for the test panel. */
19720
- var TestResultSchema = SendResultSchema;
19721
- method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
19722
- kind: string(),
19723
- config: record(string(), unknown()).optional()
19724
- }), array(DiscoveredTargetSchema)), method(object({
19725
- targetId: string(),
19726
- notification: NotificationSchema
19727
- }), SendResultSchema, { kind: "mutation" }), method(object({
19728
- targetId: string(),
19729
- sample: NotificationSchema.optional()
19730
- }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
19731
- targetId: string(),
19732
- enabled: boolean()
19733
- }), _void(), { kind: "mutation" });
19734
20455
  /**
19735
- * Shared LLM generate contracts imported by BOTH `llm.cap.ts` (consumer
19736
- * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
19737
- * caps stay wire-compatible without a circular cap→cap import.
19738
- *
19739
- * Errors are a discriminated-union RESULT, never thrown: the shape survives
19740
- * every transport tier structurally, and failed calls still write usage rows.
19741
- * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
20456
+ * Connection details what a consumer needs to call
20457
+ * `mqtt.connect(url, options)`. We split URL + credentials so the
20458
+ * consumer can pass them as `mqtt.connect(url, { username, password })`
20459
+ * instead of stuffing creds into the URL (which leaks them into logs).
19742
20460
  */
19743
- var LlmUsageSchema = object({
19744
- inputTokens: number(),
19745
- outputTokens: number()
20461
+ var BrokerConnectionDetailsSchema = object({
20462
+ url: string(),
20463
+ username: string().optional(),
20464
+ password: string().optional(),
20465
+ /**
20466
+ * Suggested prefix for `clientId`. Each consumer should suffix this
20467
+ * with its own discriminator (addon id, instance id) so reconnects
20468
+ * don't kick each other off (MQTT spec: clientId must be unique per
20469
+ * broker).
20470
+ */
20471
+ clientIdPrefix: string().optional()
19746
20472
  });
19747
- var LlmErrorCodeSchema = _enum([
19748
- "timeout",
19749
- "rate-limited",
19750
- "auth",
19751
- "refusal",
19752
- "bad-request",
19753
- "unavailable",
19754
- "no-profile",
19755
- "budget-exceeded",
19756
- "adapter-error"
19757
- ]);
19758
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
20473
+ var AddBrokerInputSchema = object({
20474
+ name: string().min(1),
20475
+ url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
20476
+ username: string().optional(),
20477
+ password: string().optional(),
20478
+ clientIdPrefix: string().optional()
20479
+ });
20480
+ var AddBrokerResultSchema = object({ id: string() });
20481
+ var IdInputSchema = object({ id: string() });
20482
+ var TestResultSchema$1 = discriminatedUnion("ok", [object({
19759
20483
  ok: literal(true),
19760
- text: string(),
19761
- model: string(),
19762
- usage: LlmUsageSchema,
19763
- truncated: boolean(),
19764
20484
  latencyMs: number()
19765
20485
  }), object({
19766
20486
  ok: literal(false),
19767
- code: LlmErrorCodeSchema,
19768
- message: string(),
19769
- retryAfterMs: number().optional()
20487
+ error: string()
19770
20488
  })]);
19771
- /**
19772
- * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
19773
- * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
19774
- * notification-output.cap.ts:27-31 precedents).
19775
- */
19776
- var LlmImageSchema = object({
19777
- bytes: _instanceof(Uint8Array),
19778
- mimeType: string()
20489
+ var StartEmbeddedInputSchema = object({
20490
+ port: number().int().min(1).max(65535).default(1883),
20491
+ /** Allow anonymous connect (no username/password). Default: false. */
20492
+ allowAnonymous: boolean().default(false),
20493
+ /** Optional shared username/password for clients. */
20494
+ username: string().optional(),
20495
+ password: string().optional()
19779
20496
  });
19780
- var LlmGenerateBaseInputSchema = object({
19781
- /** Collection routing (the notification-output posture). */
19782
- addonId: string().optional(),
19783
- /** Explicit profile; else the resolution chain (spec §3). */
19784
- profileId: string().optional(),
19785
- /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
19786
- consumer: string(),
19787
- system: string().optional(),
19788
- /** v1: single-turn. `messages[]` is a v2 additive field. */
19789
- prompt: string(),
19790
- /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
19791
- jsonSchema: record(string(), unknown()).optional(),
19792
- /** Per-call override of the profile default. */
19793
- maxTokens: number().int().positive().optional(),
19794
- temperature: number().optional()
20497
+ var StartEmbeddedResultSchema = object({
20498
+ id: string(),
20499
+ url: string()
19795
20500
  });
19796
- /**
19797
- * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
19798
- * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
19799
- * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
19800
- * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
19801
- * this only through the `llm` cap's methods.
19802
- *
19803
- * One running llama-server child per node in v1 (models are RAM-heavy).
19804
- * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
19805
- * watchdog — operator decision #3).
19806
- */
19807
- var ManagedModelRefSchema = discriminatedUnion("kind", [
19808
- object({
19809
- kind: literal("catalog"),
19810
- catalogId: string()
19811
- }),
19812
- object({
19813
- kind: literal("url"),
19814
- url: string(),
19815
- sha256: string().optional()
19816
- }),
19817
- object({
19818
- kind: literal("path"),
19819
- path: string()
19820
- })
19821
- ]);
19822
- var ManagedRuntimeConfigSchema = object({
19823
- /** WHERE the runtime lives — hub or any agent. */
19824
- nodeId: string(),
19825
- /** Closed for v1; 'ollama' is a v2 candidate. */
19826
- engine: _enum(["llama-cpp"]),
19827
- model: ManagedModelRefSchema,
19828
- contextSize: number().int().default(4096),
19829
- /** 0 = CPU-only. */
19830
- gpuLayers: number().int().default(0),
19831
- /** Default: cpus-2, clamped ≥1 (resolved node-side). */
19832
- threads: number().int().optional(),
19833
- /** Concurrent slots. */
19834
- parallel: number().int().default(1),
19835
- /** Else lazy: first generate boots it. */
19836
- autoStart: boolean().default(false),
19837
- /** 0 = never; frees RAM after quiet periods. */
19838
- idleStopMinutes: number().int().default(30)
20501
+ var StatusSchema = object({
20502
+ brokerCount: number(),
20503
+ embeddedRunning: boolean()
19839
20504
  });
19840
- var LlmRuntimeStatusSchema = object({
19841
- /** Status is ALWAYS node-qualified. */
19842
- nodeId: string(),
19843
- state: _enum([
19844
- "stopped",
19845
- "downloading",
19846
- "starting",
19847
- "ready",
19848
- "crashed",
19849
- "failed"
19850
- ]),
19851
- pid: number().optional(),
19852
- port: number().optional(),
19853
- modelPath: string().optional(),
19854
- modelId: string().optional(),
19855
- downloadProgress: number().min(0).max(1).optional(),
19856
- lastError: string().optional(),
19857
- crashesInWindow: number(),
19858
- /** Child RSS (sampled best-effort). */
19859
- memoryBytes: number().optional(),
19860
- vramBytes: number().optional()
20505
+ 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);
20506
+ var NetworkEndpointSchema = object({
20507
+ url: string(),
20508
+ hostname: string(),
20509
+ port: number(),
20510
+ protocol: _enum(["http", "https"])
19861
20511
  });
19862
- var LlmNodeModelSchema = object({
19863
- file: string(),
19864
- sizeBytes: number(),
19865
- catalogId: string().optional(),
19866
- installedAt: number().optional()
20512
+ var NetworkAccessStatusSchema = object({
20513
+ connected: boolean(),
20514
+ endpoint: NetworkEndpointSchema.nullable(),
20515
+ error: string().optional()
19867
20516
  });
19868
- var LlmRuntimeDiskUsageSchema = object({
19869
- nodeId: string(),
19870
- modelsBytes: number(),
19871
- freeBytes: number().optional()
20517
+ /**
20518
+ * Optional, richer endpoint shape returned by providers that expose
20519
+ * MORE than one ingress concurrently (Tailscale Ingress with mixed
20520
+ * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
20521
+ * the originating provider config (mode + sourcePort) so the
20522
+ * orchestrator UI can label rows distinctly. Providers that expose only
20523
+ * one endpoint just omit `listEndpoints` from their provider impl.
20524
+ */
20525
+ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
20526
+ /**
20527
+ * Stable id within the provider — typically `<mode>-<sourcePort>` so
20528
+ * the orchestrator can dedupe across `listEndpoints` polls.
20529
+ */
20530
+ id: string(),
20531
+ /** Operator-facing label (mirrors `MeshEndpoint.label`). */
20532
+ label: string(),
20533
+ /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
20534
+ mode: string().optional(),
20535
+ /** Originating local port the ingress fronts (informational). */
20536
+ sourcePort: number().optional()
19872
20537
  });
19873
- method(LlmGenerateBaseInputSchema.extend({
19874
- images: array(LlmImageSchema).optional(),
19875
- runtime: ManagedRuntimeConfigSchema,
19876
- /** The managed profile's timeout, threaded by the hub provider. */
19877
- timeoutMs: number().int().positive().optional()
19878
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
19879
- kind: "mutation",
19880
- auth: "admin"
19881
- }), method(object({}), _void(), {
19882
- kind: "mutation",
19883
- auth: "admin"
19884
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
19885
- kind: "mutation",
19886
- auth: "admin"
19887
- }), method(object({ file: string() }), _void(), {
19888
- kind: "mutation",
19889
- auth: "admin"
19890
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
20538
+ method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
19891
20539
  /**
19892
- * `llm`consumer-facing LLM surface (spec §1-§3). Collection-mode: array
19893
- * methods concat-fan across providers; single-row methods route to ONE
19894
- * provider by the `addonId` in the call input (the notification-output
19895
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
19896
- * (hub-placed); the cap stays open for future providers.
20540
+ * notification-outputcanonical, capability-gated notification delivery.
20541
+ *
20542
+ * Apprise-derived model (see
20543
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
20544
+ * callers emit ONE canonical `Notification`; each provider declares a
20545
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
20546
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
20547
+ * message to what the kind supports — callers never special-case a service.
20548
+ *
20549
+ * DESIGN DECISIONS (locked):
20550
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
20551
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
20552
+ * cap. Rationale: the admin UI needs one uniform surface across the
20553
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
20554
+ * alternative would fork the UI per addon and cannot host the
20555
+ * discovery→adopt flow.
20556
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
20557
+ * the generated cap-mount auto-`concatCollection`-fans them across every
20558
+ * registered provider (notifiers addon + HA addon) so one catalog is
20559
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
20560
+ * `addonId` the generated collection router extracts from the call input.
20561
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
20562
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
20563
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
20564
+ * base64 fallback needed.
19897
20565
  *
19898
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
19899
- * `apiKey` is a password field — providers REDACT it on read and merge on
19900
- * write; a stored key NEVER round-trips to a client.
20566
+ * TODO (deferred, closed-set change separate decision): add
20567
+ * `providerKind: 'notify'` so notification providers surface on the unified
20568
+ * admin "Integrations" page.
19901
20569
  */
19902
- var LlmProfileKindSchema = _enum([
19903
- "openai-compatible",
19904
- "openai",
19905
- "anthropic",
19906
- "google",
19907
- "managed-local"
20570
+ /**
20571
+ * Zentik-derived typed-media enum — the superset across every kind. Each
20572
+ * adapter picks what it supports and the degrade engine filters the rest.
20573
+ */
20574
+ var AttachmentMediaTypeSchema = _enum([
20575
+ "image",
20576
+ "video",
20577
+ "gif",
20578
+ "audio",
20579
+ "icon"
19908
20580
  ]);
19909
- var LlmProfileSchema = object({
20581
+ /**
20582
+ * A single attachment. Exactly one of `url` (remote source, most adapters
20583
+ * prefer this) or `bytes` (inline source; required for Pushover-style
20584
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
20585
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
20586
+ */
20587
+ var AttachmentSchema = object({
20588
+ mediaType: AttachmentMediaTypeSchema,
20589
+ url: string().optional(),
20590
+ bytes: _instanceof(Uint8Array).optional(),
20591
+ mime: string().optional(),
20592
+ name: string().optional()
20593
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
20594
+ var NotificationFormatSchema = _enum([
20595
+ "text",
20596
+ "markdown",
20597
+ "html"
20598
+ ]);
20599
+ /** A single tap-through action button. */
20600
+ var NotificationActionSchema = object({
19910
20601
  id: string(),
19911
- name: string(),
19912
- kind: LlmProfileKindSchema,
19913
- /** Stamped by the provider — keeps the fanned catalog routable. */
19914
- addonId: string(),
19915
- enabled: boolean(),
19916
- /** Vendor model id, or the managed runtime's loaded model. */
19917
- model: string(),
19918
- /** Required for openai-compatible; override for cloud kinds. */
19919
- baseUrl: string().optional(),
19920
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
19921
- apiKey: string().optional(),
19922
- supportsVision: boolean(),
19923
- temperature: number().min(0).max(2).optional(),
19924
- maxTokens: number().int().positive().optional(),
19925
- timeoutMs: number().int().positive().default(6e4),
19926
- extraHeaders: record(string(), string()).optional(),
19927
- /** kind === 'managed-local' only (spec §4). */
19928
- runtime: ManagedRuntimeConfigSchema.optional()
20602
+ label: string(),
20603
+ url: string().optional()
19929
20604
  });
19930
- /** ConfigUISchema tree passed through untyped on the wire (the
19931
- * notification-output `ConfigSchemaPassthrough` precedent at
19932
- * notification-output.cap.ts:151); the exported TS type re-tightens it. */
20605
+ /**
20606
+ * The canonical notification. `body` is the only hard field (Apprise model).
20607
+ * `priority` is a 5-level ORDINAL (1=lowest 3=normal(default) 5=urgent),
20608
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
20609
+ * the adapter maps this ordinal onto its native level. `level?` is an
20610
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
20611
+ * `priority` for that one target.
20612
+ */
20613
+ var NotificationSchema = object({
20614
+ body: string(),
20615
+ title: string().optional(),
20616
+ format: NotificationFormatSchema.default("text"),
20617
+ priority: number().int().min(1).max(5).default(3),
20618
+ level: string().optional(),
20619
+ attachments: array(AttachmentSchema).optional(),
20620
+ clickUrl: string().optional(),
20621
+ actions: array(NotificationActionSchema).optional(),
20622
+ sound: string().optional(),
20623
+ ttl: number().optional(),
20624
+ tag: string().optional(),
20625
+ deviceId: number().optional(),
20626
+ eventId: string().optional(),
20627
+ metadata: record(string(), unknown()).optional()
20628
+ });
20629
+ /** One declared native severity/priority level for a kind. */
20630
+ var TargetKindLevelSchema = object({
20631
+ id: string(),
20632
+ label: string(),
20633
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
20634
+ ordinal: number().int().min(1).max(5).nullable(),
20635
+ flags: object({
20636
+ critical: boolean().optional(),
20637
+ silent: boolean().optional(),
20638
+ noPush: boolean().optional()
20639
+ }).optional(),
20640
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
20641
+ requires: array(string()).optional(),
20642
+ description: string().optional()
20643
+ });
20644
+ /** The full capability block consulted before dispatch. */
20645
+ var TargetKindCapsSchema = object({
20646
+ attachments: object({
20647
+ mediaTypes: array(AttachmentMediaTypeSchema),
20648
+ mode: _enum([
20649
+ "url",
20650
+ "bytes",
20651
+ "both"
20652
+ ]),
20653
+ max: number().int().nonnegative(),
20654
+ maxBytes: number().int().positive().optional()
20655
+ }),
20656
+ /** Max action buttons (0 = none). */
20657
+ actions: number().int().nonnegative(),
20658
+ levels: array(TargetKindLevelSchema),
20659
+ format: array(NotificationFormatSchema),
20660
+ clickUrl: boolean(),
20661
+ sound: boolean(),
20662
+ ttl: boolean(),
20663
+ bodyMaxLen: number().int().positive()
20664
+ });
20665
+ /**
20666
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
20667
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
20668
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
20669
+ * the union is large and not meant for runtime validation here; the exported
20670
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
20671
+ */
19933
20672
  var ConfigSchemaPassthrough = unknown();
19934
- var LlmProfileKindDescriptorSchema = object({
19935
- kind: LlmProfileKindSchema,
20673
+ var TargetKindSchema = object({
20674
+ kind: string(),
19936
20675
  label: string(),
19937
20676
  icon: string(),
19938
20677
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
19939
20678
  addonId: string(),
19940
- configSchema: ConfigSchemaPassthrough
19941
- });
19942
- var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
19943
- var LlmDefaultSchema = object({
19944
- selector: LlmDefaultSelectorSchema,
19945
- profileId: string()
19946
- });
19947
- /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
19948
- var LlmUsageRollupSchema = object({
19949
- day: string(),
19950
- consumer: string(),
19951
- profileId: string(),
19952
- calls: number(),
19953
- okCalls: number(),
19954
- errorCalls: number(),
19955
- inputTokens: number(),
19956
- outputTokens: number(),
19957
- avgLatencyMs: number()
20679
+ configSchema: ConfigSchemaPassthrough,
20680
+ supportsDiscovery: boolean(),
20681
+ caps: TargetKindCapsSchema
19958
20682
  });
19959
- /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
19960
- var ManagedModelCatalogEntrySchema = object({
20683
+ /**
20684
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
20685
+ * (return a presence marker only) when serving `listTargets` — never
20686
+ * round-trip a stored secret to the UI.
20687
+ */
20688
+ var TargetSchema = object({
19961
20689
  id: string(),
19962
- label: string(),
19963
- family: string(),
19964
- purpose: _enum(["text", "vision"]),
19965
- url: string(),
19966
- sha256: string(),
19967
- sizeBytes: number(),
19968
- quantization: string(),
19969
- /** Load-time guidance shown in the picker. */
19970
- minRamBytes: number(),
19971
- contextSizeDefault: number().int(),
19972
- /** Vision models: companion projector file. */
19973
- mmprojUrl: string().optional()
19974
- });
19975
- var LlmRuntimeNodeSchema = object({
19976
- nodeId: string(),
19977
- reachable: boolean(),
19978
- status: LlmRuntimeStatusSchema.optional(),
19979
- disk: LlmRuntimeDiskUsageSchema.optional(),
19980
- error: string().optional()
19981
- });
19982
- var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
19983
- var ProfileRefInputSchema = object({
20690
+ name: string(),
20691
+ kind: string(),
19984
20692
  addonId: string(),
19985
- profileId: string()
20693
+ enabled: boolean(),
20694
+ config: record(string(), unknown())
19986
20695
  });
19987
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
19988
- kind: "mutation",
19989
- auth: "admin"
19990
- }), method(ProfileRefInputSchema, _void(), {
19991
- kind: "mutation",
19992
- auth: "admin"
19993
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
19994
- kind: "mutation",
19995
- auth: "admin"
19996
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
19997
- selector: LlmDefaultSelectorSchema,
19998
- profileId: string().nullable()
19999
- }), _void(), {
20000
- kind: "mutation",
20001
- auth: "admin"
20002
- }), method(object({
20003
- since: number().optional(),
20004
- until: number().optional(),
20005
- consumer: string().optional(),
20006
- profileId: string().optional()
20007
- }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
20008
- nodeId: string(),
20009
- model: ManagedModelRefSchema
20010
- }), _void(), {
20011
- kind: "mutation",
20012
- auth: "admin"
20013
- }), method(object({
20014
- nodeId: string(),
20015
- file: string()
20016
- }), _void(), {
20017
- kind: "mutation",
20018
- auth: "admin"
20019
- }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
20020
- kind: "mutation",
20021
- auth: "admin"
20022
- }), method(ProfileRefInputSchema, _void(), {
20023
- kind: "mutation",
20024
- auth: "admin"
20696
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
20697
+ var DiscoveredTargetSchema = object({
20698
+ kind: string(),
20699
+ suggestedName: string(),
20700
+ config: record(string(), unknown())
20701
+ });
20702
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
20703
+ var RenderedAsSchema = object({
20704
+ level: string(),
20705
+ format: NotificationFormatSchema,
20706
+ attachmentsSent: number().int().nonnegative(),
20707
+ actionsSent: number().int().nonnegative(),
20708
+ truncated: boolean(),
20709
+ dropped: array(string())
20710
+ });
20711
+ var SendResultSchema = object({
20712
+ success: boolean(),
20713
+ error: string().optional(),
20714
+ renderedAs: RenderedAsSchema.optional()
20025
20715
  });
20716
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
20717
+ var TestResultSchema = SendResultSchema;
20718
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
20719
+ kind: string(),
20720
+ config: record(string(), unknown()).optional()
20721
+ }), array(DiscoveredTargetSchema)), method(object({
20722
+ targetId: string(),
20723
+ notification: NotificationSchema
20724
+ }), SendResultSchema, { kind: "mutation" }), method(object({
20725
+ targetId: string(),
20726
+ sample: NotificationSchema.optional()
20727
+ }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
20728
+ targetId: string(),
20729
+ enabled: boolean()
20730
+ }), _void(), { kind: "mutation" });
20026
20731
  /**
20027
20732
  * Zod schemas for persisted record types.
20028
20733
  *
@@ -20708,7 +21413,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
20708
21413
  }), method(object({
20709
21414
  eventId: string(),
20710
21415
  kind: MediaFileKindEnum.optional()
20711
- }), array(MediaFileSchema).readonly()), method(object({ trackId: string() }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
21416
+ }), array(MediaFileSchema).readonly()), method(object({
21417
+ trackId: string(),
21418
+ kinds: array(MediaFileKindEnum).optional()
21419
+ }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
20712
21420
  deviceId: number(),
20713
21421
  timestamp: number(),
20714
21422
  frameWidth: number(),
@@ -20729,76 +21437,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
20729
21437
  eventId: string(),
20730
21438
  timestamp: number()
20731
21439
  });
20732
- /**
20733
- * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
20734
- * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
20735
- * caps into per-camera event-kind descriptors.
20736
- *
20737
- * The descriptor DATA (color / iconId / labelKey / parentKind / category)
20738
- * is NOT duplicated here — every entry is derived from the single
20739
- * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
20740
- * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
20741
- * control cap means adding one line here (and a taxonomy entry); the anti-
20742
- * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
20743
- * eventful cap is missing.
20744
- */
20745
- /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
20746
- var LEGACY_ICON = {
20747
- motion: "motion",
20748
- audio: "audio",
20749
- person: "person",
20750
- vehicle: "vehicle",
20751
- animal: "animal",
20752
- package: "package",
20753
- door: "door",
20754
- pir: "pir",
20755
- smoke: "smoke",
20756
- water: "water",
20757
- button: "button",
20758
- generic: "generic",
20759
- gas: "smoke",
20760
- vibration: "generic",
20761
- tamper: "generic",
20762
- presence: "person",
20763
- lock: "generic",
20764
- siren: "generic",
20765
- switch: "generic",
20766
- doorbell: "button"
20767
- };
20768
- function legacyIcon(iconId) {
20769
- return LEGACY_ICON[iconId] ?? "generic";
20770
- }
20771
- /**
20772
- * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
20773
- * The anti-drift guard cross-checks this against the eventful caps declared
20774
- * in `packages/types/src/capabilities/*.cap.ts`.
20775
- */
20776
- var CAP_TO_KIND = {
20777
- contact: "contact",
20778
- motion: "motion-sensor",
20779
- smoke: "smoke",
20780
- flood: "flood",
20781
- gas: "gas",
20782
- "carbon-monoxide": "carbon-monoxide",
20783
- vibration: "vibration",
20784
- tamper: "tamper",
20785
- presence: "presence",
20786
- "enum-sensor": "enum-sensor",
20787
- "event-emitter": "device-event",
20788
- "lock-control": "lock",
20789
- switch: "switch",
20790
- button: "button",
20791
- doorbell: "doorbell"
20792
- };
20793
- function buildDescriptor(capName, kind) {
20794
- const t = EVENT_TAXONOMY[kind];
20795
- if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
20796
- return {
20797
- ...t,
20798
- icon: legacyIcon(t.iconId)
20799
- };
20800
- }
20801
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
20802
21440
  var CameraPipelineConfigSchema = object({
20803
21441
  engine: PipelineEngineChoiceSchema.optional(),
20804
21442
  steps: array(PipelineStepInputSchema).readonly(),
@@ -21284,6 +21922,76 @@ method(object({
21284
21922
  auth: "admin"
21285
21923
  });
21286
21924
  /**
21925
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
21926
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
21927
+ * caps into per-camera event-kind descriptors.
21928
+ *
21929
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
21930
+ * is NOT duplicated here — every entry is derived from the single
21931
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
21932
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
21933
+ * control cap means adding one line here (and a taxonomy entry); the anti-
21934
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
21935
+ * eventful cap is missing.
21936
+ */
21937
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
21938
+ var LEGACY_ICON = {
21939
+ motion: "motion",
21940
+ audio: "audio",
21941
+ person: "person",
21942
+ vehicle: "vehicle",
21943
+ animal: "animal",
21944
+ package: "package",
21945
+ door: "door",
21946
+ pir: "pir",
21947
+ smoke: "smoke",
21948
+ water: "water",
21949
+ button: "button",
21950
+ generic: "generic",
21951
+ gas: "smoke",
21952
+ vibration: "generic",
21953
+ tamper: "generic",
21954
+ presence: "person",
21955
+ lock: "generic",
21956
+ siren: "generic",
21957
+ switch: "generic",
21958
+ doorbell: "button"
21959
+ };
21960
+ function legacyIcon(iconId) {
21961
+ return LEGACY_ICON[iconId] ?? "generic";
21962
+ }
21963
+ /**
21964
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
21965
+ * The anti-drift guard cross-checks this against the eventful caps declared
21966
+ * in `packages/types/src/capabilities/*.cap.ts`.
21967
+ */
21968
+ var CAP_TO_KIND = {
21969
+ contact: "contact",
21970
+ motion: "motion-sensor",
21971
+ smoke: "smoke",
21972
+ flood: "flood",
21973
+ gas: "gas",
21974
+ "carbon-monoxide": "carbon-monoxide",
21975
+ vibration: "vibration",
21976
+ tamper: "tamper",
21977
+ presence: "presence",
21978
+ "enum-sensor": "enum-sensor",
21979
+ "event-emitter": "device-event",
21980
+ "lock-control": "lock",
21981
+ switch: "switch",
21982
+ button: "button",
21983
+ doorbell: "doorbell"
21984
+ };
21985
+ function buildDescriptor(capName, kind) {
21986
+ const t = EVENT_TAXONOMY[kind];
21987
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
21988
+ return {
21989
+ ...t,
21990
+ icon: legacyIcon(t.iconId)
21991
+ };
21992
+ }
21993
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
21994
+ /**
21287
21995
  * server-management — per-NODE singleton capability for a node's ROOT
21288
21996
  * package lifecycle (runtime-updatable node packages).
21289
21997
  *
@@ -22738,7 +23446,28 @@ var FaceInfoSchema = object({
22738
23446
  * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`). Absent when the
22739
23447
  * track produced no key frame (e.g. native/onboard source) — the UI falls
22740
23448
  * back to the inline `base64` face crop. */
22741
- keyFrameMediaKey: string().optional()
23449
+ keyFrameMediaKey: string().optional(),
23450
+ /** Winning identity-match cosine (0..1) for this face's track, when an
23451
+ * identity was auto-confirmed. Lets the UI surface WHY a face was assigned
23452
+ * (confidence badge / low-confidence audit). Absent on legacy rows and on
23453
+ * faces that were never auto-recognized. */
23454
+ bestMatchScore: number().optional(),
23455
+ /** Native-scale face short side (px) at recognition time, when the runner
23456
+ * measured it. Lets the UI flag low-resolution auto-assignments. Absent on
23457
+ * legacy rows / runners that reported no native measure. */
23458
+ nativeFaceShortSidePx: number().optional(),
23459
+ /** SUGGESTED identity for this face — a plausible-but-not-confident match that
23460
+ * MISSED auto-assignment (cosine in the suggestion band, or above threshold
23461
+ * but blocked only by the recognition size floor). Mutually exclusive with
23462
+ * `recognizedIdentityId` (a suggestion is NEVER an assignment): the face stays
23463
+ * UNASSIGNED and everything else keeps treating it as unrecognized — the UI
23464
+ * merely offers a one-tap "is this <name>?" confirm. Absent on legacy rows and
23465
+ * on faces that were auto-assigned or below the suggestion band. (2026-07-24) */
23466
+ suggestedIdentityId: string().optional(),
23467
+ /** Peak identity-match cosine (0..1) for `suggestedIdentityId`, captured at the
23468
+ * same moment as `bestMatchScore` (track peak, at close). Lets the UI rank /
23469
+ * badge suggestion confidence. Present iff `suggestedIdentityId` is. (2026-07-24) */
23470
+ suggestedMatchScore: number().optional()
22742
23471
  });
22743
23472
  var FaceFilterEnum = _enum([
22744
23473
  "unassigned",
@@ -24781,36 +25510,6 @@ Object.freeze({
24781
25510
  addonId: null,
24782
25511
  access: "view"
24783
25512
  },
24784
- "advancedNotifier.deleteRule": {
24785
- capName: "advanced-notifier",
24786
- capScope: "system",
24787
- addonId: null,
24788
- access: "delete"
24789
- },
24790
- "advancedNotifier.getHistory": {
24791
- capName: "advanced-notifier",
24792
- capScope: "system",
24793
- addonId: null,
24794
- access: "view"
24795
- },
24796
- "advancedNotifier.getRules": {
24797
- capName: "advanced-notifier",
24798
- capScope: "system",
24799
- addonId: null,
24800
- access: "view"
24801
- },
24802
- "advancedNotifier.testRule": {
24803
- capName: "advanced-notifier",
24804
- capScope: "system",
24805
- addonId: null,
24806
- access: "create"
24807
- },
24808
- "advancedNotifier.upsertRule": {
24809
- capName: "advanced-notifier",
24810
- capScope: "system",
24811
- addonId: null,
24812
- access: "create"
24813
- },
24814
25513
  "alarmPanel.arm": {
24815
25514
  capName: "alarm-panel",
24816
25515
  capScope: "device",
@@ -25033,6 +25732,12 @@ Object.freeze({
25033
25732
  addonId: null,
25034
25733
  access: "delete"
25035
25734
  },
25735
+ "backup.deleteSchedule": {
25736
+ capName: "backup",
25737
+ capScope: "system",
25738
+ addonId: null,
25739
+ access: "delete"
25740
+ },
25036
25741
  "backup.getEntries": {
25037
25742
  capName: "backup",
25038
25743
  capScope: "system",
@@ -25063,6 +25768,12 @@ Object.freeze({
25063
25768
  addonId: null,
25064
25769
  access: "view"
25065
25770
  },
25771
+ "backup.listSchedules": {
25772
+ capName: "backup",
25773
+ capScope: "system",
25774
+ addonId: null,
25775
+ access: "view"
25776
+ },
25066
25777
  "backup.previewSchedule": {
25067
25778
  capName: "backup",
25068
25779
  capScope: "system",
@@ -25087,6 +25798,12 @@ Object.freeze({
25087
25798
  addonId: null,
25088
25799
  access: "create"
25089
25800
  },
25801
+ "backup.upsertSchedule": {
25802
+ capName: "backup",
25803
+ capScope: "system",
25804
+ addonId: null,
25805
+ access: "create"
25806
+ },
25090
25807
  "battery.wakeForStream": {
25091
25808
  capName: "battery",
25092
25809
  capScope: "device",
@@ -27115,6 +27832,60 @@ Object.freeze({
27115
27832
  addonId: null,
27116
27833
  access: "create"
27117
27834
  },
27835
+ "notificationRules.createRule": {
27836
+ capName: "notification-rules",
27837
+ capScope: "system",
27838
+ addonId: null,
27839
+ access: "create"
27840
+ },
27841
+ "notificationRules.deleteRule": {
27842
+ capName: "notification-rules",
27843
+ capScope: "system",
27844
+ addonId: null,
27845
+ access: "delete"
27846
+ },
27847
+ "notificationRules.getConditionCatalog": {
27848
+ capName: "notification-rules",
27849
+ capScope: "system",
27850
+ addonId: null,
27851
+ access: "view"
27852
+ },
27853
+ "notificationRules.getHistory": {
27854
+ capName: "notification-rules",
27855
+ capScope: "system",
27856
+ addonId: null,
27857
+ access: "view"
27858
+ },
27859
+ "notificationRules.getRule": {
27860
+ capName: "notification-rules",
27861
+ capScope: "system",
27862
+ addonId: null,
27863
+ access: "view"
27864
+ },
27865
+ "notificationRules.listRules": {
27866
+ capName: "notification-rules",
27867
+ capScope: "system",
27868
+ addonId: null,
27869
+ access: "view"
27870
+ },
27871
+ "notificationRules.setRuleEnabled": {
27872
+ capName: "notification-rules",
27873
+ capScope: "system",
27874
+ addonId: null,
27875
+ access: "create"
27876
+ },
27877
+ "notificationRules.testRule": {
27878
+ capName: "notification-rules",
27879
+ capScope: "system",
27880
+ addonId: null,
27881
+ access: "create"
27882
+ },
27883
+ "notificationRules.updateRule": {
27884
+ capName: "notification-rules",
27885
+ capScope: "system",
27886
+ addonId: null,
27887
+ access: "create"
27888
+ },
27118
27889
  "notifier.cancel": {
27119
27890
  capName: "notifier",
27120
27891
  capScope: "device",
@@ -28867,6 +29638,36 @@ Object.freeze({
28867
29638
  addonId: null,
28868
29639
  access: "create"
28869
29640
  },
29641
+ "terminalSession.close": {
29642
+ capName: "terminal-session",
29643
+ capScope: "system",
29644
+ addonId: null,
29645
+ access: "create"
29646
+ },
29647
+ "terminalSession.listProfiles": {
29648
+ capName: "terminal-session",
29649
+ capScope: "system",
29650
+ addonId: null,
29651
+ access: "view"
29652
+ },
29653
+ "terminalSession.listSessions": {
29654
+ capName: "terminal-session",
29655
+ capScope: "system",
29656
+ addonId: null,
29657
+ access: "view"
29658
+ },
29659
+ "terminalSession.openSession": {
29660
+ capName: "terminal-session",
29661
+ capScope: "system",
29662
+ addonId: null,
29663
+ access: "create"
29664
+ },
29665
+ "terminalSession.resize": {
29666
+ capName: "terminal-session",
29667
+ capScope: "system",
29668
+ addonId: null,
29669
+ access: "create"
29670
+ },
28870
29671
  "toast.onToast": {
28871
29672
  capName: "toast",
28872
29673
  capScope: "system",