@camstack/addon-cloudflare 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
  *
@@ -14209,7 +14831,8 @@ function customAction(input, output, options) {
14209
14831
  output,
14210
14832
  kind: options?.kind ?? "query",
14211
14833
  auth: options?.auth ?? "protected",
14212
- scope: options?.scope ?? { kind: "system" }
14834
+ scope: options?.scope ?? { kind: "system" },
14835
+ ...options?.caller ? { caller: "required" } : {}
14213
14836
  };
14214
14837
  }
14215
14838
  /**
@@ -15200,868 +15823,951 @@ method(_void(), array(string()).readonly(), { auth: "admin" }), method(object({
15200
15823
  kind: "mutation",
15201
15824
  auth: "admin"
15202
15825
  });
15203
- var LogLevelSchema = _enum([
15204
- "debug",
15205
- "info",
15206
- "warn",
15207
- "error"
15208
- ]);
15209
- var LogEntrySchema = object({
15210
- timestamp: date(),
15211
- level: LogLevelSchema,
15212
- scope: array(string()),
15213
- message: string(),
15214
- meta: record(string(), unknown()).optional(),
15215
- tags: record(string(), string()).optional()
15826
+ /**
15827
+ * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
15828
+ * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15829
+ * caps stay wire-compatible without a circular cap→cap import.
15830
+ *
15831
+ * Errors are a discriminated-union RESULT, never thrown: the shape survives
15832
+ * every transport tier structurally, and failed calls still write usage rows.
15833
+ * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
15834
+ */
15835
+ var LlmUsageSchema = object({
15836
+ inputTokens: number(),
15837
+ outputTokens: number()
15216
15838
  });
15217
- method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
15218
- scope: array(string()).optional(),
15219
- level: LogLevelSchema.optional(),
15220
- since: date().optional(),
15221
- until: date().optional(),
15222
- limit: number().optional(),
15223
- tags: record(string(), string()).optional()
15224
- }), array(LogEntrySchema).readonly());
15225
- var CpuBreakdownSchema = object({
15226
- total: number(),
15227
- user: number(),
15228
- system: number(),
15229
- irq: number(),
15230
- nice: number(),
15231
- loadAvg: tuple([
15232
- number(),
15233
- number(),
15234
- number()
15235
- ]),
15236
- cores: number()
15237
- });
15238
- var MemoryInfoSchema = object({
15239
- percent: number(),
15240
- totalBytes: number(),
15241
- usedBytes: number(),
15242
- availableBytes: number(),
15243
- swapUsedBytes: number(),
15244
- swapTotalBytes: number()
15245
- });
15246
- var DiskIoSnapshotSchema = object({
15247
- readBytes: number(),
15248
- writeBytes: number(),
15249
- readOps: number(),
15250
- writeOps: number(),
15251
- timestampMs: number()
15252
- });
15253
- var NetworkIoSnapshotSchema = object({
15254
- rxBytes: number(),
15255
- txBytes: number(),
15256
- rxPackets: number(),
15257
- txPackets: number(),
15258
- rxErrors: number(),
15259
- txErrors: number(),
15260
- timestampMs: number()
15261
- });
15262
- var MetricsGpuInfoSchema = object({
15263
- utilization: number(),
15839
+ var LlmErrorCodeSchema = _enum([
15840
+ "timeout",
15841
+ "rate-limited",
15842
+ "auth",
15843
+ "refusal",
15844
+ "bad-request",
15845
+ "unavailable",
15846
+ "no-profile",
15847
+ "budget-exceeded",
15848
+ "adapter-error"
15849
+ ]);
15850
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
15851
+ ok: literal(true),
15852
+ text: string(),
15264
15853
  model: string(),
15265
- memoryUsedBytes: number(),
15266
- memoryTotalBytes: number(),
15267
- temperature: number().nullable()
15268
- });
15269
- var ProcessResourceInfoSchema = object({
15270
- openFds: number(),
15271
- threadCount: number(),
15272
- activeHandles: number(),
15273
- activeRequests: number()
15274
- });
15275
- var PressureAvgsSchema = object({
15276
- avg10: number(),
15277
- avg60: number(),
15278
- avg300: number()
15854
+ usage: LlmUsageSchema,
15855
+ truncated: boolean(),
15856
+ latencyMs: number()
15857
+ }), object({
15858
+ ok: literal(false),
15859
+ code: LlmErrorCodeSchema,
15860
+ message: string(),
15861
+ retryAfterMs: number().optional()
15862
+ })]);
15863
+ /**
15864
+ * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
15865
+ * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
15866
+ * notification-output.cap.ts:27-31 precedents).
15867
+ */
15868
+ var LlmImageSchema = object({
15869
+ bytes: _instanceof(Uint8Array),
15870
+ mimeType: string()
15279
15871
  });
15280
- var PressureInfoSchema = object({
15281
- some: PressureAvgsSchema,
15282
- full: PressureAvgsSchema.nullable()
15872
+ var LlmGenerateBaseInputSchema = object({
15873
+ /** Collection routing (the notification-output posture). */
15874
+ addonId: string().optional(),
15875
+ /** Explicit profile; else the resolution chain (spec §3). */
15876
+ profileId: string().optional(),
15877
+ /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
15878
+ consumer: string(),
15879
+ system: string().optional(),
15880
+ /** v1: single-turn. `messages[]` is a v2 additive field. */
15881
+ prompt: string(),
15882
+ /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
15883
+ jsonSchema: record(string(), unknown()).optional(),
15884
+ /** Per-call override of the profile default. */
15885
+ maxTokens: number().int().positive().optional(),
15886
+ temperature: number().optional()
15283
15887
  });
15284
- var SystemResourceSnapshotSchema = object({
15285
- cpu: CpuBreakdownSchema,
15286
- memory: MemoryInfoSchema,
15287
- gpu: MetricsGpuInfoSchema.nullable(),
15288
- network: NetworkIoSnapshotSchema,
15289
- disk: DiskIoSnapshotSchema,
15290
- pressure: object({
15291
- cpu: PressureInfoSchema.nullable(),
15292
- memory: PressureInfoSchema.nullable(),
15293
- io: PressureInfoSchema.nullable()
15888
+ /**
15889
+ * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
15890
+ * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
15891
+ * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
15892
+ * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
15893
+ * this only through the `llm` cap's methods.
15894
+ *
15895
+ * One running llama-server child per node in v1 (models are RAM-heavy).
15896
+ * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
15897
+ * watchdog — operator decision #3).
15898
+ */
15899
+ var ManagedModelRefSchema = discriminatedUnion("kind", [
15900
+ object({
15901
+ kind: literal("catalog"),
15902
+ catalogId: string()
15294
15903
  }),
15295
- process: ProcessResourceInfoSchema,
15296
- cpuTemperature: number().nullable(),
15297
- timestampMs: number()
15298
- });
15299
- var DiskSpaceInfoSchema = object({
15300
- path: string(),
15301
- totalBytes: number(),
15302
- usedBytes: number(),
15303
- availableBytes: number(),
15304
- percent: number()
15305
- });
15306
- var PidResourceStatsSchema = object({
15307
- pid: number(),
15308
- cpu: number(),
15309
- memory: number(),
15310
- /**
15311
- * Private (anonymous) resident bytes — the per-process V8 heap + native
15312
- * allocations NOT shared with other processes (Linux RssAnon). This is the
15313
- * "real" per-runner cost; summing it across runners is meaningful, unlike
15314
- * `memory` (RSS), which double-counts the shared mmap'd framework code.
15315
- * Undefined where /proc is unavailable (e.g. macOS).
15316
- */
15317
- privateBytes: number().optional(),
15318
- /**
15319
- * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
15320
- * code shared copy-on-write across runners. Undefined on macOS.
15321
- */
15322
- sharedBytes: number().optional()
15904
+ object({
15905
+ kind: literal("url"),
15906
+ url: string(),
15907
+ sha256: string().optional()
15908
+ }),
15909
+ object({
15910
+ kind: literal("path"),
15911
+ path: string()
15912
+ })
15913
+ ]);
15914
+ var ManagedRuntimeConfigSchema = object({
15915
+ /** WHERE the runtime lives — hub or any agent. */
15916
+ nodeId: string(),
15917
+ /** Closed for v1; 'ollama' is a v2 candidate. */
15918
+ engine: _enum(["llama-cpp"]),
15919
+ model: ManagedModelRefSchema,
15920
+ contextSize: number().int().default(4096),
15921
+ /** 0 = CPU-only. */
15922
+ gpuLayers: number().int().default(0),
15923
+ /** Default: cpus-2, clamped ≥1 (resolved node-side). */
15924
+ threads: number().int().optional(),
15925
+ /** Concurrent slots. */
15926
+ parallel: number().int().default(1),
15927
+ /** Else lazy: first generate boots it. */
15928
+ autoStart: boolean().default(false),
15929
+ /** 0 = never; frees RAM after quiet periods. */
15930
+ idleStopMinutes: number().int().default(30)
15323
15931
  });
15324
- var AddonInstanceSchema = object({
15325
- addonId: string(),
15932
+ var LlmRuntimeStatusSchema = object({
15933
+ /** Status is ALWAYS node-qualified. */
15326
15934
  nodeId: string(),
15327
- role: _enum(["hub", "worker"]),
15328
- pid: number(),
15329
15935
  state: _enum([
15330
- "starting",
15331
- "running",
15332
- "stopping",
15333
15936
  "stopped",
15334
- "crashed"
15335
- ]),
15336
- uptimeSec: number()
15337
- });
15338
- var NodeProcessSchema = object({
15339
- pid: number(),
15340
- ppid: number(),
15341
- pgid: number(),
15342
- classification: _enum([
15343
- "root",
15344
- "managed",
15345
- "system",
15346
- "ghost"
15937
+ "downloading",
15938
+ "starting",
15939
+ "ready",
15940
+ "crashed",
15941
+ "failed"
15347
15942
  ]),
15348
- /** `$process` addon binding when `managed`, else null. */
15349
- addonId: string().nullable(),
15350
- /** Kernel-reported nodeId when the process is a known agent/worker. */
15351
- nodeId: string().nullable(),
15352
- /** Truncated command line. */
15353
- command: string(),
15354
- cpuPercent: number(),
15355
- memoryRssBytes: number(),
15356
- /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
15357
- uptimeSec: number(),
15358
- /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
15359
- orphaned: boolean()
15943
+ pid: number().optional(),
15944
+ port: number().optional(),
15945
+ modelPath: string().optional(),
15946
+ modelId: string().optional(),
15947
+ downloadProgress: number().min(0).max(1).optional(),
15948
+ lastError: string().optional(),
15949
+ crashesInWindow: number(),
15950
+ /** Child RSS (sampled best-effort). */
15951
+ memoryBytes: number().optional(),
15952
+ vramBytes: number().optional()
15360
15953
  });
15361
- var KillProcessInputSchema = object({
15362
- pid: number(),
15363
- /** Force = SIGKILL. Default is SIGTERM. */
15364
- force: boolean().optional()
15954
+ var LlmNodeModelSchema = object({
15955
+ file: string(),
15956
+ sizeBytes: number(),
15957
+ catalogId: string().optional(),
15958
+ installedAt: number().optional()
15365
15959
  });
15366
- var KillProcessResultSchema = object({
15367
- success: boolean(),
15368
- reason: string().optional(),
15369
- signal: _enum(["SIGTERM", "SIGKILL"]).optional()
15960
+ var LlmRuntimeDiskUsageSchema = object({
15961
+ nodeId: string(),
15962
+ modelsBytes: number(),
15963
+ freeBytes: number().optional()
15370
15964
  });
15371
- var DumpHeapSnapshotInputSchema = object({
15372
- /** The addon whose runner should dump a heap snapshot. */
15373
- addonId: string() });
15374
- var DumpHeapSnapshotResultSchema = object({
15375
- success: boolean(),
15376
- /** Path of the written .heapsnapshot inside the runner's container/host. */
15377
- path: string().optional(),
15378
- /** Process pid that was signalled. */
15379
- pid: number().optional(),
15380
- reason: string().optional()
15381
- });
15382
- var SystemMetricsSchema = object({
15383
- cpuPercent: number(),
15384
- memoryPercent: number(),
15385
- memoryUsedMB: number(),
15386
- memoryTotalMB: number(),
15387
- diskPercent: number().optional(),
15388
- temperature: number().optional(),
15389
- gpuPercent: number().optional(),
15390
- gpuMemoryPercent: number().optional()
15391
- });
15392
- 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, {
15965
+ method(LlmGenerateBaseInputSchema.extend({
15966
+ images: array(LlmImageSchema).optional(),
15967
+ runtime: ManagedRuntimeConfigSchema,
15968
+ /** The managed profile's timeout, threaded by the hub provider. */
15969
+ timeoutMs: number().int().positive().optional()
15970
+ }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
15393
15971
  kind: "mutation",
15394
15972
  auth: "admin"
15395
- }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
15973
+ }), method(object({}), _void(), {
15396
15974
  kind: "mutation",
15397
15975
  auth: "admin"
15398
- });
15399
- method(object({
15400
- sourceUrl: string(),
15401
- metadata: ModelConvertMetadataSchema,
15402
- targets: array(ConvertTargetSchema).min(1).readonly(),
15403
- calibrationRef: string().optional(),
15404
- sessionId: string().optional()
15405
- }), ConvertResultSchema, {
15976
+ }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
15406
15977
  kind: "mutation",
15407
- auth: "admin",
15408
- timeoutMs: 6e5
15409
- });
15410
- method(object({
15411
- nodeId: string(),
15412
- modelId: string(),
15413
- format: _enum(MODEL_FORMATS),
15414
- entry: ModelCatalogEntrySchema
15415
- }), object({
15416
- ok: boolean(),
15417
- /** sha256 of the staged tarball (empty for a hub-local no-op). */
15418
- sha256: string(),
15419
- bytes: number(),
15420
- /** The target node's modelsDir the artifact landed in. */
15421
- path: string()
15422
- }), {
15978
+ auth: "admin"
15979
+ }), method(object({ file: string() }), _void(), {
15423
15980
  kind: "mutation",
15424
15981
  auth: "admin"
15425
- });
15426
- /**
15427
- * `mqtt-broker` — broker-registry cap.
15428
- *
15429
- * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
15430
- * MQTT brokers (external + optionally an embedded `aedes`-backed one)
15431
- * and (b) the connection details a consumer addon needs to spin up
15432
- * its OWN `mqtt.js` client.
15433
- *
15434
- * Why: pub/sub routing over the system event-bus loses fidelity
15435
- * (callback shape, QoS guarantees, will/retain semantics) and adds
15436
- * refcount bookkeeping that addons would rather own themselves. The
15437
- * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
15438
- * features anyway — give it the connection config, get out of the way.
15439
- *
15440
- * Consumer flow:
15441
- * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
15442
- * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
15443
- * client.subscribe('zigbee2mqtt/+')
15444
- *
15445
- * Collection mode: multiple brokers (e.g. one local mosquitto + one
15446
- * cloud bridge). The "embedded" entry (when present) is just another
15447
- * broker in the registry — its lifecycle is owned by the addon that
15448
- * spawned it.
15449
- */
15450
- var BrokerKindSchema = _enum(["external", "embedded"]);
15982
+ }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
15451
15983
  /**
15452
- * Broker live-probe status.
15984
+ * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
15985
+ * methods concat-fan across providers; single-row methods route to ONE
15986
+ * provider by the `addonId` in the call input (the notification-output
15987
+ * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
15988
+ * (hub-placed); the cap stays open for future providers.
15453
15989
  *
15454
- * - `connected` last probe completed a clean CONNACK
15455
- * - `disconnected` — no probe has run yet (cold cache)
15456
- * - `auth-failed` CONNACK refused with auth error (RC 4 / 5)
15457
- * - `unreachable` — TCP connect timed out / refused
15458
- * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
15990
+ * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
15991
+ * `apiKey` is a password field providers REDACT it on read and merge on
15992
+ * write; a stored key NEVER round-trips to a client.
15459
15993
  */
15460
- var BrokerStatusSchema$1 = _enum([
15461
- "connected",
15462
- "disconnected",
15463
- "auth-failed",
15464
- "unreachable",
15465
- "tls-error"
15994
+ var LlmProfileKindSchema = _enum([
15995
+ "openai-compatible",
15996
+ "openai",
15997
+ "anthropic",
15998
+ "google",
15999
+ "managed-local"
15466
16000
  ]);
15467
- var BrokerInfoSchema = object({
16001
+ var LlmProfileSchema = object({
15468
16002
  id: string(),
15469
16003
  name: string(),
15470
- url: string(),
15471
- kind: BrokerKindSchema,
15472
- status: BrokerStatusSchema$1,
15473
- latencyMs: number().nullable(),
15474
- error: string().optional(),
15475
- /** Embedded brokers only: number of MQTT clients currently connected. */
15476
- connectedClients: number().int().nonnegative().optional(),
15477
- /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
15478
- lastCheckedAt: number().optional()
16004
+ kind: LlmProfileKindSchema,
16005
+ /** Stamped by the provider — keeps the fanned catalog routable. */
16006
+ addonId: string(),
16007
+ enabled: boolean(),
16008
+ /** Vendor model id, or the managed runtime's loaded model. */
16009
+ model: string(),
16010
+ /** Required for openai-compatible; override for cloud kinds. */
16011
+ baseUrl: string().optional(),
16012
+ /** ConfigUISchema type:'password' — never round-trips (spec §5). */
16013
+ apiKey: string().optional(),
16014
+ supportsVision: boolean(),
16015
+ temperature: number().min(0).max(2).optional(),
16016
+ maxTokens: number().int().positive().optional(),
16017
+ timeoutMs: number().int().positive().default(6e4),
16018
+ extraHeaders: record(string(), string()).optional(),
16019
+ /** kind === 'managed-local' only (spec §4). */
16020
+ runtime: ManagedRuntimeConfigSchema.optional()
15479
16021
  });
15480
- /**
15481
- * Connection details — what a consumer needs to call
15482
- * `mqtt.connect(url, options)`. We split URL + credentials so the
15483
- * consumer can pass them as `mqtt.connect(url, { username, password })`
15484
- * instead of stuffing creds into the URL (which leaks them into logs).
15485
- */
15486
- var BrokerConnectionDetailsSchema = object({
15487
- url: string(),
15488
- username: string().optional(),
15489
- password: string().optional(),
15490
- /**
15491
- * Suggested prefix for `clientId`. Each consumer should suffix this
15492
- * with its own discriminator (addon id, instance id) so reconnects
15493
- * don't kick each other off (MQTT spec: clientId must be unique per
15494
- * broker).
15495
- */
15496
- clientIdPrefix: string().optional()
16022
+ /** ConfigUISchema tree passed through untyped on the wire (the
16023
+ * notification-output `ConfigSchemaPassthrough` precedent at
16024
+ * notification-output.cap.ts:151); the exported TS type re-tightens it. */
16025
+ var ConfigSchemaPassthrough$1 = unknown();
16026
+ var LlmProfileKindDescriptorSchema = object({
16027
+ kind: LlmProfileKindSchema,
16028
+ label: string(),
16029
+ icon: string(),
16030
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
16031
+ addonId: string(),
16032
+ configSchema: ConfigSchemaPassthrough$1
15497
16033
  });
15498
- var AddBrokerInputSchema = object({
15499
- name: string().min(1),
15500
- url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
15501
- username: string().optional(),
15502
- password: string().optional(),
15503
- clientIdPrefix: string().optional()
16034
+ var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
16035
+ var LlmDefaultSchema = object({
16036
+ selector: LlmDefaultSelectorSchema,
16037
+ profileId: string()
15504
16038
  });
15505
- var AddBrokerResultSchema = object({ id: string() });
15506
- var IdInputSchema = object({ id: string() });
15507
- var TestResultSchema$1 = discriminatedUnion("ok", [object({
15508
- ok: literal(true),
15509
- latencyMs: number()
15510
- }), object({
15511
- ok: literal(false),
15512
- error: string()
15513
- })]);
15514
- var StartEmbeddedInputSchema = object({
15515
- port: number().int().min(1).max(65535).default(1883),
15516
- /** Allow anonymous connect (no username/password). Default: false. */
15517
- allowAnonymous: boolean().default(false),
15518
- /** Optional shared username/password for clients. */
15519
- username: string().optional(),
15520
- password: string().optional()
16039
+ /** Server-side rollup row getUsage never dumps raw call rows (spec §6). */
16040
+ var LlmUsageRollupSchema = object({
16041
+ day: string(),
16042
+ consumer: string(),
16043
+ profileId: string(),
16044
+ calls: number(),
16045
+ okCalls: number(),
16046
+ errorCalls: number(),
16047
+ inputTokens: number(),
16048
+ outputTokens: number(),
16049
+ avgLatencyMs: number()
15521
16050
  });
15522
- var StartEmbeddedResultSchema = object({
16051
+ /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
16052
+ var ManagedModelCatalogEntrySchema = object({
15523
16053
  id: string(),
15524
- url: string()
15525
- });
15526
- var StatusSchema = object({
15527
- brokerCount: number(),
15528
- embeddedRunning: boolean()
15529
- });
15530
- 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);
15531
- var NetworkEndpointSchema = object({
16054
+ label: string(),
16055
+ family: string(),
16056
+ purpose: _enum(["text", "vision"]),
15532
16057
  url: string(),
15533
- hostname: string(),
15534
- port: number(),
15535
- protocol: _enum(["http", "https"])
16058
+ sha256: string(),
16059
+ sizeBytes: number(),
16060
+ quantization: string(),
16061
+ /** Load-time guidance shown in the picker. */
16062
+ minRamBytes: number(),
16063
+ contextSizeDefault: number().int(),
16064
+ /** Vision models: companion projector file. */
16065
+ mmprojUrl: string().optional()
15536
16066
  });
15537
- var NetworkAccessStatusSchema = object({
15538
- connected: boolean(),
15539
- endpoint: NetworkEndpointSchema.nullable(),
16067
+ var LlmRuntimeNodeSchema = object({
16068
+ nodeId: string(),
16069
+ reachable: boolean(),
16070
+ status: LlmRuntimeStatusSchema.optional(),
16071
+ disk: LlmRuntimeDiskUsageSchema.optional(),
15540
16072
  error: string().optional()
15541
16073
  });
16074
+ var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
16075
+ var ProfileRefInputSchema = object({
16076
+ addonId: string(),
16077
+ profileId: string()
16078
+ });
16079
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
16080
+ kind: "mutation",
16081
+ auth: "admin"
16082
+ }), method(ProfileRefInputSchema, _void(), {
16083
+ kind: "mutation",
16084
+ auth: "admin"
16085
+ }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
16086
+ kind: "mutation",
16087
+ auth: "admin"
16088
+ }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
16089
+ selector: LlmDefaultSelectorSchema,
16090
+ profileId: string().nullable()
16091
+ }), _void(), {
16092
+ kind: "mutation",
16093
+ auth: "admin"
16094
+ }), method(object({
16095
+ since: number().optional(),
16096
+ until: number().optional(),
16097
+ consumer: string().optional(),
16098
+ profileId: string().optional()
16099
+ }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
16100
+ nodeId: string(),
16101
+ model: ManagedModelRefSchema
16102
+ }), _void(), {
16103
+ kind: "mutation",
16104
+ auth: "admin"
16105
+ }), method(object({
16106
+ nodeId: string(),
16107
+ file: string()
16108
+ }), _void(), {
16109
+ kind: "mutation",
16110
+ auth: "admin"
16111
+ }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
16112
+ kind: "mutation",
16113
+ auth: "admin"
16114
+ }), method(ProfileRefInputSchema, _void(), {
16115
+ kind: "mutation",
16116
+ auth: "admin"
16117
+ });
16118
+ var LogLevelSchema = _enum([
16119
+ "debug",
16120
+ "info",
16121
+ "warn",
16122
+ "error"
16123
+ ]);
16124
+ var LogEntrySchema = object({
16125
+ timestamp: date(),
16126
+ level: LogLevelSchema,
16127
+ scope: array(string()),
16128
+ message: string(),
16129
+ meta: record(string(), unknown()).optional(),
16130
+ tags: record(string(), string()).optional()
16131
+ });
16132
+ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16133
+ scope: array(string()).optional(),
16134
+ level: LogLevelSchema.optional(),
16135
+ since: date().optional(),
16136
+ until: date().optional(),
16137
+ limit: number().optional(),
16138
+ tags: record(string(), string()).optional()
16139
+ }), array(LogEntrySchema).readonly());
15542
16140
  /**
15543
- * Optional, richer endpoint shape returned by providers that expose
15544
- * MORE than one ingress concurrently (Tailscale Ingress with mixed
15545
- * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
15546
- * the originating provider config (mode + sourcePort) so the
15547
- * orchestrator UI can label rows distinctly. Providers that expose only
15548
- * one endpoint just omit `listEndpoints` from their provider impl.
15549
- */
15550
- var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
15551
- /**
15552
- * Stable id within the provider — typically `<mode>-<sourcePort>` so
15553
- * the orchestrator can dedupe across `listEndpoints` polls.
15554
- */
15555
- id: string(),
15556
- /** Operator-facing label (mirrors `MeshEndpoint.label`). */
15557
- label: string(),
15558
- /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
15559
- mode: string().optional(),
15560
- /** Originating local port the ingress fronts (informational). */
15561
- sourcePort: number().optional()
15562
- });
15563
- var networkAccessCapability = {
15564
- name: "network-access",
15565
- scope: "system",
15566
- mode: "collection",
15567
- providerKind: "ingress",
15568
- methods: {
15569
- start: method(_void(), NetworkEndpointSchema, { kind: "mutation" }),
15570
- stop: method(_void(), _void(), { kind: "mutation" }),
15571
- getEndpoint: method(_void(), NetworkEndpointSchema.nullable()),
15572
- getStatus: method(_void(), NetworkAccessStatusSchema),
15573
- /**
15574
- * Enumerate every active ingress entry. Providers that expose only a
15575
- * single endpoint may omit this method; callers fall back to
15576
- * `getEndpoint()` in that case.
15577
- */
15578
- listEndpoints: method(_void(), array(NetworkEndpointEntrySchema).readonly())
15579
- }
15580
- };
15581
- /**
15582
- * notification-output — canonical, capability-gated notification delivery.
16141
+ * `login-method` collection cap through which auth addons contribute
16142
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
16143
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
16144
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
16145
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
16146
+ * procedure aggregates them for the unauthenticated login page.
15583
16147
  *
15584
- * Apprise-derived model (see
15585
- * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
15586
- * callers emit ONE canonical `Notification`; each provider declares a
15587
- * per-kind capability descriptor (`TargetKind`), and the pure degrade
15588
- * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
15589
- * message to what the kind supports — callers never special-case a service.
16148
+ * A contribution is a discriminated union on `kind`:
15590
16149
  *
15591
- * DESIGN DECISIONS (locked):
15592
- * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
15593
- * `setTargetEnabled`), each provider persisting via the `settings-store`
15594
- * cap. Rationale: the admin UI needs one uniform surface across the
15595
- * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
15596
- * alternative would fork the UI per addon and cannot host the
15597
- * discovery→adopt flow.
15598
- * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
15599
- * the generated cap-mount auto-`concatCollection`-fans them across every
15600
- * registered provider (notifiers addon + HA addon) so one catalog is
15601
- * routable. `send` / `testTarget` / CRUD route to ONE provider by the
15602
- * `addonId` the generated collection router extracts from the call input.
15603
- * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
15604
- * transformer) + UDS MsgPack both round-trip typed arrays — already used by
15605
- * `storage` / `storage-provider` / `recording` caps over the same path. No
15606
- * base64 fallback needed.
16150
+ * - `redirect` a declarative button. The login page renders a generic
16151
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
16152
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
16153
+ * ZERO shell-side JS. A future SSO addon plugs in the same way the
16154
+ * login page needs NO change.
15607
16155
  *
15608
- * TODO (deferred, closed-set change separate decision): add
15609
- * `providerKind: 'notify'` so notification providers surface on the unified
15610
- * admin "Integrations" page.
15611
- */
15612
- /**
15613
- * Zentik-derived typed-media enum — the superset across every kind. Each
15614
- * adapter picks what it supports and the degrade engine filters the rest.
15615
- */
15616
- var AttachmentMediaTypeSchema = _enum([
15617
- "image",
15618
- "video",
15619
- "gif",
15620
- "audio",
15621
- "icon"
15622
- ]);
15623
- /**
15624
- * A single attachment. Exactly one of `url` (remote source, most adapters
15625
- * prefer this) or `bytes` (inline source; required for Pushover-style
15626
- * bytes-only kinds) MUST be present the degrade engine expresses a
15627
- * url→bytes fetch as a `needsFetch` directive the adapter executes.
16156
+ * - `widget` a Module-Federation widget the login page mounts (via
16157
+ * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
16158
+ * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
16159
+ * mechanism kept for future use; no shipped addon uses it on the login
16160
+ * page (the passkey ceremony below runs natively in the shell instead).
16161
+ *
16162
+ * - `passkey` a declarative WebAuthn ceremony the shell renders
16163
+ * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
16164
+ * a remotely-loaded bundle). Carries the addon's effective `rpId` /
16165
+ * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
16166
+ * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
16167
+ * fetching any remote code pre-auth. Contribution stays unconditional —
16168
+ * enrollment state is never leaked pre-auth; visibility is a shell
16169
+ * decision.
16170
+ *
16171
+ * Every contribution carries a `stage`:
16172
+ * - `primary` — shown on the first credentials screen (OIDC /
16173
+ * magic-link buttons; a future usernameless passkey).
16174
+ * - `second-factor` — shown AFTER the password leg, gated on the
16175
+ * returned `factors` (passkey-as-2FA today).
16176
+ *
16177
+ * `mount: skip` — the cap is read server-side by the core auth router
16178
+ * (`registry.getCollection('login-method')`), never mounted as its own
16179
+ * tRPC router.
15628
16180
  */
15629
- var AttachmentSchema = object({
15630
- mediaType: AttachmentMediaTypeSchema,
15631
- url: string().optional(),
15632
- bytes: _instanceof(Uint8Array).optional(),
15633
- mime: string().optional(),
15634
- name: string().optional()
15635
- }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
15636
- var NotificationFormatSchema = _enum([
15637
- "text",
15638
- "markdown",
15639
- "html"
16181
+ /** When a login method renders in the two-phase login flow. */
16182
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
16183
+ /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
16184
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [
16185
+ object({
16186
+ kind: literal("redirect"),
16187
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
16188
+ id: string(),
16189
+ /** Operator-facing button label. */
16190
+ label: string(),
16191
+ /** lucide-react icon name. */
16192
+ icon: string().optional(),
16193
+ /** Addon-owned HTTP route the button navigates to (GET). */
16194
+ startUrl: string(),
16195
+ stage: LoginStageEnum
16196
+ }),
16197
+ object({
16198
+ kind: literal("widget"),
16199
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
16200
+ id: string(),
16201
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
16202
+ addonId: string(),
16203
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
16204
+ bundle: string(),
16205
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
16206
+ remote: WidgetRemoteSchema,
16207
+ stage: LoginStageEnum
16208
+ }),
16209
+ object({
16210
+ kind: literal("passkey"),
16211
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
16212
+ id: string(),
16213
+ /** Operator-facing button label. */
16214
+ label: string(),
16215
+ stage: LoginStageEnum,
16216
+ /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
16217
+ rpId: string(),
16218
+ /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
16219
+ origin: string().nullable()
16220
+ })
15640
16221
  ]);
15641
- /** A single tap-through action button. */
15642
- var NotificationActionSchema = object({
15643
- id: string(),
15644
- label: string(),
15645
- url: string().optional()
16222
+ method(_void(), array(LoginMethodContributionSchema).readonly());
16223
+ var CpuBreakdownSchema = object({
16224
+ total: number(),
16225
+ user: number(),
16226
+ system: number(),
16227
+ irq: number(),
16228
+ nice: number(),
16229
+ loadAvg: tuple([
16230
+ number(),
16231
+ number(),
16232
+ number()
16233
+ ]),
16234
+ cores: number()
15646
16235
  });
15647
- /**
15648
- * The canonical notification. `body` is the only hard field (Apprise model).
15649
- * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
15650
- * NOT a fixed severity enum — each kind declares its own `caps.levels` and
15651
- * the adapter maps this ordinal onto its native level. `level?` is an
15652
- * optional kind-native level id (`emergency`, `silent`, …) that overrides
15653
- * `priority` for that one target.
15654
- */
15655
- var NotificationSchema = object({
15656
- body: string(),
15657
- title: string().optional(),
15658
- format: NotificationFormatSchema.default("text"),
15659
- priority: number().int().min(1).max(5).default(3),
15660
- level: string().optional(),
15661
- attachments: array(AttachmentSchema).optional(),
15662
- clickUrl: string().optional(),
15663
- actions: array(NotificationActionSchema).optional(),
15664
- sound: string().optional(),
15665
- ttl: number().optional(),
15666
- tag: string().optional(),
15667
- deviceId: number().optional(),
15668
- eventId: string().optional(),
15669
- metadata: record(string(), unknown()).optional()
16236
+ var MemoryInfoSchema = object({
16237
+ percent: number(),
16238
+ totalBytes: number(),
16239
+ usedBytes: number(),
16240
+ availableBytes: number(),
16241
+ swapUsedBytes: number(),
16242
+ swapTotalBytes: number()
15670
16243
  });
15671
- /** One declared native severity/priority level for a kind. */
15672
- var TargetKindLevelSchema = object({
15673
- id: string(),
15674
- label: string(),
15675
- /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
15676
- ordinal: number().int().min(1).max(5).nullable(),
15677
- flags: object({
15678
- critical: boolean().optional(),
15679
- silent: boolean().optional(),
15680
- noPush: boolean().optional()
15681
- }).optional(),
15682
- /** e.g. Pushover `emergency` requires `retry` / `expire`. */
15683
- requires: array(string()).optional(),
15684
- description: string().optional()
16244
+ var DiskIoSnapshotSchema = object({
16245
+ readBytes: number(),
16246
+ writeBytes: number(),
16247
+ readOps: number(),
16248
+ writeOps: number(),
16249
+ timestampMs: number()
16250
+ });
16251
+ var NetworkIoSnapshotSchema = object({
16252
+ rxBytes: number(),
16253
+ txBytes: number(),
16254
+ rxPackets: number(),
16255
+ txPackets: number(),
16256
+ rxErrors: number(),
16257
+ txErrors: number(),
16258
+ timestampMs: number()
16259
+ });
16260
+ var MetricsGpuInfoSchema = object({
16261
+ utilization: number(),
16262
+ model: string(),
16263
+ memoryUsedBytes: number(),
16264
+ memoryTotalBytes: number(),
16265
+ temperature: number().nullable()
16266
+ });
16267
+ var ProcessResourceInfoSchema = object({
16268
+ openFds: number(),
16269
+ threadCount: number(),
16270
+ activeHandles: number(),
16271
+ activeRequests: number()
16272
+ });
16273
+ var PressureAvgsSchema = object({
16274
+ avg10: number(),
16275
+ avg60: number(),
16276
+ avg300: number()
16277
+ });
16278
+ var PressureInfoSchema = object({
16279
+ some: PressureAvgsSchema,
16280
+ full: PressureAvgsSchema.nullable()
15685
16281
  });
15686
- /** The full capability block consulted before dispatch. */
15687
- var TargetKindCapsSchema = object({
15688
- attachments: object({
15689
- mediaTypes: array(AttachmentMediaTypeSchema),
15690
- mode: _enum([
15691
- "url",
15692
- "bytes",
15693
- "both"
15694
- ]),
15695
- max: number().int().nonnegative(),
15696
- maxBytes: number().int().positive().optional()
16282
+ var SystemResourceSnapshotSchema = object({
16283
+ cpu: CpuBreakdownSchema,
16284
+ memory: MemoryInfoSchema,
16285
+ gpu: MetricsGpuInfoSchema.nullable(),
16286
+ network: NetworkIoSnapshotSchema,
16287
+ disk: DiskIoSnapshotSchema,
16288
+ pressure: object({
16289
+ cpu: PressureInfoSchema.nullable(),
16290
+ memory: PressureInfoSchema.nullable(),
16291
+ io: PressureInfoSchema.nullable()
15697
16292
  }),
15698
- /** Max action buttons (0 = none). */
15699
- actions: number().int().nonnegative(),
15700
- levels: array(TargetKindLevelSchema),
15701
- format: array(NotificationFormatSchema),
15702
- clickUrl: boolean(),
15703
- sound: boolean(),
15704
- ttl: boolean(),
15705
- bodyMaxLen: number().int().positive()
16293
+ process: ProcessResourceInfoSchema,
16294
+ cpuTemperature: number().nullable(),
16295
+ timestampMs: number()
15706
16296
  });
15707
- /**
15708
- * `configSchema` is a `ConfigUISchema` tree passed through to the admin
15709
- * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
15710
- * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`)
15711
- * the union is large and not meant for runtime validation here; the exported
15712
- * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
15713
- */
15714
- var ConfigSchemaPassthrough$1 = unknown();
15715
- var TargetKindSchema = object({
15716
- kind: string(),
15717
- label: string(),
15718
- icon: string(),
15719
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
15720
- addonId: string(),
15721
- configSchema: ConfigSchemaPassthrough$1,
15722
- supportsDiscovery: boolean(),
15723
- caps: TargetKindCapsSchema
16297
+ var DiskSpaceInfoSchema = object({
16298
+ path: string(),
16299
+ totalBytes: number(),
16300
+ usedBytes: number(),
16301
+ availableBytes: number(),
16302
+ percent: number()
15724
16303
  });
15725
- /**
15726
- * A persisted target. `config` holds secrets; providers REDACT secret fields
15727
- * (return a presence marker only) when serving `listTargets` — never
15728
- * round-trip a stored secret to the UI.
15729
- */
15730
- var TargetSchema = object({
15731
- id: string(),
15732
- name: string(),
15733
- kind: string(),
16304
+ var PidResourceStatsSchema = object({
16305
+ pid: number(),
16306
+ cpu: number(),
16307
+ memory: number(),
16308
+ /**
16309
+ * Private (anonymous) resident bytes — the per-process V8 heap + native
16310
+ * allocations NOT shared with other processes (Linux RssAnon). This is the
16311
+ * "real" per-runner cost; summing it across runners is meaningful, unlike
16312
+ * `memory` (RSS), which double-counts the shared mmap'd framework code.
16313
+ * Undefined where /proc is unavailable (e.g. macOS).
16314
+ */
16315
+ privateBytes: number().optional(),
16316
+ /**
16317
+ * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
16318
+ * code shared copy-on-write across runners. Undefined on macOS.
16319
+ */
16320
+ sharedBytes: number().optional()
16321
+ });
16322
+ var AddonInstanceSchema = object({
15734
16323
  addonId: string(),
15735
- enabled: boolean(),
15736
- config: record(string(), unknown())
16324
+ nodeId: string(),
16325
+ role: _enum(["hub", "worker"]),
16326
+ pid: number(),
16327
+ state: _enum([
16328
+ "starting",
16329
+ "running",
16330
+ "stopping",
16331
+ "stopped",
16332
+ "crashed"
16333
+ ]),
16334
+ uptimeSec: number()
15737
16335
  });
15738
- /** A discovery-surfaced candidate (config is partial + non-secret). */
15739
- var DiscoveredTargetSchema = object({
15740
- kind: string(),
15741
- suggestedName: string(),
15742
- config: record(string(), unknown())
16336
+ var NodeProcessSchema = object({
16337
+ pid: number(),
16338
+ ppid: number(),
16339
+ pgid: number(),
16340
+ classification: _enum([
16341
+ "root",
16342
+ "managed",
16343
+ "system",
16344
+ "ghost"
16345
+ ]),
16346
+ /** `$process` addon binding when `managed`, else null. */
16347
+ addonId: string().nullable(),
16348
+ /** Kernel-reported nodeId when the process is a known agent/worker. */
16349
+ nodeId: string().nullable(),
16350
+ /** Truncated command line. */
16351
+ command: string(),
16352
+ cpuPercent: number(),
16353
+ memoryRssBytes: number(),
16354
+ /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
16355
+ uptimeSec: number(),
16356
+ /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
16357
+ orphaned: boolean()
15743
16358
  });
15744
- /** The degrade engine's report — what was resolved / dropped / degraded. */
15745
- var RenderedAsSchema = object({
15746
- level: string(),
15747
- format: NotificationFormatSchema,
15748
- attachmentsSent: number().int().nonnegative(),
15749
- actionsSent: number().int().nonnegative(),
15750
- truncated: boolean(),
15751
- dropped: array(string())
16359
+ var KillProcessInputSchema = object({
16360
+ pid: number(),
16361
+ /** Force = SIGKILL. Default is SIGTERM. */
16362
+ force: boolean().optional()
15752
16363
  });
15753
- var SendResultSchema = object({
16364
+ var KillProcessResultSchema = object({
15754
16365
  success: boolean(),
15755
- error: string().optional(),
15756
- renderedAs: RenderedAsSchema.optional()
16366
+ reason: string().optional(),
16367
+ signal: _enum(["SIGTERM", "SIGKILL"]).optional()
16368
+ });
16369
+ var DumpHeapSnapshotInputSchema = object({
16370
+ /** The addon whose runner should dump a heap snapshot. */
16371
+ addonId: string() });
16372
+ var DumpHeapSnapshotResultSchema = object({
16373
+ success: boolean(),
16374
+ /** Path of the written .heapsnapshot inside the runner's container/host. */
16375
+ path: string().optional(),
16376
+ /** Process pid that was signalled. */
16377
+ pid: number().optional(),
16378
+ reason: string().optional()
16379
+ });
16380
+ var SystemMetricsSchema = object({
16381
+ cpuPercent: number(),
16382
+ memoryPercent: number(),
16383
+ memoryUsedMB: number(),
16384
+ memoryTotalMB: number(),
16385
+ diskPercent: number().optional(),
16386
+ temperature: number().optional(),
16387
+ gpuPercent: number().optional(),
16388
+ gpuMemoryPercent: number().optional()
16389
+ });
16390
+ 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, {
16391
+ kind: "mutation",
16392
+ auth: "admin"
16393
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
16394
+ kind: "mutation",
16395
+ auth: "admin"
16396
+ });
16397
+ method(object({
16398
+ sourceUrl: string(),
16399
+ metadata: ModelConvertMetadataSchema,
16400
+ targets: array(ConvertTargetSchema).min(1).readonly(),
16401
+ calibrationRef: string().optional(),
16402
+ sessionId: string().optional()
16403
+ }), ConvertResultSchema, {
16404
+ kind: "mutation",
16405
+ auth: "admin",
16406
+ timeoutMs: 6e5
16407
+ });
16408
+ method(object({
16409
+ nodeId: string(),
16410
+ modelId: string(),
16411
+ format: _enum(MODEL_FORMATS),
16412
+ entry: ModelCatalogEntrySchema
16413
+ }), object({
16414
+ ok: boolean(),
16415
+ /** sha256 of the staged tarball (empty for a hub-local no-op). */
16416
+ sha256: string(),
16417
+ bytes: number(),
16418
+ /** The target node's modelsDir the artifact landed in. */
16419
+ path: string()
16420
+ }), {
16421
+ kind: "mutation",
16422
+ auth: "admin"
16423
+ });
16424
+ /**
16425
+ * `mqtt-broker` — broker-registry cap.
16426
+ *
16427
+ * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
16428
+ * MQTT brokers (external + optionally an embedded `aedes`-backed one)
16429
+ * and (b) the connection details a consumer addon needs to spin up
16430
+ * its OWN `mqtt.js` client.
16431
+ *
16432
+ * Why: pub/sub routing over the system event-bus loses fidelity
16433
+ * (callback shape, QoS guarantees, will/retain semantics) and adds
16434
+ * refcount bookkeeping that addons would rather own themselves. The
16435
+ * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
16436
+ * features anyway — give it the connection config, get out of the way.
16437
+ *
16438
+ * Consumer flow:
16439
+ * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
16440
+ * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
16441
+ * client.subscribe('zigbee2mqtt/+')
16442
+ *
16443
+ * Collection mode: multiple brokers (e.g. one local mosquitto + one
16444
+ * cloud bridge). The "embedded" entry (when present) is just another
16445
+ * broker in the registry — its lifecycle is owned by the addon that
16446
+ * spawned it.
16447
+ */
16448
+ var BrokerKindSchema = _enum(["external", "embedded"]);
16449
+ /**
16450
+ * Broker live-probe status.
16451
+ *
16452
+ * - `connected` — last probe completed a clean CONNACK
16453
+ * - `disconnected` — no probe has run yet (cold cache)
16454
+ * - `auth-failed` — CONNACK refused with auth error (RC 4 / 5)
16455
+ * - `unreachable` — TCP connect timed out / refused
16456
+ * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
16457
+ */
16458
+ var BrokerStatusSchema$1 = _enum([
16459
+ "connected",
16460
+ "disconnected",
16461
+ "auth-failed",
16462
+ "unreachable",
16463
+ "tls-error"
16464
+ ]);
16465
+ var BrokerInfoSchema = object({
16466
+ id: string(),
16467
+ name: string(),
16468
+ url: string(),
16469
+ kind: BrokerKindSchema,
16470
+ status: BrokerStatusSchema$1,
16471
+ latencyMs: number().nullable(),
16472
+ error: string().optional(),
16473
+ /** Embedded brokers only: number of MQTT clients currently connected. */
16474
+ connectedClients: number().int().nonnegative().optional(),
16475
+ /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
16476
+ lastCheckedAt: number().optional()
15757
16477
  });
15758
- /** Same shape as SendResult — kept as a distinct name for the test panel. */
15759
- var TestResultSchema = SendResultSchema;
15760
- method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
15761
- kind: string(),
15762
- config: record(string(), unknown()).optional()
15763
- }), array(DiscoveredTargetSchema)), method(object({
15764
- targetId: string(),
15765
- notification: NotificationSchema
15766
- }), SendResultSchema, { kind: "mutation" }), method(object({
15767
- targetId: string(),
15768
- sample: NotificationSchema.optional()
15769
- }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
15770
- targetId: string(),
15771
- enabled: boolean()
15772
- }), _void(), { kind: "mutation" });
15773
16478
  /**
15774
- * Shared LLM generate contracts imported by BOTH `llm.cap.ts` (consumer
15775
- * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15776
- * caps stay wire-compatible without a circular cap→cap import.
15777
- *
15778
- * Errors are a discriminated-union RESULT, never thrown: the shape survives
15779
- * every transport tier structurally, and failed calls still write usage rows.
15780
- * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
16479
+ * Connection details what a consumer needs to call
16480
+ * `mqtt.connect(url, options)`. We split URL + credentials so the
16481
+ * consumer can pass them as `mqtt.connect(url, { username, password })`
16482
+ * instead of stuffing creds into the URL (which leaks them into logs).
15781
16483
  */
15782
- var LlmUsageSchema = object({
15783
- inputTokens: number(),
15784
- outputTokens: number()
16484
+ var BrokerConnectionDetailsSchema = object({
16485
+ url: string(),
16486
+ username: string().optional(),
16487
+ password: string().optional(),
16488
+ /**
16489
+ * Suggested prefix for `clientId`. Each consumer should suffix this
16490
+ * with its own discriminator (addon id, instance id) so reconnects
16491
+ * don't kick each other off (MQTT spec: clientId must be unique per
16492
+ * broker).
16493
+ */
16494
+ clientIdPrefix: string().optional()
15785
16495
  });
15786
- var LlmErrorCodeSchema = _enum([
15787
- "timeout",
15788
- "rate-limited",
15789
- "auth",
15790
- "refusal",
15791
- "bad-request",
15792
- "unavailable",
15793
- "no-profile",
15794
- "budget-exceeded",
15795
- "adapter-error"
15796
- ]);
15797
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
16496
+ var AddBrokerInputSchema = object({
16497
+ name: string().min(1),
16498
+ url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
16499
+ username: string().optional(),
16500
+ password: string().optional(),
16501
+ clientIdPrefix: string().optional()
16502
+ });
16503
+ var AddBrokerResultSchema = object({ id: string() });
16504
+ var IdInputSchema = object({ id: string() });
16505
+ var TestResultSchema$1 = discriminatedUnion("ok", [object({
15798
16506
  ok: literal(true),
15799
- text: string(),
15800
- model: string(),
15801
- usage: LlmUsageSchema,
15802
- truncated: boolean(),
15803
16507
  latencyMs: number()
15804
16508
  }), object({
15805
16509
  ok: literal(false),
15806
- code: LlmErrorCodeSchema,
15807
- message: string(),
15808
- retryAfterMs: number().optional()
16510
+ error: string()
15809
16511
  })]);
15810
- /**
15811
- * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
15812
- * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
15813
- * notification-output.cap.ts:27-31 precedents).
15814
- */
15815
- var LlmImageSchema = object({
15816
- bytes: _instanceof(Uint8Array),
15817
- mimeType: string()
16512
+ var StartEmbeddedInputSchema = object({
16513
+ port: number().int().min(1).max(65535).default(1883),
16514
+ /** Allow anonymous connect (no username/password). Default: false. */
16515
+ allowAnonymous: boolean().default(false),
16516
+ /** Optional shared username/password for clients. */
16517
+ username: string().optional(),
16518
+ password: string().optional()
15818
16519
  });
15819
- var LlmGenerateBaseInputSchema = object({
15820
- /** Collection routing (the notification-output posture). */
15821
- addonId: string().optional(),
15822
- /** Explicit profile; else the resolution chain (spec §3). */
15823
- profileId: string().optional(),
15824
- /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
15825
- consumer: string(),
15826
- system: string().optional(),
15827
- /** v1: single-turn. `messages[]` is a v2 additive field. */
15828
- prompt: string(),
15829
- /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
15830
- jsonSchema: record(string(), unknown()).optional(),
15831
- /** Per-call override of the profile default. */
15832
- maxTokens: number().int().positive().optional(),
15833
- temperature: number().optional()
16520
+ var StartEmbeddedResultSchema = object({
16521
+ id: string(),
16522
+ url: string()
15834
16523
  });
15835
- /**
15836
- * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
15837
- * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
15838
- * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
15839
- * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
15840
- * this only through the `llm` cap's methods.
15841
- *
15842
- * One running llama-server child per node in v1 (models are RAM-heavy).
15843
- * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
15844
- * watchdog — operator decision #3).
15845
- */
15846
- var ManagedModelRefSchema = discriminatedUnion("kind", [
15847
- object({
15848
- kind: literal("catalog"),
15849
- catalogId: string()
15850
- }),
15851
- object({
15852
- kind: literal("url"),
15853
- url: string(),
15854
- sha256: string().optional()
15855
- }),
15856
- object({
15857
- kind: literal("path"),
15858
- path: string()
15859
- })
15860
- ]);
15861
- var ManagedRuntimeConfigSchema = object({
15862
- /** WHERE the runtime lives — hub or any agent. */
15863
- nodeId: string(),
15864
- /** Closed for v1; 'ollama' is a v2 candidate. */
15865
- engine: _enum(["llama-cpp"]),
15866
- model: ManagedModelRefSchema,
15867
- contextSize: number().int().default(4096),
15868
- /** 0 = CPU-only. */
15869
- gpuLayers: number().int().default(0),
15870
- /** Default: cpus-2, clamped ≥1 (resolved node-side). */
15871
- threads: number().int().optional(),
15872
- /** Concurrent slots. */
15873
- parallel: number().int().default(1),
15874
- /** Else lazy: first generate boots it. */
15875
- autoStart: boolean().default(false),
15876
- /** 0 = never; frees RAM after quiet periods. */
15877
- idleStopMinutes: number().int().default(30)
16524
+ var StatusSchema = object({
16525
+ brokerCount: number(),
16526
+ embeddedRunning: boolean()
15878
16527
  });
15879
- var LlmRuntimeStatusSchema = object({
15880
- /** Status is ALWAYS node-qualified. */
15881
- nodeId: string(),
15882
- state: _enum([
15883
- "stopped",
15884
- "downloading",
15885
- "starting",
15886
- "ready",
15887
- "crashed",
15888
- "failed"
15889
- ]),
15890
- pid: number().optional(),
15891
- port: number().optional(),
15892
- modelPath: string().optional(),
15893
- modelId: string().optional(),
15894
- downloadProgress: number().min(0).max(1).optional(),
15895
- lastError: string().optional(),
15896
- crashesInWindow: number(),
15897
- /** Child RSS (sampled best-effort). */
15898
- memoryBytes: number().optional(),
15899
- vramBytes: number().optional()
16528
+ 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);
16529
+ var NetworkEndpointSchema = object({
16530
+ url: string(),
16531
+ hostname: string(),
16532
+ port: number(),
16533
+ protocol: _enum(["http", "https"])
15900
16534
  });
15901
- var LlmNodeModelSchema = object({
15902
- file: string(),
15903
- sizeBytes: number(),
15904
- catalogId: string().optional(),
15905
- installedAt: number().optional()
16535
+ var NetworkAccessStatusSchema = object({
16536
+ connected: boolean(),
16537
+ endpoint: NetworkEndpointSchema.nullable(),
16538
+ error: string().optional()
15906
16539
  });
15907
- var LlmRuntimeDiskUsageSchema = object({
15908
- nodeId: string(),
15909
- modelsBytes: number(),
15910
- freeBytes: number().optional()
16540
+ /**
16541
+ * Optional, richer endpoint shape returned by providers that expose
16542
+ * MORE than one ingress concurrently (Tailscale Ingress with mixed
16543
+ * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
16544
+ * the originating provider config (mode + sourcePort) so the
16545
+ * orchestrator UI can label rows distinctly. Providers that expose only
16546
+ * one endpoint just omit `listEndpoints` from their provider impl.
16547
+ */
16548
+ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
16549
+ /**
16550
+ * Stable id within the provider — typically `<mode>-<sourcePort>` so
16551
+ * the orchestrator can dedupe across `listEndpoints` polls.
16552
+ */
16553
+ id: string(),
16554
+ /** Operator-facing label (mirrors `MeshEndpoint.label`). */
16555
+ label: string(),
16556
+ /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
16557
+ mode: string().optional(),
16558
+ /** Originating local port the ingress fronts (informational). */
16559
+ sourcePort: number().optional()
15911
16560
  });
15912
- method(LlmGenerateBaseInputSchema.extend({
15913
- images: array(LlmImageSchema).optional(),
15914
- runtime: ManagedRuntimeConfigSchema,
15915
- /** The managed profile's timeout, threaded by the hub provider. */
15916
- timeoutMs: number().int().positive().optional()
15917
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
15918
- kind: "mutation",
15919
- auth: "admin"
15920
- }), method(object({}), _void(), {
15921
- kind: "mutation",
15922
- auth: "admin"
15923
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
15924
- kind: "mutation",
15925
- auth: "admin"
15926
- }), method(object({ file: string() }), _void(), {
15927
- kind: "mutation",
15928
- auth: "admin"
15929
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
16561
+ var networkAccessCapability = {
16562
+ name: "network-access",
16563
+ scope: "system",
16564
+ mode: "collection",
16565
+ providerKind: "ingress",
16566
+ methods: {
16567
+ start: method(_void(), NetworkEndpointSchema, { kind: "mutation" }),
16568
+ stop: method(_void(), _void(), { kind: "mutation" }),
16569
+ getEndpoint: method(_void(), NetworkEndpointSchema.nullable()),
16570
+ getStatus: method(_void(), NetworkAccessStatusSchema),
16571
+ /**
16572
+ * Enumerate every active ingress entry. Providers that expose only a
16573
+ * single endpoint may omit this method; callers fall back to
16574
+ * `getEndpoint()` in that case.
16575
+ */
16576
+ listEndpoints: method(_void(), array(NetworkEndpointEntrySchema).readonly())
16577
+ }
16578
+ };
15930
16579
  /**
15931
- * `llm`consumer-facing LLM surface (spec §1-§3). Collection-mode: array
15932
- * methods concat-fan across providers; single-row methods route to ONE
15933
- * provider by the `addonId` in the call input (the notification-output
15934
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
15935
- * (hub-placed); the cap stays open for future providers.
16580
+ * notification-outputcanonical, capability-gated notification delivery.
16581
+ *
16582
+ * Apprise-derived model (see
16583
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
16584
+ * callers emit ONE canonical `Notification`; each provider declares a
16585
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
16586
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
16587
+ * message to what the kind supports — callers never special-case a service.
16588
+ *
16589
+ * DESIGN DECISIONS (locked):
16590
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
16591
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
16592
+ * cap. Rationale: the admin UI needs one uniform surface across the
16593
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
16594
+ * alternative would fork the UI per addon and cannot host the
16595
+ * discovery→adopt flow.
16596
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
16597
+ * the generated cap-mount auto-`concatCollection`-fans them across every
16598
+ * registered provider (notifiers addon + HA addon) so one catalog is
16599
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
16600
+ * `addonId` the generated collection router extracts from the call input.
16601
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
16602
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
16603
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
16604
+ * base64 fallback needed.
15936
16605
  *
15937
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
15938
- * `apiKey` is a password field — providers REDACT it on read and merge on
15939
- * write; a stored key NEVER round-trips to a client.
16606
+ * TODO (deferred, closed-set change separate decision): add
16607
+ * `providerKind: 'notify'` so notification providers surface on the unified
16608
+ * admin "Integrations" page.
15940
16609
  */
15941
- var LlmProfileKindSchema = _enum([
15942
- "openai-compatible",
15943
- "openai",
15944
- "anthropic",
15945
- "google",
15946
- "managed-local"
16610
+ /**
16611
+ * Zentik-derived typed-media enum — the superset across every kind. Each
16612
+ * adapter picks what it supports and the degrade engine filters the rest.
16613
+ */
16614
+ var AttachmentMediaTypeSchema = _enum([
16615
+ "image",
16616
+ "video",
16617
+ "gif",
16618
+ "audio",
16619
+ "icon"
15947
16620
  ]);
15948
- var LlmProfileSchema = object({
16621
+ /**
16622
+ * A single attachment. Exactly one of `url` (remote source, most adapters
16623
+ * prefer this) or `bytes` (inline source; required for Pushover-style
16624
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
16625
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
16626
+ */
16627
+ var AttachmentSchema = object({
16628
+ mediaType: AttachmentMediaTypeSchema,
16629
+ url: string().optional(),
16630
+ bytes: _instanceof(Uint8Array).optional(),
16631
+ mime: string().optional(),
16632
+ name: string().optional()
16633
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
16634
+ var NotificationFormatSchema = _enum([
16635
+ "text",
16636
+ "markdown",
16637
+ "html"
16638
+ ]);
16639
+ /** A single tap-through action button. */
16640
+ var NotificationActionSchema = object({
15949
16641
  id: string(),
15950
- name: string(),
15951
- kind: LlmProfileKindSchema,
15952
- /** Stamped by the provider — keeps the fanned catalog routable. */
15953
- addonId: string(),
15954
- enabled: boolean(),
15955
- /** Vendor model id, or the managed runtime's loaded model. */
15956
- model: string(),
15957
- /** Required for openai-compatible; override for cloud kinds. */
15958
- baseUrl: string().optional(),
15959
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
15960
- apiKey: string().optional(),
15961
- supportsVision: boolean(),
15962
- temperature: number().min(0).max(2).optional(),
15963
- maxTokens: number().int().positive().optional(),
15964
- timeoutMs: number().int().positive().default(6e4),
15965
- extraHeaders: record(string(), string()).optional(),
15966
- /** kind === 'managed-local' only (spec §4). */
15967
- runtime: ManagedRuntimeConfigSchema.optional()
16642
+ label: string(),
16643
+ url: string().optional()
15968
16644
  });
15969
- /** ConfigUISchema tree passed through untyped on the wire (the
15970
- * notification-output `ConfigSchemaPassthrough` precedent at
15971
- * notification-output.cap.ts:151); the exported TS type re-tightens it. */
16645
+ /**
16646
+ * The canonical notification. `body` is the only hard field (Apprise model).
16647
+ * `priority` is a 5-level ORDINAL (1=lowest 3=normal(default) 5=urgent),
16648
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
16649
+ * the adapter maps this ordinal onto its native level. `level?` is an
16650
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
16651
+ * `priority` for that one target.
16652
+ */
16653
+ var NotificationSchema = object({
16654
+ body: string(),
16655
+ title: string().optional(),
16656
+ format: NotificationFormatSchema.default("text"),
16657
+ priority: number().int().min(1).max(5).default(3),
16658
+ level: string().optional(),
16659
+ attachments: array(AttachmentSchema).optional(),
16660
+ clickUrl: string().optional(),
16661
+ actions: array(NotificationActionSchema).optional(),
16662
+ sound: string().optional(),
16663
+ ttl: number().optional(),
16664
+ tag: string().optional(),
16665
+ deviceId: number().optional(),
16666
+ eventId: string().optional(),
16667
+ metadata: record(string(), unknown()).optional()
16668
+ });
16669
+ /** One declared native severity/priority level for a kind. */
16670
+ var TargetKindLevelSchema = object({
16671
+ id: string(),
16672
+ label: string(),
16673
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
16674
+ ordinal: number().int().min(1).max(5).nullable(),
16675
+ flags: object({
16676
+ critical: boolean().optional(),
16677
+ silent: boolean().optional(),
16678
+ noPush: boolean().optional()
16679
+ }).optional(),
16680
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
16681
+ requires: array(string()).optional(),
16682
+ description: string().optional()
16683
+ });
16684
+ /** The full capability block consulted before dispatch. */
16685
+ var TargetKindCapsSchema = object({
16686
+ attachments: object({
16687
+ mediaTypes: array(AttachmentMediaTypeSchema),
16688
+ mode: _enum([
16689
+ "url",
16690
+ "bytes",
16691
+ "both"
16692
+ ]),
16693
+ max: number().int().nonnegative(),
16694
+ maxBytes: number().int().positive().optional()
16695
+ }),
16696
+ /** Max action buttons (0 = none). */
16697
+ actions: number().int().nonnegative(),
16698
+ levels: array(TargetKindLevelSchema),
16699
+ format: array(NotificationFormatSchema),
16700
+ clickUrl: boolean(),
16701
+ sound: boolean(),
16702
+ ttl: boolean(),
16703
+ bodyMaxLen: number().int().positive()
16704
+ });
16705
+ /**
16706
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
16707
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
16708
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
16709
+ * the union is large and not meant for runtime validation here; the exported
16710
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
16711
+ */
15972
16712
  var ConfigSchemaPassthrough = unknown();
15973
- var LlmProfileKindDescriptorSchema = object({
15974
- kind: LlmProfileKindSchema,
16713
+ var TargetKindSchema = object({
16714
+ kind: string(),
15975
16715
  label: string(),
15976
16716
  icon: string(),
15977
16717
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
15978
16718
  addonId: string(),
15979
- configSchema: ConfigSchemaPassthrough
15980
- });
15981
- var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
15982
- var LlmDefaultSchema = object({
15983
- selector: LlmDefaultSelectorSchema,
15984
- profileId: string()
15985
- });
15986
- /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
15987
- var LlmUsageRollupSchema = object({
15988
- day: string(),
15989
- consumer: string(),
15990
- profileId: string(),
15991
- calls: number(),
15992
- okCalls: number(),
15993
- errorCalls: number(),
15994
- inputTokens: number(),
15995
- outputTokens: number(),
15996
- avgLatencyMs: number()
16719
+ configSchema: ConfigSchemaPassthrough,
16720
+ supportsDiscovery: boolean(),
16721
+ caps: TargetKindCapsSchema
15997
16722
  });
15998
- /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
15999
- var ManagedModelCatalogEntrySchema = object({
16723
+ /**
16724
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
16725
+ * (return a presence marker only) when serving `listTargets` — never
16726
+ * round-trip a stored secret to the UI.
16727
+ */
16728
+ var TargetSchema = object({
16000
16729
  id: string(),
16001
- label: string(),
16002
- family: string(),
16003
- purpose: _enum(["text", "vision"]),
16004
- url: string(),
16005
- sha256: string(),
16006
- sizeBytes: number(),
16007
- quantization: string(),
16008
- /** Load-time guidance shown in the picker. */
16009
- minRamBytes: number(),
16010
- contextSizeDefault: number().int(),
16011
- /** Vision models: companion projector file. */
16012
- mmprojUrl: string().optional()
16013
- });
16014
- var LlmRuntimeNodeSchema = object({
16015
- nodeId: string(),
16016
- reachable: boolean(),
16017
- status: LlmRuntimeStatusSchema.optional(),
16018
- disk: LlmRuntimeDiskUsageSchema.optional(),
16019
- error: string().optional()
16020
- });
16021
- var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
16022
- var ProfileRefInputSchema = object({
16730
+ name: string(),
16731
+ kind: string(),
16023
16732
  addonId: string(),
16024
- profileId: string()
16733
+ enabled: boolean(),
16734
+ config: record(string(), unknown())
16025
16735
  });
16026
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
16027
- kind: "mutation",
16028
- auth: "admin"
16029
- }), method(ProfileRefInputSchema, _void(), {
16030
- kind: "mutation",
16031
- auth: "admin"
16032
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
16033
- kind: "mutation",
16034
- auth: "admin"
16035
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
16036
- selector: LlmDefaultSelectorSchema,
16037
- profileId: string().nullable()
16038
- }), _void(), {
16039
- kind: "mutation",
16040
- auth: "admin"
16041
- }), method(object({
16042
- since: number().optional(),
16043
- until: number().optional(),
16044
- consumer: string().optional(),
16045
- profileId: string().optional()
16046
- }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
16047
- nodeId: string(),
16048
- model: ManagedModelRefSchema
16049
- }), _void(), {
16050
- kind: "mutation",
16051
- auth: "admin"
16052
- }), method(object({
16053
- nodeId: string(),
16054
- file: string()
16055
- }), _void(), {
16056
- kind: "mutation",
16057
- auth: "admin"
16058
- }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
16059
- kind: "mutation",
16060
- auth: "admin"
16061
- }), method(ProfileRefInputSchema, _void(), {
16062
- kind: "mutation",
16063
- auth: "admin"
16736
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
16737
+ var DiscoveredTargetSchema = object({
16738
+ kind: string(),
16739
+ suggestedName: string(),
16740
+ config: record(string(), unknown())
16741
+ });
16742
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
16743
+ var RenderedAsSchema = object({
16744
+ level: string(),
16745
+ format: NotificationFormatSchema,
16746
+ attachmentsSent: number().int().nonnegative(),
16747
+ actionsSent: number().int().nonnegative(),
16748
+ truncated: boolean(),
16749
+ dropped: array(string())
16750
+ });
16751
+ var SendResultSchema = object({
16752
+ success: boolean(),
16753
+ error: string().optional(),
16754
+ renderedAs: RenderedAsSchema.optional()
16064
16755
  });
16756
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
16757
+ var TestResultSchema = SendResultSchema;
16758
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
16759
+ kind: string(),
16760
+ config: record(string(), unknown()).optional()
16761
+ }), array(DiscoveredTargetSchema)), method(object({
16762
+ targetId: string(),
16763
+ notification: NotificationSchema
16764
+ }), SendResultSchema, { kind: "mutation" }), method(object({
16765
+ targetId: string(),
16766
+ sample: NotificationSchema.optional()
16767
+ }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
16768
+ targetId: string(),
16769
+ enabled: boolean()
16770
+ }), _void(), { kind: "mutation" });
16065
16771
  /**
16066
16772
  * Zod schemas for persisted record types.
16067
16773
  *
@@ -16747,7 +17453,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
16747
17453
  }), method(object({
16748
17454
  eventId: string(),
16749
17455
  kind: MediaFileKindEnum.optional()
16750
- }), array(MediaFileSchema).readonly()), method(object({ trackId: string() }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
17456
+ }), array(MediaFileSchema).readonly()), method(object({
17457
+ trackId: string(),
17458
+ kinds: array(MediaFileKindEnum).optional()
17459
+ }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
16751
17460
  deviceId: number(),
16752
17461
  timestamp: number(),
16753
17462
  frameWidth: number(),
@@ -16768,76 +17477,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
16768
17477
  eventId: string(),
16769
17478
  timestamp: number()
16770
17479
  });
16771
- /**
16772
- * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
16773
- * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
16774
- * caps into per-camera event-kind descriptors.
16775
- *
16776
- * The descriptor DATA (color / iconId / labelKey / parentKind / category)
16777
- * is NOT duplicated here — every entry is derived from the single
16778
- * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
16779
- * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
16780
- * control cap means adding one line here (and a taxonomy entry); the anti-
16781
- * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
16782
- * eventful cap is missing.
16783
- */
16784
- /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
16785
- var LEGACY_ICON = {
16786
- motion: "motion",
16787
- audio: "audio",
16788
- person: "person",
16789
- vehicle: "vehicle",
16790
- animal: "animal",
16791
- package: "package",
16792
- door: "door",
16793
- pir: "pir",
16794
- smoke: "smoke",
16795
- water: "water",
16796
- button: "button",
16797
- generic: "generic",
16798
- gas: "smoke",
16799
- vibration: "generic",
16800
- tamper: "generic",
16801
- presence: "person",
16802
- lock: "generic",
16803
- siren: "generic",
16804
- switch: "generic",
16805
- doorbell: "button"
16806
- };
16807
- function legacyIcon(iconId) {
16808
- return LEGACY_ICON[iconId] ?? "generic";
16809
- }
16810
- /**
16811
- * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
16812
- * The anti-drift guard cross-checks this against the eventful caps declared
16813
- * in `packages/types/src/capabilities/*.cap.ts`.
16814
- */
16815
- var CAP_TO_KIND = {
16816
- contact: "contact",
16817
- motion: "motion-sensor",
16818
- smoke: "smoke",
16819
- flood: "flood",
16820
- gas: "gas",
16821
- "carbon-monoxide": "carbon-monoxide",
16822
- vibration: "vibration",
16823
- tamper: "tamper",
16824
- presence: "presence",
16825
- "enum-sensor": "enum-sensor",
16826
- "event-emitter": "device-event",
16827
- "lock-control": "lock",
16828
- switch: "switch",
16829
- button: "button",
16830
- doorbell: "doorbell"
16831
- };
16832
- function buildDescriptor(capName, kind) {
16833
- const t = EVENT_TAXONOMY[kind];
16834
- if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
16835
- return {
16836
- ...t,
16837
- icon: legacyIcon(t.iconId)
16838
- };
16839
- }
16840
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
16841
17480
  var CameraPipelineConfigSchema = object({
16842
17481
  engine: PipelineEngineChoiceSchema.optional(),
16843
17482
  steps: array(PipelineStepInputSchema).readonly(),
@@ -17323,6 +17962,76 @@ method(object({
17323
17962
  auth: "admin"
17324
17963
  });
17325
17964
  /**
17965
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
17966
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
17967
+ * caps into per-camera event-kind descriptors.
17968
+ *
17969
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
17970
+ * is NOT duplicated here — every entry is derived from the single
17971
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
17972
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
17973
+ * control cap means adding one line here (and a taxonomy entry); the anti-
17974
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
17975
+ * eventful cap is missing.
17976
+ */
17977
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
17978
+ var LEGACY_ICON = {
17979
+ motion: "motion",
17980
+ audio: "audio",
17981
+ person: "person",
17982
+ vehicle: "vehicle",
17983
+ animal: "animal",
17984
+ package: "package",
17985
+ door: "door",
17986
+ pir: "pir",
17987
+ smoke: "smoke",
17988
+ water: "water",
17989
+ button: "button",
17990
+ generic: "generic",
17991
+ gas: "smoke",
17992
+ vibration: "generic",
17993
+ tamper: "generic",
17994
+ presence: "person",
17995
+ lock: "generic",
17996
+ siren: "generic",
17997
+ switch: "generic",
17998
+ doorbell: "button"
17999
+ };
18000
+ function legacyIcon(iconId) {
18001
+ return LEGACY_ICON[iconId] ?? "generic";
18002
+ }
18003
+ /**
18004
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
18005
+ * The anti-drift guard cross-checks this against the eventful caps declared
18006
+ * in `packages/types/src/capabilities/*.cap.ts`.
18007
+ */
18008
+ var CAP_TO_KIND = {
18009
+ contact: "contact",
18010
+ motion: "motion-sensor",
18011
+ smoke: "smoke",
18012
+ flood: "flood",
18013
+ gas: "gas",
18014
+ "carbon-monoxide": "carbon-monoxide",
18015
+ vibration: "vibration",
18016
+ tamper: "tamper",
18017
+ presence: "presence",
18018
+ "enum-sensor": "enum-sensor",
18019
+ "event-emitter": "device-event",
18020
+ "lock-control": "lock",
18021
+ switch: "switch",
18022
+ button: "button",
18023
+ doorbell: "doorbell"
18024
+ };
18025
+ function buildDescriptor(capName, kind) {
18026
+ const t = EVENT_TAXONOMY[kind];
18027
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
18028
+ return {
18029
+ ...t,
18030
+ icon: legacyIcon(t.iconId)
18031
+ };
18032
+ }
18033
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
18034
+ /**
17326
18035
  * server-management — per-NODE singleton capability for a node's ROOT
17327
18036
  * package lifecycle (runtime-updatable node packages).
17328
18037
  *
@@ -18800,7 +19509,28 @@ var FaceInfoSchema = object({
18800
19509
  * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`). Absent when the
18801
19510
  * track produced no key frame (e.g. native/onboard source) — the UI falls
18802
19511
  * back to the inline `base64` face crop. */
18803
- keyFrameMediaKey: string().optional()
19512
+ keyFrameMediaKey: string().optional(),
19513
+ /** Winning identity-match cosine (0..1) for this face's track, when an
19514
+ * identity was auto-confirmed. Lets the UI surface WHY a face was assigned
19515
+ * (confidence badge / low-confidence audit). Absent on legacy rows and on
19516
+ * faces that were never auto-recognized. */
19517
+ bestMatchScore: number().optional(),
19518
+ /** Native-scale face short side (px) at recognition time, when the runner
19519
+ * measured it. Lets the UI flag low-resolution auto-assignments. Absent on
19520
+ * legacy rows / runners that reported no native measure. */
19521
+ nativeFaceShortSidePx: number().optional(),
19522
+ /** SUGGESTED identity for this face — a plausible-but-not-confident match that
19523
+ * MISSED auto-assignment (cosine in the suggestion band, or above threshold
19524
+ * but blocked only by the recognition size floor). Mutually exclusive with
19525
+ * `recognizedIdentityId` (a suggestion is NEVER an assignment): the face stays
19526
+ * UNASSIGNED and everything else keeps treating it as unrecognized — the UI
19527
+ * merely offers a one-tap "is this <name>?" confirm. Absent on legacy rows and
19528
+ * on faces that were auto-assigned or below the suggestion band. (2026-07-24) */
19529
+ suggestedIdentityId: string().optional(),
19530
+ /** Peak identity-match cosine (0..1) for `suggestedIdentityId`, captured at the
19531
+ * same moment as `bestMatchScore` (track peak, at close). Lets the UI rank /
19532
+ * badge suggestion confidence. Present iff `suggestedIdentityId` is. (2026-07-24) */
19533
+ suggestedMatchScore: number().optional()
18804
19534
  });
18805
19535
  var FaceFilterEnum = _enum([
18806
19536
  "unassigned",
@@ -20843,36 +21573,6 @@ Object.freeze({
20843
21573
  addonId: null,
20844
21574
  access: "view"
20845
21575
  },
20846
- "advancedNotifier.deleteRule": {
20847
- capName: "advanced-notifier",
20848
- capScope: "system",
20849
- addonId: null,
20850
- access: "delete"
20851
- },
20852
- "advancedNotifier.getHistory": {
20853
- capName: "advanced-notifier",
20854
- capScope: "system",
20855
- addonId: null,
20856
- access: "view"
20857
- },
20858
- "advancedNotifier.getRules": {
20859
- capName: "advanced-notifier",
20860
- capScope: "system",
20861
- addonId: null,
20862
- access: "view"
20863
- },
20864
- "advancedNotifier.testRule": {
20865
- capName: "advanced-notifier",
20866
- capScope: "system",
20867
- addonId: null,
20868
- access: "create"
20869
- },
20870
- "advancedNotifier.upsertRule": {
20871
- capName: "advanced-notifier",
20872
- capScope: "system",
20873
- addonId: null,
20874
- access: "create"
20875
- },
20876
21576
  "alarmPanel.arm": {
20877
21577
  capName: "alarm-panel",
20878
21578
  capScope: "device",
@@ -21095,6 +21795,12 @@ Object.freeze({
21095
21795
  addonId: null,
21096
21796
  access: "delete"
21097
21797
  },
21798
+ "backup.deleteSchedule": {
21799
+ capName: "backup",
21800
+ capScope: "system",
21801
+ addonId: null,
21802
+ access: "delete"
21803
+ },
21098
21804
  "backup.getEntries": {
21099
21805
  capName: "backup",
21100
21806
  capScope: "system",
@@ -21125,6 +21831,12 @@ Object.freeze({
21125
21831
  addonId: null,
21126
21832
  access: "view"
21127
21833
  },
21834
+ "backup.listSchedules": {
21835
+ capName: "backup",
21836
+ capScope: "system",
21837
+ addonId: null,
21838
+ access: "view"
21839
+ },
21128
21840
  "backup.previewSchedule": {
21129
21841
  capName: "backup",
21130
21842
  capScope: "system",
@@ -21149,6 +21861,12 @@ Object.freeze({
21149
21861
  addonId: null,
21150
21862
  access: "create"
21151
21863
  },
21864
+ "backup.upsertSchedule": {
21865
+ capName: "backup",
21866
+ capScope: "system",
21867
+ addonId: null,
21868
+ access: "create"
21869
+ },
21152
21870
  "battery.wakeForStream": {
21153
21871
  capName: "battery",
21154
21872
  capScope: "device",
@@ -23177,6 +23895,60 @@ Object.freeze({
23177
23895
  addonId: null,
23178
23896
  access: "create"
23179
23897
  },
23898
+ "notificationRules.createRule": {
23899
+ capName: "notification-rules",
23900
+ capScope: "system",
23901
+ addonId: null,
23902
+ access: "create"
23903
+ },
23904
+ "notificationRules.deleteRule": {
23905
+ capName: "notification-rules",
23906
+ capScope: "system",
23907
+ addonId: null,
23908
+ access: "delete"
23909
+ },
23910
+ "notificationRules.getConditionCatalog": {
23911
+ capName: "notification-rules",
23912
+ capScope: "system",
23913
+ addonId: null,
23914
+ access: "view"
23915
+ },
23916
+ "notificationRules.getHistory": {
23917
+ capName: "notification-rules",
23918
+ capScope: "system",
23919
+ addonId: null,
23920
+ access: "view"
23921
+ },
23922
+ "notificationRules.getRule": {
23923
+ capName: "notification-rules",
23924
+ capScope: "system",
23925
+ addonId: null,
23926
+ access: "view"
23927
+ },
23928
+ "notificationRules.listRules": {
23929
+ capName: "notification-rules",
23930
+ capScope: "system",
23931
+ addonId: null,
23932
+ access: "view"
23933
+ },
23934
+ "notificationRules.setRuleEnabled": {
23935
+ capName: "notification-rules",
23936
+ capScope: "system",
23937
+ addonId: null,
23938
+ access: "create"
23939
+ },
23940
+ "notificationRules.testRule": {
23941
+ capName: "notification-rules",
23942
+ capScope: "system",
23943
+ addonId: null,
23944
+ access: "create"
23945
+ },
23946
+ "notificationRules.updateRule": {
23947
+ capName: "notification-rules",
23948
+ capScope: "system",
23949
+ addonId: null,
23950
+ access: "create"
23951
+ },
23180
23952
  "notifier.cancel": {
23181
23953
  capName: "notifier",
23182
23954
  capScope: "device",
@@ -24929,6 +25701,36 @@ Object.freeze({
24929
25701
  addonId: null,
24930
25702
  access: "create"
24931
25703
  },
25704
+ "terminalSession.close": {
25705
+ capName: "terminal-session",
25706
+ capScope: "system",
25707
+ addonId: null,
25708
+ access: "create"
25709
+ },
25710
+ "terminalSession.listProfiles": {
25711
+ capName: "terminal-session",
25712
+ capScope: "system",
25713
+ addonId: null,
25714
+ access: "view"
25715
+ },
25716
+ "terminalSession.listSessions": {
25717
+ capName: "terminal-session",
25718
+ capScope: "system",
25719
+ addonId: null,
25720
+ access: "view"
25721
+ },
25722
+ "terminalSession.openSession": {
25723
+ capName: "terminal-session",
25724
+ capScope: "system",
25725
+ addonId: null,
25726
+ access: "create"
25727
+ },
25728
+ "terminalSession.resize": {
25729
+ capName: "terminal-session",
25730
+ capScope: "system",
25731
+ addonId: null,
25732
+ access: "create"
25733
+ },
24932
25734
  "toast.onToast": {
24933
25735
  capName: "toast",
24934
25736
  capScope: "system",