@camstack/addon-tailscale 1.2.4 → 1.2.6

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