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