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