@camstack/addon-mqtt-broker 1.2.5 → 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.
@@ -7547,16 +7547,23 @@ var StorageLocationDeclarationSchema = object({
7547
7547
  * Which node root the seeded `<id>:default` instance is placed under on a
7548
7548
  * FRESH install:
7549
7549
  * - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
7550
- * the appData volume. Right for small/durable data (backups, logs, models).
7550
+ * the appData volume. Right for small/durable data (logs, models).
7551
7551
  * - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
7552
7552
  * env is set, else falls back to the data root. Right for bulky, hot media
7553
7553
  * (recordings, event media) that should stay off the appData disk.
7554
+ * - `'backup'` — the dedicated backup volume (`CAMSTACK_BACKUP_ROOT`, default
7555
+ * `/backups` in the image) so archives live on their own mount rather than
7556
+ * filling the appData disk. Falls back to the data root when unset.
7554
7557
  *
7555
7558
  * Only affects the seeded default's `basePath`; operators can repoint any
7556
7559
  * location afterwards, and a `defaultsTo` slot inherits its parent's root
7557
7560
  * regardless of this field. Absent (the common case) is treated as `'data'`.
7558
7561
  */
7559
- defaultRoot: _enum(["data", "media"]).optional()
7562
+ defaultRoot: _enum([
7563
+ "data",
7564
+ "media",
7565
+ "backup"
7566
+ ]).optional()
7560
7567
  });
7561
7568
  var DecoderStatsSchema = object({
7562
7569
  inputFps: number(),
@@ -8907,92 +8914,730 @@ var AccessoryKind = {
8907
8914
  AccessoryKind.Siren, AccessoryKind.Floodlight, AccessoryKind.Spotlight, AccessoryKind.PirSensor, AccessoryKind.Chime, AccessoryKind.Autotrack, AccessoryKind.Nightvision, AccessoryKind.PrivacyMask;
8908
8915
  DeviceFeature.BatteryOperated;
8909
8916
  /**
8910
- * Generic device-level status snapshot. Auto-registered by `BaseDevice`
8911
- * for every device, regardless of provider the kernel needs a uniform
8912
- * cap-keyed slice for the basic device flags every consumer expects to
8913
- * read across processes (the `online` flag in particular). Driver-specific
8914
- * caps (`battery`, `doorbell`, …) carry their domain-specific state on
8915
- * their own slices.
8917
+ * Shared geometry vocabulary for on-frame shape caps — privacy-mask,
8918
+ * motion-zones, and the detection zones/lines editor all speak this one
8919
+ * language so a single drawing-plane editor and the providers stay
8920
+ * decoupled from each cap's storage.
8916
8921
  *
8917
- * Pattern is identical to `battery`: schema-bearing `runtimeState`,
8918
- * empty `methods`, single change event. Reads land at
8919
- * `runtimeState.getCapState('device-status')`; writes at
8920
- * `runtimeState.setCapState('device-status', …)`. Cross-process
8921
- * consumers reach the same data via the `device-state` cap router
8922
- * (`getCapSlice({deviceId, capName: 'device-status'})`).
8922
+ * All coordinates are normalized 0..1 of the camera frame (top-left
8923
+ * origin). Each cap composes the SUBSET of shape kinds it supports and
8924
+ * advertises it via `supportedShapes` in its `getOptions`.
8923
8925
  */
8924
- var DeviceStatusSchema = object({
8925
- /**
8926
- * Device-level liveness. Drivers flip via `markOnline(boolean)` on
8927
- * `BaseDevice`. Provider semantics vary — RTSP aggregates broker
8928
- * stream-health, Reolink reads firmware push events, ONVIF tracks
8929
- * ping responses. This cap intentionally does NOT prescribe which
8930
- * signal drives the flag.
8931
- */
8932
- online: boolean(),
8933
- /** Ms epoch of the last `online` transition. Lets consumers tell
8934
- * apart "just came online" from "still online". */
8935
- lastChangedAt: number()
8926
+ /** A normalized 0..1 point (top-left origin). */
8927
+ var MaskPointSchema = object({
8928
+ x: number(),
8929
+ y: number()
8936
8930
  });
8937
- object({
8938
- deviceId: number(),
8939
- status: DeviceStatusSchema
8931
+ /** Axis-aligned rectangle (normalized 0..1). */
8932
+ var MaskRectShapeSchema = object({
8933
+ kind: literal("rect"),
8934
+ x: number(),
8935
+ y: number(),
8936
+ width: number(),
8937
+ height: number()
8938
+ });
8939
+ /** Free polygon — an ordered list of normalized vertices (≥3). */
8940
+ var MaskPolygonShapeSchema = object({
8941
+ kind: literal("polygon"),
8942
+ points: array(MaskPointSchema)
8943
+ });
8944
+ /** Boolean cell grid — row-major, length === gridWidth*gridHeight. */
8945
+ var MaskGridShapeSchema = object({
8946
+ kind: literal("grid"),
8947
+ gridWidth: number(),
8948
+ gridHeight: number(),
8949
+ cells: array(boolean())
8950
+ });
8951
+ discriminatedUnion("kind", [
8952
+ MaskRectShapeSchema,
8953
+ MaskPolygonShapeSchema,
8954
+ MaskGridShapeSchema,
8955
+ object({
8956
+ kind: literal("line"),
8957
+ points: array(MaskPointSchema)
8958
+ })
8959
+ ]);
8960
+ /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
8961
+ var MaskShapeKindSchema = _enum([
8962
+ "rect",
8963
+ "polygon",
8964
+ "grid",
8965
+ "line"
8966
+ ]);
8967
+ /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
8968
+ var MaskPolygonVerticesSchema = object({
8969
+ min: number(),
8970
+ max: number()
8971
+ });
8972
+ /** Grid dimensions when a cap supports 'grid'. */
8973
+ var MaskGridDimsSchema = object({
8974
+ width: number(),
8975
+ height: number()
8940
8976
  });
8941
8977
  /**
8942
- * Per-device feature/identity probe slice. Holds the runtime-resolved
8943
- * truth about what a device CAN do — which the kernel uses to:
8944
- * 1. Reconcile accessory children (hub-children spawn siren/floodlight/PIR
8945
- * based on what the firmware actually advertises).
8946
- * 2. Compute the public `features: DeviceFeature[]` array surfaced via
8947
- * `device-manager.listAll`.
8948
- * 3. Decide which optional caps (PTZ, intercom, doorbell, battery, …)
8949
- * to register on the device's capability surface.
8978
+ * notification-rules the Notification Center rule surface (P1 core).
8950
8979
  *
8951
- * Auto-registered by `BaseDevice` for every device. Drivers populate the
8952
- * slice from `onProbe()` (kernel calls it once after register, before
8953
- * accessory reconciliation). Consumers read via:
8954
- * `runtimeState.getCapState<FeatureProbeStatus>('feature-probe')`
8980
+ * Spec: `docs/superpowers/specs/2026-07-22-notification-center-requirements.md`
8981
+ * (operator decisions D-1/D-2/D-3 are binding):
8955
8982
  *
8956
- * `flags` is an open record so each driver carries its own keys without
8957
- * a centralized schema bottleneck Reolink writes `hasPtz/hasIntercom`,
8958
- * Hikvision writes `hasSupplementalLight/hasAlarmIo`, etc.
8983
+ * - D-2: rule EVALUATION lives in `addon-post-analysis` (the
8984
+ * `notification-center` module), hooked on the durable persistence
8985
+ * moments (object-event insert, TrackCloser.closeExpired) with a
8986
+ * persisted outbox + retry — never the lossy telemetry bus (D8).
8987
+ * - D-3: urgency belongs to the RULE. `delivery: 'immediate'` fires on the
8988
+ * FIRST persisted detection matching the conditions (per-track dedup,
8989
+ * `maxPerTrack` fixed at 1 — see {@link NC_MAX_PER_TRACK_IMMEDIATE});
8990
+ * `delivery: 'track-end'` evaluates the finalized track record at close.
8991
+ * - DISPATCH stays behind `notification-output` (rules reference targets
8992
+ * by id; per-backend params are a passthrough blob capped by the
8993
+ * target kind's own caps/degrade engine).
8959
8994
  *
8960
- * Replaces the older driver-local `deviceCache.has*` blob: the per-device
8961
- * config is for operator-edited overrides + UI snapshots; runtime probe
8962
- * results belong in runtime-state where the kernel handles persistence,
8963
- * cross-process mirroring, and reactive updates.
8995
+ * P1 scope: admin-authored rules only (`createdBy` stamped from the
8996
+ * server-injected caller identity the first `caller: 'required'`
8997
+ * adopter). The P1 condition subset is: devices, classes(+exclude),
8998
+ * minConfidence, admin zones (any/all + exclude), weekly schedule
8999
+ * windows, and the optional label/identity/plate matchers. User rules,
9000
+ * private zones, per-recipient fan-out and the wider condition table are
9001
+ * P2+ (see spec §7).
9002
+ *
9003
+ * All schemas here are the single source of truth — `NcRule` etc. are
9004
+ * `z.infer` exports; no duplicate interfaces (the advanced-notifier
9005
+ * schema/interface drift is explicitly not repeated).
8964
9006
  */
8965
- var FeatureProbeStatusSchema = object({
9007
+ /**
9008
+ * D-3: the trigger/urgency of a rule — which persistence moment evaluates it.
9009
+ * The value maps 1:1 onto the evaluated record kind:
9010
+ * - `immediate` ↔ object-event persist (lowest-latency detection burst)
9011
+ * - `track-end` ↔ TrackCloser.closeExpired (finalized track record)
9012
+ * - `device-event` ↔ SensorEventStore insert (doorbell press / sensor state
9013
+ * change of a LINKED device, one row per linked camera)
9014
+ * - `package-event` ↔ PackageDropDetector object-event insert (a `package`
9015
+ * delivery / pick-up)
9016
+ *
9017
+ * `immediate`/`track-end` carry the D-3 urgency semantics; `device-event`/
9018
+ * `package-event` are pure trigger kinds (no urgency dimension). Extending
9019
+ * this one field keeps the schema additive — a rule still declares exactly
9020
+ * one trigger.
9021
+ */
9022
+ var NcDeliverySchema = _enum([
9023
+ "immediate",
9024
+ "track-end",
9025
+ "device-event",
9026
+ "package-event"
9027
+ ]);
9028
+ /** Weekly schedule — OR of windows; absence on the rule = always active. */
9029
+ var NcScheduleSchema = object({
9030
+ windows: array(object({
9031
+ /** Days of week the window STARTS on (0 = Sunday … 6 = Saturday). */
9032
+ days: array(number().int().min(0).max(6)).min(1),
9033
+ startMinute: number().int().min(0).max(1439),
9034
+ endMinute: number().int().min(0).max(1439)
9035
+ })).min(1),
9036
+ /** IANA timezone; default = hub host timezone. */
9037
+ timezone: string().optional(),
9038
+ /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
9039
+ invert: boolean().optional()
9040
+ });
9041
+ /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
9042
+ var NcPlateMatcherSchema = object({
9043
+ values: array(string().min(1)).min(1),
9044
+ /** Max Levenshtein distance after normalization (uppercase alphanumeric). */
9045
+ maxDistance: number().int().min(0).max(3).default(1)
9046
+ });
9047
+ /**
9048
+ * Occupancy condition (DEVICE-EVENT trigger). Fires on a ZoneAnalytics
9049
+ * occupancy edge for a device — optionally narrowed to a single admin
9050
+ * `zoneId` and/or object `className`. `op` selects the edge/threshold:
9051
+ * - `became-occupied` (default) — count crossed 0 → ≥ `count`
9052
+ * - `became-free` — count crossed ≥ `count` → below it
9053
+ * - `>=` / `<=` — count is at/over or at/under `count`
9054
+ * `sustainSeconds` requires the condition hold continuously that long
9055
+ * before firing (debounces flicker; 0 = fire on the first matching edge).
9056
+ * Fail-closed: no ZoneAnalytics snapshot / missing zone / null snapshot ⇒
9057
+ * the condition never matches. Confirmed edge-state survives addon restarts
9058
+ * (declared SQLite collection, reseeded on boot).
9059
+ */
9060
+ var NcOccupancyConditionSchema = object({
9061
+ /** Admin zone id to scope the count to; absent = whole-frame occupancy. */
9062
+ zoneId: string().optional(),
9063
+ /** Object class to count; absent = any class. */
9064
+ className: string().optional(),
9065
+ op: _enum([
9066
+ "became-occupied",
9067
+ "became-free",
9068
+ ">=",
9069
+ "<="
9070
+ ]).default("became-occupied"),
9071
+ count: number().int().min(0).default(1),
9072
+ sustainSeconds: number().int().min(0).max(3600).default(15)
9073
+ });
9074
+ /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
9075
+ var NcZoneConditionSchema = object({
9076
+ ids: array(string().min(1)).min(1),
9077
+ /** Quantifier over `ids` — at least one / every one visited. */
9078
+ match: _enum(["any", "all"]).default("any")
9079
+ });
9080
+ /**
9081
+ * The P1 condition set — a flat AND of groups; absent group = pass;
9082
+ * membership lists are OR within the list (spec §2.3).
9083
+ */
9084
+ var NcConditionsSchema = object({
9085
+ /** Device scope — absent = all devices. */
9086
+ devices: array(number()).optional(),
9087
+ /** Detector class names (any overlap with the record's class set). */
9088
+ classes: array(string().min(1)).optional(),
9089
+ /** Veto classes — any overlap fails the rule. */
9090
+ classesExclude: array(string().min(1)).optional(),
9091
+ /** Minimum detection confidence 0–1 (fails when the record has none). */
9092
+ minConfidence: number().min(0).max(1).optional(),
9093
+ /** Admin zone membership over event `zones` / track `zonesVisited`. */
9094
+ zones: NcZoneConditionSchema.optional(),
9095
+ /** Veto zones — any hit fails the rule. */
9096
+ zonesExclude: array(string().min(1)).optional(),
8966
9097
  /**
8967
- * Driver-specific flag bag. Each driver picks its own key names — the
8968
- * cap deliberately does NOT enforce a closed enum here. Reolink keys:
8969
- * `hasPtz`, `hasIntercom`, `hasDoorbell`, `hasFloodlight`, `hasSiren`,
8970
- * `hasPirSensor`, `hasAutotrack`, `hasBattery`. Hikvision keys:
8971
- * `hasSupplementalLight`, `lightHasWhiteLight`, `hasAlarmIo`, `hasPtz`.
9098
+ * Exact (case-insensitive) match on the record's collapsed `label`
9099
+ * (identity name / plate text / subclass).
8972
9100
  */
8973
- flags: record(string(), unknown()),
9101
+ labelEquals: array(string().min(1)).optional(),
8974
9102
  /**
8975
- * Coarse driver-classification lets cross-process consumers tell apart
8976
- * cameras / battery-cams / NVRs without re-running the probe. `null`
8977
- * before the first probe completes.
9103
+ * Identity matcher. P1 boundary: matched against the record's collapsed
9104
+ * `label` (the identity display name propagated by the face pipeline) —
9105
+ * identity-ID matching rides in P2 when identity ids reach the record.
8978
9106
  */
8979
- deviceType: string().nullable(),
8980
- /** Camera/firmware model string. `null` when the firmware doesn't expose it. */
8981
- model: string().nullable(),
8982
- /** Channel count for NVR/Hub devices; `1` for standalone cameras; `null` pre-probe. */
8983
- channelCount: number().nullable(),
9107
+ identities: array(string().min(1)).optional(),
9108
+ /** Fuzzy plate matcher against the record's `label` (plate text). */
9109
+ plates: NcPlateMatcherSchema.optional(),
8984
9110
  /**
8985
- * Ms epoch of the last SUCCESSFUL probe. `0` before the first probe
8986
- * completes drivers' `getAccessoryChildren()` should treat zero as
8987
- * "probe not done yet, return empty" so accessories aren't spawned
8988
- * before the firmware is queried.
9111
+ * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
9112
+ * Same P1 boundary: matched against the record's collapsed `label` (the
9113
+ * identity display name). A record with NO label passes (nothing to
9114
+ * exclude), unlike the include variant which fails on an absent label.
8989
9115
  */
8990
- lastProbedAt: number(),
9116
+ identitiesExclude: array(string().min(1)).optional(),
8991
9117
  /**
8992
- * Framework convention: every runtime-state slice carries this for the
8993
- * createRuntimeStateBridge stale-check helper. We keep it in sync with
8994
- * `lastProbedAt` on every write.
8995
- */
9118
+ * Minimum server-computed key-event importance in [0,1] (`Track.importance`).
9119
+ * TRACK-END only: importance is scored at track close, so it does not exist
9120
+ * at immediate / object-event evaluation time (see catalog `appliesTo`). At
9121
+ * close the value is threaded via the close-time info (the `Track` clone is
9122
+ * captured before the DB row is updated, so it would otherwise read stale).
9123
+ * Fails when the record carries no importance (never guess quality — the
9124
+ * `minConfidence` precedent). MVP cut: a single scalar threshold.
9125
+ */
9126
+ minImportance: number().min(0).max(1).optional(),
9127
+ /**
9128
+ * Minimum track dwell in SECONDS — `(lastSeen − firstSeen) / 1000`.
9129
+ * TRACK-END only: an `immediate` / object-event subject has no closed
9130
+ * lifespan, so a dwell condition never matches immediate delivery
9131
+ * (documented choice — the object-event record carries no `firstSeen`,
9132
+ * so dwell cannot be computed from what the subject actually carries).
9133
+ */
9134
+ minDwellSeconds: number().min(0).optional(),
9135
+ /**
9136
+ * Detection provenance filter. `any` (default / absent) matches every
9137
+ * source; otherwise the subject's source must equal it. Legacy records
9138
+ * with no stamped source are treated as `pipeline`. The union spans both
9139
+ * record kinds — object events carry `pipeline` | `onboard`, synthetic
9140
+ * tracks carry `sensor`.
9141
+ */
9142
+ source: _enum([
9143
+ "pipeline",
9144
+ "onboard",
9145
+ "sensor",
9146
+ "any"
9147
+ ]).optional(),
9148
+ /**
9149
+ * Minimum identity / plate MATCH confidence in [0,1] — DISTINCT from the
9150
+ * detector `minConfidence` (that gates the object-detection score; this
9151
+ * gates the recognition/OCR match score). Fails when the subject carries
9152
+ * no label-match confidence (never guess). TRACK-END only: the confidence
9153
+ * lives on the recognition result and reaches the subject at track close.
9154
+ *
9155
+ * What it measures precisely (plumbed at track close — the closer threads
9156
+ * the value into `NcTrackClosedInfo.labelConfidence`, the same seam as
9157
+ * `importance`): the BEST recognition match confidence observed for the
9158
+ * label the track carries at close — for a face, the peak cosine similarity
9159
+ * of the ASSIGNED identity (`FaceMatch.score`, reset on an identity switch);
9160
+ * for a plate, the peak OCR read score of the best-held plate
9161
+ * (`plateText.confidence`). When BOTH a face and a plate were recognized on
9162
+ * one track the higher of the two is used. A track that ended with no
9163
+ * confident identity/plate match carries no value, so the condition fails
9164
+ * closed for it (an un-recognized subject).
9165
+ */
9166
+ minLabelConfidence: number().min(0).max(1).optional(),
9167
+ /**
9168
+ * DEVICE-EVENT only. Raw device event-type tokens (`EventFire.eventType`,
9169
+ * e.g. a doorbell `press` / `press_long`) — matched case-insensitively
9170
+ * against the token carried on the device-event subject (extracted from the
9171
+ * event-emitter runtime slice's `lastEvent.eventType`). Fails when the
9172
+ * subject carries no token. Doorbell-pulse / passive-sensor kinds emit no
9173
+ * eventType, so gate those with {@link sensorKinds} instead.
9174
+ */
9175
+ eventTypeTokens: array(string().min(1)).optional(),
9176
+ /**
9177
+ * DEVICE-EVENT only. Sensor/control taxonomy kinds (e.g. `doorbell`,
9178
+ * `contact`, `button`, `device-event`) — matched against the persisted
9179
+ * `SensorEvent.kind` (see `sensor-event-kinds.ts`). Membership is OR.
9180
+ */
9181
+ sensorKinds: array(string().min(1)).optional(),
9182
+ /**
9183
+ * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
9184
+ * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
9185
+ * when the subject's phase does not match (a subject always carries a phase
9186
+ * on the package-event trigger).
9187
+ */
9188
+ packagePhase: _enum([
9189
+ "delivered",
9190
+ "picked-up",
9191
+ "both"
9192
+ ]).optional(),
9193
+ /**
9194
+ * PERSONAL-RULE custom zones (viewer-drawn). Inline normalized polygons
9195
+ * (MaskShape vocabulary). A record passes when its bbox overlaps ANY
9196
+ * listed polygon (ZoneEngine membership semantics). Evaluated only when
9197
+ * the subject carries a bbox; absent bbox ⇒ the condition FAILS.
9198
+ */
9199
+ customZones: array(MaskPolygonShapeSchema).optional(),
9200
+ /**
9201
+ * DEVICE-EVENT only. ZoneAnalytics occupancy edge — fires when a device's
9202
+ * (optionally zone/class-scoped) occupancy count crosses the configured
9203
+ * threshold and holds for `sustainSeconds`. Fail-closed on missing
9204
+ * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
9205
+ */
9206
+ occupancy: NcOccupancyConditionSchema.optional()
9207
+ });
9208
+ /** One delivery target: a `notification-output` Target ref + passthrough params. */
9209
+ var NcRuleTargetSchema = object({
9210
+ /** `notification-output` Target id. */
9211
+ targetId: string().min(1),
9212
+ /**
9213
+ * Per-backend passthrough. Recognized keys are mapped onto the canonical
9214
+ * Notification (`priority`, `level`, `sound`, `clickUrl`, `ttl`); the
9215
+ * degrade engine drops what the backend can't render.
9216
+ */
9217
+ params: record(string(), unknown()).optional()
9218
+ });
9219
+ /**
9220
+ * Media attachment policy (P1 still-image subset).
9221
+ * - `best` — the best AVAILABLE subject image at dispatch time (D-3).
9222
+ * - `best-matching` — the media that explains WHY the rule fired: a rule
9223
+ * matched on identities attaches the subject's `faceCrop`, one matched on
9224
+ * plates attaches the `plateCrop`; a rule with no identity/plate condition
9225
+ * (or when the specific crop is missing) degrades to `best`, then
9226
+ * `keyFrame`, then no attachment — never delaying the send. The matched
9227
+ * condition summary is frozen on the outbox row at enqueue (like the rule
9228
+ * name), so the choice never drifts from the record that fired it.
9229
+ * - `keyFrame` — the clean scene frame (no subject box).
9230
+ * - `none` — no attachment.
9231
+ */
9232
+ var NcMediaPolicySchema = object({ attach: _enum([
9233
+ "best",
9234
+ "best-matching",
9235
+ "keyFrame",
9236
+ "none"
9237
+ ]).default("best") });
9238
+ /** Throttle — cooldown survives restarts (rebuilt from the outbox on boot). */
9239
+ var NcThrottleSchema = object({
9240
+ cooldownSec: number().int().min(0).max(86400).default(60),
9241
+ /** `rule` = one shared cooldown; `rule-device` = per-camera cooldown. */
9242
+ scope: _enum(["rule", "rule-device"]).default("rule-device")
9243
+ });
9244
+ /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
9245
+ var NcRuleInputSchema = object({
9246
+ name: string().min(1).max(200),
9247
+ enabled: boolean().default(true),
9248
+ delivery: NcDeliverySchema,
9249
+ conditions: NcConditionsSchema.default({}),
9250
+ schedule: NcScheduleSchema.optional(),
9251
+ targets: array(NcRuleTargetSchema).min(1),
9252
+ media: NcMediaPolicySchema.default({ attach: "best" }),
9253
+ throttle: NcThrottleSchema.default({
9254
+ cooldownSec: 60,
9255
+ scope: "rule-device"
9256
+ }),
9257
+ /** `{{var}}` templating over camera/class/label/zones/confidence/time. */
9258
+ template: object({
9259
+ title: string().max(500).optional(),
9260
+ body: string().max(2e3).optional()
9261
+ }).optional(),
9262
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
9263
+ priority: number().int().min(1).max(5).default(3),
9264
+ /**
9265
+ * Ownership/visibility key. Absent = admin/global rule (unchanged legacy
9266
+ * behaviour, visible to all, read-only in the viewer). Present = personal
9267
+ * rule owned by this userId. Server-stamped; never trusted from a client.
9268
+ */
9269
+ ownerUserId: string().optional()
9270
+ });
9271
+ /**
9272
+ * Partial patch for `updateRule` — any subset of the input fields, plus the
9273
+ * persisted-only {@link NcRuleSchema} `disabledTargetIds` set. The latter is
9274
+ * NOT a client-authored input field (it lives on the persisted rule, not the
9275
+ * input), so it is added here explicitly to let the store's per-target opt-out
9276
+ * toggle round-trip through the shared `update` path. Viewer opt-out mutations
9277
+ * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
9278
+ * `updateRule` patch.
9279
+ */
9280
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
9281
+ /** A persisted rule. */
9282
+ var NcRuleSchema = NcRuleInputSchema.extend({
9283
+ id: string(),
9284
+ /** userId of the admin who created the rule (server-stamped caller). */
9285
+ createdBy: string(),
9286
+ createdAt: number(),
9287
+ updatedAt: number(),
9288
+ /**
9289
+ * Per-target opt-out set. A targetId here is suppressed for THIS rule at
9290
+ * send time. Only a target's OWNER may add/remove its id (server-checked
9291
+ * in `nc.setRuleTargetEnabled`). Defaults to empty.
9292
+ */
9293
+ disabledTargetIds: array(string()).default([])
9294
+ });
9295
+ var NcTestResultSchema = object({
9296
+ recordId: string(),
9297
+ recordKind: _enum([
9298
+ "object-event",
9299
+ "track",
9300
+ "device-event",
9301
+ "package-event"
9302
+ ]),
9303
+ deviceId: number(),
9304
+ timestamp: number(),
9305
+ wouldFire: boolean(),
9306
+ /** Condition id that failed (first failing group), when `wouldFire` is false. */
9307
+ failedCondition: string().optional(),
9308
+ className: string().optional(),
9309
+ label: string().optional()
9310
+ });
9311
+ var NcConditionDescriptorSchema = object({
9312
+ /** Field id inside `NcConditions` (or `'schedule'` for the rule-level group). */
9313
+ id: string(),
9314
+ group: _enum([
9315
+ "scope",
9316
+ "class",
9317
+ "zones",
9318
+ "quality",
9319
+ "label",
9320
+ "schedule",
9321
+ "device",
9322
+ "package",
9323
+ "occupancy"
9324
+ ]),
9325
+ label: string(),
9326
+ /** Editor widget the UI renders — never hardcode per-condition forms. */
9327
+ valueType: _enum([
9328
+ "deviceIdList",
9329
+ "stringList",
9330
+ "number01",
9331
+ "number",
9332
+ "sourceSelect",
9333
+ "zoneSelection",
9334
+ "zoneIdList",
9335
+ "schedule",
9336
+ "plateMatcher",
9337
+ "packagePhase",
9338
+ "polygonDraw",
9339
+ "occupancy"
9340
+ ]),
9341
+ operator: _enum([
9342
+ "in",
9343
+ "notIn",
9344
+ "anyOf",
9345
+ "allOf",
9346
+ "gte",
9347
+ "fuzzyIn",
9348
+ "withinSchedule"
9349
+ ]),
9350
+ /** Which delivery kinds the condition applies to. */
9351
+ appliesTo: array(NcDeliverySchema),
9352
+ phase: string(),
9353
+ description: string().optional()
9354
+ });
9355
+ /**
9356
+ * The delivery lifecycle status of a history row — a straight read of the
9357
+ * durable outbox row's own status (single source of truth):
9358
+ * - `pending` — enqueued, in-flight or retrying with backoff
9359
+ * - `sent` — delivered (terminal)
9360
+ * - `dead` — dead-lettered after exhausting retries / a permanent
9361
+ * backend rejection / a deleted target (terminal; carries
9362
+ * the failure `error`)
9363
+ *
9364
+ * P1 has no `suppressed-quiet-hours` / `snoozed` states — those ride the P2
9365
+ * user dimension (quiet hours / snooze) and are additive when they land.
9366
+ */
9367
+ var NcHistoryStatusSchema = _enum([
9368
+ "pending",
9369
+ "sent",
9370
+ "dead"
9371
+ ]);
9372
+ /** The evaluated record kind a history row descends from (one per trigger). */
9373
+ var NcHistoryRecordKindSchema = _enum([
9374
+ "object-event",
9375
+ "track-end",
9376
+ "device-event",
9377
+ "package-event"
9378
+ ]);
9379
+ /** Subject summary frozen on the row at fire time (survives rule/record edits). */
9380
+ var NcHistorySubjectSchema = object({
9381
+ className: string(),
9382
+ label: string().optional(),
9383
+ confidence: number().optional(),
9384
+ zones: array(string()),
9385
+ timestamp: number()
9386
+ });
9387
+ /**
9388
+ * One delivery-history row. This is a read-only VIEW over the durable
9389
+ * outbox row (single source of truth — the same row the drain loop drives;
9390
+ * NO second write path, so history can never drift from delivery state).
9391
+ * The §3.2 fields map directly: `ruleId`/`targetId`/`deviceId` are columns,
9392
+ * `eventRef` is `recordKind`+`recordId`, `timestamps` are `createdAt`
9393
+ * (fire) / `updatedAt` (last transition), `status` + `error` are the
9394
+ * lifecycle. `ruleName` + `subject` are the intent snapshot frozen at
9395
+ * enqueue. `userId?` (per-recipient history) is P2 — no user dimension in
9396
+ * P1 (admin scope only).
9397
+ */
9398
+ var NcHistoryEntrySchema = object({
9399
+ /** Outbox row id — the stable dedup id `ruleId:dedupRef:targetId`. */
9400
+ id: string(),
9401
+ ruleId: string(),
9402
+ /** Rule name frozen at fire time (outlives a later rename / delete). */
9403
+ ruleName: string(),
9404
+ /** The rule urgency/trigger that produced this delivery. */
9405
+ delivery: NcDeliverySchema,
9406
+ targetId: string(),
9407
+ deviceId: number(),
9408
+ recordKind: NcHistoryRecordKindSchema,
9409
+ /** Event / track ref of the evaluated record (§3.2 `eventRef`). */
9410
+ recordId: string(),
9411
+ /** Present for track-scoped deliveries (object-event / track-end). */
9412
+ trackId: string().optional(),
9413
+ status: NcHistoryStatusSchema,
9414
+ /** Delivery attempts made so far. */
9415
+ attempts: number().int(),
9416
+ /** Fire time (outbox enqueue). */
9417
+ createdAt: number(),
9418
+ /** Last transition time (terminal for sent / dead). */
9419
+ updatedAt: number(),
9420
+ /** Failure detail — present on a `dead` row. */
9421
+ error: string().optional(),
9422
+ subject: NcHistorySubjectSchema
9423
+ });
9424
+ /**
9425
+ * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
9426
+ * AND; absent = unbounded on that axis. `since`/`until` bound the fire time
9427
+ * (`createdAt`, epoch ms, inclusive). `limit` is clamped to
9428
+ * {@link NC_HISTORY_LIMIT_MAX}. `userId` (per-recipient filtering) is P2.
9429
+ */
9430
+ var NcHistoryFilterSchema = object({
9431
+ ruleId: string().optional(),
9432
+ deviceId: number().optional(),
9433
+ status: NcHistoryStatusSchema.optional(),
9434
+ since: number().optional(),
9435
+ until: number().optional(),
9436
+ limit: number().int().min(1).max(500).default(100)
9437
+ });
9438
+ 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 }), {
9439
+ kind: "mutation",
9440
+ auth: "admin",
9441
+ caller: "required"
9442
+ }), method(object({
9443
+ ruleId: string(),
9444
+ patch: NcRulePatchSchema
9445
+ }), object({ rule: NcRuleSchema }), {
9446
+ kind: "mutation",
9447
+ auth: "admin",
9448
+ caller: "required"
9449
+ }), method(object({ ruleId: string() }), object({ success: literal(true) }), {
9450
+ kind: "mutation",
9451
+ auth: "admin"
9452
+ }), method(object({
9453
+ ruleId: string(),
9454
+ enabled: boolean()
9455
+ }), object({ success: literal(true) }), {
9456
+ kind: "mutation",
9457
+ auth: "admin"
9458
+ }), method(object({
9459
+ rule: NcRuleInputSchema,
9460
+ lookbackMinutes: number().int().min(1).max(1440).default(60)
9461
+ }), object({ results: array(NcTestResultSchema) }), {
9462
+ kind: "mutation",
9463
+ auth: "admin"
9464
+ }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
9465
+ /**
9466
+ * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
9467
+ *
9468
+ * Spec: `docs/superpowers/specs/2026-07-24-nc-occupancy-timelapse-design.md`
9469
+ * §3.2/§3.3.
9470
+ *
9471
+ * Deliberately NOT a capability definition and NOT an `NcRule`:
9472
+ * - Every `NcDelivery` member is a *persisted-pipeline-record* trigger. A
9473
+ * timelapse fires on a SCHEDULE WINDOW BOUNDARY, evaluates no pipeline
9474
+ * record, and produces a video it assembled itself — so it rides no
9475
+ * delivery-enum member (the enum is frozen) and no cap method. This file is
9476
+ * a plain typed schema; it does NOT go through `npm run codegen`.
9477
+ * - It shares only the delivery leg (`notification-output.send`) and the
9478
+ * persistence/ownership patterns with the Notification Center, reusing
9479
+ * {@link NcScheduleSchema} (weekly windows, midnight-crossing, invertible)
9480
+ * and {@link NcRuleTargetSchema} (target ref + passthrough params).
9481
+ *
9482
+ * Ownership is SERVER-DERIVED. `ownerUserId` / `createdBy` / `createdAt` /
9483
+ * `updatedAt` / `id` / `lastGeneratedAt` live on the PERSISTED rule only —
9484
+ * {@link TimelapseRuleInputSchema} and {@link TimelapseRulePatchSchema} do not
9485
+ * carry them, so a forged client payload can never claim or re-own a rule
9486
+ * (Zod strips unknown keys). The store stamps them from the resolved caller.
9487
+ */
9488
+ /** `{{var}}` templating over camera/rule/time — same vocabulary as `NcRule`. */
9489
+ var TimelapseTemplateSchema = object({
9490
+ title: string().max(500).optional(),
9491
+ body: string().max(2e3).optional()
9492
+ });
9493
+ var NameField = string().min(1).max(200);
9494
+ var DeviceIdsField = array(number()).min(1);
9495
+ var CadenceSecField = number().int().min(2).max(3600);
9496
+ var FramerateField = number().int().min(1).max(60);
9497
+ var TargetsField = array(NcRuleTargetSchema).min(1);
9498
+ var PriorityField = number().int().min(1).max(5);
9499
+ /**
9500
+ * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
9501
+ * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
9502
+ * here (see the ownership note above).
9503
+ */
9504
+ var TimelapseRuleInputSchema = object({
9505
+ name: NameField,
9506
+ enabled: boolean().default(true),
9507
+ /** Cameras sampled by this rule — one scratch dir + one artifact per device. */
9508
+ deviceIds: DeviceIdsField,
9509
+ /**
9510
+ * Activation window(s). REQUIRED (unlike `NcRule`, where an absent schedule
9511
+ * means "always active"): a timelapse is defined by its window boundaries —
9512
+ * open clears the scratch, close assembles and delivers.
9513
+ */
9514
+ schedule: NcScheduleSchema,
9515
+ /** Force-snapshot cadence inside the window, seconds (predecessor parity). */
9516
+ cadenceSec: CadenceSecField.default(15),
9517
+ /** Output frames per second of the assembled mp4 (predecessor parity). */
9518
+ framerate: FramerateField.default(10),
9519
+ /** `notification-output` targets the finished video/thumbnail is sent to. */
9520
+ targets: TargetsField,
9521
+ template: TimelapseTemplateSchema.optional(),
9522
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
9523
+ priority: PriorityField.default(3)
9524
+ });
9525
+ object({
9526
+ name: NameField.optional(),
9527
+ enabled: boolean().optional(),
9528
+ deviceIds: DeviceIdsField.optional(),
9529
+ schedule: NcScheduleSchema.optional(),
9530
+ cadenceSec: CadenceSecField.optional(),
9531
+ framerate: FramerateField.optional(),
9532
+ targets: TargetsField.optional(),
9533
+ template: TimelapseTemplateSchema.nullable().optional(),
9534
+ priority: PriorityField.optional()
9535
+ });
9536
+ TimelapseRuleInputSchema.extend({
9537
+ id: string(),
9538
+ /**
9539
+ * Ownership/visibility key. Absent = admin/global rule (visible to all).
9540
+ * Present = personal rule owned by this userId. Server-stamped from the
9541
+ * resolved caller; never trusted from a client payload.
9542
+ */
9543
+ ownerUserId: string().optional(),
9544
+ /**
9545
+ * Epoch-ms of the last successful generation — the 1-hour re-generation
9546
+ * guard's durable state (predecessor parity). Absent = never generated.
9547
+ */
9548
+ lastGeneratedAt: number().optional(),
9549
+ /** userId of the caller who created the rule (server-stamped). */
9550
+ createdBy: string(),
9551
+ createdAt: number(),
9552
+ updatedAt: number()
9553
+ });
9554
+ /**
9555
+ * Generic device-level status snapshot. Auto-registered by `BaseDevice`
9556
+ * for every device, regardless of provider — the kernel needs a uniform
9557
+ * cap-keyed slice for the basic device flags every consumer expects to
9558
+ * read across processes (the `online` flag in particular). Driver-specific
9559
+ * caps (`battery`, `doorbell`, …) carry their domain-specific state on
9560
+ * their own slices.
9561
+ *
9562
+ * Pattern is identical to `battery`: schema-bearing `runtimeState`,
9563
+ * empty `methods`, single change event. Reads land at
9564
+ * `runtimeState.getCapState('device-status')`; writes at
9565
+ * `runtimeState.setCapState('device-status', …)`. Cross-process
9566
+ * consumers reach the same data via the `device-state` cap router
9567
+ * (`getCapSlice({deviceId, capName: 'device-status'})`).
9568
+ */
9569
+ var DeviceStatusSchema = object({
9570
+ /**
9571
+ * Device-level liveness. Drivers flip via `markOnline(boolean)` on
9572
+ * `BaseDevice`. Provider semantics vary — RTSP aggregates broker
9573
+ * stream-health, Reolink reads firmware push events, ONVIF tracks
9574
+ * ping responses. This cap intentionally does NOT prescribe which
9575
+ * signal drives the flag.
9576
+ */
9577
+ online: boolean(),
9578
+ /** Ms epoch of the last `online` transition. Lets consumers tell
9579
+ * apart "just came online" from "still online". */
9580
+ lastChangedAt: number()
9581
+ });
9582
+ object({
9583
+ deviceId: number(),
9584
+ status: DeviceStatusSchema
9585
+ });
9586
+ /**
9587
+ * Per-device feature/identity probe slice. Holds the runtime-resolved
9588
+ * truth about what a device CAN do — which the kernel uses to:
9589
+ * 1. Reconcile accessory children (hub-children spawn siren/floodlight/PIR
9590
+ * based on what the firmware actually advertises).
9591
+ * 2. Compute the public `features: DeviceFeature[]` array surfaced via
9592
+ * `device-manager.listAll`.
9593
+ * 3. Decide which optional caps (PTZ, intercom, doorbell, battery, …)
9594
+ * to register on the device's capability surface.
9595
+ *
9596
+ * Auto-registered by `BaseDevice` for every device. Drivers populate the
9597
+ * slice from `onProbe()` (kernel calls it once after register, before
9598
+ * accessory reconciliation). Consumers read via:
9599
+ * `runtimeState.getCapState<FeatureProbeStatus>('feature-probe')`
9600
+ *
9601
+ * `flags` is an open record so each driver carries its own keys without
9602
+ * a centralized schema bottleneck — Reolink writes `hasPtz/hasIntercom`,
9603
+ * Hikvision writes `hasSupplementalLight/hasAlarmIo`, etc.
9604
+ *
9605
+ * Replaces the older driver-local `deviceCache.has*` blob: the per-device
9606
+ * config is for operator-edited overrides + UI snapshots; runtime probe
9607
+ * results belong in runtime-state where the kernel handles persistence,
9608
+ * cross-process mirroring, and reactive updates.
9609
+ */
9610
+ var FeatureProbeStatusSchema = object({
9611
+ /**
9612
+ * Driver-specific flag bag. Each driver picks its own key names — the
9613
+ * cap deliberately does NOT enforce a closed enum here. Reolink keys:
9614
+ * `hasPtz`, `hasIntercom`, `hasDoorbell`, `hasFloodlight`, `hasSiren`,
9615
+ * `hasPirSensor`, `hasAutotrack`, `hasBattery`. Hikvision keys:
9616
+ * `hasSupplementalLight`, `lightHasWhiteLight`, `hasAlarmIo`, `hasPtz`.
9617
+ */
9618
+ flags: record(string(), unknown()),
9619
+ /**
9620
+ * Coarse driver-classification — lets cross-process consumers tell apart
9621
+ * cameras / battery-cams / NVRs without re-running the probe. `null`
9622
+ * before the first probe completes.
9623
+ */
9624
+ deviceType: string().nullable(),
9625
+ /** Camera/firmware model string. `null` when the firmware doesn't expose it. */
9626
+ model: string().nullable(),
9627
+ /** Channel count for NVR/Hub devices; `1` for standalone cameras; `null` pre-probe. */
9628
+ channelCount: number().nullable(),
9629
+ /**
9630
+ * Ms epoch of the last SUCCESSFUL probe. `0` before the first probe
9631
+ * completes — drivers' `getAccessoryChildren()` should treat zero as
9632
+ * "probe not done yet, return empty" so accessories aren't spawned
9633
+ * before the firmware is queried.
9634
+ */
9635
+ lastProbedAt: number(),
9636
+ /**
9637
+ * Framework convention: every runtime-state slice carries this for the
9638
+ * createRuntimeStateBridge stale-check helper. We keep it in sync with
9639
+ * `lastProbedAt` on every write.
9640
+ */
8996
9641
  lastFetchedAt: number()
8997
9642
  });
8998
9643
  object({
@@ -11886,67 +12531,6 @@ DeviceType.Light, DeviceType.Siren, DeviceType.Switch, method(object({
11886
12531
  lastChangedAt: number()
11887
12532
  });
11888
12533
  /**
11889
- * Shared geometry vocabulary for on-frame shape caps — privacy-mask,
11890
- * motion-zones, and the detection zones/lines editor all speak this one
11891
- * language so a single drawing-plane editor and the providers stay
11892
- * decoupled from each cap's storage.
11893
- *
11894
- * All coordinates are normalized 0..1 of the camera frame (top-left
11895
- * origin). Each cap composes the SUBSET of shape kinds it supports and
11896
- * advertises it via `supportedShapes` in its `getOptions`.
11897
- */
11898
- /** A normalized 0..1 point (top-left origin). */
11899
- var MaskPointSchema = object({
11900
- x: number(),
11901
- y: number()
11902
- });
11903
- /** Axis-aligned rectangle (normalized 0..1). */
11904
- var MaskRectShapeSchema = object({
11905
- kind: literal("rect"),
11906
- x: number(),
11907
- y: number(),
11908
- width: number(),
11909
- height: number()
11910
- });
11911
- /** Free polygon — an ordered list of normalized vertices (≥3). */
11912
- var MaskPolygonShapeSchema = object({
11913
- kind: literal("polygon"),
11914
- points: array(MaskPointSchema)
11915
- });
11916
- /** Boolean cell grid — row-major, length === gridWidth*gridHeight. */
11917
- var MaskGridShapeSchema = object({
11918
- kind: literal("grid"),
11919
- gridWidth: number(),
11920
- gridHeight: number(),
11921
- cells: array(boolean())
11922
- });
11923
- discriminatedUnion("kind", [
11924
- MaskRectShapeSchema,
11925
- MaskPolygonShapeSchema,
11926
- MaskGridShapeSchema,
11927
- object({
11928
- kind: literal("line"),
11929
- points: array(MaskPointSchema)
11930
- })
11931
- ]);
11932
- /** Every shape-kind discriminant, for `supportedShapes` advertisement. */
11933
- var MaskShapeKindSchema = _enum([
11934
- "rect",
11935
- "polygon",
11936
- "grid",
11937
- "line"
11938
- ]);
11939
- /** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
11940
- var MaskPolygonVerticesSchema = object({
11941
- min: number(),
11942
- max: number()
11943
- });
11944
- /** Grid dimensions when a cap supports 'grid'. */
11945
- var MaskGridDimsSchema = object({
11946
- width: number(),
11947
- height: number()
11948
- });
11949
- /**
11950
12534
  * Motion-zones share the same MaskShape vocabulary as privacy-mask — the
11951
12535
  * on-camera motion-detection mask is a single `grid` region (a row-major
11952
12536
  * boolean cell lattice the camera's onboard VMD evaluates). Composing it as
@@ -13815,6 +14399,55 @@ method(object({
13815
14399
  password: string()
13816
14400
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
13817
14401
  /**
14402
+ * A live terminal session hosted by the provider addon. Output and input do
14403
+ * NOT flow through the capability — they use the addon data plane
14404
+ * (`GET /addon/terminal/<id>/out` SSE, `POST /addon/terminal/<id>/in`) because
14405
+ * terminal output must be ordered and lossless. The event bus is telemetry and
14406
+ * may drop chunks ([D8]), and a dropped chunk desynchronises the vt parser
14407
+ * permanently until a full repaint. The capability owns only lifecycle.
14408
+ */
14409
+ var TerminalSessionInfoSchema = object({
14410
+ /** Opaque session id minted by the provider on `openSession`. */
14411
+ sessionId: string(),
14412
+ /** The pre-declared profile this session runs (never a free-form command). */
14413
+ profileId: string(),
14414
+ /** Human-readable profile label for the UI session list. */
14415
+ label: string(),
14416
+ cols: number().int().positive(),
14417
+ rows: number().int().positive(),
14418
+ /** ms-epoch the session's pty was spawned. */
14419
+ startedAt: number()
14420
+ });
14421
+ /**
14422
+ * A profile the operator may open — a pre-declared, allowlisted program
14423
+ * (`monitor` → `btm`). The capability accepts only these ids; a free-form
14424
+ * command string would be remote code execution as the server's user, so it is
14425
+ * deliberately not part of the contract.
14426
+ */
14427
+ var TerminalProfileInfoSchema = object({
14428
+ profileId: string(),
14429
+ label: string(),
14430
+ description: string().optional()
14431
+ });
14432
+ method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(TerminalSessionInfoSchema).readonly(), { auth: "admin" }), method(object({
14433
+ profileId: string(),
14434
+ cols: number().int().positive(),
14435
+ rows: number().int().positive()
14436
+ }), TerminalSessionInfoSchema, {
14437
+ kind: "mutation",
14438
+ auth: "admin"
14439
+ }), method(object({
14440
+ sessionId: string(),
14441
+ cols: number().int().positive(),
14442
+ rows: number().int().positive()
14443
+ }), _void(), {
14444
+ kind: "mutation",
14445
+ auth: "admin"
14446
+ }), method(object({ sessionId: string() }), _void(), {
14447
+ kind: "mutation",
14448
+ auth: "admin"
14449
+ });
14450
+ /**
13818
14451
  * Orchestrator-side destination metadata. The orchestrator computes
13819
14452
  * `id = <addonId>:<subId>` from its provider lookup so consumers
13820
14453
  * (admin UI, restore flow) see one canonical key.
@@ -13915,11 +14548,53 @@ var LocationStatSchema = object({
13915
14548
  fileCount: number(),
13916
14549
  present: boolean()
13917
14550
  });
14551
+ /**
14552
+ * A backup schedule — the N:M "entry" that binds one cron cadence to a
14553
+ * SET of destination locations. Supersedes the per-location cron on
14554
+ * `BackupDestinationPolicy`: an operator creates a schedule, picks the
14555
+ * `backups` locations it should write to, and the orchestrator fans a
14556
+ * single archive out to all of them when the cron fires.
14557
+ *
14558
+ * `retentionCount` is per-schedule (D-decision 2026-07-28): every
14559
+ * location targeted by this schedule keeps this many archives from
14560
+ * this schedule's runs.
14561
+ *
14562
+ * `dataSources` optionally narrows which top-level state locations
14563
+ * (db, addons, tls, …) are archived; omitted = the orchestrator's
14564
+ * default full set.
14565
+ */
14566
+ var BackupScheduleSchema = object({
14567
+ /** Stable id. Generated by the orchestrator on first upsert if absent. */
14568
+ id: string(),
14569
+ /** Operator-facing display name. */
14570
+ label: string(),
14571
+ /** 5-field POSIX cron. Empty = disabled cadence (kept for editing). */
14572
+ cron: string(),
14573
+ /** Master on/off toggle for the whole schedule. */
14574
+ enabled: boolean(),
14575
+ /** `backups`-location ids this schedule writes to (fan-out set). */
14576
+ locationIds: array(string()).readonly(),
14577
+ /** Archives kept per targeted location for this schedule. */
14578
+ retentionCount: number().int().min(1).max(1e3),
14579
+ /** Optional subset of source locations to include; omitted = all. */
14580
+ dataSources: array(string()).readonly().optional(),
14581
+ /** ms-epoch of last successful run. */
14582
+ lastRunAt: number().optional(),
14583
+ /** ms-epoch of next computed firing (read-only, filled on list). */
14584
+ nextRunAt: number().optional()
14585
+ });
13918
14586
  method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }), method(object({
13919
14587
  /** Subset of registered `backup-destination` addon ids to write to. */
13920
14588
  destinations: array(string()).optional(),
13921
14589
  locations: array(string()).optional(),
13922
- label: string().optional()
14590
+ label: string().optional(),
14591
+ /**
14592
+ * Per-run retention override applied to every targeted
14593
+ * destination. Used by schedule-driven runs (per-entry
14594
+ * retention). Omitted = each destination's own policy
14595
+ * retention (manual runs).
14596
+ */
14597
+ retentionCount: number().int().min(1).max(1e3).optional()
13923
14598
  }).optional(), array(BackupEntrySchema).readonly(), {
13924
14599
  kind: "mutation",
13925
14600
  auth: "admin"
@@ -13968,7 +14643,21 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
13968
14643
  ok: boolean(),
13969
14644
  error: string().optional(),
13970
14645
  nextRuns: array(number()).readonly()
13971
- }));
14646
+ })), method(_void(), array(BackupScheduleSchema).readonly(), { auth: "admin" }), method(object({
14647
+ id: string().optional(),
14648
+ label: string(),
14649
+ cron: string(),
14650
+ enabled: boolean(),
14651
+ locationIds: array(string()).readonly(),
14652
+ retentionCount: number().int().min(1).max(1e3),
14653
+ dataSources: array(string()).readonly().optional()
14654
+ }), BackupScheduleSchema, {
14655
+ kind: "mutation",
14656
+ auth: "admin"
14657
+ }), method(object({ id: string() }), _void(), {
14658
+ kind: "mutation",
14659
+ auth: "admin"
14660
+ });
13972
14661
  /**
13973
14662
  * `broker` — unified pub/sub broker registry, system-scoped collection.
13974
14663
  *
@@ -14875,1773 +15564,1285 @@ method(object({
14875
15564
  auth: "admin"
14876
15565
  }), method(object({
14877
15566
  deviceId: number(),
14878
- integrationId: string()
14879
- }), _void(), {
14880
- kind: "mutation",
14881
- auth: "admin"
14882
- }), method(object({
14883
- deviceId: number(),
14884
- linkDeviceId: number().nullable()
14885
- }), _void(), {
14886
- kind: "mutation",
14887
- auth: "admin"
14888
- }), method(object({
14889
- deviceId: number(),
14890
- primaryChildEntityId: string().nullable()
14891
- }), _void(), {
14892
- kind: "mutation",
14893
- auth: "admin"
14894
- }), method(object({
14895
- deviceId: number(),
14896
- childLayout: array(ChildLayoutEntrySchema).readonly()
14897
- }), _void(), {
14898
- kind: "mutation",
14899
- auth: "admin"
14900
- }), method(object({
14901
- deviceId: number(),
14902
- deviceLinks: array(DeviceLinkSchema).readonly()
14903
- }), _void(), {
14904
- kind: "mutation",
14905
- auth: "admin"
14906
- }), method(object({
14907
- deviceId: number(),
14908
- display: DeviceDisplayOverrideSchema.nullable()
14909
- }), _void(), {
14910
- kind: "mutation",
14911
- auth: "admin"
14912
- }), method(object({}), object({ defaults: record(string(), RoleDisplayDefaultSchema) }), { kind: "query" }), method(object({ defaults: record(string(), RoleDisplayDefaultSchema) }), _void(), {
14913
- kind: "mutation",
14914
- auth: "admin"
14915
- }), method(object({
14916
- deviceId: number(),
14917
- includeSynthesizable: boolean().optional()
14918
- }), object({ caps: array(object({
14919
- cap: string(),
14920
- fields: array(object({
14921
- path: string(),
14922
- kind: _enum([
14923
- "string",
14924
- "number",
14925
- "boolean",
14926
- "enum"
14927
- ]),
14928
- enumValues: array(string()).optional(),
14929
- item: boolean().optional()
14930
- })).readonly(),
14931
- itemArray: object({
14932
- path: string(),
14933
- keyField: string()
14934
- }).optional()
14935
- })).readonly() }), { kind: "query" }), method(object({
14936
- deviceId: number(),
14937
- role: string().nullable()
14938
- }), _void(), {
14939
- kind: "mutation",
14940
- auth: "admin"
14941
- }), method(object({
14942
- deviceId: number(),
14943
- name: string().optional(),
14944
- location: string().nullable().optional(),
14945
- type: _enum(DeviceType).optional(),
14946
- integrationId: string().optional(),
14947
- linkDeviceId: number().nullable().optional(),
14948
- role: string().nullable().optional()
14949
- }), _void(), {
14950
- kind: "mutation",
14951
- auth: "admin"
14952
- }), method(object({
14953
- deviceId: number(),
14954
- patch: record(string(), unknown())
14955
- }), _void(), {
14956
- kind: "mutation",
14957
- auth: "admin"
14958
- }), method(_void(), array(string())), method(object({ name: string() }), _void(), {
14959
- kind: "mutation",
14960
- auth: "admin"
14961
- }), method(object({
14962
- name: string(),
14963
- cascade: boolean().optional()
14964
- }), _void(), {
14965
- kind: "mutation",
14966
- auth: "admin"
14967
- }), method(object({
14968
- deviceId: number(),
14969
- disabled: boolean()
14970
- }), _void(), {
14971
- kind: "mutation",
14972
- auth: "admin"
14973
- }), method(object({ addonId: string() }), array(SavedDeviceRowSchema)), method(object({ addonId: string().optional() }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), DeviceInfoSchema.nullable()), method(object({ parentDeviceId: number() }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), object({
14974
- mode: DeviceLinkModeSchema,
14975
- devices: array(LinkedDeviceSchema)
14976
- })), method(object({ deviceId: number() }), array(StreamSourceEntrySchema$1)), method(object({ deviceId: number() }), array(ConfigEntrySchema)), method(object({ deviceId: number() }), ConfigUISchemaOutput), method(object({
14977
- deviceId: number(),
14978
- values: record(string(), unknown())
14979
- }), object({ success: literal(true) }), {
14980
- kind: "mutation",
14981
- auth: "admin"
14982
- }), method(object({ deviceId: number() }), object({ success: literal(true) }), {
14983
- kind: "mutation",
14984
- auth: "admin"
14985
- }), method(object({ deviceId: number() }), object({ success: literal(true) }), {
14986
- kind: "mutation",
14987
- auth: "admin"
14988
- }), method(object({ deviceId: number() }), object({ success: literal(true) }), {
14989
- kind: "mutation",
14990
- auth: "admin"
14991
- }), method(object({ integrationId: string() }), object({ removed: number() }), {
14992
- kind: "mutation",
14993
- auth: "admin"
14994
- }), method(object({ deviceId: number() }), record(string(), string().nullable())), method(object({
14995
- deviceId: number(),
14996
- profileMap: record(string(), string().nullable())
14997
- }), object({ success: literal(true) }), {
14998
- kind: "mutation",
14999
- auth: "admin"
15000
- }), method(object({ deviceId: number() }), array(StreamProbeResultSchema), {
15001
- kind: "mutation",
15002
- auth: "admin"
15003
- }), method(object({ deviceId: number() }), object({
15004
- deviceId: number(),
15005
- entries: array(object({
15006
- capName: string(),
15007
- kind: _enum([
15008
- "native",
15009
- "wrapped",
15010
- "linked"
15011
- ]),
15012
- providerAddonId: string(),
15013
- providerNodeId: string(),
15014
- nativeAddonId: string()
15015
- }))
15016
- })), method(object({}), array(object({
15017
- deviceId: number(),
15018
- entries: array(object({
15019
- capName: string(),
15020
- kind: _enum([
15021
- "native",
15022
- "wrapped",
15023
- "linked"
15024
- ]),
15025
- providerAddonId: string(),
15026
- providerNodeId: string(),
15027
- nativeAddonId: string()
15028
- }))
15029
- }))), method(object({
15030
- deviceId: number(),
15031
- capName: string(),
15032
- wrapperAddonId: string(),
15033
- active: boolean()
15034
- }), _void(), {
15035
- kind: "mutation",
15036
- auth: "admin"
15037
- }), method(object({ capName: string() }), array(string())), method(object({ deviceType: string() }), array(object({
15038
- capName: string(),
15039
- wrappers: array(string())
15040
- }))), method(object({ deviceId: number() }), SettingsSchemaWithValuesSchema.nullable()), method(object({ deviceId: number() }), SettingsSchemaWithValuesSchema.nullable()), method(object({ deviceId: number() }), object({
15041
- settings: SettingsSchemaWithValuesSchema.nullable(),
15042
- live: SettingsSchemaWithValuesSchema.nullable()
15043
- })), method(object({
15044
- deviceId: number().int().nonnegative(),
15045
- action: string().min(1),
15046
- input: unknown()
15047
- }), unknown(), { kind: "mutation" }), method(object({
15048
- deviceId: number(),
15049
- writerCapName: string(),
15050
- writerAddonId: string(),
15051
- key: string(),
15052
- value: unknown()
15053
- }), object({ success: literal(true) }), {
15054
- kind: "mutation",
15055
- auth: "admin"
15056
- }), method(object({
15057
- deviceId: number(),
15058
- changes: array(object({
15059
- writerCapName: string(),
15060
- writerAddonId: string(),
15061
- key: string(),
15062
- value: unknown()
15063
- }))
15064
- }), object({
15065
- success: literal(true),
15066
- failures: array(object({
15067
- writerCapName: string(),
15068
- writerAddonId: string(),
15069
- error: string()
15070
- }))
15071
- }), {
15072
- kind: "mutation",
15073
- auth: "admin"
15074
- }), method(object({ addonId: string() }), array(DiscoveryCandidateSchema), {
15075
- kind: "mutation",
15076
- auth: "admin"
15077
- }), method(object({
15078
- addonId: string(),
15079
- candidate: DiscoveryCandidateSchema,
15080
- /** Owning integration id, stamped onto the new device's meta by the
15081
- * device-manager forwarder so `removeByIntegration` can cascade it.
15082
- * Optional for back-compat (omitted = no stamp = pre-existing behavior). */
15083
- integrationId: string().optional()
15084
- }), DeviceSummarySchema, {
15085
- kind: "mutation",
15086
- auth: "admin"
15087
- }), method(object({
15088
- addonId: string(),
15089
- type: _enum(DeviceType)
15090
- }), unknown().nullable()), method(object({
15091
- addonId: string(),
15092
- type: _enum(DeviceType),
15093
- config: record(string(), unknown()),
15094
- /** Owning integration id, stamped onto the new device's meta by the
15095
- * device-manager forwarder so `removeByIntegration` can cascade it.
15096
- * Optional for back-compat (omitted = no stamp = pre-existing behavior). */
15097
- integrationId: string().optional()
15098
- }), DeviceSummarySchema, {
15099
- kind: "mutation",
15100
- auth: "admin"
15101
- }), method(object({
15102
- addonId: string(),
15103
- type: _enum(DeviceType),
15104
- key: string(),
15105
- value: unknown(),
15106
- formValues: record(string(), unknown()).optional()
15107
- }), FieldProbeResultSchema, {
15108
- kind: "mutation",
15109
- auth: "admin"
15110
- }), method(object({
15111
- addonId: string(),
15112
- integrationId: string()
15113
- }), object({ filters: array(AdoptionFilterSchema) }), { auth: "admin" }), method(ListCandidatesInputSchema.extend({ addonId: string() }), ListCandidatesOutputSchema, { auth: "admin" }), method(object({
15114
- addonId: string(),
15115
- integrationId: string()
15116
- }), AdoptionStatusSchema, {
15117
- kind: "mutation",
15118
- auth: "admin"
15119
- }), method(AdoptInputSchema.extend({ addonId: string() }), AdoptResultSchema, {
15120
- kind: "mutation",
15121
- auth: "admin"
15122
- }), method(ReleaseInputSchema.extend({ addonId: string() }), _void(), {
15567
+ integrationId: string()
15568
+ }), _void(), {
15123
15569
  kind: "mutation",
15124
15570
  auth: "admin"
15125
- }), method(ResyncInputSchema, ResyncResultSchema, {
15571
+ }), method(object({
15572
+ deviceId: number(),
15573
+ linkDeviceId: number().nullable()
15574
+ }), _void(), {
15126
15575
  kind: "mutation",
15127
15576
  auth: "admin"
15128
- }), method(object({}), object({ providers: array(object({
15129
- addonId: string(),
15130
- label: string()
15131
- })).readonly() }), { auth: "admin" }), method(object({}), object({ groups: array(object({
15132
- addonId: string(),
15133
- label: string(),
15134
- candidates: array(DiscoveryCandidateSchema).readonly(),
15135
- error: string().nullable()
15136
- })).readonly() }), {
15577
+ }), method(object({
15578
+ deviceId: number(),
15579
+ primaryChildEntityId: string().nullable()
15580
+ }), _void(), {
15137
15581
  kind: "mutation",
15138
15582
  auth: "admin"
15139
15583
  }), method(object({
15140
- addonId: string(),
15141
- params: record(string(), unknown()).optional()
15142
- }), object({ candidates: array(DiscoveryCandidateSchema).readonly() }), {
15584
+ deviceId: number(),
15585
+ childLayout: array(ChildLayoutEntrySchema).readonly()
15586
+ }), _void(), {
15143
15587
  kind: "mutation",
15144
15588
  auth: "admin"
15145
- }), method(object({ addonId: string() }), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
15589
+ }), method(object({
15146
15590
  deviceId: number(),
15147
- key: string(),
15148
- value: unknown()
15149
- }), FieldProbeResultSchema, {
15591
+ deviceLinks: array(DeviceLinkSchema).readonly()
15592
+ }), _void(), {
15150
15593
  kind: "mutation",
15151
15594
  auth: "admin"
15152
15595
  }), method(object({
15153
15596
  deviceId: number(),
15154
- caps: array(string()).readonly().optional()
15155
- }), record(string(), unknown().nullable()));
15156
- method(object({ deviceId: number() }), record(string(), record(string(), unknown()))), method(object({
15157
- deviceId: number(),
15158
- capName: string()
15159
- }), record(string(), unknown()).nullable()), method(object({}), record(string(), record(string(), record(string(), unknown())))), method(object({
15160
- deviceId: number(),
15161
- capName: string(),
15162
- slice: record(string(), unknown())
15163
- }), _void(), { kind: "mutation" }), object({
15164
- deviceId: number(),
15165
- capName: string(),
15166
- slice: record(string(), unknown())
15167
- });
15168
- /**
15169
- * Embedding output. `embedding` is wire-encoded as `number[]` so the
15170
- * Zod-validated tRPC surface round-trips cleanly; consumers that need a
15171
- * `Float32Array` can wrap it on the way out (in-process, no marshalling
15172
- * is involved). `inferenceMs` mirrors the runtime field used by the
15173
- * post-analysis enrichment-engine.
15174
- */
15175
- var EmbeddingResultSchema = object({
15176
- embedding: array(number()),
15177
- inferenceMs: number()
15178
- });
15179
- var EmbeddingInfoSchema = object({
15180
- modelId: string(),
15181
- embeddingDim: number(),
15182
- ready: boolean()
15183
- });
15184
- method(object({
15185
- crop: _instanceof(Uint8Array),
15186
- width: number(),
15187
- height: number()
15188
- }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
15189
- /**
15190
- * filesystem-browse — per-node capability for browsing the node's local
15191
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
15192
- * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
15193
- * (one provider per node); the hub calls it with `{nodeId}` so the codegen
15194
- * routes to that exact node (default `nodeIdMode:'routing'`).
15195
- */
15196
- var DirEntrySchema = object({
15197
- name: string(),
15198
- path: string()
15199
- });
15200
- var BrowseResultSchema = object({
15201
- path: string(),
15202
- entries: array(DirEntrySchema).readonly(),
15203
- freeBytes: number(),
15204
- totalBytes: number()
15205
- });
15206
- method(_void(), array(string()).readonly(), { auth: "admin" }), method(object({ path: string() }), BrowseResultSchema, { auth: "admin" }), method(object({ path: string() }), object({ path: string() }), {
15597
+ display: DeviceDisplayOverrideSchema.nullable()
15598
+ }), _void(), {
15207
15599
  kind: "mutation",
15208
15600
  auth: "admin"
15209
- });
15210
- /**
15211
- * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
15212
- * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15213
- * caps stay wire-compatible without a circular cap→cap import.
15214
- *
15215
- * Errors are a discriminated-union RESULT, never thrown: the shape survives
15216
- * every transport tier structurally, and failed calls still write usage rows.
15217
- * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
15218
- */
15219
- var LlmUsageSchema = object({
15220
- inputTokens: number(),
15221
- outputTokens: number()
15222
- });
15223
- var LlmErrorCodeSchema = _enum([
15224
- "timeout",
15225
- "rate-limited",
15226
- "auth",
15227
- "refusal",
15228
- "bad-request",
15229
- "unavailable",
15230
- "no-profile",
15231
- "budget-exceeded",
15232
- "adapter-error"
15233
- ]);
15234
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
15235
- ok: literal(true),
15236
- text: string(),
15237
- model: string(),
15238
- usage: LlmUsageSchema,
15239
- truncated: boolean(),
15240
- latencyMs: number()
15241
- }), object({
15242
- ok: literal(false),
15243
- code: LlmErrorCodeSchema,
15244
- message: string(),
15245
- retryAfterMs: number().optional()
15246
- })]);
15247
- /**
15248
- * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
15249
- * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
15250
- * notification-output.cap.ts:27-31 precedents).
15251
- */
15252
- var LlmImageSchema = object({
15253
- bytes: _instanceof(Uint8Array),
15254
- mimeType: string()
15255
- });
15256
- var LlmGenerateBaseInputSchema = object({
15257
- /** Collection routing (the notification-output posture). */
15258
- addonId: string().optional(),
15259
- /** Explicit profile; else the resolution chain (spec §3). */
15260
- profileId: string().optional(),
15261
- /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
15262
- consumer: string(),
15263
- system: string().optional(),
15264
- /** v1: single-turn. `messages[]` is a v2 additive field. */
15265
- prompt: string(),
15266
- /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
15267
- jsonSchema: record(string(), unknown()).optional(),
15268
- /** Per-call override of the profile default. */
15269
- maxTokens: number().int().positive().optional(),
15270
- temperature: number().optional()
15271
- });
15272
- /**
15273
- * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
15274
- * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
15275
- * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
15276
- * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
15277
- * this only through the `llm` cap's methods.
15278
- *
15279
- * One running llama-server child per node in v1 (models are RAM-heavy).
15280
- * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
15281
- * watchdog — operator decision #3).
15282
- */
15283
- var ManagedModelRefSchema = discriminatedUnion("kind", [
15284
- object({
15285
- kind: literal("catalog"),
15286
- catalogId: string()
15287
- }),
15288
- object({
15289
- kind: literal("url"),
15290
- url: string(),
15291
- sha256: string().optional()
15292
- }),
15293
- object({
15294
- kind: literal("path"),
15295
- path: string()
15296
- })
15297
- ]);
15298
- var ManagedRuntimeConfigSchema = object({
15299
- /** WHERE the runtime lives — hub or any agent. */
15300
- nodeId: string(),
15301
- /** Closed for v1; 'ollama' is a v2 candidate. */
15302
- engine: _enum(["llama-cpp"]),
15303
- model: ManagedModelRefSchema,
15304
- contextSize: number().int().default(4096),
15305
- /** 0 = CPU-only. */
15306
- gpuLayers: number().int().default(0),
15307
- /** Default: cpus-2, clamped ≥1 (resolved node-side). */
15308
- threads: number().int().optional(),
15309
- /** Concurrent slots. */
15310
- parallel: number().int().default(1),
15311
- /** Else lazy: first generate boots it. */
15312
- autoStart: boolean().default(false),
15313
- /** 0 = never; frees RAM after quiet periods. */
15314
- idleStopMinutes: number().int().default(30)
15315
- });
15316
- var LlmRuntimeStatusSchema = object({
15317
- /** Status is ALWAYS node-qualified. */
15318
- nodeId: string(),
15319
- state: _enum([
15320
- "stopped",
15321
- "downloading",
15322
- "starting",
15323
- "ready",
15324
- "crashed",
15325
- "failed"
15326
- ]),
15327
- pid: number().optional(),
15328
- port: number().optional(),
15329
- modelPath: string().optional(),
15330
- modelId: string().optional(),
15331
- downloadProgress: number().min(0).max(1).optional(),
15332
- lastError: string().optional(),
15333
- crashesInWindow: number(),
15334
- /** Child RSS (sampled best-effort). */
15335
- memoryBytes: number().optional(),
15336
- vramBytes: number().optional()
15337
- });
15338
- var LlmNodeModelSchema = object({
15339
- file: string(),
15340
- sizeBytes: number(),
15341
- catalogId: string().optional(),
15342
- installedAt: number().optional()
15343
- });
15344
- var LlmRuntimeDiskUsageSchema = object({
15345
- nodeId: string(),
15346
- modelsBytes: number(),
15347
- freeBytes: number().optional()
15348
- });
15349
- method(LlmGenerateBaseInputSchema.extend({
15350
- images: array(LlmImageSchema).optional(),
15351
- runtime: ManagedRuntimeConfigSchema,
15352
- /** The managed profile's timeout, threaded by the hub provider. */
15353
- timeoutMs: number().int().positive().optional()
15354
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
15601
+ }), method(object({}), object({ defaults: record(string(), RoleDisplayDefaultSchema) }), { kind: "query" }), method(object({ defaults: record(string(), RoleDisplayDefaultSchema) }), _void(), {
15602
+ kind: "mutation",
15603
+ auth: "admin"
15604
+ }), method(object({
15605
+ deviceId: number(),
15606
+ includeSynthesizable: boolean().optional()
15607
+ }), object({ caps: array(object({
15608
+ cap: string(),
15609
+ fields: array(object({
15610
+ path: string(),
15611
+ kind: _enum([
15612
+ "string",
15613
+ "number",
15614
+ "boolean",
15615
+ "enum"
15616
+ ]),
15617
+ enumValues: array(string()).optional(),
15618
+ item: boolean().optional()
15619
+ })).readonly(),
15620
+ itemArray: object({
15621
+ path: string(),
15622
+ keyField: string()
15623
+ }).optional()
15624
+ })).readonly() }), { kind: "query" }), method(object({
15625
+ deviceId: number(),
15626
+ role: string().nullable()
15627
+ }), _void(), {
15355
15628
  kind: "mutation",
15356
15629
  auth: "admin"
15357
- }), method(object({}), _void(), {
15630
+ }), method(object({
15631
+ deviceId: number(),
15632
+ name: string().optional(),
15633
+ location: string().nullable().optional(),
15634
+ type: _enum(DeviceType).optional(),
15635
+ integrationId: string().optional(),
15636
+ linkDeviceId: number().nullable().optional(),
15637
+ role: string().nullable().optional()
15638
+ }), _void(), {
15358
15639
  kind: "mutation",
15359
15640
  auth: "admin"
15360
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
15641
+ }), method(object({
15642
+ deviceId: number(),
15643
+ patch: record(string(), unknown())
15644
+ }), _void(), {
15361
15645
  kind: "mutation",
15362
15646
  auth: "admin"
15363
- }), method(object({ file: string() }), _void(), {
15647
+ }), method(_void(), array(string())), method(object({ name: string() }), _void(), {
15364
15648
  kind: "mutation",
15365
15649
  auth: "admin"
15366
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
15367
- /**
15368
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
15369
- * methods concat-fan across providers; single-row methods route to ONE
15370
- * provider by the `addonId` in the call input (the notification-output
15371
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
15372
- * (hub-placed); the cap stays open for future providers.
15373
- *
15374
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
15375
- * `apiKey` is a password field — providers REDACT it on read and merge on
15376
- * write; a stored key NEVER round-trips to a client.
15377
- */
15378
- var LlmProfileKindSchema = _enum([
15379
- "openai-compatible",
15380
- "openai",
15381
- "anthropic",
15382
- "google",
15383
- "managed-local"
15384
- ]);
15385
- var LlmProfileSchema = object({
15386
- id: string(),
15650
+ }), method(object({
15387
15651
  name: string(),
15388
- kind: LlmProfileKindSchema,
15389
- /** Stamped by the provider — keeps the fanned catalog routable. */
15652
+ cascade: boolean().optional()
15653
+ }), _void(), {
15654
+ kind: "mutation",
15655
+ auth: "admin"
15656
+ }), method(object({
15657
+ deviceId: number(),
15658
+ disabled: boolean()
15659
+ }), _void(), {
15660
+ kind: "mutation",
15661
+ auth: "admin"
15662
+ }), method(object({ addonId: string() }), array(SavedDeviceRowSchema)), method(object({ addonId: string().optional() }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), DeviceInfoSchema.nullable()), method(object({ parentDeviceId: number() }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), object({
15663
+ mode: DeviceLinkModeSchema,
15664
+ devices: array(LinkedDeviceSchema)
15665
+ })), method(object({ deviceId: number() }), array(StreamSourceEntrySchema$1)), method(object({ deviceId: number() }), array(ConfigEntrySchema)), method(object({ deviceId: number() }), ConfigUISchemaOutput), method(object({
15666
+ deviceId: number(),
15667
+ values: record(string(), unknown())
15668
+ }), object({ success: literal(true) }), {
15669
+ kind: "mutation",
15670
+ auth: "admin"
15671
+ }), method(object({ deviceId: number() }), object({ success: literal(true) }), {
15672
+ kind: "mutation",
15673
+ auth: "admin"
15674
+ }), method(object({ deviceId: number() }), object({ success: literal(true) }), {
15675
+ kind: "mutation",
15676
+ auth: "admin"
15677
+ }), method(object({ deviceId: number() }), object({ success: literal(true) }), {
15678
+ kind: "mutation",
15679
+ auth: "admin"
15680
+ }), method(object({ integrationId: string() }), object({ removed: number() }), {
15681
+ kind: "mutation",
15682
+ auth: "admin"
15683
+ }), method(object({ deviceId: number() }), record(string(), string().nullable())), method(object({
15684
+ deviceId: number(),
15685
+ profileMap: record(string(), string().nullable())
15686
+ }), object({ success: literal(true) }), {
15687
+ kind: "mutation",
15688
+ auth: "admin"
15689
+ }), method(object({ deviceId: number() }), array(StreamProbeResultSchema), {
15690
+ kind: "mutation",
15691
+ auth: "admin"
15692
+ }), method(object({ deviceId: number() }), object({
15693
+ deviceId: number(),
15694
+ entries: array(object({
15695
+ capName: string(),
15696
+ kind: _enum([
15697
+ "native",
15698
+ "wrapped",
15699
+ "linked"
15700
+ ]),
15701
+ providerAddonId: string(),
15702
+ providerNodeId: string(),
15703
+ nativeAddonId: string()
15704
+ }))
15705
+ })), method(object({}), array(object({
15706
+ deviceId: number(),
15707
+ entries: array(object({
15708
+ capName: string(),
15709
+ kind: _enum([
15710
+ "native",
15711
+ "wrapped",
15712
+ "linked"
15713
+ ]),
15714
+ providerAddonId: string(),
15715
+ providerNodeId: string(),
15716
+ nativeAddonId: string()
15717
+ }))
15718
+ }))), method(object({
15719
+ deviceId: number(),
15720
+ capName: string(),
15721
+ wrapperAddonId: string(),
15722
+ active: boolean()
15723
+ }), _void(), {
15724
+ kind: "mutation",
15725
+ auth: "admin"
15726
+ }), method(object({ capName: string() }), array(string())), method(object({ deviceType: string() }), array(object({
15727
+ capName: string(),
15728
+ wrappers: array(string())
15729
+ }))), method(object({ deviceId: number() }), SettingsSchemaWithValuesSchema.nullable()), method(object({ deviceId: number() }), SettingsSchemaWithValuesSchema.nullable()), method(object({ deviceId: number() }), object({
15730
+ settings: SettingsSchemaWithValuesSchema.nullable(),
15731
+ live: SettingsSchemaWithValuesSchema.nullable()
15732
+ })), method(object({
15733
+ deviceId: number().int().nonnegative(),
15734
+ action: string().min(1),
15735
+ input: unknown()
15736
+ }), unknown(), { kind: "mutation" }), method(object({
15737
+ deviceId: number(),
15738
+ writerCapName: string(),
15739
+ writerAddonId: string(),
15740
+ key: string(),
15741
+ value: unknown()
15742
+ }), object({ success: literal(true) }), {
15743
+ kind: "mutation",
15744
+ auth: "admin"
15745
+ }), method(object({
15746
+ deviceId: number(),
15747
+ changes: array(object({
15748
+ writerCapName: string(),
15749
+ writerAddonId: string(),
15750
+ key: string(),
15751
+ value: unknown()
15752
+ }))
15753
+ }), object({
15754
+ success: literal(true),
15755
+ failures: array(object({
15756
+ writerCapName: string(),
15757
+ writerAddonId: string(),
15758
+ error: string()
15759
+ }))
15760
+ }), {
15761
+ kind: "mutation",
15762
+ auth: "admin"
15763
+ }), method(object({ addonId: string() }), array(DiscoveryCandidateSchema), {
15764
+ kind: "mutation",
15765
+ auth: "admin"
15766
+ }), method(object({
15390
15767
  addonId: string(),
15391
- enabled: boolean(),
15392
- /** Vendor model id, or the managed runtime's loaded model. */
15393
- model: string(),
15394
- /** Required for openai-compatible; override for cloud kinds. */
15395
- baseUrl: string().optional(),
15396
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
15397
- apiKey: string().optional(),
15398
- supportsVision: boolean(),
15399
- temperature: number().min(0).max(2).optional(),
15400
- maxTokens: number().int().positive().optional(),
15401
- timeoutMs: number().int().positive().default(6e4),
15402
- extraHeaders: record(string(), string()).optional(),
15403
- /** kind === 'managed-local' only (spec §4). */
15404
- runtime: ManagedRuntimeConfigSchema.optional()
15405
- });
15406
- /** ConfigUISchema tree passed through untyped on the wire (the
15407
- * notification-output `ConfigSchemaPassthrough` precedent at
15408
- * notification-output.cap.ts:151); the exported TS type re-tightens it. */
15409
- var ConfigSchemaPassthrough$1 = unknown();
15410
- var LlmProfileKindDescriptorSchema = object({
15411
- kind: LlmProfileKindSchema,
15412
- label: string(),
15413
- icon: string(),
15414
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
15768
+ candidate: DiscoveryCandidateSchema,
15769
+ /** Owning integration id, stamped onto the new device's meta by the
15770
+ * device-manager forwarder so `removeByIntegration` can cascade it.
15771
+ * Optional for back-compat (omitted = no stamp = pre-existing behavior). */
15772
+ integrationId: string().optional()
15773
+ }), DeviceSummarySchema, {
15774
+ kind: "mutation",
15775
+ auth: "admin"
15776
+ }), method(object({
15415
15777
  addonId: string(),
15416
- configSchema: ConfigSchemaPassthrough$1
15417
- });
15418
- var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
15419
- var LlmDefaultSchema = object({
15420
- selector: LlmDefaultSelectorSchema,
15421
- profileId: string()
15422
- });
15423
- /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
15424
- var LlmUsageRollupSchema = object({
15425
- day: string(),
15426
- consumer: string(),
15427
- profileId: string(),
15428
- calls: number(),
15429
- okCalls: number(),
15430
- errorCalls: number(),
15431
- inputTokens: number(),
15432
- outputTokens: number(),
15433
- avgLatencyMs: number()
15434
- });
15435
- /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
15436
- var ManagedModelCatalogEntrySchema = object({
15437
- id: string(),
15438
- label: string(),
15439
- family: string(),
15440
- purpose: _enum(["text", "vision"]),
15441
- url: string(),
15442
- sha256: string(),
15443
- sizeBytes: number(),
15444
- quantization: string(),
15445
- /** Load-time guidance shown in the picker. */
15446
- minRamBytes: number(),
15447
- contextSizeDefault: number().int(),
15448
- /** Vision models: companion projector file. */
15449
- mmprojUrl: string().optional()
15450
- });
15451
- var LlmRuntimeNodeSchema = object({
15452
- nodeId: string(),
15453
- reachable: boolean(),
15454
- status: LlmRuntimeStatusSchema.optional(),
15455
- disk: LlmRuntimeDiskUsageSchema.optional(),
15456
- error: string().optional()
15457
- });
15458
- var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
15459
- var ProfileRefInputSchema = object({
15778
+ type: _enum(DeviceType)
15779
+ }), unknown().nullable()), method(object({
15460
15780
  addonId: string(),
15461
- profileId: string()
15462
- });
15463
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
15781
+ type: _enum(DeviceType),
15782
+ config: record(string(), unknown()),
15783
+ /** Owning integration id, stamped onto the new device's meta by the
15784
+ * device-manager forwarder so `removeByIntegration` can cascade it.
15785
+ * Optional for back-compat (omitted = no stamp = pre-existing behavior). */
15786
+ integrationId: string().optional()
15787
+ }), DeviceSummarySchema, {
15788
+ kind: "mutation",
15789
+ auth: "admin"
15790
+ }), method(object({
15791
+ addonId: string(),
15792
+ type: _enum(DeviceType),
15793
+ key: string(),
15794
+ value: unknown(),
15795
+ formValues: record(string(), unknown()).optional()
15796
+ }), FieldProbeResultSchema, {
15464
15797
  kind: "mutation",
15465
15798
  auth: "admin"
15466
- }), method(ProfileRefInputSchema, _void(), {
15799
+ }), method(object({
15800
+ addonId: string(),
15801
+ integrationId: string()
15802
+ }), object({ filters: array(AdoptionFilterSchema) }), { auth: "admin" }), method(ListCandidatesInputSchema.extend({ addonId: string() }), ListCandidatesOutputSchema, { auth: "admin" }), method(object({
15803
+ addonId: string(),
15804
+ integrationId: string()
15805
+ }), AdoptionStatusSchema, {
15467
15806
  kind: "mutation",
15468
15807
  auth: "admin"
15469
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
15808
+ }), method(AdoptInputSchema.extend({ addonId: string() }), AdoptResultSchema, {
15470
15809
  kind: "mutation",
15471
15810
  auth: "admin"
15472
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
15473
- selector: LlmDefaultSelectorSchema,
15474
- profileId: string().nullable()
15475
- }), _void(), {
15811
+ }), method(ReleaseInputSchema.extend({ addonId: string() }), _void(), {
15476
15812
  kind: "mutation",
15477
15813
  auth: "admin"
15478
- }), method(object({
15479
- since: number().optional(),
15480
- until: number().optional(),
15481
- consumer: string().optional(),
15482
- profileId: string().optional()
15483
- }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
15484
- nodeId: string(),
15485
- model: ManagedModelRefSchema
15486
- }), _void(), {
15814
+ }), method(ResyncInputSchema, ResyncResultSchema, {
15487
15815
  kind: "mutation",
15488
15816
  auth: "admin"
15489
- }), method(object({
15490
- nodeId: string(),
15491
- file: string()
15492
- }), _void(), {
15817
+ }), method(object({}), object({ providers: array(object({
15818
+ addonId: string(),
15819
+ label: string()
15820
+ })).readonly() }), { auth: "admin" }), method(object({}), object({ groups: array(object({
15821
+ addonId: string(),
15822
+ label: string(),
15823
+ candidates: array(DiscoveryCandidateSchema).readonly(),
15824
+ error: string().nullable()
15825
+ })).readonly() }), {
15493
15826
  kind: "mutation",
15494
15827
  auth: "admin"
15495
- }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
15828
+ }), method(object({
15829
+ addonId: string(),
15830
+ params: record(string(), unknown()).optional()
15831
+ }), object({ candidates: array(DiscoveryCandidateSchema).readonly() }), {
15496
15832
  kind: "mutation",
15497
15833
  auth: "admin"
15498
- }), method(ProfileRefInputSchema, _void(), {
15834
+ }), method(object({ addonId: string() }), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
15835
+ deviceId: number(),
15836
+ key: string(),
15837
+ value: unknown()
15838
+ }), FieldProbeResultSchema, {
15499
15839
  kind: "mutation",
15500
15840
  auth: "admin"
15841
+ }), method(object({
15842
+ deviceId: number(),
15843
+ caps: array(string()).readonly().optional()
15844
+ }), record(string(), unknown().nullable()));
15845
+ method(object({ deviceId: number() }), record(string(), record(string(), unknown()))), method(object({
15846
+ deviceId: number(),
15847
+ capName: string()
15848
+ }), record(string(), unknown()).nullable()), method(object({}), record(string(), record(string(), record(string(), unknown())))), method(object({
15849
+ deviceId: number(),
15850
+ capName: string(),
15851
+ slice: record(string(), unknown())
15852
+ }), _void(), { kind: "mutation" }), object({
15853
+ deviceId: number(),
15854
+ capName: string(),
15855
+ slice: record(string(), unknown())
15501
15856
  });
15502
- var LogLevelSchema = _enum([
15503
- "debug",
15504
- "info",
15505
- "warn",
15506
- "error"
15507
- ]);
15508
- var LogEntrySchema = object({
15509
- timestamp: date(),
15510
- level: LogLevelSchema,
15511
- scope: array(string()),
15512
- message: string(),
15513
- meta: record(string(), unknown()).optional(),
15514
- tags: record(string(), string()).optional()
15515
- });
15516
- method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
15517
- scope: array(string()).optional(),
15518
- level: LogLevelSchema.optional(),
15519
- since: date().optional(),
15520
- until: date().optional(),
15521
- limit: number().optional(),
15522
- tags: record(string(), string()).optional()
15523
- }), array(LogEntrySchema).readonly());
15524
15857
  /**
15525
- * `login-method` collection cap through which auth addons contribute
15526
- * their pre-auth login surfaces to the login page. This is the SINGLE,
15527
- * generic mechanism that supersedes the dead `auth.listProviders` reader:
15528
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
15529
- * `login-method` provider and the PUBLIC `auth.listLoginMethods`
15530
- * procedure aggregates them for the unauthenticated login page.
15531
- *
15532
- * A contribution is a discriminated union on `kind`:
15533
- *
15534
- * - `redirect` — a declarative button. The login page renders a generic
15535
- * button that navigates to `startUrl` (an addon-owned HTTP route).
15536
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
15537
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
15538
- * login page needs NO change.
15539
- *
15540
- * - `widget` — a Module-Federation widget the login page mounts (via
15541
- * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
15542
- * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
15543
- * mechanism kept for future use; no shipped addon uses it on the login
15544
- * page (the passkey ceremony below runs natively in the shell instead).
15545
- *
15546
- * - `passkey` — a declarative WebAuthn ceremony the shell renders
15547
- * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
15548
- * a remotely-loaded bundle). Carries the addon's effective `rpId` /
15549
- * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
15550
- * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
15551
- * fetching any remote code pre-auth. Contribution stays unconditional —
15552
- * enrollment state is never leaked pre-auth; visibility is a shell
15553
- * decision.
15554
- *
15555
- * Every contribution carries a `stage`:
15556
- * - `primary` — shown on the first credentials screen (OIDC /
15557
- * magic-link buttons; a future usernameless passkey).
15558
- * - `second-factor` — shown AFTER the password leg, gated on the
15559
- * returned `factors` (passkey-as-2FA today).
15560
- *
15561
- * `mount: skip` — the cap is read server-side by the core auth router
15562
- * (`registry.getCollection('login-method')`), never mounted as its own
15563
- * tRPC router.
15858
+ * Embedding output. `embedding` is wire-encoded as `number[]` so the
15859
+ * Zod-validated tRPC surface round-trips cleanly; consumers that need a
15860
+ * `Float32Array` can wrap it on the way out (in-process, no marshalling
15861
+ * is involved). `inferenceMs` mirrors the runtime field used by the
15862
+ * post-analysis enrichment-engine.
15564
15863
  */
15565
- /** When a login method renders in the two-phase login flow. */
15566
- var LoginStageEnum = _enum(["primary", "second-factor"]);
15567
- /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
15568
- var LoginMethodContributionSchema = discriminatedUnion("kind", [
15569
- object({
15570
- kind: literal("redirect"),
15571
- /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
15572
- id: string(),
15573
- /** Operator-facing button label. */
15574
- label: string(),
15575
- /** lucide-react icon name. */
15576
- icon: string().optional(),
15577
- /** Addon-owned HTTP route the button navigates to (GET). */
15578
- startUrl: string(),
15579
- stage: LoginStageEnum
15580
- }),
15581
- object({
15582
- kind: literal("widget"),
15583
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
15584
- id: string(),
15585
- /** Owning addon id — drives the public bundle URL + the MF namespace. */
15586
- addonId: string(),
15587
- /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
15588
- bundle: string(),
15589
- /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
15590
- remote: WidgetRemoteSchema,
15591
- stage: LoginStageEnum
15592
- }),
15593
- object({
15594
- kind: literal("passkey"),
15595
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
15596
- id: string(),
15597
- /** Operator-facing button label. */
15598
- label: string(),
15599
- stage: LoginStageEnum,
15600
- /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
15601
- rpId: string(),
15602
- /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
15603
- origin: string().nullable()
15604
- })
15605
- ]);
15606
- method(_void(), array(LoginMethodContributionSchema).readonly());
15607
- var CpuBreakdownSchema = object({
15608
- total: number(),
15609
- user: number(),
15610
- system: number(),
15611
- irq: number(),
15612
- nice: number(),
15613
- loadAvg: tuple([
15614
- number(),
15615
- number(),
15616
- number()
15617
- ]),
15618
- cores: number()
15864
+ var EmbeddingResultSchema = object({
15865
+ embedding: array(number()),
15866
+ inferenceMs: number()
15619
15867
  });
15620
- var MemoryInfoSchema = object({
15621
- percent: number(),
15622
- totalBytes: number(),
15623
- usedBytes: number(),
15624
- availableBytes: number(),
15625
- swapUsedBytes: number(),
15626
- swapTotalBytes: number()
15868
+ var EmbeddingInfoSchema = object({
15869
+ modelId: string(),
15870
+ embeddingDim: number(),
15871
+ ready: boolean()
15627
15872
  });
15628
- var DiskIoSnapshotSchema = object({
15629
- readBytes: number(),
15630
- writeBytes: number(),
15631
- readOps: number(),
15632
- writeOps: number(),
15633
- timestampMs: number()
15873
+ method(object({
15874
+ crop: _instanceof(Uint8Array),
15875
+ width: number(),
15876
+ height: number()
15877
+ }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
15878
+ /**
15879
+ * filesystem-browse — per-node capability for browsing the node's local
15880
+ * filesystem, sandboxed to operator-configured allowed roots. Used by the
15881
+ * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
15882
+ * (one provider per node); the hub calls it with `{nodeId}` so the codegen
15883
+ * routes to that exact node (default `nodeIdMode:'routing'`).
15884
+ */
15885
+ var DirEntrySchema = object({
15886
+ name: string(),
15887
+ path: string()
15634
15888
  });
15635
- var NetworkIoSnapshotSchema = object({
15636
- rxBytes: number(),
15637
- txBytes: number(),
15638
- rxPackets: number(),
15639
- txPackets: number(),
15640
- rxErrors: number(),
15641
- txErrors: number(),
15642
- timestampMs: number()
15889
+ var BrowseResultSchema = object({
15890
+ path: string(),
15891
+ entries: array(DirEntrySchema).readonly(),
15892
+ freeBytes: number(),
15893
+ totalBytes: number()
15643
15894
  });
15644
- var MetricsGpuInfoSchema = object({
15645
- utilization: number(),
15646
- model: string(),
15647
- memoryUsedBytes: number(),
15648
- memoryTotalBytes: number(),
15649
- temperature: number().nullable()
15895
+ method(_void(), array(string()).readonly(), { auth: "admin" }), method(object({ path: string() }), BrowseResultSchema, { auth: "admin" }), method(object({ path: string() }), object({ path: string() }), {
15896
+ kind: "mutation",
15897
+ auth: "admin"
15650
15898
  });
15651
- var ProcessResourceInfoSchema = object({
15652
- openFds: number(),
15653
- threadCount: number(),
15654
- activeHandles: number(),
15655
- activeRequests: number()
15899
+ /**
15900
+ * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
15901
+ * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15902
+ * caps stay wire-compatible without a circular cap→cap import.
15903
+ *
15904
+ * Errors are a discriminated-union RESULT, never thrown: the shape survives
15905
+ * every transport tier structurally, and failed calls still write usage rows.
15906
+ * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
15907
+ */
15908
+ var LlmUsageSchema = object({
15909
+ inputTokens: number(),
15910
+ outputTokens: number()
15656
15911
  });
15657
- var PressureAvgsSchema = object({
15658
- avg10: number(),
15659
- avg60: number(),
15660
- avg300: number()
15912
+ var LlmErrorCodeSchema = _enum([
15913
+ "timeout",
15914
+ "rate-limited",
15915
+ "auth",
15916
+ "refusal",
15917
+ "bad-request",
15918
+ "unavailable",
15919
+ "no-profile",
15920
+ "budget-exceeded",
15921
+ "adapter-error"
15922
+ ]);
15923
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
15924
+ ok: literal(true),
15925
+ text: string(),
15926
+ model: string(),
15927
+ usage: LlmUsageSchema,
15928
+ truncated: boolean(),
15929
+ latencyMs: number()
15930
+ }), object({
15931
+ ok: literal(false),
15932
+ code: LlmErrorCodeSchema,
15933
+ message: string(),
15934
+ retryAfterMs: number().optional()
15935
+ })]);
15936
+ /**
15937
+ * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
15938
+ * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
15939
+ * notification-output.cap.ts:27-31 precedents).
15940
+ */
15941
+ var LlmImageSchema = object({
15942
+ bytes: _instanceof(Uint8Array),
15943
+ mimeType: string()
15661
15944
  });
15662
- var PressureInfoSchema = object({
15663
- some: PressureAvgsSchema,
15664
- full: PressureAvgsSchema.nullable()
15945
+ var LlmGenerateBaseInputSchema = object({
15946
+ /** Collection routing (the notification-output posture). */
15947
+ addonId: string().optional(),
15948
+ /** Explicit profile; else the resolution chain (spec §3). */
15949
+ profileId: string().optional(),
15950
+ /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
15951
+ consumer: string(),
15952
+ system: string().optional(),
15953
+ /** v1: single-turn. `messages[]` is a v2 additive field. */
15954
+ prompt: string(),
15955
+ /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
15956
+ jsonSchema: record(string(), unknown()).optional(),
15957
+ /** Per-call override of the profile default. */
15958
+ maxTokens: number().int().positive().optional(),
15959
+ temperature: number().optional()
15665
15960
  });
15666
- var SystemResourceSnapshotSchema = object({
15667
- cpu: CpuBreakdownSchema,
15668
- memory: MemoryInfoSchema,
15669
- gpu: MetricsGpuInfoSchema.nullable(),
15670
- network: NetworkIoSnapshotSchema,
15671
- disk: DiskIoSnapshotSchema,
15672
- pressure: object({
15673
- cpu: PressureInfoSchema.nullable(),
15674
- memory: PressureInfoSchema.nullable(),
15675
- io: PressureInfoSchema.nullable()
15961
+ /**
15962
+ * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
15963
+ * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
15964
+ * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
15965
+ * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
15966
+ * this only through the `llm` cap's methods.
15967
+ *
15968
+ * One running llama-server child per node in v1 (models are RAM-heavy).
15969
+ * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
15970
+ * watchdog — operator decision #3).
15971
+ */
15972
+ var ManagedModelRefSchema = discriminatedUnion("kind", [
15973
+ object({
15974
+ kind: literal("catalog"),
15975
+ catalogId: string()
15676
15976
  }),
15677
- process: ProcessResourceInfoSchema,
15678
- cpuTemperature: number().nullable(),
15679
- timestampMs: number()
15680
- });
15681
- var DiskSpaceInfoSchema = object({
15682
- path: string(),
15683
- totalBytes: number(),
15684
- usedBytes: number(),
15685
- availableBytes: number(),
15686
- percent: number()
15687
- });
15688
- var PidResourceStatsSchema = object({
15689
- pid: number(),
15690
- cpu: number(),
15691
- memory: number(),
15692
- /**
15693
- * Private (anonymous) resident bytes — the per-process V8 heap + native
15694
- * allocations NOT shared with other processes (Linux RssAnon). This is the
15695
- * "real" per-runner cost; summing it across runners is meaningful, unlike
15696
- * `memory` (RSS), which double-counts the shared mmap'd framework code.
15697
- * Undefined where /proc is unavailable (e.g. macOS).
15698
- */
15699
- privateBytes: number().optional(),
15700
- /**
15701
- * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
15702
- * code shared copy-on-write across runners. Undefined on macOS.
15703
- */
15704
- sharedBytes: number().optional()
15977
+ object({
15978
+ kind: literal("url"),
15979
+ url: string(),
15980
+ sha256: string().optional()
15981
+ }),
15982
+ object({
15983
+ kind: literal("path"),
15984
+ path: string()
15985
+ })
15986
+ ]);
15987
+ var ManagedRuntimeConfigSchema = object({
15988
+ /** WHERE the runtime lives — hub or any agent. */
15989
+ nodeId: string(),
15990
+ /** Closed for v1; 'ollama' is a v2 candidate. */
15991
+ engine: _enum(["llama-cpp"]),
15992
+ model: ManagedModelRefSchema,
15993
+ contextSize: number().int().default(4096),
15994
+ /** 0 = CPU-only. */
15995
+ gpuLayers: number().int().default(0),
15996
+ /** Default: cpus-2, clamped ≥1 (resolved node-side). */
15997
+ threads: number().int().optional(),
15998
+ /** Concurrent slots. */
15999
+ parallel: number().int().default(1),
16000
+ /** Else lazy: first generate boots it. */
16001
+ autoStart: boolean().default(false),
16002
+ /** 0 = never; frees RAM after quiet periods. */
16003
+ idleStopMinutes: number().int().default(30)
15705
16004
  });
15706
- var AddonInstanceSchema = object({
15707
- addonId: string(),
16005
+ var LlmRuntimeStatusSchema = object({
16006
+ /** Status is ALWAYS node-qualified. */
15708
16007
  nodeId: string(),
15709
- role: _enum(["hub", "worker"]),
15710
- pid: number(),
15711
16008
  state: _enum([
15712
- "starting",
15713
- "running",
15714
- "stopping",
15715
16009
  "stopped",
15716
- "crashed"
15717
- ]),
15718
- uptimeSec: number()
15719
- });
15720
- var NodeProcessSchema = object({
15721
- pid: number(),
15722
- ppid: number(),
15723
- pgid: number(),
15724
- classification: _enum([
15725
- "root",
15726
- "managed",
15727
- "system",
15728
- "ghost"
16010
+ "downloading",
16011
+ "starting",
16012
+ "ready",
16013
+ "crashed",
16014
+ "failed"
15729
16015
  ]),
15730
- /** `$process` addon binding when `managed`, else null. */
15731
- addonId: string().nullable(),
15732
- /** Kernel-reported nodeId when the process is a known agent/worker. */
15733
- nodeId: string().nullable(),
15734
- /** Truncated command line. */
15735
- command: string(),
15736
- cpuPercent: number(),
15737
- memoryRssBytes: number(),
15738
- /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
15739
- uptimeSec: number(),
15740
- /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
15741
- orphaned: boolean()
15742
- });
15743
- var KillProcessInputSchema = object({
15744
- pid: number(),
15745
- /** Force = SIGKILL. Default is SIGTERM. */
15746
- force: boolean().optional()
15747
- });
15748
- var KillProcessResultSchema = object({
15749
- success: boolean(),
15750
- reason: string().optional(),
15751
- signal: _enum(["SIGTERM", "SIGKILL"]).optional()
15752
- });
15753
- var DumpHeapSnapshotInputSchema = object({
15754
- /** The addon whose runner should dump a heap snapshot. */
15755
- addonId: string() });
15756
- var DumpHeapSnapshotResultSchema = object({
15757
- success: boolean(),
15758
- /** Path of the written .heapsnapshot inside the runner's container/host. */
15759
- path: string().optional(),
15760
- /** Process pid that was signalled. */
15761
16016
  pid: number().optional(),
15762
- reason: string().optional()
15763
- });
15764
- var SystemMetricsSchema = object({
15765
- cpuPercent: number(),
15766
- memoryPercent: number(),
15767
- memoryUsedMB: number(),
15768
- memoryTotalMB: number(),
15769
- diskPercent: number().optional(),
15770
- temperature: number().optional(),
15771
- gpuPercent: number().optional(),
15772
- gpuMemoryPercent: number().optional()
15773
- });
15774
- 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, {
15775
- kind: "mutation",
15776
- auth: "admin"
15777
- }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
15778
- kind: "mutation",
15779
- auth: "admin"
16017
+ port: number().optional(),
16018
+ modelPath: string().optional(),
16019
+ modelId: string().optional(),
16020
+ downloadProgress: number().min(0).max(1).optional(),
16021
+ lastError: string().optional(),
16022
+ crashesInWindow: number(),
16023
+ /** Child RSS (sampled best-effort). */
16024
+ memoryBytes: number().optional(),
16025
+ vramBytes: number().optional()
15780
16026
  });
15781
- method(object({
15782
- sourceUrl: string(),
15783
- metadata: ModelConvertMetadataSchema,
15784
- targets: array(ConvertTargetSchema).min(1).readonly(),
15785
- calibrationRef: string().optional(),
15786
- sessionId: string().optional()
15787
- }), ConvertResultSchema, {
15788
- kind: "mutation",
15789
- auth: "admin",
15790
- timeoutMs: 6e5
16027
+ var LlmNodeModelSchema = object({
16028
+ file: string(),
16029
+ sizeBytes: number(),
16030
+ catalogId: string().optional(),
16031
+ installedAt: number().optional()
15791
16032
  });
15792
- method(object({
16033
+ var LlmRuntimeDiskUsageSchema = object({
15793
16034
  nodeId: string(),
15794
- modelId: string(),
15795
- format: _enum(MODEL_FORMATS),
15796
- entry: ModelCatalogEntrySchema
15797
- }), object({
15798
- ok: boolean(),
15799
- /** sha256 of the staged tarball (empty for a hub-local no-op). */
15800
- sha256: string(),
15801
- bytes: number(),
15802
- /** The target node's modelsDir the artifact landed in. */
15803
- path: string()
15804
- }), {
16035
+ modelsBytes: number(),
16036
+ freeBytes: number().optional()
16037
+ });
16038
+ method(LlmGenerateBaseInputSchema.extend({
16039
+ images: array(LlmImageSchema).optional(),
16040
+ runtime: ManagedRuntimeConfigSchema,
16041
+ /** The managed profile's timeout, threaded by the hub provider. */
16042
+ timeoutMs: number().int().positive().optional()
16043
+ }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
15805
16044
  kind: "mutation",
15806
16045
  auth: "admin"
15807
- });
15808
- /**
15809
- * `mqtt-broker` — broker-registry cap.
15810
- *
15811
- * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
15812
- * MQTT brokers (external + optionally an embedded `aedes`-backed one)
15813
- * and (b) the connection details a consumer addon needs to spin up
15814
- * its OWN `mqtt.js` client.
15815
- *
15816
- * Why: pub/sub routing over the system event-bus loses fidelity
15817
- * (callback shape, QoS guarantees, will/retain semantics) and adds
15818
- * refcount bookkeeping that addons would rather own themselves. The
15819
- * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
15820
- * features anyway — give it the connection config, get out of the way.
15821
- *
15822
- * Consumer flow:
15823
- * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
15824
- * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
15825
- * client.subscribe('zigbee2mqtt/+')
15826
- *
15827
- * Collection mode: multiple brokers (e.g. one local mosquitto + one
15828
- * cloud bridge). The "embedded" entry (when present) is just another
15829
- * broker in the registry — its lifecycle is owned by the addon that
15830
- * spawned it.
15831
- */
15832
- var BrokerKindSchema = _enum(["external", "embedded"]);
16046
+ }), method(object({}), _void(), {
16047
+ kind: "mutation",
16048
+ auth: "admin"
16049
+ }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
16050
+ kind: "mutation",
16051
+ auth: "admin"
16052
+ }), method(object({ file: string() }), _void(), {
16053
+ kind: "mutation",
16054
+ auth: "admin"
16055
+ }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
15833
16056
  /**
15834
- * Broker live-probe status.
16057
+ * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
16058
+ * methods concat-fan across providers; single-row methods route to ONE
16059
+ * provider by the `addonId` in the call input (the notification-output
16060
+ * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
16061
+ * (hub-placed); the cap stays open for future providers.
15835
16062
  *
15836
- * - `connected` last probe completed a clean CONNACK
15837
- * - `disconnected` — no probe has run yet (cold cache)
15838
- * - `auth-failed` CONNACK refused with auth error (RC 4 / 5)
15839
- * - `unreachable` — TCP connect timed out / refused
15840
- * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
16063
+ * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
16064
+ * `apiKey` is a password field providers REDACT it on read and merge on
16065
+ * write; a stored key NEVER round-trips to a client.
15841
16066
  */
15842
- var BrokerStatusSchema$1 = _enum([
15843
- "connected",
15844
- "disconnected",
15845
- "auth-failed",
15846
- "unreachable",
15847
- "tls-error"
16067
+ var LlmProfileKindSchema = _enum([
16068
+ "openai-compatible",
16069
+ "openai",
16070
+ "anthropic",
16071
+ "google",
16072
+ "managed-local"
15848
16073
  ]);
15849
- var BrokerInfoSchema = object({
16074
+ var LlmProfileSchema = object({
15850
16075
  id: string(),
15851
16076
  name: string(),
15852
- url: string(),
15853
- kind: BrokerKindSchema,
15854
- status: BrokerStatusSchema$1,
15855
- latencyMs: number().nullable(),
15856
- error: string().optional(),
15857
- /** Embedded brokers only: number of MQTT clients currently connected. */
15858
- connectedClients: number().int().nonnegative().optional(),
15859
- /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
15860
- lastCheckedAt: number().optional()
16077
+ kind: LlmProfileKindSchema,
16078
+ /** Stamped by the provider — keeps the fanned catalog routable. */
16079
+ addonId: string(),
16080
+ enabled: boolean(),
16081
+ /** Vendor model id, or the managed runtime's loaded model. */
16082
+ model: string(),
16083
+ /** Required for openai-compatible; override for cloud kinds. */
16084
+ baseUrl: string().optional(),
16085
+ /** ConfigUISchema type:'password' — never round-trips (spec §5). */
16086
+ apiKey: string().optional(),
16087
+ supportsVision: boolean(),
16088
+ temperature: number().min(0).max(2).optional(),
16089
+ maxTokens: number().int().positive().optional(),
16090
+ timeoutMs: number().int().positive().default(6e4),
16091
+ extraHeaders: record(string(), string()).optional(),
16092
+ /** kind === 'managed-local' only (spec §4). */
16093
+ runtime: ManagedRuntimeConfigSchema.optional()
15861
16094
  });
15862
- /**
15863
- * Connection details — what a consumer needs to call
15864
- * `mqtt.connect(url, options)`. We split URL + credentials so the
15865
- * consumer can pass them as `mqtt.connect(url, { username, password })`
15866
- * instead of stuffing creds into the URL (which leaks them into logs).
15867
- */
15868
- var BrokerConnectionDetailsSchema = object({
15869
- url: string(),
15870
- username: string().optional(),
15871
- password: string().optional(),
15872
- /**
15873
- * Suggested prefix for `clientId`. Each consumer should suffix this
15874
- * with its own discriminator (addon id, instance id) so reconnects
15875
- * don't kick each other off (MQTT spec: clientId must be unique per
15876
- * broker).
15877
- */
15878
- clientIdPrefix: string().optional()
16095
+ /** ConfigUISchema tree passed through untyped on the wire (the
16096
+ * notification-output `ConfigSchemaPassthrough` precedent at
16097
+ * notification-output.cap.ts:151); the exported TS type re-tightens it. */
16098
+ var ConfigSchemaPassthrough$1 = unknown();
16099
+ var LlmProfileKindDescriptorSchema = object({
16100
+ kind: LlmProfileKindSchema,
16101
+ label: string(),
16102
+ icon: string(),
16103
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
16104
+ addonId: string(),
16105
+ configSchema: ConfigSchemaPassthrough$1
15879
16106
  });
15880
- var AddBrokerInputSchema = object({
15881
- name: string().min(1),
15882
- url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
15883
- username: string().optional(),
15884
- password: string().optional(),
15885
- clientIdPrefix: string().optional()
16107
+ var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
16108
+ var LlmDefaultSchema = object({
16109
+ selector: LlmDefaultSelectorSchema,
16110
+ profileId: string()
15886
16111
  });
15887
- var AddBrokerResultSchema = object({ id: string() });
15888
- var IdInputSchema = object({ id: string() });
15889
- var TestResultSchema$1 = discriminatedUnion("ok", [object({
15890
- ok: literal(true),
15891
- latencyMs: number()
15892
- }), object({
15893
- ok: literal(false),
15894
- error: string()
15895
- })]);
15896
- var StartEmbeddedInputSchema = object({
15897
- port: number().int().min(1).max(65535).default(1883),
15898
- /** Allow anonymous connect (no username/password). Default: false. */
15899
- allowAnonymous: boolean().default(false),
15900
- /** Optional shared username/password for clients. */
15901
- username: string().optional(),
15902
- password: string().optional()
16112
+ /** Server-side rollup row getUsage never dumps raw call rows (spec §6). */
16113
+ var LlmUsageRollupSchema = object({
16114
+ day: string(),
16115
+ consumer: string(),
16116
+ profileId: string(),
16117
+ calls: number(),
16118
+ okCalls: number(),
16119
+ errorCalls: number(),
16120
+ inputTokens: number(),
16121
+ outputTokens: number(),
16122
+ avgLatencyMs: number()
15903
16123
  });
15904
- var StartEmbeddedResultSchema = object({
16124
+ /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
16125
+ var ManagedModelCatalogEntrySchema = object({
15905
16126
  id: string(),
15906
- url: string()
15907
- });
15908
- var StatusSchema = object({
15909
- brokerCount: number(),
15910
- embeddedRunning: boolean()
15911
- });
15912
- var mqttBrokerCapability = {
15913
- name: "mqtt-broker",
15914
- scope: "system",
15915
- mode: "collection",
15916
- providerKind: "broker",
15917
- status: {
15918
- schema: StatusSchema,
15919
- kind: "poll"
15920
- },
15921
- methods: {
15922
- listBrokers: method(_void(), array(BrokerInfoSchema)),
15923
- getBrokerConfig: method(IdInputSchema, BrokerConnectionDetailsSchema),
15924
- addBroker: method(AddBrokerInputSchema, AddBrokerResultSchema, { kind: "mutation" }),
15925
- removeBroker: method(IdInputSchema, _void(), { kind: "mutation" }),
15926
- testConnection: method(IdInputSchema, TestResultSchema$1, { kind: "mutation" }),
15927
- startEmbeddedBroker: method(StartEmbeddedInputSchema, StartEmbeddedResultSchema, { kind: "mutation" }),
15928
- stopEmbeddedBroker: method(IdInputSchema, _void(), { kind: "mutation" }),
15929
- getStatus: method(_void(), StatusSchema)
15930
- }
15931
- };
15932
- var NetworkEndpointSchema = object({
16127
+ label: string(),
16128
+ family: string(),
16129
+ purpose: _enum(["text", "vision"]),
15933
16130
  url: string(),
15934
- hostname: string(),
15935
- port: number(),
15936
- protocol: _enum(["http", "https"])
16131
+ sha256: string(),
16132
+ sizeBytes: number(),
16133
+ quantization: string(),
16134
+ /** Load-time guidance shown in the picker. */
16135
+ minRamBytes: number(),
16136
+ contextSizeDefault: number().int(),
16137
+ /** Vision models: companion projector file. */
16138
+ mmprojUrl: string().optional()
15937
16139
  });
15938
- var NetworkAccessStatusSchema = object({
15939
- connected: boolean(),
15940
- endpoint: NetworkEndpointSchema.nullable(),
16140
+ var LlmRuntimeNodeSchema = object({
16141
+ nodeId: string(),
16142
+ reachable: boolean(),
16143
+ status: LlmRuntimeStatusSchema.optional(),
16144
+ disk: LlmRuntimeDiskUsageSchema.optional(),
15941
16145
  error: string().optional()
15942
16146
  });
15943
- /**
15944
- * Optional, richer endpoint shape returned by providers that expose
15945
- * MORE than one ingress concurrently (Tailscale Ingress with mixed
15946
- * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
15947
- * the originating provider config (mode + sourcePort) so the
15948
- * orchestrator UI can label rows distinctly. Providers that expose only
15949
- * one endpoint just omit `listEndpoints` from their provider impl.
15950
- */
15951
- var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
15952
- /**
15953
- * Stable id within the provider — typically `<mode>-<sourcePort>` so
15954
- * the orchestrator can dedupe across `listEndpoints` polls.
15955
- */
15956
- id: string(),
15957
- /** Operator-facing label (mirrors `MeshEndpoint.label`). */
15958
- label: string(),
15959
- /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
15960
- mode: string().optional(),
15961
- /** Originating local port the ingress fronts (informational). */
15962
- sourcePort: number().optional()
16147
+ var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
16148
+ var ProfileRefInputSchema = object({
16149
+ addonId: string(),
16150
+ profileId: string()
16151
+ });
16152
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
16153
+ kind: "mutation",
16154
+ auth: "admin"
16155
+ }), method(ProfileRefInputSchema, _void(), {
16156
+ kind: "mutation",
16157
+ auth: "admin"
16158
+ }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
16159
+ kind: "mutation",
16160
+ auth: "admin"
16161
+ }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
16162
+ selector: LlmDefaultSelectorSchema,
16163
+ profileId: string().nullable()
16164
+ }), _void(), {
16165
+ kind: "mutation",
16166
+ auth: "admin"
16167
+ }), method(object({
16168
+ since: number().optional(),
16169
+ until: number().optional(),
16170
+ consumer: string().optional(),
16171
+ profileId: string().optional()
16172
+ }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
16173
+ nodeId: string(),
16174
+ model: ManagedModelRefSchema
16175
+ }), _void(), {
16176
+ kind: "mutation",
16177
+ auth: "admin"
16178
+ }), method(object({
16179
+ nodeId: string(),
16180
+ file: string()
16181
+ }), _void(), {
16182
+ kind: "mutation",
16183
+ auth: "admin"
16184
+ }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
16185
+ kind: "mutation",
16186
+ auth: "admin"
16187
+ }), method(ProfileRefInputSchema, _void(), {
16188
+ kind: "mutation",
16189
+ auth: "admin"
16190
+ });
16191
+ var LogLevelSchema = _enum([
16192
+ "debug",
16193
+ "info",
16194
+ "warn",
16195
+ "error"
16196
+ ]);
16197
+ var LogEntrySchema = object({
16198
+ timestamp: date(),
16199
+ level: LogLevelSchema,
16200
+ scope: array(string()),
16201
+ message: string(),
16202
+ meta: record(string(), unknown()).optional(),
16203
+ tags: record(string(), string()).optional()
15963
16204
  });
15964
- method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
16205
+ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16206
+ scope: array(string()).optional(),
16207
+ level: LogLevelSchema.optional(),
16208
+ since: date().optional(),
16209
+ until: date().optional(),
16210
+ limit: number().optional(),
16211
+ tags: record(string(), string()).optional()
16212
+ }), array(LogEntrySchema).readonly());
15965
16213
  /**
15966
- * notification-outputcanonical, capability-gated notification delivery.
16214
+ * `login-method`collection cap through which auth addons contribute
16215
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
16216
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
16217
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
16218
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
16219
+ * procedure aggregates them for the unauthenticated login page.
15967
16220
  *
15968
- * Apprise-derived model (see
15969
- * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
15970
- * callers emit ONE canonical `Notification`; each provider declares a
15971
- * per-kind capability descriptor (`TargetKind`), and the pure degrade
15972
- * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
15973
- * message to what the kind supports — callers never special-case a service.
16221
+ * A contribution is a discriminated union on `kind`:
15974
16222
  *
15975
- * DESIGN DECISIONS (locked):
15976
- * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
15977
- * `setTargetEnabled`), each provider persisting via the `settings-store`
15978
- * cap. Rationale: the admin UI needs one uniform surface across the
15979
- * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
15980
- * alternative would fork the UI per addon and cannot host the
15981
- * discovery→adopt flow.
15982
- * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
15983
- * the generated cap-mount auto-`concatCollection`-fans them across every
15984
- * registered provider (notifiers addon + HA addon) so one catalog is
15985
- * routable. `send` / `testTarget` / CRUD route to ONE provider by the
15986
- * `addonId` the generated collection router extracts from the call input.
15987
- * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
15988
- * transformer) + UDS MsgPack both round-trip typed arrays — already used by
15989
- * `storage` / `storage-provider` / `recording` caps over the same path. No
15990
- * base64 fallback needed.
16223
+ * - `redirect` a declarative button. The login page renders a generic
16224
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
16225
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
16226
+ * ZERO shell-side JS. A future SSO addon plugs in the same way the
16227
+ * login page needs NO change.
15991
16228
  *
15992
- * TODO (deferred, closed-set change separate decision): add
15993
- * `providerKind: 'notify'` so notification providers surface on the unified
15994
- * admin "Integrations" page.
15995
- */
15996
- /**
15997
- * Zentik-derived typed-media enum — the superset across every kind. Each
15998
- * adapter picks what it supports and the degrade engine filters the rest.
15999
- */
16000
- var AttachmentMediaTypeSchema = _enum([
16001
- "image",
16002
- "video",
16003
- "gif",
16004
- "audio",
16005
- "icon"
16006
- ]);
16007
- /**
16008
- * A single attachment. Exactly one of `url` (remote source, most adapters
16009
- * prefer this) or `bytes` (inline source; required for Pushover-style
16010
- * bytes-only kinds) MUST be present the degrade engine expresses a
16011
- * url→bytes fetch as a `needsFetch` directive the adapter executes.
16229
+ * - `widget` a Module-Federation widget the login page mounts (via
16230
+ * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
16231
+ * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
16232
+ * mechanism kept for future use; no shipped addon uses it on the login
16233
+ * page (the passkey ceremony below runs natively in the shell instead).
16234
+ *
16235
+ * - `passkey` a declarative WebAuthn ceremony the shell renders
16236
+ * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
16237
+ * a remotely-loaded bundle). Carries the addon's effective `rpId` /
16238
+ * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
16239
+ * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
16240
+ * fetching any remote code pre-auth. Contribution stays unconditional —
16241
+ * enrollment state is never leaked pre-auth; visibility is a shell
16242
+ * decision.
16243
+ *
16244
+ * Every contribution carries a `stage`:
16245
+ * - `primary` — shown on the first credentials screen (OIDC /
16246
+ * magic-link buttons; a future usernameless passkey).
16247
+ * - `second-factor` — shown AFTER the password leg, gated on the
16248
+ * returned `factors` (passkey-as-2FA today).
16249
+ *
16250
+ * `mount: skip` — the cap is read server-side by the core auth router
16251
+ * (`registry.getCollection('login-method')`), never mounted as its own
16252
+ * tRPC router.
16012
16253
  */
16013
- var AttachmentSchema = object({
16014
- mediaType: AttachmentMediaTypeSchema,
16015
- url: string().optional(),
16016
- bytes: _instanceof(Uint8Array).optional(),
16017
- mime: string().optional(),
16018
- name: string().optional()
16019
- }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
16020
- var NotificationFormatSchema = _enum([
16021
- "text",
16022
- "markdown",
16023
- "html"
16254
+ /** When a login method renders in the two-phase login flow. */
16255
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
16256
+ /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
16257
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [
16258
+ object({
16259
+ kind: literal("redirect"),
16260
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
16261
+ id: string(),
16262
+ /** Operator-facing button label. */
16263
+ label: string(),
16264
+ /** lucide-react icon name. */
16265
+ icon: string().optional(),
16266
+ /** Addon-owned HTTP route the button navigates to (GET). */
16267
+ startUrl: string(),
16268
+ stage: LoginStageEnum
16269
+ }),
16270
+ object({
16271
+ kind: literal("widget"),
16272
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
16273
+ id: string(),
16274
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
16275
+ addonId: string(),
16276
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
16277
+ bundle: string(),
16278
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
16279
+ remote: WidgetRemoteSchema,
16280
+ stage: LoginStageEnum
16281
+ }),
16282
+ object({
16283
+ kind: literal("passkey"),
16284
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
16285
+ id: string(),
16286
+ /** Operator-facing button label. */
16287
+ label: string(),
16288
+ stage: LoginStageEnum,
16289
+ /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
16290
+ rpId: string(),
16291
+ /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
16292
+ origin: string().nullable()
16293
+ })
16024
16294
  ]);
16025
- /** A single tap-through action button. */
16026
- var NotificationActionSchema = object({
16027
- id: string(),
16028
- label: string(),
16029
- url: string().optional()
16295
+ method(_void(), array(LoginMethodContributionSchema).readonly());
16296
+ var CpuBreakdownSchema = object({
16297
+ total: number(),
16298
+ user: number(),
16299
+ system: number(),
16300
+ irq: number(),
16301
+ nice: number(),
16302
+ loadAvg: tuple([
16303
+ number(),
16304
+ number(),
16305
+ number()
16306
+ ]),
16307
+ cores: number()
16030
16308
  });
16031
- /**
16032
- * The canonical notification. `body` is the only hard field (Apprise model).
16033
- * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
16034
- * NOT a fixed severity enum — each kind declares its own `caps.levels` and
16035
- * the adapter maps this ordinal onto its native level. `level?` is an
16036
- * optional kind-native level id (`emergency`, `silent`, …) that overrides
16037
- * `priority` for that one target.
16038
- */
16039
- var NotificationSchema = object({
16040
- body: string(),
16041
- title: string().optional(),
16042
- format: NotificationFormatSchema.default("text"),
16043
- priority: number().int().min(1).max(5).default(3),
16044
- level: string().optional(),
16045
- attachments: array(AttachmentSchema).optional(),
16046
- clickUrl: string().optional(),
16047
- actions: array(NotificationActionSchema).optional(),
16048
- sound: string().optional(),
16049
- ttl: number().optional(),
16050
- tag: string().optional(),
16051
- deviceId: number().optional(),
16052
- eventId: string().optional(),
16053
- metadata: record(string(), unknown()).optional()
16309
+ var MemoryInfoSchema = object({
16310
+ percent: number(),
16311
+ totalBytes: number(),
16312
+ usedBytes: number(),
16313
+ availableBytes: number(),
16314
+ swapUsedBytes: number(),
16315
+ swapTotalBytes: number()
16054
16316
  });
16055
- /** One declared native severity/priority level for a kind. */
16056
- var TargetKindLevelSchema = object({
16057
- id: string(),
16058
- label: string(),
16059
- /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
16060
- ordinal: number().int().min(1).max(5).nullable(),
16061
- flags: object({
16062
- critical: boolean().optional(),
16063
- silent: boolean().optional(),
16064
- noPush: boolean().optional()
16065
- }).optional(),
16066
- /** e.g. Pushover `emergency` requires `retry` / `expire`. */
16067
- requires: array(string()).optional(),
16068
- description: string().optional()
16317
+ var DiskIoSnapshotSchema = object({
16318
+ readBytes: number(),
16319
+ writeBytes: number(),
16320
+ readOps: number(),
16321
+ writeOps: number(),
16322
+ timestampMs: number()
16323
+ });
16324
+ var NetworkIoSnapshotSchema = object({
16325
+ rxBytes: number(),
16326
+ txBytes: number(),
16327
+ rxPackets: number(),
16328
+ txPackets: number(),
16329
+ rxErrors: number(),
16330
+ txErrors: number(),
16331
+ timestampMs: number()
16332
+ });
16333
+ var MetricsGpuInfoSchema = object({
16334
+ utilization: number(),
16335
+ model: string(),
16336
+ memoryUsedBytes: number(),
16337
+ memoryTotalBytes: number(),
16338
+ temperature: number().nullable()
16069
16339
  });
16070
- /** The full capability block consulted before dispatch. */
16071
- var TargetKindCapsSchema = object({
16072
- attachments: object({
16073
- mediaTypes: array(AttachmentMediaTypeSchema),
16074
- mode: _enum([
16075
- "url",
16076
- "bytes",
16077
- "both"
16078
- ]),
16079
- max: number().int().nonnegative(),
16080
- maxBytes: number().int().positive().optional()
16340
+ var ProcessResourceInfoSchema = object({
16341
+ openFds: number(),
16342
+ threadCount: number(),
16343
+ activeHandles: number(),
16344
+ activeRequests: number()
16345
+ });
16346
+ var PressureAvgsSchema = object({
16347
+ avg10: number(),
16348
+ avg60: number(),
16349
+ avg300: number()
16350
+ });
16351
+ var PressureInfoSchema = object({
16352
+ some: PressureAvgsSchema,
16353
+ full: PressureAvgsSchema.nullable()
16354
+ });
16355
+ var SystemResourceSnapshotSchema = object({
16356
+ cpu: CpuBreakdownSchema,
16357
+ memory: MemoryInfoSchema,
16358
+ gpu: MetricsGpuInfoSchema.nullable(),
16359
+ network: NetworkIoSnapshotSchema,
16360
+ disk: DiskIoSnapshotSchema,
16361
+ pressure: object({
16362
+ cpu: PressureInfoSchema.nullable(),
16363
+ memory: PressureInfoSchema.nullable(),
16364
+ io: PressureInfoSchema.nullable()
16081
16365
  }),
16082
- /** Max action buttons (0 = none). */
16083
- actions: number().int().nonnegative(),
16084
- levels: array(TargetKindLevelSchema),
16085
- format: array(NotificationFormatSchema),
16086
- clickUrl: boolean(),
16087
- sound: boolean(),
16088
- ttl: boolean(),
16089
- bodyMaxLen: number().int().positive()
16366
+ process: ProcessResourceInfoSchema,
16367
+ cpuTemperature: number().nullable(),
16368
+ timestampMs: number()
16090
16369
  });
16091
- /**
16092
- * `configSchema` is a `ConfigUISchema` tree passed through to the admin
16093
- * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
16094
- * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`)
16095
- * the union is large and not meant for runtime validation here; the exported
16096
- * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
16097
- */
16098
- var ConfigSchemaPassthrough = unknown();
16099
- var TargetKindSchema = object({
16100
- kind: string(),
16101
- label: string(),
16102
- icon: string(),
16103
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
16104
- addonId: string(),
16105
- configSchema: ConfigSchemaPassthrough,
16106
- supportsDiscovery: boolean(),
16107
- caps: TargetKindCapsSchema
16370
+ var DiskSpaceInfoSchema = object({
16371
+ path: string(),
16372
+ totalBytes: number(),
16373
+ usedBytes: number(),
16374
+ availableBytes: number(),
16375
+ percent: number()
16108
16376
  });
16109
- /**
16110
- * A persisted target. `config` holds secrets; providers REDACT secret fields
16111
- * (return a presence marker only) when serving `listTargets` — never
16112
- * round-trip a stored secret to the UI.
16113
- */
16114
- var TargetSchema = object({
16115
- id: string(),
16116
- name: string(),
16117
- kind: string(),
16377
+ var PidResourceStatsSchema = object({
16378
+ pid: number(),
16379
+ cpu: number(),
16380
+ memory: number(),
16381
+ /**
16382
+ * Private (anonymous) resident bytes — the per-process V8 heap + native
16383
+ * allocations NOT shared with other processes (Linux RssAnon). This is the
16384
+ * "real" per-runner cost; summing it across runners is meaningful, unlike
16385
+ * `memory` (RSS), which double-counts the shared mmap'd framework code.
16386
+ * Undefined where /proc is unavailable (e.g. macOS).
16387
+ */
16388
+ privateBytes: number().optional(),
16389
+ /**
16390
+ * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
16391
+ * code shared copy-on-write across runners. Undefined on macOS.
16392
+ */
16393
+ sharedBytes: number().optional()
16394
+ });
16395
+ var AddonInstanceSchema = object({
16118
16396
  addonId: string(),
16119
- enabled: boolean(),
16120
- config: record(string(), unknown())
16397
+ nodeId: string(),
16398
+ role: _enum(["hub", "worker"]),
16399
+ pid: number(),
16400
+ state: _enum([
16401
+ "starting",
16402
+ "running",
16403
+ "stopping",
16404
+ "stopped",
16405
+ "crashed"
16406
+ ]),
16407
+ uptimeSec: number()
16121
16408
  });
16122
- /** A discovery-surfaced candidate (config is partial + non-secret). */
16123
- var DiscoveredTargetSchema = object({
16124
- kind: string(),
16125
- suggestedName: string(),
16126
- config: record(string(), unknown())
16409
+ var NodeProcessSchema = object({
16410
+ pid: number(),
16411
+ ppid: number(),
16412
+ pgid: number(),
16413
+ classification: _enum([
16414
+ "root",
16415
+ "managed",
16416
+ "system",
16417
+ "ghost"
16418
+ ]),
16419
+ /** `$process` addon binding when `managed`, else null. */
16420
+ addonId: string().nullable(),
16421
+ /** Kernel-reported nodeId when the process is a known agent/worker. */
16422
+ nodeId: string().nullable(),
16423
+ /** Truncated command line. */
16424
+ command: string(),
16425
+ cpuPercent: number(),
16426
+ memoryRssBytes: number(),
16427
+ /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
16428
+ uptimeSec: number(),
16429
+ /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
16430
+ orphaned: boolean()
16127
16431
  });
16128
- /** The degrade engine's report — what was resolved / dropped / degraded. */
16129
- var RenderedAsSchema = object({
16130
- level: string(),
16131
- format: NotificationFormatSchema,
16132
- attachmentsSent: number().int().nonnegative(),
16133
- actionsSent: number().int().nonnegative(),
16134
- truncated: boolean(),
16135
- dropped: array(string())
16432
+ var KillProcessInputSchema = object({
16433
+ pid: number(),
16434
+ /** Force = SIGKILL. Default is SIGTERM. */
16435
+ force: boolean().optional()
16136
16436
  });
16137
- var SendResultSchema = object({
16437
+ var KillProcessResultSchema = object({
16138
16438
  success: boolean(),
16139
- error: string().optional(),
16140
- renderedAs: RenderedAsSchema.optional()
16439
+ reason: string().optional(),
16440
+ signal: _enum(["SIGTERM", "SIGKILL"]).optional()
16441
+ });
16442
+ var DumpHeapSnapshotInputSchema = object({
16443
+ /** The addon whose runner should dump a heap snapshot. */
16444
+ addonId: string() });
16445
+ var DumpHeapSnapshotResultSchema = object({
16446
+ success: boolean(),
16447
+ /** Path of the written .heapsnapshot inside the runner's container/host. */
16448
+ path: string().optional(),
16449
+ /** Process pid that was signalled. */
16450
+ pid: number().optional(),
16451
+ reason: string().optional()
16452
+ });
16453
+ var SystemMetricsSchema = object({
16454
+ cpuPercent: number(),
16455
+ memoryPercent: number(),
16456
+ memoryUsedMB: number(),
16457
+ memoryTotalMB: number(),
16458
+ diskPercent: number().optional(),
16459
+ temperature: number().optional(),
16460
+ gpuPercent: number().optional(),
16461
+ gpuMemoryPercent: number().optional()
16462
+ });
16463
+ 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, {
16464
+ kind: "mutation",
16465
+ auth: "admin"
16466
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
16467
+ kind: "mutation",
16468
+ auth: "admin"
16469
+ });
16470
+ method(object({
16471
+ sourceUrl: string(),
16472
+ metadata: ModelConvertMetadataSchema,
16473
+ targets: array(ConvertTargetSchema).min(1).readonly(),
16474
+ calibrationRef: string().optional(),
16475
+ sessionId: string().optional()
16476
+ }), ConvertResultSchema, {
16477
+ kind: "mutation",
16478
+ auth: "admin",
16479
+ timeoutMs: 6e5
16480
+ });
16481
+ method(object({
16482
+ nodeId: string(),
16483
+ modelId: string(),
16484
+ format: _enum(MODEL_FORMATS),
16485
+ entry: ModelCatalogEntrySchema
16486
+ }), object({
16487
+ ok: boolean(),
16488
+ /** sha256 of the staged tarball (empty for a hub-local no-op). */
16489
+ sha256: string(),
16490
+ bytes: number(),
16491
+ /** The target node's modelsDir the artifact landed in. */
16492
+ path: string()
16493
+ }), {
16494
+ kind: "mutation",
16495
+ auth: "admin"
16141
16496
  });
16142
- /** Same shape as SendResult — kept as a distinct name for the test panel. */
16143
- var TestResultSchema = SendResultSchema;
16144
- method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
16145
- kind: string(),
16146
- config: record(string(), unknown()).optional()
16147
- }), array(DiscoveredTargetSchema)), method(object({
16148
- targetId: string(),
16149
- notification: NotificationSchema
16150
- }), SendResultSchema, { kind: "mutation" }), method(object({
16151
- targetId: string(),
16152
- sample: NotificationSchema.optional()
16153
- }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
16154
- targetId: string(),
16155
- enabled: boolean()
16156
- }), _void(), { kind: "mutation" });
16157
16497
  /**
16158
- * notification-rulesthe Notification Center rule surface (P1 core).
16159
- *
16160
- * Spec: `docs/superpowers/specs/2026-07-22-notification-center-requirements.md`
16161
- * (operator decisions D-1/D-2/D-3 are binding):
16498
+ * `mqtt-broker`broker-registry cap.
16162
16499
  *
16163
- * - D-2: rule EVALUATION lives in `addon-post-analysis` (the
16164
- * `notification-center` module), hooked on the durable persistence
16165
- * moments (object-event insert, TrackCloser.closeExpired) with a
16166
- * persisted outbox + retry — never the lossy telemetry bus (D8).
16167
- * - D-3: urgency belongs to the RULE. `delivery: 'immediate'` fires on the
16168
- * FIRST persisted detection matching the conditions (per-track dedup,
16169
- * `maxPerTrack` fixed at 1 — see {@link NC_MAX_PER_TRACK_IMMEDIATE});
16170
- * `delivery: 'track-end'` evaluates the finalized track record at close.
16171
- * - DISPATCH stays behind `notification-output` (rules reference targets
16172
- * by id; per-backend params are a passthrough blob capped by the
16173
- * target kind's own caps/degrade engine).
16500
+ * NOT a pub/sub proxy. The cap exposes (a) a registry of configured
16501
+ * MQTT brokers (external + optionally an embedded `aedes`-backed one)
16502
+ * and (b) the connection details a consumer addon needs to spin up
16503
+ * its OWN `mqtt.js` client.
16174
16504
  *
16175
- * P1 scope: admin-authored rules only (`createdBy` stamped from the
16176
- * server-injected caller identity the first `caller: 'required'`
16177
- * adopter). The P1 condition subset is: devices, classes(+exclude),
16178
- * minConfidence, admin zones (any/all + exclude), weekly schedule
16179
- * windows, and the optional label/identity/plate matchers. User rules,
16180
- * private zones, per-recipient fan-out and the wider condition table are
16181
- * P2+ (see spec §7).
16505
+ * Why: pub/sub routing over the system event-bus loses fidelity
16506
+ * (callback shape, QoS guarantees, will/retain semantics) and adds
16507
+ * refcount bookkeeping that addons would rather own themselves. The
16508
+ * canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
16509
+ * features anyway — give it the connection config, get out of the way.
16182
16510
  *
16183
- * All schemas here are the single source of truth — `NcRule` etc. are
16184
- * `z.infer` exports; no duplicate interfaces (the advanced-notifier
16185
- * schema/interface drift is explicitly not repeated).
16511
+ * Consumer flow:
16512
+ * const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
16513
+ * const client = mqtt.connect(cfg.url, { username: cfg.username, … })
16514
+ * client.subscribe('zigbee2mqtt/+')
16515
+ *
16516
+ * Collection mode: multiple brokers (e.g. one local mosquitto + one
16517
+ * cloud bridge). The "embedded" entry (when present) is just another
16518
+ * broker in the registry — its lifecycle is owned by the addon that
16519
+ * spawned it.
16186
16520
  */
16521
+ var BrokerKindSchema = _enum(["external", "embedded"]);
16187
16522
  /**
16188
- * D-3: the trigger/urgency of a rule — which persistence moment evaluates it.
16189
- * The value maps 1:1 onto the evaluated record kind:
16190
- * - `immediate` ↔ object-event persist (lowest-latency detection burst)
16191
- * - `track-end` ↔ TrackCloser.closeExpired (finalized track record)
16192
- * - `device-event` ↔ SensorEventStore insert (doorbell press / sensor state
16193
- * change of a LINKED device, one row per linked camera)
16194
- * - `package-event` ↔ PackageDropDetector object-event insert (a `package`
16195
- * delivery / pick-up)
16523
+ * Broker live-probe status.
16196
16524
  *
16197
- * `immediate`/`track-end` carry the D-3 urgency semantics; `device-event`/
16198
- * `package-event` are pure trigger kinds (no urgency dimension). Extending
16199
- * this one field keeps the schema additive a rule still declares exactly
16200
- * one trigger.
16525
+ * - `connected` last probe completed a clean CONNACK
16526
+ * - `disconnected` no probe has run yet (cold cache)
16527
+ * - `auth-failed` CONNACK refused with auth error (RC 4 / 5)
16528
+ * - `unreachable` — TCP connect timed out / refused
16529
+ * - `tls-error` — TLS handshake failed (cert / SNI / cipher)
16201
16530
  */
16202
- var NcDeliverySchema = _enum([
16203
- "immediate",
16204
- "track-end",
16205
- "device-event",
16206
- "package-event"
16531
+ var BrokerStatusSchema$1 = _enum([
16532
+ "connected",
16533
+ "disconnected",
16534
+ "auth-failed",
16535
+ "unreachable",
16536
+ "tls-error"
16207
16537
  ]);
16208
- /** Weekly schedule — OR of windows; absence on the rule = always active. */
16209
- var NcScheduleSchema = object({
16210
- windows: array(object({
16211
- /** Days of week the window STARTS on (0 = Sunday … 6 = Saturday). */
16212
- days: array(number().int().min(0).max(6)).min(1),
16213
- startMinute: number().int().min(0).max(1439),
16214
- endMinute: number().int().min(0).max(1439)
16215
- })).min(1),
16216
- /** IANA timezone; default = hub host timezone. */
16217
- timezone: string().optional(),
16218
- /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
16219
- invert: boolean().optional()
16220
- });
16221
- /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
16222
- var NcPlateMatcherSchema = object({
16223
- values: array(string().min(1)).min(1),
16224
- /** Max Levenshtein distance after normalization (uppercase alphanumeric). */
16225
- maxDistance: number().int().min(0).max(3).default(1)
16226
- });
16227
- /**
16228
- * Occupancy condition (DEVICE-EVENT trigger). Fires on a ZoneAnalytics
16229
- * occupancy edge for a device — optionally narrowed to a single admin
16230
- * `zoneId` and/or object `className`. `op` selects the edge/threshold:
16231
- * - `became-occupied` (default) — count crossed 0 → ≥ `count`
16232
- * - `became-free` — count crossed ≥ `count` → below it
16233
- * - `>=` / `<=` — count is at/over or at/under `count`
16234
- * `sustainSeconds` requires the condition hold continuously that long
16235
- * before firing (debounces flicker; 0 = fire on the first matching edge).
16236
- * Fail-closed: no ZoneAnalytics snapshot / missing zone / null snapshot ⇒
16237
- * the condition never matches. Confirmed edge-state survives addon restarts
16238
- * (declared SQLite collection, reseeded on boot).
16239
- */
16240
- var NcOccupancyConditionSchema = object({
16241
- /** Admin zone id to scope the count to; absent = whole-frame occupancy. */
16242
- zoneId: string().optional(),
16243
- /** Object class to count; absent = any class. */
16244
- className: string().optional(),
16245
- op: _enum([
16246
- "became-occupied",
16247
- "became-free",
16248
- ">=",
16249
- "<="
16250
- ]).default("became-occupied"),
16251
- count: number().int().min(0).default(1),
16252
- sustainSeconds: number().int().min(0).max(3600).default(15)
16253
- });
16254
- /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
16255
- var NcZoneConditionSchema = object({
16256
- ids: array(string().min(1)).min(1),
16257
- /** Quantifier over `ids` — at least one / every one visited. */
16258
- match: _enum(["any", "all"]).default("any")
16538
+ var BrokerInfoSchema = object({
16539
+ id: string(),
16540
+ name: string(),
16541
+ url: string(),
16542
+ kind: BrokerKindSchema,
16543
+ status: BrokerStatusSchema$1,
16544
+ latencyMs: number().nullable(),
16545
+ error: string().optional(),
16546
+ /** Embedded brokers only: number of MQTT clients currently connected. */
16547
+ connectedClients: number().int().nonnegative().optional(),
16548
+ /** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
16549
+ lastCheckedAt: number().optional()
16259
16550
  });
16260
16551
  /**
16261
- * The P1 condition set a flat AND of groups; absent group = pass;
16262
- * membership lists are OR within the list (spec §2.3).
16552
+ * Connection details what a consumer needs to call
16553
+ * `mqtt.connect(url, options)`. We split URL + credentials so the
16554
+ * consumer can pass them as `mqtt.connect(url, { username, password })`
16555
+ * instead of stuffing creds into the URL (which leaks them into logs).
16263
16556
  */
16264
- var NcConditionsSchema = object({
16265
- /** Device scope — absent = all devices. */
16266
- devices: array(number()).optional(),
16267
- /** Detector class names (any overlap with the record's class set). */
16268
- classes: array(string().min(1)).optional(),
16269
- /** Veto classes — any overlap fails the rule. */
16270
- classesExclude: array(string().min(1)).optional(),
16271
- /** Minimum detection confidence 0–1 (fails when the record has none). */
16272
- minConfidence: number().min(0).max(1).optional(),
16273
- /** Admin zone membership over event `zones` / track `zonesVisited`. */
16274
- zones: NcZoneConditionSchema.optional(),
16275
- /** Veto zones — any hit fails the rule. */
16276
- zonesExclude: array(string().min(1)).optional(),
16277
- /**
16278
- * Exact (case-insensitive) match on the record's collapsed `label`
16279
- * (identity name / plate text / subclass).
16280
- */
16281
- labelEquals: array(string().min(1)).optional(),
16282
- /**
16283
- * Identity matcher. P1 boundary: matched against the record's collapsed
16284
- * `label` (the identity display name propagated by the face pipeline) —
16285
- * identity-ID matching rides in P2 when identity ids reach the record.
16286
- */
16287
- identities: array(string().min(1)).optional(),
16288
- /** Fuzzy plate matcher against the record's `label` (plate text). */
16289
- plates: NcPlateMatcherSchema.optional(),
16290
- /**
16291
- * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
16292
- * Same P1 boundary: matched against the record's collapsed `label` (the
16293
- * identity display name). A record with NO label passes (nothing to
16294
- * exclude), unlike the include variant which fails on an absent label.
16295
- */
16296
- identitiesExclude: array(string().min(1)).optional(),
16297
- /**
16298
- * Minimum server-computed key-event importance in [0,1] (`Track.importance`).
16299
- * TRACK-END only: importance is scored at track close, so it does not exist
16300
- * at immediate / object-event evaluation time (see catalog `appliesTo`). At
16301
- * close the value is threaded via the close-time info (the `Track` clone is
16302
- * captured before the DB row is updated, so it would otherwise read stale).
16303
- * Fails when the record carries no importance (never guess quality — the
16304
- * `minConfidence` precedent). MVP cut: a single scalar threshold.
16305
- */
16306
- minImportance: number().min(0).max(1).optional(),
16307
- /**
16308
- * Minimum track dwell in SECONDS — `(lastSeen − firstSeen) / 1000`.
16309
- * TRACK-END only: an `immediate` / object-event subject has no closed
16310
- * lifespan, so a dwell condition never matches immediate delivery
16311
- * (documented choice — the object-event record carries no `firstSeen`,
16312
- * so dwell cannot be computed from what the subject actually carries).
16313
- */
16314
- minDwellSeconds: number().min(0).optional(),
16315
- /**
16316
- * Detection provenance filter. `any` (default / absent) matches every
16317
- * source; otherwise the subject's source must equal it. Legacy records
16318
- * with no stamped source are treated as `pipeline`. The union spans both
16319
- * record kinds — object events carry `pipeline` | `onboard`, synthetic
16320
- * tracks carry `sensor`.
16321
- */
16322
- source: _enum([
16323
- "pipeline",
16324
- "onboard",
16325
- "sensor",
16326
- "any"
16327
- ]).optional(),
16328
- /**
16329
- * Minimum identity / plate MATCH confidence in [0,1] — DISTINCT from the
16330
- * detector `minConfidence` (that gates the object-detection score; this
16331
- * gates the recognition/OCR match score). Fails when the subject carries
16332
- * no label-match confidence (never guess). TRACK-END only: the confidence
16333
- * lives on the recognition result and reaches the subject at track close.
16334
- *
16335
- * What it measures precisely (plumbed at track close — the closer threads
16336
- * the value into `NcTrackClosedInfo.labelConfidence`, the same seam as
16337
- * `importance`): the BEST recognition match confidence observed for the
16338
- * label the track carries at close — for a face, the peak cosine similarity
16339
- * of the ASSIGNED identity (`FaceMatch.score`, reset on an identity switch);
16340
- * for a plate, the peak OCR read score of the best-held plate
16341
- * (`plateText.confidence`). When BOTH a face and a plate were recognized on
16342
- * one track the higher of the two is used. A track that ended with no
16343
- * confident identity/plate match carries no value, so the condition fails
16344
- * closed for it (an un-recognized subject).
16345
- */
16346
- minLabelConfidence: number().min(0).max(1).optional(),
16347
- /**
16348
- * DEVICE-EVENT only. Raw device event-type tokens (`EventFire.eventType`,
16349
- * e.g. a doorbell `press` / `press_long`) — matched case-insensitively
16350
- * against the token carried on the device-event subject (extracted from the
16351
- * event-emitter runtime slice's `lastEvent.eventType`). Fails when the
16352
- * subject carries no token. Doorbell-pulse / passive-sensor kinds emit no
16353
- * eventType, so gate those with {@link sensorKinds} instead.
16354
- */
16355
- eventTypeTokens: array(string().min(1)).optional(),
16356
- /**
16357
- * DEVICE-EVENT only. Sensor/control taxonomy kinds (e.g. `doorbell`,
16358
- * `contact`, `button`, `device-event`) — matched against the persisted
16359
- * `SensorEvent.kind` (see `sensor-event-kinds.ts`). Membership is OR.
16360
- */
16361
- sensorKinds: array(string().min(1)).optional(),
16362
- /**
16363
- * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
16364
- * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
16365
- * when the subject's phase does not match (a subject always carries a phase
16366
- * on the package-event trigger).
16367
- */
16368
- packagePhase: _enum([
16369
- "delivered",
16370
- "picked-up",
16371
- "both"
16372
- ]).optional(),
16373
- /**
16374
- * PERSONAL-RULE custom zones (viewer-drawn). Inline normalized polygons
16375
- * (MaskShape vocabulary). A record passes when its bbox overlaps ANY
16376
- * listed polygon (ZoneEngine membership semantics). Evaluated only when
16377
- * the subject carries a bbox; absent bbox ⇒ the condition FAILS.
16378
- */
16379
- customZones: array(MaskPolygonShapeSchema).optional(),
16557
+ var BrokerConnectionDetailsSchema = object({
16558
+ url: string(),
16559
+ username: string().optional(),
16560
+ password: string().optional(),
16380
16561
  /**
16381
- * DEVICE-EVENT only. ZoneAnalytics occupancy edge fires when a device's
16382
- * (optionally zone/class-scoped) occupancy count crosses the configured
16383
- * threshold and holds for `sustainSeconds`. Fail-closed on missing
16384
- * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
16562
+ * Suggested prefix for `clientId`. Each consumer should suffix this
16563
+ * with its own discriminator (addon id, instance id) so reconnects
16564
+ * don't kick each other off (MQTT spec: clientId must be unique per
16565
+ * broker).
16385
16566
  */
16386
- occupancy: NcOccupancyConditionSchema.optional()
16567
+ clientIdPrefix: string().optional()
16568
+ });
16569
+ var AddBrokerInputSchema = object({
16570
+ name: string().min(1),
16571
+ url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
16572
+ username: string().optional(),
16573
+ password: string().optional(),
16574
+ clientIdPrefix: string().optional()
16575
+ });
16576
+ var AddBrokerResultSchema = object({ id: string() });
16577
+ var IdInputSchema = object({ id: string() });
16578
+ var TestResultSchema$1 = discriminatedUnion("ok", [object({
16579
+ ok: literal(true),
16580
+ latencyMs: number()
16581
+ }), object({
16582
+ ok: literal(false),
16583
+ error: string()
16584
+ })]);
16585
+ var StartEmbeddedInputSchema = object({
16586
+ port: number().int().min(1).max(65535).default(1883),
16587
+ /** Allow anonymous connect (no username/password). Default: false. */
16588
+ allowAnonymous: boolean().default(false),
16589
+ /** Optional shared username/password for clients. */
16590
+ username: string().optional(),
16591
+ password: string().optional()
16387
16592
  });
16388
- /** One delivery target: a `notification-output` Target ref + passthrough params. */
16389
- var NcRuleTargetSchema = object({
16390
- /** `notification-output` Target id. */
16391
- targetId: string().min(1),
16392
- /**
16393
- * Per-backend passthrough. Recognized keys are mapped onto the canonical
16394
- * Notification (`priority`, `level`, `sound`, `clickUrl`, `ttl`); the
16395
- * degrade engine drops what the backend can't render.
16396
- */
16397
- params: record(string(), unknown()).optional()
16593
+ var StartEmbeddedResultSchema = object({
16594
+ id: string(),
16595
+ url: string()
16596
+ });
16597
+ var StatusSchema = object({
16598
+ brokerCount: number(),
16599
+ embeddedRunning: boolean()
16600
+ });
16601
+ var mqttBrokerCapability = {
16602
+ name: "mqtt-broker",
16603
+ scope: "system",
16604
+ mode: "collection",
16605
+ providerKind: "broker",
16606
+ status: {
16607
+ schema: StatusSchema,
16608
+ kind: "poll"
16609
+ },
16610
+ methods: {
16611
+ listBrokers: method(_void(), array(BrokerInfoSchema)),
16612
+ getBrokerConfig: method(IdInputSchema, BrokerConnectionDetailsSchema),
16613
+ addBroker: method(AddBrokerInputSchema, AddBrokerResultSchema, { kind: "mutation" }),
16614
+ removeBroker: method(IdInputSchema, _void(), { kind: "mutation" }),
16615
+ testConnection: method(IdInputSchema, TestResultSchema$1, { kind: "mutation" }),
16616
+ startEmbeddedBroker: method(StartEmbeddedInputSchema, StartEmbeddedResultSchema, { kind: "mutation" }),
16617
+ stopEmbeddedBroker: method(IdInputSchema, _void(), { kind: "mutation" }),
16618
+ getStatus: method(_void(), StatusSchema)
16619
+ }
16620
+ };
16621
+ var NetworkEndpointSchema = object({
16622
+ url: string(),
16623
+ hostname: string(),
16624
+ port: number(),
16625
+ protocol: _enum(["http", "https"])
16626
+ });
16627
+ var NetworkAccessStatusSchema = object({
16628
+ connected: boolean(),
16629
+ endpoint: NetworkEndpointSchema.nullable(),
16630
+ error: string().optional()
16398
16631
  });
16399
16632
  /**
16400
- * Media attachment policy (P1 still-image subset).
16401
- * - `best` the best AVAILABLE subject image at dispatch time (D-3).
16402
- * - `best-matching` the media that explains WHY the rule fired: a rule
16403
- * matched on identities attaches the subject's `faceCrop`, one matched on
16404
- * plates attaches the `plateCrop`; a rule with no identity/plate condition
16405
- * (or when the specific crop is missing) degrades to `best`, then
16406
- * `keyFrame`, then no attachment — never delaying the send. The matched
16407
- * condition summary is frozen on the outbox row at enqueue (like the rule
16408
- * name), so the choice never drifts from the record that fired it.
16409
- * - `keyFrame` — the clean scene frame (no subject box).
16410
- * - `none` — no attachment.
16633
+ * Optional, richer endpoint shape returned by providers that expose
16634
+ * MORE than one ingress concurrently (Tailscale Ingress with mixed
16635
+ * serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
16636
+ * the originating provider config (mode + sourcePort) so the
16637
+ * orchestrator UI can label rows distinctly. Providers that expose only
16638
+ * one endpoint just omit `listEndpoints` from their provider impl.
16411
16639
  */
16412
- var NcMediaPolicySchema = object({ attach: _enum([
16413
- "best",
16414
- "best-matching",
16415
- "keyFrame",
16416
- "none"
16417
- ]).default("best") });
16418
- /** Throttle — cooldown survives restarts (rebuilt from the outbox on boot). */
16419
- var NcThrottleSchema = object({
16420
- cooldownSec: number().int().min(0).max(86400).default(60),
16421
- /** `rule` = one shared cooldown; `rule-device` = per-camera cooldown. */
16422
- scope: _enum(["rule", "rule-device"]).default("rule-device")
16423
- });
16424
- /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
16425
- var NcRuleInputSchema = object({
16426
- name: string().min(1).max(200),
16427
- enabled: boolean().default(true),
16428
- delivery: NcDeliverySchema,
16429
- conditions: NcConditionsSchema.default({}),
16430
- schedule: NcScheduleSchema.optional(),
16431
- targets: array(NcRuleTargetSchema).min(1),
16432
- media: NcMediaPolicySchema.default({ attach: "best" }),
16433
- throttle: NcThrottleSchema.default({
16434
- cooldownSec: 60,
16435
- scope: "rule-device"
16436
- }),
16437
- /** `{{var}}` templating over camera/class/label/zones/confidence/time. */
16438
- template: object({
16439
- title: string().max(500).optional(),
16440
- body: string().max(2e3).optional()
16441
- }).optional(),
16442
- /** Canonical notification priority ordinal (1..5); per-target overridable. */
16443
- priority: number().int().min(1).max(5).default(3),
16640
+ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
16444
16641
  /**
16445
- * Ownership/visibility key. Absent = admin/global rule (unchanged legacy
16446
- * behaviour, visible to all, read-only in the viewer). Present = personal
16447
- * rule owned by this userId. Server-stamped; never trusted from a client.
16642
+ * Stable id within the provider typically `<mode>-<sourcePort>` so
16643
+ * the orchestrator can dedupe across `listEndpoints` polls.
16448
16644
  */
16449
- ownerUserId: string().optional()
16645
+ id: string(),
16646
+ /** Operator-facing label (mirrors `MeshEndpoint.label`). */
16647
+ label: string(),
16648
+ /** Optional provider-specific mode tag, used for icon/colour in admin UI. */
16649
+ mode: string().optional(),
16650
+ /** Originating local port the ingress fronts (informational). */
16651
+ sourcePort: number().optional()
16450
16652
  });
16653
+ method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
16451
16654
  /**
16452
- * Partial patch for `updateRule` any subset of the input fields, plus the
16453
- * persisted-only {@link NcRuleSchema} `disabledTargetIds` set. The latter is
16454
- * NOT a client-authored input field (it lives on the persisted rule, not the
16455
- * input), so it is added here explicitly to let the store's per-target opt-out
16456
- * toggle round-trip through the shared `update` path. Viewer opt-out mutations
16457
- * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
16458
- * `updateRule` patch.
16655
+ * notification-outputcanonical, capability-gated notification delivery.
16656
+ *
16657
+ * Apprise-derived model (see
16658
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
16659
+ * callers emit ONE canonical `Notification`; each provider declares a
16660
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
16661
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
16662
+ * message to what the kind supports — callers never special-case a service.
16663
+ *
16664
+ * DESIGN DECISIONS (locked):
16665
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
16666
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
16667
+ * cap. Rationale: the admin UI needs one uniform surface across the
16668
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
16669
+ * alternative would fork the UI per addon and cannot host the
16670
+ * discovery→adopt flow.
16671
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
16672
+ * the generated cap-mount auto-`concatCollection`-fans them across every
16673
+ * registered provider (notifiers addon + HA addon) so one catalog is
16674
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
16675
+ * `addonId` the generated collection router extracts from the call input.
16676
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
16677
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
16678
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
16679
+ * base64 fallback needed.
16680
+ *
16681
+ * TODO (deferred, closed-set change — separate decision): add
16682
+ * `providerKind: 'notify'` so notification providers surface on the unified
16683
+ * admin "Integrations" page.
16459
16684
  */
16460
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
16461
- /** A persisted rule. */
16462
- var NcRuleSchema = NcRuleInputSchema.extend({
16685
+ /**
16686
+ * Zentik-derived typed-media enum — the superset across every kind. Each
16687
+ * adapter picks what it supports and the degrade engine filters the rest.
16688
+ */
16689
+ var AttachmentMediaTypeSchema = _enum([
16690
+ "image",
16691
+ "video",
16692
+ "gif",
16693
+ "audio",
16694
+ "icon"
16695
+ ]);
16696
+ /**
16697
+ * A single attachment. Exactly one of `url` (remote source, most adapters
16698
+ * prefer this) or `bytes` (inline source; required for Pushover-style
16699
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
16700
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
16701
+ */
16702
+ var AttachmentSchema = object({
16703
+ mediaType: AttachmentMediaTypeSchema,
16704
+ url: string().optional(),
16705
+ bytes: _instanceof(Uint8Array).optional(),
16706
+ mime: string().optional(),
16707
+ name: string().optional()
16708
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
16709
+ var NotificationFormatSchema = _enum([
16710
+ "text",
16711
+ "markdown",
16712
+ "html"
16713
+ ]);
16714
+ /** A single tap-through action button. */
16715
+ var NotificationActionSchema = object({
16463
16716
  id: string(),
16464
- /** userId of the admin who created the rule (server-stamped caller). */
16465
- createdBy: string(),
16466
- createdAt: number(),
16467
- updatedAt: number(),
16468
- /**
16469
- * Per-target opt-out set. A targetId here is suppressed for THIS rule at
16470
- * send time. Only a target's OWNER may add/remove its id (server-checked
16471
- * in `nc.setRuleTargetEnabled`). Defaults to empty.
16472
- */
16473
- disabledTargetIds: array(string()).default([])
16474
- });
16475
- var NcTestResultSchema = object({
16476
- recordId: string(),
16477
- recordKind: _enum([
16478
- "object-event",
16479
- "track",
16480
- "device-event",
16481
- "package-event"
16482
- ]),
16483
- deviceId: number(),
16484
- timestamp: number(),
16485
- wouldFire: boolean(),
16486
- /** Condition id that failed (first failing group), when `wouldFire` is false. */
16487
- failedCondition: string().optional(),
16488
- className: string().optional(),
16489
- label: string().optional()
16717
+ label: string(),
16718
+ url: string().optional()
16490
16719
  });
16491
- var NcConditionDescriptorSchema = object({
16492
- /** Field id inside `NcConditions` (or `'schedule'` for the rule-level group). */
16493
- id: string(),
16494
- group: _enum([
16495
- "scope",
16496
- "class",
16497
- "zones",
16498
- "quality",
16499
- "label",
16500
- "schedule",
16501
- "device",
16502
- "package",
16503
- "occupancy"
16504
- ]),
16720
+ /**
16721
+ * The canonical notification. `body` is the only hard field (Apprise model).
16722
+ * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
16723
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
16724
+ * the adapter maps this ordinal onto its native level. `level?` is an
16725
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
16726
+ * `priority` for that one target.
16727
+ */
16728
+ var NotificationSchema = object({
16729
+ body: string(),
16730
+ title: string().optional(),
16731
+ format: NotificationFormatSchema.default("text"),
16732
+ priority: number().int().min(1).max(5).default(3),
16733
+ level: string().optional(),
16734
+ attachments: array(AttachmentSchema).optional(),
16735
+ clickUrl: string().optional(),
16736
+ actions: array(NotificationActionSchema).optional(),
16737
+ sound: string().optional(),
16738
+ ttl: number().optional(),
16739
+ tag: string().optional(),
16740
+ deviceId: number().optional(),
16741
+ eventId: string().optional(),
16742
+ metadata: record(string(), unknown()).optional()
16743
+ });
16744
+ /** One declared native severity/priority level for a kind. */
16745
+ var TargetKindLevelSchema = object({
16746
+ id: string(),
16505
16747
  label: string(),
16506
- /** Editor widget the UI renders never hardcode per-condition forms. */
16507
- valueType: _enum([
16508
- "deviceIdList",
16509
- "stringList",
16510
- "number01",
16511
- "number",
16512
- "sourceSelect",
16513
- "zoneSelection",
16514
- "zoneIdList",
16515
- "schedule",
16516
- "plateMatcher",
16517
- "packagePhase",
16518
- "polygonDraw",
16519
- "occupancy"
16520
- ]),
16521
- operator: _enum([
16522
- "in",
16523
- "notIn",
16524
- "anyOf",
16525
- "allOf",
16526
- "gte",
16527
- "fuzzyIn",
16528
- "withinSchedule"
16529
- ]),
16530
- /** Which delivery kinds the condition applies to. */
16531
- appliesTo: array(NcDeliverySchema),
16532
- phase: string(),
16748
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
16749
+ ordinal: number().int().min(1).max(5).nullable(),
16750
+ flags: object({
16751
+ critical: boolean().optional(),
16752
+ silent: boolean().optional(),
16753
+ noPush: boolean().optional()
16754
+ }).optional(),
16755
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
16756
+ requires: array(string()).optional(),
16533
16757
  description: string().optional()
16534
16758
  });
16759
+ /** The full capability block consulted before dispatch. */
16760
+ var TargetKindCapsSchema = object({
16761
+ attachments: object({
16762
+ mediaTypes: array(AttachmentMediaTypeSchema),
16763
+ mode: _enum([
16764
+ "url",
16765
+ "bytes",
16766
+ "both"
16767
+ ]),
16768
+ max: number().int().nonnegative(),
16769
+ maxBytes: number().int().positive().optional()
16770
+ }),
16771
+ /** Max action buttons (0 = none). */
16772
+ actions: number().int().nonnegative(),
16773
+ levels: array(TargetKindLevelSchema),
16774
+ format: array(NotificationFormatSchema),
16775
+ clickUrl: boolean(),
16776
+ sound: boolean(),
16777
+ ttl: boolean(),
16778
+ bodyMaxLen: number().int().positive()
16779
+ });
16535
16780
  /**
16536
- * The delivery lifecycle status of a history row a straight read of the
16537
- * durable outbox row's own status (single source of truth):
16538
- * - `pending` — enqueued, in-flight or retrying with backoff
16539
- * - `sent` — delivered (terminal)
16540
- * - `dead` dead-lettered after exhausting retries / a permanent
16541
- * backend rejection / a deleted target (terminal; carries
16542
- * the failure `error`)
16543
- *
16544
- * P1 has no `suppressed-quiet-hours` / `snoozed` states — those ride the P2
16545
- * user dimension (quiet hours / snooze) and are additive when they land.
16781
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
16782
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
16783
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`)
16784
+ * the union is large and not meant for runtime validation here; the exported
16785
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
16546
16786
  */
16547
- var NcHistoryStatusSchema = _enum([
16548
- "pending",
16549
- "sent",
16550
- "dead"
16551
- ]);
16552
- /** The evaluated record kind a history row descends from (one per trigger). */
16553
- var NcHistoryRecordKindSchema = _enum([
16554
- "object-event",
16555
- "track-end",
16556
- "device-event",
16557
- "package-event"
16558
- ]);
16559
- /** Subject summary frozen on the row at fire time (survives rule/record edits). */
16560
- var NcHistorySubjectSchema = object({
16561
- className: string(),
16562
- label: string().optional(),
16563
- confidence: number().optional(),
16564
- zones: array(string()),
16565
- timestamp: number()
16787
+ var ConfigSchemaPassthrough = unknown();
16788
+ var TargetKindSchema = object({
16789
+ kind: string(),
16790
+ label: string(),
16791
+ icon: string(),
16792
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
16793
+ addonId: string(),
16794
+ configSchema: ConfigSchemaPassthrough,
16795
+ supportsDiscovery: boolean(),
16796
+ caps: TargetKindCapsSchema
16566
16797
  });
16567
16798
  /**
16568
- * One delivery-history row. This is a read-only VIEW over the durable
16569
- * outbox row (single source of truth the same row the drain loop drives;
16570
- * NO second write path, so history can never drift from delivery state).
16571
- * The §3.2 fields map directly: `ruleId`/`targetId`/`deviceId` are columns,
16572
- * `eventRef` is `recordKind`+`recordId`, `timestamps` are `createdAt`
16573
- * (fire) / `updatedAt` (last transition), `status` + `error` are the
16574
- * lifecycle. `ruleName` + `subject` are the intent snapshot frozen at
16575
- * enqueue. `userId?` (per-recipient history) is P2 — no user dimension in
16576
- * P1 (admin scope only).
16799
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
16800
+ * (return a presence marker only) when serving `listTargets` never
16801
+ * round-trip a stored secret to the UI.
16577
16802
  */
16578
- var NcHistoryEntrySchema = object({
16579
- /** Outbox row id — the stable dedup id `ruleId:dedupRef:targetId`. */
16803
+ var TargetSchema = object({
16580
16804
  id: string(),
16581
- ruleId: string(),
16582
- /** Rule name frozen at fire time (outlives a later rename / delete). */
16583
- ruleName: string(),
16584
- /** The rule urgency/trigger that produced this delivery. */
16585
- delivery: NcDeliverySchema,
16586
- targetId: string(),
16587
- deviceId: number(),
16588
- recordKind: NcHistoryRecordKindSchema,
16589
- /** Event / track ref of the evaluated record (§3.2 `eventRef`). */
16590
- recordId: string(),
16591
- /** Present for track-scoped deliveries (object-event / track-end). */
16592
- trackId: string().optional(),
16593
- status: NcHistoryStatusSchema,
16594
- /** Delivery attempts made so far. */
16595
- attempts: number().int(),
16596
- /** Fire time (outbox enqueue). */
16597
- createdAt: number(),
16598
- /** Last transition time (terminal for sent / dead). */
16599
- updatedAt: number(),
16600
- /** Failure detail — present on a `dead` row. */
16601
- error: string().optional(),
16602
- subject: NcHistorySubjectSchema
16805
+ name: string(),
16806
+ kind: string(),
16807
+ addonId: string(),
16808
+ enabled: boolean(),
16809
+ config: record(string(), unknown())
16603
16810
  });
16604
- /**
16605
- * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
16606
- * AND; absent = unbounded on that axis. `since`/`until` bound the fire time
16607
- * (`createdAt`, epoch ms, inclusive). `limit` is clamped to
16608
- * {@link NC_HISTORY_LIMIT_MAX}. `userId` (per-recipient filtering) is P2.
16609
- */
16610
- var NcHistoryFilterSchema = object({
16611
- ruleId: string().optional(),
16612
- deviceId: number().optional(),
16613
- status: NcHistoryStatusSchema.optional(),
16614
- since: number().optional(),
16615
- until: number().optional(),
16616
- limit: number().int().min(1).max(500).default(100)
16811
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
16812
+ var DiscoveredTargetSchema = object({
16813
+ kind: string(),
16814
+ suggestedName: string(),
16815
+ config: record(string(), unknown())
16617
16816
  });
16618
- 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 }), {
16619
- kind: "mutation",
16620
- auth: "admin",
16621
- caller: "required"
16622
- }), method(object({
16623
- ruleId: string(),
16624
- patch: NcRulePatchSchema
16625
- }), object({ rule: NcRuleSchema }), {
16626
- kind: "mutation",
16627
- auth: "admin",
16628
- caller: "required"
16629
- }), method(object({ ruleId: string() }), object({ success: literal(true) }), {
16630
- kind: "mutation",
16631
- auth: "admin"
16632
- }), method(object({
16633
- ruleId: string(),
16817
+ /** The degrade engine's report what was resolved / dropped / degraded. */
16818
+ var RenderedAsSchema = object({
16819
+ level: string(),
16820
+ format: NotificationFormatSchema,
16821
+ attachmentsSent: number().int().nonnegative(),
16822
+ actionsSent: number().int().nonnegative(),
16823
+ truncated: boolean(),
16824
+ dropped: array(string())
16825
+ });
16826
+ var SendResultSchema = object({
16827
+ success: boolean(),
16828
+ error: string().optional(),
16829
+ renderedAs: RenderedAsSchema.optional()
16830
+ });
16831
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
16832
+ var TestResultSchema = SendResultSchema;
16833
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
16834
+ kind: string(),
16835
+ config: record(string(), unknown()).optional()
16836
+ }), array(DiscoveredTargetSchema)), method(object({
16837
+ targetId: string(),
16838
+ notification: NotificationSchema
16839
+ }), SendResultSchema, { kind: "mutation" }), method(object({
16840
+ targetId: string(),
16841
+ sample: NotificationSchema.optional()
16842
+ }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
16843
+ targetId: string(),
16634
16844
  enabled: boolean()
16635
- }), object({ success: literal(true) }), {
16636
- kind: "mutation",
16637
- auth: "admin"
16638
- }), method(object({
16639
- rule: NcRuleInputSchema,
16640
- lookbackMinutes: number().int().min(1).max(1440).default(60)
16641
- }), object({ results: array(NcTestResultSchema) }), {
16642
- kind: "mutation",
16643
- auth: "admin"
16644
- }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
16845
+ }), _void(), { kind: "mutation" });
16645
16846
  /**
16646
16847
  * Zod schemas for persisted record types.
16647
16848
  *
@@ -21646,6 +21847,12 @@ Object.freeze({
21646
21847
  addonId: null,
21647
21848
  access: "delete"
21648
21849
  },
21850
+ "backup.deleteSchedule": {
21851
+ capName: "backup",
21852
+ capScope: "system",
21853
+ addonId: null,
21854
+ access: "delete"
21855
+ },
21649
21856
  "backup.getEntries": {
21650
21857
  capName: "backup",
21651
21858
  capScope: "system",
@@ -21676,6 +21883,12 @@ Object.freeze({
21676
21883
  addonId: null,
21677
21884
  access: "view"
21678
21885
  },
21886
+ "backup.listSchedules": {
21887
+ capName: "backup",
21888
+ capScope: "system",
21889
+ addonId: null,
21890
+ access: "view"
21891
+ },
21679
21892
  "backup.previewSchedule": {
21680
21893
  capName: "backup",
21681
21894
  capScope: "system",
@@ -21700,6 +21913,12 @@ Object.freeze({
21700
21913
  addonId: null,
21701
21914
  access: "create"
21702
21915
  },
21916
+ "backup.upsertSchedule": {
21917
+ capName: "backup",
21918
+ capScope: "system",
21919
+ addonId: null,
21920
+ access: "create"
21921
+ },
21703
21922
  "battery.wakeForStream": {
21704
21923
  capName: "battery",
21705
21924
  capScope: "device",
@@ -25534,6 +25753,36 @@ Object.freeze({
25534
25753
  addonId: null,
25535
25754
  access: "create"
25536
25755
  },
25756
+ "terminalSession.close": {
25757
+ capName: "terminal-session",
25758
+ capScope: "system",
25759
+ addonId: null,
25760
+ access: "create"
25761
+ },
25762
+ "terminalSession.listProfiles": {
25763
+ capName: "terminal-session",
25764
+ capScope: "system",
25765
+ addonId: null,
25766
+ access: "view"
25767
+ },
25768
+ "terminalSession.listSessions": {
25769
+ capName: "terminal-session",
25770
+ capScope: "system",
25771
+ addonId: null,
25772
+ access: "view"
25773
+ },
25774
+ "terminalSession.openSession": {
25775
+ capName: "terminal-session",
25776
+ capScope: "system",
25777
+ addonId: null,
25778
+ access: "create"
25779
+ },
25780
+ "terminalSession.resize": {
25781
+ capName: "terminal-session",
25782
+ capScope: "system",
25783
+ addonId: null,
25784
+ access: "create"
25785
+ },
25537
25786
  "toast.onToast": {
25538
25787
  capName: "toast",
25539
25788
  capScope: "system",