@camstack/addon-provider-homeassistant 1.2.58 → 1.2.60

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_dist = require("./dist-DjxuSmvp.js");
2
+ const require_dist = require("./dist-BN8TjCTI.js");
3
3
  let node_crypto = require("node:crypto");
4
4
  let node_zlib = require("node:zlib");
5
5
  //#region src/ha-device-source.ts
package/dist/addon.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as presenceCapability, A as controlCapability, At as EventCategory, B as humiditySensorCapability, C as buildAddonRouteProvider, Ct as number, D as colorCapability, Dt as union, E as climateControlCapability, Et as string, F as eventEmitterCapability, G as motionCapability, H as lawnMowerControlCapability, I as fanControlCapability, J as notifierCapability, K as normalizeUnit, L as floodCapability, M as deviceAdoptionCapability, O as connectivityCapability, Ot as unknown, P as enumSensorCapability, Q as prepareNotification, R as gasCapability, S as brokerCapability, St as literal, T as carbonMonoxideCapability, Tt as record, U as lockControlCapability, V as imageCapability, W as mediaPlayerCapability, Y as numericSensorCapability, Z as powerMeterCapability, _ as automationControlCapability, _t as createEvent, at as temperatureSensorCapability, b as binaryCapability, bt as array, ct as valveCapability, d as TargetSchema, dt as weatherCapability, et as pressureSensorCapability, f as accessoriesCapability, ft as errMsg, g as ambientLightSensorCapability, gt as DeviceType, h as alarmPanelCapability, ht as DeviceRole, it as tamperCapability, j as coverCapability, k as contactCapability, kt as url, lt as vibrationCapability, m as airQualitySensorCapability, mt as DeviceFeature, n as BaseDevice, nt as smokeCapability, ot as updateCapability, p as addonRoutesCapability, q as notificationOutputCapability, r as BaseDeviceProvider, rt as switchCapability, s as EnumSensorDateTimeFormatSchema, st as vacuumControlCapability, tt as scriptRunnerCapability, ut as waterHeaterCapability, v as batteryCapability, w as buttonCapability, wt as object, x as brightnessCapability, xt as discriminatedUnion, y as bestLocationMatch, yt as _enum, z as humidifierCapability } from "./dist-CCHqsqE6.mjs";
1
+ import { $ as presenceCapability, A as controlCapability, At as EventCategory, B as humiditySensorCapability, C as buildAddonRouteProvider, Ct as number, D as colorCapability, Dt as union, E as climateControlCapability, Et as string, F as eventEmitterCapability, G as motionCapability, H as lawnMowerControlCapability, I as fanControlCapability, J as notifierCapability, K as normalizeUnit, L as floodCapability, M as deviceAdoptionCapability, O as connectivityCapability, Ot as unknown, P as enumSensorCapability, Q as prepareNotification, R as gasCapability, S as brokerCapability, St as literal, T as carbonMonoxideCapability, Tt as record, U as lockControlCapability, V as imageCapability, W as mediaPlayerCapability, Y as numericSensorCapability, Z as powerMeterCapability, _ as automationControlCapability, _t as createEvent, at as temperatureSensorCapability, b as binaryCapability, bt as array, ct as valveCapability, d as TargetSchema, dt as weatherCapability, et as pressureSensorCapability, f as accessoriesCapability, ft as errMsg, g as ambientLightSensorCapability, gt as DeviceType, h as alarmPanelCapability, ht as DeviceRole, it as tamperCapability, j as coverCapability, k as contactCapability, kt as url, lt as vibrationCapability, m as airQualitySensorCapability, mt as DeviceFeature, n as BaseDevice, nt as smokeCapability, ot as updateCapability, p as addonRoutesCapability, q as notificationOutputCapability, r as BaseDeviceProvider, rt as switchCapability, s as EnumSensorDateTimeFormatSchema, st as vacuumControlCapability, tt as scriptRunnerCapability, ut as waterHeaterCapability, v as batteryCapability, w as buttonCapability, wt as object, x as brightnessCapability, xt as discriminatedUnion, y as bestLocationMatch, yt as _enum, z as humidifierCapability } from "./dist-D4pIhy8v.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { brotliCompressSync, deflateSync, gzipSync } from "node:zlib";
4
4
  //#region src/ha-device-source.ts
@@ -8206,6 +8206,21 @@ var RelocateJobSchema = object({
8206
8206
  bytesMoved: number().int(),
8207
8207
  /** Total files discovered up front; null while (or when) unknown. */
8208
8208
  filesTotal: number().int().nullable(),
8209
+ /**
8210
+ * Rows this run CORRECTED while moving them — a durable mutation the move
8211
+ * made that nobody asked for, so it is reported where the operator reads the
8212
+ * job rather than only in a log line.
8213
+ *
8214
+ * A footage segment records its byte count in its own NAME, and the durable
8215
+ * hour row derives its aggregates from those names. A file that does not
8216
+ * match its name therefore makes the ledger's sums — and with them quota and
8217
+ * pressure eviction — wrong by the difference, and only a rename can fix it.
8218
+ * On 2026-08-30 one such row also stalled a 110 749-file drain permanently.
8219
+ *
8220
+ * Absent on lanes where the question has no meaning: a media blob's size is
8221
+ * in its row, not in its name, so `MediaRelocateEngine` never reconciles one.
8222
+ */
8223
+ rowsReconciled: number().int().nonnegative().optional(),
8209
8224
  startedAt: number(),
8210
8225
  finishedAt: number().nullable(),
8211
8226
  error: string().nullable()
@@ -8274,14 +8289,42 @@ var RelocateMediaInputSchema = object({
8274
8289
  /** Omitted = `move`, the pre-existing behaviour. */
8275
8290
  mode: MediaRelocateModeSchema.optional()
8276
8291
  });
8277
- /** How many rows still carry NO `locationId` — the population a repoint would
8278
- * silently re-aim at a disk that does not hold their bytes. Zero is the only
8279
- * value that permits a non-blocking `eventMedia` cutover. */
8280
- var UnstampedEventMediaCountSchema = object({
8281
- media: number().int().nonnegative(),
8282
- retrainFrames: number().int().nonnegative(),
8283
- total: number().int().nonnegative()
8292
+ /**
8293
+ * The unstamped population of ONE collection split, because the gate and the
8294
+ * operator ask two different questions and only one of them has to be cheap.
8295
+ *
8296
+ * `present` is the GATE: "is there at least one row that would be orphaned by a
8297
+ * repoint". It is a single indexed seek to the first matching row, so it stays
8298
+ * answerable on a saturated disk and answers in O(log n) precisely in the state
8299
+ * that matters — after a seal, when the population is empty.
8300
+ *
8301
+ * `rows` is the NUMBER, for the refusal message and the operator's sense of
8302
+ * scale. It is a second, indexed `COUNT(*)`, and `null` means **not
8303
+ * measurable** — never zero. `{ present: true, rows: null }` is a legitimate
8304
+ * and useful answer: "there are some, and this read could not say how many"
8305
+ * still refuses the cutover, which is the whole job.
8306
+ */
8307
+ var UnstampedRowsSchema = object({
8308
+ present: boolean(),
8309
+ rows: number().int().nonnegative().nullable()
8284
8310
  });
8311
+ /**
8312
+ * How many rows still carry NO `locationId` — the population a repoint would
8313
+ * silently re-aim at a disk that does not hold their bytes.
8314
+ *
8315
+ * **`null` = the count could not be taken**, and it is NOT permission to cut
8316
+ * over. The gate opens on a measured absence and on nothing else; an unread
8317
+ * collection and an empty one are different facts, and this repo has already
8318
+ * paid for conflating them (`RelocateResidueSchema`, D295).
8319
+ */
8320
+ var UnstampedEventMediaCountSchema = object({
8321
+ media: UnstampedRowsSchema,
8322
+ retrainFrames: UnstampedRowsSchema,
8323
+ /** True when EITHER collection holds one. The refusal reads this. */
8324
+ anyPresent: boolean(),
8325
+ /** Sum across both, or `null` when either lane could not be counted. */
8326
+ total: number().int().nonnegative().nullable()
8327
+ }).nullable();
8285
8328
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8286
8329
  /** The independently selectable logical storage classes — every class
8287
8330
  * `storage.listLocationDeclarations` reports, so an operator never meets a
@@ -8392,6 +8435,10 @@ var StorageMigrationMoveProgressSchema = object({
8392
8435
  /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8393
8436
  filesTotal: number().int().nonnegative().nullable(),
8394
8437
  bytesMoved: number().int().nonnegative(),
8438
+ /** Rows the mover corrected while moving them — see `RelocateJob`. Absent on
8439
+ * a lane that cannot reconcile. A migration that silently rewrote durable
8440
+ * rows would be the same failure as one that silently skipped them. */
8441
+ rowsReconciled: number().int().nonnegative().optional(),
8395
8442
  /** The MOVER's start, not the migration's: a drain restarted after an addon
8396
8443
  * crash gets a new mover, and a rate computed from the migration's start
8397
8444
  * would silently average in the time nothing was running. */
@@ -13495,6 +13542,114 @@ method(object({
13495
13542
  height: number()
13496
13543
  }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
13497
13544
  /**
13545
+ * `failure-contribution` — the capability an addon reports its OWN losses
13546
+ * through, per camera, with the denominator attached. It stores nothing.
13547
+ *
13548
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13549
+ *
13550
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13551
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13552
+ * copied: the contributor reports what it already knows, hub-main adds only
13553
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13554
+ * somebody to forget to edit.
13555
+ *
13556
+ * They are not merged, because their invariants are opposites:
13557
+ *
13558
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13559
+ * claim a camera cost nothing, which is a measurement nobody made;
13560
+ * - a `failure-contribution` zero is the **most valuable value on the
13561
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13562
+ * and it is exactly what an absent entry cannot say.
13563
+ *
13564
+ * Putting a loss counter on a cost entry would also break the reconciliation
13565
+ * that gives `load-contribution` its point: contributions are subtracted from
13566
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13567
+ * has no process.
13568
+ *
13569
+ * ## Why not a log line, since the counters already exist
13570
+ *
13571
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13572
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13573
+ * ends in a log line, and a log line is the thing the operator asked to stop
13574
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13575
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13576
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13577
+ * media blackout were both diagnosed. The counters stay; this is where they can
13578
+ * be READ.
13579
+ *
13580
+ * ## The rate is served with its denominator or not at all
13581
+ *
13582
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13583
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13584
+ * than yesterday" and was **flat across twelve hours** once divided by the
13585
+ * successes on the same path. A surface that publishes only the numerator
13586
+ * reproduces that mistake on every read.
13587
+ *
13588
+ * ## Shape
13589
+ *
13590
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13591
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13592
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13593
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13594
+ * a forked runner's entries reach hub-main over transport that already exists.
13595
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13596
+ * result through `system.getFailureContributions`.
13597
+ */
13598
+ var FailureReasonCountSchema = object({
13599
+ /**
13600
+ * Why the attempt did not land, in the contributor's own vocabulary —
13601
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13602
+ * strings that already appear in this repo's logs and, where one exists, the
13603
+ * same string the per-track `previewMissReason` records (D276): a second
13604
+ * vocabulary for the same loss would make the row and the counter
13605
+ * un-joinable.
13606
+ */
13607
+ reason: string(),
13608
+ count: number().int().nonnegative()
13609
+ });
13610
+ var FailureContributionSchema = object({
13611
+ /**
13612
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13613
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13614
+ * `unit` free: the families are owned by different addons and a shared enum
13615
+ * is a central list that rots invisibly.
13616
+ */
13617
+ family: string(),
13618
+ /**
13619
+ * The NUMERIC device id — the same value every log line carries as
13620
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13621
+ * cannot name the camera must not emit the entry, because a fleet total
13622
+ * cannot answer the only question anybody asks of this surface.
13623
+ */
13624
+ deviceId: number().int().positive(),
13625
+ /**
13626
+ * A second dimension inside the family: the model / step id for an inference
13627
+ * timeout, so "which camera AND which model" is one read. Absent when the
13628
+ * family has a single variant.
13629
+ */
13630
+ variant: string().optional(),
13631
+ /**
13632
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13633
+ * differencing two reads must drop the interval when it changes, because the
13634
+ * counter restarted from zero in a respawned runner. Same discipline as
13635
+ * `LoadContribution.startedAtMs`.
13636
+ */
13637
+ sinceMs: number(),
13638
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13639
+ atMs: number(),
13640
+ /**
13641
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13642
+ * window. A failure count published without it is the mistake this schema
13643
+ * exists to make impossible.
13644
+ */
13645
+ attempts: number().int().nonnegative(),
13646
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13647
+ succeeded: number().int().nonnegative(),
13648
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13649
+ reasons: array(FailureReasonCountSchema).readonly()
13650
+ });
13651
+ method(_void(), array(FailureContributionSchema).readonly());
13652
+ /**
13498
13653
  * filesystem-browse — per-node capability for browsing the node's local
13499
13654
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
13500
13655
  * are sandboxed to operator-configured allowed roots (D115). Used by the
@@ -14016,6 +14171,68 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }
14016
14171
  kind: "mutation",
14017
14172
  auth: "admin"
14018
14173
  });
14174
+ var LoadContributionSchema = object({
14175
+ role: _enum([
14176
+ "decode",
14177
+ "transcode",
14178
+ "recording",
14179
+ "streaming",
14180
+ "detection"
14181
+ ]),
14182
+ /**
14183
+ * The NUMERIC device id — the same value every log line carries as
14184
+ * `tags.deviceId`. `null` means this cost genuinely belongs to no single
14185
+ * camera (a shared pool), NOT that the contributor forgot to look it up: a
14186
+ * contributor that cannot name its camera must not emit the entry at all,
14187
+ * because an unnamed per-camera entry is indistinguishable from a shared one
14188
+ * and would quietly turn one camera's cost into everybody's.
14189
+ */
14190
+ deviceId: number().int().positive().nullable(),
14191
+ attribution: _enum([
14192
+ "measured",
14193
+ "accounted",
14194
+ "unattributable"
14195
+ ]),
14196
+ /**
14197
+ * What ONE entry is, in the contributor's own words — `615/high`,
14198
+ * `617/native`, `cuda:0 shared pool`. Free text because the unit differs per
14199
+ * family and inventing a common one would lose the only information that
14200
+ * makes two entries for the same camera distinguishable.
14201
+ */
14202
+ unit: string(),
14203
+ /**
14204
+ * The OS process this cost lives in, when there is one. Present so a
14205
+ * consumer can (a) tell two generations of the same unit apart across a
14206
+ * restart, and (b) subtract claimed processes from the node's process
14207
+ * snapshot to see what NOBODY claimed. Absent for an entry that owns no
14208
+ * process of its own.
14209
+ */
14210
+ pid: number().int().positive().optional(),
14211
+ /**
14212
+ * When this generation started. The pid's incarnation marker: a consumer
14213
+ * differencing {@link LoadContributionSchema.shape.cpuSeconds} must drop the
14214
+ * window when this changes, because the counter restarted from zero in a new
14215
+ * process.
14216
+ */
14217
+ startedAtMs: number().optional(),
14218
+ /**
14219
+ * CUMULATIVE CPU seconds this unit has consumed since it started — user +
14220
+ * system, read from the child's own `/proc/<pid>/stat` at the moment the
14221
+ * contribution is asked for.
14222
+ *
14223
+ * Cumulative and not a rate on purpose: a rate needs a window, a window
14224
+ * needs a sampler, and a new per-node sampler is the defect half of
14225
+ * `docs/architecture/load-ledger.md` documents. A counter can be differenced
14226
+ * by whoever already keeps a history; a rate cannot be un-averaged.
14227
+ *
14228
+ * Absent — never zero — on a node with no `/proc`, on a read failure, and on
14229
+ * an entry with no process.
14230
+ */
14231
+ cpuSeconds: number().optional(),
14232
+ /** Resident bytes of this unit's process, same source and same rules. */
14233
+ rssBytes: number().optional()
14234
+ });
14235
+ method(_void(), array(LoadContributionSchema).readonly());
14019
14236
  /**
14020
14237
  * `log-channels` — the capability an addon DECLARES its diagnostic channels
14021
14238
  * through. It stores nothing.
@@ -14092,176 +14309,6 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
14092
14309
  tags: record(string(), string()).optional()
14093
14310
  }), array(LogEntrySchema).readonly());
14094
14311
  /**
14095
- * `failure-contribution` — the capability an addon reports its OWN losses
14096
- * through, per camera, with the denominator attached. It stores nothing.
14097
- *
14098
- * ## The twin of `load-contribution`, and why it is a twin and not a field
14099
- *
14100
- * `load-contribution` answers *what did this camera COST*. This answers *what
14101
- * did this camera LOSE*. The reporting discipline is identical and deliberately
14102
- * copied: the contributor reports what it already knows, hub-main adds only
14103
- * `addonId`, nothing needs global knowledge, and there is no central list for
14104
- * somebody to forget to edit.
14105
- *
14106
- * They are not merged, because their invariants are opposites:
14107
- *
14108
- * - a `load-contribution` measurement is **absent, never zero** — a zero would
14109
- * claim a camera cost nothing, which is a measurement nobody made;
14110
- * - a `failure-contribution` zero is the **most valuable value on the
14111
- * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
14112
- * and it is exactly what an absent entry cannot say.
14113
- *
14114
- * Putting a loss counter on a cost entry would also break the reconciliation
14115
- * that gives `load-contribution` its point: contributions are subtracted from
14116
- * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
14117
- * has no process.
14118
- *
14119
- * ## Why not a log line, since the counters already exist
14120
- *
14121
- * Several of these paths already counted themselves — `CaptureScheduler`'s
14122
- * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
14123
- * ends in a log line, and a log line is the thing the operator asked to stop
14124
- * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
14125
- * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
14126
- * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
14127
- * media blackout were both diagnosed. The counters stay; this is where they can
14128
- * be READ.
14129
- *
14130
- * ## The rate is served with its denominator or not at all
14131
- *
14132
- * Every entry carries `attempts` and `succeeded`. A miss count alone is
14133
- * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
14134
- * than yesterday" and was **flat across twelve hours** once divided by the
14135
- * successes on the same path. A surface that publishes only the numerator
14136
- * reproduces that mistake on every read.
14137
- *
14138
- * ## Shape
14139
- *
14140
- * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
14141
- * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
14142
- * generated hooks, while `addons.listCapabilityProviders` still enumerates it
14143
- * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
14144
- * a forked runner's entries reach hub-main over transport that already exists.
14145
- * No new UDS message, no second registry (D3). The operator reads the assembled
14146
- * result through `system.getFailureContributions`.
14147
- */
14148
- var FailureReasonCountSchema = object({
14149
- /**
14150
- * Why the attempt did not land, in the contributor's own vocabulary —
14151
- * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
14152
- * strings that already appear in this repo's logs and, where one exists, the
14153
- * same string the per-track `previewMissReason` records (D276): a second
14154
- * vocabulary for the same loss would make the row and the counter
14155
- * un-joinable.
14156
- */
14157
- reason: string(),
14158
- count: number().int().nonnegative()
14159
- });
14160
- var FailureContributionSchema = object({
14161
- /**
14162
- * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
14163
- * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
14164
- * `unit` free: the families are owned by different addons and a shared enum
14165
- * is a central list that rots invisibly.
14166
- */
14167
- family: string(),
14168
- /**
14169
- * The NUMERIC device id — the same value every log line carries as
14170
- * `tags.deviceId`. Never nullable and never absent: a contributor that
14171
- * cannot name the camera must not emit the entry, because a fleet total
14172
- * cannot answer the only question anybody asks of this surface.
14173
- */
14174
- deviceId: number().int().positive(),
14175
- /**
14176
- * A second dimension inside the family: the model / step id for an inference
14177
- * timeout, so "which camera AND which model" is one read. Absent when the
14178
- * family has a single variant.
14179
- */
14180
- variant: string().optional(),
14181
- /**
14182
- * Epoch ms this counter started — the INCARNATION MARKER. A consumer
14183
- * differencing two reads must drop the interval when it changes, because the
14184
- * counter restarted from zero in a respawned runner. Same discipline as
14185
- * `LoadContribution.startedAtMs`.
14186
- */
14187
- sinceMs: number(),
14188
- /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
14189
- atMs: number(),
14190
- /**
14191
- * THE DENOMINATOR — every attempt on this path for this camera in the
14192
- * window. A failure count published without it is the mistake this schema
14193
- * exists to make impossible.
14194
- */
14195
- attempts: number().int().nonnegative(),
14196
- /** Attempts that landed. `attempts - succeeded` is the loss. */
14197
- succeeded: number().int().nonnegative(),
14198
- /** The loss, partitioned. Sums to `attempts - succeeded`. */
14199
- reasons: array(FailureReasonCountSchema).readonly()
14200
- });
14201
- method(_void(), array(FailureContributionSchema).readonly());
14202
- var LoadContributionSchema = object({
14203
- role: _enum([
14204
- "decode",
14205
- "transcode",
14206
- "recording",
14207
- "streaming",
14208
- "detection"
14209
- ]),
14210
- /**
14211
- * The NUMERIC device id — the same value every log line carries as
14212
- * `tags.deviceId`. `null` means this cost genuinely belongs to no single
14213
- * camera (a shared pool), NOT that the contributor forgot to look it up: a
14214
- * contributor that cannot name its camera must not emit the entry at all,
14215
- * because an unnamed per-camera entry is indistinguishable from a shared one
14216
- * and would quietly turn one camera's cost into everybody's.
14217
- */
14218
- deviceId: number().int().positive().nullable(),
14219
- attribution: _enum([
14220
- "measured",
14221
- "accounted",
14222
- "unattributable"
14223
- ]),
14224
- /**
14225
- * What ONE entry is, in the contributor's own words — `615/high`,
14226
- * `617/native`, `cuda:0 shared pool`. Free text because the unit differs per
14227
- * family and inventing a common one would lose the only information that
14228
- * makes two entries for the same camera distinguishable.
14229
- */
14230
- unit: string(),
14231
- /**
14232
- * The OS process this cost lives in, when there is one. Present so a
14233
- * consumer can (a) tell two generations of the same unit apart across a
14234
- * restart, and (b) subtract claimed processes from the node's process
14235
- * snapshot to see what NOBODY claimed. Absent for an entry that owns no
14236
- * process of its own.
14237
- */
14238
- pid: number().int().positive().optional(),
14239
- /**
14240
- * When this generation started. The pid's incarnation marker: a consumer
14241
- * differencing {@link LoadContributionSchema.shape.cpuSeconds} must drop the
14242
- * window when this changes, because the counter restarted from zero in a new
14243
- * process.
14244
- */
14245
- startedAtMs: number().optional(),
14246
- /**
14247
- * CUMULATIVE CPU seconds this unit has consumed since it started — user +
14248
- * system, read from the child's own `/proc/<pid>/stat` at the moment the
14249
- * contribution is asked for.
14250
- *
14251
- * Cumulative and not a rate on purpose: a rate needs a window, a window
14252
- * needs a sampler, and a new per-node sampler is the defect half of
14253
- * `docs/architecture/load-ledger.md` documents. A counter can be differenced
14254
- * by whoever already keeps a history; a rate cannot be un-averaged.
14255
- *
14256
- * Absent — never zero — on a node with no `/proc`, on a read failure, and on
14257
- * an entry with no process.
14258
- */
14259
- cpuSeconds: number().optional(),
14260
- /** Resident bytes of this unit's process, same source and same rules. */
14261
- rssBytes: number().optional()
14262
- });
14263
- method(_void(), array(LoadContributionSchema).readonly());
14264
- /**
14265
14312
  * `login-method` — collection cap through which auth addons contribute
14266
14313
  * their pre-auth login surfaces to the login page. This is the SINGLE,
14267
14314
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
@@ -19029,12 +19076,53 @@ var MediaFileKindEnum = _enum([
19029
19076
  "keyFrameSmall",
19030
19077
  "thumbnailSmall"
19031
19078
  ]);
19079
+ /**
19080
+ * One media row ON THE WIRE: what it is, how big it is, and WHERE ITS BYTES
19081
+ * ARE — never the bytes themselves.
19082
+ *
19083
+ * ## Why `url` and not `base64`
19084
+ *
19085
+ * Measured on the live hub 2026-08-30: `getTrackMedia {trackId, deviceId}`
19086
+ * with no `kinds` returned 6 rows / **3 597 219 B**, of which `keyFrame` alone
19087
+ * was **2 824 077 B** — one full-resolution frame, base64, so +33 % on the
19088
+ * wire. Forty events is ~144 MB. Every byte of it was read off disk,
19089
+ * base64-encoded, held whole in a unary tRPC envelope, and materialised in
19090
+ * hub-main's heap on the way past — for an `<img>` that would have cached it.
19091
+ *
19092
+ * `url` points at the `event-media` data plane
19093
+ * (`/addon/<addonId>/event-media/<storedKey>`), which serves the same blob
19094
+ * with an ETag and `Cache-Control: immutable`, honours conditional GETs, can
19095
+ * render a `?variant=thumb`, and streams. The hub gate in front of it requires
19096
+ * a bearer or the session cookie (`access: 'authenticated'`), so the bytes are
19097
+ * no less protected than they were inside a `view`-level cap response — see
19098
+ * `data-plane-access.ts` for the rule and the one gap it does not close
19099
+ * (per-device scoping).
19100
+ *
19101
+ * The URL is built from the row's **stored** key, which is not always its
19102
+ * published `kind`: a track's face/plate crop is stored as `crop` under
19103
+ * `('face'|'plate', '<prefix>-<trackId>')` and published as
19104
+ * `faceCrop`/`plateCrop`. `MediaStore.getByKey` knows only the stored key.
19105
+ *
19106
+ * ## `base64` is TRANSITIONAL and is going away
19107
+ *
19108
+ * It is still populated for one reason: the deployed viewer's track-detail
19109
+ * HERO tile reads it (`use-track-media-entry.ts` → `parseMediaFiles`, which
19110
+ * REQUIRES the field), and a row without it parses as a FAILED read — the red
19111
+ * triangle — not as absence. Removing the field before that viewer ships is an
19112
+ * outage, not a cleanup. Once the viewer takes its hero bytes from `url`,
19113
+ * delete this line and the `withBytes` pass-through in
19114
+ * `analytics-query-facade.ts`; nothing else reads it.
19115
+ */
19032
19116
  var MediaFileSchema = object({
19033
19117
  key: string(),
19034
19118
  kind: MediaFileKindEnum,
19035
- base64: string(),
19036
19119
  sizeBytes: number(),
19037
19120
  timestamp: number()
19121
+ }).extend({
19122
+ /** `/addon/<addonId>/event-media/<encoded stored key>`. Always present. */
19123
+ url: string(),
19124
+ /** @deprecated Transitional — see the schema docblock. Use {@link url}. */
19125
+ base64: string()
19038
19126
  });
19039
19127
  /**
19040
19128
  * One media row WITHOUT its bytes.
@@ -19046,7 +19134,9 @@ var MediaFileSchema = object({
19046
19134
  * blocks the whole view.
19047
19135
  *
19048
19136
  * `sizeBytes` is carried because it is what lets a client decide between the
19049
- * stored blob and a `?variant=thumb` rendering without fetching either.
19137
+ * stored blob and a `?variant=thumb` rendering without fetching either, and
19138
+ * `url` because a client that had to build the plane path itself is a second
19139
+ * copy of a route — the embed, the viewer and the admin UI each grew one.
19050
19140
  */
19051
19141
  var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
19052
19142
  /**
@@ -19735,6 +19825,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19735
19825
  }), array(MediaFileSchema).readonly()), method(object({
19736
19826
  trackId: string(),
19737
19827
  deviceId: number()
19828
+ }), array(MediaFileInfoSchema).readonly()), method(object({
19829
+ eventId: string(),
19830
+ deviceId: number()
19738
19831
  }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
19739
19832
  kind: "mutation",
19740
19833
  auth: "admin"
@@ -24814,10 +24907,24 @@ var FaceClusterSchema = object({
24814
24907
  size: number().int(),
24815
24908
  cohesion: number()
24816
24909
  });
24910
+ /**
24911
+ * One gallery media row: what the crop is, how big it is, and WHERE its bytes
24912
+ * are — never the bytes.
24913
+ *
24914
+ * `base64` was deleted here rather than deprecated. `MediaFile.base64` (the
24915
+ * track/event contract) is still populated because a deployed viewer requires
24916
+ * the field to parse a row at all; this method has no such reader. Its ONE
24917
+ * caller is the admin UI's detail modal, which was building
24918
+ * `data:image/jpeg;base64,…` from a row whose `key` sat right beside it, in a
24919
+ * dialog already rendering its key FRAME from the `event-media` plane.
24920
+ *
24921
+ * `url` is `/addon/<addonId>/event-media/<encoded key>`. The plane resolves a
24922
+ * media key directly, so this needed no new plane and no new access decision.
24923
+ */
24817
24924
  var MediaFileLiteSchema$1 = object({
24818
24925
  key: string(),
24819
24926
  kind: string(),
24820
- base64: string(),
24927
+ url: string(),
24821
24928
  sizeBytes: number(),
24822
24929
  timestamp: number()
24823
24930
  });
@@ -27839,10 +27946,24 @@ var PlateInfoSchema = object({
27839
27946
  */
27840
27947
  cropUrl: string().optional()
27841
27948
  });
27949
+ /**
27950
+ * One gallery media row: what the crop is, how big it is, and WHERE its bytes
27951
+ * are — never the bytes.
27952
+ *
27953
+ * `base64` was deleted here rather than deprecated. `MediaFile.base64` (the
27954
+ * track/event contract) is still populated because a deployed viewer requires
27955
+ * the field to parse a row at all; this method has no such reader. Its ONE
27956
+ * caller is the admin UI's detail modal, which was building
27957
+ * `data:image/jpeg;base64,…` from a row whose `key` sat right beside it, in a
27958
+ * dialog already rendering its key FRAME from the `event-media` plane.
27959
+ *
27960
+ * `url` is `/addon/<addonId>/event-media/<encoded key>`. The plane resolves a
27961
+ * media key directly, so this needed no new plane and no new access decision.
27962
+ */
27842
27963
  var MediaFileLiteSchema = object({
27843
27964
  key: string(),
27844
27965
  kind: string(),
27845
- base64: string(),
27966
+ url: string(),
27846
27967
  sizeBytes: number(),
27847
27968
  timestamp: number()
27848
27969
  });
@@ -35739,6 +35860,12 @@ Object.freeze({
35739
35860
  addonId: null,
35740
35861
  access: "view"
35741
35862
  },
35863
+ "pipelineAnalytics.listEventMedia": {
35864
+ capName: "pipeline-analytics",
35865
+ capScope: "device",
35866
+ addonId: null,
35867
+ access: "view"
35868
+ },
35742
35869
  "pipelineAnalytics.listGroups": {
35743
35870
  capName: "pipeline-analytics",
35744
35871
  capScope: "device",
@@ -39362,6 +39489,11 @@ Object.freeze({
39362
39489
  form: "array",
39363
39490
  optional: false
39364
39491
  }],
39492
+ "pipelineAnalytics.listEventMedia": [{
39493
+ name: "deviceId",
39494
+ form: "single",
39495
+ optional: false
39496
+ }],
39365
39497
  "pipelineAnalytics.listGroups": [{
39366
39498
  name: "deviceIds",
39367
39499
  form: "array",
@@ -8206,6 +8206,21 @@ var RelocateJobSchema = object({
8206
8206
  bytesMoved: number().int(),
8207
8207
  /** Total files discovered up front; null while (or when) unknown. */
8208
8208
  filesTotal: number().int().nullable(),
8209
+ /**
8210
+ * Rows this run CORRECTED while moving them — a durable mutation the move
8211
+ * made that nobody asked for, so it is reported where the operator reads the
8212
+ * job rather than only in a log line.
8213
+ *
8214
+ * A footage segment records its byte count in its own NAME, and the durable
8215
+ * hour row derives its aggregates from those names. A file that does not
8216
+ * match its name therefore makes the ledger's sums — and with them quota and
8217
+ * pressure eviction — wrong by the difference, and only a rename can fix it.
8218
+ * On 2026-08-30 one such row also stalled a 110 749-file drain permanently.
8219
+ *
8220
+ * Absent on lanes where the question has no meaning: a media blob's size is
8221
+ * in its row, not in its name, so `MediaRelocateEngine` never reconciles one.
8222
+ */
8223
+ rowsReconciled: number().int().nonnegative().optional(),
8209
8224
  startedAt: number(),
8210
8225
  finishedAt: number().nullable(),
8211
8226
  error: string().nullable()
@@ -8274,14 +8289,42 @@ var RelocateMediaInputSchema = object({
8274
8289
  /** Omitted = `move`, the pre-existing behaviour. */
8275
8290
  mode: MediaRelocateModeSchema.optional()
8276
8291
  });
8277
- /** How many rows still carry NO `locationId` — the population a repoint would
8278
- * silently re-aim at a disk that does not hold their bytes. Zero is the only
8279
- * value that permits a non-blocking `eventMedia` cutover. */
8280
- var UnstampedEventMediaCountSchema = object({
8281
- media: number().int().nonnegative(),
8282
- retrainFrames: number().int().nonnegative(),
8283
- total: number().int().nonnegative()
8292
+ /**
8293
+ * The unstamped population of ONE collection split, because the gate and the
8294
+ * operator ask two different questions and only one of them has to be cheap.
8295
+ *
8296
+ * `present` is the GATE: "is there at least one row that would be orphaned by a
8297
+ * repoint". It is a single indexed seek to the first matching row, so it stays
8298
+ * answerable on a saturated disk and answers in O(log n) precisely in the state
8299
+ * that matters — after a seal, when the population is empty.
8300
+ *
8301
+ * `rows` is the NUMBER, for the refusal message and the operator's sense of
8302
+ * scale. It is a second, indexed `COUNT(*)`, and `null` means **not
8303
+ * measurable** — never zero. `{ present: true, rows: null }` is a legitimate
8304
+ * and useful answer: "there are some, and this read could not say how many"
8305
+ * still refuses the cutover, which is the whole job.
8306
+ */
8307
+ var UnstampedRowsSchema = object({
8308
+ present: boolean(),
8309
+ rows: number().int().nonnegative().nullable()
8284
8310
  });
8311
+ /**
8312
+ * How many rows still carry NO `locationId` — the population a repoint would
8313
+ * silently re-aim at a disk that does not hold their bytes.
8314
+ *
8315
+ * **`null` = the count could not be taken**, and it is NOT permission to cut
8316
+ * over. The gate opens on a measured absence and on nothing else; an unread
8317
+ * collection and an empty one are different facts, and this repo has already
8318
+ * paid for conflating them (`RelocateResidueSchema`, D295).
8319
+ */
8320
+ var UnstampedEventMediaCountSchema = object({
8321
+ media: UnstampedRowsSchema,
8322
+ retrainFrames: UnstampedRowsSchema,
8323
+ /** True when EITHER collection holds one. The refusal reads this. */
8324
+ anyPresent: boolean(),
8325
+ /** Sum across both, or `null` when either lane could not be counted. */
8326
+ total: number().int().nonnegative().nullable()
8327
+ }).nullable();
8285
8328
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8286
8329
  /** The independently selectable logical storage classes — every class
8287
8330
  * `storage.listLocationDeclarations` reports, so an operator never meets a
@@ -8392,6 +8435,10 @@ var StorageMigrationMoveProgressSchema = object({
8392
8435
  /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8393
8436
  filesTotal: number().int().nonnegative().nullable(),
8394
8437
  bytesMoved: number().int().nonnegative(),
8438
+ /** Rows the mover corrected while moving them — see `RelocateJob`. Absent on
8439
+ * a lane that cannot reconcile. A migration that silently rewrote durable
8440
+ * rows would be the same failure as one that silently skipped them. */
8441
+ rowsReconciled: number().int().nonnegative().optional(),
8395
8442
  /** The MOVER's start, not the migration's: a drain restarted after an addon
8396
8443
  * crash gets a new mover, and a rate computed from the migration's start
8397
8444
  * would silently average in the time nothing was running. */
@@ -13495,6 +13542,114 @@ method(object({
13495
13542
  height: number()
13496
13543
  }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
13497
13544
  /**
13545
+ * `failure-contribution` — the capability an addon reports its OWN losses
13546
+ * through, per camera, with the denominator attached. It stores nothing.
13547
+ *
13548
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13549
+ *
13550
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13551
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13552
+ * copied: the contributor reports what it already knows, hub-main adds only
13553
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13554
+ * somebody to forget to edit.
13555
+ *
13556
+ * They are not merged, because their invariants are opposites:
13557
+ *
13558
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13559
+ * claim a camera cost nothing, which is a measurement nobody made;
13560
+ * - a `failure-contribution` zero is the **most valuable value on the
13561
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13562
+ * and it is exactly what an absent entry cannot say.
13563
+ *
13564
+ * Putting a loss counter on a cost entry would also break the reconciliation
13565
+ * that gives `load-contribution` its point: contributions are subtracted from
13566
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13567
+ * has no process.
13568
+ *
13569
+ * ## Why not a log line, since the counters already exist
13570
+ *
13571
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13572
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13573
+ * ends in a log line, and a log line is the thing the operator asked to stop
13574
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13575
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13576
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13577
+ * media blackout were both diagnosed. The counters stay; this is where they can
13578
+ * be READ.
13579
+ *
13580
+ * ## The rate is served with its denominator or not at all
13581
+ *
13582
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13583
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13584
+ * than yesterday" and was **flat across twelve hours** once divided by the
13585
+ * successes on the same path. A surface that publishes only the numerator
13586
+ * reproduces that mistake on every read.
13587
+ *
13588
+ * ## Shape
13589
+ *
13590
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13591
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13592
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13593
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13594
+ * a forked runner's entries reach hub-main over transport that already exists.
13595
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13596
+ * result through `system.getFailureContributions`.
13597
+ */
13598
+ var FailureReasonCountSchema = object({
13599
+ /**
13600
+ * Why the attempt did not land, in the contributor's own vocabulary —
13601
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13602
+ * strings that already appear in this repo's logs and, where one exists, the
13603
+ * same string the per-track `previewMissReason` records (D276): a second
13604
+ * vocabulary for the same loss would make the row and the counter
13605
+ * un-joinable.
13606
+ */
13607
+ reason: string(),
13608
+ count: number().int().nonnegative()
13609
+ });
13610
+ var FailureContributionSchema = object({
13611
+ /**
13612
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13613
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13614
+ * `unit` free: the families are owned by different addons and a shared enum
13615
+ * is a central list that rots invisibly.
13616
+ */
13617
+ family: string(),
13618
+ /**
13619
+ * The NUMERIC device id — the same value every log line carries as
13620
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13621
+ * cannot name the camera must not emit the entry, because a fleet total
13622
+ * cannot answer the only question anybody asks of this surface.
13623
+ */
13624
+ deviceId: number().int().positive(),
13625
+ /**
13626
+ * A second dimension inside the family: the model / step id for an inference
13627
+ * timeout, so "which camera AND which model" is one read. Absent when the
13628
+ * family has a single variant.
13629
+ */
13630
+ variant: string().optional(),
13631
+ /**
13632
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13633
+ * differencing two reads must drop the interval when it changes, because the
13634
+ * counter restarted from zero in a respawned runner. Same discipline as
13635
+ * `LoadContribution.startedAtMs`.
13636
+ */
13637
+ sinceMs: number(),
13638
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13639
+ atMs: number(),
13640
+ /**
13641
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13642
+ * window. A failure count published without it is the mistake this schema
13643
+ * exists to make impossible.
13644
+ */
13645
+ attempts: number().int().nonnegative(),
13646
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13647
+ succeeded: number().int().nonnegative(),
13648
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13649
+ reasons: array(FailureReasonCountSchema).readonly()
13650
+ });
13651
+ method(_void(), array(FailureContributionSchema).readonly());
13652
+ /**
13498
13653
  * filesystem-browse — per-node capability for browsing the node's local
13499
13654
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
13500
13655
  * are sandboxed to operator-configured allowed roots (D115). Used by the
@@ -14016,6 +14171,68 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }
14016
14171
  kind: "mutation",
14017
14172
  auth: "admin"
14018
14173
  });
14174
+ var LoadContributionSchema = object({
14175
+ role: _enum([
14176
+ "decode",
14177
+ "transcode",
14178
+ "recording",
14179
+ "streaming",
14180
+ "detection"
14181
+ ]),
14182
+ /**
14183
+ * The NUMERIC device id — the same value every log line carries as
14184
+ * `tags.deviceId`. `null` means this cost genuinely belongs to no single
14185
+ * camera (a shared pool), NOT that the contributor forgot to look it up: a
14186
+ * contributor that cannot name its camera must not emit the entry at all,
14187
+ * because an unnamed per-camera entry is indistinguishable from a shared one
14188
+ * and would quietly turn one camera's cost into everybody's.
14189
+ */
14190
+ deviceId: number().int().positive().nullable(),
14191
+ attribution: _enum([
14192
+ "measured",
14193
+ "accounted",
14194
+ "unattributable"
14195
+ ]),
14196
+ /**
14197
+ * What ONE entry is, in the contributor's own words — `615/high`,
14198
+ * `617/native`, `cuda:0 shared pool`. Free text because the unit differs per
14199
+ * family and inventing a common one would lose the only information that
14200
+ * makes two entries for the same camera distinguishable.
14201
+ */
14202
+ unit: string(),
14203
+ /**
14204
+ * The OS process this cost lives in, when there is one. Present so a
14205
+ * consumer can (a) tell two generations of the same unit apart across a
14206
+ * restart, and (b) subtract claimed processes from the node's process
14207
+ * snapshot to see what NOBODY claimed. Absent for an entry that owns no
14208
+ * process of its own.
14209
+ */
14210
+ pid: number().int().positive().optional(),
14211
+ /**
14212
+ * When this generation started. The pid's incarnation marker: a consumer
14213
+ * differencing {@link LoadContributionSchema.shape.cpuSeconds} must drop the
14214
+ * window when this changes, because the counter restarted from zero in a new
14215
+ * process.
14216
+ */
14217
+ startedAtMs: number().optional(),
14218
+ /**
14219
+ * CUMULATIVE CPU seconds this unit has consumed since it started — user +
14220
+ * system, read from the child's own `/proc/<pid>/stat` at the moment the
14221
+ * contribution is asked for.
14222
+ *
14223
+ * Cumulative and not a rate on purpose: a rate needs a window, a window
14224
+ * needs a sampler, and a new per-node sampler is the defect half of
14225
+ * `docs/architecture/load-ledger.md` documents. A counter can be differenced
14226
+ * by whoever already keeps a history; a rate cannot be un-averaged.
14227
+ *
14228
+ * Absent — never zero — on a node with no `/proc`, on a read failure, and on
14229
+ * an entry with no process.
14230
+ */
14231
+ cpuSeconds: number().optional(),
14232
+ /** Resident bytes of this unit's process, same source and same rules. */
14233
+ rssBytes: number().optional()
14234
+ });
14235
+ method(_void(), array(LoadContributionSchema).readonly());
14019
14236
  /**
14020
14237
  * `log-channels` — the capability an addon DECLARES its diagnostic channels
14021
14238
  * through. It stores nothing.
@@ -14092,176 +14309,6 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
14092
14309
  tags: record(string(), string()).optional()
14093
14310
  }), array(LogEntrySchema).readonly());
14094
14311
  /**
14095
- * `failure-contribution` — the capability an addon reports its OWN losses
14096
- * through, per camera, with the denominator attached. It stores nothing.
14097
- *
14098
- * ## The twin of `load-contribution`, and why it is a twin and not a field
14099
- *
14100
- * `load-contribution` answers *what did this camera COST*. This answers *what
14101
- * did this camera LOSE*. The reporting discipline is identical and deliberately
14102
- * copied: the contributor reports what it already knows, hub-main adds only
14103
- * `addonId`, nothing needs global knowledge, and there is no central list for
14104
- * somebody to forget to edit.
14105
- *
14106
- * They are not merged, because their invariants are opposites:
14107
- *
14108
- * - a `load-contribution` measurement is **absent, never zero** — a zero would
14109
- * claim a camera cost nothing, which is a measurement nobody made;
14110
- * - a `failure-contribution` zero is the **most valuable value on the
14111
- * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
14112
- * and it is exactly what an absent entry cannot say.
14113
- *
14114
- * Putting a loss counter on a cost entry would also break the reconciliation
14115
- * that gives `load-contribution` its point: contributions are subtracted from
14116
- * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
14117
- * has no process.
14118
- *
14119
- * ## Why not a log line, since the counters already exist
14120
- *
14121
- * Several of these paths already counted themselves — `CaptureScheduler`'s
14122
- * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
14123
- * ends in a log line, and a log line is the thing the operator asked to stop
14124
- * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
14125
- * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
14126
- * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
14127
- * media blackout were both diagnosed. The counters stay; this is where they can
14128
- * be READ.
14129
- *
14130
- * ## The rate is served with its denominator or not at all
14131
- *
14132
- * Every entry carries `attempts` and `succeeded`. A miss count alone is
14133
- * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
14134
- * than yesterday" and was **flat across twelve hours** once divided by the
14135
- * successes on the same path. A surface that publishes only the numerator
14136
- * reproduces that mistake on every read.
14137
- *
14138
- * ## Shape
14139
- *
14140
- * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
14141
- * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
14142
- * generated hooks, while `addons.listCapabilityProviders` still enumerates it
14143
- * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
14144
- * a forked runner's entries reach hub-main over transport that already exists.
14145
- * No new UDS message, no second registry (D3). The operator reads the assembled
14146
- * result through `system.getFailureContributions`.
14147
- */
14148
- var FailureReasonCountSchema = object({
14149
- /**
14150
- * Why the attempt did not land, in the contributor's own vocabulary —
14151
- * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
14152
- * strings that already appear in this repo's logs and, where one exists, the
14153
- * same string the per-track `previewMissReason` records (D276): a second
14154
- * vocabulary for the same loss would make the row and the counter
14155
- * un-joinable.
14156
- */
14157
- reason: string(),
14158
- count: number().int().nonnegative()
14159
- });
14160
- var FailureContributionSchema = object({
14161
- /**
14162
- * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
14163
- * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
14164
- * `unit` free: the families are owned by different addons and a shared enum
14165
- * is a central list that rots invisibly.
14166
- */
14167
- family: string(),
14168
- /**
14169
- * The NUMERIC device id — the same value every log line carries as
14170
- * `tags.deviceId`. Never nullable and never absent: a contributor that
14171
- * cannot name the camera must not emit the entry, because a fleet total
14172
- * cannot answer the only question anybody asks of this surface.
14173
- */
14174
- deviceId: number().int().positive(),
14175
- /**
14176
- * A second dimension inside the family: the model / step id for an inference
14177
- * timeout, so "which camera AND which model" is one read. Absent when the
14178
- * family has a single variant.
14179
- */
14180
- variant: string().optional(),
14181
- /**
14182
- * Epoch ms this counter started — the INCARNATION MARKER. A consumer
14183
- * differencing two reads must drop the interval when it changes, because the
14184
- * counter restarted from zero in a respawned runner. Same discipline as
14185
- * `LoadContribution.startedAtMs`.
14186
- */
14187
- sinceMs: number(),
14188
- /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
14189
- atMs: number(),
14190
- /**
14191
- * THE DENOMINATOR — every attempt on this path for this camera in the
14192
- * window. A failure count published without it is the mistake this schema
14193
- * exists to make impossible.
14194
- */
14195
- attempts: number().int().nonnegative(),
14196
- /** Attempts that landed. `attempts - succeeded` is the loss. */
14197
- succeeded: number().int().nonnegative(),
14198
- /** The loss, partitioned. Sums to `attempts - succeeded`. */
14199
- reasons: array(FailureReasonCountSchema).readonly()
14200
- });
14201
- method(_void(), array(FailureContributionSchema).readonly());
14202
- var LoadContributionSchema = object({
14203
- role: _enum([
14204
- "decode",
14205
- "transcode",
14206
- "recording",
14207
- "streaming",
14208
- "detection"
14209
- ]),
14210
- /**
14211
- * The NUMERIC device id — the same value every log line carries as
14212
- * `tags.deviceId`. `null` means this cost genuinely belongs to no single
14213
- * camera (a shared pool), NOT that the contributor forgot to look it up: a
14214
- * contributor that cannot name its camera must not emit the entry at all,
14215
- * because an unnamed per-camera entry is indistinguishable from a shared one
14216
- * and would quietly turn one camera's cost into everybody's.
14217
- */
14218
- deviceId: number().int().positive().nullable(),
14219
- attribution: _enum([
14220
- "measured",
14221
- "accounted",
14222
- "unattributable"
14223
- ]),
14224
- /**
14225
- * What ONE entry is, in the contributor's own words — `615/high`,
14226
- * `617/native`, `cuda:0 shared pool`. Free text because the unit differs per
14227
- * family and inventing a common one would lose the only information that
14228
- * makes two entries for the same camera distinguishable.
14229
- */
14230
- unit: string(),
14231
- /**
14232
- * The OS process this cost lives in, when there is one. Present so a
14233
- * consumer can (a) tell two generations of the same unit apart across a
14234
- * restart, and (b) subtract claimed processes from the node's process
14235
- * snapshot to see what NOBODY claimed. Absent for an entry that owns no
14236
- * process of its own.
14237
- */
14238
- pid: number().int().positive().optional(),
14239
- /**
14240
- * When this generation started. The pid's incarnation marker: a consumer
14241
- * differencing {@link LoadContributionSchema.shape.cpuSeconds} must drop the
14242
- * window when this changes, because the counter restarted from zero in a new
14243
- * process.
14244
- */
14245
- startedAtMs: number().optional(),
14246
- /**
14247
- * CUMULATIVE CPU seconds this unit has consumed since it started — user +
14248
- * system, read from the child's own `/proc/<pid>/stat` at the moment the
14249
- * contribution is asked for.
14250
- *
14251
- * Cumulative and not a rate on purpose: a rate needs a window, a window
14252
- * needs a sampler, and a new per-node sampler is the defect half of
14253
- * `docs/architecture/load-ledger.md` documents. A counter can be differenced
14254
- * by whoever already keeps a history; a rate cannot be un-averaged.
14255
- *
14256
- * Absent — never zero — on a node with no `/proc`, on a read failure, and on
14257
- * an entry with no process.
14258
- */
14259
- cpuSeconds: number().optional(),
14260
- /** Resident bytes of this unit's process, same source and same rules. */
14261
- rssBytes: number().optional()
14262
- });
14263
- method(_void(), array(LoadContributionSchema).readonly());
14264
- /**
14265
14312
  * `login-method` — collection cap through which auth addons contribute
14266
14313
  * their pre-auth login surfaces to the login page. This is the SINGLE,
14267
14314
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
@@ -19029,12 +19076,53 @@ var MediaFileKindEnum = _enum([
19029
19076
  "keyFrameSmall",
19030
19077
  "thumbnailSmall"
19031
19078
  ]);
19079
+ /**
19080
+ * One media row ON THE WIRE: what it is, how big it is, and WHERE ITS BYTES
19081
+ * ARE — never the bytes themselves.
19082
+ *
19083
+ * ## Why `url` and not `base64`
19084
+ *
19085
+ * Measured on the live hub 2026-08-30: `getTrackMedia {trackId, deviceId}`
19086
+ * with no `kinds` returned 6 rows / **3 597 219 B**, of which `keyFrame` alone
19087
+ * was **2 824 077 B** — one full-resolution frame, base64, so +33 % on the
19088
+ * wire. Forty events is ~144 MB. Every byte of it was read off disk,
19089
+ * base64-encoded, held whole in a unary tRPC envelope, and materialised in
19090
+ * hub-main's heap on the way past — for an `<img>` that would have cached it.
19091
+ *
19092
+ * `url` points at the `event-media` data plane
19093
+ * (`/addon/<addonId>/event-media/<storedKey>`), which serves the same blob
19094
+ * with an ETag and `Cache-Control: immutable`, honours conditional GETs, can
19095
+ * render a `?variant=thumb`, and streams. The hub gate in front of it requires
19096
+ * a bearer or the session cookie (`access: 'authenticated'`), so the bytes are
19097
+ * no less protected than they were inside a `view`-level cap response — see
19098
+ * `data-plane-access.ts` for the rule and the one gap it does not close
19099
+ * (per-device scoping).
19100
+ *
19101
+ * The URL is built from the row's **stored** key, which is not always its
19102
+ * published `kind`: a track's face/plate crop is stored as `crop` under
19103
+ * `('face'|'plate', '<prefix>-<trackId>')` and published as
19104
+ * `faceCrop`/`plateCrop`. `MediaStore.getByKey` knows only the stored key.
19105
+ *
19106
+ * ## `base64` is TRANSITIONAL and is going away
19107
+ *
19108
+ * It is still populated for one reason: the deployed viewer's track-detail
19109
+ * HERO tile reads it (`use-track-media-entry.ts` → `parseMediaFiles`, which
19110
+ * REQUIRES the field), and a row without it parses as a FAILED read — the red
19111
+ * triangle — not as absence. Removing the field before that viewer ships is an
19112
+ * outage, not a cleanup. Once the viewer takes its hero bytes from `url`,
19113
+ * delete this line and the `withBytes` pass-through in
19114
+ * `analytics-query-facade.ts`; nothing else reads it.
19115
+ */
19032
19116
  var MediaFileSchema = object({
19033
19117
  key: string(),
19034
19118
  kind: MediaFileKindEnum,
19035
- base64: string(),
19036
19119
  sizeBytes: number(),
19037
19120
  timestamp: number()
19121
+ }).extend({
19122
+ /** `/addon/<addonId>/event-media/<encoded stored key>`. Always present. */
19123
+ url: string(),
19124
+ /** @deprecated Transitional — see the schema docblock. Use {@link url}. */
19125
+ base64: string()
19038
19126
  });
19039
19127
  /**
19040
19128
  * One media row WITHOUT its bytes.
@@ -19046,7 +19134,9 @@ var MediaFileSchema = object({
19046
19134
  * blocks the whole view.
19047
19135
  *
19048
19136
  * `sizeBytes` is carried because it is what lets a client decide between the
19049
- * stored blob and a `?variant=thumb` rendering without fetching either.
19137
+ * stored blob and a `?variant=thumb` rendering without fetching either, and
19138
+ * `url` because a client that had to build the plane path itself is a second
19139
+ * copy of a route — the embed, the viewer and the admin UI each grew one.
19050
19140
  */
19051
19141
  var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
19052
19142
  /**
@@ -19735,6 +19825,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19735
19825
  }), array(MediaFileSchema).readonly()), method(object({
19736
19826
  trackId: string(),
19737
19827
  deviceId: number()
19828
+ }), array(MediaFileInfoSchema).readonly()), method(object({
19829
+ eventId: string(),
19830
+ deviceId: number()
19738
19831
  }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
19739
19832
  kind: "mutation",
19740
19833
  auth: "admin"
@@ -24814,10 +24907,24 @@ var FaceClusterSchema = object({
24814
24907
  size: number().int(),
24815
24908
  cohesion: number()
24816
24909
  });
24910
+ /**
24911
+ * One gallery media row: what the crop is, how big it is, and WHERE its bytes
24912
+ * are — never the bytes.
24913
+ *
24914
+ * `base64` was deleted here rather than deprecated. `MediaFile.base64` (the
24915
+ * track/event contract) is still populated because a deployed viewer requires
24916
+ * the field to parse a row at all; this method has no such reader. Its ONE
24917
+ * caller is the admin UI's detail modal, which was building
24918
+ * `data:image/jpeg;base64,…` from a row whose `key` sat right beside it, in a
24919
+ * dialog already rendering its key FRAME from the `event-media` plane.
24920
+ *
24921
+ * `url` is `/addon/<addonId>/event-media/<encoded key>`. The plane resolves a
24922
+ * media key directly, so this needed no new plane and no new access decision.
24923
+ */
24817
24924
  var MediaFileLiteSchema$1 = object({
24818
24925
  key: string(),
24819
24926
  kind: string(),
24820
- base64: string(),
24927
+ url: string(),
24821
24928
  sizeBytes: number(),
24822
24929
  timestamp: number()
24823
24930
  });
@@ -27839,10 +27946,24 @@ var PlateInfoSchema = object({
27839
27946
  */
27840
27947
  cropUrl: string().optional()
27841
27948
  });
27949
+ /**
27950
+ * One gallery media row: what the crop is, how big it is, and WHERE its bytes
27951
+ * are — never the bytes.
27952
+ *
27953
+ * `base64` was deleted here rather than deprecated. `MediaFile.base64` (the
27954
+ * track/event contract) is still populated because a deployed viewer requires
27955
+ * the field to parse a row at all; this method has no such reader. Its ONE
27956
+ * caller is the admin UI's detail modal, which was building
27957
+ * `data:image/jpeg;base64,…` from a row whose `key` sat right beside it, in a
27958
+ * dialog already rendering its key FRAME from the `event-media` plane.
27959
+ *
27960
+ * `url` is `/addon/<addonId>/event-media/<encoded key>`. The plane resolves a
27961
+ * media key directly, so this needed no new plane and no new access decision.
27962
+ */
27842
27963
  var MediaFileLiteSchema = object({
27843
27964
  key: string(),
27844
27965
  kind: string(),
27845
- base64: string(),
27966
+ url: string(),
27846
27967
  sizeBytes: number(),
27847
27968
  timestamp: number()
27848
27969
  });
@@ -35739,6 +35860,12 @@ Object.freeze({
35739
35860
  addonId: null,
35740
35861
  access: "view"
35741
35862
  },
35863
+ "pipelineAnalytics.listEventMedia": {
35864
+ capName: "pipeline-analytics",
35865
+ capScope: "device",
35866
+ addonId: null,
35867
+ access: "view"
35868
+ },
35742
35869
  "pipelineAnalytics.listGroups": {
35743
35870
  capName: "pipeline-analytics",
35744
35871
  capScope: "device",
@@ -39362,6 +39489,11 @@ Object.freeze({
39362
39489
  form: "array",
39363
39490
  optional: false
39364
39491
  }],
39492
+ "pipelineAnalytics.listEventMedia": [{
39493
+ name: "deviceId",
39494
+ form: "single",
39495
+ optional: false
39496
+ }],
39365
39497
  "pipelineAnalytics.listGroups": [{
39366
39498
  name: "deviceIds",
39367
39499
  form: "array",
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  //#endregion
6
- const require_dist = require("../dist-DjxuSmvp.js");
6
+ const require_dist = require("../dist-BN8TjCTI.js");
7
7
  let node_crypto = require("node:crypto");
8
8
  //#region src/ha-export/topics.ts
9
9
  /**
@@ -1,4 +1,4 @@
1
- import { At as EventCategory, C as buildAddonRouteProvider, Et as string, N as deviceExportCapability, X as oauthIntegrationCapability, a as COCO_TO_MACRO, c as FanDirectionSchema, i as CAMERA_SWITCH_ORDER, l as HvacModeSchema, o as CameraSwitchIdSchema, p as addonRoutesCapability, pt as BaseAddon, t as AlarmArmModeSchema, u as MediaPlayerRepeatSchema, vt as nodePin } from "../dist-CCHqsqE6.mjs";
1
+ import { At as EventCategory, C as buildAddonRouteProvider, Et as string, N as deviceExportCapability, X as oauthIntegrationCapability, a as COCO_TO_MACRO, c as FanDirectionSchema, i as CAMERA_SWITCH_ORDER, l as HvacModeSchema, o as CameraSwitchIdSchema, p as addonRoutesCapability, pt as BaseAddon, t as AlarmArmModeSchema, u as MediaPlayerRepeatSchema, vt as nodePin } from "../dist-D4pIhy8v.mjs";
2
2
  import { createHmac, timingSafeEqual } from "node:crypto";
3
3
  //#region src/ha-export/topics.ts
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-homeassistant",
3
- "version": "1.2.58",
3
+ "version": "1.2.60",
4
4
  "description": "Home Assistant device provider addon for CamStack",
5
5
  "keywords": [
6
6
  "camstack",