@camstack/addon-provider-amcrest 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +1924 -1123
  2. package/dist/addon.mjs +1924 -1123
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -5,7 +5,7 @@ import { networkInterfaces } from "node:os";
5
5
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
6
6
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
7
7
  //#endregion
8
- //#region ../types/dist/event-category-D4HJq7Mw.mjs
8
+ //#region ../types/dist/event-category-BLcNejAE.mjs
9
9
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
10
10
  EventCategory["SystemBoot"] = "system.boot";
11
11
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -155,9 +155,6 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
155
155
  EventCategory["RecordingSegmentWritten"] = "recording.segment.written";
156
156
  EventCategory["RecordingPolicyFallback"] = "recording.policy.fallback";
157
157
  EventCategory["RecordingRetentionCompleted"] = "recording.retention.completed";
158
- /** Runner-sampled scrub thumbnail (~1/5 s/camera). Telemetry (D8): a lost
159
- * thumb is a scrub gap the recorder's keyframe backfill covers. */
160
- EventCategory["RecordingThumbSampled"] = "recording.thumb-sampled";
161
158
  /** Export render progress (0–100). Telemetry (D8): a lost tick is a stale
162
159
  * progress bar the client reconciles via `recordingExport.getExport`. */
163
160
  EventCategory["RecordingExportProgress"] = "recording.export.progress";
@@ -6822,7 +6819,6 @@ object({ deviceId: number() }), object({ deviceId: number() }), object({
6822
6819
  patch: record(string(), unknown())
6823
6820
  }), object({ success: literal(true) });
6824
6821
  object({ deviceId: number() }), unknown().nullable();
6825
- /** Shorthand to define a method schema */
6826
6822
  function method(input, output, options) {
6827
6823
  return {
6828
6824
  input,
@@ -6830,6 +6826,7 @@ function method(input, output, options) {
6830
6826
  kind: options?.kind ?? "query",
6831
6827
  auth: options?.auth ?? "protected",
6832
6828
  ...options?.access !== void 0 ? { access: options.access } : {},
6829
+ ...options?.caller !== void 0 ? { caller: options.caller } : {},
6833
6830
  timeoutMs: options?.timeoutMs
6834
6831
  };
6835
6832
  }
@@ -7515,16 +7512,23 @@ var StorageLocationDeclarationSchema = object({
7515
7512
  * Which node root the seeded `<id>:default` instance is placed under on a
7516
7513
  * FRESH install:
7517
7514
  * - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
7518
- * the appData volume. Right for small/durable data (backups, logs, models).
7515
+ * the appData volume. Right for small/durable data (logs, models).
7519
7516
  * - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
7520
7517
  * env is set, else falls back to the data root. Right for bulky, hot media
7521
7518
  * (recordings, event media) that should stay off the appData disk.
7519
+ * - `'backup'` — the dedicated backup volume (`CAMSTACK_BACKUP_ROOT`, default
7520
+ * `/backups` in the image) so archives live on their own mount rather than
7521
+ * filling the appData disk. Falls back to the data root when unset.
7522
7522
  *
7523
7523
  * Only affects the seeded default's `basePath`; operators can repoint any
7524
7524
  * location afterwards, and a `defaultsTo` slot inherits its parent's root
7525
7525
  * regardless of this field. Absent (the common case) is treated as `'data'`.
7526
7526
  */
7527
- defaultRoot: _enum(["data", "media"]).optional()
7527
+ defaultRoot: _enum([
7528
+ "data",
7529
+ "media",
7530
+ "backup"
7531
+ ]).optional()
7528
7532
  });
7529
7533
  var DecoderStatsSchema = object({
7530
7534
  inputFps: number(),
@@ -8187,6 +8191,59 @@ for (const l of AUDIO_MACRO_LABELS) {
8187
8191
  /** The complete taxonomy dictionary, keyed by kind. */
8188
8192
  var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
8189
8193
  /**
8194
+ * Notification-Center taxonomy — the fixed vocabulary the NC rule editor
8195
+ * offers as pickers instead of free text. Derived (never hand-listed) from the
8196
+ * single `EVENT_TAXONOMY` dictionary so it stays in lockstep with every other
8197
+ * taxonomy surface (timeline, filters, event page).
8198
+ *
8199
+ * Three buckets, mapped onto the rule editor's `stringList` conditions:
8200
+ * - `videoClasses` → detection classes (person / vehicle / animal + subs)
8201
+ * for the `classes` / `classesExclude` conditions.
8202
+ * - `audioKinds` → audio-analyzer sub kinds (`audio-scream`, …) shown in
8203
+ * the same class picker, grouped under an Audio header.
8204
+ * - `labels` → sensor + control taxonomy kinds (doorbell / contact /
8205
+ * lock / …) for the `sensorKinds` device-event condition.
8206
+ *
8207
+ * Each entry carries `parentKind` so the client can group video subs under
8208
+ * their macro and sensor/control kinds under their category. This surface is
8209
+ * served ADDITIVELY on the `nc.getConditionCatalog` bridge response — no cap
8210
+ * method, no codegen — so it ships train-free with an addon deploy.
8211
+ */
8212
+ /** One selectable taxonomy value: a stable kind id + display label + parent. */
8213
+ var NcTaxonomyEntrySchema = object({
8214
+ /** Stable kind id (e.g. 'person', 'car', 'audio-scream', 'doorbell'). */
8215
+ kind: string(),
8216
+ /** English fallback label (the UI translates via the event-kind i18n key). */
8217
+ label: string(),
8218
+ /** Macro/category parent for grouping ('car' → 'vehicle'); null for a top. */
8219
+ parentKind: string().nullable()
8220
+ });
8221
+ object({
8222
+ videoClasses: array(NcTaxonomyEntrySchema),
8223
+ audioKinds: array(NcTaxonomyEntrySchema),
8224
+ labels: array(NcTaxonomyEntrySchema)
8225
+ });
8226
+ function toEntry(kind, label, parentKind) {
8227
+ return {
8228
+ kind,
8229
+ label,
8230
+ parentKind
8231
+ };
8232
+ }
8233
+ /**
8234
+ * Build the NC taxonomy from `EVENT_TAXONOMY`. Insertion order is preserved
8235
+ * (macros before their subs), which the client relies on for stable grouping.
8236
+ */
8237
+ function buildNcTaxonomy() {
8238
+ const all = Object.values(EVENT_TAXONOMY);
8239
+ return {
8240
+ videoClasses: all.filter((e) => e.category === "detection").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8241
+ audioKinds: all.filter((e) => e.category === "audio" && e.level === "sub").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8242
+ labels: all.filter((e) => e.category === "sensor" || e.category === "control").map((e) => toEntry(e.kind, e.label, e.parentKind))
8243
+ };
8244
+ }
8245
+ Object.freeze(buildNcTaxonomy());
8246
+ /**
8190
8247
  * Error types for the safe expression engine. Two distinct classes so callers
8191
8248
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
8192
8249
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -9155,6 +9212,644 @@ function startReachabilityPoll(options) {
9155
9212
  } };
9156
9213
  }
9157
9214
  /**
9215
+ * Shared geometry vocabulary for on-frame shape caps — privacy-mask,
9216
+ * motion-zones, and the detection zones/lines editor all speak this one
9217
+ * language so a single drawing-plane editor and the providers stay
9218
+ * decoupled from each cap's storage.
9219
+ *
9220
+ * All coordinates are normalized 0..1 of the camera frame (top-left
9221
+ * origin). Each cap composes the SUBSET of shape kinds it supports and
9222
+ * advertises it via `supportedShapes` in its `getOptions`.
9223
+ */
9224
+ /** A normalized 0..1 point (top-left origin). */
9225
+ var MaskPointSchema = object({
9226
+ x: number(),
9227
+ y: number()
9228
+ });
9229
+ /** Axis-aligned rectangle (normalized 0..1). */
9230
+ var MaskRectShapeSchema = object({
9231
+ kind: literal("rect"),
9232
+ x: number(),
9233
+ y: number(),
9234
+ width: number(),
9235
+ height: number()
9236
+ });
9237
+ /** Free polygon — an ordered list of normalized vertices (≥3). */
9238
+ var MaskPolygonShapeSchema = object({
9239
+ kind: literal("polygon"),
9240
+ points: array(MaskPointSchema)
9241
+ });
9242
+ /** Boolean cell grid — row-major, length === gridWidth*gridHeight. */
9243
+ var MaskGridShapeSchema = object({
9244
+ kind: literal("grid"),
9245
+ gridWidth: number(),
9246
+ gridHeight: number(),
9247
+ cells: array(boolean())
9248
+ });
9249
+ discriminatedUnion("kind", [
9250
+ MaskRectShapeSchema,
9251
+ MaskPolygonShapeSchema,
9252
+ MaskGridShapeSchema,
9253
+ object({
9254
+ kind: literal("line"),
9255
+ points: array(MaskPointSchema)
9256
+ })
9257
+ ]);
9258
+ /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
9259
+ var MaskShapeKindSchema = _enum([
9260
+ "rect",
9261
+ "polygon",
9262
+ "grid",
9263
+ "line"
9264
+ ]);
9265
+ /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
9266
+ var MaskPolygonVerticesSchema = object({
9267
+ min: number(),
9268
+ max: number()
9269
+ });
9270
+ /** Grid dimensions when a cap supports 'grid'. */
9271
+ var MaskGridDimsSchema = object({
9272
+ width: number(),
9273
+ height: number()
9274
+ });
9275
+ /**
9276
+ * notification-rules — the Notification Center rule surface (P1 core).
9277
+ *
9278
+ * Spec: `docs/superpowers/specs/2026-07-22-notification-center-requirements.md`
9279
+ * (operator decisions D-1/D-2/D-3 are binding):
9280
+ *
9281
+ * - D-2: rule EVALUATION lives in `addon-post-analysis` (the
9282
+ * `notification-center` module), hooked on the durable persistence
9283
+ * moments (object-event insert, TrackCloser.closeExpired) with a
9284
+ * persisted outbox + retry — never the lossy telemetry bus (D8).
9285
+ * - D-3: urgency belongs to the RULE. `delivery: 'immediate'` fires on the
9286
+ * FIRST persisted detection matching the conditions (per-track dedup,
9287
+ * `maxPerTrack` fixed at 1 — see {@link NC_MAX_PER_TRACK_IMMEDIATE});
9288
+ * `delivery: 'track-end'` evaluates the finalized track record at close.
9289
+ * - DISPATCH stays behind `notification-output` (rules reference targets
9290
+ * by id; per-backend params are a passthrough blob capped by the
9291
+ * target kind's own caps/degrade engine).
9292
+ *
9293
+ * P1 scope: admin-authored rules only (`createdBy` stamped from the
9294
+ * server-injected caller identity — the first `caller: 'required'`
9295
+ * adopter). The P1 condition subset is: devices, classes(+exclude),
9296
+ * minConfidence, admin zones (any/all + exclude), weekly schedule
9297
+ * windows, and the optional label/identity/plate matchers. User rules,
9298
+ * private zones, per-recipient fan-out and the wider condition table are
9299
+ * P2+ (see spec §7).
9300
+ *
9301
+ * All schemas here are the single source of truth — `NcRule` etc. are
9302
+ * `z.infer` exports; no duplicate interfaces (the advanced-notifier
9303
+ * schema/interface drift is explicitly not repeated).
9304
+ */
9305
+ /**
9306
+ * D-3: the trigger/urgency of a rule — which persistence moment evaluates it.
9307
+ * The value maps 1:1 onto the evaluated record kind:
9308
+ * - `immediate` ↔ object-event persist (lowest-latency detection burst)
9309
+ * - `track-end` ↔ TrackCloser.closeExpired (finalized track record)
9310
+ * - `device-event` ↔ SensorEventStore insert (doorbell press / sensor state
9311
+ * change of a LINKED device, one row per linked camera)
9312
+ * - `package-event` ↔ PackageDropDetector object-event insert (a `package`
9313
+ * delivery / pick-up)
9314
+ *
9315
+ * `immediate`/`track-end` carry the D-3 urgency semantics; `device-event`/
9316
+ * `package-event` are pure trigger kinds (no urgency dimension). Extending
9317
+ * this one field keeps the schema additive — a rule still declares exactly
9318
+ * one trigger.
9319
+ */
9320
+ var NcDeliverySchema = _enum([
9321
+ "immediate",
9322
+ "track-end",
9323
+ "device-event",
9324
+ "package-event"
9325
+ ]);
9326
+ /** Weekly schedule — OR of windows; absence on the rule = always active. */
9327
+ var NcScheduleSchema = object({
9328
+ windows: array(object({
9329
+ /** Days of week the window STARTS on (0 = Sunday … 6 = Saturday). */
9330
+ days: array(number().int().min(0).max(6)).min(1),
9331
+ startMinute: number().int().min(0).max(1439),
9332
+ endMinute: number().int().min(0).max(1439)
9333
+ })).min(1),
9334
+ /** IANA timezone; default = hub host timezone. */
9335
+ timezone: string().optional(),
9336
+ /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
9337
+ invert: boolean().optional()
9338
+ });
9339
+ /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
9340
+ var NcPlateMatcherSchema = object({
9341
+ values: array(string().min(1)).min(1),
9342
+ /** Max Levenshtein distance after normalization (uppercase alphanumeric). */
9343
+ maxDistance: number().int().min(0).max(3).default(1)
9344
+ });
9345
+ /**
9346
+ * Occupancy condition (DEVICE-EVENT trigger). Fires on a ZoneAnalytics
9347
+ * occupancy edge for a device — optionally narrowed to a single admin
9348
+ * `zoneId` and/or object `className`. `op` selects the edge/threshold:
9349
+ * - `became-occupied` (default) — count crossed 0 → ≥ `count`
9350
+ * - `became-free` — count crossed ≥ `count` → below it
9351
+ * - `>=` / `<=` — count is at/over or at/under `count`
9352
+ * `sustainSeconds` requires the condition hold continuously that long
9353
+ * before firing (debounces flicker; 0 = fire on the first matching edge).
9354
+ * Fail-closed: no ZoneAnalytics snapshot / missing zone / null snapshot ⇒
9355
+ * the condition never matches. Confirmed edge-state survives addon restarts
9356
+ * (declared SQLite collection, reseeded on boot).
9357
+ */
9358
+ var NcOccupancyConditionSchema = object({
9359
+ /** Admin zone id to scope the count to; absent = whole-frame occupancy. */
9360
+ zoneId: string().optional(),
9361
+ /** Object class to count; absent = any class. */
9362
+ className: string().optional(),
9363
+ op: _enum([
9364
+ "became-occupied",
9365
+ "became-free",
9366
+ ">=",
9367
+ "<="
9368
+ ]).default("became-occupied"),
9369
+ count: number().int().min(0).default(1),
9370
+ sustainSeconds: number().int().min(0).max(3600).default(15)
9371
+ });
9372
+ /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
9373
+ var NcZoneConditionSchema = object({
9374
+ ids: array(string().min(1)).min(1),
9375
+ /** Quantifier over `ids` — at least one / every one visited. */
9376
+ match: _enum(["any", "all"]).default("any")
9377
+ });
9378
+ /**
9379
+ * The P1 condition set — a flat AND of groups; absent group = pass;
9380
+ * membership lists are OR within the list (spec §2.3).
9381
+ */
9382
+ var NcConditionsSchema = object({
9383
+ /** Device scope — absent = all devices. */
9384
+ devices: array(number()).optional(),
9385
+ /** Detector class names (any overlap with the record's class set). */
9386
+ classes: array(string().min(1)).optional(),
9387
+ /** Veto classes — any overlap fails the rule. */
9388
+ classesExclude: array(string().min(1)).optional(),
9389
+ /** Minimum detection confidence 0–1 (fails when the record has none). */
9390
+ minConfidence: number().min(0).max(1).optional(),
9391
+ /** Admin zone membership over event `zones` / track `zonesVisited`. */
9392
+ zones: NcZoneConditionSchema.optional(),
9393
+ /** Veto zones — any hit fails the rule. */
9394
+ zonesExclude: array(string().min(1)).optional(),
9395
+ /**
9396
+ * Exact (case-insensitive) match on the record's collapsed `label`
9397
+ * (identity name / plate text / subclass).
9398
+ */
9399
+ labelEquals: array(string().min(1)).optional(),
9400
+ /**
9401
+ * Identity matcher. P1 boundary: matched against the record's collapsed
9402
+ * `label` (the identity display name propagated by the face pipeline) —
9403
+ * identity-ID matching rides in P2 when identity ids reach the record.
9404
+ */
9405
+ identities: array(string().min(1)).optional(),
9406
+ /** Fuzzy plate matcher against the record's `label` (plate text). */
9407
+ plates: NcPlateMatcherSchema.optional(),
9408
+ /**
9409
+ * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
9410
+ * Same P1 boundary: matched against the record's collapsed `label` (the
9411
+ * identity display name). A record with NO label passes (nothing to
9412
+ * exclude), unlike the include variant which fails on an absent label.
9413
+ */
9414
+ identitiesExclude: array(string().min(1)).optional(),
9415
+ /**
9416
+ * Minimum server-computed key-event importance in [0,1] (`Track.importance`).
9417
+ * TRACK-END only: importance is scored at track close, so it does not exist
9418
+ * at immediate / object-event evaluation time (see catalog `appliesTo`). At
9419
+ * close the value is threaded via the close-time info (the `Track` clone is
9420
+ * captured before the DB row is updated, so it would otherwise read stale).
9421
+ * Fails when the record carries no importance (never guess quality — the
9422
+ * `minConfidence` precedent). MVP cut: a single scalar threshold.
9423
+ */
9424
+ minImportance: number().min(0).max(1).optional(),
9425
+ /**
9426
+ * Minimum track dwell in SECONDS — `(lastSeen − firstSeen) / 1000`.
9427
+ * TRACK-END only: an `immediate` / object-event subject has no closed
9428
+ * lifespan, so a dwell condition never matches immediate delivery
9429
+ * (documented choice — the object-event record carries no `firstSeen`,
9430
+ * so dwell cannot be computed from what the subject actually carries).
9431
+ */
9432
+ minDwellSeconds: number().min(0).optional(),
9433
+ /**
9434
+ * Detection provenance filter. `any` (default / absent) matches every
9435
+ * source; otherwise the subject's source must equal it. Legacy records
9436
+ * with no stamped source are treated as `pipeline`. The union spans both
9437
+ * record kinds — object events carry `pipeline` | `onboard`, synthetic
9438
+ * tracks carry `sensor`.
9439
+ */
9440
+ source: _enum([
9441
+ "pipeline",
9442
+ "onboard",
9443
+ "sensor",
9444
+ "any"
9445
+ ]).optional(),
9446
+ /**
9447
+ * Minimum identity / plate MATCH confidence in [0,1] — DISTINCT from the
9448
+ * detector `minConfidence` (that gates the object-detection score; this
9449
+ * gates the recognition/OCR match score). Fails when the subject carries
9450
+ * no label-match confidence (never guess). TRACK-END only: the confidence
9451
+ * lives on the recognition result and reaches the subject at track close.
9452
+ *
9453
+ * What it measures precisely (plumbed at track close — the closer threads
9454
+ * the value into `NcTrackClosedInfo.labelConfidence`, the same seam as
9455
+ * `importance`): the BEST recognition match confidence observed for the
9456
+ * label the track carries at close — for a face, the peak cosine similarity
9457
+ * of the ASSIGNED identity (`FaceMatch.score`, reset on an identity switch);
9458
+ * for a plate, the peak OCR read score of the best-held plate
9459
+ * (`plateText.confidence`). When BOTH a face and a plate were recognized on
9460
+ * one track the higher of the two is used. A track that ended with no
9461
+ * confident identity/plate match carries no value, so the condition fails
9462
+ * closed for it (an un-recognized subject).
9463
+ */
9464
+ minLabelConfidence: number().min(0).max(1).optional(),
9465
+ /**
9466
+ * DEVICE-EVENT only. Raw device event-type tokens (`EventFire.eventType`,
9467
+ * e.g. a doorbell `press` / `press_long`) — matched case-insensitively
9468
+ * against the token carried on the device-event subject (extracted from the
9469
+ * event-emitter runtime slice's `lastEvent.eventType`). Fails when the
9470
+ * subject carries no token. Doorbell-pulse / passive-sensor kinds emit no
9471
+ * eventType, so gate those with {@link sensorKinds} instead.
9472
+ */
9473
+ eventTypeTokens: array(string().min(1)).optional(),
9474
+ /**
9475
+ * DEVICE-EVENT only. Sensor/control taxonomy kinds (e.g. `doorbell`,
9476
+ * `contact`, `button`, `device-event`) — matched against the persisted
9477
+ * `SensorEvent.kind` (see `sensor-event-kinds.ts`). Membership is OR.
9478
+ */
9479
+ sensorKinds: array(string().min(1)).optional(),
9480
+ /**
9481
+ * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
9482
+ * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
9483
+ * when the subject's phase does not match (a subject always carries a phase
9484
+ * on the package-event trigger).
9485
+ */
9486
+ packagePhase: _enum([
9487
+ "delivered",
9488
+ "picked-up",
9489
+ "both"
9490
+ ]).optional(),
9491
+ /**
9492
+ * PERSONAL-RULE custom zones (viewer-drawn). Inline normalized polygons
9493
+ * (MaskShape vocabulary). A record passes when its bbox overlaps ANY
9494
+ * listed polygon (ZoneEngine membership semantics). Evaluated only when
9495
+ * the subject carries a bbox; absent bbox ⇒ the condition FAILS.
9496
+ */
9497
+ customZones: array(MaskPolygonShapeSchema).optional(),
9498
+ /**
9499
+ * DEVICE-EVENT only. ZoneAnalytics occupancy edge — fires when a device's
9500
+ * (optionally zone/class-scoped) occupancy count crosses the configured
9501
+ * threshold and holds for `sustainSeconds`. Fail-closed on missing
9502
+ * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
9503
+ */
9504
+ occupancy: NcOccupancyConditionSchema.optional()
9505
+ });
9506
+ /** One delivery target: a `notification-output` Target ref + passthrough params. */
9507
+ var NcRuleTargetSchema = object({
9508
+ /** `notification-output` Target id. */
9509
+ targetId: string().min(1),
9510
+ /**
9511
+ * Per-backend passthrough. Recognized keys are mapped onto the canonical
9512
+ * Notification (`priority`, `level`, `sound`, `clickUrl`, `ttl`); the
9513
+ * degrade engine drops what the backend can't render.
9514
+ */
9515
+ params: record(string(), unknown()).optional()
9516
+ });
9517
+ /**
9518
+ * Media attachment policy (P1 still-image subset).
9519
+ * - `best` — the best AVAILABLE subject image at dispatch time (D-3).
9520
+ * - `best-matching` — the media that explains WHY the rule fired: a rule
9521
+ * matched on identities attaches the subject's `faceCrop`, one matched on
9522
+ * plates attaches the `plateCrop`; a rule with no identity/plate condition
9523
+ * (or when the specific crop is missing) degrades to `best`, then
9524
+ * `keyFrame`, then no attachment — never delaying the send. The matched
9525
+ * condition summary is frozen on the outbox row at enqueue (like the rule
9526
+ * name), so the choice never drifts from the record that fired it.
9527
+ * - `keyFrame` — the clean scene frame (no subject box).
9528
+ * - `none` — no attachment.
9529
+ */
9530
+ var NcMediaPolicySchema = object({ attach: _enum([
9531
+ "best",
9532
+ "best-matching",
9533
+ "keyFrame",
9534
+ "none"
9535
+ ]).default("best") });
9536
+ /** Throttle — cooldown survives restarts (rebuilt from the outbox on boot). */
9537
+ var NcThrottleSchema = object({
9538
+ cooldownSec: number().int().min(0).max(86400).default(60),
9539
+ /** `rule` = one shared cooldown; `rule-device` = per-camera cooldown. */
9540
+ scope: _enum(["rule", "rule-device"]).default("rule-device")
9541
+ });
9542
+ /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
9543
+ var NcRuleInputSchema = object({
9544
+ name: string().min(1).max(200),
9545
+ enabled: boolean().default(true),
9546
+ delivery: NcDeliverySchema,
9547
+ conditions: NcConditionsSchema.default({}),
9548
+ schedule: NcScheduleSchema.optional(),
9549
+ targets: array(NcRuleTargetSchema).min(1),
9550
+ media: NcMediaPolicySchema.default({ attach: "best" }),
9551
+ throttle: NcThrottleSchema.default({
9552
+ cooldownSec: 60,
9553
+ scope: "rule-device"
9554
+ }),
9555
+ /** `{{var}}` templating over camera/class/label/zones/confidence/time. */
9556
+ template: object({
9557
+ title: string().max(500).optional(),
9558
+ body: string().max(2e3).optional()
9559
+ }).optional(),
9560
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
9561
+ priority: number().int().min(1).max(5).default(3),
9562
+ /**
9563
+ * Ownership/visibility key. Absent = admin/global rule (unchanged legacy
9564
+ * behaviour, visible to all, read-only in the viewer). Present = personal
9565
+ * rule owned by this userId. Server-stamped; never trusted from a client.
9566
+ */
9567
+ ownerUserId: string().optional()
9568
+ });
9569
+ /**
9570
+ * Partial patch for `updateRule` — any subset of the input fields, plus the
9571
+ * persisted-only {@link NcRuleSchema} `disabledTargetIds` set. The latter is
9572
+ * NOT a client-authored input field (it lives on the persisted rule, not the
9573
+ * input), so it is added here explicitly to let the store's per-target opt-out
9574
+ * toggle round-trip through the shared `update` path. Viewer opt-out mutations
9575
+ * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
9576
+ * `updateRule` patch.
9577
+ */
9578
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
9579
+ /** A persisted rule. */
9580
+ var NcRuleSchema = NcRuleInputSchema.extend({
9581
+ id: string(),
9582
+ /** userId of the admin who created the rule (server-stamped caller). */
9583
+ createdBy: string(),
9584
+ createdAt: number(),
9585
+ updatedAt: number(),
9586
+ /**
9587
+ * Per-target opt-out set. A targetId here is suppressed for THIS rule at
9588
+ * send time. Only a target's OWNER may add/remove its id (server-checked
9589
+ * in `nc.setRuleTargetEnabled`). Defaults to empty.
9590
+ */
9591
+ disabledTargetIds: array(string()).default([])
9592
+ });
9593
+ var NcTestResultSchema = object({
9594
+ recordId: string(),
9595
+ recordKind: _enum([
9596
+ "object-event",
9597
+ "track",
9598
+ "device-event",
9599
+ "package-event"
9600
+ ]),
9601
+ deviceId: number(),
9602
+ timestamp: number(),
9603
+ wouldFire: boolean(),
9604
+ /** Condition id that failed (first failing group), when `wouldFire` is false. */
9605
+ failedCondition: string().optional(),
9606
+ className: string().optional(),
9607
+ label: string().optional()
9608
+ });
9609
+ var NcConditionDescriptorSchema = object({
9610
+ /** Field id inside `NcConditions` (or `'schedule'` for the rule-level group). */
9611
+ id: string(),
9612
+ group: _enum([
9613
+ "scope",
9614
+ "class",
9615
+ "zones",
9616
+ "quality",
9617
+ "label",
9618
+ "schedule",
9619
+ "device",
9620
+ "package",
9621
+ "occupancy"
9622
+ ]),
9623
+ label: string(),
9624
+ /** Editor widget the UI renders — never hardcode per-condition forms. */
9625
+ valueType: _enum([
9626
+ "deviceIdList",
9627
+ "stringList",
9628
+ "number01",
9629
+ "number",
9630
+ "sourceSelect",
9631
+ "zoneSelection",
9632
+ "zoneIdList",
9633
+ "schedule",
9634
+ "plateMatcher",
9635
+ "packagePhase",
9636
+ "polygonDraw",
9637
+ "occupancy"
9638
+ ]),
9639
+ operator: _enum([
9640
+ "in",
9641
+ "notIn",
9642
+ "anyOf",
9643
+ "allOf",
9644
+ "gte",
9645
+ "fuzzyIn",
9646
+ "withinSchedule"
9647
+ ]),
9648
+ /** Which delivery kinds the condition applies to. */
9649
+ appliesTo: array(NcDeliverySchema),
9650
+ phase: string(),
9651
+ description: string().optional()
9652
+ });
9653
+ /**
9654
+ * The delivery lifecycle status of a history row — a straight read of the
9655
+ * durable outbox row's own status (single source of truth):
9656
+ * - `pending` — enqueued, in-flight or retrying with backoff
9657
+ * - `sent` — delivered (terminal)
9658
+ * - `dead` — dead-lettered after exhausting retries / a permanent
9659
+ * backend rejection / a deleted target (terminal; carries
9660
+ * the failure `error`)
9661
+ *
9662
+ * P1 has no `suppressed-quiet-hours` / `snoozed` states — those ride the P2
9663
+ * user dimension (quiet hours / snooze) and are additive when they land.
9664
+ */
9665
+ var NcHistoryStatusSchema = _enum([
9666
+ "pending",
9667
+ "sent",
9668
+ "dead"
9669
+ ]);
9670
+ /** The evaluated record kind a history row descends from (one per trigger). */
9671
+ var NcHistoryRecordKindSchema = _enum([
9672
+ "object-event",
9673
+ "track-end",
9674
+ "device-event",
9675
+ "package-event"
9676
+ ]);
9677
+ /** Subject summary frozen on the row at fire time (survives rule/record edits). */
9678
+ var NcHistorySubjectSchema = object({
9679
+ className: string(),
9680
+ label: string().optional(),
9681
+ confidence: number().optional(),
9682
+ zones: array(string()),
9683
+ timestamp: number()
9684
+ });
9685
+ /**
9686
+ * One delivery-history row. This is a read-only VIEW over the durable
9687
+ * outbox row (single source of truth — the same row the drain loop drives;
9688
+ * NO second write path, so history can never drift from delivery state).
9689
+ * The §3.2 fields map directly: `ruleId`/`targetId`/`deviceId` are columns,
9690
+ * `eventRef` is `recordKind`+`recordId`, `timestamps` are `createdAt`
9691
+ * (fire) / `updatedAt` (last transition), `status` + `error` are the
9692
+ * lifecycle. `ruleName` + `subject` are the intent snapshot frozen at
9693
+ * enqueue. `userId?` (per-recipient history) is P2 — no user dimension in
9694
+ * P1 (admin scope only).
9695
+ */
9696
+ var NcHistoryEntrySchema = object({
9697
+ /** Outbox row id — the stable dedup id `ruleId:dedupRef:targetId`. */
9698
+ id: string(),
9699
+ ruleId: string(),
9700
+ /** Rule name frozen at fire time (outlives a later rename / delete). */
9701
+ ruleName: string(),
9702
+ /** The rule urgency/trigger that produced this delivery. */
9703
+ delivery: NcDeliverySchema,
9704
+ targetId: string(),
9705
+ deviceId: number(),
9706
+ recordKind: NcHistoryRecordKindSchema,
9707
+ /** Event / track ref of the evaluated record (§3.2 `eventRef`). */
9708
+ recordId: string(),
9709
+ /** Present for track-scoped deliveries (object-event / track-end). */
9710
+ trackId: string().optional(),
9711
+ status: NcHistoryStatusSchema,
9712
+ /** Delivery attempts made so far. */
9713
+ attempts: number().int(),
9714
+ /** Fire time (outbox enqueue). */
9715
+ createdAt: number(),
9716
+ /** Last transition time (terminal for sent / dead). */
9717
+ updatedAt: number(),
9718
+ /** Failure detail — present on a `dead` row. */
9719
+ error: string().optional(),
9720
+ subject: NcHistorySubjectSchema
9721
+ });
9722
+ /**
9723
+ * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
9724
+ * AND; absent = unbounded on that axis. `since`/`until` bound the fire time
9725
+ * (`createdAt`, epoch ms, inclusive). `limit` is clamped to
9726
+ * {@link NC_HISTORY_LIMIT_MAX}. `userId` (per-recipient filtering) is P2.
9727
+ */
9728
+ var NcHistoryFilterSchema = object({
9729
+ ruleId: string().optional(),
9730
+ deviceId: number().optional(),
9731
+ status: NcHistoryStatusSchema.optional(),
9732
+ since: number().optional(),
9733
+ until: number().optional(),
9734
+ limit: number().int().min(1).max(500).default(100)
9735
+ });
9736
+ 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 }), {
9737
+ kind: "mutation",
9738
+ auth: "admin",
9739
+ caller: "required"
9740
+ }), method(object({
9741
+ ruleId: string(),
9742
+ patch: NcRulePatchSchema
9743
+ }), object({ rule: NcRuleSchema }), {
9744
+ kind: "mutation",
9745
+ auth: "admin",
9746
+ caller: "required"
9747
+ }), method(object({ ruleId: string() }), object({ success: literal(true) }), {
9748
+ kind: "mutation",
9749
+ auth: "admin"
9750
+ }), method(object({
9751
+ ruleId: string(),
9752
+ enabled: boolean()
9753
+ }), object({ success: literal(true) }), {
9754
+ kind: "mutation",
9755
+ auth: "admin"
9756
+ }), method(object({
9757
+ rule: NcRuleInputSchema,
9758
+ lookbackMinutes: number().int().min(1).max(1440).default(60)
9759
+ }), object({ results: array(NcTestResultSchema) }), {
9760
+ kind: "mutation",
9761
+ auth: "admin"
9762
+ }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
9763
+ /**
9764
+ * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
9765
+ *
9766
+ * Spec: `docs/superpowers/specs/2026-07-24-nc-occupancy-timelapse-design.md`
9767
+ * §3.2/§3.3.
9768
+ *
9769
+ * Deliberately NOT a capability definition and NOT an `NcRule`:
9770
+ * - Every `NcDelivery` member is a *persisted-pipeline-record* trigger. A
9771
+ * timelapse fires on a SCHEDULE WINDOW BOUNDARY, evaluates no pipeline
9772
+ * record, and produces a video it assembled itself — so it rides no
9773
+ * delivery-enum member (the enum is frozen) and no cap method. This file is
9774
+ * a plain typed schema; it does NOT go through `npm run codegen`.
9775
+ * - It shares only the delivery leg (`notification-output.send`) and the
9776
+ * persistence/ownership patterns with the Notification Center, reusing
9777
+ * {@link NcScheduleSchema} (weekly windows, midnight-crossing, invertible)
9778
+ * and {@link NcRuleTargetSchema} (target ref + passthrough params).
9779
+ *
9780
+ * Ownership is SERVER-DERIVED. `ownerUserId` / `createdBy` / `createdAt` /
9781
+ * `updatedAt` / `id` / `lastGeneratedAt` live on the PERSISTED rule only —
9782
+ * {@link TimelapseRuleInputSchema} and {@link TimelapseRulePatchSchema} do not
9783
+ * carry them, so a forged client payload can never claim or re-own a rule
9784
+ * (Zod strips unknown keys). The store stamps them from the resolved caller.
9785
+ */
9786
+ /** `{{var}}` templating over camera/rule/time — same vocabulary as `NcRule`. */
9787
+ var TimelapseTemplateSchema = object({
9788
+ title: string().max(500).optional(),
9789
+ body: string().max(2e3).optional()
9790
+ });
9791
+ var NameField = string().min(1).max(200);
9792
+ var DeviceIdsField = array(number()).min(1);
9793
+ var CadenceSecField = number().int().min(2).max(3600);
9794
+ var FramerateField = number().int().min(1).max(60);
9795
+ var TargetsField = array(NcRuleTargetSchema).min(1);
9796
+ var PriorityField = number().int().min(1).max(5);
9797
+ /**
9798
+ * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
9799
+ * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
9800
+ * here (see the ownership note above).
9801
+ */
9802
+ var TimelapseRuleInputSchema = object({
9803
+ name: NameField,
9804
+ enabled: boolean().default(true),
9805
+ /** Cameras sampled by this rule — one scratch dir + one artifact per device. */
9806
+ deviceIds: DeviceIdsField,
9807
+ /**
9808
+ * Activation window(s). REQUIRED (unlike `NcRule`, where an absent schedule
9809
+ * means "always active"): a timelapse is defined by its window boundaries —
9810
+ * open clears the scratch, close assembles and delivers.
9811
+ */
9812
+ schedule: NcScheduleSchema,
9813
+ /** Force-snapshot cadence inside the window, seconds (predecessor parity). */
9814
+ cadenceSec: CadenceSecField.default(15),
9815
+ /** Output frames per second of the assembled mp4 (predecessor parity). */
9816
+ framerate: FramerateField.default(10),
9817
+ /** `notification-output` targets the finished video/thumbnail is sent to. */
9818
+ targets: TargetsField,
9819
+ template: TimelapseTemplateSchema.optional(),
9820
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
9821
+ priority: PriorityField.default(3)
9822
+ });
9823
+ object({
9824
+ name: NameField.optional(),
9825
+ enabled: boolean().optional(),
9826
+ deviceIds: DeviceIdsField.optional(),
9827
+ schedule: NcScheduleSchema.optional(),
9828
+ cadenceSec: CadenceSecField.optional(),
9829
+ framerate: FramerateField.optional(),
9830
+ targets: TargetsField.optional(),
9831
+ template: TimelapseTemplateSchema.nullable().optional(),
9832
+ priority: PriorityField.optional()
9833
+ });
9834
+ TimelapseRuleInputSchema.extend({
9835
+ id: string(),
9836
+ /**
9837
+ * Ownership/visibility key. Absent = admin/global rule (visible to all).
9838
+ * Present = personal rule owned by this userId. Server-stamped from the
9839
+ * resolved caller; never trusted from a client payload.
9840
+ */
9841
+ ownerUserId: string().optional(),
9842
+ /**
9843
+ * Epoch-ms of the last successful generation — the 1-hour re-generation
9844
+ * guard's durable state (predecessor parity). Absent = never generated.
9845
+ */
9846
+ lastGeneratedAt: number().optional(),
9847
+ /** userId of the caller who created the rule (server-stamped). */
9848
+ createdBy: string(),
9849
+ createdAt: number(),
9850
+ updatedAt: number()
9851
+ });
9852
+ /**
9158
9853
  * Generic device-level status snapshot. Auto-registered by `BaseDevice`
9159
9854
  * for every device, regardless of provider — the kernel needs a uniform
9160
9855
  * cap-keyed slice for the basic device flags every consumer expects to
@@ -12262,6 +12957,22 @@ var CameraMetricsSchema = object({
12262
12957
  ])
12263
12958
  });
12264
12959
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
12960
+ /**
12961
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
12962
+ * within the frame, so the executor can re-cut a leaf child ROI at native
12963
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
12964
+ */
12965
+ var NativeCropRefSchema = object({
12966
+ /** Handle keying the retained native surface (node-pinned to its owner). */
12967
+ handle: FrameHandleSchema,
12968
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
12969
+ cropFrameSpace: object({
12970
+ x: number(),
12971
+ y: number(),
12972
+ w: number(),
12973
+ h: number()
12974
+ })
12975
+ });
12265
12976
  var ModelFormatSchema$1 = _enum([
12266
12977
  "onnx",
12267
12978
  "coreml",
@@ -12537,7 +13248,22 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
12537
13248
  * Omitted ⇒ the runner's default device (current single-engine
12538
13249
  * behaviour). Selects WHICH device pool of the node runs the call.
12539
13250
  */
12540
- deviceKey: string().optional()
13251
+ deviceKey: string().optional(),
13252
+ /**
13253
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
13254
+ * when the parent crop was resolved from the frame's retained NATIVE
13255
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
13256
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
13257
+ * resolution from that surface — the SAME quality path faces already
13258
+ * had — instead of the downscaled parent tile. `handle` keys the native
13259
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
13260
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
13261
+ * the executor's crop-normalized child ROI back into frame-normalized
13262
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
13263
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
13264
+ * (today's behaviour on the fallback path).
13265
+ */
13266
+ nativeCropRef: NativeCropRefSchema.optional()
12541
13267
  }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
12542
13268
  engine: PipelineEngineChoiceSchema.optional(),
12543
13269
  steps: array(PipelineStepInputSchema).min(1),
@@ -12786,7 +13512,11 @@ var DetailResultSchema = object({
12786
13512
  bbox: NativeCropBboxSchema.optional(),
12787
13513
  embedding: string().optional(),
12788
13514
  label: string().optional(),
12789
- alignedCropJpeg: string().optional()
13515
+ alignedCropJpeg: string().optional(),
13516
+ /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
13517
+ * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
13518
+ * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
13519
+ nativeFaceShortSidePx: number().optional()
12790
13520
  });
12791
13521
  /**
12792
13522
  * Per-camera tunable ranges + defaults. Single source of truth used
@@ -12800,6 +13530,12 @@ var motionCooldownMsField = {
12800
13530
  default: 3e4,
12801
13531
  step: 500
12802
13532
  };
13533
+ var maxSessionHoldMsField = {
13534
+ min: 0,
13535
+ max: 6e5,
13536
+ default: 12e4,
13537
+ step: 5e3
13538
+ };
12803
13539
  var motionFpsField = {
12804
13540
  min: 1,
12805
13541
  max: 30,
@@ -12947,6 +13683,19 @@ var RunnerCameraConfigSchema = object({
12947
13683
  "on-motion"
12948
13684
  ]).default("always-on"),
12949
13685
  motionCooldownMs: number().min(motionCooldownMsField.min).default(motionCooldownMsField.default),
13686
+ /**
13687
+ * Orchestrator-side on-motion session-hold cap (ms). While an on-motion
13688
+ * detection session is active and ≥1 confirmed non-stationary track is
13689
+ * still live, the orchestrator keeps the session open past
13690
+ * `motionCooldownMs` (a slowly-moving subject can stop re-triggering the
13691
+ * camera's VMD yet is still being tracked frame-to-frame) — up to this many
13692
+ * ms since the session opened, after which it closes regardless. `0`
13693
+ * disables the hold (legacy cooldown-only teardown). Not consumed by the
13694
+ * runner itself — carried here so it shares the per-camera device-settings
13695
+ * surface with `motionCooldownMs`; the orchestrator reads it off the
13696
+ * resolved `CameraDetectionConfig`.
13697
+ */
13698
+ maxSessionHoldMs: number().min(maxSessionHoldMsField.min).max(maxSessionHoldMsField.max).optional(),
12950
13699
  motionFps: number().min(motionFpsField.min).max(motionFpsField.max).default(motionFpsField.default),
12951
13700
  detectionFps: number().min(detectionFpsField.min).max(detectionFpsField.max).default(detectionFpsField.default),
12952
13701
  motionStreamId: string(),
@@ -13036,7 +13785,7 @@ var RunnerCameraConfigSchema = object({
13036
13785
  */
13037
13786
  inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
13038
13787
  });
13039
- 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;
13788
+ 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;
13040
13789
  /**
13041
13790
  * Runtime load summary returned by `getLocalLoad`. Used by the orchestrator's
13042
13791
  * load-balancing levels (L2 capacity-based, L3 hardware-aware) to decide
@@ -13252,86 +14001,25 @@ var motionTriggerCapability = {
13252
14001
  runtimeState: MotionTriggerRuntimeStateSchema
13253
14002
  };
13254
14003
  /**
13255
- * Shared geometry vocabulary for on-frame shape caps privacy-mask,
13256
- * motion-zones, and the detection zones/lines editor all speak this one
13257
- * language so a single drawing-plane editor and the providers stay
13258
- * decoupled from each cap's storage.
13259
- *
13260
- * All coordinates are normalized 0..1 of the camera frame (top-left
13261
- * origin). Each cap composes the SUBSET of shape kinds it supports and
13262
- * advertises it via `supportedShapes` in its `getOptions`.
14004
+ * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
14005
+ * on-camera motion-detection mask is a single `grid` region (a row-major
14006
+ * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
14007
+ * a region keeps one drawing-plane model across all geometry caps.
13263
14008
  */
13264
- /** A normalized 0..1 point (top-left origin). */
13265
- var MaskPointSchema = object({
13266
- x: number(),
13267
- y: number()
13268
- });
13269
- /** Axis-aligned rectangle (normalized 0..1). */
13270
- var MaskRectShapeSchema = object({
13271
- kind: literal("rect"),
13272
- x: number(),
13273
- y: number(),
13274
- width: number(),
13275
- height: number()
14009
+ /** A motion-zone region exactly one boolean cell grid today. */
14010
+ var MotionZoneRegionSchema = object({
14011
+ id: number(),
14012
+ enabled: boolean(),
14013
+ shape: MaskGridShapeSchema
13276
14014
  });
13277
- /** Free polygon an ordered list of normalized vertices (≥3). */
13278
- var MaskPolygonShapeSchema = object({
13279
- kind: literal("polygon"),
13280
- points: array(MaskPointSchema)
13281
- });
13282
- /** Boolean cell grid row-major, length === gridWidth*gridHeight. */
13283
- var MaskGridShapeSchema = object({
13284
- kind: literal("grid"),
13285
- gridWidth: number(),
13286
- gridHeight: number(),
13287
- cells: array(boolean())
13288
- });
13289
- discriminatedUnion("kind", [
13290
- MaskRectShapeSchema,
13291
- MaskPolygonShapeSchema,
13292
- MaskGridShapeSchema,
13293
- object({
13294
- kind: literal("line"),
13295
- points: array(MaskPointSchema)
13296
- })
13297
- ]);
13298
- /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
13299
- var MaskShapeKindSchema = _enum([
13300
- "rect",
13301
- "polygon",
13302
- "grid",
13303
- "line"
13304
- ]);
13305
- /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
13306
- var MaskPolygonVerticesSchema = object({
13307
- min: number(),
13308
- max: number()
13309
- });
13310
- /** Grid dimensions when a cap supports 'grid'. */
13311
- var MaskGridDimsSchema = object({
13312
- width: number(),
13313
- height: number()
13314
- });
13315
- /**
13316
- * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
13317
- * on-camera motion-detection mask is a single `grid` region (a row-major
13318
- * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
13319
- * a region keeps one drawing-plane model across all geometry caps.
13320
- */
13321
- /** A motion-zone region — exactly one boolean cell grid today. */
13322
- var MotionZoneRegionSchema = object({
13323
- id: number(),
13324
- enabled: boolean(),
13325
- shape: MaskGridShapeSchema
13326
- });
13327
- /** Current on-camera motion-detection state — master enable + sensitivity +
13328
- * the grid region(s). */
13329
- var MotionZoneStatusSchema = object({
13330
- enabled: boolean(),
13331
- sensitivity: number(),
13332
- /** Grid region(s). Today exactly one `grid` shape. */
13333
- regions: array(MotionZoneRegionSchema),
13334
- lastFetchedAt: number()
14015
+ /** Current on-camera motion-detection state master enable + sensitivity +
14016
+ * the grid region(s). */
14017
+ var MotionZoneStatusSchema = object({
14018
+ enabled: boolean(),
14019
+ sensitivity: number(),
14020
+ /** Grid region(s). Today exactly one `grid` shape. */
14021
+ regions: array(MotionZoneRegionSchema),
14022
+ lastFetchedAt: number()
13335
14023
  });
13336
14024
  /** Per-camera availability — grid dims are fixed per camera model; the UI
13337
14025
  * sizes its editor from `grid`. */
@@ -16563,94 +17251,6 @@ var EnrichedWidgetMetadataSchema = WidgetMetadataSchema.extend({
16563
17251
  bundleUrl: string()
16564
17252
  });
16565
17253
  method(_void(), array(EnrichedWidgetMetadataSchema).readonly());
16566
- var NotificationRuleConditionsSchema = object({
16567
- deviceIds: array(number()).readonly().optional(),
16568
- classNames: array(string()).readonly().optional(),
16569
- zoneIds: array(string()).readonly().optional(),
16570
- minConfidence: number().optional(),
16571
- source: _enum([
16572
- "pipeline",
16573
- "onboard",
16574
- "any"
16575
- ]).optional(),
16576
- schedule: object({
16577
- days: array(number()).readonly(),
16578
- startHour: number(),
16579
- endHour: number()
16580
- }).optional(),
16581
- cooldownSeconds: number().optional(),
16582
- minDwellSeconds: number().optional(),
16583
- /** Match against `event.data.eventType` token (e.g. `'press_long'`). When non-empty, only events
16584
- * carrying a matching `data.eventType` string pass this condition. Rules without this field are
16585
- * unaffected (back-compat). Distinct from `rule.eventTypes` which holds EventCategory strings. */
16586
- eventTypeTokens: array(string()).readonly().optional(),
16587
- /** Match detections whose CLIP image embedding is semantically similar to this free-text
16588
- * description. Requires the embedding-encoder cap to have pre-warmed the text vector.
16589
- * `minSimilarity` is the cosine similarity threshold in [0, 1]. */
16590
- clipDescription: object({
16591
- text: string().min(1),
16592
- minSimilarity: number().min(0).max(1)
16593
- }).optional(),
16594
- /** Match events whose recognized-entity label (face identity name or plate
16595
- * vehicle name, propagated onto `event.data.label`) is one of these values.
16596
- * Empty/absent → unaffected (back-compat). Enables "notify me when <named
16597
- * vehicle/person> is seen". */
16598
- labels: array(string()).readonly().optional()
16599
- });
16600
- var NotificationRuleTemplateSchema = object({
16601
- title: string(),
16602
- body: string(),
16603
- imageMode: _enum([
16604
- "crop",
16605
- "annotated",
16606
- "full",
16607
- "none"
16608
- ])
16609
- });
16610
- var NotificationRuleSchema = object({
16611
- id: string(),
16612
- name: string(),
16613
- enabled: boolean(),
16614
- eventTypes: array(string()).readonly(),
16615
- conditions: NotificationRuleConditionsSchema,
16616
- outputs: array(string()).readonly(),
16617
- template: NotificationRuleTemplateSchema.optional(),
16618
- priority: _enum([
16619
- "low",
16620
- "normal",
16621
- "high",
16622
- "critical"
16623
- ])
16624
- });
16625
- var NotificationTestResultSchema = object({
16626
- ruleId: string(),
16627
- eventId: string(),
16628
- timestamp: number(),
16629
- wouldFire: boolean(),
16630
- reason: string().optional()
16631
- });
16632
- var NotificationHistoryEntrySchema = object({
16633
- id: string(),
16634
- ruleId: string(),
16635
- ruleName: string(),
16636
- eventId: string(),
16637
- timestamp: number(),
16638
- outputs: array(string()).readonly(),
16639
- success: boolean(),
16640
- error: string().optional(),
16641
- deviceId: number().optional()
16642
- });
16643
- var NotificationHistoryFilterSchema = object({
16644
- ruleId: string().optional(),
16645
- deviceId: number().optional(),
16646
- from: number().optional(),
16647
- to: number().optional(),
16648
- limit: number().optional()
16649
- });
16650
- 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({
16651
- ruleId: string(),
16652
- lookbackMinutes: number()
16653
- }), object({ results: array(NotificationTestResultSchema).readonly() }), { kind: "mutation" }), method(object({ filter: NotificationHistoryFilterSchema.optional() }), object({ entries: array(NotificationHistoryEntrySchema).readonly() }));
16654
17254
  /**
16655
17255
  * Alerts capability — collection-based internal alert system.
16656
17256
  *
@@ -16837,88 +17437,54 @@ method(object({
16837
17437
  password: string()
16838
17438
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
16839
17439
  /**
16840
- * `login-method` collection cap through which auth addons contribute
16841
- * their pre-auth login surfaces to the login page. This is the SINGLE,
16842
- * generic mechanism that supersedes the dead `auth.listProviders` reader:
16843
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
16844
- * `login-method` provider and the PUBLIC `auth.listLoginMethods`
16845
- * procedure aggregates them for the unauthenticated login page.
16846
- *
16847
- * A contribution is a discriminated union on `kind`:
16848
- *
16849
- * - `redirect` — a declarative button. The login page renders a generic
16850
- * button that navigates to `startUrl` (an addon-owned HTTP route).
16851
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
16852
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
16853
- * login page needs NO change.
16854
- *
16855
- * - `widget` — a Module-Federation widget the login page mounts (via
16856
- * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
16857
- * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
16858
- * mechanism kept for future use; no shipped addon uses it on the login
16859
- * page (the passkey ceremony below runs natively in the shell instead).
16860
- *
16861
- * - `passkey` — a declarative WebAuthn ceremony the shell renders
16862
- * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
16863
- * a remotely-loaded bundle). Carries the addon's effective `rpId` /
16864
- * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
16865
- * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
16866
- * fetching any remote code pre-auth. Contribution stays unconditional —
16867
- * enrollment state is never leaked pre-auth; visibility is a shell
16868
- * decision.
16869
- *
16870
- * Every contribution carries a `stage`:
16871
- * - `primary` — shown on the first credentials screen (OIDC /
16872
- * magic-link buttons; a future usernameless passkey).
16873
- * - `second-factor` — shown AFTER the password leg, gated on the
16874
- * returned `factors` (passkey-as-2FA today).
16875
- *
16876
- * `mount: skip` — the cap is read server-side by the core auth router
16877
- * (`registry.getCollection('login-method')`), never mounted as its own
16878
- * tRPC router.
17440
+ * A live terminal session hosted by the provider addon. Output and input do
17441
+ * NOT flow through the capability they use the addon data plane
17442
+ * (`GET /addon/terminal/<id>/out` SSE, `POST /addon/terminal/<id>/in`) because
17443
+ * terminal output must be ordered and lossless. The event bus is telemetry and
17444
+ * may drop chunks ([D8]), and a dropped chunk desynchronises the vt parser
17445
+ * permanently until a full repaint. The capability owns only lifecycle.
16879
17446
  */
16880
- /** When a login method renders in the two-phase login flow. */
16881
- var LoginStageEnum = _enum(["primary", "second-factor"]);
16882
- /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
16883
- var LoginMethodContributionSchema = discriminatedUnion("kind", [
16884
- object({
16885
- kind: literal("redirect"),
16886
- /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
16887
- id: string(),
16888
- /** Operator-facing button label. */
16889
- label: string(),
16890
- /** lucide-react icon name. */
16891
- icon: string().optional(),
16892
- /** Addon-owned HTTP route the button navigates to (GET). */
16893
- startUrl: string(),
16894
- stage: LoginStageEnum
16895
- }),
16896
- object({
16897
- kind: literal("widget"),
16898
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
16899
- id: string(),
16900
- /** Owning addon id — drives the public bundle URL + the MF namespace. */
16901
- addonId: string(),
16902
- /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
16903
- bundle: string(),
16904
- /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
16905
- remote: WidgetRemoteSchema,
16906
- stage: LoginStageEnum
16907
- }),
16908
- object({
16909
- kind: literal("passkey"),
16910
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
16911
- id: string(),
16912
- /** Operator-facing button label. */
16913
- label: string(),
16914
- stage: LoginStageEnum,
16915
- /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
16916
- rpId: string(),
16917
- /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
16918
- origin: string().nullable()
16919
- })
16920
- ]);
16921
- method(_void(), array(LoginMethodContributionSchema).readonly());
17447
+ var TerminalSessionInfoSchema = object({
17448
+ /** Opaque session id minted by the provider on `openSession`. */
17449
+ sessionId: string(),
17450
+ /** The pre-declared profile this session runs (never a free-form command). */
17451
+ profileId: string(),
17452
+ /** Human-readable profile label for the UI session list. */
17453
+ label: string(),
17454
+ cols: number().int().positive(),
17455
+ rows: number().int().positive(),
17456
+ /** ms-epoch the session's pty was spawned. */
17457
+ startedAt: number()
17458
+ });
17459
+ /**
17460
+ * A profile the operator may open — a pre-declared, allowlisted program
17461
+ * (`monitor` → `btm`). The capability accepts only these ids; a free-form
17462
+ * command string would be remote code execution as the server's user, so it is
17463
+ * deliberately not part of the contract.
17464
+ */
17465
+ var TerminalProfileInfoSchema = object({
17466
+ profileId: string(),
17467
+ label: string(),
17468
+ description: string().optional()
17469
+ });
17470
+ method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(TerminalSessionInfoSchema).readonly(), { auth: "admin" }), method(object({
17471
+ profileId: string(),
17472
+ cols: number().int().positive(),
17473
+ rows: number().int().positive()
17474
+ }), TerminalSessionInfoSchema, {
17475
+ kind: "mutation",
17476
+ auth: "admin"
17477
+ }), method(object({
17478
+ sessionId: string(),
17479
+ cols: number().int().positive(),
17480
+ rows: number().int().positive()
17481
+ }), _void(), {
17482
+ kind: "mutation",
17483
+ auth: "admin"
17484
+ }), method(object({ sessionId: string() }), _void(), {
17485
+ kind: "mutation",
17486
+ auth: "admin"
17487
+ });
16922
17488
  /**
16923
17489
  * Orchestrator-side destination metadata. The orchestrator computes
16924
17490
  * `id = <addonId>:<subId>` from its provider lookup so consumers
@@ -17020,11 +17586,53 @@ var LocationStatSchema = object({
17020
17586
  fileCount: number(),
17021
17587
  present: boolean()
17022
17588
  });
17589
+ /**
17590
+ * A backup schedule — the N:M "entry" that binds one cron cadence to a
17591
+ * SET of destination locations. Supersedes the per-location cron on
17592
+ * `BackupDestinationPolicy`: an operator creates a schedule, picks the
17593
+ * `backups` locations it should write to, and the orchestrator fans a
17594
+ * single archive out to all of them when the cron fires.
17595
+ *
17596
+ * `retentionCount` is per-schedule (D-decision 2026-07-28): every
17597
+ * location targeted by this schedule keeps this many archives from
17598
+ * this schedule's runs.
17599
+ *
17600
+ * `dataSources` optionally narrows which top-level state locations
17601
+ * (db, addons, tls, …) are archived; omitted = the orchestrator's
17602
+ * default full set.
17603
+ */
17604
+ var BackupScheduleSchema = object({
17605
+ /** Stable id. Generated by the orchestrator on first upsert if absent. */
17606
+ id: string(),
17607
+ /** Operator-facing display name. */
17608
+ label: string(),
17609
+ /** 5-field POSIX cron. Empty = disabled cadence (kept for editing). */
17610
+ cron: string(),
17611
+ /** Master on/off toggle for the whole schedule. */
17612
+ enabled: boolean(),
17613
+ /** `backups`-location ids this schedule writes to (fan-out set). */
17614
+ locationIds: array(string()).readonly(),
17615
+ /** Archives kept per targeted location for this schedule. */
17616
+ retentionCount: number().int().min(1).max(1e3),
17617
+ /** Optional subset of source locations to include; omitted = all. */
17618
+ dataSources: array(string()).readonly().optional(),
17619
+ /** ms-epoch of last successful run. */
17620
+ lastRunAt: number().optional(),
17621
+ /** ms-epoch of next computed firing (read-only, filled on list). */
17622
+ nextRunAt: number().optional()
17623
+ });
17023
17624
  method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }), method(object({
17024
17625
  /** Subset of registered `backup-destination` addon ids to write to. */
17025
17626
  destinations: array(string()).optional(),
17026
17627
  locations: array(string()).optional(),
17027
- label: string().optional()
17628
+ label: string().optional(),
17629
+ /**
17630
+ * Per-run retention override applied to every targeted
17631
+ * destination. Used by schedule-driven runs (per-entry
17632
+ * retention). Omitted = each destination's own policy
17633
+ * retention (manual runs).
17634
+ */
17635
+ retentionCount: number().int().min(1).max(1e3).optional()
17028
17636
  }).optional(), array(BackupEntrySchema).readonly(), {
17029
17637
  kind: "mutation",
17030
17638
  auth: "admin"
@@ -17073,7 +17681,21 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
17073
17681
  ok: boolean(),
17074
17682
  error: string().optional(),
17075
17683
  nextRuns: array(number()).readonly()
17076
- }));
17684
+ })), method(_void(), array(BackupScheduleSchema).readonly(), { auth: "admin" }), method(object({
17685
+ id: string().optional(),
17686
+ label: string(),
17687
+ cron: string(),
17688
+ enabled: boolean(),
17689
+ locationIds: array(string()).readonly(),
17690
+ retentionCount: number().int().min(1).max(1e3),
17691
+ dataSources: array(string()).readonly().optional()
17692
+ }), BackupScheduleSchema, {
17693
+ kind: "mutation",
17694
+ auth: "admin"
17695
+ }), method(object({ id: string() }), _void(), {
17696
+ kind: "mutation",
17697
+ auth: "admin"
17698
+ });
17077
17699
  /**
17078
17700
  * `broker` — unified pub/sub broker registry, system-scoped collection.
17079
17701
  *
@@ -18263,851 +18885,934 @@ method(_void(), array(string()).readonly(), { auth: "admin" }), method(object({
18263
18885
  kind: "mutation",
18264
18886
  auth: "admin"
18265
18887
  });
18266
- var LogLevelSchema = _enum([
18267
- "debug",
18268
- "info",
18269
- "warn",
18270
- "error"
18271
- ]);
18272
- var LogEntrySchema = object({
18273
- timestamp: date(),
18274
- level: LogLevelSchema,
18275
- scope: array(string()),
18276
- message: string(),
18277
- meta: record(string(), unknown()).optional(),
18278
- tags: record(string(), string()).optional()
18888
+ /**
18889
+ * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
18890
+ * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
18891
+ * caps stay wire-compatible without a circular cap→cap import.
18892
+ *
18893
+ * Errors are a discriminated-union RESULT, never thrown: the shape survives
18894
+ * every transport tier structurally, and failed calls still write usage rows.
18895
+ * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
18896
+ */
18897
+ var LlmUsageSchema = object({
18898
+ inputTokens: number(),
18899
+ outputTokens: number()
18279
18900
  });
18280
- method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18281
- scope: array(string()).optional(),
18282
- level: LogLevelSchema.optional(),
18283
- since: date().optional(),
18284
- until: date().optional(),
18285
- limit: number().optional(),
18286
- tags: record(string(), string()).optional()
18287
- }), array(LogEntrySchema).readonly());
18288
- var CpuBreakdownSchema = object({
18289
- total: number(),
18290
- user: number(),
18291
- system: number(),
18292
- irq: number(),
18293
- nice: number(),
18294
- loadAvg: tuple([
18295
- number(),
18296
- number(),
18297
- number()
18298
- ]),
18299
- cores: number()
18300
- });
18301
- var MemoryInfoSchema = object({
18302
- percent: number(),
18303
- totalBytes: number(),
18304
- usedBytes: number(),
18305
- availableBytes: number(),
18306
- swapUsedBytes: number(),
18307
- swapTotalBytes: number()
18308
- });
18309
- var DiskIoSnapshotSchema = object({
18310
- readBytes: number(),
18311
- writeBytes: number(),
18312
- readOps: number(),
18313
- writeOps: number(),
18314
- timestampMs: number()
18315
- });
18316
- var NetworkIoSnapshotSchema = object({
18317
- rxBytes: number(),
18318
- txBytes: number(),
18319
- rxPackets: number(),
18320
- txPackets: number(),
18321
- rxErrors: number(),
18322
- txErrors: number(),
18323
- timestampMs: number()
18324
- });
18325
- var MetricsGpuInfoSchema = object({
18326
- utilization: number(),
18901
+ var LlmErrorCodeSchema = _enum([
18902
+ "timeout",
18903
+ "rate-limited",
18904
+ "auth",
18905
+ "refusal",
18906
+ "bad-request",
18907
+ "unavailable",
18908
+ "no-profile",
18909
+ "budget-exceeded",
18910
+ "adapter-error"
18911
+ ]);
18912
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
18913
+ ok: literal(true),
18914
+ text: string(),
18327
18915
  model: string(),
18328
- memoryUsedBytes: number(),
18329
- memoryTotalBytes: number(),
18330
- temperature: number().nullable()
18331
- });
18332
- var ProcessResourceInfoSchema = object({
18333
- openFds: number(),
18334
- threadCount: number(),
18335
- activeHandles: number(),
18336
- activeRequests: number()
18337
- });
18338
- var PressureAvgsSchema = object({
18339
- avg10: number(),
18340
- avg60: number(),
18341
- avg300: number()
18916
+ usage: LlmUsageSchema,
18917
+ truncated: boolean(),
18918
+ latencyMs: number()
18919
+ }), object({
18920
+ ok: literal(false),
18921
+ code: LlmErrorCodeSchema,
18922
+ message: string(),
18923
+ retryAfterMs: number().optional()
18924
+ })]);
18925
+ /**
18926
+ * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
18927
+ * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
18928
+ * notification-output.cap.ts:27-31 precedents).
18929
+ */
18930
+ var LlmImageSchema = object({
18931
+ bytes: _instanceof(Uint8Array),
18932
+ mimeType: string()
18342
18933
  });
18343
- var PressureInfoSchema = object({
18344
- some: PressureAvgsSchema,
18345
- full: PressureAvgsSchema.nullable()
18934
+ var LlmGenerateBaseInputSchema = object({
18935
+ /** Collection routing (the notification-output posture). */
18936
+ addonId: string().optional(),
18937
+ /** Explicit profile; else the resolution chain (spec §3). */
18938
+ profileId: string().optional(),
18939
+ /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
18940
+ consumer: string(),
18941
+ system: string().optional(),
18942
+ /** v1: single-turn. `messages[]` is a v2 additive field. */
18943
+ prompt: string(),
18944
+ /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
18945
+ jsonSchema: record(string(), unknown()).optional(),
18946
+ /** Per-call override of the profile default. */
18947
+ maxTokens: number().int().positive().optional(),
18948
+ temperature: number().optional()
18346
18949
  });
18347
- var SystemResourceSnapshotSchema = object({
18348
- cpu: CpuBreakdownSchema,
18349
- memory: MemoryInfoSchema,
18350
- gpu: MetricsGpuInfoSchema.nullable(),
18351
- network: NetworkIoSnapshotSchema,
18352
- disk: DiskIoSnapshotSchema,
18353
- pressure: object({
18354
- cpu: PressureInfoSchema.nullable(),
18355
- memory: PressureInfoSchema.nullable(),
18356
- io: PressureInfoSchema.nullable()
18950
+ /**
18951
+ * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
18952
+ * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
18953
+ * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
18954
+ * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
18955
+ * this only through the `llm` cap's methods.
18956
+ *
18957
+ * One running llama-server child per node in v1 (models are RAM-heavy).
18958
+ * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
18959
+ * watchdog — operator decision #3).
18960
+ */
18961
+ var ManagedModelRefSchema = discriminatedUnion("kind", [
18962
+ object({
18963
+ kind: literal("catalog"),
18964
+ catalogId: string()
18357
18965
  }),
18358
- process: ProcessResourceInfoSchema,
18359
- cpuTemperature: number().nullable(),
18360
- timestampMs: number()
18361
- });
18362
- var DiskSpaceInfoSchema = object({
18363
- path: string(),
18364
- totalBytes: number(),
18365
- usedBytes: number(),
18366
- availableBytes: number(),
18367
- percent: number()
18368
- });
18369
- var PidResourceStatsSchema = object({
18370
- pid: number(),
18371
- cpu: number(),
18372
- memory: number(),
18373
- /**
18374
- * Private (anonymous) resident bytes — the per-process V8 heap + native
18375
- * allocations NOT shared with other processes (Linux RssAnon). This is the
18376
- * "real" per-runner cost; summing it across runners is meaningful, unlike
18377
- * `memory` (RSS), which double-counts the shared mmap'd framework code.
18378
- * Undefined where /proc is unavailable (e.g. macOS).
18379
- */
18380
- privateBytes: number().optional(),
18381
- /**
18382
- * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
18383
- * code shared copy-on-write across runners. Undefined on macOS.
18384
- */
18385
- sharedBytes: number().optional()
18966
+ object({
18967
+ kind: literal("url"),
18968
+ url: string(),
18969
+ sha256: string().optional()
18970
+ }),
18971
+ object({
18972
+ kind: literal("path"),
18973
+ path: string()
18974
+ })
18975
+ ]);
18976
+ var ManagedRuntimeConfigSchema = object({
18977
+ /** WHERE the runtime lives — hub or any agent. */
18978
+ nodeId: string(),
18979
+ /** Closed for v1; 'ollama' is a v2 candidate. */
18980
+ engine: _enum(["llama-cpp"]),
18981
+ model: ManagedModelRefSchema,
18982
+ contextSize: number().int().default(4096),
18983
+ /** 0 = CPU-only. */
18984
+ gpuLayers: number().int().default(0),
18985
+ /** Default: cpus-2, clamped ≥1 (resolved node-side). */
18986
+ threads: number().int().optional(),
18987
+ /** Concurrent slots. */
18988
+ parallel: number().int().default(1),
18989
+ /** Else lazy: first generate boots it. */
18990
+ autoStart: boolean().default(false),
18991
+ /** 0 = never; frees RAM after quiet periods. */
18992
+ idleStopMinutes: number().int().default(30)
18386
18993
  });
18387
- var AddonInstanceSchema = object({
18388
- addonId: string(),
18994
+ var LlmRuntimeStatusSchema = object({
18995
+ /** Status is ALWAYS node-qualified. */
18389
18996
  nodeId: string(),
18390
- role: _enum(["hub", "worker"]),
18391
- pid: number(),
18392
18997
  state: _enum([
18393
- "starting",
18394
- "running",
18395
- "stopping",
18396
18998
  "stopped",
18397
- "crashed"
18398
- ]),
18399
- uptimeSec: number()
18400
- });
18401
- var NodeProcessSchema = object({
18402
- pid: number(),
18403
- ppid: number(),
18404
- pgid: number(),
18405
- classification: _enum([
18406
- "root",
18407
- "managed",
18408
- "system",
18409
- "ghost"
18999
+ "downloading",
19000
+ "starting",
19001
+ "ready",
19002
+ "crashed",
19003
+ "failed"
18410
19004
  ]),
18411
- /** `$process` addon binding when `managed`, else null. */
18412
- addonId: string().nullable(),
18413
- /** Kernel-reported nodeId when the process is a known agent/worker. */
18414
- nodeId: string().nullable(),
18415
- /** Truncated command line. */
18416
- command: string(),
18417
- cpuPercent: number(),
18418
- memoryRssBytes: number(),
18419
- /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
18420
- uptimeSec: number(),
18421
- /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
18422
- orphaned: boolean()
18423
- });
18424
- var KillProcessInputSchema = object({
18425
- pid: number(),
18426
- /** Force = SIGKILL. Default is SIGTERM. */
18427
- force: boolean().optional()
19005
+ pid: number().optional(),
19006
+ port: number().optional(),
19007
+ modelPath: string().optional(),
19008
+ modelId: string().optional(),
19009
+ downloadProgress: number().min(0).max(1).optional(),
19010
+ lastError: string().optional(),
19011
+ crashesInWindow: number(),
19012
+ /** Child RSS (sampled best-effort). */
19013
+ memoryBytes: number().optional(),
19014
+ vramBytes: number().optional()
18428
19015
  });
18429
- var KillProcessResultSchema = object({
18430
- success: boolean(),
18431
- reason: string().optional(),
18432
- signal: _enum(["SIGTERM", "SIGKILL"]).optional()
19016
+ var LlmNodeModelSchema = object({
19017
+ file: string(),
19018
+ sizeBytes: number(),
19019
+ catalogId: string().optional(),
19020
+ installedAt: number().optional()
18433
19021
  });
18434
- var DumpHeapSnapshotInputSchema = object({
18435
- /** The addon whose runner should dump a heap snapshot. */
18436
- addonId: string() });
18437
- var DumpHeapSnapshotResultSchema = object({
18438
- success: boolean(),
18439
- /** Path of the written .heapsnapshot inside the runner's container/host. */
18440
- path: string().optional(),
18441
- /** Process pid that was signalled. */
18442
- pid: number().optional(),
18443
- reason: string().optional()
19022
+ var LlmRuntimeDiskUsageSchema = object({
19023
+ nodeId: string(),
19024
+ modelsBytes: number(),
19025
+ freeBytes: number().optional()
18444
19026
  });
18445
- var SystemMetricsSchema = object({
18446
- cpuPercent: number(),
18447
- memoryPercent: number(),
18448
- memoryUsedMB: number(),
18449
- memoryTotalMB: number(),
18450
- diskPercent: number().optional(),
18451
- temperature: number().optional(),
18452
- gpuPercent: number().optional(),
18453
- gpuMemoryPercent: number().optional()
18454
- });
18455
- 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, {
19027
+ method(LlmGenerateBaseInputSchema.extend({
19028
+ images: array(LlmImageSchema).optional(),
19029
+ runtime: ManagedRuntimeConfigSchema,
19030
+ /** The managed profile's timeout, threaded by the hub provider. */
19031
+ timeoutMs: number().int().positive().optional()
19032
+ }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
18456
19033
  kind: "mutation",
18457
19034
  auth: "admin"
18458
- }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
19035
+ }), method(object({}), _void(), {
18459
19036
  kind: "mutation",
18460
19037
  auth: "admin"
18461
- });
18462
- method(object({
18463
- sourceUrl: string(),
18464
- metadata: ModelConvertMetadataSchema,
18465
- targets: array(ConvertTargetSchema).min(1).readonly(),
18466
- calibrationRef: string().optional(),
18467
- sessionId: string().optional()
18468
- }), ConvertResultSchema, {
19038
+ }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
18469
19039
  kind: "mutation",
18470
- auth: "admin",
18471
- timeoutMs: 6e5
18472
- });
18473
- method(object({
18474
- nodeId: string(),
18475
- modelId: string(),
18476
- format: _enum(MODEL_FORMATS),
18477
- entry: ModelCatalogEntrySchema
18478
- }), object({
18479
- ok: boolean(),
18480
- /** sha256 of the staged tarball (empty for a hub-local no-op). */
18481
- sha256: string(),
18482
- bytes: number(),
18483
- /** The target node's modelsDir the artifact landed in. */
18484
- path: string()
18485
- }), {
19040
+ auth: "admin"
19041
+ }), method(object({ file: string() }), _void(), {
18486
19042
  kind: "mutation",
18487
19043
  auth: "admin"
18488
- });
18489
- /**
18490
- * `mqtt-broker` — broker-registry cap.
18491
- *
18492
- * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
18493
- * MQTT brokers (external + optionally an embedded `aedes`-backed one)
18494
- * and (b) the connection details a consumer addon needs to spin up
18495
- * its OWN `mqtt.js` client.
18496
- *
18497
- * Why: pub/sub routing over the system event-bus loses fidelity
18498
- * (callback shape, QoS guarantees, will/retain semantics) and adds
18499
- * refcount bookkeeping that addons would rather own themselves. The
18500
- * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
18501
- * features anyway — give it the connection config, get out of the way.
18502
- *
18503
- * Consumer flow:
18504
- * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
18505
- * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
18506
- * client.subscribe('zigbee2mqtt/+')
18507
- *
18508
- * Collection mode: multiple brokers (e.g. one local mosquitto + one
18509
- * cloud bridge). The "embedded" entry (when present) is just another
18510
- * broker in the registry — its lifecycle is owned by the addon that
18511
- * spawned it.
18512
- */
18513
- var BrokerKindSchema = _enum(["external", "embedded"]);
19044
+ }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
18514
19045
  /**
18515
- * Broker live-probe status.
19046
+ * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
19047
+ * methods concat-fan across providers; single-row methods route to ONE
19048
+ * provider by the `addonId` in the call input (the notification-output
19049
+ * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
19050
+ * (hub-placed); the cap stays open for future providers.
18516
19051
  *
18517
- * - `connected` last probe completed a clean CONNACK
18518
- * - `disconnected` — no probe has run yet (cold cache)
18519
- * - `auth-failed` CONNACK refused with auth error (RC 4 / 5)
18520
- * - `unreachable` — TCP connect timed out / refused
18521
- * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
19052
+ * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
19053
+ * `apiKey` is a password field providers REDACT it on read and merge on
19054
+ * write; a stored key NEVER round-trips to a client.
18522
19055
  */
18523
- var BrokerStatusSchema$1 = _enum([
18524
- "connected",
18525
- "disconnected",
18526
- "auth-failed",
18527
- "unreachable",
18528
- "tls-error"
19056
+ var LlmProfileKindSchema = _enum([
19057
+ "openai-compatible",
19058
+ "openai",
19059
+ "anthropic",
19060
+ "google",
19061
+ "managed-local"
18529
19062
  ]);
18530
- var BrokerInfoSchema = object({
19063
+ var LlmProfileSchema = object({
18531
19064
  id: string(),
18532
19065
  name: string(),
18533
- url: string(),
18534
- kind: BrokerKindSchema,
18535
- status: BrokerStatusSchema$1,
18536
- latencyMs: number().nullable(),
18537
- error: string().optional(),
18538
- /** Embedded brokers only: number of MQTT clients currently connected. */
18539
- connectedClients: number().int().nonnegative().optional(),
18540
- /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
18541
- lastCheckedAt: number().optional()
19066
+ kind: LlmProfileKindSchema,
19067
+ /** Stamped by the provider — keeps the fanned catalog routable. */
19068
+ addonId: string(),
19069
+ enabled: boolean(),
19070
+ /** Vendor model id, or the managed runtime's loaded model. */
19071
+ model: string(),
19072
+ /** Required for openai-compatible; override for cloud kinds. */
19073
+ baseUrl: string().optional(),
19074
+ /** ConfigUISchema type:'password' — never round-trips (spec §5). */
19075
+ apiKey: string().optional(),
19076
+ supportsVision: boolean(),
19077
+ temperature: number().min(0).max(2).optional(),
19078
+ maxTokens: number().int().positive().optional(),
19079
+ timeoutMs: number().int().positive().default(6e4),
19080
+ extraHeaders: record(string(), string()).optional(),
19081
+ /** kind === 'managed-local' only (spec §4). */
19082
+ runtime: ManagedRuntimeConfigSchema.optional()
18542
19083
  });
18543
- /**
18544
- * Connection details — what a consumer needs to call
18545
- * `mqtt.connect(url, options)`. We split URL + credentials so the
18546
- * consumer can pass them as `mqtt.connect(url, { username, password })`
18547
- * instead of stuffing creds into the URL (which leaks them into logs).
18548
- */
18549
- var BrokerConnectionDetailsSchema = object({
18550
- url: string(),
18551
- username: string().optional(),
18552
- password: string().optional(),
18553
- /**
18554
- * Suggested prefix for `clientId`. Each consumer should suffix this
18555
- * with its own discriminator (addon id, instance id) so reconnects
18556
- * don't kick each other off (MQTT spec: clientId must be unique per
18557
- * broker).
18558
- */
18559
- clientIdPrefix: string().optional()
19084
+ /** ConfigUISchema tree passed through untyped on the wire (the
19085
+ * notification-output `ConfigSchemaPassthrough` precedent at
19086
+ * notification-output.cap.ts:151); the exported TS type re-tightens it. */
19087
+ var ConfigSchemaPassthrough$1 = unknown();
19088
+ var LlmProfileKindDescriptorSchema = object({
19089
+ kind: LlmProfileKindSchema,
19090
+ label: string(),
19091
+ icon: string(),
19092
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
19093
+ addonId: string(),
19094
+ configSchema: ConfigSchemaPassthrough$1
18560
19095
  });
18561
- var AddBrokerInputSchema = object({
18562
- name: string().min(1),
18563
- url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
18564
- username: string().optional(),
18565
- password: string().optional(),
18566
- clientIdPrefix: string().optional()
19096
+ var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
19097
+ var LlmDefaultSchema = object({
19098
+ selector: LlmDefaultSelectorSchema,
19099
+ profileId: string()
18567
19100
  });
18568
- var AddBrokerResultSchema = object({ id: string() });
18569
- var IdInputSchema = object({ id: string() });
18570
- var TestResultSchema$1 = discriminatedUnion("ok", [object({
18571
- ok: literal(true),
18572
- latencyMs: number()
18573
- }), object({
18574
- ok: literal(false),
18575
- error: string()
18576
- })]);
18577
- var StartEmbeddedInputSchema = object({
18578
- port: number().int().min(1).max(65535).default(1883),
18579
- /** Allow anonymous connect (no username/password). Default: false. */
18580
- allowAnonymous: boolean().default(false),
18581
- /** Optional shared username/password for clients. */
18582
- username: string().optional(),
18583
- password: string().optional()
19101
+ /** Server-side rollup row getUsage never dumps raw call rows (spec §6). */
19102
+ var LlmUsageRollupSchema = object({
19103
+ day: string(),
19104
+ consumer: string(),
19105
+ profileId: string(),
19106
+ calls: number(),
19107
+ okCalls: number(),
19108
+ errorCalls: number(),
19109
+ inputTokens: number(),
19110
+ outputTokens: number(),
19111
+ avgLatencyMs: number()
18584
19112
  });
18585
- var StartEmbeddedResultSchema = object({
19113
+ /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
19114
+ var ManagedModelCatalogEntrySchema = object({
18586
19115
  id: string(),
18587
- url: string()
18588
- });
18589
- var StatusSchema = object({
18590
- brokerCount: number(),
18591
- embeddedRunning: boolean()
18592
- });
18593
- 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);
18594
- var NetworkEndpointSchema = object({
19116
+ label: string(),
19117
+ family: string(),
19118
+ purpose: _enum(["text", "vision"]),
18595
19119
  url: string(),
18596
- hostname: string(),
18597
- port: number(),
18598
- protocol: _enum(["http", "https"])
19120
+ sha256: string(),
19121
+ sizeBytes: number(),
19122
+ quantization: string(),
19123
+ /** Load-time guidance shown in the picker. */
19124
+ minRamBytes: number(),
19125
+ contextSizeDefault: number().int(),
19126
+ /** Vision models: companion projector file. */
19127
+ mmprojUrl: string().optional()
18599
19128
  });
18600
- var NetworkAccessStatusSchema = object({
18601
- connected: boolean(),
18602
- endpoint: NetworkEndpointSchema.nullable(),
19129
+ var LlmRuntimeNodeSchema = object({
19130
+ nodeId: string(),
19131
+ reachable: boolean(),
19132
+ status: LlmRuntimeStatusSchema.optional(),
19133
+ disk: LlmRuntimeDiskUsageSchema.optional(),
18603
19134
  error: string().optional()
18604
19135
  });
18605
- /**
18606
- * Optional, richer endpoint shape returned by providers that expose
18607
- * MORE than one ingress concurrently (Tailscale Ingress with mixed
18608
- * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
18609
- * the originating provider config (mode + sourcePort) so the
18610
- * orchestrator UI can label rows distinctly. Providers that expose only
18611
- * one endpoint just omit `listEndpoints` from their provider impl.
18612
- */
18613
- var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
18614
- /**
18615
- * Stable id within the provider — typically `<mode>-<sourcePort>` so
18616
- * the orchestrator can dedupe across `listEndpoints` polls.
18617
- */
18618
- id: string(),
18619
- /** Operator-facing label (mirrors `MeshEndpoint.label`). */
18620
- label: string(),
18621
- /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
18622
- mode: string().optional(),
18623
- /** Originating local port the ingress fronts (informational). */
18624
- sourcePort: number().optional()
19136
+ var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
19137
+ var ProfileRefInputSchema = object({
19138
+ addonId: string(),
19139
+ profileId: string()
18625
19140
  });
18626
- method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
18627
- /**
18628
- * notification-output — canonical, capability-gated notification delivery.
18629
- *
18630
- * Apprise-derived model (see
18631
- * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
18632
- * callers emit ONE canonical `Notification`; each provider declares a
18633
- * per-kind capability descriptor (`TargetKind`), and the pure degrade
18634
- * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
18635
- * message to what the kind supports — callers never special-case a service.
18636
- *
18637
- * DESIGN DECISIONS (locked):
18638
- * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
18639
- * `setTargetEnabled`), each provider persisting via the `settings-store`
18640
- * cap. Rationale: the admin UI needs one uniform surface across the
18641
- * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
18642
- * alternative would fork the UI per addon and cannot host the
18643
- * discovery→adopt flow.
18644
- * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
18645
- * the generated cap-mount auto-`concatCollection`-fans them across every
18646
- * registered provider (notifiers addon + HA addon) so one catalog is
18647
- * routable. `send` / `testTarget` / CRUD route to ONE provider by the
18648
- * `addonId` the generated collection router extracts from the call input.
18649
- * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
18650
- * transformer) + UDS MsgPack both round-trip typed arrays — already used by
18651
- * `storage` / `storage-provider` / `recording` caps over the same path. No
18652
- * base64 fallback needed.
18653
- *
18654
- * TODO (deferred, closed-set change — separate decision): add
18655
- * `providerKind: 'notify'` so notification providers surface on the unified
18656
- * admin "Integrations" page.
18657
- */
18658
- /**
18659
- * Zentik-derived typed-media enum — the superset across every kind. Each
18660
- * adapter picks what it supports and the degrade engine filters the rest.
18661
- */
18662
- var AttachmentMediaTypeSchema = _enum([
18663
- "image",
18664
- "video",
18665
- "gif",
18666
- "audio",
18667
- "icon"
19141
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
19142
+ kind: "mutation",
19143
+ auth: "admin"
19144
+ }), method(ProfileRefInputSchema, _void(), {
19145
+ kind: "mutation",
19146
+ auth: "admin"
19147
+ }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
19148
+ kind: "mutation",
19149
+ auth: "admin"
19150
+ }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
19151
+ selector: LlmDefaultSelectorSchema,
19152
+ profileId: string().nullable()
19153
+ }), _void(), {
19154
+ kind: "mutation",
19155
+ auth: "admin"
19156
+ }), method(object({
19157
+ since: number().optional(),
19158
+ until: number().optional(),
19159
+ consumer: string().optional(),
19160
+ profileId: string().optional()
19161
+ }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
19162
+ nodeId: string(),
19163
+ model: ManagedModelRefSchema
19164
+ }), _void(), {
19165
+ kind: "mutation",
19166
+ auth: "admin"
19167
+ }), method(object({
19168
+ nodeId: string(),
19169
+ file: string()
19170
+ }), _void(), {
19171
+ kind: "mutation",
19172
+ auth: "admin"
19173
+ }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
19174
+ kind: "mutation",
19175
+ auth: "admin"
19176
+ }), method(ProfileRefInputSchema, _void(), {
19177
+ kind: "mutation",
19178
+ auth: "admin"
19179
+ });
19180
+ var LogLevelSchema = _enum([
19181
+ "debug",
19182
+ "info",
19183
+ "warn",
19184
+ "error"
18668
19185
  ]);
19186
+ var LogEntrySchema = object({
19187
+ timestamp: date(),
19188
+ level: LogLevelSchema,
19189
+ scope: array(string()),
19190
+ message: string(),
19191
+ meta: record(string(), unknown()).optional(),
19192
+ tags: record(string(), string()).optional()
19193
+ });
19194
+ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
19195
+ scope: array(string()).optional(),
19196
+ level: LogLevelSchema.optional(),
19197
+ since: date().optional(),
19198
+ until: date().optional(),
19199
+ limit: number().optional(),
19200
+ tags: record(string(), string()).optional()
19201
+ }), array(LogEntrySchema).readonly());
18669
19202
  /**
18670
- * A single attachment. Exactly one of `url` (remote source, most adapters
18671
- * prefer this) or `bytes` (inline source; required for Pushover-style
18672
- * bytes-only kinds) MUST be present — the degrade engine expresses a
18673
- * url→bytes fetch as a `needsFetch` directive the adapter executes.
19203
+ * `login-method` collection cap through which auth addons contribute
19204
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
19205
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
19206
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
19207
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
19208
+ * procedure aggregates them for the unauthenticated login page.
19209
+ *
19210
+ * A contribution is a discriminated union on `kind`:
19211
+ *
19212
+ * - `redirect` — a declarative button. The login page renders a generic
19213
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
19214
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
19215
+ * ZERO shell-side JS. A future SSO addon plugs in the same way — the
19216
+ * login page needs NO change.
19217
+ *
19218
+ * - `widget` — a Module-Federation widget the login page mounts (via
19219
+ * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
19220
+ * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
19221
+ * mechanism kept for future use; no shipped addon uses it on the login
19222
+ * page (the passkey ceremony below runs natively in the shell instead).
19223
+ *
19224
+ * - `passkey` — a declarative WebAuthn ceremony the shell renders
19225
+ * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
19226
+ * a remotely-loaded bundle). Carries the addon's effective `rpId` /
19227
+ * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
19228
+ * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
19229
+ * fetching any remote code pre-auth. Contribution stays unconditional —
19230
+ * enrollment state is never leaked pre-auth; visibility is a shell
19231
+ * decision.
19232
+ *
19233
+ * Every contribution carries a `stage`:
19234
+ * - `primary` — shown on the first credentials screen (OIDC /
19235
+ * magic-link buttons; a future usernameless passkey).
19236
+ * - `second-factor` — shown AFTER the password leg, gated on the
19237
+ * returned `factors` (passkey-as-2FA today).
19238
+ *
19239
+ * `mount: skip` — the cap is read server-side by the core auth router
19240
+ * (`registry.getCollection('login-method')`), never mounted as its own
19241
+ * tRPC router.
18674
19242
  */
18675
- var AttachmentSchema = object({
18676
- mediaType: AttachmentMediaTypeSchema,
18677
- url: string().optional(),
18678
- bytes: _instanceof(Uint8Array).optional(),
18679
- mime: string().optional(),
18680
- name: string().optional()
18681
- }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
18682
- var NotificationFormatSchema = _enum([
18683
- "text",
18684
- "markdown",
18685
- "html"
19243
+ /** When a login method renders in the two-phase login flow. */
19244
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
19245
+ /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
19246
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [
19247
+ object({
19248
+ kind: literal("redirect"),
19249
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
19250
+ id: string(),
19251
+ /** Operator-facing button label. */
19252
+ label: string(),
19253
+ /** lucide-react icon name. */
19254
+ icon: string().optional(),
19255
+ /** Addon-owned HTTP route the button navigates to (GET). */
19256
+ startUrl: string(),
19257
+ stage: LoginStageEnum
19258
+ }),
19259
+ object({
19260
+ kind: literal("widget"),
19261
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
19262
+ id: string(),
19263
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
19264
+ addonId: string(),
19265
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
19266
+ bundle: string(),
19267
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
19268
+ remote: WidgetRemoteSchema,
19269
+ stage: LoginStageEnum
19270
+ }),
19271
+ object({
19272
+ kind: literal("passkey"),
19273
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
19274
+ id: string(),
19275
+ /** Operator-facing button label. */
19276
+ label: string(),
19277
+ stage: LoginStageEnum,
19278
+ /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
19279
+ rpId: string(),
19280
+ /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
19281
+ origin: string().nullable()
19282
+ })
18686
19283
  ]);
18687
- /** A single tap-through action button. */
18688
- var NotificationActionSchema = object({
18689
- id: string(),
18690
- label: string(),
18691
- url: string().optional()
19284
+ method(_void(), array(LoginMethodContributionSchema).readonly());
19285
+ var CpuBreakdownSchema = object({
19286
+ total: number(),
19287
+ user: number(),
19288
+ system: number(),
19289
+ irq: number(),
19290
+ nice: number(),
19291
+ loadAvg: tuple([
19292
+ number(),
19293
+ number(),
19294
+ number()
19295
+ ]),
19296
+ cores: number()
18692
19297
  });
18693
- /**
18694
- * The canonical notification. `body` is the only hard field (Apprise model).
18695
- * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
18696
- * NOT a fixed severity enum — each kind declares its own `caps.levels` and
18697
- * the adapter maps this ordinal onto its native level. `level?` is an
18698
- * optional kind-native level id (`emergency`, `silent`, …) that overrides
18699
- * `priority` for that one target.
18700
- */
18701
- var NotificationSchema = object({
18702
- body: string(),
18703
- title: string().optional(),
18704
- format: NotificationFormatSchema.default("text"),
18705
- priority: number().int().min(1).max(5).default(3),
18706
- level: string().optional(),
18707
- attachments: array(AttachmentSchema).optional(),
18708
- clickUrl: string().optional(),
18709
- actions: array(NotificationActionSchema).optional(),
18710
- sound: string().optional(),
18711
- ttl: number().optional(),
18712
- tag: string().optional(),
18713
- deviceId: number().optional(),
18714
- eventId: string().optional(),
18715
- metadata: record(string(), unknown()).optional()
19298
+ var MemoryInfoSchema = object({
19299
+ percent: number(),
19300
+ totalBytes: number(),
19301
+ usedBytes: number(),
19302
+ availableBytes: number(),
19303
+ swapUsedBytes: number(),
19304
+ swapTotalBytes: number()
19305
+ });
19306
+ var DiskIoSnapshotSchema = object({
19307
+ readBytes: number(),
19308
+ writeBytes: number(),
19309
+ readOps: number(),
19310
+ writeOps: number(),
19311
+ timestampMs: number()
19312
+ });
19313
+ var NetworkIoSnapshotSchema = object({
19314
+ rxBytes: number(),
19315
+ txBytes: number(),
19316
+ rxPackets: number(),
19317
+ txPackets: number(),
19318
+ rxErrors: number(),
19319
+ txErrors: number(),
19320
+ timestampMs: number()
19321
+ });
19322
+ var MetricsGpuInfoSchema = object({
19323
+ utilization: number(),
19324
+ model: string(),
19325
+ memoryUsedBytes: number(),
19326
+ memoryTotalBytes: number(),
19327
+ temperature: number().nullable()
19328
+ });
19329
+ var ProcessResourceInfoSchema = object({
19330
+ openFds: number(),
19331
+ threadCount: number(),
19332
+ activeHandles: number(),
19333
+ activeRequests: number()
18716
19334
  });
18717
- /** One declared native severity/priority level for a kind. */
18718
- var TargetKindLevelSchema = object({
18719
- id: string(),
18720
- label: string(),
18721
- /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
18722
- ordinal: number().int().min(1).max(5).nullable(),
18723
- flags: object({
18724
- critical: boolean().optional(),
18725
- silent: boolean().optional(),
18726
- noPush: boolean().optional()
18727
- }).optional(),
18728
- /** e.g. Pushover `emergency` requires `retry` / `expire`. */
18729
- requires: array(string()).optional(),
18730
- description: string().optional()
19335
+ var PressureAvgsSchema = object({
19336
+ avg10: number(),
19337
+ avg60: number(),
19338
+ avg300: number()
18731
19339
  });
18732
- /** The full capability block consulted before dispatch. */
18733
- var TargetKindCapsSchema = object({
18734
- attachments: object({
18735
- mediaTypes: array(AttachmentMediaTypeSchema),
18736
- mode: _enum([
18737
- "url",
18738
- "bytes",
18739
- "both"
18740
- ]),
18741
- max: number().int().nonnegative(),
18742
- maxBytes: number().int().positive().optional()
19340
+ var PressureInfoSchema = object({
19341
+ some: PressureAvgsSchema,
19342
+ full: PressureAvgsSchema.nullable()
19343
+ });
19344
+ var SystemResourceSnapshotSchema = object({
19345
+ cpu: CpuBreakdownSchema,
19346
+ memory: MemoryInfoSchema,
19347
+ gpu: MetricsGpuInfoSchema.nullable(),
19348
+ network: NetworkIoSnapshotSchema,
19349
+ disk: DiskIoSnapshotSchema,
19350
+ pressure: object({
19351
+ cpu: PressureInfoSchema.nullable(),
19352
+ memory: PressureInfoSchema.nullable(),
19353
+ io: PressureInfoSchema.nullable()
18743
19354
  }),
18744
- /** Max action buttons (0 = none). */
18745
- actions: number().int().nonnegative(),
18746
- levels: array(TargetKindLevelSchema),
18747
- format: array(NotificationFormatSchema),
18748
- clickUrl: boolean(),
18749
- sound: boolean(),
18750
- ttl: boolean(),
18751
- bodyMaxLen: number().int().positive()
19355
+ process: ProcessResourceInfoSchema,
19356
+ cpuTemperature: number().nullable(),
19357
+ timestampMs: number()
18752
19358
  });
18753
- /**
18754
- * `configSchema` is a `ConfigUISchema` tree passed through to the admin
18755
- * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
18756
- * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`)
18757
- * the union is large and not meant for runtime validation here; the exported
18758
- * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
18759
- */
18760
- var ConfigSchemaPassthrough$1 = unknown();
18761
- var TargetKindSchema = object({
18762
- kind: string(),
18763
- label: string(),
18764
- icon: string(),
18765
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
18766
- addonId: string(),
18767
- configSchema: ConfigSchemaPassthrough$1,
18768
- supportsDiscovery: boolean(),
18769
- caps: TargetKindCapsSchema
19359
+ var DiskSpaceInfoSchema = object({
19360
+ path: string(),
19361
+ totalBytes: number(),
19362
+ usedBytes: number(),
19363
+ availableBytes: number(),
19364
+ percent: number()
18770
19365
  });
18771
- /**
18772
- * A persisted target. `config` holds secrets; providers REDACT secret fields
18773
- * (return a presence marker only) when serving `listTargets` — never
18774
- * round-trip a stored secret to the UI.
18775
- */
18776
- var TargetSchema = object({
18777
- id: string(),
18778
- name: string(),
18779
- kind: string(),
19366
+ var PidResourceStatsSchema = object({
19367
+ pid: number(),
19368
+ cpu: number(),
19369
+ memory: number(),
19370
+ /**
19371
+ * Private (anonymous) resident bytes — the per-process V8 heap + native
19372
+ * allocations NOT shared with other processes (Linux RssAnon). This is the
19373
+ * "real" per-runner cost; summing it across runners is meaningful, unlike
19374
+ * `memory` (RSS), which double-counts the shared mmap'd framework code.
19375
+ * Undefined where /proc is unavailable (e.g. macOS).
19376
+ */
19377
+ privateBytes: number().optional(),
19378
+ /**
19379
+ * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
19380
+ * code shared copy-on-write across runners. Undefined on macOS.
19381
+ */
19382
+ sharedBytes: number().optional()
19383
+ });
19384
+ var AddonInstanceSchema = object({
18780
19385
  addonId: string(),
18781
- enabled: boolean(),
18782
- config: record(string(), unknown())
19386
+ nodeId: string(),
19387
+ role: _enum(["hub", "worker"]),
19388
+ pid: number(),
19389
+ state: _enum([
19390
+ "starting",
19391
+ "running",
19392
+ "stopping",
19393
+ "stopped",
19394
+ "crashed"
19395
+ ]),
19396
+ uptimeSec: number()
18783
19397
  });
18784
- /** A discovery-surfaced candidate (config is partial + non-secret). */
18785
- var DiscoveredTargetSchema = object({
18786
- kind: string(),
18787
- suggestedName: string(),
18788
- config: record(string(), unknown())
19398
+ var NodeProcessSchema = object({
19399
+ pid: number(),
19400
+ ppid: number(),
19401
+ pgid: number(),
19402
+ classification: _enum([
19403
+ "root",
19404
+ "managed",
19405
+ "system",
19406
+ "ghost"
19407
+ ]),
19408
+ /** `$process` addon binding when `managed`, else null. */
19409
+ addonId: string().nullable(),
19410
+ /** Kernel-reported nodeId when the process is a known agent/worker. */
19411
+ nodeId: string().nullable(),
19412
+ /** Truncated command line. */
19413
+ command: string(),
19414
+ cpuPercent: number(),
19415
+ memoryRssBytes: number(),
19416
+ /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
19417
+ uptimeSec: number(),
19418
+ /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
19419
+ orphaned: boolean()
18789
19420
  });
18790
- /** The degrade engine's report — what was resolved / dropped / degraded. */
18791
- var RenderedAsSchema = object({
18792
- level: string(),
18793
- format: NotificationFormatSchema,
18794
- attachmentsSent: number().int().nonnegative(),
18795
- actionsSent: number().int().nonnegative(),
18796
- truncated: boolean(),
18797
- dropped: array(string())
19421
+ var KillProcessInputSchema = object({
19422
+ pid: number(),
19423
+ /** Force = SIGKILL. Default is SIGTERM. */
19424
+ force: boolean().optional()
18798
19425
  });
18799
- var SendResultSchema = object({
19426
+ var KillProcessResultSchema = object({
19427
+ success: boolean(),
19428
+ reason: string().optional(),
19429
+ signal: _enum(["SIGTERM", "SIGKILL"]).optional()
19430
+ });
19431
+ var DumpHeapSnapshotInputSchema = object({
19432
+ /** The addon whose runner should dump a heap snapshot. */
19433
+ addonId: string() });
19434
+ var DumpHeapSnapshotResultSchema = object({
18800
19435
  success: boolean(),
19436
+ /** Path of the written .heapsnapshot inside the runner's container/host. */
19437
+ path: string().optional(),
19438
+ /** Process pid that was signalled. */
19439
+ pid: number().optional(),
19440
+ reason: string().optional()
19441
+ });
19442
+ var SystemMetricsSchema = object({
19443
+ cpuPercent: number(),
19444
+ memoryPercent: number(),
19445
+ memoryUsedMB: number(),
19446
+ memoryTotalMB: number(),
19447
+ diskPercent: number().optional(),
19448
+ temperature: number().optional(),
19449
+ gpuPercent: number().optional(),
19450
+ gpuMemoryPercent: number().optional()
19451
+ });
19452
+ 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, {
19453
+ kind: "mutation",
19454
+ auth: "admin"
19455
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
19456
+ kind: "mutation",
19457
+ auth: "admin"
19458
+ });
19459
+ method(object({
19460
+ sourceUrl: string(),
19461
+ metadata: ModelConvertMetadataSchema,
19462
+ targets: array(ConvertTargetSchema).min(1).readonly(),
19463
+ calibrationRef: string().optional(),
19464
+ sessionId: string().optional()
19465
+ }), ConvertResultSchema, {
19466
+ kind: "mutation",
19467
+ auth: "admin",
19468
+ timeoutMs: 6e5
19469
+ });
19470
+ method(object({
19471
+ nodeId: string(),
19472
+ modelId: string(),
19473
+ format: _enum(MODEL_FORMATS),
19474
+ entry: ModelCatalogEntrySchema
19475
+ }), object({
19476
+ ok: boolean(),
19477
+ /** sha256 of the staged tarball (empty for a hub-local no-op). */
19478
+ sha256: string(),
19479
+ bytes: number(),
19480
+ /** The target node's modelsDir the artifact landed in. */
19481
+ path: string()
19482
+ }), {
19483
+ kind: "mutation",
19484
+ auth: "admin"
19485
+ });
19486
+ /**
19487
+ * `mqtt-broker` — broker-registry cap.
19488
+ *
19489
+ * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
19490
+ * MQTT brokers (external + optionally an embedded `aedes`-backed one)
19491
+ * and (b) the connection details a consumer addon needs to spin up
19492
+ * its OWN `mqtt.js` client.
19493
+ *
19494
+ * Why: pub/sub routing over the system event-bus loses fidelity
19495
+ * (callback shape, QoS guarantees, will/retain semantics) and adds
19496
+ * refcount bookkeeping that addons would rather own themselves. The
19497
+ * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
19498
+ * features anyway — give it the connection config, get out of the way.
19499
+ *
19500
+ * Consumer flow:
19501
+ * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
19502
+ * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
19503
+ * client.subscribe('zigbee2mqtt/+')
19504
+ *
19505
+ * Collection mode: multiple brokers (e.g. one local mosquitto + one
19506
+ * cloud bridge). The "embedded" entry (when present) is just another
19507
+ * broker in the registry — its lifecycle is owned by the addon that
19508
+ * spawned it.
19509
+ */
19510
+ var BrokerKindSchema = _enum(["external", "embedded"]);
19511
+ /**
19512
+ * Broker live-probe status.
19513
+ *
19514
+ * - `connected` — last probe completed a clean CONNACK
19515
+ * - `disconnected` — no probe has run yet (cold cache)
19516
+ * - `auth-failed` — CONNACK refused with auth error (RC 4 / 5)
19517
+ * - `unreachable` — TCP connect timed out / refused
19518
+ * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
19519
+ */
19520
+ var BrokerStatusSchema$1 = _enum([
19521
+ "connected",
19522
+ "disconnected",
19523
+ "auth-failed",
19524
+ "unreachable",
19525
+ "tls-error"
19526
+ ]);
19527
+ var BrokerInfoSchema = object({
19528
+ id: string(),
19529
+ name: string(),
19530
+ url: string(),
19531
+ kind: BrokerKindSchema,
19532
+ status: BrokerStatusSchema$1,
19533
+ latencyMs: number().nullable(),
18801
19534
  error: string().optional(),
18802
- renderedAs: RenderedAsSchema.optional()
19535
+ /** Embedded brokers only: number of MQTT clients currently connected. */
19536
+ connectedClients: number().int().nonnegative().optional(),
19537
+ /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
19538
+ lastCheckedAt: number().optional()
18803
19539
  });
18804
- /** Same shape as SendResult — kept as a distinct name for the test panel. */
18805
- var TestResultSchema = SendResultSchema;
18806
- method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
18807
- kind: string(),
18808
- config: record(string(), unknown()).optional()
18809
- }), array(DiscoveredTargetSchema)), method(object({
18810
- targetId: string(),
18811
- notification: NotificationSchema
18812
- }), SendResultSchema, { kind: "mutation" }), method(object({
18813
- targetId: string(),
18814
- sample: NotificationSchema.optional()
18815
- }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
18816
- targetId: string(),
18817
- enabled: boolean()
18818
- }), _void(), { kind: "mutation" });
18819
19540
  /**
18820
- * Shared LLM generate contracts imported by BOTH `llm.cap.ts` (consumer
18821
- * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
18822
- * caps stay wire-compatible without a circular cap→cap import.
18823
- *
18824
- * Errors are a discriminated-union RESULT, never thrown: the shape survives
18825
- * every transport tier structurally, and failed calls still write usage rows.
18826
- * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
19541
+ * Connection details what a consumer needs to call
19542
+ * `mqtt.connect(url, options)`. We split URL + credentials so the
19543
+ * consumer can pass them as `mqtt.connect(url, { username, password })`
19544
+ * instead of stuffing creds into the URL (which leaks them into logs).
18827
19545
  */
18828
- var LlmUsageSchema = object({
18829
- inputTokens: number(),
18830
- outputTokens: number()
19546
+ var BrokerConnectionDetailsSchema = object({
19547
+ url: string(),
19548
+ username: string().optional(),
19549
+ password: string().optional(),
19550
+ /**
19551
+ * Suggested prefix for `clientId`. Each consumer should suffix this
19552
+ * with its own discriminator (addon id, instance id) so reconnects
19553
+ * don't kick each other off (MQTT spec: clientId must be unique per
19554
+ * broker).
19555
+ */
19556
+ clientIdPrefix: string().optional()
18831
19557
  });
18832
- var LlmErrorCodeSchema = _enum([
18833
- "timeout",
18834
- "rate-limited",
18835
- "auth",
18836
- "refusal",
18837
- "bad-request",
18838
- "unavailable",
18839
- "no-profile",
18840
- "budget-exceeded",
18841
- "adapter-error"
18842
- ]);
18843
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
19558
+ var AddBrokerInputSchema = object({
19559
+ name: string().min(1),
19560
+ url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
19561
+ username: string().optional(),
19562
+ password: string().optional(),
19563
+ clientIdPrefix: string().optional()
19564
+ });
19565
+ var AddBrokerResultSchema = object({ id: string() });
19566
+ var IdInputSchema = object({ id: string() });
19567
+ var TestResultSchema$1 = discriminatedUnion("ok", [object({
18844
19568
  ok: literal(true),
18845
- text: string(),
18846
- model: string(),
18847
- usage: LlmUsageSchema,
18848
- truncated: boolean(),
18849
19569
  latencyMs: number()
18850
19570
  }), object({
18851
19571
  ok: literal(false),
18852
- code: LlmErrorCodeSchema,
18853
- message: string(),
18854
- retryAfterMs: number().optional()
19572
+ error: string()
18855
19573
  })]);
18856
- /**
18857
- * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
18858
- * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
18859
- * notification-output.cap.ts:27-31 precedents).
18860
- */
18861
- var LlmImageSchema = object({
18862
- bytes: _instanceof(Uint8Array),
18863
- mimeType: string()
19574
+ var StartEmbeddedInputSchema = object({
19575
+ port: number().int().min(1).max(65535).default(1883),
19576
+ /** Allow anonymous connect (no username/password). Default: false. */
19577
+ allowAnonymous: boolean().default(false),
19578
+ /** Optional shared username/password for clients. */
19579
+ username: string().optional(),
19580
+ password: string().optional()
18864
19581
  });
18865
- var LlmGenerateBaseInputSchema = object({
18866
- /** Collection routing (the notification-output posture). */
18867
- addonId: string().optional(),
18868
- /** Explicit profile; else the resolution chain (spec §3). */
18869
- profileId: string().optional(),
18870
- /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
18871
- consumer: string(),
18872
- system: string().optional(),
18873
- /** v1: single-turn. `messages[]` is a v2 additive field. */
18874
- prompt: string(),
18875
- /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
18876
- jsonSchema: record(string(), unknown()).optional(),
18877
- /** Per-call override of the profile default. */
18878
- maxTokens: number().int().positive().optional(),
18879
- temperature: number().optional()
19582
+ var StartEmbeddedResultSchema = object({
19583
+ id: string(),
19584
+ url: string()
18880
19585
  });
18881
- /**
18882
- * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
18883
- * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
18884
- * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
18885
- * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
18886
- * this only through the `llm` cap's methods.
18887
- *
18888
- * One running llama-server child per node in v1 (models are RAM-heavy).
18889
- * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
18890
- * watchdog — operator decision #3).
18891
- */
18892
- var ManagedModelRefSchema = discriminatedUnion("kind", [
18893
- object({
18894
- kind: literal("catalog"),
18895
- catalogId: string()
18896
- }),
18897
- object({
18898
- kind: literal("url"),
18899
- url: string(),
18900
- sha256: string().optional()
18901
- }),
18902
- object({
18903
- kind: literal("path"),
18904
- path: string()
18905
- })
18906
- ]);
18907
- var ManagedRuntimeConfigSchema = object({
18908
- /** WHERE the runtime lives — hub or any agent. */
18909
- nodeId: string(),
18910
- /** Closed for v1; 'ollama' is a v2 candidate. */
18911
- engine: _enum(["llama-cpp"]),
18912
- model: ManagedModelRefSchema,
18913
- contextSize: number().int().default(4096),
18914
- /** 0 = CPU-only. */
18915
- gpuLayers: number().int().default(0),
18916
- /** Default: cpus-2, clamped ≥1 (resolved node-side). */
18917
- threads: number().int().optional(),
18918
- /** Concurrent slots. */
18919
- parallel: number().int().default(1),
18920
- /** Else lazy: first generate boots it. */
18921
- autoStart: boolean().default(false),
18922
- /** 0 = never; frees RAM after quiet periods. */
18923
- idleStopMinutes: number().int().default(30)
19586
+ var StatusSchema = object({
19587
+ brokerCount: number(),
19588
+ embeddedRunning: boolean()
18924
19589
  });
18925
- var LlmRuntimeStatusSchema = object({
18926
- /** Status is ALWAYS node-qualified. */
18927
- nodeId: string(),
18928
- state: _enum([
18929
- "stopped",
18930
- "downloading",
18931
- "starting",
18932
- "ready",
18933
- "crashed",
18934
- "failed"
18935
- ]),
18936
- pid: number().optional(),
18937
- port: number().optional(),
18938
- modelPath: string().optional(),
18939
- modelId: string().optional(),
18940
- downloadProgress: number().min(0).max(1).optional(),
18941
- lastError: string().optional(),
18942
- crashesInWindow: number(),
18943
- /** Child RSS (sampled best-effort). */
18944
- memoryBytes: number().optional(),
18945
- vramBytes: number().optional()
19590
+ 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);
19591
+ var NetworkEndpointSchema = object({
19592
+ url: string(),
19593
+ hostname: string(),
19594
+ port: number(),
19595
+ protocol: _enum(["http", "https"])
18946
19596
  });
18947
- var LlmNodeModelSchema = object({
18948
- file: string(),
18949
- sizeBytes: number(),
18950
- catalogId: string().optional(),
18951
- installedAt: number().optional()
19597
+ var NetworkAccessStatusSchema = object({
19598
+ connected: boolean(),
19599
+ endpoint: NetworkEndpointSchema.nullable(),
19600
+ error: string().optional()
18952
19601
  });
18953
- var LlmRuntimeDiskUsageSchema = object({
18954
- nodeId: string(),
18955
- modelsBytes: number(),
18956
- freeBytes: number().optional()
19602
+ /**
19603
+ * Optional, richer endpoint shape returned by providers that expose
19604
+ * MORE than one ingress concurrently (Tailscale Ingress with mixed
19605
+ * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
19606
+ * the originating provider config (mode + sourcePort) so the
19607
+ * orchestrator UI can label rows distinctly. Providers that expose only
19608
+ * one endpoint just omit `listEndpoints` from their provider impl.
19609
+ */
19610
+ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
19611
+ /**
19612
+ * Stable id within the provider — typically `<mode>-<sourcePort>` so
19613
+ * the orchestrator can dedupe across `listEndpoints` polls.
19614
+ */
19615
+ id: string(),
19616
+ /** Operator-facing label (mirrors `MeshEndpoint.label`). */
19617
+ label: string(),
19618
+ /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
19619
+ mode: string().optional(),
19620
+ /** Originating local port the ingress fronts (informational). */
19621
+ sourcePort: number().optional()
18957
19622
  });
18958
- method(LlmGenerateBaseInputSchema.extend({
18959
- images: array(LlmImageSchema).optional(),
18960
- runtime: ManagedRuntimeConfigSchema,
18961
- /** The managed profile's timeout, threaded by the hub provider. */
18962
- timeoutMs: number().int().positive().optional()
18963
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
18964
- kind: "mutation",
18965
- auth: "admin"
18966
- }), method(object({}), _void(), {
18967
- kind: "mutation",
18968
- auth: "admin"
18969
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
18970
- kind: "mutation",
18971
- auth: "admin"
18972
- }), method(object({ file: string() }), _void(), {
18973
- kind: "mutation",
18974
- auth: "admin"
18975
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
19623
+ method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
18976
19624
  /**
18977
- * `llm`consumer-facing LLM surface (spec §1-§3). Collection-mode: array
18978
- * methods concat-fan across providers; single-row methods route to ONE
18979
- * provider by the `addonId` in the call input (the notification-output
18980
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
18981
- * (hub-placed); the cap stays open for future providers.
19625
+ * notification-outputcanonical, capability-gated notification delivery.
19626
+ *
19627
+ * Apprise-derived model (see
19628
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
19629
+ * callers emit ONE canonical `Notification`; each provider declares a
19630
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
19631
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
19632
+ * message to what the kind supports — callers never special-case a service.
19633
+ *
19634
+ * DESIGN DECISIONS (locked):
19635
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
19636
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
19637
+ * cap. Rationale: the admin UI needs one uniform surface across the
19638
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
19639
+ * alternative would fork the UI per addon and cannot host the
19640
+ * discovery→adopt flow.
19641
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
19642
+ * the generated cap-mount auto-`concatCollection`-fans them across every
19643
+ * registered provider (notifiers addon + HA addon) so one catalog is
19644
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
19645
+ * `addonId` the generated collection router extracts from the call input.
19646
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
19647
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
19648
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
19649
+ * base64 fallback needed.
18982
19650
  *
18983
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
18984
- * `apiKey` is a password field — providers REDACT it on read and merge on
18985
- * write; a stored key NEVER round-trips to a client.
19651
+ * TODO (deferred, closed-set change separate decision): add
19652
+ * `providerKind: 'notify'` so notification providers surface on the unified
19653
+ * admin "Integrations" page.
18986
19654
  */
18987
- var LlmProfileKindSchema = _enum([
18988
- "openai-compatible",
18989
- "openai",
18990
- "anthropic",
18991
- "google",
18992
- "managed-local"
19655
+ /**
19656
+ * Zentik-derived typed-media enum — the superset across every kind. Each
19657
+ * adapter picks what it supports and the degrade engine filters the rest.
19658
+ */
19659
+ var AttachmentMediaTypeSchema = _enum([
19660
+ "image",
19661
+ "video",
19662
+ "gif",
19663
+ "audio",
19664
+ "icon"
18993
19665
  ]);
18994
- var LlmProfileSchema = object({
19666
+ /**
19667
+ * A single attachment. Exactly one of `url` (remote source, most adapters
19668
+ * prefer this) or `bytes` (inline source; required for Pushover-style
19669
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
19670
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
19671
+ */
19672
+ var AttachmentSchema = object({
19673
+ mediaType: AttachmentMediaTypeSchema,
19674
+ url: string().optional(),
19675
+ bytes: _instanceof(Uint8Array).optional(),
19676
+ mime: string().optional(),
19677
+ name: string().optional()
19678
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
19679
+ var NotificationFormatSchema = _enum([
19680
+ "text",
19681
+ "markdown",
19682
+ "html"
19683
+ ]);
19684
+ /** A single tap-through action button. */
19685
+ var NotificationActionSchema = object({
18995
19686
  id: string(),
18996
- name: string(),
18997
- kind: LlmProfileKindSchema,
18998
- /** Stamped by the provider — keeps the fanned catalog routable. */
18999
- addonId: string(),
19000
- enabled: boolean(),
19001
- /** Vendor model id, or the managed runtime's loaded model. */
19002
- model: string(),
19003
- /** Required for openai-compatible; override for cloud kinds. */
19004
- baseUrl: string().optional(),
19005
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
19006
- apiKey: string().optional(),
19007
- supportsVision: boolean(),
19008
- temperature: number().min(0).max(2).optional(),
19009
- maxTokens: number().int().positive().optional(),
19010
- timeoutMs: number().int().positive().default(6e4),
19011
- extraHeaders: record(string(), string()).optional(),
19012
- /** kind === 'managed-local' only (spec §4). */
19013
- runtime: ManagedRuntimeConfigSchema.optional()
19687
+ label: string(),
19688
+ url: string().optional()
19014
19689
  });
19015
- /** ConfigUISchema tree passed through untyped on the wire (the
19016
- * notification-output `ConfigSchemaPassthrough` precedent at
19017
- * notification-output.cap.ts:151); the exported TS type re-tightens it. */
19690
+ /**
19691
+ * The canonical notification. `body` is the only hard field (Apprise model).
19692
+ * `priority` is a 5-level ORDINAL (1=lowest 3=normal(default) 5=urgent),
19693
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
19694
+ * the adapter maps this ordinal onto its native level. `level?` is an
19695
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
19696
+ * `priority` for that one target.
19697
+ */
19698
+ var NotificationSchema = object({
19699
+ body: string(),
19700
+ title: string().optional(),
19701
+ format: NotificationFormatSchema.default("text"),
19702
+ priority: number().int().min(1).max(5).default(3),
19703
+ level: string().optional(),
19704
+ attachments: array(AttachmentSchema).optional(),
19705
+ clickUrl: string().optional(),
19706
+ actions: array(NotificationActionSchema).optional(),
19707
+ sound: string().optional(),
19708
+ ttl: number().optional(),
19709
+ tag: string().optional(),
19710
+ deviceId: number().optional(),
19711
+ eventId: string().optional(),
19712
+ metadata: record(string(), unknown()).optional()
19713
+ });
19714
+ /** One declared native severity/priority level for a kind. */
19715
+ var TargetKindLevelSchema = object({
19716
+ id: string(),
19717
+ label: string(),
19718
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
19719
+ ordinal: number().int().min(1).max(5).nullable(),
19720
+ flags: object({
19721
+ critical: boolean().optional(),
19722
+ silent: boolean().optional(),
19723
+ noPush: boolean().optional()
19724
+ }).optional(),
19725
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
19726
+ requires: array(string()).optional(),
19727
+ description: string().optional()
19728
+ });
19729
+ /** The full capability block consulted before dispatch. */
19730
+ var TargetKindCapsSchema = object({
19731
+ attachments: object({
19732
+ mediaTypes: array(AttachmentMediaTypeSchema),
19733
+ mode: _enum([
19734
+ "url",
19735
+ "bytes",
19736
+ "both"
19737
+ ]),
19738
+ max: number().int().nonnegative(),
19739
+ maxBytes: number().int().positive().optional()
19740
+ }),
19741
+ /** Max action buttons (0 = none). */
19742
+ actions: number().int().nonnegative(),
19743
+ levels: array(TargetKindLevelSchema),
19744
+ format: array(NotificationFormatSchema),
19745
+ clickUrl: boolean(),
19746
+ sound: boolean(),
19747
+ ttl: boolean(),
19748
+ bodyMaxLen: number().int().positive()
19749
+ });
19750
+ /**
19751
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
19752
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
19753
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
19754
+ * the union is large and not meant for runtime validation here; the exported
19755
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
19756
+ */
19018
19757
  var ConfigSchemaPassthrough = unknown();
19019
- var LlmProfileKindDescriptorSchema = object({
19020
- kind: LlmProfileKindSchema,
19758
+ var TargetKindSchema = object({
19759
+ kind: string(),
19021
19760
  label: string(),
19022
19761
  icon: string(),
19023
19762
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
19024
19763
  addonId: string(),
19025
- configSchema: ConfigSchemaPassthrough
19026
- });
19027
- var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
19028
- var LlmDefaultSchema = object({
19029
- selector: LlmDefaultSelectorSchema,
19030
- profileId: string()
19031
- });
19032
- /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
19033
- var LlmUsageRollupSchema = object({
19034
- day: string(),
19035
- consumer: string(),
19036
- profileId: string(),
19037
- calls: number(),
19038
- okCalls: number(),
19039
- errorCalls: number(),
19040
- inputTokens: number(),
19041
- outputTokens: number(),
19042
- avgLatencyMs: number()
19764
+ configSchema: ConfigSchemaPassthrough,
19765
+ supportsDiscovery: boolean(),
19766
+ caps: TargetKindCapsSchema
19043
19767
  });
19044
- /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
19045
- var ManagedModelCatalogEntrySchema = object({
19768
+ /**
19769
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
19770
+ * (return a presence marker only) when serving `listTargets` — never
19771
+ * round-trip a stored secret to the UI.
19772
+ */
19773
+ var TargetSchema = object({
19046
19774
  id: string(),
19047
- label: string(),
19048
- family: string(),
19049
- purpose: _enum(["text", "vision"]),
19050
- url: string(),
19051
- sha256: string(),
19052
- sizeBytes: number(),
19053
- quantization: string(),
19054
- /** Load-time guidance shown in the picker. */
19055
- minRamBytes: number(),
19056
- contextSizeDefault: number().int(),
19057
- /** Vision models: companion projector file. */
19058
- mmprojUrl: string().optional()
19059
- });
19060
- var LlmRuntimeNodeSchema = object({
19061
- nodeId: string(),
19062
- reachable: boolean(),
19063
- status: LlmRuntimeStatusSchema.optional(),
19064
- disk: LlmRuntimeDiskUsageSchema.optional(),
19065
- error: string().optional()
19066
- });
19067
- var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
19068
- var ProfileRefInputSchema = object({
19775
+ name: string(),
19776
+ kind: string(),
19069
19777
  addonId: string(),
19070
- profileId: string()
19778
+ enabled: boolean(),
19779
+ config: record(string(), unknown())
19071
19780
  });
19072
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
19073
- kind: "mutation",
19074
- auth: "admin"
19075
- }), method(ProfileRefInputSchema, _void(), {
19076
- kind: "mutation",
19077
- auth: "admin"
19078
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
19079
- kind: "mutation",
19080
- auth: "admin"
19081
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
19082
- selector: LlmDefaultSelectorSchema,
19083
- profileId: string().nullable()
19084
- }), _void(), {
19085
- kind: "mutation",
19086
- auth: "admin"
19087
- }), method(object({
19088
- since: number().optional(),
19089
- until: number().optional(),
19090
- consumer: string().optional(),
19091
- profileId: string().optional()
19092
- }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
19093
- nodeId: string(),
19094
- model: ManagedModelRefSchema
19095
- }), _void(), {
19096
- kind: "mutation",
19097
- auth: "admin"
19098
- }), method(object({
19099
- nodeId: string(),
19100
- file: string()
19101
- }), _void(), {
19102
- kind: "mutation",
19103
- auth: "admin"
19104
- }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
19105
- kind: "mutation",
19106
- auth: "admin"
19107
- }), method(ProfileRefInputSchema, _void(), {
19108
- kind: "mutation",
19109
- auth: "admin"
19781
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
19782
+ var DiscoveredTargetSchema = object({
19783
+ kind: string(),
19784
+ suggestedName: string(),
19785
+ config: record(string(), unknown())
19786
+ });
19787
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
19788
+ var RenderedAsSchema = object({
19789
+ level: string(),
19790
+ format: NotificationFormatSchema,
19791
+ attachmentsSent: number().int().nonnegative(),
19792
+ actionsSent: number().int().nonnegative(),
19793
+ truncated: boolean(),
19794
+ dropped: array(string())
19795
+ });
19796
+ var SendResultSchema = object({
19797
+ success: boolean(),
19798
+ error: string().optional(),
19799
+ renderedAs: RenderedAsSchema.optional()
19110
19800
  });
19801
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
19802
+ var TestResultSchema = SendResultSchema;
19803
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
19804
+ kind: string(),
19805
+ config: record(string(), unknown()).optional()
19806
+ }), array(DiscoveredTargetSchema)), method(object({
19807
+ targetId: string(),
19808
+ notification: NotificationSchema
19809
+ }), SendResultSchema, { kind: "mutation" }), method(object({
19810
+ targetId: string(),
19811
+ sample: NotificationSchema.optional()
19812
+ }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
19813
+ targetId: string(),
19814
+ enabled: boolean()
19815
+ }), _void(), { kind: "mutation" });
19111
19816
  /**
19112
19817
  * Zod schemas for persisted record types.
19113
19818
  *
@@ -19793,7 +20498,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19793
20498
  }), method(object({
19794
20499
  eventId: string(),
19795
20500
  kind: MediaFileKindEnum.optional()
19796
- }), array(MediaFileSchema).readonly()), method(object({ trackId: string() }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
20501
+ }), array(MediaFileSchema).readonly()), method(object({
20502
+ trackId: string(),
20503
+ kinds: array(MediaFileKindEnum).optional()
20504
+ }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
19797
20505
  deviceId: number(),
19798
20506
  timestamp: number(),
19799
20507
  frameWidth: number(),
@@ -19814,76 +20522,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19814
20522
  eventId: string(),
19815
20523
  timestamp: number()
19816
20524
  });
19817
- /**
19818
- * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
19819
- * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
19820
- * caps into per-camera event-kind descriptors.
19821
- *
19822
- * The descriptor DATA (color / iconId / labelKey / parentKind / category)
19823
- * is NOT duplicated here — every entry is derived from the single
19824
- * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
19825
- * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
19826
- * control cap means adding one line here (and a taxonomy entry); the anti-
19827
- * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
19828
- * eventful cap is missing.
19829
- */
19830
- /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
19831
- var LEGACY_ICON = {
19832
- motion: "motion",
19833
- audio: "audio",
19834
- person: "person",
19835
- vehicle: "vehicle",
19836
- animal: "animal",
19837
- package: "package",
19838
- door: "door",
19839
- pir: "pir",
19840
- smoke: "smoke",
19841
- water: "water",
19842
- button: "button",
19843
- generic: "generic",
19844
- gas: "smoke",
19845
- vibration: "generic",
19846
- tamper: "generic",
19847
- presence: "person",
19848
- lock: "generic",
19849
- siren: "generic",
19850
- switch: "generic",
19851
- doorbell: "button"
19852
- };
19853
- function legacyIcon(iconId) {
19854
- return LEGACY_ICON[iconId] ?? "generic";
19855
- }
19856
- /**
19857
- * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
19858
- * The anti-drift guard cross-checks this against the eventful caps declared
19859
- * in `packages/types/src/capabilities/*.cap.ts`.
19860
- */
19861
- var CAP_TO_KIND = {
19862
- contact: "contact",
19863
- motion: "motion-sensor",
19864
- smoke: "smoke",
19865
- flood: "flood",
19866
- gas: "gas",
19867
- "carbon-monoxide": "carbon-monoxide",
19868
- vibration: "vibration",
19869
- tamper: "tamper",
19870
- presence: "presence",
19871
- "enum-sensor": "enum-sensor",
19872
- "event-emitter": "device-event",
19873
- "lock-control": "lock",
19874
- switch: "switch",
19875
- button: "button",
19876
- doorbell: "doorbell"
19877
- };
19878
- function buildDescriptor(capName, kind) {
19879
- const t = EVENT_TAXONOMY[kind];
19880
- if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
19881
- return {
19882
- ...t,
19883
- icon: legacyIcon(t.iconId)
19884
- };
19885
- }
19886
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
19887
20525
  var CameraPipelineConfigSchema = object({
19888
20526
  engine: PipelineEngineChoiceSchema.optional(),
19889
20527
  steps: array(PipelineStepInputSchema).readonly(),
@@ -20369,6 +21007,76 @@ method(object({
20369
21007
  auth: "admin"
20370
21008
  });
20371
21009
  /**
21010
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
21011
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
21012
+ * caps into per-camera event-kind descriptors.
21013
+ *
21014
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
21015
+ * is NOT duplicated here — every entry is derived from the single
21016
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
21017
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
21018
+ * control cap means adding one line here (and a taxonomy entry); the anti-
21019
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
21020
+ * eventful cap is missing.
21021
+ */
21022
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
21023
+ var LEGACY_ICON = {
21024
+ motion: "motion",
21025
+ audio: "audio",
21026
+ person: "person",
21027
+ vehicle: "vehicle",
21028
+ animal: "animal",
21029
+ package: "package",
21030
+ door: "door",
21031
+ pir: "pir",
21032
+ smoke: "smoke",
21033
+ water: "water",
21034
+ button: "button",
21035
+ generic: "generic",
21036
+ gas: "smoke",
21037
+ vibration: "generic",
21038
+ tamper: "generic",
21039
+ presence: "person",
21040
+ lock: "generic",
21041
+ siren: "generic",
21042
+ switch: "generic",
21043
+ doorbell: "button"
21044
+ };
21045
+ function legacyIcon(iconId) {
21046
+ return LEGACY_ICON[iconId] ?? "generic";
21047
+ }
21048
+ /**
21049
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
21050
+ * The anti-drift guard cross-checks this against the eventful caps declared
21051
+ * in `packages/types/src/capabilities/*.cap.ts`.
21052
+ */
21053
+ var CAP_TO_KIND = {
21054
+ contact: "contact",
21055
+ motion: "motion-sensor",
21056
+ smoke: "smoke",
21057
+ flood: "flood",
21058
+ gas: "gas",
21059
+ "carbon-monoxide": "carbon-monoxide",
21060
+ vibration: "vibration",
21061
+ tamper: "tamper",
21062
+ presence: "presence",
21063
+ "enum-sensor": "enum-sensor",
21064
+ "event-emitter": "device-event",
21065
+ "lock-control": "lock",
21066
+ switch: "switch",
21067
+ button: "button",
21068
+ doorbell: "doorbell"
21069
+ };
21070
+ function buildDescriptor(capName, kind) {
21071
+ const t = EVENT_TAXONOMY[kind];
21072
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
21073
+ return {
21074
+ ...t,
21075
+ icon: legacyIcon(t.iconId)
21076
+ };
21077
+ }
21078
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
21079
+ /**
20372
21080
  * server-management — per-NODE singleton capability for a node's ROOT
20373
21081
  * package lifecycle (runtime-updatable node packages).
20374
21082
  *
@@ -21874,7 +22582,28 @@ var FaceInfoSchema = object({
21874
22582
  * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`). Absent when the
21875
22583
  * track produced no key frame (e.g. native/onboard source) — the UI falls
21876
22584
  * back to the inline `base64` face crop. */
21877
- keyFrameMediaKey: string().optional()
22585
+ keyFrameMediaKey: string().optional(),
22586
+ /** Winning identity-match cosine (0..1) for this face's track, when an
22587
+ * identity was auto-confirmed. Lets the UI surface WHY a face was assigned
22588
+ * (confidence badge / low-confidence audit). Absent on legacy rows and on
22589
+ * faces that were never auto-recognized. */
22590
+ bestMatchScore: number().optional(),
22591
+ /** Native-scale face short side (px) at recognition time, when the runner
22592
+ * measured it. Lets the UI flag low-resolution auto-assignments. Absent on
22593
+ * legacy rows / runners that reported no native measure. */
22594
+ nativeFaceShortSidePx: number().optional(),
22595
+ /** SUGGESTED identity for this face — a plausible-but-not-confident match that
22596
+ * MISSED auto-assignment (cosine in the suggestion band, or above threshold
22597
+ * but blocked only by the recognition size floor). Mutually exclusive with
22598
+ * `recognizedIdentityId` (a suggestion is NEVER an assignment): the face stays
22599
+ * UNASSIGNED and everything else keeps treating it as unrecognized — the UI
22600
+ * merely offers a one-tap "is this <name>?" confirm. Absent on legacy rows and
22601
+ * on faces that were auto-assigned or below the suggestion band. (2026-07-24) */
22602
+ suggestedIdentityId: string().optional(),
22603
+ /** Peak identity-match cosine (0..1) for `suggestedIdentityId`, captured at the
22604
+ * same moment as `bestMatchScore` (track peak, at close). Lets the UI rank /
22605
+ * badge suggestion confidence. Present iff `suggestedIdentityId` is. (2026-07-24) */
22606
+ suggestedMatchScore: number().optional()
21878
22607
  });
21879
22608
  var FaceFilterEnum = _enum([
21880
22609
  "unassigned",
@@ -24216,36 +24945,6 @@ Object.freeze({
24216
24945
  addonId: null,
24217
24946
  access: "view"
24218
24947
  },
24219
- "advancedNotifier.deleteRule": {
24220
- capName: "advanced-notifier",
24221
- capScope: "system",
24222
- addonId: null,
24223
- access: "delete"
24224
- },
24225
- "advancedNotifier.getHistory": {
24226
- capName: "advanced-notifier",
24227
- capScope: "system",
24228
- addonId: null,
24229
- access: "view"
24230
- },
24231
- "advancedNotifier.getRules": {
24232
- capName: "advanced-notifier",
24233
- capScope: "system",
24234
- addonId: null,
24235
- access: "view"
24236
- },
24237
- "advancedNotifier.testRule": {
24238
- capName: "advanced-notifier",
24239
- capScope: "system",
24240
- addonId: null,
24241
- access: "create"
24242
- },
24243
- "advancedNotifier.upsertRule": {
24244
- capName: "advanced-notifier",
24245
- capScope: "system",
24246
- addonId: null,
24247
- access: "create"
24248
- },
24249
24948
  "alarmPanel.arm": {
24250
24949
  capName: "alarm-panel",
24251
24950
  capScope: "device",
@@ -24468,6 +25167,12 @@ Object.freeze({
24468
25167
  addonId: null,
24469
25168
  access: "delete"
24470
25169
  },
25170
+ "backup.deleteSchedule": {
25171
+ capName: "backup",
25172
+ capScope: "system",
25173
+ addonId: null,
25174
+ access: "delete"
25175
+ },
24471
25176
  "backup.getEntries": {
24472
25177
  capName: "backup",
24473
25178
  capScope: "system",
@@ -24498,6 +25203,12 @@ Object.freeze({
24498
25203
  addonId: null,
24499
25204
  access: "view"
24500
25205
  },
25206
+ "backup.listSchedules": {
25207
+ capName: "backup",
25208
+ capScope: "system",
25209
+ addonId: null,
25210
+ access: "view"
25211
+ },
24501
25212
  "backup.previewSchedule": {
24502
25213
  capName: "backup",
24503
25214
  capScope: "system",
@@ -24522,6 +25233,12 @@ Object.freeze({
24522
25233
  addonId: null,
24523
25234
  access: "create"
24524
25235
  },
25236
+ "backup.upsertSchedule": {
25237
+ capName: "backup",
25238
+ capScope: "system",
25239
+ addonId: null,
25240
+ access: "create"
25241
+ },
24525
25242
  "battery.wakeForStream": {
24526
25243
  capName: "battery",
24527
25244
  capScope: "device",
@@ -26550,6 +27267,60 @@ Object.freeze({
26550
27267
  addonId: null,
26551
27268
  access: "create"
26552
27269
  },
27270
+ "notificationRules.createRule": {
27271
+ capName: "notification-rules",
27272
+ capScope: "system",
27273
+ addonId: null,
27274
+ access: "create"
27275
+ },
27276
+ "notificationRules.deleteRule": {
27277
+ capName: "notification-rules",
27278
+ capScope: "system",
27279
+ addonId: null,
27280
+ access: "delete"
27281
+ },
27282
+ "notificationRules.getConditionCatalog": {
27283
+ capName: "notification-rules",
27284
+ capScope: "system",
27285
+ addonId: null,
27286
+ access: "view"
27287
+ },
27288
+ "notificationRules.getHistory": {
27289
+ capName: "notification-rules",
27290
+ capScope: "system",
27291
+ addonId: null,
27292
+ access: "view"
27293
+ },
27294
+ "notificationRules.getRule": {
27295
+ capName: "notification-rules",
27296
+ capScope: "system",
27297
+ addonId: null,
27298
+ access: "view"
27299
+ },
27300
+ "notificationRules.listRules": {
27301
+ capName: "notification-rules",
27302
+ capScope: "system",
27303
+ addonId: null,
27304
+ access: "view"
27305
+ },
27306
+ "notificationRules.setRuleEnabled": {
27307
+ capName: "notification-rules",
27308
+ capScope: "system",
27309
+ addonId: null,
27310
+ access: "create"
27311
+ },
27312
+ "notificationRules.testRule": {
27313
+ capName: "notification-rules",
27314
+ capScope: "system",
27315
+ addonId: null,
27316
+ access: "create"
27317
+ },
27318
+ "notificationRules.updateRule": {
27319
+ capName: "notification-rules",
27320
+ capScope: "system",
27321
+ addonId: null,
27322
+ access: "create"
27323
+ },
26553
27324
  "notifier.cancel": {
26554
27325
  capName: "notifier",
26555
27326
  capScope: "device",
@@ -28302,6 +29073,36 @@ Object.freeze({
28302
29073
  addonId: null,
28303
29074
  access: "create"
28304
29075
  },
29076
+ "terminalSession.close": {
29077
+ capName: "terminal-session",
29078
+ capScope: "system",
29079
+ addonId: null,
29080
+ access: "create"
29081
+ },
29082
+ "terminalSession.listProfiles": {
29083
+ capName: "terminal-session",
29084
+ capScope: "system",
29085
+ addonId: null,
29086
+ access: "view"
29087
+ },
29088
+ "terminalSession.listSessions": {
29089
+ capName: "terminal-session",
29090
+ capScope: "system",
29091
+ addonId: null,
29092
+ access: "view"
29093
+ },
29094
+ "terminalSession.openSession": {
29095
+ capName: "terminal-session",
29096
+ capScope: "system",
29097
+ addonId: null,
29098
+ access: "create"
29099
+ },
29100
+ "terminalSession.resize": {
29101
+ capName: "terminal-session",
29102
+ capScope: "system",
29103
+ addonId: null,
29104
+ access: "create"
29105
+ },
28305
29106
  "toast.onToast": {
28306
29107
  capName: "toast",
28307
29108
  capScope: "system",