@camstack/addon-agent-ui 1.2.134 → 1.2.136

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.
Files changed (2) hide show
  1. package/dist/addon.js +273 -18
  2. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -5361,7 +5361,7 @@ var ZodIssueCode = {
5361
5361
  var ZodFirstPartyTypeKind;
5362
5362
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5363
5363
  //#endregion
5364
- //#region ../types/dist/sleep-CaB_hL5g.mjs
5364
+ //#region ../types/dist/sleep-BVhJDJka.mjs
5365
5365
  /**
5366
5366
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5367
5367
  * window to float samples (D455).
@@ -6932,6 +6932,18 @@ function systemMethod(input, output, options) {
6932
6932
  systemOnly: true
6933
6933
  };
6934
6934
  }
6935
+ /**
6936
+ * A method a SOURCE of a collection cap may legitimately not serve — OPTIONAL
6937
+ * on `InferProvider`. The `providerOptional: true` literal is what
6938
+ * `InferProvider` keys on; see {@link CapabilityMethodSchema.providerOptional}
6939
+ * for when this is the honest answer and when it is a soft stub.
6940
+ */
6941
+ function optionalMethod(input, output, options) {
6942
+ return {
6943
+ ...method(input, output, options),
6944
+ providerOptional: true
6945
+ };
6946
+ }
6935
6947
  var StaticDirOutputSchema$1 = object({ staticDir: string() });
6936
6948
  var VersionOutputSchema$1 = object({ version: string() });
6937
6949
  var adminUiCapability = {
@@ -24194,6 +24206,59 @@ var ClipPlaybackSchema = object({
24194
24206
  * which days it asked for and got nothing — "no clips" would be a lie about a
24195
24207
  * card that is full of them.
24196
24208
  */
24209
+ /**
24210
+ * The operator's authorisation to WAKE a sleeping camera for one clip read.
24211
+ *
24212
+ * ONE value, absent by default, and it is a `force`-shaped operator signal in
24213
+ * exactly the sense `snapshot-wake-gate.ts` uses the word: *"`snapshot.getSnapshot`'s
24214
+ * `force` flag, and nothing else… a background caller must never set it…
24215
+ * Stale but honest beats woken"*. A scheduler, a retry, a reconcile and a
24216
+ * prefetch never set it; a surface sets it only behind the same confirm the
24217
+ * "Wake and refresh" gesture uses, and it is refused below 15 % battery
24218
+ * exactly as that gesture is.
24219
+ *
24220
+ * The gate is decided BEFORE `getApi()`, because on UDP the login IS the wake
24221
+ * (D549) — a read that opened a session and then checked would have woken the
24222
+ * camera to find out it was not allowed to.
24223
+ *
24224
+ * **One authorised yes is one wake.** `next-natural` — take the clip the next
24225
+ * time the camera is awake for its own reasons — is deliberately not a member:
24226
+ * it was proposed, it is free on the battery, and the operator declined it on
24227
+ * 2026-09-20 (*"Quando un export viene richiesto si sveglia la camera."*,
24228
+ * D558 "Considered and not taken").
24229
+ */
24230
+ var ClipWakeSchema = _enum(["authorised"]);
24231
+ /**
24232
+ * A clip's finished bytes, inline — the twin of `recordingExport.readExportBytes`.
24233
+ *
24234
+ * `bytes` is the DECODED length, so nobody infers it from the base64 length,
24235
+ * and `served` says which twin the caller actually got.
24236
+ */
24237
+ var ClipBytesSchema = object({
24238
+ base64: string(),
24239
+ contentType: string(),
24240
+ /** Suggested filename, extension included. */
24241
+ name: string(),
24242
+ bytes: number().int().nonnegative(),
24243
+ /**
24244
+ * Which twin was actually served — the same contract
24245
+ * {@link ClipPlaybackSchema.served} carries, and REQUIRED here because the
24246
+ * export record persists it: a row read a week later must say the same thing
24247
+ * the panel said at the moment of the tap. A missing main twin is never
24248
+ * served silently as if it were the asked-for quality (D549 15).
24249
+ */
24250
+ served: CamProfileSchema,
24251
+ /**
24252
+ * The DECODED duration of the delivered file, when the fetch measured one.
24253
+ *
24254
+ * A clip fetch verifies its own completion against the catalog row and
24255
+ * retries a materially short pass (D568); this is that measurement, carried
24256
+ * so a consumer can say the same thing rather than re-deriving it. Absent
24257
+ * when the producer did not measure — never zero, which would say the file
24258
+ * is empty.
24259
+ */
24260
+ durationMs: number().positive().optional()
24261
+ });
24197
24262
  var ClipSourceAvailabilitySchema = object({
24198
24263
  state: _enum([
24199
24264
  "ok",
@@ -24250,22 +24315,40 @@ DeviceType.Camera, method(object({
24250
24315
  limit: number().int().positive().optional(),
24251
24316
  /**
24252
24317
  * WHICH provider to ask — the `addonId` a {@link ClipSourceSchema} row
24253
- * carries, never a source id and never a list.
24254
- *
24255
- * Absent means the device's BOUND provider, which is CamStack on every
24256
- * camera today because that is what `deviceManager.getBindings`
24257
- * answers with. A provider the device is not bound to is refused by
24258
- * name rather than answered by another one (D552's
24259
- * `rejectUnresolvedAddonPin` rule).
24318
+ * carries, never a source id and never a list. **Required** (D554 amended).
24319
+ *
24320
+ * A provider the device is not bound to is refused by name rather than
24321
+ * answered by another one (D552's `rejectUnresolvedAddonPin` rule).
24322
+ *
24323
+ * It was optional, documented as "absent means the device's BOUND
24324
+ * provider, which is CamStack on every camera". No code implemented
24325
+ * that. Measured on the live hub 2026-09-20 — device 592, bound to
24326
+ * `recorder` AND `provider-reolink` — a bare call with `limit: 3`
24327
+ * answered SIX rows, three from each source, merged newest-first:
24328
+ * `device-collection-dispatch.ts` simply left the fan-out un-narrowed,
24329
+ * so absence bought the union this method exists not to be, and
24330
+ * `limit` meant `limit × sources`.
24331
+ *
24332
+ * There is nothing to restore the default to. `getBindings` answers a
24333
+ * collection cap with a DERIVED, PLURAL set (D554 amended, step 0);
24334
+ * `setWrapperActive` — the singleton authority that could name one —
24335
+ * throws for a collection cap by design. Naming CamStack here instead
24336
+ * would privilege one addon by id inside a surface whose premise is
24337
+ * that sources are peers, and would be wrong on the first camera with
24338
+ * no recorder binding. So absence is REFUSED, in the schema, where the
24339
+ * generated types make it unomittable rather than merely discouraged.
24340
+ *
24341
+ * The default belongs to the SURFACE, which has the `listSources` rows
24342
+ * and can say which one it picked (D569 § 1–3; the viewer already
24343
+ * always sends this).
24260
24344
  *
24261
24345
  * It replaced `sources?: string[]`, a VIEW filter over source ids that
24262
24346
  * assumed the answer was a fan-out over everything a camera has. The
24263
- * operator settled otherwise on 2026-09-20 — *"il get videoclips
24264
- * prendere un provider opzionale, di default va su camstack"*,
24265
- * *"l'utilizzatore è uno solo"* — so the list is asked of one provider
24266
- * at a time and there is nothing to filter out of it.
24347
+ * operator settled otherwise on 2026-09-20 — *"l'utilizzatore è uno
24348
+ * solo"* — so the list is asked of one provider at a time and there is
24349
+ * nothing to filter out of it.
24267
24350
  */
24268
- provider: string().optional()
24351
+ provider: string().min(1)
24269
24352
  }), array(ClipSchema).readonly(), {
24270
24353
  kind: "query",
24271
24354
  auth: "protected"
@@ -24291,6 +24374,33 @@ DeviceType.Camera, method(object({
24291
24374
  }), ClipPlaybackSchema, {
24292
24375
  kind: "query",
24293
24376
  auth: "protected"
24377
+ }), optionalMethod(object({
24378
+ deviceId: number(),
24379
+ clipId: string().min(1),
24380
+ /**
24381
+ * Which twin to fetch, on the mapping D549 15 already fixed:
24382
+ * `low | mid` → the sub file, `high` → the main twin. `auto` is not
24383
+ * accepted here for the same reason it is not accepted by
24384
+ * `getClipPlayback` — a stored file has no broker session, so the
24385
+ * adaptive tier cannot be resolved for it.
24386
+ */
24387
+ profile: CamProfileSchema.optional(),
24388
+ /**
24389
+ * The CALLER's byte bound, so an over-size clip is refused before it is
24390
+ * read and encoded rather than after. Capped by
24391
+ * {@link VIDEOCLIPS_MAX_READ_BYTES} whatever is passed; absent means
24392
+ * that ceiling.
24393
+ */
24394
+ maxBytes: number().int().positive().optional(),
24395
+ /**
24396
+ * The operator's authorisation to wake a sleeping camera for this
24397
+ * read. Absent — the default — means a sleeping standalone battery
24398
+ * camera is REFUSED by name, before any session is opened.
24399
+ */
24400
+ wake: ClipWakeSchema.optional()
24401
+ }), ClipBytesSchema, {
24402
+ kind: "query",
24403
+ auth: "protected"
24294
24404
  });
24295
24405
  /**
24296
24406
  * Optional client-side hints sent at session creation to help the provider
@@ -30223,13 +30333,101 @@ var ExportStateSchema = _enum([
30223
30333
  "expired",
30224
30334
  "deleted"
30225
30335
  ]);
30226
- /** One export job / history row. */
30336
+ /**
30337
+ * WHAT an export is — the authority, as opposed to the four top-level fields
30338
+ * the Library sorts and labels on (D558 § 2.2).
30339
+ *
30340
+ * Read it through {@link exportSubjectOf}, never off the record directly: the
30341
+ * field is optional for the history rows written before it existed, and that
30342
+ * absence has exactly one interpreter.
30343
+ */
30344
+ var ExportSubjectSchema = discriminatedUnion("kind", [object({
30345
+ kind: literal("footage"),
30346
+ deviceId: number(),
30347
+ profiles: array(string()).min(1),
30348
+ fromMs: number(),
30349
+ toMs: number()
30350
+ }), object({
30351
+ kind: literal("clip"),
30352
+ deviceId: number(),
30353
+ provider: string().min(1),
30354
+ source: string().min(1),
30355
+ sourceLabel: string().min(1),
30356
+ clipId: string().min(1),
30357
+ /**
30358
+ * WHERE IN THE CATALOG to confirm this clip — the day window the surface was
30359
+ * already listing when the operator picked the segment.
30360
+ *
30361
+ * It is **not** a time range control and it never becomes one: the record's
30362
+ * `fromMs`/`toMs` come from the catalog ROW and from nothing a caller
30363
+ * supplied (D558 § 5.4.3), and a window that does not contain the clip is a
30364
+ * `catalog-miss`, not a silently wider search. It exists because
30365
+ * `videoclips.listClips` takes `since`/`until` and has no by-handle twin:
30366
+ * the catalog check D558 asks for is literally that call, and a call needs a
30367
+ * window. The surface has one — `ClipsBrowser`'s `dayWindow`, one local
30368
+ * wall-clock day, which is also the only width measured to be cheap (one
30369
+ * day on 592 lists 171 clips in 712 ms, a busy day 546 in 2.0 s; twenty days
30370
+ * of one child's events took 3.6–5.4 s).
30371
+ */
30372
+ catalogWindow: object({
30373
+ sinceMs: number(),
30374
+ untilMs: number()
30375
+ }),
30376
+ profile: _enum([
30377
+ "high",
30378
+ "mid",
30379
+ "low"
30380
+ ]),
30381
+ /**
30382
+ * The operator's authorisation to wake a sleeping camera for this export.
30383
+ * ONE definition, in the cap that owns the clip read ({@link ClipWakeSchema}),
30384
+ * because the gate that honours it is the clip provider's sleep gate — a
30385
+ * second enum here would be a second contract. Absent by default; never
30386
+ * settable by a scheduler or a retry.
30387
+ *
30388
+ * **One authorised yes is ONE wake.** A failed clip export is retried only by
30389
+ * an operator act that asks again; a queued job that outlived its wake fails
30390
+ * with a reason rather than waking on its turn; and this subject carries
30391
+ * exactly one profile precisely so one tap is never two fetches (D558 § 5.2).
30392
+ */
30393
+ wake: ClipWakeSchema.optional()
30394
+ })]);
30395
+ /**
30396
+ * One export job / history row.
30397
+ *
30398
+ * **`subject` is the AUTHORITY on what was exported. `deviceId`, `profile`,
30399
+ * `fromMs` and `toMs` are its PROJECTION** — kept top-level because the whole
30400
+ * Library sorts and labels on them (`library-items.ts` orders an export by
30401
+ * `fromMs`; `export-format.ts` draws `rangeLabel` from the pair), and a row
30402
+ * that did not fill them would sort under the epoch and render a blank range.
30403
+ * Write to the subject and read from the projection and the two will disagree;
30404
+ * the projection is derived at creation and never edited afterwards.
30405
+ *
30406
+ * And they mean DIFFERENT FACTS for the two kinds, which is the part a reader
30407
+ * who knows only the recording export will get wrong:
30408
+ *
30409
+ * | field | `kind:'footage'` | `kind:'clip'` |
30410
+ * | --- | --- | --- |
30411
+ * | `fromMs`/`toMs` | the stretch the operator ASKED for | the camera's own boundaries, always `clip.timeRange`, never anything a caller supplied |
30412
+ * | `profile` | the stream rendered | the twin actually SERVED (`subject.profile` is the one asked for) |
30413
+ *
30414
+ * Same type, different fact — the shape this repo keeps getting wrong (D385's
30415
+ * two authorities, D224's second copy).
30416
+ */
30227
30417
  var ExportRecordSchema = object({
30228
30418
  id: string(),
30229
30419
  deviceId: number(),
30230
30420
  profile: string(),
30231
30421
  fromMs: number(),
30232
30422
  toMs: number(),
30423
+ /**
30424
+ * What this export IS. Optional ONLY for the rows written before D558: the
30425
+ * store parses every row through this schema on every read, so a required
30426
+ * field would make the export AUDIT — which is the whole reason rows survive
30427
+ * file deletion — unreadable in one release. Absence means `footage`, and
30428
+ * {@link exportSubjectOf} is the one place that says so.
30429
+ */
30430
+ subject: ExportSubjectSchema.optional(),
30233
30431
  options: ExportOptionsSchema,
30234
30432
  state: ExportStateSchema,
30235
30433
  /** 0–100 while rendering; null otherwise. */
@@ -30246,6 +30444,18 @@ var ExportRecordSchema = object({
30246
30444
  /** Failure reason when state is 'failed'; null otherwise. */
30247
30445
  error: string().nullable()
30248
30446
  });
30447
+ _enum([
30448
+ "catalog-miss",
30449
+ "catalog-unreachable",
30450
+ "no-file-for-window",
30451
+ "clip-in-progress",
30452
+ "unsupported-option",
30453
+ "sleeping",
30454
+ "camera-refused",
30455
+ "fetch-failed",
30456
+ "too-large-to-transfer",
30457
+ "wake-expired"
30458
+ ]);
30249
30459
  /** Candidate download URLs (LAN first, then operator extra hosts). */
30250
30460
  var ExportDownloadSchema = object({
30251
30461
  url: string(),
@@ -30264,16 +30474,50 @@ var ExportBytesSchema = object({
30264
30474
  name: string(),
30265
30475
  bytes: number().int().nonnegative()
30266
30476
  });
30477
+ /** Canonical `profiles[]`, falling back to the legacy singular `profile`. */
30478
+ function resolveExportProfiles(input) {
30479
+ if (input.profiles !== void 0 && input.profiles.length > 0) return [...input.profiles];
30480
+ if (typeof input.profile === "string" && input.profile.length > 0) return [input.profile];
30481
+ return [];
30482
+ }
30267
30483
  method(object({
30268
30484
  deviceId: number(),
30269
30485
  /** @deprecated Prefer `profiles`. Kept so timelapse/notifiers keep working. */
30270
30486
  profile: string().optional(),
30271
30487
  profiles: array(string()).min(1).optional(),
30272
- fromMs: number(),
30273
- toMs: number(),
30488
+ /** Footage only — a clip's boundaries are the camera's. */
30489
+ fromMs: number().optional(),
30490
+ toMs: number().optional(),
30491
+ /** What to export. Absent means the legacy flat footage request. */
30492
+ subject: ExportSubjectSchema.optional(),
30274
30493
  options: ExportOptionsSchema
30275
30494
  }).superRefine((v, ctx) => {
30276
- if ((v.profiles !== void 0 && v.profiles.length > 0 ? v.profiles : v.profile !== void 0 ? [v.profile] : []).length < 1) ctx.addIssue({
30495
+ if (v.subject?.kind === "clip") {
30496
+ if (v.subject.deviceId !== v.deviceId) ctx.addIssue({
30497
+ code: ZodIssueCode.custom,
30498
+ message: `subject.deviceId (${v.subject.deviceId}) must equal deviceId (${v.deviceId}) — the top-level field is what per-device scope enforcement reads`,
30499
+ path: ["subject", "deviceId"]
30500
+ });
30501
+ if (v.fromMs !== void 0 || v.toMs !== void 0) ctx.addIssue({
30502
+ code: ZodIssueCode.custom,
30503
+ message: "a clip export asks for no time range: the camera chose the boundaries and they are read from the catalog row",
30504
+ path: ["fromMs"]
30505
+ });
30506
+ return;
30507
+ }
30508
+ if (v.subject?.kind === "footage" && v.subject.deviceId !== v.deviceId) ctx.addIssue({
30509
+ code: ZodIssueCode.custom,
30510
+ message: `subject.deviceId (${v.subject.deviceId}) must equal deviceId (${v.deviceId})`,
30511
+ path: ["subject", "deviceId"]
30512
+ });
30513
+ const fromMs = v.subject?.kind === "footage" ? v.subject.fromMs : v.fromMs;
30514
+ const toMs = v.subject?.kind === "footage" ? v.subject.toMs : v.toMs;
30515
+ if (typeof fromMs !== "number" || typeof toMs !== "number") ctx.addIssue({
30516
+ code: ZodIssueCode.custom,
30517
+ message: "a footage export needs fromMs and toMs",
30518
+ path: ["fromMs"]
30519
+ });
30520
+ if ((v.subject?.kind === "footage" ? [...v.subject.profiles] : resolveExportProfiles(v)).length < 1) ctx.addIssue({
30277
30521
  code: ZodIssueCode.custom,
30278
30522
  message: "pass profiles[] (min 1) or legacy profile",
30279
30523
  path: ["profiles"]
@@ -38273,6 +38517,12 @@ Object.freeze({
38273
38517
  addonId: null,
38274
38518
  access: "view"
38275
38519
  },
38520
+ "videoclips.readClipBytes": {
38521
+ capName: "videoclips",
38522
+ capScope: "device",
38523
+ addonId: null,
38524
+ access: "view"
38525
+ },
38276
38526
  "viewerUi.getStaticDir": {
38277
38527
  capName: "viewer-ui",
38278
38528
  capScope: "system",
@@ -40291,6 +40541,11 @@ Object.freeze({
40291
40541
  form: "single",
40292
40542
  optional: false
40293
40543
  }],
40544
+ "videoclips.readClipBytes": [{
40545
+ name: "deviceId",
40546
+ form: "single",
40547
+ optional: false
40548
+ }],
40294
40549
  "waterHeater.setAway": [{
40295
40550
  name: "deviceId",
40296
40551
  form: "single",
@@ -40970,7 +41225,7 @@ var AgentUIAddon = class extends BaseAddon {
40970
41225
  capability: adminUiCapability,
40971
41226
  provider: {
40972
41227
  getStaticDir: async () => ({ staticDir: path.resolve(__dirname) }),
40973
- getVersion: async () => ({ version: "1.2.134" })
41228
+ getVersion: async () => ({ version: "1.2.136" })
40974
41229
  }
40975
41230
  }];
40976
41231
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-agent-ui",
3
- "version": "1.2.134",
3
+ "version": "1.2.136",
4
4
  "description": "Agent UI — lightweight status dashboard served by every agent node",
5
5
  "keywords": [
6
6
  "camstack",