@camstack/addon-auth 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.
@@ -1,4 +1,4 @@
1
- //#region ../types/dist/event-category-D4HJq7Mw.mjs
1
+ //#region ../types/dist/event-category-BLcNejAE.mjs
2
2
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
3
3
  EventCategory["SystemBoot"] = "system.boot";
4
4
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -148,9 +148,6 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
148
148
  EventCategory["RecordingSegmentWritten"] = "recording.segment.written";
149
149
  EventCategory["RecordingPolicyFallback"] = "recording.policy.fallback";
150
150
  EventCategory["RecordingRetentionCompleted"] = "recording.retention.completed";
151
- /** Runner-sampled scrub thumbnail (~1/5 s/camera). Telemetry (D8): a lost
152
- * thumb is a scrub gap the recorder's keyframe backfill covers. */
153
- EventCategory["RecordingThumbSampled"] = "recording.thumb-sampled";
154
151
  /** Export render progress (0–100). Telemetry (D8): a lost tick is a stale
155
152
  * progress bar the client reconciles via `recordingExport.getExport`. */
156
153
  EventCategory["RecordingExportProgress"] = "recording.export.progress";
@@ -6815,7 +6812,6 @@ object({ deviceId: number() }), object({ deviceId: number() }), object({
6815
6812
  patch: record(string(), unknown())
6816
6813
  }), object({ success: literal(true) });
6817
6814
  object({ deviceId: number() }), unknown().nullable();
6818
- /** Shorthand to define a method schema */
6819
6815
  function method(input, output, options) {
6820
6816
  return {
6821
6817
  input,
@@ -6823,6 +6819,7 @@ function method(input, output, options) {
6823
6819
  kind: options?.kind ?? "query",
6824
6820
  auth: options?.auth ?? "protected",
6825
6821
  ...options?.access !== void 0 ? { access: options.access } : {},
6822
+ ...options?.caller !== void 0 ? { caller: options.caller } : {},
6826
6823
  timeoutMs: options?.timeoutMs
6827
6824
  };
6828
6825
  }
@@ -7633,16 +7630,23 @@ var StorageLocationDeclarationSchema = object({
7633
7630
  * Which node root the seeded `<id>:default` instance is placed under on a
7634
7631
  * FRESH install:
7635
7632
  * - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
7636
- * the appData volume. Right for small/durable data (backups, logs, models).
7633
+ * the appData volume. Right for small/durable data (logs, models).
7637
7634
  * - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
7638
7635
  * env is set, else falls back to the data root. Right for bulky, hot media
7639
7636
  * (recordings, event media) that should stay off the appData disk.
7637
+ * - `'backup'` — the dedicated backup volume (`CAMSTACK_BACKUP_ROOT`, default
7638
+ * `/backups` in the image) so archives live on their own mount rather than
7639
+ * filling the appData disk. Falls back to the data root when unset.
7640
7640
  *
7641
7641
  * Only affects the seeded default's `basePath`; operators can repoint any
7642
7642
  * location afterwards, and a `defaultsTo` slot inherits its parent's root
7643
7643
  * regardless of this field. Absent (the common case) is treated as `'data'`.
7644
7644
  */
7645
- defaultRoot: _enum(["data", "media"]).optional()
7645
+ defaultRoot: _enum([
7646
+ "data",
7647
+ "media",
7648
+ "backup"
7649
+ ]).optional()
7646
7650
  });
7647
7651
  var DecoderStatsSchema = object({
7648
7652
  inputFps: number(),
@@ -8305,6 +8309,59 @@ for (const l of AUDIO_MACRO_LABELS) {
8305
8309
  /** The complete taxonomy dictionary, keyed by kind. */
8306
8310
  var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
8307
8311
  /**
8312
+ * Notification-Center taxonomy — the fixed vocabulary the NC rule editor
8313
+ * offers as pickers instead of free text. Derived (never hand-listed) from the
8314
+ * single `EVENT_TAXONOMY` dictionary so it stays in lockstep with every other
8315
+ * taxonomy surface (timeline, filters, event page).
8316
+ *
8317
+ * Three buckets, mapped onto the rule editor's `stringList` conditions:
8318
+ * - `videoClasses` → detection classes (person / vehicle / animal + subs)
8319
+ * for the `classes` / `classesExclude` conditions.
8320
+ * - `audioKinds` → audio-analyzer sub kinds (`audio-scream`, …) shown in
8321
+ * the same class picker, grouped under an Audio header.
8322
+ * - `labels` → sensor + control taxonomy kinds (doorbell / contact /
8323
+ * lock / …) for the `sensorKinds` device-event condition.
8324
+ *
8325
+ * Each entry carries `parentKind` so the client can group video subs under
8326
+ * their macro and sensor/control kinds under their category. This surface is
8327
+ * served ADDITIVELY on the `nc.getConditionCatalog` bridge response — no cap
8328
+ * method, no codegen — so it ships train-free with an addon deploy.
8329
+ */
8330
+ /** One selectable taxonomy value: a stable kind id + display label + parent. */
8331
+ var NcTaxonomyEntrySchema = object({
8332
+ /** Stable kind id (e.g. 'person', 'car', 'audio-scream', 'doorbell'). */
8333
+ kind: string(),
8334
+ /** English fallback label (the UI translates via the event-kind i18n key). */
8335
+ label: string(),
8336
+ /** Macro/category parent for grouping ('car' → 'vehicle'); null for a top. */
8337
+ parentKind: string().nullable()
8338
+ });
8339
+ object({
8340
+ videoClasses: array(NcTaxonomyEntrySchema),
8341
+ audioKinds: array(NcTaxonomyEntrySchema),
8342
+ labels: array(NcTaxonomyEntrySchema)
8343
+ });
8344
+ function toEntry(kind, label, parentKind) {
8345
+ return {
8346
+ kind,
8347
+ label,
8348
+ parentKind
8349
+ };
8350
+ }
8351
+ /**
8352
+ * Build the NC taxonomy from `EVENT_TAXONOMY`. Insertion order is preserved
8353
+ * (macros before their subs), which the client relies on for stable grouping.
8354
+ */
8355
+ function buildNcTaxonomy() {
8356
+ const all = Object.values(EVENT_TAXONOMY);
8357
+ return {
8358
+ videoClasses: all.filter((e) => e.category === "detection").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8359
+ audioKinds: all.filter((e) => e.category === "audio" && e.level === "sub").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8360
+ labels: all.filter((e) => e.category === "sensor" || e.category === "control").map((e) => toEntry(e.kind, e.label, e.parentKind))
8361
+ };
8362
+ }
8363
+ Object.freeze(buildNcTaxonomy());
8364
+ /**
8308
8365
  * Error types for the safe expression engine. Two distinct classes so callers
8309
8366
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
8310
8367
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -8940,6 +8997,644 @@ var AccessoryKind = {
8940
8997
  AccessoryKind.Siren, AccessoryKind.Floodlight, AccessoryKind.Spotlight, AccessoryKind.PirSensor, AccessoryKind.Chime, AccessoryKind.Autotrack, AccessoryKind.Nightvision, AccessoryKind.PrivacyMask;
8941
8998
  DeviceFeature.BatteryOperated;
8942
8999
  /**
9000
+ * Shared geometry vocabulary for on-frame shape caps — privacy-mask,
9001
+ * motion-zones, and the detection zones/lines editor all speak this one
9002
+ * language so a single drawing-plane editor and the providers stay
9003
+ * decoupled from each cap's storage.
9004
+ *
9005
+ * All coordinates are normalized 0..1 of the camera frame (top-left
9006
+ * origin). Each cap composes the SUBSET of shape kinds it supports and
9007
+ * advertises it via `supportedShapes` in its `getOptions`.
9008
+ */
9009
+ /** A normalized 0..1 point (top-left origin). */
9010
+ var MaskPointSchema = object({
9011
+ x: number(),
9012
+ y: number()
9013
+ });
9014
+ /** Axis-aligned rectangle (normalized 0..1). */
9015
+ var MaskRectShapeSchema = object({
9016
+ kind: literal("rect"),
9017
+ x: number(),
9018
+ y: number(),
9019
+ width: number(),
9020
+ height: number()
9021
+ });
9022
+ /** Free polygon — an ordered list of normalized vertices (≥3). */
9023
+ var MaskPolygonShapeSchema = object({
9024
+ kind: literal("polygon"),
9025
+ points: array(MaskPointSchema)
9026
+ });
9027
+ /** Boolean cell grid — row-major, length === gridWidth*gridHeight. */
9028
+ var MaskGridShapeSchema = object({
9029
+ kind: literal("grid"),
9030
+ gridWidth: number(),
9031
+ gridHeight: number(),
9032
+ cells: array(boolean())
9033
+ });
9034
+ discriminatedUnion("kind", [
9035
+ MaskRectShapeSchema,
9036
+ MaskPolygonShapeSchema,
9037
+ MaskGridShapeSchema,
9038
+ object({
9039
+ kind: literal("line"),
9040
+ points: array(MaskPointSchema)
9041
+ })
9042
+ ]);
9043
+ /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
9044
+ var MaskShapeKindSchema = _enum([
9045
+ "rect",
9046
+ "polygon",
9047
+ "grid",
9048
+ "line"
9049
+ ]);
9050
+ /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
9051
+ var MaskPolygonVerticesSchema = object({
9052
+ min: number(),
9053
+ max: number()
9054
+ });
9055
+ /** Grid dimensions when a cap supports 'grid'. */
9056
+ var MaskGridDimsSchema = object({
9057
+ width: number(),
9058
+ height: number()
9059
+ });
9060
+ /**
9061
+ * notification-rules — the Notification Center rule surface (P1 core).
9062
+ *
9063
+ * Spec: `docs/superpowers/specs/2026-07-22-notification-center-requirements.md`
9064
+ * (operator decisions D-1/D-2/D-3 are binding):
9065
+ *
9066
+ * - D-2: rule EVALUATION lives in `addon-post-analysis` (the
9067
+ * `notification-center` module), hooked on the durable persistence
9068
+ * moments (object-event insert, TrackCloser.closeExpired) with a
9069
+ * persisted outbox + retry — never the lossy telemetry bus (D8).
9070
+ * - D-3: urgency belongs to the RULE. `delivery: 'immediate'` fires on the
9071
+ * FIRST persisted detection matching the conditions (per-track dedup,
9072
+ * `maxPerTrack` fixed at 1 — see {@link NC_MAX_PER_TRACK_IMMEDIATE});
9073
+ * `delivery: 'track-end'` evaluates the finalized track record at close.
9074
+ * - DISPATCH stays behind `notification-output` (rules reference targets
9075
+ * by id; per-backend params are a passthrough blob capped by the
9076
+ * target kind's own caps/degrade engine).
9077
+ *
9078
+ * P1 scope: admin-authored rules only (`createdBy` stamped from the
9079
+ * server-injected caller identity — the first `caller: 'required'`
9080
+ * adopter). The P1 condition subset is: devices, classes(+exclude),
9081
+ * minConfidence, admin zones (any/all + exclude), weekly schedule
9082
+ * windows, and the optional label/identity/plate matchers. User rules,
9083
+ * private zones, per-recipient fan-out and the wider condition table are
9084
+ * P2+ (see spec §7).
9085
+ *
9086
+ * All schemas here are the single source of truth — `NcRule` etc. are
9087
+ * `z.infer` exports; no duplicate interfaces (the advanced-notifier
9088
+ * schema/interface drift is explicitly not repeated).
9089
+ */
9090
+ /**
9091
+ * D-3: the trigger/urgency of a rule — which persistence moment evaluates it.
9092
+ * The value maps 1:1 onto the evaluated record kind:
9093
+ * - `immediate` ↔ object-event persist (lowest-latency detection burst)
9094
+ * - `track-end` ↔ TrackCloser.closeExpired (finalized track record)
9095
+ * - `device-event` ↔ SensorEventStore insert (doorbell press / sensor state
9096
+ * change of a LINKED device, one row per linked camera)
9097
+ * - `package-event` ↔ PackageDropDetector object-event insert (a `package`
9098
+ * delivery / pick-up)
9099
+ *
9100
+ * `immediate`/`track-end` carry the D-3 urgency semantics; `device-event`/
9101
+ * `package-event` are pure trigger kinds (no urgency dimension). Extending
9102
+ * this one field keeps the schema additive — a rule still declares exactly
9103
+ * one trigger.
9104
+ */
9105
+ var NcDeliverySchema = _enum([
9106
+ "immediate",
9107
+ "track-end",
9108
+ "device-event",
9109
+ "package-event"
9110
+ ]);
9111
+ /** Weekly schedule — OR of windows; absence on the rule = always active. */
9112
+ var NcScheduleSchema = object({
9113
+ windows: array(object({
9114
+ /** Days of week the window STARTS on (0 = Sunday … 6 = Saturday). */
9115
+ days: array(number().int().min(0).max(6)).min(1),
9116
+ startMinute: number().int().min(0).max(1439),
9117
+ endMinute: number().int().min(0).max(1439)
9118
+ })).min(1),
9119
+ /** IANA timezone; default = hub host timezone. */
9120
+ timezone: string().optional(),
9121
+ /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
9122
+ invert: boolean().optional()
9123
+ });
9124
+ /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
9125
+ var NcPlateMatcherSchema = object({
9126
+ values: array(string().min(1)).min(1),
9127
+ /** Max Levenshtein distance after normalization (uppercase alphanumeric). */
9128
+ maxDistance: number().int().min(0).max(3).default(1)
9129
+ });
9130
+ /**
9131
+ * Occupancy condition (DEVICE-EVENT trigger). Fires on a ZoneAnalytics
9132
+ * occupancy edge for a device — optionally narrowed to a single admin
9133
+ * `zoneId` and/or object `className`. `op` selects the edge/threshold:
9134
+ * - `became-occupied` (default) — count crossed 0 → ≥ `count`
9135
+ * - `became-free` — count crossed ≥ `count` → below it
9136
+ * - `>=` / `<=` — count is at/over or at/under `count`
9137
+ * `sustainSeconds` requires the condition hold continuously that long
9138
+ * before firing (debounces flicker; 0 = fire on the first matching edge).
9139
+ * Fail-closed: no ZoneAnalytics snapshot / missing zone / null snapshot ⇒
9140
+ * the condition never matches. Confirmed edge-state survives addon restarts
9141
+ * (declared SQLite collection, reseeded on boot).
9142
+ */
9143
+ var NcOccupancyConditionSchema = object({
9144
+ /** Admin zone id to scope the count to; absent = whole-frame occupancy. */
9145
+ zoneId: string().optional(),
9146
+ /** Object class to count; absent = any class. */
9147
+ className: string().optional(),
9148
+ op: _enum([
9149
+ "became-occupied",
9150
+ "became-free",
9151
+ ">=",
9152
+ "<="
9153
+ ]).default("became-occupied"),
9154
+ count: number().int().min(0).default(1),
9155
+ sustainSeconds: number().int().min(0).max(3600).default(15)
9156
+ });
9157
+ /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
9158
+ var NcZoneConditionSchema = object({
9159
+ ids: array(string().min(1)).min(1),
9160
+ /** Quantifier over `ids` — at least one / every one visited. */
9161
+ match: _enum(["any", "all"]).default("any")
9162
+ });
9163
+ /**
9164
+ * The P1 condition set — a flat AND of groups; absent group = pass;
9165
+ * membership lists are OR within the list (spec §2.3).
9166
+ */
9167
+ var NcConditionsSchema = object({
9168
+ /** Device scope — absent = all devices. */
9169
+ devices: array(number()).optional(),
9170
+ /** Detector class names (any overlap with the record's class set). */
9171
+ classes: array(string().min(1)).optional(),
9172
+ /** Veto classes — any overlap fails the rule. */
9173
+ classesExclude: array(string().min(1)).optional(),
9174
+ /** Minimum detection confidence 0–1 (fails when the record has none). */
9175
+ minConfidence: number().min(0).max(1).optional(),
9176
+ /** Admin zone membership over event `zones` / track `zonesVisited`. */
9177
+ zones: NcZoneConditionSchema.optional(),
9178
+ /** Veto zones — any hit fails the rule. */
9179
+ zonesExclude: array(string().min(1)).optional(),
9180
+ /**
9181
+ * Exact (case-insensitive) match on the record's collapsed `label`
9182
+ * (identity name / plate text / subclass).
9183
+ */
9184
+ labelEquals: array(string().min(1)).optional(),
9185
+ /**
9186
+ * Identity matcher. P1 boundary: matched against the record's collapsed
9187
+ * `label` (the identity display name propagated by the face pipeline) —
9188
+ * identity-ID matching rides in P2 when identity ids reach the record.
9189
+ */
9190
+ identities: array(string().min(1)).optional(),
9191
+ /** Fuzzy plate matcher against the record's `label` (plate text). */
9192
+ plates: NcPlateMatcherSchema.optional(),
9193
+ /**
9194
+ * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
9195
+ * Same P1 boundary: matched against the record's collapsed `label` (the
9196
+ * identity display name). A record with NO label passes (nothing to
9197
+ * exclude), unlike the include variant which fails on an absent label.
9198
+ */
9199
+ identitiesExclude: array(string().min(1)).optional(),
9200
+ /**
9201
+ * Minimum server-computed key-event importance in [0,1] (`Track.importance`).
9202
+ * TRACK-END only: importance is scored at track close, so it does not exist
9203
+ * at immediate / object-event evaluation time (see catalog `appliesTo`). At
9204
+ * close the value is threaded via the close-time info (the `Track` clone is
9205
+ * captured before the DB row is updated, so it would otherwise read stale).
9206
+ * Fails when the record carries no importance (never guess quality — the
9207
+ * `minConfidence` precedent). MVP cut: a single scalar threshold.
9208
+ */
9209
+ minImportance: number().min(0).max(1).optional(),
9210
+ /**
9211
+ * Minimum track dwell in SECONDS — `(lastSeen − firstSeen) / 1000`.
9212
+ * TRACK-END only: an `immediate` / object-event subject has no closed
9213
+ * lifespan, so a dwell condition never matches immediate delivery
9214
+ * (documented choice — the object-event record carries no `firstSeen`,
9215
+ * so dwell cannot be computed from what the subject actually carries).
9216
+ */
9217
+ minDwellSeconds: number().min(0).optional(),
9218
+ /**
9219
+ * Detection provenance filter. `any` (default / absent) matches every
9220
+ * source; otherwise the subject's source must equal it. Legacy records
9221
+ * with no stamped source are treated as `pipeline`. The union spans both
9222
+ * record kinds — object events carry `pipeline` | `onboard`, synthetic
9223
+ * tracks carry `sensor`.
9224
+ */
9225
+ source: _enum([
9226
+ "pipeline",
9227
+ "onboard",
9228
+ "sensor",
9229
+ "any"
9230
+ ]).optional(),
9231
+ /**
9232
+ * Minimum identity / plate MATCH confidence in [0,1] — DISTINCT from the
9233
+ * detector `minConfidence` (that gates the object-detection score; this
9234
+ * gates the recognition/OCR match score). Fails when the subject carries
9235
+ * no label-match confidence (never guess). TRACK-END only: the confidence
9236
+ * lives on the recognition result and reaches the subject at track close.
9237
+ *
9238
+ * What it measures precisely (plumbed at track close — the closer threads
9239
+ * the value into `NcTrackClosedInfo.labelConfidence`, the same seam as
9240
+ * `importance`): the BEST recognition match confidence observed for the
9241
+ * label the track carries at close — for a face, the peak cosine similarity
9242
+ * of the ASSIGNED identity (`FaceMatch.score`, reset on an identity switch);
9243
+ * for a plate, the peak OCR read score of the best-held plate
9244
+ * (`plateText.confidence`). When BOTH a face and a plate were recognized on
9245
+ * one track the higher of the two is used. A track that ended with no
9246
+ * confident identity/plate match carries no value, so the condition fails
9247
+ * closed for it (an un-recognized subject).
9248
+ */
9249
+ minLabelConfidence: number().min(0).max(1).optional(),
9250
+ /**
9251
+ * DEVICE-EVENT only. Raw device event-type tokens (`EventFire.eventType`,
9252
+ * e.g. a doorbell `press` / `press_long`) — matched case-insensitively
9253
+ * against the token carried on the device-event subject (extracted from the
9254
+ * event-emitter runtime slice's `lastEvent.eventType`). Fails when the
9255
+ * subject carries no token. Doorbell-pulse / passive-sensor kinds emit no
9256
+ * eventType, so gate those with {@link sensorKinds} instead.
9257
+ */
9258
+ eventTypeTokens: array(string().min(1)).optional(),
9259
+ /**
9260
+ * DEVICE-EVENT only. Sensor/control taxonomy kinds (e.g. `doorbell`,
9261
+ * `contact`, `button`, `device-event`) — matched against the persisted
9262
+ * `SensorEvent.kind` (see `sensor-event-kinds.ts`). Membership is OR.
9263
+ */
9264
+ sensorKinds: array(string().min(1)).optional(),
9265
+ /**
9266
+ * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
9267
+ * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
9268
+ * when the subject's phase does not match (a subject always carries a phase
9269
+ * on the package-event trigger).
9270
+ */
9271
+ packagePhase: _enum([
9272
+ "delivered",
9273
+ "picked-up",
9274
+ "both"
9275
+ ]).optional(),
9276
+ /**
9277
+ * PERSONAL-RULE custom zones (viewer-drawn). Inline normalized polygons
9278
+ * (MaskShape vocabulary). A record passes when its bbox overlaps ANY
9279
+ * listed polygon (ZoneEngine membership semantics). Evaluated only when
9280
+ * the subject carries a bbox; absent bbox ⇒ the condition FAILS.
9281
+ */
9282
+ customZones: array(MaskPolygonShapeSchema).optional(),
9283
+ /**
9284
+ * DEVICE-EVENT only. ZoneAnalytics occupancy edge — fires when a device's
9285
+ * (optionally zone/class-scoped) occupancy count crosses the configured
9286
+ * threshold and holds for `sustainSeconds`. Fail-closed on missing
9287
+ * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
9288
+ */
9289
+ occupancy: NcOccupancyConditionSchema.optional()
9290
+ });
9291
+ /** One delivery target: a `notification-output` Target ref + passthrough params. */
9292
+ var NcRuleTargetSchema = object({
9293
+ /** `notification-output` Target id. */
9294
+ targetId: string().min(1),
9295
+ /**
9296
+ * Per-backend passthrough. Recognized keys are mapped onto the canonical
9297
+ * Notification (`priority`, `level`, `sound`, `clickUrl`, `ttl`); the
9298
+ * degrade engine drops what the backend can't render.
9299
+ */
9300
+ params: record(string(), unknown()).optional()
9301
+ });
9302
+ /**
9303
+ * Media attachment policy (P1 still-image subset).
9304
+ * - `best` — the best AVAILABLE subject image at dispatch time (D-3).
9305
+ * - `best-matching` — the media that explains WHY the rule fired: a rule
9306
+ * matched on identities attaches the subject's `faceCrop`, one matched on
9307
+ * plates attaches the `plateCrop`; a rule with no identity/plate condition
9308
+ * (or when the specific crop is missing) degrades to `best`, then
9309
+ * `keyFrame`, then no attachment — never delaying the send. The matched
9310
+ * condition summary is frozen on the outbox row at enqueue (like the rule
9311
+ * name), so the choice never drifts from the record that fired it.
9312
+ * - `keyFrame` — the clean scene frame (no subject box).
9313
+ * - `none` — no attachment.
9314
+ */
9315
+ var NcMediaPolicySchema = object({ attach: _enum([
9316
+ "best",
9317
+ "best-matching",
9318
+ "keyFrame",
9319
+ "none"
9320
+ ]).default("best") });
9321
+ /** Throttle — cooldown survives restarts (rebuilt from the outbox on boot). */
9322
+ var NcThrottleSchema = object({
9323
+ cooldownSec: number().int().min(0).max(86400).default(60),
9324
+ /** `rule` = one shared cooldown; `rule-device` = per-camera cooldown. */
9325
+ scope: _enum(["rule", "rule-device"]).default("rule-device")
9326
+ });
9327
+ /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
9328
+ var NcRuleInputSchema = object({
9329
+ name: string().min(1).max(200),
9330
+ enabled: boolean().default(true),
9331
+ delivery: NcDeliverySchema,
9332
+ conditions: NcConditionsSchema.default({}),
9333
+ schedule: NcScheduleSchema.optional(),
9334
+ targets: array(NcRuleTargetSchema).min(1),
9335
+ media: NcMediaPolicySchema.default({ attach: "best" }),
9336
+ throttle: NcThrottleSchema.default({
9337
+ cooldownSec: 60,
9338
+ scope: "rule-device"
9339
+ }),
9340
+ /** `{{var}}` templating over camera/class/label/zones/confidence/time. */
9341
+ template: object({
9342
+ title: string().max(500).optional(),
9343
+ body: string().max(2e3).optional()
9344
+ }).optional(),
9345
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
9346
+ priority: number().int().min(1).max(5).default(3),
9347
+ /**
9348
+ * Ownership/visibility key. Absent = admin/global rule (unchanged legacy
9349
+ * behaviour, visible to all, read-only in the viewer). Present = personal
9350
+ * rule owned by this userId. Server-stamped; never trusted from a client.
9351
+ */
9352
+ ownerUserId: string().optional()
9353
+ });
9354
+ /**
9355
+ * Partial patch for `updateRule` — any subset of the input fields, plus the
9356
+ * persisted-only {@link NcRuleSchema} `disabledTargetIds` set. The latter is
9357
+ * NOT a client-authored input field (it lives on the persisted rule, not the
9358
+ * input), so it is added here explicitly to let the store's per-target opt-out
9359
+ * toggle round-trip through the shared `update` path. Viewer opt-out mutations
9360
+ * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
9361
+ * `updateRule` patch.
9362
+ */
9363
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
9364
+ /** A persisted rule. */
9365
+ var NcRuleSchema = NcRuleInputSchema.extend({
9366
+ id: string(),
9367
+ /** userId of the admin who created the rule (server-stamped caller). */
9368
+ createdBy: string(),
9369
+ createdAt: number(),
9370
+ updatedAt: number(),
9371
+ /**
9372
+ * Per-target opt-out set. A targetId here is suppressed for THIS rule at
9373
+ * send time. Only a target's OWNER may add/remove its id (server-checked
9374
+ * in `nc.setRuleTargetEnabled`). Defaults to empty.
9375
+ */
9376
+ disabledTargetIds: array(string()).default([])
9377
+ });
9378
+ var NcTestResultSchema = object({
9379
+ recordId: string(),
9380
+ recordKind: _enum([
9381
+ "object-event",
9382
+ "track",
9383
+ "device-event",
9384
+ "package-event"
9385
+ ]),
9386
+ deviceId: number(),
9387
+ timestamp: number(),
9388
+ wouldFire: boolean(),
9389
+ /** Condition id that failed (first failing group), when `wouldFire` is false. */
9390
+ failedCondition: string().optional(),
9391
+ className: string().optional(),
9392
+ label: string().optional()
9393
+ });
9394
+ var NcConditionDescriptorSchema = object({
9395
+ /** Field id inside `NcConditions` (or `'schedule'` for the rule-level group). */
9396
+ id: string(),
9397
+ group: _enum([
9398
+ "scope",
9399
+ "class",
9400
+ "zones",
9401
+ "quality",
9402
+ "label",
9403
+ "schedule",
9404
+ "device",
9405
+ "package",
9406
+ "occupancy"
9407
+ ]),
9408
+ label: string(),
9409
+ /** Editor widget the UI renders — never hardcode per-condition forms. */
9410
+ valueType: _enum([
9411
+ "deviceIdList",
9412
+ "stringList",
9413
+ "number01",
9414
+ "number",
9415
+ "sourceSelect",
9416
+ "zoneSelection",
9417
+ "zoneIdList",
9418
+ "schedule",
9419
+ "plateMatcher",
9420
+ "packagePhase",
9421
+ "polygonDraw",
9422
+ "occupancy"
9423
+ ]),
9424
+ operator: _enum([
9425
+ "in",
9426
+ "notIn",
9427
+ "anyOf",
9428
+ "allOf",
9429
+ "gte",
9430
+ "fuzzyIn",
9431
+ "withinSchedule"
9432
+ ]),
9433
+ /** Which delivery kinds the condition applies to. */
9434
+ appliesTo: array(NcDeliverySchema),
9435
+ phase: string(),
9436
+ description: string().optional()
9437
+ });
9438
+ /**
9439
+ * The delivery lifecycle status of a history row — a straight read of the
9440
+ * durable outbox row's own status (single source of truth):
9441
+ * - `pending` — enqueued, in-flight or retrying with backoff
9442
+ * - `sent` — delivered (terminal)
9443
+ * - `dead` — dead-lettered after exhausting retries / a permanent
9444
+ * backend rejection / a deleted target (terminal; carries
9445
+ * the failure `error`)
9446
+ *
9447
+ * P1 has no `suppressed-quiet-hours` / `snoozed` states — those ride the P2
9448
+ * user dimension (quiet hours / snooze) and are additive when they land.
9449
+ */
9450
+ var NcHistoryStatusSchema = _enum([
9451
+ "pending",
9452
+ "sent",
9453
+ "dead"
9454
+ ]);
9455
+ /** The evaluated record kind a history row descends from (one per trigger). */
9456
+ var NcHistoryRecordKindSchema = _enum([
9457
+ "object-event",
9458
+ "track-end",
9459
+ "device-event",
9460
+ "package-event"
9461
+ ]);
9462
+ /** Subject summary frozen on the row at fire time (survives rule/record edits). */
9463
+ var NcHistorySubjectSchema = object({
9464
+ className: string(),
9465
+ label: string().optional(),
9466
+ confidence: number().optional(),
9467
+ zones: array(string()),
9468
+ timestamp: number()
9469
+ });
9470
+ /**
9471
+ * One delivery-history row. This is a read-only VIEW over the durable
9472
+ * outbox row (single source of truth — the same row the drain loop drives;
9473
+ * NO second write path, so history can never drift from delivery state).
9474
+ * The §3.2 fields map directly: `ruleId`/`targetId`/`deviceId` are columns,
9475
+ * `eventRef` is `recordKind`+`recordId`, `timestamps` are `createdAt`
9476
+ * (fire) / `updatedAt` (last transition), `status` + `error` are the
9477
+ * lifecycle. `ruleName` + `subject` are the intent snapshot frozen at
9478
+ * enqueue. `userId?` (per-recipient history) is P2 — no user dimension in
9479
+ * P1 (admin scope only).
9480
+ */
9481
+ var NcHistoryEntrySchema = object({
9482
+ /** Outbox row id — the stable dedup id `ruleId:dedupRef:targetId`. */
9483
+ id: string(),
9484
+ ruleId: string(),
9485
+ /** Rule name frozen at fire time (outlives a later rename / delete). */
9486
+ ruleName: string(),
9487
+ /** The rule urgency/trigger that produced this delivery. */
9488
+ delivery: NcDeliverySchema,
9489
+ targetId: string(),
9490
+ deviceId: number(),
9491
+ recordKind: NcHistoryRecordKindSchema,
9492
+ /** Event / track ref of the evaluated record (§3.2 `eventRef`). */
9493
+ recordId: string(),
9494
+ /** Present for track-scoped deliveries (object-event / track-end). */
9495
+ trackId: string().optional(),
9496
+ status: NcHistoryStatusSchema,
9497
+ /** Delivery attempts made so far. */
9498
+ attempts: number().int(),
9499
+ /** Fire time (outbox enqueue). */
9500
+ createdAt: number(),
9501
+ /** Last transition time (terminal for sent / dead). */
9502
+ updatedAt: number(),
9503
+ /** Failure detail — present on a `dead` row. */
9504
+ error: string().optional(),
9505
+ subject: NcHistorySubjectSchema
9506
+ });
9507
+ /**
9508
+ * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
9509
+ * AND; absent = unbounded on that axis. `since`/`until` bound the fire time
9510
+ * (`createdAt`, epoch ms, inclusive). `limit` is clamped to
9511
+ * {@link NC_HISTORY_LIMIT_MAX}. `userId` (per-recipient filtering) is P2.
9512
+ */
9513
+ var NcHistoryFilterSchema = object({
9514
+ ruleId: string().optional(),
9515
+ deviceId: number().optional(),
9516
+ status: NcHistoryStatusSchema.optional(),
9517
+ since: number().optional(),
9518
+ until: number().optional(),
9519
+ limit: number().int().min(1).max(500).default(100)
9520
+ });
9521
+ 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 }), {
9522
+ kind: "mutation",
9523
+ auth: "admin",
9524
+ caller: "required"
9525
+ }), method(object({
9526
+ ruleId: string(),
9527
+ patch: NcRulePatchSchema
9528
+ }), object({ rule: NcRuleSchema }), {
9529
+ kind: "mutation",
9530
+ auth: "admin",
9531
+ caller: "required"
9532
+ }), method(object({ ruleId: string() }), object({ success: literal(true) }), {
9533
+ kind: "mutation",
9534
+ auth: "admin"
9535
+ }), method(object({
9536
+ ruleId: string(),
9537
+ enabled: boolean()
9538
+ }), object({ success: literal(true) }), {
9539
+ kind: "mutation",
9540
+ auth: "admin"
9541
+ }), method(object({
9542
+ rule: NcRuleInputSchema,
9543
+ lookbackMinutes: number().int().min(1).max(1440).default(60)
9544
+ }), object({ results: array(NcTestResultSchema) }), {
9545
+ kind: "mutation",
9546
+ auth: "admin"
9547
+ }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
9548
+ /**
9549
+ * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
9550
+ *
9551
+ * Spec: `docs/superpowers/specs/2026-07-24-nc-occupancy-timelapse-design.md`
9552
+ * §3.2/§3.3.
9553
+ *
9554
+ * Deliberately NOT a capability definition and NOT an `NcRule`:
9555
+ * - Every `NcDelivery` member is a *persisted-pipeline-record* trigger. A
9556
+ * timelapse fires on a SCHEDULE WINDOW BOUNDARY, evaluates no pipeline
9557
+ * record, and produces a video it assembled itself — so it rides no
9558
+ * delivery-enum member (the enum is frozen) and no cap method. This file is
9559
+ * a plain typed schema; it does NOT go through `npm run codegen`.
9560
+ * - It shares only the delivery leg (`notification-output.send`) and the
9561
+ * persistence/ownership patterns with the Notification Center, reusing
9562
+ * {@link NcScheduleSchema} (weekly windows, midnight-crossing, invertible)
9563
+ * and {@link NcRuleTargetSchema} (target ref + passthrough params).
9564
+ *
9565
+ * Ownership is SERVER-DERIVED. `ownerUserId` / `createdBy` / `createdAt` /
9566
+ * `updatedAt` / `id` / `lastGeneratedAt` live on the PERSISTED rule only —
9567
+ * {@link TimelapseRuleInputSchema} and {@link TimelapseRulePatchSchema} do not
9568
+ * carry them, so a forged client payload can never claim or re-own a rule
9569
+ * (Zod strips unknown keys). The store stamps them from the resolved caller.
9570
+ */
9571
+ /** `{{var}}` templating over camera/rule/time — same vocabulary as `NcRule`. */
9572
+ var TimelapseTemplateSchema = object({
9573
+ title: string().max(500).optional(),
9574
+ body: string().max(2e3).optional()
9575
+ });
9576
+ var NameField = string().min(1).max(200);
9577
+ var DeviceIdsField = array(number()).min(1);
9578
+ var CadenceSecField = number().int().min(2).max(3600);
9579
+ var FramerateField = number().int().min(1).max(60);
9580
+ var TargetsField = array(NcRuleTargetSchema).min(1);
9581
+ var PriorityField = number().int().min(1).max(5);
9582
+ /**
9583
+ * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
9584
+ * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
9585
+ * here (see the ownership note above).
9586
+ */
9587
+ var TimelapseRuleInputSchema = object({
9588
+ name: NameField,
9589
+ enabled: boolean().default(true),
9590
+ /** Cameras sampled by this rule — one scratch dir + one artifact per device. */
9591
+ deviceIds: DeviceIdsField,
9592
+ /**
9593
+ * Activation window(s). REQUIRED (unlike `NcRule`, where an absent schedule
9594
+ * means "always active"): a timelapse is defined by its window boundaries —
9595
+ * open clears the scratch, close assembles and delivers.
9596
+ */
9597
+ schedule: NcScheduleSchema,
9598
+ /** Force-snapshot cadence inside the window, seconds (predecessor parity). */
9599
+ cadenceSec: CadenceSecField.default(15),
9600
+ /** Output frames per second of the assembled mp4 (predecessor parity). */
9601
+ framerate: FramerateField.default(10),
9602
+ /** `notification-output` targets the finished video/thumbnail is sent to. */
9603
+ targets: TargetsField,
9604
+ template: TimelapseTemplateSchema.optional(),
9605
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
9606
+ priority: PriorityField.default(3)
9607
+ });
9608
+ object({
9609
+ name: NameField.optional(),
9610
+ enabled: boolean().optional(),
9611
+ deviceIds: DeviceIdsField.optional(),
9612
+ schedule: NcScheduleSchema.optional(),
9613
+ cadenceSec: CadenceSecField.optional(),
9614
+ framerate: FramerateField.optional(),
9615
+ targets: TargetsField.optional(),
9616
+ template: TimelapseTemplateSchema.nullable().optional(),
9617
+ priority: PriorityField.optional()
9618
+ });
9619
+ TimelapseRuleInputSchema.extend({
9620
+ id: string(),
9621
+ /**
9622
+ * Ownership/visibility key. Absent = admin/global rule (visible to all).
9623
+ * Present = personal rule owned by this userId. Server-stamped from the
9624
+ * resolved caller; never trusted from a client payload.
9625
+ */
9626
+ ownerUserId: string().optional(),
9627
+ /**
9628
+ * Epoch-ms of the last successful generation — the 1-hour re-generation
9629
+ * guard's durable state (predecessor parity). Absent = never generated.
9630
+ */
9631
+ lastGeneratedAt: number().optional(),
9632
+ /** userId of the caller who created the rule (server-stamped). */
9633
+ createdBy: string(),
9634
+ createdAt: number(),
9635
+ updatedAt: number()
9636
+ });
9637
+ /**
8943
9638
  * Generic device-level status snapshot. Auto-registered by `BaseDevice`
8944
9639
  * for every device, regardless of provider — the kernel needs a uniform
8945
9640
  * cap-keyed slice for the basic device flags every consumer expects to
@@ -11013,6 +11708,22 @@ var CameraMetricsSchema = object({
11013
11708
  ])
11014
11709
  });
11015
11710
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
11711
+ /**
11712
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
11713
+ * within the frame, so the executor can re-cut a leaf child ROI at native
11714
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
11715
+ */
11716
+ var NativeCropRefSchema = object({
11717
+ /** Handle keying the retained native surface (node-pinned to its owner). */
11718
+ handle: FrameHandleSchema,
11719
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
11720
+ cropFrameSpace: object({
11721
+ x: number(),
11722
+ y: number(),
11723
+ w: number(),
11724
+ h: number()
11725
+ })
11726
+ });
11016
11727
  var ModelFormatSchema$1 = _enum([
11017
11728
  "onnx",
11018
11729
  "coreml",
@@ -11288,7 +11999,22 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
11288
11999
  * Omitted ⇒ the runner's default device (current single-engine
11289
12000
  * behaviour). Selects WHICH device pool of the node runs the call.
11290
12001
  */
11291
- deviceKey: string().optional()
12002
+ deviceKey: string().optional(),
12003
+ /**
12004
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
12005
+ * when the parent crop was resolved from the frame's retained NATIVE
12006
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
12007
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
12008
+ * resolution from that surface — the SAME quality path faces already
12009
+ * had — instead of the downscaled parent tile. `handle` keys the native
12010
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
12011
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
12012
+ * the executor's crop-normalized child ROI back into frame-normalized
12013
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
12014
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
12015
+ * (today's behaviour on the fallback path).
12016
+ */
12017
+ nativeCropRef: NativeCropRefSchema.optional()
11292
12018
  }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
11293
12019
  engine: PipelineEngineChoiceSchema.optional(),
11294
12020
  steps: array(PipelineStepInputSchema).min(1),
@@ -11504,7 +12230,11 @@ var DetailResultSchema = object({
11504
12230
  bbox: NativeCropBboxSchema.optional(),
11505
12231
  embedding: string().optional(),
11506
12232
  label: string().optional(),
11507
- alignedCropJpeg: string().optional()
12233
+ alignedCropJpeg: string().optional(),
12234
+ /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
12235
+ * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
12236
+ * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
12237
+ nativeFaceShortSidePx: number().optional()
11508
12238
  });
11509
12239
  /**
11510
12240
  * Per-camera tunable ranges + defaults. Single source of truth used
@@ -11518,6 +12248,12 @@ var motionCooldownMsField = {
11518
12248
  default: 3e4,
11519
12249
  step: 500
11520
12250
  };
12251
+ var maxSessionHoldMsField = {
12252
+ min: 0,
12253
+ max: 6e5,
12254
+ default: 12e4,
12255
+ step: 5e3
12256
+ };
11521
12257
  var motionFpsField = {
11522
12258
  min: 1,
11523
12259
  max: 30,
@@ -11665,6 +12401,19 @@ var RunnerCameraConfigSchema = object({
11665
12401
  "on-motion"
11666
12402
  ]).default("always-on"),
11667
12403
  motionCooldownMs: number().min(motionCooldownMsField.min).default(motionCooldownMsField.default),
12404
+ /**
12405
+ * Orchestrator-side on-motion session-hold cap (ms). While an on-motion
12406
+ * detection session is active and ≥1 confirmed non-stationary track is
12407
+ * still live, the orchestrator keeps the session open past
12408
+ * `motionCooldownMs` (a slowly-moving subject can stop re-triggering the
12409
+ * camera's VMD yet is still being tracked frame-to-frame) — up to this many
12410
+ * ms since the session opened, after which it closes regardless. `0`
12411
+ * disables the hold (legacy cooldown-only teardown). Not consumed by the
12412
+ * runner itself — carried here so it shares the per-camera device-settings
12413
+ * surface with `motionCooldownMs`; the orchestrator reads it off the
12414
+ * resolved `CameraDetectionConfig`.
12415
+ */
12416
+ maxSessionHoldMs: number().min(maxSessionHoldMsField.min).max(maxSessionHoldMsField.max).optional(),
11668
12417
  motionFps: number().min(motionFpsField.min).max(motionFpsField.max).default(motionFpsField.default),
11669
12418
  detectionFps: number().min(detectionFpsField.min).max(detectionFpsField.max).default(detectionFpsField.default),
11670
12419
  motionStreamId: string(),
@@ -11754,7 +12503,7 @@ var RunnerCameraConfigSchema = object({
11754
12503
  */
11755
12504
  inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
11756
12505
  });
11757
- 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;
12506
+ 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;
11758
12507
  /**
11759
12508
  * Runtime load summary returned by `getLocalLoad`. Used by the orchestrator's
11760
12509
  * load-balancing levels (L2 capacity-based, L3 hardware-aware) to decide
@@ -11865,67 +12614,6 @@ DeviceType.Light, DeviceType.Siren, DeviceType.Switch, method(object({
11865
12614
  lastChangedAt: number()
11866
12615
  });
11867
12616
  /**
11868
- * Shared geometry vocabulary for on-frame shape caps — privacy-mask,
11869
- * motion-zones, and the detection zones/lines editor all speak this one
11870
- * language so a single drawing-plane editor and the providers stay
11871
- * decoupled from each cap's storage.
11872
- *
11873
- * All coordinates are normalized 0..1 of the camera frame (top-left
11874
- * origin). Each cap composes the SUBSET of shape kinds it supports and
11875
- * advertises it via `supportedShapes` in its `getOptions`.
11876
- */
11877
- /** A normalized 0..1 point (top-left origin). */
11878
- var MaskPointSchema = object({
11879
- x: number(),
11880
- y: number()
11881
- });
11882
- /** Axis-aligned rectangle (normalized 0..1). */
11883
- var MaskRectShapeSchema = object({
11884
- kind: literal("rect"),
11885
- x: number(),
11886
- y: number(),
11887
- width: number(),
11888
- height: number()
11889
- });
11890
- /** Free polygon — an ordered list of normalized vertices (≥3). */
11891
- var MaskPolygonShapeSchema = object({
11892
- kind: literal("polygon"),
11893
- points: array(MaskPointSchema)
11894
- });
11895
- /** Boolean cell grid — row-major, length === gridWidth*gridHeight. */
11896
- var MaskGridShapeSchema = object({
11897
- kind: literal("grid"),
11898
- gridWidth: number(),
11899
- gridHeight: number(),
11900
- cells: array(boolean())
11901
- });
11902
- discriminatedUnion("kind", [
11903
- MaskRectShapeSchema,
11904
- MaskPolygonShapeSchema,
11905
- MaskGridShapeSchema,
11906
- object({
11907
- kind: literal("line"),
11908
- points: array(MaskPointSchema)
11909
- })
11910
- ]);
11911
- /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
11912
- var MaskShapeKindSchema = _enum([
11913
- "rect",
11914
- "polygon",
11915
- "grid",
11916
- "line"
11917
- ]);
11918
- /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
11919
- var MaskPolygonVerticesSchema = object({
11920
- min: number(),
11921
- max: number()
11922
- });
11923
- /** Grid dimensions when a cap supports 'grid'. */
11924
- var MaskGridDimsSchema = object({
11925
- width: number(),
11926
- height: number()
11927
- });
11928
- /**
11929
12617
  * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
11930
12618
  * on-camera motion-detection mask is a single `grid` region (a row-major
11931
12619
  * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
@@ -13633,94 +14321,6 @@ var EnrichedWidgetMetadataSchema = WidgetMetadataSchema.extend({
13633
14321
  bundleUrl: string()
13634
14322
  });
13635
14323
  method(_void(), array(EnrichedWidgetMetadataSchema).readonly());
13636
- var NotificationRuleConditionsSchema = object({
13637
- deviceIds: array(number()).readonly().optional(),
13638
- classNames: array(string()).readonly().optional(),
13639
- zoneIds: array(string()).readonly().optional(),
13640
- minConfidence: number().optional(),
13641
- source: _enum([
13642
- "pipeline",
13643
- "onboard",
13644
- "any"
13645
- ]).optional(),
13646
- schedule: object({
13647
- days: array(number()).readonly(),
13648
- startHour: number(),
13649
- endHour: number()
13650
- }).optional(),
13651
- cooldownSeconds: number().optional(),
13652
- minDwellSeconds: number().optional(),
13653
- /** Match against `event.data.eventType` token (e.g. `'press_long'`). When non-empty, only events
13654
- * carrying a matching `data.eventType` string pass this condition. Rules without this field are
13655
- * unaffected (back-compat). Distinct from `rule.eventTypes` which holds EventCategory strings. */
13656
- eventTypeTokens: array(string()).readonly().optional(),
13657
- /** Match detections whose CLIP image embedding is semantically similar to this free-text
13658
- * description. Requires the embedding-encoder cap to have pre-warmed the text vector.
13659
- * `minSimilarity` is the cosine similarity threshold in [0, 1]. */
13660
- clipDescription: object({
13661
- text: string().min(1),
13662
- minSimilarity: number().min(0).max(1)
13663
- }).optional(),
13664
- /** Match events whose recognized-entity label (face identity name or plate
13665
- * vehicle name, propagated onto `event.data.label`) is one of these values.
13666
- * Empty/absent → unaffected (back-compat). Enables "notify me when <named
13667
- * vehicle/person> is seen". */
13668
- labels: array(string()).readonly().optional()
13669
- });
13670
- var NotificationRuleTemplateSchema = object({
13671
- title: string(),
13672
- body: string(),
13673
- imageMode: _enum([
13674
- "crop",
13675
- "annotated",
13676
- "full",
13677
- "none"
13678
- ])
13679
- });
13680
- var NotificationRuleSchema = object({
13681
- id: string(),
13682
- name: string(),
13683
- enabled: boolean(),
13684
- eventTypes: array(string()).readonly(),
13685
- conditions: NotificationRuleConditionsSchema,
13686
- outputs: array(string()).readonly(),
13687
- template: NotificationRuleTemplateSchema.optional(),
13688
- priority: _enum([
13689
- "low",
13690
- "normal",
13691
- "high",
13692
- "critical"
13693
- ])
13694
- });
13695
- var NotificationTestResultSchema = object({
13696
- ruleId: string(),
13697
- eventId: string(),
13698
- timestamp: number(),
13699
- wouldFire: boolean(),
13700
- reason: string().optional()
13701
- });
13702
- var NotificationHistoryEntrySchema = object({
13703
- id: string(),
13704
- ruleId: string(),
13705
- ruleName: string(),
13706
- eventId: string(),
13707
- timestamp: number(),
13708
- outputs: array(string()).readonly(),
13709
- success: boolean(),
13710
- error: string().optional(),
13711
- deviceId: number().optional()
13712
- });
13713
- var NotificationHistoryFilterSchema = object({
13714
- ruleId: string().optional(),
13715
- deviceId: number().optional(),
13716
- from: number().optional(),
13717
- to: number().optional(),
13718
- limit: number().optional()
13719
- });
13720
- 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({
13721
- ruleId: string(),
13722
- lookbackMinutes: number()
13723
- }), object({ results: array(NotificationTestResultSchema).readonly() }), { kind: "mutation" }), method(object({ filter: NotificationHistoryFilterSchema.optional() }), object({ entries: array(NotificationHistoryEntrySchema).readonly() }));
13724
14324
  /**
13725
14325
  * Alerts capability — collection-based internal alert system.
13726
14326
  *
@@ -13920,96 +14520,54 @@ var authProviderCapability = {
13920
14520
  mount: { kind: "skip" }
13921
14521
  };
13922
14522
  /**
13923
- * `login-method` collection cap through which auth addons contribute
13924
- * their pre-auth login surfaces to the login page. This is the SINGLE,
13925
- * generic mechanism that supersedes the dead `auth.listProviders` reader:
13926
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
13927
- * `login-method` provider and the PUBLIC `auth.listLoginMethods`
13928
- * procedure aggregates them for the unauthenticated login page.
13929
- *
13930
- * A contribution is a discriminated union on `kind`:
13931
- *
13932
- * - `redirect` — a declarative button. The login page renders a generic
13933
- * button that navigates to `startUrl` (an addon-owned HTTP route).
13934
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
13935
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
13936
- * login page needs NO change.
13937
- *
13938
- * - `widget` — a Module-Federation widget the login page mounts (via
13939
- * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
13940
- * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
13941
- * mechanism kept for future use; no shipped addon uses it on the login
13942
- * page (the passkey ceremony below runs natively in the shell instead).
13943
- *
13944
- * - `passkey` — a declarative WebAuthn ceremony the shell renders
13945
- * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
13946
- * a remotely-loaded bundle). Carries the addon's effective `rpId` /
13947
- * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
13948
- * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
13949
- * fetching any remote code pre-auth. Contribution stays unconditional —
13950
- * enrollment state is never leaked pre-auth; visibility is a shell
13951
- * decision.
13952
- *
13953
- * Every contribution carries a `stage`:
13954
- * - `primary` — shown on the first credentials screen (OIDC /
13955
- * magic-link buttons; a future usernameless passkey).
13956
- * - `second-factor` — shown AFTER the password leg, gated on the
13957
- * returned `factors` (passkey-as-2FA today).
13958
- *
13959
- * `mount: skip` — the cap is read server-side by the core auth router
13960
- * (`registry.getCollection('login-method')`), never mounted as its own
13961
- * tRPC router.
14523
+ * A live terminal session hosted by the provider addon. Output and input do
14524
+ * NOT flow through the capability they use the addon data plane
14525
+ * (`GET /addon/terminal/<id>/out` SSE, `POST /addon/terminal/<id>/in`) because
14526
+ * terminal output must be ordered and lossless. The event bus is telemetry and
14527
+ * may drop chunks ([D8]), and a dropped chunk desynchronises the vt parser
14528
+ * permanently until a full repaint. The capability owns only lifecycle.
13962
14529
  */
13963
- /** When a login method renders in the two-phase login flow. */
13964
- var LoginStageEnum = _enum(["primary", "second-factor"]);
13965
- /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
13966
- var LoginMethodContributionSchema = discriminatedUnion("kind", [
13967
- object({
13968
- kind: literal("redirect"),
13969
- /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
13970
- id: string(),
13971
- /** Operator-facing button label. */
13972
- label: string(),
13973
- /** lucide-react icon name. */
13974
- icon: string().optional(),
13975
- /** Addon-owned HTTP route the button navigates to (GET). */
13976
- startUrl: string(),
13977
- stage: LoginStageEnum
13978
- }),
13979
- object({
13980
- kind: literal("widget"),
13981
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
13982
- id: string(),
13983
- /** Owning addon id — drives the public bundle URL + the MF namespace. */
13984
- addonId: string(),
13985
- /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
13986
- bundle: string(),
13987
- /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
13988
- remote: WidgetRemoteSchema,
13989
- stage: LoginStageEnum
13990
- }),
13991
- object({
13992
- kind: literal("passkey"),
13993
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
13994
- id: string(),
13995
- /** Operator-facing button label. */
13996
- label: string(),
13997
- stage: LoginStageEnum,
13998
- /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
13999
- rpId: string(),
14000
- /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
14001
- origin: string().nullable()
14002
- })
14003
- ]);
14004
- var loginMethodCapability = {
14005
- name: "login-method",
14006
- scope: "system",
14007
- mode: "collection",
14008
- internal: true,
14009
- methods: { getLoginMethods: method(_void(), array(LoginMethodContributionSchema).readonly()) },
14010
- /** BIG PLAN 2: declarative mount hint — read by `@camstack/system` `buildCapRouters`. */
14011
- mount: { kind: "skip" }
14012
- };
14530
+ var TerminalSessionInfoSchema = object({
14531
+ /** Opaque session id minted by the provider on `openSession`. */
14532
+ sessionId: string(),
14533
+ /** The pre-declared profile this session runs (never a free-form command). */
14534
+ profileId: string(),
14535
+ /** Human-readable profile label for the UI session list. */
14536
+ label: string(),
14537
+ cols: number().int().positive(),
14538
+ rows: number().int().positive(),
14539
+ /** ms-epoch the session's pty was spawned. */
14540
+ startedAt: number()
14541
+ });
14542
+ /**
14543
+ * A profile the operator may open — a pre-declared, allowlisted program
14544
+ * (`monitor` → `btm`). The capability accepts only these ids; a free-form
14545
+ * command string would be remote code execution as the server's user, so it is
14546
+ * deliberately not part of the contract.
14547
+ */
14548
+ var TerminalProfileInfoSchema = object({
14549
+ profileId: string(),
14550
+ label: string(),
14551
+ description: string().optional()
14552
+ });
14553
+ method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(TerminalSessionInfoSchema).readonly(), { auth: "admin" }), method(object({
14554
+ profileId: string(),
14555
+ cols: number().int().positive(),
14556
+ rows: number().int().positive()
14557
+ }), TerminalSessionInfoSchema, {
14558
+ kind: "mutation",
14559
+ auth: "admin"
14560
+ }), method(object({
14561
+ sessionId: string(),
14562
+ cols: number().int().positive(),
14563
+ rows: number().int().positive()
14564
+ }), _void(), {
14565
+ kind: "mutation",
14566
+ auth: "admin"
14567
+ }), method(object({ sessionId: string() }), _void(), {
14568
+ kind: "mutation",
14569
+ auth: "admin"
14570
+ });
14013
14571
  /**
14014
14572
  * Orchestrator-side destination metadata. The orchestrator computes
14015
14573
  * `id = <addonId>:<subId>` from its provider lookup so consumers
@@ -14111,11 +14669,53 @@ var LocationStatSchema = object({
14111
14669
  fileCount: number(),
14112
14670
  present: boolean()
14113
14671
  });
14672
+ /**
14673
+ * A backup schedule — the N:M "entry" that binds one cron cadence to a
14674
+ * SET of destination locations. Supersedes the per-location cron on
14675
+ * `BackupDestinationPolicy`: an operator creates a schedule, picks the
14676
+ * `backups` locations it should write to, and the orchestrator fans a
14677
+ * single archive out to all of them when the cron fires.
14678
+ *
14679
+ * `retentionCount` is per-schedule (D-decision 2026-07-28): every
14680
+ * location targeted by this schedule keeps this many archives from
14681
+ * this schedule's runs.
14682
+ *
14683
+ * `dataSources` optionally narrows which top-level state locations
14684
+ * (db, addons, tls, …) are archived; omitted = the orchestrator's
14685
+ * default full set.
14686
+ */
14687
+ var BackupScheduleSchema = object({
14688
+ /** Stable id. Generated by the orchestrator on first upsert if absent. */
14689
+ id: string(),
14690
+ /** Operator-facing display name. */
14691
+ label: string(),
14692
+ /** 5-field POSIX cron. Empty = disabled cadence (kept for editing). */
14693
+ cron: string(),
14694
+ /** Master on/off toggle for the whole schedule. */
14695
+ enabled: boolean(),
14696
+ /** `backups`-location ids this schedule writes to (fan-out set). */
14697
+ locationIds: array(string()).readonly(),
14698
+ /** Archives kept per targeted location for this schedule. */
14699
+ retentionCount: number().int().min(1).max(1e3),
14700
+ /** Optional subset of source locations to include; omitted = all. */
14701
+ dataSources: array(string()).readonly().optional(),
14702
+ /** ms-epoch of last successful run. */
14703
+ lastRunAt: number().optional(),
14704
+ /** ms-epoch of next computed firing (read-only, filled on list). */
14705
+ nextRunAt: number().optional()
14706
+ });
14114
14707
  method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }), method(object({
14115
14708
  /** Subset of registered `backup-destination` addon ids to write to. */
14116
14709
  destinations: array(string()).optional(),
14117
14710
  locations: array(string()).optional(),
14118
- label: string().optional()
14711
+ label: string().optional(),
14712
+ /**
14713
+ * Per-run retention override applied to every targeted
14714
+ * destination. Used by schedule-driven runs (per-entry
14715
+ * retention). Omitted = each destination's own policy
14716
+ * retention (manual runs).
14717
+ */
14718
+ retentionCount: number().int().min(1).max(1e3).optional()
14119
14719
  }).optional(), array(BackupEntrySchema).readonly(), {
14120
14720
  kind: "mutation",
14121
14721
  auth: "admin"
@@ -14164,7 +14764,21 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
14164
14764
  ok: boolean(),
14165
14765
  error: string().optional(),
14166
14766
  nextRuns: array(number()).readonly()
14167
- }));
14767
+ })), method(_void(), array(BackupScheduleSchema).readonly(), { auth: "admin" }), method(object({
14768
+ id: string().optional(),
14769
+ label: string(),
14770
+ cron: string(),
14771
+ enabled: boolean(),
14772
+ locationIds: array(string()).readonly(),
14773
+ retentionCount: number().int().min(1).max(1e3),
14774
+ dataSources: array(string()).readonly().optional()
14775
+ }), BackupScheduleSchema, {
14776
+ kind: "mutation",
14777
+ auth: "admin"
14778
+ }), method(object({ id: string() }), _void(), {
14779
+ kind: "mutation",
14780
+ auth: "admin"
14781
+ });
14168
14782
  /**
14169
14783
  * `broker` — unified pub/sub broker registry, system-scoped collection.
14170
14784
  *
@@ -15354,851 +15968,942 @@ method(_void(), array(string()).readonly(), { auth: "admin" }), method(object({
15354
15968
  kind: "mutation",
15355
15969
  auth: "admin"
15356
15970
  });
15357
- var LogLevelSchema = _enum([
15358
- "debug",
15359
- "info",
15360
- "warn",
15361
- "error"
15362
- ]);
15363
- var LogEntrySchema = object({
15364
- timestamp: date(),
15365
- level: LogLevelSchema,
15366
- scope: array(string()),
15367
- message: string(),
15368
- meta: record(string(), unknown()).optional(),
15369
- tags: record(string(), string()).optional()
15370
- });
15371
- method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
15372
- scope: array(string()).optional(),
15373
- level: LogLevelSchema.optional(),
15374
- since: date().optional(),
15375
- until: date().optional(),
15376
- limit: number().optional(),
15377
- tags: record(string(), string()).optional()
15378
- }), array(LogEntrySchema).readonly());
15379
- var CpuBreakdownSchema = object({
15380
- total: number(),
15381
- user: number(),
15382
- system: number(),
15383
- irq: number(),
15384
- nice: number(),
15385
- loadAvg: tuple([
15386
- number(),
15387
- number(),
15388
- number()
15389
- ]),
15390
- cores: number()
15391
- });
15392
- var MemoryInfoSchema = object({
15393
- percent: number(),
15394
- totalBytes: number(),
15395
- usedBytes: number(),
15396
- availableBytes: number(),
15397
- swapUsedBytes: number(),
15398
- swapTotalBytes: number()
15399
- });
15400
- var DiskIoSnapshotSchema = object({
15401
- readBytes: number(),
15402
- writeBytes: number(),
15403
- readOps: number(),
15404
- writeOps: number(),
15405
- timestampMs: number()
15406
- });
15407
- var NetworkIoSnapshotSchema = object({
15408
- rxBytes: number(),
15409
- txBytes: number(),
15410
- rxPackets: number(),
15411
- txPackets: number(),
15412
- rxErrors: number(),
15413
- txErrors: number(),
15414
- timestampMs: number()
15971
+ /**
15972
+ * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
15973
+ * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15974
+ * caps stay wire-compatible without a circular cap→cap import.
15975
+ *
15976
+ * Errors are a discriminated-union RESULT, never thrown: the shape survives
15977
+ * every transport tier structurally, and failed calls still write usage rows.
15978
+ * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
15979
+ */
15980
+ var LlmUsageSchema = object({
15981
+ inputTokens: number(),
15982
+ outputTokens: number()
15415
15983
  });
15416
- var MetricsGpuInfoSchema = object({
15417
- utilization: number(),
15984
+ var LlmErrorCodeSchema = _enum([
15985
+ "timeout",
15986
+ "rate-limited",
15987
+ "auth",
15988
+ "refusal",
15989
+ "bad-request",
15990
+ "unavailable",
15991
+ "no-profile",
15992
+ "budget-exceeded",
15993
+ "adapter-error"
15994
+ ]);
15995
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
15996
+ ok: literal(true),
15997
+ text: string(),
15418
15998
  model: string(),
15419
- memoryUsedBytes: number(),
15420
- memoryTotalBytes: number(),
15421
- temperature: number().nullable()
15422
- });
15423
- var ProcessResourceInfoSchema = object({
15424
- openFds: number(),
15425
- threadCount: number(),
15426
- activeHandles: number(),
15427
- activeRequests: number()
15428
- });
15429
- var PressureAvgsSchema = object({
15430
- avg10: number(),
15431
- avg60: number(),
15432
- avg300: number()
15999
+ usage: LlmUsageSchema,
16000
+ truncated: boolean(),
16001
+ latencyMs: number()
16002
+ }), object({
16003
+ ok: literal(false),
16004
+ code: LlmErrorCodeSchema,
16005
+ message: string(),
16006
+ retryAfterMs: number().optional()
16007
+ })]);
16008
+ /**
16009
+ * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
16010
+ * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
16011
+ * notification-output.cap.ts:27-31 precedents).
16012
+ */
16013
+ var LlmImageSchema = object({
16014
+ bytes: _instanceof(Uint8Array),
16015
+ mimeType: string()
15433
16016
  });
15434
- var PressureInfoSchema = object({
15435
- some: PressureAvgsSchema,
15436
- full: PressureAvgsSchema.nullable()
16017
+ var LlmGenerateBaseInputSchema = object({
16018
+ /** Collection routing (the notification-output posture). */
16019
+ addonId: string().optional(),
16020
+ /** Explicit profile; else the resolution chain (spec §3). */
16021
+ profileId: string().optional(),
16022
+ /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
16023
+ consumer: string(),
16024
+ system: string().optional(),
16025
+ /** v1: single-turn. `messages[]` is a v2 additive field. */
16026
+ prompt: string(),
16027
+ /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
16028
+ jsonSchema: record(string(), unknown()).optional(),
16029
+ /** Per-call override of the profile default. */
16030
+ maxTokens: number().int().positive().optional(),
16031
+ temperature: number().optional()
15437
16032
  });
15438
- var SystemResourceSnapshotSchema = object({
15439
- cpu: CpuBreakdownSchema,
15440
- memory: MemoryInfoSchema,
15441
- gpu: MetricsGpuInfoSchema.nullable(),
15442
- network: NetworkIoSnapshotSchema,
15443
- disk: DiskIoSnapshotSchema,
15444
- pressure: object({
15445
- cpu: PressureInfoSchema.nullable(),
15446
- memory: PressureInfoSchema.nullable(),
15447
- io: PressureInfoSchema.nullable()
16033
+ /**
16034
+ * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
16035
+ * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
16036
+ * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
16037
+ * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
16038
+ * this only through the `llm` cap's methods.
16039
+ *
16040
+ * One running llama-server child per node in v1 (models are RAM-heavy).
16041
+ * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
16042
+ * watchdog — operator decision #3).
16043
+ */
16044
+ var ManagedModelRefSchema = discriminatedUnion("kind", [
16045
+ object({
16046
+ kind: literal("catalog"),
16047
+ catalogId: string()
15448
16048
  }),
15449
- process: ProcessResourceInfoSchema,
15450
- cpuTemperature: number().nullable(),
15451
- timestampMs: number()
15452
- });
15453
- var DiskSpaceInfoSchema = object({
15454
- path: string(),
15455
- totalBytes: number(),
15456
- usedBytes: number(),
15457
- availableBytes: number(),
15458
- percent: number()
15459
- });
15460
- var PidResourceStatsSchema = object({
15461
- pid: number(),
15462
- cpu: number(),
15463
- memory: number(),
15464
- /**
15465
- * Private (anonymous) resident bytes — the per-process V8 heap + native
15466
- * allocations NOT shared with other processes (Linux RssAnon). This is the
15467
- * "real" per-runner cost; summing it across runners is meaningful, unlike
15468
- * `memory` (RSS), which double-counts the shared mmap'd framework code.
15469
- * Undefined where /proc is unavailable (e.g. macOS).
15470
- */
15471
- privateBytes: number().optional(),
15472
- /**
15473
- * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
15474
- * code shared copy-on-write across runners. Undefined on macOS.
15475
- */
15476
- sharedBytes: number().optional()
16049
+ object({
16050
+ kind: literal("url"),
16051
+ url: string(),
16052
+ sha256: string().optional()
16053
+ }),
16054
+ object({
16055
+ kind: literal("path"),
16056
+ path: string()
16057
+ })
16058
+ ]);
16059
+ var ManagedRuntimeConfigSchema = object({
16060
+ /** WHERE the runtime lives — hub or any agent. */
16061
+ nodeId: string(),
16062
+ /** Closed for v1; 'ollama' is a v2 candidate. */
16063
+ engine: _enum(["llama-cpp"]),
16064
+ model: ManagedModelRefSchema,
16065
+ contextSize: number().int().default(4096),
16066
+ /** 0 = CPU-only. */
16067
+ gpuLayers: number().int().default(0),
16068
+ /** Default: cpus-2, clamped ≥1 (resolved node-side). */
16069
+ threads: number().int().optional(),
16070
+ /** Concurrent slots. */
16071
+ parallel: number().int().default(1),
16072
+ /** Else lazy: first generate boots it. */
16073
+ autoStart: boolean().default(false),
16074
+ /** 0 = never; frees RAM after quiet periods. */
16075
+ idleStopMinutes: number().int().default(30)
15477
16076
  });
15478
- var AddonInstanceSchema = object({
15479
- addonId: string(),
16077
+ var LlmRuntimeStatusSchema = object({
16078
+ /** Status is ALWAYS node-qualified. */
15480
16079
  nodeId: string(),
15481
- role: _enum(["hub", "worker"]),
15482
- pid: number(),
15483
16080
  state: _enum([
15484
- "starting",
15485
- "running",
15486
- "stopping",
15487
16081
  "stopped",
15488
- "crashed"
15489
- ]),
15490
- uptimeSec: number()
15491
- });
15492
- var NodeProcessSchema = object({
15493
- pid: number(),
15494
- ppid: number(),
15495
- pgid: number(),
15496
- classification: _enum([
15497
- "root",
15498
- "managed",
15499
- "system",
15500
- "ghost"
16082
+ "downloading",
16083
+ "starting",
16084
+ "ready",
16085
+ "crashed",
16086
+ "failed"
15501
16087
  ]),
15502
- /** `$process` addon binding when `managed`, else null. */
15503
- addonId: string().nullable(),
15504
- /** Kernel-reported nodeId when the process is a known agent/worker. */
15505
- nodeId: string().nullable(),
15506
- /** Truncated command line. */
15507
- command: string(),
15508
- cpuPercent: number(),
15509
- memoryRssBytes: number(),
15510
- /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
15511
- uptimeSec: number(),
15512
- /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
15513
- orphaned: boolean()
16088
+ pid: number().optional(),
16089
+ port: number().optional(),
16090
+ modelPath: string().optional(),
16091
+ modelId: string().optional(),
16092
+ downloadProgress: number().min(0).max(1).optional(),
16093
+ lastError: string().optional(),
16094
+ crashesInWindow: number(),
16095
+ /** Child RSS (sampled best-effort). */
16096
+ memoryBytes: number().optional(),
16097
+ vramBytes: number().optional()
15514
16098
  });
15515
- var KillProcessInputSchema = object({
15516
- pid: number(),
15517
- /** Force = SIGKILL. Default is SIGTERM. */
15518
- force: boolean().optional()
16099
+ var LlmNodeModelSchema = object({
16100
+ file: string(),
16101
+ sizeBytes: number(),
16102
+ catalogId: string().optional(),
16103
+ installedAt: number().optional()
15519
16104
  });
15520
- var KillProcessResultSchema = object({
15521
- success: boolean(),
15522
- reason: string().optional(),
15523
- signal: _enum(["SIGTERM", "SIGKILL"]).optional()
15524
- });
15525
- var DumpHeapSnapshotInputSchema = object({
15526
- /** The addon whose runner should dump a heap snapshot. */
15527
- addonId: string() });
15528
- var DumpHeapSnapshotResultSchema = object({
15529
- success: boolean(),
15530
- /** Path of the written .heapsnapshot inside the runner's container/host. */
15531
- path: string().optional(),
15532
- /** Process pid that was signalled. */
15533
- pid: number().optional(),
15534
- reason: string().optional()
15535
- });
15536
- var SystemMetricsSchema = object({
15537
- cpuPercent: number(),
15538
- memoryPercent: number(),
15539
- memoryUsedMB: number(),
15540
- memoryTotalMB: number(),
15541
- diskPercent: number().optional(),
15542
- temperature: number().optional(),
15543
- gpuPercent: number().optional(),
15544
- gpuMemoryPercent: number().optional()
16105
+ var LlmRuntimeDiskUsageSchema = object({
16106
+ nodeId: string(),
16107
+ modelsBytes: number(),
16108
+ freeBytes: number().optional()
15545
16109
  });
15546
- 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, {
16110
+ method(LlmGenerateBaseInputSchema.extend({
16111
+ images: array(LlmImageSchema).optional(),
16112
+ runtime: ManagedRuntimeConfigSchema,
16113
+ /** The managed profile's timeout, threaded by the hub provider. */
16114
+ timeoutMs: number().int().positive().optional()
16115
+ }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
15547
16116
  kind: "mutation",
15548
16117
  auth: "admin"
15549
- }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
16118
+ }), method(object({}), _void(), {
15550
16119
  kind: "mutation",
15551
16120
  auth: "admin"
15552
- });
15553
- method(object({
15554
- sourceUrl: string(),
15555
- metadata: ModelConvertMetadataSchema,
15556
- targets: array(ConvertTargetSchema).min(1).readonly(),
15557
- calibrationRef: string().optional(),
15558
- sessionId: string().optional()
15559
- }), ConvertResultSchema, {
16121
+ }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
15560
16122
  kind: "mutation",
15561
- auth: "admin",
15562
- timeoutMs: 6e5
15563
- });
15564
- method(object({
15565
- nodeId: string(),
15566
- modelId: string(),
15567
- format: _enum(MODEL_FORMATS),
15568
- entry: ModelCatalogEntrySchema
15569
- }), object({
15570
- ok: boolean(),
15571
- /** sha256 of the staged tarball (empty for a hub-local no-op). */
15572
- sha256: string(),
15573
- bytes: number(),
15574
- /** The target node's modelsDir the artifact landed in. */
15575
- path: string()
15576
- }), {
16123
+ auth: "admin"
16124
+ }), method(object({ file: string() }), _void(), {
15577
16125
  kind: "mutation",
15578
16126
  auth: "admin"
15579
- });
15580
- /**
15581
- * `mqtt-broker` — broker-registry cap.
15582
- *
15583
- * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
15584
- * MQTT brokers (external + optionally an embedded `aedes`-backed one)
15585
- * and (b) the connection details a consumer addon needs to spin up
15586
- * its OWN `mqtt.js` client.
15587
- *
15588
- * Why: pub/sub routing over the system event-bus loses fidelity
15589
- * (callback shape, QoS guarantees, will/retain semantics) and adds
15590
- * refcount bookkeeping that addons would rather own themselves. The
15591
- * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
15592
- * features anyway — give it the connection config, get out of the way.
15593
- *
15594
- * Consumer flow:
15595
- * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
15596
- * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
15597
- * client.subscribe('zigbee2mqtt/+')
15598
- *
15599
- * Collection mode: multiple brokers (e.g. one local mosquitto + one
15600
- * cloud bridge). The "embedded" entry (when present) is just another
15601
- * broker in the registry — its lifecycle is owned by the addon that
15602
- * spawned it.
15603
- */
15604
- var BrokerKindSchema = _enum(["external", "embedded"]);
16127
+ }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
15605
16128
  /**
15606
- * Broker live-probe status.
16129
+ * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
16130
+ * methods concat-fan across providers; single-row methods route to ONE
16131
+ * provider by the `addonId` in the call input (the notification-output
16132
+ * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
16133
+ * (hub-placed); the cap stays open for future providers.
15607
16134
  *
15608
- * - `connected` last probe completed a clean CONNACK
15609
- * - `disconnected` — no probe has run yet (cold cache)
15610
- * - `auth-failed` CONNACK refused with auth error (RC 4 / 5)
15611
- * - `unreachable` — TCP connect timed out / refused
15612
- * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
16135
+ * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
16136
+ * `apiKey` is a password field providers REDACT it on read and merge on
16137
+ * write; a stored key NEVER round-trips to a client.
15613
16138
  */
15614
- var BrokerStatusSchema$1 = _enum([
15615
- "connected",
15616
- "disconnected",
15617
- "auth-failed",
15618
- "unreachable",
15619
- "tls-error"
16139
+ var LlmProfileKindSchema = _enum([
16140
+ "openai-compatible",
16141
+ "openai",
16142
+ "anthropic",
16143
+ "google",
16144
+ "managed-local"
15620
16145
  ]);
15621
- var BrokerInfoSchema = object({
16146
+ var LlmProfileSchema = object({
15622
16147
  id: string(),
15623
16148
  name: string(),
15624
- url: string(),
15625
- kind: BrokerKindSchema,
15626
- status: BrokerStatusSchema$1,
15627
- latencyMs: number().nullable(),
15628
- error: string().optional(),
15629
- /** Embedded brokers only: number of MQTT clients currently connected. */
15630
- connectedClients: number().int().nonnegative().optional(),
15631
- /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
15632
- lastCheckedAt: number().optional()
16149
+ kind: LlmProfileKindSchema,
16150
+ /** Stamped by the provider — keeps the fanned catalog routable. */
16151
+ addonId: string(),
16152
+ enabled: boolean(),
16153
+ /** Vendor model id, or the managed runtime's loaded model. */
16154
+ model: string(),
16155
+ /** Required for openai-compatible; override for cloud kinds. */
16156
+ baseUrl: string().optional(),
16157
+ /** ConfigUISchema type:'password' — never round-trips (spec §5). */
16158
+ apiKey: string().optional(),
16159
+ supportsVision: boolean(),
16160
+ temperature: number().min(0).max(2).optional(),
16161
+ maxTokens: number().int().positive().optional(),
16162
+ timeoutMs: number().int().positive().default(6e4),
16163
+ extraHeaders: record(string(), string()).optional(),
16164
+ /** kind === 'managed-local' only (spec §4). */
16165
+ runtime: ManagedRuntimeConfigSchema.optional()
15633
16166
  });
15634
- /**
15635
- * Connection details — what a consumer needs to call
15636
- * `mqtt.connect(url, options)`. We split URL + credentials so the
15637
- * consumer can pass them as `mqtt.connect(url, { username, password })`
15638
- * instead of stuffing creds into the URL (which leaks them into logs).
15639
- */
15640
- var BrokerConnectionDetailsSchema = object({
15641
- url: string(),
15642
- username: string().optional(),
15643
- password: string().optional(),
15644
- /**
15645
- * Suggested prefix for `clientId`. Each consumer should suffix this
15646
- * with its own discriminator (addon id, instance id) so reconnects
15647
- * don't kick each other off (MQTT spec: clientId must be unique per
15648
- * broker).
15649
- */
15650
- clientIdPrefix: string().optional()
16167
+ /** ConfigUISchema tree passed through untyped on the wire (the
16168
+ * notification-output `ConfigSchemaPassthrough` precedent at
16169
+ * notification-output.cap.ts:151); the exported TS type re-tightens it. */
16170
+ var ConfigSchemaPassthrough$1 = unknown();
16171
+ var LlmProfileKindDescriptorSchema = object({
16172
+ kind: LlmProfileKindSchema,
16173
+ label: string(),
16174
+ icon: string(),
16175
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
16176
+ addonId: string(),
16177
+ configSchema: ConfigSchemaPassthrough$1
15651
16178
  });
15652
- var AddBrokerInputSchema = object({
15653
- name: string().min(1),
15654
- url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
15655
- username: string().optional(),
15656
- password: string().optional(),
15657
- clientIdPrefix: string().optional()
16179
+ var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
16180
+ var LlmDefaultSchema = object({
16181
+ selector: LlmDefaultSelectorSchema,
16182
+ profileId: string()
15658
16183
  });
15659
- var AddBrokerResultSchema = object({ id: string() });
15660
- var IdInputSchema = object({ id: string() });
15661
- var TestResultSchema$1 = discriminatedUnion("ok", [object({
15662
- ok: literal(true),
15663
- latencyMs: number()
15664
- }), object({
15665
- ok: literal(false),
15666
- error: string()
15667
- })]);
15668
- var StartEmbeddedInputSchema = object({
15669
- port: number().int().min(1).max(65535).default(1883),
15670
- /** Allow anonymous connect (no username/password). Default: false. */
15671
- allowAnonymous: boolean().default(false),
15672
- /** Optional shared username/password for clients. */
15673
- username: string().optional(),
15674
- password: string().optional()
16184
+ /** Server-side rollup row getUsage never dumps raw call rows (spec §6). */
16185
+ var LlmUsageRollupSchema = object({
16186
+ day: string(),
16187
+ consumer: string(),
16188
+ profileId: string(),
16189
+ calls: number(),
16190
+ okCalls: number(),
16191
+ errorCalls: number(),
16192
+ inputTokens: number(),
16193
+ outputTokens: number(),
16194
+ avgLatencyMs: number()
15675
16195
  });
15676
- var StartEmbeddedResultSchema = object({
16196
+ /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
16197
+ var ManagedModelCatalogEntrySchema = object({
15677
16198
  id: string(),
15678
- url: string()
15679
- });
15680
- var StatusSchema = object({
15681
- brokerCount: number(),
15682
- embeddedRunning: boolean()
15683
- });
15684
- 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);
15685
- var NetworkEndpointSchema = object({
16199
+ label: string(),
16200
+ family: string(),
16201
+ purpose: _enum(["text", "vision"]),
15686
16202
  url: string(),
15687
- hostname: string(),
15688
- port: number(),
15689
- protocol: _enum(["http", "https"])
16203
+ sha256: string(),
16204
+ sizeBytes: number(),
16205
+ quantization: string(),
16206
+ /** Load-time guidance shown in the picker. */
16207
+ minRamBytes: number(),
16208
+ contextSizeDefault: number().int(),
16209
+ /** Vision models: companion projector file. */
16210
+ mmprojUrl: string().optional()
15690
16211
  });
15691
- var NetworkAccessStatusSchema = object({
15692
- connected: boolean(),
15693
- endpoint: NetworkEndpointSchema.nullable(),
16212
+ var LlmRuntimeNodeSchema = object({
16213
+ nodeId: string(),
16214
+ reachable: boolean(),
16215
+ status: LlmRuntimeStatusSchema.optional(),
16216
+ disk: LlmRuntimeDiskUsageSchema.optional(),
15694
16217
  error: string().optional()
15695
16218
  });
15696
- /**
15697
- * Optional, richer endpoint shape returned by providers that expose
15698
- * MORE than one ingress concurrently (Tailscale Ingress with mixed
15699
- * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
15700
- * the originating provider config (mode + sourcePort) so the
15701
- * orchestrator UI can label rows distinctly. Providers that expose only
15702
- * one endpoint just omit `listEndpoints` from their provider impl.
15703
- */
15704
- var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
15705
- /**
15706
- * Stable id within the provider — typically `<mode>-<sourcePort>` so
15707
- * the orchestrator can dedupe across `listEndpoints` polls.
15708
- */
15709
- id: string(),
15710
- /** Operator-facing label (mirrors `MeshEndpoint.label`). */
15711
- label: string(),
15712
- /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
15713
- mode: string().optional(),
15714
- /** Originating local port the ingress fronts (informational). */
15715
- sourcePort: number().optional()
16219
+ var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
16220
+ var ProfileRefInputSchema = object({
16221
+ addonId: string(),
16222
+ profileId: string()
15716
16223
  });
15717
- method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
16224
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
16225
+ kind: "mutation",
16226
+ auth: "admin"
16227
+ }), method(ProfileRefInputSchema, _void(), {
16228
+ kind: "mutation",
16229
+ auth: "admin"
16230
+ }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
16231
+ kind: "mutation",
16232
+ auth: "admin"
16233
+ }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
16234
+ selector: LlmDefaultSelectorSchema,
16235
+ profileId: string().nullable()
16236
+ }), _void(), {
16237
+ kind: "mutation",
16238
+ auth: "admin"
16239
+ }), method(object({
16240
+ since: number().optional(),
16241
+ until: number().optional(),
16242
+ consumer: string().optional(),
16243
+ profileId: string().optional()
16244
+ }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
16245
+ nodeId: string(),
16246
+ model: ManagedModelRefSchema
16247
+ }), _void(), {
16248
+ kind: "mutation",
16249
+ auth: "admin"
16250
+ }), method(object({
16251
+ nodeId: string(),
16252
+ file: string()
16253
+ }), _void(), {
16254
+ kind: "mutation",
16255
+ auth: "admin"
16256
+ }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
16257
+ kind: "mutation",
16258
+ auth: "admin"
16259
+ }), method(ProfileRefInputSchema, _void(), {
16260
+ kind: "mutation",
16261
+ auth: "admin"
16262
+ });
16263
+ var LogLevelSchema = _enum([
16264
+ "debug",
16265
+ "info",
16266
+ "warn",
16267
+ "error"
16268
+ ]);
16269
+ var LogEntrySchema = object({
16270
+ timestamp: date(),
16271
+ level: LogLevelSchema,
16272
+ scope: array(string()),
16273
+ message: string(),
16274
+ meta: record(string(), unknown()).optional(),
16275
+ tags: record(string(), string()).optional()
16276
+ });
16277
+ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16278
+ scope: array(string()).optional(),
16279
+ level: LogLevelSchema.optional(),
16280
+ since: date().optional(),
16281
+ until: date().optional(),
16282
+ limit: number().optional(),
16283
+ tags: record(string(), string()).optional()
16284
+ }), array(LogEntrySchema).readonly());
15718
16285
  /**
15719
- * notification-outputcanonical, capability-gated notification delivery.
16286
+ * `login-method`collection cap through which auth addons contribute
16287
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
16288
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
16289
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
16290
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
16291
+ * procedure aggregates them for the unauthenticated login page.
15720
16292
  *
15721
- * Apprise-derived model (see
15722
- * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
15723
- * callers emit ONE canonical `Notification`; each provider declares a
15724
- * per-kind capability descriptor (`TargetKind`), and the pure degrade
15725
- * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
15726
- * message to what the kind supports — callers never special-case a service.
16293
+ * A contribution is a discriminated union on `kind`:
15727
16294
  *
15728
- * DESIGN DECISIONS (locked):
15729
- * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
15730
- * `setTargetEnabled`), each provider persisting via the `settings-store`
15731
- * cap. Rationale: the admin UI needs one uniform surface across the
15732
- * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
15733
- * alternative would fork the UI per addon and cannot host the
15734
- * discovery→adopt flow.
15735
- * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
15736
- * the generated cap-mount auto-`concatCollection`-fans them across every
15737
- * registered provider (notifiers addon + HA addon) so one catalog is
15738
- * routable. `send` / `testTarget` / CRUD route to ONE provider by the
15739
- * `addonId` the generated collection router extracts from the call input.
15740
- * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
15741
- * transformer) + UDS MsgPack both round-trip typed arrays — already used by
15742
- * `storage` / `storage-provider` / `recording` caps over the same path. No
15743
- * base64 fallback needed.
16295
+ * - `redirect` a declarative button. The login page renders a generic
16296
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
16297
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
16298
+ * ZERO shell-side JS. A future SSO addon plugs in the same way the
16299
+ * login page needs NO change.
15744
16300
  *
15745
- * TODO (deferred, closed-set change separate decision): add
15746
- * `providerKind: 'notify'` so notification providers surface on the unified
15747
- * admin "Integrations" page.
15748
- */
15749
- /**
15750
- * Zentik-derived typed-media enum — the superset across every kind. Each
15751
- * adapter picks what it supports and the degrade engine filters the rest.
15752
- */
15753
- var AttachmentMediaTypeSchema = _enum([
15754
- "image",
15755
- "video",
15756
- "gif",
15757
- "audio",
15758
- "icon"
15759
- ]);
15760
- /**
15761
- * A single attachment. Exactly one of `url` (remote source, most adapters
15762
- * prefer this) or `bytes` (inline source; required for Pushover-style
15763
- * bytes-only kinds) MUST be present the degrade engine expresses a
15764
- * url→bytes fetch as a `needsFetch` directive the adapter executes.
16301
+ * - `widget` a Module-Federation widget the login page mounts (via
16302
+ * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
16303
+ * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
16304
+ * mechanism kept for future use; no shipped addon uses it on the login
16305
+ * page (the passkey ceremony below runs natively in the shell instead).
16306
+ *
16307
+ * - `passkey` a declarative WebAuthn ceremony the shell renders
16308
+ * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
16309
+ * a remotely-loaded bundle). Carries the addon's effective `rpId` /
16310
+ * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
16311
+ * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
16312
+ * fetching any remote code pre-auth. Contribution stays unconditional —
16313
+ * enrollment state is never leaked pre-auth; visibility is a shell
16314
+ * decision.
16315
+ *
16316
+ * Every contribution carries a `stage`:
16317
+ * - `primary` — shown on the first credentials screen (OIDC /
16318
+ * magic-link buttons; a future usernameless passkey).
16319
+ * - `second-factor` — shown AFTER the password leg, gated on the
16320
+ * returned `factors` (passkey-as-2FA today).
16321
+ *
16322
+ * `mount: skip` — the cap is read server-side by the core auth router
16323
+ * (`registry.getCollection('login-method')`), never mounted as its own
16324
+ * tRPC router.
15765
16325
  */
15766
- var AttachmentSchema = object({
15767
- mediaType: AttachmentMediaTypeSchema,
15768
- url: string().optional(),
15769
- bytes: _instanceof(Uint8Array).optional(),
15770
- mime: string().optional(),
15771
- name: string().optional()
15772
- }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
15773
- var NotificationFormatSchema = _enum([
15774
- "text",
15775
- "markdown",
15776
- "html"
16326
+ /** When a login method renders in the two-phase login flow. */
16327
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
16328
+ /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
16329
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [
16330
+ object({
16331
+ kind: literal("redirect"),
16332
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
16333
+ id: string(),
16334
+ /** Operator-facing button label. */
16335
+ label: string(),
16336
+ /** lucide-react icon name. */
16337
+ icon: string().optional(),
16338
+ /** Addon-owned HTTP route the button navigates to (GET). */
16339
+ startUrl: string(),
16340
+ stage: LoginStageEnum
16341
+ }),
16342
+ object({
16343
+ kind: literal("widget"),
16344
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
16345
+ id: string(),
16346
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
16347
+ addonId: string(),
16348
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
16349
+ bundle: string(),
16350
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
16351
+ remote: WidgetRemoteSchema,
16352
+ stage: LoginStageEnum
16353
+ }),
16354
+ object({
16355
+ kind: literal("passkey"),
16356
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
16357
+ id: string(),
16358
+ /** Operator-facing button label. */
16359
+ label: string(),
16360
+ stage: LoginStageEnum,
16361
+ /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
16362
+ rpId: string(),
16363
+ /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
16364
+ origin: string().nullable()
16365
+ })
15777
16366
  ]);
15778
- /** A single tap-through action button. */
15779
- var NotificationActionSchema = object({
15780
- id: string(),
15781
- label: string(),
15782
- url: string().optional()
16367
+ var loginMethodCapability = {
16368
+ name: "login-method",
16369
+ scope: "system",
16370
+ mode: "collection",
16371
+ internal: true,
16372
+ methods: { getLoginMethods: method(_void(), array(LoginMethodContributionSchema).readonly()) },
16373
+ /** BIG PLAN 2: declarative mount hint — read by `@camstack/system` `buildCapRouters`. */
16374
+ mount: { kind: "skip" }
16375
+ };
16376
+ var CpuBreakdownSchema = object({
16377
+ total: number(),
16378
+ user: number(),
16379
+ system: number(),
16380
+ irq: number(),
16381
+ nice: number(),
16382
+ loadAvg: tuple([
16383
+ number(),
16384
+ number(),
16385
+ number()
16386
+ ]),
16387
+ cores: number()
15783
16388
  });
15784
- /**
15785
- * The canonical notification. `body` is the only hard field (Apprise model).
15786
- * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
15787
- * NOT a fixed severity enum — each kind declares its own `caps.levels` and
15788
- * the adapter maps this ordinal onto its native level. `level?` is an
15789
- * optional kind-native level id (`emergency`, `silent`, …) that overrides
15790
- * `priority` for that one target.
15791
- */
15792
- var NotificationSchema = object({
15793
- body: string(),
15794
- title: string().optional(),
15795
- format: NotificationFormatSchema.default("text"),
15796
- priority: number().int().min(1).max(5).default(3),
15797
- level: string().optional(),
15798
- attachments: array(AttachmentSchema).optional(),
15799
- clickUrl: string().optional(),
15800
- actions: array(NotificationActionSchema).optional(),
15801
- sound: string().optional(),
15802
- ttl: number().optional(),
15803
- tag: string().optional(),
15804
- deviceId: number().optional(),
15805
- eventId: string().optional(),
15806
- metadata: record(string(), unknown()).optional()
16389
+ var MemoryInfoSchema = object({
16390
+ percent: number(),
16391
+ totalBytes: number(),
16392
+ usedBytes: number(),
16393
+ availableBytes: number(),
16394
+ swapUsedBytes: number(),
16395
+ swapTotalBytes: number()
16396
+ });
16397
+ var DiskIoSnapshotSchema = object({
16398
+ readBytes: number(),
16399
+ writeBytes: number(),
16400
+ readOps: number(),
16401
+ writeOps: number(),
16402
+ timestampMs: number()
16403
+ });
16404
+ var NetworkIoSnapshotSchema = object({
16405
+ rxBytes: number(),
16406
+ txBytes: number(),
16407
+ rxPackets: number(),
16408
+ txPackets: number(),
16409
+ rxErrors: number(),
16410
+ txErrors: number(),
16411
+ timestampMs: number()
16412
+ });
16413
+ var MetricsGpuInfoSchema = object({
16414
+ utilization: number(),
16415
+ model: string(),
16416
+ memoryUsedBytes: number(),
16417
+ memoryTotalBytes: number(),
16418
+ temperature: number().nullable()
16419
+ });
16420
+ var ProcessResourceInfoSchema = object({
16421
+ openFds: number(),
16422
+ threadCount: number(),
16423
+ activeHandles: number(),
16424
+ activeRequests: number()
15807
16425
  });
15808
- /** One declared native severity/priority level for a kind. */
15809
- var TargetKindLevelSchema = object({
15810
- id: string(),
15811
- label: string(),
15812
- /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
15813
- ordinal: number().int().min(1).max(5).nullable(),
15814
- flags: object({
15815
- critical: boolean().optional(),
15816
- silent: boolean().optional(),
15817
- noPush: boolean().optional()
15818
- }).optional(),
15819
- /** e.g. Pushover `emergency` requires `retry` / `expire`. */
15820
- requires: array(string()).optional(),
15821
- description: string().optional()
16426
+ var PressureAvgsSchema = object({
16427
+ avg10: number(),
16428
+ avg60: number(),
16429
+ avg300: number()
15822
16430
  });
15823
- /** The full capability block consulted before dispatch. */
15824
- var TargetKindCapsSchema = object({
15825
- attachments: object({
15826
- mediaTypes: array(AttachmentMediaTypeSchema),
15827
- mode: _enum([
15828
- "url",
15829
- "bytes",
15830
- "both"
15831
- ]),
15832
- max: number().int().nonnegative(),
15833
- maxBytes: number().int().positive().optional()
16431
+ var PressureInfoSchema = object({
16432
+ some: PressureAvgsSchema,
16433
+ full: PressureAvgsSchema.nullable()
16434
+ });
16435
+ var SystemResourceSnapshotSchema = object({
16436
+ cpu: CpuBreakdownSchema,
16437
+ memory: MemoryInfoSchema,
16438
+ gpu: MetricsGpuInfoSchema.nullable(),
16439
+ network: NetworkIoSnapshotSchema,
16440
+ disk: DiskIoSnapshotSchema,
16441
+ pressure: object({
16442
+ cpu: PressureInfoSchema.nullable(),
16443
+ memory: PressureInfoSchema.nullable(),
16444
+ io: PressureInfoSchema.nullable()
15834
16445
  }),
15835
- /** Max action buttons (0 = none). */
15836
- actions: number().int().nonnegative(),
15837
- levels: array(TargetKindLevelSchema),
15838
- format: array(NotificationFormatSchema),
15839
- clickUrl: boolean(),
15840
- sound: boolean(),
15841
- ttl: boolean(),
15842
- bodyMaxLen: number().int().positive()
16446
+ process: ProcessResourceInfoSchema,
16447
+ cpuTemperature: number().nullable(),
16448
+ timestampMs: number()
15843
16449
  });
15844
- /**
15845
- * `configSchema` is a `ConfigUISchema` tree passed through to the admin
15846
- * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
15847
- * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`)
15848
- * the union is large and not meant for runtime validation here; the exported
15849
- * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
15850
- */
15851
- var ConfigSchemaPassthrough$1 = unknown();
15852
- var TargetKindSchema = object({
15853
- kind: string(),
15854
- label: string(),
15855
- icon: string(),
15856
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
15857
- addonId: string(),
15858
- configSchema: ConfigSchemaPassthrough$1,
15859
- supportsDiscovery: boolean(),
15860
- caps: TargetKindCapsSchema
16450
+ var DiskSpaceInfoSchema = object({
16451
+ path: string(),
16452
+ totalBytes: number(),
16453
+ usedBytes: number(),
16454
+ availableBytes: number(),
16455
+ percent: number()
15861
16456
  });
15862
- /**
15863
- * A persisted target. `config` holds secrets; providers REDACT secret fields
15864
- * (return a presence marker only) when serving `listTargets` — never
15865
- * round-trip a stored secret to the UI.
15866
- */
15867
- var TargetSchema = object({
15868
- id: string(),
15869
- name: string(),
15870
- kind: string(),
16457
+ var PidResourceStatsSchema = object({
16458
+ pid: number(),
16459
+ cpu: number(),
16460
+ memory: number(),
16461
+ /**
16462
+ * Private (anonymous) resident bytes — the per-process V8 heap + native
16463
+ * allocations NOT shared with other processes (Linux RssAnon). This is the
16464
+ * "real" per-runner cost; summing it across runners is meaningful, unlike
16465
+ * `memory` (RSS), which double-counts the shared mmap'd framework code.
16466
+ * Undefined where /proc is unavailable (e.g. macOS).
16467
+ */
16468
+ privateBytes: number().optional(),
16469
+ /**
16470
+ * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
16471
+ * code shared copy-on-write across runners. Undefined on macOS.
16472
+ */
16473
+ sharedBytes: number().optional()
16474
+ });
16475
+ var AddonInstanceSchema = object({
15871
16476
  addonId: string(),
15872
- enabled: boolean(),
15873
- config: record(string(), unknown())
16477
+ nodeId: string(),
16478
+ role: _enum(["hub", "worker"]),
16479
+ pid: number(),
16480
+ state: _enum([
16481
+ "starting",
16482
+ "running",
16483
+ "stopping",
16484
+ "stopped",
16485
+ "crashed"
16486
+ ]),
16487
+ uptimeSec: number()
15874
16488
  });
15875
- /** A discovery-surfaced candidate (config is partial + non-secret). */
15876
- var DiscoveredTargetSchema = object({
15877
- kind: string(),
15878
- suggestedName: string(),
15879
- config: record(string(), unknown())
16489
+ var NodeProcessSchema = object({
16490
+ pid: number(),
16491
+ ppid: number(),
16492
+ pgid: number(),
16493
+ classification: _enum([
16494
+ "root",
16495
+ "managed",
16496
+ "system",
16497
+ "ghost"
16498
+ ]),
16499
+ /** `$process` addon binding when `managed`, else null. */
16500
+ addonId: string().nullable(),
16501
+ /** Kernel-reported nodeId when the process is a known agent/worker. */
16502
+ nodeId: string().nullable(),
16503
+ /** Truncated command line. */
16504
+ command: string(),
16505
+ cpuPercent: number(),
16506
+ memoryRssBytes: number(),
16507
+ /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
16508
+ uptimeSec: number(),
16509
+ /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
16510
+ orphaned: boolean()
15880
16511
  });
15881
- /** The degrade engine's report — what was resolved / dropped / degraded. */
15882
- var RenderedAsSchema = object({
15883
- level: string(),
15884
- format: NotificationFormatSchema,
15885
- attachmentsSent: number().int().nonnegative(),
15886
- actionsSent: number().int().nonnegative(),
15887
- truncated: boolean(),
15888
- dropped: array(string())
16512
+ var KillProcessInputSchema = object({
16513
+ pid: number(),
16514
+ /** Force = SIGKILL. Default is SIGTERM. */
16515
+ force: boolean().optional()
15889
16516
  });
15890
- var SendResultSchema = object({
16517
+ var KillProcessResultSchema = object({
16518
+ success: boolean(),
16519
+ reason: string().optional(),
16520
+ signal: _enum(["SIGTERM", "SIGKILL"]).optional()
16521
+ });
16522
+ var DumpHeapSnapshotInputSchema = object({
16523
+ /** The addon whose runner should dump a heap snapshot. */
16524
+ addonId: string() });
16525
+ var DumpHeapSnapshotResultSchema = object({
15891
16526
  success: boolean(),
16527
+ /** Path of the written .heapsnapshot inside the runner's container/host. */
16528
+ path: string().optional(),
16529
+ /** Process pid that was signalled. */
16530
+ pid: number().optional(),
16531
+ reason: string().optional()
16532
+ });
16533
+ var SystemMetricsSchema = object({
16534
+ cpuPercent: number(),
16535
+ memoryPercent: number(),
16536
+ memoryUsedMB: number(),
16537
+ memoryTotalMB: number(),
16538
+ diskPercent: number().optional(),
16539
+ temperature: number().optional(),
16540
+ gpuPercent: number().optional(),
16541
+ gpuMemoryPercent: number().optional()
16542
+ });
16543
+ 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, {
16544
+ kind: "mutation",
16545
+ auth: "admin"
16546
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
16547
+ kind: "mutation",
16548
+ auth: "admin"
16549
+ });
16550
+ method(object({
16551
+ sourceUrl: string(),
16552
+ metadata: ModelConvertMetadataSchema,
16553
+ targets: array(ConvertTargetSchema).min(1).readonly(),
16554
+ calibrationRef: string().optional(),
16555
+ sessionId: string().optional()
16556
+ }), ConvertResultSchema, {
16557
+ kind: "mutation",
16558
+ auth: "admin",
16559
+ timeoutMs: 6e5
16560
+ });
16561
+ method(object({
16562
+ nodeId: string(),
16563
+ modelId: string(),
16564
+ format: _enum(MODEL_FORMATS),
16565
+ entry: ModelCatalogEntrySchema
16566
+ }), object({
16567
+ ok: boolean(),
16568
+ /** sha256 of the staged tarball (empty for a hub-local no-op). */
16569
+ sha256: string(),
16570
+ bytes: number(),
16571
+ /** The target node's modelsDir the artifact landed in. */
16572
+ path: string()
16573
+ }), {
16574
+ kind: "mutation",
16575
+ auth: "admin"
16576
+ });
16577
+ /**
16578
+ * `mqtt-broker` — broker-registry cap.
16579
+ *
16580
+ * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
16581
+ * MQTT brokers (external + optionally an embedded `aedes`-backed one)
16582
+ * and (b) the connection details a consumer addon needs to spin up
16583
+ * its OWN `mqtt.js` client.
16584
+ *
16585
+ * Why: pub/sub routing over the system event-bus loses fidelity
16586
+ * (callback shape, QoS guarantees, will/retain semantics) and adds
16587
+ * refcount bookkeeping that addons would rather own themselves. The
16588
+ * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
16589
+ * features anyway — give it the connection config, get out of the way.
16590
+ *
16591
+ * Consumer flow:
16592
+ * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
16593
+ * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
16594
+ * client.subscribe('zigbee2mqtt/+')
16595
+ *
16596
+ * Collection mode: multiple brokers (e.g. one local mosquitto + one
16597
+ * cloud bridge). The "embedded" entry (when present) is just another
16598
+ * broker in the registry — its lifecycle is owned by the addon that
16599
+ * spawned it.
16600
+ */
16601
+ var BrokerKindSchema = _enum(["external", "embedded"]);
16602
+ /**
16603
+ * Broker live-probe status.
16604
+ *
16605
+ * - `connected` — last probe completed a clean CONNACK
16606
+ * - `disconnected` — no probe has run yet (cold cache)
16607
+ * - `auth-failed` — CONNACK refused with auth error (RC 4 / 5)
16608
+ * - `unreachable` — TCP connect timed out / refused
16609
+ * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
16610
+ */
16611
+ var BrokerStatusSchema$1 = _enum([
16612
+ "connected",
16613
+ "disconnected",
16614
+ "auth-failed",
16615
+ "unreachable",
16616
+ "tls-error"
16617
+ ]);
16618
+ var BrokerInfoSchema = object({
16619
+ id: string(),
16620
+ name: string(),
16621
+ url: string(),
16622
+ kind: BrokerKindSchema,
16623
+ status: BrokerStatusSchema$1,
16624
+ latencyMs: number().nullable(),
15892
16625
  error: string().optional(),
15893
- renderedAs: RenderedAsSchema.optional()
16626
+ /** Embedded brokers only: number of MQTT clients currently connected. */
16627
+ connectedClients: number().int().nonnegative().optional(),
16628
+ /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
16629
+ lastCheckedAt: number().optional()
15894
16630
  });
15895
- /** Same shape as SendResult — kept as a distinct name for the test panel. */
15896
- var TestResultSchema = SendResultSchema;
15897
- method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
15898
- kind: string(),
15899
- config: record(string(), unknown()).optional()
15900
- }), array(DiscoveredTargetSchema)), method(object({
15901
- targetId: string(),
15902
- notification: NotificationSchema
15903
- }), SendResultSchema, { kind: "mutation" }), method(object({
15904
- targetId: string(),
15905
- sample: NotificationSchema.optional()
15906
- }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
15907
- targetId: string(),
15908
- enabled: boolean()
15909
- }), _void(), { kind: "mutation" });
15910
16631
  /**
15911
- * Shared LLM generate contracts imported by BOTH `llm.cap.ts` (consumer
15912
- * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15913
- * caps stay wire-compatible without a circular cap→cap import.
15914
- *
15915
- * Errors are a discriminated-union RESULT, never thrown: the shape survives
15916
- * every transport tier structurally, and failed calls still write usage rows.
15917
- * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
16632
+ * Connection details what a consumer needs to call
16633
+ * `mqtt.connect(url, options)`. We split URL + credentials so the
16634
+ * consumer can pass them as `mqtt.connect(url, { username, password })`
16635
+ * instead of stuffing creds into the URL (which leaks them into logs).
15918
16636
  */
15919
- var LlmUsageSchema = object({
15920
- inputTokens: number(),
15921
- outputTokens: number()
16637
+ var BrokerConnectionDetailsSchema = object({
16638
+ url: string(),
16639
+ username: string().optional(),
16640
+ password: string().optional(),
16641
+ /**
16642
+ * Suggested prefix for `clientId`. Each consumer should suffix this
16643
+ * with its own discriminator (addon id, instance id) so reconnects
16644
+ * don't kick each other off (MQTT spec: clientId must be unique per
16645
+ * broker).
16646
+ */
16647
+ clientIdPrefix: string().optional()
15922
16648
  });
15923
- var LlmErrorCodeSchema = _enum([
15924
- "timeout",
15925
- "rate-limited",
15926
- "auth",
15927
- "refusal",
15928
- "bad-request",
15929
- "unavailable",
15930
- "no-profile",
15931
- "budget-exceeded",
15932
- "adapter-error"
15933
- ]);
15934
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
16649
+ var AddBrokerInputSchema = object({
16650
+ name: string().min(1),
16651
+ url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
16652
+ username: string().optional(),
16653
+ password: string().optional(),
16654
+ clientIdPrefix: string().optional()
16655
+ });
16656
+ var AddBrokerResultSchema = object({ id: string() });
16657
+ var IdInputSchema = object({ id: string() });
16658
+ var TestResultSchema$1 = discriminatedUnion("ok", [object({
15935
16659
  ok: literal(true),
15936
- text: string(),
15937
- model: string(),
15938
- usage: LlmUsageSchema,
15939
- truncated: boolean(),
15940
16660
  latencyMs: number()
15941
16661
  }), object({
15942
16662
  ok: literal(false),
15943
- code: LlmErrorCodeSchema,
15944
- message: string(),
15945
- retryAfterMs: number().optional()
16663
+ error: string()
15946
16664
  })]);
15947
- /**
15948
- * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
15949
- * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
15950
- * notification-output.cap.ts:27-31 precedents).
15951
- */
15952
- var LlmImageSchema = object({
15953
- bytes: _instanceof(Uint8Array),
15954
- mimeType: string()
16665
+ var StartEmbeddedInputSchema = object({
16666
+ port: number().int().min(1).max(65535).default(1883),
16667
+ /** Allow anonymous connect (no username/password). Default: false. */
16668
+ allowAnonymous: boolean().default(false),
16669
+ /** Optional shared username/password for clients. */
16670
+ username: string().optional(),
16671
+ password: string().optional()
15955
16672
  });
15956
- var LlmGenerateBaseInputSchema = object({
15957
- /** Collection routing (the notification-output posture). */
15958
- addonId: string().optional(),
15959
- /** Explicit profile; else the resolution chain (spec §3). */
15960
- profileId: string().optional(),
15961
- /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
15962
- consumer: string(),
15963
- system: string().optional(),
15964
- /** v1: single-turn. `messages[]` is a v2 additive field. */
15965
- prompt: string(),
15966
- /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
15967
- jsonSchema: record(string(), unknown()).optional(),
15968
- /** Per-call override of the profile default. */
15969
- maxTokens: number().int().positive().optional(),
15970
- temperature: number().optional()
16673
+ var StartEmbeddedResultSchema = object({
16674
+ id: string(),
16675
+ url: string()
15971
16676
  });
15972
- /**
15973
- * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
15974
- * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
15975
- * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
15976
- * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
15977
- * this only through the `llm` cap's methods.
15978
- *
15979
- * One running llama-server child per node in v1 (models are RAM-heavy).
15980
- * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
15981
- * watchdog — operator decision #3).
15982
- */
15983
- var ManagedModelRefSchema = discriminatedUnion("kind", [
15984
- object({
15985
- kind: literal("catalog"),
15986
- catalogId: string()
15987
- }),
15988
- object({
15989
- kind: literal("url"),
15990
- url: string(),
15991
- sha256: string().optional()
15992
- }),
15993
- object({
15994
- kind: literal("path"),
15995
- path: string()
15996
- })
15997
- ]);
15998
- var ManagedRuntimeConfigSchema = object({
15999
- /** WHERE the runtime lives — hub or any agent. */
16000
- nodeId: string(),
16001
- /** Closed for v1; 'ollama' is a v2 candidate. */
16002
- engine: _enum(["llama-cpp"]),
16003
- model: ManagedModelRefSchema,
16004
- contextSize: number().int().default(4096),
16005
- /** 0 = CPU-only. */
16006
- gpuLayers: number().int().default(0),
16007
- /** Default: cpus-2, clamped ≥1 (resolved node-side). */
16008
- threads: number().int().optional(),
16009
- /** Concurrent slots. */
16010
- parallel: number().int().default(1),
16011
- /** Else lazy: first generate boots it. */
16012
- autoStart: boolean().default(false),
16013
- /** 0 = never; frees RAM after quiet periods. */
16014
- idleStopMinutes: number().int().default(30)
16677
+ var StatusSchema = object({
16678
+ brokerCount: number(),
16679
+ embeddedRunning: boolean()
16015
16680
  });
16016
- var LlmRuntimeStatusSchema = object({
16017
- /** Status is ALWAYS node-qualified. */
16018
- nodeId: string(),
16019
- state: _enum([
16020
- "stopped",
16021
- "downloading",
16022
- "starting",
16023
- "ready",
16024
- "crashed",
16025
- "failed"
16026
- ]),
16027
- pid: number().optional(),
16028
- port: number().optional(),
16029
- modelPath: string().optional(),
16030
- modelId: string().optional(),
16031
- downloadProgress: number().min(0).max(1).optional(),
16032
- lastError: string().optional(),
16033
- crashesInWindow: number(),
16034
- /** Child RSS (sampled best-effort). */
16035
- memoryBytes: number().optional(),
16036
- vramBytes: number().optional()
16681
+ 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);
16682
+ var NetworkEndpointSchema = object({
16683
+ url: string(),
16684
+ hostname: string(),
16685
+ port: number(),
16686
+ protocol: _enum(["http", "https"])
16037
16687
  });
16038
- var LlmNodeModelSchema = object({
16039
- file: string(),
16040
- sizeBytes: number(),
16041
- catalogId: string().optional(),
16042
- installedAt: number().optional()
16688
+ var NetworkAccessStatusSchema = object({
16689
+ connected: boolean(),
16690
+ endpoint: NetworkEndpointSchema.nullable(),
16691
+ error: string().optional()
16043
16692
  });
16044
- var LlmRuntimeDiskUsageSchema = object({
16045
- nodeId: string(),
16046
- modelsBytes: number(),
16047
- freeBytes: number().optional()
16693
+ /**
16694
+ * Optional, richer endpoint shape returned by providers that expose
16695
+ * MORE than one ingress concurrently (Tailscale Ingress with mixed
16696
+ * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
16697
+ * the originating provider config (mode + sourcePort) so the
16698
+ * orchestrator UI can label rows distinctly. Providers that expose only
16699
+ * one endpoint just omit `listEndpoints` from their provider impl.
16700
+ */
16701
+ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
16702
+ /**
16703
+ * Stable id within the provider — typically `<mode>-<sourcePort>` so
16704
+ * the orchestrator can dedupe across `listEndpoints` polls.
16705
+ */
16706
+ id: string(),
16707
+ /** Operator-facing label (mirrors `MeshEndpoint.label`). */
16708
+ label: string(),
16709
+ /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
16710
+ mode: string().optional(),
16711
+ /** Originating local port the ingress fronts (informational). */
16712
+ sourcePort: number().optional()
16048
16713
  });
16049
- method(LlmGenerateBaseInputSchema.extend({
16050
- images: array(LlmImageSchema).optional(),
16051
- runtime: ManagedRuntimeConfigSchema,
16052
- /** The managed profile's timeout, threaded by the hub provider. */
16053
- timeoutMs: number().int().positive().optional()
16054
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
16055
- kind: "mutation",
16056
- auth: "admin"
16057
- }), method(object({}), _void(), {
16058
- kind: "mutation",
16059
- auth: "admin"
16060
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
16061
- kind: "mutation",
16062
- auth: "admin"
16063
- }), method(object({ file: string() }), _void(), {
16064
- kind: "mutation",
16065
- auth: "admin"
16066
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
16714
+ method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
16067
16715
  /**
16068
- * `llm`consumer-facing LLM surface (spec §1-§3). Collection-mode: array
16069
- * methods concat-fan across providers; single-row methods route to ONE
16070
- * provider by the `addonId` in the call input (the notification-output
16071
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
16072
- * (hub-placed); the cap stays open for future providers.
16716
+ * notification-outputcanonical, capability-gated notification delivery.
16717
+ *
16718
+ * Apprise-derived model (see
16719
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
16720
+ * callers emit ONE canonical `Notification`; each provider declares a
16721
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
16722
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
16723
+ * message to what the kind supports — callers never special-case a service.
16724
+ *
16725
+ * DESIGN DECISIONS (locked):
16726
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
16727
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
16728
+ * cap. Rationale: the admin UI needs one uniform surface across the
16729
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
16730
+ * alternative would fork the UI per addon and cannot host the
16731
+ * discovery→adopt flow.
16732
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
16733
+ * the generated cap-mount auto-`concatCollection`-fans them across every
16734
+ * registered provider (notifiers addon + HA addon) so one catalog is
16735
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
16736
+ * `addonId` the generated collection router extracts from the call input.
16737
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
16738
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
16739
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
16740
+ * base64 fallback needed.
16073
16741
  *
16074
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
16075
- * `apiKey` is a password field — providers REDACT it on read and merge on
16076
- * write; a stored key NEVER round-trips to a client.
16742
+ * TODO (deferred, closed-set change separate decision): add
16743
+ * `providerKind: 'notify'` so notification providers surface on the unified
16744
+ * admin "Integrations" page.
16077
16745
  */
16078
- var LlmProfileKindSchema = _enum([
16079
- "openai-compatible",
16080
- "openai",
16081
- "anthropic",
16082
- "google",
16083
- "managed-local"
16746
+ /**
16747
+ * Zentik-derived typed-media enum — the superset across every kind. Each
16748
+ * adapter picks what it supports and the degrade engine filters the rest.
16749
+ */
16750
+ var AttachmentMediaTypeSchema = _enum([
16751
+ "image",
16752
+ "video",
16753
+ "gif",
16754
+ "audio",
16755
+ "icon"
16084
16756
  ]);
16085
- var LlmProfileSchema = object({
16757
+ /**
16758
+ * A single attachment. Exactly one of `url` (remote source, most adapters
16759
+ * prefer this) or `bytes` (inline source; required for Pushover-style
16760
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
16761
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
16762
+ */
16763
+ var AttachmentSchema = object({
16764
+ mediaType: AttachmentMediaTypeSchema,
16765
+ url: string().optional(),
16766
+ bytes: _instanceof(Uint8Array).optional(),
16767
+ mime: string().optional(),
16768
+ name: string().optional()
16769
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
16770
+ var NotificationFormatSchema = _enum([
16771
+ "text",
16772
+ "markdown",
16773
+ "html"
16774
+ ]);
16775
+ /** A single tap-through action button. */
16776
+ var NotificationActionSchema = object({
16086
16777
  id: string(),
16087
- name: string(),
16088
- kind: LlmProfileKindSchema,
16089
- /** Stamped by the provider — keeps the fanned catalog routable. */
16090
- addonId: string(),
16091
- enabled: boolean(),
16092
- /** Vendor model id, or the managed runtime's loaded model. */
16093
- model: string(),
16094
- /** Required for openai-compatible; override for cloud kinds. */
16095
- baseUrl: string().optional(),
16096
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
16097
- apiKey: string().optional(),
16098
- supportsVision: boolean(),
16099
- temperature: number().min(0).max(2).optional(),
16100
- maxTokens: number().int().positive().optional(),
16101
- timeoutMs: number().int().positive().default(6e4),
16102
- extraHeaders: record(string(), string()).optional(),
16103
- /** kind === 'managed-local' only (spec §4). */
16104
- runtime: ManagedRuntimeConfigSchema.optional()
16778
+ label: string(),
16779
+ url: string().optional()
16105
16780
  });
16106
- /** ConfigUISchema tree passed through untyped on the wire (the
16107
- * notification-output `ConfigSchemaPassthrough` precedent at
16108
- * notification-output.cap.ts:151); the exported TS type re-tightens it. */
16781
+ /**
16782
+ * The canonical notification. `body` is the only hard field (Apprise model).
16783
+ * `priority` is a 5-level ORDINAL (1=lowest 3=normal(default) 5=urgent),
16784
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
16785
+ * the adapter maps this ordinal onto its native level. `level?` is an
16786
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
16787
+ * `priority` for that one target.
16788
+ */
16789
+ var NotificationSchema = object({
16790
+ body: string(),
16791
+ title: string().optional(),
16792
+ format: NotificationFormatSchema.default("text"),
16793
+ priority: number().int().min(1).max(5).default(3),
16794
+ level: string().optional(),
16795
+ attachments: array(AttachmentSchema).optional(),
16796
+ clickUrl: string().optional(),
16797
+ actions: array(NotificationActionSchema).optional(),
16798
+ sound: string().optional(),
16799
+ ttl: number().optional(),
16800
+ tag: string().optional(),
16801
+ deviceId: number().optional(),
16802
+ eventId: string().optional(),
16803
+ metadata: record(string(), unknown()).optional()
16804
+ });
16805
+ /** One declared native severity/priority level for a kind. */
16806
+ var TargetKindLevelSchema = object({
16807
+ id: string(),
16808
+ label: string(),
16809
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
16810
+ ordinal: number().int().min(1).max(5).nullable(),
16811
+ flags: object({
16812
+ critical: boolean().optional(),
16813
+ silent: boolean().optional(),
16814
+ noPush: boolean().optional()
16815
+ }).optional(),
16816
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
16817
+ requires: array(string()).optional(),
16818
+ description: string().optional()
16819
+ });
16820
+ /** The full capability block consulted before dispatch. */
16821
+ var TargetKindCapsSchema = object({
16822
+ attachments: object({
16823
+ mediaTypes: array(AttachmentMediaTypeSchema),
16824
+ mode: _enum([
16825
+ "url",
16826
+ "bytes",
16827
+ "both"
16828
+ ]),
16829
+ max: number().int().nonnegative(),
16830
+ maxBytes: number().int().positive().optional()
16831
+ }),
16832
+ /** Max action buttons (0 = none). */
16833
+ actions: number().int().nonnegative(),
16834
+ levels: array(TargetKindLevelSchema),
16835
+ format: array(NotificationFormatSchema),
16836
+ clickUrl: boolean(),
16837
+ sound: boolean(),
16838
+ ttl: boolean(),
16839
+ bodyMaxLen: number().int().positive()
16840
+ });
16841
+ /**
16842
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
16843
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
16844
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
16845
+ * the union is large and not meant for runtime validation here; the exported
16846
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
16847
+ */
16109
16848
  var ConfigSchemaPassthrough = unknown();
16110
- var LlmProfileKindDescriptorSchema = object({
16111
- kind: LlmProfileKindSchema,
16849
+ var TargetKindSchema = object({
16850
+ kind: string(),
16112
16851
  label: string(),
16113
16852
  icon: string(),
16114
16853
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
16115
16854
  addonId: string(),
16116
- configSchema: ConfigSchemaPassthrough
16117
- });
16118
- var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
16119
- var LlmDefaultSchema = object({
16120
- selector: LlmDefaultSelectorSchema,
16121
- profileId: string()
16122
- });
16123
- /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
16124
- var LlmUsageRollupSchema = object({
16125
- day: string(),
16126
- consumer: string(),
16127
- profileId: string(),
16128
- calls: number(),
16129
- okCalls: number(),
16130
- errorCalls: number(),
16131
- inputTokens: number(),
16132
- outputTokens: number(),
16133
- avgLatencyMs: number()
16855
+ configSchema: ConfigSchemaPassthrough,
16856
+ supportsDiscovery: boolean(),
16857
+ caps: TargetKindCapsSchema
16134
16858
  });
16135
- /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
16136
- var ManagedModelCatalogEntrySchema = object({
16859
+ /**
16860
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
16861
+ * (return a presence marker only) when serving `listTargets` — never
16862
+ * round-trip a stored secret to the UI.
16863
+ */
16864
+ var TargetSchema = object({
16137
16865
  id: string(),
16138
- label: string(),
16139
- family: string(),
16140
- purpose: _enum(["text", "vision"]),
16141
- url: string(),
16142
- sha256: string(),
16143
- sizeBytes: number(),
16144
- quantization: string(),
16145
- /** Load-time guidance shown in the picker. */
16146
- minRamBytes: number(),
16147
- contextSizeDefault: number().int(),
16148
- /** Vision models: companion projector file. */
16149
- mmprojUrl: string().optional()
16150
- });
16151
- var LlmRuntimeNodeSchema = object({
16152
- nodeId: string(),
16153
- reachable: boolean(),
16154
- status: LlmRuntimeStatusSchema.optional(),
16155
- disk: LlmRuntimeDiskUsageSchema.optional(),
16156
- error: string().optional()
16157
- });
16158
- var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
16159
- var ProfileRefInputSchema = object({
16866
+ name: string(),
16867
+ kind: string(),
16160
16868
  addonId: string(),
16161
- profileId: string()
16869
+ enabled: boolean(),
16870
+ config: record(string(), unknown())
16162
16871
  });
16163
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
16164
- kind: "mutation",
16165
- auth: "admin"
16166
- }), method(ProfileRefInputSchema, _void(), {
16167
- kind: "mutation",
16168
- auth: "admin"
16169
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
16170
- kind: "mutation",
16171
- auth: "admin"
16172
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
16173
- selector: LlmDefaultSelectorSchema,
16174
- profileId: string().nullable()
16175
- }), _void(), {
16176
- kind: "mutation",
16177
- auth: "admin"
16178
- }), method(object({
16179
- since: number().optional(),
16180
- until: number().optional(),
16181
- consumer: string().optional(),
16182
- profileId: string().optional()
16183
- }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
16184
- nodeId: string(),
16185
- model: ManagedModelRefSchema
16186
- }), _void(), {
16187
- kind: "mutation",
16188
- auth: "admin"
16189
- }), method(object({
16190
- nodeId: string(),
16191
- file: string()
16192
- }), _void(), {
16193
- kind: "mutation",
16194
- auth: "admin"
16195
- }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
16196
- kind: "mutation",
16197
- auth: "admin"
16198
- }), method(ProfileRefInputSchema, _void(), {
16199
- kind: "mutation",
16200
- auth: "admin"
16872
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
16873
+ var DiscoveredTargetSchema = object({
16874
+ kind: string(),
16875
+ suggestedName: string(),
16876
+ config: record(string(), unknown())
16877
+ });
16878
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
16879
+ var RenderedAsSchema = object({
16880
+ level: string(),
16881
+ format: NotificationFormatSchema,
16882
+ attachmentsSent: number().int().nonnegative(),
16883
+ actionsSent: number().int().nonnegative(),
16884
+ truncated: boolean(),
16885
+ dropped: array(string())
16886
+ });
16887
+ var SendResultSchema = object({
16888
+ success: boolean(),
16889
+ error: string().optional(),
16890
+ renderedAs: RenderedAsSchema.optional()
16201
16891
  });
16892
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
16893
+ var TestResultSchema = SendResultSchema;
16894
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
16895
+ kind: string(),
16896
+ config: record(string(), unknown()).optional()
16897
+ }), array(DiscoveredTargetSchema)), method(object({
16898
+ targetId: string(),
16899
+ notification: NotificationSchema
16900
+ }), SendResultSchema, { kind: "mutation" }), method(object({
16901
+ targetId: string(),
16902
+ sample: NotificationSchema.optional()
16903
+ }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
16904
+ targetId: string(),
16905
+ enabled: boolean()
16906
+ }), _void(), { kind: "mutation" });
16202
16907
  /**
16203
16908
  * Zod schemas for persisted record types.
16204
16909
  *
@@ -16884,7 +17589,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
16884
17589
  }), method(object({
16885
17590
  eventId: string(),
16886
17591
  kind: MediaFileKindEnum.optional()
16887
- }), array(MediaFileSchema).readonly()), method(object({ trackId: string() }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
17592
+ }), array(MediaFileSchema).readonly()), method(object({
17593
+ trackId: string(),
17594
+ kinds: array(MediaFileKindEnum).optional()
17595
+ }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
16888
17596
  deviceId: number(),
16889
17597
  timestamp: number(),
16890
17598
  frameWidth: number(),
@@ -16905,76 +17613,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
16905
17613
  eventId: string(),
16906
17614
  timestamp: number()
16907
17615
  });
16908
- /**
16909
- * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
16910
- * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
16911
- * caps into per-camera event-kind descriptors.
16912
- *
16913
- * The descriptor DATA (color / iconId / labelKey / parentKind / category)
16914
- * is NOT duplicated here — every entry is derived from the single
16915
- * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
16916
- * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
16917
- * control cap means adding one line here (and a taxonomy entry); the anti-
16918
- * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
16919
- * eventful cap is missing.
16920
- */
16921
- /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
16922
- var LEGACY_ICON = {
16923
- motion: "motion",
16924
- audio: "audio",
16925
- person: "person",
16926
- vehicle: "vehicle",
16927
- animal: "animal",
16928
- package: "package",
16929
- door: "door",
16930
- pir: "pir",
16931
- smoke: "smoke",
16932
- water: "water",
16933
- button: "button",
16934
- generic: "generic",
16935
- gas: "smoke",
16936
- vibration: "generic",
16937
- tamper: "generic",
16938
- presence: "person",
16939
- lock: "generic",
16940
- siren: "generic",
16941
- switch: "generic",
16942
- doorbell: "button"
16943
- };
16944
- function legacyIcon(iconId) {
16945
- return LEGACY_ICON[iconId] ?? "generic";
16946
- }
16947
- /**
16948
- * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
16949
- * The anti-drift guard cross-checks this against the eventful caps declared
16950
- * in `packages/types/src/capabilities/*.cap.ts`.
16951
- */
16952
- var CAP_TO_KIND = {
16953
- contact: "contact",
16954
- motion: "motion-sensor",
16955
- smoke: "smoke",
16956
- flood: "flood",
16957
- gas: "gas",
16958
- "carbon-monoxide": "carbon-monoxide",
16959
- vibration: "vibration",
16960
- tamper: "tamper",
16961
- presence: "presence",
16962
- "enum-sensor": "enum-sensor",
16963
- "event-emitter": "device-event",
16964
- "lock-control": "lock",
16965
- switch: "switch",
16966
- button: "button",
16967
- doorbell: "doorbell"
16968
- };
16969
- function buildDescriptor(capName, kind) {
16970
- const t = EVENT_TAXONOMY[kind];
16971
- if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
16972
- return {
16973
- ...t,
16974
- icon: legacyIcon(t.iconId)
16975
- };
16976
- }
16977
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
16978
17616
  var CameraPipelineConfigSchema = object({
16979
17617
  engine: PipelineEngineChoiceSchema.optional(),
16980
17618
  steps: array(PipelineStepInputSchema).readonly(),
@@ -17460,6 +18098,76 @@ method(object({
17460
18098
  auth: "admin"
17461
18099
  });
17462
18100
  /**
18101
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
18102
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
18103
+ * caps into per-camera event-kind descriptors.
18104
+ *
18105
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
18106
+ * is NOT duplicated here — every entry is derived from the single
18107
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
18108
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
18109
+ * control cap means adding one line here (and a taxonomy entry); the anti-
18110
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
18111
+ * eventful cap is missing.
18112
+ */
18113
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
18114
+ var LEGACY_ICON = {
18115
+ motion: "motion",
18116
+ audio: "audio",
18117
+ person: "person",
18118
+ vehicle: "vehicle",
18119
+ animal: "animal",
18120
+ package: "package",
18121
+ door: "door",
18122
+ pir: "pir",
18123
+ smoke: "smoke",
18124
+ water: "water",
18125
+ button: "button",
18126
+ generic: "generic",
18127
+ gas: "smoke",
18128
+ vibration: "generic",
18129
+ tamper: "generic",
18130
+ presence: "person",
18131
+ lock: "generic",
18132
+ siren: "generic",
18133
+ switch: "generic",
18134
+ doorbell: "button"
18135
+ };
18136
+ function legacyIcon(iconId) {
18137
+ return LEGACY_ICON[iconId] ?? "generic";
18138
+ }
18139
+ /**
18140
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
18141
+ * The anti-drift guard cross-checks this against the eventful caps declared
18142
+ * in `packages/types/src/capabilities/*.cap.ts`.
18143
+ */
18144
+ var CAP_TO_KIND = {
18145
+ contact: "contact",
18146
+ motion: "motion-sensor",
18147
+ smoke: "smoke",
18148
+ flood: "flood",
18149
+ gas: "gas",
18150
+ "carbon-monoxide": "carbon-monoxide",
18151
+ vibration: "vibration",
18152
+ tamper: "tamper",
18153
+ presence: "presence",
18154
+ "enum-sensor": "enum-sensor",
18155
+ "event-emitter": "device-event",
18156
+ "lock-control": "lock",
18157
+ switch: "switch",
18158
+ button: "button",
18159
+ doorbell: "doorbell"
18160
+ };
18161
+ function buildDescriptor(capName, kind) {
18162
+ const t = EVENT_TAXONOMY[kind];
18163
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
18164
+ return {
18165
+ ...t,
18166
+ icon: legacyIcon(t.iconId)
18167
+ };
18168
+ }
18169
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
18170
+ /**
17463
18171
  * server-management — per-NODE singleton capability for a node's ROOT
17464
18172
  * package lifecycle (runtime-updatable node packages).
17465
18173
  *
@@ -18931,7 +19639,28 @@ var FaceInfoSchema = object({
18931
19639
  * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`). Absent when the
18932
19640
  * track produced no key frame (e.g. native/onboard source) — the UI falls
18933
19641
  * back to the inline `base64` face crop. */
18934
- keyFrameMediaKey: string().optional()
19642
+ keyFrameMediaKey: string().optional(),
19643
+ /** Winning identity-match cosine (0..1) for this face's track, when an
19644
+ * identity was auto-confirmed. Lets the UI surface WHY a face was assigned
19645
+ * (confidence badge / low-confidence audit). Absent on legacy rows and on
19646
+ * faces that were never auto-recognized. */
19647
+ bestMatchScore: number().optional(),
19648
+ /** Native-scale face short side (px) at recognition time, when the runner
19649
+ * measured it. Lets the UI flag low-resolution auto-assignments. Absent on
19650
+ * legacy rows / runners that reported no native measure. */
19651
+ nativeFaceShortSidePx: number().optional(),
19652
+ /** SUGGESTED identity for this face — a plausible-but-not-confident match that
19653
+ * MISSED auto-assignment (cosine in the suggestion band, or above threshold
19654
+ * but blocked only by the recognition size floor). Mutually exclusive with
19655
+ * `recognizedIdentityId` (a suggestion is NEVER an assignment): the face stays
19656
+ * UNASSIGNED and everything else keeps treating it as unrecognized — the UI
19657
+ * merely offers a one-tap "is this <name>?" confirm. Absent on legacy rows and
19658
+ * on faces that were auto-assigned or below the suggestion band. (2026-07-24) */
19659
+ suggestedIdentityId: string().optional(),
19660
+ /** Peak identity-match cosine (0..1) for `suggestedIdentityId`, captured at the
19661
+ * same moment as `bestMatchScore` (track peak, at close). Lets the UI rank /
19662
+ * badge suggestion confidence. Present iff `suggestedIdentityId` is. (2026-07-24) */
19663
+ suggestedMatchScore: number().optional()
18935
19664
  });
18936
19665
  var FaceFilterEnum = _enum([
18937
19666
  "unassigned",
@@ -20974,36 +21703,6 @@ Object.freeze({
20974
21703
  addonId: null,
20975
21704
  access: "view"
20976
21705
  },
20977
- "advancedNotifier.deleteRule": {
20978
- capName: "advanced-notifier",
20979
- capScope: "system",
20980
- addonId: null,
20981
- access: "delete"
20982
- },
20983
- "advancedNotifier.getHistory": {
20984
- capName: "advanced-notifier",
20985
- capScope: "system",
20986
- addonId: null,
20987
- access: "view"
20988
- },
20989
- "advancedNotifier.getRules": {
20990
- capName: "advanced-notifier",
20991
- capScope: "system",
20992
- addonId: null,
20993
- access: "view"
20994
- },
20995
- "advancedNotifier.testRule": {
20996
- capName: "advanced-notifier",
20997
- capScope: "system",
20998
- addonId: null,
20999
- access: "create"
21000
- },
21001
- "advancedNotifier.upsertRule": {
21002
- capName: "advanced-notifier",
21003
- capScope: "system",
21004
- addonId: null,
21005
- access: "create"
21006
- },
21007
21706
  "alarmPanel.arm": {
21008
21707
  capName: "alarm-panel",
21009
21708
  capScope: "device",
@@ -21226,6 +21925,12 @@ Object.freeze({
21226
21925
  addonId: null,
21227
21926
  access: "delete"
21228
21927
  },
21928
+ "backup.deleteSchedule": {
21929
+ capName: "backup",
21930
+ capScope: "system",
21931
+ addonId: null,
21932
+ access: "delete"
21933
+ },
21229
21934
  "backup.getEntries": {
21230
21935
  capName: "backup",
21231
21936
  capScope: "system",
@@ -21256,6 +21961,12 @@ Object.freeze({
21256
21961
  addonId: null,
21257
21962
  access: "view"
21258
21963
  },
21964
+ "backup.listSchedules": {
21965
+ capName: "backup",
21966
+ capScope: "system",
21967
+ addonId: null,
21968
+ access: "view"
21969
+ },
21259
21970
  "backup.previewSchedule": {
21260
21971
  capName: "backup",
21261
21972
  capScope: "system",
@@ -21280,6 +21991,12 @@ Object.freeze({
21280
21991
  addonId: null,
21281
21992
  access: "create"
21282
21993
  },
21994
+ "backup.upsertSchedule": {
21995
+ capName: "backup",
21996
+ capScope: "system",
21997
+ addonId: null,
21998
+ access: "create"
21999
+ },
21283
22000
  "battery.wakeForStream": {
21284
22001
  capName: "battery",
21285
22002
  capScope: "device",
@@ -23308,6 +24025,60 @@ Object.freeze({
23308
24025
  addonId: null,
23309
24026
  access: "create"
23310
24027
  },
24028
+ "notificationRules.createRule": {
24029
+ capName: "notification-rules",
24030
+ capScope: "system",
24031
+ addonId: null,
24032
+ access: "create"
24033
+ },
24034
+ "notificationRules.deleteRule": {
24035
+ capName: "notification-rules",
24036
+ capScope: "system",
24037
+ addonId: null,
24038
+ access: "delete"
24039
+ },
24040
+ "notificationRules.getConditionCatalog": {
24041
+ capName: "notification-rules",
24042
+ capScope: "system",
24043
+ addonId: null,
24044
+ access: "view"
24045
+ },
24046
+ "notificationRules.getHistory": {
24047
+ capName: "notification-rules",
24048
+ capScope: "system",
24049
+ addonId: null,
24050
+ access: "view"
24051
+ },
24052
+ "notificationRules.getRule": {
24053
+ capName: "notification-rules",
24054
+ capScope: "system",
24055
+ addonId: null,
24056
+ access: "view"
24057
+ },
24058
+ "notificationRules.listRules": {
24059
+ capName: "notification-rules",
24060
+ capScope: "system",
24061
+ addonId: null,
24062
+ access: "view"
24063
+ },
24064
+ "notificationRules.setRuleEnabled": {
24065
+ capName: "notification-rules",
24066
+ capScope: "system",
24067
+ addonId: null,
24068
+ access: "create"
24069
+ },
24070
+ "notificationRules.testRule": {
24071
+ capName: "notification-rules",
24072
+ capScope: "system",
24073
+ addonId: null,
24074
+ access: "create"
24075
+ },
24076
+ "notificationRules.updateRule": {
24077
+ capName: "notification-rules",
24078
+ capScope: "system",
24079
+ addonId: null,
24080
+ access: "create"
24081
+ },
23311
24082
  "notifier.cancel": {
23312
24083
  capName: "notifier",
23313
24084
  capScope: "device",
@@ -25060,6 +25831,36 @@ Object.freeze({
25060
25831
  addonId: null,
25061
25832
  access: "create"
25062
25833
  },
25834
+ "terminalSession.close": {
25835
+ capName: "terminal-session",
25836
+ capScope: "system",
25837
+ addonId: null,
25838
+ access: "create"
25839
+ },
25840
+ "terminalSession.listProfiles": {
25841
+ capName: "terminal-session",
25842
+ capScope: "system",
25843
+ addonId: null,
25844
+ access: "view"
25845
+ },
25846
+ "terminalSession.listSessions": {
25847
+ capName: "terminal-session",
25848
+ capScope: "system",
25849
+ addonId: null,
25850
+ access: "view"
25851
+ },
25852
+ "terminalSession.openSession": {
25853
+ capName: "terminal-session",
25854
+ capScope: "system",
25855
+ addonId: null,
25856
+ access: "create"
25857
+ },
25858
+ "terminalSession.resize": {
25859
+ capName: "terminal-session",
25860
+ capScope: "system",
25861
+ addonId: null,
25862
+ access: "create"
25863
+ },
25063
25864
  "toast.onToast": {
25064
25865
  capName: "toast",
25065
25866
  capScope: "system",