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