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