@camstack/addon-agent-ui 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 (2) hide show
  1. package/dist/addon.js +1908 -1107
  2. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import path from "node:path";
2
2
  import { fileURLToPath } from "node:url";
3
- //#region ../types/dist/event-category-D4HJq7Mw.mjs
3
+ //#region ../types/dist/event-category-BLcNejAE.mjs
4
4
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
5
5
  EventCategory["SystemBoot"] = "system.boot";
6
6
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -150,9 +150,6 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
150
150
  EventCategory["RecordingSegmentWritten"] = "recording.segment.written";
151
151
  EventCategory["RecordingPolicyFallback"] = "recording.policy.fallback";
152
152
  EventCategory["RecordingRetentionCompleted"] = "recording.retention.completed";
153
- /** Runner-sampled scrub thumbnail (~1/5 s/camera). Telemetry (D8): a lost
154
- * thumb is a scrub gap the recorder's keyframe backfill covers. */
155
- EventCategory["RecordingThumbSampled"] = "recording.thumb-sampled";
156
153
  /** Export render progress (0–100). Telemetry (D8): a lost tick is a stale
157
154
  * progress bar the client reconciles via `recordingExport.getExport`. */
158
155
  EventCategory["RecordingExportProgress"] = "recording.export.progress";
@@ -6817,7 +6814,6 @@ object({ deviceId: number() }), object({ deviceId: number() }), object({
6817
6814
  patch: record(string(), unknown())
6818
6815
  }), object({ success: literal(true) });
6819
6816
  object({ deviceId: number() }), unknown().nullable();
6820
- /** Shorthand to define a method schema */
6821
6817
  function method(input, output, options) {
6822
6818
  return {
6823
6819
  input,
@@ -6825,6 +6821,7 @@ function method(input, output, options) {
6825
6821
  kind: options?.kind ?? "query",
6826
6822
  auth: options?.auth ?? "protected",
6827
6823
  ...options?.access !== void 0 ? { access: options.access } : {},
6824
+ ...options?.caller !== void 0 ? { caller: options.caller } : {},
6828
6825
  timeoutMs: options?.timeoutMs
6829
6826
  };
6830
6827
  }
@@ -7515,16 +7512,23 @@ var StorageLocationDeclarationSchema = object({
7515
7512
  * Which node root the seeded `<id>:default` instance is placed under on a
7516
7513
  * FRESH install:
7517
7514
  * - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
7518
- * the appData volume. Right for small/durable data (backups, logs, models).
7515
+ * the appData volume. Right for small/durable data (logs, models).
7519
7516
  * - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
7520
7517
  * env is set, else falls back to the data root. Right for bulky, hot media
7521
7518
  * (recordings, event media) that should stay off the appData disk.
7519
+ * - `'backup'` — the dedicated backup volume (`CAMSTACK_BACKUP_ROOT`, default
7520
+ * `/backups` in the image) so archives live on their own mount rather than
7521
+ * filling the appData disk. Falls back to the data root when unset.
7522
7522
  *
7523
7523
  * Only affects the seeded default's `basePath`; operators can repoint any
7524
7524
  * location afterwards, and a `defaultsTo` slot inherits its parent's root
7525
7525
  * regardless of this field. Absent (the common case) is treated as `'data'`.
7526
7526
  */
7527
- defaultRoot: _enum(["data", "media"]).optional()
7527
+ defaultRoot: _enum([
7528
+ "data",
7529
+ "media",
7530
+ "backup"
7531
+ ]).optional()
7528
7532
  });
7529
7533
  var DecoderStatsSchema = object({
7530
7534
  inputFps: number(),
@@ -8187,6 +8191,59 @@ for (const l of AUDIO_MACRO_LABELS) {
8187
8191
  /** The complete taxonomy dictionary, keyed by kind. */
8188
8192
  var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
8189
8193
  /**
8194
+ * Notification-Center taxonomy — the fixed vocabulary the NC rule editor
8195
+ * offers as pickers instead of free text. Derived (never hand-listed) from the
8196
+ * single `EVENT_TAXONOMY` dictionary so it stays in lockstep with every other
8197
+ * taxonomy surface (timeline, filters, event page).
8198
+ *
8199
+ * Three buckets, mapped onto the rule editor's `stringList` conditions:
8200
+ * - `videoClasses` → detection classes (person / vehicle / animal + subs)
8201
+ * for the `classes` / `classesExclude` conditions.
8202
+ * - `audioKinds` → audio-analyzer sub kinds (`audio-scream`, …) shown in
8203
+ * the same class picker, grouped under an Audio header.
8204
+ * - `labels` → sensor + control taxonomy kinds (doorbell / contact /
8205
+ * lock / …) for the `sensorKinds` device-event condition.
8206
+ *
8207
+ * Each entry carries `parentKind` so the client can group video subs under
8208
+ * their macro and sensor/control kinds under their category. This surface is
8209
+ * served ADDITIVELY on the `nc.getConditionCatalog` bridge response — no cap
8210
+ * method, no codegen — so it ships train-free with an addon deploy.
8211
+ */
8212
+ /** One selectable taxonomy value: a stable kind id + display label + parent. */
8213
+ var NcTaxonomyEntrySchema = object({
8214
+ /** Stable kind id (e.g. 'person', 'car', 'audio-scream', 'doorbell'). */
8215
+ kind: string(),
8216
+ /** English fallback label (the UI translates via the event-kind i18n key). */
8217
+ label: string(),
8218
+ /** Macro/category parent for grouping ('car' → 'vehicle'); null for a top. */
8219
+ parentKind: string().nullable()
8220
+ });
8221
+ object({
8222
+ videoClasses: array(NcTaxonomyEntrySchema),
8223
+ audioKinds: array(NcTaxonomyEntrySchema),
8224
+ labels: array(NcTaxonomyEntrySchema)
8225
+ });
8226
+ function toEntry(kind, label, parentKind) {
8227
+ return {
8228
+ kind,
8229
+ label,
8230
+ parentKind
8231
+ };
8232
+ }
8233
+ /**
8234
+ * Build the NC taxonomy from `EVENT_TAXONOMY`. Insertion order is preserved
8235
+ * (macros before their subs), which the client relies on for stable grouping.
8236
+ */
8237
+ function buildNcTaxonomy() {
8238
+ const all = Object.values(EVENT_TAXONOMY);
8239
+ return {
8240
+ videoClasses: all.filter((e) => e.category === "detection").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8241
+ audioKinds: all.filter((e) => e.category === "audio" && e.level === "sub").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8242
+ labels: all.filter((e) => e.category === "sensor" || e.category === "control").map((e) => toEntry(e.kind, e.label, e.parentKind))
8243
+ };
8244
+ }
8245
+ Object.freeze(buildNcTaxonomy());
8246
+ /**
8190
8247
  * Error types for the safe expression engine. Two distinct classes so callers
8191
8248
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
8192
8249
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -8822,6 +8879,644 @@ var AccessoryKind = {
8822
8879
  AccessoryKind.Siren, AccessoryKind.Floodlight, AccessoryKind.Spotlight, AccessoryKind.PirSensor, AccessoryKind.Chime, AccessoryKind.Autotrack, AccessoryKind.Nightvision, AccessoryKind.PrivacyMask;
8823
8880
  DeviceFeature.BatteryOperated;
8824
8881
  /**
8882
+ * Shared geometry vocabulary for on-frame shape caps — privacy-mask,
8883
+ * motion-zones, and the detection zones/lines editor all speak this one
8884
+ * language so a single drawing-plane editor and the providers stay
8885
+ * decoupled from each cap's storage.
8886
+ *
8887
+ * All coordinates are normalized 0..1 of the camera frame (top-left
8888
+ * origin). Each cap composes the SUBSET of shape kinds it supports and
8889
+ * advertises it via `supportedShapes` in its `getOptions`.
8890
+ */
8891
+ /** A normalized 0..1 point (top-left origin). */
8892
+ var MaskPointSchema = object({
8893
+ x: number(),
8894
+ y: number()
8895
+ });
8896
+ /** Axis-aligned rectangle (normalized 0..1). */
8897
+ var MaskRectShapeSchema = object({
8898
+ kind: literal("rect"),
8899
+ x: number(),
8900
+ y: number(),
8901
+ width: number(),
8902
+ height: number()
8903
+ });
8904
+ /** Free polygon — an ordered list of normalized vertices (≥3). */
8905
+ var MaskPolygonShapeSchema = object({
8906
+ kind: literal("polygon"),
8907
+ points: array(MaskPointSchema)
8908
+ });
8909
+ /** Boolean cell grid — row-major, length === gridWidth*gridHeight. */
8910
+ var MaskGridShapeSchema = object({
8911
+ kind: literal("grid"),
8912
+ gridWidth: number(),
8913
+ gridHeight: number(),
8914
+ cells: array(boolean())
8915
+ });
8916
+ discriminatedUnion("kind", [
8917
+ MaskRectShapeSchema,
8918
+ MaskPolygonShapeSchema,
8919
+ MaskGridShapeSchema,
8920
+ object({
8921
+ kind: literal("line"),
8922
+ points: array(MaskPointSchema)
8923
+ })
8924
+ ]);
8925
+ /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
8926
+ var MaskShapeKindSchema = _enum([
8927
+ "rect",
8928
+ "polygon",
8929
+ "grid",
8930
+ "line"
8931
+ ]);
8932
+ /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
8933
+ var MaskPolygonVerticesSchema = object({
8934
+ min: number(),
8935
+ max: number()
8936
+ });
8937
+ /** Grid dimensions when a cap supports 'grid'. */
8938
+ var MaskGridDimsSchema = object({
8939
+ width: number(),
8940
+ height: number()
8941
+ });
8942
+ /**
8943
+ * notification-rules — the Notification Center rule surface (P1 core).
8944
+ *
8945
+ * Spec: `docs/superpowers/specs/2026-07-22-notification-center-requirements.md`
8946
+ * (operator decisions D-1/D-2/D-3 are binding):
8947
+ *
8948
+ * - D-2: rule EVALUATION lives in `addon-post-analysis` (the
8949
+ * `notification-center` module), hooked on the durable persistence
8950
+ * moments (object-event insert, TrackCloser.closeExpired) with a
8951
+ * persisted outbox + retry — never the lossy telemetry bus (D8).
8952
+ * - D-3: urgency belongs to the RULE. `delivery: 'immediate'` fires on the
8953
+ * FIRST persisted detection matching the conditions (per-track dedup,
8954
+ * `maxPerTrack` fixed at 1 — see {@link NC_MAX_PER_TRACK_IMMEDIATE});
8955
+ * `delivery: 'track-end'` evaluates the finalized track record at close.
8956
+ * - DISPATCH stays behind `notification-output` (rules reference targets
8957
+ * by id; per-backend params are a passthrough blob capped by the
8958
+ * target kind's own caps/degrade engine).
8959
+ *
8960
+ * P1 scope: admin-authored rules only (`createdBy` stamped from the
8961
+ * server-injected caller identity — the first `caller: 'required'`
8962
+ * adopter). The P1 condition subset is: devices, classes(+exclude),
8963
+ * minConfidence, admin zones (any/all + exclude), weekly schedule
8964
+ * windows, and the optional label/identity/plate matchers. User rules,
8965
+ * private zones, per-recipient fan-out and the wider condition table are
8966
+ * P2+ (see spec §7).
8967
+ *
8968
+ * All schemas here are the single source of truth — `NcRule` etc. are
8969
+ * `z.infer` exports; no duplicate interfaces (the advanced-notifier
8970
+ * schema/interface drift is explicitly not repeated).
8971
+ */
8972
+ /**
8973
+ * D-3: the trigger/urgency of a rule — which persistence moment evaluates it.
8974
+ * The value maps 1:1 onto the evaluated record kind:
8975
+ * - `immediate` ↔ object-event persist (lowest-latency detection burst)
8976
+ * - `track-end` ↔ TrackCloser.closeExpired (finalized track record)
8977
+ * - `device-event` ↔ SensorEventStore insert (doorbell press / sensor state
8978
+ * change of a LINKED device, one row per linked camera)
8979
+ * - `package-event` ↔ PackageDropDetector object-event insert (a `package`
8980
+ * delivery / pick-up)
8981
+ *
8982
+ * `immediate`/`track-end` carry the D-3 urgency semantics; `device-event`/
8983
+ * `package-event` are pure trigger kinds (no urgency dimension). Extending
8984
+ * this one field keeps the schema additive — a rule still declares exactly
8985
+ * one trigger.
8986
+ */
8987
+ var NcDeliverySchema = _enum([
8988
+ "immediate",
8989
+ "track-end",
8990
+ "device-event",
8991
+ "package-event"
8992
+ ]);
8993
+ /** Weekly schedule — OR of windows; absence on the rule = always active. */
8994
+ var NcScheduleSchema = object({
8995
+ windows: array(object({
8996
+ /** Days of week the window STARTS on (0 = Sunday … 6 = Saturday). */
8997
+ days: array(number().int().min(0).max(6)).min(1),
8998
+ startMinute: number().int().min(0).max(1439),
8999
+ endMinute: number().int().min(0).max(1439)
9000
+ })).min(1),
9001
+ /** IANA timezone; default = hub host timezone. */
9002
+ timezone: string().optional(),
9003
+ /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
9004
+ invert: boolean().optional()
9005
+ });
9006
+ /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
9007
+ var NcPlateMatcherSchema = object({
9008
+ values: array(string().min(1)).min(1),
9009
+ /** Max Levenshtein distance after normalization (uppercase alphanumeric). */
9010
+ maxDistance: number().int().min(0).max(3).default(1)
9011
+ });
9012
+ /**
9013
+ * Occupancy condition (DEVICE-EVENT trigger). Fires on a ZoneAnalytics
9014
+ * occupancy edge for a device — optionally narrowed to a single admin
9015
+ * `zoneId` and/or object `className`. `op` selects the edge/threshold:
9016
+ * - `became-occupied` (default) — count crossed 0 → ≥ `count`
9017
+ * - `became-free` — count crossed ≥ `count` → below it
9018
+ * - `>=` / `<=` — count is at/over or at/under `count`
9019
+ * `sustainSeconds` requires the condition hold continuously that long
9020
+ * before firing (debounces flicker; 0 = fire on the first matching edge).
9021
+ * Fail-closed: no ZoneAnalytics snapshot / missing zone / null snapshot ⇒
9022
+ * the condition never matches. Confirmed edge-state survives addon restarts
9023
+ * (declared SQLite collection, reseeded on boot).
9024
+ */
9025
+ var NcOccupancyConditionSchema = object({
9026
+ /** Admin zone id to scope the count to; absent = whole-frame occupancy. */
9027
+ zoneId: string().optional(),
9028
+ /** Object class to count; absent = any class. */
9029
+ className: string().optional(),
9030
+ op: _enum([
9031
+ "became-occupied",
9032
+ "became-free",
9033
+ ">=",
9034
+ "<="
9035
+ ]).default("became-occupied"),
9036
+ count: number().int().min(0).default(1),
9037
+ sustainSeconds: number().int().min(0).max(3600).default(15)
9038
+ });
9039
+ /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
9040
+ var NcZoneConditionSchema = object({
9041
+ ids: array(string().min(1)).min(1),
9042
+ /** Quantifier over `ids` — at least one / every one visited. */
9043
+ match: _enum(["any", "all"]).default("any")
9044
+ });
9045
+ /**
9046
+ * The P1 condition set — a flat AND of groups; absent group = pass;
9047
+ * membership lists are OR within the list (spec §2.3).
9048
+ */
9049
+ var NcConditionsSchema = object({
9050
+ /** Device scope — absent = all devices. */
9051
+ devices: array(number()).optional(),
9052
+ /** Detector class names (any overlap with the record's class set). */
9053
+ classes: array(string().min(1)).optional(),
9054
+ /** Veto classes — any overlap fails the rule. */
9055
+ classesExclude: array(string().min(1)).optional(),
9056
+ /** Minimum detection confidence 0–1 (fails when the record has none). */
9057
+ minConfidence: number().min(0).max(1).optional(),
9058
+ /** Admin zone membership over event `zones` / track `zonesVisited`. */
9059
+ zones: NcZoneConditionSchema.optional(),
9060
+ /** Veto zones — any hit fails the rule. */
9061
+ zonesExclude: array(string().min(1)).optional(),
9062
+ /**
9063
+ * Exact (case-insensitive) match on the record's collapsed `label`
9064
+ * (identity name / plate text / subclass).
9065
+ */
9066
+ labelEquals: array(string().min(1)).optional(),
9067
+ /**
9068
+ * Identity matcher. P1 boundary: matched against the record's collapsed
9069
+ * `label` (the identity display name propagated by the face pipeline) —
9070
+ * identity-ID matching rides in P2 when identity ids reach the record.
9071
+ */
9072
+ identities: array(string().min(1)).optional(),
9073
+ /** Fuzzy plate matcher against the record's `label` (plate text). */
9074
+ plates: NcPlateMatcherSchema.optional(),
9075
+ /**
9076
+ * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
9077
+ * Same P1 boundary: matched against the record's collapsed `label` (the
9078
+ * identity display name). A record with NO label passes (nothing to
9079
+ * exclude), unlike the include variant which fails on an absent label.
9080
+ */
9081
+ identitiesExclude: array(string().min(1)).optional(),
9082
+ /**
9083
+ * Minimum server-computed key-event importance in [0,1] (`Track.importance`).
9084
+ * TRACK-END only: importance is scored at track close, so it does not exist
9085
+ * at immediate / object-event evaluation time (see catalog `appliesTo`). At
9086
+ * close the value is threaded via the close-time info (the `Track` clone is
9087
+ * captured before the DB row is updated, so it would otherwise read stale).
9088
+ * Fails when the record carries no importance (never guess quality — the
9089
+ * `minConfidence` precedent). MVP cut: a single scalar threshold.
9090
+ */
9091
+ minImportance: number().min(0).max(1).optional(),
9092
+ /**
9093
+ * Minimum track dwell in SECONDS — `(lastSeen − firstSeen) / 1000`.
9094
+ * TRACK-END only: an `immediate` / object-event subject has no closed
9095
+ * lifespan, so a dwell condition never matches immediate delivery
9096
+ * (documented choice — the object-event record carries no `firstSeen`,
9097
+ * so dwell cannot be computed from what the subject actually carries).
9098
+ */
9099
+ minDwellSeconds: number().min(0).optional(),
9100
+ /**
9101
+ * Detection provenance filter. `any` (default / absent) matches every
9102
+ * source; otherwise the subject's source must equal it. Legacy records
9103
+ * with no stamped source are treated as `pipeline`. The union spans both
9104
+ * record kinds — object events carry `pipeline` | `onboard`, synthetic
9105
+ * tracks carry `sensor`.
9106
+ */
9107
+ source: _enum([
9108
+ "pipeline",
9109
+ "onboard",
9110
+ "sensor",
9111
+ "any"
9112
+ ]).optional(),
9113
+ /**
9114
+ * Minimum identity / plate MATCH confidence in [0,1] — DISTINCT from the
9115
+ * detector `minConfidence` (that gates the object-detection score; this
9116
+ * gates the recognition/OCR match score). Fails when the subject carries
9117
+ * no label-match confidence (never guess). TRACK-END only: the confidence
9118
+ * lives on the recognition result and reaches the subject at track close.
9119
+ *
9120
+ * What it measures precisely (plumbed at track close — the closer threads
9121
+ * the value into `NcTrackClosedInfo.labelConfidence`, the same seam as
9122
+ * `importance`): the BEST recognition match confidence observed for the
9123
+ * label the track carries at close — for a face, the peak cosine similarity
9124
+ * of the ASSIGNED identity (`FaceMatch.score`, reset on an identity switch);
9125
+ * for a plate, the peak OCR read score of the best-held plate
9126
+ * (`plateText.confidence`). When BOTH a face and a plate were recognized on
9127
+ * one track the higher of the two is used. A track that ended with no
9128
+ * confident identity/plate match carries no value, so the condition fails
9129
+ * closed for it (an un-recognized subject).
9130
+ */
9131
+ minLabelConfidence: number().min(0).max(1).optional(),
9132
+ /**
9133
+ * DEVICE-EVENT only. Raw device event-type tokens (`EventFire.eventType`,
9134
+ * e.g. a doorbell `press` / `press_long`) — matched case-insensitively
9135
+ * against the token carried on the device-event subject (extracted from the
9136
+ * event-emitter runtime slice's `lastEvent.eventType`). Fails when the
9137
+ * subject carries no token. Doorbell-pulse / passive-sensor kinds emit no
9138
+ * eventType, so gate those with {@link sensorKinds} instead.
9139
+ */
9140
+ eventTypeTokens: array(string().min(1)).optional(),
9141
+ /**
9142
+ * DEVICE-EVENT only. Sensor/control taxonomy kinds (e.g. `doorbell`,
9143
+ * `contact`, `button`, `device-event`) — matched against the persisted
9144
+ * `SensorEvent.kind` (see `sensor-event-kinds.ts`). Membership is OR.
9145
+ */
9146
+ sensorKinds: array(string().min(1)).optional(),
9147
+ /**
9148
+ * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
9149
+ * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
9150
+ * when the subject's phase does not match (a subject always carries a phase
9151
+ * on the package-event trigger).
9152
+ */
9153
+ packagePhase: _enum([
9154
+ "delivered",
9155
+ "picked-up",
9156
+ "both"
9157
+ ]).optional(),
9158
+ /**
9159
+ * PERSONAL-RULE custom zones (viewer-drawn). Inline normalized polygons
9160
+ * (MaskShape vocabulary). A record passes when its bbox overlaps ANY
9161
+ * listed polygon (ZoneEngine membership semantics). Evaluated only when
9162
+ * the subject carries a bbox; absent bbox ⇒ the condition FAILS.
9163
+ */
9164
+ customZones: array(MaskPolygonShapeSchema).optional(),
9165
+ /**
9166
+ * DEVICE-EVENT only. ZoneAnalytics occupancy edge — fires when a device's
9167
+ * (optionally zone/class-scoped) occupancy count crosses the configured
9168
+ * threshold and holds for `sustainSeconds`. Fail-closed on missing
9169
+ * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
9170
+ */
9171
+ occupancy: NcOccupancyConditionSchema.optional()
9172
+ });
9173
+ /** One delivery target: a `notification-output` Target ref + passthrough params. */
9174
+ var NcRuleTargetSchema = object({
9175
+ /** `notification-output` Target id. */
9176
+ targetId: string().min(1),
9177
+ /**
9178
+ * Per-backend passthrough. Recognized keys are mapped onto the canonical
9179
+ * Notification (`priority`, `level`, `sound`, `clickUrl`, `ttl`); the
9180
+ * degrade engine drops what the backend can't render.
9181
+ */
9182
+ params: record(string(), unknown()).optional()
9183
+ });
9184
+ /**
9185
+ * Media attachment policy (P1 still-image subset).
9186
+ * - `best` — the best AVAILABLE subject image at dispatch time (D-3).
9187
+ * - `best-matching` — the media that explains WHY the rule fired: a rule
9188
+ * matched on identities attaches the subject's `faceCrop`, one matched on
9189
+ * plates attaches the `plateCrop`; a rule with no identity/plate condition
9190
+ * (or when the specific crop is missing) degrades to `best`, then
9191
+ * `keyFrame`, then no attachment — never delaying the send. The matched
9192
+ * condition summary is frozen on the outbox row at enqueue (like the rule
9193
+ * name), so the choice never drifts from the record that fired it.
9194
+ * - `keyFrame` — the clean scene frame (no subject box).
9195
+ * - `none` — no attachment.
9196
+ */
9197
+ var NcMediaPolicySchema = object({ attach: _enum([
9198
+ "best",
9199
+ "best-matching",
9200
+ "keyFrame",
9201
+ "none"
9202
+ ]).default("best") });
9203
+ /** Throttle — cooldown survives restarts (rebuilt from the outbox on boot). */
9204
+ var NcThrottleSchema = object({
9205
+ cooldownSec: number().int().min(0).max(86400).default(60),
9206
+ /** `rule` = one shared cooldown; `rule-device` = per-camera cooldown. */
9207
+ scope: _enum(["rule", "rule-device"]).default("rule-device")
9208
+ });
9209
+ /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
9210
+ var NcRuleInputSchema = object({
9211
+ name: string().min(1).max(200),
9212
+ enabled: boolean().default(true),
9213
+ delivery: NcDeliverySchema,
9214
+ conditions: NcConditionsSchema.default({}),
9215
+ schedule: NcScheduleSchema.optional(),
9216
+ targets: array(NcRuleTargetSchema).min(1),
9217
+ media: NcMediaPolicySchema.default({ attach: "best" }),
9218
+ throttle: NcThrottleSchema.default({
9219
+ cooldownSec: 60,
9220
+ scope: "rule-device"
9221
+ }),
9222
+ /** `{{var}}` templating over camera/class/label/zones/confidence/time. */
9223
+ template: object({
9224
+ title: string().max(500).optional(),
9225
+ body: string().max(2e3).optional()
9226
+ }).optional(),
9227
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
9228
+ priority: number().int().min(1).max(5).default(3),
9229
+ /**
9230
+ * Ownership/visibility key. Absent = admin/global rule (unchanged legacy
9231
+ * behaviour, visible to all, read-only in the viewer). Present = personal
9232
+ * rule owned by this userId. Server-stamped; never trusted from a client.
9233
+ */
9234
+ ownerUserId: string().optional()
9235
+ });
9236
+ /**
9237
+ * Partial patch for `updateRule` — any subset of the input fields, plus the
9238
+ * persisted-only {@link NcRuleSchema} `disabledTargetIds` set. The latter is
9239
+ * NOT a client-authored input field (it lives on the persisted rule, not the
9240
+ * input), so it is added here explicitly to let the store's per-target opt-out
9241
+ * toggle round-trip through the shared `update` path. Viewer opt-out mutations
9242
+ * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
9243
+ * `updateRule` patch.
9244
+ */
9245
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
9246
+ /** A persisted rule. */
9247
+ var NcRuleSchema = NcRuleInputSchema.extend({
9248
+ id: string(),
9249
+ /** userId of the admin who created the rule (server-stamped caller). */
9250
+ createdBy: string(),
9251
+ createdAt: number(),
9252
+ updatedAt: number(),
9253
+ /**
9254
+ * Per-target opt-out set. A targetId here is suppressed for THIS rule at
9255
+ * send time. Only a target's OWNER may add/remove its id (server-checked
9256
+ * in `nc.setRuleTargetEnabled`). Defaults to empty.
9257
+ */
9258
+ disabledTargetIds: array(string()).default([])
9259
+ });
9260
+ var NcTestResultSchema = object({
9261
+ recordId: string(),
9262
+ recordKind: _enum([
9263
+ "object-event",
9264
+ "track",
9265
+ "device-event",
9266
+ "package-event"
9267
+ ]),
9268
+ deviceId: number(),
9269
+ timestamp: number(),
9270
+ wouldFire: boolean(),
9271
+ /** Condition id that failed (first failing group), when `wouldFire` is false. */
9272
+ failedCondition: string().optional(),
9273
+ className: string().optional(),
9274
+ label: string().optional()
9275
+ });
9276
+ var NcConditionDescriptorSchema = object({
9277
+ /** Field id inside `NcConditions` (or `'schedule'` for the rule-level group). */
9278
+ id: string(),
9279
+ group: _enum([
9280
+ "scope",
9281
+ "class",
9282
+ "zones",
9283
+ "quality",
9284
+ "label",
9285
+ "schedule",
9286
+ "device",
9287
+ "package",
9288
+ "occupancy"
9289
+ ]),
9290
+ label: string(),
9291
+ /** Editor widget the UI renders — never hardcode per-condition forms. */
9292
+ valueType: _enum([
9293
+ "deviceIdList",
9294
+ "stringList",
9295
+ "number01",
9296
+ "number",
9297
+ "sourceSelect",
9298
+ "zoneSelection",
9299
+ "zoneIdList",
9300
+ "schedule",
9301
+ "plateMatcher",
9302
+ "packagePhase",
9303
+ "polygonDraw",
9304
+ "occupancy"
9305
+ ]),
9306
+ operator: _enum([
9307
+ "in",
9308
+ "notIn",
9309
+ "anyOf",
9310
+ "allOf",
9311
+ "gte",
9312
+ "fuzzyIn",
9313
+ "withinSchedule"
9314
+ ]),
9315
+ /** Which delivery kinds the condition applies to. */
9316
+ appliesTo: array(NcDeliverySchema),
9317
+ phase: string(),
9318
+ description: string().optional()
9319
+ });
9320
+ /**
9321
+ * The delivery lifecycle status of a history row — a straight read of the
9322
+ * durable outbox row's own status (single source of truth):
9323
+ * - `pending` — enqueued, in-flight or retrying with backoff
9324
+ * - `sent` — delivered (terminal)
9325
+ * - `dead` — dead-lettered after exhausting retries / a permanent
9326
+ * backend rejection / a deleted target (terminal; carries
9327
+ * the failure `error`)
9328
+ *
9329
+ * P1 has no `suppressed-quiet-hours` / `snoozed` states — those ride the P2
9330
+ * user dimension (quiet hours / snooze) and are additive when they land.
9331
+ */
9332
+ var NcHistoryStatusSchema = _enum([
9333
+ "pending",
9334
+ "sent",
9335
+ "dead"
9336
+ ]);
9337
+ /** The evaluated record kind a history row descends from (one per trigger). */
9338
+ var NcHistoryRecordKindSchema = _enum([
9339
+ "object-event",
9340
+ "track-end",
9341
+ "device-event",
9342
+ "package-event"
9343
+ ]);
9344
+ /** Subject summary frozen on the row at fire time (survives rule/record edits). */
9345
+ var NcHistorySubjectSchema = object({
9346
+ className: string(),
9347
+ label: string().optional(),
9348
+ confidence: number().optional(),
9349
+ zones: array(string()),
9350
+ timestamp: number()
9351
+ });
9352
+ /**
9353
+ * One delivery-history row. This is a read-only VIEW over the durable
9354
+ * outbox row (single source of truth — the same row the drain loop drives;
9355
+ * NO second write path, so history can never drift from delivery state).
9356
+ * The §3.2 fields map directly: `ruleId`/`targetId`/`deviceId` are columns,
9357
+ * `eventRef` is `recordKind`+`recordId`, `timestamps` are `createdAt`
9358
+ * (fire) / `updatedAt` (last transition), `status` + `error` are the
9359
+ * lifecycle. `ruleName` + `subject` are the intent snapshot frozen at
9360
+ * enqueue. `userId?` (per-recipient history) is P2 — no user dimension in
9361
+ * P1 (admin scope only).
9362
+ */
9363
+ var NcHistoryEntrySchema = object({
9364
+ /** Outbox row id — the stable dedup id `ruleId:dedupRef:targetId`. */
9365
+ id: string(),
9366
+ ruleId: string(),
9367
+ /** Rule name frozen at fire time (outlives a later rename / delete). */
9368
+ ruleName: string(),
9369
+ /** The rule urgency/trigger that produced this delivery. */
9370
+ delivery: NcDeliverySchema,
9371
+ targetId: string(),
9372
+ deviceId: number(),
9373
+ recordKind: NcHistoryRecordKindSchema,
9374
+ /** Event / track ref of the evaluated record (§3.2 `eventRef`). */
9375
+ recordId: string(),
9376
+ /** Present for track-scoped deliveries (object-event / track-end). */
9377
+ trackId: string().optional(),
9378
+ status: NcHistoryStatusSchema,
9379
+ /** Delivery attempts made so far. */
9380
+ attempts: number().int(),
9381
+ /** Fire time (outbox enqueue). */
9382
+ createdAt: number(),
9383
+ /** Last transition time (terminal for sent / dead). */
9384
+ updatedAt: number(),
9385
+ /** Failure detail — present on a `dead` row. */
9386
+ error: string().optional(),
9387
+ subject: NcHistorySubjectSchema
9388
+ });
9389
+ /**
9390
+ * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
9391
+ * AND; absent = unbounded on that axis. `since`/`until` bound the fire time
9392
+ * (`createdAt`, epoch ms, inclusive). `limit` is clamped to
9393
+ * {@link NC_HISTORY_LIMIT_MAX}. `userId` (per-recipient filtering) is P2.
9394
+ */
9395
+ var NcHistoryFilterSchema = object({
9396
+ ruleId: string().optional(),
9397
+ deviceId: number().optional(),
9398
+ status: NcHistoryStatusSchema.optional(),
9399
+ since: number().optional(),
9400
+ until: number().optional(),
9401
+ limit: number().int().min(1).max(500).default(100)
9402
+ });
9403
+ 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 }), {
9404
+ kind: "mutation",
9405
+ auth: "admin",
9406
+ caller: "required"
9407
+ }), method(object({
9408
+ ruleId: string(),
9409
+ patch: NcRulePatchSchema
9410
+ }), object({ rule: NcRuleSchema }), {
9411
+ kind: "mutation",
9412
+ auth: "admin",
9413
+ caller: "required"
9414
+ }), method(object({ ruleId: string() }), object({ success: literal(true) }), {
9415
+ kind: "mutation",
9416
+ auth: "admin"
9417
+ }), method(object({
9418
+ ruleId: string(),
9419
+ enabled: boolean()
9420
+ }), object({ success: literal(true) }), {
9421
+ kind: "mutation",
9422
+ auth: "admin"
9423
+ }), method(object({
9424
+ rule: NcRuleInputSchema,
9425
+ lookbackMinutes: number().int().min(1).max(1440).default(60)
9426
+ }), object({ results: array(NcTestResultSchema) }), {
9427
+ kind: "mutation",
9428
+ auth: "admin"
9429
+ }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
9430
+ /**
9431
+ * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
9432
+ *
9433
+ * Spec: `docs/superpowers/specs/2026-07-24-nc-occupancy-timelapse-design.md`
9434
+ * §3.2/§3.3.
9435
+ *
9436
+ * Deliberately NOT a capability definition and NOT an `NcRule`:
9437
+ * - Every `NcDelivery` member is a *persisted-pipeline-record* trigger. A
9438
+ * timelapse fires on a SCHEDULE WINDOW BOUNDARY, evaluates no pipeline
9439
+ * record, and produces a video it assembled itself — so it rides no
9440
+ * delivery-enum member (the enum is frozen) and no cap method. This file is
9441
+ * a plain typed schema; it does NOT go through `npm run codegen`.
9442
+ * - It shares only the delivery leg (`notification-output.send`) and the
9443
+ * persistence/ownership patterns with the Notification Center, reusing
9444
+ * {@link NcScheduleSchema} (weekly windows, midnight-crossing, invertible)
9445
+ * and {@link NcRuleTargetSchema} (target ref + passthrough params).
9446
+ *
9447
+ * Ownership is SERVER-DERIVED. `ownerUserId` / `createdBy` / `createdAt` /
9448
+ * `updatedAt` / `id` / `lastGeneratedAt` live on the PERSISTED rule only —
9449
+ * {@link TimelapseRuleInputSchema} and {@link TimelapseRulePatchSchema} do not
9450
+ * carry them, so a forged client payload can never claim or re-own a rule
9451
+ * (Zod strips unknown keys). The store stamps them from the resolved caller.
9452
+ */
9453
+ /** `{{var}}` templating over camera/rule/time — same vocabulary as `NcRule`. */
9454
+ var TimelapseTemplateSchema = object({
9455
+ title: string().max(500).optional(),
9456
+ body: string().max(2e3).optional()
9457
+ });
9458
+ var NameField = string().min(1).max(200);
9459
+ var DeviceIdsField = array(number()).min(1);
9460
+ var CadenceSecField = number().int().min(2).max(3600);
9461
+ var FramerateField = number().int().min(1).max(60);
9462
+ var TargetsField = array(NcRuleTargetSchema).min(1);
9463
+ var PriorityField = number().int().min(1).max(5);
9464
+ /**
9465
+ * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
9466
+ * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
9467
+ * here (see the ownership note above).
9468
+ */
9469
+ var TimelapseRuleInputSchema = object({
9470
+ name: NameField,
9471
+ enabled: boolean().default(true),
9472
+ /** Cameras sampled by this rule — one scratch dir + one artifact per device. */
9473
+ deviceIds: DeviceIdsField,
9474
+ /**
9475
+ * Activation window(s). REQUIRED (unlike `NcRule`, where an absent schedule
9476
+ * means "always active"): a timelapse is defined by its window boundaries —
9477
+ * open clears the scratch, close assembles and delivers.
9478
+ */
9479
+ schedule: NcScheduleSchema,
9480
+ /** Force-snapshot cadence inside the window, seconds (predecessor parity). */
9481
+ cadenceSec: CadenceSecField.default(15),
9482
+ /** Output frames per second of the assembled mp4 (predecessor parity). */
9483
+ framerate: FramerateField.default(10),
9484
+ /** `notification-output` targets the finished video/thumbnail is sent to. */
9485
+ targets: TargetsField,
9486
+ template: TimelapseTemplateSchema.optional(),
9487
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
9488
+ priority: PriorityField.default(3)
9489
+ });
9490
+ object({
9491
+ name: NameField.optional(),
9492
+ enabled: boolean().optional(),
9493
+ deviceIds: DeviceIdsField.optional(),
9494
+ schedule: NcScheduleSchema.optional(),
9495
+ cadenceSec: CadenceSecField.optional(),
9496
+ framerate: FramerateField.optional(),
9497
+ targets: TargetsField.optional(),
9498
+ template: TimelapseTemplateSchema.nullable().optional(),
9499
+ priority: PriorityField.optional()
9500
+ });
9501
+ TimelapseRuleInputSchema.extend({
9502
+ id: string(),
9503
+ /**
9504
+ * Ownership/visibility key. Absent = admin/global rule (visible to all).
9505
+ * Present = personal rule owned by this userId. Server-stamped from the
9506
+ * resolved caller; never trusted from a client payload.
9507
+ */
9508
+ ownerUserId: string().optional(),
9509
+ /**
9510
+ * Epoch-ms of the last successful generation — the 1-hour re-generation
9511
+ * guard's durable state (predecessor parity). Absent = never generated.
9512
+ */
9513
+ lastGeneratedAt: number().optional(),
9514
+ /** userId of the caller who created the rule (server-stamped). */
9515
+ createdBy: string(),
9516
+ createdAt: number(),
9517
+ updatedAt: number()
9518
+ });
9519
+ /**
8825
9520
  * Generic device-level status snapshot. Auto-registered by `BaseDevice`
8826
9521
  * for every device, regardless of provider — the kernel needs a uniform
8827
9522
  * cap-keyed slice for the basic device flags every consumer expects to
@@ -10895,6 +11590,22 @@ var CameraMetricsSchema = object({
10895
11590
  ])
10896
11591
  });
10897
11592
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
11593
+ /**
11594
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
11595
+ * within the frame, so the executor can re-cut a leaf child ROI at native
11596
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
11597
+ */
11598
+ var NativeCropRefSchema = object({
11599
+ /** Handle keying the retained native surface (node-pinned to its owner). */
11600
+ handle: FrameHandleSchema,
11601
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
11602
+ cropFrameSpace: object({
11603
+ x: number(),
11604
+ y: number(),
11605
+ w: number(),
11606
+ h: number()
11607
+ })
11608
+ });
10898
11609
  var ModelFormatSchema$1 = _enum([
10899
11610
  "onnx",
10900
11611
  "coreml",
@@ -11170,7 +11881,22 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
11170
11881
  * Omitted ⇒ the runner's default device (current single-engine
11171
11882
  * behaviour). Selects WHICH device pool of the node runs the call.
11172
11883
  */
11173
- deviceKey: string().optional()
11884
+ deviceKey: string().optional(),
11885
+ /**
11886
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
11887
+ * when the parent crop was resolved from the frame's retained NATIVE
11888
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
11889
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
11890
+ * resolution from that surface — the SAME quality path faces already
11891
+ * had — instead of the downscaled parent tile. `handle` keys the native
11892
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
11893
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
11894
+ * the executor's crop-normalized child ROI back into frame-normalized
11895
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
11896
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
11897
+ * (today's behaviour on the fallback path).
11898
+ */
11899
+ nativeCropRef: NativeCropRefSchema.optional()
11174
11900
  }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
11175
11901
  engine: PipelineEngineChoiceSchema.optional(),
11176
11902
  steps: array(PipelineStepInputSchema).min(1),
@@ -11386,7 +12112,11 @@ var DetailResultSchema = object({
11386
12112
  bbox: NativeCropBboxSchema.optional(),
11387
12113
  embedding: string().optional(),
11388
12114
  label: string().optional(),
11389
- alignedCropJpeg: string().optional()
12115
+ alignedCropJpeg: string().optional(),
12116
+ /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
12117
+ * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
12118
+ * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
12119
+ nativeFaceShortSidePx: number().optional()
11390
12120
  });
11391
12121
  /**
11392
12122
  * Per-camera tunable ranges + defaults. Single source of truth used
@@ -11400,6 +12130,12 @@ var motionCooldownMsField = {
11400
12130
  default: 3e4,
11401
12131
  step: 500
11402
12132
  };
12133
+ var maxSessionHoldMsField = {
12134
+ min: 0,
12135
+ max: 6e5,
12136
+ default: 12e4,
12137
+ step: 5e3
12138
+ };
11403
12139
  var motionFpsField = {
11404
12140
  min: 1,
11405
12141
  max: 30,
@@ -11547,6 +12283,19 @@ var RunnerCameraConfigSchema = object({
11547
12283
  "on-motion"
11548
12284
  ]).default("always-on"),
11549
12285
  motionCooldownMs: number().min(motionCooldownMsField.min).default(motionCooldownMsField.default),
12286
+ /**
12287
+ * Orchestrator-side on-motion session-hold cap (ms). While an on-motion
12288
+ * detection session is active and ≥1 confirmed non-stationary track is
12289
+ * still live, the orchestrator keeps the session open past
12290
+ * `motionCooldownMs` (a slowly-moving subject can stop re-triggering the
12291
+ * camera's VMD yet is still being tracked frame-to-frame) — up to this many
12292
+ * ms since the session opened, after which it closes regardless. `0`
12293
+ * disables the hold (legacy cooldown-only teardown). Not consumed by the
12294
+ * runner itself — carried here so it shares the per-camera device-settings
12295
+ * surface with `motionCooldownMs`; the orchestrator reads it off the
12296
+ * resolved `CameraDetectionConfig`.
12297
+ */
12298
+ maxSessionHoldMs: number().min(maxSessionHoldMsField.min).max(maxSessionHoldMsField.max).optional(),
11550
12299
  motionFps: number().min(motionFpsField.min).max(motionFpsField.max).default(motionFpsField.default),
11551
12300
  detectionFps: number().min(detectionFpsField.min).max(detectionFpsField.max).default(detectionFpsField.default),
11552
12301
  motionStreamId: string(),
@@ -11636,7 +12385,7 @@ var RunnerCameraConfigSchema = object({
11636
12385
  */
11637
12386
  inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
11638
12387
  });
11639
- 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;
12388
+ 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;
11640
12389
  /**
11641
12390
  * Runtime load summary returned by `getLocalLoad`. Used by the orchestrator's
11642
12391
  * load-balancing levels (L2 capacity-based, L3 hardware-aware) to decide
@@ -11747,67 +12496,6 @@ DeviceType.Light, DeviceType.Siren, DeviceType.Switch, method(object({
11747
12496
  lastChangedAt: number()
11748
12497
  });
11749
12498
  /**
11750
- * Shared geometry vocabulary for on-frame shape caps — privacy-mask,
11751
- * motion-zones, and the detection zones/lines editor all speak this one
11752
- * language so a single drawing-plane editor and the providers stay
11753
- * decoupled from each cap's storage.
11754
- *
11755
- * All coordinates are normalized 0..1 of the camera frame (top-left
11756
- * origin). Each cap composes the SUBSET of shape kinds it supports and
11757
- * advertises it via `supportedShapes` in its `getOptions`.
11758
- */
11759
- /** A normalized 0..1 point (top-left origin). */
11760
- var MaskPointSchema = object({
11761
- x: number(),
11762
- y: number()
11763
- });
11764
- /** Axis-aligned rectangle (normalized 0..1). */
11765
- var MaskRectShapeSchema = object({
11766
- kind: literal("rect"),
11767
- x: number(),
11768
- y: number(),
11769
- width: number(),
11770
- height: number()
11771
- });
11772
- /** Free polygon — an ordered list of normalized vertices (≥3). */
11773
- var MaskPolygonShapeSchema = object({
11774
- kind: literal("polygon"),
11775
- points: array(MaskPointSchema)
11776
- });
11777
- /** Boolean cell grid — row-major, length === gridWidth*gridHeight. */
11778
- var MaskGridShapeSchema = object({
11779
- kind: literal("grid"),
11780
- gridWidth: number(),
11781
- gridHeight: number(),
11782
- cells: array(boolean())
11783
- });
11784
- discriminatedUnion("kind", [
11785
- MaskRectShapeSchema,
11786
- MaskPolygonShapeSchema,
11787
- MaskGridShapeSchema,
11788
- object({
11789
- kind: literal("line"),
11790
- points: array(MaskPointSchema)
11791
- })
11792
- ]);
11793
- /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
11794
- var MaskShapeKindSchema = _enum([
11795
- "rect",
11796
- "polygon",
11797
- "grid",
11798
- "line"
11799
- ]);
11800
- /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
11801
- var MaskPolygonVerticesSchema = object({
11802
- min: number(),
11803
- max: number()
11804
- });
11805
- /** Grid dimensions when a cap supports 'grid'. */
11806
- var MaskGridDimsSchema = object({
11807
- width: number(),
11808
- height: number()
11809
- });
11810
- /**
11811
12499
  * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
11812
12500
  * on-camera motion-detection mask is a single `grid` region (a row-major
11813
12501
  * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
@@ -13490,94 +14178,6 @@ var EnrichedWidgetMetadataSchema = WidgetMetadataSchema.extend({
13490
14178
  bundleUrl: string()
13491
14179
  });
13492
14180
  method(_void(), array(EnrichedWidgetMetadataSchema).readonly());
13493
- var NotificationRuleConditionsSchema = object({
13494
- deviceIds: array(number()).readonly().optional(),
13495
- classNames: array(string()).readonly().optional(),
13496
- zoneIds: array(string()).readonly().optional(),
13497
- minConfidence: number().optional(),
13498
- source: _enum([
13499
- "pipeline",
13500
- "onboard",
13501
- "any"
13502
- ]).optional(),
13503
- schedule: object({
13504
- days: array(number()).readonly(),
13505
- startHour: number(),
13506
- endHour: number()
13507
- }).optional(),
13508
- cooldownSeconds: number().optional(),
13509
- minDwellSeconds: number().optional(),
13510
- /** Match against `event.data.eventType` token (e.g. `'press_long'`). When non-empty, only events
13511
- * carrying a matching `data.eventType` string pass this condition. Rules without this field are
13512
- * unaffected (back-compat). Distinct from `rule.eventTypes` which holds EventCategory strings. */
13513
- eventTypeTokens: array(string()).readonly().optional(),
13514
- /** Match detections whose CLIP image embedding is semantically similar to this free-text
13515
- * description. Requires the embedding-encoder cap to have pre-warmed the text vector.
13516
- * `minSimilarity` is the cosine similarity threshold in [0, 1]. */
13517
- clipDescription: object({
13518
- text: string().min(1),
13519
- minSimilarity: number().min(0).max(1)
13520
- }).optional(),
13521
- /** Match events whose recognized-entity label (face identity name or plate
13522
- * vehicle name, propagated onto `event.data.label`) is one of these values.
13523
- * Empty/absent → unaffected (back-compat). Enables "notify me when <named
13524
- * vehicle/person> is seen". */
13525
- labels: array(string()).readonly().optional()
13526
- });
13527
- var NotificationRuleTemplateSchema = object({
13528
- title: string(),
13529
- body: string(),
13530
- imageMode: _enum([
13531
- "crop",
13532
- "annotated",
13533
- "full",
13534
- "none"
13535
- ])
13536
- });
13537
- var NotificationRuleSchema = object({
13538
- id: string(),
13539
- name: string(),
13540
- enabled: boolean(),
13541
- eventTypes: array(string()).readonly(),
13542
- conditions: NotificationRuleConditionsSchema,
13543
- outputs: array(string()).readonly(),
13544
- template: NotificationRuleTemplateSchema.optional(),
13545
- priority: _enum([
13546
- "low",
13547
- "normal",
13548
- "high",
13549
- "critical"
13550
- ])
13551
- });
13552
- var NotificationTestResultSchema = object({
13553
- ruleId: string(),
13554
- eventId: string(),
13555
- timestamp: number(),
13556
- wouldFire: boolean(),
13557
- reason: string().optional()
13558
- });
13559
- var NotificationHistoryEntrySchema = object({
13560
- id: string(),
13561
- ruleId: string(),
13562
- ruleName: string(),
13563
- eventId: string(),
13564
- timestamp: number(),
13565
- outputs: array(string()).readonly(),
13566
- success: boolean(),
13567
- error: string().optional(),
13568
- deviceId: number().optional()
13569
- });
13570
- var NotificationHistoryFilterSchema = object({
13571
- ruleId: string().optional(),
13572
- deviceId: number().optional(),
13573
- from: number().optional(),
13574
- to: number().optional(),
13575
- limit: number().optional()
13576
- });
13577
- 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({
13578
- ruleId: string(),
13579
- lookbackMinutes: number()
13580
- }), object({ results: array(NotificationTestResultSchema).readonly() }), { kind: "mutation" }), method(object({ filter: NotificationHistoryFilterSchema.optional() }), object({ entries: array(NotificationHistoryEntrySchema).readonly() }));
13581
14181
  /**
13582
14182
  * Alerts capability — collection-based internal alert system.
13583
14183
  *
@@ -13764,88 +14364,54 @@ method(object({
13764
14364
  password: string()
13765
14365
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
13766
14366
  /**
13767
- * `login-method` collection cap through which auth addons contribute
13768
- * their pre-auth login surfaces to the login page. This is the SINGLE,
13769
- * generic mechanism that supersedes the dead `auth.listProviders` reader:
13770
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
13771
- * `login-method` provider and the PUBLIC `auth.listLoginMethods`
13772
- * procedure aggregates them for the unauthenticated login page.
13773
- *
13774
- * A contribution is a discriminated union on `kind`:
13775
- *
13776
- * - `redirect` — a declarative button. The login page renders a generic
13777
- * button that navigates to `startUrl` (an addon-owned HTTP route).
13778
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
13779
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
13780
- * login page needs NO change.
13781
- *
13782
- * - `widget` — a Module-Federation widget the login page mounts (via
13783
- * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
13784
- * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
13785
- * mechanism kept for future use; no shipped addon uses it on the login
13786
- * page (the passkey ceremony below runs natively in the shell instead).
13787
- *
13788
- * - `passkey` — a declarative WebAuthn ceremony the shell renders
13789
- * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
13790
- * a remotely-loaded bundle). Carries the addon's effective `rpId` /
13791
- * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
13792
- * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
13793
- * fetching any remote code pre-auth. Contribution stays unconditional —
13794
- * enrollment state is never leaked pre-auth; visibility is a shell
13795
- * decision.
13796
- *
13797
- * Every contribution carries a `stage`:
13798
- * - `primary` — shown on the first credentials screen (OIDC /
13799
- * magic-link buttons; a future usernameless passkey).
13800
- * - `second-factor` — shown AFTER the password leg, gated on the
13801
- * returned `factors` (passkey-as-2FA today).
13802
- *
13803
- * `mount: skip` — the cap is read server-side by the core auth router
13804
- * (`registry.getCollection('login-method')`), never mounted as its own
13805
- * tRPC router.
14367
+ * A live terminal session hosted by the provider addon. Output and input do
14368
+ * NOT flow through the capability they use the addon data plane
14369
+ * (`GET /addon/terminal/<id>/out` SSE, `POST /addon/terminal/<id>/in`) because
14370
+ * terminal output must be ordered and lossless. The event bus is telemetry and
14371
+ * may drop chunks ([D8]), and a dropped chunk desynchronises the vt parser
14372
+ * permanently until a full repaint. The capability owns only lifecycle.
13806
14373
  */
13807
- /** When a login method renders in the two-phase login flow. */
13808
- var LoginStageEnum = _enum(["primary", "second-factor"]);
13809
- /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
13810
- var LoginMethodContributionSchema = discriminatedUnion("kind", [
13811
- object({
13812
- kind: literal("redirect"),
13813
- /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
13814
- id: string(),
13815
- /** Operator-facing button label. */
13816
- label: string(),
13817
- /** lucide-react icon name. */
13818
- icon: string().optional(),
13819
- /** Addon-owned HTTP route the button navigates to (GET). */
13820
- startUrl: string(),
13821
- stage: LoginStageEnum
13822
- }),
13823
- object({
13824
- kind: literal("widget"),
13825
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
13826
- id: string(),
13827
- /** Owning addon id — drives the public bundle URL + the MF namespace. */
13828
- addonId: string(),
13829
- /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
13830
- bundle: string(),
13831
- /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
13832
- remote: WidgetRemoteSchema,
13833
- stage: LoginStageEnum
13834
- }),
13835
- object({
13836
- kind: literal("passkey"),
13837
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
13838
- id: string(),
13839
- /** Operator-facing button label. */
13840
- label: string(),
13841
- stage: LoginStageEnum,
13842
- /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
13843
- rpId: string(),
13844
- /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
13845
- origin: string().nullable()
13846
- })
13847
- ]);
13848
- method(_void(), array(LoginMethodContributionSchema).readonly());
14374
+ var TerminalSessionInfoSchema = object({
14375
+ /** Opaque session id minted by the provider on `openSession`. */
14376
+ sessionId: string(),
14377
+ /** The pre-declared profile this session runs (never a free-form command). */
14378
+ profileId: string(),
14379
+ /** Human-readable profile label for the UI session list. */
14380
+ label: string(),
14381
+ cols: number().int().positive(),
14382
+ rows: number().int().positive(),
14383
+ /** ms-epoch the session's pty was spawned. */
14384
+ startedAt: number()
14385
+ });
14386
+ /**
14387
+ * A profile the operator may open — a pre-declared, allowlisted program
14388
+ * (`monitor` → `btm`). The capability accepts only these ids; a free-form
14389
+ * command string would be remote code execution as the server's user, so it is
14390
+ * deliberately not part of the contract.
14391
+ */
14392
+ var TerminalProfileInfoSchema = object({
14393
+ profileId: string(),
14394
+ label: string(),
14395
+ description: string().optional()
14396
+ });
14397
+ method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(TerminalSessionInfoSchema).readonly(), { auth: "admin" }), method(object({
14398
+ profileId: string(),
14399
+ cols: number().int().positive(),
14400
+ rows: number().int().positive()
14401
+ }), TerminalSessionInfoSchema, {
14402
+ kind: "mutation",
14403
+ auth: "admin"
14404
+ }), method(object({
14405
+ sessionId: string(),
14406
+ cols: number().int().positive(),
14407
+ rows: number().int().positive()
14408
+ }), _void(), {
14409
+ kind: "mutation",
14410
+ auth: "admin"
14411
+ }), method(object({ sessionId: string() }), _void(), {
14412
+ kind: "mutation",
14413
+ auth: "admin"
14414
+ });
13849
14415
  /**
13850
14416
  * Orchestrator-side destination metadata. The orchestrator computes
13851
14417
  * `id = <addonId>:<subId>` from its provider lookup so consumers
@@ -13947,11 +14513,53 @@ var LocationStatSchema = object({
13947
14513
  fileCount: number(),
13948
14514
  present: boolean()
13949
14515
  });
14516
+ /**
14517
+ * A backup schedule — the N:M "entry" that binds one cron cadence to a
14518
+ * SET of destination locations. Supersedes the per-location cron on
14519
+ * `BackupDestinationPolicy`: an operator creates a schedule, picks the
14520
+ * `backups` locations it should write to, and the orchestrator fans a
14521
+ * single archive out to all of them when the cron fires.
14522
+ *
14523
+ * `retentionCount` is per-schedule (D-decision 2026-07-28): every
14524
+ * location targeted by this schedule keeps this many archives from
14525
+ * this schedule's runs.
14526
+ *
14527
+ * `dataSources` optionally narrows which top-level state locations
14528
+ * (db, addons, tls, …) are archived; omitted = the orchestrator's
14529
+ * default full set.
14530
+ */
14531
+ var BackupScheduleSchema = object({
14532
+ /** Stable id. Generated by the orchestrator on first upsert if absent. */
14533
+ id: string(),
14534
+ /** Operator-facing display name. */
14535
+ label: string(),
14536
+ /** 5-field POSIX cron. Empty = disabled cadence (kept for editing). */
14537
+ cron: string(),
14538
+ /** Master on/off toggle for the whole schedule. */
14539
+ enabled: boolean(),
14540
+ /** `backups`-location ids this schedule writes to (fan-out set). */
14541
+ locationIds: array(string()).readonly(),
14542
+ /** Archives kept per targeted location for this schedule. */
14543
+ retentionCount: number().int().min(1).max(1e3),
14544
+ /** Optional subset of source locations to include; omitted = all. */
14545
+ dataSources: array(string()).readonly().optional(),
14546
+ /** ms-epoch of last successful run. */
14547
+ lastRunAt: number().optional(),
14548
+ /** ms-epoch of next computed firing (read-only, filled on list). */
14549
+ nextRunAt: number().optional()
14550
+ });
13950
14551
  method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }), method(object({
13951
14552
  /** Subset of registered `backup-destination` addon ids to write to. */
13952
14553
  destinations: array(string()).optional(),
13953
14554
  locations: array(string()).optional(),
13954
- label: string().optional()
14555
+ label: string().optional(),
14556
+ /**
14557
+ * Per-run retention override applied to every targeted
14558
+ * destination. Used by schedule-driven runs (per-entry
14559
+ * retention). Omitted = each destination's own policy
14560
+ * retention (manual runs).
14561
+ */
14562
+ retentionCount: number().int().min(1).max(1e3).optional()
13955
14563
  }).optional(), array(BackupEntrySchema).readonly(), {
13956
14564
  kind: "mutation",
13957
14565
  auth: "admin"
@@ -14000,7 +14608,21 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
14000
14608
  ok: boolean(),
14001
14609
  error: string().optional(),
14002
14610
  nextRuns: array(number()).readonly()
14003
- }));
14611
+ })), method(_void(), array(BackupScheduleSchema).readonly(), { auth: "admin" }), method(object({
14612
+ id: string().optional(),
14613
+ label: string(),
14614
+ cron: string(),
14615
+ enabled: boolean(),
14616
+ locationIds: array(string()).readonly(),
14617
+ retentionCount: number().int().min(1).max(1e3),
14618
+ dataSources: array(string()).readonly().optional()
14619
+ }), BackupScheduleSchema, {
14620
+ kind: "mutation",
14621
+ auth: "admin"
14622
+ }), method(object({ id: string() }), _void(), {
14623
+ kind: "mutation",
14624
+ auth: "admin"
14625
+ });
14004
14626
  /**
14005
14627
  * `broker` — unified pub/sub broker registry, system-scoped collection.
14006
14628
  *
@@ -15190,851 +15812,934 @@ method(_void(), array(string()).readonly(), { auth: "admin" }), method(object({
15190
15812
  kind: "mutation",
15191
15813
  auth: "admin"
15192
15814
  });
15193
- var LogLevelSchema = _enum([
15194
- "debug",
15195
- "info",
15196
- "warn",
15197
- "error"
15198
- ]);
15199
- var LogEntrySchema = object({
15200
- timestamp: date(),
15201
- level: LogLevelSchema,
15202
- scope: array(string()),
15203
- message: string(),
15204
- meta: record(string(), unknown()).optional(),
15205
- tags: record(string(), string()).optional()
15815
+ /**
15816
+ * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
15817
+ * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15818
+ * caps stay wire-compatible without a circular cap→cap import.
15819
+ *
15820
+ * Errors are a discriminated-union RESULT, never thrown: the shape survives
15821
+ * every transport tier structurally, and failed calls still write usage rows.
15822
+ * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
15823
+ */
15824
+ var LlmUsageSchema = object({
15825
+ inputTokens: number(),
15826
+ outputTokens: number()
15206
15827
  });
15207
- method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
15208
- scope: array(string()).optional(),
15209
- level: LogLevelSchema.optional(),
15210
- since: date().optional(),
15211
- until: date().optional(),
15212
- limit: number().optional(),
15213
- tags: record(string(), string()).optional()
15214
- }), array(LogEntrySchema).readonly());
15215
- var CpuBreakdownSchema = object({
15216
- total: number(),
15217
- user: number(),
15218
- system: number(),
15219
- irq: number(),
15220
- nice: number(),
15221
- loadAvg: tuple([
15222
- number(),
15223
- number(),
15224
- number()
15225
- ]),
15226
- cores: number()
15227
- });
15228
- var MemoryInfoSchema = object({
15229
- percent: number(),
15230
- totalBytes: number(),
15231
- usedBytes: number(),
15232
- availableBytes: number(),
15233
- swapUsedBytes: number(),
15234
- swapTotalBytes: number()
15235
- });
15236
- var DiskIoSnapshotSchema = object({
15237
- readBytes: number(),
15238
- writeBytes: number(),
15239
- readOps: number(),
15240
- writeOps: number(),
15241
- timestampMs: number()
15242
- });
15243
- var NetworkIoSnapshotSchema = object({
15244
- rxBytes: number(),
15245
- txBytes: number(),
15246
- rxPackets: number(),
15247
- txPackets: number(),
15248
- rxErrors: number(),
15249
- txErrors: number(),
15250
- timestampMs: number()
15251
- });
15252
- var MetricsGpuInfoSchema = object({
15253
- utilization: number(),
15828
+ var LlmErrorCodeSchema = _enum([
15829
+ "timeout",
15830
+ "rate-limited",
15831
+ "auth",
15832
+ "refusal",
15833
+ "bad-request",
15834
+ "unavailable",
15835
+ "no-profile",
15836
+ "budget-exceeded",
15837
+ "adapter-error"
15838
+ ]);
15839
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
15840
+ ok: literal(true),
15841
+ text: string(),
15254
15842
  model: string(),
15255
- memoryUsedBytes: number(),
15256
- memoryTotalBytes: number(),
15257
- temperature: number().nullable()
15258
- });
15259
- var ProcessResourceInfoSchema = object({
15260
- openFds: number(),
15261
- threadCount: number(),
15262
- activeHandles: number(),
15263
- activeRequests: number()
15264
- });
15265
- var PressureAvgsSchema = object({
15266
- avg10: number(),
15267
- avg60: number(),
15268
- avg300: number()
15843
+ usage: LlmUsageSchema,
15844
+ truncated: boolean(),
15845
+ latencyMs: number()
15846
+ }), object({
15847
+ ok: literal(false),
15848
+ code: LlmErrorCodeSchema,
15849
+ message: string(),
15850
+ retryAfterMs: number().optional()
15851
+ })]);
15852
+ /**
15853
+ * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
15854
+ * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
15855
+ * notification-output.cap.ts:27-31 precedents).
15856
+ */
15857
+ var LlmImageSchema = object({
15858
+ bytes: _instanceof(Uint8Array),
15859
+ mimeType: string()
15269
15860
  });
15270
- var PressureInfoSchema = object({
15271
- some: PressureAvgsSchema,
15272
- full: PressureAvgsSchema.nullable()
15861
+ var LlmGenerateBaseInputSchema = object({
15862
+ /** Collection routing (the notification-output posture). */
15863
+ addonId: string().optional(),
15864
+ /** Explicit profile; else the resolution chain (spec §3). */
15865
+ profileId: string().optional(),
15866
+ /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
15867
+ consumer: string(),
15868
+ system: string().optional(),
15869
+ /** v1: single-turn. `messages[]` is a v2 additive field. */
15870
+ prompt: string(),
15871
+ /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
15872
+ jsonSchema: record(string(), unknown()).optional(),
15873
+ /** Per-call override of the profile default. */
15874
+ maxTokens: number().int().positive().optional(),
15875
+ temperature: number().optional()
15273
15876
  });
15274
- var SystemResourceSnapshotSchema = object({
15275
- cpu: CpuBreakdownSchema,
15276
- memory: MemoryInfoSchema,
15277
- gpu: MetricsGpuInfoSchema.nullable(),
15278
- network: NetworkIoSnapshotSchema,
15279
- disk: DiskIoSnapshotSchema,
15280
- pressure: object({
15281
- cpu: PressureInfoSchema.nullable(),
15282
- memory: PressureInfoSchema.nullable(),
15283
- io: PressureInfoSchema.nullable()
15877
+ /**
15878
+ * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
15879
+ * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
15880
+ * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
15881
+ * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
15882
+ * this only through the `llm` cap's methods.
15883
+ *
15884
+ * One running llama-server child per node in v1 (models are RAM-heavy).
15885
+ * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
15886
+ * watchdog — operator decision #3).
15887
+ */
15888
+ var ManagedModelRefSchema = discriminatedUnion("kind", [
15889
+ object({
15890
+ kind: literal("catalog"),
15891
+ catalogId: string()
15284
15892
  }),
15285
- process: ProcessResourceInfoSchema,
15286
- cpuTemperature: number().nullable(),
15287
- timestampMs: number()
15288
- });
15289
- var DiskSpaceInfoSchema = object({
15290
- path: string(),
15291
- totalBytes: number(),
15292
- usedBytes: number(),
15293
- availableBytes: number(),
15294
- percent: number()
15295
- });
15296
- var PidResourceStatsSchema = object({
15297
- pid: number(),
15298
- cpu: number(),
15299
- memory: number(),
15300
- /**
15301
- * Private (anonymous) resident bytes — the per-process V8 heap + native
15302
- * allocations NOT shared with other processes (Linux RssAnon). This is the
15303
- * "real" per-runner cost; summing it across runners is meaningful, unlike
15304
- * `memory` (RSS), which double-counts the shared mmap'd framework code.
15305
- * Undefined where /proc is unavailable (e.g. macOS).
15306
- */
15307
- privateBytes: number().optional(),
15308
- /**
15309
- * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
15310
- * code shared copy-on-write across runners. Undefined on macOS.
15311
- */
15312
- sharedBytes: number().optional()
15893
+ object({
15894
+ kind: literal("url"),
15895
+ url: string(),
15896
+ sha256: string().optional()
15897
+ }),
15898
+ object({
15899
+ kind: literal("path"),
15900
+ path: string()
15901
+ })
15902
+ ]);
15903
+ var ManagedRuntimeConfigSchema = object({
15904
+ /** WHERE the runtime lives — hub or any agent. */
15905
+ nodeId: string(),
15906
+ /** Closed for v1; 'ollama' is a v2 candidate. */
15907
+ engine: _enum(["llama-cpp"]),
15908
+ model: ManagedModelRefSchema,
15909
+ contextSize: number().int().default(4096),
15910
+ /** 0 = CPU-only. */
15911
+ gpuLayers: number().int().default(0),
15912
+ /** Default: cpus-2, clamped ≥1 (resolved node-side). */
15913
+ threads: number().int().optional(),
15914
+ /** Concurrent slots. */
15915
+ parallel: number().int().default(1),
15916
+ /** Else lazy: first generate boots it. */
15917
+ autoStart: boolean().default(false),
15918
+ /** 0 = never; frees RAM after quiet periods. */
15919
+ idleStopMinutes: number().int().default(30)
15313
15920
  });
15314
- var AddonInstanceSchema = object({
15315
- addonId: string(),
15921
+ var LlmRuntimeStatusSchema = object({
15922
+ /** Status is ALWAYS node-qualified. */
15316
15923
  nodeId: string(),
15317
- role: _enum(["hub", "worker"]),
15318
- pid: number(),
15319
15924
  state: _enum([
15320
- "starting",
15321
- "running",
15322
- "stopping",
15323
15925
  "stopped",
15324
- "crashed"
15325
- ]),
15326
- uptimeSec: number()
15327
- });
15328
- var NodeProcessSchema = object({
15329
- pid: number(),
15330
- ppid: number(),
15331
- pgid: number(),
15332
- classification: _enum([
15333
- "root",
15334
- "managed",
15335
- "system",
15336
- "ghost"
15926
+ "downloading",
15927
+ "starting",
15928
+ "ready",
15929
+ "crashed",
15930
+ "failed"
15337
15931
  ]),
15338
- /** `$process` addon binding when `managed`, else null. */
15339
- addonId: string().nullable(),
15340
- /** Kernel-reported nodeId when the process is a known agent/worker. */
15341
- nodeId: string().nullable(),
15342
- /** Truncated command line. */
15343
- command: string(),
15344
- cpuPercent: number(),
15345
- memoryRssBytes: number(),
15346
- /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
15347
- uptimeSec: number(),
15348
- /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
15349
- orphaned: boolean()
15932
+ pid: number().optional(),
15933
+ port: number().optional(),
15934
+ modelPath: string().optional(),
15935
+ modelId: string().optional(),
15936
+ downloadProgress: number().min(0).max(1).optional(),
15937
+ lastError: string().optional(),
15938
+ crashesInWindow: number(),
15939
+ /** Child RSS (sampled best-effort). */
15940
+ memoryBytes: number().optional(),
15941
+ vramBytes: number().optional()
15350
15942
  });
15351
- var KillProcessInputSchema = object({
15352
- pid: number(),
15353
- /** Force = SIGKILL. Default is SIGTERM. */
15354
- force: boolean().optional()
15943
+ var LlmNodeModelSchema = object({
15944
+ file: string(),
15945
+ sizeBytes: number(),
15946
+ catalogId: string().optional(),
15947
+ installedAt: number().optional()
15355
15948
  });
15356
- var KillProcessResultSchema = object({
15357
- success: boolean(),
15358
- reason: string().optional(),
15359
- signal: _enum(["SIGTERM", "SIGKILL"]).optional()
15949
+ var LlmRuntimeDiskUsageSchema = object({
15950
+ nodeId: string(),
15951
+ modelsBytes: number(),
15952
+ freeBytes: number().optional()
15360
15953
  });
15361
- var DumpHeapSnapshotInputSchema = object({
15362
- /** The addon whose runner should dump a heap snapshot. */
15363
- addonId: string() });
15364
- var DumpHeapSnapshotResultSchema = object({
15365
- success: boolean(),
15366
- /** Path of the written .heapsnapshot inside the runner's container/host. */
15367
- path: string().optional(),
15368
- /** Process pid that was signalled. */
15369
- pid: number().optional(),
15370
- reason: string().optional()
15371
- });
15372
- var SystemMetricsSchema = object({
15373
- cpuPercent: number(),
15374
- memoryPercent: number(),
15375
- memoryUsedMB: number(),
15376
- memoryTotalMB: number(),
15377
- diskPercent: number().optional(),
15378
- temperature: number().optional(),
15379
- gpuPercent: number().optional(),
15380
- gpuMemoryPercent: number().optional()
15381
- });
15382
- 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, {
15954
+ method(LlmGenerateBaseInputSchema.extend({
15955
+ images: array(LlmImageSchema).optional(),
15956
+ runtime: ManagedRuntimeConfigSchema,
15957
+ /** The managed profile's timeout, threaded by the hub provider. */
15958
+ timeoutMs: number().int().positive().optional()
15959
+ }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
15383
15960
  kind: "mutation",
15384
15961
  auth: "admin"
15385
- }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
15962
+ }), method(object({}), _void(), {
15386
15963
  kind: "mutation",
15387
15964
  auth: "admin"
15388
- });
15389
- method(object({
15390
- sourceUrl: string(),
15391
- metadata: ModelConvertMetadataSchema,
15392
- targets: array(ConvertTargetSchema).min(1).readonly(),
15393
- calibrationRef: string().optional(),
15394
- sessionId: string().optional()
15395
- }), ConvertResultSchema, {
15965
+ }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
15396
15966
  kind: "mutation",
15397
- auth: "admin",
15398
- timeoutMs: 6e5
15399
- });
15400
- method(object({
15401
- nodeId: string(),
15402
- modelId: string(),
15403
- format: _enum(MODEL_FORMATS),
15404
- entry: ModelCatalogEntrySchema
15405
- }), object({
15406
- ok: boolean(),
15407
- /** sha256 of the staged tarball (empty for a hub-local no-op). */
15408
- sha256: string(),
15409
- bytes: number(),
15410
- /** The target node's modelsDir the artifact landed in. */
15411
- path: string()
15412
- }), {
15967
+ auth: "admin"
15968
+ }), method(object({ file: string() }), _void(), {
15413
15969
  kind: "mutation",
15414
15970
  auth: "admin"
15415
- });
15416
- /**
15417
- * `mqtt-broker` — broker-registry cap.
15418
- *
15419
- * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
15420
- * MQTT brokers (external + optionally an embedded `aedes`-backed one)
15421
- * and (b) the connection details a consumer addon needs to spin up
15422
- * its OWN `mqtt.js` client.
15423
- *
15424
- * Why: pub/sub routing over the system event-bus loses fidelity
15425
- * (callback shape, QoS guarantees, will/retain semantics) and adds
15426
- * refcount bookkeeping that addons would rather own themselves. The
15427
- * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
15428
- * features anyway — give it the connection config, get out of the way.
15429
- *
15430
- * Consumer flow:
15431
- * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
15432
- * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
15433
- * client.subscribe('zigbee2mqtt/+')
15434
- *
15435
- * Collection mode: multiple brokers (e.g. one local mosquitto + one
15436
- * cloud bridge). The "embedded" entry (when present) is just another
15437
- * broker in the registry — its lifecycle is owned by the addon that
15438
- * spawned it.
15439
- */
15440
- var BrokerKindSchema = _enum(["external", "embedded"]);
15971
+ }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
15441
15972
  /**
15442
- * Broker live-probe status.
15973
+ * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
15974
+ * methods concat-fan across providers; single-row methods route to ONE
15975
+ * provider by the `addonId` in the call input (the notification-output
15976
+ * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
15977
+ * (hub-placed); the cap stays open for future providers.
15443
15978
  *
15444
- * - `connected` last probe completed a clean CONNACK
15445
- * - `disconnected` — no probe has run yet (cold cache)
15446
- * - `auth-failed` CONNACK refused with auth error (RC 4 / 5)
15447
- * - `unreachable` — TCP connect timed out / refused
15448
- * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
15979
+ * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
15980
+ * `apiKey` is a password field providers REDACT it on read and merge on
15981
+ * write; a stored key NEVER round-trips to a client.
15449
15982
  */
15450
- var BrokerStatusSchema$1 = _enum([
15451
- "connected",
15452
- "disconnected",
15453
- "auth-failed",
15454
- "unreachable",
15455
- "tls-error"
15983
+ var LlmProfileKindSchema = _enum([
15984
+ "openai-compatible",
15985
+ "openai",
15986
+ "anthropic",
15987
+ "google",
15988
+ "managed-local"
15456
15989
  ]);
15457
- var BrokerInfoSchema = object({
15990
+ var LlmProfileSchema = object({
15458
15991
  id: string(),
15459
15992
  name: string(),
15460
- url: string(),
15461
- kind: BrokerKindSchema,
15462
- status: BrokerStatusSchema$1,
15463
- latencyMs: number().nullable(),
15464
- error: string().optional(),
15465
- /** Embedded brokers only: number of MQTT clients currently connected. */
15466
- connectedClients: number().int().nonnegative().optional(),
15467
- /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
15468
- lastCheckedAt: number().optional()
15993
+ kind: LlmProfileKindSchema,
15994
+ /** Stamped by the provider — keeps the fanned catalog routable. */
15995
+ addonId: string(),
15996
+ enabled: boolean(),
15997
+ /** Vendor model id, or the managed runtime's loaded model. */
15998
+ model: string(),
15999
+ /** Required for openai-compatible; override for cloud kinds. */
16000
+ baseUrl: string().optional(),
16001
+ /** ConfigUISchema type:'password' — never round-trips (spec §5). */
16002
+ apiKey: string().optional(),
16003
+ supportsVision: boolean(),
16004
+ temperature: number().min(0).max(2).optional(),
16005
+ maxTokens: number().int().positive().optional(),
16006
+ timeoutMs: number().int().positive().default(6e4),
16007
+ extraHeaders: record(string(), string()).optional(),
16008
+ /** kind === 'managed-local' only (spec §4). */
16009
+ runtime: ManagedRuntimeConfigSchema.optional()
15469
16010
  });
15470
- /**
15471
- * Connection details — what a consumer needs to call
15472
- * `mqtt.connect(url, options)`. We split URL + credentials so the
15473
- * consumer can pass them as `mqtt.connect(url, { username, password })`
15474
- * instead of stuffing creds into the URL (which leaks them into logs).
15475
- */
15476
- var BrokerConnectionDetailsSchema = object({
15477
- url: string(),
15478
- username: string().optional(),
15479
- password: string().optional(),
15480
- /**
15481
- * Suggested prefix for `clientId`. Each consumer should suffix this
15482
- * with its own discriminator (addon id, instance id) so reconnects
15483
- * don't kick each other off (MQTT spec: clientId must be unique per
15484
- * broker).
15485
- */
15486
- clientIdPrefix: string().optional()
16011
+ /** ConfigUISchema tree passed through untyped on the wire (the
16012
+ * notification-output `ConfigSchemaPassthrough` precedent at
16013
+ * notification-output.cap.ts:151); the exported TS type re-tightens it. */
16014
+ var ConfigSchemaPassthrough$1 = unknown();
16015
+ var LlmProfileKindDescriptorSchema = object({
16016
+ kind: LlmProfileKindSchema,
16017
+ label: string(),
16018
+ icon: string(),
16019
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
16020
+ addonId: string(),
16021
+ configSchema: ConfigSchemaPassthrough$1
15487
16022
  });
15488
- var AddBrokerInputSchema = object({
15489
- name: string().min(1),
15490
- url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
15491
- username: string().optional(),
15492
- password: string().optional(),
15493
- clientIdPrefix: string().optional()
16023
+ var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
16024
+ var LlmDefaultSchema = object({
16025
+ selector: LlmDefaultSelectorSchema,
16026
+ profileId: string()
15494
16027
  });
15495
- var AddBrokerResultSchema = object({ id: string() });
15496
- var IdInputSchema = object({ id: string() });
15497
- var TestResultSchema$1 = discriminatedUnion("ok", [object({
15498
- ok: literal(true),
15499
- latencyMs: number()
15500
- }), object({
15501
- ok: literal(false),
15502
- error: string()
15503
- })]);
15504
- var StartEmbeddedInputSchema = object({
15505
- port: number().int().min(1).max(65535).default(1883),
15506
- /** Allow anonymous connect (no username/password). Default: false. */
15507
- allowAnonymous: boolean().default(false),
15508
- /** Optional shared username/password for clients. */
15509
- username: string().optional(),
15510
- password: string().optional()
16028
+ /** Server-side rollup row getUsage never dumps raw call rows (spec §6). */
16029
+ var LlmUsageRollupSchema = object({
16030
+ day: string(),
16031
+ consumer: string(),
16032
+ profileId: string(),
16033
+ calls: number(),
16034
+ okCalls: number(),
16035
+ errorCalls: number(),
16036
+ inputTokens: number(),
16037
+ outputTokens: number(),
16038
+ avgLatencyMs: number()
15511
16039
  });
15512
- var StartEmbeddedResultSchema = object({
16040
+ /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
16041
+ var ManagedModelCatalogEntrySchema = object({
15513
16042
  id: string(),
15514
- url: string()
15515
- });
15516
- var StatusSchema = object({
15517
- brokerCount: number(),
15518
- embeddedRunning: boolean()
15519
- });
15520
- 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);
15521
- var NetworkEndpointSchema = object({
16043
+ label: string(),
16044
+ family: string(),
16045
+ purpose: _enum(["text", "vision"]),
15522
16046
  url: string(),
15523
- hostname: string(),
15524
- port: number(),
15525
- protocol: _enum(["http", "https"])
16047
+ sha256: string(),
16048
+ sizeBytes: number(),
16049
+ quantization: string(),
16050
+ /** Load-time guidance shown in the picker. */
16051
+ minRamBytes: number(),
16052
+ contextSizeDefault: number().int(),
16053
+ /** Vision models: companion projector file. */
16054
+ mmprojUrl: string().optional()
15526
16055
  });
15527
- var NetworkAccessStatusSchema = object({
15528
- connected: boolean(),
15529
- endpoint: NetworkEndpointSchema.nullable(),
16056
+ var LlmRuntimeNodeSchema = object({
16057
+ nodeId: string(),
16058
+ reachable: boolean(),
16059
+ status: LlmRuntimeStatusSchema.optional(),
16060
+ disk: LlmRuntimeDiskUsageSchema.optional(),
15530
16061
  error: string().optional()
15531
16062
  });
15532
- /**
15533
- * Optional, richer endpoint shape returned by providers that expose
15534
- * MORE than one ingress concurrently (Tailscale Ingress with mixed
15535
- * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
15536
- * the originating provider config (mode + sourcePort) so the
15537
- * orchestrator UI can label rows distinctly. Providers that expose only
15538
- * one endpoint just omit `listEndpoints` from their provider impl.
15539
- */
15540
- var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
15541
- /**
15542
- * Stable id within the provider — typically `<mode>-<sourcePort>` so
15543
- * the orchestrator can dedupe across `listEndpoints` polls.
15544
- */
15545
- id: string(),
15546
- /** Operator-facing label (mirrors `MeshEndpoint.label`). */
15547
- label: string(),
15548
- /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
15549
- mode: string().optional(),
15550
- /** Originating local port the ingress fronts (informational). */
15551
- sourcePort: number().optional()
15552
- });
15553
- method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
15554
- /**
15555
- * notification-output — canonical, capability-gated notification delivery.
16063
+ var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
16064
+ var ProfileRefInputSchema = object({
16065
+ addonId: string(),
16066
+ profileId: string()
16067
+ });
16068
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
16069
+ kind: "mutation",
16070
+ auth: "admin"
16071
+ }), method(ProfileRefInputSchema, _void(), {
16072
+ kind: "mutation",
16073
+ auth: "admin"
16074
+ }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
16075
+ kind: "mutation",
16076
+ auth: "admin"
16077
+ }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
16078
+ selector: LlmDefaultSelectorSchema,
16079
+ profileId: string().nullable()
16080
+ }), _void(), {
16081
+ kind: "mutation",
16082
+ auth: "admin"
16083
+ }), method(object({
16084
+ since: number().optional(),
16085
+ until: number().optional(),
16086
+ consumer: string().optional(),
16087
+ profileId: string().optional()
16088
+ }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
16089
+ nodeId: string(),
16090
+ model: ManagedModelRefSchema
16091
+ }), _void(), {
16092
+ kind: "mutation",
16093
+ auth: "admin"
16094
+ }), method(object({
16095
+ nodeId: string(),
16096
+ file: string()
16097
+ }), _void(), {
16098
+ kind: "mutation",
16099
+ auth: "admin"
16100
+ }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
16101
+ kind: "mutation",
16102
+ auth: "admin"
16103
+ }), method(ProfileRefInputSchema, _void(), {
16104
+ kind: "mutation",
16105
+ auth: "admin"
16106
+ });
16107
+ var LogLevelSchema = _enum([
16108
+ "debug",
16109
+ "info",
16110
+ "warn",
16111
+ "error"
16112
+ ]);
16113
+ var LogEntrySchema = object({
16114
+ timestamp: date(),
16115
+ level: LogLevelSchema,
16116
+ scope: array(string()),
16117
+ message: string(),
16118
+ meta: record(string(), unknown()).optional(),
16119
+ tags: record(string(), string()).optional()
16120
+ });
16121
+ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16122
+ scope: array(string()).optional(),
16123
+ level: LogLevelSchema.optional(),
16124
+ since: date().optional(),
16125
+ until: date().optional(),
16126
+ limit: number().optional(),
16127
+ tags: record(string(), string()).optional()
16128
+ }), array(LogEntrySchema).readonly());
16129
+ /**
16130
+ * `login-method` — collection cap through which auth addons contribute
16131
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
16132
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
16133
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
16134
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
16135
+ * procedure aggregates them for the unauthenticated login page.
15556
16136
  *
15557
- * Apprise-derived model (see
15558
- * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
15559
- * callers emit ONE canonical `Notification`; each provider declares a
15560
- * per-kind capability descriptor (`TargetKind`), and the pure degrade
15561
- * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
15562
- * message to what the kind supports — callers never special-case a service.
16137
+ * A contribution is a discriminated union on `kind`:
15563
16138
  *
15564
- * DESIGN DECISIONS (locked):
15565
- * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
15566
- * `setTargetEnabled`), each provider persisting via the `settings-store`
15567
- * cap. Rationale: the admin UI needs one uniform surface across the
15568
- * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
15569
- * alternative would fork the UI per addon and cannot host the
15570
- * discovery→adopt flow.
15571
- * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
15572
- * the generated cap-mount auto-`concatCollection`-fans them across every
15573
- * registered provider (notifiers addon + HA addon) so one catalog is
15574
- * routable. `send` / `testTarget` / CRUD route to ONE provider by the
15575
- * `addonId` the generated collection router extracts from the call input.
15576
- * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
15577
- * transformer) + UDS MsgPack both round-trip typed arrays — already used by
15578
- * `storage` / `storage-provider` / `recording` caps over the same path. No
15579
- * base64 fallback needed.
16139
+ * - `redirect` a declarative button. The login page renders a generic
16140
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
16141
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
16142
+ * ZERO shell-side JS. A future SSO addon plugs in the same way the
16143
+ * login page needs NO change.
15580
16144
  *
15581
- * TODO (deferred, closed-set change separate decision): add
15582
- * `providerKind: 'notify'` so notification providers surface on the unified
15583
- * admin "Integrations" page.
15584
- */
15585
- /**
15586
- * Zentik-derived typed-media enum — the superset across every kind. Each
15587
- * adapter picks what it supports and the degrade engine filters the rest.
15588
- */
15589
- var AttachmentMediaTypeSchema = _enum([
15590
- "image",
15591
- "video",
15592
- "gif",
15593
- "audio",
15594
- "icon"
15595
- ]);
15596
- /**
15597
- * A single attachment. Exactly one of `url` (remote source, most adapters
15598
- * prefer this) or `bytes` (inline source; required for Pushover-style
15599
- * bytes-only kinds) MUST be present the degrade engine expresses a
15600
- * url→bytes fetch as a `needsFetch` directive the adapter executes.
16145
+ * - `widget` a Module-Federation widget the login page mounts (via
16146
+ * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
16147
+ * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
16148
+ * mechanism kept for future use; no shipped addon uses it on the login
16149
+ * page (the passkey ceremony below runs natively in the shell instead).
16150
+ *
16151
+ * - `passkey` a declarative WebAuthn ceremony the shell renders
16152
+ * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
16153
+ * a remotely-loaded bundle). Carries the addon's effective `rpId` /
16154
+ * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
16155
+ * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
16156
+ * fetching any remote code pre-auth. Contribution stays unconditional —
16157
+ * enrollment state is never leaked pre-auth; visibility is a shell
16158
+ * decision.
16159
+ *
16160
+ * Every contribution carries a `stage`:
16161
+ * - `primary` — shown on the first credentials screen (OIDC /
16162
+ * magic-link buttons; a future usernameless passkey).
16163
+ * - `second-factor` — shown AFTER the password leg, gated on the
16164
+ * returned `factors` (passkey-as-2FA today).
16165
+ *
16166
+ * `mount: skip` — the cap is read server-side by the core auth router
16167
+ * (`registry.getCollection('login-method')`), never mounted as its own
16168
+ * tRPC router.
15601
16169
  */
15602
- var AttachmentSchema = object({
15603
- mediaType: AttachmentMediaTypeSchema,
15604
- url: string().optional(),
15605
- bytes: _instanceof(Uint8Array).optional(),
15606
- mime: string().optional(),
15607
- name: string().optional()
15608
- }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
15609
- var NotificationFormatSchema = _enum([
15610
- "text",
15611
- "markdown",
15612
- "html"
16170
+ /** When a login method renders in the two-phase login flow. */
16171
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
16172
+ /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
16173
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [
16174
+ object({
16175
+ kind: literal("redirect"),
16176
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
16177
+ id: string(),
16178
+ /** Operator-facing button label. */
16179
+ label: string(),
16180
+ /** lucide-react icon name. */
16181
+ icon: string().optional(),
16182
+ /** Addon-owned HTTP route the button navigates to (GET). */
16183
+ startUrl: string(),
16184
+ stage: LoginStageEnum
16185
+ }),
16186
+ object({
16187
+ kind: literal("widget"),
16188
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
16189
+ id: string(),
16190
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
16191
+ addonId: string(),
16192
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
16193
+ bundle: string(),
16194
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
16195
+ remote: WidgetRemoteSchema,
16196
+ stage: LoginStageEnum
16197
+ }),
16198
+ object({
16199
+ kind: literal("passkey"),
16200
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
16201
+ id: string(),
16202
+ /** Operator-facing button label. */
16203
+ label: string(),
16204
+ stage: LoginStageEnum,
16205
+ /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
16206
+ rpId: string(),
16207
+ /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
16208
+ origin: string().nullable()
16209
+ })
15613
16210
  ]);
15614
- /** A single tap-through action button. */
15615
- var NotificationActionSchema = object({
15616
- id: string(),
15617
- label: string(),
15618
- url: string().optional()
16211
+ method(_void(), array(LoginMethodContributionSchema).readonly());
16212
+ var CpuBreakdownSchema = object({
16213
+ total: number(),
16214
+ user: number(),
16215
+ system: number(),
16216
+ irq: number(),
16217
+ nice: number(),
16218
+ loadAvg: tuple([
16219
+ number(),
16220
+ number(),
16221
+ number()
16222
+ ]),
16223
+ cores: number()
15619
16224
  });
15620
- /**
15621
- * The canonical notification. `body` is the only hard field (Apprise model).
15622
- * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
15623
- * NOT a fixed severity enum — each kind declares its own `caps.levels` and
15624
- * the adapter maps this ordinal onto its native level. `level?` is an
15625
- * optional kind-native level id (`emergency`, `silent`, …) that overrides
15626
- * `priority` for that one target.
15627
- */
15628
- var NotificationSchema = object({
15629
- body: string(),
15630
- title: string().optional(),
15631
- format: NotificationFormatSchema.default("text"),
15632
- priority: number().int().min(1).max(5).default(3),
15633
- level: string().optional(),
15634
- attachments: array(AttachmentSchema).optional(),
15635
- clickUrl: string().optional(),
15636
- actions: array(NotificationActionSchema).optional(),
15637
- sound: string().optional(),
15638
- ttl: number().optional(),
15639
- tag: string().optional(),
15640
- deviceId: number().optional(),
15641
- eventId: string().optional(),
15642
- metadata: record(string(), unknown()).optional()
16225
+ var MemoryInfoSchema = object({
16226
+ percent: number(),
16227
+ totalBytes: number(),
16228
+ usedBytes: number(),
16229
+ availableBytes: number(),
16230
+ swapUsedBytes: number(),
16231
+ swapTotalBytes: number()
16232
+ });
16233
+ var DiskIoSnapshotSchema = object({
16234
+ readBytes: number(),
16235
+ writeBytes: number(),
16236
+ readOps: number(),
16237
+ writeOps: number(),
16238
+ timestampMs: number()
16239
+ });
16240
+ var NetworkIoSnapshotSchema = object({
16241
+ rxBytes: number(),
16242
+ txBytes: number(),
16243
+ rxPackets: number(),
16244
+ txPackets: number(),
16245
+ rxErrors: number(),
16246
+ txErrors: number(),
16247
+ timestampMs: number()
16248
+ });
16249
+ var MetricsGpuInfoSchema = object({
16250
+ utilization: number(),
16251
+ model: string(),
16252
+ memoryUsedBytes: number(),
16253
+ memoryTotalBytes: number(),
16254
+ temperature: number().nullable()
16255
+ });
16256
+ var ProcessResourceInfoSchema = object({
16257
+ openFds: number(),
16258
+ threadCount: number(),
16259
+ activeHandles: number(),
16260
+ activeRequests: number()
15643
16261
  });
15644
- /** One declared native severity/priority level for a kind. */
15645
- var TargetKindLevelSchema = object({
15646
- id: string(),
15647
- label: string(),
15648
- /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
15649
- ordinal: number().int().min(1).max(5).nullable(),
15650
- flags: object({
15651
- critical: boolean().optional(),
15652
- silent: boolean().optional(),
15653
- noPush: boolean().optional()
15654
- }).optional(),
15655
- /** e.g. Pushover `emergency` requires `retry` / `expire`. */
15656
- requires: array(string()).optional(),
15657
- description: string().optional()
16262
+ var PressureAvgsSchema = object({
16263
+ avg10: number(),
16264
+ avg60: number(),
16265
+ avg300: number()
15658
16266
  });
15659
- /** The full capability block consulted before dispatch. */
15660
- var TargetKindCapsSchema = object({
15661
- attachments: object({
15662
- mediaTypes: array(AttachmentMediaTypeSchema),
15663
- mode: _enum([
15664
- "url",
15665
- "bytes",
15666
- "both"
15667
- ]),
15668
- max: number().int().nonnegative(),
15669
- maxBytes: number().int().positive().optional()
16267
+ var PressureInfoSchema = object({
16268
+ some: PressureAvgsSchema,
16269
+ full: PressureAvgsSchema.nullable()
16270
+ });
16271
+ var SystemResourceSnapshotSchema = object({
16272
+ cpu: CpuBreakdownSchema,
16273
+ memory: MemoryInfoSchema,
16274
+ gpu: MetricsGpuInfoSchema.nullable(),
16275
+ network: NetworkIoSnapshotSchema,
16276
+ disk: DiskIoSnapshotSchema,
16277
+ pressure: object({
16278
+ cpu: PressureInfoSchema.nullable(),
16279
+ memory: PressureInfoSchema.nullable(),
16280
+ io: PressureInfoSchema.nullable()
15670
16281
  }),
15671
- /** Max action buttons (0 = none). */
15672
- actions: number().int().nonnegative(),
15673
- levels: array(TargetKindLevelSchema),
15674
- format: array(NotificationFormatSchema),
15675
- clickUrl: boolean(),
15676
- sound: boolean(),
15677
- ttl: boolean(),
15678
- bodyMaxLen: number().int().positive()
16282
+ process: ProcessResourceInfoSchema,
16283
+ cpuTemperature: number().nullable(),
16284
+ timestampMs: number()
15679
16285
  });
15680
- /**
15681
- * `configSchema` is a `ConfigUISchema` tree passed through to the admin
15682
- * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
15683
- * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`)
15684
- * the union is large and not meant for runtime validation here; the exported
15685
- * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
15686
- */
15687
- var ConfigSchemaPassthrough$1 = unknown();
15688
- var TargetKindSchema = object({
15689
- kind: string(),
15690
- label: string(),
15691
- icon: string(),
15692
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
15693
- addonId: string(),
15694
- configSchema: ConfigSchemaPassthrough$1,
15695
- supportsDiscovery: boolean(),
15696
- caps: TargetKindCapsSchema
16286
+ var DiskSpaceInfoSchema = object({
16287
+ path: string(),
16288
+ totalBytes: number(),
16289
+ usedBytes: number(),
16290
+ availableBytes: number(),
16291
+ percent: number()
15697
16292
  });
15698
- /**
15699
- * A persisted target. `config` holds secrets; providers REDACT secret fields
15700
- * (return a presence marker only) when serving `listTargets` — never
15701
- * round-trip a stored secret to the UI.
15702
- */
15703
- var TargetSchema = object({
15704
- id: string(),
15705
- name: string(),
15706
- kind: string(),
16293
+ var PidResourceStatsSchema = object({
16294
+ pid: number(),
16295
+ cpu: number(),
16296
+ memory: number(),
16297
+ /**
16298
+ * Private (anonymous) resident bytes — the per-process V8 heap + native
16299
+ * allocations NOT shared with other processes (Linux RssAnon). This is the
16300
+ * "real" per-runner cost; summing it across runners is meaningful, unlike
16301
+ * `memory` (RSS), which double-counts the shared mmap'd framework code.
16302
+ * Undefined where /proc is unavailable (e.g. macOS).
16303
+ */
16304
+ privateBytes: number().optional(),
16305
+ /**
16306
+ * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
16307
+ * code shared copy-on-write across runners. Undefined on macOS.
16308
+ */
16309
+ sharedBytes: number().optional()
16310
+ });
16311
+ var AddonInstanceSchema = object({
15707
16312
  addonId: string(),
15708
- enabled: boolean(),
15709
- config: record(string(), unknown())
16313
+ nodeId: string(),
16314
+ role: _enum(["hub", "worker"]),
16315
+ pid: number(),
16316
+ state: _enum([
16317
+ "starting",
16318
+ "running",
16319
+ "stopping",
16320
+ "stopped",
16321
+ "crashed"
16322
+ ]),
16323
+ uptimeSec: number()
15710
16324
  });
15711
- /** A discovery-surfaced candidate (config is partial + non-secret). */
15712
- var DiscoveredTargetSchema = object({
15713
- kind: string(),
15714
- suggestedName: string(),
15715
- config: record(string(), unknown())
16325
+ var NodeProcessSchema = object({
16326
+ pid: number(),
16327
+ ppid: number(),
16328
+ pgid: number(),
16329
+ classification: _enum([
16330
+ "root",
16331
+ "managed",
16332
+ "system",
16333
+ "ghost"
16334
+ ]),
16335
+ /** `$process` addon binding when `managed`, else null. */
16336
+ addonId: string().nullable(),
16337
+ /** Kernel-reported nodeId when the process is a known agent/worker. */
16338
+ nodeId: string().nullable(),
16339
+ /** Truncated command line. */
16340
+ command: string(),
16341
+ cpuPercent: number(),
16342
+ memoryRssBytes: number(),
16343
+ /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
16344
+ uptimeSec: number(),
16345
+ /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
16346
+ orphaned: boolean()
15716
16347
  });
15717
- /** The degrade engine's report — what was resolved / dropped / degraded. */
15718
- var RenderedAsSchema = object({
15719
- level: string(),
15720
- format: NotificationFormatSchema,
15721
- attachmentsSent: number().int().nonnegative(),
15722
- actionsSent: number().int().nonnegative(),
15723
- truncated: boolean(),
15724
- dropped: array(string())
16348
+ var KillProcessInputSchema = object({
16349
+ pid: number(),
16350
+ /** Force = SIGKILL. Default is SIGTERM. */
16351
+ force: boolean().optional()
15725
16352
  });
15726
- var SendResultSchema = object({
16353
+ var KillProcessResultSchema = object({
16354
+ success: boolean(),
16355
+ reason: string().optional(),
16356
+ signal: _enum(["SIGTERM", "SIGKILL"]).optional()
16357
+ });
16358
+ var DumpHeapSnapshotInputSchema = object({
16359
+ /** The addon whose runner should dump a heap snapshot. */
16360
+ addonId: string() });
16361
+ var DumpHeapSnapshotResultSchema = object({
15727
16362
  success: boolean(),
16363
+ /** Path of the written .heapsnapshot inside the runner's container/host. */
16364
+ path: string().optional(),
16365
+ /** Process pid that was signalled. */
16366
+ pid: number().optional(),
16367
+ reason: string().optional()
16368
+ });
16369
+ var SystemMetricsSchema = object({
16370
+ cpuPercent: number(),
16371
+ memoryPercent: number(),
16372
+ memoryUsedMB: number(),
16373
+ memoryTotalMB: number(),
16374
+ diskPercent: number().optional(),
16375
+ temperature: number().optional(),
16376
+ gpuPercent: number().optional(),
16377
+ gpuMemoryPercent: number().optional()
16378
+ });
16379
+ 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, {
16380
+ kind: "mutation",
16381
+ auth: "admin"
16382
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
16383
+ kind: "mutation",
16384
+ auth: "admin"
16385
+ });
16386
+ method(object({
16387
+ sourceUrl: string(),
16388
+ metadata: ModelConvertMetadataSchema,
16389
+ targets: array(ConvertTargetSchema).min(1).readonly(),
16390
+ calibrationRef: string().optional(),
16391
+ sessionId: string().optional()
16392
+ }), ConvertResultSchema, {
16393
+ kind: "mutation",
16394
+ auth: "admin",
16395
+ timeoutMs: 6e5
16396
+ });
16397
+ method(object({
16398
+ nodeId: string(),
16399
+ modelId: string(),
16400
+ format: _enum(MODEL_FORMATS),
16401
+ entry: ModelCatalogEntrySchema
16402
+ }), object({
16403
+ ok: boolean(),
16404
+ /** sha256 of the staged tarball (empty for a hub-local no-op). */
16405
+ sha256: string(),
16406
+ bytes: number(),
16407
+ /** The target node's modelsDir the artifact landed in. */
16408
+ path: string()
16409
+ }), {
16410
+ kind: "mutation",
16411
+ auth: "admin"
16412
+ });
16413
+ /**
16414
+ * `mqtt-broker` — broker-registry cap.
16415
+ *
16416
+ * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
16417
+ * MQTT brokers (external + optionally an embedded `aedes`-backed one)
16418
+ * and (b) the connection details a consumer addon needs to spin up
16419
+ * its OWN `mqtt.js` client.
16420
+ *
16421
+ * Why: pub/sub routing over the system event-bus loses fidelity
16422
+ * (callback shape, QoS guarantees, will/retain semantics) and adds
16423
+ * refcount bookkeeping that addons would rather own themselves. The
16424
+ * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
16425
+ * features anyway — give it the connection config, get out of the way.
16426
+ *
16427
+ * Consumer flow:
16428
+ * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
16429
+ * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
16430
+ * client.subscribe('zigbee2mqtt/+')
16431
+ *
16432
+ * Collection mode: multiple brokers (e.g. one local mosquitto + one
16433
+ * cloud bridge). The "embedded" entry (when present) is just another
16434
+ * broker in the registry — its lifecycle is owned by the addon that
16435
+ * spawned it.
16436
+ */
16437
+ var BrokerKindSchema = _enum(["external", "embedded"]);
16438
+ /**
16439
+ * Broker live-probe status.
16440
+ *
16441
+ * - `connected` — last probe completed a clean CONNACK
16442
+ * - `disconnected` — no probe has run yet (cold cache)
16443
+ * - `auth-failed` — CONNACK refused with auth error (RC 4 / 5)
16444
+ * - `unreachable` — TCP connect timed out / refused
16445
+ * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
16446
+ */
16447
+ var BrokerStatusSchema$1 = _enum([
16448
+ "connected",
16449
+ "disconnected",
16450
+ "auth-failed",
16451
+ "unreachable",
16452
+ "tls-error"
16453
+ ]);
16454
+ var BrokerInfoSchema = object({
16455
+ id: string(),
16456
+ name: string(),
16457
+ url: string(),
16458
+ kind: BrokerKindSchema,
16459
+ status: BrokerStatusSchema$1,
16460
+ latencyMs: number().nullable(),
15728
16461
  error: string().optional(),
15729
- renderedAs: RenderedAsSchema.optional()
16462
+ /** Embedded brokers only: number of MQTT clients currently connected. */
16463
+ connectedClients: number().int().nonnegative().optional(),
16464
+ /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
16465
+ lastCheckedAt: number().optional()
15730
16466
  });
15731
- /** Same shape as SendResult — kept as a distinct name for the test panel. */
15732
- var TestResultSchema = SendResultSchema;
15733
- method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
15734
- kind: string(),
15735
- config: record(string(), unknown()).optional()
15736
- }), array(DiscoveredTargetSchema)), method(object({
15737
- targetId: string(),
15738
- notification: NotificationSchema
15739
- }), SendResultSchema, { kind: "mutation" }), method(object({
15740
- targetId: string(),
15741
- sample: NotificationSchema.optional()
15742
- }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
15743
- targetId: string(),
15744
- enabled: boolean()
15745
- }), _void(), { kind: "mutation" });
15746
16467
  /**
15747
- * Shared LLM generate contracts imported by BOTH `llm.cap.ts` (consumer
15748
- * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15749
- * caps stay wire-compatible without a circular cap→cap import.
15750
- *
15751
- * Errors are a discriminated-union RESULT, never thrown: the shape survives
15752
- * every transport tier structurally, and failed calls still write usage rows.
15753
- * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
16468
+ * Connection details what a consumer needs to call
16469
+ * `mqtt.connect(url, options)`. We split URL + credentials so the
16470
+ * consumer can pass them as `mqtt.connect(url, { username, password })`
16471
+ * instead of stuffing creds into the URL (which leaks them into logs).
15754
16472
  */
15755
- var LlmUsageSchema = object({
15756
- inputTokens: number(),
15757
- outputTokens: number()
16473
+ var BrokerConnectionDetailsSchema = object({
16474
+ url: string(),
16475
+ username: string().optional(),
16476
+ password: string().optional(),
16477
+ /**
16478
+ * Suggested prefix for `clientId`. Each consumer should suffix this
16479
+ * with its own discriminator (addon id, instance id) so reconnects
16480
+ * don't kick each other off (MQTT spec: clientId must be unique per
16481
+ * broker).
16482
+ */
16483
+ clientIdPrefix: string().optional()
15758
16484
  });
15759
- var LlmErrorCodeSchema = _enum([
15760
- "timeout",
15761
- "rate-limited",
15762
- "auth",
15763
- "refusal",
15764
- "bad-request",
15765
- "unavailable",
15766
- "no-profile",
15767
- "budget-exceeded",
15768
- "adapter-error"
15769
- ]);
15770
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
16485
+ var AddBrokerInputSchema = object({
16486
+ name: string().min(1),
16487
+ url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
16488
+ username: string().optional(),
16489
+ password: string().optional(),
16490
+ clientIdPrefix: string().optional()
16491
+ });
16492
+ var AddBrokerResultSchema = object({ id: string() });
16493
+ var IdInputSchema = object({ id: string() });
16494
+ var TestResultSchema$1 = discriminatedUnion("ok", [object({
15771
16495
  ok: literal(true),
15772
- text: string(),
15773
- model: string(),
15774
- usage: LlmUsageSchema,
15775
- truncated: boolean(),
15776
16496
  latencyMs: number()
15777
16497
  }), object({
15778
16498
  ok: literal(false),
15779
- code: LlmErrorCodeSchema,
15780
- message: string(),
15781
- retryAfterMs: number().optional()
16499
+ error: string()
15782
16500
  })]);
15783
- /**
15784
- * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
15785
- * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
15786
- * notification-output.cap.ts:27-31 precedents).
15787
- */
15788
- var LlmImageSchema = object({
15789
- bytes: _instanceof(Uint8Array),
15790
- mimeType: string()
16501
+ var StartEmbeddedInputSchema = object({
16502
+ port: number().int().min(1).max(65535).default(1883),
16503
+ /** Allow anonymous connect (no username/password). Default: false. */
16504
+ allowAnonymous: boolean().default(false),
16505
+ /** Optional shared username/password for clients. */
16506
+ username: string().optional(),
16507
+ password: string().optional()
15791
16508
  });
15792
- var LlmGenerateBaseInputSchema = object({
15793
- /** Collection routing (the notification-output posture). */
15794
- addonId: string().optional(),
15795
- /** Explicit profile; else the resolution chain (spec §3). */
15796
- profileId: string().optional(),
15797
- /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
15798
- consumer: string(),
15799
- system: string().optional(),
15800
- /** v1: single-turn. `messages[]` is a v2 additive field. */
15801
- prompt: string(),
15802
- /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
15803
- jsonSchema: record(string(), unknown()).optional(),
15804
- /** Per-call override of the profile default. */
15805
- maxTokens: number().int().positive().optional(),
15806
- temperature: number().optional()
16509
+ var StartEmbeddedResultSchema = object({
16510
+ id: string(),
16511
+ url: string()
15807
16512
  });
15808
- /**
15809
- * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
15810
- * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
15811
- * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
15812
- * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
15813
- * this only through the `llm` cap's methods.
15814
- *
15815
- * One running llama-server child per node in v1 (models are RAM-heavy).
15816
- * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
15817
- * watchdog — operator decision #3).
15818
- */
15819
- var ManagedModelRefSchema = discriminatedUnion("kind", [
15820
- object({
15821
- kind: literal("catalog"),
15822
- catalogId: string()
15823
- }),
15824
- object({
15825
- kind: literal("url"),
15826
- url: string(),
15827
- sha256: string().optional()
15828
- }),
15829
- object({
15830
- kind: literal("path"),
15831
- path: string()
15832
- })
15833
- ]);
15834
- var ManagedRuntimeConfigSchema = object({
15835
- /** WHERE the runtime lives — hub or any agent. */
15836
- nodeId: string(),
15837
- /** Closed for v1; 'ollama' is a v2 candidate. */
15838
- engine: _enum(["llama-cpp"]),
15839
- model: ManagedModelRefSchema,
15840
- contextSize: number().int().default(4096),
15841
- /** 0 = CPU-only. */
15842
- gpuLayers: number().int().default(0),
15843
- /** Default: cpus-2, clamped ≥1 (resolved node-side). */
15844
- threads: number().int().optional(),
15845
- /** Concurrent slots. */
15846
- parallel: number().int().default(1),
15847
- /** Else lazy: first generate boots it. */
15848
- autoStart: boolean().default(false),
15849
- /** 0 = never; frees RAM after quiet periods. */
15850
- idleStopMinutes: number().int().default(30)
16513
+ var StatusSchema = object({
16514
+ brokerCount: number(),
16515
+ embeddedRunning: boolean()
15851
16516
  });
15852
- var LlmRuntimeStatusSchema = object({
15853
- /** Status is ALWAYS node-qualified. */
15854
- nodeId: string(),
15855
- state: _enum([
15856
- "stopped",
15857
- "downloading",
15858
- "starting",
15859
- "ready",
15860
- "crashed",
15861
- "failed"
15862
- ]),
15863
- pid: number().optional(),
15864
- port: number().optional(),
15865
- modelPath: string().optional(),
15866
- modelId: string().optional(),
15867
- downloadProgress: number().min(0).max(1).optional(),
15868
- lastError: string().optional(),
15869
- crashesInWindow: number(),
15870
- /** Child RSS (sampled best-effort). */
15871
- memoryBytes: number().optional(),
15872
- vramBytes: number().optional()
16517
+ 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);
16518
+ var NetworkEndpointSchema = object({
16519
+ url: string(),
16520
+ hostname: string(),
16521
+ port: number(),
16522
+ protocol: _enum(["http", "https"])
15873
16523
  });
15874
- var LlmNodeModelSchema = object({
15875
- file: string(),
15876
- sizeBytes: number(),
15877
- catalogId: string().optional(),
15878
- installedAt: number().optional()
16524
+ var NetworkAccessStatusSchema = object({
16525
+ connected: boolean(),
16526
+ endpoint: NetworkEndpointSchema.nullable(),
16527
+ error: string().optional()
15879
16528
  });
15880
- var LlmRuntimeDiskUsageSchema = object({
15881
- nodeId: string(),
15882
- modelsBytes: number(),
15883
- freeBytes: number().optional()
16529
+ /**
16530
+ * Optional, richer endpoint shape returned by providers that expose
16531
+ * MORE than one ingress concurrently (Tailscale Ingress with mixed
16532
+ * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
16533
+ * the originating provider config (mode + sourcePort) so the
16534
+ * orchestrator UI can label rows distinctly. Providers that expose only
16535
+ * one endpoint just omit `listEndpoints` from their provider impl.
16536
+ */
16537
+ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
16538
+ /**
16539
+ * Stable id within the provider — typically `<mode>-<sourcePort>` so
16540
+ * the orchestrator can dedupe across `listEndpoints` polls.
16541
+ */
16542
+ id: string(),
16543
+ /** Operator-facing label (mirrors `MeshEndpoint.label`). */
16544
+ label: string(),
16545
+ /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
16546
+ mode: string().optional(),
16547
+ /** Originating local port the ingress fronts (informational). */
16548
+ sourcePort: number().optional()
15884
16549
  });
15885
- method(LlmGenerateBaseInputSchema.extend({
15886
- images: array(LlmImageSchema).optional(),
15887
- runtime: ManagedRuntimeConfigSchema,
15888
- /** The managed profile's timeout, threaded by the hub provider. */
15889
- timeoutMs: number().int().positive().optional()
15890
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
15891
- kind: "mutation",
15892
- auth: "admin"
15893
- }), method(object({}), _void(), {
15894
- kind: "mutation",
15895
- auth: "admin"
15896
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
15897
- kind: "mutation",
15898
- auth: "admin"
15899
- }), method(object({ file: string() }), _void(), {
15900
- kind: "mutation",
15901
- auth: "admin"
15902
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
16550
+ method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
15903
16551
  /**
15904
- * `llm`consumer-facing LLM surface (spec §1-§3). Collection-mode: array
15905
- * methods concat-fan across providers; single-row methods route to ONE
15906
- * provider by the `addonId` in the call input (the notification-output
15907
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
15908
- * (hub-placed); the cap stays open for future providers.
16552
+ * notification-outputcanonical, capability-gated notification delivery.
16553
+ *
16554
+ * Apprise-derived model (see
16555
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
16556
+ * callers emit ONE canonical `Notification`; each provider declares a
16557
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
16558
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
16559
+ * message to what the kind supports — callers never special-case a service.
16560
+ *
16561
+ * DESIGN DECISIONS (locked):
16562
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
16563
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
16564
+ * cap. Rationale: the admin UI needs one uniform surface across the
16565
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
16566
+ * alternative would fork the UI per addon and cannot host the
16567
+ * discovery→adopt flow.
16568
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
16569
+ * the generated cap-mount auto-`concatCollection`-fans them across every
16570
+ * registered provider (notifiers addon + HA addon) so one catalog is
16571
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
16572
+ * `addonId` the generated collection router extracts from the call input.
16573
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
16574
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
16575
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
16576
+ * base64 fallback needed.
15909
16577
  *
15910
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
15911
- * `apiKey` is a password field — providers REDACT it on read and merge on
15912
- * write; a stored key NEVER round-trips to a client.
16578
+ * TODO (deferred, closed-set change separate decision): add
16579
+ * `providerKind: 'notify'` so notification providers surface on the unified
16580
+ * admin "Integrations" page.
15913
16581
  */
15914
- var LlmProfileKindSchema = _enum([
15915
- "openai-compatible",
15916
- "openai",
15917
- "anthropic",
15918
- "google",
15919
- "managed-local"
16582
+ /**
16583
+ * Zentik-derived typed-media enum — the superset across every kind. Each
16584
+ * adapter picks what it supports and the degrade engine filters the rest.
16585
+ */
16586
+ var AttachmentMediaTypeSchema = _enum([
16587
+ "image",
16588
+ "video",
16589
+ "gif",
16590
+ "audio",
16591
+ "icon"
15920
16592
  ]);
15921
- var LlmProfileSchema = object({
16593
+ /**
16594
+ * A single attachment. Exactly one of `url` (remote source, most adapters
16595
+ * prefer this) or `bytes` (inline source; required for Pushover-style
16596
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
16597
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
16598
+ */
16599
+ var AttachmentSchema = object({
16600
+ mediaType: AttachmentMediaTypeSchema,
16601
+ url: string().optional(),
16602
+ bytes: _instanceof(Uint8Array).optional(),
16603
+ mime: string().optional(),
16604
+ name: string().optional()
16605
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
16606
+ var NotificationFormatSchema = _enum([
16607
+ "text",
16608
+ "markdown",
16609
+ "html"
16610
+ ]);
16611
+ /** A single tap-through action button. */
16612
+ var NotificationActionSchema = object({
15922
16613
  id: string(),
15923
- name: string(),
15924
- kind: LlmProfileKindSchema,
15925
- /** Stamped by the provider — keeps the fanned catalog routable. */
15926
- addonId: string(),
15927
- enabled: boolean(),
15928
- /** Vendor model id, or the managed runtime's loaded model. */
15929
- model: string(),
15930
- /** Required for openai-compatible; override for cloud kinds. */
15931
- baseUrl: string().optional(),
15932
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
15933
- apiKey: string().optional(),
15934
- supportsVision: boolean(),
15935
- temperature: number().min(0).max(2).optional(),
15936
- maxTokens: number().int().positive().optional(),
15937
- timeoutMs: number().int().positive().default(6e4),
15938
- extraHeaders: record(string(), string()).optional(),
15939
- /** kind === 'managed-local' only (spec §4). */
15940
- runtime: ManagedRuntimeConfigSchema.optional()
16614
+ label: string(),
16615
+ url: string().optional()
15941
16616
  });
15942
- /** ConfigUISchema tree passed through untyped on the wire (the
15943
- * notification-output `ConfigSchemaPassthrough` precedent at
15944
- * notification-output.cap.ts:151); the exported TS type re-tightens it. */
16617
+ /**
16618
+ * The canonical notification. `body` is the only hard field (Apprise model).
16619
+ * `priority` is a 5-level ORDINAL (1=lowest 3=normal(default) 5=urgent),
16620
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
16621
+ * the adapter maps this ordinal onto its native level. `level?` is an
16622
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
16623
+ * `priority` for that one target.
16624
+ */
16625
+ var NotificationSchema = object({
16626
+ body: string(),
16627
+ title: string().optional(),
16628
+ format: NotificationFormatSchema.default("text"),
16629
+ priority: number().int().min(1).max(5).default(3),
16630
+ level: string().optional(),
16631
+ attachments: array(AttachmentSchema).optional(),
16632
+ clickUrl: string().optional(),
16633
+ actions: array(NotificationActionSchema).optional(),
16634
+ sound: string().optional(),
16635
+ ttl: number().optional(),
16636
+ tag: string().optional(),
16637
+ deviceId: number().optional(),
16638
+ eventId: string().optional(),
16639
+ metadata: record(string(), unknown()).optional()
16640
+ });
16641
+ /** One declared native severity/priority level for a kind. */
16642
+ var TargetKindLevelSchema = object({
16643
+ id: string(),
16644
+ label: string(),
16645
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
16646
+ ordinal: number().int().min(1).max(5).nullable(),
16647
+ flags: object({
16648
+ critical: boolean().optional(),
16649
+ silent: boolean().optional(),
16650
+ noPush: boolean().optional()
16651
+ }).optional(),
16652
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
16653
+ requires: array(string()).optional(),
16654
+ description: string().optional()
16655
+ });
16656
+ /** The full capability block consulted before dispatch. */
16657
+ var TargetKindCapsSchema = object({
16658
+ attachments: object({
16659
+ mediaTypes: array(AttachmentMediaTypeSchema),
16660
+ mode: _enum([
16661
+ "url",
16662
+ "bytes",
16663
+ "both"
16664
+ ]),
16665
+ max: number().int().nonnegative(),
16666
+ maxBytes: number().int().positive().optional()
16667
+ }),
16668
+ /** Max action buttons (0 = none). */
16669
+ actions: number().int().nonnegative(),
16670
+ levels: array(TargetKindLevelSchema),
16671
+ format: array(NotificationFormatSchema),
16672
+ clickUrl: boolean(),
16673
+ sound: boolean(),
16674
+ ttl: boolean(),
16675
+ bodyMaxLen: number().int().positive()
16676
+ });
16677
+ /**
16678
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
16679
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
16680
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
16681
+ * the union is large and not meant for runtime validation here; the exported
16682
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
16683
+ */
15945
16684
  var ConfigSchemaPassthrough = unknown();
15946
- var LlmProfileKindDescriptorSchema = object({
15947
- kind: LlmProfileKindSchema,
16685
+ var TargetKindSchema = object({
16686
+ kind: string(),
15948
16687
  label: string(),
15949
16688
  icon: string(),
15950
16689
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
15951
16690
  addonId: string(),
15952
- configSchema: ConfigSchemaPassthrough
15953
- });
15954
- var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
15955
- var LlmDefaultSchema = object({
15956
- selector: LlmDefaultSelectorSchema,
15957
- profileId: string()
15958
- });
15959
- /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
15960
- var LlmUsageRollupSchema = object({
15961
- day: string(),
15962
- consumer: string(),
15963
- profileId: string(),
15964
- calls: number(),
15965
- okCalls: number(),
15966
- errorCalls: number(),
15967
- inputTokens: number(),
15968
- outputTokens: number(),
15969
- avgLatencyMs: number()
16691
+ configSchema: ConfigSchemaPassthrough,
16692
+ supportsDiscovery: boolean(),
16693
+ caps: TargetKindCapsSchema
15970
16694
  });
15971
- /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
15972
- var ManagedModelCatalogEntrySchema = object({
16695
+ /**
16696
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
16697
+ * (return a presence marker only) when serving `listTargets` — never
16698
+ * round-trip a stored secret to the UI.
16699
+ */
16700
+ var TargetSchema = object({
15973
16701
  id: string(),
15974
- label: string(),
15975
- family: string(),
15976
- purpose: _enum(["text", "vision"]),
15977
- url: string(),
15978
- sha256: string(),
15979
- sizeBytes: number(),
15980
- quantization: string(),
15981
- /** Load-time guidance shown in the picker. */
15982
- minRamBytes: number(),
15983
- contextSizeDefault: number().int(),
15984
- /** Vision models: companion projector file. */
15985
- mmprojUrl: string().optional()
15986
- });
15987
- var LlmRuntimeNodeSchema = object({
15988
- nodeId: string(),
15989
- reachable: boolean(),
15990
- status: LlmRuntimeStatusSchema.optional(),
15991
- disk: LlmRuntimeDiskUsageSchema.optional(),
15992
- error: string().optional()
15993
- });
15994
- var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
15995
- var ProfileRefInputSchema = object({
16702
+ name: string(),
16703
+ kind: string(),
15996
16704
  addonId: string(),
15997
- profileId: string()
16705
+ enabled: boolean(),
16706
+ config: record(string(), unknown())
15998
16707
  });
15999
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
16000
- kind: "mutation",
16001
- auth: "admin"
16002
- }), method(ProfileRefInputSchema, _void(), {
16003
- kind: "mutation",
16004
- auth: "admin"
16005
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
16006
- kind: "mutation",
16007
- auth: "admin"
16008
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
16009
- selector: LlmDefaultSelectorSchema,
16010
- profileId: string().nullable()
16011
- }), _void(), {
16012
- kind: "mutation",
16013
- auth: "admin"
16014
- }), method(object({
16015
- since: number().optional(),
16016
- until: number().optional(),
16017
- consumer: string().optional(),
16018
- profileId: string().optional()
16019
- }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
16020
- nodeId: string(),
16021
- model: ManagedModelRefSchema
16022
- }), _void(), {
16023
- kind: "mutation",
16024
- auth: "admin"
16025
- }), method(object({
16026
- nodeId: string(),
16027
- file: string()
16028
- }), _void(), {
16029
- kind: "mutation",
16030
- auth: "admin"
16031
- }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
16032
- kind: "mutation",
16033
- auth: "admin"
16034
- }), method(ProfileRefInputSchema, _void(), {
16035
- kind: "mutation",
16036
- auth: "admin"
16708
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
16709
+ var DiscoveredTargetSchema = object({
16710
+ kind: string(),
16711
+ suggestedName: string(),
16712
+ config: record(string(), unknown())
16713
+ });
16714
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
16715
+ var RenderedAsSchema = object({
16716
+ level: string(),
16717
+ format: NotificationFormatSchema,
16718
+ attachmentsSent: number().int().nonnegative(),
16719
+ actionsSent: number().int().nonnegative(),
16720
+ truncated: boolean(),
16721
+ dropped: array(string())
16722
+ });
16723
+ var SendResultSchema = object({
16724
+ success: boolean(),
16725
+ error: string().optional(),
16726
+ renderedAs: RenderedAsSchema.optional()
16037
16727
  });
16728
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
16729
+ var TestResultSchema = SendResultSchema;
16730
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
16731
+ kind: string(),
16732
+ config: record(string(), unknown()).optional()
16733
+ }), array(DiscoveredTargetSchema)), method(object({
16734
+ targetId: string(),
16735
+ notification: NotificationSchema
16736
+ }), SendResultSchema, { kind: "mutation" }), method(object({
16737
+ targetId: string(),
16738
+ sample: NotificationSchema.optional()
16739
+ }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
16740
+ targetId: string(),
16741
+ enabled: boolean()
16742
+ }), _void(), { kind: "mutation" });
16038
16743
  /**
16039
16744
  * Zod schemas for persisted record types.
16040
16745
  *
@@ -16720,7 +17425,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
16720
17425
  }), method(object({
16721
17426
  eventId: string(),
16722
17427
  kind: MediaFileKindEnum.optional()
16723
- }), array(MediaFileSchema).readonly()), method(object({ trackId: string() }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
17428
+ }), array(MediaFileSchema).readonly()), method(object({
17429
+ trackId: string(),
17430
+ kinds: array(MediaFileKindEnum).optional()
17431
+ }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
16724
17432
  deviceId: number(),
16725
17433
  timestamp: number(),
16726
17434
  frameWidth: number(),
@@ -16741,76 +17449,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
16741
17449
  eventId: string(),
16742
17450
  timestamp: number()
16743
17451
  });
16744
- /**
16745
- * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
16746
- * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
16747
- * caps into per-camera event-kind descriptors.
16748
- *
16749
- * The descriptor DATA (color / iconId / labelKey / parentKind / category)
16750
- * is NOT duplicated here — every entry is derived from the single
16751
- * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
16752
- * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
16753
- * control cap means adding one line here (and a taxonomy entry); the anti-
16754
- * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
16755
- * eventful cap is missing.
16756
- */
16757
- /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
16758
- var LEGACY_ICON = {
16759
- motion: "motion",
16760
- audio: "audio",
16761
- person: "person",
16762
- vehicle: "vehicle",
16763
- animal: "animal",
16764
- package: "package",
16765
- door: "door",
16766
- pir: "pir",
16767
- smoke: "smoke",
16768
- water: "water",
16769
- button: "button",
16770
- generic: "generic",
16771
- gas: "smoke",
16772
- vibration: "generic",
16773
- tamper: "generic",
16774
- presence: "person",
16775
- lock: "generic",
16776
- siren: "generic",
16777
- switch: "generic",
16778
- doorbell: "button"
16779
- };
16780
- function legacyIcon(iconId) {
16781
- return LEGACY_ICON[iconId] ?? "generic";
16782
- }
16783
- /**
16784
- * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
16785
- * The anti-drift guard cross-checks this against the eventful caps declared
16786
- * in `packages/types/src/capabilities/*.cap.ts`.
16787
- */
16788
- var CAP_TO_KIND = {
16789
- contact: "contact",
16790
- motion: "motion-sensor",
16791
- smoke: "smoke",
16792
- flood: "flood",
16793
- gas: "gas",
16794
- "carbon-monoxide": "carbon-monoxide",
16795
- vibration: "vibration",
16796
- tamper: "tamper",
16797
- presence: "presence",
16798
- "enum-sensor": "enum-sensor",
16799
- "event-emitter": "device-event",
16800
- "lock-control": "lock",
16801
- switch: "switch",
16802
- button: "button",
16803
- doorbell: "doorbell"
16804
- };
16805
- function buildDescriptor(capName, kind) {
16806
- const t = EVENT_TAXONOMY[kind];
16807
- if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
16808
- return {
16809
- ...t,
16810
- icon: legacyIcon(t.iconId)
16811
- };
16812
- }
16813
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
16814
17452
  var CameraPipelineConfigSchema = object({
16815
17453
  engine: PipelineEngineChoiceSchema.optional(),
16816
17454
  steps: array(PipelineStepInputSchema).readonly(),
@@ -17296,6 +17934,76 @@ method(object({
17296
17934
  auth: "admin"
17297
17935
  });
17298
17936
  /**
17937
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
17938
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
17939
+ * caps into per-camera event-kind descriptors.
17940
+ *
17941
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
17942
+ * is NOT duplicated here — every entry is derived from the single
17943
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
17944
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
17945
+ * control cap means adding one line here (and a taxonomy entry); the anti-
17946
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
17947
+ * eventful cap is missing.
17948
+ */
17949
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
17950
+ var LEGACY_ICON = {
17951
+ motion: "motion",
17952
+ audio: "audio",
17953
+ person: "person",
17954
+ vehicle: "vehicle",
17955
+ animal: "animal",
17956
+ package: "package",
17957
+ door: "door",
17958
+ pir: "pir",
17959
+ smoke: "smoke",
17960
+ water: "water",
17961
+ button: "button",
17962
+ generic: "generic",
17963
+ gas: "smoke",
17964
+ vibration: "generic",
17965
+ tamper: "generic",
17966
+ presence: "person",
17967
+ lock: "generic",
17968
+ siren: "generic",
17969
+ switch: "generic",
17970
+ doorbell: "button"
17971
+ };
17972
+ function legacyIcon(iconId) {
17973
+ return LEGACY_ICON[iconId] ?? "generic";
17974
+ }
17975
+ /**
17976
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
17977
+ * The anti-drift guard cross-checks this against the eventful caps declared
17978
+ * in `packages/types/src/capabilities/*.cap.ts`.
17979
+ */
17980
+ var CAP_TO_KIND = {
17981
+ contact: "contact",
17982
+ motion: "motion-sensor",
17983
+ smoke: "smoke",
17984
+ flood: "flood",
17985
+ gas: "gas",
17986
+ "carbon-monoxide": "carbon-monoxide",
17987
+ vibration: "vibration",
17988
+ tamper: "tamper",
17989
+ presence: "presence",
17990
+ "enum-sensor": "enum-sensor",
17991
+ "event-emitter": "device-event",
17992
+ "lock-control": "lock",
17993
+ switch: "switch",
17994
+ button: "button",
17995
+ doorbell: "doorbell"
17996
+ };
17997
+ function buildDescriptor(capName, kind) {
17998
+ const t = EVENT_TAXONOMY[kind];
17999
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
18000
+ return {
18001
+ ...t,
18002
+ icon: legacyIcon(t.iconId)
18003
+ };
18004
+ }
18005
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
18006
+ /**
17299
18007
  * server-management — per-NODE singleton capability for a node's ROOT
17300
18008
  * package lifecycle (runtime-updatable node packages).
17301
18009
  *
@@ -18750,7 +19458,28 @@ var FaceInfoSchema = object({
18750
19458
  * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`). Absent when the
18751
19459
  * track produced no key frame (e.g. native/onboard source) — the UI falls
18752
19460
  * back to the inline `base64` face crop. */
18753
- keyFrameMediaKey: string().optional()
19461
+ keyFrameMediaKey: string().optional(),
19462
+ /** Winning identity-match cosine (0..1) for this face's track, when an
19463
+ * identity was auto-confirmed. Lets the UI surface WHY a face was assigned
19464
+ * (confidence badge / low-confidence audit). Absent on legacy rows and on
19465
+ * faces that were never auto-recognized. */
19466
+ bestMatchScore: number().optional(),
19467
+ /** Native-scale face short side (px) at recognition time, when the runner
19468
+ * measured it. Lets the UI flag low-resolution auto-assignments. Absent on
19469
+ * legacy rows / runners that reported no native measure. */
19470
+ nativeFaceShortSidePx: number().optional(),
19471
+ /** SUGGESTED identity for this face — a plausible-but-not-confident match that
19472
+ * MISSED auto-assignment (cosine in the suggestion band, or above threshold
19473
+ * but blocked only by the recognition size floor). Mutually exclusive with
19474
+ * `recognizedIdentityId` (a suggestion is NEVER an assignment): the face stays
19475
+ * UNASSIGNED and everything else keeps treating it as unrecognized — the UI
19476
+ * merely offers a one-tap "is this <name>?" confirm. Absent on legacy rows and
19477
+ * on faces that were auto-assigned or below the suggestion band. (2026-07-24) */
19478
+ suggestedIdentityId: string().optional(),
19479
+ /** Peak identity-match cosine (0..1) for `suggestedIdentityId`, captured at the
19480
+ * same moment as `bestMatchScore` (track peak, at close). Lets the UI rank /
19481
+ * badge suggestion confidence. Present iff `suggestedIdentityId` is. (2026-07-24) */
19482
+ suggestedMatchScore: number().optional()
18754
19483
  });
18755
19484
  var FaceFilterEnum = _enum([
18756
19485
  "unassigned",
@@ -20793,36 +21522,6 @@ Object.freeze({
20793
21522
  addonId: null,
20794
21523
  access: "view"
20795
21524
  },
20796
- "advancedNotifier.deleteRule": {
20797
- capName: "advanced-notifier",
20798
- capScope: "system",
20799
- addonId: null,
20800
- access: "delete"
20801
- },
20802
- "advancedNotifier.getHistory": {
20803
- capName: "advanced-notifier",
20804
- capScope: "system",
20805
- addonId: null,
20806
- access: "view"
20807
- },
20808
- "advancedNotifier.getRules": {
20809
- capName: "advanced-notifier",
20810
- capScope: "system",
20811
- addonId: null,
20812
- access: "view"
20813
- },
20814
- "advancedNotifier.testRule": {
20815
- capName: "advanced-notifier",
20816
- capScope: "system",
20817
- addonId: null,
20818
- access: "create"
20819
- },
20820
- "advancedNotifier.upsertRule": {
20821
- capName: "advanced-notifier",
20822
- capScope: "system",
20823
- addonId: null,
20824
- access: "create"
20825
- },
20826
21525
  "alarmPanel.arm": {
20827
21526
  capName: "alarm-panel",
20828
21527
  capScope: "device",
@@ -21045,6 +21744,12 @@ Object.freeze({
21045
21744
  addonId: null,
21046
21745
  access: "delete"
21047
21746
  },
21747
+ "backup.deleteSchedule": {
21748
+ capName: "backup",
21749
+ capScope: "system",
21750
+ addonId: null,
21751
+ access: "delete"
21752
+ },
21048
21753
  "backup.getEntries": {
21049
21754
  capName: "backup",
21050
21755
  capScope: "system",
@@ -21075,6 +21780,12 @@ Object.freeze({
21075
21780
  addonId: null,
21076
21781
  access: "view"
21077
21782
  },
21783
+ "backup.listSchedules": {
21784
+ capName: "backup",
21785
+ capScope: "system",
21786
+ addonId: null,
21787
+ access: "view"
21788
+ },
21078
21789
  "backup.previewSchedule": {
21079
21790
  capName: "backup",
21080
21791
  capScope: "system",
@@ -21099,6 +21810,12 @@ Object.freeze({
21099
21810
  addonId: null,
21100
21811
  access: "create"
21101
21812
  },
21813
+ "backup.upsertSchedule": {
21814
+ capName: "backup",
21815
+ capScope: "system",
21816
+ addonId: null,
21817
+ access: "create"
21818
+ },
21102
21819
  "battery.wakeForStream": {
21103
21820
  capName: "battery",
21104
21821
  capScope: "device",
@@ -23127,6 +23844,60 @@ Object.freeze({
23127
23844
  addonId: null,
23128
23845
  access: "create"
23129
23846
  },
23847
+ "notificationRules.createRule": {
23848
+ capName: "notification-rules",
23849
+ capScope: "system",
23850
+ addonId: null,
23851
+ access: "create"
23852
+ },
23853
+ "notificationRules.deleteRule": {
23854
+ capName: "notification-rules",
23855
+ capScope: "system",
23856
+ addonId: null,
23857
+ access: "delete"
23858
+ },
23859
+ "notificationRules.getConditionCatalog": {
23860
+ capName: "notification-rules",
23861
+ capScope: "system",
23862
+ addonId: null,
23863
+ access: "view"
23864
+ },
23865
+ "notificationRules.getHistory": {
23866
+ capName: "notification-rules",
23867
+ capScope: "system",
23868
+ addonId: null,
23869
+ access: "view"
23870
+ },
23871
+ "notificationRules.getRule": {
23872
+ capName: "notification-rules",
23873
+ capScope: "system",
23874
+ addonId: null,
23875
+ access: "view"
23876
+ },
23877
+ "notificationRules.listRules": {
23878
+ capName: "notification-rules",
23879
+ capScope: "system",
23880
+ addonId: null,
23881
+ access: "view"
23882
+ },
23883
+ "notificationRules.setRuleEnabled": {
23884
+ capName: "notification-rules",
23885
+ capScope: "system",
23886
+ addonId: null,
23887
+ access: "create"
23888
+ },
23889
+ "notificationRules.testRule": {
23890
+ capName: "notification-rules",
23891
+ capScope: "system",
23892
+ addonId: null,
23893
+ access: "create"
23894
+ },
23895
+ "notificationRules.updateRule": {
23896
+ capName: "notification-rules",
23897
+ capScope: "system",
23898
+ addonId: null,
23899
+ access: "create"
23900
+ },
23130
23901
  "notifier.cancel": {
23131
23902
  capName: "notifier",
23132
23903
  capScope: "device",
@@ -24879,6 +25650,36 @@ Object.freeze({
24879
25650
  addonId: null,
24880
25651
  access: "create"
24881
25652
  },
25653
+ "terminalSession.close": {
25654
+ capName: "terminal-session",
25655
+ capScope: "system",
25656
+ addonId: null,
25657
+ access: "create"
25658
+ },
25659
+ "terminalSession.listProfiles": {
25660
+ capName: "terminal-session",
25661
+ capScope: "system",
25662
+ addonId: null,
25663
+ access: "view"
25664
+ },
25665
+ "terminalSession.listSessions": {
25666
+ capName: "terminal-session",
25667
+ capScope: "system",
25668
+ addonId: null,
25669
+ access: "view"
25670
+ },
25671
+ "terminalSession.openSession": {
25672
+ capName: "terminal-session",
25673
+ capScope: "system",
25674
+ addonId: null,
25675
+ access: "create"
25676
+ },
25677
+ "terminalSession.resize": {
25678
+ capName: "terminal-session",
25679
+ capScope: "system",
25680
+ addonId: null,
25681
+ access: "create"
25682
+ },
24882
25683
  "toast.onToast": {
24883
25684
  capName: "toast",
24884
25685
  capScope: "system",
@@ -25360,7 +26161,7 @@ var AgentUIAddon = class extends BaseAddon {
25360
26161
  capability: adminUiCapability,
25361
26162
  provider: {
25362
26163
  getStaticDir: async () => ({ staticDir: path.resolve(__dirname) }),
25363
- getVersion: async () => ({ version: "1.2.4" })
26164
+ getVersion: async () => ({ version: "1.2.6" })
25364
26165
  }
25365
26166
  }];
25366
26167
  }