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