@camstack/addon-provider-onvif 1.2.4 → 1.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 +1911 -1110
  2. package/dist/addon.mjs +1911 -1110
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -3,7 +3,7 @@ import { createRequire } from "node:module";
3
3
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
4
4
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
5
5
  //#endregion
6
- //#region ../types/dist/event-category-D4HJq7Mw.mjs
6
+ //#region ../types/dist/event-category-BLcNejAE.mjs
7
7
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
8
8
  EventCategory["SystemBoot"] = "system.boot";
9
9
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -153,9 +153,6 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
153
153
  EventCategory["RecordingSegmentWritten"] = "recording.segment.written";
154
154
  EventCategory["RecordingPolicyFallback"] = "recording.policy.fallback";
155
155
  EventCategory["RecordingRetentionCompleted"] = "recording.retention.completed";
156
- /** Runner-sampled scrub thumbnail (~1/5 s/camera). Telemetry (D8): a lost
157
- * thumb is a scrub gap the recorder's keyframe backfill covers. */
158
- EventCategory["RecordingThumbSampled"] = "recording.thumb-sampled";
159
156
  /** Export render progress (0–100). Telemetry (D8): a lost tick is a stale
160
157
  * progress bar the client reconciles via `recordingExport.getExport`. */
161
158
  EventCategory["RecordingExportProgress"] = "recording.export.progress";
@@ -6820,7 +6817,6 @@ object({ deviceId: number() }), object({ deviceId: number() }), object({
6820
6817
  patch: record(string(), unknown())
6821
6818
  }), object({ success: literal(true) });
6822
6819
  object({ deviceId: number() }), unknown().nullable();
6823
- /** Shorthand to define a method schema */
6824
6820
  function method(input, output, options) {
6825
6821
  return {
6826
6822
  input,
@@ -6828,6 +6824,7 @@ function method(input, output, options) {
6828
6824
  kind: options?.kind ?? "query",
6829
6825
  auth: options?.auth ?? "protected",
6830
6826
  ...options?.access !== void 0 ? { access: options.access } : {},
6827
+ ...options?.caller !== void 0 ? { caller: options.caller } : {},
6831
6828
  timeoutMs: options?.timeoutMs
6832
6829
  };
6833
6830
  }
@@ -7521,16 +7518,23 @@ var StorageLocationDeclarationSchema = object({
7521
7518
  * Which node root the seeded `<id>:default` instance is placed under on a
7522
7519
  * FRESH install:
7523
7520
  * - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
7524
- * the appData volume. Right for small/durable data (backups, logs, models).
7521
+ * the appData volume. Right for small/durable data (logs, models).
7525
7522
  * - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
7526
7523
  * env is set, else falls back to the data root. Right for bulky, hot media
7527
7524
  * (recordings, event media) that should stay off the appData disk.
7525
+ * - `'backup'` — the dedicated backup volume (`CAMSTACK_BACKUP_ROOT`, default
7526
+ * `/backups` in the image) so archives live on their own mount rather than
7527
+ * filling the appData disk. Falls back to the data root when unset.
7528
7528
  *
7529
7529
  * Only affects the seeded default's `basePath`; operators can repoint any
7530
7530
  * location afterwards, and a `defaultsTo` slot inherits its parent's root
7531
7531
  * regardless of this field. Absent (the common case) is treated as `'data'`.
7532
7532
  */
7533
- defaultRoot: _enum(["data", "media"]).optional()
7533
+ defaultRoot: _enum([
7534
+ "data",
7535
+ "media",
7536
+ "backup"
7537
+ ]).optional()
7534
7538
  });
7535
7539
  var DecoderStatsSchema = object({
7536
7540
  inputFps: number(),
@@ -8193,6 +8197,59 @@ for (const l of AUDIO_MACRO_LABELS) {
8193
8197
  /** The complete taxonomy dictionary, keyed by kind. */
8194
8198
  var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
8195
8199
  /**
8200
+ * Notification-Center taxonomy — the fixed vocabulary the NC rule editor
8201
+ * offers as pickers instead of free text. Derived (never hand-listed) from the
8202
+ * single `EVENT_TAXONOMY` dictionary so it stays in lockstep with every other
8203
+ * taxonomy surface (timeline, filters, event page).
8204
+ *
8205
+ * Three buckets, mapped onto the rule editor's `stringList` conditions:
8206
+ * - `videoClasses` → detection classes (person / vehicle / animal + subs)
8207
+ * for the `classes` / `classesExclude` conditions.
8208
+ * - `audioKinds` → audio-analyzer sub kinds (`audio-scream`, …) shown in
8209
+ * the same class picker, grouped under an Audio header.
8210
+ * - `labels` → sensor + control taxonomy kinds (doorbell / contact /
8211
+ * lock / …) for the `sensorKinds` device-event condition.
8212
+ *
8213
+ * Each entry carries `parentKind` so the client can group video subs under
8214
+ * their macro and sensor/control kinds under their category. This surface is
8215
+ * served ADDITIVELY on the `nc.getConditionCatalog` bridge response — no cap
8216
+ * method, no codegen — so it ships train-free with an addon deploy.
8217
+ */
8218
+ /** One selectable taxonomy value: a stable kind id + display label + parent. */
8219
+ var NcTaxonomyEntrySchema = object({
8220
+ /** Stable kind id (e.g. 'person', 'car', 'audio-scream', 'doorbell'). */
8221
+ kind: string(),
8222
+ /** English fallback label (the UI translates via the event-kind i18n key). */
8223
+ label: string(),
8224
+ /** Macro/category parent for grouping ('car' → 'vehicle'); null for a top. */
8225
+ parentKind: string().nullable()
8226
+ });
8227
+ object({
8228
+ videoClasses: array(NcTaxonomyEntrySchema),
8229
+ audioKinds: array(NcTaxonomyEntrySchema),
8230
+ labels: array(NcTaxonomyEntrySchema)
8231
+ });
8232
+ function toEntry(kind, label, parentKind) {
8233
+ return {
8234
+ kind,
8235
+ label,
8236
+ parentKind
8237
+ };
8238
+ }
8239
+ /**
8240
+ * Build the NC taxonomy from `EVENT_TAXONOMY`. Insertion order is preserved
8241
+ * (macros before their subs), which the client relies on for stable grouping.
8242
+ */
8243
+ function buildNcTaxonomy() {
8244
+ const all = Object.values(EVENT_TAXONOMY);
8245
+ return {
8246
+ videoClasses: all.filter((e) => e.category === "detection").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8247
+ audioKinds: all.filter((e) => e.category === "audio" && e.level === "sub").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8248
+ labels: all.filter((e) => e.category === "sensor" || e.category === "control").map((e) => toEntry(e.kind, e.label, e.parentKind))
8249
+ };
8250
+ }
8251
+ Object.freeze(buildNcTaxonomy());
8252
+ /**
8196
8253
  * Error types for the safe expression engine. Two distinct classes so callers
8197
8254
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
8198
8255
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -8998,6 +9055,644 @@ function startReachabilityPoll(options) {
8998
9055
  } };
8999
9056
  }
9000
9057
  /**
9058
+ * Shared geometry vocabulary for on-frame shape caps — privacy-mask,
9059
+ * motion-zones, and the detection zones/lines editor all speak this one
9060
+ * language so a single drawing-plane editor and the providers stay
9061
+ * decoupled from each cap's storage.
9062
+ *
9063
+ * All coordinates are normalized 0..1 of the camera frame (top-left
9064
+ * origin). Each cap composes the SUBSET of shape kinds it supports and
9065
+ * advertises it via `supportedShapes` in its `getOptions`.
9066
+ */
9067
+ /** A normalized 0..1 point (top-left origin). */
9068
+ var MaskPointSchema = object({
9069
+ x: number(),
9070
+ y: number()
9071
+ });
9072
+ /** Axis-aligned rectangle (normalized 0..1). */
9073
+ var MaskRectShapeSchema = object({
9074
+ kind: literal("rect"),
9075
+ x: number(),
9076
+ y: number(),
9077
+ width: number(),
9078
+ height: number()
9079
+ });
9080
+ /** Free polygon — an ordered list of normalized vertices (≥3). */
9081
+ var MaskPolygonShapeSchema = object({
9082
+ kind: literal("polygon"),
9083
+ points: array(MaskPointSchema)
9084
+ });
9085
+ /** Boolean cell grid — row-major, length === gridWidth*gridHeight. */
9086
+ var MaskGridShapeSchema = object({
9087
+ kind: literal("grid"),
9088
+ gridWidth: number(),
9089
+ gridHeight: number(),
9090
+ cells: array(boolean())
9091
+ });
9092
+ discriminatedUnion("kind", [
9093
+ MaskRectShapeSchema,
9094
+ MaskPolygonShapeSchema,
9095
+ MaskGridShapeSchema,
9096
+ object({
9097
+ kind: literal("line"),
9098
+ points: array(MaskPointSchema)
9099
+ })
9100
+ ]);
9101
+ /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
9102
+ var MaskShapeKindSchema = _enum([
9103
+ "rect",
9104
+ "polygon",
9105
+ "grid",
9106
+ "line"
9107
+ ]);
9108
+ /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
9109
+ var MaskPolygonVerticesSchema = object({
9110
+ min: number(),
9111
+ max: number()
9112
+ });
9113
+ /** Grid dimensions when a cap supports 'grid'. */
9114
+ var MaskGridDimsSchema = object({
9115
+ width: number(),
9116
+ height: number()
9117
+ });
9118
+ /**
9119
+ * notification-rules — the Notification Center rule surface (P1 core).
9120
+ *
9121
+ * Spec: `docs/superpowers/specs/2026-07-22-notification-center-requirements.md`
9122
+ * (operator decisions D-1/D-2/D-3 are binding):
9123
+ *
9124
+ * - D-2: rule EVALUATION lives in `addon-post-analysis` (the
9125
+ * `notification-center` module), hooked on the durable persistence
9126
+ * moments (object-event insert, TrackCloser.closeExpired) with a
9127
+ * persisted outbox + retry — never the lossy telemetry bus (D8).
9128
+ * - D-3: urgency belongs to the RULE. `delivery: 'immediate'` fires on the
9129
+ * FIRST persisted detection matching the conditions (per-track dedup,
9130
+ * `maxPerTrack` fixed at 1 — see {@link NC_MAX_PER_TRACK_IMMEDIATE});
9131
+ * `delivery: 'track-end'` evaluates the finalized track record at close.
9132
+ * - DISPATCH stays behind `notification-output` (rules reference targets
9133
+ * by id; per-backend params are a passthrough blob capped by the
9134
+ * target kind's own caps/degrade engine).
9135
+ *
9136
+ * P1 scope: admin-authored rules only (`createdBy` stamped from the
9137
+ * server-injected caller identity — the first `caller: 'required'`
9138
+ * adopter). The P1 condition subset is: devices, classes(+exclude),
9139
+ * minConfidence, admin zones (any/all + exclude), weekly schedule
9140
+ * windows, and the optional label/identity/plate matchers. User rules,
9141
+ * private zones, per-recipient fan-out and the wider condition table are
9142
+ * P2+ (see spec §7).
9143
+ *
9144
+ * All schemas here are the single source of truth — `NcRule` etc. are
9145
+ * `z.infer` exports; no duplicate interfaces (the advanced-notifier
9146
+ * schema/interface drift is explicitly not repeated).
9147
+ */
9148
+ /**
9149
+ * D-3: the trigger/urgency of a rule — which persistence moment evaluates it.
9150
+ * The value maps 1:1 onto the evaluated record kind:
9151
+ * - `immediate` ↔ object-event persist (lowest-latency detection burst)
9152
+ * - `track-end` ↔ TrackCloser.closeExpired (finalized track record)
9153
+ * - `device-event` ↔ SensorEventStore insert (doorbell press / sensor state
9154
+ * change of a LINKED device, one row per linked camera)
9155
+ * - `package-event` ↔ PackageDropDetector object-event insert (a `package`
9156
+ * delivery / pick-up)
9157
+ *
9158
+ * `immediate`/`track-end` carry the D-3 urgency semantics; `device-event`/
9159
+ * `package-event` are pure trigger kinds (no urgency dimension). Extending
9160
+ * this one field keeps the schema additive — a rule still declares exactly
9161
+ * one trigger.
9162
+ */
9163
+ var NcDeliverySchema = _enum([
9164
+ "immediate",
9165
+ "track-end",
9166
+ "device-event",
9167
+ "package-event"
9168
+ ]);
9169
+ /** Weekly schedule — OR of windows; absence on the rule = always active. */
9170
+ var NcScheduleSchema = object({
9171
+ windows: array(object({
9172
+ /** Days of week the window STARTS on (0 = Sunday … 6 = Saturday). */
9173
+ days: array(number().int().min(0).max(6)).min(1),
9174
+ startMinute: number().int().min(0).max(1439),
9175
+ endMinute: number().int().min(0).max(1439)
9176
+ })).min(1),
9177
+ /** IANA timezone; default = hub host timezone. */
9178
+ timezone: string().optional(),
9179
+ /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
9180
+ invert: boolean().optional()
9181
+ });
9182
+ /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
9183
+ var NcPlateMatcherSchema = object({
9184
+ values: array(string().min(1)).min(1),
9185
+ /** Max Levenshtein distance after normalization (uppercase alphanumeric). */
9186
+ maxDistance: number().int().min(0).max(3).default(1)
9187
+ });
9188
+ /**
9189
+ * Occupancy condition (DEVICE-EVENT trigger). Fires on a ZoneAnalytics
9190
+ * occupancy edge for a device — optionally narrowed to a single admin
9191
+ * `zoneId` and/or object `className`. `op` selects the edge/threshold:
9192
+ * - `became-occupied` (default) — count crossed 0 → ≥ `count`
9193
+ * - `became-free` — count crossed ≥ `count` → below it
9194
+ * - `>=` / `<=` — count is at/over or at/under `count`
9195
+ * `sustainSeconds` requires the condition hold continuously that long
9196
+ * before firing (debounces flicker; 0 = fire on the first matching edge).
9197
+ * Fail-closed: no ZoneAnalytics snapshot / missing zone / null snapshot ⇒
9198
+ * the condition never matches. Confirmed edge-state survives addon restarts
9199
+ * (declared SQLite collection, reseeded on boot).
9200
+ */
9201
+ var NcOccupancyConditionSchema = object({
9202
+ /** Admin zone id to scope the count to; absent = whole-frame occupancy. */
9203
+ zoneId: string().optional(),
9204
+ /** Object class to count; absent = any class. */
9205
+ className: string().optional(),
9206
+ op: _enum([
9207
+ "became-occupied",
9208
+ "became-free",
9209
+ ">=",
9210
+ "<="
9211
+ ]).default("became-occupied"),
9212
+ count: number().int().min(0).default(1),
9213
+ sustainSeconds: number().int().min(0).max(3600).default(15)
9214
+ });
9215
+ /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
9216
+ var NcZoneConditionSchema = object({
9217
+ ids: array(string().min(1)).min(1),
9218
+ /** Quantifier over `ids` — at least one / every one visited. */
9219
+ match: _enum(["any", "all"]).default("any")
9220
+ });
9221
+ /**
9222
+ * The P1 condition set — a flat AND of groups; absent group = pass;
9223
+ * membership lists are OR within the list (spec §2.3).
9224
+ */
9225
+ var NcConditionsSchema = object({
9226
+ /** Device scope — absent = all devices. */
9227
+ devices: array(number()).optional(),
9228
+ /** Detector class names (any overlap with the record's class set). */
9229
+ classes: array(string().min(1)).optional(),
9230
+ /** Veto classes — any overlap fails the rule. */
9231
+ classesExclude: array(string().min(1)).optional(),
9232
+ /** Minimum detection confidence 0–1 (fails when the record has none). */
9233
+ minConfidence: number().min(0).max(1).optional(),
9234
+ /** Admin zone membership over event `zones` / track `zonesVisited`. */
9235
+ zones: NcZoneConditionSchema.optional(),
9236
+ /** Veto zones — any hit fails the rule. */
9237
+ zonesExclude: array(string().min(1)).optional(),
9238
+ /**
9239
+ * Exact (case-insensitive) match on the record's collapsed `label`
9240
+ * (identity name / plate text / subclass).
9241
+ */
9242
+ labelEquals: array(string().min(1)).optional(),
9243
+ /**
9244
+ * Identity matcher. P1 boundary: matched against the record's collapsed
9245
+ * `label` (the identity display name propagated by the face pipeline) —
9246
+ * identity-ID matching rides in P2 when identity ids reach the record.
9247
+ */
9248
+ identities: array(string().min(1)).optional(),
9249
+ /** Fuzzy plate matcher against the record's `label` (plate text). */
9250
+ plates: NcPlateMatcherSchema.optional(),
9251
+ /**
9252
+ * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
9253
+ * Same P1 boundary: matched against the record's collapsed `label` (the
9254
+ * identity display name). A record with NO label passes (nothing to
9255
+ * exclude), unlike the include variant which fails on an absent label.
9256
+ */
9257
+ identitiesExclude: array(string().min(1)).optional(),
9258
+ /**
9259
+ * Minimum server-computed key-event importance in [0,1] (`Track.importance`).
9260
+ * TRACK-END only: importance is scored at track close, so it does not exist
9261
+ * at immediate / object-event evaluation time (see catalog `appliesTo`). At
9262
+ * close the value is threaded via the close-time info (the `Track` clone is
9263
+ * captured before the DB row is updated, so it would otherwise read stale).
9264
+ * Fails when the record carries no importance (never guess quality — the
9265
+ * `minConfidence` precedent). MVP cut: a single scalar threshold.
9266
+ */
9267
+ minImportance: number().min(0).max(1).optional(),
9268
+ /**
9269
+ * Minimum track dwell in SECONDS — `(lastSeen − firstSeen) / 1000`.
9270
+ * TRACK-END only: an `immediate` / object-event subject has no closed
9271
+ * lifespan, so a dwell condition never matches immediate delivery
9272
+ * (documented choice — the object-event record carries no `firstSeen`,
9273
+ * so dwell cannot be computed from what the subject actually carries).
9274
+ */
9275
+ minDwellSeconds: number().min(0).optional(),
9276
+ /**
9277
+ * Detection provenance filter. `any` (default / absent) matches every
9278
+ * source; otherwise the subject's source must equal it. Legacy records
9279
+ * with no stamped source are treated as `pipeline`. The union spans both
9280
+ * record kinds — object events carry `pipeline` | `onboard`, synthetic
9281
+ * tracks carry `sensor`.
9282
+ */
9283
+ source: _enum([
9284
+ "pipeline",
9285
+ "onboard",
9286
+ "sensor",
9287
+ "any"
9288
+ ]).optional(),
9289
+ /**
9290
+ * Minimum identity / plate MATCH confidence in [0,1] — DISTINCT from the
9291
+ * detector `minConfidence` (that gates the object-detection score; this
9292
+ * gates the recognition/OCR match score). Fails when the subject carries
9293
+ * no label-match confidence (never guess). TRACK-END only: the confidence
9294
+ * lives on the recognition result and reaches the subject at track close.
9295
+ *
9296
+ * What it measures precisely (plumbed at track close — the closer threads
9297
+ * the value into `NcTrackClosedInfo.labelConfidence`, the same seam as
9298
+ * `importance`): the BEST recognition match confidence observed for the
9299
+ * label the track carries at close — for a face, the peak cosine similarity
9300
+ * of the ASSIGNED identity (`FaceMatch.score`, reset on an identity switch);
9301
+ * for a plate, the peak OCR read score of the best-held plate
9302
+ * (`plateText.confidence`). When BOTH a face and a plate were recognized on
9303
+ * one track the higher of the two is used. A track that ended with no
9304
+ * confident identity/plate match carries no value, so the condition fails
9305
+ * closed for it (an un-recognized subject).
9306
+ */
9307
+ minLabelConfidence: number().min(0).max(1).optional(),
9308
+ /**
9309
+ * DEVICE-EVENT only. Raw device event-type tokens (`EventFire.eventType`,
9310
+ * e.g. a doorbell `press` / `press_long`) — matched case-insensitively
9311
+ * against the token carried on the device-event subject (extracted from the
9312
+ * event-emitter runtime slice's `lastEvent.eventType`). Fails when the
9313
+ * subject carries no token. Doorbell-pulse / passive-sensor kinds emit no
9314
+ * eventType, so gate those with {@link sensorKinds} instead.
9315
+ */
9316
+ eventTypeTokens: array(string().min(1)).optional(),
9317
+ /**
9318
+ * DEVICE-EVENT only. Sensor/control taxonomy kinds (e.g. `doorbell`,
9319
+ * `contact`, `button`, `device-event`) — matched against the persisted
9320
+ * `SensorEvent.kind` (see `sensor-event-kinds.ts`). Membership is OR.
9321
+ */
9322
+ sensorKinds: array(string().min(1)).optional(),
9323
+ /**
9324
+ * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
9325
+ * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
9326
+ * when the subject's phase does not match (a subject always carries a phase
9327
+ * on the package-event trigger).
9328
+ */
9329
+ packagePhase: _enum([
9330
+ "delivered",
9331
+ "picked-up",
9332
+ "both"
9333
+ ]).optional(),
9334
+ /**
9335
+ * PERSONAL-RULE custom zones (viewer-drawn). Inline normalized polygons
9336
+ * (MaskShape vocabulary). A record passes when its bbox overlaps ANY
9337
+ * listed polygon (ZoneEngine membership semantics). Evaluated only when
9338
+ * the subject carries a bbox; absent bbox ⇒ the condition FAILS.
9339
+ */
9340
+ customZones: array(MaskPolygonShapeSchema).optional(),
9341
+ /**
9342
+ * DEVICE-EVENT only. ZoneAnalytics occupancy edge — fires when a device's
9343
+ * (optionally zone/class-scoped) occupancy count crosses the configured
9344
+ * threshold and holds for `sustainSeconds`. Fail-closed on missing
9345
+ * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
9346
+ */
9347
+ occupancy: NcOccupancyConditionSchema.optional()
9348
+ });
9349
+ /** One delivery target: a `notification-output` Target ref + passthrough params. */
9350
+ var NcRuleTargetSchema = object({
9351
+ /** `notification-output` Target id. */
9352
+ targetId: string().min(1),
9353
+ /**
9354
+ * Per-backend passthrough. Recognized keys are mapped onto the canonical
9355
+ * Notification (`priority`, `level`, `sound`, `clickUrl`, `ttl`); the
9356
+ * degrade engine drops what the backend can't render.
9357
+ */
9358
+ params: record(string(), unknown()).optional()
9359
+ });
9360
+ /**
9361
+ * Media attachment policy (P1 still-image subset).
9362
+ * - `best` — the best AVAILABLE subject image at dispatch time (D-3).
9363
+ * - `best-matching` — the media that explains WHY the rule fired: a rule
9364
+ * matched on identities attaches the subject's `faceCrop`, one matched on
9365
+ * plates attaches the `plateCrop`; a rule with no identity/plate condition
9366
+ * (or when the specific crop is missing) degrades to `best`, then
9367
+ * `keyFrame`, then no attachment — never delaying the send. The matched
9368
+ * condition summary is frozen on the outbox row at enqueue (like the rule
9369
+ * name), so the choice never drifts from the record that fired it.
9370
+ * - `keyFrame` — the clean scene frame (no subject box).
9371
+ * - `none` — no attachment.
9372
+ */
9373
+ var NcMediaPolicySchema = object({ attach: _enum([
9374
+ "best",
9375
+ "best-matching",
9376
+ "keyFrame",
9377
+ "none"
9378
+ ]).default("best") });
9379
+ /** Throttle — cooldown survives restarts (rebuilt from the outbox on boot). */
9380
+ var NcThrottleSchema = object({
9381
+ cooldownSec: number().int().min(0).max(86400).default(60),
9382
+ /** `rule` = one shared cooldown; `rule-device` = per-camera cooldown. */
9383
+ scope: _enum(["rule", "rule-device"]).default("rule-device")
9384
+ });
9385
+ /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
9386
+ var NcRuleInputSchema = object({
9387
+ name: string().min(1).max(200),
9388
+ enabled: boolean().default(true),
9389
+ delivery: NcDeliverySchema,
9390
+ conditions: NcConditionsSchema.default({}),
9391
+ schedule: NcScheduleSchema.optional(),
9392
+ targets: array(NcRuleTargetSchema).min(1),
9393
+ media: NcMediaPolicySchema.default({ attach: "best" }),
9394
+ throttle: NcThrottleSchema.default({
9395
+ cooldownSec: 60,
9396
+ scope: "rule-device"
9397
+ }),
9398
+ /** `{{var}}` templating over camera/class/label/zones/confidence/time. */
9399
+ template: object({
9400
+ title: string().max(500).optional(),
9401
+ body: string().max(2e3).optional()
9402
+ }).optional(),
9403
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
9404
+ priority: number().int().min(1).max(5).default(3),
9405
+ /**
9406
+ * Ownership/visibility key. Absent = admin/global rule (unchanged legacy
9407
+ * behaviour, visible to all, read-only in the viewer). Present = personal
9408
+ * rule owned by this userId. Server-stamped; never trusted from a client.
9409
+ */
9410
+ ownerUserId: string().optional()
9411
+ });
9412
+ /**
9413
+ * Partial patch for `updateRule` — any subset of the input fields, plus the
9414
+ * persisted-only {@link NcRuleSchema} `disabledTargetIds` set. The latter is
9415
+ * NOT a client-authored input field (it lives on the persisted rule, not the
9416
+ * input), so it is added here explicitly to let the store's per-target opt-out
9417
+ * toggle round-trip through the shared `update` path. Viewer opt-out mutations
9418
+ * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
9419
+ * `updateRule` patch.
9420
+ */
9421
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
9422
+ /** A persisted rule. */
9423
+ var NcRuleSchema = NcRuleInputSchema.extend({
9424
+ id: string(),
9425
+ /** userId of the admin who created the rule (server-stamped caller). */
9426
+ createdBy: string(),
9427
+ createdAt: number(),
9428
+ updatedAt: number(),
9429
+ /**
9430
+ * Per-target opt-out set. A targetId here is suppressed for THIS rule at
9431
+ * send time. Only a target's OWNER may add/remove its id (server-checked
9432
+ * in `nc.setRuleTargetEnabled`). Defaults to empty.
9433
+ */
9434
+ disabledTargetIds: array(string()).default([])
9435
+ });
9436
+ var NcTestResultSchema = object({
9437
+ recordId: string(),
9438
+ recordKind: _enum([
9439
+ "object-event",
9440
+ "track",
9441
+ "device-event",
9442
+ "package-event"
9443
+ ]),
9444
+ deviceId: number(),
9445
+ timestamp: number(),
9446
+ wouldFire: boolean(),
9447
+ /** Condition id that failed (first failing group), when `wouldFire` is false. */
9448
+ failedCondition: string().optional(),
9449
+ className: string().optional(),
9450
+ label: string().optional()
9451
+ });
9452
+ var NcConditionDescriptorSchema = object({
9453
+ /** Field id inside `NcConditions` (or `'schedule'` for the rule-level group). */
9454
+ id: string(),
9455
+ group: _enum([
9456
+ "scope",
9457
+ "class",
9458
+ "zones",
9459
+ "quality",
9460
+ "label",
9461
+ "schedule",
9462
+ "device",
9463
+ "package",
9464
+ "occupancy"
9465
+ ]),
9466
+ label: string(),
9467
+ /** Editor widget the UI renders — never hardcode per-condition forms. */
9468
+ valueType: _enum([
9469
+ "deviceIdList",
9470
+ "stringList",
9471
+ "number01",
9472
+ "number",
9473
+ "sourceSelect",
9474
+ "zoneSelection",
9475
+ "zoneIdList",
9476
+ "schedule",
9477
+ "plateMatcher",
9478
+ "packagePhase",
9479
+ "polygonDraw",
9480
+ "occupancy"
9481
+ ]),
9482
+ operator: _enum([
9483
+ "in",
9484
+ "notIn",
9485
+ "anyOf",
9486
+ "allOf",
9487
+ "gte",
9488
+ "fuzzyIn",
9489
+ "withinSchedule"
9490
+ ]),
9491
+ /** Which delivery kinds the condition applies to. */
9492
+ appliesTo: array(NcDeliverySchema),
9493
+ phase: string(),
9494
+ description: string().optional()
9495
+ });
9496
+ /**
9497
+ * The delivery lifecycle status of a history row — a straight read of the
9498
+ * durable outbox row's own status (single source of truth):
9499
+ * - `pending` — enqueued, in-flight or retrying with backoff
9500
+ * - `sent` — delivered (terminal)
9501
+ * - `dead` — dead-lettered after exhausting retries / a permanent
9502
+ * backend rejection / a deleted target (terminal; carries
9503
+ * the failure `error`)
9504
+ *
9505
+ * P1 has no `suppressed-quiet-hours` / `snoozed` states — those ride the P2
9506
+ * user dimension (quiet hours / snooze) and are additive when they land.
9507
+ */
9508
+ var NcHistoryStatusSchema = _enum([
9509
+ "pending",
9510
+ "sent",
9511
+ "dead"
9512
+ ]);
9513
+ /** The evaluated record kind a history row descends from (one per trigger). */
9514
+ var NcHistoryRecordKindSchema = _enum([
9515
+ "object-event",
9516
+ "track-end",
9517
+ "device-event",
9518
+ "package-event"
9519
+ ]);
9520
+ /** Subject summary frozen on the row at fire time (survives rule/record edits). */
9521
+ var NcHistorySubjectSchema = object({
9522
+ className: string(),
9523
+ label: string().optional(),
9524
+ confidence: number().optional(),
9525
+ zones: array(string()),
9526
+ timestamp: number()
9527
+ });
9528
+ /**
9529
+ * One delivery-history row. This is a read-only VIEW over the durable
9530
+ * outbox row (single source of truth — the same row the drain loop drives;
9531
+ * NO second write path, so history can never drift from delivery state).
9532
+ * The §3.2 fields map directly: `ruleId`/`targetId`/`deviceId` are columns,
9533
+ * `eventRef` is `recordKind`+`recordId`, `timestamps` are `createdAt`
9534
+ * (fire) / `updatedAt` (last transition), `status` + `error` are the
9535
+ * lifecycle. `ruleName` + `subject` are the intent snapshot frozen at
9536
+ * enqueue. `userId?` (per-recipient history) is P2 — no user dimension in
9537
+ * P1 (admin scope only).
9538
+ */
9539
+ var NcHistoryEntrySchema = object({
9540
+ /** Outbox row id — the stable dedup id `ruleId:dedupRef:targetId`. */
9541
+ id: string(),
9542
+ ruleId: string(),
9543
+ /** Rule name frozen at fire time (outlives a later rename / delete). */
9544
+ ruleName: string(),
9545
+ /** The rule urgency/trigger that produced this delivery. */
9546
+ delivery: NcDeliverySchema,
9547
+ targetId: string(),
9548
+ deviceId: number(),
9549
+ recordKind: NcHistoryRecordKindSchema,
9550
+ /** Event / track ref of the evaluated record (§3.2 `eventRef`). */
9551
+ recordId: string(),
9552
+ /** Present for track-scoped deliveries (object-event / track-end). */
9553
+ trackId: string().optional(),
9554
+ status: NcHistoryStatusSchema,
9555
+ /** Delivery attempts made so far. */
9556
+ attempts: number().int(),
9557
+ /** Fire time (outbox enqueue). */
9558
+ createdAt: number(),
9559
+ /** Last transition time (terminal for sent / dead). */
9560
+ updatedAt: number(),
9561
+ /** Failure detail — present on a `dead` row. */
9562
+ error: string().optional(),
9563
+ subject: NcHistorySubjectSchema
9564
+ });
9565
+ /**
9566
+ * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
9567
+ * AND; absent = unbounded on that axis. `since`/`until` bound the fire time
9568
+ * (`createdAt`, epoch ms, inclusive). `limit` is clamped to
9569
+ * {@link NC_HISTORY_LIMIT_MAX}. `userId` (per-recipient filtering) is P2.
9570
+ */
9571
+ var NcHistoryFilterSchema = object({
9572
+ ruleId: string().optional(),
9573
+ deviceId: number().optional(),
9574
+ status: NcHistoryStatusSchema.optional(),
9575
+ since: number().optional(),
9576
+ until: number().optional(),
9577
+ limit: number().int().min(1).max(500).default(100)
9578
+ });
9579
+ 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 }), {
9580
+ kind: "mutation",
9581
+ auth: "admin",
9582
+ caller: "required"
9583
+ }), method(object({
9584
+ ruleId: string(),
9585
+ patch: NcRulePatchSchema
9586
+ }), object({ rule: NcRuleSchema }), {
9587
+ kind: "mutation",
9588
+ auth: "admin",
9589
+ caller: "required"
9590
+ }), method(object({ ruleId: string() }), object({ success: literal(true) }), {
9591
+ kind: "mutation",
9592
+ auth: "admin"
9593
+ }), method(object({
9594
+ ruleId: string(),
9595
+ enabled: boolean()
9596
+ }), object({ success: literal(true) }), {
9597
+ kind: "mutation",
9598
+ auth: "admin"
9599
+ }), method(object({
9600
+ rule: NcRuleInputSchema,
9601
+ lookbackMinutes: number().int().min(1).max(1440).default(60)
9602
+ }), object({ results: array(NcTestResultSchema) }), {
9603
+ kind: "mutation",
9604
+ auth: "admin"
9605
+ }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
9606
+ /**
9607
+ * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
9608
+ *
9609
+ * Spec: `docs/superpowers/specs/2026-07-24-nc-occupancy-timelapse-design.md`
9610
+ * §3.2/§3.3.
9611
+ *
9612
+ * Deliberately NOT a capability definition and NOT an `NcRule`:
9613
+ * - Every `NcDelivery` member is a *persisted-pipeline-record* trigger. A
9614
+ * timelapse fires on a SCHEDULE WINDOW BOUNDARY, evaluates no pipeline
9615
+ * record, and produces a video it assembled itself — so it rides no
9616
+ * delivery-enum member (the enum is frozen) and no cap method. This file is
9617
+ * a plain typed schema; it does NOT go through `npm run codegen`.
9618
+ * - It shares only the delivery leg (`notification-output.send`) and the
9619
+ * persistence/ownership patterns with the Notification Center, reusing
9620
+ * {@link NcScheduleSchema} (weekly windows, midnight-crossing, invertible)
9621
+ * and {@link NcRuleTargetSchema} (target ref + passthrough params).
9622
+ *
9623
+ * Ownership is SERVER-DERIVED. `ownerUserId` / `createdBy` / `createdAt` /
9624
+ * `updatedAt` / `id` / `lastGeneratedAt` live on the PERSISTED rule only —
9625
+ * {@link TimelapseRuleInputSchema} and {@link TimelapseRulePatchSchema} do not
9626
+ * carry them, so a forged client payload can never claim or re-own a rule
9627
+ * (Zod strips unknown keys). The store stamps them from the resolved caller.
9628
+ */
9629
+ /** `{{var}}` templating over camera/rule/time — same vocabulary as `NcRule`. */
9630
+ var TimelapseTemplateSchema = object({
9631
+ title: string().max(500).optional(),
9632
+ body: string().max(2e3).optional()
9633
+ });
9634
+ var NameField = string().min(1).max(200);
9635
+ var DeviceIdsField = array(number()).min(1);
9636
+ var CadenceSecField = number().int().min(2).max(3600);
9637
+ var FramerateField = number().int().min(1).max(60);
9638
+ var TargetsField = array(NcRuleTargetSchema).min(1);
9639
+ var PriorityField = number().int().min(1).max(5);
9640
+ /**
9641
+ * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
9642
+ * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
9643
+ * here (see the ownership note above).
9644
+ */
9645
+ var TimelapseRuleInputSchema = object({
9646
+ name: NameField,
9647
+ enabled: boolean().default(true),
9648
+ /** Cameras sampled by this rule — one scratch dir + one artifact per device. */
9649
+ deviceIds: DeviceIdsField,
9650
+ /**
9651
+ * Activation window(s). REQUIRED (unlike `NcRule`, where an absent schedule
9652
+ * means "always active"): a timelapse is defined by its window boundaries —
9653
+ * open clears the scratch, close assembles and delivers.
9654
+ */
9655
+ schedule: NcScheduleSchema,
9656
+ /** Force-snapshot cadence inside the window, seconds (predecessor parity). */
9657
+ cadenceSec: CadenceSecField.default(15),
9658
+ /** Output frames per second of the assembled mp4 (predecessor parity). */
9659
+ framerate: FramerateField.default(10),
9660
+ /** `notification-output` targets the finished video/thumbnail is sent to. */
9661
+ targets: TargetsField,
9662
+ template: TimelapseTemplateSchema.optional(),
9663
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
9664
+ priority: PriorityField.default(3)
9665
+ });
9666
+ object({
9667
+ name: NameField.optional(),
9668
+ enabled: boolean().optional(),
9669
+ deviceIds: DeviceIdsField.optional(),
9670
+ schedule: NcScheduleSchema.optional(),
9671
+ cadenceSec: CadenceSecField.optional(),
9672
+ framerate: FramerateField.optional(),
9673
+ targets: TargetsField.optional(),
9674
+ template: TimelapseTemplateSchema.nullable().optional(),
9675
+ priority: PriorityField.optional()
9676
+ });
9677
+ TimelapseRuleInputSchema.extend({
9678
+ id: string(),
9679
+ /**
9680
+ * Ownership/visibility key. Absent = admin/global rule (visible to all).
9681
+ * Present = personal rule owned by this userId. Server-stamped from the
9682
+ * resolved caller; never trusted from a client payload.
9683
+ */
9684
+ ownerUserId: string().optional(),
9685
+ /**
9686
+ * Epoch-ms of the last successful generation — the 1-hour re-generation
9687
+ * guard's durable state (predecessor parity). Absent = never generated.
9688
+ */
9689
+ lastGeneratedAt: number().optional(),
9690
+ /** userId of the caller who created the rule (server-stamped). */
9691
+ createdBy: string(),
9692
+ createdAt: number(),
9693
+ updatedAt: number()
9694
+ });
9695
+ /**
9001
9696
  * Generic device-level status snapshot. Auto-registered by `BaseDevice`
9002
9697
  * for every device, regardless of provider — the kernel needs a uniform
9003
9698
  * cap-keyed slice for the basic device flags every consumer expects to
@@ -11071,6 +11766,22 @@ var CameraMetricsSchema = object({
11071
11766
  ])
11072
11767
  });
11073
11768
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
11769
+ /**
11770
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
11771
+ * within the frame, so the executor can re-cut a leaf child ROI at native
11772
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
11773
+ */
11774
+ var NativeCropRefSchema = object({
11775
+ /** Handle keying the retained native surface (node-pinned to its owner). */
11776
+ handle: FrameHandleSchema,
11777
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
11778
+ cropFrameSpace: object({
11779
+ x: number(),
11780
+ y: number(),
11781
+ w: number(),
11782
+ h: number()
11783
+ })
11784
+ });
11074
11785
  var ModelFormatSchema$1 = _enum([
11075
11786
  "onnx",
11076
11787
  "coreml",
@@ -11346,7 +12057,22 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
11346
12057
  * Omitted ⇒ the runner's default device (current single-engine
11347
12058
  * behaviour). Selects WHICH device pool of the node runs the call.
11348
12059
  */
11349
- deviceKey: string().optional()
12060
+ deviceKey: string().optional(),
12061
+ /**
12062
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
12063
+ * when the parent crop was resolved from the frame's retained NATIVE
12064
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
12065
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
12066
+ * resolution from that surface — the SAME quality path faces already
12067
+ * had — instead of the downscaled parent tile. `handle` keys the native
12068
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
12069
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
12070
+ * the executor's crop-normalized child ROI back into frame-normalized
12071
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
12072
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
12073
+ * (today's behaviour on the fallback path).
12074
+ */
12075
+ nativeCropRef: NativeCropRefSchema.optional()
11350
12076
  }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
11351
12077
  engine: PipelineEngineChoiceSchema.optional(),
11352
12078
  steps: array(PipelineStepInputSchema).min(1),
@@ -11562,7 +12288,11 @@ var DetailResultSchema = object({
11562
12288
  bbox: NativeCropBboxSchema.optional(),
11563
12289
  embedding: string().optional(),
11564
12290
  label: string().optional(),
11565
- alignedCropJpeg: string().optional()
12291
+ alignedCropJpeg: string().optional(),
12292
+ /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
12293
+ * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
12294
+ * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
12295
+ nativeFaceShortSidePx: number().optional()
11566
12296
  });
11567
12297
  /**
11568
12298
  * Per-camera tunable ranges + defaults. Single source of truth used
@@ -11576,6 +12306,12 @@ var motionCooldownMsField = {
11576
12306
  default: 3e4,
11577
12307
  step: 500
11578
12308
  };
12309
+ var maxSessionHoldMsField = {
12310
+ min: 0,
12311
+ max: 6e5,
12312
+ default: 12e4,
12313
+ step: 5e3
12314
+ };
11579
12315
  var motionFpsField = {
11580
12316
  min: 1,
11581
12317
  max: 30,
@@ -11723,6 +12459,19 @@ var RunnerCameraConfigSchema = object({
11723
12459
  "on-motion"
11724
12460
  ]).default("always-on"),
11725
12461
  motionCooldownMs: number().min(motionCooldownMsField.min).default(motionCooldownMsField.default),
12462
+ /**
12463
+ * Orchestrator-side on-motion session-hold cap (ms). While an on-motion
12464
+ * detection session is active and ≥1 confirmed non-stationary track is
12465
+ * still live, the orchestrator keeps the session open past
12466
+ * `motionCooldownMs` (a slowly-moving subject can stop re-triggering the
12467
+ * camera's VMD yet is still being tracked frame-to-frame) — up to this many
12468
+ * ms since the session opened, after which it closes regardless. `0`
12469
+ * disables the hold (legacy cooldown-only teardown). Not consumed by the
12470
+ * runner itself — carried here so it shares the per-camera device-settings
12471
+ * surface with `motionCooldownMs`; the orchestrator reads it off the
12472
+ * resolved `CameraDetectionConfig`.
12473
+ */
12474
+ maxSessionHoldMs: number().min(maxSessionHoldMsField.min).max(maxSessionHoldMsField.max).optional(),
11726
12475
  motionFps: number().min(motionFpsField.min).max(motionFpsField.max).default(motionFpsField.default),
11727
12476
  detectionFps: number().min(detectionFpsField.min).max(detectionFpsField.max).default(detectionFpsField.default),
11728
12477
  motionStreamId: string(),
@@ -11812,7 +12561,7 @@ var RunnerCameraConfigSchema = object({
11812
12561
  */
11813
12562
  inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
11814
12563
  });
11815
- 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;
12564
+ 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;
11816
12565
  /**
11817
12566
  * Runtime load summary returned by `getLocalLoad`. Used by the orchestrator's
11818
12567
  * load-balancing levels (L2 capacity-based, L3 hardware-aware) to decide
@@ -11923,71 +12672,10 @@ DeviceType.Light, DeviceType.Siren, DeviceType.Switch, method(object({
11923
12672
  lastChangedAt: number()
11924
12673
  });
11925
12674
  /**
11926
- * Shared geometry vocabulary for on-frame shape caps privacy-mask,
11927
- * motion-zones, and the detection zones/lines editor all speak this one
11928
- * language so a single drawing-plane editor and the providers stay
11929
- * decoupled from each cap's storage.
11930
- *
11931
- * All coordinates are normalized 0..1 of the camera frame (top-left
11932
- * origin). Each cap composes the SUBSET of shape kinds it supports and
11933
- * advertises it via `supportedShapes` in its `getOptions`.
11934
- */
11935
- /** A normalized 0..1 point (top-left origin). */
11936
- var MaskPointSchema = object({
11937
- x: number(),
11938
- y: number()
11939
- });
11940
- /** Axis-aligned rectangle (normalized 0..1). */
11941
- var MaskRectShapeSchema = object({
11942
- kind: literal("rect"),
11943
- x: number(),
11944
- y: number(),
11945
- width: number(),
11946
- height: number()
11947
- });
11948
- /** Free polygon — an ordered list of normalized vertices (≥3). */
11949
- var MaskPolygonShapeSchema = object({
11950
- kind: literal("polygon"),
11951
- points: array(MaskPointSchema)
11952
- });
11953
- /** Boolean cell grid — row-major, length === gridWidth*gridHeight. */
11954
- var MaskGridShapeSchema = object({
11955
- kind: literal("grid"),
11956
- gridWidth: number(),
11957
- gridHeight: number(),
11958
- cells: array(boolean())
11959
- });
11960
- discriminatedUnion("kind", [
11961
- MaskRectShapeSchema,
11962
- MaskPolygonShapeSchema,
11963
- MaskGridShapeSchema,
11964
- object({
11965
- kind: literal("line"),
11966
- points: array(MaskPointSchema)
11967
- })
11968
- ]);
11969
- /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
11970
- var MaskShapeKindSchema = _enum([
11971
- "rect",
11972
- "polygon",
11973
- "grid",
11974
- "line"
11975
- ]);
11976
- /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
11977
- var MaskPolygonVerticesSchema = object({
11978
- min: number(),
11979
- max: number()
11980
- });
11981
- /** Grid dimensions when a cap supports 'grid'. */
11982
- var MaskGridDimsSchema = object({
11983
- width: number(),
11984
- height: number()
11985
- });
11986
- /**
11987
- * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
11988
- * on-camera motion-detection mask is a single `grid` region (a row-major
11989
- * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
11990
- * a region keeps one drawing-plane model across all geometry caps.
12675
+ * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
12676
+ * on-camera motion-detection mask is a single `grid` region (a row-major
12677
+ * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
12678
+ * a region keeps one drawing-plane model across all geometry caps.
11991
12679
  */
11992
12680
  /** A motion-zone region — exactly one boolean cell grid today. */
11993
12681
  var MotionZoneRegionSchema = object({
@@ -13960,94 +14648,6 @@ var EnrichedWidgetMetadataSchema = WidgetMetadataSchema.extend({
13960
14648
  bundleUrl: string()
13961
14649
  });
13962
14650
  method(_void(), array(EnrichedWidgetMetadataSchema).readonly());
13963
- var NotificationRuleConditionsSchema = object({
13964
- deviceIds: array(number()).readonly().optional(),
13965
- classNames: array(string()).readonly().optional(),
13966
- zoneIds: array(string()).readonly().optional(),
13967
- minConfidence: number().optional(),
13968
- source: _enum([
13969
- "pipeline",
13970
- "onboard",
13971
- "any"
13972
- ]).optional(),
13973
- schedule: object({
13974
- days: array(number()).readonly(),
13975
- startHour: number(),
13976
- endHour: number()
13977
- }).optional(),
13978
- cooldownSeconds: number().optional(),
13979
- minDwellSeconds: number().optional(),
13980
- /** Match against `event.data.eventType` token (e.g. `'press_long'`). When non-empty, only events
13981
- * carrying a matching `data.eventType` string pass this condition. Rules without this field are
13982
- * unaffected (back-compat). Distinct from `rule.eventTypes` which holds EventCategory strings. */
13983
- eventTypeTokens: array(string()).readonly().optional(),
13984
- /** Match detections whose CLIP image embedding is semantically similar to this free-text
13985
- * description. Requires the embedding-encoder cap to have pre-warmed the text vector.
13986
- * `minSimilarity` is the cosine similarity threshold in [0, 1]. */
13987
- clipDescription: object({
13988
- text: string().min(1),
13989
- minSimilarity: number().min(0).max(1)
13990
- }).optional(),
13991
- /** Match events whose recognized-entity label (face identity name or plate
13992
- * vehicle name, propagated onto `event.data.label`) is one of these values.
13993
- * Empty/absent → unaffected (back-compat). Enables "notify me when <named
13994
- * vehicle/person> is seen". */
13995
- labels: array(string()).readonly().optional()
13996
- });
13997
- var NotificationRuleTemplateSchema = object({
13998
- title: string(),
13999
- body: string(),
14000
- imageMode: _enum([
14001
- "crop",
14002
- "annotated",
14003
- "full",
14004
- "none"
14005
- ])
14006
- });
14007
- var NotificationRuleSchema = object({
14008
- id: string(),
14009
- name: string(),
14010
- enabled: boolean(),
14011
- eventTypes: array(string()).readonly(),
14012
- conditions: NotificationRuleConditionsSchema,
14013
- outputs: array(string()).readonly(),
14014
- template: NotificationRuleTemplateSchema.optional(),
14015
- priority: _enum([
14016
- "low",
14017
- "normal",
14018
- "high",
14019
- "critical"
14020
- ])
14021
- });
14022
- var NotificationTestResultSchema = object({
14023
- ruleId: string(),
14024
- eventId: string(),
14025
- timestamp: number(),
14026
- wouldFire: boolean(),
14027
- reason: string().optional()
14028
- });
14029
- var NotificationHistoryEntrySchema = object({
14030
- id: string(),
14031
- ruleId: string(),
14032
- ruleName: string(),
14033
- eventId: string(),
14034
- timestamp: number(),
14035
- outputs: array(string()).readonly(),
14036
- success: boolean(),
14037
- error: string().optional(),
14038
- deviceId: number().optional()
14039
- });
14040
- var NotificationHistoryFilterSchema = object({
14041
- ruleId: string().optional(),
14042
- deviceId: number().optional(),
14043
- from: number().optional(),
14044
- to: number().optional(),
14045
- limit: number().optional()
14046
- });
14047
- 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({
14048
- ruleId: string(),
14049
- lookbackMinutes: number()
14050
- }), object({ results: array(NotificationTestResultSchema).readonly() }), { kind: "mutation" }), method(object({ filter: NotificationHistoryFilterSchema.optional() }), object({ entries: array(NotificationHistoryEntrySchema).readonly() }));
14051
14651
  /**
14052
14652
  * Alerts capability — collection-based internal alert system.
14053
14653
  *
@@ -14234,88 +14834,54 @@ method(object({
14234
14834
  password: string()
14235
14835
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
14236
14836
  /**
14237
- * `login-method` collection cap through which auth addons contribute
14238
- * their pre-auth login surfaces to the login page. This is the SINGLE,
14239
- * generic mechanism that supersedes the dead `auth.listProviders` reader:
14240
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
14241
- * `login-method` provider and the PUBLIC `auth.listLoginMethods`
14242
- * procedure aggregates them for the unauthenticated login page.
14243
- *
14244
- * A contribution is a discriminated union on `kind`:
14245
- *
14246
- * - `redirect` — a declarative button. The login page renders a generic
14247
- * button that navigates to `startUrl` (an addon-owned HTTP route).
14248
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
14249
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
14250
- * login page needs NO change.
14251
- *
14252
- * - `widget` — a Module-Federation widget the login page mounts (via
14253
- * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
14254
- * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
14255
- * mechanism kept for future use; no shipped addon uses it on the login
14256
- * page (the passkey ceremony below runs natively in the shell instead).
14257
- *
14258
- * - `passkey` — a declarative WebAuthn ceremony the shell renders
14259
- * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
14260
- * a remotely-loaded bundle). Carries the addon's effective `rpId` /
14261
- * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
14262
- * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
14263
- * fetching any remote code pre-auth. Contribution stays unconditional —
14264
- * enrollment state is never leaked pre-auth; visibility is a shell
14265
- * decision.
14266
- *
14267
- * Every contribution carries a `stage`:
14268
- * - `primary` — shown on the first credentials screen (OIDC /
14269
- * magic-link buttons; a future usernameless passkey).
14270
- * - `second-factor` — shown AFTER the password leg, gated on the
14271
- * returned `factors` (passkey-as-2FA today).
14272
- *
14273
- * `mount: skip` — the cap is read server-side by the core auth router
14274
- * (`registry.getCollection('login-method')`), never mounted as its own
14275
- * tRPC router.
14837
+ * A live terminal session hosted by the provider addon. Output and input do
14838
+ * NOT flow through the capability they use the addon data plane
14839
+ * (`GET /addon/terminal/<id>/out` SSE, `POST /addon/terminal/<id>/in`) because
14840
+ * terminal output must be ordered and lossless. The event bus is telemetry and
14841
+ * may drop chunks ([D8]), and a dropped chunk desynchronises the vt parser
14842
+ * permanently until a full repaint. The capability owns only lifecycle.
14276
14843
  */
14277
- /** When a login method renders in the two-phase login flow. */
14278
- var LoginStageEnum = _enum(["primary", "second-factor"]);
14279
- /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
14280
- var LoginMethodContributionSchema = discriminatedUnion("kind", [
14281
- object({
14282
- kind: literal("redirect"),
14283
- /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
14284
- id: string(),
14285
- /** Operator-facing button label. */
14286
- label: string(),
14287
- /** lucide-react icon name. */
14288
- icon: string().optional(),
14289
- /** Addon-owned HTTP route the button navigates to (GET). */
14290
- startUrl: string(),
14291
- stage: LoginStageEnum
14292
- }),
14293
- object({
14294
- kind: literal("widget"),
14295
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
14296
- id: string(),
14297
- /** Owning addon id — drives the public bundle URL + the MF namespace. */
14298
- addonId: string(),
14299
- /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
14300
- bundle: string(),
14301
- /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
14302
- remote: WidgetRemoteSchema,
14303
- stage: LoginStageEnum
14304
- }),
14305
- object({
14306
- kind: literal("passkey"),
14307
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
14308
- id: string(),
14309
- /** Operator-facing button label. */
14310
- label: string(),
14311
- stage: LoginStageEnum,
14312
- /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
14313
- rpId: string(),
14314
- /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
14315
- origin: string().nullable()
14316
- })
14317
- ]);
14318
- method(_void(), array(LoginMethodContributionSchema).readonly());
14844
+ var TerminalSessionInfoSchema = object({
14845
+ /** Opaque session id minted by the provider on `openSession`. */
14846
+ sessionId: string(),
14847
+ /** The pre-declared profile this session runs (never a free-form command). */
14848
+ profileId: string(),
14849
+ /** Human-readable profile label for the UI session list. */
14850
+ label: string(),
14851
+ cols: number().int().positive(),
14852
+ rows: number().int().positive(),
14853
+ /** ms-epoch the session's pty was spawned. */
14854
+ startedAt: number()
14855
+ });
14856
+ /**
14857
+ * A profile the operator may open — a pre-declared, allowlisted program
14858
+ * (`monitor` → `btm`). The capability accepts only these ids; a free-form
14859
+ * command string would be remote code execution as the server's user, so it is
14860
+ * deliberately not part of the contract.
14861
+ */
14862
+ var TerminalProfileInfoSchema = object({
14863
+ profileId: string(),
14864
+ label: string(),
14865
+ description: string().optional()
14866
+ });
14867
+ method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(TerminalSessionInfoSchema).readonly(), { auth: "admin" }), method(object({
14868
+ profileId: string(),
14869
+ cols: number().int().positive(),
14870
+ rows: number().int().positive()
14871
+ }), TerminalSessionInfoSchema, {
14872
+ kind: "mutation",
14873
+ auth: "admin"
14874
+ }), method(object({
14875
+ sessionId: string(),
14876
+ cols: number().int().positive(),
14877
+ rows: number().int().positive()
14878
+ }), _void(), {
14879
+ kind: "mutation",
14880
+ auth: "admin"
14881
+ }), method(object({ sessionId: string() }), _void(), {
14882
+ kind: "mutation",
14883
+ auth: "admin"
14884
+ });
14319
14885
  /**
14320
14886
  * Orchestrator-side destination metadata. The orchestrator computes
14321
14887
  * `id = <addonId>:<subId>` from its provider lookup so consumers
@@ -14417,11 +14983,53 @@ var LocationStatSchema = object({
14417
14983
  fileCount: number(),
14418
14984
  present: boolean()
14419
14985
  });
14986
+ /**
14987
+ * A backup schedule — the N:M "entry" that binds one cron cadence to a
14988
+ * SET of destination locations. Supersedes the per-location cron on
14989
+ * `BackupDestinationPolicy`: an operator creates a schedule, picks the
14990
+ * `backups` locations it should write to, and the orchestrator fans a
14991
+ * single archive out to all of them when the cron fires.
14992
+ *
14993
+ * `retentionCount` is per-schedule (D-decision 2026-07-28): every
14994
+ * location targeted by this schedule keeps this many archives from
14995
+ * this schedule's runs.
14996
+ *
14997
+ * `dataSources` optionally narrows which top-level state locations
14998
+ * (db, addons, tls, …) are archived; omitted = the orchestrator's
14999
+ * default full set.
15000
+ */
15001
+ var BackupScheduleSchema = object({
15002
+ /** Stable id. Generated by the orchestrator on first upsert if absent. */
15003
+ id: string(),
15004
+ /** Operator-facing display name. */
15005
+ label: string(),
15006
+ /** 5-field POSIX cron. Empty = disabled cadence (kept for editing). */
15007
+ cron: string(),
15008
+ /** Master on/off toggle for the whole schedule. */
15009
+ enabled: boolean(),
15010
+ /** `backups`-location ids this schedule writes to (fan-out set). */
15011
+ locationIds: array(string()).readonly(),
15012
+ /** Archives kept per targeted location for this schedule. */
15013
+ retentionCount: number().int().min(1).max(1e3),
15014
+ /** Optional subset of source locations to include; omitted = all. */
15015
+ dataSources: array(string()).readonly().optional(),
15016
+ /** ms-epoch of last successful run. */
15017
+ lastRunAt: number().optional(),
15018
+ /** ms-epoch of next computed firing (read-only, filled on list). */
15019
+ nextRunAt: number().optional()
15020
+ });
14420
15021
  method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }), method(object({
14421
15022
  /** Subset of registered `backup-destination` addon ids to write to. */
14422
15023
  destinations: array(string()).optional(),
14423
15024
  locations: array(string()).optional(),
14424
- label: string().optional()
15025
+ label: string().optional(),
15026
+ /**
15027
+ * Per-run retention override applied to every targeted
15028
+ * destination. Used by schedule-driven runs (per-entry
15029
+ * retention). Omitted = each destination's own policy
15030
+ * retention (manual runs).
15031
+ */
15032
+ retentionCount: number().int().min(1).max(1e3).optional()
14425
15033
  }).optional(), array(BackupEntrySchema).readonly(), {
14426
15034
  kind: "mutation",
14427
15035
  auth: "admin"
@@ -14470,7 +15078,21 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
14470
15078
  ok: boolean(),
14471
15079
  error: string().optional(),
14472
15080
  nextRuns: array(number()).readonly()
14473
- }));
15081
+ })), method(_void(), array(BackupScheduleSchema).readonly(), { auth: "admin" }), method(object({
15082
+ id: string().optional(),
15083
+ label: string(),
15084
+ cron: string(),
15085
+ enabled: boolean(),
15086
+ locationIds: array(string()).readonly(),
15087
+ retentionCount: number().int().min(1).max(1e3),
15088
+ dataSources: array(string()).readonly().optional()
15089
+ }), BackupScheduleSchema, {
15090
+ kind: "mutation",
15091
+ auth: "admin"
15092
+ }), method(object({ id: string() }), _void(), {
15093
+ kind: "mutation",
15094
+ auth: "admin"
15095
+ });
14474
15096
  /**
14475
15097
  * `broker` — unified pub/sub broker registry, system-scoped collection.
14476
15098
  *
@@ -15660,851 +16282,934 @@ method(_void(), array(string()).readonly(), { auth: "admin" }), method(object({
15660
16282
  kind: "mutation",
15661
16283
  auth: "admin"
15662
16284
  });
15663
- var LogLevelSchema = _enum([
15664
- "debug",
15665
- "info",
15666
- "warn",
15667
- "error"
15668
- ]);
15669
- var LogEntrySchema = object({
15670
- timestamp: date(),
15671
- level: LogLevelSchema,
15672
- scope: array(string()),
15673
- message: string(),
15674
- meta: record(string(), unknown()).optional(),
15675
- tags: record(string(), string()).optional()
16285
+ /**
16286
+ * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
16287
+ * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
16288
+ * caps stay wire-compatible without a circular cap→cap import.
16289
+ *
16290
+ * Errors are a discriminated-union RESULT, never thrown: the shape survives
16291
+ * every transport tier structurally, and failed calls still write usage rows.
16292
+ * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
16293
+ */
16294
+ var LlmUsageSchema = object({
16295
+ inputTokens: number(),
16296
+ outputTokens: number()
15676
16297
  });
15677
- method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
15678
- scope: array(string()).optional(),
15679
- level: LogLevelSchema.optional(),
15680
- since: date().optional(),
15681
- until: date().optional(),
15682
- limit: number().optional(),
15683
- tags: record(string(), string()).optional()
15684
- }), array(LogEntrySchema).readonly());
15685
- var CpuBreakdownSchema = object({
15686
- total: number(),
15687
- user: number(),
15688
- system: number(),
15689
- irq: number(),
15690
- nice: number(),
15691
- loadAvg: tuple([
15692
- number(),
15693
- number(),
15694
- number()
15695
- ]),
15696
- cores: number()
15697
- });
15698
- var MemoryInfoSchema = object({
15699
- percent: number(),
15700
- totalBytes: number(),
15701
- usedBytes: number(),
15702
- availableBytes: number(),
15703
- swapUsedBytes: number(),
15704
- swapTotalBytes: number()
15705
- });
15706
- var DiskIoSnapshotSchema = object({
15707
- readBytes: number(),
15708
- writeBytes: number(),
15709
- readOps: number(),
15710
- writeOps: number(),
15711
- timestampMs: number()
15712
- });
15713
- var NetworkIoSnapshotSchema = object({
15714
- rxBytes: number(),
15715
- txBytes: number(),
15716
- rxPackets: number(),
15717
- txPackets: number(),
15718
- rxErrors: number(),
15719
- txErrors: number(),
15720
- timestampMs: number()
15721
- });
15722
- var MetricsGpuInfoSchema = object({
15723
- utilization: number(),
16298
+ var LlmErrorCodeSchema = _enum([
16299
+ "timeout",
16300
+ "rate-limited",
16301
+ "auth",
16302
+ "refusal",
16303
+ "bad-request",
16304
+ "unavailable",
16305
+ "no-profile",
16306
+ "budget-exceeded",
16307
+ "adapter-error"
16308
+ ]);
16309
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
16310
+ ok: literal(true),
16311
+ text: string(),
15724
16312
  model: string(),
15725
- memoryUsedBytes: number(),
15726
- memoryTotalBytes: number(),
15727
- temperature: number().nullable()
15728
- });
15729
- var ProcessResourceInfoSchema = object({
15730
- openFds: number(),
15731
- threadCount: number(),
15732
- activeHandles: number(),
15733
- activeRequests: number()
15734
- });
15735
- var PressureAvgsSchema = object({
15736
- avg10: number(),
15737
- avg60: number(),
15738
- avg300: number()
16313
+ usage: LlmUsageSchema,
16314
+ truncated: boolean(),
16315
+ latencyMs: number()
16316
+ }), object({
16317
+ ok: literal(false),
16318
+ code: LlmErrorCodeSchema,
16319
+ message: string(),
16320
+ retryAfterMs: number().optional()
16321
+ })]);
16322
+ /**
16323
+ * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
16324
+ * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
16325
+ * notification-output.cap.ts:27-31 precedents).
16326
+ */
16327
+ var LlmImageSchema = object({
16328
+ bytes: _instanceof(Uint8Array),
16329
+ mimeType: string()
15739
16330
  });
15740
- var PressureInfoSchema = object({
15741
- some: PressureAvgsSchema,
15742
- full: PressureAvgsSchema.nullable()
16331
+ var LlmGenerateBaseInputSchema = object({
16332
+ /** Collection routing (the notification-output posture). */
16333
+ addonId: string().optional(),
16334
+ /** Explicit profile; else the resolution chain (spec §3). */
16335
+ profileId: string().optional(),
16336
+ /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
16337
+ consumer: string(),
16338
+ system: string().optional(),
16339
+ /** v1: single-turn. `messages[]` is a v2 additive field. */
16340
+ prompt: string(),
16341
+ /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
16342
+ jsonSchema: record(string(), unknown()).optional(),
16343
+ /** Per-call override of the profile default. */
16344
+ maxTokens: number().int().positive().optional(),
16345
+ temperature: number().optional()
15743
16346
  });
15744
- var SystemResourceSnapshotSchema = object({
15745
- cpu: CpuBreakdownSchema,
15746
- memory: MemoryInfoSchema,
15747
- gpu: MetricsGpuInfoSchema.nullable(),
15748
- network: NetworkIoSnapshotSchema,
15749
- disk: DiskIoSnapshotSchema,
15750
- pressure: object({
15751
- cpu: PressureInfoSchema.nullable(),
15752
- memory: PressureInfoSchema.nullable(),
15753
- io: PressureInfoSchema.nullable()
16347
+ /**
16348
+ * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
16349
+ * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
16350
+ * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
16351
+ * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
16352
+ * this only through the `llm` cap's methods.
16353
+ *
16354
+ * One running llama-server child per node in v1 (models are RAM-heavy).
16355
+ * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
16356
+ * watchdog — operator decision #3).
16357
+ */
16358
+ var ManagedModelRefSchema = discriminatedUnion("kind", [
16359
+ object({
16360
+ kind: literal("catalog"),
16361
+ catalogId: string()
15754
16362
  }),
15755
- process: ProcessResourceInfoSchema,
15756
- cpuTemperature: number().nullable(),
15757
- timestampMs: number()
15758
- });
15759
- var DiskSpaceInfoSchema = object({
15760
- path: string(),
15761
- totalBytes: number(),
15762
- usedBytes: number(),
15763
- availableBytes: number(),
15764
- percent: number()
15765
- });
15766
- var PidResourceStatsSchema = object({
15767
- pid: number(),
15768
- cpu: number(),
15769
- memory: number(),
15770
- /**
15771
- * Private (anonymous) resident bytes — the per-process V8 heap + native
15772
- * allocations NOT shared with other processes (Linux RssAnon). This is the
15773
- * "real" per-runner cost; summing it across runners is meaningful, unlike
15774
- * `memory` (RSS), which double-counts the shared mmap'd framework code.
15775
- * Undefined where /proc is unavailable (e.g. macOS).
15776
- */
15777
- privateBytes: number().optional(),
15778
- /**
15779
- * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
15780
- * code shared copy-on-write across runners. Undefined on macOS.
15781
- */
15782
- sharedBytes: number().optional()
16363
+ object({
16364
+ kind: literal("url"),
16365
+ url: string(),
16366
+ sha256: string().optional()
16367
+ }),
16368
+ object({
16369
+ kind: literal("path"),
16370
+ path: string()
16371
+ })
16372
+ ]);
16373
+ var ManagedRuntimeConfigSchema = object({
16374
+ /** WHERE the runtime lives — hub or any agent. */
16375
+ nodeId: string(),
16376
+ /** Closed for v1; 'ollama' is a v2 candidate. */
16377
+ engine: _enum(["llama-cpp"]),
16378
+ model: ManagedModelRefSchema,
16379
+ contextSize: number().int().default(4096),
16380
+ /** 0 = CPU-only. */
16381
+ gpuLayers: number().int().default(0),
16382
+ /** Default: cpus-2, clamped ≥1 (resolved node-side). */
16383
+ threads: number().int().optional(),
16384
+ /** Concurrent slots. */
16385
+ parallel: number().int().default(1),
16386
+ /** Else lazy: first generate boots it. */
16387
+ autoStart: boolean().default(false),
16388
+ /** 0 = never; frees RAM after quiet periods. */
16389
+ idleStopMinutes: number().int().default(30)
15783
16390
  });
15784
- var AddonInstanceSchema = object({
15785
- addonId: string(),
16391
+ var LlmRuntimeStatusSchema = object({
16392
+ /** Status is ALWAYS node-qualified. */
15786
16393
  nodeId: string(),
15787
- role: _enum(["hub", "worker"]),
15788
- pid: number(),
15789
16394
  state: _enum([
15790
- "starting",
15791
- "running",
15792
- "stopping",
15793
16395
  "stopped",
15794
- "crashed"
15795
- ]),
15796
- uptimeSec: number()
15797
- });
15798
- var NodeProcessSchema = object({
15799
- pid: number(),
15800
- ppid: number(),
15801
- pgid: number(),
15802
- classification: _enum([
15803
- "root",
15804
- "managed",
15805
- "system",
15806
- "ghost"
16396
+ "downloading",
16397
+ "starting",
16398
+ "ready",
16399
+ "crashed",
16400
+ "failed"
15807
16401
  ]),
15808
- /** `$process` addon binding when `managed`, else null. */
15809
- addonId: string().nullable(),
15810
- /** Kernel-reported nodeId when the process is a known agent/worker. */
15811
- nodeId: string().nullable(),
15812
- /** Truncated command line. */
15813
- command: string(),
15814
- cpuPercent: number(),
15815
- memoryRssBytes: number(),
15816
- /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
15817
- uptimeSec: number(),
15818
- /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
15819
- orphaned: boolean()
15820
- });
15821
- var KillProcessInputSchema = object({
15822
- pid: number(),
15823
- /** Force = SIGKILL. Default is SIGTERM. */
15824
- force: boolean().optional()
16402
+ pid: number().optional(),
16403
+ port: number().optional(),
16404
+ modelPath: string().optional(),
16405
+ modelId: string().optional(),
16406
+ downloadProgress: number().min(0).max(1).optional(),
16407
+ lastError: string().optional(),
16408
+ crashesInWindow: number(),
16409
+ /** Child RSS (sampled best-effort). */
16410
+ memoryBytes: number().optional(),
16411
+ vramBytes: number().optional()
15825
16412
  });
15826
- var KillProcessResultSchema = object({
15827
- success: boolean(),
15828
- reason: string().optional(),
15829
- signal: _enum(["SIGTERM", "SIGKILL"]).optional()
16413
+ var LlmNodeModelSchema = object({
16414
+ file: string(),
16415
+ sizeBytes: number(),
16416
+ catalogId: string().optional(),
16417
+ installedAt: number().optional()
15830
16418
  });
15831
- var DumpHeapSnapshotInputSchema = object({
15832
- /** The addon whose runner should dump a heap snapshot. */
15833
- addonId: string() });
15834
- var DumpHeapSnapshotResultSchema = object({
15835
- success: boolean(),
15836
- /** Path of the written .heapsnapshot inside the runner's container/host. */
15837
- path: string().optional(),
15838
- /** Process pid that was signalled. */
15839
- pid: number().optional(),
15840
- reason: string().optional()
16419
+ var LlmRuntimeDiskUsageSchema = object({
16420
+ nodeId: string(),
16421
+ modelsBytes: number(),
16422
+ freeBytes: number().optional()
15841
16423
  });
15842
- var SystemMetricsSchema = object({
15843
- cpuPercent: number(),
15844
- memoryPercent: number(),
15845
- memoryUsedMB: number(),
15846
- memoryTotalMB: number(),
15847
- diskPercent: number().optional(),
15848
- temperature: number().optional(),
15849
- gpuPercent: number().optional(),
15850
- gpuMemoryPercent: number().optional()
15851
- });
15852
- 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, {
16424
+ method(LlmGenerateBaseInputSchema.extend({
16425
+ images: array(LlmImageSchema).optional(),
16426
+ runtime: ManagedRuntimeConfigSchema,
16427
+ /** The managed profile's timeout, threaded by the hub provider. */
16428
+ timeoutMs: number().int().positive().optional()
16429
+ }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
15853
16430
  kind: "mutation",
15854
16431
  auth: "admin"
15855
- }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
16432
+ }), method(object({}), _void(), {
15856
16433
  kind: "mutation",
15857
16434
  auth: "admin"
15858
- });
15859
- method(object({
15860
- sourceUrl: string(),
15861
- metadata: ModelConvertMetadataSchema,
15862
- targets: array(ConvertTargetSchema).min(1).readonly(),
15863
- calibrationRef: string().optional(),
15864
- sessionId: string().optional()
15865
- }), ConvertResultSchema, {
16435
+ }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
15866
16436
  kind: "mutation",
15867
- auth: "admin",
15868
- timeoutMs: 6e5
15869
- });
15870
- method(object({
15871
- nodeId: string(),
15872
- modelId: string(),
15873
- format: _enum(MODEL_FORMATS),
15874
- entry: ModelCatalogEntrySchema
15875
- }), object({
15876
- ok: boolean(),
15877
- /** sha256 of the staged tarball (empty for a hub-local no-op). */
15878
- sha256: string(),
15879
- bytes: number(),
15880
- /** The target node's modelsDir the artifact landed in. */
15881
- path: string()
15882
- }), {
16437
+ auth: "admin"
16438
+ }), method(object({ file: string() }), _void(), {
15883
16439
  kind: "mutation",
15884
16440
  auth: "admin"
15885
- });
15886
- /**
15887
- * `mqtt-broker` — broker-registry cap.
15888
- *
15889
- * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
15890
- * MQTT brokers (external + optionally an embedded `aedes`-backed one)
15891
- * and (b) the connection details a consumer addon needs to spin up
15892
- * its OWN `mqtt.js` client.
15893
- *
15894
- * Why: pub/sub routing over the system event-bus loses fidelity
15895
- * (callback shape, QoS guarantees, will/retain semantics) and adds
15896
- * refcount bookkeeping that addons would rather own themselves. The
15897
- * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
15898
- * features anyway — give it the connection config, get out of the way.
15899
- *
15900
- * Consumer flow:
15901
- * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
15902
- * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
15903
- * client.subscribe('zigbee2mqtt/+')
15904
- *
15905
- * Collection mode: multiple brokers (e.g. one local mosquitto + one
15906
- * cloud bridge). The "embedded" entry (when present) is just another
15907
- * broker in the registry — its lifecycle is owned by the addon that
15908
- * spawned it.
15909
- */
15910
- var BrokerKindSchema = _enum(["external", "embedded"]);
16441
+ }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
15911
16442
  /**
15912
- * Broker live-probe status.
16443
+ * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
16444
+ * methods concat-fan across providers; single-row methods route to ONE
16445
+ * provider by the `addonId` in the call input (the notification-output
16446
+ * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
16447
+ * (hub-placed); the cap stays open for future providers.
15913
16448
  *
15914
- * - `connected` last probe completed a clean CONNACK
15915
- * - `disconnected` — no probe has run yet (cold cache)
15916
- * - `auth-failed` CONNACK refused with auth error (RC 4 / 5)
15917
- * - `unreachable` — TCP connect timed out / refused
15918
- * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
16449
+ * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
16450
+ * `apiKey` is a password field providers REDACT it on read and merge on
16451
+ * write; a stored key NEVER round-trips to a client.
15919
16452
  */
15920
- var BrokerStatusSchema$1 = _enum([
15921
- "connected",
15922
- "disconnected",
15923
- "auth-failed",
15924
- "unreachable",
15925
- "tls-error"
16453
+ var LlmProfileKindSchema = _enum([
16454
+ "openai-compatible",
16455
+ "openai",
16456
+ "anthropic",
16457
+ "google",
16458
+ "managed-local"
15926
16459
  ]);
15927
- var BrokerInfoSchema = object({
16460
+ var LlmProfileSchema = object({
15928
16461
  id: string(),
15929
16462
  name: string(),
15930
- url: string(),
15931
- kind: BrokerKindSchema,
15932
- status: BrokerStatusSchema$1,
15933
- latencyMs: number().nullable(),
15934
- error: string().optional(),
15935
- /** Embedded brokers only: number of MQTT clients currently connected. */
15936
- connectedClients: number().int().nonnegative().optional(),
15937
- /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
15938
- lastCheckedAt: number().optional()
16463
+ kind: LlmProfileKindSchema,
16464
+ /** Stamped by the provider — keeps the fanned catalog routable. */
16465
+ addonId: string(),
16466
+ enabled: boolean(),
16467
+ /** Vendor model id, or the managed runtime's loaded model. */
16468
+ model: string(),
16469
+ /** Required for openai-compatible; override for cloud kinds. */
16470
+ baseUrl: string().optional(),
16471
+ /** ConfigUISchema type:'password' — never round-trips (spec §5). */
16472
+ apiKey: string().optional(),
16473
+ supportsVision: boolean(),
16474
+ temperature: number().min(0).max(2).optional(),
16475
+ maxTokens: number().int().positive().optional(),
16476
+ timeoutMs: number().int().positive().default(6e4),
16477
+ extraHeaders: record(string(), string()).optional(),
16478
+ /** kind === 'managed-local' only (spec §4). */
16479
+ runtime: ManagedRuntimeConfigSchema.optional()
15939
16480
  });
15940
- /**
15941
- * Connection details — what a consumer needs to call
15942
- * `mqtt.connect(url, options)`. We split URL + credentials so the
15943
- * consumer can pass them as `mqtt.connect(url, { username, password })`
15944
- * instead of stuffing creds into the URL (which leaks them into logs).
15945
- */
15946
- var BrokerConnectionDetailsSchema = object({
15947
- url: string(),
15948
- username: string().optional(),
15949
- password: string().optional(),
15950
- /**
15951
- * Suggested prefix for `clientId`. Each consumer should suffix this
15952
- * with its own discriminator (addon id, instance id) so reconnects
15953
- * don't kick each other off (MQTT spec: clientId must be unique per
15954
- * broker).
15955
- */
15956
- clientIdPrefix: string().optional()
16481
+ /** ConfigUISchema tree passed through untyped on the wire (the
16482
+ * notification-output `ConfigSchemaPassthrough` precedent at
16483
+ * notification-output.cap.ts:151); the exported TS type re-tightens it. */
16484
+ var ConfigSchemaPassthrough$1 = unknown();
16485
+ var LlmProfileKindDescriptorSchema = object({
16486
+ kind: LlmProfileKindSchema,
16487
+ label: string(),
16488
+ icon: string(),
16489
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
16490
+ addonId: string(),
16491
+ configSchema: ConfigSchemaPassthrough$1
15957
16492
  });
15958
- var AddBrokerInputSchema = object({
15959
- name: string().min(1),
15960
- url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
15961
- username: string().optional(),
15962
- password: string().optional(),
15963
- clientIdPrefix: string().optional()
16493
+ var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
16494
+ var LlmDefaultSchema = object({
16495
+ selector: LlmDefaultSelectorSchema,
16496
+ profileId: string()
15964
16497
  });
15965
- var AddBrokerResultSchema = object({ id: string() });
15966
- var IdInputSchema = object({ id: string() });
15967
- var TestResultSchema$1 = discriminatedUnion("ok", [object({
15968
- ok: literal(true),
15969
- latencyMs: number()
15970
- }), object({
15971
- ok: literal(false),
15972
- error: string()
15973
- })]);
15974
- var StartEmbeddedInputSchema = object({
15975
- port: number().int().min(1).max(65535).default(1883),
15976
- /** Allow anonymous connect (no username/password). Default: false. */
15977
- allowAnonymous: boolean().default(false),
15978
- /** Optional shared username/password for clients. */
15979
- username: string().optional(),
15980
- password: string().optional()
16498
+ /** Server-side rollup row getUsage never dumps raw call rows (spec §6). */
16499
+ var LlmUsageRollupSchema = object({
16500
+ day: string(),
16501
+ consumer: string(),
16502
+ profileId: string(),
16503
+ calls: number(),
16504
+ okCalls: number(),
16505
+ errorCalls: number(),
16506
+ inputTokens: number(),
16507
+ outputTokens: number(),
16508
+ avgLatencyMs: number()
15981
16509
  });
15982
- var StartEmbeddedResultSchema = object({
16510
+ /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
16511
+ var ManagedModelCatalogEntrySchema = object({
15983
16512
  id: string(),
15984
- url: string()
15985
- });
15986
- var StatusSchema = object({
15987
- brokerCount: number(),
15988
- embeddedRunning: boolean()
15989
- });
15990
- 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);
15991
- var NetworkEndpointSchema = object({
16513
+ label: string(),
16514
+ family: string(),
16515
+ purpose: _enum(["text", "vision"]),
15992
16516
  url: string(),
15993
- hostname: string(),
15994
- port: number(),
15995
- protocol: _enum(["http", "https"])
16517
+ sha256: string(),
16518
+ sizeBytes: number(),
16519
+ quantization: string(),
16520
+ /** Load-time guidance shown in the picker. */
16521
+ minRamBytes: number(),
16522
+ contextSizeDefault: number().int(),
16523
+ /** Vision models: companion projector file. */
16524
+ mmprojUrl: string().optional()
15996
16525
  });
15997
- var NetworkAccessStatusSchema = object({
15998
- connected: boolean(),
15999
- endpoint: NetworkEndpointSchema.nullable(),
16526
+ var LlmRuntimeNodeSchema = object({
16527
+ nodeId: string(),
16528
+ reachable: boolean(),
16529
+ status: LlmRuntimeStatusSchema.optional(),
16530
+ disk: LlmRuntimeDiskUsageSchema.optional(),
16000
16531
  error: string().optional()
16001
16532
  });
16002
- /**
16003
- * Optional, richer endpoint shape returned by providers that expose
16004
- * MORE than one ingress concurrently (Tailscale Ingress with mixed
16005
- * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
16006
- * the originating provider config (mode + sourcePort) so the
16007
- * orchestrator UI can label rows distinctly. Providers that expose only
16008
- * one endpoint just omit `listEndpoints` from their provider impl.
16009
- */
16010
- var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
16011
- /**
16012
- * Stable id within the provider — typically `<mode>-<sourcePort>` so
16013
- * the orchestrator can dedupe across `listEndpoints` polls.
16014
- */
16015
- id: string(),
16016
- /** Operator-facing label (mirrors `MeshEndpoint.label`). */
16017
- label: string(),
16018
- /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
16019
- mode: string().optional(),
16020
- /** Originating local port the ingress fronts (informational). */
16021
- sourcePort: number().optional()
16533
+ var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
16534
+ var ProfileRefInputSchema = object({
16535
+ addonId: string(),
16536
+ profileId: string()
16022
16537
  });
16023
- method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
16024
- /**
16025
- * notification-output — canonical, capability-gated notification delivery.
16026
- *
16027
- * Apprise-derived model (see
16028
- * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
16029
- * callers emit ONE canonical `Notification`; each provider declares a
16030
- * per-kind capability descriptor (`TargetKind`), and the pure degrade
16031
- * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
16032
- * message to what the kind supports — callers never special-case a service.
16033
- *
16034
- * DESIGN DECISIONS (locked):
16035
- * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
16036
- * `setTargetEnabled`), each provider persisting via the `settings-store`
16037
- * cap. Rationale: the admin UI needs one uniform surface across the
16038
- * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
16039
- * alternative would fork the UI per addon and cannot host the
16040
- * discovery→adopt flow.
16041
- * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
16042
- * the generated cap-mount auto-`concatCollection`-fans them across every
16043
- * registered provider (notifiers addon + HA addon) so one catalog is
16044
- * routable. `send` / `testTarget` / CRUD route to ONE provider by the
16045
- * `addonId` the generated collection router extracts from the call input.
16046
- * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
16047
- * transformer) + UDS MsgPack both round-trip typed arrays — already used by
16048
- * `storage` / `storage-provider` / `recording` caps over the same path. No
16049
- * base64 fallback needed.
16050
- *
16051
- * TODO (deferred, closed-set change — separate decision): add
16052
- * `providerKind: 'notify'` so notification providers surface on the unified
16053
- * admin "Integrations" page.
16054
- */
16055
- /**
16056
- * Zentik-derived typed-media enum — the superset across every kind. Each
16057
- * adapter picks what it supports and the degrade engine filters the rest.
16058
- */
16059
- var AttachmentMediaTypeSchema = _enum([
16060
- "image",
16061
- "video",
16062
- "gif",
16063
- "audio",
16064
- "icon"
16538
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
16539
+ kind: "mutation",
16540
+ auth: "admin"
16541
+ }), method(ProfileRefInputSchema, _void(), {
16542
+ kind: "mutation",
16543
+ auth: "admin"
16544
+ }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
16545
+ kind: "mutation",
16546
+ auth: "admin"
16547
+ }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
16548
+ selector: LlmDefaultSelectorSchema,
16549
+ profileId: string().nullable()
16550
+ }), _void(), {
16551
+ kind: "mutation",
16552
+ auth: "admin"
16553
+ }), method(object({
16554
+ since: number().optional(),
16555
+ until: number().optional(),
16556
+ consumer: string().optional(),
16557
+ profileId: string().optional()
16558
+ }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
16559
+ nodeId: string(),
16560
+ model: ManagedModelRefSchema
16561
+ }), _void(), {
16562
+ kind: "mutation",
16563
+ auth: "admin"
16564
+ }), method(object({
16565
+ nodeId: string(),
16566
+ file: string()
16567
+ }), _void(), {
16568
+ kind: "mutation",
16569
+ auth: "admin"
16570
+ }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
16571
+ kind: "mutation",
16572
+ auth: "admin"
16573
+ }), method(ProfileRefInputSchema, _void(), {
16574
+ kind: "mutation",
16575
+ auth: "admin"
16576
+ });
16577
+ var LogLevelSchema = _enum([
16578
+ "debug",
16579
+ "info",
16580
+ "warn",
16581
+ "error"
16065
16582
  ]);
16583
+ var LogEntrySchema = object({
16584
+ timestamp: date(),
16585
+ level: LogLevelSchema,
16586
+ scope: array(string()),
16587
+ message: string(),
16588
+ meta: record(string(), unknown()).optional(),
16589
+ tags: record(string(), string()).optional()
16590
+ });
16591
+ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16592
+ scope: array(string()).optional(),
16593
+ level: LogLevelSchema.optional(),
16594
+ since: date().optional(),
16595
+ until: date().optional(),
16596
+ limit: number().optional(),
16597
+ tags: record(string(), string()).optional()
16598
+ }), array(LogEntrySchema).readonly());
16066
16599
  /**
16067
- * A single attachment. Exactly one of `url` (remote source, most adapters
16068
- * prefer this) or `bytes` (inline source; required for Pushover-style
16069
- * bytes-only kinds) MUST be present — the degrade engine expresses a
16070
- * url→bytes fetch as a `needsFetch` directive the adapter executes.
16600
+ * `login-method` collection cap through which auth addons contribute
16601
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
16602
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
16603
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
16604
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
16605
+ * procedure aggregates them for the unauthenticated login page.
16606
+ *
16607
+ * A contribution is a discriminated union on `kind`:
16608
+ *
16609
+ * - `redirect` — a declarative button. The login page renders a generic
16610
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
16611
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
16612
+ * ZERO shell-side JS. A future SSO addon plugs in the same way — the
16613
+ * login page needs NO change.
16614
+ *
16615
+ * - `widget` — a Module-Federation widget the login page mounts (via
16616
+ * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
16617
+ * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
16618
+ * mechanism kept for future use; no shipped addon uses it on the login
16619
+ * page (the passkey ceremony below runs natively in the shell instead).
16620
+ *
16621
+ * - `passkey` — a declarative WebAuthn ceremony the shell renders
16622
+ * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
16623
+ * a remotely-loaded bundle). Carries the addon's effective `rpId` /
16624
+ * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
16625
+ * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
16626
+ * fetching any remote code pre-auth. Contribution stays unconditional —
16627
+ * enrollment state is never leaked pre-auth; visibility is a shell
16628
+ * decision.
16629
+ *
16630
+ * Every contribution carries a `stage`:
16631
+ * - `primary` — shown on the first credentials screen (OIDC /
16632
+ * magic-link buttons; a future usernameless passkey).
16633
+ * - `second-factor` — shown AFTER the password leg, gated on the
16634
+ * returned `factors` (passkey-as-2FA today).
16635
+ *
16636
+ * `mount: skip` — the cap is read server-side by the core auth router
16637
+ * (`registry.getCollection('login-method')`), never mounted as its own
16638
+ * tRPC router.
16071
16639
  */
16072
- var AttachmentSchema = object({
16073
- mediaType: AttachmentMediaTypeSchema,
16074
- url: string().optional(),
16075
- bytes: _instanceof(Uint8Array).optional(),
16076
- mime: string().optional(),
16077
- name: string().optional()
16078
- }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
16079
- var NotificationFormatSchema = _enum([
16080
- "text",
16081
- "markdown",
16082
- "html"
16640
+ /** When a login method renders in the two-phase login flow. */
16641
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
16642
+ /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
16643
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [
16644
+ object({
16645
+ kind: literal("redirect"),
16646
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
16647
+ id: string(),
16648
+ /** Operator-facing button label. */
16649
+ label: string(),
16650
+ /** lucide-react icon name. */
16651
+ icon: string().optional(),
16652
+ /** Addon-owned HTTP route the button navigates to (GET). */
16653
+ startUrl: string(),
16654
+ stage: LoginStageEnum
16655
+ }),
16656
+ object({
16657
+ kind: literal("widget"),
16658
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
16659
+ id: string(),
16660
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
16661
+ addonId: string(),
16662
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
16663
+ bundle: string(),
16664
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
16665
+ remote: WidgetRemoteSchema,
16666
+ stage: LoginStageEnum
16667
+ }),
16668
+ object({
16669
+ kind: literal("passkey"),
16670
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
16671
+ id: string(),
16672
+ /** Operator-facing button label. */
16673
+ label: string(),
16674
+ stage: LoginStageEnum,
16675
+ /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
16676
+ rpId: string(),
16677
+ /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
16678
+ origin: string().nullable()
16679
+ })
16083
16680
  ]);
16084
- /** A single tap-through action button. */
16085
- var NotificationActionSchema = object({
16086
- id: string(),
16087
- label: string(),
16088
- url: string().optional()
16681
+ method(_void(), array(LoginMethodContributionSchema).readonly());
16682
+ var CpuBreakdownSchema = object({
16683
+ total: number(),
16684
+ user: number(),
16685
+ system: number(),
16686
+ irq: number(),
16687
+ nice: number(),
16688
+ loadAvg: tuple([
16689
+ number(),
16690
+ number(),
16691
+ number()
16692
+ ]),
16693
+ cores: number()
16089
16694
  });
16090
- /**
16091
- * The canonical notification. `body` is the only hard field (Apprise model).
16092
- * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
16093
- * NOT a fixed severity enum — each kind declares its own `caps.levels` and
16094
- * the adapter maps this ordinal onto its native level. `level?` is an
16095
- * optional kind-native level id (`emergency`, `silent`, …) that overrides
16096
- * `priority` for that one target.
16097
- */
16098
- var NotificationSchema = object({
16099
- body: string(),
16100
- title: string().optional(),
16101
- format: NotificationFormatSchema.default("text"),
16102
- priority: number().int().min(1).max(5).default(3),
16103
- level: string().optional(),
16104
- attachments: array(AttachmentSchema).optional(),
16105
- clickUrl: string().optional(),
16106
- actions: array(NotificationActionSchema).optional(),
16107
- sound: string().optional(),
16108
- ttl: number().optional(),
16109
- tag: string().optional(),
16110
- deviceId: number().optional(),
16111
- eventId: string().optional(),
16112
- metadata: record(string(), unknown()).optional()
16695
+ var MemoryInfoSchema = object({
16696
+ percent: number(),
16697
+ totalBytes: number(),
16698
+ usedBytes: number(),
16699
+ availableBytes: number(),
16700
+ swapUsedBytes: number(),
16701
+ swapTotalBytes: number()
16702
+ });
16703
+ var DiskIoSnapshotSchema = object({
16704
+ readBytes: number(),
16705
+ writeBytes: number(),
16706
+ readOps: number(),
16707
+ writeOps: number(),
16708
+ timestampMs: number()
16709
+ });
16710
+ var NetworkIoSnapshotSchema = object({
16711
+ rxBytes: number(),
16712
+ txBytes: number(),
16713
+ rxPackets: number(),
16714
+ txPackets: number(),
16715
+ rxErrors: number(),
16716
+ txErrors: number(),
16717
+ timestampMs: number()
16718
+ });
16719
+ var MetricsGpuInfoSchema = object({
16720
+ utilization: number(),
16721
+ model: string(),
16722
+ memoryUsedBytes: number(),
16723
+ memoryTotalBytes: number(),
16724
+ temperature: number().nullable()
16725
+ });
16726
+ var ProcessResourceInfoSchema = object({
16727
+ openFds: number(),
16728
+ threadCount: number(),
16729
+ activeHandles: number(),
16730
+ activeRequests: number()
16113
16731
  });
16114
- /** One declared native severity/priority level for a kind. */
16115
- var TargetKindLevelSchema = object({
16116
- id: string(),
16117
- label: string(),
16118
- /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
16119
- ordinal: number().int().min(1).max(5).nullable(),
16120
- flags: object({
16121
- critical: boolean().optional(),
16122
- silent: boolean().optional(),
16123
- noPush: boolean().optional()
16124
- }).optional(),
16125
- /** e.g. Pushover `emergency` requires `retry` / `expire`. */
16126
- requires: array(string()).optional(),
16127
- description: string().optional()
16732
+ var PressureAvgsSchema = object({
16733
+ avg10: number(),
16734
+ avg60: number(),
16735
+ avg300: number()
16128
16736
  });
16129
- /** The full capability block consulted before dispatch. */
16130
- var TargetKindCapsSchema = object({
16131
- attachments: object({
16132
- mediaTypes: array(AttachmentMediaTypeSchema),
16133
- mode: _enum([
16134
- "url",
16135
- "bytes",
16136
- "both"
16137
- ]),
16138
- max: number().int().nonnegative(),
16139
- maxBytes: number().int().positive().optional()
16737
+ var PressureInfoSchema = object({
16738
+ some: PressureAvgsSchema,
16739
+ full: PressureAvgsSchema.nullable()
16740
+ });
16741
+ var SystemResourceSnapshotSchema = object({
16742
+ cpu: CpuBreakdownSchema,
16743
+ memory: MemoryInfoSchema,
16744
+ gpu: MetricsGpuInfoSchema.nullable(),
16745
+ network: NetworkIoSnapshotSchema,
16746
+ disk: DiskIoSnapshotSchema,
16747
+ pressure: object({
16748
+ cpu: PressureInfoSchema.nullable(),
16749
+ memory: PressureInfoSchema.nullable(),
16750
+ io: PressureInfoSchema.nullable()
16140
16751
  }),
16141
- /** Max action buttons (0 = none). */
16142
- actions: number().int().nonnegative(),
16143
- levels: array(TargetKindLevelSchema),
16144
- format: array(NotificationFormatSchema),
16145
- clickUrl: boolean(),
16146
- sound: boolean(),
16147
- ttl: boolean(),
16148
- bodyMaxLen: number().int().positive()
16752
+ process: ProcessResourceInfoSchema,
16753
+ cpuTemperature: number().nullable(),
16754
+ timestampMs: number()
16149
16755
  });
16150
- /**
16151
- * `configSchema` is a `ConfigUISchema` tree passed through to the admin
16152
- * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
16153
- * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`)
16154
- * the union is large and not meant for runtime validation here; the exported
16155
- * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
16156
- */
16157
- var ConfigSchemaPassthrough$1 = unknown();
16158
- var TargetKindSchema = object({
16159
- kind: string(),
16160
- label: string(),
16161
- icon: string(),
16162
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
16163
- addonId: string(),
16164
- configSchema: ConfigSchemaPassthrough$1,
16165
- supportsDiscovery: boolean(),
16166
- caps: TargetKindCapsSchema
16756
+ var DiskSpaceInfoSchema = object({
16757
+ path: string(),
16758
+ totalBytes: number(),
16759
+ usedBytes: number(),
16760
+ availableBytes: number(),
16761
+ percent: number()
16167
16762
  });
16168
- /**
16169
- * A persisted target. `config` holds secrets; providers REDACT secret fields
16170
- * (return a presence marker only) when serving `listTargets` — never
16171
- * round-trip a stored secret to the UI.
16172
- */
16173
- var TargetSchema = object({
16174
- id: string(),
16175
- name: string(),
16176
- kind: string(),
16763
+ var PidResourceStatsSchema = object({
16764
+ pid: number(),
16765
+ cpu: number(),
16766
+ memory: number(),
16767
+ /**
16768
+ * Private (anonymous) resident bytes — the per-process V8 heap + native
16769
+ * allocations NOT shared with other processes (Linux RssAnon). This is the
16770
+ * "real" per-runner cost; summing it across runners is meaningful, unlike
16771
+ * `memory` (RSS), which double-counts the shared mmap'd framework code.
16772
+ * Undefined where /proc is unavailable (e.g. macOS).
16773
+ */
16774
+ privateBytes: number().optional(),
16775
+ /**
16776
+ * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
16777
+ * code shared copy-on-write across runners. Undefined on macOS.
16778
+ */
16779
+ sharedBytes: number().optional()
16780
+ });
16781
+ var AddonInstanceSchema = object({
16177
16782
  addonId: string(),
16178
- enabled: boolean(),
16179
- config: record(string(), unknown())
16783
+ nodeId: string(),
16784
+ role: _enum(["hub", "worker"]),
16785
+ pid: number(),
16786
+ state: _enum([
16787
+ "starting",
16788
+ "running",
16789
+ "stopping",
16790
+ "stopped",
16791
+ "crashed"
16792
+ ]),
16793
+ uptimeSec: number()
16180
16794
  });
16181
- /** A discovery-surfaced candidate (config is partial + non-secret). */
16182
- var DiscoveredTargetSchema = object({
16183
- kind: string(),
16184
- suggestedName: string(),
16185
- config: record(string(), unknown())
16795
+ var NodeProcessSchema = object({
16796
+ pid: number(),
16797
+ ppid: number(),
16798
+ pgid: number(),
16799
+ classification: _enum([
16800
+ "root",
16801
+ "managed",
16802
+ "system",
16803
+ "ghost"
16804
+ ]),
16805
+ /** `$process` addon binding when `managed`, else null. */
16806
+ addonId: string().nullable(),
16807
+ /** Kernel-reported nodeId when the process is a known agent/worker. */
16808
+ nodeId: string().nullable(),
16809
+ /** Truncated command line. */
16810
+ command: string(),
16811
+ cpuPercent: number(),
16812
+ memoryRssBytes: number(),
16813
+ /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
16814
+ uptimeSec: number(),
16815
+ /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
16816
+ orphaned: boolean()
16186
16817
  });
16187
- /** The degrade engine's report — what was resolved / dropped / degraded. */
16188
- var RenderedAsSchema = object({
16189
- level: string(),
16190
- format: NotificationFormatSchema,
16191
- attachmentsSent: number().int().nonnegative(),
16192
- actionsSent: number().int().nonnegative(),
16193
- truncated: boolean(),
16194
- dropped: array(string())
16818
+ var KillProcessInputSchema = object({
16819
+ pid: number(),
16820
+ /** Force = SIGKILL. Default is SIGTERM. */
16821
+ force: boolean().optional()
16195
16822
  });
16196
- var SendResultSchema = object({
16823
+ var KillProcessResultSchema = object({
16824
+ success: boolean(),
16825
+ reason: string().optional(),
16826
+ signal: _enum(["SIGTERM", "SIGKILL"]).optional()
16827
+ });
16828
+ var DumpHeapSnapshotInputSchema = object({
16829
+ /** The addon whose runner should dump a heap snapshot. */
16830
+ addonId: string() });
16831
+ var DumpHeapSnapshotResultSchema = object({
16197
16832
  success: boolean(),
16833
+ /** Path of the written .heapsnapshot inside the runner's container/host. */
16834
+ path: string().optional(),
16835
+ /** Process pid that was signalled. */
16836
+ pid: number().optional(),
16837
+ reason: string().optional()
16838
+ });
16839
+ var SystemMetricsSchema = object({
16840
+ cpuPercent: number(),
16841
+ memoryPercent: number(),
16842
+ memoryUsedMB: number(),
16843
+ memoryTotalMB: number(),
16844
+ diskPercent: number().optional(),
16845
+ temperature: number().optional(),
16846
+ gpuPercent: number().optional(),
16847
+ gpuMemoryPercent: number().optional()
16848
+ });
16849
+ 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, {
16850
+ kind: "mutation",
16851
+ auth: "admin"
16852
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
16853
+ kind: "mutation",
16854
+ auth: "admin"
16855
+ });
16856
+ method(object({
16857
+ sourceUrl: string(),
16858
+ metadata: ModelConvertMetadataSchema,
16859
+ targets: array(ConvertTargetSchema).min(1).readonly(),
16860
+ calibrationRef: string().optional(),
16861
+ sessionId: string().optional()
16862
+ }), ConvertResultSchema, {
16863
+ kind: "mutation",
16864
+ auth: "admin",
16865
+ timeoutMs: 6e5
16866
+ });
16867
+ method(object({
16868
+ nodeId: string(),
16869
+ modelId: string(),
16870
+ format: _enum(MODEL_FORMATS),
16871
+ entry: ModelCatalogEntrySchema
16872
+ }), object({
16873
+ ok: boolean(),
16874
+ /** sha256 of the staged tarball (empty for a hub-local no-op). */
16875
+ sha256: string(),
16876
+ bytes: number(),
16877
+ /** The target node's modelsDir the artifact landed in. */
16878
+ path: string()
16879
+ }), {
16880
+ kind: "mutation",
16881
+ auth: "admin"
16882
+ });
16883
+ /**
16884
+ * `mqtt-broker` — broker-registry cap.
16885
+ *
16886
+ * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
16887
+ * MQTT brokers (external + optionally an embedded `aedes`-backed one)
16888
+ * and (b) the connection details a consumer addon needs to spin up
16889
+ * its OWN `mqtt.js` client.
16890
+ *
16891
+ * Why: pub/sub routing over the system event-bus loses fidelity
16892
+ * (callback shape, QoS guarantees, will/retain semantics) and adds
16893
+ * refcount bookkeeping that addons would rather own themselves. The
16894
+ * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
16895
+ * features anyway — give it the connection config, get out of the way.
16896
+ *
16897
+ * Consumer flow:
16898
+ * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
16899
+ * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
16900
+ * client.subscribe('zigbee2mqtt/+')
16901
+ *
16902
+ * Collection mode: multiple brokers (e.g. one local mosquitto + one
16903
+ * cloud bridge). The "embedded" entry (when present) is just another
16904
+ * broker in the registry — its lifecycle is owned by the addon that
16905
+ * spawned it.
16906
+ */
16907
+ var BrokerKindSchema = _enum(["external", "embedded"]);
16908
+ /**
16909
+ * Broker live-probe status.
16910
+ *
16911
+ * - `connected` — last probe completed a clean CONNACK
16912
+ * - `disconnected` — no probe has run yet (cold cache)
16913
+ * - `auth-failed` — CONNACK refused with auth error (RC 4 / 5)
16914
+ * - `unreachable` — TCP connect timed out / refused
16915
+ * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
16916
+ */
16917
+ var BrokerStatusSchema$1 = _enum([
16918
+ "connected",
16919
+ "disconnected",
16920
+ "auth-failed",
16921
+ "unreachable",
16922
+ "tls-error"
16923
+ ]);
16924
+ var BrokerInfoSchema = object({
16925
+ id: string(),
16926
+ name: string(),
16927
+ url: string(),
16928
+ kind: BrokerKindSchema,
16929
+ status: BrokerStatusSchema$1,
16930
+ latencyMs: number().nullable(),
16198
16931
  error: string().optional(),
16199
- renderedAs: RenderedAsSchema.optional()
16932
+ /** Embedded brokers only: number of MQTT clients currently connected. */
16933
+ connectedClients: number().int().nonnegative().optional(),
16934
+ /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
16935
+ lastCheckedAt: number().optional()
16200
16936
  });
16201
- /** Same shape as SendResult — kept as a distinct name for the test panel. */
16202
- var TestResultSchema = SendResultSchema;
16203
- method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
16204
- kind: string(),
16205
- config: record(string(), unknown()).optional()
16206
- }), array(DiscoveredTargetSchema)), method(object({
16207
- targetId: string(),
16208
- notification: NotificationSchema
16209
- }), SendResultSchema, { kind: "mutation" }), method(object({
16210
- targetId: string(),
16211
- sample: NotificationSchema.optional()
16212
- }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
16213
- targetId: string(),
16214
- enabled: boolean()
16215
- }), _void(), { kind: "mutation" });
16216
16937
  /**
16217
- * Shared LLM generate contracts imported by BOTH `llm.cap.ts` (consumer
16218
- * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
16219
- * caps stay wire-compatible without a circular cap→cap import.
16220
- *
16221
- * Errors are a discriminated-union RESULT, never thrown: the shape survives
16222
- * every transport tier structurally, and failed calls still write usage rows.
16223
- * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
16938
+ * Connection details what a consumer needs to call
16939
+ * `mqtt.connect(url, options)`. We split URL + credentials so the
16940
+ * consumer can pass them as `mqtt.connect(url, { username, password })`
16941
+ * instead of stuffing creds into the URL (which leaks them into logs).
16224
16942
  */
16225
- var LlmUsageSchema = object({
16226
- inputTokens: number(),
16227
- outputTokens: number()
16943
+ var BrokerConnectionDetailsSchema = object({
16944
+ url: string(),
16945
+ username: string().optional(),
16946
+ password: string().optional(),
16947
+ /**
16948
+ * Suggested prefix for `clientId`. Each consumer should suffix this
16949
+ * with its own discriminator (addon id, instance id) so reconnects
16950
+ * don't kick each other off (MQTT spec: clientId must be unique per
16951
+ * broker).
16952
+ */
16953
+ clientIdPrefix: string().optional()
16228
16954
  });
16229
- var LlmErrorCodeSchema = _enum([
16230
- "timeout",
16231
- "rate-limited",
16232
- "auth",
16233
- "refusal",
16234
- "bad-request",
16235
- "unavailable",
16236
- "no-profile",
16237
- "budget-exceeded",
16238
- "adapter-error"
16239
- ]);
16240
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
16955
+ var AddBrokerInputSchema = object({
16956
+ name: string().min(1),
16957
+ url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
16958
+ username: string().optional(),
16959
+ password: string().optional(),
16960
+ clientIdPrefix: string().optional()
16961
+ });
16962
+ var AddBrokerResultSchema = object({ id: string() });
16963
+ var IdInputSchema = object({ id: string() });
16964
+ var TestResultSchema$1 = discriminatedUnion("ok", [object({
16241
16965
  ok: literal(true),
16242
- text: string(),
16243
- model: string(),
16244
- usage: LlmUsageSchema,
16245
- truncated: boolean(),
16246
16966
  latencyMs: number()
16247
16967
  }), object({
16248
16968
  ok: literal(false),
16249
- code: LlmErrorCodeSchema,
16250
- message: string(),
16251
- retryAfterMs: number().optional()
16969
+ error: string()
16252
16970
  })]);
16253
- /**
16254
- * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
16255
- * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
16256
- * notification-output.cap.ts:27-31 precedents).
16257
- */
16258
- var LlmImageSchema = object({
16259
- bytes: _instanceof(Uint8Array),
16260
- mimeType: string()
16971
+ var StartEmbeddedInputSchema = object({
16972
+ port: number().int().min(1).max(65535).default(1883),
16973
+ /** Allow anonymous connect (no username/password). Default: false. */
16974
+ allowAnonymous: boolean().default(false),
16975
+ /** Optional shared username/password for clients. */
16976
+ username: string().optional(),
16977
+ password: string().optional()
16261
16978
  });
16262
- var LlmGenerateBaseInputSchema = object({
16263
- /** Collection routing (the notification-output posture). */
16264
- addonId: string().optional(),
16265
- /** Explicit profile; else the resolution chain (spec §3). */
16266
- profileId: string().optional(),
16267
- /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
16268
- consumer: string(),
16269
- system: string().optional(),
16270
- /** v1: single-turn. `messages[]` is a v2 additive field. */
16271
- prompt: string(),
16272
- /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
16273
- jsonSchema: record(string(), unknown()).optional(),
16274
- /** Per-call override of the profile default. */
16275
- maxTokens: number().int().positive().optional(),
16276
- temperature: number().optional()
16979
+ var StartEmbeddedResultSchema = object({
16980
+ id: string(),
16981
+ url: string()
16277
16982
  });
16278
- /**
16279
- * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
16280
- * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
16281
- * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
16282
- * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
16283
- * this only through the `llm` cap's methods.
16284
- *
16285
- * One running llama-server child per node in v1 (models are RAM-heavy).
16286
- * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
16287
- * watchdog — operator decision #3).
16288
- */
16289
- var ManagedModelRefSchema = discriminatedUnion("kind", [
16290
- object({
16291
- kind: literal("catalog"),
16292
- catalogId: string()
16293
- }),
16294
- object({
16295
- kind: literal("url"),
16296
- url: string(),
16297
- sha256: string().optional()
16298
- }),
16299
- object({
16300
- kind: literal("path"),
16301
- path: string()
16302
- })
16303
- ]);
16304
- var ManagedRuntimeConfigSchema = object({
16305
- /** WHERE the runtime lives — hub or any agent. */
16306
- nodeId: string(),
16307
- /** Closed for v1; 'ollama' is a v2 candidate. */
16308
- engine: _enum(["llama-cpp"]),
16309
- model: ManagedModelRefSchema,
16310
- contextSize: number().int().default(4096),
16311
- /** 0 = CPU-only. */
16312
- gpuLayers: number().int().default(0),
16313
- /** Default: cpus-2, clamped ≥1 (resolved node-side). */
16314
- threads: number().int().optional(),
16315
- /** Concurrent slots. */
16316
- parallel: number().int().default(1),
16317
- /** Else lazy: first generate boots it. */
16318
- autoStart: boolean().default(false),
16319
- /** 0 = never; frees RAM after quiet periods. */
16320
- idleStopMinutes: number().int().default(30)
16983
+ var StatusSchema = object({
16984
+ brokerCount: number(),
16985
+ embeddedRunning: boolean()
16321
16986
  });
16322
- var LlmRuntimeStatusSchema = object({
16323
- /** Status is ALWAYS node-qualified. */
16324
- nodeId: string(),
16325
- state: _enum([
16326
- "stopped",
16327
- "downloading",
16328
- "starting",
16329
- "ready",
16330
- "crashed",
16331
- "failed"
16332
- ]),
16333
- pid: number().optional(),
16334
- port: number().optional(),
16335
- modelPath: string().optional(),
16336
- modelId: string().optional(),
16337
- downloadProgress: number().min(0).max(1).optional(),
16338
- lastError: string().optional(),
16339
- crashesInWindow: number(),
16340
- /** Child RSS (sampled best-effort). */
16341
- memoryBytes: number().optional(),
16342
- vramBytes: number().optional()
16987
+ 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);
16988
+ var NetworkEndpointSchema = object({
16989
+ url: string(),
16990
+ hostname: string(),
16991
+ port: number(),
16992
+ protocol: _enum(["http", "https"])
16343
16993
  });
16344
- var LlmNodeModelSchema = object({
16345
- file: string(),
16346
- sizeBytes: number(),
16347
- catalogId: string().optional(),
16348
- installedAt: number().optional()
16994
+ var NetworkAccessStatusSchema = object({
16995
+ connected: boolean(),
16996
+ endpoint: NetworkEndpointSchema.nullable(),
16997
+ error: string().optional()
16349
16998
  });
16350
- var LlmRuntimeDiskUsageSchema = object({
16351
- nodeId: string(),
16352
- modelsBytes: number(),
16353
- freeBytes: number().optional()
16999
+ /**
17000
+ * Optional, richer endpoint shape returned by providers that expose
17001
+ * MORE than one ingress concurrently (Tailscale Ingress with mixed
17002
+ * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
17003
+ * the originating provider config (mode + sourcePort) so the
17004
+ * orchestrator UI can label rows distinctly. Providers that expose only
17005
+ * one endpoint just omit `listEndpoints` from their provider impl.
17006
+ */
17007
+ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
17008
+ /**
17009
+ * Stable id within the provider — typically `<mode>-<sourcePort>` so
17010
+ * the orchestrator can dedupe across `listEndpoints` polls.
17011
+ */
17012
+ id: string(),
17013
+ /** Operator-facing label (mirrors `MeshEndpoint.label`). */
17014
+ label: string(),
17015
+ /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
17016
+ mode: string().optional(),
17017
+ /** Originating local port the ingress fronts (informational). */
17018
+ sourcePort: number().optional()
16354
17019
  });
16355
- method(LlmGenerateBaseInputSchema.extend({
16356
- images: array(LlmImageSchema).optional(),
16357
- runtime: ManagedRuntimeConfigSchema,
16358
- /** The managed profile's timeout, threaded by the hub provider. */
16359
- timeoutMs: number().int().positive().optional()
16360
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
16361
- kind: "mutation",
16362
- auth: "admin"
16363
- }), method(object({}), _void(), {
16364
- kind: "mutation",
16365
- auth: "admin"
16366
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
16367
- kind: "mutation",
16368
- auth: "admin"
16369
- }), method(object({ file: string() }), _void(), {
16370
- kind: "mutation",
16371
- auth: "admin"
16372
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
17020
+ method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
16373
17021
  /**
16374
- * `llm`consumer-facing LLM surface (spec §1-§3). Collection-mode: array
16375
- * methods concat-fan across providers; single-row methods route to ONE
16376
- * provider by the `addonId` in the call input (the notification-output
16377
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
16378
- * (hub-placed); the cap stays open for future providers.
17022
+ * notification-outputcanonical, capability-gated notification delivery.
17023
+ *
17024
+ * Apprise-derived model (see
17025
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
17026
+ * callers emit ONE canonical `Notification`; each provider declares a
17027
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
17028
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
17029
+ * message to what the kind supports — callers never special-case a service.
17030
+ *
17031
+ * DESIGN DECISIONS (locked):
17032
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
17033
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
17034
+ * cap. Rationale: the admin UI needs one uniform surface across the
17035
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
17036
+ * alternative would fork the UI per addon and cannot host the
17037
+ * discovery→adopt flow.
17038
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
17039
+ * the generated cap-mount auto-`concatCollection`-fans them across every
17040
+ * registered provider (notifiers addon + HA addon) so one catalog is
17041
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
17042
+ * `addonId` the generated collection router extracts from the call input.
17043
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
17044
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
17045
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
17046
+ * base64 fallback needed.
16379
17047
  *
16380
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
16381
- * `apiKey` is a password field — providers REDACT it on read and merge on
16382
- * write; a stored key NEVER round-trips to a client.
17048
+ * TODO (deferred, closed-set change separate decision): add
17049
+ * `providerKind: 'notify'` so notification providers surface on the unified
17050
+ * admin "Integrations" page.
16383
17051
  */
16384
- var LlmProfileKindSchema = _enum([
16385
- "openai-compatible",
16386
- "openai",
16387
- "anthropic",
16388
- "google",
16389
- "managed-local"
17052
+ /**
17053
+ * Zentik-derived typed-media enum — the superset across every kind. Each
17054
+ * adapter picks what it supports and the degrade engine filters the rest.
17055
+ */
17056
+ var AttachmentMediaTypeSchema = _enum([
17057
+ "image",
17058
+ "video",
17059
+ "gif",
17060
+ "audio",
17061
+ "icon"
16390
17062
  ]);
16391
- var LlmProfileSchema = object({
17063
+ /**
17064
+ * A single attachment. Exactly one of `url` (remote source, most adapters
17065
+ * prefer this) or `bytes` (inline source; required for Pushover-style
17066
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
17067
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
17068
+ */
17069
+ var AttachmentSchema = object({
17070
+ mediaType: AttachmentMediaTypeSchema,
17071
+ url: string().optional(),
17072
+ bytes: _instanceof(Uint8Array).optional(),
17073
+ mime: string().optional(),
17074
+ name: string().optional()
17075
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
17076
+ var NotificationFormatSchema = _enum([
17077
+ "text",
17078
+ "markdown",
17079
+ "html"
17080
+ ]);
17081
+ /** A single tap-through action button. */
17082
+ var NotificationActionSchema = object({
16392
17083
  id: string(),
16393
- name: string(),
16394
- kind: LlmProfileKindSchema,
16395
- /** Stamped by the provider — keeps the fanned catalog routable. */
16396
- addonId: string(),
16397
- enabled: boolean(),
16398
- /** Vendor model id, or the managed runtime's loaded model. */
16399
- model: string(),
16400
- /** Required for openai-compatible; override for cloud kinds. */
16401
- baseUrl: string().optional(),
16402
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
16403
- apiKey: string().optional(),
16404
- supportsVision: boolean(),
16405
- temperature: number().min(0).max(2).optional(),
16406
- maxTokens: number().int().positive().optional(),
16407
- timeoutMs: number().int().positive().default(6e4),
16408
- extraHeaders: record(string(), string()).optional(),
16409
- /** kind === 'managed-local' only (spec §4). */
16410
- runtime: ManagedRuntimeConfigSchema.optional()
17084
+ label: string(),
17085
+ url: string().optional()
16411
17086
  });
16412
- /** ConfigUISchema tree passed through untyped on the wire (the
16413
- * notification-output `ConfigSchemaPassthrough` precedent at
16414
- * notification-output.cap.ts:151); the exported TS type re-tightens it. */
17087
+ /**
17088
+ * The canonical notification. `body` is the only hard field (Apprise model).
17089
+ * `priority` is a 5-level ORDINAL (1=lowest 3=normal(default) 5=urgent),
17090
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
17091
+ * the adapter maps this ordinal onto its native level. `level?` is an
17092
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
17093
+ * `priority` for that one target.
17094
+ */
17095
+ var NotificationSchema = object({
17096
+ body: string(),
17097
+ title: string().optional(),
17098
+ format: NotificationFormatSchema.default("text"),
17099
+ priority: number().int().min(1).max(5).default(3),
17100
+ level: string().optional(),
17101
+ attachments: array(AttachmentSchema).optional(),
17102
+ clickUrl: string().optional(),
17103
+ actions: array(NotificationActionSchema).optional(),
17104
+ sound: string().optional(),
17105
+ ttl: number().optional(),
17106
+ tag: string().optional(),
17107
+ deviceId: number().optional(),
17108
+ eventId: string().optional(),
17109
+ metadata: record(string(), unknown()).optional()
17110
+ });
17111
+ /** One declared native severity/priority level for a kind. */
17112
+ var TargetKindLevelSchema = object({
17113
+ id: string(),
17114
+ label: string(),
17115
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
17116
+ ordinal: number().int().min(1).max(5).nullable(),
17117
+ flags: object({
17118
+ critical: boolean().optional(),
17119
+ silent: boolean().optional(),
17120
+ noPush: boolean().optional()
17121
+ }).optional(),
17122
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
17123
+ requires: array(string()).optional(),
17124
+ description: string().optional()
17125
+ });
17126
+ /** The full capability block consulted before dispatch. */
17127
+ var TargetKindCapsSchema = object({
17128
+ attachments: object({
17129
+ mediaTypes: array(AttachmentMediaTypeSchema),
17130
+ mode: _enum([
17131
+ "url",
17132
+ "bytes",
17133
+ "both"
17134
+ ]),
17135
+ max: number().int().nonnegative(),
17136
+ maxBytes: number().int().positive().optional()
17137
+ }),
17138
+ /** Max action buttons (0 = none). */
17139
+ actions: number().int().nonnegative(),
17140
+ levels: array(TargetKindLevelSchema),
17141
+ format: array(NotificationFormatSchema),
17142
+ clickUrl: boolean(),
17143
+ sound: boolean(),
17144
+ ttl: boolean(),
17145
+ bodyMaxLen: number().int().positive()
17146
+ });
17147
+ /**
17148
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
17149
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
17150
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
17151
+ * the union is large and not meant for runtime validation here; the exported
17152
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
17153
+ */
16415
17154
  var ConfigSchemaPassthrough = unknown();
16416
- var LlmProfileKindDescriptorSchema = object({
16417
- kind: LlmProfileKindSchema,
17155
+ var TargetKindSchema = object({
17156
+ kind: string(),
16418
17157
  label: string(),
16419
17158
  icon: string(),
16420
17159
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
16421
17160
  addonId: string(),
16422
- configSchema: ConfigSchemaPassthrough
16423
- });
16424
- var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
16425
- var LlmDefaultSchema = object({
16426
- selector: LlmDefaultSelectorSchema,
16427
- profileId: string()
16428
- });
16429
- /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
16430
- var LlmUsageRollupSchema = object({
16431
- day: string(),
16432
- consumer: string(),
16433
- profileId: string(),
16434
- calls: number(),
16435
- okCalls: number(),
16436
- errorCalls: number(),
16437
- inputTokens: number(),
16438
- outputTokens: number(),
16439
- avgLatencyMs: number()
17161
+ configSchema: ConfigSchemaPassthrough,
17162
+ supportsDiscovery: boolean(),
17163
+ caps: TargetKindCapsSchema
16440
17164
  });
16441
- /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
16442
- var ManagedModelCatalogEntrySchema = object({
17165
+ /**
17166
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
17167
+ * (return a presence marker only) when serving `listTargets` — never
17168
+ * round-trip a stored secret to the UI.
17169
+ */
17170
+ var TargetSchema = object({
16443
17171
  id: string(),
16444
- label: string(),
16445
- family: string(),
16446
- purpose: _enum(["text", "vision"]),
16447
- url: string(),
16448
- sha256: string(),
16449
- sizeBytes: number(),
16450
- quantization: string(),
16451
- /** Load-time guidance shown in the picker. */
16452
- minRamBytes: number(),
16453
- contextSizeDefault: number().int(),
16454
- /** Vision models: companion projector file. */
16455
- mmprojUrl: string().optional()
16456
- });
16457
- var LlmRuntimeNodeSchema = object({
16458
- nodeId: string(),
16459
- reachable: boolean(),
16460
- status: LlmRuntimeStatusSchema.optional(),
16461
- disk: LlmRuntimeDiskUsageSchema.optional(),
16462
- error: string().optional()
16463
- });
16464
- var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
16465
- var ProfileRefInputSchema = object({
17172
+ name: string(),
17173
+ kind: string(),
16466
17174
  addonId: string(),
16467
- profileId: string()
17175
+ enabled: boolean(),
17176
+ config: record(string(), unknown())
16468
17177
  });
16469
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
16470
- kind: "mutation",
16471
- auth: "admin"
16472
- }), method(ProfileRefInputSchema, _void(), {
16473
- kind: "mutation",
16474
- auth: "admin"
16475
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
16476
- kind: "mutation",
16477
- auth: "admin"
16478
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
16479
- selector: LlmDefaultSelectorSchema,
16480
- profileId: string().nullable()
16481
- }), _void(), {
16482
- kind: "mutation",
16483
- auth: "admin"
16484
- }), method(object({
16485
- since: number().optional(),
16486
- until: number().optional(),
16487
- consumer: string().optional(),
16488
- profileId: string().optional()
16489
- }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
16490
- nodeId: string(),
16491
- model: ManagedModelRefSchema
16492
- }), _void(), {
16493
- kind: "mutation",
16494
- auth: "admin"
16495
- }), method(object({
16496
- nodeId: string(),
16497
- file: string()
16498
- }), _void(), {
16499
- kind: "mutation",
16500
- auth: "admin"
16501
- }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
16502
- kind: "mutation",
16503
- auth: "admin"
16504
- }), method(ProfileRefInputSchema, _void(), {
16505
- kind: "mutation",
16506
- auth: "admin"
17178
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
17179
+ var DiscoveredTargetSchema = object({
17180
+ kind: string(),
17181
+ suggestedName: string(),
17182
+ config: record(string(), unknown())
17183
+ });
17184
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
17185
+ var RenderedAsSchema = object({
17186
+ level: string(),
17187
+ format: NotificationFormatSchema,
17188
+ attachmentsSent: number().int().nonnegative(),
17189
+ actionsSent: number().int().nonnegative(),
17190
+ truncated: boolean(),
17191
+ dropped: array(string())
17192
+ });
17193
+ var SendResultSchema = object({
17194
+ success: boolean(),
17195
+ error: string().optional(),
17196
+ renderedAs: RenderedAsSchema.optional()
16507
17197
  });
17198
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
17199
+ var TestResultSchema = SendResultSchema;
17200
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
17201
+ kind: string(),
17202
+ config: record(string(), unknown()).optional()
17203
+ }), array(DiscoveredTargetSchema)), method(object({
17204
+ targetId: string(),
17205
+ notification: NotificationSchema
17206
+ }), SendResultSchema, { kind: "mutation" }), method(object({
17207
+ targetId: string(),
17208
+ sample: NotificationSchema.optional()
17209
+ }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
17210
+ targetId: string(),
17211
+ enabled: boolean()
17212
+ }), _void(), { kind: "mutation" });
16508
17213
  /**
16509
17214
  * Zod schemas for persisted record types.
16510
17215
  *
@@ -17190,7 +17895,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17190
17895
  }), method(object({
17191
17896
  eventId: string(),
17192
17897
  kind: MediaFileKindEnum.optional()
17193
- }), array(MediaFileSchema).readonly()), method(object({ trackId: string() }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
17898
+ }), array(MediaFileSchema).readonly()), method(object({
17899
+ trackId: string(),
17900
+ kinds: array(MediaFileKindEnum).optional()
17901
+ }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
17194
17902
  deviceId: number(),
17195
17903
  timestamp: number(),
17196
17904
  frameWidth: number(),
@@ -17211,76 +17919,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17211
17919
  eventId: string(),
17212
17920
  timestamp: number()
17213
17921
  });
17214
- /**
17215
- * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
17216
- * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
17217
- * caps into per-camera event-kind descriptors.
17218
- *
17219
- * The descriptor DATA (color / iconId / labelKey / parentKind / category)
17220
- * is NOT duplicated here — every entry is derived from the single
17221
- * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
17222
- * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
17223
- * control cap means adding one line here (and a taxonomy entry); the anti-
17224
- * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
17225
- * eventful cap is missing.
17226
- */
17227
- /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
17228
- var LEGACY_ICON = {
17229
- motion: "motion",
17230
- audio: "audio",
17231
- person: "person",
17232
- vehicle: "vehicle",
17233
- animal: "animal",
17234
- package: "package",
17235
- door: "door",
17236
- pir: "pir",
17237
- smoke: "smoke",
17238
- water: "water",
17239
- button: "button",
17240
- generic: "generic",
17241
- gas: "smoke",
17242
- vibration: "generic",
17243
- tamper: "generic",
17244
- presence: "person",
17245
- lock: "generic",
17246
- siren: "generic",
17247
- switch: "generic",
17248
- doorbell: "button"
17249
- };
17250
- function legacyIcon(iconId) {
17251
- return LEGACY_ICON[iconId] ?? "generic";
17252
- }
17253
- /**
17254
- * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
17255
- * The anti-drift guard cross-checks this against the eventful caps declared
17256
- * in `packages/types/src/capabilities/*.cap.ts`.
17257
- */
17258
- var CAP_TO_KIND = {
17259
- contact: "contact",
17260
- motion: "motion-sensor",
17261
- smoke: "smoke",
17262
- flood: "flood",
17263
- gas: "gas",
17264
- "carbon-monoxide": "carbon-monoxide",
17265
- vibration: "vibration",
17266
- tamper: "tamper",
17267
- presence: "presence",
17268
- "enum-sensor": "enum-sensor",
17269
- "event-emitter": "device-event",
17270
- "lock-control": "lock",
17271
- switch: "switch",
17272
- button: "button",
17273
- doorbell: "doorbell"
17274
- };
17275
- function buildDescriptor(capName, kind) {
17276
- const t = EVENT_TAXONOMY[kind];
17277
- if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
17278
- return {
17279
- ...t,
17280
- icon: legacyIcon(t.iconId)
17281
- };
17282
- }
17283
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
17284
17922
  var CameraPipelineConfigSchema = object({
17285
17923
  engine: PipelineEngineChoiceSchema.optional(),
17286
17924
  steps: array(PipelineStepInputSchema).readonly(),
@@ -17766,6 +18404,76 @@ method(object({
17766
18404
  auth: "admin"
17767
18405
  });
17768
18406
  /**
18407
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
18408
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
18409
+ * caps into per-camera event-kind descriptors.
18410
+ *
18411
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
18412
+ * is NOT duplicated here — every entry is derived from the single
18413
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
18414
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
18415
+ * control cap means adding one line here (and a taxonomy entry); the anti-
18416
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
18417
+ * eventful cap is missing.
18418
+ */
18419
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
18420
+ var LEGACY_ICON = {
18421
+ motion: "motion",
18422
+ audio: "audio",
18423
+ person: "person",
18424
+ vehicle: "vehicle",
18425
+ animal: "animal",
18426
+ package: "package",
18427
+ door: "door",
18428
+ pir: "pir",
18429
+ smoke: "smoke",
18430
+ water: "water",
18431
+ button: "button",
18432
+ generic: "generic",
18433
+ gas: "smoke",
18434
+ vibration: "generic",
18435
+ tamper: "generic",
18436
+ presence: "person",
18437
+ lock: "generic",
18438
+ siren: "generic",
18439
+ switch: "generic",
18440
+ doorbell: "button"
18441
+ };
18442
+ function legacyIcon(iconId) {
18443
+ return LEGACY_ICON[iconId] ?? "generic";
18444
+ }
18445
+ /**
18446
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
18447
+ * The anti-drift guard cross-checks this against the eventful caps declared
18448
+ * in `packages/types/src/capabilities/*.cap.ts`.
18449
+ */
18450
+ var CAP_TO_KIND = {
18451
+ contact: "contact",
18452
+ motion: "motion-sensor",
18453
+ smoke: "smoke",
18454
+ flood: "flood",
18455
+ gas: "gas",
18456
+ "carbon-monoxide": "carbon-monoxide",
18457
+ vibration: "vibration",
18458
+ tamper: "tamper",
18459
+ presence: "presence",
18460
+ "enum-sensor": "enum-sensor",
18461
+ "event-emitter": "device-event",
18462
+ "lock-control": "lock",
18463
+ switch: "switch",
18464
+ button: "button",
18465
+ doorbell: "doorbell"
18466
+ };
18467
+ function buildDescriptor(capName, kind) {
18468
+ const t = EVENT_TAXONOMY[kind];
18469
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
18470
+ return {
18471
+ ...t,
18472
+ icon: legacyIcon(t.iconId)
18473
+ };
18474
+ }
18475
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
18476
+ /**
17769
18477
  * server-management — per-NODE singleton capability for a node's ROOT
17770
18478
  * package lifecycle (runtime-updatable node packages).
17771
18479
  *
@@ -19271,7 +19979,28 @@ var FaceInfoSchema = object({
19271
19979
  * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`). Absent when the
19272
19980
  * track produced no key frame (e.g. native/onboard source) — the UI falls
19273
19981
  * back to the inline `base64` face crop. */
19274
- keyFrameMediaKey: string().optional()
19982
+ keyFrameMediaKey: string().optional(),
19983
+ /** Winning identity-match cosine (0..1) for this face's track, when an
19984
+ * identity was auto-confirmed. Lets the UI surface WHY a face was assigned
19985
+ * (confidence badge / low-confidence audit). Absent on legacy rows and on
19986
+ * faces that were never auto-recognized. */
19987
+ bestMatchScore: number().optional(),
19988
+ /** Native-scale face short side (px) at recognition time, when the runner
19989
+ * measured it. Lets the UI flag low-resolution auto-assignments. Absent on
19990
+ * legacy rows / runners that reported no native measure. */
19991
+ nativeFaceShortSidePx: number().optional(),
19992
+ /** SUGGESTED identity for this face — a plausible-but-not-confident match that
19993
+ * MISSED auto-assignment (cosine in the suggestion band, or above threshold
19994
+ * but blocked only by the recognition size floor). Mutually exclusive with
19995
+ * `recognizedIdentityId` (a suggestion is NEVER an assignment): the face stays
19996
+ * UNASSIGNED and everything else keeps treating it as unrecognized — the UI
19997
+ * merely offers a one-tap "is this <name>?" confirm. Absent on legacy rows and
19998
+ * on faces that were auto-assigned or below the suggestion band. (2026-07-24) */
19999
+ suggestedIdentityId: string().optional(),
20000
+ /** Peak identity-match cosine (0..1) for `suggestedIdentityId`, captured at the
20001
+ * same moment as `bestMatchScore` (track peak, at close). Lets the UI rank /
20002
+ * badge suggestion confidence. Present iff `suggestedIdentityId` is. (2026-07-24) */
20003
+ suggestedMatchScore: number().optional()
19275
20004
  });
19276
20005
  var FaceFilterEnum = _enum([
19277
20006
  "unassigned",
@@ -21356,36 +22085,6 @@ Object.freeze({
21356
22085
  addonId: null,
21357
22086
  access: "view"
21358
22087
  },
21359
- "advancedNotifier.deleteRule": {
21360
- capName: "advanced-notifier",
21361
- capScope: "system",
21362
- addonId: null,
21363
- access: "delete"
21364
- },
21365
- "advancedNotifier.getHistory": {
21366
- capName: "advanced-notifier",
21367
- capScope: "system",
21368
- addonId: null,
21369
- access: "view"
21370
- },
21371
- "advancedNotifier.getRules": {
21372
- capName: "advanced-notifier",
21373
- capScope: "system",
21374
- addonId: null,
21375
- access: "view"
21376
- },
21377
- "advancedNotifier.testRule": {
21378
- capName: "advanced-notifier",
21379
- capScope: "system",
21380
- addonId: null,
21381
- access: "create"
21382
- },
21383
- "advancedNotifier.upsertRule": {
21384
- capName: "advanced-notifier",
21385
- capScope: "system",
21386
- addonId: null,
21387
- access: "create"
21388
- },
21389
22088
  "alarmPanel.arm": {
21390
22089
  capName: "alarm-panel",
21391
22090
  capScope: "device",
@@ -21608,6 +22307,12 @@ Object.freeze({
21608
22307
  addonId: null,
21609
22308
  access: "delete"
21610
22309
  },
22310
+ "backup.deleteSchedule": {
22311
+ capName: "backup",
22312
+ capScope: "system",
22313
+ addonId: null,
22314
+ access: "delete"
22315
+ },
21611
22316
  "backup.getEntries": {
21612
22317
  capName: "backup",
21613
22318
  capScope: "system",
@@ -21638,6 +22343,12 @@ Object.freeze({
21638
22343
  addonId: null,
21639
22344
  access: "view"
21640
22345
  },
22346
+ "backup.listSchedules": {
22347
+ capName: "backup",
22348
+ capScope: "system",
22349
+ addonId: null,
22350
+ access: "view"
22351
+ },
21641
22352
  "backup.previewSchedule": {
21642
22353
  capName: "backup",
21643
22354
  capScope: "system",
@@ -21662,6 +22373,12 @@ Object.freeze({
21662
22373
  addonId: null,
21663
22374
  access: "create"
21664
22375
  },
22376
+ "backup.upsertSchedule": {
22377
+ capName: "backup",
22378
+ capScope: "system",
22379
+ addonId: null,
22380
+ access: "create"
22381
+ },
21665
22382
  "battery.wakeForStream": {
21666
22383
  capName: "battery",
21667
22384
  capScope: "device",
@@ -23690,6 +24407,60 @@ Object.freeze({
23690
24407
  addonId: null,
23691
24408
  access: "create"
23692
24409
  },
24410
+ "notificationRules.createRule": {
24411
+ capName: "notification-rules",
24412
+ capScope: "system",
24413
+ addonId: null,
24414
+ access: "create"
24415
+ },
24416
+ "notificationRules.deleteRule": {
24417
+ capName: "notification-rules",
24418
+ capScope: "system",
24419
+ addonId: null,
24420
+ access: "delete"
24421
+ },
24422
+ "notificationRules.getConditionCatalog": {
24423
+ capName: "notification-rules",
24424
+ capScope: "system",
24425
+ addonId: null,
24426
+ access: "view"
24427
+ },
24428
+ "notificationRules.getHistory": {
24429
+ capName: "notification-rules",
24430
+ capScope: "system",
24431
+ addonId: null,
24432
+ access: "view"
24433
+ },
24434
+ "notificationRules.getRule": {
24435
+ capName: "notification-rules",
24436
+ capScope: "system",
24437
+ addonId: null,
24438
+ access: "view"
24439
+ },
24440
+ "notificationRules.listRules": {
24441
+ capName: "notification-rules",
24442
+ capScope: "system",
24443
+ addonId: null,
24444
+ access: "view"
24445
+ },
24446
+ "notificationRules.setRuleEnabled": {
24447
+ capName: "notification-rules",
24448
+ capScope: "system",
24449
+ addonId: null,
24450
+ access: "create"
24451
+ },
24452
+ "notificationRules.testRule": {
24453
+ capName: "notification-rules",
24454
+ capScope: "system",
24455
+ addonId: null,
24456
+ access: "create"
24457
+ },
24458
+ "notificationRules.updateRule": {
24459
+ capName: "notification-rules",
24460
+ capScope: "system",
24461
+ addonId: null,
24462
+ access: "create"
24463
+ },
23693
24464
  "notifier.cancel": {
23694
24465
  capName: "notifier",
23695
24466
  capScope: "device",
@@ -25442,6 +26213,36 @@ Object.freeze({
25442
26213
  addonId: null,
25443
26214
  access: "create"
25444
26215
  },
26216
+ "terminalSession.close": {
26217
+ capName: "terminal-session",
26218
+ capScope: "system",
26219
+ addonId: null,
26220
+ access: "create"
26221
+ },
26222
+ "terminalSession.listProfiles": {
26223
+ capName: "terminal-session",
26224
+ capScope: "system",
26225
+ addonId: null,
26226
+ access: "view"
26227
+ },
26228
+ "terminalSession.listSessions": {
26229
+ capName: "terminal-session",
26230
+ capScope: "system",
26231
+ addonId: null,
26232
+ access: "view"
26233
+ },
26234
+ "terminalSession.openSession": {
26235
+ capName: "terminal-session",
26236
+ capScope: "system",
26237
+ addonId: null,
26238
+ access: "create"
26239
+ },
26240
+ "terminalSession.resize": {
26241
+ capName: "terminal-session",
26242
+ capScope: "system",
26243
+ addonId: null,
26244
+ access: "create"
26245
+ },
25445
26246
  "toast.onToast": {
25446
26247
  capName: "toast",
25447
26248
  capScope: "system",