@camstack/addon-notifiers 1.2.5 → 1.2.7
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/addon.js +1644 -1395
- package/dist/addon.mjs +1644 -1395
- package/package.json +1 -1
package/dist/addon.mjs
CHANGED
|
@@ -7619,16 +7619,23 @@ var StorageLocationDeclarationSchema = object({
|
|
|
7619
7619
|
* Which node root the seeded `<id>:default` instance is placed under on a
|
|
7620
7620
|
* FRESH install:
|
|
7621
7621
|
* - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
|
|
7622
|
-
* the appData volume. Right for small/durable data (
|
|
7622
|
+
* the appData volume. Right for small/durable data (logs, models).
|
|
7623
7623
|
* - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
|
|
7624
7624
|
* env is set, else falls back to the data root. Right for bulky, hot media
|
|
7625
7625
|
* (recordings, event media) that should stay off the appData disk.
|
|
7626
|
+
* - `'backup'` — the dedicated backup volume (`CAMSTACK_BACKUP_ROOT`, default
|
|
7627
|
+
* `/backups` in the image) so archives live on their own mount rather than
|
|
7628
|
+
* filling the appData disk. Falls back to the data root when unset.
|
|
7626
7629
|
*
|
|
7627
7630
|
* Only affects the seeded default's `basePath`; operators can repoint any
|
|
7628
7631
|
* location afterwards, and a `defaultsTo` slot inherits its parent's root
|
|
7629
7632
|
* regardless of this field. Absent (the common case) is treated as `'data'`.
|
|
7630
7633
|
*/
|
|
7631
|
-
defaultRoot: _enum([
|
|
7634
|
+
defaultRoot: _enum([
|
|
7635
|
+
"data",
|
|
7636
|
+
"media",
|
|
7637
|
+
"backup"
|
|
7638
|
+
]).optional()
|
|
7632
7639
|
});
|
|
7633
7640
|
var DecoderStatsSchema = object({
|
|
7634
7641
|
inputFps: number(),
|
|
@@ -9172,401 +9179,1039 @@ function prepareNotification(caps, n) {
|
|
|
9172
9179
|
};
|
|
9173
9180
|
}
|
|
9174
9181
|
/**
|
|
9175
|
-
*
|
|
9176
|
-
*
|
|
9177
|
-
*
|
|
9178
|
-
*
|
|
9179
|
-
* caps (`battery`, `doorbell`, …) carry their domain-specific state on
|
|
9180
|
-
* their own slices.
|
|
9182
|
+
* Shared geometry vocabulary for on-frame shape caps — privacy-mask,
|
|
9183
|
+
* motion-zones, and the detection zones/lines editor all speak this one
|
|
9184
|
+
* language so a single drawing-plane editor and the providers stay
|
|
9185
|
+
* decoupled from each cap's storage.
|
|
9181
9186
|
*
|
|
9182
|
-
*
|
|
9183
|
-
*
|
|
9184
|
-
* `
|
|
9185
|
-
* `runtimeState.setCapState('device-status', …)`. Cross-process
|
|
9186
|
-
* consumers reach the same data via the `device-state` cap router
|
|
9187
|
-
* (`getCapSlice({deviceId, capName: 'device-status'})`).
|
|
9187
|
+
* All coordinates are normalized 0..1 of the camera frame (top-left
|
|
9188
|
+
* origin). Each cap composes the SUBSET of shape kinds it supports and
|
|
9189
|
+
* advertises it via `supportedShapes` in its `getOptions`.
|
|
9188
9190
|
*/
|
|
9189
|
-
|
|
9190
|
-
|
|
9191
|
-
|
|
9192
|
-
|
|
9193
|
-
* stream-health, Reolink reads firmware push events, ONVIF tracks
|
|
9194
|
-
* ping responses. This cap intentionally does NOT prescribe which
|
|
9195
|
-
* signal drives the flag.
|
|
9196
|
-
*/
|
|
9197
|
-
online: boolean(),
|
|
9198
|
-
/** Ms epoch of the last `online` transition. Lets consumers tell
|
|
9199
|
-
* apart "just came online" from "still online". */
|
|
9200
|
-
lastChangedAt: number()
|
|
9191
|
+
/** A normalized 0..1 point (top-left origin). */
|
|
9192
|
+
var MaskPointSchema = object({
|
|
9193
|
+
x: number(),
|
|
9194
|
+
y: number()
|
|
9201
9195
|
});
|
|
9202
|
-
|
|
9203
|
-
|
|
9204
|
-
|
|
9196
|
+
/** Axis-aligned rectangle (normalized 0..1). */
|
|
9197
|
+
var MaskRectShapeSchema = object({
|
|
9198
|
+
kind: literal("rect"),
|
|
9199
|
+
x: number(),
|
|
9200
|
+
y: number(),
|
|
9201
|
+
width: number(),
|
|
9202
|
+
height: number()
|
|
9203
|
+
});
|
|
9204
|
+
/** Free polygon — an ordered list of normalized vertices (≥3). */
|
|
9205
|
+
var MaskPolygonShapeSchema = object({
|
|
9206
|
+
kind: literal("polygon"),
|
|
9207
|
+
points: array(MaskPointSchema)
|
|
9208
|
+
});
|
|
9209
|
+
/** Boolean cell grid — row-major, length === gridWidth*gridHeight. */
|
|
9210
|
+
var MaskGridShapeSchema = object({
|
|
9211
|
+
kind: literal("grid"),
|
|
9212
|
+
gridWidth: number(),
|
|
9213
|
+
gridHeight: number(),
|
|
9214
|
+
cells: array(boolean())
|
|
9215
|
+
});
|
|
9216
|
+
discriminatedUnion("kind", [
|
|
9217
|
+
MaskRectShapeSchema,
|
|
9218
|
+
MaskPolygonShapeSchema,
|
|
9219
|
+
MaskGridShapeSchema,
|
|
9220
|
+
object({
|
|
9221
|
+
kind: literal("line"),
|
|
9222
|
+
points: array(MaskPointSchema)
|
|
9223
|
+
})
|
|
9224
|
+
]);
|
|
9225
|
+
/** Every shape-kind discriminant, for `supportedShapes` advertisement. */
|
|
9226
|
+
var MaskShapeKindSchema = _enum([
|
|
9227
|
+
"rect",
|
|
9228
|
+
"polygon",
|
|
9229
|
+
"grid",
|
|
9230
|
+
"line"
|
|
9231
|
+
]);
|
|
9232
|
+
/** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
|
|
9233
|
+
var MaskPolygonVerticesSchema = object({
|
|
9234
|
+
min: number(),
|
|
9235
|
+
max: number()
|
|
9236
|
+
});
|
|
9237
|
+
/** Grid dimensions when a cap supports 'grid'. */
|
|
9238
|
+
var MaskGridDimsSchema = object({
|
|
9239
|
+
width: number(),
|
|
9240
|
+
height: number()
|
|
9205
9241
|
});
|
|
9206
9242
|
/**
|
|
9207
|
-
*
|
|
9208
|
-
* truth about what a device CAN do — which the kernel uses to:
|
|
9209
|
-
* 1. Reconcile accessory children (hub-children spawn siren/floodlight/PIR
|
|
9210
|
-
* based on what the firmware actually advertises).
|
|
9211
|
-
* 2. Compute the public `features: DeviceFeature[]` array surfaced via
|
|
9212
|
-
* `device-manager.listAll`.
|
|
9213
|
-
* 3. Decide which optional caps (PTZ, intercom, doorbell, battery, …)
|
|
9214
|
-
* to register on the device's capability surface.
|
|
9243
|
+
* notification-rules — the Notification Center rule surface (P1 core).
|
|
9215
9244
|
*
|
|
9216
|
-
*
|
|
9217
|
-
*
|
|
9218
|
-
* accessory reconciliation). Consumers read via:
|
|
9219
|
-
* `runtimeState.getCapState<FeatureProbeStatus>('feature-probe')`
|
|
9245
|
+
* Spec: `docs/superpowers/specs/2026-07-22-notification-center-requirements.md`
|
|
9246
|
+
* (operator decisions D-1/D-2/D-3 are binding):
|
|
9220
9247
|
*
|
|
9221
|
-
*
|
|
9222
|
-
*
|
|
9223
|
-
*
|
|
9248
|
+
* - D-2: rule EVALUATION lives in `addon-post-analysis` (the
|
|
9249
|
+
* `notification-center` module), hooked on the durable persistence
|
|
9250
|
+
* moments (object-event insert, TrackCloser.closeExpired) with a
|
|
9251
|
+
* persisted outbox + retry — never the lossy telemetry bus (D8).
|
|
9252
|
+
* - D-3: urgency belongs to the RULE. `delivery: 'immediate'` fires on the
|
|
9253
|
+
* FIRST persisted detection matching the conditions (per-track dedup,
|
|
9254
|
+
* `maxPerTrack` fixed at 1 — see {@link NC_MAX_PER_TRACK_IMMEDIATE});
|
|
9255
|
+
* `delivery: 'track-end'` evaluates the finalized track record at close.
|
|
9256
|
+
* - DISPATCH stays behind `notification-output` (rules reference targets
|
|
9257
|
+
* by id; per-backend params are a passthrough blob capped by the
|
|
9258
|
+
* target kind's own caps/degrade engine).
|
|
9224
9259
|
*
|
|
9225
|
-
*
|
|
9226
|
-
*
|
|
9227
|
-
*
|
|
9228
|
-
*
|
|
9260
|
+
* P1 scope: admin-authored rules only (`createdBy` stamped from the
|
|
9261
|
+
* server-injected caller identity — the first `caller: 'required'`
|
|
9262
|
+
* adopter). The P1 condition subset is: devices, classes(+exclude),
|
|
9263
|
+
* minConfidence, admin zones (any/all + exclude), weekly schedule
|
|
9264
|
+
* windows, and the optional label/identity/plate matchers. User rules,
|
|
9265
|
+
* private zones, per-recipient fan-out and the wider condition table are
|
|
9266
|
+
* P2+ (see spec §7).
|
|
9267
|
+
*
|
|
9268
|
+
* All schemas here are the single source of truth — `NcRule` etc. are
|
|
9269
|
+
* `z.infer` exports; no duplicate interfaces (the advanced-notifier
|
|
9270
|
+
* schema/interface drift is explicitly not repeated).
|
|
9229
9271
|
*/
|
|
9230
|
-
|
|
9272
|
+
/**
|
|
9273
|
+
* D-3: the trigger/urgency of a rule — which persistence moment evaluates it.
|
|
9274
|
+
* The value maps 1:1 onto the evaluated record kind:
|
|
9275
|
+
* - `immediate` ↔ object-event persist (lowest-latency detection burst)
|
|
9276
|
+
* - `track-end` ↔ TrackCloser.closeExpired (finalized track record)
|
|
9277
|
+
* - `device-event` ↔ SensorEventStore insert (doorbell press / sensor state
|
|
9278
|
+
* change of a LINKED device, one row per linked camera)
|
|
9279
|
+
* - `package-event` ↔ PackageDropDetector object-event insert (a `package`
|
|
9280
|
+
* delivery / pick-up)
|
|
9281
|
+
*
|
|
9282
|
+
* `immediate`/`track-end` carry the D-3 urgency semantics; `device-event`/
|
|
9283
|
+
* `package-event` are pure trigger kinds (no urgency dimension). Extending
|
|
9284
|
+
* this one field keeps the schema additive — a rule still declares exactly
|
|
9285
|
+
* one trigger.
|
|
9286
|
+
*/
|
|
9287
|
+
var NcDeliverySchema = _enum([
|
|
9288
|
+
"immediate",
|
|
9289
|
+
"track-end",
|
|
9290
|
+
"device-event",
|
|
9291
|
+
"package-event"
|
|
9292
|
+
]);
|
|
9293
|
+
/** Weekly schedule — OR of windows; absence on the rule = always active. */
|
|
9294
|
+
var NcScheduleSchema = object({
|
|
9295
|
+
windows: array(object({
|
|
9296
|
+
/** Days of week the window STARTS on (0 = Sunday … 6 = Saturday). */
|
|
9297
|
+
days: array(number().int().min(0).max(6)).min(1),
|
|
9298
|
+
startMinute: number().int().min(0).max(1439),
|
|
9299
|
+
endMinute: number().int().min(0).max(1439)
|
|
9300
|
+
})).min(1),
|
|
9301
|
+
/** IANA timezone; default = hub host timezone. */
|
|
9302
|
+
timezone: string().optional(),
|
|
9303
|
+
/** Active OUTSIDE the windows (e.g. "only outside business hours"). */
|
|
9304
|
+
invert: boolean().optional()
|
|
9305
|
+
});
|
|
9306
|
+
/** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
|
|
9307
|
+
var NcPlateMatcherSchema = object({
|
|
9308
|
+
values: array(string().min(1)).min(1),
|
|
9309
|
+
/** Max Levenshtein distance after normalization (uppercase alphanumeric). */
|
|
9310
|
+
maxDistance: number().int().min(0).max(3).default(1)
|
|
9311
|
+
});
|
|
9312
|
+
/**
|
|
9313
|
+
* Occupancy condition (DEVICE-EVENT trigger). Fires on a ZoneAnalytics
|
|
9314
|
+
* occupancy edge for a device — optionally narrowed to a single admin
|
|
9315
|
+
* `zoneId` and/or object `className`. `op` selects the edge/threshold:
|
|
9316
|
+
* - `became-occupied` (default) — count crossed 0 → ≥ `count`
|
|
9317
|
+
* - `became-free` — count crossed ≥ `count` → below it
|
|
9318
|
+
* - `>=` / `<=` — count is at/over or at/under `count`
|
|
9319
|
+
* `sustainSeconds` requires the condition hold continuously that long
|
|
9320
|
+
* before firing (debounces flicker; 0 = fire on the first matching edge).
|
|
9321
|
+
* Fail-closed: no ZoneAnalytics snapshot / missing zone / null snapshot ⇒
|
|
9322
|
+
* the condition never matches. Confirmed edge-state survives addon restarts
|
|
9323
|
+
* (declared SQLite collection, reseeded on boot).
|
|
9324
|
+
*/
|
|
9325
|
+
var NcOccupancyConditionSchema = object({
|
|
9326
|
+
/** Admin zone id to scope the count to; absent = whole-frame occupancy. */
|
|
9327
|
+
zoneId: string().optional(),
|
|
9328
|
+
/** Object class to count; absent = any class. */
|
|
9329
|
+
className: string().optional(),
|
|
9330
|
+
op: _enum([
|
|
9331
|
+
"became-occupied",
|
|
9332
|
+
"became-free",
|
|
9333
|
+
">=",
|
|
9334
|
+
"<="
|
|
9335
|
+
]).default("became-occupied"),
|
|
9336
|
+
count: number().int().min(0).default(1),
|
|
9337
|
+
sustainSeconds: number().int().min(0).max(3600).default(15)
|
|
9338
|
+
});
|
|
9339
|
+
/** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
|
|
9340
|
+
var NcZoneConditionSchema = object({
|
|
9341
|
+
ids: array(string().min(1)).min(1),
|
|
9342
|
+
/** Quantifier over `ids` — at least one / every one visited. */
|
|
9343
|
+
match: _enum(["any", "all"]).default("any")
|
|
9344
|
+
});
|
|
9345
|
+
/**
|
|
9346
|
+
* The P1 condition set — a flat AND of groups; absent group = pass;
|
|
9347
|
+
* membership lists are OR within the list (spec §2.3).
|
|
9348
|
+
*/
|
|
9349
|
+
var NcConditionsSchema = object({
|
|
9350
|
+
/** Device scope — absent = all devices. */
|
|
9351
|
+
devices: array(number()).optional(),
|
|
9352
|
+
/** Detector class names (any overlap with the record's class set). */
|
|
9353
|
+
classes: array(string().min(1)).optional(),
|
|
9354
|
+
/** Veto classes — any overlap fails the rule. */
|
|
9355
|
+
classesExclude: array(string().min(1)).optional(),
|
|
9356
|
+
/** Minimum detection confidence 0–1 (fails when the record has none). */
|
|
9357
|
+
minConfidence: number().min(0).max(1).optional(),
|
|
9358
|
+
/** Admin zone membership over event `zones` / track `zonesVisited`. */
|
|
9359
|
+
zones: NcZoneConditionSchema.optional(),
|
|
9360
|
+
/** Veto zones — any hit fails the rule. */
|
|
9361
|
+
zonesExclude: array(string().min(1)).optional(),
|
|
9231
9362
|
/**
|
|
9232
|
-
*
|
|
9233
|
-
*
|
|
9234
|
-
* `hasPtz`, `hasIntercom`, `hasDoorbell`, `hasFloodlight`, `hasSiren`,
|
|
9235
|
-
* `hasPirSensor`, `hasAutotrack`, `hasBattery`. Hikvision keys:
|
|
9236
|
-
* `hasSupplementalLight`, `lightHasWhiteLight`, `hasAlarmIo`, `hasPtz`.
|
|
9363
|
+
* Exact (case-insensitive) match on the record's collapsed `label`
|
|
9364
|
+
* (identity name / plate text / subclass).
|
|
9237
9365
|
*/
|
|
9238
|
-
|
|
9366
|
+
labelEquals: array(string().min(1)).optional(),
|
|
9239
9367
|
/**
|
|
9240
|
-
*
|
|
9241
|
-
*
|
|
9242
|
-
*
|
|
9368
|
+
* Identity matcher. P1 boundary: matched against the record's collapsed
|
|
9369
|
+
* `label` (the identity display name propagated by the face pipeline) —
|
|
9370
|
+
* identity-ID matching rides in P2 when identity ids reach the record.
|
|
9243
9371
|
*/
|
|
9244
|
-
|
|
9245
|
-
/**
|
|
9246
|
-
|
|
9247
|
-
/** Channel count for NVR/Hub devices; `1` for standalone cameras; `null` pre-probe. */
|
|
9248
|
-
channelCount: number().nullable(),
|
|
9372
|
+
identities: array(string().min(1)).optional(),
|
|
9373
|
+
/** Fuzzy plate matcher against the record's `label` (plate text). */
|
|
9374
|
+
plates: NcPlateMatcherSchema.optional(),
|
|
9249
9375
|
/**
|
|
9250
|
-
*
|
|
9251
|
-
*
|
|
9252
|
-
*
|
|
9253
|
-
*
|
|
9376
|
+
* Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
|
|
9377
|
+
* Same P1 boundary: matched against the record's collapsed `label` (the
|
|
9378
|
+
* identity display name). A record with NO label passes (nothing to
|
|
9379
|
+
* exclude), unlike the include variant which fails on an absent label.
|
|
9254
9380
|
*/
|
|
9255
|
-
|
|
9381
|
+
identitiesExclude: array(string().min(1)).optional(),
|
|
9256
9382
|
/**
|
|
9257
|
-
*
|
|
9258
|
-
*
|
|
9259
|
-
*
|
|
9260
|
-
|
|
9261
|
-
|
|
9262
|
-
|
|
9263
|
-
|
|
9264
|
-
|
|
9265
|
-
|
|
9383
|
+
* Minimum server-computed key-event importance in [0,1] (`Track.importance`).
|
|
9384
|
+
* TRACK-END only: importance is scored at track close, so it does not exist
|
|
9385
|
+
* at immediate / object-event evaluation time (see catalog `appliesTo`). At
|
|
9386
|
+
* close the value is threaded via the close-time info (the `Track` clone is
|
|
9387
|
+
* captured before the DB row is updated, so it would otherwise read stale).
|
|
9388
|
+
* Fails when the record carries no importance (never guess quality — the
|
|
9389
|
+
* `minConfidence` precedent). MVP cut: a single scalar threshold.
|
|
9390
|
+
*/
|
|
9391
|
+
minImportance: number().min(0).max(1).optional(),
|
|
9392
|
+
/**
|
|
9393
|
+
* Minimum track dwell in SECONDS — `(lastSeen − firstSeen) / 1000`.
|
|
9394
|
+
* TRACK-END only: an `immediate` / object-event subject has no closed
|
|
9395
|
+
* lifespan, so a dwell condition never matches immediate delivery
|
|
9396
|
+
* (documented choice — the object-event record carries no `firstSeen`,
|
|
9397
|
+
* so dwell cannot be computed from what the subject actually carries).
|
|
9398
|
+
*/
|
|
9399
|
+
minDwellSeconds: number().min(0).optional(),
|
|
9400
|
+
/**
|
|
9401
|
+
* Detection provenance filter. `any` (default / absent) matches every
|
|
9402
|
+
* source; otherwise the subject's source must equal it. Legacy records
|
|
9403
|
+
* with no stamped source are treated as `pipeline`. The union spans both
|
|
9404
|
+
* record kinds — object events carry `pipeline` | `onboard`, synthetic
|
|
9405
|
+
* tracks carry `sensor`.
|
|
9406
|
+
*/
|
|
9407
|
+
source: _enum([
|
|
9408
|
+
"pipeline",
|
|
9409
|
+
"onboard",
|
|
9410
|
+
"sensor",
|
|
9411
|
+
"any"
|
|
9412
|
+
]).optional(),
|
|
9413
|
+
/**
|
|
9414
|
+
* Minimum identity / plate MATCH confidence in [0,1] — DISTINCT from the
|
|
9415
|
+
* detector `minConfidence` (that gates the object-detection score; this
|
|
9416
|
+
* gates the recognition/OCR match score). Fails when the subject carries
|
|
9417
|
+
* no label-match confidence (never guess). TRACK-END only: the confidence
|
|
9418
|
+
* lives on the recognition result and reaches the subject at track close.
|
|
9419
|
+
*
|
|
9420
|
+
* What it measures precisely (plumbed at track close — the closer threads
|
|
9421
|
+
* the value into `NcTrackClosedInfo.labelConfidence`, the same seam as
|
|
9422
|
+
* `importance`): the BEST recognition match confidence observed for the
|
|
9423
|
+
* label the track carries at close — for a face, the peak cosine similarity
|
|
9424
|
+
* of the ASSIGNED identity (`FaceMatch.score`, reset on an identity switch);
|
|
9425
|
+
* for a plate, the peak OCR read score of the best-held plate
|
|
9426
|
+
* (`plateText.confidence`). When BOTH a face and a plate were recognized on
|
|
9427
|
+
* one track the higher of the two is used. A track that ended with no
|
|
9428
|
+
* confident identity/plate match carries no value, so the condition fails
|
|
9429
|
+
* closed for it (an un-recognized subject).
|
|
9430
|
+
*/
|
|
9431
|
+
minLabelConfidence: number().min(0).max(1).optional(),
|
|
9432
|
+
/**
|
|
9433
|
+
* DEVICE-EVENT only. Raw device event-type tokens (`EventFire.eventType`,
|
|
9434
|
+
* e.g. a doorbell `press` / `press_long`) — matched case-insensitively
|
|
9435
|
+
* against the token carried on the device-event subject (extracted from the
|
|
9436
|
+
* event-emitter runtime slice's `lastEvent.eventType`). Fails when the
|
|
9437
|
+
* subject carries no token. Doorbell-pulse / passive-sensor kinds emit no
|
|
9438
|
+
* eventType, so gate those with {@link sensorKinds} instead.
|
|
9439
|
+
*/
|
|
9440
|
+
eventTypeTokens: array(string().min(1)).optional(),
|
|
9441
|
+
/**
|
|
9442
|
+
* DEVICE-EVENT only. Sensor/control taxonomy kinds (e.g. `doorbell`,
|
|
9443
|
+
* `contact`, `button`, `device-event`) — matched against the persisted
|
|
9444
|
+
* `SensorEvent.kind` (see `sensor-event-kinds.ts`). Membership is OR.
|
|
9445
|
+
*/
|
|
9446
|
+
sensorKinds: array(string().min(1)).optional(),
|
|
9447
|
+
/**
|
|
9448
|
+
* PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
|
|
9449
|
+
* (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
|
|
9450
|
+
* when the subject's phase does not match (a subject always carries a phase
|
|
9451
|
+
* on the package-event trigger).
|
|
9452
|
+
*/
|
|
9453
|
+
packagePhase: _enum([
|
|
9454
|
+
"delivered",
|
|
9455
|
+
"picked-up",
|
|
9456
|
+
"both"
|
|
9457
|
+
]).optional(),
|
|
9458
|
+
/**
|
|
9459
|
+
* PERSONAL-RULE custom zones (viewer-drawn). Inline normalized polygons
|
|
9460
|
+
* (MaskShape vocabulary). A record passes when its bbox overlaps ANY
|
|
9461
|
+
* listed polygon (ZoneEngine membership semantics). Evaluated only when
|
|
9462
|
+
* the subject carries a bbox; absent bbox ⇒ the condition FAILS.
|
|
9463
|
+
*/
|
|
9464
|
+
customZones: array(MaskPolygonShapeSchema).optional(),
|
|
9465
|
+
/**
|
|
9466
|
+
* DEVICE-EVENT only. ZoneAnalytics occupancy edge — fires when a device's
|
|
9467
|
+
* (optionally zone/class-scoped) occupancy count crosses the configured
|
|
9468
|
+
* threshold and holds for `sustainSeconds`. Fail-closed on missing
|
|
9469
|
+
* substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
|
|
9470
|
+
*/
|
|
9471
|
+
occupancy: NcOccupancyConditionSchema.optional()
|
|
9266
9472
|
});
|
|
9267
|
-
|
|
9268
|
-
|
|
9269
|
-
|
|
9270
|
-
|
|
9271
|
-
|
|
9272
|
-
|
|
9273
|
-
|
|
9274
|
-
|
|
9275
|
-
|
|
9276
|
-
|
|
9277
|
-
aqi: number().optional(),
|
|
9278
|
-
/** Ms epoch when the slice was last updated. */
|
|
9279
|
-
lastFetchedAt: number(),
|
|
9280
|
-
/** Live display unit of the single metric this slice carries (e.g. HA
|
|
9281
|
-
* `attributes.unit_of_measurement` → 'ppm' / 'ppb' / 'µg/m³'). Each
|
|
9282
|
-
* upstream `sensor.*` entity surfaces ONE device_class, so one unit
|
|
9283
|
-
* per slice is unambiguous. */
|
|
9284
|
-
unit: string().optional(),
|
|
9285
|
-
/** Suggested decimal places for numeric display.
|
|
9286
|
-
* Populated live from the upstream source when provided (e.g. HA
|
|
9287
|
-
* `attributes.suggested_display_precision`). Falls back to
|
|
9288
|
-
* auto-formatting when absent. */
|
|
9289
|
-
precision: number().int().min(0).max(10).optional()
|
|
9473
|
+
/** One delivery target: a `notification-output` Target ref + passthrough params. */
|
|
9474
|
+
var NcRuleTargetSchema = object({
|
|
9475
|
+
/** `notification-output` Target id. */
|
|
9476
|
+
targetId: string().min(1),
|
|
9477
|
+
/**
|
|
9478
|
+
* Per-backend passthrough. Recognized keys are mapped onto the canonical
|
|
9479
|
+
* Notification (`priority`, `level`, `sound`, `clickUrl`, `ttl`); the
|
|
9480
|
+
* degrade engine drops what the backend can't render.
|
|
9481
|
+
*/
|
|
9482
|
+
params: record(string(), unknown()).optional()
|
|
9290
9483
|
});
|
|
9291
|
-
DeviceType.Sensor;
|
|
9292
9484
|
/**
|
|
9293
|
-
*
|
|
9294
|
-
* `
|
|
9295
|
-
*
|
|
9296
|
-
*
|
|
9297
|
-
*
|
|
9298
|
-
*
|
|
9299
|
-
*
|
|
9300
|
-
*
|
|
9301
|
-
*
|
|
9302
|
-
* `
|
|
9303
|
-
*
|
|
9304
|
-
*
|
|
9305
|
-
* `availableModes` mirrors HA's `supported_features`-derived arm
|
|
9306
|
-
* mode list — the UI renders only the buttons the panel accepts.
|
|
9485
|
+
* Media attachment policy (P1 still-image subset).
|
|
9486
|
+
* - `best` — the best AVAILABLE subject image at dispatch time (D-3).
|
|
9487
|
+
* - `best-matching` — the media that explains WHY the rule fired: a rule
|
|
9488
|
+
* matched on identities attaches the subject's `faceCrop`, one matched on
|
|
9489
|
+
* plates attaches the `plateCrop`; a rule with no identity/plate condition
|
|
9490
|
+
* (or when the specific crop is missing) degrades to `best`, then
|
|
9491
|
+
* `keyFrame`, then no attachment — never delaying the send. The matched
|
|
9492
|
+
* condition summary is frozen on the outbox row at enqueue (like the rule
|
|
9493
|
+
* name), so the choice never drifts from the record that fired it.
|
|
9494
|
+
* - `keyFrame` — the clean scene frame (no subject box).
|
|
9495
|
+
* - `none` — no attachment.
|
|
9307
9496
|
*/
|
|
9308
|
-
var
|
|
9309
|
-
"
|
|
9310
|
-
"
|
|
9311
|
-
"
|
|
9312
|
-
"
|
|
9313
|
-
|
|
9314
|
-
|
|
9315
|
-
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
"
|
|
9319
|
-
]);
|
|
9320
|
-
var AlarmArmModeSchema = _enum([
|
|
9321
|
-
"home",
|
|
9322
|
-
"away",
|
|
9323
|
-
"night",
|
|
9324
|
-
"vacation",
|
|
9325
|
-
"custom_bypass"
|
|
9326
|
-
]);
|
|
9327
|
-
object({
|
|
9328
|
-
/** Current lifecycle state. */
|
|
9329
|
-
state: AlarmStateSchema,
|
|
9330
|
-
/** Subset of arm modes the panel accepts. UI renders one button per
|
|
9331
|
-
* mode in this list. */
|
|
9332
|
-
availableModes: array(AlarmArmModeSchema),
|
|
9333
|
-
/** Whether the panel requires a PIN on arm / disarm. Mirrors
|
|
9334
|
-
* `DeviceFeature.AlarmPinRequired` for slice consumers. */
|
|
9335
|
-
requiresCode: boolean(),
|
|
9336
|
-
/** Ms epoch when the slice was last updated. */
|
|
9337
|
-
lastChangedAt: number()
|
|
9338
|
-
});
|
|
9339
|
-
DeviceType.AlarmPanel, method(object({
|
|
9340
|
-
deviceId: number().int().nonnegative(),
|
|
9341
|
-
mode: AlarmArmModeSchema,
|
|
9342
|
-
/** Optional PIN code. Required when `requiresCode === true`.
|
|
9343
|
-
* Passed through to the upstream service; never persisted. */
|
|
9344
|
-
code: string().min(1).optional()
|
|
9345
|
-
}), _void(), {
|
|
9346
|
-
kind: "mutation",
|
|
9347
|
-
auth: "admin"
|
|
9348
|
-
}), method(object({
|
|
9349
|
-
deviceId: number().int().nonnegative(),
|
|
9350
|
-
code: string().min(1).optional()
|
|
9351
|
-
}), _void(), {
|
|
9352
|
-
kind: "mutation",
|
|
9353
|
-
auth: "admin"
|
|
9354
|
-
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
9355
|
-
kind: "mutation",
|
|
9356
|
-
auth: "admin"
|
|
9497
|
+
var NcMediaPolicySchema = object({ attach: _enum([
|
|
9498
|
+
"best",
|
|
9499
|
+
"best-matching",
|
|
9500
|
+
"keyFrame",
|
|
9501
|
+
"none"
|
|
9502
|
+
]).default("best") });
|
|
9503
|
+
/** Throttle — cooldown survives restarts (rebuilt from the outbox on boot). */
|
|
9504
|
+
var NcThrottleSchema = object({
|
|
9505
|
+
cooldownSec: number().int().min(0).max(86400).default(60),
|
|
9506
|
+
/** `rule` = one shared cooldown; `rule-device` = per-camera cooldown. */
|
|
9507
|
+
scope: _enum(["rule", "rule-device"]).default("rule-device")
|
|
9357
9508
|
});
|
|
9358
|
-
|
|
9359
|
-
|
|
9360
|
-
|
|
9361
|
-
|
|
9362
|
-
|
|
9363
|
-
|
|
9364
|
-
|
|
9365
|
-
|
|
9366
|
-
|
|
9367
|
-
|
|
9368
|
-
|
|
9369
|
-
|
|
9370
|
-
|
|
9371
|
-
|
|
9509
|
+
/** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
|
|
9510
|
+
var NcRuleInputSchema = object({
|
|
9511
|
+
name: string().min(1).max(200),
|
|
9512
|
+
enabled: boolean().default(true),
|
|
9513
|
+
delivery: NcDeliverySchema,
|
|
9514
|
+
conditions: NcConditionsSchema.default({}),
|
|
9515
|
+
schedule: NcScheduleSchema.optional(),
|
|
9516
|
+
targets: array(NcRuleTargetSchema).min(1),
|
|
9517
|
+
media: NcMediaPolicySchema.default({ attach: "best" }),
|
|
9518
|
+
throttle: NcThrottleSchema.default({
|
|
9519
|
+
cooldownSec: 60,
|
|
9520
|
+
scope: "rule-device"
|
|
9521
|
+
}),
|
|
9522
|
+
/** `{{var}}` templating over camera/class/label/zones/confidence/time. */
|
|
9523
|
+
template: object({
|
|
9524
|
+
title: string().max(500).optional(),
|
|
9525
|
+
body: string().max(2e3).optional()
|
|
9526
|
+
}).optional(),
|
|
9527
|
+
/** Canonical notification priority ordinal (1..5); per-target overridable. */
|
|
9528
|
+
priority: number().int().min(1).max(5).default(3),
|
|
9529
|
+
/**
|
|
9530
|
+
* Ownership/visibility key. Absent = admin/global rule (unchanged legacy
|
|
9531
|
+
* behaviour, visible to all, read-only in the viewer). Present = personal
|
|
9532
|
+
* rule owned by this userId. Server-stamped; never trusted from a client.
|
|
9533
|
+
*/
|
|
9534
|
+
ownerUserId: string().optional()
|
|
9372
9535
|
});
|
|
9373
|
-
DeviceType.Sensor;
|
|
9374
9536
|
/**
|
|
9375
|
-
*
|
|
9376
|
-
|
|
9377
|
-
|
|
9378
|
-
|
|
9379
|
-
|
|
9380
|
-
|
|
9381
|
-
|
|
9382
|
-
|
|
9383
|
-
|
|
9384
|
-
|
|
9537
|
+
* Partial patch for `updateRule` — any subset of the input fields, plus the
|
|
9538
|
+
* persisted-only {@link NcRuleSchema} `disabledTargetIds` set. The latter is
|
|
9539
|
+
* NOT a client-authored input field (it lives on the persisted rule, not the
|
|
9540
|
+
* input), so it is added here explicitly to let the store's per-target opt-out
|
|
9541
|
+
* toggle round-trip through the shared `update` path. Viewer opt-out mutations
|
|
9542
|
+
* still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
|
|
9543
|
+
* `updateRule` patch.
|
|
9544
|
+
*/
|
|
9545
|
+
var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
|
|
9546
|
+
/** A persisted rule. */
|
|
9547
|
+
var NcRuleSchema = NcRuleInputSchema.extend({
|
|
9548
|
+
id: string(),
|
|
9549
|
+
/** userId of the admin who created the rule (server-stamped caller). */
|
|
9550
|
+
createdBy: string(),
|
|
9551
|
+
createdAt: number(),
|
|
9552
|
+
updatedAt: number(),
|
|
9553
|
+
/**
|
|
9554
|
+
* Per-target opt-out set. A targetId here is suppressed for THIS rule at
|
|
9555
|
+
* send time. Only a target's OWNER may add/remove its id (server-checked
|
|
9556
|
+
* in `nc.setRuleTargetEnabled`). Defaults to empty.
|
|
9557
|
+
*/
|
|
9558
|
+
disabledTargetIds: array(string()).default([])
|
|
9559
|
+
});
|
|
9560
|
+
var NcTestResultSchema = object({
|
|
9561
|
+
recordId: string(),
|
|
9562
|
+
recordKind: _enum([
|
|
9563
|
+
"object-event",
|
|
9564
|
+
"track",
|
|
9565
|
+
"device-event",
|
|
9566
|
+
"package-event"
|
|
9567
|
+
]),
|
|
9568
|
+
deviceId: number(),
|
|
9569
|
+
timestamp: number(),
|
|
9570
|
+
wouldFire: boolean(),
|
|
9571
|
+
/** Condition id that failed (first failing group), when `wouldFire` is false. */
|
|
9572
|
+
failedCondition: string().optional(),
|
|
9573
|
+
className: string().optional(),
|
|
9574
|
+
label: string().optional()
|
|
9575
|
+
});
|
|
9576
|
+
var NcConditionDescriptorSchema = object({
|
|
9577
|
+
/** Field id inside `NcConditions` (or `'schedule'` for the rule-level group). */
|
|
9578
|
+
id: string(),
|
|
9579
|
+
group: _enum([
|
|
9580
|
+
"scope",
|
|
9581
|
+
"class",
|
|
9582
|
+
"zones",
|
|
9583
|
+
"quality",
|
|
9584
|
+
"label",
|
|
9585
|
+
"schedule",
|
|
9586
|
+
"device",
|
|
9587
|
+
"package",
|
|
9588
|
+
"occupancy"
|
|
9589
|
+
]),
|
|
9590
|
+
label: string(),
|
|
9591
|
+
/** Editor widget the UI renders — never hardcode per-condition forms. */
|
|
9592
|
+
valueType: _enum([
|
|
9593
|
+
"deviceIdList",
|
|
9594
|
+
"stringList",
|
|
9595
|
+
"number01",
|
|
9596
|
+
"number",
|
|
9597
|
+
"sourceSelect",
|
|
9598
|
+
"zoneSelection",
|
|
9599
|
+
"zoneIdList",
|
|
9600
|
+
"schedule",
|
|
9601
|
+
"plateMatcher",
|
|
9602
|
+
"packagePhase",
|
|
9603
|
+
"polygonDraw",
|
|
9604
|
+
"occupancy"
|
|
9605
|
+
]),
|
|
9606
|
+
operator: _enum([
|
|
9607
|
+
"in",
|
|
9608
|
+
"notIn",
|
|
9609
|
+
"anyOf",
|
|
9610
|
+
"allOf",
|
|
9611
|
+
"gte",
|
|
9612
|
+
"fuzzyIn",
|
|
9613
|
+
"withinSchedule"
|
|
9614
|
+
]),
|
|
9615
|
+
/** Which delivery kinds the condition applies to. */
|
|
9616
|
+
appliesTo: array(NcDeliverySchema),
|
|
9617
|
+
phase: string(),
|
|
9618
|
+
description: string().optional()
|
|
9385
9619
|
});
|
|
9386
9620
|
/**
|
|
9387
|
-
*
|
|
9388
|
-
*
|
|
9389
|
-
*
|
|
9390
|
-
*
|
|
9391
|
-
*
|
|
9392
|
-
*
|
|
9621
|
+
* The delivery lifecycle status of a history row — a straight read of the
|
|
9622
|
+
* durable outbox row's own status (single source of truth):
|
|
9623
|
+
* - `pending` — enqueued, in-flight or retrying with backoff
|
|
9624
|
+
* - `sent` — delivered (terminal)
|
|
9625
|
+
* - `dead` — dead-lettered after exhausting retries / a permanent
|
|
9626
|
+
* backend rejection / a deleted target (terminal; carries
|
|
9627
|
+
* the failure `error`)
|
|
9393
9628
|
*
|
|
9394
|
-
*
|
|
9395
|
-
* (
|
|
9396
|
-
* and the level history shifts forward.
|
|
9629
|
+
* P1 has no `suppressed-quiet-hours` / `snoozed` states — those ride the P2
|
|
9630
|
+
* user dimension (quiet hours / snooze) and are additive when they land.
|
|
9397
9631
|
*/
|
|
9398
|
-
var
|
|
9399
|
-
|
|
9400
|
-
|
|
9401
|
-
|
|
9402
|
-
|
|
9403
|
-
|
|
9404
|
-
|
|
9405
|
-
|
|
9406
|
-
|
|
9407
|
-
|
|
9408
|
-
|
|
9409
|
-
|
|
9410
|
-
|
|
9411
|
-
|
|
9412
|
-
|
|
9413
|
-
|
|
9414
|
-
|
|
9415
|
-
|
|
9416
|
-
|
|
9417
|
-
}).nullable(),
|
|
9418
|
-
/** Per-class summary across the rolling window — keys are
|
|
9419
|
-
* `macroClass` strings (e.g. `dog_bark`, `speech`, `glass_break`). */
|
|
9420
|
-
byClass: array(AudioClassSummarySchema).readonly()
|
|
9632
|
+
var NcHistoryStatusSchema = _enum([
|
|
9633
|
+
"pending",
|
|
9634
|
+
"sent",
|
|
9635
|
+
"dead"
|
|
9636
|
+
]);
|
|
9637
|
+
/** The evaluated record kind a history row descends from (one per trigger). */
|
|
9638
|
+
var NcHistoryRecordKindSchema = _enum([
|
|
9639
|
+
"object-event",
|
|
9640
|
+
"track-end",
|
|
9641
|
+
"device-event",
|
|
9642
|
+
"package-event"
|
|
9643
|
+
]);
|
|
9644
|
+
/** Subject summary frozen on the row at fire time (survives rule/record edits). */
|
|
9645
|
+
var NcHistorySubjectSchema = object({
|
|
9646
|
+
className: string(),
|
|
9647
|
+
label: string().optional(),
|
|
9648
|
+
confidence: number().optional(),
|
|
9649
|
+
zones: array(string()),
|
|
9650
|
+
timestamp: number()
|
|
9421
9651
|
});
|
|
9422
9652
|
/**
|
|
9423
|
-
*
|
|
9424
|
-
*
|
|
9425
|
-
*
|
|
9426
|
-
*
|
|
9427
|
-
*
|
|
9653
|
+
* One delivery-history row. This is a read-only VIEW over the durable
|
|
9654
|
+
* outbox row (single source of truth — the same row the drain loop drives;
|
|
9655
|
+
* NO second write path, so history can never drift from delivery state).
|
|
9656
|
+
* The §3.2 fields map directly: `ruleId`/`targetId`/`deviceId` are columns,
|
|
9657
|
+
* `eventRef` is `recordKind`+`recordId`, `timestamps` are `createdAt`
|
|
9658
|
+
* (fire) / `updatedAt` (last transition), `status` + `error` are the
|
|
9659
|
+
* lifecycle. `ruleName` + `subject` are the intent snapshot frozen at
|
|
9660
|
+
* enqueue. `userId?` (per-recipient history) is P2 — no user dimension in
|
|
9661
|
+
* P1 (admin scope only).
|
|
9428
9662
|
*/
|
|
9429
|
-
var
|
|
9430
|
-
|
|
9431
|
-
|
|
9432
|
-
|
|
9433
|
-
|
|
9434
|
-
|
|
9435
|
-
|
|
9436
|
-
|
|
9437
|
-
|
|
9438
|
-
peakDbfs: number(),
|
|
9439
|
-
/** Rolling-window mean dBFS at sample time. */
|
|
9440
|
-
avgDbfs: number(),
|
|
9441
|
-
/** Dominant above-threshold class at sample time, or null on silence. */
|
|
9442
|
-
topClass: string().nullable(),
|
|
9443
|
-
/** Score of the dominant class (`null` whenever `topClass` is null). */
|
|
9444
|
-
topScore: number().min(0).max(1).nullable()
|
|
9445
|
-
})).readonly(),
|
|
9446
|
-
/** Actual ms between adjacent samples after any subsampling. */
|
|
9447
|
-
effectiveSampleEveryMs: number().int().positive(),
|
|
9448
|
-
/** Wall-clock window covered by `points` (`points[N-1].ts - points[0].ts`),
|
|
9449
|
-
* or `0` when there's fewer than 2 samples. */
|
|
9450
|
-
windowMsActual: number().int().nonnegative()
|
|
9451
|
-
});
|
|
9452
|
-
DeviceType.Camera, method(object({ deviceId: number() }), AudioMetricsSnapshotSchema.nullable()), method(object({
|
|
9663
|
+
var NcHistoryEntrySchema = object({
|
|
9664
|
+
/** Outbox row id — the stable dedup id `ruleId:dedupRef:targetId`. */
|
|
9665
|
+
id: string(),
|
|
9666
|
+
ruleId: string(),
|
|
9667
|
+
/** Rule name frozen at fire time (outlives a later rename / delete). */
|
|
9668
|
+
ruleName: string(),
|
|
9669
|
+
/** The rule urgency/trigger that produced this delivery. */
|
|
9670
|
+
delivery: NcDeliverySchema,
|
|
9671
|
+
targetId: string(),
|
|
9453
9672
|
deviceId: number(),
|
|
9454
|
-
|
|
9455
|
-
|
|
9456
|
-
|
|
9457
|
-
/**
|
|
9458
|
-
|
|
9459
|
-
|
|
9460
|
-
|
|
9461
|
-
|
|
9462
|
-
|
|
9463
|
-
|
|
9464
|
-
/**
|
|
9465
|
-
|
|
9466
|
-
|
|
9467
|
-
|
|
9468
|
-
|
|
9469
|
-
/** Ms epoch of the last successful run. 0 when never run. */
|
|
9470
|
-
lastTriggeredAt: number(),
|
|
9471
|
-
/** Failure description from the last completed run. Null on success
|
|
9472
|
-
* or when never run. */
|
|
9473
|
-
lastError: string().nullable(),
|
|
9474
|
-
/** Ms epoch when the slice was last updated. */
|
|
9475
|
-
lastChangedAt: number()
|
|
9673
|
+
recordKind: NcHistoryRecordKindSchema,
|
|
9674
|
+
/** Event / track ref of the evaluated record (§3.2 `eventRef`). */
|
|
9675
|
+
recordId: string(),
|
|
9676
|
+
/** Present for track-scoped deliveries (object-event / track-end). */
|
|
9677
|
+
trackId: string().optional(),
|
|
9678
|
+
status: NcHistoryStatusSchema,
|
|
9679
|
+
/** Delivery attempts made so far. */
|
|
9680
|
+
attempts: number().int(),
|
|
9681
|
+
/** Fire time (outbox enqueue). */
|
|
9682
|
+
createdAt: number(),
|
|
9683
|
+
/** Last transition time (terminal for sent / dead). */
|
|
9684
|
+
updatedAt: number(),
|
|
9685
|
+
/** Failure detail — present on a `dead` row. */
|
|
9686
|
+
error: string().optional(),
|
|
9687
|
+
subject: NcHistorySubjectSchema
|
|
9476
9688
|
});
|
|
9477
|
-
|
|
9478
|
-
|
|
9479
|
-
|
|
9480
|
-
|
|
9689
|
+
/**
|
|
9690
|
+
* Query filter for `getHistory` (spec §4.2). Every field is a narrowing
|
|
9691
|
+
* AND; absent = unbounded on that axis. `since`/`until` bound the fire time
|
|
9692
|
+
* (`createdAt`, epoch ms, inclusive). `limit` is clamped to
|
|
9693
|
+
* {@link NC_HISTORY_LIMIT_MAX}. `userId` (per-recipient filtering) is P2.
|
|
9694
|
+
*/
|
|
9695
|
+
var NcHistoryFilterSchema = object({
|
|
9696
|
+
ruleId: string().optional(),
|
|
9697
|
+
deviceId: number().optional(),
|
|
9698
|
+
status: NcHistoryStatusSchema.optional(),
|
|
9699
|
+
since: number().optional(),
|
|
9700
|
+
until: number().optional(),
|
|
9701
|
+
limit: number().int().min(1).max(500).default(100)
|
|
9702
|
+
});
|
|
9703
|
+
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 }), {
|
|
9481
9704
|
kind: "mutation",
|
|
9482
|
-
auth: "admin"
|
|
9705
|
+
auth: "admin",
|
|
9706
|
+
caller: "required"
|
|
9483
9707
|
}), method(object({
|
|
9484
|
-
|
|
9485
|
-
|
|
9486
|
-
|
|
9487
|
-
|
|
9488
|
-
|
|
9489
|
-
|
|
9708
|
+
ruleId: string(),
|
|
9709
|
+
patch: NcRulePatchSchema
|
|
9710
|
+
}), object({ rule: NcRuleSchema }), {
|
|
9711
|
+
kind: "mutation",
|
|
9712
|
+
auth: "admin",
|
|
9713
|
+
caller: "required"
|
|
9714
|
+
}), method(object({ ruleId: string() }), object({ success: literal(true) }), {
|
|
9715
|
+
kind: "mutation",
|
|
9716
|
+
auth: "admin"
|
|
9717
|
+
}), method(object({
|
|
9718
|
+
ruleId: string(),
|
|
9719
|
+
enabled: boolean()
|
|
9720
|
+
}), object({ success: literal(true) }), {
|
|
9721
|
+
kind: "mutation",
|
|
9722
|
+
auth: "admin"
|
|
9723
|
+
}), method(object({
|
|
9724
|
+
rule: NcRuleInputSchema,
|
|
9725
|
+
lookbackMinutes: number().int().min(1).max(1440).default(60)
|
|
9726
|
+
}), object({ results: array(NcTestResultSchema) }), {
|
|
9490
9727
|
kind: "mutation",
|
|
9491
9728
|
auth: "admin"
|
|
9729
|
+
}), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
|
|
9730
|
+
/**
|
|
9731
|
+
* TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
|
|
9732
|
+
*
|
|
9733
|
+
* Spec: `docs/superpowers/specs/2026-07-24-nc-occupancy-timelapse-design.md`
|
|
9734
|
+
* §3.2/§3.3.
|
|
9735
|
+
*
|
|
9736
|
+
* Deliberately NOT a capability definition and NOT an `NcRule`:
|
|
9737
|
+
* - Every `NcDelivery` member is a *persisted-pipeline-record* trigger. A
|
|
9738
|
+
* timelapse fires on a SCHEDULE WINDOW BOUNDARY, evaluates no pipeline
|
|
9739
|
+
* record, and produces a video it assembled itself — so it rides no
|
|
9740
|
+
* delivery-enum member (the enum is frozen) and no cap method. This file is
|
|
9741
|
+
* a plain typed schema; it does NOT go through `npm run codegen`.
|
|
9742
|
+
* - It shares only the delivery leg (`notification-output.send`) and the
|
|
9743
|
+
* persistence/ownership patterns with the Notification Center, reusing
|
|
9744
|
+
* {@link NcScheduleSchema} (weekly windows, midnight-crossing, invertible)
|
|
9745
|
+
* and {@link NcRuleTargetSchema} (target ref + passthrough params).
|
|
9746
|
+
*
|
|
9747
|
+
* Ownership is SERVER-DERIVED. `ownerUserId` / `createdBy` / `createdAt` /
|
|
9748
|
+
* `updatedAt` / `id` / `lastGeneratedAt` live on the PERSISTED rule only —
|
|
9749
|
+
* {@link TimelapseRuleInputSchema} and {@link TimelapseRulePatchSchema} do not
|
|
9750
|
+
* carry them, so a forged client payload can never claim or re-own a rule
|
|
9751
|
+
* (Zod strips unknown keys). The store stamps them from the resolved caller.
|
|
9752
|
+
*/
|
|
9753
|
+
/** `{{var}}` templating over camera/rule/time — same vocabulary as `NcRule`. */
|
|
9754
|
+
var TimelapseTemplateSchema = object({
|
|
9755
|
+
title: string().max(500).optional(),
|
|
9756
|
+
body: string().max(2e3).optional()
|
|
9757
|
+
});
|
|
9758
|
+
var NameField = string().min(1).max(200);
|
|
9759
|
+
var DeviceIdsField = array(number()).min(1);
|
|
9760
|
+
var CadenceSecField = number().int().min(2).max(3600);
|
|
9761
|
+
var FramerateField = number().int().min(1).max(60);
|
|
9762
|
+
var TargetsField = array(NcRuleTargetSchema).min(1);
|
|
9763
|
+
var PriorityField = number().int().min(1).max(5);
|
|
9764
|
+
/**
|
|
9765
|
+
* Client-supplied timelapse-rule fields. The server stamps id / createdBy /
|
|
9766
|
+
* createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
|
|
9767
|
+
* here (see the ownership note above).
|
|
9768
|
+
*/
|
|
9769
|
+
var TimelapseRuleInputSchema = object({
|
|
9770
|
+
name: NameField,
|
|
9771
|
+
enabled: boolean().default(true),
|
|
9772
|
+
/** Cameras sampled by this rule — one scratch dir + one artifact per device. */
|
|
9773
|
+
deviceIds: DeviceIdsField,
|
|
9774
|
+
/**
|
|
9775
|
+
* Activation window(s). REQUIRED (unlike `NcRule`, where an absent schedule
|
|
9776
|
+
* means "always active"): a timelapse is defined by its window boundaries —
|
|
9777
|
+
* open clears the scratch, close assembles and delivers.
|
|
9778
|
+
*/
|
|
9779
|
+
schedule: NcScheduleSchema,
|
|
9780
|
+
/** Force-snapshot cadence inside the window, seconds (predecessor parity). */
|
|
9781
|
+
cadenceSec: CadenceSecField.default(15),
|
|
9782
|
+
/** Output frames per second of the assembled mp4 (predecessor parity). */
|
|
9783
|
+
framerate: FramerateField.default(10),
|
|
9784
|
+
/** `notification-output` targets the finished video/thumbnail is sent to. */
|
|
9785
|
+
targets: TargetsField,
|
|
9786
|
+
template: TimelapseTemplateSchema.optional(),
|
|
9787
|
+
/** Canonical notification priority ordinal (1..5); per-target overridable. */
|
|
9788
|
+
priority: PriorityField.default(3)
|
|
9789
|
+
});
|
|
9790
|
+
object({
|
|
9791
|
+
name: NameField.optional(),
|
|
9792
|
+
enabled: boolean().optional(),
|
|
9793
|
+
deviceIds: DeviceIdsField.optional(),
|
|
9794
|
+
schedule: NcScheduleSchema.optional(),
|
|
9795
|
+
cadenceSec: CadenceSecField.optional(),
|
|
9796
|
+
framerate: FramerateField.optional(),
|
|
9797
|
+
targets: TargetsField.optional(),
|
|
9798
|
+
template: TimelapseTemplateSchema.nullable().optional(),
|
|
9799
|
+
priority: PriorityField.optional()
|
|
9800
|
+
});
|
|
9801
|
+
TimelapseRuleInputSchema.extend({
|
|
9802
|
+
id: string(),
|
|
9803
|
+
/**
|
|
9804
|
+
* Ownership/visibility key. Absent = admin/global rule (visible to all).
|
|
9805
|
+
* Present = personal rule owned by this userId. Server-stamped from the
|
|
9806
|
+
* resolved caller; never trusted from a client payload.
|
|
9807
|
+
*/
|
|
9808
|
+
ownerUserId: string().optional(),
|
|
9809
|
+
/**
|
|
9810
|
+
* Epoch-ms of the last successful generation — the 1-hour re-generation
|
|
9811
|
+
* guard's durable state (predecessor parity). Absent = never generated.
|
|
9812
|
+
*/
|
|
9813
|
+
lastGeneratedAt: number().optional(),
|
|
9814
|
+
/** userId of the caller who created the rule (server-stamped). */
|
|
9815
|
+
createdBy: string(),
|
|
9816
|
+
createdAt: number(),
|
|
9817
|
+
updatedAt: number()
|
|
9492
9818
|
});
|
|
9493
9819
|
/**
|
|
9494
|
-
*
|
|
9495
|
-
*
|
|
9496
|
-
*
|
|
9497
|
-
*
|
|
9498
|
-
*
|
|
9820
|
+
* Generic device-level status snapshot. Auto-registered by `BaseDevice`
|
|
9821
|
+
* for every device, regardless of provider — the kernel needs a uniform
|
|
9822
|
+
* cap-keyed slice for the basic device flags every consumer expects to
|
|
9823
|
+
* read across processes (the `online` flag in particular). Driver-specific
|
|
9824
|
+
* caps (`battery`, `doorbell`, …) carry their domain-specific state on
|
|
9825
|
+
* their own slices.
|
|
9826
|
+
*
|
|
9827
|
+
* Pattern is identical to `battery`: schema-bearing `runtimeState`,
|
|
9828
|
+
* empty `methods`, single change event. Reads land at
|
|
9829
|
+
* `runtimeState.getCapState('device-status')`; writes at
|
|
9830
|
+
* `runtimeState.setCapState('device-status', …)`. Cross-process
|
|
9831
|
+
* consumers reach the same data via the `device-state` cap router
|
|
9832
|
+
* (`getCapSlice({deviceId, capName: 'device-status'})`).
|
|
9499
9833
|
*/
|
|
9500
|
-
var
|
|
9501
|
-
/** 0..100 inclusive. Firmware-reported. */
|
|
9502
|
-
percentage: number().min(0).max(100),
|
|
9834
|
+
var DeviceStatusSchema = object({
|
|
9503
9835
|
/**
|
|
9504
|
-
*
|
|
9505
|
-
*
|
|
9506
|
-
*
|
|
9507
|
-
*
|
|
9836
|
+
* Device-level liveness. Drivers flip via `markOnline(boolean)` on
|
|
9837
|
+
* `BaseDevice`. Provider semantics vary — RTSP aggregates broker
|
|
9838
|
+
* stream-health, Reolink reads firmware push events, ONVIF tracks
|
|
9839
|
+
* ping responses. This cap intentionally does NOT prescribe which
|
|
9840
|
+
* signal drives the flag.
|
|
9508
9841
|
*/
|
|
9509
|
-
|
|
9510
|
-
|
|
9511
|
-
|
|
9512
|
-
|
|
9513
|
-
|
|
9842
|
+
online: boolean(),
|
|
9843
|
+
/** Ms epoch of the last `online` transition. Lets consumers tell
|
|
9844
|
+
* apart "just came online" from "still online". */
|
|
9845
|
+
lastChangedAt: number()
|
|
9846
|
+
});
|
|
9847
|
+
object({
|
|
9848
|
+
deviceId: number(),
|
|
9849
|
+
status: DeviceStatusSchema
|
|
9850
|
+
});
|
|
9851
|
+
/**
|
|
9852
|
+
* Per-device feature/identity probe slice. Holds the runtime-resolved
|
|
9853
|
+
* truth about what a device CAN do — which the kernel uses to:
|
|
9854
|
+
* 1. Reconcile accessory children (hub-children spawn siren/floodlight/PIR
|
|
9855
|
+
* based on what the firmware actually advertises).
|
|
9856
|
+
* 2. Compute the public `features: DeviceFeature[]` array surfaced via
|
|
9857
|
+
* `device-manager.listAll`.
|
|
9858
|
+
* 3. Decide which optional caps (PTZ, intercom, doorbell, battery, …)
|
|
9859
|
+
* to register on the device's capability surface.
|
|
9860
|
+
*
|
|
9861
|
+
* Auto-registered by `BaseDevice` for every device. Drivers populate the
|
|
9862
|
+
* slice from `onProbe()` (kernel calls it once after register, before
|
|
9863
|
+
* accessory reconciliation). Consumers read via:
|
|
9864
|
+
* `runtimeState.getCapState<FeatureProbeStatus>('feature-probe')`
|
|
9865
|
+
*
|
|
9866
|
+
* `flags` is an open record so each driver carries its own keys without
|
|
9867
|
+
* a centralized schema bottleneck — Reolink writes `hasPtz/hasIntercom`,
|
|
9868
|
+
* Hikvision writes `hasSupplementalLight/hasAlarmIo`, etc.
|
|
9869
|
+
*
|
|
9870
|
+
* Replaces the older driver-local `deviceCache.has*` blob: the per-device
|
|
9871
|
+
* config is for operator-edited overrides + UI snapshots; runtime probe
|
|
9872
|
+
* results belong in runtime-state where the kernel handles persistence,
|
|
9873
|
+
* cross-process mirroring, and reactive updates.
|
|
9874
|
+
*/
|
|
9875
|
+
var FeatureProbeStatusSchema = object({
|
|
9514
9876
|
/**
|
|
9515
|
-
*
|
|
9516
|
-
*
|
|
9517
|
-
*
|
|
9877
|
+
* Driver-specific flag bag. Each driver picks its own key names — the
|
|
9878
|
+
* cap deliberately does NOT enforce a closed enum here. Reolink keys:
|
|
9879
|
+
* `hasPtz`, `hasIntercom`, `hasDoorbell`, `hasFloodlight`, `hasSiren`,
|
|
9880
|
+
* `hasPirSensor`, `hasAutotrack`, `hasBattery`. Hikvision keys:
|
|
9881
|
+
* `hasSupplementalLight`, `lightHasWhiteLight`, `hasAlarmIo`, `hasPtz`.
|
|
9518
9882
|
*/
|
|
9519
|
-
|
|
9520
|
-
/** Ms epoch of the last observation. Lets consumers reason about freshness. */
|
|
9521
|
-
lastUpdated: number(),
|
|
9883
|
+
flags: record(string(), unknown()),
|
|
9522
9884
|
/**
|
|
9523
|
-
*
|
|
9524
|
-
*
|
|
9525
|
-
*
|
|
9526
|
-
* sub-threshold = low). UI MUST render "Normal"/"Low" instead of a
|
|
9527
|
-
* misleading exact percentage. Absent/false → genuine 0–100 % reading.
|
|
9885
|
+
* Coarse driver-classification — lets cross-process consumers tell apart
|
|
9886
|
+
* cameras / battery-cams / NVRs without re-running the probe. `null`
|
|
9887
|
+
* before the first probe completes.
|
|
9528
9888
|
*/
|
|
9529
|
-
|
|
9889
|
+
deviceType: string().nullable(),
|
|
9890
|
+
/** Camera/firmware model string. `null` when the firmware doesn't expose it. */
|
|
9891
|
+
model: string().nullable(),
|
|
9892
|
+
/** Channel count for NVR/Hub devices; `1` for standalone cameras; `null` pre-probe. */
|
|
9893
|
+
channelCount: number().nullable(),
|
|
9894
|
+
/**
|
|
9895
|
+
* Ms epoch of the last SUCCESSFUL probe. `0` before the first probe
|
|
9896
|
+
* completes — drivers' `getAccessoryChildren()` should treat zero as
|
|
9897
|
+
* "probe not done yet, return empty" so accessories aren't spawned
|
|
9898
|
+
* before the firmware is queried.
|
|
9899
|
+
*/
|
|
9900
|
+
lastProbedAt: number(),
|
|
9901
|
+
/**
|
|
9902
|
+
* Framework convention: every runtime-state slice carries this for the
|
|
9903
|
+
* createRuntimeStateBridge stale-check helper. We keep it in sync with
|
|
9904
|
+
* `lastProbedAt` on every write.
|
|
9905
|
+
*/
|
|
9906
|
+
lastFetchedAt: number()
|
|
9530
9907
|
});
|
|
9531
|
-
|
|
9532
|
-
deviceId: number(),
|
|
9533
|
-
/** Bound on the wait. Sensible range 3000–10000ms. */
|
|
9534
|
-
timeoutMs: number().int().min(500).max(3e4).default(8e3)
|
|
9535
|
-
}), object({
|
|
9536
|
-
awoke: boolean(),
|
|
9537
|
-
durationMs: number()
|
|
9538
|
-
}), { kind: "mutation" }), object({
|
|
9908
|
+
object({
|
|
9539
9909
|
deviceId: number(),
|
|
9540
|
-
status:
|
|
9910
|
+
status: FeatureProbeStatusSchema
|
|
9541
9911
|
});
|
|
9542
9912
|
object({
|
|
9543
|
-
|
|
9544
|
-
|
|
9545
|
-
|
|
9913
|
+
/** Carbon dioxide concentration in ppm. */
|
|
9914
|
+
co2Ppm: number().min(0).optional(),
|
|
9915
|
+
/** Total volatile organic compounds in ppb. */
|
|
9916
|
+
vocPpb: number().min(0).optional(),
|
|
9917
|
+
/** Particulate matter ≤ 2.5 μm in µg/m³. */
|
|
9918
|
+
pm25: number().min(0).optional(),
|
|
9919
|
+
/** Particulate matter ≤ 10 μm in µg/m³. */
|
|
9920
|
+
pm10: number().min(0).optional(),
|
|
9921
|
+
/** Composite AQI value (typically 0..500). */
|
|
9922
|
+
aqi: number().optional(),
|
|
9923
|
+
/** Ms epoch when the slice was last updated. */
|
|
9924
|
+
lastFetchedAt: number(),
|
|
9925
|
+
/** Live display unit of the single metric this slice carries (e.g. HA
|
|
9926
|
+
* `attributes.unit_of_measurement` → 'ppm' / 'ppb' / 'µg/m³'). Each
|
|
9927
|
+
* upstream `sensor.*` entity surfaces ONE device_class, so one unit
|
|
9928
|
+
* per slice is unambiguous. */
|
|
9929
|
+
unit: string().optional(),
|
|
9930
|
+
/** Suggested decimal places for numeric display.
|
|
9931
|
+
* Populated live from the upstream source when provided (e.g. HA
|
|
9932
|
+
* `attributes.suggested_display_precision`). Falls back to
|
|
9933
|
+
* auto-formatting when absent. */
|
|
9934
|
+
precision: number().int().min(0).max(10).optional()
|
|
9546
9935
|
});
|
|
9547
9936
|
DeviceType.Sensor;
|
|
9937
|
+
/**
|
|
9938
|
+
* Alarm-panel cap. Models HA `alarm_control_panel.*` on
|
|
9939
|
+
* `DeviceType.AlarmPanel`. State follows HA's canonical lifecycle
|
|
9940
|
+
* across disarmed / armed_(home|away|night|vacation|custom_bypass) /
|
|
9941
|
+
* arming / pending / triggered / disarming.
|
|
9942
|
+
*
|
|
9943
|
+
* Many panels require a PIN code on arm / disarm — the optional
|
|
9944
|
+
* `code` field on the methods passes it through to the upstream
|
|
9945
|
+
* service; it's NEVER persisted in the runtime slice or any event
|
|
9946
|
+
* payload. The presence of a required code is signalled by
|
|
9947
|
+
* `DeviceFeature.AlarmPinRequired` so the UI gates a code-entry
|
|
9948
|
+
* field without a slice fetch.
|
|
9949
|
+
*
|
|
9950
|
+
* `availableModes` mirrors HA's `supported_features`-derived arm
|
|
9951
|
+
* mode list — the UI renders only the buttons the panel accepts.
|
|
9952
|
+
*/
|
|
9953
|
+
var AlarmStateSchema = _enum([
|
|
9954
|
+
"disarmed",
|
|
9955
|
+
"armed_home",
|
|
9956
|
+
"armed_away",
|
|
9957
|
+
"armed_night",
|
|
9958
|
+
"armed_vacation",
|
|
9959
|
+
"armed_custom_bypass",
|
|
9960
|
+
"arming",
|
|
9961
|
+
"disarming",
|
|
9962
|
+
"pending",
|
|
9963
|
+
"triggered"
|
|
9964
|
+
]);
|
|
9965
|
+
var AlarmArmModeSchema = _enum([
|
|
9966
|
+
"home",
|
|
9967
|
+
"away",
|
|
9968
|
+
"night",
|
|
9969
|
+
"vacation",
|
|
9970
|
+
"custom_bypass"
|
|
9971
|
+
]);
|
|
9548
9972
|
object({
|
|
9549
|
-
/** Current
|
|
9550
|
-
|
|
9551
|
-
/**
|
|
9973
|
+
/** Current lifecycle state. */
|
|
9974
|
+
state: AlarmStateSchema,
|
|
9975
|
+
/** Subset of arm modes the panel accepts. UI renders one button per
|
|
9976
|
+
* mode in this list. */
|
|
9977
|
+
availableModes: array(AlarmArmModeSchema),
|
|
9978
|
+
/** Whether the panel requires a PIN on arm / disarm. Mirrors
|
|
9979
|
+
* `DeviceFeature.AlarmPinRequired` for slice consumers. */
|
|
9980
|
+
requiresCode: boolean(),
|
|
9981
|
+
/** Ms epoch when the slice was last updated. */
|
|
9552
9982
|
lastChangedAt: number()
|
|
9553
9983
|
});
|
|
9554
|
-
DeviceType.
|
|
9984
|
+
DeviceType.AlarmPanel, method(object({
|
|
9555
9985
|
deviceId: number().int().nonnegative(),
|
|
9556
|
-
|
|
9986
|
+
mode: AlarmArmModeSchema,
|
|
9987
|
+
/** Optional PIN code. Required when `requiresCode === true`.
|
|
9988
|
+
* Passed through to the upstream service; never persisted. */
|
|
9989
|
+
code: string().min(1).optional()
|
|
9557
9990
|
}), _void(), {
|
|
9558
9991
|
kind: "mutation",
|
|
9559
9992
|
auth: "admin"
|
|
9560
|
-
}), object({
|
|
9561
|
-
deviceId: number(),
|
|
9562
|
-
|
|
9563
|
-
|
|
9564
|
-
|
|
9565
|
-
|
|
9566
|
-
|
|
9567
|
-
"
|
|
9568
|
-
"
|
|
9569
|
-
|
|
9993
|
+
}), method(object({
|
|
9994
|
+
deviceId: number().int().nonnegative(),
|
|
9995
|
+
code: string().min(1).optional()
|
|
9996
|
+
}), _void(), {
|
|
9997
|
+
kind: "mutation",
|
|
9998
|
+
auth: "admin"
|
|
9999
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
10000
|
+
kind: "mutation",
|
|
10001
|
+
auth: "admin"
|
|
10002
|
+
});
|
|
10003
|
+
object({
|
|
10004
|
+
/** Current illuminance in lux (lx). */
|
|
10005
|
+
lux: number().min(0),
|
|
10006
|
+
/** Ms epoch when the slice was last updated. */
|
|
10007
|
+
lastFetchedAt: number(),
|
|
10008
|
+
/** Live display unit from the upstream source (e.g. HA
|
|
10009
|
+
* `attributes.unit_of_measurement`). The UI prefers this over the
|
|
10010
|
+
* role's canonical unit. Absent → fall back to the canonical unit. */
|
|
10011
|
+
unit: string().optional(),
|
|
10012
|
+
/** Suggested decimal places for numeric display.
|
|
10013
|
+
* Populated live from the upstream source when provided (e.g. HA
|
|
10014
|
+
* `attributes.suggested_display_precision`). Falls back to
|
|
10015
|
+
* auto-formatting when absent. */
|
|
10016
|
+
precision: number().int().min(0).max(10).optional()
|
|
10017
|
+
});
|
|
10018
|
+
DeviceType.Sensor;
|
|
10019
|
+
/**
|
|
10020
|
+
* Per-class audio metrics aggregated over a sliding window.
|
|
10021
|
+
*/
|
|
10022
|
+
var AudioClassSummarySchema = object({
|
|
10023
|
+
className: string(),
|
|
10024
|
+
/** Number of windows (chunks) where this class was the top hit. */
|
|
10025
|
+
hits: number().int().nonnegative(),
|
|
10026
|
+
/** Mean score across those hits, clamped to [0,1]. */
|
|
10027
|
+
avgScore: number().min(0).max(1),
|
|
10028
|
+
/** Peak score in the window. */
|
|
10029
|
+
peakScore: number().min(0).max(1)
|
|
10030
|
+
});
|
|
10031
|
+
/**
|
|
10032
|
+
* Per-camera audio metrics snapshot — emitted by the analytics frame
|
|
10033
|
+
* handler on every `pipeline.audio-inference-result` event and
|
|
10034
|
+
* mirrored into the `audio-metrics` device-state slice. Symmetric
|
|
10035
|
+
* with `zone-analytics` snapshots for video — every consumer
|
|
10036
|
+
* (admin UI panel, automations, alert rules) reads via the
|
|
10037
|
+
* canonical `device.state.audioMetrics.value` reactive handle.
|
|
10038
|
+
*
|
|
10039
|
+
* Aggregates are computed over a rolling `windowSec` window
|
|
10040
|
+
* (default 60s). Past that window, classes drop out of `byClass`
|
|
10041
|
+
* and the level history shifts forward.
|
|
10042
|
+
*/
|
|
10043
|
+
var AudioMetricsSnapshotSchema = object({
|
|
10044
|
+
/** Wall-clock timestamp (ms) of the most recent audio window. */
|
|
10045
|
+
ts: number().int(),
|
|
10046
|
+
/** Sliding-window length (seconds) used for aggregation. */
|
|
10047
|
+
windowSec: number().int().positive(),
|
|
10048
|
+
/** Latest level reading from the most recent window. */
|
|
10049
|
+
level: object({
|
|
10050
|
+
rms: number(),
|
|
10051
|
+
dbfs: number()
|
|
10052
|
+
}),
|
|
10053
|
+
/** Peak dBFS observed across the rolling window. */
|
|
10054
|
+
peakDbfs: number(),
|
|
10055
|
+
/** Mean dBFS across the rolling window. */
|
|
10056
|
+
avgDbfs: number(),
|
|
10057
|
+
/** Most recent above-threshold classification, or null on silence. */
|
|
10058
|
+
current: object({
|
|
10059
|
+
className: string(),
|
|
10060
|
+
score: number().min(0).max(1),
|
|
10061
|
+
timestamp: number().int()
|
|
10062
|
+
}).nullable(),
|
|
10063
|
+
/** Per-class summary across the rolling window — keys are
|
|
10064
|
+
* `macroClass` strings (e.g. `dog_bark`, `speech`, `glass_break`). */
|
|
10065
|
+
byClass: array(AudioClassSummarySchema).readonly()
|
|
10066
|
+
});
|
|
10067
|
+
/**
|
|
10068
|
+
* Audio-metrics history payload — a series of `AudioMetricsHistoryPoint`
|
|
10069
|
+
* samples capped at `maxPoints` (default 1024). When the requested
|
|
10070
|
+
* `windowSec / sampleEveryMs` would exceed the cap, the provider
|
|
10071
|
+
* subsamples by bucketed averaging and reports the effective sample
|
|
10072
|
+
* spacing on `effectiveSampleEveryMs` so the UI can label the x-axis.
|
|
10073
|
+
*/
|
|
10074
|
+
var AudioMetricsHistorySchema = object({
|
|
10075
|
+
points: array(object({
|
|
10076
|
+
/** Wall-clock ms when this sample was recorded. */
|
|
10077
|
+
ts: number().int(),
|
|
10078
|
+
/** Instantaneous dBFS level at sample time. `null` for windows where
|
|
10079
|
+
* the source had no level reading (rare; happens at decode startup). */
|
|
10080
|
+
dbfs: number().nullable(),
|
|
10081
|
+
/** Rolling-window peak dBFS at sample time. Same window the live
|
|
10082
|
+
* snapshot reports. */
|
|
10083
|
+
peakDbfs: number(),
|
|
10084
|
+
/** Rolling-window mean dBFS at sample time. */
|
|
10085
|
+
avgDbfs: number(),
|
|
10086
|
+
/** Dominant above-threshold class at sample time, or null on silence. */
|
|
10087
|
+
topClass: string().nullable(),
|
|
10088
|
+
/** Score of the dominant class (`null` whenever `topClass` is null). */
|
|
10089
|
+
topScore: number().min(0).max(1).nullable()
|
|
10090
|
+
})).readonly(),
|
|
10091
|
+
/** Actual ms between adjacent samples after any subsampling. */
|
|
10092
|
+
effectiveSampleEveryMs: number().int().positive(),
|
|
10093
|
+
/** Wall-clock window covered by `points` (`points[N-1].ts - points[0].ts`),
|
|
10094
|
+
* or `0` when there's fewer than 2 samples. */
|
|
10095
|
+
windowMsActual: number().int().nonnegative()
|
|
10096
|
+
});
|
|
10097
|
+
DeviceType.Camera, method(object({ deviceId: number() }), AudioMetricsSnapshotSchema.nullable()), method(object({
|
|
10098
|
+
deviceId: number(),
|
|
10099
|
+
/** History window in seconds. Default 300 (5 minutes).
|
|
10100
|
+
* Provider clamps to its retention cap if larger. */
|
|
10101
|
+
windowSec: number().int().positive().optional(),
|
|
10102
|
+
/** Target sample interval in ms. Default 1000 (1 sample/second).
|
|
10103
|
+
* Provider clamps to natural sample rate if smaller, and
|
|
10104
|
+
* bucket-averages when bigger than the requested window
|
|
10105
|
+
* would produce more than `maxPoints` samples. */
|
|
10106
|
+
sampleEveryMs: number().int().positive().optional()
|
|
10107
|
+
}), AudioMetricsHistorySchema);
|
|
10108
|
+
object({
|
|
10109
|
+
/** Whether the automation is currently enabled. Disabled automations
|
|
10110
|
+
* ignore their trigger block — manual `trigger` still works. */
|
|
10111
|
+
enabled: boolean(),
|
|
10112
|
+
/** Whether the automation is currently executing its action block. */
|
|
10113
|
+
isRunning: boolean(),
|
|
10114
|
+
/** Ms epoch of the last successful run. 0 when never run. */
|
|
10115
|
+
lastTriggeredAt: number(),
|
|
10116
|
+
/** Failure description from the last completed run. Null on success
|
|
10117
|
+
* or when never run. */
|
|
10118
|
+
lastError: string().nullable(),
|
|
10119
|
+
/** Ms epoch when the slice was last updated. */
|
|
10120
|
+
lastChangedAt: number()
|
|
10121
|
+
});
|
|
10122
|
+
DeviceType.Automation, method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
10123
|
+
kind: "mutation",
|
|
10124
|
+
auth: "admin"
|
|
10125
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
10126
|
+
kind: "mutation",
|
|
10127
|
+
auth: "admin"
|
|
10128
|
+
}), method(object({
|
|
10129
|
+
deviceId: number().int().nonnegative(),
|
|
10130
|
+
/** When true, fires the action block while bypassing the
|
|
10131
|
+
* automation's condition evaluation. Gated by
|
|
10132
|
+
* `DeviceFeature.AutomationSkipCondition`. */
|
|
10133
|
+
skipCondition: boolean().optional()
|
|
10134
|
+
}), _void(), {
|
|
10135
|
+
kind: "mutation",
|
|
10136
|
+
auth: "admin"
|
|
10137
|
+
});
|
|
10138
|
+
/**
|
|
10139
|
+
* Battery status snapshot. Emitted by providers whose device is
|
|
10140
|
+
* battery-operated (cameras with `DeviceFeature.BatteryOperated`,
|
|
10141
|
+
* future sensor/button accessories). Consumers build their own "low
|
|
10142
|
+
* battery" alerting on top — the cap deliberately does NOT enforce a
|
|
10143
|
+
* threshold.
|
|
10144
|
+
*/
|
|
10145
|
+
var BatteryStatusSchema = object({
|
|
10146
|
+
/** 0..100 inclusive. Firmware-reported. */
|
|
10147
|
+
percentage: number().min(0).max(100),
|
|
10148
|
+
/**
|
|
10149
|
+
* Charging source. `'dc'` covers wall/USB adapters; `'solar'` is
|
|
10150
|
+
* Reolink-specific for the Solar Panel 2 accessory (will become
|
|
10151
|
+
* common on other battery cams). `'none'` means running on battery
|
|
10152
|
+
* alone.
|
|
10153
|
+
*/
|
|
10154
|
+
charging: _enum([
|
|
10155
|
+
"dc",
|
|
10156
|
+
"solar",
|
|
10157
|
+
"none"
|
|
10158
|
+
]),
|
|
10159
|
+
/**
|
|
10160
|
+
* True when the camera firmware has gone into low-power mode. Battery
|
|
10161
|
+
* providers MUST avoid polling during sleep — reading the battery
|
|
10162
|
+
* wakes the camera up and drains charge.
|
|
10163
|
+
*/
|
|
10164
|
+
sleeping: boolean(),
|
|
10165
|
+
/** Ms epoch of the last observation. Lets consumers reason about freshness. */
|
|
10166
|
+
lastUpdated: number(),
|
|
10167
|
+
/**
|
|
10168
|
+
* True when the source is a BINARY low-battery indicator (HA
|
|
10169
|
+
* `binary_sensor` device_class=battery / `LOW_BAT`) that has no real
|
|
10170
|
+
* charge level — `percentage` is then a coarse stand-in (100 = normal,
|
|
10171
|
+
* sub-threshold = low). UI MUST render "Normal"/"Low" instead of a
|
|
10172
|
+
* misleading exact percentage. Absent/false → genuine 0–100 % reading.
|
|
10173
|
+
*/
|
|
10174
|
+
binary: boolean().optional()
|
|
10175
|
+
});
|
|
10176
|
+
DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, method(object({
|
|
10177
|
+
deviceId: number(),
|
|
10178
|
+
/** Bound on the wait. Sensible range 3000–10000ms. */
|
|
10179
|
+
timeoutMs: number().int().min(500).max(3e4).default(8e3)
|
|
10180
|
+
}), object({
|
|
10181
|
+
awoke: boolean(),
|
|
10182
|
+
durationMs: number()
|
|
10183
|
+
}), { kind: "mutation" }), object({
|
|
10184
|
+
deviceId: number(),
|
|
10185
|
+
status: BatteryStatusSchema
|
|
10186
|
+
});
|
|
10187
|
+
object({
|
|
10188
|
+
on: boolean(),
|
|
10189
|
+
/** Ms epoch of the last transition. 0 if never observed. */
|
|
10190
|
+
lastChangedAt: number()
|
|
10191
|
+
});
|
|
10192
|
+
DeviceType.Sensor;
|
|
10193
|
+
object({
|
|
10194
|
+
/** Current level as 0..100 inclusive. Firmware-reported. */
|
|
10195
|
+
percentage: number().min(0).max(100),
|
|
10196
|
+
/** Ms epoch of the last operator-driven change. Useful for UI freshness. */
|
|
10197
|
+
lastChangedAt: number()
|
|
10198
|
+
});
|
|
10199
|
+
DeviceType.Light, method(object({
|
|
10200
|
+
deviceId: number().int().nonnegative(),
|
|
10201
|
+
percentage: number().min(0).max(100)
|
|
10202
|
+
}), _void(), {
|
|
10203
|
+
kind: "mutation",
|
|
10204
|
+
auth: "admin"
|
|
10205
|
+
}), object({
|
|
10206
|
+
deviceId: number(),
|
|
10207
|
+
percentage: number().min(0).max(100),
|
|
10208
|
+
lastChangedAt: number()
|
|
10209
|
+
});
|
|
10210
|
+
/** Stream delivery format. (Relocated from the retired `streaming-engine` cap.) */
|
|
10211
|
+
var StreamFormatSchema = _enum([
|
|
10212
|
+
"webrtc",
|
|
10213
|
+
"hls",
|
|
10214
|
+
"mjpeg",
|
|
9570
10215
|
"rtsp"
|
|
9571
10216
|
]);
|
|
9572
10217
|
var RtspRestreamEntrySchema = object({
|
|
@@ -12151,84 +12796,23 @@ DeviceType.Light, DeviceType.Siren, DeviceType.Switch, method(object({
|
|
|
12151
12796
|
lastChangedAt: number()
|
|
12152
12797
|
});
|
|
12153
12798
|
/**
|
|
12154
|
-
*
|
|
12155
|
-
* motion-
|
|
12156
|
-
*
|
|
12157
|
-
*
|
|
12158
|
-
*
|
|
12159
|
-
* All coordinates are normalized 0..1 of the camera frame (top-left
|
|
12160
|
-
* origin). Each cap composes the SUBSET of shape kinds it supports and
|
|
12161
|
-
* advertises it via `supportedShapes` in its `getOptions`.
|
|
12799
|
+
* Motion-zones share the same MaskShape vocabulary as privacy-mask — the
|
|
12800
|
+
* on-camera motion-detection mask is a single `grid` region (a row-major
|
|
12801
|
+
* boolean cell lattice the camera's onboard VMD evaluates). Composing it as
|
|
12802
|
+
* a region keeps one drawing-plane model across all geometry caps.
|
|
12162
12803
|
*/
|
|
12163
|
-
/** A
|
|
12164
|
-
var
|
|
12165
|
-
|
|
12166
|
-
|
|
12804
|
+
/** A motion-zone region — exactly one boolean cell grid today. */
|
|
12805
|
+
var MotionZoneRegionSchema = object({
|
|
12806
|
+
id: number(),
|
|
12807
|
+
enabled: boolean(),
|
|
12808
|
+
shape: MaskGridShapeSchema
|
|
12167
12809
|
});
|
|
12168
|
-
|
|
12169
|
-
|
|
12170
|
-
|
|
12171
|
-
|
|
12172
|
-
|
|
12173
|
-
|
|
12174
|
-
height: number()
|
|
12175
|
-
});
|
|
12176
|
-
/** Free polygon — an ordered list of normalized vertices (≥3). */
|
|
12177
|
-
var MaskPolygonShapeSchema = object({
|
|
12178
|
-
kind: literal("polygon"),
|
|
12179
|
-
points: array(MaskPointSchema)
|
|
12180
|
-
});
|
|
12181
|
-
/** Boolean cell grid — row-major, length === gridWidth*gridHeight. */
|
|
12182
|
-
var MaskGridShapeSchema = object({
|
|
12183
|
-
kind: literal("grid"),
|
|
12184
|
-
gridWidth: number(),
|
|
12185
|
-
gridHeight: number(),
|
|
12186
|
-
cells: array(boolean())
|
|
12187
|
-
});
|
|
12188
|
-
discriminatedUnion("kind", [
|
|
12189
|
-
MaskRectShapeSchema,
|
|
12190
|
-
MaskPolygonShapeSchema,
|
|
12191
|
-
MaskGridShapeSchema,
|
|
12192
|
-
object({
|
|
12193
|
-
kind: literal("line"),
|
|
12194
|
-
points: array(MaskPointSchema)
|
|
12195
|
-
})
|
|
12196
|
-
]);
|
|
12197
|
-
/** Every shape-kind discriminant, for `supportedShapes` advertisement. */
|
|
12198
|
-
var MaskShapeKindSchema = _enum([
|
|
12199
|
-
"rect",
|
|
12200
|
-
"polygon",
|
|
12201
|
-
"grid",
|
|
12202
|
-
"line"
|
|
12203
|
-
]);
|
|
12204
|
-
/** Polygon vertex bounds when a cap supports 'polygon' (e.g. Hikvision {min:4,max:4}). */
|
|
12205
|
-
var MaskPolygonVerticesSchema = object({
|
|
12206
|
-
min: number(),
|
|
12207
|
-
max: number()
|
|
12208
|
-
});
|
|
12209
|
-
/** Grid dimensions when a cap supports 'grid'. */
|
|
12210
|
-
var MaskGridDimsSchema = object({
|
|
12211
|
-
width: number(),
|
|
12212
|
-
height: number()
|
|
12213
|
-
});
|
|
12214
|
-
/**
|
|
12215
|
-
* Motion-zones share the same MaskShape vocabulary as privacy-mask — the
|
|
12216
|
-
* on-camera motion-detection mask is a single `grid` region (a row-major
|
|
12217
|
-
* boolean cell lattice the camera's onboard VMD evaluates). Composing it as
|
|
12218
|
-
* a region keeps one drawing-plane model across all geometry caps.
|
|
12219
|
-
*/
|
|
12220
|
-
/** A motion-zone region — exactly one boolean cell grid today. */
|
|
12221
|
-
var MotionZoneRegionSchema = object({
|
|
12222
|
-
id: number(),
|
|
12223
|
-
enabled: boolean(),
|
|
12224
|
-
shape: MaskGridShapeSchema
|
|
12225
|
-
});
|
|
12226
|
-
object({
|
|
12227
|
-
enabled: boolean(),
|
|
12228
|
-
sensitivity: number(),
|
|
12229
|
-
/** Grid region(s). Today exactly one `grid` shape. */
|
|
12230
|
-
regions: array(MotionZoneRegionSchema),
|
|
12231
|
-
lastFetchedAt: number()
|
|
12810
|
+
object({
|
|
12811
|
+
enabled: boolean(),
|
|
12812
|
+
sensitivity: number(),
|
|
12813
|
+
/** Grid region(s). Today exactly one `grid` shape. */
|
|
12814
|
+
regions: array(MotionZoneRegionSchema),
|
|
12815
|
+
lastFetchedAt: number()
|
|
12232
12816
|
});
|
|
12233
12817
|
/** Per-camera availability — grid dims are fixed per camera model; the UI
|
|
12234
12818
|
* sizes its editor from `grid`. */
|
|
@@ -14099,6 +14683,55 @@ method(object({
|
|
|
14099
14683
|
password: string()
|
|
14100
14684
|
}), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
|
|
14101
14685
|
/**
|
|
14686
|
+
* A live terminal session hosted by the provider addon. Output and input do
|
|
14687
|
+
* NOT flow through the capability — they use the addon data plane
|
|
14688
|
+
* (`GET /addon/terminal/<id>/out` SSE, `POST /addon/terminal/<id>/in`) because
|
|
14689
|
+
* terminal output must be ordered and lossless. The event bus is telemetry and
|
|
14690
|
+
* may drop chunks ([D8]), and a dropped chunk desynchronises the vt parser
|
|
14691
|
+
* permanently until a full repaint. The capability owns only lifecycle.
|
|
14692
|
+
*/
|
|
14693
|
+
var TerminalSessionInfoSchema = object({
|
|
14694
|
+
/** Opaque session id minted by the provider on `openSession`. */
|
|
14695
|
+
sessionId: string(),
|
|
14696
|
+
/** The pre-declared profile this session runs (never a free-form command). */
|
|
14697
|
+
profileId: string(),
|
|
14698
|
+
/** Human-readable profile label for the UI session list. */
|
|
14699
|
+
label: string(),
|
|
14700
|
+
cols: number().int().positive(),
|
|
14701
|
+
rows: number().int().positive(),
|
|
14702
|
+
/** ms-epoch the session's pty was spawned. */
|
|
14703
|
+
startedAt: number()
|
|
14704
|
+
});
|
|
14705
|
+
/**
|
|
14706
|
+
* A profile the operator may open — a pre-declared, allowlisted program
|
|
14707
|
+
* (`monitor` → `btm`). The capability accepts only these ids; a free-form
|
|
14708
|
+
* command string would be remote code execution as the server's user, so it is
|
|
14709
|
+
* deliberately not part of the contract.
|
|
14710
|
+
*/
|
|
14711
|
+
var TerminalProfileInfoSchema = object({
|
|
14712
|
+
profileId: string(),
|
|
14713
|
+
label: string(),
|
|
14714
|
+
description: string().optional()
|
|
14715
|
+
});
|
|
14716
|
+
method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(TerminalSessionInfoSchema).readonly(), { auth: "admin" }), method(object({
|
|
14717
|
+
profileId: string(),
|
|
14718
|
+
cols: number().int().positive(),
|
|
14719
|
+
rows: number().int().positive()
|
|
14720
|
+
}), TerminalSessionInfoSchema, {
|
|
14721
|
+
kind: "mutation",
|
|
14722
|
+
auth: "admin"
|
|
14723
|
+
}), method(object({
|
|
14724
|
+
sessionId: string(),
|
|
14725
|
+
cols: number().int().positive(),
|
|
14726
|
+
rows: number().int().positive()
|
|
14727
|
+
}), _void(), {
|
|
14728
|
+
kind: "mutation",
|
|
14729
|
+
auth: "admin"
|
|
14730
|
+
}), method(object({ sessionId: string() }), _void(), {
|
|
14731
|
+
kind: "mutation",
|
|
14732
|
+
auth: "admin"
|
|
14733
|
+
});
|
|
14734
|
+
/**
|
|
14102
14735
|
* Orchestrator-side destination metadata. The orchestrator computes
|
|
14103
14736
|
* `id = <addonId>:<subId>` from its provider lookup so consumers
|
|
14104
14737
|
* (admin UI, restore flow) see one canonical key.
|
|
@@ -14199,11 +14832,53 @@ var LocationStatSchema = object({
|
|
|
14199
14832
|
fileCount: number(),
|
|
14200
14833
|
present: boolean()
|
|
14201
14834
|
});
|
|
14835
|
+
/**
|
|
14836
|
+
* A backup schedule — the N:M "entry" that binds one cron cadence to a
|
|
14837
|
+
* SET of destination locations. Supersedes the per-location cron on
|
|
14838
|
+
* `BackupDestinationPolicy`: an operator creates a schedule, picks the
|
|
14839
|
+
* `backups` locations it should write to, and the orchestrator fans a
|
|
14840
|
+
* single archive out to all of them when the cron fires.
|
|
14841
|
+
*
|
|
14842
|
+
* `retentionCount` is per-schedule (D-decision 2026-07-28): every
|
|
14843
|
+
* location targeted by this schedule keeps this many archives from
|
|
14844
|
+
* this schedule's runs.
|
|
14845
|
+
*
|
|
14846
|
+
* `dataSources` optionally narrows which top-level state locations
|
|
14847
|
+
* (db, addons, tls, …) are archived; omitted = the orchestrator's
|
|
14848
|
+
* default full set.
|
|
14849
|
+
*/
|
|
14850
|
+
var BackupScheduleSchema = object({
|
|
14851
|
+
/** Stable id. Generated by the orchestrator on first upsert if absent. */
|
|
14852
|
+
id: string(),
|
|
14853
|
+
/** Operator-facing display name. */
|
|
14854
|
+
label: string(),
|
|
14855
|
+
/** 5-field POSIX cron. Empty = disabled cadence (kept for editing). */
|
|
14856
|
+
cron: string(),
|
|
14857
|
+
/** Master on/off toggle for the whole schedule. */
|
|
14858
|
+
enabled: boolean(),
|
|
14859
|
+
/** `backups`-location ids this schedule writes to (fan-out set). */
|
|
14860
|
+
locationIds: array(string()).readonly(),
|
|
14861
|
+
/** Archives kept per targeted location for this schedule. */
|
|
14862
|
+
retentionCount: number().int().min(1).max(1e3),
|
|
14863
|
+
/** Optional subset of source locations to include; omitted = all. */
|
|
14864
|
+
dataSources: array(string()).readonly().optional(),
|
|
14865
|
+
/** ms-epoch of last successful run. */
|
|
14866
|
+
lastRunAt: number().optional(),
|
|
14867
|
+
/** ms-epoch of next computed firing (read-only, filled on list). */
|
|
14868
|
+
nextRunAt: number().optional()
|
|
14869
|
+
});
|
|
14202
14870
|
method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }), method(object({
|
|
14203
14871
|
/** Subset of registered `backup-destination` addon ids to write to. */
|
|
14204
14872
|
destinations: array(string()).optional(),
|
|
14205
14873
|
locations: array(string()).optional(),
|
|
14206
|
-
label: string().optional()
|
|
14874
|
+
label: string().optional(),
|
|
14875
|
+
/**
|
|
14876
|
+
* Per-run retention override applied to every targeted
|
|
14877
|
+
* destination. Used by schedule-driven runs (per-entry
|
|
14878
|
+
* retention). Omitted = each destination's own policy
|
|
14879
|
+
* retention (manual runs).
|
|
14880
|
+
*/
|
|
14881
|
+
retentionCount: number().int().min(1).max(1e3).optional()
|
|
14207
14882
|
}).optional(), array(BackupEntrySchema).readonly(), {
|
|
14208
14883
|
kind: "mutation",
|
|
14209
14884
|
auth: "admin"
|
|
@@ -14252,7 +14927,21 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
|
|
|
14252
14927
|
ok: boolean(),
|
|
14253
14928
|
error: string().optional(),
|
|
14254
14929
|
nextRuns: array(number()).readonly()
|
|
14255
|
-
}))
|
|
14930
|
+
})), method(_void(), array(BackupScheduleSchema).readonly(), { auth: "admin" }), method(object({
|
|
14931
|
+
id: string().optional(),
|
|
14932
|
+
label: string(),
|
|
14933
|
+
cron: string(),
|
|
14934
|
+
enabled: boolean(),
|
|
14935
|
+
locationIds: array(string()).readonly(),
|
|
14936
|
+
retentionCount: number().int().min(1).max(1e3),
|
|
14937
|
+
dataSources: array(string()).readonly().optional()
|
|
14938
|
+
}), BackupScheduleSchema, {
|
|
14939
|
+
kind: "mutation",
|
|
14940
|
+
auth: "admin"
|
|
14941
|
+
}), method(object({ id: string() }), _void(), {
|
|
14942
|
+
kind: "mutation",
|
|
14943
|
+
auth: "admin"
|
|
14944
|
+
});
|
|
14256
14945
|
/**
|
|
14257
14946
|
* `broker` — unified pub/sub broker registry, system-scoped collection.
|
|
14258
14947
|
*
|
|
@@ -15887,1013 +16576,525 @@ var DiskIoSnapshotSchema = object({
|
|
|
15887
16576
|
writeBytes: number(),
|
|
15888
16577
|
readOps: number(),
|
|
15889
16578
|
writeOps: number(),
|
|
15890
|
-
timestampMs: number()
|
|
15891
|
-
});
|
|
15892
|
-
var NetworkIoSnapshotSchema = object({
|
|
15893
|
-
rxBytes: number(),
|
|
15894
|
-
txBytes: number(),
|
|
15895
|
-
rxPackets: number(),
|
|
15896
|
-
txPackets: number(),
|
|
15897
|
-
rxErrors: number(),
|
|
15898
|
-
txErrors: number(),
|
|
15899
|
-
timestampMs: number()
|
|
15900
|
-
});
|
|
15901
|
-
var MetricsGpuInfoSchema = object({
|
|
15902
|
-
utilization: number(),
|
|
15903
|
-
model: string(),
|
|
15904
|
-
memoryUsedBytes: number(),
|
|
15905
|
-
memoryTotalBytes: number(),
|
|
15906
|
-
temperature: number().nullable()
|
|
15907
|
-
});
|
|
15908
|
-
var ProcessResourceInfoSchema = object({
|
|
15909
|
-
openFds: number(),
|
|
15910
|
-
threadCount: number(),
|
|
15911
|
-
activeHandles: number(),
|
|
15912
|
-
activeRequests: number()
|
|
15913
|
-
});
|
|
15914
|
-
var PressureAvgsSchema = object({
|
|
15915
|
-
avg10: number(),
|
|
15916
|
-
avg60: number(),
|
|
15917
|
-
avg300: number()
|
|
15918
|
-
});
|
|
15919
|
-
var PressureInfoSchema = object({
|
|
15920
|
-
some: PressureAvgsSchema,
|
|
15921
|
-
full: PressureAvgsSchema.nullable()
|
|
15922
|
-
});
|
|
15923
|
-
var SystemResourceSnapshotSchema = object({
|
|
15924
|
-
cpu: CpuBreakdownSchema,
|
|
15925
|
-
memory: MemoryInfoSchema,
|
|
15926
|
-
gpu: MetricsGpuInfoSchema.nullable(),
|
|
15927
|
-
network: NetworkIoSnapshotSchema,
|
|
15928
|
-
disk: DiskIoSnapshotSchema,
|
|
15929
|
-
pressure: object({
|
|
15930
|
-
cpu: PressureInfoSchema.nullable(),
|
|
15931
|
-
memory: PressureInfoSchema.nullable(),
|
|
15932
|
-
io: PressureInfoSchema.nullable()
|
|
15933
|
-
}),
|
|
15934
|
-
process: ProcessResourceInfoSchema,
|
|
15935
|
-
cpuTemperature: number().nullable(),
|
|
15936
|
-
timestampMs: number()
|
|
15937
|
-
});
|
|
15938
|
-
var DiskSpaceInfoSchema = object({
|
|
15939
|
-
path: string(),
|
|
15940
|
-
totalBytes: number(),
|
|
15941
|
-
usedBytes: number(),
|
|
15942
|
-
availableBytes: number(),
|
|
15943
|
-
percent: number()
|
|
15944
|
-
});
|
|
15945
|
-
var PidResourceStatsSchema = object({
|
|
15946
|
-
pid: number(),
|
|
15947
|
-
cpu: number(),
|
|
15948
|
-
memory: number(),
|
|
15949
|
-
/**
|
|
15950
|
-
* Private (anonymous) resident bytes — the per-process V8 heap + native
|
|
15951
|
-
* allocations NOT shared with other processes (Linux RssAnon). This is the
|
|
15952
|
-
* "real" per-runner cost; summing it across runners is meaningful, unlike
|
|
15953
|
-
* `memory` (RSS), which double-counts the shared mmap'd framework code.
|
|
15954
|
-
* Undefined where /proc is unavailable (e.g. macOS).
|
|
15955
|
-
*/
|
|
15956
|
-
privateBytes: number().optional(),
|
|
15957
|
-
/**
|
|
15958
|
-
* Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
|
|
15959
|
-
* code shared copy-on-write across runners. Undefined on macOS.
|
|
15960
|
-
*/
|
|
15961
|
-
sharedBytes: number().optional()
|
|
15962
|
-
});
|
|
15963
|
-
var AddonInstanceSchema = object({
|
|
15964
|
-
addonId: string(),
|
|
15965
|
-
nodeId: string(),
|
|
15966
|
-
role: _enum(["hub", "worker"]),
|
|
15967
|
-
pid: number(),
|
|
15968
|
-
state: _enum([
|
|
15969
|
-
"starting",
|
|
15970
|
-
"running",
|
|
15971
|
-
"stopping",
|
|
15972
|
-
"stopped",
|
|
15973
|
-
"crashed"
|
|
15974
|
-
]),
|
|
15975
|
-
uptimeSec: number()
|
|
15976
|
-
});
|
|
15977
|
-
var NodeProcessSchema = object({
|
|
15978
|
-
pid: number(),
|
|
15979
|
-
ppid: number(),
|
|
15980
|
-
pgid: number(),
|
|
15981
|
-
classification: _enum([
|
|
15982
|
-
"root",
|
|
15983
|
-
"managed",
|
|
15984
|
-
"system",
|
|
15985
|
-
"ghost"
|
|
15986
|
-
]),
|
|
15987
|
-
/** `$process` addon binding when `managed`, else null. */
|
|
15988
|
-
addonId: string().nullable(),
|
|
15989
|
-
/** Kernel-reported nodeId when the process is a known agent/worker. */
|
|
15990
|
-
nodeId: string().nullable(),
|
|
15991
|
-
/** Truncated command line. */
|
|
15992
|
-
command: string(),
|
|
15993
|
-
cpuPercent: number(),
|
|
15994
|
-
memoryRssBytes: number(),
|
|
15995
|
-
/** Wall-clock uptime (seconds). Parsed from `ps etime`. */
|
|
15996
|
-
uptimeSec: number(),
|
|
15997
|
-
/** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
|
|
15998
|
-
orphaned: boolean()
|
|
15999
|
-
});
|
|
16000
|
-
var KillProcessInputSchema = object({
|
|
16001
|
-
pid: number(),
|
|
16002
|
-
/** Force = SIGKILL. Default is SIGTERM. */
|
|
16003
|
-
force: boolean().optional()
|
|
16004
|
-
});
|
|
16005
|
-
var KillProcessResultSchema = object({
|
|
16006
|
-
success: boolean(),
|
|
16007
|
-
reason: string().optional(),
|
|
16008
|
-
signal: _enum(["SIGTERM", "SIGKILL"]).optional()
|
|
16009
|
-
});
|
|
16010
|
-
var DumpHeapSnapshotInputSchema = object({
|
|
16011
|
-
/** The addon whose runner should dump a heap snapshot. */
|
|
16012
|
-
addonId: string() });
|
|
16013
|
-
var DumpHeapSnapshotResultSchema = object({
|
|
16014
|
-
success: boolean(),
|
|
16015
|
-
/** Path of the written .heapsnapshot inside the runner's container/host. */
|
|
16016
|
-
path: string().optional(),
|
|
16017
|
-
/** Process pid that was signalled. */
|
|
16018
|
-
pid: number().optional(),
|
|
16019
|
-
reason: string().optional()
|
|
16020
|
-
});
|
|
16021
|
-
var SystemMetricsSchema = object({
|
|
16022
|
-
cpuPercent: number(),
|
|
16023
|
-
memoryPercent: number(),
|
|
16024
|
-
memoryUsedMB: number(),
|
|
16025
|
-
memoryTotalMB: number(),
|
|
16026
|
-
diskPercent: number().optional(),
|
|
16027
|
-
temperature: number().optional(),
|
|
16028
|
-
gpuPercent: number().optional(),
|
|
16029
|
-
gpuMemoryPercent: number().optional()
|
|
16030
|
-
});
|
|
16031
|
-
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, {
|
|
16032
|
-
kind: "mutation",
|
|
16033
|
-
auth: "admin"
|
|
16034
|
-
}), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
|
|
16035
|
-
kind: "mutation",
|
|
16036
|
-
auth: "admin"
|
|
16037
|
-
});
|
|
16038
|
-
method(object({
|
|
16039
|
-
sourceUrl: string(),
|
|
16040
|
-
metadata: ModelConvertMetadataSchema,
|
|
16041
|
-
targets: array(ConvertTargetSchema).min(1).readonly(),
|
|
16042
|
-
calibrationRef: string().optional(),
|
|
16043
|
-
sessionId: string().optional()
|
|
16044
|
-
}), ConvertResultSchema, {
|
|
16045
|
-
kind: "mutation",
|
|
16046
|
-
auth: "admin",
|
|
16047
|
-
timeoutMs: 6e5
|
|
16048
|
-
});
|
|
16049
|
-
method(object({
|
|
16050
|
-
nodeId: string(),
|
|
16051
|
-
modelId: string(),
|
|
16052
|
-
format: _enum(MODEL_FORMATS),
|
|
16053
|
-
entry: ModelCatalogEntrySchema
|
|
16054
|
-
}), object({
|
|
16055
|
-
ok: boolean(),
|
|
16056
|
-
/** sha256 of the staged tarball (empty for a hub-local no-op). */
|
|
16057
|
-
sha256: string(),
|
|
16058
|
-
bytes: number(),
|
|
16059
|
-
/** The target node's modelsDir the artifact landed in. */
|
|
16060
|
-
path: string()
|
|
16061
|
-
}), {
|
|
16062
|
-
kind: "mutation",
|
|
16063
|
-
auth: "admin"
|
|
16064
|
-
});
|
|
16065
|
-
/**
|
|
16066
|
-
* `mqtt-broker` — broker-registry cap.
|
|
16067
|
-
*
|
|
16068
|
-
* NOT a pub/sub proxy. The cap exposes (a) a registry of configured
|
|
16069
|
-
* MQTT brokers (external + optionally an embedded `aedes`-backed one)
|
|
16070
|
-
* and (b) the connection details a consumer addon needs to spin up
|
|
16071
|
-
* its OWN `mqtt.js` client.
|
|
16072
|
-
*
|
|
16073
|
-
* Why: pub/sub routing over the system event-bus loses fidelity
|
|
16074
|
-
* (callback shape, QoS guarantees, will/retain semantics) and adds
|
|
16075
|
-
* refcount bookkeeping that addons would rather own themselves. The
|
|
16076
|
-
* canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
|
|
16077
|
-
* features anyway — give it the connection config, get out of the way.
|
|
16078
|
-
*
|
|
16079
|
-
* Consumer flow:
|
|
16080
|
-
* const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
|
|
16081
|
-
* const client = mqtt.connect(cfg.url, { username: cfg.username, … })
|
|
16082
|
-
* client.subscribe('zigbee2mqtt/+')
|
|
16083
|
-
*
|
|
16084
|
-
* Collection mode: multiple brokers (e.g. one local mosquitto + one
|
|
16085
|
-
* cloud bridge). The "embedded" entry (when present) is just another
|
|
16086
|
-
* broker in the registry — its lifecycle is owned by the addon that
|
|
16087
|
-
* spawned it.
|
|
16088
|
-
*/
|
|
16089
|
-
var BrokerKindSchema = _enum(["external", "embedded"]);
|
|
16090
|
-
/**
|
|
16091
|
-
* Broker live-probe status.
|
|
16092
|
-
*
|
|
16093
|
-
* - `connected` — last probe completed a clean CONNACK
|
|
16094
|
-
* - `disconnected` — no probe has run yet (cold cache)
|
|
16095
|
-
* - `auth-failed` — CONNACK refused with auth error (RC 4 / 5)
|
|
16096
|
-
* - `unreachable` — TCP connect timed out / refused
|
|
16097
|
-
* - `tls-error` — TLS handshake failed (cert / SNI / cipher)
|
|
16098
|
-
*/
|
|
16099
|
-
var BrokerStatusSchema$1 = _enum([
|
|
16100
|
-
"connected",
|
|
16101
|
-
"disconnected",
|
|
16102
|
-
"auth-failed",
|
|
16103
|
-
"unreachable",
|
|
16104
|
-
"tls-error"
|
|
16105
|
-
]);
|
|
16106
|
-
var BrokerInfoSchema = object({
|
|
16107
|
-
id: string(),
|
|
16108
|
-
name: string(),
|
|
16109
|
-
url: string(),
|
|
16110
|
-
kind: BrokerKindSchema,
|
|
16111
|
-
status: BrokerStatusSchema$1,
|
|
16112
|
-
latencyMs: number().nullable(),
|
|
16113
|
-
error: string().optional(),
|
|
16114
|
-
/** Embedded brokers only: number of MQTT clients currently connected. */
|
|
16115
|
-
connectedClients: number().int().nonnegative().optional(),
|
|
16116
|
-
/** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
|
|
16117
|
-
lastCheckedAt: number().optional()
|
|
16118
|
-
});
|
|
16119
|
-
/**
|
|
16120
|
-
* Connection details — what a consumer needs to call
|
|
16121
|
-
* `mqtt.connect(url, options)`. We split URL + credentials so the
|
|
16122
|
-
* consumer can pass them as `mqtt.connect(url, { username, password })`
|
|
16123
|
-
* instead of stuffing creds into the URL (which leaks them into logs).
|
|
16124
|
-
*/
|
|
16125
|
-
var BrokerConnectionDetailsSchema = object({
|
|
16126
|
-
url: string(),
|
|
16127
|
-
username: string().optional(),
|
|
16128
|
-
password: string().optional(),
|
|
16129
|
-
/**
|
|
16130
|
-
* Suggested prefix for `clientId`. Each consumer should suffix this
|
|
16131
|
-
* with its own discriminator (addon id, instance id) so reconnects
|
|
16132
|
-
* don't kick each other off (MQTT spec: clientId must be unique per
|
|
16133
|
-
* broker).
|
|
16134
|
-
*/
|
|
16135
|
-
clientIdPrefix: string().optional()
|
|
16136
|
-
});
|
|
16137
|
-
var AddBrokerInputSchema = object({
|
|
16138
|
-
name: string().min(1),
|
|
16139
|
-
url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
|
|
16140
|
-
username: string().optional(),
|
|
16141
|
-
password: string().optional(),
|
|
16142
|
-
clientIdPrefix: string().optional()
|
|
16143
|
-
});
|
|
16144
|
-
var AddBrokerResultSchema = object({ id: string() });
|
|
16145
|
-
var IdInputSchema = object({ id: string() });
|
|
16146
|
-
var TestResultSchema$1 = discriminatedUnion("ok", [object({
|
|
16147
|
-
ok: literal(true),
|
|
16148
|
-
latencyMs: number()
|
|
16149
|
-
}), object({
|
|
16150
|
-
ok: literal(false),
|
|
16151
|
-
error: string()
|
|
16152
|
-
})]);
|
|
16153
|
-
var StartEmbeddedInputSchema = object({
|
|
16154
|
-
port: number().int().min(1).max(65535).default(1883),
|
|
16155
|
-
/** Allow anonymous connect (no username/password). Default: false. */
|
|
16156
|
-
allowAnonymous: boolean().default(false),
|
|
16157
|
-
/** Optional shared username/password for clients. */
|
|
16158
|
-
username: string().optional(),
|
|
16159
|
-
password: string().optional()
|
|
16160
|
-
});
|
|
16161
|
-
var StartEmbeddedResultSchema = object({
|
|
16162
|
-
id: string(),
|
|
16163
|
-
url: string()
|
|
16164
|
-
});
|
|
16165
|
-
var StatusSchema = object({
|
|
16166
|
-
brokerCount: number(),
|
|
16167
|
-
embeddedRunning: boolean()
|
|
16168
|
-
});
|
|
16169
|
-
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);
|
|
16170
|
-
var NetworkEndpointSchema = object({
|
|
16171
|
-
url: string(),
|
|
16172
|
-
hostname: string(),
|
|
16173
|
-
port: number(),
|
|
16174
|
-
protocol: _enum(["http", "https"])
|
|
16175
|
-
});
|
|
16176
|
-
var NetworkAccessStatusSchema = object({
|
|
16177
|
-
connected: boolean(),
|
|
16178
|
-
endpoint: NetworkEndpointSchema.nullable(),
|
|
16179
|
-
error: string().optional()
|
|
16180
|
-
});
|
|
16181
|
-
/**
|
|
16182
|
-
* Optional, richer endpoint shape returned by providers that expose
|
|
16183
|
-
* MORE than one ingress concurrently (Tailscale Ingress with mixed
|
|
16184
|
-
* serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
|
|
16185
|
-
* the originating provider config (mode + sourcePort) so the
|
|
16186
|
-
* orchestrator UI can label rows distinctly. Providers that expose only
|
|
16187
|
-
* one endpoint just omit `listEndpoints` from their provider impl.
|
|
16188
|
-
*/
|
|
16189
|
-
var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
|
|
16190
|
-
/**
|
|
16191
|
-
* Stable id within the provider — typically `<mode>-<sourcePort>` so
|
|
16192
|
-
* the orchestrator can dedupe across `listEndpoints` polls.
|
|
16193
|
-
*/
|
|
16194
|
-
id: string(),
|
|
16195
|
-
/** Operator-facing label (mirrors `MeshEndpoint.label`). */
|
|
16196
|
-
label: string(),
|
|
16197
|
-
/** Optional provider-specific mode tag, used for icon/colour in admin UI. */
|
|
16198
|
-
mode: string().optional(),
|
|
16199
|
-
/** Originating local port the ingress fronts (informational). */
|
|
16200
|
-
sourcePort: number().optional()
|
|
16201
|
-
});
|
|
16202
|
-
method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
|
|
16203
|
-
/**
|
|
16204
|
-
* notification-output — canonical, capability-gated notification delivery.
|
|
16205
|
-
*
|
|
16206
|
-
* Apprise-derived model (see
|
|
16207
|
-
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
16208
|
-
* callers emit ONE canonical `Notification`; each provider declares a
|
|
16209
|
-
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
16210
|
-
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
16211
|
-
* message to what the kind supports — callers never special-case a service.
|
|
16212
|
-
*
|
|
16213
|
-
* DESIGN DECISIONS (locked):
|
|
16214
|
-
* - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
|
|
16215
|
-
* `setTargetEnabled`), each provider persisting via the `settings-store`
|
|
16216
|
-
* cap. Rationale: the admin UI needs one uniform surface across the
|
|
16217
|
-
* notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
|
|
16218
|
-
* alternative would fork the UI per addon and cannot host the
|
|
16219
|
-
* discovery→adopt flow.
|
|
16220
|
-
* - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
|
|
16221
|
-
* the generated cap-mount auto-`concatCollection`-fans them across every
|
|
16222
|
-
* registered provider (notifiers addon + HA addon) so one catalog is
|
|
16223
|
-
* routable. `send` / `testTarget` / CRUD route to ONE provider by the
|
|
16224
|
-
* `addonId` the generated collection router extracts from the call input.
|
|
16225
|
-
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
16226
|
-
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
16227
|
-
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
16228
|
-
* base64 fallback needed.
|
|
16229
|
-
*
|
|
16230
|
-
* TODO (deferred, closed-set change — separate decision): add
|
|
16231
|
-
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
16232
|
-
* admin "Integrations" page.
|
|
16233
|
-
*/
|
|
16234
|
-
/**
|
|
16235
|
-
* Zentik-derived typed-media enum — the superset across every kind. Each
|
|
16236
|
-
* adapter picks what it supports and the degrade engine filters the rest.
|
|
16237
|
-
*/
|
|
16238
|
-
var AttachmentMediaTypeSchema = _enum([
|
|
16239
|
-
"image",
|
|
16240
|
-
"video",
|
|
16241
|
-
"gif",
|
|
16242
|
-
"audio",
|
|
16243
|
-
"icon"
|
|
16244
|
-
]);
|
|
16245
|
-
/**
|
|
16246
|
-
* A single attachment. Exactly one of `url` (remote source, most adapters
|
|
16247
|
-
* prefer this) or `bytes` (inline source; required for Pushover-style
|
|
16248
|
-
* bytes-only kinds) MUST be present — the degrade engine expresses a
|
|
16249
|
-
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
16250
|
-
*/
|
|
16251
|
-
var AttachmentSchema = object({
|
|
16252
|
-
mediaType: AttachmentMediaTypeSchema,
|
|
16253
|
-
url: string().optional(),
|
|
16254
|
-
bytes: _instanceof(Uint8Array).optional(),
|
|
16255
|
-
mime: string().optional(),
|
|
16256
|
-
name: string().optional()
|
|
16257
|
-
}).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
|
|
16258
|
-
var NotificationFormatSchema = _enum([
|
|
16259
|
-
"text",
|
|
16260
|
-
"markdown",
|
|
16261
|
-
"html"
|
|
16262
|
-
]);
|
|
16263
|
-
/** A single tap-through action button. */
|
|
16264
|
-
var NotificationActionSchema = object({
|
|
16265
|
-
id: string(),
|
|
16266
|
-
label: string(),
|
|
16267
|
-
url: string().optional()
|
|
16268
|
-
});
|
|
16269
|
-
/**
|
|
16270
|
-
* The canonical notification. `body` is the only hard field (Apprise model).
|
|
16271
|
-
* `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
|
|
16272
|
-
* NOT a fixed severity enum — each kind declares its own `caps.levels` and
|
|
16273
|
-
* the adapter maps this ordinal onto its native level. `level?` is an
|
|
16274
|
-
* optional kind-native level id (`emergency`, `silent`, …) that overrides
|
|
16275
|
-
* `priority` for that one target.
|
|
16276
|
-
*/
|
|
16277
|
-
var NotificationSchema = object({
|
|
16278
|
-
body: string(),
|
|
16279
|
-
title: string().optional(),
|
|
16280
|
-
format: NotificationFormatSchema.default("text"),
|
|
16281
|
-
priority: number().int().min(1).max(5).default(3),
|
|
16282
|
-
level: string().optional(),
|
|
16283
|
-
attachments: array(AttachmentSchema).optional(),
|
|
16284
|
-
clickUrl: string().optional(),
|
|
16285
|
-
actions: array(NotificationActionSchema).optional(),
|
|
16286
|
-
sound: string().optional(),
|
|
16287
|
-
ttl: number().optional(),
|
|
16288
|
-
tag: string().optional(),
|
|
16289
|
-
deviceId: number().optional(),
|
|
16290
|
-
eventId: string().optional(),
|
|
16291
|
-
metadata: record(string(), unknown()).optional()
|
|
16292
|
-
});
|
|
16293
|
-
/** One declared native severity/priority level for a kind. */
|
|
16294
|
-
var TargetKindLevelSchema = object({
|
|
16295
|
-
id: string(),
|
|
16296
|
-
label: string(),
|
|
16297
|
-
/** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
|
|
16298
|
-
ordinal: number().int().min(1).max(5).nullable(),
|
|
16299
|
-
flags: object({
|
|
16300
|
-
critical: boolean().optional(),
|
|
16301
|
-
silent: boolean().optional(),
|
|
16302
|
-
noPush: boolean().optional()
|
|
16303
|
-
}).optional(),
|
|
16304
|
-
/** e.g. Pushover `emergency` requires `retry` / `expire`. */
|
|
16305
|
-
requires: array(string()).optional(),
|
|
16306
|
-
description: string().optional()
|
|
16307
|
-
});
|
|
16308
|
-
/** The full capability block consulted before dispatch. */
|
|
16309
|
-
var TargetKindCapsSchema = object({
|
|
16310
|
-
attachments: object({
|
|
16311
|
-
mediaTypes: array(AttachmentMediaTypeSchema),
|
|
16312
|
-
mode: _enum([
|
|
16313
|
-
"url",
|
|
16314
|
-
"bytes",
|
|
16315
|
-
"both"
|
|
16316
|
-
]),
|
|
16317
|
-
max: number().int().nonnegative(),
|
|
16318
|
-
maxBytes: number().int().positive().optional()
|
|
16319
|
-
}),
|
|
16320
|
-
/** Max action buttons (0 = none). */
|
|
16321
|
-
actions: number().int().nonnegative(),
|
|
16322
|
-
levels: array(TargetKindLevelSchema),
|
|
16323
|
-
format: array(NotificationFormatSchema),
|
|
16324
|
-
clickUrl: boolean(),
|
|
16325
|
-
sound: boolean(),
|
|
16326
|
-
ttl: boolean(),
|
|
16327
|
-
bodyMaxLen: number().int().positive()
|
|
16328
|
-
});
|
|
16329
|
-
/**
|
|
16330
|
-
* `configSchema` is a `ConfigUISchema` tree passed through to the admin
|
|
16331
|
-
* FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
|
|
16332
|
-
* `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
|
|
16333
|
-
* the union is large and not meant for runtime validation here; the exported
|
|
16334
|
-
* `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
|
|
16335
|
-
*/
|
|
16336
|
-
var ConfigSchemaPassthrough = unknown();
|
|
16337
|
-
var TargetKindSchema = object({
|
|
16338
|
-
kind: string(),
|
|
16339
|
-
label: string(),
|
|
16340
|
-
icon: string(),
|
|
16341
|
-
/** Stamped by each provider so the concat-fanned catalog stays routable. */
|
|
16342
|
-
addonId: string(),
|
|
16343
|
-
configSchema: ConfigSchemaPassthrough,
|
|
16344
|
-
supportsDiscovery: boolean(),
|
|
16345
|
-
caps: TargetKindCapsSchema
|
|
16346
|
-
});
|
|
16347
|
-
/**
|
|
16348
|
-
* A persisted target. `config` holds secrets; providers REDACT secret fields
|
|
16349
|
-
* (return a presence marker only) when serving `listTargets` — never
|
|
16350
|
-
* round-trip a stored secret to the UI.
|
|
16351
|
-
*/
|
|
16352
|
-
var TargetSchema = object({
|
|
16353
|
-
id: string(),
|
|
16354
|
-
name: string(),
|
|
16355
|
-
kind: string(),
|
|
16356
|
-
addonId: string(),
|
|
16357
|
-
enabled: boolean(),
|
|
16358
|
-
config: record(string(), unknown())
|
|
16359
|
-
});
|
|
16360
|
-
/** A discovery-surfaced candidate (config is partial + non-secret). */
|
|
16361
|
-
var DiscoveredTargetSchema = object({
|
|
16362
|
-
kind: string(),
|
|
16363
|
-
suggestedName: string(),
|
|
16364
|
-
config: record(string(), unknown())
|
|
16365
|
-
});
|
|
16366
|
-
/** The degrade engine's report — what was resolved / dropped / degraded. */
|
|
16367
|
-
var RenderedAsSchema = object({
|
|
16368
|
-
level: string(),
|
|
16369
|
-
format: NotificationFormatSchema,
|
|
16370
|
-
attachmentsSent: number().int().nonnegative(),
|
|
16371
|
-
actionsSent: number().int().nonnegative(),
|
|
16372
|
-
truncated: boolean(),
|
|
16373
|
-
dropped: array(string())
|
|
16374
|
-
});
|
|
16375
|
-
var SendResultSchema = object({
|
|
16376
|
-
success: boolean(),
|
|
16377
|
-
error: string().optional(),
|
|
16378
|
-
renderedAs: RenderedAsSchema.optional()
|
|
16379
|
-
});
|
|
16380
|
-
/** Same shape as SendResult — kept as a distinct name for the test panel. */
|
|
16381
|
-
var TestResultSchema = SendResultSchema;
|
|
16382
|
-
var notificationOutputCapability = {
|
|
16383
|
-
name: "notification-output",
|
|
16384
|
-
scope: "system",
|
|
16385
|
-
mode: "collection",
|
|
16386
|
-
methods: {
|
|
16387
|
-
listTargetKinds: method(object({}), array(TargetKindSchema)),
|
|
16388
|
-
listTargets: method(object({}), array(TargetSchema)),
|
|
16389
|
-
discoverTargets: method(object({
|
|
16390
|
-
kind: string(),
|
|
16391
|
-
config: record(string(), unknown()).optional()
|
|
16392
|
-
}), array(DiscoveredTargetSchema)),
|
|
16393
|
-
send: method(object({
|
|
16394
|
-
targetId: string(),
|
|
16395
|
-
notification: NotificationSchema
|
|
16396
|
-
}), SendResultSchema, { kind: "mutation" }),
|
|
16397
|
-
testTarget: method(object({
|
|
16398
|
-
targetId: string(),
|
|
16399
|
-
sample: NotificationSchema.optional()
|
|
16400
|
-
}), TestResultSchema, { kind: "mutation" }),
|
|
16401
|
-
upsertTarget: method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }),
|
|
16402
|
-
deleteTarget: method(object({ targetId: string() }), _void(), { kind: "mutation" }),
|
|
16403
|
-
setTargetEnabled: method(object({
|
|
16404
|
-
targetId: string(),
|
|
16405
|
-
enabled: boolean()
|
|
16406
|
-
}), _void(), { kind: "mutation" })
|
|
16407
|
-
}
|
|
16408
|
-
};
|
|
16409
|
-
/**
|
|
16410
|
-
* notification-rules — the Notification Center rule surface (P1 core).
|
|
16411
|
-
*
|
|
16412
|
-
* Spec: `docs/superpowers/specs/2026-07-22-notification-center-requirements.md`
|
|
16413
|
-
* (operator decisions D-1/D-2/D-3 are binding):
|
|
16414
|
-
*
|
|
16415
|
-
* - D-2: rule EVALUATION lives in `addon-post-analysis` (the
|
|
16416
|
-
* `notification-center` module), hooked on the durable persistence
|
|
16417
|
-
* moments (object-event insert, TrackCloser.closeExpired) with a
|
|
16418
|
-
* persisted outbox + retry — never the lossy telemetry bus (D8).
|
|
16419
|
-
* - D-3: urgency belongs to the RULE. `delivery: 'immediate'` fires on the
|
|
16420
|
-
* FIRST persisted detection matching the conditions (per-track dedup,
|
|
16421
|
-
* `maxPerTrack` fixed at 1 — see {@link NC_MAX_PER_TRACK_IMMEDIATE});
|
|
16422
|
-
* `delivery: 'track-end'` evaluates the finalized track record at close.
|
|
16423
|
-
* - DISPATCH stays behind `notification-output` (rules reference targets
|
|
16424
|
-
* by id; per-backend params are a passthrough blob capped by the
|
|
16425
|
-
* target kind's own caps/degrade engine).
|
|
16426
|
-
*
|
|
16427
|
-
* P1 scope: admin-authored rules only (`createdBy` stamped from the
|
|
16428
|
-
* server-injected caller identity — the first `caller: 'required'`
|
|
16429
|
-
* adopter). The P1 condition subset is: devices, classes(+exclude),
|
|
16430
|
-
* minConfidence, admin zones (any/all + exclude), weekly schedule
|
|
16431
|
-
* windows, and the optional label/identity/plate matchers. User rules,
|
|
16432
|
-
* private zones, per-recipient fan-out and the wider condition table are
|
|
16433
|
-
* P2+ (see spec §7).
|
|
16434
|
-
*
|
|
16435
|
-
* All schemas here are the single source of truth — `NcRule` etc. are
|
|
16436
|
-
* `z.infer` exports; no duplicate interfaces (the advanced-notifier
|
|
16437
|
-
* schema/interface drift is explicitly not repeated).
|
|
16438
|
-
*/
|
|
16439
|
-
/**
|
|
16440
|
-
* D-3: the trigger/urgency of a rule — which persistence moment evaluates it.
|
|
16441
|
-
* The value maps 1:1 onto the evaluated record kind:
|
|
16442
|
-
* - `immediate` ↔ object-event persist (lowest-latency detection burst)
|
|
16443
|
-
* - `track-end` ↔ TrackCloser.closeExpired (finalized track record)
|
|
16444
|
-
* - `device-event` ↔ SensorEventStore insert (doorbell press / sensor state
|
|
16445
|
-
* change of a LINKED device, one row per linked camera)
|
|
16446
|
-
* - `package-event` ↔ PackageDropDetector object-event insert (a `package`
|
|
16447
|
-
* delivery / pick-up)
|
|
16448
|
-
*
|
|
16449
|
-
* `immediate`/`track-end` carry the D-3 urgency semantics; `device-event`/
|
|
16450
|
-
* `package-event` are pure trigger kinds (no urgency dimension). Extending
|
|
16451
|
-
* this one field keeps the schema additive — a rule still declares exactly
|
|
16452
|
-
* one trigger.
|
|
16453
|
-
*/
|
|
16454
|
-
var NcDeliverySchema = _enum([
|
|
16455
|
-
"immediate",
|
|
16456
|
-
"track-end",
|
|
16457
|
-
"device-event",
|
|
16458
|
-
"package-event"
|
|
16459
|
-
]);
|
|
16460
|
-
/** Weekly schedule — OR of windows; absence on the rule = always active. */
|
|
16461
|
-
var NcScheduleSchema = object({
|
|
16462
|
-
windows: array(object({
|
|
16463
|
-
/** Days of week the window STARTS on (0 = Sunday … 6 = Saturday). */
|
|
16464
|
-
days: array(number().int().min(0).max(6)).min(1),
|
|
16465
|
-
startMinute: number().int().min(0).max(1439),
|
|
16466
|
-
endMinute: number().int().min(0).max(1439)
|
|
16467
|
-
})).min(1),
|
|
16468
|
-
/** IANA timezone; default = hub host timezone. */
|
|
16469
|
-
timezone: string().optional(),
|
|
16470
|
-
/** Active OUTSIDE the windows (e.g. "only outside business hours"). */
|
|
16471
|
-
invert: boolean().optional()
|
|
16472
|
-
});
|
|
16473
|
-
/** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
|
|
16474
|
-
var NcPlateMatcherSchema = object({
|
|
16475
|
-
values: array(string().min(1)).min(1),
|
|
16476
|
-
/** Max Levenshtein distance after normalization (uppercase alphanumeric). */
|
|
16477
|
-
maxDistance: number().int().min(0).max(3).default(1)
|
|
16478
|
-
});
|
|
16479
|
-
/**
|
|
16480
|
-
* Occupancy condition (DEVICE-EVENT trigger). Fires on a ZoneAnalytics
|
|
16481
|
-
* occupancy edge for a device — optionally narrowed to a single admin
|
|
16482
|
-
* `zoneId` and/or object `className`. `op` selects the edge/threshold:
|
|
16483
|
-
* - `became-occupied` (default) — count crossed 0 → ≥ `count`
|
|
16484
|
-
* - `became-free` — count crossed ≥ `count` → below it
|
|
16485
|
-
* - `>=` / `<=` — count is at/over or at/under `count`
|
|
16486
|
-
* `sustainSeconds` requires the condition hold continuously that long
|
|
16487
|
-
* before firing (debounces flicker; 0 = fire on the first matching edge).
|
|
16488
|
-
* Fail-closed: no ZoneAnalytics snapshot / missing zone / null snapshot ⇒
|
|
16489
|
-
* the condition never matches. Confirmed edge-state survives addon restarts
|
|
16490
|
-
* (declared SQLite collection, reseeded on boot).
|
|
16491
|
-
*/
|
|
16492
|
-
var NcOccupancyConditionSchema = object({
|
|
16493
|
-
/** Admin zone id to scope the count to; absent = whole-frame occupancy. */
|
|
16494
|
-
zoneId: string().optional(),
|
|
16495
|
-
/** Object class to count; absent = any class. */
|
|
16496
|
-
className: string().optional(),
|
|
16497
|
-
op: _enum([
|
|
16498
|
-
"became-occupied",
|
|
16499
|
-
"became-free",
|
|
16500
|
-
">=",
|
|
16501
|
-
"<="
|
|
16502
|
-
]).default("became-occupied"),
|
|
16503
|
-
count: number().int().min(0).default(1),
|
|
16504
|
-
sustainSeconds: number().int().min(0).max(3600).default(15)
|
|
16505
|
-
});
|
|
16506
|
-
/** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
|
|
16507
|
-
var NcZoneConditionSchema = object({
|
|
16508
|
-
ids: array(string().min(1)).min(1),
|
|
16509
|
-
/** Quantifier over `ids` — at least one / every one visited. */
|
|
16510
|
-
match: _enum(["any", "all"]).default("any")
|
|
16511
|
-
});
|
|
16512
|
-
/**
|
|
16513
|
-
* The P1 condition set — a flat AND of groups; absent group = pass;
|
|
16514
|
-
* membership lists are OR within the list (spec §2.3).
|
|
16515
|
-
*/
|
|
16516
|
-
var NcConditionsSchema = object({
|
|
16517
|
-
/** Device scope — absent = all devices. */
|
|
16518
|
-
devices: array(number()).optional(),
|
|
16519
|
-
/** Detector class names (any overlap with the record's class set). */
|
|
16520
|
-
classes: array(string().min(1)).optional(),
|
|
16521
|
-
/** Veto classes — any overlap fails the rule. */
|
|
16522
|
-
classesExclude: array(string().min(1)).optional(),
|
|
16523
|
-
/** Minimum detection confidence 0–1 (fails when the record has none). */
|
|
16524
|
-
minConfidence: number().min(0).max(1).optional(),
|
|
16525
|
-
/** Admin zone membership over event `zones` / track `zonesVisited`. */
|
|
16526
|
-
zones: NcZoneConditionSchema.optional(),
|
|
16527
|
-
/** Veto zones — any hit fails the rule. */
|
|
16528
|
-
zonesExclude: array(string().min(1)).optional(),
|
|
16529
|
-
/**
|
|
16530
|
-
* Exact (case-insensitive) match on the record's collapsed `label`
|
|
16531
|
-
* (identity name / plate text / subclass).
|
|
16532
|
-
*/
|
|
16533
|
-
labelEquals: array(string().min(1)).optional(),
|
|
16534
|
-
/**
|
|
16535
|
-
* Identity matcher. P1 boundary: matched against the record's collapsed
|
|
16536
|
-
* `label` (the identity display name propagated by the face pipeline) —
|
|
16537
|
-
* identity-ID matching rides in P2 when identity ids reach the record.
|
|
16538
|
-
*/
|
|
16539
|
-
identities: array(string().min(1)).optional(),
|
|
16540
|
-
/** Fuzzy plate matcher against the record's `label` (plate text). */
|
|
16541
|
-
plates: NcPlateMatcherSchema.optional(),
|
|
16542
|
-
/**
|
|
16543
|
-
* Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
|
|
16544
|
-
* Same P1 boundary: matched against the record's collapsed `label` (the
|
|
16545
|
-
* identity display name). A record with NO label passes (nothing to
|
|
16546
|
-
* exclude), unlike the include variant which fails on an absent label.
|
|
16547
|
-
*/
|
|
16548
|
-
identitiesExclude: array(string().min(1)).optional(),
|
|
16549
|
-
/**
|
|
16550
|
-
* Minimum server-computed key-event importance in [0,1] (`Track.importance`).
|
|
16551
|
-
* TRACK-END only: importance is scored at track close, so it does not exist
|
|
16552
|
-
* at immediate / object-event evaluation time (see catalog `appliesTo`). At
|
|
16553
|
-
* close the value is threaded via the close-time info (the `Track` clone is
|
|
16554
|
-
* captured before the DB row is updated, so it would otherwise read stale).
|
|
16555
|
-
* Fails when the record carries no importance (never guess quality — the
|
|
16556
|
-
* `minConfidence` precedent). MVP cut: a single scalar threshold.
|
|
16557
|
-
*/
|
|
16558
|
-
minImportance: number().min(0).max(1).optional(),
|
|
16559
|
-
/**
|
|
16560
|
-
* Minimum track dwell in SECONDS — `(lastSeen − firstSeen) / 1000`.
|
|
16561
|
-
* TRACK-END only: an `immediate` / object-event subject has no closed
|
|
16562
|
-
* lifespan, so a dwell condition never matches immediate delivery
|
|
16563
|
-
* (documented choice — the object-event record carries no `firstSeen`,
|
|
16564
|
-
* so dwell cannot be computed from what the subject actually carries).
|
|
16565
|
-
*/
|
|
16566
|
-
minDwellSeconds: number().min(0).optional(),
|
|
16567
|
-
/**
|
|
16568
|
-
* Detection provenance filter. `any` (default / absent) matches every
|
|
16569
|
-
* source; otherwise the subject's source must equal it. Legacy records
|
|
16570
|
-
* with no stamped source are treated as `pipeline`. The union spans both
|
|
16571
|
-
* record kinds — object events carry `pipeline` | `onboard`, synthetic
|
|
16572
|
-
* tracks carry `sensor`.
|
|
16573
|
-
*/
|
|
16574
|
-
source: _enum([
|
|
16575
|
-
"pipeline",
|
|
16576
|
-
"onboard",
|
|
16577
|
-
"sensor",
|
|
16578
|
-
"any"
|
|
16579
|
-
]).optional(),
|
|
16580
|
-
/**
|
|
16581
|
-
* Minimum identity / plate MATCH confidence in [0,1] — DISTINCT from the
|
|
16582
|
-
* detector `minConfidence` (that gates the object-detection score; this
|
|
16583
|
-
* gates the recognition/OCR match score). Fails when the subject carries
|
|
16584
|
-
* no label-match confidence (never guess). TRACK-END only: the confidence
|
|
16585
|
-
* lives on the recognition result and reaches the subject at track close.
|
|
16586
|
-
*
|
|
16587
|
-
* What it measures precisely (plumbed at track close — the closer threads
|
|
16588
|
-
* the value into `NcTrackClosedInfo.labelConfidence`, the same seam as
|
|
16589
|
-
* `importance`): the BEST recognition match confidence observed for the
|
|
16590
|
-
* label the track carries at close — for a face, the peak cosine similarity
|
|
16591
|
-
* of the ASSIGNED identity (`FaceMatch.score`, reset on an identity switch);
|
|
16592
|
-
* for a plate, the peak OCR read score of the best-held plate
|
|
16593
|
-
* (`plateText.confidence`). When BOTH a face and a plate were recognized on
|
|
16594
|
-
* one track the higher of the two is used. A track that ended with no
|
|
16595
|
-
* confident identity/plate match carries no value, so the condition fails
|
|
16596
|
-
* closed for it (an un-recognized subject).
|
|
16597
|
-
*/
|
|
16598
|
-
minLabelConfidence: number().min(0).max(1).optional(),
|
|
16599
|
-
/**
|
|
16600
|
-
* DEVICE-EVENT only. Raw device event-type tokens (`EventFire.eventType`,
|
|
16601
|
-
* e.g. a doorbell `press` / `press_long`) — matched case-insensitively
|
|
16602
|
-
* against the token carried on the device-event subject (extracted from the
|
|
16603
|
-
* event-emitter runtime slice's `lastEvent.eventType`). Fails when the
|
|
16604
|
-
* subject carries no token. Doorbell-pulse / passive-sensor kinds emit no
|
|
16605
|
-
* eventType, so gate those with {@link sensorKinds} instead.
|
|
16606
|
-
*/
|
|
16607
|
-
eventTypeTokens: array(string().min(1)).optional(),
|
|
16608
|
-
/**
|
|
16609
|
-
* DEVICE-EVENT only. Sensor/control taxonomy kinds (e.g. `doorbell`,
|
|
16610
|
-
* `contact`, `button`, `device-event`) — matched against the persisted
|
|
16611
|
-
* `SensorEvent.kind` (see `sensor-event-kinds.ts`). Membership is OR.
|
|
16612
|
-
*/
|
|
16613
|
-
sensorKinds: array(string().min(1)).optional(),
|
|
16614
|
-
/**
|
|
16615
|
-
* PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
|
|
16616
|
-
* (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
|
|
16617
|
-
* when the subject's phase does not match (a subject always carries a phase
|
|
16618
|
-
* on the package-event trigger).
|
|
16619
|
-
*/
|
|
16620
|
-
packagePhase: _enum([
|
|
16621
|
-
"delivered",
|
|
16622
|
-
"picked-up",
|
|
16623
|
-
"both"
|
|
16624
|
-
]).optional(),
|
|
16579
|
+
timestampMs: number()
|
|
16580
|
+
});
|
|
16581
|
+
var NetworkIoSnapshotSchema = object({
|
|
16582
|
+
rxBytes: number(),
|
|
16583
|
+
txBytes: number(),
|
|
16584
|
+
rxPackets: number(),
|
|
16585
|
+
txPackets: number(),
|
|
16586
|
+
rxErrors: number(),
|
|
16587
|
+
txErrors: number(),
|
|
16588
|
+
timestampMs: number()
|
|
16589
|
+
});
|
|
16590
|
+
var MetricsGpuInfoSchema = object({
|
|
16591
|
+
utilization: number(),
|
|
16592
|
+
model: string(),
|
|
16593
|
+
memoryUsedBytes: number(),
|
|
16594
|
+
memoryTotalBytes: number(),
|
|
16595
|
+
temperature: number().nullable()
|
|
16596
|
+
});
|
|
16597
|
+
var ProcessResourceInfoSchema = object({
|
|
16598
|
+
openFds: number(),
|
|
16599
|
+
threadCount: number(),
|
|
16600
|
+
activeHandles: number(),
|
|
16601
|
+
activeRequests: number()
|
|
16602
|
+
});
|
|
16603
|
+
var PressureAvgsSchema = object({
|
|
16604
|
+
avg10: number(),
|
|
16605
|
+
avg60: number(),
|
|
16606
|
+
avg300: number()
|
|
16607
|
+
});
|
|
16608
|
+
var PressureInfoSchema = object({
|
|
16609
|
+
some: PressureAvgsSchema,
|
|
16610
|
+
full: PressureAvgsSchema.nullable()
|
|
16611
|
+
});
|
|
16612
|
+
var SystemResourceSnapshotSchema = object({
|
|
16613
|
+
cpu: CpuBreakdownSchema,
|
|
16614
|
+
memory: MemoryInfoSchema,
|
|
16615
|
+
gpu: MetricsGpuInfoSchema.nullable(),
|
|
16616
|
+
network: NetworkIoSnapshotSchema,
|
|
16617
|
+
disk: DiskIoSnapshotSchema,
|
|
16618
|
+
pressure: object({
|
|
16619
|
+
cpu: PressureInfoSchema.nullable(),
|
|
16620
|
+
memory: PressureInfoSchema.nullable(),
|
|
16621
|
+
io: PressureInfoSchema.nullable()
|
|
16622
|
+
}),
|
|
16623
|
+
process: ProcessResourceInfoSchema,
|
|
16624
|
+
cpuTemperature: number().nullable(),
|
|
16625
|
+
timestampMs: number()
|
|
16626
|
+
});
|
|
16627
|
+
var DiskSpaceInfoSchema = object({
|
|
16628
|
+
path: string(),
|
|
16629
|
+
totalBytes: number(),
|
|
16630
|
+
usedBytes: number(),
|
|
16631
|
+
availableBytes: number(),
|
|
16632
|
+
percent: number()
|
|
16633
|
+
});
|
|
16634
|
+
var PidResourceStatsSchema = object({
|
|
16635
|
+
pid: number(),
|
|
16636
|
+
cpu: number(),
|
|
16637
|
+
memory: number(),
|
|
16625
16638
|
/**
|
|
16626
|
-
*
|
|
16627
|
-
*
|
|
16628
|
-
*
|
|
16629
|
-
*
|
|
16639
|
+
* Private (anonymous) resident bytes — the per-process V8 heap + native
|
|
16640
|
+
* allocations NOT shared with other processes (Linux RssAnon). This is the
|
|
16641
|
+
* "real" per-runner cost; summing it across runners is meaningful, unlike
|
|
16642
|
+
* `memory` (RSS), which double-counts the shared mmap'd framework code.
|
|
16643
|
+
* Undefined where /proc is unavailable (e.g. macOS).
|
|
16630
16644
|
*/
|
|
16631
|
-
|
|
16645
|
+
privateBytes: number().optional(),
|
|
16632
16646
|
/**
|
|
16633
|
-
*
|
|
16634
|
-
*
|
|
16635
|
-
* threshold and holds for `sustainSeconds`. Fail-closed on missing
|
|
16636
|
-
* substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
|
|
16647
|
+
* Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
|
|
16648
|
+
* code shared copy-on-write across runners. Undefined on macOS.
|
|
16637
16649
|
*/
|
|
16638
|
-
|
|
16650
|
+
sharedBytes: number().optional()
|
|
16639
16651
|
});
|
|
16640
|
-
|
|
16641
|
-
|
|
16642
|
-
|
|
16643
|
-
|
|
16644
|
-
|
|
16645
|
-
|
|
16646
|
-
|
|
16647
|
-
|
|
16648
|
-
|
|
16649
|
-
|
|
16652
|
+
var AddonInstanceSchema = object({
|
|
16653
|
+
addonId: string(),
|
|
16654
|
+
nodeId: string(),
|
|
16655
|
+
role: _enum(["hub", "worker"]),
|
|
16656
|
+
pid: number(),
|
|
16657
|
+
state: _enum([
|
|
16658
|
+
"starting",
|
|
16659
|
+
"running",
|
|
16660
|
+
"stopping",
|
|
16661
|
+
"stopped",
|
|
16662
|
+
"crashed"
|
|
16663
|
+
]),
|
|
16664
|
+
uptimeSec: number()
|
|
16665
|
+
});
|
|
16666
|
+
var NodeProcessSchema = object({
|
|
16667
|
+
pid: number(),
|
|
16668
|
+
ppid: number(),
|
|
16669
|
+
pgid: number(),
|
|
16670
|
+
classification: _enum([
|
|
16671
|
+
"root",
|
|
16672
|
+
"managed",
|
|
16673
|
+
"system",
|
|
16674
|
+
"ghost"
|
|
16675
|
+
]),
|
|
16676
|
+
/** `$process` addon binding when `managed`, else null. */
|
|
16677
|
+
addonId: string().nullable(),
|
|
16678
|
+
/** Kernel-reported nodeId when the process is a known agent/worker. */
|
|
16679
|
+
nodeId: string().nullable(),
|
|
16680
|
+
/** Truncated command line. */
|
|
16681
|
+
command: string(),
|
|
16682
|
+
cpuPercent: number(),
|
|
16683
|
+
memoryRssBytes: number(),
|
|
16684
|
+
/** Wall-clock uptime (seconds). Parsed from `ps etime`. */
|
|
16685
|
+
uptimeSec: number(),
|
|
16686
|
+
/** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
|
|
16687
|
+
orphaned: boolean()
|
|
16688
|
+
});
|
|
16689
|
+
var KillProcessInputSchema = object({
|
|
16690
|
+
pid: number(),
|
|
16691
|
+
/** Force = SIGKILL. Default is SIGTERM. */
|
|
16692
|
+
force: boolean().optional()
|
|
16693
|
+
});
|
|
16694
|
+
var KillProcessResultSchema = object({
|
|
16695
|
+
success: boolean(),
|
|
16696
|
+
reason: string().optional(),
|
|
16697
|
+
signal: _enum(["SIGTERM", "SIGKILL"]).optional()
|
|
16698
|
+
});
|
|
16699
|
+
var DumpHeapSnapshotInputSchema = object({
|
|
16700
|
+
/** The addon whose runner should dump a heap snapshot. */
|
|
16701
|
+
addonId: string() });
|
|
16702
|
+
var DumpHeapSnapshotResultSchema = object({
|
|
16703
|
+
success: boolean(),
|
|
16704
|
+
/** Path of the written .heapsnapshot inside the runner's container/host. */
|
|
16705
|
+
path: string().optional(),
|
|
16706
|
+
/** Process pid that was signalled. */
|
|
16707
|
+
pid: number().optional(),
|
|
16708
|
+
reason: string().optional()
|
|
16709
|
+
});
|
|
16710
|
+
var SystemMetricsSchema = object({
|
|
16711
|
+
cpuPercent: number(),
|
|
16712
|
+
memoryPercent: number(),
|
|
16713
|
+
memoryUsedMB: number(),
|
|
16714
|
+
memoryTotalMB: number(),
|
|
16715
|
+
diskPercent: number().optional(),
|
|
16716
|
+
temperature: number().optional(),
|
|
16717
|
+
gpuPercent: number().optional(),
|
|
16718
|
+
gpuMemoryPercent: number().optional()
|
|
16719
|
+
});
|
|
16720
|
+
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, {
|
|
16721
|
+
kind: "mutation",
|
|
16722
|
+
auth: "admin"
|
|
16723
|
+
}), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
|
|
16724
|
+
kind: "mutation",
|
|
16725
|
+
auth: "admin"
|
|
16726
|
+
});
|
|
16727
|
+
method(object({
|
|
16728
|
+
sourceUrl: string(),
|
|
16729
|
+
metadata: ModelConvertMetadataSchema,
|
|
16730
|
+
targets: array(ConvertTargetSchema).min(1).readonly(),
|
|
16731
|
+
calibrationRef: string().optional(),
|
|
16732
|
+
sessionId: string().optional()
|
|
16733
|
+
}), ConvertResultSchema, {
|
|
16734
|
+
kind: "mutation",
|
|
16735
|
+
auth: "admin",
|
|
16736
|
+
timeoutMs: 6e5
|
|
16737
|
+
});
|
|
16738
|
+
method(object({
|
|
16739
|
+
nodeId: string(),
|
|
16740
|
+
modelId: string(),
|
|
16741
|
+
format: _enum(MODEL_FORMATS),
|
|
16742
|
+
entry: ModelCatalogEntrySchema
|
|
16743
|
+
}), object({
|
|
16744
|
+
ok: boolean(),
|
|
16745
|
+
/** sha256 of the staged tarball (empty for a hub-local no-op). */
|
|
16746
|
+
sha256: string(),
|
|
16747
|
+
bytes: number(),
|
|
16748
|
+
/** The target node's modelsDir the artifact landed in. */
|
|
16749
|
+
path: string()
|
|
16750
|
+
}), {
|
|
16751
|
+
kind: "mutation",
|
|
16752
|
+
auth: "admin"
|
|
16650
16753
|
});
|
|
16651
16754
|
/**
|
|
16652
|
-
*
|
|
16653
|
-
*
|
|
16654
|
-
*
|
|
16655
|
-
*
|
|
16656
|
-
*
|
|
16657
|
-
*
|
|
16658
|
-
*
|
|
16659
|
-
*
|
|
16660
|
-
*
|
|
16661
|
-
*
|
|
16662
|
-
*
|
|
16755
|
+
* `mqtt-broker` — broker-registry cap.
|
|
16756
|
+
*
|
|
16757
|
+
* NOT a pub/sub proxy. The cap exposes (a) a registry of configured
|
|
16758
|
+
* MQTT brokers (external + optionally an embedded `aedes`-backed one)
|
|
16759
|
+
* and (b) the connection details a consumer addon needs to spin up
|
|
16760
|
+
* its OWN `mqtt.js` client.
|
|
16761
|
+
*
|
|
16762
|
+
* Why: pub/sub routing over the system event-bus loses fidelity
|
|
16763
|
+
* (callback shape, QoS guarantees, will/retain semantics) and adds
|
|
16764
|
+
* refcount bookkeeping that addons would rather own themselves. The
|
|
16765
|
+
* canonical consumer (`addon-export-ha-mqtt`) needs raw `mqtt.js`
|
|
16766
|
+
* features anyway — give it the connection config, get out of the way.
|
|
16767
|
+
*
|
|
16768
|
+
* Consumer flow:
|
|
16769
|
+
* const cfg = await ctx.api.mqttBroker.getBrokerConfig({ id })
|
|
16770
|
+
* const client = mqtt.connect(cfg.url, { username: cfg.username, … })
|
|
16771
|
+
* client.subscribe('zigbee2mqtt/+')
|
|
16772
|
+
*
|
|
16773
|
+
* Collection mode: multiple brokers (e.g. one local mosquitto + one
|
|
16774
|
+
* cloud bridge). The "embedded" entry (when present) is just another
|
|
16775
|
+
* broker in the registry — its lifecycle is owned by the addon that
|
|
16776
|
+
* spawned it.
|
|
16663
16777
|
*/
|
|
16664
|
-
var
|
|
16665
|
-
|
|
16666
|
-
|
|
16667
|
-
|
|
16668
|
-
|
|
16669
|
-
|
|
16670
|
-
|
|
16671
|
-
|
|
16672
|
-
|
|
16673
|
-
|
|
16674
|
-
|
|
16778
|
+
var BrokerKindSchema = _enum(["external", "embedded"]);
|
|
16779
|
+
/**
|
|
16780
|
+
* Broker live-probe status.
|
|
16781
|
+
*
|
|
16782
|
+
* - `connected` — last probe completed a clean CONNACK
|
|
16783
|
+
* - `disconnected` — no probe has run yet (cold cache)
|
|
16784
|
+
* - `auth-failed` — CONNACK refused with auth error (RC 4 / 5)
|
|
16785
|
+
* - `unreachable` — TCP connect timed out / refused
|
|
16786
|
+
* - `tls-error` — TLS handshake failed (cert / SNI / cipher)
|
|
16787
|
+
*/
|
|
16788
|
+
var BrokerStatusSchema$1 = _enum([
|
|
16789
|
+
"connected",
|
|
16790
|
+
"disconnected",
|
|
16791
|
+
"auth-failed",
|
|
16792
|
+
"unreachable",
|
|
16793
|
+
"tls-error"
|
|
16794
|
+
]);
|
|
16795
|
+
var BrokerInfoSchema = object({
|
|
16796
|
+
id: string(),
|
|
16797
|
+
name: string(),
|
|
16798
|
+
url: string(),
|
|
16799
|
+
kind: BrokerKindSchema,
|
|
16800
|
+
status: BrokerStatusSchema$1,
|
|
16801
|
+
latencyMs: number().nullable(),
|
|
16802
|
+
error: string().optional(),
|
|
16803
|
+
/** Embedded brokers only: number of MQTT clients currently connected. */
|
|
16804
|
+
connectedClients: number().int().nonnegative().optional(),
|
|
16805
|
+
/** Epoch ms of the last live probe (external) or aedes snapshot (embedded). */
|
|
16806
|
+
lastCheckedAt: number().optional()
|
|
16675
16807
|
});
|
|
16676
|
-
/**
|
|
16677
|
-
|
|
16678
|
-
|
|
16679
|
-
|
|
16680
|
-
|
|
16681
|
-
|
|
16682
|
-
|
|
16683
|
-
|
|
16684
|
-
|
|
16685
|
-
|
|
16686
|
-
cooldownSec: 60,
|
|
16687
|
-
scope: "rule-device"
|
|
16688
|
-
}),
|
|
16689
|
-
/** `{{var}}` templating over camera/class/label/zones/confidence/time. */
|
|
16690
|
-
template: object({
|
|
16691
|
-
title: string().max(500).optional(),
|
|
16692
|
-
body: string().max(2e3).optional()
|
|
16693
|
-
}).optional(),
|
|
16694
|
-
/** Canonical notification priority ordinal (1..5); per-target overridable. */
|
|
16695
|
-
priority: number().int().min(1).max(5).default(3),
|
|
16808
|
+
/**
|
|
16809
|
+
* Connection details — what a consumer needs to call
|
|
16810
|
+
* `mqtt.connect(url, options)`. We split URL + credentials so the
|
|
16811
|
+
* consumer can pass them as `mqtt.connect(url, { username, password })`
|
|
16812
|
+
* instead of stuffing creds into the URL (which leaks them into logs).
|
|
16813
|
+
*/
|
|
16814
|
+
var BrokerConnectionDetailsSchema = object({
|
|
16815
|
+
url: string(),
|
|
16816
|
+
username: string().optional(),
|
|
16817
|
+
password: string().optional(),
|
|
16696
16818
|
/**
|
|
16697
|
-
*
|
|
16698
|
-
*
|
|
16699
|
-
*
|
|
16819
|
+
* Suggested prefix for `clientId`. Each consumer should suffix this
|
|
16820
|
+
* with its own discriminator (addon id, instance id) so reconnects
|
|
16821
|
+
* don't kick each other off (MQTT spec: clientId must be unique per
|
|
16822
|
+
* broker).
|
|
16700
16823
|
*/
|
|
16701
|
-
|
|
16824
|
+
clientIdPrefix: string().optional()
|
|
16825
|
+
});
|
|
16826
|
+
var AddBrokerInputSchema = object({
|
|
16827
|
+
name: string().min(1),
|
|
16828
|
+
url: string().regex(/^(mqtt|mqtts|ws|wss):\/\//, "URL must start with mqtt(s):// or ws(s)://"),
|
|
16829
|
+
username: string().optional(),
|
|
16830
|
+
password: string().optional(),
|
|
16831
|
+
clientIdPrefix: string().optional()
|
|
16832
|
+
});
|
|
16833
|
+
var AddBrokerResultSchema = object({ id: string() });
|
|
16834
|
+
var IdInputSchema = object({ id: string() });
|
|
16835
|
+
var TestResultSchema$1 = discriminatedUnion("ok", [object({
|
|
16836
|
+
ok: literal(true),
|
|
16837
|
+
latencyMs: number()
|
|
16838
|
+
}), object({
|
|
16839
|
+
ok: literal(false),
|
|
16840
|
+
error: string()
|
|
16841
|
+
})]);
|
|
16842
|
+
var StartEmbeddedInputSchema = object({
|
|
16843
|
+
port: number().int().min(1).max(65535).default(1883),
|
|
16844
|
+
/** Allow anonymous connect (no username/password). Default: false. */
|
|
16845
|
+
allowAnonymous: boolean().default(false),
|
|
16846
|
+
/** Optional shared username/password for clients. */
|
|
16847
|
+
username: string().optional(),
|
|
16848
|
+
password: string().optional()
|
|
16849
|
+
});
|
|
16850
|
+
var StartEmbeddedResultSchema = object({
|
|
16851
|
+
id: string(),
|
|
16852
|
+
url: string()
|
|
16853
|
+
});
|
|
16854
|
+
var StatusSchema = object({
|
|
16855
|
+
brokerCount: number(),
|
|
16856
|
+
embeddedRunning: boolean()
|
|
16857
|
+
});
|
|
16858
|
+
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);
|
|
16859
|
+
var NetworkEndpointSchema = object({
|
|
16860
|
+
url: string(),
|
|
16861
|
+
hostname: string(),
|
|
16862
|
+
port: number(),
|
|
16863
|
+
protocol: _enum(["http", "https"])
|
|
16864
|
+
});
|
|
16865
|
+
var NetworkAccessStatusSchema = object({
|
|
16866
|
+
connected: boolean(),
|
|
16867
|
+
endpoint: NetworkEndpointSchema.nullable(),
|
|
16868
|
+
error: string().optional()
|
|
16702
16869
|
});
|
|
16703
16870
|
/**
|
|
16704
|
-
*
|
|
16705
|
-
*
|
|
16706
|
-
*
|
|
16707
|
-
*
|
|
16708
|
-
*
|
|
16709
|
-
*
|
|
16710
|
-
* `updateRule` patch.
|
|
16871
|
+
* Optional, richer endpoint shape returned by providers that expose
|
|
16872
|
+
* MORE than one ingress concurrently (Tailscale Ingress with mixed
|
|
16873
|
+
* serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
|
|
16874
|
+
* the originating provider config (mode + sourcePort) so the
|
|
16875
|
+
* orchestrator UI can label rows distinctly. Providers that expose only
|
|
16876
|
+
* one endpoint just omit `listEndpoints` from their provider impl.
|
|
16711
16877
|
*/
|
|
16712
|
-
var
|
|
16713
|
-
/** A persisted rule. */
|
|
16714
|
-
var NcRuleSchema = NcRuleInputSchema.extend({
|
|
16715
|
-
id: string(),
|
|
16716
|
-
/** userId of the admin who created the rule (server-stamped caller). */
|
|
16717
|
-
createdBy: string(),
|
|
16718
|
-
createdAt: number(),
|
|
16719
|
-
updatedAt: number(),
|
|
16878
|
+
var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
|
|
16720
16879
|
/**
|
|
16721
|
-
*
|
|
16722
|
-
*
|
|
16723
|
-
* in `nc.setRuleTargetEnabled`). Defaults to empty.
|
|
16880
|
+
* Stable id within the provider — typically `<mode>-<sourcePort>` so
|
|
16881
|
+
* the orchestrator can dedupe across `listEndpoints` polls.
|
|
16724
16882
|
*/
|
|
16725
|
-
|
|
16726
|
-
|
|
16727
|
-
|
|
16728
|
-
|
|
16729
|
-
|
|
16730
|
-
|
|
16731
|
-
|
|
16732
|
-
"device-event",
|
|
16733
|
-
"package-event"
|
|
16734
|
-
]),
|
|
16735
|
-
deviceId: number(),
|
|
16736
|
-
timestamp: number(),
|
|
16737
|
-
wouldFire: boolean(),
|
|
16738
|
-
/** Condition id that failed (first failing group), when `wouldFire` is false. */
|
|
16739
|
-
failedCondition: string().optional(),
|
|
16740
|
-
className: string().optional(),
|
|
16741
|
-
label: string().optional()
|
|
16883
|
+
id: string(),
|
|
16884
|
+
/** Operator-facing label (mirrors `MeshEndpoint.label`). */
|
|
16885
|
+
label: string(),
|
|
16886
|
+
/** Optional provider-specific mode tag, used for icon/colour in admin UI. */
|
|
16887
|
+
mode: string().optional(),
|
|
16888
|
+
/** Originating local port the ingress fronts (informational). */
|
|
16889
|
+
sourcePort: number().optional()
|
|
16742
16890
|
});
|
|
16743
|
-
|
|
16744
|
-
|
|
16891
|
+
method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
|
|
16892
|
+
/**
|
|
16893
|
+
* notification-output — canonical, capability-gated notification delivery.
|
|
16894
|
+
*
|
|
16895
|
+
* Apprise-derived model (see
|
|
16896
|
+
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
16897
|
+
* callers emit ONE canonical `Notification`; each provider declares a
|
|
16898
|
+
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
16899
|
+
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
16900
|
+
* message to what the kind supports — callers never special-case a service.
|
|
16901
|
+
*
|
|
16902
|
+
* DESIGN DECISIONS (locked):
|
|
16903
|
+
* - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
|
|
16904
|
+
* `setTargetEnabled`), each provider persisting via the `settings-store`
|
|
16905
|
+
* cap. Rationale: the admin UI needs one uniform surface across the
|
|
16906
|
+
* notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
|
|
16907
|
+
* alternative would fork the UI per addon and cannot host the
|
|
16908
|
+
* discovery→adopt flow.
|
|
16909
|
+
* - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
|
|
16910
|
+
* the generated cap-mount auto-`concatCollection`-fans them across every
|
|
16911
|
+
* registered provider (notifiers addon + HA addon) so one catalog is
|
|
16912
|
+
* routable. `send` / `testTarget` / CRUD route to ONE provider by the
|
|
16913
|
+
* `addonId` the generated collection router extracts from the call input.
|
|
16914
|
+
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
16915
|
+
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
16916
|
+
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
16917
|
+
* base64 fallback needed.
|
|
16918
|
+
*
|
|
16919
|
+
* TODO (deferred, closed-set change — separate decision): add
|
|
16920
|
+
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
16921
|
+
* admin "Integrations" page.
|
|
16922
|
+
*/
|
|
16923
|
+
/**
|
|
16924
|
+
* Zentik-derived typed-media enum — the superset across every kind. Each
|
|
16925
|
+
* adapter picks what it supports and the degrade engine filters the rest.
|
|
16926
|
+
*/
|
|
16927
|
+
var AttachmentMediaTypeSchema = _enum([
|
|
16928
|
+
"image",
|
|
16929
|
+
"video",
|
|
16930
|
+
"gif",
|
|
16931
|
+
"audio",
|
|
16932
|
+
"icon"
|
|
16933
|
+
]);
|
|
16934
|
+
/**
|
|
16935
|
+
* A single attachment. Exactly one of `url` (remote source, most adapters
|
|
16936
|
+
* prefer this) or `bytes` (inline source; required for Pushover-style
|
|
16937
|
+
* bytes-only kinds) MUST be present — the degrade engine expresses a
|
|
16938
|
+
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
16939
|
+
*/
|
|
16940
|
+
var AttachmentSchema = object({
|
|
16941
|
+
mediaType: AttachmentMediaTypeSchema,
|
|
16942
|
+
url: string().optional(),
|
|
16943
|
+
bytes: _instanceof(Uint8Array).optional(),
|
|
16944
|
+
mime: string().optional(),
|
|
16945
|
+
name: string().optional()
|
|
16946
|
+
}).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
|
|
16947
|
+
var NotificationFormatSchema = _enum([
|
|
16948
|
+
"text",
|
|
16949
|
+
"markdown",
|
|
16950
|
+
"html"
|
|
16951
|
+
]);
|
|
16952
|
+
/** A single tap-through action button. */
|
|
16953
|
+
var NotificationActionSchema = object({
|
|
16745
16954
|
id: string(),
|
|
16746
|
-
group: _enum([
|
|
16747
|
-
"scope",
|
|
16748
|
-
"class",
|
|
16749
|
-
"zones",
|
|
16750
|
-
"quality",
|
|
16751
|
-
"label",
|
|
16752
|
-
"schedule",
|
|
16753
|
-
"device",
|
|
16754
|
-
"package",
|
|
16755
|
-
"occupancy"
|
|
16756
|
-
]),
|
|
16757
16955
|
label: string(),
|
|
16758
|
-
|
|
16759
|
-
|
|
16760
|
-
|
|
16761
|
-
|
|
16762
|
-
|
|
16763
|
-
|
|
16764
|
-
|
|
16765
|
-
|
|
16766
|
-
|
|
16767
|
-
|
|
16768
|
-
|
|
16769
|
-
|
|
16770
|
-
|
|
16771
|
-
|
|
16772
|
-
|
|
16773
|
-
|
|
16774
|
-
|
|
16775
|
-
|
|
16776
|
-
|
|
16777
|
-
|
|
16778
|
-
|
|
16779
|
-
|
|
16780
|
-
|
|
16781
|
-
|
|
16782
|
-
|
|
16783
|
-
|
|
16784
|
-
|
|
16956
|
+
url: string().optional()
|
|
16957
|
+
});
|
|
16958
|
+
/**
|
|
16959
|
+
* The canonical notification. `body` is the only hard field (Apprise model).
|
|
16960
|
+
* `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
|
|
16961
|
+
* NOT a fixed severity enum — each kind declares its own `caps.levels` and
|
|
16962
|
+
* the adapter maps this ordinal onto its native level. `level?` is an
|
|
16963
|
+
* optional kind-native level id (`emergency`, `silent`, …) that overrides
|
|
16964
|
+
* `priority` for that one target.
|
|
16965
|
+
*/
|
|
16966
|
+
var NotificationSchema = object({
|
|
16967
|
+
body: string(),
|
|
16968
|
+
title: string().optional(),
|
|
16969
|
+
format: NotificationFormatSchema.default("text"),
|
|
16970
|
+
priority: number().int().min(1).max(5).default(3),
|
|
16971
|
+
level: string().optional(),
|
|
16972
|
+
attachments: array(AttachmentSchema).optional(),
|
|
16973
|
+
clickUrl: string().optional(),
|
|
16974
|
+
actions: array(NotificationActionSchema).optional(),
|
|
16975
|
+
sound: string().optional(),
|
|
16976
|
+
ttl: number().optional(),
|
|
16977
|
+
tag: string().optional(),
|
|
16978
|
+
deviceId: number().optional(),
|
|
16979
|
+
eventId: string().optional(),
|
|
16980
|
+
metadata: record(string(), unknown()).optional()
|
|
16981
|
+
});
|
|
16982
|
+
/** One declared native severity/priority level for a kind. */
|
|
16983
|
+
var TargetKindLevelSchema = object({
|
|
16984
|
+
id: string(),
|
|
16985
|
+
label: string(),
|
|
16986
|
+
/** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
|
|
16987
|
+
ordinal: number().int().min(1).max(5).nullable(),
|
|
16988
|
+
flags: object({
|
|
16989
|
+
critical: boolean().optional(),
|
|
16990
|
+
silent: boolean().optional(),
|
|
16991
|
+
noPush: boolean().optional()
|
|
16992
|
+
}).optional(),
|
|
16993
|
+
/** e.g. Pushover `emergency` requires `retry` / `expire`. */
|
|
16994
|
+
requires: array(string()).optional(),
|
|
16785
16995
|
description: string().optional()
|
|
16786
16996
|
});
|
|
16997
|
+
/** The full capability block consulted before dispatch. */
|
|
16998
|
+
var TargetKindCapsSchema = object({
|
|
16999
|
+
attachments: object({
|
|
17000
|
+
mediaTypes: array(AttachmentMediaTypeSchema),
|
|
17001
|
+
mode: _enum([
|
|
17002
|
+
"url",
|
|
17003
|
+
"bytes",
|
|
17004
|
+
"both"
|
|
17005
|
+
]),
|
|
17006
|
+
max: number().int().nonnegative(),
|
|
17007
|
+
maxBytes: number().int().positive().optional()
|
|
17008
|
+
}),
|
|
17009
|
+
/** Max action buttons (0 = none). */
|
|
17010
|
+
actions: number().int().nonnegative(),
|
|
17011
|
+
levels: array(TargetKindLevelSchema),
|
|
17012
|
+
format: array(NotificationFormatSchema),
|
|
17013
|
+
clickUrl: boolean(),
|
|
17014
|
+
sound: boolean(),
|
|
17015
|
+
ttl: boolean(),
|
|
17016
|
+
bodyMaxLen: number().int().positive()
|
|
17017
|
+
});
|
|
16787
17018
|
/**
|
|
16788
|
-
*
|
|
16789
|
-
*
|
|
16790
|
-
*
|
|
16791
|
-
*
|
|
16792
|
-
*
|
|
16793
|
-
* backend rejection / a deleted target (terminal; carries
|
|
16794
|
-
* the failure `error`)
|
|
16795
|
-
*
|
|
16796
|
-
* P1 has no `suppressed-quiet-hours` / `snoozed` states — those ride the P2
|
|
16797
|
-
* user dimension (quiet hours / snooze) and are additive when they land.
|
|
17019
|
+
* `configSchema` is a `ConfigUISchema` tree passed through to the admin
|
|
17020
|
+
* FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
|
|
17021
|
+
* `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
|
|
17022
|
+
* the union is large and not meant for runtime validation here; the exported
|
|
17023
|
+
* `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
|
|
16798
17024
|
*/
|
|
16799
|
-
var
|
|
16800
|
-
|
|
16801
|
-
|
|
16802
|
-
|
|
16803
|
-
|
|
16804
|
-
/**
|
|
16805
|
-
|
|
16806
|
-
|
|
16807
|
-
|
|
16808
|
-
|
|
16809
|
-
"package-event"
|
|
16810
|
-
]);
|
|
16811
|
-
/** Subject summary frozen on the row at fire time (survives rule/record edits). */
|
|
16812
|
-
var NcHistorySubjectSchema = object({
|
|
16813
|
-
className: string(),
|
|
16814
|
-
label: string().optional(),
|
|
16815
|
-
confidence: number().optional(),
|
|
16816
|
-
zones: array(string()),
|
|
16817
|
-
timestamp: number()
|
|
17025
|
+
var ConfigSchemaPassthrough = unknown();
|
|
17026
|
+
var TargetKindSchema = object({
|
|
17027
|
+
kind: string(),
|
|
17028
|
+
label: string(),
|
|
17029
|
+
icon: string(),
|
|
17030
|
+
/** Stamped by each provider so the concat-fanned catalog stays routable. */
|
|
17031
|
+
addonId: string(),
|
|
17032
|
+
configSchema: ConfigSchemaPassthrough,
|
|
17033
|
+
supportsDiscovery: boolean(),
|
|
17034
|
+
caps: TargetKindCapsSchema
|
|
16818
17035
|
});
|
|
16819
17036
|
/**
|
|
16820
|
-
*
|
|
16821
|
-
*
|
|
16822
|
-
*
|
|
16823
|
-
* The §3.2 fields map directly: `ruleId`/`targetId`/`deviceId` are columns,
|
|
16824
|
-
* `eventRef` is `recordKind`+`recordId`, `timestamps` are `createdAt`
|
|
16825
|
-
* (fire) / `updatedAt` (last transition), `status` + `error` are the
|
|
16826
|
-
* lifecycle. `ruleName` + `subject` are the intent snapshot frozen at
|
|
16827
|
-
* enqueue. `userId?` (per-recipient history) is P2 — no user dimension in
|
|
16828
|
-
* P1 (admin scope only).
|
|
17037
|
+
* A persisted target. `config` holds secrets; providers REDACT secret fields
|
|
17038
|
+
* (return a presence marker only) when serving `listTargets` — never
|
|
17039
|
+
* round-trip a stored secret to the UI.
|
|
16829
17040
|
*/
|
|
16830
|
-
var
|
|
16831
|
-
/** Outbox row id — the stable dedup id `ruleId:dedupRef:targetId`. */
|
|
17041
|
+
var TargetSchema = object({
|
|
16832
17042
|
id: string(),
|
|
16833
|
-
|
|
16834
|
-
|
|
16835
|
-
|
|
16836
|
-
|
|
16837
|
-
|
|
16838
|
-
targetId: string(),
|
|
16839
|
-
deviceId: number(),
|
|
16840
|
-
recordKind: NcHistoryRecordKindSchema,
|
|
16841
|
-
/** Event / track ref of the evaluated record (§3.2 `eventRef`). */
|
|
16842
|
-
recordId: string(),
|
|
16843
|
-
/** Present for track-scoped deliveries (object-event / track-end). */
|
|
16844
|
-
trackId: string().optional(),
|
|
16845
|
-
status: NcHistoryStatusSchema,
|
|
16846
|
-
/** Delivery attempts made so far. */
|
|
16847
|
-
attempts: number().int(),
|
|
16848
|
-
/** Fire time (outbox enqueue). */
|
|
16849
|
-
createdAt: number(),
|
|
16850
|
-
/** Last transition time (terminal for sent / dead). */
|
|
16851
|
-
updatedAt: number(),
|
|
16852
|
-
/** Failure detail — present on a `dead` row. */
|
|
16853
|
-
error: string().optional(),
|
|
16854
|
-
subject: NcHistorySubjectSchema
|
|
17043
|
+
name: string(),
|
|
17044
|
+
kind: string(),
|
|
17045
|
+
addonId: string(),
|
|
17046
|
+
enabled: boolean(),
|
|
17047
|
+
config: record(string(), unknown())
|
|
16855
17048
|
});
|
|
16856
|
-
/**
|
|
16857
|
-
|
|
16858
|
-
|
|
16859
|
-
|
|
16860
|
-
|
|
16861
|
-
*/
|
|
16862
|
-
var NcHistoryFilterSchema = object({
|
|
16863
|
-
ruleId: string().optional(),
|
|
16864
|
-
deviceId: number().optional(),
|
|
16865
|
-
status: NcHistoryStatusSchema.optional(),
|
|
16866
|
-
since: number().optional(),
|
|
16867
|
-
until: number().optional(),
|
|
16868
|
-
limit: number().int().min(1).max(500).default(100)
|
|
17049
|
+
/** A discovery-surfaced candidate (config is partial + non-secret). */
|
|
17050
|
+
var DiscoveredTargetSchema = object({
|
|
17051
|
+
kind: string(),
|
|
17052
|
+
suggestedName: string(),
|
|
17053
|
+
config: record(string(), unknown())
|
|
16869
17054
|
});
|
|
16870
|
-
|
|
16871
|
-
|
|
16872
|
-
|
|
16873
|
-
|
|
16874
|
-
|
|
16875
|
-
|
|
16876
|
-
|
|
16877
|
-
|
|
16878
|
-
|
|
16879
|
-
|
|
16880
|
-
|
|
16881
|
-
|
|
16882
|
-
|
|
16883
|
-
|
|
16884
|
-
|
|
16885
|
-
|
|
16886
|
-
|
|
16887
|
-
|
|
16888
|
-
|
|
16889
|
-
|
|
16890
|
-
|
|
16891
|
-
|
|
16892
|
-
|
|
16893
|
-
|
|
16894
|
-
|
|
16895
|
-
|
|
16896
|
-
}),
|
|
17055
|
+
/** The degrade engine's report — what was resolved / dropped / degraded. */
|
|
17056
|
+
var RenderedAsSchema = object({
|
|
17057
|
+
level: string(),
|
|
17058
|
+
format: NotificationFormatSchema,
|
|
17059
|
+
attachmentsSent: number().int().nonnegative(),
|
|
17060
|
+
actionsSent: number().int().nonnegative(),
|
|
17061
|
+
truncated: boolean(),
|
|
17062
|
+
dropped: array(string())
|
|
17063
|
+
});
|
|
17064
|
+
var SendResultSchema = object({
|
|
17065
|
+
success: boolean(),
|
|
17066
|
+
error: string().optional(),
|
|
17067
|
+
renderedAs: RenderedAsSchema.optional()
|
|
17068
|
+
});
|
|
17069
|
+
/** Same shape as SendResult — kept as a distinct name for the test panel. */
|
|
17070
|
+
var TestResultSchema = SendResultSchema;
|
|
17071
|
+
var notificationOutputCapability = {
|
|
17072
|
+
name: "notification-output",
|
|
17073
|
+
scope: "system",
|
|
17074
|
+
mode: "collection",
|
|
17075
|
+
methods: {
|
|
17076
|
+
listTargetKinds: method(object({}), array(TargetKindSchema)),
|
|
17077
|
+
listTargets: method(object({}), array(TargetSchema)),
|
|
17078
|
+
discoverTargets: method(object({
|
|
17079
|
+
kind: string(),
|
|
17080
|
+
config: record(string(), unknown()).optional()
|
|
17081
|
+
}), array(DiscoveredTargetSchema)),
|
|
17082
|
+
send: method(object({
|
|
17083
|
+
targetId: string(),
|
|
17084
|
+
notification: NotificationSchema
|
|
17085
|
+
}), SendResultSchema, { kind: "mutation" }),
|
|
17086
|
+
testTarget: method(object({
|
|
17087
|
+
targetId: string(),
|
|
17088
|
+
sample: NotificationSchema.optional()
|
|
17089
|
+
}), TestResultSchema, { kind: "mutation" }),
|
|
17090
|
+
upsertTarget: method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }),
|
|
17091
|
+
deleteTarget: method(object({ targetId: string() }), _void(), { kind: "mutation" }),
|
|
17092
|
+
setTargetEnabled: method(object({
|
|
17093
|
+
targetId: string(),
|
|
17094
|
+
enabled: boolean()
|
|
17095
|
+
}), _void(), { kind: "mutation" })
|
|
17096
|
+
}
|
|
17097
|
+
};
|
|
16897
17098
|
/**
|
|
16898
17099
|
* Zod schemas for persisted record types.
|
|
16899
17100
|
*
|
|
@@ -21898,6 +22099,12 @@ Object.freeze({
|
|
|
21898
22099
|
addonId: null,
|
|
21899
22100
|
access: "delete"
|
|
21900
22101
|
},
|
|
22102
|
+
"backup.deleteSchedule": {
|
|
22103
|
+
capName: "backup",
|
|
22104
|
+
capScope: "system",
|
|
22105
|
+
addonId: null,
|
|
22106
|
+
access: "delete"
|
|
22107
|
+
},
|
|
21901
22108
|
"backup.getEntries": {
|
|
21902
22109
|
capName: "backup",
|
|
21903
22110
|
capScope: "system",
|
|
@@ -21928,6 +22135,12 @@ Object.freeze({
|
|
|
21928
22135
|
addonId: null,
|
|
21929
22136
|
access: "view"
|
|
21930
22137
|
},
|
|
22138
|
+
"backup.listSchedules": {
|
|
22139
|
+
capName: "backup",
|
|
22140
|
+
capScope: "system",
|
|
22141
|
+
addonId: null,
|
|
22142
|
+
access: "view"
|
|
22143
|
+
},
|
|
21931
22144
|
"backup.previewSchedule": {
|
|
21932
22145
|
capName: "backup",
|
|
21933
22146
|
capScope: "system",
|
|
@@ -21952,6 +22165,12 @@ Object.freeze({
|
|
|
21952
22165
|
addonId: null,
|
|
21953
22166
|
access: "create"
|
|
21954
22167
|
},
|
|
22168
|
+
"backup.upsertSchedule": {
|
|
22169
|
+
capName: "backup",
|
|
22170
|
+
capScope: "system",
|
|
22171
|
+
addonId: null,
|
|
22172
|
+
access: "create"
|
|
22173
|
+
},
|
|
21955
22174
|
"battery.wakeForStream": {
|
|
21956
22175
|
capName: "battery",
|
|
21957
22176
|
capScope: "device",
|
|
@@ -25786,6 +26005,36 @@ Object.freeze({
|
|
|
25786
26005
|
addonId: null,
|
|
25787
26006
|
access: "create"
|
|
25788
26007
|
},
|
|
26008
|
+
"terminalSession.close": {
|
|
26009
|
+
capName: "terminal-session",
|
|
26010
|
+
capScope: "system",
|
|
26011
|
+
addonId: null,
|
|
26012
|
+
access: "create"
|
|
26013
|
+
},
|
|
26014
|
+
"terminalSession.listProfiles": {
|
|
26015
|
+
capName: "terminal-session",
|
|
26016
|
+
capScope: "system",
|
|
26017
|
+
addonId: null,
|
|
26018
|
+
access: "view"
|
|
26019
|
+
},
|
|
26020
|
+
"terminalSession.listSessions": {
|
|
26021
|
+
capName: "terminal-session",
|
|
26022
|
+
capScope: "system",
|
|
26023
|
+
addonId: null,
|
|
26024
|
+
access: "view"
|
|
26025
|
+
},
|
|
26026
|
+
"terminalSession.openSession": {
|
|
26027
|
+
capName: "terminal-session",
|
|
26028
|
+
capScope: "system",
|
|
26029
|
+
addonId: null,
|
|
26030
|
+
access: "create"
|
|
26031
|
+
},
|
|
26032
|
+
"terminalSession.resize": {
|
|
26033
|
+
capName: "terminal-session",
|
|
26034
|
+
capScope: "system",
|
|
26035
|
+
addonId: null,
|
|
26036
|
+
access: "create"
|
|
26037
|
+
},
|
|
25789
26038
|
"toast.onToast": {
|
|
25790
26039
|
capName: "toast",
|
|
25791
26040
|
capScope: "system",
|