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