@camstack/addon-export-ha-mqtt 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.
@@ -34,7 +34,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
34
34
  var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
35
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
36
36
  //#endregion
37
- //#region ../types/dist/event-category-D4HJq7Mw.mjs
37
+ //#region ../types/dist/event-category-BLcNejAE.mjs
38
38
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
39
39
  EventCategory["SystemBoot"] = "system.boot";
40
40
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -184,9 +184,6 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
184
184
  EventCategory["RecordingSegmentWritten"] = "recording.segment.written";
185
185
  EventCategory["RecordingPolicyFallback"] = "recording.policy.fallback";
186
186
  EventCategory["RecordingRetentionCompleted"] = "recording.retention.completed";
187
- /** Runner-sampled scrub thumbnail (~1/5 s/camera). Telemetry (D8): a lost
188
- * thumb is a scrub gap the recorder's keyframe backfill covers. */
189
- EventCategory["RecordingThumbSampled"] = "recording.thumb-sampled";
190
187
  /** Export render progress (0–100). Telemetry (D8): a lost tick is a stale
191
188
  * progress bar the client reconciles via `recordingExport.getExport`. */
192
189
  EventCategory["RecordingExportProgress"] = "recording.export.progress";
@@ -6865,7 +6862,6 @@ object({ deviceId: number$1() }), object({ deviceId: number$1() }), object({
6865
6862
  patch: record(string(), unknown())
6866
6863
  }), object({ success: literal(true) });
6867
6864
  object({ deviceId: number$1() }), unknown().nullable();
6868
- /** Shorthand to define a method schema */
6869
6865
  function method(input, output, options) {
6870
6866
  return {
6871
6867
  input,
@@ -6873,6 +6869,7 @@ function method(input, output, options) {
6873
6869
  kind: options?.kind ?? "query",
6874
6870
  auth: options?.auth ?? "protected",
6875
6871
  ...options?.access !== void 0 ? { access: options.access } : {},
6872
+ ...options?.caller !== void 0 ? { caller: options.caller } : {},
6876
6873
  timeoutMs: options?.timeoutMs
6877
6874
  };
6878
6875
  }
@@ -7554,16 +7551,23 @@ var StorageLocationDeclarationSchema = object({
7554
7551
  * Which node root the seeded `<id>:default` instance is placed under on a
7555
7552
  * FRESH install:
7556
7553
  * - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
7557
- * the appData volume. Right for small/durable data (backups, logs, models).
7554
+ * the appData volume. Right for small/durable data (logs, models).
7558
7555
  * - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
7559
7556
  * env is set, else falls back to the data root. Right for bulky, hot media
7560
7557
  * (recordings, event media) that should stay off the appData disk.
7558
+ * - `'backup'` — the dedicated backup volume (`CAMSTACK_BACKUP_ROOT`, default
7559
+ * `/backups` in the image) so archives live on their own mount rather than
7560
+ * filling the appData disk. Falls back to the data root when unset.
7561
7561
  *
7562
7562
  * Only affects the seeded default's `basePath`; operators can repoint any
7563
7563
  * location afterwards, and a `defaultsTo` slot inherits its parent's root
7564
7564
  * regardless of this field. Absent (the common case) is treated as `'data'`.
7565
7565
  */
7566
- defaultRoot: _enum(["data", "media"]).optional()
7566
+ defaultRoot: _enum([
7567
+ "data",
7568
+ "media",
7569
+ "backup"
7570
+ ]).optional()
7567
7571
  });
7568
7572
  var DecoderStatsSchema = object({
7569
7573
  inputFps: number$1(),
@@ -8226,6 +8230,59 @@ for (const l of AUDIO_MACRO_LABELS) {
8226
8230
  /** The complete taxonomy dictionary, keyed by kind. */
8227
8231
  var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
8228
8232
  /**
8233
+ * Notification-Center taxonomy — the fixed vocabulary the NC rule editor
8234
+ * offers as pickers instead of free text. Derived (never hand-listed) from the
8235
+ * single `EVENT_TAXONOMY` dictionary so it stays in lockstep with every other
8236
+ * taxonomy surface (timeline, filters, event page).
8237
+ *
8238
+ * Three buckets, mapped onto the rule editor's `stringList` conditions:
8239
+ * - `videoClasses` → detection classes (person / vehicle / animal + subs)
8240
+ * for the `classes` / `classesExclude` conditions.
8241
+ * - `audioKinds` → audio-analyzer sub kinds (`audio-scream`, …) shown in
8242
+ * the same class picker, grouped under an Audio header.
8243
+ * - `labels` → sensor + control taxonomy kinds (doorbell / contact /
8244
+ * lock / …) for the `sensorKinds` device-event condition.
8245
+ *
8246
+ * Each entry carries `parentKind` so the client can group video subs under
8247
+ * their macro and sensor/control kinds under their category. This surface is
8248
+ * served ADDITIVELY on the `nc.getConditionCatalog` bridge response — no cap
8249
+ * method, no codegen — so it ships train-free with an addon deploy.
8250
+ */
8251
+ /** One selectable taxonomy value: a stable kind id + display label + parent. */
8252
+ var NcTaxonomyEntrySchema = object({
8253
+ /** Stable kind id (e.g. 'person', 'car', 'audio-scream', 'doorbell'). */
8254
+ kind: string(),
8255
+ /** English fallback label (the UI translates via the event-kind i18n key). */
8256
+ label: string(),
8257
+ /** Macro/category parent for grouping ('car' → 'vehicle'); null for a top. */
8258
+ parentKind: string().nullable()
8259
+ });
8260
+ object({
8261
+ videoClasses: array(NcTaxonomyEntrySchema),
8262
+ audioKinds: array(NcTaxonomyEntrySchema),
8263
+ labels: array(NcTaxonomyEntrySchema)
8264
+ });
8265
+ function toEntry(kind, label, parentKind) {
8266
+ return {
8267
+ kind,
8268
+ label,
8269
+ parentKind
8270
+ };
8271
+ }
8272
+ /**
8273
+ * Build the NC taxonomy from `EVENT_TAXONOMY`. Insertion order is preserved
8274
+ * (macros before their subs), which the client relies on for stable grouping.
8275
+ */
8276
+ function buildNcTaxonomy() {
8277
+ const all = Object.values(EVENT_TAXONOMY);
8278
+ return {
8279
+ videoClasses: all.filter((e) => e.category === "detection").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8280
+ audioKinds: all.filter((e) => e.category === "audio" && e.level === "sub").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8281
+ labels: all.filter((e) => e.category === "sensor" || e.category === "control").map((e) => toEntry(e.kind, e.label, e.parentKind))
8282
+ };
8283
+ }
8284
+ Object.freeze(buildNcTaxonomy());
8285
+ /**
8229
8286
  * Error types for the safe expression engine. Two distinct classes so callers
8230
8287
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
8231
8288
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -8861,6 +8918,644 @@ var AccessoryKind = {
8861
8918
  AccessoryKind.Siren, AccessoryKind.Floodlight, AccessoryKind.Spotlight, AccessoryKind.PirSensor, AccessoryKind.Chime, AccessoryKind.Autotrack, AccessoryKind.Nightvision, AccessoryKind.PrivacyMask;
8862
8919
  DeviceFeature.BatteryOperated;
8863
8920
  /**
8921
+ * Shared geometry vocabulary for on-frame shape caps — privacy-mask,
8922
+ * motion-zones, and the detection zones/lines editor all speak this one
8923
+ * language so a single drawing-plane editor and the providers stay
8924
+ * decoupled from each cap's storage.
8925
+ *
8926
+ * All coordinates are normalized 0..1 of the camera frame (top-left
8927
+ * origin). Each cap composes the SUBSET of shape kinds it supports and
8928
+ * advertises it via `supportedShapes` in its `getOptions`.
8929
+ */
8930
+ /** A normalized 0..1 point (top-left origin). */
8931
+ var MaskPointSchema = object({
8932
+ x: number$1(),
8933
+ y: number$1()
8934
+ });
8935
+ /** Axis-aligned rectangle (normalized 0..1). */
8936
+ var MaskRectShapeSchema = object({
8937
+ kind: literal("rect"),
8938
+ x: number$1(),
8939
+ y: number$1(),
8940
+ width: number$1(),
8941
+ height: number$1()
8942
+ });
8943
+ /** Free polygon — an ordered list of normalized vertices (≥3). */
8944
+ var MaskPolygonShapeSchema = object({
8945
+ kind: literal("polygon"),
8946
+ points: array(MaskPointSchema)
8947
+ });
8948
+ /** Boolean cell grid — row-major, length === gridWidth*gridHeight. */
8949
+ var MaskGridShapeSchema = object({
8950
+ kind: literal("grid"),
8951
+ gridWidth: number$1(),
8952
+ gridHeight: number$1(),
8953
+ cells: array(boolean())
8954
+ });
8955
+ discriminatedUnion("kind", [
8956
+ MaskRectShapeSchema,
8957
+ MaskPolygonShapeSchema,
8958
+ MaskGridShapeSchema,
8959
+ object({
8960
+ kind: literal("line"),
8961
+ points: array(MaskPointSchema)
8962
+ })
8963
+ ]);
8964
+ /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
8965
+ var MaskShapeKindSchema = _enum([
8966
+ "rect",
8967
+ "polygon",
8968
+ "grid",
8969
+ "line"
8970
+ ]);
8971
+ /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
8972
+ var MaskPolygonVerticesSchema = object({
8973
+ min: number$1(),
8974
+ max: number$1()
8975
+ });
8976
+ /** Grid dimensions when a cap supports 'grid'. */
8977
+ var MaskGridDimsSchema = object({
8978
+ width: number$1(),
8979
+ height: number$1()
8980
+ });
8981
+ /**
8982
+ * notification-rules — the Notification Center rule surface (P1 core).
8983
+ *
8984
+ * Spec: `docs/superpowers/specs/2026-07-22-notification-center-requirements.md`
8985
+ * (operator decisions D-1/D-2/D-3 are binding):
8986
+ *
8987
+ * - D-2: rule EVALUATION lives in `addon-post-analysis` (the
8988
+ * `notification-center` module), hooked on the durable persistence
8989
+ * moments (object-event insert, TrackCloser.closeExpired) with a
8990
+ * persisted outbox + retry — never the lossy telemetry bus (D8).
8991
+ * - D-3: urgency belongs to the RULE. `delivery: 'immediate'` fires on the
8992
+ * FIRST persisted detection matching the conditions (per-track dedup,
8993
+ * `maxPerTrack` fixed at 1 — see {@link NC_MAX_PER_TRACK_IMMEDIATE});
8994
+ * `delivery: 'track-end'` evaluates the finalized track record at close.
8995
+ * - DISPATCH stays behind `notification-output` (rules reference targets
8996
+ * by id; per-backend params are a passthrough blob capped by the
8997
+ * target kind's own caps/degrade engine).
8998
+ *
8999
+ * P1 scope: admin-authored rules only (`createdBy` stamped from the
9000
+ * server-injected caller identity — the first `caller: 'required'`
9001
+ * adopter). The P1 condition subset is: devices, classes(+exclude),
9002
+ * minConfidence, admin zones (any/all + exclude), weekly schedule
9003
+ * windows, and the optional label/identity/plate matchers. User rules,
9004
+ * private zones, per-recipient fan-out and the wider condition table are
9005
+ * P2+ (see spec §7).
9006
+ *
9007
+ * All schemas here are the single source of truth — `NcRule` etc. are
9008
+ * `z.infer` exports; no duplicate interfaces (the advanced-notifier
9009
+ * schema/interface drift is explicitly not repeated).
9010
+ */
9011
+ /**
9012
+ * D-3: the trigger/urgency of a rule — which persistence moment evaluates it.
9013
+ * The value maps 1:1 onto the evaluated record kind:
9014
+ * - `immediate` ↔ object-event persist (lowest-latency detection burst)
9015
+ * - `track-end` ↔ TrackCloser.closeExpired (finalized track record)
9016
+ * - `device-event` ↔ SensorEventStore insert (doorbell press / sensor state
9017
+ * change of a LINKED device, one row per linked camera)
9018
+ * - `package-event` ↔ PackageDropDetector object-event insert (a `package`
9019
+ * delivery / pick-up)
9020
+ *
9021
+ * `immediate`/`track-end` carry the D-3 urgency semantics; `device-event`/
9022
+ * `package-event` are pure trigger kinds (no urgency dimension). Extending
9023
+ * this one field keeps the schema additive — a rule still declares exactly
9024
+ * one trigger.
9025
+ */
9026
+ var NcDeliverySchema = _enum([
9027
+ "immediate",
9028
+ "track-end",
9029
+ "device-event",
9030
+ "package-event"
9031
+ ]);
9032
+ /** Weekly schedule — OR of windows; absence on the rule = always active. */
9033
+ var NcScheduleSchema = object({
9034
+ windows: array(object({
9035
+ /** Days of week the window STARTS on (0 = Sunday … 6 = Saturday). */
9036
+ days: array(number$1().int().min(0).max(6)).min(1),
9037
+ startMinute: number$1().int().min(0).max(1439),
9038
+ endMinute: number$1().int().min(0).max(1439)
9039
+ })).min(1),
9040
+ /** IANA timezone; default = hub host timezone. */
9041
+ timezone: string().optional(),
9042
+ /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
9043
+ invert: boolean().optional()
9044
+ });
9045
+ /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
9046
+ var NcPlateMatcherSchema = object({
9047
+ values: array(string().min(1)).min(1),
9048
+ /** Max Levenshtein distance after normalization (uppercase alphanumeric). */
9049
+ maxDistance: number$1().int().min(0).max(3).default(1)
9050
+ });
9051
+ /**
9052
+ * Occupancy condition (DEVICE-EVENT trigger). Fires on a ZoneAnalytics
9053
+ * occupancy edge for a device — optionally narrowed to a single admin
9054
+ * `zoneId` and/or object `className`. `op` selects the edge/threshold:
9055
+ * - `became-occupied` (default) — count crossed 0 → ≥ `count`
9056
+ * - `became-free` — count crossed ≥ `count` → below it
9057
+ * - `>=` / `<=` — count is at/over or at/under `count`
9058
+ * `sustainSeconds` requires the condition hold continuously that long
9059
+ * before firing (debounces flicker; 0 = fire on the first matching edge).
9060
+ * Fail-closed: no ZoneAnalytics snapshot / missing zone / null snapshot ⇒
9061
+ * the condition never matches. Confirmed edge-state survives addon restarts
9062
+ * (declared SQLite collection, reseeded on boot).
9063
+ */
9064
+ var NcOccupancyConditionSchema = object({
9065
+ /** Admin zone id to scope the count to; absent = whole-frame occupancy. */
9066
+ zoneId: string().optional(),
9067
+ /** Object class to count; absent = any class. */
9068
+ className: string().optional(),
9069
+ op: _enum([
9070
+ "became-occupied",
9071
+ "became-free",
9072
+ ">=",
9073
+ "<="
9074
+ ]).default("became-occupied"),
9075
+ count: number$1().int().min(0).default(1),
9076
+ sustainSeconds: number$1().int().min(0).max(3600).default(15)
9077
+ });
9078
+ /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
9079
+ var NcZoneConditionSchema = object({
9080
+ ids: array(string().min(1)).min(1),
9081
+ /** Quantifier over `ids` — at least one / every one visited. */
9082
+ match: _enum(["any", "all"]).default("any")
9083
+ });
9084
+ /**
9085
+ * The P1 condition set — a flat AND of groups; absent group = pass;
9086
+ * membership lists are OR within the list (spec §2.3).
9087
+ */
9088
+ var NcConditionsSchema = object({
9089
+ /** Device scope — absent = all devices. */
9090
+ devices: array(number$1()).optional(),
9091
+ /** Detector class names (any overlap with the record's class set). */
9092
+ classes: array(string().min(1)).optional(),
9093
+ /** Veto classes — any overlap fails the rule. */
9094
+ classesExclude: array(string().min(1)).optional(),
9095
+ /** Minimum detection confidence 0–1 (fails when the record has none). */
9096
+ minConfidence: number$1().min(0).max(1).optional(),
9097
+ /** Admin zone membership over event `zones` / track `zonesVisited`. */
9098
+ zones: NcZoneConditionSchema.optional(),
9099
+ /** Veto zones — any hit fails the rule. */
9100
+ zonesExclude: array(string().min(1)).optional(),
9101
+ /**
9102
+ * Exact (case-insensitive) match on the record's collapsed `label`
9103
+ * (identity name / plate text / subclass).
9104
+ */
9105
+ labelEquals: array(string().min(1)).optional(),
9106
+ /**
9107
+ * Identity matcher. P1 boundary: matched against the record's collapsed
9108
+ * `label` (the identity display name propagated by the face pipeline) —
9109
+ * identity-ID matching rides in P2 when identity ids reach the record.
9110
+ */
9111
+ identities: array(string().min(1)).optional(),
9112
+ /** Fuzzy plate matcher against the record's `label` (plate text). */
9113
+ plates: NcPlateMatcherSchema.optional(),
9114
+ /**
9115
+ * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
9116
+ * Same P1 boundary: matched against the record's collapsed `label` (the
9117
+ * identity display name). A record with NO label passes (nothing to
9118
+ * exclude), unlike the include variant which fails on an absent label.
9119
+ */
9120
+ identitiesExclude: array(string().min(1)).optional(),
9121
+ /**
9122
+ * Minimum server-computed key-event importance in [0,1] (`Track.importance`).
9123
+ * TRACK-END only: importance is scored at track close, so it does not exist
9124
+ * at immediate / object-event evaluation time (see catalog `appliesTo`). At
9125
+ * close the value is threaded via the close-time info (the `Track` clone is
9126
+ * captured before the DB row is updated, so it would otherwise read stale).
9127
+ * Fails when the record carries no importance (never guess quality — the
9128
+ * `minConfidence` precedent). MVP cut: a single scalar threshold.
9129
+ */
9130
+ minImportance: number$1().min(0).max(1).optional(),
9131
+ /**
9132
+ * Minimum track dwell in SECONDS — `(lastSeen − firstSeen) / 1000`.
9133
+ * TRACK-END only: an `immediate` / object-event subject has no closed
9134
+ * lifespan, so a dwell condition never matches immediate delivery
9135
+ * (documented choice — the object-event record carries no `firstSeen`,
9136
+ * so dwell cannot be computed from what the subject actually carries).
9137
+ */
9138
+ minDwellSeconds: number$1().min(0).optional(),
9139
+ /**
9140
+ * Detection provenance filter. `any` (default / absent) matches every
9141
+ * source; otherwise the subject's source must equal it. Legacy records
9142
+ * with no stamped source are treated as `pipeline`. The union spans both
9143
+ * record kinds — object events carry `pipeline` | `onboard`, synthetic
9144
+ * tracks carry `sensor`.
9145
+ */
9146
+ source: _enum([
9147
+ "pipeline",
9148
+ "onboard",
9149
+ "sensor",
9150
+ "any"
9151
+ ]).optional(),
9152
+ /**
9153
+ * Minimum identity / plate MATCH confidence in [0,1] — DISTINCT from the
9154
+ * detector `minConfidence` (that gates the object-detection score; this
9155
+ * gates the recognition/OCR match score). Fails when the subject carries
9156
+ * no label-match confidence (never guess). TRACK-END only: the confidence
9157
+ * lives on the recognition result and reaches the subject at track close.
9158
+ *
9159
+ * What it measures precisely (plumbed at track close — the closer threads
9160
+ * the value into `NcTrackClosedInfo.labelConfidence`, the same seam as
9161
+ * `importance`): the BEST recognition match confidence observed for the
9162
+ * label the track carries at close — for a face, the peak cosine similarity
9163
+ * of the ASSIGNED identity (`FaceMatch.score`, reset on an identity switch);
9164
+ * for a plate, the peak OCR read score of the best-held plate
9165
+ * (`plateText.confidence`). When BOTH a face and a plate were recognized on
9166
+ * one track the higher of the two is used. A track that ended with no
9167
+ * confident identity/plate match carries no value, so the condition fails
9168
+ * closed for it (an un-recognized subject).
9169
+ */
9170
+ minLabelConfidence: number$1().min(0).max(1).optional(),
9171
+ /**
9172
+ * DEVICE-EVENT only. Raw device event-type tokens (`EventFire.eventType`,
9173
+ * e.g. a doorbell `press` / `press_long`) — matched case-insensitively
9174
+ * against the token carried on the device-event subject (extracted from the
9175
+ * event-emitter runtime slice's `lastEvent.eventType`). Fails when the
9176
+ * subject carries no token. Doorbell-pulse / passive-sensor kinds emit no
9177
+ * eventType, so gate those with {@link sensorKinds} instead.
9178
+ */
9179
+ eventTypeTokens: array(string().min(1)).optional(),
9180
+ /**
9181
+ * DEVICE-EVENT only. Sensor/control taxonomy kinds (e.g. `doorbell`,
9182
+ * `contact`, `button`, `device-event`) — matched against the persisted
9183
+ * `SensorEvent.kind` (see `sensor-event-kinds.ts`). Membership is OR.
9184
+ */
9185
+ sensorKinds: array(string().min(1)).optional(),
9186
+ /**
9187
+ * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
9188
+ * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
9189
+ * when the subject's phase does not match (a subject always carries a phase
9190
+ * on the package-event trigger).
9191
+ */
9192
+ packagePhase: _enum([
9193
+ "delivered",
9194
+ "picked-up",
9195
+ "both"
9196
+ ]).optional(),
9197
+ /**
9198
+ * PERSONAL-RULE custom zones (viewer-drawn). Inline normalized polygons
9199
+ * (MaskShape vocabulary). A record passes when its bbox overlaps ANY
9200
+ * listed polygon (ZoneEngine membership semantics). Evaluated only when
9201
+ * the subject carries a bbox; absent bbox ⇒ the condition FAILS.
9202
+ */
9203
+ customZones: array(MaskPolygonShapeSchema).optional(),
9204
+ /**
9205
+ * DEVICE-EVENT only. ZoneAnalytics occupancy edge — fires when a device's
9206
+ * (optionally zone/class-scoped) occupancy count crosses the configured
9207
+ * threshold and holds for `sustainSeconds`. Fail-closed on missing
9208
+ * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
9209
+ */
9210
+ occupancy: NcOccupancyConditionSchema.optional()
9211
+ });
9212
+ /** One delivery target: a `notification-output` Target ref + passthrough params. */
9213
+ var NcRuleTargetSchema = object({
9214
+ /** `notification-output` Target id. */
9215
+ targetId: string().min(1),
9216
+ /**
9217
+ * Per-backend passthrough. Recognized keys are mapped onto the canonical
9218
+ * Notification (`priority`, `level`, `sound`, `clickUrl`, `ttl`); the
9219
+ * degrade engine drops what the backend can't render.
9220
+ */
9221
+ params: record(string(), unknown()).optional()
9222
+ });
9223
+ /**
9224
+ * Media attachment policy (P1 still-image subset).
9225
+ * - `best` — the best AVAILABLE subject image at dispatch time (D-3).
9226
+ * - `best-matching` — the media that explains WHY the rule fired: a rule
9227
+ * matched on identities attaches the subject's `faceCrop`, one matched on
9228
+ * plates attaches the `plateCrop`; a rule with no identity/plate condition
9229
+ * (or when the specific crop is missing) degrades to `best`, then
9230
+ * `keyFrame`, then no attachment — never delaying the send. The matched
9231
+ * condition summary is frozen on the outbox row at enqueue (like the rule
9232
+ * name), so the choice never drifts from the record that fired it.
9233
+ * - `keyFrame` — the clean scene frame (no subject box).
9234
+ * - `none` — no attachment.
9235
+ */
9236
+ var NcMediaPolicySchema = object({ attach: _enum([
9237
+ "best",
9238
+ "best-matching",
9239
+ "keyFrame",
9240
+ "none"
9241
+ ]).default("best") });
9242
+ /** Throttle — cooldown survives restarts (rebuilt from the outbox on boot). */
9243
+ var NcThrottleSchema = object({
9244
+ cooldownSec: number$1().int().min(0).max(86400).default(60),
9245
+ /** `rule` = one shared cooldown; `rule-device` = per-camera cooldown. */
9246
+ scope: _enum(["rule", "rule-device"]).default("rule-device")
9247
+ });
9248
+ /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
9249
+ var NcRuleInputSchema = object({
9250
+ name: string().min(1).max(200),
9251
+ enabled: boolean().default(true),
9252
+ delivery: NcDeliverySchema,
9253
+ conditions: NcConditionsSchema.default({}),
9254
+ schedule: NcScheduleSchema.optional(),
9255
+ targets: array(NcRuleTargetSchema).min(1),
9256
+ media: NcMediaPolicySchema.default({ attach: "best" }),
9257
+ throttle: NcThrottleSchema.default({
9258
+ cooldownSec: 60,
9259
+ scope: "rule-device"
9260
+ }),
9261
+ /** `{{var}}` templating over camera/class/label/zones/confidence/time. */
9262
+ template: object({
9263
+ title: string().max(500).optional(),
9264
+ body: string().max(2e3).optional()
9265
+ }).optional(),
9266
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
9267
+ priority: number$1().int().min(1).max(5).default(3),
9268
+ /**
9269
+ * Ownership/visibility key. Absent = admin/global rule (unchanged legacy
9270
+ * behaviour, visible to all, read-only in the viewer). Present = personal
9271
+ * rule owned by this userId. Server-stamped; never trusted from a client.
9272
+ */
9273
+ ownerUserId: string().optional()
9274
+ });
9275
+ /**
9276
+ * Partial patch for `updateRule` — any subset of the input fields, plus the
9277
+ * persisted-only {@link NcRuleSchema} `disabledTargetIds` set. The latter is
9278
+ * NOT a client-authored input field (it lives on the persisted rule, not the
9279
+ * input), so it is added here explicitly to let the store's per-target opt-out
9280
+ * toggle round-trip through the shared `update` path. Viewer opt-out mutations
9281
+ * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
9282
+ * `updateRule` patch.
9283
+ */
9284
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
9285
+ /** A persisted rule. */
9286
+ var NcRuleSchema = NcRuleInputSchema.extend({
9287
+ id: string(),
9288
+ /** userId of the admin who created the rule (server-stamped caller). */
9289
+ createdBy: string(),
9290
+ createdAt: number$1(),
9291
+ updatedAt: number$1(),
9292
+ /**
9293
+ * Per-target opt-out set. A targetId here is suppressed for THIS rule at
9294
+ * send time. Only a target's OWNER may add/remove its id (server-checked
9295
+ * in `nc.setRuleTargetEnabled`). Defaults to empty.
9296
+ */
9297
+ disabledTargetIds: array(string()).default([])
9298
+ });
9299
+ var NcTestResultSchema = object({
9300
+ recordId: string(),
9301
+ recordKind: _enum([
9302
+ "object-event",
9303
+ "track",
9304
+ "device-event",
9305
+ "package-event"
9306
+ ]),
9307
+ deviceId: number$1(),
9308
+ timestamp: number$1(),
9309
+ wouldFire: boolean(),
9310
+ /** Condition id that failed (first failing group), when `wouldFire` is false. */
9311
+ failedCondition: string().optional(),
9312
+ className: string().optional(),
9313
+ label: string().optional()
9314
+ });
9315
+ var NcConditionDescriptorSchema = object({
9316
+ /** Field id inside `NcConditions` (or `'schedule'` for the rule-level group). */
9317
+ id: string(),
9318
+ group: _enum([
9319
+ "scope",
9320
+ "class",
9321
+ "zones",
9322
+ "quality",
9323
+ "label",
9324
+ "schedule",
9325
+ "device",
9326
+ "package",
9327
+ "occupancy"
9328
+ ]),
9329
+ label: string(),
9330
+ /** Editor widget the UI renders — never hardcode per-condition forms. */
9331
+ valueType: _enum([
9332
+ "deviceIdList",
9333
+ "stringList",
9334
+ "number01",
9335
+ "number",
9336
+ "sourceSelect",
9337
+ "zoneSelection",
9338
+ "zoneIdList",
9339
+ "schedule",
9340
+ "plateMatcher",
9341
+ "packagePhase",
9342
+ "polygonDraw",
9343
+ "occupancy"
9344
+ ]),
9345
+ operator: _enum([
9346
+ "in",
9347
+ "notIn",
9348
+ "anyOf",
9349
+ "allOf",
9350
+ "gte",
9351
+ "fuzzyIn",
9352
+ "withinSchedule"
9353
+ ]),
9354
+ /** Which delivery kinds the condition applies to. */
9355
+ appliesTo: array(NcDeliverySchema),
9356
+ phase: string(),
9357
+ description: string().optional()
9358
+ });
9359
+ /**
9360
+ * The delivery lifecycle status of a history row — a straight read of the
9361
+ * durable outbox row's own status (single source of truth):
9362
+ * - `pending` — enqueued, in-flight or retrying with backoff
9363
+ * - `sent` — delivered (terminal)
9364
+ * - `dead` — dead-lettered after exhausting retries / a permanent
9365
+ * backend rejection / a deleted target (terminal; carries
9366
+ * the failure `error`)
9367
+ *
9368
+ * P1 has no `suppressed-quiet-hours` / `snoozed` states — those ride the P2
9369
+ * user dimension (quiet hours / snooze) and are additive when they land.
9370
+ */
9371
+ var NcHistoryStatusSchema = _enum([
9372
+ "pending",
9373
+ "sent",
9374
+ "dead"
9375
+ ]);
9376
+ /** The evaluated record kind a history row descends from (one per trigger). */
9377
+ var NcHistoryRecordKindSchema = _enum([
9378
+ "object-event",
9379
+ "track-end",
9380
+ "device-event",
9381
+ "package-event"
9382
+ ]);
9383
+ /** Subject summary frozen on the row at fire time (survives rule/record edits). */
9384
+ var NcHistorySubjectSchema = object({
9385
+ className: string(),
9386
+ label: string().optional(),
9387
+ confidence: number$1().optional(),
9388
+ zones: array(string()),
9389
+ timestamp: number$1()
9390
+ });
9391
+ /**
9392
+ * One delivery-history row. This is a read-only VIEW over the durable
9393
+ * outbox row (single source of truth — the same row the drain loop drives;
9394
+ * NO second write path, so history can never drift from delivery state).
9395
+ * The §3.2 fields map directly: `ruleId`/`targetId`/`deviceId` are columns,
9396
+ * `eventRef` is `recordKind`+`recordId`, `timestamps` are `createdAt`
9397
+ * (fire) / `updatedAt` (last transition), `status` + `error` are the
9398
+ * lifecycle. `ruleName` + `subject` are the intent snapshot frozen at
9399
+ * enqueue. `userId?` (per-recipient history) is P2 — no user dimension in
9400
+ * P1 (admin scope only).
9401
+ */
9402
+ var NcHistoryEntrySchema = object({
9403
+ /** Outbox row id — the stable dedup id `ruleId:dedupRef:targetId`. */
9404
+ id: string(),
9405
+ ruleId: string(),
9406
+ /** Rule name frozen at fire time (outlives a later rename / delete). */
9407
+ ruleName: string(),
9408
+ /** The rule urgency/trigger that produced this delivery. */
9409
+ delivery: NcDeliverySchema,
9410
+ targetId: string(),
9411
+ deviceId: number$1(),
9412
+ recordKind: NcHistoryRecordKindSchema,
9413
+ /** Event / track ref of the evaluated record (§3.2 `eventRef`). */
9414
+ recordId: string(),
9415
+ /** Present for track-scoped deliveries (object-event / track-end). */
9416
+ trackId: string().optional(),
9417
+ status: NcHistoryStatusSchema,
9418
+ /** Delivery attempts made so far. */
9419
+ attempts: number$1().int(),
9420
+ /** Fire time (outbox enqueue). */
9421
+ createdAt: number$1(),
9422
+ /** Last transition time (terminal for sent / dead). */
9423
+ updatedAt: number$1(),
9424
+ /** Failure detail — present on a `dead` row. */
9425
+ error: string().optional(),
9426
+ subject: NcHistorySubjectSchema
9427
+ });
9428
+ /**
9429
+ * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
9430
+ * AND; absent = unbounded on that axis. `since`/`until` bound the fire time
9431
+ * (`createdAt`, epoch ms, inclusive). `limit` is clamped to
9432
+ * {@link NC_HISTORY_LIMIT_MAX}. `userId` (per-recipient filtering) is P2.
9433
+ */
9434
+ var NcHistoryFilterSchema = object({
9435
+ ruleId: string().optional(),
9436
+ deviceId: number$1().optional(),
9437
+ status: NcHistoryStatusSchema.optional(),
9438
+ since: number$1().optional(),
9439
+ until: number$1().optional(),
9440
+ limit: number$1().int().min(1).max(500).default(100)
9441
+ });
9442
+ 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 }), {
9443
+ kind: "mutation",
9444
+ auth: "admin",
9445
+ caller: "required"
9446
+ }), method(object({
9447
+ ruleId: string(),
9448
+ patch: NcRulePatchSchema
9449
+ }), object({ rule: NcRuleSchema }), {
9450
+ kind: "mutation",
9451
+ auth: "admin",
9452
+ caller: "required"
9453
+ }), method(object({ ruleId: string() }), object({ success: literal(true) }), {
9454
+ kind: "mutation",
9455
+ auth: "admin"
9456
+ }), method(object({
9457
+ ruleId: string(),
9458
+ enabled: boolean()
9459
+ }), object({ success: literal(true) }), {
9460
+ kind: "mutation",
9461
+ auth: "admin"
9462
+ }), method(object({
9463
+ rule: NcRuleInputSchema,
9464
+ lookbackMinutes: number$1().int().min(1).max(1440).default(60)
9465
+ }), object({ results: array(NcTestResultSchema) }), {
9466
+ kind: "mutation",
9467
+ auth: "admin"
9468
+ }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
9469
+ /**
9470
+ * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
9471
+ *
9472
+ * Spec: `docs/superpowers/specs/2026-07-24-nc-occupancy-timelapse-design.md`
9473
+ * §3.2/§3.3.
9474
+ *
9475
+ * Deliberately NOT a capability definition and NOT an `NcRule`:
9476
+ * - Every `NcDelivery` member is a *persisted-pipeline-record* trigger. A
9477
+ * timelapse fires on a SCHEDULE WINDOW BOUNDARY, evaluates no pipeline
9478
+ * record, and produces a video it assembled itself — so it rides no
9479
+ * delivery-enum member (the enum is frozen) and no cap method. This file is
9480
+ * a plain typed schema; it does NOT go through `npm run codegen`.
9481
+ * - It shares only the delivery leg (`notification-output.send`) and the
9482
+ * persistence/ownership patterns with the Notification Center, reusing
9483
+ * {@link NcScheduleSchema} (weekly windows, midnight-crossing, invertible)
9484
+ * and {@link NcRuleTargetSchema} (target ref + passthrough params).
9485
+ *
9486
+ * Ownership is SERVER-DERIVED. `ownerUserId` / `createdBy` / `createdAt` /
9487
+ * `updatedAt` / `id` / `lastGeneratedAt` live on the PERSISTED rule only —
9488
+ * {@link TimelapseRuleInputSchema} and {@link TimelapseRulePatchSchema} do not
9489
+ * carry them, so a forged client payload can never claim or re-own a rule
9490
+ * (Zod strips unknown keys). The store stamps them from the resolved caller.
9491
+ */
9492
+ /** `{{var}}` templating over camera/rule/time — same vocabulary as `NcRule`. */
9493
+ var TimelapseTemplateSchema = object({
9494
+ title: string().max(500).optional(),
9495
+ body: string().max(2e3).optional()
9496
+ });
9497
+ var NameField = string().min(1).max(200);
9498
+ var DeviceIdsField = array(number$1()).min(1);
9499
+ var CadenceSecField = number$1().int().min(2).max(3600);
9500
+ var FramerateField = number$1().int().min(1).max(60);
9501
+ var TargetsField = array(NcRuleTargetSchema).min(1);
9502
+ var PriorityField = number$1().int().min(1).max(5);
9503
+ /**
9504
+ * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
9505
+ * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
9506
+ * here (see the ownership note above).
9507
+ */
9508
+ var TimelapseRuleInputSchema = object({
9509
+ name: NameField,
9510
+ enabled: boolean().default(true),
9511
+ /** Cameras sampled by this rule — one scratch dir + one artifact per device. */
9512
+ deviceIds: DeviceIdsField,
9513
+ /**
9514
+ * Activation window(s). REQUIRED (unlike `NcRule`, where an absent schedule
9515
+ * means "always active"): a timelapse is defined by its window boundaries —
9516
+ * open clears the scratch, close assembles and delivers.
9517
+ */
9518
+ schedule: NcScheduleSchema,
9519
+ /** Force-snapshot cadence inside the window, seconds (predecessor parity). */
9520
+ cadenceSec: CadenceSecField.default(15),
9521
+ /** Output frames per second of the assembled mp4 (predecessor parity). */
9522
+ framerate: FramerateField.default(10),
9523
+ /** `notification-output` targets the finished video/thumbnail is sent to. */
9524
+ targets: TargetsField,
9525
+ template: TimelapseTemplateSchema.optional(),
9526
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
9527
+ priority: PriorityField.default(3)
9528
+ });
9529
+ object({
9530
+ name: NameField.optional(),
9531
+ enabled: boolean().optional(),
9532
+ deviceIds: DeviceIdsField.optional(),
9533
+ schedule: NcScheduleSchema.optional(),
9534
+ cadenceSec: CadenceSecField.optional(),
9535
+ framerate: FramerateField.optional(),
9536
+ targets: TargetsField.optional(),
9537
+ template: TimelapseTemplateSchema.nullable().optional(),
9538
+ priority: PriorityField.optional()
9539
+ });
9540
+ TimelapseRuleInputSchema.extend({
9541
+ id: string(),
9542
+ /**
9543
+ * Ownership/visibility key. Absent = admin/global rule (visible to all).
9544
+ * Present = personal rule owned by this userId. Server-stamped from the
9545
+ * resolved caller; never trusted from a client payload.
9546
+ */
9547
+ ownerUserId: string().optional(),
9548
+ /**
9549
+ * Epoch-ms of the last successful generation — the 1-hour re-generation
9550
+ * guard's durable state (predecessor parity). Absent = never generated.
9551
+ */
9552
+ lastGeneratedAt: number$1().optional(),
9553
+ /** userId of the caller who created the rule (server-stamped). */
9554
+ createdBy: string(),
9555
+ createdAt: number$1(),
9556
+ updatedAt: number$1()
9557
+ });
9558
+ /**
8864
9559
  * Generic device-level status snapshot. Auto-registered by `BaseDevice`
8865
9560
  * for every device, regardless of provider — the kernel needs a uniform
8866
9561
  * cap-keyed slice for the basic device flags every consumer expects to
@@ -10934,6 +11629,22 @@ var CameraMetricsSchema = object({
10934
11629
  ])
10935
11630
  });
10936
11631
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number$1() });
11632
+ /**
11633
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
11634
+ * within the frame, so the executor can re-cut a leaf child ROI at native
11635
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
11636
+ */
11637
+ var NativeCropRefSchema = object({
11638
+ /** Handle keying the retained native surface (node-pinned to its owner). */
11639
+ handle: FrameHandleSchema,
11640
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
11641
+ cropFrameSpace: object({
11642
+ x: number$1(),
11643
+ y: number$1(),
11644
+ w: number$1(),
11645
+ h: number$1()
11646
+ })
11647
+ });
10937
11648
  var ModelFormatSchema$1 = _enum([
10938
11649
  "onnx",
10939
11650
  "coreml",
@@ -11209,7 +11920,22 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
11209
11920
  * Omitted ⇒ the runner's default device (current single-engine
11210
11921
  * behaviour). Selects WHICH device pool of the node runs the call.
11211
11922
  */
11212
- deviceKey: string().optional()
11923
+ deviceKey: string().optional(),
11924
+ /**
11925
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
11926
+ * when the parent crop was resolved from the frame's retained NATIVE
11927
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
11928
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
11929
+ * resolution from that surface — the SAME quality path faces already
11930
+ * had — instead of the downscaled parent tile. `handle` keys the native
11931
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
11932
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
11933
+ * the executor's crop-normalized child ROI back into frame-normalized
11934
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
11935
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
11936
+ * (today's behaviour on the fallback path).
11937
+ */
11938
+ nativeCropRef: NativeCropRefSchema.optional()
11213
11939
  }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
11214
11940
  engine: PipelineEngineChoiceSchema.optional(),
11215
11941
  steps: array(PipelineStepInputSchema).min(1),
@@ -11425,7 +12151,11 @@ var DetailResultSchema = object({
11425
12151
  bbox: NativeCropBboxSchema.optional(),
11426
12152
  embedding: string().optional(),
11427
12153
  label: string().optional(),
11428
- alignedCropJpeg: string().optional()
12154
+ alignedCropJpeg: string().optional(),
12155
+ /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
12156
+ * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
12157
+ * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
12158
+ nativeFaceShortSidePx: number$1().optional()
11429
12159
  });
11430
12160
  /**
11431
12161
  * Per-camera tunable ranges + defaults. Single source of truth used
@@ -11439,6 +12169,12 @@ var motionCooldownMsField = {
11439
12169
  default: 3e4,
11440
12170
  step: 500
11441
12171
  };
12172
+ var maxSessionHoldMsField = {
12173
+ min: 0,
12174
+ max: 6e5,
12175
+ default: 12e4,
12176
+ step: 5e3
12177
+ };
11442
12178
  var motionFpsField = {
11443
12179
  min: 1,
11444
12180
  max: 30,
@@ -11586,6 +12322,19 @@ var RunnerCameraConfigSchema = object({
11586
12322
  "on-motion"
11587
12323
  ]).default("always-on"),
11588
12324
  motionCooldownMs: number$1().min(motionCooldownMsField.min).default(motionCooldownMsField.default),
12325
+ /**
12326
+ * Orchestrator-side on-motion session-hold cap (ms). While an on-motion
12327
+ * detection session is active and ≥1 confirmed non-stationary track is
12328
+ * still live, the orchestrator keeps the session open past
12329
+ * `motionCooldownMs` (a slowly-moving subject can stop re-triggering the
12330
+ * camera's VMD yet is still being tracked frame-to-frame) — up to this many
12331
+ * ms since the session opened, after which it closes regardless. `0`
12332
+ * disables the hold (legacy cooldown-only teardown). Not consumed by the
12333
+ * runner itself — carried here so it shares the per-camera device-settings
12334
+ * surface with `motionCooldownMs`; the orchestrator reads it off the
12335
+ * resolved `CameraDetectionConfig`.
12336
+ */
12337
+ maxSessionHoldMs: number$1().min(maxSessionHoldMsField.min).max(maxSessionHoldMsField.max).optional(),
11589
12338
  motionFps: number$1().min(motionFpsField.min).max(motionFpsField.max).default(motionFpsField.default),
11590
12339
  detectionFps: number$1().min(detectionFpsField.min).max(detectionFpsField.max).default(detectionFpsField.default),
11591
12340
  motionStreamId: string(),
@@ -11675,7 +12424,7 @@ var RunnerCameraConfigSchema = object({
11675
12424
  */
11676
12425
  inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
11677
12426
  });
11678
- 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;
12427
+ 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;
11679
12428
  /**
11680
12429
  * Runtime load summary returned by `getLocalLoad`. Used by the orchestrator's
11681
12430
  * load-balancing levels (L2 capacity-based, L3 hardware-aware) to decide
@@ -11786,71 +12535,10 @@ DeviceType.Light, DeviceType.Siren, DeviceType.Switch, method(object({
11786
12535
  lastChangedAt: number$1()
11787
12536
  });
11788
12537
  /**
11789
- * Shared geometry vocabulary for on-frame shape caps privacy-mask,
11790
- * motion-zones, and the detection zones/lines editor all speak this one
11791
- * language so a single drawing-plane editor and the providers stay
11792
- * decoupled from each cap's storage.
11793
- *
11794
- * All coordinates are normalized 0..1 of the camera frame (top-left
11795
- * origin). Each cap composes the SUBSET of shape kinds it supports and
11796
- * advertises it via `supportedShapes` in its `getOptions`.
11797
- */
11798
- /** A normalized 0..1 point (top-left origin). */
11799
- var MaskPointSchema = object({
11800
- x: number$1(),
11801
- y: number$1()
11802
- });
11803
- /** Axis-aligned rectangle (normalized 0..1). */
11804
- var MaskRectShapeSchema = object({
11805
- kind: literal("rect"),
11806
- x: number$1(),
11807
- y: number$1(),
11808
- width: number$1(),
11809
- height: number$1()
11810
- });
11811
- /** Free polygon — an ordered list of normalized vertices (≥3). */
11812
- var MaskPolygonShapeSchema = object({
11813
- kind: literal("polygon"),
11814
- points: array(MaskPointSchema)
11815
- });
11816
- /** Boolean cell grid — row-major, length === gridWidth*gridHeight. */
11817
- var MaskGridShapeSchema = object({
11818
- kind: literal("grid"),
11819
- gridWidth: number$1(),
11820
- gridHeight: number$1(),
11821
- cells: array(boolean())
11822
- });
11823
- discriminatedUnion("kind", [
11824
- MaskRectShapeSchema,
11825
- MaskPolygonShapeSchema,
11826
- MaskGridShapeSchema,
11827
- object({
11828
- kind: literal("line"),
11829
- points: array(MaskPointSchema)
11830
- })
11831
- ]);
11832
- /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
11833
- var MaskShapeKindSchema = _enum([
11834
- "rect",
11835
- "polygon",
11836
- "grid",
11837
- "line"
11838
- ]);
11839
- /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
11840
- var MaskPolygonVerticesSchema = object({
11841
- min: number$1(),
11842
- max: number$1()
11843
- });
11844
- /** Grid dimensions when a cap supports 'grid'. */
11845
- var MaskGridDimsSchema = object({
11846
- width: number$1(),
11847
- height: number$1()
11848
- });
11849
- /**
11850
- * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
11851
- * on-camera motion-detection mask is a single `grid` region (a row-major
11852
- * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
11853
- * a region keeps one drawing-plane model across all geometry caps.
12538
+ * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
12539
+ * on-camera motion-detection mask is a single `grid` region (a row-major
12540
+ * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
12541
+ * a region keeps one drawing-plane model across all geometry caps.
11854
12542
  */
11855
12543
  /** A motion-zone region — exactly one boolean cell grid today. */
11856
12544
  var MotionZoneRegionSchema = object({
@@ -13529,94 +14217,6 @@ var EnrichedWidgetMetadataSchema = WidgetMetadataSchema.extend({
13529
14217
  bundleUrl: string()
13530
14218
  });
13531
14219
  method(_void(), array(EnrichedWidgetMetadataSchema).readonly());
13532
- var NotificationRuleConditionsSchema = object({
13533
- deviceIds: array(number$1()).readonly().optional(),
13534
- classNames: array(string()).readonly().optional(),
13535
- zoneIds: array(string()).readonly().optional(),
13536
- minConfidence: number$1().optional(),
13537
- source: _enum([
13538
- "pipeline",
13539
- "onboard",
13540
- "any"
13541
- ]).optional(),
13542
- schedule: object({
13543
- days: array(number$1()).readonly(),
13544
- startHour: number$1(),
13545
- endHour: number$1()
13546
- }).optional(),
13547
- cooldownSeconds: number$1().optional(),
13548
- minDwellSeconds: number$1().optional(),
13549
- /** Match against `event.data.eventType` token (e.g. `'press_long'`). When non-empty, only events
13550
- * carrying a matching `data.eventType` string pass this condition. Rules without this field are
13551
- * unaffected (back-compat). Distinct from `rule.eventTypes` which holds EventCategory strings. */
13552
- eventTypeTokens: array(string()).readonly().optional(),
13553
- /** Match detections whose CLIP image embedding is semantically similar to this free-text
13554
- * description. Requires the embedding-encoder cap to have pre-warmed the text vector.
13555
- * `minSimilarity` is the cosine similarity threshold in [0, 1]. */
13556
- clipDescription: object({
13557
- text: string().min(1),
13558
- minSimilarity: number$1().min(0).max(1)
13559
- }).optional(),
13560
- /** Match events whose recognized-entity label (face identity name or plate
13561
- * vehicle name, propagated onto `event.data.label`) is one of these values.
13562
- * Empty/absent → unaffected (back-compat). Enables "notify me when <named
13563
- * vehicle/person> is seen". */
13564
- labels: array(string()).readonly().optional()
13565
- });
13566
- var NotificationRuleTemplateSchema = object({
13567
- title: string(),
13568
- body: string(),
13569
- imageMode: _enum([
13570
- "crop",
13571
- "annotated",
13572
- "full",
13573
- "none"
13574
- ])
13575
- });
13576
- var NotificationRuleSchema = object({
13577
- id: string(),
13578
- name: string(),
13579
- enabled: boolean(),
13580
- eventTypes: array(string()).readonly(),
13581
- conditions: NotificationRuleConditionsSchema,
13582
- outputs: array(string()).readonly(),
13583
- template: NotificationRuleTemplateSchema.optional(),
13584
- priority: _enum([
13585
- "low",
13586
- "normal",
13587
- "high",
13588
- "critical"
13589
- ])
13590
- });
13591
- var NotificationTestResultSchema = object({
13592
- ruleId: string(),
13593
- eventId: string(),
13594
- timestamp: number$1(),
13595
- wouldFire: boolean(),
13596
- reason: string().optional()
13597
- });
13598
- var NotificationHistoryEntrySchema = object({
13599
- id: string(),
13600
- ruleId: string(),
13601
- ruleName: string(),
13602
- eventId: string(),
13603
- timestamp: number$1(),
13604
- outputs: array(string()).readonly(),
13605
- success: boolean(),
13606
- error: string().optional(),
13607
- deviceId: number$1().optional()
13608
- });
13609
- var NotificationHistoryFilterSchema = object({
13610
- ruleId: string().optional(),
13611
- deviceId: number$1().optional(),
13612
- from: number$1().optional(),
13613
- to: number$1().optional(),
13614
- limit: number$1().optional()
13615
- });
13616
- 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({
13617
- ruleId: string(),
13618
- lookbackMinutes: number$1()
13619
- }), object({ results: array(NotificationTestResultSchema).readonly() }), { kind: "mutation" }), method(object({ filter: NotificationHistoryFilterSchema.optional() }), object({ entries: array(NotificationHistoryEntrySchema).readonly() }));
13620
14220
  /**
13621
14221
  * Alerts capability — collection-based internal alert system.
13622
14222
  *
@@ -13803,88 +14403,54 @@ method(object({
13803
14403
  password: string()
13804
14404
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
13805
14405
  /**
13806
- * `login-method` collection cap through which auth addons contribute
13807
- * their pre-auth login surfaces to the login page. This is the SINGLE,
13808
- * generic mechanism that supersedes the dead `auth.listProviders` reader:
13809
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
13810
- * `login-method` provider and the PUBLIC `auth.listLoginMethods`
13811
- * procedure aggregates them for the unauthenticated login page.
13812
- *
13813
- * A contribution is a discriminated union on `kind`:
13814
- *
13815
- * - `redirect` — a declarative button. The login page renders a generic
13816
- * button that navigates to `startUrl` (an addon-owned HTTP route).
13817
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
13818
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
13819
- * login page needs NO change.
13820
- *
13821
- * - `widget` — a Module-Federation widget the login page mounts (via
13822
- * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
13823
- * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
13824
- * mechanism kept for future use; no shipped addon uses it on the login
13825
- * page (the passkey ceremony below runs natively in the shell instead).
13826
- *
13827
- * - `passkey` — a declarative WebAuthn ceremony the shell renders
13828
- * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
13829
- * a remotely-loaded bundle). Carries the addon's effective `rpId` /
13830
- * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
13831
- * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
13832
- * fetching any remote code pre-auth. Contribution stays unconditional —
13833
- * enrollment state is never leaked pre-auth; visibility is a shell
13834
- * decision.
13835
- *
13836
- * Every contribution carries a `stage`:
13837
- * - `primary` — shown on the first credentials screen (OIDC /
13838
- * magic-link buttons; a future usernameless passkey).
13839
- * - `second-factor` — shown AFTER the password leg, gated on the
13840
- * returned `factors` (passkey-as-2FA today).
13841
- *
13842
- * `mount: skip` — the cap is read server-side by the core auth router
13843
- * (`registry.getCollection('login-method')`), never mounted as its own
13844
- * tRPC router.
14406
+ * A live terminal session hosted by the provider addon. Output and input do
14407
+ * NOT flow through the capability they use the addon data plane
14408
+ * (`GET /addon/terminal/<id>/out` SSE, `POST /addon/terminal/<id>/in`) because
14409
+ * terminal output must be ordered and lossless. The event bus is telemetry and
14410
+ * may drop chunks ([D8]), and a dropped chunk desynchronises the vt parser
14411
+ * permanently until a full repaint. The capability owns only lifecycle.
13845
14412
  */
13846
- /** When a login method renders in the two-phase login flow. */
13847
- var LoginStageEnum = _enum(["primary", "second-factor"]);
13848
- /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
13849
- var LoginMethodContributionSchema = discriminatedUnion("kind", [
13850
- object({
13851
- kind: literal("redirect"),
13852
- /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
13853
- id: string(),
13854
- /** Operator-facing button label. */
13855
- label: string(),
13856
- /** lucide-react icon name. */
13857
- icon: string().optional(),
13858
- /** Addon-owned HTTP route the button navigates to (GET). */
13859
- startUrl: string(),
13860
- stage: LoginStageEnum
13861
- }),
13862
- object({
13863
- kind: literal("widget"),
13864
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
13865
- id: string(),
13866
- /** Owning addon id — drives the public bundle URL + the MF namespace. */
13867
- addonId: string(),
13868
- /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
13869
- bundle: string(),
13870
- /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
13871
- remote: WidgetRemoteSchema,
13872
- stage: LoginStageEnum
13873
- }),
13874
- object({
13875
- kind: literal("passkey"),
13876
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
13877
- id: string(),
13878
- /** Operator-facing button label. */
13879
- label: string(),
13880
- stage: LoginStageEnum,
13881
- /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
13882
- rpId: string(),
13883
- /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
13884
- origin: string().nullable()
13885
- })
13886
- ]);
13887
- method(_void(), array(LoginMethodContributionSchema).readonly());
14413
+ var TerminalSessionInfoSchema = object({
14414
+ /** Opaque session id minted by the provider on `openSession`. */
14415
+ sessionId: string(),
14416
+ /** The pre-declared profile this session runs (never a free-form command). */
14417
+ profileId: string(),
14418
+ /** Human-readable profile label for the UI session list. */
14419
+ label: string(),
14420
+ cols: number$1().int().positive(),
14421
+ rows: number$1().int().positive(),
14422
+ /** ms-epoch the session's pty was spawned. */
14423
+ startedAt: number$1()
14424
+ });
14425
+ /**
14426
+ * A profile the operator may open — a pre-declared, allowlisted program
14427
+ * (`monitor` → `btm`). The capability accepts only these ids; a free-form
14428
+ * command string would be remote code execution as the server's user, so it is
14429
+ * deliberately not part of the contract.
14430
+ */
14431
+ var TerminalProfileInfoSchema = object({
14432
+ profileId: string(),
14433
+ label: string(),
14434
+ description: string().optional()
14435
+ });
14436
+ method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(TerminalSessionInfoSchema).readonly(), { auth: "admin" }), method(object({
14437
+ profileId: string(),
14438
+ cols: number$1().int().positive(),
14439
+ rows: number$1().int().positive()
14440
+ }), TerminalSessionInfoSchema, {
14441
+ kind: "mutation",
14442
+ auth: "admin"
14443
+ }), method(object({
14444
+ sessionId: string(),
14445
+ cols: number$1().int().positive(),
14446
+ rows: number$1().int().positive()
14447
+ }), _void(), {
14448
+ kind: "mutation",
14449
+ auth: "admin"
14450
+ }), method(object({ sessionId: string() }), _void(), {
14451
+ kind: "mutation",
14452
+ auth: "admin"
14453
+ });
13888
14454
  /**
13889
14455
  * Orchestrator-side destination metadata. The orchestrator computes
13890
14456
  * `id = <addonId>:<subId>` from its provider lookup so consumers
@@ -13986,11 +14552,53 @@ var LocationStatSchema = object({
13986
14552
  fileCount: number$1(),
13987
14553
  present: boolean()
13988
14554
  });
14555
+ /**
14556
+ * A backup schedule — the N:M "entry" that binds one cron cadence to a
14557
+ * SET of destination locations. Supersedes the per-location cron on
14558
+ * `BackupDestinationPolicy`: an operator creates a schedule, picks the
14559
+ * `backups` locations it should write to, and the orchestrator fans a
14560
+ * single archive out to all of them when the cron fires.
14561
+ *
14562
+ * `retentionCount` is per-schedule (D-decision 2026-07-28): every
14563
+ * location targeted by this schedule keeps this many archives from
14564
+ * this schedule's runs.
14565
+ *
14566
+ * `dataSources` optionally narrows which top-level state locations
14567
+ * (db, addons, tls, …) are archived; omitted = the orchestrator's
14568
+ * default full set.
14569
+ */
14570
+ var BackupScheduleSchema = object({
14571
+ /** Stable id. Generated by the orchestrator on first upsert if absent. */
14572
+ id: string(),
14573
+ /** Operator-facing display name. */
14574
+ label: string(),
14575
+ /** 5-field POSIX cron. Empty = disabled cadence (kept for editing). */
14576
+ cron: string(),
14577
+ /** Master on/off toggle for the whole schedule. */
14578
+ enabled: boolean(),
14579
+ /** `backups`-location ids this schedule writes to (fan-out set). */
14580
+ locationIds: array(string()).readonly(),
14581
+ /** Archives kept per targeted location for this schedule. */
14582
+ retentionCount: number$1().int().min(1).max(1e3),
14583
+ /** Optional subset of source locations to include; omitted = all. */
14584
+ dataSources: array(string()).readonly().optional(),
14585
+ /** ms-epoch of last successful run. */
14586
+ lastRunAt: number$1().optional(),
14587
+ /** ms-epoch of next computed firing (read-only, filled on list). */
14588
+ nextRunAt: number$1().optional()
14589
+ });
13989
14590
  method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }), method(object({
13990
14591
  /** Subset of registered `backup-destination` addon ids to write to. */
13991
14592
  destinations: array(string()).optional(),
13992
14593
  locations: array(string()).optional(),
13993
- label: string().optional()
14594
+ label: string().optional(),
14595
+ /**
14596
+ * Per-run retention override applied to every targeted
14597
+ * destination. Used by schedule-driven runs (per-entry
14598
+ * retention). Omitted = each destination's own policy
14599
+ * retention (manual runs).
14600
+ */
14601
+ retentionCount: number$1().int().min(1).max(1e3).optional()
13994
14602
  }).optional(), array(BackupEntrySchema).readonly(), {
13995
14603
  kind: "mutation",
13996
14604
  auth: "admin"
@@ -14039,7 +14647,21 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
14039
14647
  ok: boolean(),
14040
14648
  error: string().optional(),
14041
14649
  nextRuns: array(number$1()).readonly()
14042
- }));
14650
+ })), method(_void(), array(BackupScheduleSchema).readonly(), { auth: "admin" }), method(object({
14651
+ id: string().optional(),
14652
+ label: string(),
14653
+ cron: string(),
14654
+ enabled: boolean(),
14655
+ locationIds: array(string()).readonly(),
14656
+ retentionCount: number$1().int().min(1).max(1e3),
14657
+ dataSources: array(string()).readonly().optional()
14658
+ }), BackupScheduleSchema, {
14659
+ kind: "mutation",
14660
+ auth: "admin"
14661
+ }), method(object({ id: string() }), _void(), {
14662
+ kind: "mutation",
14663
+ auth: "admin"
14664
+ });
14043
14665
  /**
14044
14666
  * `broker` — unified pub/sub broker registry, system-scoped collection.
14045
14667
  *
@@ -15254,851 +15876,934 @@ method(_void(), array(string()).readonly(), { auth: "admin" }), method(object({
15254
15876
  kind: "mutation",
15255
15877
  auth: "admin"
15256
15878
  });
15257
- var LogLevelSchema = _enum([
15258
- "debug",
15259
- "info",
15260
- "warn",
15261
- "error"
15262
- ]);
15263
- var LogEntrySchema = object({
15264
- timestamp: date(),
15265
- level: LogLevelSchema,
15266
- scope: array(string()),
15267
- message: string(),
15268
- meta: record(string(), unknown()).optional(),
15269
- tags: record(string(), string()).optional()
15879
+ /**
15880
+ * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
15881
+ * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15882
+ * caps stay wire-compatible without a circular cap→cap import.
15883
+ *
15884
+ * Errors are a discriminated-union RESULT, never thrown: the shape survives
15885
+ * every transport tier structurally, and failed calls still write usage rows.
15886
+ * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
15887
+ */
15888
+ var LlmUsageSchema = object({
15889
+ inputTokens: number$1(),
15890
+ outputTokens: number$1()
15270
15891
  });
15271
- method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
15272
- scope: array(string()).optional(),
15273
- level: LogLevelSchema.optional(),
15274
- since: date().optional(),
15275
- until: date().optional(),
15276
- limit: number$1().optional(),
15277
- tags: record(string(), string()).optional()
15278
- }), array(LogEntrySchema).readonly());
15279
- var CpuBreakdownSchema = object({
15280
- total: number$1(),
15281
- user: number$1(),
15282
- system: number$1(),
15283
- irq: number$1(),
15284
- nice: number$1(),
15285
- loadAvg: tuple([
15286
- number$1(),
15287
- number$1(),
15288
- number$1()
15289
- ]),
15290
- cores: number$1()
15291
- });
15292
- var MemoryInfoSchema = object({
15293
- percent: number$1(),
15294
- totalBytes: number$1(),
15295
- usedBytes: number$1(),
15296
- availableBytes: number$1(),
15297
- swapUsedBytes: number$1(),
15298
- swapTotalBytes: number$1()
15299
- });
15300
- var DiskIoSnapshotSchema = object({
15301
- readBytes: number$1(),
15302
- writeBytes: number$1(),
15303
- readOps: number$1(),
15304
- writeOps: number$1(),
15305
- timestampMs: number$1()
15306
- });
15307
- var NetworkIoSnapshotSchema = object({
15308
- rxBytes: number$1(),
15309
- txBytes: number$1(),
15310
- rxPackets: number$1(),
15311
- txPackets: number$1(),
15312
- rxErrors: number$1(),
15313
- txErrors: number$1(),
15314
- timestampMs: number$1()
15315
- });
15316
- var MetricsGpuInfoSchema = object({
15317
- utilization: number$1(),
15892
+ var LlmErrorCodeSchema = _enum([
15893
+ "timeout",
15894
+ "rate-limited",
15895
+ "auth",
15896
+ "refusal",
15897
+ "bad-request",
15898
+ "unavailable",
15899
+ "no-profile",
15900
+ "budget-exceeded",
15901
+ "adapter-error"
15902
+ ]);
15903
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
15904
+ ok: literal(true),
15905
+ text: string(),
15318
15906
  model: string(),
15319
- memoryUsedBytes: number$1(),
15320
- memoryTotalBytes: number$1(),
15321
- temperature: number$1().nullable()
15322
- });
15323
- var ProcessResourceInfoSchema = object({
15324
- openFds: number$1(),
15325
- threadCount: number$1(),
15326
- activeHandles: number$1(),
15327
- activeRequests: number$1()
15328
- });
15329
- var PressureAvgsSchema = object({
15330
- avg10: number$1(),
15331
- avg60: number$1(),
15332
- avg300: number$1()
15907
+ usage: LlmUsageSchema,
15908
+ truncated: boolean(),
15909
+ latencyMs: number$1()
15910
+ }), object({
15911
+ ok: literal(false),
15912
+ code: LlmErrorCodeSchema,
15913
+ message: string(),
15914
+ retryAfterMs: number$1().optional()
15915
+ })]);
15916
+ /**
15917
+ * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
15918
+ * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
15919
+ * notification-output.cap.ts:27-31 precedents).
15920
+ */
15921
+ var LlmImageSchema = object({
15922
+ bytes: _instanceof(Uint8Array),
15923
+ mimeType: string()
15333
15924
  });
15334
- var PressureInfoSchema = object({
15335
- some: PressureAvgsSchema,
15336
- full: PressureAvgsSchema.nullable()
15925
+ var LlmGenerateBaseInputSchema = object({
15926
+ /** Collection routing (the notification-output posture). */
15927
+ addonId: string().optional(),
15928
+ /** Explicit profile; else the resolution chain (spec §3). */
15929
+ profileId: string().optional(),
15930
+ /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
15931
+ consumer: string(),
15932
+ system: string().optional(),
15933
+ /** v1: single-turn. `messages[]` is a v2 additive field. */
15934
+ prompt: string(),
15935
+ /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
15936
+ jsonSchema: record(string(), unknown()).optional(),
15937
+ /** Per-call override of the profile default. */
15938
+ maxTokens: number$1().int().positive().optional(),
15939
+ temperature: number$1().optional()
15337
15940
  });
15338
- var SystemResourceSnapshotSchema = object({
15339
- cpu: CpuBreakdownSchema,
15340
- memory: MemoryInfoSchema,
15341
- gpu: MetricsGpuInfoSchema.nullable(),
15342
- network: NetworkIoSnapshotSchema,
15343
- disk: DiskIoSnapshotSchema,
15344
- pressure: object({
15345
- cpu: PressureInfoSchema.nullable(),
15346
- memory: PressureInfoSchema.nullable(),
15347
- io: PressureInfoSchema.nullable()
15941
+ /**
15942
+ * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
15943
+ * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
15944
+ * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
15945
+ * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
15946
+ * this only through the `llm` cap's methods.
15947
+ *
15948
+ * One running llama-server child per node in v1 (models are RAM-heavy).
15949
+ * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
15950
+ * watchdog — operator decision #3).
15951
+ */
15952
+ var ManagedModelRefSchema = discriminatedUnion("kind", [
15953
+ object({
15954
+ kind: literal("catalog"),
15955
+ catalogId: string()
15348
15956
  }),
15349
- process: ProcessResourceInfoSchema,
15350
- cpuTemperature: number$1().nullable(),
15351
- timestampMs: number$1()
15352
- });
15353
- var DiskSpaceInfoSchema = object({
15354
- path: string(),
15355
- totalBytes: number$1(),
15356
- usedBytes: number$1(),
15357
- availableBytes: number$1(),
15358
- percent: number$1()
15359
- });
15360
- var PidResourceStatsSchema = object({
15361
- pid: number$1(),
15362
- cpu: number$1(),
15363
- memory: number$1(),
15364
- /**
15365
- * Private (anonymous) resident bytes — the per-process V8 heap + native
15366
- * allocations NOT shared with other processes (Linux RssAnon). This is the
15367
- * "real" per-runner cost; summing it across runners is meaningful, unlike
15368
- * `memory` (RSS), which double-counts the shared mmap'd framework code.
15369
- * Undefined where /proc is unavailable (e.g. macOS).
15370
- */
15371
- privateBytes: number$1().optional(),
15372
- /**
15373
- * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
15374
- * code shared copy-on-write across runners. Undefined on macOS.
15375
- */
15376
- sharedBytes: number$1().optional()
15957
+ object({
15958
+ kind: literal("url"),
15959
+ url: string(),
15960
+ sha256: string().optional()
15961
+ }),
15962
+ object({
15963
+ kind: literal("path"),
15964
+ path: string()
15965
+ })
15966
+ ]);
15967
+ var ManagedRuntimeConfigSchema = object({
15968
+ /** WHERE the runtime lives — hub or any agent. */
15969
+ nodeId: string(),
15970
+ /** Closed for v1; 'ollama' is a v2 candidate. */
15971
+ engine: _enum(["llama-cpp"]),
15972
+ model: ManagedModelRefSchema,
15973
+ contextSize: number$1().int().default(4096),
15974
+ /** 0 = CPU-only. */
15975
+ gpuLayers: number$1().int().default(0),
15976
+ /** Default: cpus-2, clamped ≥1 (resolved node-side). */
15977
+ threads: number$1().int().optional(),
15978
+ /** Concurrent slots. */
15979
+ parallel: number$1().int().default(1),
15980
+ /** Else lazy: first generate boots it. */
15981
+ autoStart: boolean().default(false),
15982
+ /** 0 = never; frees RAM after quiet periods. */
15983
+ idleStopMinutes: number$1().int().default(30)
15377
15984
  });
15378
- var AddonInstanceSchema = object({
15379
- addonId: string(),
15985
+ var LlmRuntimeStatusSchema = object({
15986
+ /** Status is ALWAYS node-qualified. */
15380
15987
  nodeId: string(),
15381
- role: _enum(["hub", "worker"]),
15382
- pid: number$1(),
15383
15988
  state: _enum([
15384
- "starting",
15385
- "running",
15386
- "stopping",
15387
15989
  "stopped",
15388
- "crashed"
15389
- ]),
15390
- uptimeSec: number$1()
15391
- });
15392
- var NodeProcessSchema = object({
15393
- pid: number$1(),
15394
- ppid: number$1(),
15395
- pgid: number$1(),
15396
- classification: _enum([
15397
- "root",
15398
- "managed",
15399
- "system",
15400
- "ghost"
15990
+ "downloading",
15991
+ "starting",
15992
+ "ready",
15993
+ "crashed",
15994
+ "failed"
15401
15995
  ]),
15402
- /** `$process` addon binding when `managed`, else null. */
15403
- addonId: string().nullable(),
15404
- /** Kernel-reported nodeId when the process is a known agent/worker. */
15405
- nodeId: string().nullable(),
15406
- /** Truncated command line. */
15407
- command: string(),
15408
- cpuPercent: number$1(),
15409
- memoryRssBytes: number$1(),
15410
- /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
15411
- uptimeSec: number$1(),
15412
- /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
15413
- orphaned: boolean()
15996
+ pid: number$1().optional(),
15997
+ port: number$1().optional(),
15998
+ modelPath: string().optional(),
15999
+ modelId: string().optional(),
16000
+ downloadProgress: number$1().min(0).max(1).optional(),
16001
+ lastError: string().optional(),
16002
+ crashesInWindow: number$1(),
16003
+ /** Child RSS (sampled best-effort). */
16004
+ memoryBytes: number$1().optional(),
16005
+ vramBytes: number$1().optional()
15414
16006
  });
15415
- var KillProcessInputSchema = object({
15416
- pid: number$1(),
15417
- /** Force = SIGKILL. Default is SIGTERM. */
15418
- force: boolean().optional()
16007
+ var LlmNodeModelSchema = object({
16008
+ file: string(),
16009
+ sizeBytes: number$1(),
16010
+ catalogId: string().optional(),
16011
+ installedAt: number$1().optional()
15419
16012
  });
15420
- var KillProcessResultSchema = object({
15421
- success: boolean(),
15422
- reason: string().optional(),
15423
- signal: _enum(["SIGTERM", "SIGKILL"]).optional()
16013
+ var LlmRuntimeDiskUsageSchema = object({
16014
+ nodeId: string(),
16015
+ modelsBytes: number$1(),
16016
+ freeBytes: number$1().optional()
15424
16017
  });
15425
- var DumpHeapSnapshotInputSchema = object({
15426
- /** The addon whose runner should dump a heap snapshot. */
15427
- addonId: string() });
15428
- var DumpHeapSnapshotResultSchema = object({
15429
- success: boolean(),
15430
- /** Path of the written .heapsnapshot inside the runner's container/host. */
15431
- path: string().optional(),
15432
- /** Process pid that was signalled. */
15433
- pid: number$1().optional(),
15434
- reason: string().optional()
15435
- });
15436
- var SystemMetricsSchema = object({
15437
- cpuPercent: number$1(),
15438
- memoryPercent: number$1(),
15439
- memoryUsedMB: number$1(),
15440
- memoryTotalMB: number$1(),
15441
- diskPercent: number$1().optional(),
15442
- temperature: number$1().optional(),
15443
- gpuPercent: number$1().optional(),
15444
- gpuMemoryPercent: number$1().optional()
15445
- });
15446
- method(_void(), SystemResourceSnapshotSchema), method(_void(), SystemResourceSnapshotSchema.nullable()), method(_void(), SystemMetricsSchema), method(object({ dirPath: string() }), DiskSpaceInfoSchema), method(_void(), MetricsGpuInfoSchema.nullable()), method(_void(), number$1().nullable()), method(object({ pids: array(number$1()) }), array(PidResourceStatsSchema)), method(_void(), array(AddonInstanceSchema).readonly()), method(object({ addonId: string() }), PidResourceStatsSchema.nullable()), method(_void(), array(NodeProcessSchema).readonly()), method(KillProcessInputSchema, KillProcessResultSchema, {
16018
+ method(LlmGenerateBaseInputSchema.extend({
16019
+ images: array(LlmImageSchema).optional(),
16020
+ runtime: ManagedRuntimeConfigSchema,
16021
+ /** The managed profile's timeout, threaded by the hub provider. */
16022
+ timeoutMs: number$1().int().positive().optional()
16023
+ }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
15447
16024
  kind: "mutation",
15448
16025
  auth: "admin"
15449
- }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
16026
+ }), method(object({}), _void(), {
15450
16027
  kind: "mutation",
15451
16028
  auth: "admin"
15452
- });
15453
- method(object({
15454
- sourceUrl: string(),
15455
- metadata: ModelConvertMetadataSchema,
15456
- targets: array(ConvertTargetSchema).min(1).readonly(),
15457
- calibrationRef: string().optional(),
15458
- sessionId: string().optional()
15459
- }), ConvertResultSchema, {
16029
+ }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
15460
16030
  kind: "mutation",
15461
- auth: "admin",
15462
- timeoutMs: 6e5
15463
- });
15464
- method(object({
15465
- nodeId: string(),
15466
- modelId: string(),
15467
- format: _enum(MODEL_FORMATS),
15468
- entry: ModelCatalogEntrySchema
15469
- }), object({
15470
- ok: boolean(),
15471
- /** sha256 of the staged tarball (empty for a hub-local no-op). */
15472
- sha256: string(),
15473
- bytes: number$1(),
15474
- /** The target node's modelsDir the artifact landed in. */
15475
- path: string()
15476
- }), {
16031
+ auth: "admin"
16032
+ }), method(object({ file: string() }), _void(), {
15477
16033
  kind: "mutation",
15478
16034
  auth: "admin"
15479
- });
15480
- /**
15481
- * `mqtt-broker` — broker-registry cap.
15482
- *
15483
- * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
15484
- * MQTT brokers (external + optionally an embedded `aedes`-backed one)
15485
- * and (b) the connection details a consumer addon needs to spin up
15486
- * its OWN `mqtt.js` client.
15487
- *
15488
- * Why: pub/sub routing over the system event-bus loses fidelity
15489
- * (callback shape, QoS guarantees, will/retain semantics) and adds
15490
- * refcount bookkeeping that addons would rather own themselves. The
15491
- * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
15492
- * features anyway — give it the connection config, get out of the way.
15493
- *
15494
- * Consumer flow:
15495
- * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
15496
- * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
15497
- * client.subscribe('zigbee2mqtt/+')
15498
- *
15499
- * Collection mode: multiple brokers (e.g. one local mosquitto + one
15500
- * cloud bridge). The "embedded" entry (when present) is just another
15501
- * broker in the registry — its lifecycle is owned by the addon that
15502
- * spawned it.
15503
- */
15504
- var BrokerKindSchema = _enum(["external", "embedded"]);
16035
+ }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
15505
16036
  /**
15506
- * Broker live-probe status.
16037
+ * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
16038
+ * methods concat-fan across providers; single-row methods route to ONE
16039
+ * provider by the `addonId` in the call input (the notification-output
16040
+ * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
16041
+ * (hub-placed); the cap stays open for future providers.
15507
16042
  *
15508
- * - `connected` last probe completed a clean CONNACK
15509
- * - `disconnected` — no probe has run yet (cold cache)
15510
- * - `auth-failed` CONNACK refused with auth error (RC 4 / 5)
15511
- * - `unreachable` — TCP connect timed out / refused
15512
- * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
16043
+ * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
16044
+ * `apiKey` is a password field providers REDACT it on read and merge on
16045
+ * write; a stored key NEVER round-trips to a client.
15513
16046
  */
15514
- var BrokerStatusSchema$1 = _enum([
15515
- "connected",
15516
- "disconnected",
15517
- "auth-failed",
15518
- "unreachable",
15519
- "tls-error"
16047
+ var LlmProfileKindSchema = _enum([
16048
+ "openai-compatible",
16049
+ "openai",
16050
+ "anthropic",
16051
+ "google",
16052
+ "managed-local"
15520
16053
  ]);
15521
- var BrokerInfoSchema = object({
16054
+ var LlmProfileSchema = object({
15522
16055
  id: string(),
15523
16056
  name: string(),
15524
- url: string(),
15525
- kind: BrokerKindSchema,
15526
- status: BrokerStatusSchema$1,
15527
- latencyMs: number$1().nullable(),
15528
- error: string().optional(),
15529
- /** Embedded brokers only: number of MQTT clients currently connected. */
15530
- connectedClients: number$1().int().nonnegative().optional(),
15531
- /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
15532
- lastCheckedAt: number$1().optional()
16057
+ kind: LlmProfileKindSchema,
16058
+ /** Stamped by the provider — keeps the fanned catalog routable. */
16059
+ addonId: string(),
16060
+ enabled: boolean(),
16061
+ /** Vendor model id, or the managed runtime's loaded model. */
16062
+ model: string(),
16063
+ /** Required for openai-compatible; override for cloud kinds. */
16064
+ baseUrl: string().optional(),
16065
+ /** ConfigUISchema type:'password' — never round-trips (spec §5). */
16066
+ apiKey: string().optional(),
16067
+ supportsVision: boolean(),
16068
+ temperature: number$1().min(0).max(2).optional(),
16069
+ maxTokens: number$1().int().positive().optional(),
16070
+ timeoutMs: number$1().int().positive().default(6e4),
16071
+ extraHeaders: record(string(), string()).optional(),
16072
+ /** kind === 'managed-local' only (spec §4). */
16073
+ runtime: ManagedRuntimeConfigSchema.optional()
15533
16074
  });
15534
- /**
15535
- * Connection details — what a consumer needs to call
15536
- * `mqtt.connect(url, options)`. We split URL + credentials so the
15537
- * consumer can pass them as `mqtt.connect(url, { username, password })`
15538
- * instead of stuffing creds into the URL (which leaks them into logs).
15539
- */
15540
- var BrokerConnectionDetailsSchema = object({
15541
- url: string(),
15542
- username: string().optional(),
15543
- password: string().optional(),
15544
- /**
15545
- * Suggested prefix for `clientId`. Each consumer should suffix this
15546
- * with its own discriminator (addon id, instance id) so reconnects
15547
- * don't kick each other off (MQTT spec: clientId must be unique per
15548
- * broker).
15549
- */
15550
- clientIdPrefix: string().optional()
16075
+ /** ConfigUISchema tree passed through untyped on the wire (the
16076
+ * notification-output `ConfigSchemaPassthrough` precedent at
16077
+ * notification-output.cap.ts:151); the exported TS type re-tightens it. */
16078
+ var ConfigSchemaPassthrough$1 = unknown();
16079
+ var LlmProfileKindDescriptorSchema = object({
16080
+ kind: LlmProfileKindSchema,
16081
+ label: string(),
16082
+ icon: string(),
16083
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
16084
+ addonId: string(),
16085
+ configSchema: ConfigSchemaPassthrough$1
15551
16086
  });
15552
- var AddBrokerInputSchema = object({
15553
- name: string().min(1),
15554
- url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
15555
- username: string().optional(),
15556
- password: string().optional(),
15557
- clientIdPrefix: string().optional()
16087
+ var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
16088
+ var LlmDefaultSchema = object({
16089
+ selector: LlmDefaultSelectorSchema,
16090
+ profileId: string()
15558
16091
  });
15559
- var AddBrokerResultSchema = object({ id: string() });
15560
- var IdInputSchema = object({ id: string() });
15561
- var TestResultSchema$1 = discriminatedUnion("ok", [object({
15562
- ok: literal(true),
15563
- latencyMs: number$1()
15564
- }), object({
15565
- ok: literal(false),
15566
- error: string()
15567
- })]);
15568
- var StartEmbeddedInputSchema = object({
15569
- port: number$1().int().min(1).max(65535).default(1883),
15570
- /** Allow anonymous connect (no username/password). Default: false. */
15571
- allowAnonymous: boolean().default(false),
15572
- /** Optional shared username/password for clients. */
15573
- username: string().optional(),
15574
- password: string().optional()
16092
+ /** Server-side rollup row getUsage never dumps raw call rows (spec §6). */
16093
+ var LlmUsageRollupSchema = object({
16094
+ day: string(),
16095
+ consumer: string(),
16096
+ profileId: string(),
16097
+ calls: number$1(),
16098
+ okCalls: number$1(),
16099
+ errorCalls: number$1(),
16100
+ inputTokens: number$1(),
16101
+ outputTokens: number$1(),
16102
+ avgLatencyMs: number$1()
15575
16103
  });
15576
- var StartEmbeddedResultSchema = object({
16104
+ /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
16105
+ var ManagedModelCatalogEntrySchema = object({
15577
16106
  id: string(),
15578
- url: string()
15579
- });
15580
- var StatusSchema = object({
15581
- brokerCount: number$1(),
15582
- embeddedRunning: boolean()
15583
- });
15584
- 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);
15585
- var NetworkEndpointSchema = object({
16107
+ label: string(),
16108
+ family: string(),
16109
+ purpose: _enum(["text", "vision"]),
15586
16110
  url: string(),
15587
- hostname: string(),
15588
- port: number$1(),
15589
- protocol: _enum(["http", "https"])
16111
+ sha256: string(),
16112
+ sizeBytes: number$1(),
16113
+ quantization: string(),
16114
+ /** Load-time guidance shown in the picker. */
16115
+ minRamBytes: number$1(),
16116
+ contextSizeDefault: number$1().int(),
16117
+ /** Vision models: companion projector file. */
16118
+ mmprojUrl: string().optional()
15590
16119
  });
15591
- var NetworkAccessStatusSchema = object({
15592
- connected: boolean(),
15593
- endpoint: NetworkEndpointSchema.nullable(),
16120
+ var LlmRuntimeNodeSchema = object({
16121
+ nodeId: string(),
16122
+ reachable: boolean(),
16123
+ status: LlmRuntimeStatusSchema.optional(),
16124
+ disk: LlmRuntimeDiskUsageSchema.optional(),
15594
16125
  error: string().optional()
15595
16126
  });
15596
- /**
15597
- * Optional, richer endpoint shape returned by providers that expose
15598
- * MORE than one ingress concurrently (Tailscale Ingress with mixed
15599
- * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
15600
- * the originating provider config (mode + sourcePort) so the
15601
- * orchestrator UI can label rows distinctly. Providers that expose only
15602
- * one endpoint just omit `listEndpoints` from their provider impl.
15603
- */
15604
- var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
15605
- /**
15606
- * Stable id within the provider — typically `<mode>-<sourcePort>` so
15607
- * the orchestrator can dedupe across `listEndpoints` polls.
15608
- */
15609
- id: string(),
15610
- /** Operator-facing label (mirrors `MeshEndpoint.label`). */
15611
- label: string(),
15612
- /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
15613
- mode: string().optional(),
15614
- /** Originating local port the ingress fronts (informational). */
15615
- sourcePort: number$1().optional()
16127
+ var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
16128
+ var ProfileRefInputSchema = object({
16129
+ addonId: string(),
16130
+ profileId: string()
15616
16131
  });
15617
- method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
15618
- /**
15619
- * notification-output — canonical, capability-gated notification delivery.
15620
- *
15621
- * Apprise-derived model (see
15622
- * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
15623
- * callers emit ONE canonical `Notification`; each provider declares a
15624
- * per-kind capability descriptor (`TargetKind`), and the pure degrade
15625
- * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
15626
- * message to what the kind supports — callers never special-case a service.
15627
- *
15628
- * DESIGN DECISIONS (locked):
15629
- * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
15630
- * `setTargetEnabled`), each provider persisting via the `settings-store`
15631
- * cap. Rationale: the admin UI needs one uniform surface across the
15632
- * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
15633
- * alternative would fork the UI per addon and cannot host the
15634
- * discovery→adopt flow.
15635
- * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
15636
- * the generated cap-mount auto-`concatCollection`-fans them across every
15637
- * registered provider (notifiers addon + HA addon) so one catalog is
15638
- * routable. `send` / `testTarget` / CRUD route to ONE provider by the
15639
- * `addonId` the generated collection router extracts from the call input.
15640
- * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
15641
- * transformer) + UDS MsgPack both round-trip typed arrays — already used by
15642
- * `storage` / `storage-provider` / `recording` caps over the same path. No
15643
- * base64 fallback needed.
15644
- *
15645
- * TODO (deferred, closed-set change — separate decision): add
15646
- * `providerKind: 'notify'` so notification providers surface on the unified
15647
- * admin "Integrations" page.
15648
- */
15649
- /**
15650
- * Zentik-derived typed-media enum — the superset across every kind. Each
15651
- * adapter picks what it supports and the degrade engine filters the rest.
15652
- */
15653
- var AttachmentMediaTypeSchema = _enum([
15654
- "image",
15655
- "video",
15656
- "gif",
15657
- "audio",
15658
- "icon"
16132
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
16133
+ kind: "mutation",
16134
+ auth: "admin"
16135
+ }), method(ProfileRefInputSchema, _void(), {
16136
+ kind: "mutation",
16137
+ auth: "admin"
16138
+ }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
16139
+ kind: "mutation",
16140
+ auth: "admin"
16141
+ }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
16142
+ selector: LlmDefaultSelectorSchema,
16143
+ profileId: string().nullable()
16144
+ }), _void(), {
16145
+ kind: "mutation",
16146
+ auth: "admin"
16147
+ }), method(object({
16148
+ since: number$1().optional(),
16149
+ until: number$1().optional(),
16150
+ consumer: string().optional(),
16151
+ profileId: string().optional()
16152
+ }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
16153
+ nodeId: string(),
16154
+ model: ManagedModelRefSchema
16155
+ }), _void(), {
16156
+ kind: "mutation",
16157
+ auth: "admin"
16158
+ }), method(object({
16159
+ nodeId: string(),
16160
+ file: string()
16161
+ }), _void(), {
16162
+ kind: "mutation",
16163
+ auth: "admin"
16164
+ }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
16165
+ kind: "mutation",
16166
+ auth: "admin"
16167
+ }), method(ProfileRefInputSchema, _void(), {
16168
+ kind: "mutation",
16169
+ auth: "admin"
16170
+ });
16171
+ var LogLevelSchema = _enum([
16172
+ "debug",
16173
+ "info",
16174
+ "warn",
16175
+ "error"
15659
16176
  ]);
16177
+ var LogEntrySchema = object({
16178
+ timestamp: date(),
16179
+ level: LogLevelSchema,
16180
+ scope: array(string()),
16181
+ message: string(),
16182
+ meta: record(string(), unknown()).optional(),
16183
+ tags: record(string(), string()).optional()
16184
+ });
16185
+ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16186
+ scope: array(string()).optional(),
16187
+ level: LogLevelSchema.optional(),
16188
+ since: date().optional(),
16189
+ until: date().optional(),
16190
+ limit: number$1().optional(),
16191
+ tags: record(string(), string()).optional()
16192
+ }), array(LogEntrySchema).readonly());
15660
16193
  /**
15661
- * A single attachment. Exactly one of `url` (remote source, most adapters
15662
- * prefer this) or `bytes` (inline source; required for Pushover-style
15663
- * bytes-only kinds) MUST be present — the degrade engine expresses a
15664
- * url→bytes fetch as a `needsFetch` directive the adapter executes.
16194
+ * `login-method` collection cap through which auth addons contribute
16195
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
16196
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
16197
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
16198
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
16199
+ * procedure aggregates them for the unauthenticated login page.
16200
+ *
16201
+ * A contribution is a discriminated union on `kind`:
16202
+ *
16203
+ * - `redirect` — a declarative button. The login page renders a generic
16204
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
16205
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
16206
+ * ZERO shell-side JS. A future SSO addon plugs in the same way — the
16207
+ * login page needs NO change.
16208
+ *
16209
+ * - `widget` — a Module-Federation widget the login page mounts (via
16210
+ * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
16211
+ * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
16212
+ * mechanism kept for future use; no shipped addon uses it on the login
16213
+ * page (the passkey ceremony below runs natively in the shell instead).
16214
+ *
16215
+ * - `passkey` — a declarative WebAuthn ceremony the shell renders
16216
+ * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
16217
+ * a remotely-loaded bundle). Carries the addon's effective `rpId` /
16218
+ * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
16219
+ * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
16220
+ * fetching any remote code pre-auth. Contribution stays unconditional —
16221
+ * enrollment state is never leaked pre-auth; visibility is a shell
16222
+ * decision.
16223
+ *
16224
+ * Every contribution carries a `stage`:
16225
+ * - `primary` — shown on the first credentials screen (OIDC /
16226
+ * magic-link buttons; a future usernameless passkey).
16227
+ * - `second-factor` — shown AFTER the password leg, gated on the
16228
+ * returned `factors` (passkey-as-2FA today).
16229
+ *
16230
+ * `mount: skip` — the cap is read server-side by the core auth router
16231
+ * (`registry.getCollection('login-method')`), never mounted as its own
16232
+ * tRPC router.
15665
16233
  */
15666
- var AttachmentSchema = object({
15667
- mediaType: AttachmentMediaTypeSchema,
15668
- url: string().optional(),
15669
- bytes: _instanceof(Uint8Array).optional(),
15670
- mime: string().optional(),
15671
- name: string().optional()
15672
- }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
15673
- var NotificationFormatSchema = _enum([
15674
- "text",
15675
- "markdown",
15676
- "html"
16234
+ /** When a login method renders in the two-phase login flow. */
16235
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
16236
+ /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
16237
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [
16238
+ object({
16239
+ kind: literal("redirect"),
16240
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
16241
+ id: string(),
16242
+ /** Operator-facing button label. */
16243
+ label: string(),
16244
+ /** lucide-react icon name. */
16245
+ icon: string().optional(),
16246
+ /** Addon-owned HTTP route the button navigates to (GET). */
16247
+ startUrl: string(),
16248
+ stage: LoginStageEnum
16249
+ }),
16250
+ object({
16251
+ kind: literal("widget"),
16252
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
16253
+ id: string(),
16254
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
16255
+ addonId: string(),
16256
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
16257
+ bundle: string(),
16258
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
16259
+ remote: WidgetRemoteSchema,
16260
+ stage: LoginStageEnum
16261
+ }),
16262
+ object({
16263
+ kind: literal("passkey"),
16264
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
16265
+ id: string(),
16266
+ /** Operator-facing button label. */
16267
+ label: string(),
16268
+ stage: LoginStageEnum,
16269
+ /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
16270
+ rpId: string(),
16271
+ /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
16272
+ origin: string().nullable()
16273
+ })
15677
16274
  ]);
15678
- /** A single tap-through action button. */
15679
- var NotificationActionSchema = object({
15680
- id: string(),
15681
- label: string(),
15682
- url: string().optional()
16275
+ method(_void(), array(LoginMethodContributionSchema).readonly());
16276
+ var CpuBreakdownSchema = object({
16277
+ total: number$1(),
16278
+ user: number$1(),
16279
+ system: number$1(),
16280
+ irq: number$1(),
16281
+ nice: number$1(),
16282
+ loadAvg: tuple([
16283
+ number$1(),
16284
+ number$1(),
16285
+ number$1()
16286
+ ]),
16287
+ cores: number$1()
15683
16288
  });
15684
- /**
15685
- * The canonical notification. `body` is the only hard field (Apprise model).
15686
- * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
15687
- * NOT a fixed severity enum — each kind declares its own `caps.levels` and
15688
- * the adapter maps this ordinal onto its native level. `level?` is an
15689
- * optional kind-native level id (`emergency`, `silent`, …) that overrides
15690
- * `priority` for that one target.
15691
- */
15692
- var NotificationSchema = object({
15693
- body: string(),
15694
- title: string().optional(),
15695
- format: NotificationFormatSchema.default("text"),
15696
- priority: number$1().int().min(1).max(5).default(3),
15697
- level: string().optional(),
15698
- attachments: array(AttachmentSchema).optional(),
15699
- clickUrl: string().optional(),
15700
- actions: array(NotificationActionSchema).optional(),
15701
- sound: string().optional(),
15702
- ttl: number$1().optional(),
15703
- tag: string().optional(),
15704
- deviceId: number$1().optional(),
15705
- eventId: string().optional(),
15706
- metadata: record(string(), unknown()).optional()
16289
+ var MemoryInfoSchema = object({
16290
+ percent: number$1(),
16291
+ totalBytes: number$1(),
16292
+ usedBytes: number$1(),
16293
+ availableBytes: number$1(),
16294
+ swapUsedBytes: number$1(),
16295
+ swapTotalBytes: number$1()
16296
+ });
16297
+ var DiskIoSnapshotSchema = object({
16298
+ readBytes: number$1(),
16299
+ writeBytes: number$1(),
16300
+ readOps: number$1(),
16301
+ writeOps: number$1(),
16302
+ timestampMs: number$1()
16303
+ });
16304
+ var NetworkIoSnapshotSchema = object({
16305
+ rxBytes: number$1(),
16306
+ txBytes: number$1(),
16307
+ rxPackets: number$1(),
16308
+ txPackets: number$1(),
16309
+ rxErrors: number$1(),
16310
+ txErrors: number$1(),
16311
+ timestampMs: number$1()
16312
+ });
16313
+ var MetricsGpuInfoSchema = object({
16314
+ utilization: number$1(),
16315
+ model: string(),
16316
+ memoryUsedBytes: number$1(),
16317
+ memoryTotalBytes: number$1(),
16318
+ temperature: number$1().nullable()
16319
+ });
16320
+ var ProcessResourceInfoSchema = object({
16321
+ openFds: number$1(),
16322
+ threadCount: number$1(),
16323
+ activeHandles: number$1(),
16324
+ activeRequests: number$1()
15707
16325
  });
15708
- /** One declared native severity/priority level for a kind. */
15709
- var TargetKindLevelSchema = object({
15710
- id: string(),
15711
- label: string(),
15712
- /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
15713
- ordinal: number$1().int().min(1).max(5).nullable(),
15714
- flags: object({
15715
- critical: boolean().optional(),
15716
- silent: boolean().optional(),
15717
- noPush: boolean().optional()
15718
- }).optional(),
15719
- /** e.g. Pushover `emergency` requires `retry` / `expire`. */
15720
- requires: array(string()).optional(),
15721
- description: string().optional()
16326
+ var PressureAvgsSchema = object({
16327
+ avg10: number$1(),
16328
+ avg60: number$1(),
16329
+ avg300: number$1()
15722
16330
  });
15723
- /** The full capability block consulted before dispatch. */
15724
- var TargetKindCapsSchema = object({
15725
- attachments: object({
15726
- mediaTypes: array(AttachmentMediaTypeSchema),
15727
- mode: _enum([
15728
- "url",
15729
- "bytes",
15730
- "both"
15731
- ]),
15732
- max: number$1().int().nonnegative(),
15733
- maxBytes: number$1().int().positive().optional()
16331
+ var PressureInfoSchema = object({
16332
+ some: PressureAvgsSchema,
16333
+ full: PressureAvgsSchema.nullable()
16334
+ });
16335
+ var SystemResourceSnapshotSchema = object({
16336
+ cpu: CpuBreakdownSchema,
16337
+ memory: MemoryInfoSchema,
16338
+ gpu: MetricsGpuInfoSchema.nullable(),
16339
+ network: NetworkIoSnapshotSchema,
16340
+ disk: DiskIoSnapshotSchema,
16341
+ pressure: object({
16342
+ cpu: PressureInfoSchema.nullable(),
16343
+ memory: PressureInfoSchema.nullable(),
16344
+ io: PressureInfoSchema.nullable()
15734
16345
  }),
15735
- /** Max action buttons (0 = none). */
15736
- actions: number$1().int().nonnegative(),
15737
- levels: array(TargetKindLevelSchema),
15738
- format: array(NotificationFormatSchema),
15739
- clickUrl: boolean(),
15740
- sound: boolean(),
15741
- ttl: boolean(),
15742
- bodyMaxLen: number$1().int().positive()
16346
+ process: ProcessResourceInfoSchema,
16347
+ cpuTemperature: number$1().nullable(),
16348
+ timestampMs: number$1()
15743
16349
  });
15744
- /**
15745
- * `configSchema` is a `ConfigUISchema` tree passed through to the admin
15746
- * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
15747
- * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`)
15748
- * the union is large and not meant for runtime validation here; the exported
15749
- * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
15750
- */
15751
- var ConfigSchemaPassthrough$1 = unknown();
15752
- var TargetKindSchema = object({
15753
- kind: string(),
15754
- label: string(),
15755
- icon: string(),
15756
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
15757
- addonId: string(),
15758
- configSchema: ConfigSchemaPassthrough$1,
15759
- supportsDiscovery: boolean(),
15760
- caps: TargetKindCapsSchema
16350
+ var DiskSpaceInfoSchema = object({
16351
+ path: string(),
16352
+ totalBytes: number$1(),
16353
+ usedBytes: number$1(),
16354
+ availableBytes: number$1(),
16355
+ percent: number$1()
15761
16356
  });
15762
- /**
15763
- * A persisted target. `config` holds secrets; providers REDACT secret fields
15764
- * (return a presence marker only) when serving `listTargets` — never
15765
- * round-trip a stored secret to the UI.
15766
- */
15767
- var TargetSchema = object({
15768
- id: string(),
15769
- name: string(),
15770
- kind: string(),
16357
+ var PidResourceStatsSchema = object({
16358
+ pid: number$1(),
16359
+ cpu: number$1(),
16360
+ memory: number$1(),
16361
+ /**
16362
+ * Private (anonymous) resident bytes — the per-process V8 heap + native
16363
+ * allocations NOT shared with other processes (Linux RssAnon). This is the
16364
+ * "real" per-runner cost; summing it across runners is meaningful, unlike
16365
+ * `memory` (RSS), which double-counts the shared mmap'd framework code.
16366
+ * Undefined where /proc is unavailable (e.g. macOS).
16367
+ */
16368
+ privateBytes: number$1().optional(),
16369
+ /**
16370
+ * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
16371
+ * code shared copy-on-write across runners. Undefined on macOS.
16372
+ */
16373
+ sharedBytes: number$1().optional()
16374
+ });
16375
+ var AddonInstanceSchema = object({
15771
16376
  addonId: string(),
15772
- enabled: boolean(),
15773
- config: record(string(), unknown())
16377
+ nodeId: string(),
16378
+ role: _enum(["hub", "worker"]),
16379
+ pid: number$1(),
16380
+ state: _enum([
16381
+ "starting",
16382
+ "running",
16383
+ "stopping",
16384
+ "stopped",
16385
+ "crashed"
16386
+ ]),
16387
+ uptimeSec: number$1()
15774
16388
  });
15775
- /** A discovery-surfaced candidate (config is partial + non-secret). */
15776
- var DiscoveredTargetSchema = object({
15777
- kind: string(),
15778
- suggestedName: string(),
15779
- config: record(string(), unknown())
16389
+ var NodeProcessSchema = object({
16390
+ pid: number$1(),
16391
+ ppid: number$1(),
16392
+ pgid: number$1(),
16393
+ classification: _enum([
16394
+ "root",
16395
+ "managed",
16396
+ "system",
16397
+ "ghost"
16398
+ ]),
16399
+ /** `$process` addon binding when `managed`, else null. */
16400
+ addonId: string().nullable(),
16401
+ /** Kernel-reported nodeId when the process is a known agent/worker. */
16402
+ nodeId: string().nullable(),
16403
+ /** Truncated command line. */
16404
+ command: string(),
16405
+ cpuPercent: number$1(),
16406
+ memoryRssBytes: number$1(),
16407
+ /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
16408
+ uptimeSec: number$1(),
16409
+ /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
16410
+ orphaned: boolean()
15780
16411
  });
15781
- /** The degrade engine's report — what was resolved / dropped / degraded. */
15782
- var RenderedAsSchema = object({
15783
- level: string(),
15784
- format: NotificationFormatSchema,
15785
- attachmentsSent: number$1().int().nonnegative(),
15786
- actionsSent: number$1().int().nonnegative(),
15787
- truncated: boolean(),
15788
- dropped: array(string())
16412
+ var KillProcessInputSchema = object({
16413
+ pid: number$1(),
16414
+ /** Force = SIGKILL. Default is SIGTERM. */
16415
+ force: boolean().optional()
15789
16416
  });
15790
- var SendResultSchema = object({
16417
+ var KillProcessResultSchema = object({
16418
+ success: boolean(),
16419
+ reason: string().optional(),
16420
+ signal: _enum(["SIGTERM", "SIGKILL"]).optional()
16421
+ });
16422
+ var DumpHeapSnapshotInputSchema = object({
16423
+ /** The addon whose runner should dump a heap snapshot. */
16424
+ addonId: string() });
16425
+ var DumpHeapSnapshotResultSchema = object({
15791
16426
  success: boolean(),
16427
+ /** Path of the written .heapsnapshot inside the runner's container/host. */
16428
+ path: string().optional(),
16429
+ /** Process pid that was signalled. */
16430
+ pid: number$1().optional(),
16431
+ reason: string().optional()
16432
+ });
16433
+ var SystemMetricsSchema = object({
16434
+ cpuPercent: number$1(),
16435
+ memoryPercent: number$1(),
16436
+ memoryUsedMB: number$1(),
16437
+ memoryTotalMB: number$1(),
16438
+ diskPercent: number$1().optional(),
16439
+ temperature: number$1().optional(),
16440
+ gpuPercent: number$1().optional(),
16441
+ gpuMemoryPercent: number$1().optional()
16442
+ });
16443
+ method(_void(), SystemResourceSnapshotSchema), method(_void(), SystemResourceSnapshotSchema.nullable()), method(_void(), SystemMetricsSchema), method(object({ dirPath: string() }), DiskSpaceInfoSchema), method(_void(), MetricsGpuInfoSchema.nullable()), method(_void(), number$1().nullable()), method(object({ pids: array(number$1()) }), array(PidResourceStatsSchema)), method(_void(), array(AddonInstanceSchema).readonly()), method(object({ addonId: string() }), PidResourceStatsSchema.nullable()), method(_void(), array(NodeProcessSchema).readonly()), method(KillProcessInputSchema, KillProcessResultSchema, {
16444
+ kind: "mutation",
16445
+ auth: "admin"
16446
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
16447
+ kind: "mutation",
16448
+ auth: "admin"
16449
+ });
16450
+ method(object({
16451
+ sourceUrl: string(),
16452
+ metadata: ModelConvertMetadataSchema,
16453
+ targets: array(ConvertTargetSchema).min(1).readonly(),
16454
+ calibrationRef: string().optional(),
16455
+ sessionId: string().optional()
16456
+ }), ConvertResultSchema, {
16457
+ kind: "mutation",
16458
+ auth: "admin",
16459
+ timeoutMs: 6e5
16460
+ });
16461
+ method(object({
16462
+ nodeId: string(),
16463
+ modelId: string(),
16464
+ format: _enum(MODEL_FORMATS),
16465
+ entry: ModelCatalogEntrySchema
16466
+ }), object({
16467
+ ok: boolean(),
16468
+ /** sha256 of the staged tarball (empty for a hub-local no-op). */
16469
+ sha256: string(),
16470
+ bytes: number$1(),
16471
+ /** The target node's modelsDir the artifact landed in. */
16472
+ path: string()
16473
+ }), {
16474
+ kind: "mutation",
16475
+ auth: "admin"
16476
+ });
16477
+ /**
16478
+ * `mqtt-broker` — broker-registry cap.
16479
+ *
16480
+ * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
16481
+ * MQTT brokers (external + optionally an embedded `aedes`-backed one)
16482
+ * and (b) the connection details a consumer addon needs to spin up
16483
+ * its OWN `mqtt.js` client.
16484
+ *
16485
+ * Why: pub/sub routing over the system event-bus loses fidelity
16486
+ * (callback shape, QoS guarantees, will/retain semantics) and adds
16487
+ * refcount bookkeeping that addons would rather own themselves. The
16488
+ * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
16489
+ * features anyway — give it the connection config, get out of the way.
16490
+ *
16491
+ * Consumer flow:
16492
+ * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
16493
+ * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
16494
+ * client.subscribe('zigbee2mqtt/+')
16495
+ *
16496
+ * Collection mode: multiple brokers (e.g. one local mosquitto + one
16497
+ * cloud bridge). The "embedded" entry (when present) is just another
16498
+ * broker in the registry — its lifecycle is owned by the addon that
16499
+ * spawned it.
16500
+ */
16501
+ var BrokerKindSchema = _enum(["external", "embedded"]);
16502
+ /**
16503
+ * Broker live-probe status.
16504
+ *
16505
+ * - `connected` — last probe completed a clean CONNACK
16506
+ * - `disconnected` — no probe has run yet (cold cache)
16507
+ * - `auth-failed` — CONNACK refused with auth error (RC 4 / 5)
16508
+ * - `unreachable` — TCP connect timed out / refused
16509
+ * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
16510
+ */
16511
+ var BrokerStatusSchema$1 = _enum([
16512
+ "connected",
16513
+ "disconnected",
16514
+ "auth-failed",
16515
+ "unreachable",
16516
+ "tls-error"
16517
+ ]);
16518
+ var BrokerInfoSchema = object({
16519
+ id: string(),
16520
+ name: string(),
16521
+ url: string(),
16522
+ kind: BrokerKindSchema,
16523
+ status: BrokerStatusSchema$1,
16524
+ latencyMs: number$1().nullable(),
15792
16525
  error: string().optional(),
15793
- renderedAs: RenderedAsSchema.optional()
16526
+ /** Embedded brokers only: number of MQTT clients currently connected. */
16527
+ connectedClients: number$1().int().nonnegative().optional(),
16528
+ /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
16529
+ lastCheckedAt: number$1().optional()
15794
16530
  });
15795
- /** Same shape as SendResult — kept as a distinct name for the test panel. */
15796
- var TestResultSchema = SendResultSchema;
15797
- method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
15798
- kind: string(),
15799
- config: record(string(), unknown()).optional()
15800
- }), array(DiscoveredTargetSchema)), method(object({
15801
- targetId: string(),
15802
- notification: NotificationSchema
15803
- }), SendResultSchema, { kind: "mutation" }), method(object({
15804
- targetId: string(),
15805
- sample: NotificationSchema.optional()
15806
- }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
15807
- targetId: string(),
15808
- enabled: boolean()
15809
- }), _void(), { kind: "mutation" });
15810
16531
  /**
15811
- * Shared LLM generate contracts imported by BOTH `llm.cap.ts` (consumer
15812
- * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15813
- * caps stay wire-compatible without a circular cap→cap import.
15814
- *
15815
- * Errors are a discriminated-union RESULT, never thrown: the shape survives
15816
- * every transport tier structurally, and failed calls still write usage rows.
15817
- * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
16532
+ * Connection details what a consumer needs to call
16533
+ * `mqtt.connect(url, options)`. We split URL + credentials so the
16534
+ * consumer can pass them as `mqtt.connect(url, { username, password })`
16535
+ * instead of stuffing creds into the URL (which leaks them into logs).
15818
16536
  */
15819
- var LlmUsageSchema = object({
15820
- inputTokens: number$1(),
15821
- outputTokens: number$1()
16537
+ var BrokerConnectionDetailsSchema = object({
16538
+ url: string(),
16539
+ username: string().optional(),
16540
+ password: string().optional(),
16541
+ /**
16542
+ * Suggested prefix for `clientId`. Each consumer should suffix this
16543
+ * with its own discriminator (addon id, instance id) so reconnects
16544
+ * don't kick each other off (MQTT spec: clientId must be unique per
16545
+ * broker).
16546
+ */
16547
+ clientIdPrefix: string().optional()
15822
16548
  });
15823
- var LlmErrorCodeSchema = _enum([
15824
- "timeout",
15825
- "rate-limited",
15826
- "auth",
15827
- "refusal",
15828
- "bad-request",
15829
- "unavailable",
15830
- "no-profile",
15831
- "budget-exceeded",
15832
- "adapter-error"
15833
- ]);
15834
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
16549
+ var AddBrokerInputSchema = object({
16550
+ name: string().min(1),
16551
+ url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
16552
+ username: string().optional(),
16553
+ password: string().optional(),
16554
+ clientIdPrefix: string().optional()
16555
+ });
16556
+ var AddBrokerResultSchema = object({ id: string() });
16557
+ var IdInputSchema = object({ id: string() });
16558
+ var TestResultSchema$1 = discriminatedUnion("ok", [object({
15835
16559
  ok: literal(true),
15836
- text: string(),
15837
- model: string(),
15838
- usage: LlmUsageSchema,
15839
- truncated: boolean(),
15840
16560
  latencyMs: number$1()
15841
16561
  }), object({
15842
16562
  ok: literal(false),
15843
- code: LlmErrorCodeSchema,
15844
- message: string(),
15845
- retryAfterMs: number$1().optional()
16563
+ error: string()
15846
16564
  })]);
15847
- /**
15848
- * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
15849
- * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
15850
- * notification-output.cap.ts:27-31 precedents).
15851
- */
15852
- var LlmImageSchema = object({
15853
- bytes: _instanceof(Uint8Array),
15854
- mimeType: string()
16565
+ var StartEmbeddedInputSchema = object({
16566
+ port: number$1().int().min(1).max(65535).default(1883),
16567
+ /** Allow anonymous connect (no username/password). Default: false. */
16568
+ allowAnonymous: boolean().default(false),
16569
+ /** Optional shared username/password for clients. */
16570
+ username: string().optional(),
16571
+ password: string().optional()
15855
16572
  });
15856
- var LlmGenerateBaseInputSchema = object({
15857
- /** Collection routing (the notification-output posture). */
15858
- addonId: string().optional(),
15859
- /** Explicit profile; else the resolution chain (spec §3). */
15860
- profileId: string().optional(),
15861
- /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
15862
- consumer: string(),
15863
- system: string().optional(),
15864
- /** v1: single-turn. `messages[]` is a v2 additive field. */
15865
- prompt: string(),
15866
- /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
15867
- jsonSchema: record(string(), unknown()).optional(),
15868
- /** Per-call override of the profile default. */
15869
- maxTokens: number$1().int().positive().optional(),
15870
- temperature: number$1().optional()
16573
+ var StartEmbeddedResultSchema = object({
16574
+ id: string(),
16575
+ url: string()
15871
16576
  });
15872
- /**
15873
- * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
15874
- * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
15875
- * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
15876
- * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
15877
- * this only through the `llm` cap's methods.
15878
- *
15879
- * One running llama-server child per node in v1 (models are RAM-heavy).
15880
- * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
15881
- * watchdog — operator decision #3).
15882
- */
15883
- var ManagedModelRefSchema = discriminatedUnion("kind", [
15884
- object({
15885
- kind: literal("catalog"),
15886
- catalogId: string()
15887
- }),
15888
- object({
15889
- kind: literal("url"),
15890
- url: string(),
15891
- sha256: string().optional()
15892
- }),
15893
- object({
15894
- kind: literal("path"),
15895
- path: string()
15896
- })
15897
- ]);
15898
- var ManagedRuntimeConfigSchema = object({
15899
- /** WHERE the runtime lives — hub or any agent. */
15900
- nodeId: string(),
15901
- /** Closed for v1; 'ollama' is a v2 candidate. */
15902
- engine: _enum(["llama-cpp"]),
15903
- model: ManagedModelRefSchema,
15904
- contextSize: number$1().int().default(4096),
15905
- /** 0 = CPU-only. */
15906
- gpuLayers: number$1().int().default(0),
15907
- /** Default: cpus-2, clamped ≥1 (resolved node-side). */
15908
- threads: number$1().int().optional(),
15909
- /** Concurrent slots. */
15910
- parallel: number$1().int().default(1),
15911
- /** Else lazy: first generate boots it. */
15912
- autoStart: boolean().default(false),
15913
- /** 0 = never; frees RAM after quiet periods. */
15914
- idleStopMinutes: number$1().int().default(30)
16577
+ var StatusSchema = object({
16578
+ brokerCount: number$1(),
16579
+ embeddedRunning: boolean()
15915
16580
  });
15916
- var LlmRuntimeStatusSchema = object({
15917
- /** Status is ALWAYS node-qualified. */
15918
- nodeId: string(),
15919
- state: _enum([
15920
- "stopped",
15921
- "downloading",
15922
- "starting",
15923
- "ready",
15924
- "crashed",
15925
- "failed"
15926
- ]),
15927
- pid: number$1().optional(),
15928
- port: number$1().optional(),
15929
- modelPath: string().optional(),
15930
- modelId: string().optional(),
15931
- downloadProgress: number$1().min(0).max(1).optional(),
15932
- lastError: string().optional(),
15933
- crashesInWindow: number$1(),
15934
- /** Child RSS (sampled best-effort). */
15935
- memoryBytes: number$1().optional(),
15936
- vramBytes: number$1().optional()
16581
+ 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);
16582
+ var NetworkEndpointSchema = object({
16583
+ url: string(),
16584
+ hostname: string(),
16585
+ port: number$1(),
16586
+ protocol: _enum(["http", "https"])
15937
16587
  });
15938
- var LlmNodeModelSchema = object({
15939
- file: string(),
15940
- sizeBytes: number$1(),
15941
- catalogId: string().optional(),
15942
- installedAt: number$1().optional()
16588
+ var NetworkAccessStatusSchema = object({
16589
+ connected: boolean(),
16590
+ endpoint: NetworkEndpointSchema.nullable(),
16591
+ error: string().optional()
15943
16592
  });
15944
- var LlmRuntimeDiskUsageSchema = object({
15945
- nodeId: string(),
15946
- modelsBytes: number$1(),
15947
- freeBytes: number$1().optional()
16593
+ /**
16594
+ * Optional, richer endpoint shape returned by providers that expose
16595
+ * MORE than one ingress concurrently (Tailscale Ingress with mixed
16596
+ * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
16597
+ * the originating provider config (mode + sourcePort) so the
16598
+ * orchestrator UI can label rows distinctly. Providers that expose only
16599
+ * one endpoint just omit `listEndpoints` from their provider impl.
16600
+ */
16601
+ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
16602
+ /**
16603
+ * Stable id within the provider — typically `<mode>-<sourcePort>` so
16604
+ * the orchestrator can dedupe across `listEndpoints` polls.
16605
+ */
16606
+ id: string(),
16607
+ /** Operator-facing label (mirrors `MeshEndpoint.label`). */
16608
+ label: string(),
16609
+ /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
16610
+ mode: string().optional(),
16611
+ /** Originating local port the ingress fronts (informational). */
16612
+ sourcePort: number$1().optional()
15948
16613
  });
15949
- method(LlmGenerateBaseInputSchema.extend({
15950
- images: array(LlmImageSchema).optional(),
15951
- runtime: ManagedRuntimeConfigSchema,
15952
- /** The managed profile's timeout, threaded by the hub provider. */
15953
- timeoutMs: number$1().int().positive().optional()
15954
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
15955
- kind: "mutation",
15956
- auth: "admin"
15957
- }), method(object({}), _void(), {
15958
- kind: "mutation",
15959
- auth: "admin"
15960
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
15961
- kind: "mutation",
15962
- auth: "admin"
15963
- }), method(object({ file: string() }), _void(), {
15964
- kind: "mutation",
15965
- auth: "admin"
15966
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
16614
+ method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
15967
16615
  /**
15968
- * `llm`consumer-facing LLM surface (spec §1-§3). Collection-mode: array
15969
- * methods concat-fan across providers; single-row methods route to ONE
15970
- * provider by the `addonId` in the call input (the notification-output
15971
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
15972
- * (hub-placed); the cap stays open for future providers.
16616
+ * notification-outputcanonical, capability-gated notification delivery.
16617
+ *
16618
+ * Apprise-derived model (see
16619
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
16620
+ * callers emit ONE canonical `Notification`; each provider declares a
16621
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
16622
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
16623
+ * message to what the kind supports — callers never special-case a service.
16624
+ *
16625
+ * DESIGN DECISIONS (locked):
16626
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
16627
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
16628
+ * cap. Rationale: the admin UI needs one uniform surface across the
16629
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
16630
+ * alternative would fork the UI per addon and cannot host the
16631
+ * discovery→adopt flow.
16632
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
16633
+ * the generated cap-mount auto-`concatCollection`-fans them across every
16634
+ * registered provider (notifiers addon + HA addon) so one catalog is
16635
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
16636
+ * `addonId` the generated collection router extracts from the call input.
16637
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
16638
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
16639
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
16640
+ * base64 fallback needed.
15973
16641
  *
15974
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
15975
- * `apiKey` is a password field — providers REDACT it on read and merge on
15976
- * write; a stored key NEVER round-trips to a client.
16642
+ * TODO (deferred, closed-set change separate decision): add
16643
+ * `providerKind: 'notify'` so notification providers surface on the unified
16644
+ * admin "Integrations" page.
15977
16645
  */
15978
- var LlmProfileKindSchema = _enum([
15979
- "openai-compatible",
15980
- "openai",
15981
- "anthropic",
15982
- "google",
15983
- "managed-local"
16646
+ /**
16647
+ * Zentik-derived typed-media enum — the superset across every kind. Each
16648
+ * adapter picks what it supports and the degrade engine filters the rest.
16649
+ */
16650
+ var AttachmentMediaTypeSchema = _enum([
16651
+ "image",
16652
+ "video",
16653
+ "gif",
16654
+ "audio",
16655
+ "icon"
15984
16656
  ]);
15985
- var LlmProfileSchema = object({
16657
+ /**
16658
+ * A single attachment. Exactly one of `url` (remote source, most adapters
16659
+ * prefer this) or `bytes` (inline source; required for Pushover-style
16660
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
16661
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
16662
+ */
16663
+ var AttachmentSchema = object({
16664
+ mediaType: AttachmentMediaTypeSchema,
16665
+ url: string().optional(),
16666
+ bytes: _instanceof(Uint8Array).optional(),
16667
+ mime: string().optional(),
16668
+ name: string().optional()
16669
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
16670
+ var NotificationFormatSchema = _enum([
16671
+ "text",
16672
+ "markdown",
16673
+ "html"
16674
+ ]);
16675
+ /** A single tap-through action button. */
16676
+ var NotificationActionSchema = object({
15986
16677
  id: string(),
15987
- name: string(),
15988
- kind: LlmProfileKindSchema,
15989
- /** Stamped by the provider — keeps the fanned catalog routable. */
15990
- addonId: string(),
15991
- enabled: boolean(),
15992
- /** Vendor model id, or the managed runtime's loaded model. */
15993
- model: string(),
15994
- /** Required for openai-compatible; override for cloud kinds. */
15995
- baseUrl: string().optional(),
15996
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
15997
- apiKey: string().optional(),
15998
- supportsVision: boolean(),
15999
- temperature: number$1().min(0).max(2).optional(),
16000
- maxTokens: number$1().int().positive().optional(),
16001
- timeoutMs: number$1().int().positive().default(6e4),
16002
- extraHeaders: record(string(), string()).optional(),
16003
- /** kind === 'managed-local' only (spec §4). */
16004
- runtime: ManagedRuntimeConfigSchema.optional()
16678
+ label: string(),
16679
+ url: string().optional()
16005
16680
  });
16006
- /** ConfigUISchema tree passed through untyped on the wire (the
16007
- * notification-output `ConfigSchemaPassthrough` precedent at
16008
- * notification-output.cap.ts:151); the exported TS type re-tightens it. */
16681
+ /**
16682
+ * The canonical notification. `body` is the only hard field (Apprise model).
16683
+ * `priority` is a 5-level ORDINAL (1=lowest 3=normal(default) 5=urgent),
16684
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
16685
+ * the adapter maps this ordinal onto its native level. `level?` is an
16686
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
16687
+ * `priority` for that one target.
16688
+ */
16689
+ var NotificationSchema = object({
16690
+ body: string(),
16691
+ title: string().optional(),
16692
+ format: NotificationFormatSchema.default("text"),
16693
+ priority: number$1().int().min(1).max(5).default(3),
16694
+ level: string().optional(),
16695
+ attachments: array(AttachmentSchema).optional(),
16696
+ clickUrl: string().optional(),
16697
+ actions: array(NotificationActionSchema).optional(),
16698
+ sound: string().optional(),
16699
+ ttl: number$1().optional(),
16700
+ tag: string().optional(),
16701
+ deviceId: number$1().optional(),
16702
+ eventId: string().optional(),
16703
+ metadata: record(string(), unknown()).optional()
16704
+ });
16705
+ /** One declared native severity/priority level for a kind. */
16706
+ var TargetKindLevelSchema = object({
16707
+ id: string(),
16708
+ label: string(),
16709
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
16710
+ ordinal: number$1().int().min(1).max(5).nullable(),
16711
+ flags: object({
16712
+ critical: boolean().optional(),
16713
+ silent: boolean().optional(),
16714
+ noPush: boolean().optional()
16715
+ }).optional(),
16716
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
16717
+ requires: array(string()).optional(),
16718
+ description: string().optional()
16719
+ });
16720
+ /** The full capability block consulted before dispatch. */
16721
+ var TargetKindCapsSchema = object({
16722
+ attachments: object({
16723
+ mediaTypes: array(AttachmentMediaTypeSchema),
16724
+ mode: _enum([
16725
+ "url",
16726
+ "bytes",
16727
+ "both"
16728
+ ]),
16729
+ max: number$1().int().nonnegative(),
16730
+ maxBytes: number$1().int().positive().optional()
16731
+ }),
16732
+ /** Max action buttons (0 = none). */
16733
+ actions: number$1().int().nonnegative(),
16734
+ levels: array(TargetKindLevelSchema),
16735
+ format: array(NotificationFormatSchema),
16736
+ clickUrl: boolean(),
16737
+ sound: boolean(),
16738
+ ttl: boolean(),
16739
+ bodyMaxLen: number$1().int().positive()
16740
+ });
16741
+ /**
16742
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
16743
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
16744
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
16745
+ * the union is large and not meant for runtime validation here; the exported
16746
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
16747
+ */
16009
16748
  var ConfigSchemaPassthrough = unknown();
16010
- var LlmProfileKindDescriptorSchema = object({
16011
- kind: LlmProfileKindSchema,
16749
+ var TargetKindSchema = object({
16750
+ kind: string(),
16012
16751
  label: string(),
16013
16752
  icon: string(),
16014
16753
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
16015
16754
  addonId: string(),
16016
- configSchema: ConfigSchemaPassthrough
16017
- });
16018
- var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
16019
- var LlmDefaultSchema = object({
16020
- selector: LlmDefaultSelectorSchema,
16021
- profileId: string()
16022
- });
16023
- /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
16024
- var LlmUsageRollupSchema = object({
16025
- day: string(),
16026
- consumer: string(),
16027
- profileId: string(),
16028
- calls: number$1(),
16029
- okCalls: number$1(),
16030
- errorCalls: number$1(),
16031
- inputTokens: number$1(),
16032
- outputTokens: number$1(),
16033
- avgLatencyMs: number$1()
16755
+ configSchema: ConfigSchemaPassthrough,
16756
+ supportsDiscovery: boolean(),
16757
+ caps: TargetKindCapsSchema
16034
16758
  });
16035
- /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
16036
- var ManagedModelCatalogEntrySchema = object({
16759
+ /**
16760
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
16761
+ * (return a presence marker only) when serving `listTargets` — never
16762
+ * round-trip a stored secret to the UI.
16763
+ */
16764
+ var TargetSchema = object({
16037
16765
  id: string(),
16038
- label: string(),
16039
- family: string(),
16040
- purpose: _enum(["text", "vision"]),
16041
- url: string(),
16042
- sha256: string(),
16043
- sizeBytes: number$1(),
16044
- quantization: string(),
16045
- /** Load-time guidance shown in the picker. */
16046
- minRamBytes: number$1(),
16047
- contextSizeDefault: number$1().int(),
16048
- /** Vision models: companion projector file. */
16049
- mmprojUrl: string().optional()
16050
- });
16051
- var LlmRuntimeNodeSchema = object({
16052
- nodeId: string(),
16053
- reachable: boolean(),
16054
- status: LlmRuntimeStatusSchema.optional(),
16055
- disk: LlmRuntimeDiskUsageSchema.optional(),
16056
- error: string().optional()
16057
- });
16058
- var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
16059
- var ProfileRefInputSchema = object({
16766
+ name: string(),
16767
+ kind: string(),
16060
16768
  addonId: string(),
16061
- profileId: string()
16769
+ enabled: boolean(),
16770
+ config: record(string(), unknown())
16062
16771
  });
16063
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
16064
- kind: "mutation",
16065
- auth: "admin"
16066
- }), method(ProfileRefInputSchema, _void(), {
16067
- kind: "mutation",
16068
- auth: "admin"
16069
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
16070
- kind: "mutation",
16071
- auth: "admin"
16072
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
16073
- selector: LlmDefaultSelectorSchema,
16074
- profileId: string().nullable()
16075
- }), _void(), {
16076
- kind: "mutation",
16077
- auth: "admin"
16078
- }), method(object({
16079
- since: number$1().optional(),
16080
- until: number$1().optional(),
16081
- consumer: string().optional(),
16082
- profileId: string().optional()
16083
- }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
16084
- nodeId: string(),
16085
- model: ManagedModelRefSchema
16086
- }), _void(), {
16087
- kind: "mutation",
16088
- auth: "admin"
16089
- }), method(object({
16090
- nodeId: string(),
16091
- file: string()
16092
- }), _void(), {
16093
- kind: "mutation",
16094
- auth: "admin"
16095
- }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
16096
- kind: "mutation",
16097
- auth: "admin"
16098
- }), method(ProfileRefInputSchema, _void(), {
16099
- kind: "mutation",
16100
- auth: "admin"
16772
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
16773
+ var DiscoveredTargetSchema = object({
16774
+ kind: string(),
16775
+ suggestedName: string(),
16776
+ config: record(string(), unknown())
16777
+ });
16778
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
16779
+ var RenderedAsSchema = object({
16780
+ level: string(),
16781
+ format: NotificationFormatSchema,
16782
+ attachmentsSent: number$1().int().nonnegative(),
16783
+ actionsSent: number$1().int().nonnegative(),
16784
+ truncated: boolean(),
16785
+ dropped: array(string())
16786
+ });
16787
+ var SendResultSchema = object({
16788
+ success: boolean(),
16789
+ error: string().optional(),
16790
+ renderedAs: RenderedAsSchema.optional()
16101
16791
  });
16792
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
16793
+ var TestResultSchema = SendResultSchema;
16794
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
16795
+ kind: string(),
16796
+ config: record(string(), unknown()).optional()
16797
+ }), array(DiscoveredTargetSchema)), method(object({
16798
+ targetId: string(),
16799
+ notification: NotificationSchema
16800
+ }), SendResultSchema, { kind: "mutation" }), method(object({
16801
+ targetId: string(),
16802
+ sample: NotificationSchema.optional()
16803
+ }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
16804
+ targetId: string(),
16805
+ enabled: boolean()
16806
+ }), _void(), { kind: "mutation" });
16102
16807
  /**
16103
16808
  * Zod schemas for persisted record types.
16104
16809
  *
@@ -16784,7 +17489,10 @@ DeviceType.Camera, method(object({ deviceId: number$1() }), array(TrackSchema).r
16784
17489
  }), method(object({
16785
17490
  eventId: string(),
16786
17491
  kind: MediaFileKindEnum.optional()
16787
- }), array(MediaFileSchema).readonly()), method(object({ trackId: string() }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
17492
+ }), array(MediaFileSchema).readonly()), method(object({
17493
+ trackId: string(),
17494
+ kinds: array(MediaFileKindEnum).optional()
17495
+ }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
16788
17496
  deviceId: number$1(),
16789
17497
  timestamp: number$1(),
16790
17498
  frameWidth: number$1(),
@@ -16805,76 +17513,6 @@ DeviceType.Camera, method(object({ deviceId: number$1() }), array(TrackSchema).r
16805
17513
  eventId: string(),
16806
17514
  timestamp: number$1()
16807
17515
  });
16808
- /**
16809
- * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
16810
- * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
16811
- * caps into per-camera event-kind descriptors.
16812
- *
16813
- * The descriptor DATA (color / iconId / labelKey / parentKind / category)
16814
- * is NOT duplicated here — every entry is derived from the single
16815
- * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
16816
- * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
16817
- * control cap means adding one line here (and a taxonomy entry); the anti-
16818
- * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
16819
- * eventful cap is missing.
16820
- */
16821
- /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
16822
- var LEGACY_ICON = {
16823
- motion: "motion",
16824
- audio: "audio",
16825
- person: "person",
16826
- vehicle: "vehicle",
16827
- animal: "animal",
16828
- package: "package",
16829
- door: "door",
16830
- pir: "pir",
16831
- smoke: "smoke",
16832
- water: "water",
16833
- button: "button",
16834
- generic: "generic",
16835
- gas: "smoke",
16836
- vibration: "generic",
16837
- tamper: "generic",
16838
- presence: "person",
16839
- lock: "generic",
16840
- siren: "generic",
16841
- switch: "generic",
16842
- doorbell: "button"
16843
- };
16844
- function legacyIcon(iconId) {
16845
- return LEGACY_ICON[iconId] ?? "generic";
16846
- }
16847
- /**
16848
- * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
16849
- * The anti-drift guard cross-checks this against the eventful caps declared
16850
- * in `packages/types/src/capabilities/*.cap.ts`.
16851
- */
16852
- var CAP_TO_KIND = {
16853
- contact: "contact",
16854
- motion: "motion-sensor",
16855
- smoke: "smoke",
16856
- flood: "flood",
16857
- gas: "gas",
16858
- "carbon-monoxide": "carbon-monoxide",
16859
- vibration: "vibration",
16860
- tamper: "tamper",
16861
- presence: "presence",
16862
- "enum-sensor": "enum-sensor",
16863
- "event-emitter": "device-event",
16864
- "lock-control": "lock",
16865
- switch: "switch",
16866
- button: "button",
16867
- doorbell: "doorbell"
16868
- };
16869
- function buildDescriptor(capName, kind) {
16870
- const t = EVENT_TAXONOMY[kind];
16871
- if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
16872
- return {
16873
- ...t,
16874
- icon: legacyIcon(t.iconId)
16875
- };
16876
- }
16877
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
16878
17516
  var CameraPipelineConfigSchema = object({
16879
17517
  engine: PipelineEngineChoiceSchema.optional(),
16880
17518
  steps: array(PipelineStepInputSchema).readonly(),
@@ -17360,6 +17998,76 @@ method(object({
17360
17998
  auth: "admin"
17361
17999
  });
17362
18000
  /**
18001
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
18002
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
18003
+ * caps into per-camera event-kind descriptors.
18004
+ *
18005
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
18006
+ * is NOT duplicated here — every entry is derived from the single
18007
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
18008
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
18009
+ * control cap means adding one line here (and a taxonomy entry); the anti-
18010
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
18011
+ * eventful cap is missing.
18012
+ */
18013
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
18014
+ var LEGACY_ICON = {
18015
+ motion: "motion",
18016
+ audio: "audio",
18017
+ person: "person",
18018
+ vehicle: "vehicle",
18019
+ animal: "animal",
18020
+ package: "package",
18021
+ door: "door",
18022
+ pir: "pir",
18023
+ smoke: "smoke",
18024
+ water: "water",
18025
+ button: "button",
18026
+ generic: "generic",
18027
+ gas: "smoke",
18028
+ vibration: "generic",
18029
+ tamper: "generic",
18030
+ presence: "person",
18031
+ lock: "generic",
18032
+ siren: "generic",
18033
+ switch: "generic",
18034
+ doorbell: "button"
18035
+ };
18036
+ function legacyIcon(iconId) {
18037
+ return LEGACY_ICON[iconId] ?? "generic";
18038
+ }
18039
+ /**
18040
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
18041
+ * The anti-drift guard cross-checks this against the eventful caps declared
18042
+ * in `packages/types/src/capabilities/*.cap.ts`.
18043
+ */
18044
+ var CAP_TO_KIND = {
18045
+ contact: "contact",
18046
+ motion: "motion-sensor",
18047
+ smoke: "smoke",
18048
+ flood: "flood",
18049
+ gas: "gas",
18050
+ "carbon-monoxide": "carbon-monoxide",
18051
+ vibration: "vibration",
18052
+ tamper: "tamper",
18053
+ presence: "presence",
18054
+ "enum-sensor": "enum-sensor",
18055
+ "event-emitter": "device-event",
18056
+ "lock-control": "lock",
18057
+ switch: "switch",
18058
+ button: "button",
18059
+ doorbell: "doorbell"
18060
+ };
18061
+ function buildDescriptor(capName, kind) {
18062
+ const t = EVENT_TAXONOMY[kind];
18063
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
18064
+ return {
18065
+ ...t,
18066
+ icon: legacyIcon(t.iconId)
18067
+ };
18068
+ }
18069
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
18070
+ /**
17363
18071
  * server-management — per-NODE singleton capability for a node's ROOT
17364
18072
  * package lifecycle (runtime-updatable node packages).
17365
18073
  *
@@ -18814,7 +19522,28 @@ var FaceInfoSchema = object({
18814
19522
  * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`). Absent when the
18815
19523
  * track produced no key frame (e.g. native/onboard source) — the UI falls
18816
19524
  * back to the inline `base64` face crop. */
18817
- keyFrameMediaKey: string().optional()
19525
+ keyFrameMediaKey: string().optional(),
19526
+ /** Winning identity-match cosine (0..1) for this face's track, when an
19527
+ * identity was auto-confirmed. Lets the UI surface WHY a face was assigned
19528
+ * (confidence badge / low-confidence audit). Absent on legacy rows and on
19529
+ * faces that were never auto-recognized. */
19530
+ bestMatchScore: number$1().optional(),
19531
+ /** Native-scale face short side (px) at recognition time, when the runner
19532
+ * measured it. Lets the UI flag low-resolution auto-assignments. Absent on
19533
+ * legacy rows / runners that reported no native measure. */
19534
+ nativeFaceShortSidePx: number$1().optional(),
19535
+ /** SUGGESTED identity for this face — a plausible-but-not-confident match that
19536
+ * MISSED auto-assignment (cosine in the suggestion band, or above threshold
19537
+ * but blocked only by the recognition size floor). Mutually exclusive with
19538
+ * `recognizedIdentityId` (a suggestion is NEVER an assignment): the face stays
19539
+ * UNASSIGNED and everything else keeps treating it as unrecognized — the UI
19540
+ * merely offers a one-tap "is this <name>?" confirm. Absent on legacy rows and
19541
+ * on faces that were auto-assigned or below the suggestion band. (2026-07-24) */
19542
+ suggestedIdentityId: string().optional(),
19543
+ /** Peak identity-match cosine (0..1) for `suggestedIdentityId`, captured at the
19544
+ * same moment as `bestMatchScore` (track peak, at close). Lets the UI rank /
19545
+ * badge suggestion confidence. Present iff `suggestedIdentityId` is. (2026-07-24) */
19546
+ suggestedMatchScore: number$1().optional()
18818
19547
  });
18819
19548
  var FaceFilterEnum = _enum([
18820
19549
  "unassigned",
@@ -20857,36 +21586,6 @@ Object.freeze({
20857
21586
  addonId: null,
20858
21587
  access: "view"
20859
21588
  },
20860
- "advancedNotifier.deleteRule": {
20861
- capName: "advanced-notifier",
20862
- capScope: "system",
20863
- addonId: null,
20864
- access: "delete"
20865
- },
20866
- "advancedNotifier.getHistory": {
20867
- capName: "advanced-notifier",
20868
- capScope: "system",
20869
- addonId: null,
20870
- access: "view"
20871
- },
20872
- "advancedNotifier.getRules": {
20873
- capName: "advanced-notifier",
20874
- capScope: "system",
20875
- addonId: null,
20876
- access: "view"
20877
- },
20878
- "advancedNotifier.testRule": {
20879
- capName: "advanced-notifier",
20880
- capScope: "system",
20881
- addonId: null,
20882
- access: "create"
20883
- },
20884
- "advancedNotifier.upsertRule": {
20885
- capName: "advanced-notifier",
20886
- capScope: "system",
20887
- addonId: null,
20888
- access: "create"
20889
- },
20890
21589
  "alarmPanel.arm": {
20891
21590
  capName: "alarm-panel",
20892
21591
  capScope: "device",
@@ -21109,6 +21808,12 @@ Object.freeze({
21109
21808
  addonId: null,
21110
21809
  access: "delete"
21111
21810
  },
21811
+ "backup.deleteSchedule": {
21812
+ capName: "backup",
21813
+ capScope: "system",
21814
+ addonId: null,
21815
+ access: "delete"
21816
+ },
21112
21817
  "backup.getEntries": {
21113
21818
  capName: "backup",
21114
21819
  capScope: "system",
@@ -21139,6 +21844,12 @@ Object.freeze({
21139
21844
  addonId: null,
21140
21845
  access: "view"
21141
21846
  },
21847
+ "backup.listSchedules": {
21848
+ capName: "backup",
21849
+ capScope: "system",
21850
+ addonId: null,
21851
+ access: "view"
21852
+ },
21142
21853
  "backup.previewSchedule": {
21143
21854
  capName: "backup",
21144
21855
  capScope: "system",
@@ -21163,6 +21874,12 @@ Object.freeze({
21163
21874
  addonId: null,
21164
21875
  access: "create"
21165
21876
  },
21877
+ "backup.upsertSchedule": {
21878
+ capName: "backup",
21879
+ capScope: "system",
21880
+ addonId: null,
21881
+ access: "create"
21882
+ },
21166
21883
  "battery.wakeForStream": {
21167
21884
  capName: "battery",
21168
21885
  capScope: "device",
@@ -23191,6 +23908,60 @@ Object.freeze({
23191
23908
  addonId: null,
23192
23909
  access: "create"
23193
23910
  },
23911
+ "notificationRules.createRule": {
23912
+ capName: "notification-rules",
23913
+ capScope: "system",
23914
+ addonId: null,
23915
+ access: "create"
23916
+ },
23917
+ "notificationRules.deleteRule": {
23918
+ capName: "notification-rules",
23919
+ capScope: "system",
23920
+ addonId: null,
23921
+ access: "delete"
23922
+ },
23923
+ "notificationRules.getConditionCatalog": {
23924
+ capName: "notification-rules",
23925
+ capScope: "system",
23926
+ addonId: null,
23927
+ access: "view"
23928
+ },
23929
+ "notificationRules.getHistory": {
23930
+ capName: "notification-rules",
23931
+ capScope: "system",
23932
+ addonId: null,
23933
+ access: "view"
23934
+ },
23935
+ "notificationRules.getRule": {
23936
+ capName: "notification-rules",
23937
+ capScope: "system",
23938
+ addonId: null,
23939
+ access: "view"
23940
+ },
23941
+ "notificationRules.listRules": {
23942
+ capName: "notification-rules",
23943
+ capScope: "system",
23944
+ addonId: null,
23945
+ access: "view"
23946
+ },
23947
+ "notificationRules.setRuleEnabled": {
23948
+ capName: "notification-rules",
23949
+ capScope: "system",
23950
+ addonId: null,
23951
+ access: "create"
23952
+ },
23953
+ "notificationRules.testRule": {
23954
+ capName: "notification-rules",
23955
+ capScope: "system",
23956
+ addonId: null,
23957
+ access: "create"
23958
+ },
23959
+ "notificationRules.updateRule": {
23960
+ capName: "notification-rules",
23961
+ capScope: "system",
23962
+ addonId: null,
23963
+ access: "create"
23964
+ },
23194
23965
  "notifier.cancel": {
23195
23966
  capName: "notifier",
23196
23967
  capScope: "device",
@@ -24943,6 +25714,36 @@ Object.freeze({
24943
25714
  addonId: null,
24944
25715
  access: "create"
24945
25716
  },
25717
+ "terminalSession.close": {
25718
+ capName: "terminal-session",
25719
+ capScope: "system",
25720
+ addonId: null,
25721
+ access: "create"
25722
+ },
25723
+ "terminalSession.listProfiles": {
25724
+ capName: "terminal-session",
25725
+ capScope: "system",
25726
+ addonId: null,
25727
+ access: "view"
25728
+ },
25729
+ "terminalSession.listSessions": {
25730
+ capName: "terminal-session",
25731
+ capScope: "system",
25732
+ addonId: null,
25733
+ access: "view"
25734
+ },
25735
+ "terminalSession.openSession": {
25736
+ capName: "terminal-session",
25737
+ capScope: "system",
25738
+ addonId: null,
25739
+ access: "create"
25740
+ },
25741
+ "terminalSession.resize": {
25742
+ capName: "terminal-session",
25743
+ capScope: "system",
25744
+ addonId: null,
25745
+ access: "create"
25746
+ },
24946
25747
  "toast.onToast": {
24947
25748
  capName: "toast",
24948
25749
  capScope: "system",