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