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