@camstack/addon-provider-amcrest 0.2.4 → 0.2.6

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