@camstack/addon-export-hap 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.
@@ -35,7 +35,7 @@ let node_fs_promises = require("node:fs/promises");
35
35
  node_fs_promises = __toESM(node_fs_promises);
36
36
  let node_dgram = require("node:dgram");
37
37
  let node_os = require("node:os");
38
- //#region ../types/dist/event-category-D4HJq7Mw.mjs
38
+ //#region ../types/dist/event-category-BLcNejAE.mjs
39
39
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
40
40
  EventCategory["SystemBoot"] = "system.boot";
41
41
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -185,9 +185,6 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
185
185
  EventCategory["RecordingSegmentWritten"] = "recording.segment.written";
186
186
  EventCategory["RecordingPolicyFallback"] = "recording.policy.fallback";
187
187
  EventCategory["RecordingRetentionCompleted"] = "recording.retention.completed";
188
- /** Runner-sampled scrub thumbnail (~1/5 s/camera). Telemetry (D8): a lost
189
- * thumb is a scrub gap the recorder's keyframe backfill covers. */
190
- EventCategory["RecordingThumbSampled"] = "recording.thumb-sampled";
191
188
  /** Export render progress (0–100). Telemetry (D8): a lost tick is a stale
192
189
  * progress bar the client reconciles via `recordingExport.getExport`. */
193
190
  EventCategory["RecordingExportProgress"] = "recording.export.progress";
@@ -6852,7 +6849,6 @@ object({ deviceId: number() }), object({ deviceId: number() }), object({
6852
6849
  patch: record(string(), unknown())
6853
6850
  }), object({ success: literal(true) });
6854
6851
  object({ deviceId: number() }), unknown().nullable();
6855
- /** Shorthand to define a method schema */
6856
6852
  function method(input, output, options) {
6857
6853
  return {
6858
6854
  input,
@@ -6860,6 +6856,7 @@ function method(input, output, options) {
6860
6856
  kind: options?.kind ?? "query",
6861
6857
  auth: options?.auth ?? "protected",
6862
6858
  ...options?.access !== void 0 ? { access: options.access } : {},
6859
+ ...options?.caller !== void 0 ? { caller: options.caller } : {},
6863
6860
  timeoutMs: options?.timeoutMs
6864
6861
  };
6865
6862
  }
@@ -7541,16 +7538,23 @@ var StorageLocationDeclarationSchema = object({
7541
7538
  * Which node root the seeded `<id>:default` instance is placed under on a
7542
7539
  * FRESH install:
7543
7540
  * - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
7544
- * the appData volume. Right for small/durable data (backups, logs, models).
7541
+ * the appData volume. Right for small/durable data (logs, models).
7545
7542
  * - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
7546
7543
  * env is set, else falls back to the data root. Right for bulky, hot media
7547
7544
  * (recordings, event media) that should stay off the appData disk.
7545
+ * - `'backup'` — the dedicated backup volume (`CAMSTACK_BACKUP_ROOT`, default
7546
+ * `/backups` in the image) so archives live on their own mount rather than
7547
+ * filling the appData disk. Falls back to the data root when unset.
7548
7548
  *
7549
7549
  * Only affects the seeded default's `basePath`; operators can repoint any
7550
7550
  * location afterwards, and a `defaultsTo` slot inherits its parent's root
7551
7551
  * regardless of this field. Absent (the common case) is treated as `'data'`.
7552
7552
  */
7553
- defaultRoot: _enum(["data", "media"]).optional()
7553
+ defaultRoot: _enum([
7554
+ "data",
7555
+ "media",
7556
+ "backup"
7557
+ ]).optional()
7554
7558
  });
7555
7559
  var DecoderStatsSchema = object({
7556
7560
  inputFps: number(),
@@ -8267,6 +8271,59 @@ for (const l of AUDIO_MACRO_LABELS) {
8267
8271
  /** The complete taxonomy dictionary, keyed by kind. */
8268
8272
  var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
8269
8273
  /**
8274
+ * Notification-Center taxonomy — the fixed vocabulary the NC rule editor
8275
+ * offers as pickers instead of free text. Derived (never hand-listed) from the
8276
+ * single `EVENT_TAXONOMY` dictionary so it stays in lockstep with every other
8277
+ * taxonomy surface (timeline, filters, event page).
8278
+ *
8279
+ * Three buckets, mapped onto the rule editor's `stringList` conditions:
8280
+ * - `videoClasses` → detection classes (person / vehicle / animal + subs)
8281
+ * for the `classes` / `classesExclude` conditions.
8282
+ * - `audioKinds` → audio-analyzer sub kinds (`audio-scream`, …) shown in
8283
+ * the same class picker, grouped under an Audio header.
8284
+ * - `labels` → sensor + control taxonomy kinds (doorbell / contact /
8285
+ * lock / …) for the `sensorKinds` device-event condition.
8286
+ *
8287
+ * Each entry carries `parentKind` so the client can group video subs under
8288
+ * their macro and sensor/control kinds under their category. This surface is
8289
+ * served ADDITIVELY on the `nc.getConditionCatalog` bridge response — no cap
8290
+ * method, no codegen — so it ships train-free with an addon deploy.
8291
+ */
8292
+ /** One selectable taxonomy value: a stable kind id + display label + parent. */
8293
+ var NcTaxonomyEntrySchema = object({
8294
+ /** Stable kind id (e.g. 'person', 'car', 'audio-scream', 'doorbell'). */
8295
+ kind: string(),
8296
+ /** English fallback label (the UI translates via the event-kind i18n key). */
8297
+ label: string(),
8298
+ /** Macro/category parent for grouping ('car' → 'vehicle'); null for a top. */
8299
+ parentKind: string().nullable()
8300
+ });
8301
+ object({
8302
+ videoClasses: array(NcTaxonomyEntrySchema),
8303
+ audioKinds: array(NcTaxonomyEntrySchema),
8304
+ labels: array(NcTaxonomyEntrySchema)
8305
+ });
8306
+ function toEntry(kind, label, parentKind) {
8307
+ return {
8308
+ kind,
8309
+ label,
8310
+ parentKind
8311
+ };
8312
+ }
8313
+ /**
8314
+ * Build the NC taxonomy from `EVENT_TAXONOMY`. Insertion order is preserved
8315
+ * (macros before their subs), which the client relies on for stable grouping.
8316
+ */
8317
+ function buildNcTaxonomy() {
8318
+ const all = Object.values(EVENT_TAXONOMY);
8319
+ return {
8320
+ videoClasses: all.filter((e) => e.category === "detection").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8321
+ audioKinds: all.filter((e) => e.category === "audio" && e.level === "sub").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8322
+ labels: all.filter((e) => e.category === "sensor" || e.category === "control").map((e) => toEntry(e.kind, e.label, e.parentKind))
8323
+ };
8324
+ }
8325
+ Object.freeze(buildNcTaxonomy());
8326
+ /**
8270
8327
  * Error types for the safe expression engine. Two distinct classes so callers
8271
8328
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
8272
8329
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -8902,6 +8959,644 @@ var AccessoryKind = {
8902
8959
  AccessoryKind.Siren, AccessoryKind.Floodlight, AccessoryKind.Spotlight, AccessoryKind.PirSensor, AccessoryKind.Chime, AccessoryKind.Autotrack, AccessoryKind.Nightvision, AccessoryKind.PrivacyMask;
8903
8960
  DeviceFeature.BatteryOperated;
8904
8961
  /**
8962
+ * Shared geometry vocabulary for on-frame shape caps — privacy-mask,
8963
+ * motion-zones, and the detection zones/lines editor all speak this one
8964
+ * language so a single drawing-plane editor and the providers stay
8965
+ * decoupled from each cap's storage.
8966
+ *
8967
+ * All coordinates are normalized 0..1 of the camera frame (top-left
8968
+ * origin). Each cap composes the SUBSET of shape kinds it supports and
8969
+ * advertises it via `supportedShapes` in its `getOptions`.
8970
+ */
8971
+ /** A normalized 0..1 point (top-left origin). */
8972
+ var MaskPointSchema = object({
8973
+ x: number(),
8974
+ y: number()
8975
+ });
8976
+ /** Axis-aligned rectangle (normalized 0..1). */
8977
+ var MaskRectShapeSchema = object({
8978
+ kind: literal("rect"),
8979
+ x: number(),
8980
+ y: number(),
8981
+ width: number(),
8982
+ height: number()
8983
+ });
8984
+ /** Free polygon — an ordered list of normalized vertices (≥3). */
8985
+ var MaskPolygonShapeSchema = object({
8986
+ kind: literal("polygon"),
8987
+ points: array(MaskPointSchema)
8988
+ });
8989
+ /** Boolean cell grid — row-major, length === gridWidth*gridHeight. */
8990
+ var MaskGridShapeSchema = object({
8991
+ kind: literal("grid"),
8992
+ gridWidth: number(),
8993
+ gridHeight: number(),
8994
+ cells: array(boolean())
8995
+ });
8996
+ discriminatedUnion("kind", [
8997
+ MaskRectShapeSchema,
8998
+ MaskPolygonShapeSchema,
8999
+ MaskGridShapeSchema,
9000
+ object({
9001
+ kind: literal("line"),
9002
+ points: array(MaskPointSchema)
9003
+ })
9004
+ ]);
9005
+ /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
9006
+ var MaskShapeKindSchema = _enum([
9007
+ "rect",
9008
+ "polygon",
9009
+ "grid",
9010
+ "line"
9011
+ ]);
9012
+ /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
9013
+ var MaskPolygonVerticesSchema = object({
9014
+ min: number(),
9015
+ max: number()
9016
+ });
9017
+ /** Grid dimensions when a cap supports 'grid'. */
9018
+ var MaskGridDimsSchema = object({
9019
+ width: number(),
9020
+ height: number()
9021
+ });
9022
+ /**
9023
+ * notification-rules — the Notification Center rule surface (P1 core).
9024
+ *
9025
+ * Spec: `docs/superpowers/specs/2026-07-22-notification-center-requirements.md`
9026
+ * (operator decisions D-1/D-2/D-3 are binding):
9027
+ *
9028
+ * - D-2: rule EVALUATION lives in `addon-post-analysis` (the
9029
+ * `notification-center` module), hooked on the durable persistence
9030
+ * moments (object-event insert, TrackCloser.closeExpired) with a
9031
+ * persisted outbox + retry — never the lossy telemetry bus (D8).
9032
+ * - D-3: urgency belongs to the RULE. `delivery: 'immediate'` fires on the
9033
+ * FIRST persisted detection matching the conditions (per-track dedup,
9034
+ * `maxPerTrack` fixed at 1 — see {@link NC_MAX_PER_TRACK_IMMEDIATE});
9035
+ * `delivery: 'track-end'` evaluates the finalized track record at close.
9036
+ * - DISPATCH stays behind `notification-output` (rules reference targets
9037
+ * by id; per-backend params are a passthrough blob capped by the
9038
+ * target kind's own caps/degrade engine).
9039
+ *
9040
+ * P1 scope: admin-authored rules only (`createdBy` stamped from the
9041
+ * server-injected caller identity — the first `caller: 'required'`
9042
+ * adopter). The P1 condition subset is: devices, classes(+exclude),
9043
+ * minConfidence, admin zones (any/all + exclude), weekly schedule
9044
+ * windows, and the optional label/identity/plate matchers. User rules,
9045
+ * private zones, per-recipient fan-out and the wider condition table are
9046
+ * P2+ (see spec §7).
9047
+ *
9048
+ * All schemas here are the single source of truth — `NcRule` etc. are
9049
+ * `z.infer` exports; no duplicate interfaces (the advanced-notifier
9050
+ * schema/interface drift is explicitly not repeated).
9051
+ */
9052
+ /**
9053
+ * D-3: the trigger/urgency of a rule — which persistence moment evaluates it.
9054
+ * The value maps 1:1 onto the evaluated record kind:
9055
+ * - `immediate` ↔ object-event persist (lowest-latency detection burst)
9056
+ * - `track-end` ↔ TrackCloser.closeExpired (finalized track record)
9057
+ * - `device-event` ↔ SensorEventStore insert (doorbell press / sensor state
9058
+ * change of a LINKED device, one row per linked camera)
9059
+ * - `package-event` ↔ PackageDropDetector object-event insert (a `package`
9060
+ * delivery / pick-up)
9061
+ *
9062
+ * `immediate`/`track-end` carry the D-3 urgency semantics; `device-event`/
9063
+ * `package-event` are pure trigger kinds (no urgency dimension). Extending
9064
+ * this one field keeps the schema additive — a rule still declares exactly
9065
+ * one trigger.
9066
+ */
9067
+ var NcDeliverySchema = _enum([
9068
+ "immediate",
9069
+ "track-end",
9070
+ "device-event",
9071
+ "package-event"
9072
+ ]);
9073
+ /** Weekly schedule — OR of windows; absence on the rule = always active. */
9074
+ var NcScheduleSchema = object({
9075
+ windows: array(object({
9076
+ /** Days of week the window STARTS on (0 = Sunday … 6 = Saturday). */
9077
+ days: array(number().int().min(0).max(6)).min(1),
9078
+ startMinute: number().int().min(0).max(1439),
9079
+ endMinute: number().int().min(0).max(1439)
9080
+ })).min(1),
9081
+ /** IANA timezone; default = hub host timezone. */
9082
+ timezone: string().optional(),
9083
+ /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
9084
+ invert: boolean().optional()
9085
+ });
9086
+ /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
9087
+ var NcPlateMatcherSchema = object({
9088
+ values: array(string().min(1)).min(1),
9089
+ /** Max Levenshtein distance after normalization (uppercase alphanumeric). */
9090
+ maxDistance: number().int().min(0).max(3).default(1)
9091
+ });
9092
+ /**
9093
+ * Occupancy condition (DEVICE-EVENT trigger). Fires on a ZoneAnalytics
9094
+ * occupancy edge for a device — optionally narrowed to a single admin
9095
+ * `zoneId` and/or object `className`. `op` selects the edge/threshold:
9096
+ * - `became-occupied` (default) — count crossed 0 → ≥ `count`
9097
+ * - `became-free` — count crossed ≥ `count` → below it
9098
+ * - `>=` / `<=` — count is at/over or at/under `count`
9099
+ * `sustainSeconds` requires the condition hold continuously that long
9100
+ * before firing (debounces flicker; 0 = fire on the first matching edge).
9101
+ * Fail-closed: no ZoneAnalytics snapshot / missing zone / null snapshot ⇒
9102
+ * the condition never matches. Confirmed edge-state survives addon restarts
9103
+ * (declared SQLite collection, reseeded on boot).
9104
+ */
9105
+ var NcOccupancyConditionSchema = object({
9106
+ /** Admin zone id to scope the count to; absent = whole-frame occupancy. */
9107
+ zoneId: string().optional(),
9108
+ /** Object class to count; absent = any class. */
9109
+ className: string().optional(),
9110
+ op: _enum([
9111
+ "became-occupied",
9112
+ "became-free",
9113
+ ">=",
9114
+ "<="
9115
+ ]).default("became-occupied"),
9116
+ count: number().int().min(0).default(1),
9117
+ sustainSeconds: number().int().min(0).max(3600).default(15)
9118
+ });
9119
+ /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
9120
+ var NcZoneConditionSchema = object({
9121
+ ids: array(string().min(1)).min(1),
9122
+ /** Quantifier over `ids` — at least one / every one visited. */
9123
+ match: _enum(["any", "all"]).default("any")
9124
+ });
9125
+ /**
9126
+ * The P1 condition set — a flat AND of groups; absent group = pass;
9127
+ * membership lists are OR within the list (spec §2.3).
9128
+ */
9129
+ var NcConditionsSchema = object({
9130
+ /** Device scope — absent = all devices. */
9131
+ devices: array(number()).optional(),
9132
+ /** Detector class names (any overlap with the record's class set). */
9133
+ classes: array(string().min(1)).optional(),
9134
+ /** Veto classes — any overlap fails the rule. */
9135
+ classesExclude: array(string().min(1)).optional(),
9136
+ /** Minimum detection confidence 0–1 (fails when the record has none). */
9137
+ minConfidence: number().min(0).max(1).optional(),
9138
+ /** Admin zone membership over event `zones` / track `zonesVisited`. */
9139
+ zones: NcZoneConditionSchema.optional(),
9140
+ /** Veto zones — any hit fails the rule. */
9141
+ zonesExclude: array(string().min(1)).optional(),
9142
+ /**
9143
+ * Exact (case-insensitive) match on the record's collapsed `label`
9144
+ * (identity name / plate text / subclass).
9145
+ */
9146
+ labelEquals: array(string().min(1)).optional(),
9147
+ /**
9148
+ * Identity matcher. P1 boundary: matched against the record's collapsed
9149
+ * `label` (the identity display name propagated by the face pipeline) —
9150
+ * identity-ID matching rides in P2 when identity ids reach the record.
9151
+ */
9152
+ identities: array(string().min(1)).optional(),
9153
+ /** Fuzzy plate matcher against the record's `label` (plate text). */
9154
+ plates: NcPlateMatcherSchema.optional(),
9155
+ /**
9156
+ * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
9157
+ * Same P1 boundary: matched against the record's collapsed `label` (the
9158
+ * identity display name). A record with NO label passes (nothing to
9159
+ * exclude), unlike the include variant which fails on an absent label.
9160
+ */
9161
+ identitiesExclude: array(string().min(1)).optional(),
9162
+ /**
9163
+ * Minimum server-computed key-event importance in [0,1] (`Track.importance`).
9164
+ * TRACK-END only: importance is scored at track close, so it does not exist
9165
+ * at immediate / object-event evaluation time (see catalog `appliesTo`). At
9166
+ * close the value is threaded via the close-time info (the `Track` clone is
9167
+ * captured before the DB row is updated, so it would otherwise read stale).
9168
+ * Fails when the record carries no importance (never guess quality — the
9169
+ * `minConfidence` precedent). MVP cut: a single scalar threshold.
9170
+ */
9171
+ minImportance: number().min(0).max(1).optional(),
9172
+ /**
9173
+ * Minimum track dwell in SECONDS — `(lastSeen − firstSeen) / 1000`.
9174
+ * TRACK-END only: an `immediate` / object-event subject has no closed
9175
+ * lifespan, so a dwell condition never matches immediate delivery
9176
+ * (documented choice — the object-event record carries no `firstSeen`,
9177
+ * so dwell cannot be computed from what the subject actually carries).
9178
+ */
9179
+ minDwellSeconds: number().min(0).optional(),
9180
+ /**
9181
+ * Detection provenance filter. `any` (default / absent) matches every
9182
+ * source; otherwise the subject's source must equal it. Legacy records
9183
+ * with no stamped source are treated as `pipeline`. The union spans both
9184
+ * record kinds — object events carry `pipeline` | `onboard`, synthetic
9185
+ * tracks carry `sensor`.
9186
+ */
9187
+ source: _enum([
9188
+ "pipeline",
9189
+ "onboard",
9190
+ "sensor",
9191
+ "any"
9192
+ ]).optional(),
9193
+ /**
9194
+ * Minimum identity / plate MATCH confidence in [0,1] — DISTINCT from the
9195
+ * detector `minConfidence` (that gates the object-detection score; this
9196
+ * gates the recognition/OCR match score). Fails when the subject carries
9197
+ * no label-match confidence (never guess). TRACK-END only: the confidence
9198
+ * lives on the recognition result and reaches the subject at track close.
9199
+ *
9200
+ * What it measures precisely (plumbed at track close — the closer threads
9201
+ * the value into `NcTrackClosedInfo.labelConfidence`, the same seam as
9202
+ * `importance`): the BEST recognition match confidence observed for the
9203
+ * label the track carries at close — for a face, the peak cosine similarity
9204
+ * of the ASSIGNED identity (`FaceMatch.score`, reset on an identity switch);
9205
+ * for a plate, the peak OCR read score of the best-held plate
9206
+ * (`plateText.confidence`). When BOTH a face and a plate were recognized on
9207
+ * one track the higher of the two is used. A track that ended with no
9208
+ * confident identity/plate match carries no value, so the condition fails
9209
+ * closed for it (an un-recognized subject).
9210
+ */
9211
+ minLabelConfidence: number().min(0).max(1).optional(),
9212
+ /**
9213
+ * DEVICE-EVENT only. Raw device event-type tokens (`EventFire.eventType`,
9214
+ * e.g. a doorbell `press` / `press_long`) — matched case-insensitively
9215
+ * against the token carried on the device-event subject (extracted from the
9216
+ * event-emitter runtime slice's `lastEvent.eventType`). Fails when the
9217
+ * subject carries no token. Doorbell-pulse / passive-sensor kinds emit no
9218
+ * eventType, so gate those with {@link sensorKinds} instead.
9219
+ */
9220
+ eventTypeTokens: array(string().min(1)).optional(),
9221
+ /**
9222
+ * DEVICE-EVENT only. Sensor/control taxonomy kinds (e.g. `doorbell`,
9223
+ * `contact`, `button`, `device-event`) — matched against the persisted
9224
+ * `SensorEvent.kind` (see `sensor-event-kinds.ts`). Membership is OR.
9225
+ */
9226
+ sensorKinds: array(string().min(1)).optional(),
9227
+ /**
9228
+ * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
9229
+ * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
9230
+ * when the subject's phase does not match (a subject always carries a phase
9231
+ * on the package-event trigger).
9232
+ */
9233
+ packagePhase: _enum([
9234
+ "delivered",
9235
+ "picked-up",
9236
+ "both"
9237
+ ]).optional(),
9238
+ /**
9239
+ * PERSONAL-RULE custom zones (viewer-drawn). Inline normalized polygons
9240
+ * (MaskShape vocabulary). A record passes when its bbox overlaps ANY
9241
+ * listed polygon (ZoneEngine membership semantics). Evaluated only when
9242
+ * the subject carries a bbox; absent bbox ⇒ the condition FAILS.
9243
+ */
9244
+ customZones: array(MaskPolygonShapeSchema).optional(),
9245
+ /**
9246
+ * DEVICE-EVENT only. ZoneAnalytics occupancy edge — fires when a device's
9247
+ * (optionally zone/class-scoped) occupancy count crosses the configured
9248
+ * threshold and holds for `sustainSeconds`. Fail-closed on missing
9249
+ * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
9250
+ */
9251
+ occupancy: NcOccupancyConditionSchema.optional()
9252
+ });
9253
+ /** One delivery target: a `notification-output` Target ref + passthrough params. */
9254
+ var NcRuleTargetSchema = object({
9255
+ /** `notification-output` Target id. */
9256
+ targetId: string().min(1),
9257
+ /**
9258
+ * Per-backend passthrough. Recognized keys are mapped onto the canonical
9259
+ * Notification (`priority`, `level`, `sound`, `clickUrl`, `ttl`); the
9260
+ * degrade engine drops what the backend can't render.
9261
+ */
9262
+ params: record(string(), unknown()).optional()
9263
+ });
9264
+ /**
9265
+ * Media attachment policy (P1 still-image subset).
9266
+ * - `best` — the best AVAILABLE subject image at dispatch time (D-3).
9267
+ * - `best-matching` — the media that explains WHY the rule fired: a rule
9268
+ * matched on identities attaches the subject's `faceCrop`, one matched on
9269
+ * plates attaches the `plateCrop`; a rule with no identity/plate condition
9270
+ * (or when the specific crop is missing) degrades to `best`, then
9271
+ * `keyFrame`, then no attachment — never delaying the send. The matched
9272
+ * condition summary is frozen on the outbox row at enqueue (like the rule
9273
+ * name), so the choice never drifts from the record that fired it.
9274
+ * - `keyFrame` — the clean scene frame (no subject box).
9275
+ * - `none` — no attachment.
9276
+ */
9277
+ var NcMediaPolicySchema = object({ attach: _enum([
9278
+ "best",
9279
+ "best-matching",
9280
+ "keyFrame",
9281
+ "none"
9282
+ ]).default("best") });
9283
+ /** Throttle — cooldown survives restarts (rebuilt from the outbox on boot). */
9284
+ var NcThrottleSchema = object({
9285
+ cooldownSec: number().int().min(0).max(86400).default(60),
9286
+ /** `rule` = one shared cooldown; `rule-device` = per-camera cooldown. */
9287
+ scope: _enum(["rule", "rule-device"]).default("rule-device")
9288
+ });
9289
+ /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
9290
+ var NcRuleInputSchema = object({
9291
+ name: string().min(1).max(200),
9292
+ enabled: boolean().default(true),
9293
+ delivery: NcDeliverySchema,
9294
+ conditions: NcConditionsSchema.default({}),
9295
+ schedule: NcScheduleSchema.optional(),
9296
+ targets: array(NcRuleTargetSchema).min(1),
9297
+ media: NcMediaPolicySchema.default({ attach: "best" }),
9298
+ throttle: NcThrottleSchema.default({
9299
+ cooldownSec: 60,
9300
+ scope: "rule-device"
9301
+ }),
9302
+ /** `{{var}}` templating over camera/class/label/zones/confidence/time. */
9303
+ template: object({
9304
+ title: string().max(500).optional(),
9305
+ body: string().max(2e3).optional()
9306
+ }).optional(),
9307
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
9308
+ priority: number().int().min(1).max(5).default(3),
9309
+ /**
9310
+ * Ownership/visibility key. Absent = admin/global rule (unchanged legacy
9311
+ * behaviour, visible to all, read-only in the viewer). Present = personal
9312
+ * rule owned by this userId. Server-stamped; never trusted from a client.
9313
+ */
9314
+ ownerUserId: string().optional()
9315
+ });
9316
+ /**
9317
+ * Partial patch for `updateRule` — any subset of the input fields, plus the
9318
+ * persisted-only {@link NcRuleSchema} `disabledTargetIds` set. The latter is
9319
+ * NOT a client-authored input field (it lives on the persisted rule, not the
9320
+ * input), so it is added here explicitly to let the store's per-target opt-out
9321
+ * toggle round-trip through the shared `update` path. Viewer opt-out mutations
9322
+ * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
9323
+ * `updateRule` patch.
9324
+ */
9325
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
9326
+ /** A persisted rule. */
9327
+ var NcRuleSchema = NcRuleInputSchema.extend({
9328
+ id: string(),
9329
+ /** userId of the admin who created the rule (server-stamped caller). */
9330
+ createdBy: string(),
9331
+ createdAt: number(),
9332
+ updatedAt: number(),
9333
+ /**
9334
+ * Per-target opt-out set. A targetId here is suppressed for THIS rule at
9335
+ * send time. Only a target's OWNER may add/remove its id (server-checked
9336
+ * in `nc.setRuleTargetEnabled`). Defaults to empty.
9337
+ */
9338
+ disabledTargetIds: array(string()).default([])
9339
+ });
9340
+ var NcTestResultSchema = object({
9341
+ recordId: string(),
9342
+ recordKind: _enum([
9343
+ "object-event",
9344
+ "track",
9345
+ "device-event",
9346
+ "package-event"
9347
+ ]),
9348
+ deviceId: number(),
9349
+ timestamp: number(),
9350
+ wouldFire: boolean(),
9351
+ /** Condition id that failed (first failing group), when `wouldFire` is false. */
9352
+ failedCondition: string().optional(),
9353
+ className: string().optional(),
9354
+ label: string().optional()
9355
+ });
9356
+ var NcConditionDescriptorSchema = object({
9357
+ /** Field id inside `NcConditions` (or `'schedule'` for the rule-level group). */
9358
+ id: string(),
9359
+ group: _enum([
9360
+ "scope",
9361
+ "class",
9362
+ "zones",
9363
+ "quality",
9364
+ "label",
9365
+ "schedule",
9366
+ "device",
9367
+ "package",
9368
+ "occupancy"
9369
+ ]),
9370
+ label: string(),
9371
+ /** Editor widget the UI renders — never hardcode per-condition forms. */
9372
+ valueType: _enum([
9373
+ "deviceIdList",
9374
+ "stringList",
9375
+ "number01",
9376
+ "number",
9377
+ "sourceSelect",
9378
+ "zoneSelection",
9379
+ "zoneIdList",
9380
+ "schedule",
9381
+ "plateMatcher",
9382
+ "packagePhase",
9383
+ "polygonDraw",
9384
+ "occupancy"
9385
+ ]),
9386
+ operator: _enum([
9387
+ "in",
9388
+ "notIn",
9389
+ "anyOf",
9390
+ "allOf",
9391
+ "gte",
9392
+ "fuzzyIn",
9393
+ "withinSchedule"
9394
+ ]),
9395
+ /** Which delivery kinds the condition applies to. */
9396
+ appliesTo: array(NcDeliverySchema),
9397
+ phase: string(),
9398
+ description: string().optional()
9399
+ });
9400
+ /**
9401
+ * The delivery lifecycle status of a history row — a straight read of the
9402
+ * durable outbox row's own status (single source of truth):
9403
+ * - `pending` — enqueued, in-flight or retrying with backoff
9404
+ * - `sent` — delivered (terminal)
9405
+ * - `dead` — dead-lettered after exhausting retries / a permanent
9406
+ * backend rejection / a deleted target (terminal; carries
9407
+ * the failure `error`)
9408
+ *
9409
+ * P1 has no `suppressed-quiet-hours` / `snoozed` states — those ride the P2
9410
+ * user dimension (quiet hours / snooze) and are additive when they land.
9411
+ */
9412
+ var NcHistoryStatusSchema = _enum([
9413
+ "pending",
9414
+ "sent",
9415
+ "dead"
9416
+ ]);
9417
+ /** The evaluated record kind a history row descends from (one per trigger). */
9418
+ var NcHistoryRecordKindSchema = _enum([
9419
+ "object-event",
9420
+ "track-end",
9421
+ "device-event",
9422
+ "package-event"
9423
+ ]);
9424
+ /** Subject summary frozen on the row at fire time (survives rule/record edits). */
9425
+ var NcHistorySubjectSchema = object({
9426
+ className: string(),
9427
+ label: string().optional(),
9428
+ confidence: number().optional(),
9429
+ zones: array(string()),
9430
+ timestamp: number()
9431
+ });
9432
+ /**
9433
+ * One delivery-history row. This is a read-only VIEW over the durable
9434
+ * outbox row (single source of truth — the same row the drain loop drives;
9435
+ * NO second write path, so history can never drift from delivery state).
9436
+ * The §3.2 fields map directly: `ruleId`/`targetId`/`deviceId` are columns,
9437
+ * `eventRef` is `recordKind`+`recordId`, `timestamps` are `createdAt`
9438
+ * (fire) / `updatedAt` (last transition), `status` + `error` are the
9439
+ * lifecycle. `ruleName` + `subject` are the intent snapshot frozen at
9440
+ * enqueue. `userId?` (per-recipient history) is P2 — no user dimension in
9441
+ * P1 (admin scope only).
9442
+ */
9443
+ var NcHistoryEntrySchema = object({
9444
+ /** Outbox row id — the stable dedup id `ruleId:dedupRef:targetId`. */
9445
+ id: string(),
9446
+ ruleId: string(),
9447
+ /** Rule name frozen at fire time (outlives a later rename / delete). */
9448
+ ruleName: string(),
9449
+ /** The rule urgency/trigger that produced this delivery. */
9450
+ delivery: NcDeliverySchema,
9451
+ targetId: string(),
9452
+ deviceId: number(),
9453
+ recordKind: NcHistoryRecordKindSchema,
9454
+ /** Event / track ref of the evaluated record (§3.2 `eventRef`). */
9455
+ recordId: string(),
9456
+ /** Present for track-scoped deliveries (object-event / track-end). */
9457
+ trackId: string().optional(),
9458
+ status: NcHistoryStatusSchema,
9459
+ /** Delivery attempts made so far. */
9460
+ attempts: number().int(),
9461
+ /** Fire time (outbox enqueue). */
9462
+ createdAt: number(),
9463
+ /** Last transition time (terminal for sent / dead). */
9464
+ updatedAt: number(),
9465
+ /** Failure detail — present on a `dead` row. */
9466
+ error: string().optional(),
9467
+ subject: NcHistorySubjectSchema
9468
+ });
9469
+ /**
9470
+ * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
9471
+ * AND; absent = unbounded on that axis. `since`/`until` bound the fire time
9472
+ * (`createdAt`, epoch ms, inclusive). `limit` is clamped to
9473
+ * {@link NC_HISTORY_LIMIT_MAX}. `userId` (per-recipient filtering) is P2.
9474
+ */
9475
+ var NcHistoryFilterSchema = object({
9476
+ ruleId: string().optional(),
9477
+ deviceId: number().optional(),
9478
+ status: NcHistoryStatusSchema.optional(),
9479
+ since: number().optional(),
9480
+ until: number().optional(),
9481
+ limit: number().int().min(1).max(500).default(100)
9482
+ });
9483
+ 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 }), {
9484
+ kind: "mutation",
9485
+ auth: "admin",
9486
+ caller: "required"
9487
+ }), method(object({
9488
+ ruleId: string(),
9489
+ patch: NcRulePatchSchema
9490
+ }), object({ rule: NcRuleSchema }), {
9491
+ kind: "mutation",
9492
+ auth: "admin",
9493
+ caller: "required"
9494
+ }), method(object({ ruleId: string() }), object({ success: literal(true) }), {
9495
+ kind: "mutation",
9496
+ auth: "admin"
9497
+ }), method(object({
9498
+ ruleId: string(),
9499
+ enabled: boolean()
9500
+ }), object({ success: literal(true) }), {
9501
+ kind: "mutation",
9502
+ auth: "admin"
9503
+ }), method(object({
9504
+ rule: NcRuleInputSchema,
9505
+ lookbackMinutes: number().int().min(1).max(1440).default(60)
9506
+ }), object({ results: array(NcTestResultSchema) }), {
9507
+ kind: "mutation",
9508
+ auth: "admin"
9509
+ }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
9510
+ /**
9511
+ * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
9512
+ *
9513
+ * Spec: `docs/superpowers/specs/2026-07-24-nc-occupancy-timelapse-design.md`
9514
+ * §3.2/§3.3.
9515
+ *
9516
+ * Deliberately NOT a capability definition and NOT an `NcRule`:
9517
+ * - Every `NcDelivery` member is a *persisted-pipeline-record* trigger. A
9518
+ * timelapse fires on a SCHEDULE WINDOW BOUNDARY, evaluates no pipeline
9519
+ * record, and produces a video it assembled itself — so it rides no
9520
+ * delivery-enum member (the enum is frozen) and no cap method. This file is
9521
+ * a plain typed schema; it does NOT go through `npm run codegen`.
9522
+ * - It shares only the delivery leg (`notification-output.send`) and the
9523
+ * persistence/ownership patterns with the Notification Center, reusing
9524
+ * {@link NcScheduleSchema} (weekly windows, midnight-crossing, invertible)
9525
+ * and {@link NcRuleTargetSchema} (target ref + passthrough params).
9526
+ *
9527
+ * Ownership is SERVER-DERIVED. `ownerUserId` / `createdBy` / `createdAt` /
9528
+ * `updatedAt` / `id` / `lastGeneratedAt` live on the PERSISTED rule only —
9529
+ * {@link TimelapseRuleInputSchema} and {@link TimelapseRulePatchSchema} do not
9530
+ * carry them, so a forged client payload can never claim or re-own a rule
9531
+ * (Zod strips unknown keys). The store stamps them from the resolved caller.
9532
+ */
9533
+ /** `{{var}}` templating over camera/rule/time — same vocabulary as `NcRule`. */
9534
+ var TimelapseTemplateSchema = object({
9535
+ title: string().max(500).optional(),
9536
+ body: string().max(2e3).optional()
9537
+ });
9538
+ var NameField = string().min(1).max(200);
9539
+ var DeviceIdsField = array(number()).min(1);
9540
+ var CadenceSecField = number().int().min(2).max(3600);
9541
+ var FramerateField = number().int().min(1).max(60);
9542
+ var TargetsField = array(NcRuleTargetSchema).min(1);
9543
+ var PriorityField = number().int().min(1).max(5);
9544
+ /**
9545
+ * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
9546
+ * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
9547
+ * here (see the ownership note above).
9548
+ */
9549
+ var TimelapseRuleInputSchema = object({
9550
+ name: NameField,
9551
+ enabled: boolean().default(true),
9552
+ /** Cameras sampled by this rule — one scratch dir + one artifact per device. */
9553
+ deviceIds: DeviceIdsField,
9554
+ /**
9555
+ * Activation window(s). REQUIRED (unlike `NcRule`, where an absent schedule
9556
+ * means "always active"): a timelapse is defined by its window boundaries —
9557
+ * open clears the scratch, close assembles and delivers.
9558
+ */
9559
+ schedule: NcScheduleSchema,
9560
+ /** Force-snapshot cadence inside the window, seconds (predecessor parity). */
9561
+ cadenceSec: CadenceSecField.default(15),
9562
+ /** Output frames per second of the assembled mp4 (predecessor parity). */
9563
+ framerate: FramerateField.default(10),
9564
+ /** `notification-output` targets the finished video/thumbnail is sent to. */
9565
+ targets: TargetsField,
9566
+ template: TimelapseTemplateSchema.optional(),
9567
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
9568
+ priority: PriorityField.default(3)
9569
+ });
9570
+ object({
9571
+ name: NameField.optional(),
9572
+ enabled: boolean().optional(),
9573
+ deviceIds: DeviceIdsField.optional(),
9574
+ schedule: NcScheduleSchema.optional(),
9575
+ cadenceSec: CadenceSecField.optional(),
9576
+ framerate: FramerateField.optional(),
9577
+ targets: TargetsField.optional(),
9578
+ template: TimelapseTemplateSchema.nullable().optional(),
9579
+ priority: PriorityField.optional()
9580
+ });
9581
+ TimelapseRuleInputSchema.extend({
9582
+ id: string(),
9583
+ /**
9584
+ * Ownership/visibility key. Absent = admin/global rule (visible to all).
9585
+ * Present = personal rule owned by this userId. Server-stamped from the
9586
+ * resolved caller; never trusted from a client payload.
9587
+ */
9588
+ ownerUserId: string().optional(),
9589
+ /**
9590
+ * Epoch-ms of the last successful generation — the 1-hour re-generation
9591
+ * guard's durable state (predecessor parity). Absent = never generated.
9592
+ */
9593
+ lastGeneratedAt: number().optional(),
9594
+ /** userId of the caller who created the rule (server-stamped). */
9595
+ createdBy: string(),
9596
+ createdAt: number(),
9597
+ updatedAt: number()
9598
+ });
9599
+ /**
8905
9600
  * Generic device-level status snapshot. Auto-registered by `BaseDevice`
8906
9601
  * for every device, regardless of provider — the kernel needs a uniform
8907
9602
  * cap-keyed slice for the basic device flags every consumer expects to
@@ -10975,6 +11670,22 @@ var CameraMetricsSchema = object({
10975
11670
  ])
10976
11671
  });
10977
11672
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
11673
+ /**
11674
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
11675
+ * within the frame, so the executor can re-cut a leaf child ROI at native
11676
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
11677
+ */
11678
+ var NativeCropRefSchema = object({
11679
+ /** Handle keying the retained native surface (node-pinned to its owner). */
11680
+ handle: FrameHandleSchema,
11681
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
11682
+ cropFrameSpace: object({
11683
+ x: number(),
11684
+ y: number(),
11685
+ w: number(),
11686
+ h: number()
11687
+ })
11688
+ });
10978
11689
  var ModelFormatSchema$1 = _enum([
10979
11690
  "onnx",
10980
11691
  "coreml",
@@ -11250,7 +11961,22 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
11250
11961
  * Omitted ⇒ the runner's default device (current single-engine
11251
11962
  * behaviour). Selects WHICH device pool of the node runs the call.
11252
11963
  */
11253
- deviceKey: string().optional()
11964
+ deviceKey: string().optional(),
11965
+ /**
11966
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
11967
+ * when the parent crop was resolved from the frame's retained NATIVE
11968
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
11969
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
11970
+ * resolution from that surface — the SAME quality path faces already
11971
+ * had — instead of the downscaled parent tile. `handle` keys the native
11972
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
11973
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
11974
+ * the executor's crop-normalized child ROI back into frame-normalized
11975
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
11976
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
11977
+ * (today's behaviour on the fallback path).
11978
+ */
11979
+ nativeCropRef: NativeCropRefSchema.optional()
11254
11980
  }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
11255
11981
  engine: PipelineEngineChoiceSchema.optional(),
11256
11982
  steps: array(PipelineStepInputSchema).min(1),
@@ -11466,7 +12192,11 @@ var DetailResultSchema = object({
11466
12192
  bbox: NativeCropBboxSchema.optional(),
11467
12193
  embedding: string().optional(),
11468
12194
  label: string().optional(),
11469
- alignedCropJpeg: string().optional()
12195
+ alignedCropJpeg: string().optional(),
12196
+ /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
12197
+ * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
12198
+ * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
12199
+ nativeFaceShortSidePx: number().optional()
11470
12200
  });
11471
12201
  /**
11472
12202
  * Per-camera tunable ranges + defaults. Single source of truth used
@@ -11480,6 +12210,12 @@ var motionCooldownMsField = {
11480
12210
  default: 3e4,
11481
12211
  step: 500
11482
12212
  };
12213
+ var maxSessionHoldMsField = {
12214
+ min: 0,
12215
+ max: 6e5,
12216
+ default: 12e4,
12217
+ step: 5e3
12218
+ };
11483
12219
  var motionFpsField = {
11484
12220
  min: 1,
11485
12221
  max: 30,
@@ -11627,6 +12363,19 @@ var RunnerCameraConfigSchema = object({
11627
12363
  "on-motion"
11628
12364
  ]).default("always-on"),
11629
12365
  motionCooldownMs: number().min(motionCooldownMsField.min).default(motionCooldownMsField.default),
12366
+ /**
12367
+ * Orchestrator-side on-motion session-hold cap (ms). While an on-motion
12368
+ * detection session is active and ≥1 confirmed non-stationary track is
12369
+ * still live, the orchestrator keeps the session open past
12370
+ * `motionCooldownMs` (a slowly-moving subject can stop re-triggering the
12371
+ * camera's VMD yet is still being tracked frame-to-frame) — up to this many
12372
+ * ms since the session opened, after which it closes regardless. `0`
12373
+ * disables the hold (legacy cooldown-only teardown). Not consumed by the
12374
+ * runner itself — carried here so it shares the per-camera device-settings
12375
+ * surface with `motionCooldownMs`; the orchestrator reads it off the
12376
+ * resolved `CameraDetectionConfig`.
12377
+ */
12378
+ maxSessionHoldMs: number().min(maxSessionHoldMsField.min).max(maxSessionHoldMsField.max).optional(),
11630
12379
  motionFps: number().min(motionFpsField.min).max(motionFpsField.max).default(motionFpsField.default),
11631
12380
  detectionFps: number().min(detectionFpsField.min).max(detectionFpsField.max).default(detectionFpsField.default),
11632
12381
  motionStreamId: string(),
@@ -11716,7 +12465,7 @@ var RunnerCameraConfigSchema = object({
11716
12465
  */
11717
12466
  inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
11718
12467
  });
11719
- 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;
12468
+ 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;
11720
12469
  /**
11721
12470
  * Runtime load summary returned by `getLocalLoad`. Used by the orchestrator's
11722
12471
  * load-balancing levels (L2 capacity-based, L3 hardware-aware) to decide
@@ -11827,71 +12576,10 @@ DeviceType.Light, DeviceType.Siren, DeviceType.Switch, method(object({
11827
12576
  lastChangedAt: number()
11828
12577
  });
11829
12578
  /**
11830
- * Shared geometry vocabulary for on-frame shape caps privacy-mask,
11831
- * motion-zones, and the detection zones/lines editor all speak this one
11832
- * language so a single drawing-plane editor and the providers stay
11833
- * decoupled from each cap's storage.
11834
- *
11835
- * All coordinates are normalized 0..1 of the camera frame (top-left
11836
- * origin). Each cap composes the SUBSET of shape kinds it supports and
11837
- * advertises it via `supportedShapes` in its `getOptions`.
11838
- */
11839
- /** A normalized 0..1 point (top-left origin). */
11840
- var MaskPointSchema = object({
11841
- x: number(),
11842
- y: number()
11843
- });
11844
- /** Axis-aligned rectangle (normalized 0..1). */
11845
- var MaskRectShapeSchema = object({
11846
- kind: literal("rect"),
11847
- x: number(),
11848
- y: number(),
11849
- width: number(),
11850
- height: number()
11851
- });
11852
- /** Free polygon — an ordered list of normalized vertices (≥3). */
11853
- var MaskPolygonShapeSchema = object({
11854
- kind: literal("polygon"),
11855
- points: array(MaskPointSchema)
11856
- });
11857
- /** Boolean cell grid — row-major, length === gridWidth*gridHeight. */
11858
- var MaskGridShapeSchema = object({
11859
- kind: literal("grid"),
11860
- gridWidth: number(),
11861
- gridHeight: number(),
11862
- cells: array(boolean())
11863
- });
11864
- discriminatedUnion("kind", [
11865
- MaskRectShapeSchema,
11866
- MaskPolygonShapeSchema,
11867
- MaskGridShapeSchema,
11868
- object({
11869
- kind: literal("line"),
11870
- points: array(MaskPointSchema)
11871
- })
11872
- ]);
11873
- /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
11874
- var MaskShapeKindSchema = _enum([
11875
- "rect",
11876
- "polygon",
11877
- "grid",
11878
- "line"
11879
- ]);
11880
- /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
11881
- var MaskPolygonVerticesSchema = object({
11882
- min: number(),
11883
- max: number()
11884
- });
11885
- /** Grid dimensions when a cap supports 'grid'. */
11886
- var MaskGridDimsSchema = object({
11887
- width: number(),
11888
- height: number()
11889
- });
11890
- /**
11891
- * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
11892
- * on-camera motion-detection mask is a single `grid` region (a row-major
11893
- * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
11894
- * a region keeps one drawing-plane model across all geometry caps.
12579
+ * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
12580
+ * on-camera motion-detection mask is a single `grid` region (a row-major
12581
+ * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
12582
+ * a region keeps one drawing-plane model across all geometry caps.
11895
12583
  */
11896
12584
  /** A motion-zone region — exactly one boolean cell grid today. */
11897
12585
  var MotionZoneRegionSchema = object({
@@ -13570,94 +14258,6 @@ var EnrichedWidgetMetadataSchema = WidgetMetadataSchema.extend({
13570
14258
  bundleUrl: string()
13571
14259
  });
13572
14260
  method(_void(), array(EnrichedWidgetMetadataSchema).readonly());
13573
- var NotificationRuleConditionsSchema = object({
13574
- deviceIds: array(number()).readonly().optional(),
13575
- classNames: array(string()).readonly().optional(),
13576
- zoneIds: array(string()).readonly().optional(),
13577
- minConfidence: number().optional(),
13578
- source: _enum([
13579
- "pipeline",
13580
- "onboard",
13581
- "any"
13582
- ]).optional(),
13583
- schedule: object({
13584
- days: array(number()).readonly(),
13585
- startHour: number(),
13586
- endHour: number()
13587
- }).optional(),
13588
- cooldownSeconds: number().optional(),
13589
- minDwellSeconds: number().optional(),
13590
- /** Match against `event.data.eventType` token (e.g. `'press_long'`). When non-empty, only events
13591
- * carrying a matching `data.eventType` string pass this condition. Rules without this field are
13592
- * unaffected (back-compat). Distinct from `rule.eventTypes` which holds EventCategory strings. */
13593
- eventTypeTokens: array(string()).readonly().optional(),
13594
- /** Match detections whose CLIP image embedding is semantically similar to this free-text
13595
- * description. Requires the embedding-encoder cap to have pre-warmed the text vector.
13596
- * `minSimilarity` is the cosine similarity threshold in [0, 1]. */
13597
- clipDescription: object({
13598
- text: string().min(1),
13599
- minSimilarity: number().min(0).max(1)
13600
- }).optional(),
13601
- /** Match events whose recognized-entity label (face identity name or plate
13602
- * vehicle name, propagated onto `event.data.label`) is one of these values.
13603
- * Empty/absent → unaffected (back-compat). Enables "notify me when <named
13604
- * vehicle/person> is seen". */
13605
- labels: array(string()).readonly().optional()
13606
- });
13607
- var NotificationRuleTemplateSchema = object({
13608
- title: string(),
13609
- body: string(),
13610
- imageMode: _enum([
13611
- "crop",
13612
- "annotated",
13613
- "full",
13614
- "none"
13615
- ])
13616
- });
13617
- var NotificationRuleSchema = object({
13618
- id: string(),
13619
- name: string(),
13620
- enabled: boolean(),
13621
- eventTypes: array(string()).readonly(),
13622
- conditions: NotificationRuleConditionsSchema,
13623
- outputs: array(string()).readonly(),
13624
- template: NotificationRuleTemplateSchema.optional(),
13625
- priority: _enum([
13626
- "low",
13627
- "normal",
13628
- "high",
13629
- "critical"
13630
- ])
13631
- });
13632
- var NotificationTestResultSchema = object({
13633
- ruleId: string(),
13634
- eventId: string(),
13635
- timestamp: number(),
13636
- wouldFire: boolean(),
13637
- reason: string().optional()
13638
- });
13639
- var NotificationHistoryEntrySchema = object({
13640
- id: string(),
13641
- ruleId: string(),
13642
- ruleName: string(),
13643
- eventId: string(),
13644
- timestamp: number(),
13645
- outputs: array(string()).readonly(),
13646
- success: boolean(),
13647
- error: string().optional(),
13648
- deviceId: number().optional()
13649
- });
13650
- var NotificationHistoryFilterSchema = object({
13651
- ruleId: string().optional(),
13652
- deviceId: number().optional(),
13653
- from: number().optional(),
13654
- to: number().optional(),
13655
- limit: number().optional()
13656
- });
13657
- 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({
13658
- ruleId: string(),
13659
- lookbackMinutes: number()
13660
- }), object({ results: array(NotificationTestResultSchema).readonly() }), { kind: "mutation" }), method(object({ filter: NotificationHistoryFilterSchema.optional() }), object({ entries: array(NotificationHistoryEntrySchema).readonly() }));
13661
14261
  /**
13662
14262
  * Alerts capability — collection-based internal alert system.
13663
14263
  *
@@ -13844,88 +14444,54 @@ method(object({
13844
14444
  password: string()
13845
14445
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
13846
14446
  /**
13847
- * `login-method` collection cap through which auth addons contribute
13848
- * their pre-auth login surfaces to the login page. This is the SINGLE,
13849
- * generic mechanism that supersedes the dead `auth.listProviders` reader:
13850
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
13851
- * `login-method` provider and the PUBLIC `auth.listLoginMethods`
13852
- * procedure aggregates them for the unauthenticated login page.
13853
- *
13854
- * A contribution is a discriminated union on `kind`:
13855
- *
13856
- * - `redirect` — a declarative button. The login page renders a generic
13857
- * button that navigates to `startUrl` (an addon-owned HTTP route).
13858
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
13859
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
13860
- * login page needs NO change.
13861
- *
13862
- * - `widget` — a Module-Federation widget the login page mounts (via
13863
- * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
13864
- * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
13865
- * mechanism kept for future use; no shipped addon uses it on the login
13866
- * page (the passkey ceremony below runs natively in the shell instead).
13867
- *
13868
- * - `passkey` — a declarative WebAuthn ceremony the shell renders
13869
- * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
13870
- * a remotely-loaded bundle). Carries the addon's effective `rpId` /
13871
- * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
13872
- * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
13873
- * fetching any remote code pre-auth. Contribution stays unconditional —
13874
- * enrollment state is never leaked pre-auth; visibility is a shell
13875
- * decision.
13876
- *
13877
- * Every contribution carries a `stage`:
13878
- * - `primary` — shown on the first credentials screen (OIDC /
13879
- * magic-link buttons; a future usernameless passkey).
13880
- * - `second-factor` — shown AFTER the password leg, gated on the
13881
- * returned `factors` (passkey-as-2FA today).
13882
- *
13883
- * `mount: skip` — the cap is read server-side by the core auth router
13884
- * (`registry.getCollection('login-method')`), never mounted as its own
13885
- * tRPC router.
14447
+ * A live terminal session hosted by the provider addon. Output and input do
14448
+ * NOT flow through the capability they use the addon data plane
14449
+ * (`GET /addon/terminal/<id>/out` SSE, `POST /addon/terminal/<id>/in`) because
14450
+ * terminal output must be ordered and lossless. The event bus is telemetry and
14451
+ * may drop chunks ([D8]), and a dropped chunk desynchronises the vt parser
14452
+ * permanently until a full repaint. The capability owns only lifecycle.
13886
14453
  */
13887
- /** When a login method renders in the two-phase login flow. */
13888
- var LoginStageEnum = _enum(["primary", "second-factor"]);
13889
- /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
13890
- var LoginMethodContributionSchema = discriminatedUnion("kind", [
13891
- object({
13892
- kind: literal("redirect"),
13893
- /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
13894
- id: string(),
13895
- /** Operator-facing button label. */
13896
- label: string(),
13897
- /** lucide-react icon name. */
13898
- icon: string().optional(),
13899
- /** Addon-owned HTTP route the button navigates to (GET). */
13900
- startUrl: string(),
13901
- stage: LoginStageEnum
13902
- }),
13903
- object({
13904
- kind: literal("widget"),
13905
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
13906
- id: string(),
13907
- /** Owning addon id — drives the public bundle URL + the MF namespace. */
13908
- addonId: string(),
13909
- /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
13910
- bundle: string(),
13911
- /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
13912
- remote: WidgetRemoteSchema,
13913
- stage: LoginStageEnum
13914
- }),
13915
- object({
13916
- kind: literal("passkey"),
13917
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
13918
- id: string(),
13919
- /** Operator-facing button label. */
13920
- label: string(),
13921
- stage: LoginStageEnum,
13922
- /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
13923
- rpId: string(),
13924
- /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
13925
- origin: string().nullable()
13926
- })
13927
- ]);
13928
- method(_void(), array(LoginMethodContributionSchema).readonly());
14454
+ var TerminalSessionInfoSchema = object({
14455
+ /** Opaque session id minted by the provider on `openSession`. */
14456
+ sessionId: string(),
14457
+ /** The pre-declared profile this session runs (never a free-form command). */
14458
+ profileId: string(),
14459
+ /** Human-readable profile label for the UI session list. */
14460
+ label: string(),
14461
+ cols: number().int().positive(),
14462
+ rows: number().int().positive(),
14463
+ /** ms-epoch the session's pty was spawned. */
14464
+ startedAt: number()
14465
+ });
14466
+ /**
14467
+ * A profile the operator may open — a pre-declared, allowlisted program
14468
+ * (`monitor` → `btm`). The capability accepts only these ids; a free-form
14469
+ * command string would be remote code execution as the server's user, so it is
14470
+ * deliberately not part of the contract.
14471
+ */
14472
+ var TerminalProfileInfoSchema = object({
14473
+ profileId: string(),
14474
+ label: string(),
14475
+ description: string().optional()
14476
+ });
14477
+ method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(TerminalSessionInfoSchema).readonly(), { auth: "admin" }), method(object({
14478
+ profileId: string(),
14479
+ cols: number().int().positive(),
14480
+ rows: number().int().positive()
14481
+ }), TerminalSessionInfoSchema, {
14482
+ kind: "mutation",
14483
+ auth: "admin"
14484
+ }), method(object({
14485
+ sessionId: string(),
14486
+ cols: number().int().positive(),
14487
+ rows: number().int().positive()
14488
+ }), _void(), {
14489
+ kind: "mutation",
14490
+ auth: "admin"
14491
+ }), method(object({ sessionId: string() }), _void(), {
14492
+ kind: "mutation",
14493
+ auth: "admin"
14494
+ });
13929
14495
  /**
13930
14496
  * Orchestrator-side destination metadata. The orchestrator computes
13931
14497
  * `id = <addonId>:<subId>` from its provider lookup so consumers
@@ -14027,11 +14593,53 @@ var LocationStatSchema = object({
14027
14593
  fileCount: number(),
14028
14594
  present: boolean()
14029
14595
  });
14596
+ /**
14597
+ * A backup schedule — the N:M "entry" that binds one cron cadence to a
14598
+ * SET of destination locations. Supersedes the per-location cron on
14599
+ * `BackupDestinationPolicy`: an operator creates a schedule, picks the
14600
+ * `backups` locations it should write to, and the orchestrator fans a
14601
+ * single archive out to all of them when the cron fires.
14602
+ *
14603
+ * `retentionCount` is per-schedule (D-decision 2026-07-28): every
14604
+ * location targeted by this schedule keeps this many archives from
14605
+ * this schedule's runs.
14606
+ *
14607
+ * `dataSources` optionally narrows which top-level state locations
14608
+ * (db, addons, tls, …) are archived; omitted = the orchestrator's
14609
+ * default full set.
14610
+ */
14611
+ var BackupScheduleSchema = object({
14612
+ /** Stable id. Generated by the orchestrator on first upsert if absent. */
14613
+ id: string(),
14614
+ /** Operator-facing display name. */
14615
+ label: string(),
14616
+ /** 5-field POSIX cron. Empty = disabled cadence (kept for editing). */
14617
+ cron: string(),
14618
+ /** Master on/off toggle for the whole schedule. */
14619
+ enabled: boolean(),
14620
+ /** `backups`-location ids this schedule writes to (fan-out set). */
14621
+ locationIds: array(string()).readonly(),
14622
+ /** Archives kept per targeted location for this schedule. */
14623
+ retentionCount: number().int().min(1).max(1e3),
14624
+ /** Optional subset of source locations to include; omitted = all. */
14625
+ dataSources: array(string()).readonly().optional(),
14626
+ /** ms-epoch of last successful run. */
14627
+ lastRunAt: number().optional(),
14628
+ /** ms-epoch of next computed firing (read-only, filled on list). */
14629
+ nextRunAt: number().optional()
14630
+ });
14030
14631
  method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }), method(object({
14031
14632
  /** Subset of registered `backup-destination` addon ids to write to. */
14032
14633
  destinations: array(string()).optional(),
14033
14634
  locations: array(string()).optional(),
14034
- label: string().optional()
14635
+ label: string().optional(),
14636
+ /**
14637
+ * Per-run retention override applied to every targeted
14638
+ * destination. Used by schedule-driven runs (per-entry
14639
+ * retention). Omitted = each destination's own policy
14640
+ * retention (manual runs).
14641
+ */
14642
+ retentionCount: number().int().min(1).max(1e3).optional()
14035
14643
  }).optional(), array(BackupEntrySchema).readonly(), {
14036
14644
  kind: "mutation",
14037
14645
  auth: "admin"
@@ -14080,7 +14688,21 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
14080
14688
  ok: boolean(),
14081
14689
  error: string().optional(),
14082
14690
  nextRuns: array(number()).readonly()
14083
- }));
14691
+ })), method(_void(), array(BackupScheduleSchema).readonly(), { auth: "admin" }), method(object({
14692
+ id: string().optional(),
14693
+ label: string(),
14694
+ cron: string(),
14695
+ enabled: boolean(),
14696
+ locationIds: array(string()).readonly(),
14697
+ retentionCount: number().int().min(1).max(1e3),
14698
+ dataSources: array(string()).readonly().optional()
14699
+ }), BackupScheduleSchema, {
14700
+ kind: "mutation",
14701
+ auth: "admin"
14702
+ }), method(object({ id: string() }), _void(), {
14703
+ kind: "mutation",
14704
+ auth: "admin"
14705
+ });
14084
14706
  /**
14085
14707
  * `broker` — unified pub/sub broker registry, system-scoped collection.
14086
14708
  *
@@ -15295,851 +15917,934 @@ method(_void(), array(string()).readonly(), { auth: "admin" }), method(object({
15295
15917
  kind: "mutation",
15296
15918
  auth: "admin"
15297
15919
  });
15298
- var LogLevelSchema = _enum([
15299
- "debug",
15300
- "info",
15301
- "warn",
15302
- "error"
15303
- ]);
15304
- var LogEntrySchema = object({
15305
- timestamp: date(),
15306
- level: LogLevelSchema,
15307
- scope: array(string()),
15308
- message: string(),
15309
- meta: record(string(), unknown()).optional(),
15310
- tags: record(string(), string()).optional()
15920
+ /**
15921
+ * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
15922
+ * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15923
+ * caps stay wire-compatible without a circular cap→cap import.
15924
+ *
15925
+ * Errors are a discriminated-union RESULT, never thrown: the shape survives
15926
+ * every transport tier structurally, and failed calls still write usage rows.
15927
+ * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
15928
+ */
15929
+ var LlmUsageSchema = object({
15930
+ inputTokens: number(),
15931
+ outputTokens: number()
15311
15932
  });
15312
- method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
15313
- scope: array(string()).optional(),
15314
- level: LogLevelSchema.optional(),
15315
- since: date().optional(),
15316
- until: date().optional(),
15317
- limit: number().optional(),
15318
- tags: record(string(), string()).optional()
15319
- }), array(LogEntrySchema).readonly());
15320
- var CpuBreakdownSchema = object({
15321
- total: number(),
15322
- user: number(),
15323
- system: number(),
15324
- irq: number(),
15325
- nice: number(),
15326
- loadAvg: tuple([
15327
- number(),
15328
- number(),
15329
- number()
15330
- ]),
15331
- cores: number()
15332
- });
15333
- var MemoryInfoSchema = object({
15334
- percent: number(),
15335
- totalBytes: number(),
15336
- usedBytes: number(),
15337
- availableBytes: number(),
15338
- swapUsedBytes: number(),
15339
- swapTotalBytes: number()
15340
- });
15341
- var DiskIoSnapshotSchema = object({
15342
- readBytes: number(),
15343
- writeBytes: number(),
15344
- readOps: number(),
15345
- writeOps: number(),
15346
- timestampMs: number()
15347
- });
15348
- var NetworkIoSnapshotSchema = object({
15349
- rxBytes: number(),
15350
- txBytes: number(),
15351
- rxPackets: number(),
15352
- txPackets: number(),
15353
- rxErrors: number(),
15354
- txErrors: number(),
15355
- timestampMs: number()
15356
- });
15357
- var MetricsGpuInfoSchema = object({
15358
- utilization: number(),
15933
+ var LlmErrorCodeSchema = _enum([
15934
+ "timeout",
15935
+ "rate-limited",
15936
+ "auth",
15937
+ "refusal",
15938
+ "bad-request",
15939
+ "unavailable",
15940
+ "no-profile",
15941
+ "budget-exceeded",
15942
+ "adapter-error"
15943
+ ]);
15944
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
15945
+ ok: literal(true),
15946
+ text: string(),
15359
15947
  model: string(),
15360
- memoryUsedBytes: number(),
15361
- memoryTotalBytes: number(),
15362
- temperature: number().nullable()
15363
- });
15364
- var ProcessResourceInfoSchema = object({
15365
- openFds: number(),
15366
- threadCount: number(),
15367
- activeHandles: number(),
15368
- activeRequests: number()
15369
- });
15370
- var PressureAvgsSchema = object({
15371
- avg10: number(),
15372
- avg60: number(),
15373
- avg300: number()
15948
+ usage: LlmUsageSchema,
15949
+ truncated: boolean(),
15950
+ latencyMs: number()
15951
+ }), object({
15952
+ ok: literal(false),
15953
+ code: LlmErrorCodeSchema,
15954
+ message: string(),
15955
+ retryAfterMs: number().optional()
15956
+ })]);
15957
+ /**
15958
+ * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
15959
+ * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
15960
+ * notification-output.cap.ts:27-31 precedents).
15961
+ */
15962
+ var LlmImageSchema = object({
15963
+ bytes: _instanceof(Uint8Array),
15964
+ mimeType: string()
15374
15965
  });
15375
- var PressureInfoSchema = object({
15376
- some: PressureAvgsSchema,
15377
- full: PressureAvgsSchema.nullable()
15966
+ var LlmGenerateBaseInputSchema = object({
15967
+ /** Collection routing (the notification-output posture). */
15968
+ addonId: string().optional(),
15969
+ /** Explicit profile; else the resolution chain (spec §3). */
15970
+ profileId: string().optional(),
15971
+ /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
15972
+ consumer: string(),
15973
+ system: string().optional(),
15974
+ /** v1: single-turn. `messages[]` is a v2 additive field. */
15975
+ prompt: string(),
15976
+ /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
15977
+ jsonSchema: record(string(), unknown()).optional(),
15978
+ /** Per-call override of the profile default. */
15979
+ maxTokens: number().int().positive().optional(),
15980
+ temperature: number().optional()
15378
15981
  });
15379
- var SystemResourceSnapshotSchema = object({
15380
- cpu: CpuBreakdownSchema,
15381
- memory: MemoryInfoSchema,
15382
- gpu: MetricsGpuInfoSchema.nullable(),
15383
- network: NetworkIoSnapshotSchema,
15384
- disk: DiskIoSnapshotSchema,
15385
- pressure: object({
15386
- cpu: PressureInfoSchema.nullable(),
15387
- memory: PressureInfoSchema.nullable(),
15388
- io: PressureInfoSchema.nullable()
15982
+ /**
15983
+ * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
15984
+ * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
15985
+ * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
15986
+ * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
15987
+ * this only through the `llm` cap's methods.
15988
+ *
15989
+ * One running llama-server child per node in v1 (models are RAM-heavy).
15990
+ * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
15991
+ * watchdog — operator decision #3).
15992
+ */
15993
+ var ManagedModelRefSchema = discriminatedUnion("kind", [
15994
+ object({
15995
+ kind: literal("catalog"),
15996
+ catalogId: string()
15389
15997
  }),
15390
- process: ProcessResourceInfoSchema,
15391
- cpuTemperature: number().nullable(),
15392
- timestampMs: number()
15393
- });
15394
- var DiskSpaceInfoSchema = object({
15395
- path: string(),
15396
- totalBytes: number(),
15397
- usedBytes: number(),
15398
- availableBytes: number(),
15399
- percent: number()
15400
- });
15401
- var PidResourceStatsSchema = object({
15402
- pid: number(),
15403
- cpu: number(),
15404
- memory: number(),
15405
- /**
15406
- * Private (anonymous) resident bytes — the per-process V8 heap + native
15407
- * allocations NOT shared with other processes (Linux RssAnon). This is the
15408
- * "real" per-runner cost; summing it across runners is meaningful, unlike
15409
- * `memory` (RSS), which double-counts the shared mmap'd framework code.
15410
- * Undefined where /proc is unavailable (e.g. macOS).
15411
- */
15412
- privateBytes: number().optional(),
15413
- /**
15414
- * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
15415
- * code shared copy-on-write across runners. Undefined on macOS.
15416
- */
15417
- sharedBytes: number().optional()
15998
+ object({
15999
+ kind: literal("url"),
16000
+ url: string(),
16001
+ sha256: string().optional()
16002
+ }),
16003
+ object({
16004
+ kind: literal("path"),
16005
+ path: string()
16006
+ })
16007
+ ]);
16008
+ var ManagedRuntimeConfigSchema = object({
16009
+ /** WHERE the runtime lives — hub or any agent. */
16010
+ nodeId: string(),
16011
+ /** Closed for v1; 'ollama' is a v2 candidate. */
16012
+ engine: _enum(["llama-cpp"]),
16013
+ model: ManagedModelRefSchema,
16014
+ contextSize: number().int().default(4096),
16015
+ /** 0 = CPU-only. */
16016
+ gpuLayers: number().int().default(0),
16017
+ /** Default: cpus-2, clamped ≥1 (resolved node-side). */
16018
+ threads: number().int().optional(),
16019
+ /** Concurrent slots. */
16020
+ parallel: number().int().default(1),
16021
+ /** Else lazy: first generate boots it. */
16022
+ autoStart: boolean().default(false),
16023
+ /** 0 = never; frees RAM after quiet periods. */
16024
+ idleStopMinutes: number().int().default(30)
15418
16025
  });
15419
- var AddonInstanceSchema = object({
15420
- addonId: string(),
16026
+ var LlmRuntimeStatusSchema = object({
16027
+ /** Status is ALWAYS node-qualified. */
15421
16028
  nodeId: string(),
15422
- role: _enum(["hub", "worker"]),
15423
- pid: number(),
15424
16029
  state: _enum([
15425
- "starting",
15426
- "running",
15427
- "stopping",
15428
16030
  "stopped",
15429
- "crashed"
15430
- ]),
15431
- uptimeSec: number()
15432
- });
15433
- var NodeProcessSchema = object({
15434
- pid: number(),
15435
- ppid: number(),
15436
- pgid: number(),
15437
- classification: _enum([
15438
- "root",
15439
- "managed",
15440
- "system",
15441
- "ghost"
16031
+ "downloading",
16032
+ "starting",
16033
+ "ready",
16034
+ "crashed",
16035
+ "failed"
15442
16036
  ]),
15443
- /** `$process` addon binding when `managed`, else null. */
15444
- addonId: string().nullable(),
15445
- /** Kernel-reported nodeId when the process is a known agent/worker. */
15446
- nodeId: string().nullable(),
15447
- /** Truncated command line. */
15448
- command: string(),
15449
- cpuPercent: number(),
15450
- memoryRssBytes: number(),
15451
- /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
15452
- uptimeSec: number(),
15453
- /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
15454
- orphaned: boolean()
15455
- });
15456
- var KillProcessInputSchema = object({
15457
- pid: number(),
15458
- /** Force = SIGKILL. Default is SIGTERM. */
15459
- force: boolean().optional()
16037
+ pid: number().optional(),
16038
+ port: number().optional(),
16039
+ modelPath: string().optional(),
16040
+ modelId: string().optional(),
16041
+ downloadProgress: number().min(0).max(1).optional(),
16042
+ lastError: string().optional(),
16043
+ crashesInWindow: number(),
16044
+ /** Child RSS (sampled best-effort). */
16045
+ memoryBytes: number().optional(),
16046
+ vramBytes: number().optional()
15460
16047
  });
15461
- var KillProcessResultSchema = object({
15462
- success: boolean(),
15463
- reason: string().optional(),
15464
- signal: _enum(["SIGTERM", "SIGKILL"]).optional()
16048
+ var LlmNodeModelSchema = object({
16049
+ file: string(),
16050
+ sizeBytes: number(),
16051
+ catalogId: string().optional(),
16052
+ installedAt: number().optional()
15465
16053
  });
15466
- var DumpHeapSnapshotInputSchema = object({
15467
- /** The addon whose runner should dump a heap snapshot. */
15468
- addonId: string() });
15469
- var DumpHeapSnapshotResultSchema = object({
15470
- success: boolean(),
15471
- /** Path of the written .heapsnapshot inside the runner's container/host. */
15472
- path: string().optional(),
15473
- /** Process pid that was signalled. */
15474
- pid: number().optional(),
15475
- reason: string().optional()
16054
+ var LlmRuntimeDiskUsageSchema = object({
16055
+ nodeId: string(),
16056
+ modelsBytes: number(),
16057
+ freeBytes: number().optional()
15476
16058
  });
15477
- var SystemMetricsSchema = object({
15478
- cpuPercent: number(),
15479
- memoryPercent: number(),
15480
- memoryUsedMB: number(),
15481
- memoryTotalMB: number(),
15482
- diskPercent: number().optional(),
15483
- temperature: number().optional(),
15484
- gpuPercent: number().optional(),
15485
- gpuMemoryPercent: number().optional()
15486
- });
15487
- 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, {
16059
+ method(LlmGenerateBaseInputSchema.extend({
16060
+ images: array(LlmImageSchema).optional(),
16061
+ runtime: ManagedRuntimeConfigSchema,
16062
+ /** The managed profile's timeout, threaded by the hub provider. */
16063
+ timeoutMs: number().int().positive().optional()
16064
+ }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
15488
16065
  kind: "mutation",
15489
16066
  auth: "admin"
15490
- }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
16067
+ }), method(object({}), _void(), {
15491
16068
  kind: "mutation",
15492
16069
  auth: "admin"
15493
- });
15494
- method(object({
15495
- sourceUrl: string(),
15496
- metadata: ModelConvertMetadataSchema,
15497
- targets: array(ConvertTargetSchema).min(1).readonly(),
15498
- calibrationRef: string().optional(),
15499
- sessionId: string().optional()
15500
- }), ConvertResultSchema, {
16070
+ }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
15501
16071
  kind: "mutation",
15502
- auth: "admin",
15503
- timeoutMs: 6e5
15504
- });
15505
- method(object({
15506
- nodeId: string(),
15507
- modelId: string(),
15508
- format: _enum(MODEL_FORMATS),
15509
- entry: ModelCatalogEntrySchema
15510
- }), object({
15511
- ok: boolean(),
15512
- /** sha256 of the staged tarball (empty for a hub-local no-op). */
15513
- sha256: string(),
15514
- bytes: number(),
15515
- /** The target node's modelsDir the artifact landed in. */
15516
- path: string()
15517
- }), {
16072
+ auth: "admin"
16073
+ }), method(object({ file: string() }), _void(), {
15518
16074
  kind: "mutation",
15519
16075
  auth: "admin"
15520
- });
15521
- /**
15522
- * `mqtt-broker` — broker-registry cap.
15523
- *
15524
- * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
15525
- * MQTT brokers (external + optionally an embedded `aedes`-backed one)
15526
- * and (b) the connection details a consumer addon needs to spin up
15527
- * its OWN `mqtt.js` client.
15528
- *
15529
- * Why: pub/sub routing over the system event-bus loses fidelity
15530
- * (callback shape, QoS guarantees, will/retain semantics) and adds
15531
- * refcount bookkeeping that addons would rather own themselves. The
15532
- * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
15533
- * features anyway — give it the connection config, get out of the way.
15534
- *
15535
- * Consumer flow:
15536
- * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
15537
- * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
15538
- * client.subscribe('zigbee2mqtt/+')
15539
- *
15540
- * Collection mode: multiple brokers (e.g. one local mosquitto + one
15541
- * cloud bridge). The "embedded" entry (when present) is just another
15542
- * broker in the registry — its lifecycle is owned by the addon that
15543
- * spawned it.
15544
- */
15545
- var BrokerKindSchema = _enum(["external", "embedded"]);
16076
+ }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
15546
16077
  /**
15547
- * Broker live-probe status.
16078
+ * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
16079
+ * methods concat-fan across providers; single-row methods route to ONE
16080
+ * provider by the `addonId` in the call input (the notification-output
16081
+ * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
16082
+ * (hub-placed); the cap stays open for future providers.
15548
16083
  *
15549
- * - `connected` last probe completed a clean CONNACK
15550
- * - `disconnected` — no probe has run yet (cold cache)
15551
- * - `auth-failed` CONNACK refused with auth error (RC 4 / 5)
15552
- * - `unreachable` — TCP connect timed out / refused
15553
- * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
16084
+ * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
16085
+ * `apiKey` is a password field providers REDACT it on read and merge on
16086
+ * write; a stored key NEVER round-trips to a client.
15554
16087
  */
15555
- var BrokerStatusSchema$1 = _enum([
15556
- "connected",
15557
- "disconnected",
15558
- "auth-failed",
15559
- "unreachable",
15560
- "tls-error"
16088
+ var LlmProfileKindSchema = _enum([
16089
+ "openai-compatible",
16090
+ "openai",
16091
+ "anthropic",
16092
+ "google",
16093
+ "managed-local"
15561
16094
  ]);
15562
- var BrokerInfoSchema = object({
16095
+ var LlmProfileSchema = object({
15563
16096
  id: string(),
15564
16097
  name: string(),
15565
- url: string(),
15566
- kind: BrokerKindSchema,
15567
- status: BrokerStatusSchema$1,
15568
- latencyMs: number().nullable(),
15569
- error: string().optional(),
15570
- /** Embedded brokers only: number of MQTT clients currently connected. */
15571
- connectedClients: number().int().nonnegative().optional(),
15572
- /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
15573
- lastCheckedAt: number().optional()
16098
+ kind: LlmProfileKindSchema,
16099
+ /** Stamped by the provider — keeps the fanned catalog routable. */
16100
+ addonId: string(),
16101
+ enabled: boolean(),
16102
+ /** Vendor model id, or the managed runtime's loaded model. */
16103
+ model: string(),
16104
+ /** Required for openai-compatible; override for cloud kinds. */
16105
+ baseUrl: string().optional(),
16106
+ /** ConfigUISchema type:'password' — never round-trips (spec §5). */
16107
+ apiKey: string().optional(),
16108
+ supportsVision: boolean(),
16109
+ temperature: number().min(0).max(2).optional(),
16110
+ maxTokens: number().int().positive().optional(),
16111
+ timeoutMs: number().int().positive().default(6e4),
16112
+ extraHeaders: record(string(), string()).optional(),
16113
+ /** kind === 'managed-local' only (spec §4). */
16114
+ runtime: ManagedRuntimeConfigSchema.optional()
15574
16115
  });
15575
- /**
15576
- * Connection details — what a consumer needs to call
15577
- * `mqtt.connect(url, options)`. We split URL + credentials so the
15578
- * consumer can pass them as `mqtt.connect(url, { username, password })`
15579
- * instead of stuffing creds into the URL (which leaks them into logs).
15580
- */
15581
- var BrokerConnectionDetailsSchema = object({
15582
- url: string(),
15583
- username: string().optional(),
15584
- password: string().optional(),
15585
- /**
15586
- * Suggested prefix for `clientId`. Each consumer should suffix this
15587
- * with its own discriminator (addon id, instance id) so reconnects
15588
- * don't kick each other off (MQTT spec: clientId must be unique per
15589
- * broker).
15590
- */
15591
- clientIdPrefix: string().optional()
16116
+ /** ConfigUISchema tree passed through untyped on the wire (the
16117
+ * notification-output `ConfigSchemaPassthrough` precedent at
16118
+ * notification-output.cap.ts:151); the exported TS type re-tightens it. */
16119
+ var ConfigSchemaPassthrough$1 = unknown();
16120
+ var LlmProfileKindDescriptorSchema = object({
16121
+ kind: LlmProfileKindSchema,
16122
+ label: string(),
16123
+ icon: string(),
16124
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
16125
+ addonId: string(),
16126
+ configSchema: ConfigSchemaPassthrough$1
15592
16127
  });
15593
- var AddBrokerInputSchema = object({
15594
- name: string().min(1),
15595
- url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
15596
- username: string().optional(),
15597
- password: string().optional(),
15598
- clientIdPrefix: string().optional()
16128
+ var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
16129
+ var LlmDefaultSchema = object({
16130
+ selector: LlmDefaultSelectorSchema,
16131
+ profileId: string()
15599
16132
  });
15600
- var AddBrokerResultSchema = object({ id: string() });
15601
- var IdInputSchema = object({ id: string() });
15602
- var TestResultSchema$1 = discriminatedUnion("ok", [object({
15603
- ok: literal(true),
15604
- latencyMs: number()
15605
- }), object({
15606
- ok: literal(false),
15607
- error: string()
15608
- })]);
15609
- var StartEmbeddedInputSchema = object({
15610
- port: number().int().min(1).max(65535).default(1883),
15611
- /** Allow anonymous connect (no username/password). Default: false. */
15612
- allowAnonymous: boolean().default(false),
15613
- /** Optional shared username/password for clients. */
15614
- username: string().optional(),
15615
- password: string().optional()
16133
+ /** Server-side rollup row getUsage never dumps raw call rows (spec §6). */
16134
+ var LlmUsageRollupSchema = object({
16135
+ day: string(),
16136
+ consumer: string(),
16137
+ profileId: string(),
16138
+ calls: number(),
16139
+ okCalls: number(),
16140
+ errorCalls: number(),
16141
+ inputTokens: number(),
16142
+ outputTokens: number(),
16143
+ avgLatencyMs: number()
15616
16144
  });
15617
- var StartEmbeddedResultSchema = object({
16145
+ /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
16146
+ var ManagedModelCatalogEntrySchema = object({
15618
16147
  id: string(),
15619
- url: string()
15620
- });
15621
- var StatusSchema = object({
15622
- brokerCount: number(),
15623
- embeddedRunning: boolean()
15624
- });
15625
- 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);
15626
- var NetworkEndpointSchema = object({
16148
+ label: string(),
16149
+ family: string(),
16150
+ purpose: _enum(["text", "vision"]),
15627
16151
  url: string(),
15628
- hostname: string(),
15629
- port: number(),
15630
- protocol: _enum(["http", "https"])
16152
+ sha256: string(),
16153
+ sizeBytes: number(),
16154
+ quantization: string(),
16155
+ /** Load-time guidance shown in the picker. */
16156
+ minRamBytes: number(),
16157
+ contextSizeDefault: number().int(),
16158
+ /** Vision models: companion projector file. */
16159
+ mmprojUrl: string().optional()
15631
16160
  });
15632
- var NetworkAccessStatusSchema = object({
15633
- connected: boolean(),
15634
- endpoint: NetworkEndpointSchema.nullable(),
16161
+ var LlmRuntimeNodeSchema = object({
16162
+ nodeId: string(),
16163
+ reachable: boolean(),
16164
+ status: LlmRuntimeStatusSchema.optional(),
16165
+ disk: LlmRuntimeDiskUsageSchema.optional(),
15635
16166
  error: string().optional()
15636
16167
  });
15637
- /**
15638
- * Optional, richer endpoint shape returned by providers that expose
15639
- * MORE than one ingress concurrently (Tailscale Ingress with mixed
15640
- * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
15641
- * the originating provider config (mode + sourcePort) so the
15642
- * orchestrator UI can label rows distinctly. Providers that expose only
15643
- * one endpoint just omit `listEndpoints` from their provider impl.
15644
- */
15645
- var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
15646
- /**
15647
- * Stable id within the provider — typically `<mode>-<sourcePort>` so
15648
- * the orchestrator can dedupe across `listEndpoints` polls.
15649
- */
15650
- id: string(),
15651
- /** Operator-facing label (mirrors `MeshEndpoint.label`). */
15652
- label: string(),
15653
- /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
15654
- mode: string().optional(),
15655
- /** Originating local port the ingress fronts (informational). */
15656
- sourcePort: number().optional()
16168
+ var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
16169
+ var ProfileRefInputSchema = object({
16170
+ addonId: string(),
16171
+ profileId: string()
15657
16172
  });
15658
- method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
15659
- /**
15660
- * notification-output — canonical, capability-gated notification delivery.
15661
- *
15662
- * Apprise-derived model (see
15663
- * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
15664
- * callers emit ONE canonical `Notification`; each provider declares a
15665
- * per-kind capability descriptor (`TargetKind`), and the pure degrade
15666
- * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
15667
- * message to what the kind supports — callers never special-case a service.
15668
- *
15669
- * DESIGN DECISIONS (locked):
15670
- * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
15671
- * `setTargetEnabled`), each provider persisting via the `settings-store`
15672
- * cap. Rationale: the admin UI needs one uniform surface across the
15673
- * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
15674
- * alternative would fork the UI per addon and cannot host the
15675
- * discovery→adopt flow.
15676
- * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
15677
- * the generated cap-mount auto-`concatCollection`-fans them across every
15678
- * registered provider (notifiers addon + HA addon) so one catalog is
15679
- * routable. `send` / `testTarget` / CRUD route to ONE provider by the
15680
- * `addonId` the generated collection router extracts from the call input.
15681
- * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
15682
- * transformer) + UDS MsgPack both round-trip typed arrays — already used by
15683
- * `storage` / `storage-provider` / `recording` caps over the same path. No
15684
- * base64 fallback needed.
15685
- *
15686
- * TODO (deferred, closed-set change — separate decision): add
15687
- * `providerKind: 'notify'` so notification providers surface on the unified
15688
- * admin "Integrations" page.
15689
- */
15690
- /**
15691
- * Zentik-derived typed-media enum — the superset across every kind. Each
15692
- * adapter picks what it supports and the degrade engine filters the rest.
15693
- */
15694
- var AttachmentMediaTypeSchema = _enum([
15695
- "image",
15696
- "video",
15697
- "gif",
15698
- "audio",
15699
- "icon"
16173
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
16174
+ kind: "mutation",
16175
+ auth: "admin"
16176
+ }), method(ProfileRefInputSchema, _void(), {
16177
+ kind: "mutation",
16178
+ auth: "admin"
16179
+ }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
16180
+ kind: "mutation",
16181
+ auth: "admin"
16182
+ }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
16183
+ selector: LlmDefaultSelectorSchema,
16184
+ profileId: string().nullable()
16185
+ }), _void(), {
16186
+ kind: "mutation",
16187
+ auth: "admin"
16188
+ }), method(object({
16189
+ since: number().optional(),
16190
+ until: number().optional(),
16191
+ consumer: string().optional(),
16192
+ profileId: string().optional()
16193
+ }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
16194
+ nodeId: string(),
16195
+ model: ManagedModelRefSchema
16196
+ }), _void(), {
16197
+ kind: "mutation",
16198
+ auth: "admin"
16199
+ }), method(object({
16200
+ nodeId: string(),
16201
+ file: string()
16202
+ }), _void(), {
16203
+ kind: "mutation",
16204
+ auth: "admin"
16205
+ }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
16206
+ kind: "mutation",
16207
+ auth: "admin"
16208
+ }), method(ProfileRefInputSchema, _void(), {
16209
+ kind: "mutation",
16210
+ auth: "admin"
16211
+ });
16212
+ var LogLevelSchema = _enum([
16213
+ "debug",
16214
+ "info",
16215
+ "warn",
16216
+ "error"
15700
16217
  ]);
16218
+ var LogEntrySchema = object({
16219
+ timestamp: date(),
16220
+ level: LogLevelSchema,
16221
+ scope: array(string()),
16222
+ message: string(),
16223
+ meta: record(string(), unknown()).optional(),
16224
+ tags: record(string(), string()).optional()
16225
+ });
16226
+ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16227
+ scope: array(string()).optional(),
16228
+ level: LogLevelSchema.optional(),
16229
+ since: date().optional(),
16230
+ until: date().optional(),
16231
+ limit: number().optional(),
16232
+ tags: record(string(), string()).optional()
16233
+ }), array(LogEntrySchema).readonly());
15701
16234
  /**
15702
- * A single attachment. Exactly one of `url` (remote source, most adapters
15703
- * prefer this) or `bytes` (inline source; required for Pushover-style
15704
- * bytes-only kinds) MUST be present — the degrade engine expresses a
15705
- * url→bytes fetch as a `needsFetch` directive the adapter executes.
16235
+ * `login-method` collection cap through which auth addons contribute
16236
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
16237
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
16238
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
16239
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
16240
+ * procedure aggregates them for the unauthenticated login page.
16241
+ *
16242
+ * A contribution is a discriminated union on `kind`:
16243
+ *
16244
+ * - `redirect` — a declarative button. The login page renders a generic
16245
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
16246
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
16247
+ * ZERO shell-side JS. A future SSO addon plugs in the same way — the
16248
+ * login page needs NO change.
16249
+ *
16250
+ * - `widget` — a Module-Federation widget the login page mounts (via
16251
+ * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
16252
+ * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
16253
+ * mechanism kept for future use; no shipped addon uses it on the login
16254
+ * page (the passkey ceremony below runs natively in the shell instead).
16255
+ *
16256
+ * - `passkey` — a declarative WebAuthn ceremony the shell renders
16257
+ * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
16258
+ * a remotely-loaded bundle). Carries the addon's effective `rpId` /
16259
+ * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
16260
+ * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
16261
+ * fetching any remote code pre-auth. Contribution stays unconditional —
16262
+ * enrollment state is never leaked pre-auth; visibility is a shell
16263
+ * decision.
16264
+ *
16265
+ * Every contribution carries a `stage`:
16266
+ * - `primary` — shown on the first credentials screen (OIDC /
16267
+ * magic-link buttons; a future usernameless passkey).
16268
+ * - `second-factor` — shown AFTER the password leg, gated on the
16269
+ * returned `factors` (passkey-as-2FA today).
16270
+ *
16271
+ * `mount: skip` — the cap is read server-side by the core auth router
16272
+ * (`registry.getCollection('login-method')`), never mounted as its own
16273
+ * tRPC router.
15706
16274
  */
15707
- var AttachmentSchema = object({
15708
- mediaType: AttachmentMediaTypeSchema,
15709
- url: string().optional(),
15710
- bytes: _instanceof(Uint8Array).optional(),
15711
- mime: string().optional(),
15712
- name: string().optional()
15713
- }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
15714
- var NotificationFormatSchema = _enum([
15715
- "text",
15716
- "markdown",
15717
- "html"
16275
+ /** When a login method renders in the two-phase login flow. */
16276
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
16277
+ /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
16278
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [
16279
+ object({
16280
+ kind: literal("redirect"),
16281
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
16282
+ id: string(),
16283
+ /** Operator-facing button label. */
16284
+ label: string(),
16285
+ /** lucide-react icon name. */
16286
+ icon: string().optional(),
16287
+ /** Addon-owned HTTP route the button navigates to (GET). */
16288
+ startUrl: string(),
16289
+ stage: LoginStageEnum
16290
+ }),
16291
+ object({
16292
+ kind: literal("widget"),
16293
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
16294
+ id: string(),
16295
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
16296
+ addonId: string(),
16297
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
16298
+ bundle: string(),
16299
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
16300
+ remote: WidgetRemoteSchema,
16301
+ stage: LoginStageEnum
16302
+ }),
16303
+ object({
16304
+ kind: literal("passkey"),
16305
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
16306
+ id: string(),
16307
+ /** Operator-facing button label. */
16308
+ label: string(),
16309
+ stage: LoginStageEnum,
16310
+ /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
16311
+ rpId: string(),
16312
+ /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
16313
+ origin: string().nullable()
16314
+ })
15718
16315
  ]);
15719
- /** A single tap-through action button. */
15720
- var NotificationActionSchema = object({
15721
- id: string(),
15722
- label: string(),
15723
- url: string().optional()
16316
+ method(_void(), array(LoginMethodContributionSchema).readonly());
16317
+ var CpuBreakdownSchema = object({
16318
+ total: number(),
16319
+ user: number(),
16320
+ system: number(),
16321
+ irq: number(),
16322
+ nice: number(),
16323
+ loadAvg: tuple([
16324
+ number(),
16325
+ number(),
16326
+ number()
16327
+ ]),
16328
+ cores: number()
15724
16329
  });
15725
- /**
15726
- * The canonical notification. `body` is the only hard field (Apprise model).
15727
- * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
15728
- * NOT a fixed severity enum — each kind declares its own `caps.levels` and
15729
- * the adapter maps this ordinal onto its native level. `level?` is an
15730
- * optional kind-native level id (`emergency`, `silent`, …) that overrides
15731
- * `priority` for that one target.
15732
- */
15733
- var NotificationSchema = object({
15734
- body: string(),
15735
- title: string().optional(),
15736
- format: NotificationFormatSchema.default("text"),
15737
- priority: number().int().min(1).max(5).default(3),
15738
- level: string().optional(),
15739
- attachments: array(AttachmentSchema).optional(),
15740
- clickUrl: string().optional(),
15741
- actions: array(NotificationActionSchema).optional(),
15742
- sound: string().optional(),
15743
- ttl: number().optional(),
15744
- tag: string().optional(),
15745
- deviceId: number().optional(),
15746
- eventId: string().optional(),
15747
- metadata: record(string(), unknown()).optional()
16330
+ var MemoryInfoSchema = object({
16331
+ percent: number(),
16332
+ totalBytes: number(),
16333
+ usedBytes: number(),
16334
+ availableBytes: number(),
16335
+ swapUsedBytes: number(),
16336
+ swapTotalBytes: number()
16337
+ });
16338
+ var DiskIoSnapshotSchema = object({
16339
+ readBytes: number(),
16340
+ writeBytes: number(),
16341
+ readOps: number(),
16342
+ writeOps: number(),
16343
+ timestampMs: number()
16344
+ });
16345
+ var NetworkIoSnapshotSchema = object({
16346
+ rxBytes: number(),
16347
+ txBytes: number(),
16348
+ rxPackets: number(),
16349
+ txPackets: number(),
16350
+ rxErrors: number(),
16351
+ txErrors: number(),
16352
+ timestampMs: number()
16353
+ });
16354
+ var MetricsGpuInfoSchema = object({
16355
+ utilization: number(),
16356
+ model: string(),
16357
+ memoryUsedBytes: number(),
16358
+ memoryTotalBytes: number(),
16359
+ temperature: number().nullable()
16360
+ });
16361
+ var ProcessResourceInfoSchema = object({
16362
+ openFds: number(),
16363
+ threadCount: number(),
16364
+ activeHandles: number(),
16365
+ activeRequests: number()
15748
16366
  });
15749
- /** One declared native severity/priority level for a kind. */
15750
- var TargetKindLevelSchema = object({
15751
- id: string(),
15752
- label: string(),
15753
- /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
15754
- ordinal: number().int().min(1).max(5).nullable(),
15755
- flags: object({
15756
- critical: boolean().optional(),
15757
- silent: boolean().optional(),
15758
- noPush: boolean().optional()
15759
- }).optional(),
15760
- /** e.g. Pushover `emergency` requires `retry` / `expire`. */
15761
- requires: array(string()).optional(),
15762
- description: string().optional()
16367
+ var PressureAvgsSchema = object({
16368
+ avg10: number(),
16369
+ avg60: number(),
16370
+ avg300: number()
15763
16371
  });
15764
- /** The full capability block consulted before dispatch. */
15765
- var TargetKindCapsSchema = object({
15766
- attachments: object({
15767
- mediaTypes: array(AttachmentMediaTypeSchema),
15768
- mode: _enum([
15769
- "url",
15770
- "bytes",
15771
- "both"
15772
- ]),
15773
- max: number().int().nonnegative(),
15774
- maxBytes: number().int().positive().optional()
16372
+ var PressureInfoSchema = object({
16373
+ some: PressureAvgsSchema,
16374
+ full: PressureAvgsSchema.nullable()
16375
+ });
16376
+ var SystemResourceSnapshotSchema = object({
16377
+ cpu: CpuBreakdownSchema,
16378
+ memory: MemoryInfoSchema,
16379
+ gpu: MetricsGpuInfoSchema.nullable(),
16380
+ network: NetworkIoSnapshotSchema,
16381
+ disk: DiskIoSnapshotSchema,
16382
+ pressure: object({
16383
+ cpu: PressureInfoSchema.nullable(),
16384
+ memory: PressureInfoSchema.nullable(),
16385
+ io: PressureInfoSchema.nullable()
15775
16386
  }),
15776
- /** Max action buttons (0 = none). */
15777
- actions: number().int().nonnegative(),
15778
- levels: array(TargetKindLevelSchema),
15779
- format: array(NotificationFormatSchema),
15780
- clickUrl: boolean(),
15781
- sound: boolean(),
15782
- ttl: boolean(),
15783
- bodyMaxLen: number().int().positive()
16387
+ process: ProcessResourceInfoSchema,
16388
+ cpuTemperature: number().nullable(),
16389
+ timestampMs: number()
15784
16390
  });
15785
- /**
15786
- * `configSchema` is a `ConfigUISchema` tree passed through to the admin
15787
- * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
15788
- * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`)
15789
- * the union is large and not meant for runtime validation here; the exported
15790
- * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
15791
- */
15792
- var ConfigSchemaPassthrough$1 = unknown();
15793
- var TargetKindSchema = object({
15794
- kind: string(),
15795
- label: string(),
15796
- icon: string(),
15797
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
15798
- addonId: string(),
15799
- configSchema: ConfigSchemaPassthrough$1,
15800
- supportsDiscovery: boolean(),
15801
- caps: TargetKindCapsSchema
16391
+ var DiskSpaceInfoSchema = object({
16392
+ path: string(),
16393
+ totalBytes: number(),
16394
+ usedBytes: number(),
16395
+ availableBytes: number(),
16396
+ percent: number()
15802
16397
  });
15803
- /**
15804
- * A persisted target. `config` holds secrets; providers REDACT secret fields
15805
- * (return a presence marker only) when serving `listTargets` — never
15806
- * round-trip a stored secret to the UI.
15807
- */
15808
- var TargetSchema = object({
15809
- id: string(),
15810
- name: string(),
15811
- kind: string(),
16398
+ var PidResourceStatsSchema = object({
16399
+ pid: number(),
16400
+ cpu: number(),
16401
+ memory: number(),
16402
+ /**
16403
+ * Private (anonymous) resident bytes — the per-process V8 heap + native
16404
+ * allocations NOT shared with other processes (Linux RssAnon). This is the
16405
+ * "real" per-runner cost; summing it across runners is meaningful, unlike
16406
+ * `memory` (RSS), which double-counts the shared mmap'd framework code.
16407
+ * Undefined where /proc is unavailable (e.g. macOS).
16408
+ */
16409
+ privateBytes: number().optional(),
16410
+ /**
16411
+ * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
16412
+ * code shared copy-on-write across runners. Undefined on macOS.
16413
+ */
16414
+ sharedBytes: number().optional()
16415
+ });
16416
+ var AddonInstanceSchema = object({
15812
16417
  addonId: string(),
15813
- enabled: boolean(),
15814
- config: record(string(), unknown())
16418
+ nodeId: string(),
16419
+ role: _enum(["hub", "worker"]),
16420
+ pid: number(),
16421
+ state: _enum([
16422
+ "starting",
16423
+ "running",
16424
+ "stopping",
16425
+ "stopped",
16426
+ "crashed"
16427
+ ]),
16428
+ uptimeSec: number()
15815
16429
  });
15816
- /** A discovery-surfaced candidate (config is partial + non-secret). */
15817
- var DiscoveredTargetSchema = object({
15818
- kind: string(),
15819
- suggestedName: string(),
15820
- config: record(string(), unknown())
16430
+ var NodeProcessSchema = object({
16431
+ pid: number(),
16432
+ ppid: number(),
16433
+ pgid: number(),
16434
+ classification: _enum([
16435
+ "root",
16436
+ "managed",
16437
+ "system",
16438
+ "ghost"
16439
+ ]),
16440
+ /** `$process` addon binding when `managed`, else null. */
16441
+ addonId: string().nullable(),
16442
+ /** Kernel-reported nodeId when the process is a known agent/worker. */
16443
+ nodeId: string().nullable(),
16444
+ /** Truncated command line. */
16445
+ command: string(),
16446
+ cpuPercent: number(),
16447
+ memoryRssBytes: number(),
16448
+ /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
16449
+ uptimeSec: number(),
16450
+ /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
16451
+ orphaned: boolean()
15821
16452
  });
15822
- /** The degrade engine's report — what was resolved / dropped / degraded. */
15823
- var RenderedAsSchema = object({
15824
- level: string(),
15825
- format: NotificationFormatSchema,
15826
- attachmentsSent: number().int().nonnegative(),
15827
- actionsSent: number().int().nonnegative(),
15828
- truncated: boolean(),
15829
- dropped: array(string())
16453
+ var KillProcessInputSchema = object({
16454
+ pid: number(),
16455
+ /** Force = SIGKILL. Default is SIGTERM. */
16456
+ force: boolean().optional()
15830
16457
  });
15831
- var SendResultSchema = object({
16458
+ var KillProcessResultSchema = object({
16459
+ success: boolean(),
16460
+ reason: string().optional(),
16461
+ signal: _enum(["SIGTERM", "SIGKILL"]).optional()
16462
+ });
16463
+ var DumpHeapSnapshotInputSchema = object({
16464
+ /** The addon whose runner should dump a heap snapshot. */
16465
+ addonId: string() });
16466
+ var DumpHeapSnapshotResultSchema = object({
15832
16467
  success: boolean(),
16468
+ /** Path of the written .heapsnapshot inside the runner's container/host. */
16469
+ path: string().optional(),
16470
+ /** Process pid that was signalled. */
16471
+ pid: number().optional(),
16472
+ reason: string().optional()
16473
+ });
16474
+ var SystemMetricsSchema = object({
16475
+ cpuPercent: number(),
16476
+ memoryPercent: number(),
16477
+ memoryUsedMB: number(),
16478
+ memoryTotalMB: number(),
16479
+ diskPercent: number().optional(),
16480
+ temperature: number().optional(),
16481
+ gpuPercent: number().optional(),
16482
+ gpuMemoryPercent: number().optional()
16483
+ });
16484
+ 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, {
16485
+ kind: "mutation",
16486
+ auth: "admin"
16487
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
16488
+ kind: "mutation",
16489
+ auth: "admin"
16490
+ });
16491
+ method(object({
16492
+ sourceUrl: string(),
16493
+ metadata: ModelConvertMetadataSchema,
16494
+ targets: array(ConvertTargetSchema).min(1).readonly(),
16495
+ calibrationRef: string().optional(),
16496
+ sessionId: string().optional()
16497
+ }), ConvertResultSchema, {
16498
+ kind: "mutation",
16499
+ auth: "admin",
16500
+ timeoutMs: 6e5
16501
+ });
16502
+ method(object({
16503
+ nodeId: string(),
16504
+ modelId: string(),
16505
+ format: _enum(MODEL_FORMATS),
16506
+ entry: ModelCatalogEntrySchema
16507
+ }), object({
16508
+ ok: boolean(),
16509
+ /** sha256 of the staged tarball (empty for a hub-local no-op). */
16510
+ sha256: string(),
16511
+ bytes: number(),
16512
+ /** The target node's modelsDir the artifact landed in. */
16513
+ path: string()
16514
+ }), {
16515
+ kind: "mutation",
16516
+ auth: "admin"
16517
+ });
16518
+ /**
16519
+ * `mqtt-broker` — broker-registry cap.
16520
+ *
16521
+ * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
16522
+ * MQTT brokers (external + optionally an embedded `aedes`-backed one)
16523
+ * and (b) the connection details a consumer addon needs to spin up
16524
+ * its OWN `mqtt.js` client.
16525
+ *
16526
+ * Why: pub/sub routing over the system event-bus loses fidelity
16527
+ * (callback shape, QoS guarantees, will/retain semantics) and adds
16528
+ * refcount bookkeeping that addons would rather own themselves. The
16529
+ * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
16530
+ * features anyway — give it the connection config, get out of the way.
16531
+ *
16532
+ * Consumer flow:
16533
+ * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
16534
+ * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
16535
+ * client.subscribe('zigbee2mqtt/+')
16536
+ *
16537
+ * Collection mode: multiple brokers (e.g. one local mosquitto + one
16538
+ * cloud bridge). The "embedded" entry (when present) is just another
16539
+ * broker in the registry — its lifecycle is owned by the addon that
16540
+ * spawned it.
16541
+ */
16542
+ var BrokerKindSchema = _enum(["external", "embedded"]);
16543
+ /**
16544
+ * Broker live-probe status.
16545
+ *
16546
+ * - `connected` — last probe completed a clean CONNACK
16547
+ * - `disconnected` — no probe has run yet (cold cache)
16548
+ * - `auth-failed` — CONNACK refused with auth error (RC 4 / 5)
16549
+ * - `unreachable` — TCP connect timed out / refused
16550
+ * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
16551
+ */
16552
+ var BrokerStatusSchema$1 = _enum([
16553
+ "connected",
16554
+ "disconnected",
16555
+ "auth-failed",
16556
+ "unreachable",
16557
+ "tls-error"
16558
+ ]);
16559
+ var BrokerInfoSchema = object({
16560
+ id: string(),
16561
+ name: string(),
16562
+ url: string(),
16563
+ kind: BrokerKindSchema,
16564
+ status: BrokerStatusSchema$1,
16565
+ latencyMs: number().nullable(),
15833
16566
  error: string().optional(),
15834
- renderedAs: RenderedAsSchema.optional()
16567
+ /** Embedded brokers only: number of MQTT clients currently connected. */
16568
+ connectedClients: number().int().nonnegative().optional(),
16569
+ /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
16570
+ lastCheckedAt: number().optional()
15835
16571
  });
15836
- /** Same shape as SendResult — kept as a distinct name for the test panel. */
15837
- var TestResultSchema = SendResultSchema;
15838
- method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
15839
- kind: string(),
15840
- config: record(string(), unknown()).optional()
15841
- }), array(DiscoveredTargetSchema)), method(object({
15842
- targetId: string(),
15843
- notification: NotificationSchema
15844
- }), SendResultSchema, { kind: "mutation" }), method(object({
15845
- targetId: string(),
15846
- sample: NotificationSchema.optional()
15847
- }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
15848
- targetId: string(),
15849
- enabled: boolean()
15850
- }), _void(), { kind: "mutation" });
15851
16572
  /**
15852
- * Shared LLM generate contracts imported by BOTH `llm.cap.ts` (consumer
15853
- * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15854
- * caps stay wire-compatible without a circular cap→cap import.
15855
- *
15856
- * Errors are a discriminated-union RESULT, never thrown: the shape survives
15857
- * every transport tier structurally, and failed calls still write usage rows.
15858
- * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
16573
+ * Connection details what a consumer needs to call
16574
+ * `mqtt.connect(url, options)`. We split URL + credentials so the
16575
+ * consumer can pass them as `mqtt.connect(url, { username, password })`
16576
+ * instead of stuffing creds into the URL (which leaks them into logs).
15859
16577
  */
15860
- var LlmUsageSchema = object({
15861
- inputTokens: number(),
15862
- outputTokens: number()
16578
+ var BrokerConnectionDetailsSchema = object({
16579
+ url: string(),
16580
+ username: string().optional(),
16581
+ password: string().optional(),
16582
+ /**
16583
+ * Suggested prefix for `clientId`. Each consumer should suffix this
16584
+ * with its own discriminator (addon id, instance id) so reconnects
16585
+ * don't kick each other off (MQTT spec: clientId must be unique per
16586
+ * broker).
16587
+ */
16588
+ clientIdPrefix: string().optional()
15863
16589
  });
15864
- var LlmErrorCodeSchema = _enum([
15865
- "timeout",
15866
- "rate-limited",
15867
- "auth",
15868
- "refusal",
15869
- "bad-request",
15870
- "unavailable",
15871
- "no-profile",
15872
- "budget-exceeded",
15873
- "adapter-error"
15874
- ]);
15875
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
16590
+ var AddBrokerInputSchema = object({
16591
+ name: string().min(1),
16592
+ url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
16593
+ username: string().optional(),
16594
+ password: string().optional(),
16595
+ clientIdPrefix: string().optional()
16596
+ });
16597
+ var AddBrokerResultSchema = object({ id: string() });
16598
+ var IdInputSchema = object({ id: string() });
16599
+ var TestResultSchema$1 = discriminatedUnion("ok", [object({
15876
16600
  ok: literal(true),
15877
- text: string(),
15878
- model: string(),
15879
- usage: LlmUsageSchema,
15880
- truncated: boolean(),
15881
16601
  latencyMs: number()
15882
16602
  }), object({
15883
16603
  ok: literal(false),
15884
- code: LlmErrorCodeSchema,
15885
- message: string(),
15886
- retryAfterMs: number().optional()
16604
+ error: string()
15887
16605
  })]);
15888
- /**
15889
- * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
15890
- * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
15891
- * notification-output.cap.ts:27-31 precedents).
15892
- */
15893
- var LlmImageSchema = object({
15894
- bytes: _instanceof(Uint8Array),
15895
- mimeType: string()
16606
+ var StartEmbeddedInputSchema = object({
16607
+ port: number().int().min(1).max(65535).default(1883),
16608
+ /** Allow anonymous connect (no username/password). Default: false. */
16609
+ allowAnonymous: boolean().default(false),
16610
+ /** Optional shared username/password for clients. */
16611
+ username: string().optional(),
16612
+ password: string().optional()
15896
16613
  });
15897
- var LlmGenerateBaseInputSchema = object({
15898
- /** Collection routing (the notification-output posture). */
15899
- addonId: string().optional(),
15900
- /** Explicit profile; else the resolution chain (spec §3). */
15901
- profileId: string().optional(),
15902
- /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
15903
- consumer: string(),
15904
- system: string().optional(),
15905
- /** v1: single-turn. `messages[]` is a v2 additive field. */
15906
- prompt: string(),
15907
- /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
15908
- jsonSchema: record(string(), unknown()).optional(),
15909
- /** Per-call override of the profile default. */
15910
- maxTokens: number().int().positive().optional(),
15911
- temperature: number().optional()
16614
+ var StartEmbeddedResultSchema = object({
16615
+ id: string(),
16616
+ url: string()
15912
16617
  });
15913
- /**
15914
- * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
15915
- * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
15916
- * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
15917
- * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
15918
- * this only through the `llm` cap's methods.
15919
- *
15920
- * One running llama-server child per node in v1 (models are RAM-heavy).
15921
- * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
15922
- * watchdog — operator decision #3).
15923
- */
15924
- var ManagedModelRefSchema = discriminatedUnion("kind", [
15925
- object({
15926
- kind: literal("catalog"),
15927
- catalogId: string()
15928
- }),
15929
- object({
15930
- kind: literal("url"),
15931
- url: string(),
15932
- sha256: string().optional()
15933
- }),
15934
- object({
15935
- kind: literal("path"),
15936
- path: string()
15937
- })
15938
- ]);
15939
- var ManagedRuntimeConfigSchema = object({
15940
- /** WHERE the runtime lives — hub or any agent. */
15941
- nodeId: string(),
15942
- /** Closed for v1; 'ollama' is a v2 candidate. */
15943
- engine: _enum(["llama-cpp"]),
15944
- model: ManagedModelRefSchema,
15945
- contextSize: number().int().default(4096),
15946
- /** 0 = CPU-only. */
15947
- gpuLayers: number().int().default(0),
15948
- /** Default: cpus-2, clamped ≥1 (resolved node-side). */
15949
- threads: number().int().optional(),
15950
- /** Concurrent slots. */
15951
- parallel: number().int().default(1),
15952
- /** Else lazy: first generate boots it. */
15953
- autoStart: boolean().default(false),
15954
- /** 0 = never; frees RAM after quiet periods. */
15955
- idleStopMinutes: number().int().default(30)
16618
+ var StatusSchema = object({
16619
+ brokerCount: number(),
16620
+ embeddedRunning: boolean()
15956
16621
  });
15957
- var LlmRuntimeStatusSchema = object({
15958
- /** Status is ALWAYS node-qualified. */
15959
- nodeId: string(),
15960
- state: _enum([
15961
- "stopped",
15962
- "downloading",
15963
- "starting",
15964
- "ready",
15965
- "crashed",
15966
- "failed"
15967
- ]),
15968
- pid: number().optional(),
15969
- port: number().optional(),
15970
- modelPath: string().optional(),
15971
- modelId: string().optional(),
15972
- downloadProgress: number().min(0).max(1).optional(),
15973
- lastError: string().optional(),
15974
- crashesInWindow: number(),
15975
- /** Child RSS (sampled best-effort). */
15976
- memoryBytes: number().optional(),
15977
- vramBytes: number().optional()
16622
+ 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);
16623
+ var NetworkEndpointSchema = object({
16624
+ url: string(),
16625
+ hostname: string(),
16626
+ port: number(),
16627
+ protocol: _enum(["http", "https"])
15978
16628
  });
15979
- var LlmNodeModelSchema = object({
15980
- file: string(),
15981
- sizeBytes: number(),
15982
- catalogId: string().optional(),
15983
- installedAt: number().optional()
16629
+ var NetworkAccessStatusSchema = object({
16630
+ connected: boolean(),
16631
+ endpoint: NetworkEndpointSchema.nullable(),
16632
+ error: string().optional()
15984
16633
  });
15985
- var LlmRuntimeDiskUsageSchema = object({
15986
- nodeId: string(),
15987
- modelsBytes: number(),
15988
- freeBytes: number().optional()
16634
+ /**
16635
+ * Optional, richer endpoint shape returned by providers that expose
16636
+ * MORE than one ingress concurrently (Tailscale Ingress with mixed
16637
+ * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
16638
+ * the originating provider config (mode + sourcePort) so the
16639
+ * orchestrator UI can label rows distinctly. Providers that expose only
16640
+ * one endpoint just omit `listEndpoints` from their provider impl.
16641
+ */
16642
+ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
16643
+ /**
16644
+ * Stable id within the provider — typically `<mode>-<sourcePort>` so
16645
+ * the orchestrator can dedupe across `listEndpoints` polls.
16646
+ */
16647
+ id: string(),
16648
+ /** Operator-facing label (mirrors `MeshEndpoint.label`). */
16649
+ label: string(),
16650
+ /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
16651
+ mode: string().optional(),
16652
+ /** Originating local port the ingress fronts (informational). */
16653
+ sourcePort: number().optional()
15989
16654
  });
15990
- method(LlmGenerateBaseInputSchema.extend({
15991
- images: array(LlmImageSchema).optional(),
15992
- runtime: ManagedRuntimeConfigSchema,
15993
- /** The managed profile's timeout, threaded by the hub provider. */
15994
- timeoutMs: number().int().positive().optional()
15995
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
15996
- kind: "mutation",
15997
- auth: "admin"
15998
- }), method(object({}), _void(), {
15999
- kind: "mutation",
16000
- auth: "admin"
16001
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
16002
- kind: "mutation",
16003
- auth: "admin"
16004
- }), method(object({ file: string() }), _void(), {
16005
- kind: "mutation",
16006
- auth: "admin"
16007
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
16655
+ method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
16008
16656
  /**
16009
- * `llm`consumer-facing LLM surface (spec §1-§3). Collection-mode: array
16010
- * methods concat-fan across providers; single-row methods route to ONE
16011
- * provider by the `addonId` in the call input (the notification-output
16012
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
16013
- * (hub-placed); the cap stays open for future providers.
16657
+ * notification-outputcanonical, capability-gated notification delivery.
16658
+ *
16659
+ * Apprise-derived model (see
16660
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
16661
+ * callers emit ONE canonical `Notification`; each provider declares a
16662
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
16663
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
16664
+ * message to what the kind supports — callers never special-case a service.
16665
+ *
16666
+ * DESIGN DECISIONS (locked):
16667
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
16668
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
16669
+ * cap. Rationale: the admin UI needs one uniform surface across the
16670
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
16671
+ * alternative would fork the UI per addon and cannot host the
16672
+ * discovery→adopt flow.
16673
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
16674
+ * the generated cap-mount auto-`concatCollection`-fans them across every
16675
+ * registered provider (notifiers addon + HA addon) so one catalog is
16676
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
16677
+ * `addonId` the generated collection router extracts from the call input.
16678
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
16679
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
16680
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
16681
+ * base64 fallback needed.
16014
16682
  *
16015
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
16016
- * `apiKey` is a password field — providers REDACT it on read and merge on
16017
- * write; a stored key NEVER round-trips to a client.
16683
+ * TODO (deferred, closed-set change separate decision): add
16684
+ * `providerKind: 'notify'` so notification providers surface on the unified
16685
+ * admin "Integrations" page.
16018
16686
  */
16019
- var LlmProfileKindSchema = _enum([
16020
- "openai-compatible",
16021
- "openai",
16022
- "anthropic",
16023
- "google",
16024
- "managed-local"
16687
+ /**
16688
+ * Zentik-derived typed-media enum — the superset across every kind. Each
16689
+ * adapter picks what it supports and the degrade engine filters the rest.
16690
+ */
16691
+ var AttachmentMediaTypeSchema = _enum([
16692
+ "image",
16693
+ "video",
16694
+ "gif",
16695
+ "audio",
16696
+ "icon"
16025
16697
  ]);
16026
- var LlmProfileSchema = object({
16698
+ /**
16699
+ * A single attachment. Exactly one of `url` (remote source, most adapters
16700
+ * prefer this) or `bytes` (inline source; required for Pushover-style
16701
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
16702
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
16703
+ */
16704
+ var AttachmentSchema = object({
16705
+ mediaType: AttachmentMediaTypeSchema,
16706
+ url: string().optional(),
16707
+ bytes: _instanceof(Uint8Array).optional(),
16708
+ mime: string().optional(),
16709
+ name: string().optional()
16710
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
16711
+ var NotificationFormatSchema = _enum([
16712
+ "text",
16713
+ "markdown",
16714
+ "html"
16715
+ ]);
16716
+ /** A single tap-through action button. */
16717
+ var NotificationActionSchema = object({
16027
16718
  id: string(),
16028
- name: string(),
16029
- kind: LlmProfileKindSchema,
16030
- /** Stamped by the provider — keeps the fanned catalog routable. */
16031
- addonId: string(),
16032
- enabled: boolean(),
16033
- /** Vendor model id, or the managed runtime's loaded model. */
16034
- model: string(),
16035
- /** Required for openai-compatible; override for cloud kinds. */
16036
- baseUrl: string().optional(),
16037
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
16038
- apiKey: string().optional(),
16039
- supportsVision: boolean(),
16040
- temperature: number().min(0).max(2).optional(),
16041
- maxTokens: number().int().positive().optional(),
16042
- timeoutMs: number().int().positive().default(6e4),
16043
- extraHeaders: record(string(), string()).optional(),
16044
- /** kind === 'managed-local' only (spec §4). */
16045
- runtime: ManagedRuntimeConfigSchema.optional()
16719
+ label: string(),
16720
+ url: string().optional()
16046
16721
  });
16047
- /** ConfigUISchema tree passed through untyped on the wire (the
16048
- * notification-output `ConfigSchemaPassthrough` precedent at
16049
- * notification-output.cap.ts:151); the exported TS type re-tightens it. */
16722
+ /**
16723
+ * The canonical notification. `body` is the only hard field (Apprise model).
16724
+ * `priority` is a 5-level ORDINAL (1=lowest 3=normal(default) 5=urgent),
16725
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
16726
+ * the adapter maps this ordinal onto its native level. `level?` is an
16727
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
16728
+ * `priority` for that one target.
16729
+ */
16730
+ var NotificationSchema = object({
16731
+ body: string(),
16732
+ title: string().optional(),
16733
+ format: NotificationFormatSchema.default("text"),
16734
+ priority: number().int().min(1).max(5).default(3),
16735
+ level: string().optional(),
16736
+ attachments: array(AttachmentSchema).optional(),
16737
+ clickUrl: string().optional(),
16738
+ actions: array(NotificationActionSchema).optional(),
16739
+ sound: string().optional(),
16740
+ ttl: number().optional(),
16741
+ tag: string().optional(),
16742
+ deviceId: number().optional(),
16743
+ eventId: string().optional(),
16744
+ metadata: record(string(), unknown()).optional()
16745
+ });
16746
+ /** One declared native severity/priority level for a kind. */
16747
+ var TargetKindLevelSchema = object({
16748
+ id: string(),
16749
+ label: string(),
16750
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
16751
+ ordinal: number().int().min(1).max(5).nullable(),
16752
+ flags: object({
16753
+ critical: boolean().optional(),
16754
+ silent: boolean().optional(),
16755
+ noPush: boolean().optional()
16756
+ }).optional(),
16757
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
16758
+ requires: array(string()).optional(),
16759
+ description: string().optional()
16760
+ });
16761
+ /** The full capability block consulted before dispatch. */
16762
+ var TargetKindCapsSchema = object({
16763
+ attachments: object({
16764
+ mediaTypes: array(AttachmentMediaTypeSchema),
16765
+ mode: _enum([
16766
+ "url",
16767
+ "bytes",
16768
+ "both"
16769
+ ]),
16770
+ max: number().int().nonnegative(),
16771
+ maxBytes: number().int().positive().optional()
16772
+ }),
16773
+ /** Max action buttons (0 = none). */
16774
+ actions: number().int().nonnegative(),
16775
+ levels: array(TargetKindLevelSchema),
16776
+ format: array(NotificationFormatSchema),
16777
+ clickUrl: boolean(),
16778
+ sound: boolean(),
16779
+ ttl: boolean(),
16780
+ bodyMaxLen: number().int().positive()
16781
+ });
16782
+ /**
16783
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
16784
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
16785
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
16786
+ * the union is large and not meant for runtime validation here; the exported
16787
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
16788
+ */
16050
16789
  var ConfigSchemaPassthrough = unknown();
16051
- var LlmProfileKindDescriptorSchema = object({
16052
- kind: LlmProfileKindSchema,
16790
+ var TargetKindSchema = object({
16791
+ kind: string(),
16053
16792
  label: string(),
16054
16793
  icon: string(),
16055
16794
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
16056
16795
  addonId: string(),
16057
- configSchema: ConfigSchemaPassthrough
16058
- });
16059
- var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
16060
- var LlmDefaultSchema = object({
16061
- selector: LlmDefaultSelectorSchema,
16062
- profileId: string()
16063
- });
16064
- /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
16065
- var LlmUsageRollupSchema = object({
16066
- day: string(),
16067
- consumer: string(),
16068
- profileId: string(),
16069
- calls: number(),
16070
- okCalls: number(),
16071
- errorCalls: number(),
16072
- inputTokens: number(),
16073
- outputTokens: number(),
16074
- avgLatencyMs: number()
16796
+ configSchema: ConfigSchemaPassthrough,
16797
+ supportsDiscovery: boolean(),
16798
+ caps: TargetKindCapsSchema
16075
16799
  });
16076
- /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
16077
- var ManagedModelCatalogEntrySchema = object({
16800
+ /**
16801
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
16802
+ * (return a presence marker only) when serving `listTargets` — never
16803
+ * round-trip a stored secret to the UI.
16804
+ */
16805
+ var TargetSchema = object({
16078
16806
  id: string(),
16079
- label: string(),
16080
- family: string(),
16081
- purpose: _enum(["text", "vision"]),
16082
- url: string(),
16083
- sha256: string(),
16084
- sizeBytes: number(),
16085
- quantization: string(),
16086
- /** Load-time guidance shown in the picker. */
16087
- minRamBytes: number(),
16088
- contextSizeDefault: number().int(),
16089
- /** Vision models: companion projector file. */
16090
- mmprojUrl: string().optional()
16091
- });
16092
- var LlmRuntimeNodeSchema = object({
16093
- nodeId: string(),
16094
- reachable: boolean(),
16095
- status: LlmRuntimeStatusSchema.optional(),
16096
- disk: LlmRuntimeDiskUsageSchema.optional(),
16097
- error: string().optional()
16098
- });
16099
- var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
16100
- var ProfileRefInputSchema = object({
16807
+ name: string(),
16808
+ kind: string(),
16101
16809
  addonId: string(),
16102
- profileId: string()
16810
+ enabled: boolean(),
16811
+ config: record(string(), unknown())
16103
16812
  });
16104
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
16105
- kind: "mutation",
16106
- auth: "admin"
16107
- }), method(ProfileRefInputSchema, _void(), {
16108
- kind: "mutation",
16109
- auth: "admin"
16110
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
16111
- kind: "mutation",
16112
- auth: "admin"
16113
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
16114
- selector: LlmDefaultSelectorSchema,
16115
- profileId: string().nullable()
16116
- }), _void(), {
16117
- kind: "mutation",
16118
- auth: "admin"
16119
- }), method(object({
16120
- since: number().optional(),
16121
- until: number().optional(),
16122
- consumer: string().optional(),
16123
- profileId: string().optional()
16124
- }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
16125
- nodeId: string(),
16126
- model: ManagedModelRefSchema
16127
- }), _void(), {
16128
- kind: "mutation",
16129
- auth: "admin"
16130
- }), method(object({
16131
- nodeId: string(),
16132
- file: string()
16133
- }), _void(), {
16134
- kind: "mutation",
16135
- auth: "admin"
16136
- }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
16137
- kind: "mutation",
16138
- auth: "admin"
16139
- }), method(ProfileRefInputSchema, _void(), {
16140
- kind: "mutation",
16141
- auth: "admin"
16813
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
16814
+ var DiscoveredTargetSchema = object({
16815
+ kind: string(),
16816
+ suggestedName: string(),
16817
+ config: record(string(), unknown())
16818
+ });
16819
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
16820
+ var RenderedAsSchema = object({
16821
+ level: string(),
16822
+ format: NotificationFormatSchema,
16823
+ attachmentsSent: number().int().nonnegative(),
16824
+ actionsSent: number().int().nonnegative(),
16825
+ truncated: boolean(),
16826
+ dropped: array(string())
16827
+ });
16828
+ var SendResultSchema = object({
16829
+ success: boolean(),
16830
+ error: string().optional(),
16831
+ renderedAs: RenderedAsSchema.optional()
16142
16832
  });
16833
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
16834
+ var TestResultSchema = SendResultSchema;
16835
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
16836
+ kind: string(),
16837
+ config: record(string(), unknown()).optional()
16838
+ }), array(DiscoveredTargetSchema)), method(object({
16839
+ targetId: string(),
16840
+ notification: NotificationSchema
16841
+ }), SendResultSchema, { kind: "mutation" }), method(object({
16842
+ targetId: string(),
16843
+ sample: NotificationSchema.optional()
16844
+ }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
16845
+ targetId: string(),
16846
+ enabled: boolean()
16847
+ }), _void(), { kind: "mutation" });
16143
16848
  /**
16144
16849
  * Zod schemas for persisted record types.
16145
16850
  *
@@ -16825,7 +17530,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
16825
17530
  }), method(object({
16826
17531
  eventId: string(),
16827
17532
  kind: MediaFileKindEnum.optional()
16828
- }), array(MediaFileSchema).readonly()), method(object({ trackId: string() }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
17533
+ }), array(MediaFileSchema).readonly()), method(object({
17534
+ trackId: string(),
17535
+ kinds: array(MediaFileKindEnum).optional()
17536
+ }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
16829
17537
  deviceId: number(),
16830
17538
  timestamp: number(),
16831
17539
  frameWidth: number(),
@@ -16846,76 +17554,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
16846
17554
  eventId: string(),
16847
17555
  timestamp: number()
16848
17556
  });
16849
- /**
16850
- * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
16851
- * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
16852
- * caps into per-camera event-kind descriptors.
16853
- *
16854
- * The descriptor DATA (color / iconId / labelKey / parentKind / category)
16855
- * is NOT duplicated here — every entry is derived from the single
16856
- * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
16857
- * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
16858
- * control cap means adding one line here (and a taxonomy entry); the anti-
16859
- * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
16860
- * eventful cap is missing.
16861
- */
16862
- /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
16863
- var LEGACY_ICON = {
16864
- motion: "motion",
16865
- audio: "audio",
16866
- person: "person",
16867
- vehicle: "vehicle",
16868
- animal: "animal",
16869
- package: "package",
16870
- door: "door",
16871
- pir: "pir",
16872
- smoke: "smoke",
16873
- water: "water",
16874
- button: "button",
16875
- generic: "generic",
16876
- gas: "smoke",
16877
- vibration: "generic",
16878
- tamper: "generic",
16879
- presence: "person",
16880
- lock: "generic",
16881
- siren: "generic",
16882
- switch: "generic",
16883
- doorbell: "button"
16884
- };
16885
- function legacyIcon(iconId) {
16886
- return LEGACY_ICON[iconId] ?? "generic";
16887
- }
16888
- /**
16889
- * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
16890
- * The anti-drift guard cross-checks this against the eventful caps declared
16891
- * in `packages/types/src/capabilities/*.cap.ts`.
16892
- */
16893
- var CAP_TO_KIND = {
16894
- contact: "contact",
16895
- motion: "motion-sensor",
16896
- smoke: "smoke",
16897
- flood: "flood",
16898
- gas: "gas",
16899
- "carbon-monoxide": "carbon-monoxide",
16900
- vibration: "vibration",
16901
- tamper: "tamper",
16902
- presence: "presence",
16903
- "enum-sensor": "enum-sensor",
16904
- "event-emitter": "device-event",
16905
- "lock-control": "lock",
16906
- switch: "switch",
16907
- button: "button",
16908
- doorbell: "doorbell"
16909
- };
16910
- function buildDescriptor(capName, kind) {
16911
- const t = EVENT_TAXONOMY[kind];
16912
- if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
16913
- return {
16914
- ...t,
16915
- icon: legacyIcon(t.iconId)
16916
- };
16917
- }
16918
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
16919
17557
  var CameraPipelineConfigSchema = object({
16920
17558
  engine: PipelineEngineChoiceSchema.optional(),
16921
17559
  steps: array(PipelineStepInputSchema).readonly(),
@@ -17401,6 +18039,76 @@ method(object({
17401
18039
  auth: "admin"
17402
18040
  });
17403
18041
  /**
18042
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
18043
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
18044
+ * caps into per-camera event-kind descriptors.
18045
+ *
18046
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
18047
+ * is NOT duplicated here — every entry is derived from the single
18048
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
18049
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
18050
+ * control cap means adding one line here (and a taxonomy entry); the anti-
18051
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
18052
+ * eventful cap is missing.
18053
+ */
18054
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
18055
+ var LEGACY_ICON = {
18056
+ motion: "motion",
18057
+ audio: "audio",
18058
+ person: "person",
18059
+ vehicle: "vehicle",
18060
+ animal: "animal",
18061
+ package: "package",
18062
+ door: "door",
18063
+ pir: "pir",
18064
+ smoke: "smoke",
18065
+ water: "water",
18066
+ button: "button",
18067
+ generic: "generic",
18068
+ gas: "smoke",
18069
+ vibration: "generic",
18070
+ tamper: "generic",
18071
+ presence: "person",
18072
+ lock: "generic",
18073
+ siren: "generic",
18074
+ switch: "generic",
18075
+ doorbell: "button"
18076
+ };
18077
+ function legacyIcon(iconId) {
18078
+ return LEGACY_ICON[iconId] ?? "generic";
18079
+ }
18080
+ /**
18081
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
18082
+ * The anti-drift guard cross-checks this against the eventful caps declared
18083
+ * in `packages/types/src/capabilities/*.cap.ts`.
18084
+ */
18085
+ var CAP_TO_KIND = {
18086
+ contact: "contact",
18087
+ motion: "motion-sensor",
18088
+ smoke: "smoke",
18089
+ flood: "flood",
18090
+ gas: "gas",
18091
+ "carbon-monoxide": "carbon-monoxide",
18092
+ vibration: "vibration",
18093
+ tamper: "tamper",
18094
+ presence: "presence",
18095
+ "enum-sensor": "enum-sensor",
18096
+ "event-emitter": "device-event",
18097
+ "lock-control": "lock",
18098
+ switch: "switch",
18099
+ button: "button",
18100
+ doorbell: "doorbell"
18101
+ };
18102
+ function buildDescriptor(capName, kind) {
18103
+ const t = EVENT_TAXONOMY[kind];
18104
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
18105
+ return {
18106
+ ...t,
18107
+ icon: legacyIcon(t.iconId)
18108
+ };
18109
+ }
18110
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
18111
+ /**
17404
18112
  * server-management — per-NODE singleton capability for a node's ROOT
17405
18113
  * package lifecycle (runtime-updatable node packages).
17406
18114
  *
@@ -18855,7 +19563,28 @@ var FaceInfoSchema = object({
18855
19563
  * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`). Absent when the
18856
19564
  * track produced no key frame (e.g. native/onboard source) — the UI falls
18857
19565
  * back to the inline `base64` face crop. */
18858
- keyFrameMediaKey: string().optional()
19566
+ keyFrameMediaKey: string().optional(),
19567
+ /** Winning identity-match cosine (0..1) for this face's track, when an
19568
+ * identity was auto-confirmed. Lets the UI surface WHY a face was assigned
19569
+ * (confidence badge / low-confidence audit). Absent on legacy rows and on
19570
+ * faces that were never auto-recognized. */
19571
+ bestMatchScore: number().optional(),
19572
+ /** Native-scale face short side (px) at recognition time, when the runner
19573
+ * measured it. Lets the UI flag low-resolution auto-assignments. Absent on
19574
+ * legacy rows / runners that reported no native measure. */
19575
+ nativeFaceShortSidePx: number().optional(),
19576
+ /** SUGGESTED identity for this face — a plausible-but-not-confident match that
19577
+ * MISSED auto-assignment (cosine in the suggestion band, or above threshold
19578
+ * but blocked only by the recognition size floor). Mutually exclusive with
19579
+ * `recognizedIdentityId` (a suggestion is NEVER an assignment): the face stays
19580
+ * UNASSIGNED and everything else keeps treating it as unrecognized — the UI
19581
+ * merely offers a one-tap "is this <name>?" confirm. Absent on legacy rows and
19582
+ * on faces that were auto-assigned or below the suggestion band. (2026-07-24) */
19583
+ suggestedIdentityId: string().optional(),
19584
+ /** Peak identity-match cosine (0..1) for `suggestedIdentityId`, captured at the
19585
+ * same moment as `bestMatchScore` (track peak, at close). Lets the UI rank /
19586
+ * badge suggestion confidence. Present iff `suggestedIdentityId` is. (2026-07-24) */
19587
+ suggestedMatchScore: number().optional()
18859
19588
  });
18860
19589
  var FaceFilterEnum = _enum([
18861
19590
  "unassigned",
@@ -20898,36 +21627,6 @@ Object.freeze({
20898
21627
  addonId: null,
20899
21628
  access: "view"
20900
21629
  },
20901
- "advancedNotifier.deleteRule": {
20902
- capName: "advanced-notifier",
20903
- capScope: "system",
20904
- addonId: null,
20905
- access: "delete"
20906
- },
20907
- "advancedNotifier.getHistory": {
20908
- capName: "advanced-notifier",
20909
- capScope: "system",
20910
- addonId: null,
20911
- access: "view"
20912
- },
20913
- "advancedNotifier.getRules": {
20914
- capName: "advanced-notifier",
20915
- capScope: "system",
20916
- addonId: null,
20917
- access: "view"
20918
- },
20919
- "advancedNotifier.testRule": {
20920
- capName: "advanced-notifier",
20921
- capScope: "system",
20922
- addonId: null,
20923
- access: "create"
20924
- },
20925
- "advancedNotifier.upsertRule": {
20926
- capName: "advanced-notifier",
20927
- capScope: "system",
20928
- addonId: null,
20929
- access: "create"
20930
- },
20931
21630
  "alarmPanel.arm": {
20932
21631
  capName: "alarm-panel",
20933
21632
  capScope: "device",
@@ -21150,6 +21849,12 @@ Object.freeze({
21150
21849
  addonId: null,
21151
21850
  access: "delete"
21152
21851
  },
21852
+ "backup.deleteSchedule": {
21853
+ capName: "backup",
21854
+ capScope: "system",
21855
+ addonId: null,
21856
+ access: "delete"
21857
+ },
21153
21858
  "backup.getEntries": {
21154
21859
  capName: "backup",
21155
21860
  capScope: "system",
@@ -21180,6 +21885,12 @@ Object.freeze({
21180
21885
  addonId: null,
21181
21886
  access: "view"
21182
21887
  },
21888
+ "backup.listSchedules": {
21889
+ capName: "backup",
21890
+ capScope: "system",
21891
+ addonId: null,
21892
+ access: "view"
21893
+ },
21183
21894
  "backup.previewSchedule": {
21184
21895
  capName: "backup",
21185
21896
  capScope: "system",
@@ -21204,6 +21915,12 @@ Object.freeze({
21204
21915
  addonId: null,
21205
21916
  access: "create"
21206
21917
  },
21918
+ "backup.upsertSchedule": {
21919
+ capName: "backup",
21920
+ capScope: "system",
21921
+ addonId: null,
21922
+ access: "create"
21923
+ },
21207
21924
  "battery.wakeForStream": {
21208
21925
  capName: "battery",
21209
21926
  capScope: "device",
@@ -23232,6 +23949,60 @@ Object.freeze({
23232
23949
  addonId: null,
23233
23950
  access: "create"
23234
23951
  },
23952
+ "notificationRules.createRule": {
23953
+ capName: "notification-rules",
23954
+ capScope: "system",
23955
+ addonId: null,
23956
+ access: "create"
23957
+ },
23958
+ "notificationRules.deleteRule": {
23959
+ capName: "notification-rules",
23960
+ capScope: "system",
23961
+ addonId: null,
23962
+ access: "delete"
23963
+ },
23964
+ "notificationRules.getConditionCatalog": {
23965
+ capName: "notification-rules",
23966
+ capScope: "system",
23967
+ addonId: null,
23968
+ access: "view"
23969
+ },
23970
+ "notificationRules.getHistory": {
23971
+ capName: "notification-rules",
23972
+ capScope: "system",
23973
+ addonId: null,
23974
+ access: "view"
23975
+ },
23976
+ "notificationRules.getRule": {
23977
+ capName: "notification-rules",
23978
+ capScope: "system",
23979
+ addonId: null,
23980
+ access: "view"
23981
+ },
23982
+ "notificationRules.listRules": {
23983
+ capName: "notification-rules",
23984
+ capScope: "system",
23985
+ addonId: null,
23986
+ access: "view"
23987
+ },
23988
+ "notificationRules.setRuleEnabled": {
23989
+ capName: "notification-rules",
23990
+ capScope: "system",
23991
+ addonId: null,
23992
+ access: "create"
23993
+ },
23994
+ "notificationRules.testRule": {
23995
+ capName: "notification-rules",
23996
+ capScope: "system",
23997
+ addonId: null,
23998
+ access: "create"
23999
+ },
24000
+ "notificationRules.updateRule": {
24001
+ capName: "notification-rules",
24002
+ capScope: "system",
24003
+ addonId: null,
24004
+ access: "create"
24005
+ },
23235
24006
  "notifier.cancel": {
23236
24007
  capName: "notifier",
23237
24008
  capScope: "device",
@@ -24984,6 +25755,36 @@ Object.freeze({
24984
25755
  addonId: null,
24985
25756
  access: "create"
24986
25757
  },
25758
+ "terminalSession.close": {
25759
+ capName: "terminal-session",
25760
+ capScope: "system",
25761
+ addonId: null,
25762
+ access: "create"
25763
+ },
25764
+ "terminalSession.listProfiles": {
25765
+ capName: "terminal-session",
25766
+ capScope: "system",
25767
+ addonId: null,
25768
+ access: "view"
25769
+ },
25770
+ "terminalSession.listSessions": {
25771
+ capName: "terminal-session",
25772
+ capScope: "system",
25773
+ addonId: null,
25774
+ access: "view"
25775
+ },
25776
+ "terminalSession.openSession": {
25777
+ capName: "terminal-session",
25778
+ capScope: "system",
25779
+ addonId: null,
25780
+ access: "create"
25781
+ },
25782
+ "terminalSession.resize": {
25783
+ capName: "terminal-session",
25784
+ capScope: "system",
25785
+ addonId: null,
25786
+ access: "create"
25787
+ },
24987
25788
  "toast.onToast": {
24988
25789
  capName: "toast",
24989
25790
  capScope: "system",