@camstack/addon-provider-ecowitt 0.2.4 → 0.2.6

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