@camstack/addon-provider-ecowitt 0.2.4 → 0.2.6

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