@camstack/addon-smtp-nodemailer 1.2.4 → 1.2.6

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