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