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