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