@camstack/addon-decoder-ffmpeg 1.2.4 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +1920 -1119
  2. package/dist/index.mjs +1920 -1119
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ Object.defineProperties(exports, {
4
4
  });
5
5
  let node_crypto = require("node:crypto");
6
6
  let node_child_process = require("node:child_process");
7
- //#region ../types/dist/event-category-D4HJq7Mw.mjs
7
+ //#region ../types/dist/event-category-BLcNejAE.mjs
8
8
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
9
9
  EventCategory["SystemBoot"] = "system.boot";
10
10
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -154,9 +154,6 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
154
154
  EventCategory["RecordingSegmentWritten"] = "recording.segment.written";
155
155
  EventCategory["RecordingPolicyFallback"] = "recording.policy.fallback";
156
156
  EventCategory["RecordingRetentionCompleted"] = "recording.retention.completed";
157
- /** Runner-sampled scrub thumbnail (~1/5 s/camera). Telemetry (D8): a lost
158
- * thumb is a scrub gap the recorder's keyframe backfill covers. */
159
- EventCategory["RecordingThumbSampled"] = "recording.thumb-sampled";
160
157
  /** Export render progress (0–100). Telemetry (D8): a lost tick is a stale
161
158
  * progress bar the client reconciles via `recordingExport.getExport`. */
162
159
  EventCategory["RecordingExportProgress"] = "recording.export.progress";
@@ -6821,7 +6818,6 @@ object({ deviceId: number() }), object({ deviceId: number() }), object({
6821
6818
  patch: record(string(), unknown())
6822
6819
  }), object({ success: literal(true) });
6823
6820
  object({ deviceId: number() }), unknown().nullable();
6824
- /** Shorthand to define a method schema */
6825
6821
  function method(input, output, options) {
6826
6822
  return {
6827
6823
  input,
@@ -6829,6 +6825,7 @@ function method(input, output, options) {
6829
6825
  kind: options?.kind ?? "query",
6830
6826
  auth: options?.auth ?? "protected",
6831
6827
  ...options?.access !== void 0 ? { access: options.access } : {},
6828
+ ...options?.caller !== void 0 ? { caller: options.caller } : {},
6832
6829
  timeoutMs: options?.timeoutMs
6833
6830
  };
6834
6831
  }
@@ -7522,16 +7519,23 @@ var StorageLocationDeclarationSchema = object({
7522
7519
  * Which node root the seeded `<id>:default` instance is placed under on a
7523
7520
  * FRESH install:
7524
7521
  * - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
7525
- * the appData volume. Right for small/durable data (backups, logs, models).
7522
+ * the appData volume. Right for small/durable data (logs, models).
7526
7523
  * - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
7527
7524
  * env is set, else falls back to the data root. Right for bulky, hot media
7528
7525
  * (recordings, event media) that should stay off the appData disk.
7526
+ * - `'backup'` — the dedicated backup volume (`CAMSTACK_BACKUP_ROOT`, default
7527
+ * `/backups` in the image) so archives live on their own mount rather than
7528
+ * filling the appData disk. Falls back to the data root when unset.
7529
7529
  *
7530
7530
  * Only affects the seeded default's `basePath`; operators can repoint any
7531
7531
  * location afterwards, and a `defaultsTo` slot inherits its parent's root
7532
7532
  * regardless of this field. Absent (the common case) is treated as `'data'`.
7533
7533
  */
7534
- defaultRoot: _enum(["data", "media"]).optional()
7534
+ defaultRoot: _enum([
7535
+ "data",
7536
+ "media",
7537
+ "backup"
7538
+ ]).optional()
7535
7539
  });
7536
7540
  var DecoderStatsSchema = object({
7537
7541
  inputFps: number(),
@@ -8194,6 +8198,59 @@ for (const l of AUDIO_MACRO_LABELS) {
8194
8198
  /** The complete taxonomy dictionary, keyed by kind. */
8195
8199
  var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
8196
8200
  /**
8201
+ * Notification-Center taxonomy — the fixed vocabulary the NC rule editor
8202
+ * offers as pickers instead of free text. Derived (never hand-listed) from the
8203
+ * single `EVENT_TAXONOMY` dictionary so it stays in lockstep with every other
8204
+ * taxonomy surface (timeline, filters, event page).
8205
+ *
8206
+ * Three buckets, mapped onto the rule editor's `stringList` conditions:
8207
+ * - `videoClasses` → detection classes (person / vehicle / animal + subs)
8208
+ * for the `classes` / `classesExclude` conditions.
8209
+ * - `audioKinds` → audio-analyzer sub kinds (`audio-scream`, …) shown in
8210
+ * the same class picker, grouped under an Audio header.
8211
+ * - `labels` → sensor + control taxonomy kinds (doorbell / contact /
8212
+ * lock / …) for the `sensorKinds` device-event condition.
8213
+ *
8214
+ * Each entry carries `parentKind` so the client can group video subs under
8215
+ * their macro and sensor/control kinds under their category. This surface is
8216
+ * served ADDITIVELY on the `nc.getConditionCatalog` bridge response — no cap
8217
+ * method, no codegen — so it ships train-free with an addon deploy.
8218
+ */
8219
+ /** One selectable taxonomy value: a stable kind id + display label + parent. */
8220
+ var NcTaxonomyEntrySchema = object({
8221
+ /** Stable kind id (e.g. 'person', 'car', 'audio-scream', 'doorbell'). */
8222
+ kind: string(),
8223
+ /** English fallback label (the UI translates via the event-kind i18n key). */
8224
+ label: string(),
8225
+ /** Macro/category parent for grouping ('car' → 'vehicle'); null for a top. */
8226
+ parentKind: string().nullable()
8227
+ });
8228
+ object({
8229
+ videoClasses: array(NcTaxonomyEntrySchema),
8230
+ audioKinds: array(NcTaxonomyEntrySchema),
8231
+ labels: array(NcTaxonomyEntrySchema)
8232
+ });
8233
+ function toEntry(kind, label, parentKind) {
8234
+ return {
8235
+ kind,
8236
+ label,
8237
+ parentKind
8238
+ };
8239
+ }
8240
+ /**
8241
+ * Build the NC taxonomy from `EVENT_TAXONOMY`. Insertion order is preserved
8242
+ * (macros before their subs), which the client relies on for stable grouping.
8243
+ */
8244
+ function buildNcTaxonomy() {
8245
+ const all = Object.values(EVENT_TAXONOMY);
8246
+ return {
8247
+ videoClasses: all.filter((e) => e.category === "detection").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8248
+ audioKinds: all.filter((e) => e.category === "audio" && e.level === "sub").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8249
+ labels: all.filter((e) => e.category === "sensor" || e.category === "control").map((e) => toEntry(e.kind, e.label, e.parentKind))
8250
+ };
8251
+ }
8252
+ Object.freeze(buildNcTaxonomy());
8253
+ /**
8197
8254
  * Error types for the safe expression engine. Two distinct classes so callers
8198
8255
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
8199
8256
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -8829,6 +8886,644 @@ var AccessoryKind = {
8829
8886
  AccessoryKind.Siren, AccessoryKind.Floodlight, AccessoryKind.Spotlight, AccessoryKind.PirSensor, AccessoryKind.Chime, AccessoryKind.Autotrack, AccessoryKind.Nightvision, AccessoryKind.PrivacyMask;
8830
8887
  DeviceFeature.BatteryOperated;
8831
8888
  /**
8889
+ * Shared geometry vocabulary for on-frame shape caps — privacy-mask,
8890
+ * motion-zones, and the detection zones/lines editor all speak this one
8891
+ * language so a single drawing-plane editor and the providers stay
8892
+ * decoupled from each cap's storage.
8893
+ *
8894
+ * All coordinates are normalized 0..1 of the camera frame (top-left
8895
+ * origin). Each cap composes the SUBSET of shape kinds it supports and
8896
+ * advertises it via `supportedShapes` in its `getOptions`.
8897
+ */
8898
+ /** A normalized 0..1 point (top-left origin). */
8899
+ var MaskPointSchema = object({
8900
+ x: number(),
8901
+ y: number()
8902
+ });
8903
+ /** Axis-aligned rectangle (normalized 0..1). */
8904
+ var MaskRectShapeSchema = object({
8905
+ kind: literal("rect"),
8906
+ x: number(),
8907
+ y: number(),
8908
+ width: number(),
8909
+ height: number()
8910
+ });
8911
+ /** Free polygon — an ordered list of normalized vertices (≥3). */
8912
+ var MaskPolygonShapeSchema = object({
8913
+ kind: literal("polygon"),
8914
+ points: array(MaskPointSchema)
8915
+ });
8916
+ /** Boolean cell grid — row-major, length === gridWidth*gridHeight. */
8917
+ var MaskGridShapeSchema = object({
8918
+ kind: literal("grid"),
8919
+ gridWidth: number(),
8920
+ gridHeight: number(),
8921
+ cells: array(boolean())
8922
+ });
8923
+ discriminatedUnion("kind", [
8924
+ MaskRectShapeSchema,
8925
+ MaskPolygonShapeSchema,
8926
+ MaskGridShapeSchema,
8927
+ object({
8928
+ kind: literal("line"),
8929
+ points: array(MaskPointSchema)
8930
+ })
8931
+ ]);
8932
+ /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
8933
+ var MaskShapeKindSchema = _enum([
8934
+ "rect",
8935
+ "polygon",
8936
+ "grid",
8937
+ "line"
8938
+ ]);
8939
+ /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
8940
+ var MaskPolygonVerticesSchema = object({
8941
+ min: number(),
8942
+ max: number()
8943
+ });
8944
+ /** Grid dimensions when a cap supports 'grid'. */
8945
+ var MaskGridDimsSchema = object({
8946
+ width: number(),
8947
+ height: number()
8948
+ });
8949
+ /**
8950
+ * notification-rules — the Notification Center rule surface (P1 core).
8951
+ *
8952
+ * Spec: `docs/superpowers/specs/2026-07-22-notification-center-requirements.md`
8953
+ * (operator decisions D-1/D-2/D-3 are binding):
8954
+ *
8955
+ * - D-2: rule EVALUATION lives in `addon-post-analysis` (the
8956
+ * `notification-center` module), hooked on the durable persistence
8957
+ * moments (object-event insert, TrackCloser.closeExpired) with a
8958
+ * persisted outbox + retry — never the lossy telemetry bus (D8).
8959
+ * - D-3: urgency belongs to the RULE. `delivery: 'immediate'` fires on the
8960
+ * FIRST persisted detection matching the conditions (per-track dedup,
8961
+ * `maxPerTrack` fixed at 1 — see {@link NC_MAX_PER_TRACK_IMMEDIATE});
8962
+ * `delivery: 'track-end'` evaluates the finalized track record at close.
8963
+ * - DISPATCH stays behind `notification-output` (rules reference targets
8964
+ * by id; per-backend params are a passthrough blob capped by the
8965
+ * target kind's own caps/degrade engine).
8966
+ *
8967
+ * P1 scope: admin-authored rules only (`createdBy` stamped from the
8968
+ * server-injected caller identity — the first `caller: 'required'`
8969
+ * adopter). The P1 condition subset is: devices, classes(+exclude),
8970
+ * minConfidence, admin zones (any/all + exclude), weekly schedule
8971
+ * windows, and the optional label/identity/plate matchers. User rules,
8972
+ * private zones, per-recipient fan-out and the wider condition table are
8973
+ * P2+ (see spec §7).
8974
+ *
8975
+ * All schemas here are the single source of truth — `NcRule` etc. are
8976
+ * `z.infer` exports; no duplicate interfaces (the advanced-notifier
8977
+ * schema/interface drift is explicitly not repeated).
8978
+ */
8979
+ /**
8980
+ * D-3: the trigger/urgency of a rule — which persistence moment evaluates it.
8981
+ * The value maps 1:1 onto the evaluated record kind:
8982
+ * - `immediate` ↔ object-event persist (lowest-latency detection burst)
8983
+ * - `track-end` ↔ TrackCloser.closeExpired (finalized track record)
8984
+ * - `device-event` ↔ SensorEventStore insert (doorbell press / sensor state
8985
+ * change of a LINKED device, one row per linked camera)
8986
+ * - `package-event` ↔ PackageDropDetector object-event insert (a `package`
8987
+ * delivery / pick-up)
8988
+ *
8989
+ * `immediate`/`track-end` carry the D-3 urgency semantics; `device-event`/
8990
+ * `package-event` are pure trigger kinds (no urgency dimension). Extending
8991
+ * this one field keeps the schema additive — a rule still declares exactly
8992
+ * one trigger.
8993
+ */
8994
+ var NcDeliverySchema = _enum([
8995
+ "immediate",
8996
+ "track-end",
8997
+ "device-event",
8998
+ "package-event"
8999
+ ]);
9000
+ /** Weekly schedule — OR of windows; absence on the rule = always active. */
9001
+ var NcScheduleSchema = object({
9002
+ windows: array(object({
9003
+ /** Days of week the window STARTS on (0 = Sunday … 6 = Saturday). */
9004
+ days: array(number().int().min(0).max(6)).min(1),
9005
+ startMinute: number().int().min(0).max(1439),
9006
+ endMinute: number().int().min(0).max(1439)
9007
+ })).min(1),
9008
+ /** IANA timezone; default = hub host timezone. */
9009
+ timezone: string().optional(),
9010
+ /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
9011
+ invert: boolean().optional()
9012
+ });
9013
+ /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
9014
+ var NcPlateMatcherSchema = object({
9015
+ values: array(string().min(1)).min(1),
9016
+ /** Max Levenshtein distance after normalization (uppercase alphanumeric). */
9017
+ maxDistance: number().int().min(0).max(3).default(1)
9018
+ });
9019
+ /**
9020
+ * Occupancy condition (DEVICE-EVENT trigger). Fires on a ZoneAnalytics
9021
+ * occupancy edge for a device — optionally narrowed to a single admin
9022
+ * `zoneId` and/or object `className`. `op` selects the edge/threshold:
9023
+ * - `became-occupied` (default) — count crossed 0 → ≥ `count`
9024
+ * - `became-free` — count crossed ≥ `count` → below it
9025
+ * - `>=` / `<=` — count is at/over or at/under `count`
9026
+ * `sustainSeconds` requires the condition hold continuously that long
9027
+ * before firing (debounces flicker; 0 = fire on the first matching edge).
9028
+ * Fail-closed: no ZoneAnalytics snapshot / missing zone / null snapshot ⇒
9029
+ * the condition never matches. Confirmed edge-state survives addon restarts
9030
+ * (declared SQLite collection, reseeded on boot).
9031
+ */
9032
+ var NcOccupancyConditionSchema = object({
9033
+ /** Admin zone id to scope the count to; absent = whole-frame occupancy. */
9034
+ zoneId: string().optional(),
9035
+ /** Object class to count; absent = any class. */
9036
+ className: string().optional(),
9037
+ op: _enum([
9038
+ "became-occupied",
9039
+ "became-free",
9040
+ ">=",
9041
+ "<="
9042
+ ]).default("became-occupied"),
9043
+ count: number().int().min(0).default(1),
9044
+ sustainSeconds: number().int().min(0).max(3600).default(15)
9045
+ });
9046
+ /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
9047
+ var NcZoneConditionSchema = object({
9048
+ ids: array(string().min(1)).min(1),
9049
+ /** Quantifier over `ids` — at least one / every one visited. */
9050
+ match: _enum(["any", "all"]).default("any")
9051
+ });
9052
+ /**
9053
+ * The P1 condition set — a flat AND of groups; absent group = pass;
9054
+ * membership lists are OR within the list (spec §2.3).
9055
+ */
9056
+ var NcConditionsSchema = object({
9057
+ /** Device scope — absent = all devices. */
9058
+ devices: array(number()).optional(),
9059
+ /** Detector class names (any overlap with the record's class set). */
9060
+ classes: array(string().min(1)).optional(),
9061
+ /** Veto classes — any overlap fails the rule. */
9062
+ classesExclude: array(string().min(1)).optional(),
9063
+ /** Minimum detection confidence 0–1 (fails when the record has none). */
9064
+ minConfidence: number().min(0).max(1).optional(),
9065
+ /** Admin zone membership over event `zones` / track `zonesVisited`. */
9066
+ zones: NcZoneConditionSchema.optional(),
9067
+ /** Veto zones — any hit fails the rule. */
9068
+ zonesExclude: array(string().min(1)).optional(),
9069
+ /**
9070
+ * Exact (case-insensitive) match on the record's collapsed `label`
9071
+ * (identity name / plate text / subclass).
9072
+ */
9073
+ labelEquals: array(string().min(1)).optional(),
9074
+ /**
9075
+ * Identity matcher. P1 boundary: matched against the record's collapsed
9076
+ * `label` (the identity display name propagated by the face pipeline) —
9077
+ * identity-ID matching rides in P2 when identity ids reach the record.
9078
+ */
9079
+ identities: array(string().min(1)).optional(),
9080
+ /** Fuzzy plate matcher against the record's `label` (plate text). */
9081
+ plates: NcPlateMatcherSchema.optional(),
9082
+ /**
9083
+ * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
9084
+ * Same P1 boundary: matched against the record's collapsed `label` (the
9085
+ * identity display name). A record with NO label passes (nothing to
9086
+ * exclude), unlike the include variant which fails on an absent label.
9087
+ */
9088
+ identitiesExclude: array(string().min(1)).optional(),
9089
+ /**
9090
+ * Minimum server-computed key-event importance in [0,1] (`Track.importance`).
9091
+ * TRACK-END only: importance is scored at track close, so it does not exist
9092
+ * at immediate / object-event evaluation time (see catalog `appliesTo`). At
9093
+ * close the value is threaded via the close-time info (the `Track` clone is
9094
+ * captured before the DB row is updated, so it would otherwise read stale).
9095
+ * Fails when the record carries no importance (never guess quality — the
9096
+ * `minConfidence` precedent). MVP cut: a single scalar threshold.
9097
+ */
9098
+ minImportance: number().min(0).max(1).optional(),
9099
+ /**
9100
+ * Minimum track dwell in SECONDS — `(lastSeen − firstSeen) / 1000`.
9101
+ * TRACK-END only: an `immediate` / object-event subject has no closed
9102
+ * lifespan, so a dwell condition never matches immediate delivery
9103
+ * (documented choice — the object-event record carries no `firstSeen`,
9104
+ * so dwell cannot be computed from what the subject actually carries).
9105
+ */
9106
+ minDwellSeconds: number().min(0).optional(),
9107
+ /**
9108
+ * Detection provenance filter. `any` (default / absent) matches every
9109
+ * source; otherwise the subject's source must equal it. Legacy records
9110
+ * with no stamped source are treated as `pipeline`. The union spans both
9111
+ * record kinds — object events carry `pipeline` | `onboard`, synthetic
9112
+ * tracks carry `sensor`.
9113
+ */
9114
+ source: _enum([
9115
+ "pipeline",
9116
+ "onboard",
9117
+ "sensor",
9118
+ "any"
9119
+ ]).optional(),
9120
+ /**
9121
+ * Minimum identity / plate MATCH confidence in [0,1] — DISTINCT from the
9122
+ * detector `minConfidence` (that gates the object-detection score; this
9123
+ * gates the recognition/OCR match score). Fails when the subject carries
9124
+ * no label-match confidence (never guess). TRACK-END only: the confidence
9125
+ * lives on the recognition result and reaches the subject at track close.
9126
+ *
9127
+ * What it measures precisely (plumbed at track close — the closer threads
9128
+ * the value into `NcTrackClosedInfo.labelConfidence`, the same seam as
9129
+ * `importance`): the BEST recognition match confidence observed for the
9130
+ * label the track carries at close — for a face, the peak cosine similarity
9131
+ * of the ASSIGNED identity (`FaceMatch.score`, reset on an identity switch);
9132
+ * for a plate, the peak OCR read score of the best-held plate
9133
+ * (`plateText.confidence`). When BOTH a face and a plate were recognized on
9134
+ * one track the higher of the two is used. A track that ended with no
9135
+ * confident identity/plate match carries no value, so the condition fails
9136
+ * closed for it (an un-recognized subject).
9137
+ */
9138
+ minLabelConfidence: number().min(0).max(1).optional(),
9139
+ /**
9140
+ * DEVICE-EVENT only. Raw device event-type tokens (`EventFire.eventType`,
9141
+ * e.g. a doorbell `press` / `press_long`) — matched case-insensitively
9142
+ * against the token carried on the device-event subject (extracted from the
9143
+ * event-emitter runtime slice's `lastEvent.eventType`). Fails when the
9144
+ * subject carries no token. Doorbell-pulse / passive-sensor kinds emit no
9145
+ * eventType, so gate those with {@link sensorKinds} instead.
9146
+ */
9147
+ eventTypeTokens: array(string().min(1)).optional(),
9148
+ /**
9149
+ * DEVICE-EVENT only. Sensor/control taxonomy kinds (e.g. `doorbell`,
9150
+ * `contact`, `button`, `device-event`) — matched against the persisted
9151
+ * `SensorEvent.kind` (see `sensor-event-kinds.ts`). Membership is OR.
9152
+ */
9153
+ sensorKinds: array(string().min(1)).optional(),
9154
+ /**
9155
+ * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
9156
+ * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
9157
+ * when the subject's phase does not match (a subject always carries a phase
9158
+ * on the package-event trigger).
9159
+ */
9160
+ packagePhase: _enum([
9161
+ "delivered",
9162
+ "picked-up",
9163
+ "both"
9164
+ ]).optional(),
9165
+ /**
9166
+ * PERSONAL-RULE custom zones (viewer-drawn). Inline normalized polygons
9167
+ * (MaskShape vocabulary). A record passes when its bbox overlaps ANY
9168
+ * listed polygon (ZoneEngine membership semantics). Evaluated only when
9169
+ * the subject carries a bbox; absent bbox ⇒ the condition FAILS.
9170
+ */
9171
+ customZones: array(MaskPolygonShapeSchema).optional(),
9172
+ /**
9173
+ * DEVICE-EVENT only. ZoneAnalytics occupancy edge — fires when a device's
9174
+ * (optionally zone/class-scoped) occupancy count crosses the configured
9175
+ * threshold and holds for `sustainSeconds`. Fail-closed on missing
9176
+ * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
9177
+ */
9178
+ occupancy: NcOccupancyConditionSchema.optional()
9179
+ });
9180
+ /** One delivery target: a `notification-output` Target ref + passthrough params. */
9181
+ var NcRuleTargetSchema = object({
9182
+ /** `notification-output` Target id. */
9183
+ targetId: string().min(1),
9184
+ /**
9185
+ * Per-backend passthrough. Recognized keys are mapped onto the canonical
9186
+ * Notification (`priority`, `level`, `sound`, `clickUrl`, `ttl`); the
9187
+ * degrade engine drops what the backend can't render.
9188
+ */
9189
+ params: record(string(), unknown()).optional()
9190
+ });
9191
+ /**
9192
+ * Media attachment policy (P1 still-image subset).
9193
+ * - `best` — the best AVAILABLE subject image at dispatch time (D-3).
9194
+ * - `best-matching` — the media that explains WHY the rule fired: a rule
9195
+ * matched on identities attaches the subject's `faceCrop`, one matched on
9196
+ * plates attaches the `plateCrop`; a rule with no identity/plate condition
9197
+ * (or when the specific crop is missing) degrades to `best`, then
9198
+ * `keyFrame`, then no attachment — never delaying the send. The matched
9199
+ * condition summary is frozen on the outbox row at enqueue (like the rule
9200
+ * name), so the choice never drifts from the record that fired it.
9201
+ * - `keyFrame` — the clean scene frame (no subject box).
9202
+ * - `none` — no attachment.
9203
+ */
9204
+ var NcMediaPolicySchema = object({ attach: _enum([
9205
+ "best",
9206
+ "best-matching",
9207
+ "keyFrame",
9208
+ "none"
9209
+ ]).default("best") });
9210
+ /** Throttle — cooldown survives restarts (rebuilt from the outbox on boot). */
9211
+ var NcThrottleSchema = object({
9212
+ cooldownSec: number().int().min(0).max(86400).default(60),
9213
+ /** `rule` = one shared cooldown; `rule-device` = per-camera cooldown. */
9214
+ scope: _enum(["rule", "rule-device"]).default("rule-device")
9215
+ });
9216
+ /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
9217
+ var NcRuleInputSchema = object({
9218
+ name: string().min(1).max(200),
9219
+ enabled: boolean().default(true),
9220
+ delivery: NcDeliverySchema,
9221
+ conditions: NcConditionsSchema.default({}),
9222
+ schedule: NcScheduleSchema.optional(),
9223
+ targets: array(NcRuleTargetSchema).min(1),
9224
+ media: NcMediaPolicySchema.default({ attach: "best" }),
9225
+ throttle: NcThrottleSchema.default({
9226
+ cooldownSec: 60,
9227
+ scope: "rule-device"
9228
+ }),
9229
+ /** `{{var}}` templating over camera/class/label/zones/confidence/time. */
9230
+ template: object({
9231
+ title: string().max(500).optional(),
9232
+ body: string().max(2e3).optional()
9233
+ }).optional(),
9234
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
9235
+ priority: number().int().min(1).max(5).default(3),
9236
+ /**
9237
+ * Ownership/visibility key. Absent = admin/global rule (unchanged legacy
9238
+ * behaviour, visible to all, read-only in the viewer). Present = personal
9239
+ * rule owned by this userId. Server-stamped; never trusted from a client.
9240
+ */
9241
+ ownerUserId: string().optional()
9242
+ });
9243
+ /**
9244
+ * Partial patch for `updateRule` — any subset of the input fields, plus the
9245
+ * persisted-only {@link NcRuleSchema} `disabledTargetIds` set. The latter is
9246
+ * NOT a client-authored input field (it lives on the persisted rule, not the
9247
+ * input), so it is added here explicitly to let the store's per-target opt-out
9248
+ * toggle round-trip through the shared `update` path. Viewer opt-out mutations
9249
+ * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
9250
+ * `updateRule` patch.
9251
+ */
9252
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
9253
+ /** A persisted rule. */
9254
+ var NcRuleSchema = NcRuleInputSchema.extend({
9255
+ id: string(),
9256
+ /** userId of the admin who created the rule (server-stamped caller). */
9257
+ createdBy: string(),
9258
+ createdAt: number(),
9259
+ updatedAt: number(),
9260
+ /**
9261
+ * Per-target opt-out set. A targetId here is suppressed for THIS rule at
9262
+ * send time. Only a target's OWNER may add/remove its id (server-checked
9263
+ * in `nc.setRuleTargetEnabled`). Defaults to empty.
9264
+ */
9265
+ disabledTargetIds: array(string()).default([])
9266
+ });
9267
+ var NcTestResultSchema = object({
9268
+ recordId: string(),
9269
+ recordKind: _enum([
9270
+ "object-event",
9271
+ "track",
9272
+ "device-event",
9273
+ "package-event"
9274
+ ]),
9275
+ deviceId: number(),
9276
+ timestamp: number(),
9277
+ wouldFire: boolean(),
9278
+ /** Condition id that failed (first failing group), when `wouldFire` is false. */
9279
+ failedCondition: string().optional(),
9280
+ className: string().optional(),
9281
+ label: string().optional()
9282
+ });
9283
+ var NcConditionDescriptorSchema = object({
9284
+ /** Field id inside `NcConditions` (or `'schedule'` for the rule-level group). */
9285
+ id: string(),
9286
+ group: _enum([
9287
+ "scope",
9288
+ "class",
9289
+ "zones",
9290
+ "quality",
9291
+ "label",
9292
+ "schedule",
9293
+ "device",
9294
+ "package",
9295
+ "occupancy"
9296
+ ]),
9297
+ label: string(),
9298
+ /** Editor widget the UI renders — never hardcode per-condition forms. */
9299
+ valueType: _enum([
9300
+ "deviceIdList",
9301
+ "stringList",
9302
+ "number01",
9303
+ "number",
9304
+ "sourceSelect",
9305
+ "zoneSelection",
9306
+ "zoneIdList",
9307
+ "schedule",
9308
+ "plateMatcher",
9309
+ "packagePhase",
9310
+ "polygonDraw",
9311
+ "occupancy"
9312
+ ]),
9313
+ operator: _enum([
9314
+ "in",
9315
+ "notIn",
9316
+ "anyOf",
9317
+ "allOf",
9318
+ "gte",
9319
+ "fuzzyIn",
9320
+ "withinSchedule"
9321
+ ]),
9322
+ /** Which delivery kinds the condition applies to. */
9323
+ appliesTo: array(NcDeliverySchema),
9324
+ phase: string(),
9325
+ description: string().optional()
9326
+ });
9327
+ /**
9328
+ * The delivery lifecycle status of a history row — a straight read of the
9329
+ * durable outbox row's own status (single source of truth):
9330
+ * - `pending` — enqueued, in-flight or retrying with backoff
9331
+ * - `sent` — delivered (terminal)
9332
+ * - `dead` — dead-lettered after exhausting retries / a permanent
9333
+ * backend rejection / a deleted target (terminal; carries
9334
+ * the failure `error`)
9335
+ *
9336
+ * P1 has no `suppressed-quiet-hours` / `snoozed` states — those ride the P2
9337
+ * user dimension (quiet hours / snooze) and are additive when they land.
9338
+ */
9339
+ var NcHistoryStatusSchema = _enum([
9340
+ "pending",
9341
+ "sent",
9342
+ "dead"
9343
+ ]);
9344
+ /** The evaluated record kind a history row descends from (one per trigger). */
9345
+ var NcHistoryRecordKindSchema = _enum([
9346
+ "object-event",
9347
+ "track-end",
9348
+ "device-event",
9349
+ "package-event"
9350
+ ]);
9351
+ /** Subject summary frozen on the row at fire time (survives rule/record edits). */
9352
+ var NcHistorySubjectSchema = object({
9353
+ className: string(),
9354
+ label: string().optional(),
9355
+ confidence: number().optional(),
9356
+ zones: array(string()),
9357
+ timestamp: number()
9358
+ });
9359
+ /**
9360
+ * One delivery-history row. This is a read-only VIEW over the durable
9361
+ * outbox row (single source of truth — the same row the drain loop drives;
9362
+ * NO second write path, so history can never drift from delivery state).
9363
+ * The §3.2 fields map directly: `ruleId`/`targetId`/`deviceId` are columns,
9364
+ * `eventRef` is `recordKind`+`recordId`, `timestamps` are `createdAt`
9365
+ * (fire) / `updatedAt` (last transition), `status` + `error` are the
9366
+ * lifecycle. `ruleName` + `subject` are the intent snapshot frozen at
9367
+ * enqueue. `userId?` (per-recipient history) is P2 — no user dimension in
9368
+ * P1 (admin scope only).
9369
+ */
9370
+ var NcHistoryEntrySchema = object({
9371
+ /** Outbox row id — the stable dedup id `ruleId:dedupRef:targetId`. */
9372
+ id: string(),
9373
+ ruleId: string(),
9374
+ /** Rule name frozen at fire time (outlives a later rename / delete). */
9375
+ ruleName: string(),
9376
+ /** The rule urgency/trigger that produced this delivery. */
9377
+ delivery: NcDeliverySchema,
9378
+ targetId: string(),
9379
+ deviceId: number(),
9380
+ recordKind: NcHistoryRecordKindSchema,
9381
+ /** Event / track ref of the evaluated record (§3.2 `eventRef`). */
9382
+ recordId: string(),
9383
+ /** Present for track-scoped deliveries (object-event / track-end). */
9384
+ trackId: string().optional(),
9385
+ status: NcHistoryStatusSchema,
9386
+ /** Delivery attempts made so far. */
9387
+ attempts: number().int(),
9388
+ /** Fire time (outbox enqueue). */
9389
+ createdAt: number(),
9390
+ /** Last transition time (terminal for sent / dead). */
9391
+ updatedAt: number(),
9392
+ /** Failure detail — present on a `dead` row. */
9393
+ error: string().optional(),
9394
+ subject: NcHistorySubjectSchema
9395
+ });
9396
+ /**
9397
+ * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
9398
+ * AND; absent = unbounded on that axis. `since`/`until` bound the fire time
9399
+ * (`createdAt`, epoch ms, inclusive). `limit` is clamped to
9400
+ * {@link NC_HISTORY_LIMIT_MAX}. `userId` (per-recipient filtering) is P2.
9401
+ */
9402
+ var NcHistoryFilterSchema = object({
9403
+ ruleId: string().optional(),
9404
+ deviceId: number().optional(),
9405
+ status: NcHistoryStatusSchema.optional(),
9406
+ since: number().optional(),
9407
+ until: number().optional(),
9408
+ limit: number().int().min(1).max(500).default(100)
9409
+ });
9410
+ 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 }), {
9411
+ kind: "mutation",
9412
+ auth: "admin",
9413
+ caller: "required"
9414
+ }), method(object({
9415
+ ruleId: string(),
9416
+ patch: NcRulePatchSchema
9417
+ }), object({ rule: NcRuleSchema }), {
9418
+ kind: "mutation",
9419
+ auth: "admin",
9420
+ caller: "required"
9421
+ }), method(object({ ruleId: string() }), object({ success: literal(true) }), {
9422
+ kind: "mutation",
9423
+ auth: "admin"
9424
+ }), method(object({
9425
+ ruleId: string(),
9426
+ enabled: boolean()
9427
+ }), object({ success: literal(true) }), {
9428
+ kind: "mutation",
9429
+ auth: "admin"
9430
+ }), method(object({
9431
+ rule: NcRuleInputSchema,
9432
+ lookbackMinutes: number().int().min(1).max(1440).default(60)
9433
+ }), object({ results: array(NcTestResultSchema) }), {
9434
+ kind: "mutation",
9435
+ auth: "admin"
9436
+ }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
9437
+ /**
9438
+ * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
9439
+ *
9440
+ * Spec: `docs/superpowers/specs/2026-07-24-nc-occupancy-timelapse-design.md`
9441
+ * §3.2/§3.3.
9442
+ *
9443
+ * Deliberately NOT a capability definition and NOT an `NcRule`:
9444
+ * - Every `NcDelivery` member is a *persisted-pipeline-record* trigger. A
9445
+ * timelapse fires on a SCHEDULE WINDOW BOUNDARY, evaluates no pipeline
9446
+ * record, and produces a video it assembled itself — so it rides no
9447
+ * delivery-enum member (the enum is frozen) and no cap method. This file is
9448
+ * a plain typed schema; it does NOT go through `npm run codegen`.
9449
+ * - It shares only the delivery leg (`notification-output.send`) and the
9450
+ * persistence/ownership patterns with the Notification Center, reusing
9451
+ * {@link NcScheduleSchema} (weekly windows, midnight-crossing, invertible)
9452
+ * and {@link NcRuleTargetSchema} (target ref + passthrough params).
9453
+ *
9454
+ * Ownership is SERVER-DERIVED. `ownerUserId` / `createdBy` / `createdAt` /
9455
+ * `updatedAt` / `id` / `lastGeneratedAt` live on the PERSISTED rule only —
9456
+ * {@link TimelapseRuleInputSchema} and {@link TimelapseRulePatchSchema} do not
9457
+ * carry them, so a forged client payload can never claim or re-own a rule
9458
+ * (Zod strips unknown keys). The store stamps them from the resolved caller.
9459
+ */
9460
+ /** `{{var}}` templating over camera/rule/time — same vocabulary as `NcRule`. */
9461
+ var TimelapseTemplateSchema = object({
9462
+ title: string().max(500).optional(),
9463
+ body: string().max(2e3).optional()
9464
+ });
9465
+ var NameField = string().min(1).max(200);
9466
+ var DeviceIdsField = array(number()).min(1);
9467
+ var CadenceSecField = number().int().min(2).max(3600);
9468
+ var FramerateField = number().int().min(1).max(60);
9469
+ var TargetsField = array(NcRuleTargetSchema).min(1);
9470
+ var PriorityField = number().int().min(1).max(5);
9471
+ /**
9472
+ * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
9473
+ * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
9474
+ * here (see the ownership note above).
9475
+ */
9476
+ var TimelapseRuleInputSchema = object({
9477
+ name: NameField,
9478
+ enabled: boolean().default(true),
9479
+ /** Cameras sampled by this rule — one scratch dir + one artifact per device. */
9480
+ deviceIds: DeviceIdsField,
9481
+ /**
9482
+ * Activation window(s). REQUIRED (unlike `NcRule`, where an absent schedule
9483
+ * means "always active"): a timelapse is defined by its window boundaries —
9484
+ * open clears the scratch, close assembles and delivers.
9485
+ */
9486
+ schedule: NcScheduleSchema,
9487
+ /** Force-snapshot cadence inside the window, seconds (predecessor parity). */
9488
+ cadenceSec: CadenceSecField.default(15),
9489
+ /** Output frames per second of the assembled mp4 (predecessor parity). */
9490
+ framerate: FramerateField.default(10),
9491
+ /** `notification-output` targets the finished video/thumbnail is sent to. */
9492
+ targets: TargetsField,
9493
+ template: TimelapseTemplateSchema.optional(),
9494
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
9495
+ priority: PriorityField.default(3)
9496
+ });
9497
+ object({
9498
+ name: NameField.optional(),
9499
+ enabled: boolean().optional(),
9500
+ deviceIds: DeviceIdsField.optional(),
9501
+ schedule: NcScheduleSchema.optional(),
9502
+ cadenceSec: CadenceSecField.optional(),
9503
+ framerate: FramerateField.optional(),
9504
+ targets: TargetsField.optional(),
9505
+ template: TimelapseTemplateSchema.nullable().optional(),
9506
+ priority: PriorityField.optional()
9507
+ });
9508
+ TimelapseRuleInputSchema.extend({
9509
+ id: string(),
9510
+ /**
9511
+ * Ownership/visibility key. Absent = admin/global rule (visible to all).
9512
+ * Present = personal rule owned by this userId. Server-stamped from the
9513
+ * resolved caller; never trusted from a client payload.
9514
+ */
9515
+ ownerUserId: string().optional(),
9516
+ /**
9517
+ * Epoch-ms of the last successful generation — the 1-hour re-generation
9518
+ * guard's durable state (predecessor parity). Absent = never generated.
9519
+ */
9520
+ lastGeneratedAt: number().optional(),
9521
+ /** userId of the caller who created the rule (server-stamped). */
9522
+ createdBy: string(),
9523
+ createdAt: number(),
9524
+ updatedAt: number()
9525
+ });
9526
+ /**
8832
9527
  * Generic device-level status snapshot. Auto-registered by `BaseDevice`
8833
9528
  * for every device, regardless of provider — the kernel needs a uniform
8834
9529
  * cap-keyed slice for the basic device flags every consumer expects to
@@ -10902,6 +11597,22 @@ var CameraMetricsSchema = object({
10902
11597
  ])
10903
11598
  });
10904
11599
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
11600
+ /**
11601
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
11602
+ * within the frame, so the executor can re-cut a leaf child ROI at native
11603
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
11604
+ */
11605
+ var NativeCropRefSchema = object({
11606
+ /** Handle keying the retained native surface (node-pinned to its owner). */
11607
+ handle: FrameHandleSchema,
11608
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
11609
+ cropFrameSpace: object({
11610
+ x: number(),
11611
+ y: number(),
11612
+ w: number(),
11613
+ h: number()
11614
+ })
11615
+ });
10905
11616
  var ModelFormatSchema$1 = _enum([
10906
11617
  "onnx",
10907
11618
  "coreml",
@@ -11177,7 +11888,22 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
11177
11888
  * Omitted ⇒ the runner's default device (current single-engine
11178
11889
  * behaviour). Selects WHICH device pool of the node runs the call.
11179
11890
  */
11180
- deviceKey: string().optional()
11891
+ deviceKey: string().optional(),
11892
+ /**
11893
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
11894
+ * when the parent crop was resolved from the frame's retained NATIVE
11895
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
11896
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
11897
+ * resolution from that surface — the SAME quality path faces already
11898
+ * had — instead of the downscaled parent tile. `handle` keys the native
11899
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
11900
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
11901
+ * the executor's crop-normalized child ROI back into frame-normalized
11902
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
11903
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
11904
+ * (today's behaviour on the fallback path).
11905
+ */
11906
+ nativeCropRef: NativeCropRefSchema.optional()
11181
11907
  }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
11182
11908
  engine: PipelineEngineChoiceSchema.optional(),
11183
11909
  steps: array(PipelineStepInputSchema).min(1),
@@ -11393,7 +12119,11 @@ var DetailResultSchema = object({
11393
12119
  bbox: NativeCropBboxSchema.optional(),
11394
12120
  embedding: string().optional(),
11395
12121
  label: string().optional(),
11396
- alignedCropJpeg: string().optional()
12122
+ alignedCropJpeg: string().optional(),
12123
+ /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
12124
+ * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
12125
+ * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
12126
+ nativeFaceShortSidePx: number().optional()
11397
12127
  });
11398
12128
  /**
11399
12129
  * Per-camera tunable ranges + defaults. Single source of truth used
@@ -11407,6 +12137,12 @@ var motionCooldownMsField = {
11407
12137
  default: 3e4,
11408
12138
  step: 500
11409
12139
  };
12140
+ var maxSessionHoldMsField = {
12141
+ min: 0,
12142
+ max: 6e5,
12143
+ default: 12e4,
12144
+ step: 5e3
12145
+ };
11410
12146
  var motionFpsField = {
11411
12147
  min: 1,
11412
12148
  max: 30,
@@ -11554,6 +12290,19 @@ var RunnerCameraConfigSchema = object({
11554
12290
  "on-motion"
11555
12291
  ]).default("always-on"),
11556
12292
  motionCooldownMs: number().min(motionCooldownMsField.min).default(motionCooldownMsField.default),
12293
+ /**
12294
+ * Orchestrator-side on-motion session-hold cap (ms). While an on-motion
12295
+ * detection session is active and ≥1 confirmed non-stationary track is
12296
+ * still live, the orchestrator keeps the session open past
12297
+ * `motionCooldownMs` (a slowly-moving subject can stop re-triggering the
12298
+ * camera's VMD yet is still being tracked frame-to-frame) — up to this many
12299
+ * ms since the session opened, after which it closes regardless. `0`
12300
+ * disables the hold (legacy cooldown-only teardown). Not consumed by the
12301
+ * runner itself — carried here so it shares the per-camera device-settings
12302
+ * surface with `motionCooldownMs`; the orchestrator reads it off the
12303
+ * resolved `CameraDetectionConfig`.
12304
+ */
12305
+ maxSessionHoldMs: number().min(maxSessionHoldMsField.min).max(maxSessionHoldMsField.max).optional(),
11557
12306
  motionFps: number().min(motionFpsField.min).max(motionFpsField.max).default(motionFpsField.default),
11558
12307
  detectionFps: number().min(detectionFpsField.min).max(detectionFpsField.max).default(detectionFpsField.default),
11559
12308
  motionStreamId: string(),
@@ -11643,7 +12392,7 @@ var RunnerCameraConfigSchema = object({
11643
12392
  */
11644
12393
  inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
11645
12394
  });
11646
- 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;
12395
+ 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;
11647
12396
  /**
11648
12397
  * Runtime load summary returned by `getLocalLoad`. Used by the orchestrator's
11649
12398
  * load-balancing levels (L2 capacity-based, L3 hardware-aware) to decide
@@ -11754,84 +12503,23 @@ DeviceType.Light, DeviceType.Siren, DeviceType.Switch, method(object({
11754
12503
  lastChangedAt: number()
11755
12504
  });
11756
12505
  /**
11757
- * Shared geometry vocabulary for on-frame shape caps privacy-mask,
11758
- * motion-zones, and the detection zones/lines editor all speak this one
11759
- * language so a single drawing-plane editor and the providers stay
11760
- * decoupled from each cap's storage.
11761
- *
11762
- * All coordinates are normalized 0..1 of the camera frame (top-left
11763
- * origin). Each cap composes the SUBSET of shape kinds it supports and
11764
- * advertises it via `supportedShapes` in its `getOptions`.
12506
+ * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
12507
+ * on-camera motion-detection mask is a single `grid` region (a row-major
12508
+ * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
12509
+ * a region keeps one drawing-plane model across all geometry caps.
11765
12510
  */
11766
- /** A normalized 0..1 point (top-left origin). */
11767
- var MaskPointSchema = object({
11768
- x: number(),
11769
- y: number()
12511
+ /** A motion-zone region exactly one boolean cell grid today. */
12512
+ var MotionZoneRegionSchema = object({
12513
+ id: number(),
12514
+ enabled: boolean(),
12515
+ shape: MaskGridShapeSchema
11770
12516
  });
11771
- /** Axis-aligned rectangle (normalized 0..1). */
11772
- var MaskRectShapeSchema = object({
11773
- kind: literal("rect"),
11774
- x: number(),
11775
- y: number(),
11776
- width: number(),
11777
- height: number()
11778
- });
11779
- /** Free polygon — an ordered list of normalized vertices (≥3). */
11780
- var MaskPolygonShapeSchema = object({
11781
- kind: literal("polygon"),
11782
- points: array(MaskPointSchema)
11783
- });
11784
- /** Boolean cell grid — row-major, length === gridWidth*gridHeight. */
11785
- var MaskGridShapeSchema = object({
11786
- kind: literal("grid"),
11787
- gridWidth: number(),
11788
- gridHeight: number(),
11789
- cells: array(boolean())
11790
- });
11791
- discriminatedUnion("kind", [
11792
- MaskRectShapeSchema,
11793
- MaskPolygonShapeSchema,
11794
- MaskGridShapeSchema,
11795
- object({
11796
- kind: literal("line"),
11797
- points: array(MaskPointSchema)
11798
- })
11799
- ]);
11800
- /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
11801
- var MaskShapeKindSchema = _enum([
11802
- "rect",
11803
- "polygon",
11804
- "grid",
11805
- "line"
11806
- ]);
11807
- /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
11808
- var MaskPolygonVerticesSchema = object({
11809
- min: number(),
11810
- max: number()
11811
- });
11812
- /** Grid dimensions when a cap supports 'grid'. */
11813
- var MaskGridDimsSchema = object({
11814
- width: number(),
11815
- height: number()
11816
- });
11817
- /**
11818
- * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
11819
- * on-camera motion-detection mask is a single `grid` region (a row-major
11820
- * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
11821
- * a region keeps one drawing-plane model across all geometry caps.
11822
- */
11823
- /** A motion-zone region — exactly one boolean cell grid today. */
11824
- var MotionZoneRegionSchema = object({
11825
- id: number(),
11826
- enabled: boolean(),
11827
- shape: MaskGridShapeSchema
11828
- });
11829
- object({
11830
- enabled: boolean(),
11831
- sensitivity: number(),
11832
- /** Grid region(s). Today exactly one `grid` shape. */
11833
- regions: array(MotionZoneRegionSchema),
11834
- lastFetchedAt: number()
12517
+ object({
12518
+ enabled: boolean(),
12519
+ sensitivity: number(),
12520
+ /** Grid region(s). Today exactly one `grid` shape. */
12521
+ regions: array(MotionZoneRegionSchema),
12522
+ lastFetchedAt: number()
11835
12523
  });
11836
12524
  /** Per-camera availability — grid dims are fixed per camera model; the UI
11837
12525
  * sizes its editor from `grid`. */
@@ -13497,94 +14185,6 @@ var EnrichedWidgetMetadataSchema = WidgetMetadataSchema.extend({
13497
14185
  bundleUrl: string()
13498
14186
  });
13499
14187
  method(_void(), array(EnrichedWidgetMetadataSchema).readonly());
13500
- var NotificationRuleConditionsSchema = object({
13501
- deviceIds: array(number()).readonly().optional(),
13502
- classNames: array(string()).readonly().optional(),
13503
- zoneIds: array(string()).readonly().optional(),
13504
- minConfidence: number().optional(),
13505
- source: _enum([
13506
- "pipeline",
13507
- "onboard",
13508
- "any"
13509
- ]).optional(),
13510
- schedule: object({
13511
- days: array(number()).readonly(),
13512
- startHour: number(),
13513
- endHour: number()
13514
- }).optional(),
13515
- cooldownSeconds: number().optional(),
13516
- minDwellSeconds: number().optional(),
13517
- /** Match against `event.data.eventType` token (e.g. `'press_long'`). When non-empty, only events
13518
- * carrying a matching `data.eventType` string pass this condition. Rules without this field are
13519
- * unaffected (back-compat). Distinct from `rule.eventTypes` which holds EventCategory strings. */
13520
- eventTypeTokens: array(string()).readonly().optional(),
13521
- /** Match detections whose CLIP image embedding is semantically similar to this free-text
13522
- * description. Requires the embedding-encoder cap to have pre-warmed the text vector.
13523
- * `minSimilarity` is the cosine similarity threshold in [0, 1]. */
13524
- clipDescription: object({
13525
- text: string().min(1),
13526
- minSimilarity: number().min(0).max(1)
13527
- }).optional(),
13528
- /** Match events whose recognized-entity label (face identity name or plate
13529
- * vehicle name, propagated onto `event.data.label`) is one of these values.
13530
- * Empty/absent → unaffected (back-compat). Enables "notify me when <named
13531
- * vehicle/person> is seen". */
13532
- labels: array(string()).readonly().optional()
13533
- });
13534
- var NotificationRuleTemplateSchema = object({
13535
- title: string(),
13536
- body: string(),
13537
- imageMode: _enum([
13538
- "crop",
13539
- "annotated",
13540
- "full",
13541
- "none"
13542
- ])
13543
- });
13544
- var NotificationRuleSchema = object({
13545
- id: string(),
13546
- name: string(),
13547
- enabled: boolean(),
13548
- eventTypes: array(string()).readonly(),
13549
- conditions: NotificationRuleConditionsSchema,
13550
- outputs: array(string()).readonly(),
13551
- template: NotificationRuleTemplateSchema.optional(),
13552
- priority: _enum([
13553
- "low",
13554
- "normal",
13555
- "high",
13556
- "critical"
13557
- ])
13558
- });
13559
- var NotificationTestResultSchema = object({
13560
- ruleId: string(),
13561
- eventId: string(),
13562
- timestamp: number(),
13563
- wouldFire: boolean(),
13564
- reason: string().optional()
13565
- });
13566
- var NotificationHistoryEntrySchema = object({
13567
- id: string(),
13568
- ruleId: string(),
13569
- ruleName: string(),
13570
- eventId: string(),
13571
- timestamp: number(),
13572
- outputs: array(string()).readonly(),
13573
- success: boolean(),
13574
- error: string().optional(),
13575
- deviceId: number().optional()
13576
- });
13577
- var NotificationHistoryFilterSchema = object({
13578
- ruleId: string().optional(),
13579
- deviceId: number().optional(),
13580
- from: number().optional(),
13581
- to: number().optional(),
13582
- limit: number().optional()
13583
- });
13584
- 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({
13585
- ruleId: string(),
13586
- lookbackMinutes: number()
13587
- }), object({ results: array(NotificationTestResultSchema).readonly() }), { kind: "mutation" }), method(object({ filter: NotificationHistoryFilterSchema.optional() }), object({ entries: array(NotificationHistoryEntrySchema).readonly() }));
13588
14188
  /**
13589
14189
  * Alerts capability — collection-based internal alert system.
13590
14190
  *
@@ -13808,88 +14408,54 @@ method(object({
13808
14408
  password: string()
13809
14409
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
13810
14410
  /**
13811
- * `login-method` collection cap through which auth addons contribute
13812
- * their pre-auth login surfaces to the login page. This is the SINGLE,
13813
- * generic mechanism that supersedes the dead `auth.listProviders` reader:
13814
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
13815
- * `login-method` provider and the PUBLIC `auth.listLoginMethods`
13816
- * procedure aggregates them for the unauthenticated login page.
13817
- *
13818
- * A contribution is a discriminated union on `kind`:
13819
- *
13820
- * - `redirect` — a declarative button. The login page renders a generic
13821
- * button that navigates to `startUrl` (an addon-owned HTTP route).
13822
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
13823
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
13824
- * login page needs NO change.
13825
- *
13826
- * - `widget` — a Module-Federation widget the login page mounts (via
13827
- * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
13828
- * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
13829
- * mechanism kept for future use; no shipped addon uses it on the login
13830
- * page (the passkey ceremony below runs natively in the shell instead).
13831
- *
13832
- * - `passkey` — a declarative WebAuthn ceremony the shell renders
13833
- * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
13834
- * a remotely-loaded bundle). Carries the addon's effective `rpId` /
13835
- * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
13836
- * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
13837
- * fetching any remote code pre-auth. Contribution stays unconditional —
13838
- * enrollment state is never leaked pre-auth; visibility is a shell
13839
- * decision.
13840
- *
13841
- * Every contribution carries a `stage`:
13842
- * - `primary` — shown on the first credentials screen (OIDC /
13843
- * magic-link buttons; a future usernameless passkey).
13844
- * - `second-factor` — shown AFTER the password leg, gated on the
13845
- * returned `factors` (passkey-as-2FA today).
13846
- *
13847
- * `mount: skip` — the cap is read server-side by the core auth router
13848
- * (`registry.getCollection('login-method')`), never mounted as its own
13849
- * tRPC router.
14411
+ * A live terminal session hosted by the provider addon. Output and input do
14412
+ * NOT flow through the capability they use the addon data plane
14413
+ * (`GET /addon/terminal/<id>/out` SSE, `POST /addon/terminal/<id>/in`) because
14414
+ * terminal output must be ordered and lossless. The event bus is telemetry and
14415
+ * may drop chunks ([D8]), and a dropped chunk desynchronises the vt parser
14416
+ * permanently until a full repaint. The capability owns only lifecycle.
13850
14417
  */
13851
- /** When a login method renders in the two-phase login flow. */
13852
- var LoginStageEnum = _enum(["primary", "second-factor"]);
13853
- /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
13854
- var LoginMethodContributionSchema = discriminatedUnion("kind", [
13855
- object({
13856
- kind: literal("redirect"),
13857
- /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
13858
- id: string(),
13859
- /** Operator-facing button label. */
13860
- label: string(),
13861
- /** lucide-react icon name. */
13862
- icon: string().optional(),
13863
- /** Addon-owned HTTP route the button navigates to (GET). */
13864
- startUrl: string(),
13865
- stage: LoginStageEnum
13866
- }),
13867
- object({
13868
- kind: literal("widget"),
13869
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
13870
- id: string(),
13871
- /** Owning addon id — drives the public bundle URL + the MF namespace. */
13872
- addonId: string(),
13873
- /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
13874
- bundle: string(),
13875
- /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
13876
- remote: WidgetRemoteSchema,
13877
- stage: LoginStageEnum
13878
- }),
13879
- object({
13880
- kind: literal("passkey"),
13881
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
13882
- id: string(),
13883
- /** Operator-facing button label. */
13884
- label: string(),
13885
- stage: LoginStageEnum,
13886
- /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
13887
- rpId: string(),
13888
- /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
13889
- origin: string().nullable()
13890
- })
13891
- ]);
13892
- method(_void(), array(LoginMethodContributionSchema).readonly());
14418
+ var TerminalSessionInfoSchema = object({
14419
+ /** Opaque session id minted by the provider on `openSession`. */
14420
+ sessionId: string(),
14421
+ /** The pre-declared profile this session runs (never a free-form command). */
14422
+ profileId: string(),
14423
+ /** Human-readable profile label for the UI session list. */
14424
+ label: string(),
14425
+ cols: number().int().positive(),
14426
+ rows: number().int().positive(),
14427
+ /** ms-epoch the session's pty was spawned. */
14428
+ startedAt: number()
14429
+ });
14430
+ /**
14431
+ * A profile the operator may open — a pre-declared, allowlisted program
14432
+ * (`monitor` → `btm`). The capability accepts only these ids; a free-form
14433
+ * command string would be remote code execution as the server's user, so it is
14434
+ * deliberately not part of the contract.
14435
+ */
14436
+ var TerminalProfileInfoSchema = object({
14437
+ profileId: string(),
14438
+ label: string(),
14439
+ description: string().optional()
14440
+ });
14441
+ method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(TerminalSessionInfoSchema).readonly(), { auth: "admin" }), method(object({
14442
+ profileId: string(),
14443
+ cols: number().int().positive(),
14444
+ rows: number().int().positive()
14445
+ }), TerminalSessionInfoSchema, {
14446
+ kind: "mutation",
14447
+ auth: "admin"
14448
+ }), method(object({
14449
+ sessionId: string(),
14450
+ cols: number().int().positive(),
14451
+ rows: number().int().positive()
14452
+ }), _void(), {
14453
+ kind: "mutation",
14454
+ auth: "admin"
14455
+ }), method(object({ sessionId: string() }), _void(), {
14456
+ kind: "mutation",
14457
+ auth: "admin"
14458
+ });
13893
14459
  /**
13894
14460
  * Orchestrator-side destination metadata. The orchestrator computes
13895
14461
  * `id = <addonId>:<subId>` from its provider lookup so consumers
@@ -13991,11 +14557,53 @@ var LocationStatSchema = object({
13991
14557
  fileCount: number(),
13992
14558
  present: boolean()
13993
14559
  });
14560
+ /**
14561
+ * A backup schedule — the N:M "entry" that binds one cron cadence to a
14562
+ * SET of destination locations. Supersedes the per-location cron on
14563
+ * `BackupDestinationPolicy`: an operator creates a schedule, picks the
14564
+ * `backups` locations it should write to, and the orchestrator fans a
14565
+ * single archive out to all of them when the cron fires.
14566
+ *
14567
+ * `retentionCount` is per-schedule (D-decision 2026-07-28): every
14568
+ * location targeted by this schedule keeps this many archives from
14569
+ * this schedule's runs.
14570
+ *
14571
+ * `dataSources` optionally narrows which top-level state locations
14572
+ * (db, addons, tls, …) are archived; omitted = the orchestrator's
14573
+ * default full set.
14574
+ */
14575
+ var BackupScheduleSchema = object({
14576
+ /** Stable id. Generated by the orchestrator on first upsert if absent. */
14577
+ id: string(),
14578
+ /** Operator-facing display name. */
14579
+ label: string(),
14580
+ /** 5-field POSIX cron. Empty = disabled cadence (kept for editing). */
14581
+ cron: string(),
14582
+ /** Master on/off toggle for the whole schedule. */
14583
+ enabled: boolean(),
14584
+ /** `backups`-location ids this schedule writes to (fan-out set). */
14585
+ locationIds: array(string()).readonly(),
14586
+ /** Archives kept per targeted location for this schedule. */
14587
+ retentionCount: number().int().min(1).max(1e3),
14588
+ /** Optional subset of source locations to include; omitted = all. */
14589
+ dataSources: array(string()).readonly().optional(),
14590
+ /** ms-epoch of last successful run. */
14591
+ lastRunAt: number().optional(),
14592
+ /** ms-epoch of next computed firing (read-only, filled on list). */
14593
+ nextRunAt: number().optional()
14594
+ });
13994
14595
  method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }), method(object({
13995
14596
  /** Subset of registered `backup-destination` addon ids to write to. */
13996
14597
  destinations: array(string()).optional(),
13997
14598
  locations: array(string()).optional(),
13998
- label: string().optional()
14599
+ label: string().optional(),
14600
+ /**
14601
+ * Per-run retention override applied to every targeted
14602
+ * destination. Used by schedule-driven runs (per-entry
14603
+ * retention). Omitted = each destination's own policy
14604
+ * retention (manual runs).
14605
+ */
14606
+ retentionCount: number().int().min(1).max(1e3).optional()
13999
14607
  }).optional(), array(BackupEntrySchema).readonly(), {
14000
14608
  kind: "mutation",
14001
14609
  auth: "admin"
@@ -14044,7 +14652,21 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
14044
14652
  ok: boolean(),
14045
14653
  error: string().optional(),
14046
14654
  nextRuns: array(number()).readonly()
14047
- }));
14655
+ })), method(_void(), array(BackupScheduleSchema).readonly(), { auth: "admin" }), method(object({
14656
+ id: string().optional(),
14657
+ label: string(),
14658
+ cron: string(),
14659
+ enabled: boolean(),
14660
+ locationIds: array(string()).readonly(),
14661
+ retentionCount: number().int().min(1).max(1e3),
14662
+ dataSources: array(string()).readonly().optional()
14663
+ }), BackupScheduleSchema, {
14664
+ kind: "mutation",
14665
+ auth: "admin"
14666
+ }), method(object({ id: string() }), _void(), {
14667
+ kind: "mutation",
14668
+ auth: "admin"
14669
+ });
14048
14670
  /**
14049
14671
  * `broker` — unified pub/sub broker registry, system-scoped collection.
14050
14672
  *
@@ -15327,851 +15949,934 @@ method(_void(), array(string()).readonly(), { auth: "admin" }), method(object({
15327
15949
  kind: "mutation",
15328
15950
  auth: "admin"
15329
15951
  });
15330
- var LogLevelSchema = _enum([
15331
- "debug",
15332
- "info",
15333
- "warn",
15334
- "error"
15335
- ]);
15336
- var LogEntrySchema = object({
15337
- timestamp: date(),
15338
- level: LogLevelSchema,
15339
- scope: array(string()),
15340
- message: string(),
15341
- meta: record(string(), unknown()).optional(),
15342
- tags: record(string(), string()).optional()
15952
+ /**
15953
+ * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
15954
+ * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15955
+ * caps stay wire-compatible without a circular cap→cap import.
15956
+ *
15957
+ * Errors are a discriminated-union RESULT, never thrown: the shape survives
15958
+ * every transport tier structurally, and failed calls still write usage rows.
15959
+ * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
15960
+ */
15961
+ var LlmUsageSchema = object({
15962
+ inputTokens: number(),
15963
+ outputTokens: number()
15343
15964
  });
15344
- method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
15345
- scope: array(string()).optional(),
15346
- level: LogLevelSchema.optional(),
15347
- since: date().optional(),
15348
- until: date().optional(),
15349
- limit: number().optional(),
15350
- tags: record(string(), string()).optional()
15351
- }), array(LogEntrySchema).readonly());
15352
- var CpuBreakdownSchema = object({
15353
- total: number(),
15354
- user: number(),
15355
- system: number(),
15356
- irq: number(),
15357
- nice: number(),
15358
- loadAvg: tuple([
15359
- number(),
15360
- number(),
15361
- number()
15362
- ]),
15363
- cores: number()
15364
- });
15365
- var MemoryInfoSchema = object({
15366
- percent: number(),
15367
- totalBytes: number(),
15368
- usedBytes: number(),
15369
- availableBytes: number(),
15370
- swapUsedBytes: number(),
15371
- swapTotalBytes: number()
15372
- });
15373
- var DiskIoSnapshotSchema = object({
15374
- readBytes: number(),
15375
- writeBytes: number(),
15376
- readOps: number(),
15377
- writeOps: number(),
15378
- timestampMs: number()
15379
- });
15380
- var NetworkIoSnapshotSchema = object({
15381
- rxBytes: number(),
15382
- txBytes: number(),
15383
- rxPackets: number(),
15384
- txPackets: number(),
15385
- rxErrors: number(),
15386
- txErrors: number(),
15387
- timestampMs: number()
15388
- });
15389
- var MetricsGpuInfoSchema = object({
15390
- utilization: number(),
15965
+ var LlmErrorCodeSchema = _enum([
15966
+ "timeout",
15967
+ "rate-limited",
15968
+ "auth",
15969
+ "refusal",
15970
+ "bad-request",
15971
+ "unavailable",
15972
+ "no-profile",
15973
+ "budget-exceeded",
15974
+ "adapter-error"
15975
+ ]);
15976
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
15977
+ ok: literal(true),
15978
+ text: string(),
15391
15979
  model: string(),
15392
- memoryUsedBytes: number(),
15393
- memoryTotalBytes: number(),
15394
- temperature: number().nullable()
15395
- });
15396
- var ProcessResourceInfoSchema = object({
15397
- openFds: number(),
15398
- threadCount: number(),
15399
- activeHandles: number(),
15400
- activeRequests: number()
15401
- });
15402
- var PressureAvgsSchema = object({
15403
- avg10: number(),
15404
- avg60: number(),
15405
- avg300: number()
15980
+ usage: LlmUsageSchema,
15981
+ truncated: boolean(),
15982
+ latencyMs: number()
15983
+ }), object({
15984
+ ok: literal(false),
15985
+ code: LlmErrorCodeSchema,
15986
+ message: string(),
15987
+ retryAfterMs: number().optional()
15988
+ })]);
15989
+ /**
15990
+ * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
15991
+ * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
15992
+ * notification-output.cap.ts:27-31 precedents).
15993
+ */
15994
+ var LlmImageSchema = object({
15995
+ bytes: _instanceof(Uint8Array),
15996
+ mimeType: string()
15406
15997
  });
15407
- var PressureInfoSchema = object({
15408
- some: PressureAvgsSchema,
15409
- full: PressureAvgsSchema.nullable()
15998
+ var LlmGenerateBaseInputSchema = object({
15999
+ /** Collection routing (the notification-output posture). */
16000
+ addonId: string().optional(),
16001
+ /** Explicit profile; else the resolution chain (spec §3). */
16002
+ profileId: string().optional(),
16003
+ /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
16004
+ consumer: string(),
16005
+ system: string().optional(),
16006
+ /** v1: single-turn. `messages[]` is a v2 additive field. */
16007
+ prompt: string(),
16008
+ /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
16009
+ jsonSchema: record(string(), unknown()).optional(),
16010
+ /** Per-call override of the profile default. */
16011
+ maxTokens: number().int().positive().optional(),
16012
+ temperature: number().optional()
15410
16013
  });
15411
- var SystemResourceSnapshotSchema = object({
15412
- cpu: CpuBreakdownSchema,
15413
- memory: MemoryInfoSchema,
15414
- gpu: MetricsGpuInfoSchema.nullable(),
15415
- network: NetworkIoSnapshotSchema,
15416
- disk: DiskIoSnapshotSchema,
15417
- pressure: object({
15418
- cpu: PressureInfoSchema.nullable(),
15419
- memory: PressureInfoSchema.nullable(),
15420
- io: PressureInfoSchema.nullable()
16014
+ /**
16015
+ * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
16016
+ * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
16017
+ * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
16018
+ * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
16019
+ * this only through the `llm` cap's methods.
16020
+ *
16021
+ * One running llama-server child per node in v1 (models are RAM-heavy).
16022
+ * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
16023
+ * watchdog — operator decision #3).
16024
+ */
16025
+ var ManagedModelRefSchema = discriminatedUnion("kind", [
16026
+ object({
16027
+ kind: literal("catalog"),
16028
+ catalogId: string()
15421
16029
  }),
15422
- process: ProcessResourceInfoSchema,
15423
- cpuTemperature: number().nullable(),
15424
- timestampMs: number()
15425
- });
15426
- var DiskSpaceInfoSchema = object({
15427
- path: string(),
15428
- totalBytes: number(),
15429
- usedBytes: number(),
15430
- availableBytes: number(),
15431
- percent: number()
15432
- });
15433
- var PidResourceStatsSchema = object({
15434
- pid: number(),
15435
- cpu: number(),
15436
- memory: number(),
15437
- /**
15438
- * Private (anonymous) resident bytes — the per-process V8 heap + native
15439
- * allocations NOT shared with other processes (Linux RssAnon). This is the
15440
- * "real" per-runner cost; summing it across runners is meaningful, unlike
15441
- * `memory` (RSS), which double-counts the shared mmap'd framework code.
15442
- * Undefined where /proc is unavailable (e.g. macOS).
15443
- */
15444
- privateBytes: number().optional(),
15445
- /**
15446
- * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
15447
- * code shared copy-on-write across runners. Undefined on macOS.
15448
- */
15449
- sharedBytes: number().optional()
16030
+ object({
16031
+ kind: literal("url"),
16032
+ url: string(),
16033
+ sha256: string().optional()
16034
+ }),
16035
+ object({
16036
+ kind: literal("path"),
16037
+ path: string()
16038
+ })
16039
+ ]);
16040
+ var ManagedRuntimeConfigSchema = object({
16041
+ /** WHERE the runtime lives — hub or any agent. */
16042
+ nodeId: string(),
16043
+ /** Closed for v1; 'ollama' is a v2 candidate. */
16044
+ engine: _enum(["llama-cpp"]),
16045
+ model: ManagedModelRefSchema,
16046
+ contextSize: number().int().default(4096),
16047
+ /** 0 = CPU-only. */
16048
+ gpuLayers: number().int().default(0),
16049
+ /** Default: cpus-2, clamped ≥1 (resolved node-side). */
16050
+ threads: number().int().optional(),
16051
+ /** Concurrent slots. */
16052
+ parallel: number().int().default(1),
16053
+ /** Else lazy: first generate boots it. */
16054
+ autoStart: boolean().default(false),
16055
+ /** 0 = never; frees RAM after quiet periods. */
16056
+ idleStopMinutes: number().int().default(30)
15450
16057
  });
15451
- var AddonInstanceSchema = object({
15452
- addonId: string(),
16058
+ var LlmRuntimeStatusSchema = object({
16059
+ /** Status is ALWAYS node-qualified. */
15453
16060
  nodeId: string(),
15454
- role: _enum(["hub", "worker"]),
15455
- pid: number(),
15456
16061
  state: _enum([
15457
- "starting",
15458
- "running",
15459
- "stopping",
15460
16062
  "stopped",
15461
- "crashed"
15462
- ]),
15463
- uptimeSec: number()
15464
- });
15465
- var NodeProcessSchema = object({
15466
- pid: number(),
15467
- ppid: number(),
15468
- pgid: number(),
15469
- classification: _enum([
15470
- "root",
15471
- "managed",
15472
- "system",
15473
- "ghost"
16063
+ "downloading",
16064
+ "starting",
16065
+ "ready",
16066
+ "crashed",
16067
+ "failed"
15474
16068
  ]),
15475
- /** `$process` addon binding when `managed`, else null. */
15476
- addonId: string().nullable(),
15477
- /** Kernel-reported nodeId when the process is a known agent/worker. */
15478
- nodeId: string().nullable(),
15479
- /** Truncated command line. */
15480
- command: string(),
15481
- cpuPercent: number(),
15482
- memoryRssBytes: number(),
15483
- /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
15484
- uptimeSec: number(),
15485
- /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
15486
- orphaned: boolean()
16069
+ pid: number().optional(),
16070
+ port: number().optional(),
16071
+ modelPath: string().optional(),
16072
+ modelId: string().optional(),
16073
+ downloadProgress: number().min(0).max(1).optional(),
16074
+ lastError: string().optional(),
16075
+ crashesInWindow: number(),
16076
+ /** Child RSS (sampled best-effort). */
16077
+ memoryBytes: number().optional(),
16078
+ vramBytes: number().optional()
15487
16079
  });
15488
- var KillProcessInputSchema = object({
15489
- pid: number(),
15490
- /** Force = SIGKILL. Default is SIGTERM. */
15491
- force: boolean().optional()
16080
+ var LlmNodeModelSchema = object({
16081
+ file: string(),
16082
+ sizeBytes: number(),
16083
+ catalogId: string().optional(),
16084
+ installedAt: number().optional()
15492
16085
  });
15493
- var KillProcessResultSchema = object({
15494
- success: boolean(),
15495
- reason: string().optional(),
15496
- signal: _enum(["SIGTERM", "SIGKILL"]).optional()
16086
+ var LlmRuntimeDiskUsageSchema = object({
16087
+ nodeId: string(),
16088
+ modelsBytes: number(),
16089
+ freeBytes: number().optional()
15497
16090
  });
15498
- var DumpHeapSnapshotInputSchema = object({
15499
- /** The addon whose runner should dump a heap snapshot. */
15500
- addonId: string() });
15501
- var DumpHeapSnapshotResultSchema = object({
15502
- success: boolean(),
15503
- /** Path of the written .heapsnapshot inside the runner's container/host. */
15504
- path: string().optional(),
15505
- /** Process pid that was signalled. */
15506
- pid: number().optional(),
15507
- reason: string().optional()
15508
- });
15509
- var SystemMetricsSchema = object({
15510
- cpuPercent: number(),
15511
- memoryPercent: number(),
15512
- memoryUsedMB: number(),
15513
- memoryTotalMB: number(),
15514
- diskPercent: number().optional(),
15515
- temperature: number().optional(),
15516
- gpuPercent: number().optional(),
15517
- gpuMemoryPercent: number().optional()
15518
- });
15519
- 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, {
16091
+ method(LlmGenerateBaseInputSchema.extend({
16092
+ images: array(LlmImageSchema).optional(),
16093
+ runtime: ManagedRuntimeConfigSchema,
16094
+ /** The managed profile's timeout, threaded by the hub provider. */
16095
+ timeoutMs: number().int().positive().optional()
16096
+ }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
15520
16097
  kind: "mutation",
15521
16098
  auth: "admin"
15522
- }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
16099
+ }), method(object({}), _void(), {
15523
16100
  kind: "mutation",
15524
16101
  auth: "admin"
15525
- });
15526
- method(object({
15527
- sourceUrl: string(),
15528
- metadata: ModelConvertMetadataSchema,
15529
- targets: array(ConvertTargetSchema).min(1).readonly(),
15530
- calibrationRef: string().optional(),
15531
- sessionId: string().optional()
15532
- }), ConvertResultSchema, {
16102
+ }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
15533
16103
  kind: "mutation",
15534
- auth: "admin",
15535
- timeoutMs: 6e5
15536
- });
15537
- method(object({
15538
- nodeId: string(),
15539
- modelId: string(),
15540
- format: _enum(MODEL_FORMATS),
15541
- entry: ModelCatalogEntrySchema
15542
- }), object({
15543
- ok: boolean(),
15544
- /** sha256 of the staged tarball (empty for a hub-local no-op). */
15545
- sha256: string(),
15546
- bytes: number(),
15547
- /** The target node's modelsDir the artifact landed in. */
15548
- path: string()
15549
- }), {
16104
+ auth: "admin"
16105
+ }), method(object({ file: string() }), _void(), {
15550
16106
  kind: "mutation",
15551
16107
  auth: "admin"
15552
- });
15553
- /**
15554
- * `mqtt-broker` — broker-registry cap.
15555
- *
15556
- * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
15557
- * MQTT brokers (external + optionally an embedded `aedes`-backed one)
15558
- * and (b) the connection details a consumer addon needs to spin up
15559
- * its OWN `mqtt.js` client.
15560
- *
15561
- * Why: pub/sub routing over the system event-bus loses fidelity
15562
- * (callback shape, QoS guarantees, will/retain semantics) and adds
15563
- * refcount bookkeeping that addons would rather own themselves. The
15564
- * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
15565
- * features anyway — give it the connection config, get out of the way.
15566
- *
15567
- * Consumer flow:
15568
- * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
15569
- * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
15570
- * client.subscribe('zigbee2mqtt/+')
15571
- *
15572
- * Collection mode: multiple brokers (e.g. one local mosquitto + one
15573
- * cloud bridge). The "embedded" entry (when present) is just another
15574
- * broker in the registry — its lifecycle is owned by the addon that
15575
- * spawned it.
15576
- */
15577
- var BrokerKindSchema = _enum(["external", "embedded"]);
16108
+ }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
15578
16109
  /**
15579
- * Broker live-probe status.
16110
+ * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
16111
+ * methods concat-fan across providers; single-row methods route to ONE
16112
+ * provider by the `addonId` in the call input (the notification-output
16113
+ * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
16114
+ * (hub-placed); the cap stays open for future providers.
15580
16115
  *
15581
- * - `connected` last probe completed a clean CONNACK
15582
- * - `disconnected` — no probe has run yet (cold cache)
15583
- * - `auth-failed` CONNACK refused with auth error (RC 4 / 5)
15584
- * - `unreachable` — TCP connect timed out / refused
15585
- * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
16116
+ * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
16117
+ * `apiKey` is a password field providers REDACT it on read and merge on
16118
+ * write; a stored key NEVER round-trips to a client.
15586
16119
  */
15587
- var BrokerStatusSchema$1 = _enum([
15588
- "connected",
15589
- "disconnected",
15590
- "auth-failed",
15591
- "unreachable",
15592
- "tls-error"
16120
+ var LlmProfileKindSchema = _enum([
16121
+ "openai-compatible",
16122
+ "openai",
16123
+ "anthropic",
16124
+ "google",
16125
+ "managed-local"
15593
16126
  ]);
15594
- var BrokerInfoSchema = object({
16127
+ var LlmProfileSchema = object({
15595
16128
  id: string(),
15596
16129
  name: string(),
15597
- url: string(),
15598
- kind: BrokerKindSchema,
15599
- status: BrokerStatusSchema$1,
15600
- latencyMs: number().nullable(),
15601
- error: string().optional(),
15602
- /** Embedded brokers only: number of MQTT clients currently connected. */
15603
- connectedClients: number().int().nonnegative().optional(),
15604
- /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
15605
- lastCheckedAt: number().optional()
16130
+ kind: LlmProfileKindSchema,
16131
+ /** Stamped by the provider — keeps the fanned catalog routable. */
16132
+ addonId: string(),
16133
+ enabled: boolean(),
16134
+ /** Vendor model id, or the managed runtime's loaded model. */
16135
+ model: string(),
16136
+ /** Required for openai-compatible; override for cloud kinds. */
16137
+ baseUrl: string().optional(),
16138
+ /** ConfigUISchema type:'password' — never round-trips (spec §5). */
16139
+ apiKey: string().optional(),
16140
+ supportsVision: boolean(),
16141
+ temperature: number().min(0).max(2).optional(),
16142
+ maxTokens: number().int().positive().optional(),
16143
+ timeoutMs: number().int().positive().default(6e4),
16144
+ extraHeaders: record(string(), string()).optional(),
16145
+ /** kind === 'managed-local' only (spec §4). */
16146
+ runtime: ManagedRuntimeConfigSchema.optional()
15606
16147
  });
15607
- /**
15608
- * Connection details — what a consumer needs to call
15609
- * `mqtt.connect(url, options)`. We split URL + credentials so the
15610
- * consumer can pass them as `mqtt.connect(url, { username, password })`
15611
- * instead of stuffing creds into the URL (which leaks them into logs).
15612
- */
15613
- var BrokerConnectionDetailsSchema = object({
15614
- url: string(),
15615
- username: string().optional(),
15616
- password: string().optional(),
15617
- /**
15618
- * Suggested prefix for `clientId`. Each consumer should suffix this
15619
- * with its own discriminator (addon id, instance id) so reconnects
15620
- * don't kick each other off (MQTT spec: clientId must be unique per
15621
- * broker).
15622
- */
15623
- clientIdPrefix: string().optional()
16148
+ /** ConfigUISchema tree passed through untyped on the wire (the
16149
+ * notification-output `ConfigSchemaPassthrough` precedent at
16150
+ * notification-output.cap.ts:151); the exported TS type re-tightens it. */
16151
+ var ConfigSchemaPassthrough$1 = unknown();
16152
+ var LlmProfileKindDescriptorSchema = object({
16153
+ kind: LlmProfileKindSchema,
16154
+ label: string(),
16155
+ icon: string(),
16156
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
16157
+ addonId: string(),
16158
+ configSchema: ConfigSchemaPassthrough$1
15624
16159
  });
15625
- var AddBrokerInputSchema = object({
15626
- name: string().min(1),
15627
- url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
15628
- username: string().optional(),
15629
- password: string().optional(),
15630
- clientIdPrefix: string().optional()
16160
+ var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
16161
+ var LlmDefaultSchema = object({
16162
+ selector: LlmDefaultSelectorSchema,
16163
+ profileId: string()
15631
16164
  });
15632
- var AddBrokerResultSchema = object({ id: string() });
15633
- var IdInputSchema = object({ id: string() });
15634
- var TestResultSchema$1 = discriminatedUnion("ok", [object({
15635
- ok: literal(true),
15636
- latencyMs: number()
15637
- }), object({
15638
- ok: literal(false),
15639
- error: string()
15640
- })]);
15641
- var StartEmbeddedInputSchema = object({
15642
- port: number().int().min(1).max(65535).default(1883),
15643
- /** Allow anonymous connect (no username/password). Default: false. */
15644
- allowAnonymous: boolean().default(false),
15645
- /** Optional shared username/password for clients. */
15646
- username: string().optional(),
15647
- password: string().optional()
16165
+ /** Server-side rollup row getUsage never dumps raw call rows (spec §6). */
16166
+ var LlmUsageRollupSchema = object({
16167
+ day: string(),
16168
+ consumer: string(),
16169
+ profileId: string(),
16170
+ calls: number(),
16171
+ okCalls: number(),
16172
+ errorCalls: number(),
16173
+ inputTokens: number(),
16174
+ outputTokens: number(),
16175
+ avgLatencyMs: number()
15648
16176
  });
15649
- var StartEmbeddedResultSchema = object({
16177
+ /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
16178
+ var ManagedModelCatalogEntrySchema = object({
15650
16179
  id: string(),
15651
- url: string()
15652
- });
15653
- var StatusSchema = object({
15654
- brokerCount: number(),
15655
- embeddedRunning: boolean()
15656
- });
15657
- 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);
15658
- var NetworkEndpointSchema = object({
16180
+ label: string(),
16181
+ family: string(),
16182
+ purpose: _enum(["text", "vision"]),
15659
16183
  url: string(),
15660
- hostname: string(),
15661
- port: number(),
15662
- protocol: _enum(["http", "https"])
16184
+ sha256: string(),
16185
+ sizeBytes: number(),
16186
+ quantization: string(),
16187
+ /** Load-time guidance shown in the picker. */
16188
+ minRamBytes: number(),
16189
+ contextSizeDefault: number().int(),
16190
+ /** Vision models: companion projector file. */
16191
+ mmprojUrl: string().optional()
15663
16192
  });
15664
- var NetworkAccessStatusSchema = object({
15665
- connected: boolean(),
15666
- endpoint: NetworkEndpointSchema.nullable(),
16193
+ var LlmRuntimeNodeSchema = object({
16194
+ nodeId: string(),
16195
+ reachable: boolean(),
16196
+ status: LlmRuntimeStatusSchema.optional(),
16197
+ disk: LlmRuntimeDiskUsageSchema.optional(),
15667
16198
  error: string().optional()
15668
16199
  });
15669
- /**
15670
- * Optional, richer endpoint shape returned by providers that expose
15671
- * MORE than one ingress concurrently (Tailscale Ingress with mixed
15672
- * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
15673
- * the originating provider config (mode + sourcePort) so the
15674
- * orchestrator UI can label rows distinctly. Providers that expose only
15675
- * one endpoint just omit `listEndpoints` from their provider impl.
15676
- */
15677
- var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
15678
- /**
15679
- * Stable id within the provider — typically `<mode>-<sourcePort>` so
15680
- * the orchestrator can dedupe across `listEndpoints` polls.
15681
- */
15682
- id: string(),
15683
- /** Operator-facing label (mirrors `MeshEndpoint.label`). */
15684
- label: string(),
15685
- /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
15686
- mode: string().optional(),
15687
- /** Originating local port the ingress fronts (informational). */
15688
- sourcePort: number().optional()
16200
+ var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
16201
+ var ProfileRefInputSchema = object({
16202
+ addonId: string(),
16203
+ profileId: string()
15689
16204
  });
15690
- method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
16205
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
16206
+ kind: "mutation",
16207
+ auth: "admin"
16208
+ }), method(ProfileRefInputSchema, _void(), {
16209
+ kind: "mutation",
16210
+ auth: "admin"
16211
+ }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
16212
+ kind: "mutation",
16213
+ auth: "admin"
16214
+ }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
16215
+ selector: LlmDefaultSelectorSchema,
16216
+ profileId: string().nullable()
16217
+ }), _void(), {
16218
+ kind: "mutation",
16219
+ auth: "admin"
16220
+ }), method(object({
16221
+ since: number().optional(),
16222
+ until: number().optional(),
16223
+ consumer: string().optional(),
16224
+ profileId: string().optional()
16225
+ }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
16226
+ nodeId: string(),
16227
+ model: ManagedModelRefSchema
16228
+ }), _void(), {
16229
+ kind: "mutation",
16230
+ auth: "admin"
16231
+ }), method(object({
16232
+ nodeId: string(),
16233
+ file: string()
16234
+ }), _void(), {
16235
+ kind: "mutation",
16236
+ auth: "admin"
16237
+ }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
16238
+ kind: "mutation",
16239
+ auth: "admin"
16240
+ }), method(ProfileRefInputSchema, _void(), {
16241
+ kind: "mutation",
16242
+ auth: "admin"
16243
+ });
16244
+ var LogLevelSchema = _enum([
16245
+ "debug",
16246
+ "info",
16247
+ "warn",
16248
+ "error"
16249
+ ]);
16250
+ var LogEntrySchema = object({
16251
+ timestamp: date(),
16252
+ level: LogLevelSchema,
16253
+ scope: array(string()),
16254
+ message: string(),
16255
+ meta: record(string(), unknown()).optional(),
16256
+ tags: record(string(), string()).optional()
16257
+ });
16258
+ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16259
+ scope: array(string()).optional(),
16260
+ level: LogLevelSchema.optional(),
16261
+ since: date().optional(),
16262
+ until: date().optional(),
16263
+ limit: number().optional(),
16264
+ tags: record(string(), string()).optional()
16265
+ }), array(LogEntrySchema).readonly());
15691
16266
  /**
15692
- * notification-outputcanonical, capability-gated notification delivery.
16267
+ * `login-method`collection cap through which auth addons contribute
16268
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
16269
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
16270
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
16271
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
16272
+ * procedure aggregates them for the unauthenticated login page.
15693
16273
  *
15694
- * Apprise-derived model (see
15695
- * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
15696
- * callers emit ONE canonical `Notification`; each provider declares a
15697
- * per-kind capability descriptor (`TargetKind`), and the pure degrade
15698
- * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
15699
- * message to what the kind supports — callers never special-case a service.
16274
+ * A contribution is a discriminated union on `kind`:
15700
16275
  *
15701
- * DESIGN DECISIONS (locked):
15702
- * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
15703
- * `setTargetEnabled`), each provider persisting via the `settings-store`
15704
- * cap. Rationale: the admin UI needs one uniform surface across the
15705
- * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
15706
- * alternative would fork the UI per addon and cannot host the
15707
- * discovery→adopt flow.
15708
- * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
15709
- * the generated cap-mount auto-`concatCollection`-fans them across every
15710
- * registered provider (notifiers addon + HA addon) so one catalog is
15711
- * routable. `send` / `testTarget` / CRUD route to ONE provider by the
15712
- * `addonId` the generated collection router extracts from the call input.
15713
- * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
15714
- * transformer) + UDS MsgPack both round-trip typed arrays — already used by
15715
- * `storage` / `storage-provider` / `recording` caps over the same path. No
15716
- * base64 fallback needed.
16276
+ * - `redirect` a declarative button. The login page renders a generic
16277
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
16278
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
16279
+ * ZERO shell-side JS. A future SSO addon plugs in the same way the
16280
+ * login page needs NO change.
15717
16281
  *
15718
- * TODO (deferred, closed-set change separate decision): add
15719
- * `providerKind: 'notify'` so notification providers surface on the unified
15720
- * admin "Integrations" page.
15721
- */
15722
- /**
15723
- * Zentik-derived typed-media enum — the superset across every kind. Each
15724
- * adapter picks what it supports and the degrade engine filters the rest.
15725
- */
15726
- var AttachmentMediaTypeSchema = _enum([
15727
- "image",
15728
- "video",
15729
- "gif",
15730
- "audio",
15731
- "icon"
15732
- ]);
15733
- /**
15734
- * A single attachment. Exactly one of `url` (remote source, most adapters
15735
- * prefer this) or `bytes` (inline source; required for Pushover-style
15736
- * bytes-only kinds) MUST be present the degrade engine expresses a
15737
- * url→bytes fetch as a `needsFetch` directive the adapter executes.
16282
+ * - `widget` a Module-Federation widget the login page mounts (via
16283
+ * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
16284
+ * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
16285
+ * mechanism kept for future use; no shipped addon uses it on the login
16286
+ * page (the passkey ceremony below runs natively in the shell instead).
16287
+ *
16288
+ * - `passkey` a declarative WebAuthn ceremony the shell renders
16289
+ * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
16290
+ * a remotely-loaded bundle). Carries the addon's effective `rpId` /
16291
+ * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
16292
+ * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
16293
+ * fetching any remote code pre-auth. Contribution stays unconditional —
16294
+ * enrollment state is never leaked pre-auth; visibility is a shell
16295
+ * decision.
16296
+ *
16297
+ * Every contribution carries a `stage`:
16298
+ * - `primary` — shown on the first credentials screen (OIDC /
16299
+ * magic-link buttons; a future usernameless passkey).
16300
+ * - `second-factor` — shown AFTER the password leg, gated on the
16301
+ * returned `factors` (passkey-as-2FA today).
16302
+ *
16303
+ * `mount: skip` — the cap is read server-side by the core auth router
16304
+ * (`registry.getCollection('login-method')`), never mounted as its own
16305
+ * tRPC router.
15738
16306
  */
15739
- var AttachmentSchema = object({
15740
- mediaType: AttachmentMediaTypeSchema,
15741
- url: string().optional(),
15742
- bytes: _instanceof(Uint8Array).optional(),
15743
- mime: string().optional(),
15744
- name: string().optional()
15745
- }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
15746
- var NotificationFormatSchema = _enum([
15747
- "text",
15748
- "markdown",
15749
- "html"
16307
+ /** When a login method renders in the two-phase login flow. */
16308
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
16309
+ /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
16310
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [
16311
+ object({
16312
+ kind: literal("redirect"),
16313
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
16314
+ id: string(),
16315
+ /** Operator-facing button label. */
16316
+ label: string(),
16317
+ /** lucide-react icon name. */
16318
+ icon: string().optional(),
16319
+ /** Addon-owned HTTP route the button navigates to (GET). */
16320
+ startUrl: string(),
16321
+ stage: LoginStageEnum
16322
+ }),
16323
+ object({
16324
+ kind: literal("widget"),
16325
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
16326
+ id: string(),
16327
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
16328
+ addonId: string(),
16329
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
16330
+ bundle: string(),
16331
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
16332
+ remote: WidgetRemoteSchema,
16333
+ stage: LoginStageEnum
16334
+ }),
16335
+ object({
16336
+ kind: literal("passkey"),
16337
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
16338
+ id: string(),
16339
+ /** Operator-facing button label. */
16340
+ label: string(),
16341
+ stage: LoginStageEnum,
16342
+ /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
16343
+ rpId: string(),
16344
+ /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
16345
+ origin: string().nullable()
16346
+ })
15750
16347
  ]);
15751
- /** A single tap-through action button. */
15752
- var NotificationActionSchema = object({
15753
- id: string(),
15754
- label: string(),
15755
- url: string().optional()
16348
+ method(_void(), array(LoginMethodContributionSchema).readonly());
16349
+ var CpuBreakdownSchema = object({
16350
+ total: number(),
16351
+ user: number(),
16352
+ system: number(),
16353
+ irq: number(),
16354
+ nice: number(),
16355
+ loadAvg: tuple([
16356
+ number(),
16357
+ number(),
16358
+ number()
16359
+ ]),
16360
+ cores: number()
15756
16361
  });
15757
- /**
15758
- * The canonical notification. `body` is the only hard field (Apprise model).
15759
- * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
15760
- * NOT a fixed severity enum — each kind declares its own `caps.levels` and
15761
- * the adapter maps this ordinal onto its native level. `level?` is an
15762
- * optional kind-native level id (`emergency`, `silent`, …) that overrides
15763
- * `priority` for that one target.
15764
- */
15765
- var NotificationSchema = object({
15766
- body: string(),
15767
- title: string().optional(),
15768
- format: NotificationFormatSchema.default("text"),
15769
- priority: number().int().min(1).max(5).default(3),
15770
- level: string().optional(),
15771
- attachments: array(AttachmentSchema).optional(),
15772
- clickUrl: string().optional(),
15773
- actions: array(NotificationActionSchema).optional(),
15774
- sound: string().optional(),
15775
- ttl: number().optional(),
15776
- tag: string().optional(),
15777
- deviceId: number().optional(),
15778
- eventId: string().optional(),
15779
- metadata: record(string(), unknown()).optional()
16362
+ var MemoryInfoSchema = object({
16363
+ percent: number(),
16364
+ totalBytes: number(),
16365
+ usedBytes: number(),
16366
+ availableBytes: number(),
16367
+ swapUsedBytes: number(),
16368
+ swapTotalBytes: number()
16369
+ });
16370
+ var DiskIoSnapshotSchema = object({
16371
+ readBytes: number(),
16372
+ writeBytes: number(),
16373
+ readOps: number(),
16374
+ writeOps: number(),
16375
+ timestampMs: number()
16376
+ });
16377
+ var NetworkIoSnapshotSchema = object({
16378
+ rxBytes: number(),
16379
+ txBytes: number(),
16380
+ rxPackets: number(),
16381
+ txPackets: number(),
16382
+ rxErrors: number(),
16383
+ txErrors: number(),
16384
+ timestampMs: number()
16385
+ });
16386
+ var MetricsGpuInfoSchema = object({
16387
+ utilization: number(),
16388
+ model: string(),
16389
+ memoryUsedBytes: number(),
16390
+ memoryTotalBytes: number(),
16391
+ temperature: number().nullable()
16392
+ });
16393
+ var ProcessResourceInfoSchema = object({
16394
+ openFds: number(),
16395
+ threadCount: number(),
16396
+ activeHandles: number(),
16397
+ activeRequests: number()
15780
16398
  });
15781
- /** One declared native severity/priority level for a kind. */
15782
- var TargetKindLevelSchema = object({
15783
- id: string(),
15784
- label: string(),
15785
- /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
15786
- ordinal: number().int().min(1).max(5).nullable(),
15787
- flags: object({
15788
- critical: boolean().optional(),
15789
- silent: boolean().optional(),
15790
- noPush: boolean().optional()
15791
- }).optional(),
15792
- /** e.g. Pushover `emergency` requires `retry` / `expire`. */
15793
- requires: array(string()).optional(),
15794
- description: string().optional()
16399
+ var PressureAvgsSchema = object({
16400
+ avg10: number(),
16401
+ avg60: number(),
16402
+ avg300: number()
15795
16403
  });
15796
- /** The full capability block consulted before dispatch. */
15797
- var TargetKindCapsSchema = object({
15798
- attachments: object({
15799
- mediaTypes: array(AttachmentMediaTypeSchema),
15800
- mode: _enum([
15801
- "url",
15802
- "bytes",
15803
- "both"
15804
- ]),
15805
- max: number().int().nonnegative(),
15806
- maxBytes: number().int().positive().optional()
16404
+ var PressureInfoSchema = object({
16405
+ some: PressureAvgsSchema,
16406
+ full: PressureAvgsSchema.nullable()
16407
+ });
16408
+ var SystemResourceSnapshotSchema = object({
16409
+ cpu: CpuBreakdownSchema,
16410
+ memory: MemoryInfoSchema,
16411
+ gpu: MetricsGpuInfoSchema.nullable(),
16412
+ network: NetworkIoSnapshotSchema,
16413
+ disk: DiskIoSnapshotSchema,
16414
+ pressure: object({
16415
+ cpu: PressureInfoSchema.nullable(),
16416
+ memory: PressureInfoSchema.nullable(),
16417
+ io: PressureInfoSchema.nullable()
15807
16418
  }),
15808
- /** Max action buttons (0 = none). */
15809
- actions: number().int().nonnegative(),
15810
- levels: array(TargetKindLevelSchema),
15811
- format: array(NotificationFormatSchema),
15812
- clickUrl: boolean(),
15813
- sound: boolean(),
15814
- ttl: boolean(),
15815
- bodyMaxLen: number().int().positive()
16419
+ process: ProcessResourceInfoSchema,
16420
+ cpuTemperature: number().nullable(),
16421
+ timestampMs: number()
15816
16422
  });
15817
- /**
15818
- * `configSchema` is a `ConfigUISchema` tree passed through to the admin
15819
- * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
15820
- * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`)
15821
- * the union is large and not meant for runtime validation here; the exported
15822
- * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
15823
- */
15824
- var ConfigSchemaPassthrough$1 = unknown();
15825
- var TargetKindSchema = object({
15826
- kind: string(),
15827
- label: string(),
15828
- icon: string(),
15829
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
15830
- addonId: string(),
15831
- configSchema: ConfigSchemaPassthrough$1,
15832
- supportsDiscovery: boolean(),
15833
- caps: TargetKindCapsSchema
16423
+ var DiskSpaceInfoSchema = object({
16424
+ path: string(),
16425
+ totalBytes: number(),
16426
+ usedBytes: number(),
16427
+ availableBytes: number(),
16428
+ percent: number()
15834
16429
  });
15835
- /**
15836
- * A persisted target. `config` holds secrets; providers REDACT secret fields
15837
- * (return a presence marker only) when serving `listTargets` — never
15838
- * round-trip a stored secret to the UI.
15839
- */
15840
- var TargetSchema = object({
15841
- id: string(),
15842
- name: string(),
15843
- kind: string(),
16430
+ var PidResourceStatsSchema = object({
16431
+ pid: number(),
16432
+ cpu: number(),
16433
+ memory: number(),
16434
+ /**
16435
+ * Private (anonymous) resident bytes — the per-process V8 heap + native
16436
+ * allocations NOT shared with other processes (Linux RssAnon). This is the
16437
+ * "real" per-runner cost; summing it across runners is meaningful, unlike
16438
+ * `memory` (RSS), which double-counts the shared mmap'd framework code.
16439
+ * Undefined where /proc is unavailable (e.g. macOS).
16440
+ */
16441
+ privateBytes: number().optional(),
16442
+ /**
16443
+ * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
16444
+ * code shared copy-on-write across runners. Undefined on macOS.
16445
+ */
16446
+ sharedBytes: number().optional()
16447
+ });
16448
+ var AddonInstanceSchema = object({
15844
16449
  addonId: string(),
15845
- enabled: boolean(),
15846
- config: record(string(), unknown())
16450
+ nodeId: string(),
16451
+ role: _enum(["hub", "worker"]),
16452
+ pid: number(),
16453
+ state: _enum([
16454
+ "starting",
16455
+ "running",
16456
+ "stopping",
16457
+ "stopped",
16458
+ "crashed"
16459
+ ]),
16460
+ uptimeSec: number()
15847
16461
  });
15848
- /** A discovery-surfaced candidate (config is partial + non-secret). */
15849
- var DiscoveredTargetSchema = object({
15850
- kind: string(),
15851
- suggestedName: string(),
15852
- config: record(string(), unknown())
16462
+ var NodeProcessSchema = object({
16463
+ pid: number(),
16464
+ ppid: number(),
16465
+ pgid: number(),
16466
+ classification: _enum([
16467
+ "root",
16468
+ "managed",
16469
+ "system",
16470
+ "ghost"
16471
+ ]),
16472
+ /** `$process` addon binding when `managed`, else null. */
16473
+ addonId: string().nullable(),
16474
+ /** Kernel-reported nodeId when the process is a known agent/worker. */
16475
+ nodeId: string().nullable(),
16476
+ /** Truncated command line. */
16477
+ command: string(),
16478
+ cpuPercent: number(),
16479
+ memoryRssBytes: number(),
16480
+ /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
16481
+ uptimeSec: number(),
16482
+ /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
16483
+ orphaned: boolean()
15853
16484
  });
15854
- /** The degrade engine's report — what was resolved / dropped / degraded. */
15855
- var RenderedAsSchema = object({
15856
- level: string(),
15857
- format: NotificationFormatSchema,
15858
- attachmentsSent: number().int().nonnegative(),
15859
- actionsSent: number().int().nonnegative(),
15860
- truncated: boolean(),
15861
- dropped: array(string())
16485
+ var KillProcessInputSchema = object({
16486
+ pid: number(),
16487
+ /** Force = SIGKILL. Default is SIGTERM. */
16488
+ force: boolean().optional()
15862
16489
  });
15863
- var SendResultSchema = object({
16490
+ var KillProcessResultSchema = object({
16491
+ success: boolean(),
16492
+ reason: string().optional(),
16493
+ signal: _enum(["SIGTERM", "SIGKILL"]).optional()
16494
+ });
16495
+ var DumpHeapSnapshotInputSchema = object({
16496
+ /** The addon whose runner should dump a heap snapshot. */
16497
+ addonId: string() });
16498
+ var DumpHeapSnapshotResultSchema = object({
15864
16499
  success: boolean(),
16500
+ /** Path of the written .heapsnapshot inside the runner's container/host. */
16501
+ path: string().optional(),
16502
+ /** Process pid that was signalled. */
16503
+ pid: number().optional(),
16504
+ reason: string().optional()
16505
+ });
16506
+ var SystemMetricsSchema = object({
16507
+ cpuPercent: number(),
16508
+ memoryPercent: number(),
16509
+ memoryUsedMB: number(),
16510
+ memoryTotalMB: number(),
16511
+ diskPercent: number().optional(),
16512
+ temperature: number().optional(),
16513
+ gpuPercent: number().optional(),
16514
+ gpuMemoryPercent: number().optional()
16515
+ });
16516
+ 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, {
16517
+ kind: "mutation",
16518
+ auth: "admin"
16519
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
16520
+ kind: "mutation",
16521
+ auth: "admin"
16522
+ });
16523
+ method(object({
16524
+ sourceUrl: string(),
16525
+ metadata: ModelConvertMetadataSchema,
16526
+ targets: array(ConvertTargetSchema).min(1).readonly(),
16527
+ calibrationRef: string().optional(),
16528
+ sessionId: string().optional()
16529
+ }), ConvertResultSchema, {
16530
+ kind: "mutation",
16531
+ auth: "admin",
16532
+ timeoutMs: 6e5
16533
+ });
16534
+ method(object({
16535
+ nodeId: string(),
16536
+ modelId: string(),
16537
+ format: _enum(MODEL_FORMATS),
16538
+ entry: ModelCatalogEntrySchema
16539
+ }), object({
16540
+ ok: boolean(),
16541
+ /** sha256 of the staged tarball (empty for a hub-local no-op). */
16542
+ sha256: string(),
16543
+ bytes: number(),
16544
+ /** The target node's modelsDir the artifact landed in. */
16545
+ path: string()
16546
+ }), {
16547
+ kind: "mutation",
16548
+ auth: "admin"
16549
+ });
16550
+ /**
16551
+ * `mqtt-broker` — broker-registry cap.
16552
+ *
16553
+ * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
16554
+ * MQTT brokers (external + optionally an embedded `aedes`-backed one)
16555
+ * and (b) the connection details a consumer addon needs to spin up
16556
+ * its OWN `mqtt.js` client.
16557
+ *
16558
+ * Why: pub/sub routing over the system event-bus loses fidelity
16559
+ * (callback shape, QoS guarantees, will/retain semantics) and adds
16560
+ * refcount bookkeeping that addons would rather own themselves. The
16561
+ * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
16562
+ * features anyway — give it the connection config, get out of the way.
16563
+ *
16564
+ * Consumer flow:
16565
+ * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
16566
+ * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
16567
+ * client.subscribe('zigbee2mqtt/+')
16568
+ *
16569
+ * Collection mode: multiple brokers (e.g. one local mosquitto + one
16570
+ * cloud bridge). The "embedded" entry (when present) is just another
16571
+ * broker in the registry — its lifecycle is owned by the addon that
16572
+ * spawned it.
16573
+ */
16574
+ var BrokerKindSchema = _enum(["external", "embedded"]);
16575
+ /**
16576
+ * Broker live-probe status.
16577
+ *
16578
+ * - `connected` — last probe completed a clean CONNACK
16579
+ * - `disconnected` — no probe has run yet (cold cache)
16580
+ * - `auth-failed` — CONNACK refused with auth error (RC 4 / 5)
16581
+ * - `unreachable` — TCP connect timed out / refused
16582
+ * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
16583
+ */
16584
+ var BrokerStatusSchema$1 = _enum([
16585
+ "connected",
16586
+ "disconnected",
16587
+ "auth-failed",
16588
+ "unreachable",
16589
+ "tls-error"
16590
+ ]);
16591
+ var BrokerInfoSchema = object({
16592
+ id: string(),
16593
+ name: string(),
16594
+ url: string(),
16595
+ kind: BrokerKindSchema,
16596
+ status: BrokerStatusSchema$1,
16597
+ latencyMs: number().nullable(),
15865
16598
  error: string().optional(),
15866
- renderedAs: RenderedAsSchema.optional()
16599
+ /** Embedded brokers only: number of MQTT clients currently connected. */
16600
+ connectedClients: number().int().nonnegative().optional(),
16601
+ /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
16602
+ lastCheckedAt: number().optional()
15867
16603
  });
15868
- /** Same shape as SendResult — kept as a distinct name for the test panel. */
15869
- var TestResultSchema = SendResultSchema;
15870
- method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
15871
- kind: string(),
15872
- config: record(string(), unknown()).optional()
15873
- }), array(DiscoveredTargetSchema)), method(object({
15874
- targetId: string(),
15875
- notification: NotificationSchema
15876
- }), SendResultSchema, { kind: "mutation" }), method(object({
15877
- targetId: string(),
15878
- sample: NotificationSchema.optional()
15879
- }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
15880
- targetId: string(),
15881
- enabled: boolean()
15882
- }), _void(), { kind: "mutation" });
15883
16604
  /**
15884
- * Shared LLM generate contracts imported by BOTH `llm.cap.ts` (consumer
15885
- * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15886
- * caps stay wire-compatible without a circular cap→cap import.
15887
- *
15888
- * Errors are a discriminated-union RESULT, never thrown: the shape survives
15889
- * every transport tier structurally, and failed calls still write usage rows.
15890
- * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
16605
+ * Connection details what a consumer needs to call
16606
+ * `mqtt.connect(url, options)`. We split URL + credentials so the
16607
+ * consumer can pass them as `mqtt.connect(url, { username, password })`
16608
+ * instead of stuffing creds into the URL (which leaks them into logs).
15891
16609
  */
15892
- var LlmUsageSchema = object({
15893
- inputTokens: number(),
15894
- outputTokens: number()
16610
+ var BrokerConnectionDetailsSchema = object({
16611
+ url: string(),
16612
+ username: string().optional(),
16613
+ password: string().optional(),
16614
+ /**
16615
+ * Suggested prefix for `clientId`. Each consumer should suffix this
16616
+ * with its own discriminator (addon id, instance id) so reconnects
16617
+ * don't kick each other off (MQTT spec: clientId must be unique per
16618
+ * broker).
16619
+ */
16620
+ clientIdPrefix: string().optional()
15895
16621
  });
15896
- var LlmErrorCodeSchema = _enum([
15897
- "timeout",
15898
- "rate-limited",
15899
- "auth",
15900
- "refusal",
15901
- "bad-request",
15902
- "unavailable",
15903
- "no-profile",
15904
- "budget-exceeded",
15905
- "adapter-error"
15906
- ]);
15907
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
16622
+ var AddBrokerInputSchema = object({
16623
+ name: string().min(1),
16624
+ url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
16625
+ username: string().optional(),
16626
+ password: string().optional(),
16627
+ clientIdPrefix: string().optional()
16628
+ });
16629
+ var AddBrokerResultSchema = object({ id: string() });
16630
+ var IdInputSchema = object({ id: string() });
16631
+ var TestResultSchema$1 = discriminatedUnion("ok", [object({
15908
16632
  ok: literal(true),
15909
- text: string(),
15910
- model: string(),
15911
- usage: LlmUsageSchema,
15912
- truncated: boolean(),
15913
16633
  latencyMs: number()
15914
16634
  }), object({
15915
16635
  ok: literal(false),
15916
- code: LlmErrorCodeSchema,
15917
- message: string(),
15918
- retryAfterMs: number().optional()
16636
+ error: string()
15919
16637
  })]);
15920
- /**
15921
- * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
15922
- * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
15923
- * notification-output.cap.ts:27-31 precedents).
15924
- */
15925
- var LlmImageSchema = object({
15926
- bytes: _instanceof(Uint8Array),
15927
- mimeType: string()
16638
+ var StartEmbeddedInputSchema = object({
16639
+ port: number().int().min(1).max(65535).default(1883),
16640
+ /** Allow anonymous connect (no username/password). Default: false. */
16641
+ allowAnonymous: boolean().default(false),
16642
+ /** Optional shared username/password for clients. */
16643
+ username: string().optional(),
16644
+ password: string().optional()
15928
16645
  });
15929
- var LlmGenerateBaseInputSchema = object({
15930
- /** Collection routing (the notification-output posture). */
15931
- addonId: string().optional(),
15932
- /** Explicit profile; else the resolution chain (spec §3). */
15933
- profileId: string().optional(),
15934
- /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
15935
- consumer: string(),
15936
- system: string().optional(),
15937
- /** v1: single-turn. `messages[]` is a v2 additive field. */
15938
- prompt: string(),
15939
- /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
15940
- jsonSchema: record(string(), unknown()).optional(),
15941
- /** Per-call override of the profile default. */
15942
- maxTokens: number().int().positive().optional(),
15943
- temperature: number().optional()
16646
+ var StartEmbeddedResultSchema = object({
16647
+ id: string(),
16648
+ url: string()
15944
16649
  });
15945
- /**
15946
- * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
15947
- * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
15948
- * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
15949
- * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
15950
- * this only through the `llm` cap's methods.
15951
- *
15952
- * One running llama-server child per node in v1 (models are RAM-heavy).
15953
- * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
15954
- * watchdog — operator decision #3).
15955
- */
15956
- var ManagedModelRefSchema = discriminatedUnion("kind", [
15957
- object({
15958
- kind: literal("catalog"),
15959
- catalogId: string()
15960
- }),
15961
- object({
15962
- kind: literal("url"),
15963
- url: string(),
15964
- sha256: string().optional()
15965
- }),
15966
- object({
15967
- kind: literal("path"),
15968
- path: string()
15969
- })
15970
- ]);
15971
- var ManagedRuntimeConfigSchema = object({
15972
- /** WHERE the runtime lives — hub or any agent. */
15973
- nodeId: string(),
15974
- /** Closed for v1; 'ollama' is a v2 candidate. */
15975
- engine: _enum(["llama-cpp"]),
15976
- model: ManagedModelRefSchema,
15977
- contextSize: number().int().default(4096),
15978
- /** 0 = CPU-only. */
15979
- gpuLayers: number().int().default(0),
15980
- /** Default: cpus-2, clamped ≥1 (resolved node-side). */
15981
- threads: number().int().optional(),
15982
- /** Concurrent slots. */
15983
- parallel: number().int().default(1),
15984
- /** Else lazy: first generate boots it. */
15985
- autoStart: boolean().default(false),
15986
- /** 0 = never; frees RAM after quiet periods. */
15987
- idleStopMinutes: number().int().default(30)
16650
+ var StatusSchema = object({
16651
+ brokerCount: number(),
16652
+ embeddedRunning: boolean()
15988
16653
  });
15989
- var LlmRuntimeStatusSchema = object({
15990
- /** Status is ALWAYS node-qualified. */
15991
- nodeId: string(),
15992
- state: _enum([
15993
- "stopped",
15994
- "downloading",
15995
- "starting",
15996
- "ready",
15997
- "crashed",
15998
- "failed"
15999
- ]),
16000
- pid: number().optional(),
16001
- port: number().optional(),
16002
- modelPath: string().optional(),
16003
- modelId: string().optional(),
16004
- downloadProgress: number().min(0).max(1).optional(),
16005
- lastError: string().optional(),
16006
- crashesInWindow: number(),
16007
- /** Child RSS (sampled best-effort). */
16008
- memoryBytes: number().optional(),
16009
- vramBytes: number().optional()
16654
+ 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);
16655
+ var NetworkEndpointSchema = object({
16656
+ url: string(),
16657
+ hostname: string(),
16658
+ port: number(),
16659
+ protocol: _enum(["http", "https"])
16010
16660
  });
16011
- var LlmNodeModelSchema = object({
16012
- file: string(),
16013
- sizeBytes: number(),
16014
- catalogId: string().optional(),
16015
- installedAt: number().optional()
16661
+ var NetworkAccessStatusSchema = object({
16662
+ connected: boolean(),
16663
+ endpoint: NetworkEndpointSchema.nullable(),
16664
+ error: string().optional()
16016
16665
  });
16017
- var LlmRuntimeDiskUsageSchema = object({
16018
- nodeId: string(),
16019
- modelsBytes: number(),
16020
- freeBytes: number().optional()
16666
+ /**
16667
+ * Optional, richer endpoint shape returned by providers that expose
16668
+ * MORE than one ingress concurrently (Tailscale Ingress with mixed
16669
+ * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
16670
+ * the originating provider config (mode + sourcePort) so the
16671
+ * orchestrator UI can label rows distinctly. Providers that expose only
16672
+ * one endpoint just omit `listEndpoints` from their provider impl.
16673
+ */
16674
+ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
16675
+ /**
16676
+ * Stable id within the provider — typically `<mode>-<sourcePort>` so
16677
+ * the orchestrator can dedupe across `listEndpoints` polls.
16678
+ */
16679
+ id: string(),
16680
+ /** Operator-facing label (mirrors `MeshEndpoint.label`). */
16681
+ label: string(),
16682
+ /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
16683
+ mode: string().optional(),
16684
+ /** Originating local port the ingress fronts (informational). */
16685
+ sourcePort: number().optional()
16021
16686
  });
16022
- method(LlmGenerateBaseInputSchema.extend({
16023
- images: array(LlmImageSchema).optional(),
16024
- runtime: ManagedRuntimeConfigSchema,
16025
- /** The managed profile's timeout, threaded by the hub provider. */
16026
- timeoutMs: number().int().positive().optional()
16027
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
16028
- kind: "mutation",
16029
- auth: "admin"
16030
- }), method(object({}), _void(), {
16031
- kind: "mutation",
16032
- auth: "admin"
16033
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
16034
- kind: "mutation",
16035
- auth: "admin"
16036
- }), method(object({ file: string() }), _void(), {
16037
- kind: "mutation",
16038
- auth: "admin"
16039
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
16687
+ method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
16040
16688
  /**
16041
- * `llm`consumer-facing LLM surface (spec §1-§3). Collection-mode: array
16042
- * methods concat-fan across providers; single-row methods route to ONE
16043
- * provider by the `addonId` in the call input (the notification-output
16044
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
16045
- * (hub-placed); the cap stays open for future providers.
16689
+ * notification-outputcanonical, capability-gated notification delivery.
16690
+ *
16691
+ * Apprise-derived model (see
16692
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
16693
+ * callers emit ONE canonical `Notification`; each provider declares a
16694
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
16695
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
16696
+ * message to what the kind supports — callers never special-case a service.
16697
+ *
16698
+ * DESIGN DECISIONS (locked):
16699
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
16700
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
16701
+ * cap. Rationale: the admin UI needs one uniform surface across the
16702
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
16703
+ * alternative would fork the UI per addon and cannot host the
16704
+ * discovery→adopt flow.
16705
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
16706
+ * the generated cap-mount auto-`concatCollection`-fans them across every
16707
+ * registered provider (notifiers addon + HA addon) so one catalog is
16708
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
16709
+ * `addonId` the generated collection router extracts from the call input.
16710
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
16711
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
16712
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
16713
+ * base64 fallback needed.
16046
16714
  *
16047
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
16048
- * `apiKey` is a password field — providers REDACT it on read and merge on
16049
- * write; a stored key NEVER round-trips to a client.
16715
+ * TODO (deferred, closed-set change separate decision): add
16716
+ * `providerKind: 'notify'` so notification providers surface on the unified
16717
+ * admin "Integrations" page.
16050
16718
  */
16051
- var LlmProfileKindSchema = _enum([
16052
- "openai-compatible",
16053
- "openai",
16054
- "anthropic",
16055
- "google",
16056
- "managed-local"
16719
+ /**
16720
+ * Zentik-derived typed-media enum — the superset across every kind. Each
16721
+ * adapter picks what it supports and the degrade engine filters the rest.
16722
+ */
16723
+ var AttachmentMediaTypeSchema = _enum([
16724
+ "image",
16725
+ "video",
16726
+ "gif",
16727
+ "audio",
16728
+ "icon"
16057
16729
  ]);
16058
- var LlmProfileSchema = object({
16730
+ /**
16731
+ * A single attachment. Exactly one of `url` (remote source, most adapters
16732
+ * prefer this) or `bytes` (inline source; required for Pushover-style
16733
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
16734
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
16735
+ */
16736
+ var AttachmentSchema = object({
16737
+ mediaType: AttachmentMediaTypeSchema,
16738
+ url: string().optional(),
16739
+ bytes: _instanceof(Uint8Array).optional(),
16740
+ mime: string().optional(),
16741
+ name: string().optional()
16742
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
16743
+ var NotificationFormatSchema = _enum([
16744
+ "text",
16745
+ "markdown",
16746
+ "html"
16747
+ ]);
16748
+ /** A single tap-through action button. */
16749
+ var NotificationActionSchema = object({
16059
16750
  id: string(),
16060
- name: string(),
16061
- kind: LlmProfileKindSchema,
16062
- /** Stamped by the provider — keeps the fanned catalog routable. */
16063
- addonId: string(),
16064
- enabled: boolean(),
16065
- /** Vendor model id, or the managed runtime's loaded model. */
16066
- model: string(),
16067
- /** Required for openai-compatible; override for cloud kinds. */
16068
- baseUrl: string().optional(),
16069
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
16070
- apiKey: string().optional(),
16071
- supportsVision: boolean(),
16072
- temperature: number().min(0).max(2).optional(),
16073
- maxTokens: number().int().positive().optional(),
16074
- timeoutMs: number().int().positive().default(6e4),
16075
- extraHeaders: record(string(), string()).optional(),
16076
- /** kind === 'managed-local' only (spec §4). */
16077
- runtime: ManagedRuntimeConfigSchema.optional()
16751
+ label: string(),
16752
+ url: string().optional()
16078
16753
  });
16079
- /** ConfigUISchema tree passed through untyped on the wire (the
16080
- * notification-output `ConfigSchemaPassthrough` precedent at
16081
- * notification-output.cap.ts:151); the exported TS type re-tightens it. */
16754
+ /**
16755
+ * The canonical notification. `body` is the only hard field (Apprise model).
16756
+ * `priority` is a 5-level ORDINAL (1=lowest 3=normal(default) 5=urgent),
16757
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
16758
+ * the adapter maps this ordinal onto its native level. `level?` is an
16759
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
16760
+ * `priority` for that one target.
16761
+ */
16762
+ var NotificationSchema = object({
16763
+ body: string(),
16764
+ title: string().optional(),
16765
+ format: NotificationFormatSchema.default("text"),
16766
+ priority: number().int().min(1).max(5).default(3),
16767
+ level: string().optional(),
16768
+ attachments: array(AttachmentSchema).optional(),
16769
+ clickUrl: string().optional(),
16770
+ actions: array(NotificationActionSchema).optional(),
16771
+ sound: string().optional(),
16772
+ ttl: number().optional(),
16773
+ tag: string().optional(),
16774
+ deviceId: number().optional(),
16775
+ eventId: string().optional(),
16776
+ metadata: record(string(), unknown()).optional()
16777
+ });
16778
+ /** One declared native severity/priority level for a kind. */
16779
+ var TargetKindLevelSchema = object({
16780
+ id: string(),
16781
+ label: string(),
16782
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
16783
+ ordinal: number().int().min(1).max(5).nullable(),
16784
+ flags: object({
16785
+ critical: boolean().optional(),
16786
+ silent: boolean().optional(),
16787
+ noPush: boolean().optional()
16788
+ }).optional(),
16789
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
16790
+ requires: array(string()).optional(),
16791
+ description: string().optional()
16792
+ });
16793
+ /** The full capability block consulted before dispatch. */
16794
+ var TargetKindCapsSchema = object({
16795
+ attachments: object({
16796
+ mediaTypes: array(AttachmentMediaTypeSchema),
16797
+ mode: _enum([
16798
+ "url",
16799
+ "bytes",
16800
+ "both"
16801
+ ]),
16802
+ max: number().int().nonnegative(),
16803
+ maxBytes: number().int().positive().optional()
16804
+ }),
16805
+ /** Max action buttons (0 = none). */
16806
+ actions: number().int().nonnegative(),
16807
+ levels: array(TargetKindLevelSchema),
16808
+ format: array(NotificationFormatSchema),
16809
+ clickUrl: boolean(),
16810
+ sound: boolean(),
16811
+ ttl: boolean(),
16812
+ bodyMaxLen: number().int().positive()
16813
+ });
16814
+ /**
16815
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
16816
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
16817
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
16818
+ * the union is large and not meant for runtime validation here; the exported
16819
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
16820
+ */
16082
16821
  var ConfigSchemaPassthrough = unknown();
16083
- var LlmProfileKindDescriptorSchema = object({
16084
- kind: LlmProfileKindSchema,
16822
+ var TargetKindSchema = object({
16823
+ kind: string(),
16085
16824
  label: string(),
16086
16825
  icon: string(),
16087
16826
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
16088
16827
  addonId: string(),
16089
- configSchema: ConfigSchemaPassthrough
16090
- });
16091
- var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
16092
- var LlmDefaultSchema = object({
16093
- selector: LlmDefaultSelectorSchema,
16094
- profileId: string()
16095
- });
16096
- /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
16097
- var LlmUsageRollupSchema = object({
16098
- day: string(),
16099
- consumer: string(),
16100
- profileId: string(),
16101
- calls: number(),
16102
- okCalls: number(),
16103
- errorCalls: number(),
16104
- inputTokens: number(),
16105
- outputTokens: number(),
16106
- avgLatencyMs: number()
16828
+ configSchema: ConfigSchemaPassthrough,
16829
+ supportsDiscovery: boolean(),
16830
+ caps: TargetKindCapsSchema
16107
16831
  });
16108
- /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
16109
- var ManagedModelCatalogEntrySchema = object({
16832
+ /**
16833
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
16834
+ * (return a presence marker only) when serving `listTargets` — never
16835
+ * round-trip a stored secret to the UI.
16836
+ */
16837
+ var TargetSchema = object({
16110
16838
  id: string(),
16111
- label: string(),
16112
- family: string(),
16113
- purpose: _enum(["text", "vision"]),
16114
- url: string(),
16115
- sha256: string(),
16116
- sizeBytes: number(),
16117
- quantization: string(),
16118
- /** Load-time guidance shown in the picker. */
16119
- minRamBytes: number(),
16120
- contextSizeDefault: number().int(),
16121
- /** Vision models: companion projector file. */
16122
- mmprojUrl: string().optional()
16123
- });
16124
- var LlmRuntimeNodeSchema = object({
16125
- nodeId: string(),
16126
- reachable: boolean(),
16127
- status: LlmRuntimeStatusSchema.optional(),
16128
- disk: LlmRuntimeDiskUsageSchema.optional(),
16129
- error: string().optional()
16130
- });
16131
- var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
16132
- var ProfileRefInputSchema = object({
16839
+ name: string(),
16840
+ kind: string(),
16133
16841
  addonId: string(),
16134
- profileId: string()
16842
+ enabled: boolean(),
16843
+ config: record(string(), unknown())
16135
16844
  });
16136
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
16137
- kind: "mutation",
16138
- auth: "admin"
16139
- }), method(ProfileRefInputSchema, _void(), {
16140
- kind: "mutation",
16141
- auth: "admin"
16142
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
16143
- kind: "mutation",
16144
- auth: "admin"
16145
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
16146
- selector: LlmDefaultSelectorSchema,
16147
- profileId: string().nullable()
16148
- }), _void(), {
16149
- kind: "mutation",
16150
- auth: "admin"
16151
- }), method(object({
16152
- since: number().optional(),
16153
- until: number().optional(),
16154
- consumer: string().optional(),
16155
- profileId: string().optional()
16156
- }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
16157
- nodeId: string(),
16158
- model: ManagedModelRefSchema
16159
- }), _void(), {
16160
- kind: "mutation",
16161
- auth: "admin"
16162
- }), method(object({
16163
- nodeId: string(),
16164
- file: string()
16165
- }), _void(), {
16166
- kind: "mutation",
16167
- auth: "admin"
16168
- }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
16169
- kind: "mutation",
16170
- auth: "admin"
16171
- }), method(ProfileRefInputSchema, _void(), {
16172
- kind: "mutation",
16173
- auth: "admin"
16845
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
16846
+ var DiscoveredTargetSchema = object({
16847
+ kind: string(),
16848
+ suggestedName: string(),
16849
+ config: record(string(), unknown())
16850
+ });
16851
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
16852
+ var RenderedAsSchema = object({
16853
+ level: string(),
16854
+ format: NotificationFormatSchema,
16855
+ attachmentsSent: number().int().nonnegative(),
16856
+ actionsSent: number().int().nonnegative(),
16857
+ truncated: boolean(),
16858
+ dropped: array(string())
16859
+ });
16860
+ var SendResultSchema = object({
16861
+ success: boolean(),
16862
+ error: string().optional(),
16863
+ renderedAs: RenderedAsSchema.optional()
16174
16864
  });
16865
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
16866
+ var TestResultSchema = SendResultSchema;
16867
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
16868
+ kind: string(),
16869
+ config: record(string(), unknown()).optional()
16870
+ }), array(DiscoveredTargetSchema)), method(object({
16871
+ targetId: string(),
16872
+ notification: NotificationSchema
16873
+ }), SendResultSchema, { kind: "mutation" }), method(object({
16874
+ targetId: string(),
16875
+ sample: NotificationSchema.optional()
16876
+ }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
16877
+ targetId: string(),
16878
+ enabled: boolean()
16879
+ }), _void(), { kind: "mutation" });
16175
16880
  /**
16176
16881
  * Zod schemas for persisted record types.
16177
16882
  *
@@ -16857,7 +17562,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
16857
17562
  }), method(object({
16858
17563
  eventId: string(),
16859
17564
  kind: MediaFileKindEnum.optional()
16860
- }), array(MediaFileSchema).readonly()), method(object({ trackId: string() }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
17565
+ }), array(MediaFileSchema).readonly()), method(object({
17566
+ trackId: string(),
17567
+ kinds: array(MediaFileKindEnum).optional()
17568
+ }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
16861
17569
  deviceId: number(),
16862
17570
  timestamp: number(),
16863
17571
  frameWidth: number(),
@@ -16878,76 +17586,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
16878
17586
  eventId: string(),
16879
17587
  timestamp: number()
16880
17588
  });
16881
- /**
16882
- * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
16883
- * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
16884
- * caps into per-camera event-kind descriptors.
16885
- *
16886
- * The descriptor DATA (color / iconId / labelKey / parentKind / category)
16887
- * is NOT duplicated here — every entry is derived from the single
16888
- * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
16889
- * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
16890
- * control cap means adding one line here (and a taxonomy entry); the anti-
16891
- * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
16892
- * eventful cap is missing.
16893
- */
16894
- /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
16895
- var LEGACY_ICON = {
16896
- motion: "motion",
16897
- audio: "audio",
16898
- person: "person",
16899
- vehicle: "vehicle",
16900
- animal: "animal",
16901
- package: "package",
16902
- door: "door",
16903
- pir: "pir",
16904
- smoke: "smoke",
16905
- water: "water",
16906
- button: "button",
16907
- generic: "generic",
16908
- gas: "smoke",
16909
- vibration: "generic",
16910
- tamper: "generic",
16911
- presence: "person",
16912
- lock: "generic",
16913
- siren: "generic",
16914
- switch: "generic",
16915
- doorbell: "button"
16916
- };
16917
- function legacyIcon(iconId) {
16918
- return LEGACY_ICON[iconId] ?? "generic";
16919
- }
16920
- /**
16921
- * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
16922
- * The anti-drift guard cross-checks this against the eventful caps declared
16923
- * in `packages/types/src/capabilities/*.cap.ts`.
16924
- */
16925
- var CAP_TO_KIND = {
16926
- contact: "contact",
16927
- motion: "motion-sensor",
16928
- smoke: "smoke",
16929
- flood: "flood",
16930
- gas: "gas",
16931
- "carbon-monoxide": "carbon-monoxide",
16932
- vibration: "vibration",
16933
- tamper: "tamper",
16934
- presence: "presence",
16935
- "enum-sensor": "enum-sensor",
16936
- "event-emitter": "device-event",
16937
- "lock-control": "lock",
16938
- switch: "switch",
16939
- button: "button",
16940
- doorbell: "doorbell"
16941
- };
16942
- function buildDescriptor(capName, kind) {
16943
- const t = EVENT_TAXONOMY[kind];
16944
- if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
16945
- return {
16946
- ...t,
16947
- icon: legacyIcon(t.iconId)
16948
- };
16949
- }
16950
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
16951
17589
  var CameraPipelineConfigSchema = object({
16952
17590
  engine: PipelineEngineChoiceSchema.optional(),
16953
17591
  steps: array(PipelineStepInputSchema).readonly(),
@@ -17433,6 +18071,76 @@ method(object({
17433
18071
  auth: "admin"
17434
18072
  });
17435
18073
  /**
18074
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
18075
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
18076
+ * caps into per-camera event-kind descriptors.
18077
+ *
18078
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
18079
+ * is NOT duplicated here — every entry is derived from the single
18080
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
18081
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
18082
+ * control cap means adding one line here (and a taxonomy entry); the anti-
18083
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
18084
+ * eventful cap is missing.
18085
+ */
18086
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
18087
+ var LEGACY_ICON = {
18088
+ motion: "motion",
18089
+ audio: "audio",
18090
+ person: "person",
18091
+ vehicle: "vehicle",
18092
+ animal: "animal",
18093
+ package: "package",
18094
+ door: "door",
18095
+ pir: "pir",
18096
+ smoke: "smoke",
18097
+ water: "water",
18098
+ button: "button",
18099
+ generic: "generic",
18100
+ gas: "smoke",
18101
+ vibration: "generic",
18102
+ tamper: "generic",
18103
+ presence: "person",
18104
+ lock: "generic",
18105
+ siren: "generic",
18106
+ switch: "generic",
18107
+ doorbell: "button"
18108
+ };
18109
+ function legacyIcon(iconId) {
18110
+ return LEGACY_ICON[iconId] ?? "generic";
18111
+ }
18112
+ /**
18113
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
18114
+ * The anti-drift guard cross-checks this against the eventful caps declared
18115
+ * in `packages/types/src/capabilities/*.cap.ts`.
18116
+ */
18117
+ var CAP_TO_KIND = {
18118
+ contact: "contact",
18119
+ motion: "motion-sensor",
18120
+ smoke: "smoke",
18121
+ flood: "flood",
18122
+ gas: "gas",
18123
+ "carbon-monoxide": "carbon-monoxide",
18124
+ vibration: "vibration",
18125
+ tamper: "tamper",
18126
+ presence: "presence",
18127
+ "enum-sensor": "enum-sensor",
18128
+ "event-emitter": "device-event",
18129
+ "lock-control": "lock",
18130
+ switch: "switch",
18131
+ button: "button",
18132
+ doorbell: "doorbell"
18133
+ };
18134
+ function buildDescriptor(capName, kind) {
18135
+ const t = EVENT_TAXONOMY[kind];
18136
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
18137
+ return {
18138
+ ...t,
18139
+ icon: legacyIcon(t.iconId)
18140
+ };
18141
+ }
18142
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
18143
+ /**
17436
18144
  * server-management — per-NODE singleton capability for a node's ROOT
17437
18145
  * package lifecycle (runtime-updatable node packages).
17438
18146
  *
@@ -18887,7 +19595,28 @@ var FaceInfoSchema = object({
18887
19595
  * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`). Absent when the
18888
19596
  * track produced no key frame (e.g. native/onboard source) — the UI falls
18889
19597
  * back to the inline `base64` face crop. */
18890
- keyFrameMediaKey: string().optional()
19598
+ keyFrameMediaKey: string().optional(),
19599
+ /** Winning identity-match cosine (0..1) for this face's track, when an
19600
+ * identity was auto-confirmed. Lets the UI surface WHY a face was assigned
19601
+ * (confidence badge / low-confidence audit). Absent on legacy rows and on
19602
+ * faces that were never auto-recognized. */
19603
+ bestMatchScore: number().optional(),
19604
+ /** Native-scale face short side (px) at recognition time, when the runner
19605
+ * measured it. Lets the UI flag low-resolution auto-assignments. Absent on
19606
+ * legacy rows / runners that reported no native measure. */
19607
+ nativeFaceShortSidePx: number().optional(),
19608
+ /** SUGGESTED identity for this face — a plausible-but-not-confident match that
19609
+ * MISSED auto-assignment (cosine in the suggestion band, or above threshold
19610
+ * but blocked only by the recognition size floor). Mutually exclusive with
19611
+ * `recognizedIdentityId` (a suggestion is NEVER an assignment): the face stays
19612
+ * UNASSIGNED and everything else keeps treating it as unrecognized — the UI
19613
+ * merely offers a one-tap "is this <name>?" confirm. Absent on legacy rows and
19614
+ * on faces that were auto-assigned or below the suggestion band. (2026-07-24) */
19615
+ suggestedIdentityId: string().optional(),
19616
+ /** Peak identity-match cosine (0..1) for `suggestedIdentityId`, captured at the
19617
+ * same moment as `bestMatchScore` (track peak, at close). Lets the UI rank /
19618
+ * badge suggestion confidence. Present iff `suggestedIdentityId` is. (2026-07-24) */
19619
+ suggestedMatchScore: number().optional()
18891
19620
  });
18892
19621
  var FaceFilterEnum = _enum([
18893
19622
  "unassigned",
@@ -20930,36 +21659,6 @@ Object.freeze({
20930
21659
  addonId: null,
20931
21660
  access: "view"
20932
21661
  },
20933
- "advancedNotifier.deleteRule": {
20934
- capName: "advanced-notifier",
20935
- capScope: "system",
20936
- addonId: null,
20937
- access: "delete"
20938
- },
20939
- "advancedNotifier.getHistory": {
20940
- capName: "advanced-notifier",
20941
- capScope: "system",
20942
- addonId: null,
20943
- access: "view"
20944
- },
20945
- "advancedNotifier.getRules": {
20946
- capName: "advanced-notifier",
20947
- capScope: "system",
20948
- addonId: null,
20949
- access: "view"
20950
- },
20951
- "advancedNotifier.testRule": {
20952
- capName: "advanced-notifier",
20953
- capScope: "system",
20954
- addonId: null,
20955
- access: "create"
20956
- },
20957
- "advancedNotifier.upsertRule": {
20958
- capName: "advanced-notifier",
20959
- capScope: "system",
20960
- addonId: null,
20961
- access: "create"
20962
- },
20963
21662
  "alarmPanel.arm": {
20964
21663
  capName: "alarm-panel",
20965
21664
  capScope: "device",
@@ -21182,6 +21881,12 @@ Object.freeze({
21182
21881
  addonId: null,
21183
21882
  access: "delete"
21184
21883
  },
21884
+ "backup.deleteSchedule": {
21885
+ capName: "backup",
21886
+ capScope: "system",
21887
+ addonId: null,
21888
+ access: "delete"
21889
+ },
21185
21890
  "backup.getEntries": {
21186
21891
  capName: "backup",
21187
21892
  capScope: "system",
@@ -21212,6 +21917,12 @@ Object.freeze({
21212
21917
  addonId: null,
21213
21918
  access: "view"
21214
21919
  },
21920
+ "backup.listSchedules": {
21921
+ capName: "backup",
21922
+ capScope: "system",
21923
+ addonId: null,
21924
+ access: "view"
21925
+ },
21215
21926
  "backup.previewSchedule": {
21216
21927
  capName: "backup",
21217
21928
  capScope: "system",
@@ -21236,6 +21947,12 @@ Object.freeze({
21236
21947
  addonId: null,
21237
21948
  access: "create"
21238
21949
  },
21950
+ "backup.upsertSchedule": {
21951
+ capName: "backup",
21952
+ capScope: "system",
21953
+ addonId: null,
21954
+ access: "create"
21955
+ },
21239
21956
  "battery.wakeForStream": {
21240
21957
  capName: "battery",
21241
21958
  capScope: "device",
@@ -23264,6 +23981,60 @@ Object.freeze({
23264
23981
  addonId: null,
23265
23982
  access: "create"
23266
23983
  },
23984
+ "notificationRules.createRule": {
23985
+ capName: "notification-rules",
23986
+ capScope: "system",
23987
+ addonId: null,
23988
+ access: "create"
23989
+ },
23990
+ "notificationRules.deleteRule": {
23991
+ capName: "notification-rules",
23992
+ capScope: "system",
23993
+ addonId: null,
23994
+ access: "delete"
23995
+ },
23996
+ "notificationRules.getConditionCatalog": {
23997
+ capName: "notification-rules",
23998
+ capScope: "system",
23999
+ addonId: null,
24000
+ access: "view"
24001
+ },
24002
+ "notificationRules.getHistory": {
24003
+ capName: "notification-rules",
24004
+ capScope: "system",
24005
+ addonId: null,
24006
+ access: "view"
24007
+ },
24008
+ "notificationRules.getRule": {
24009
+ capName: "notification-rules",
24010
+ capScope: "system",
24011
+ addonId: null,
24012
+ access: "view"
24013
+ },
24014
+ "notificationRules.listRules": {
24015
+ capName: "notification-rules",
24016
+ capScope: "system",
24017
+ addonId: null,
24018
+ access: "view"
24019
+ },
24020
+ "notificationRules.setRuleEnabled": {
24021
+ capName: "notification-rules",
24022
+ capScope: "system",
24023
+ addonId: null,
24024
+ access: "create"
24025
+ },
24026
+ "notificationRules.testRule": {
24027
+ capName: "notification-rules",
24028
+ capScope: "system",
24029
+ addonId: null,
24030
+ access: "create"
24031
+ },
24032
+ "notificationRules.updateRule": {
24033
+ capName: "notification-rules",
24034
+ capScope: "system",
24035
+ addonId: null,
24036
+ access: "create"
24037
+ },
23267
24038
  "notifier.cancel": {
23268
24039
  capName: "notifier",
23269
24040
  capScope: "device",
@@ -25016,6 +25787,36 @@ Object.freeze({
25016
25787
  addonId: null,
25017
25788
  access: "create"
25018
25789
  },
25790
+ "terminalSession.close": {
25791
+ capName: "terminal-session",
25792
+ capScope: "system",
25793
+ addonId: null,
25794
+ access: "create"
25795
+ },
25796
+ "terminalSession.listProfiles": {
25797
+ capName: "terminal-session",
25798
+ capScope: "system",
25799
+ addonId: null,
25800
+ access: "view"
25801
+ },
25802
+ "terminalSession.listSessions": {
25803
+ capName: "terminal-session",
25804
+ capScope: "system",
25805
+ addonId: null,
25806
+ access: "view"
25807
+ },
25808
+ "terminalSession.openSession": {
25809
+ capName: "terminal-session",
25810
+ capScope: "system",
25811
+ addonId: null,
25812
+ access: "create"
25813
+ },
25814
+ "terminalSession.resize": {
25815
+ capName: "terminal-session",
25816
+ capScope: "system",
25817
+ addonId: null,
25818
+ access: "create"
25819
+ },
25019
25820
  "toast.onToast": {
25020
25821
  capName: "toast",
25021
25822
  capScope: "system",