@camstack/addon-provider-vesync 0.2.4 → 0.2.6

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