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