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