@camstack/addon-provider-petkit 0.2.4 → 0.2.6

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