@camstack/addon-provider-tuya 0.2.4 → 0.2.6

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