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