@camstack/addon-provider-dreo 0.2.4 → 0.2.6

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