@camstack/addon-provider-unifi 0.2.4 → 0.2.6

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