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