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