@camstack/addon-remote-storage 1.2.4 → 1.2.6

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