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