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