@camstack/addon-provider-tuya 0.2.45 → 0.2.47

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 (3) hide show
  1. package/dist/addon.js +313 -181
  2. package/dist/addon.mjs +313 -181
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -8823,6 +8823,21 @@ var RelocateJobSchema = object({
8823
8823
  bytesMoved: number().int(),
8824
8824
  /** Total files discovered up front; null while (or when) unknown. */
8825
8825
  filesTotal: number().int().nullable(),
8826
+ /**
8827
+ * Rows this run CORRECTED while moving them — a durable mutation the move
8828
+ * made that nobody asked for, so it is reported where the operator reads the
8829
+ * job rather than only in a log line.
8830
+ *
8831
+ * A footage segment records its byte count in its own NAME, and the durable
8832
+ * hour row derives its aggregates from those names. A file that does not
8833
+ * match its name therefore makes the ledger's sums — and with them quota and
8834
+ * pressure eviction — wrong by the difference, and only a rename can fix it.
8835
+ * On 2026-08-30 one such row also stalled a 110 749-file drain permanently.
8836
+ *
8837
+ * Absent on lanes where the question has no meaning: a media blob's size is
8838
+ * in its row, not in its name, so `MediaRelocateEngine` never reconciles one.
8839
+ */
8840
+ rowsReconciled: number().int().nonnegative().optional(),
8826
8841
  startedAt: number(),
8827
8842
  finishedAt: number().nullable(),
8828
8843
  error: string().nullable()
@@ -8891,14 +8906,42 @@ var RelocateMediaInputSchema = object({
8891
8906
  /** Omitted = `move`, the pre-existing behaviour. */
8892
8907
  mode: MediaRelocateModeSchema.optional()
8893
8908
  });
8894
- /** How many rows still carry NO `locationId` — the population a repoint would
8895
- * silently re-aim at a disk that does not hold their bytes. Zero is the only
8896
- * value that permits a non-blocking `eventMedia` cutover. */
8897
- var UnstampedEventMediaCountSchema = object({
8898
- media: number().int().nonnegative(),
8899
- retrainFrames: number().int().nonnegative(),
8900
- total: number().int().nonnegative()
8909
+ /**
8910
+ * The unstamped population of ONE collection — split, because the gate and the
8911
+ * operator ask two different questions and only one of them has to be cheap.
8912
+ *
8913
+ * `present` is the GATE: "is there at least one row that would be orphaned by a
8914
+ * repoint". It is a single indexed seek to the first matching row, so it stays
8915
+ * answerable on a saturated disk and answers in O(log n) precisely in the state
8916
+ * that matters — after a seal, when the population is empty.
8917
+ *
8918
+ * `rows` is the NUMBER, for the refusal message and the operator's sense of
8919
+ * scale. It is a second, indexed `COUNT(*)`, and `null` means **not
8920
+ * measurable** — never zero. `{ present: true, rows: null }` is a legitimate
8921
+ * and useful answer: "there are some, and this read could not say how many"
8922
+ * still refuses the cutover, which is the whole job.
8923
+ */
8924
+ var UnstampedRowsSchema = object({
8925
+ present: boolean(),
8926
+ rows: number().int().nonnegative().nullable()
8901
8927
  });
8928
+ /**
8929
+ * How many rows still carry NO `locationId` — the population a repoint would
8930
+ * silently re-aim at a disk that does not hold their bytes.
8931
+ *
8932
+ * **`null` = the count could not be taken**, and it is NOT permission to cut
8933
+ * over. The gate opens on a measured absence and on nothing else; an unread
8934
+ * collection and an empty one are different facts, and this repo has already
8935
+ * paid for conflating them (`RelocateResidueSchema`, D295).
8936
+ */
8937
+ var UnstampedEventMediaCountSchema = object({
8938
+ media: UnstampedRowsSchema,
8939
+ retrainFrames: UnstampedRowsSchema,
8940
+ /** True when EITHER collection holds one. The refusal reads this. */
8941
+ anyPresent: boolean(),
8942
+ /** Sum across both, or `null` when either lane could not be counted. */
8943
+ total: number().int().nonnegative().nullable()
8944
+ }).nullable();
8902
8945
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8903
8946
  /** The independently selectable logical storage classes — every class
8904
8947
  * `storage.listLocationDeclarations` reports, so an operator never meets a
@@ -9009,6 +9052,10 @@ var StorageMigrationMoveProgressSchema = object({
9009
9052
  /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
9010
9053
  filesTotal: number().int().nonnegative().nullable(),
9011
9054
  bytesMoved: number().int().nonnegative(),
9055
+ /** Rows the mover corrected while moving them — see `RelocateJob`. Absent on
9056
+ * a lane that cannot reconcile. A migration that silently rewrote durable
9057
+ * rows would be the same failure as one that silently skipped them. */
9058
+ rowsReconciled: number().int().nonnegative().optional(),
9012
9059
  /** The MOVER's start, not the migration's: a drain restarted after an addon
9013
9060
  * crash gets a new mover, and a rate computed from the migration's start
9014
9061
  * would silently average in the time nothing was running. */
@@ -13974,6 +14021,114 @@ method(object({
13974
14021
  height: number()
13975
14022
  }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
13976
14023
  /**
14024
+ * `failure-contribution` — the capability an addon reports its OWN losses
14025
+ * through, per camera, with the denominator attached. It stores nothing.
14026
+ *
14027
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
14028
+ *
14029
+ * `load-contribution` answers *what did this camera COST*. This answers *what
14030
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
14031
+ * copied: the contributor reports what it already knows, hub-main adds only
14032
+ * `addonId`, nothing needs global knowledge, and there is no central list for
14033
+ * somebody to forget to edit.
14034
+ *
14035
+ * They are not merged, because their invariants are opposites:
14036
+ *
14037
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
14038
+ * claim a camera cost nothing, which is a measurement nobody made;
14039
+ * - a `failure-contribution` zero is the **most valuable value on the
14040
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
14041
+ * and it is exactly what an absent entry cannot say.
14042
+ *
14043
+ * Putting a loss counter on a cost entry would also break the reconciliation
14044
+ * that gives `load-contribution` its point: contributions are subtracted from
14045
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
14046
+ * has no process.
14047
+ *
14048
+ * ## Why not a log line, since the counters already exist
14049
+ *
14050
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
14051
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
14052
+ * ends in a log line, and a log line is the thing the operator asked to stop
14053
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
14054
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
14055
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
14056
+ * media blackout were both diagnosed. The counters stay; this is where they can
14057
+ * be READ.
14058
+ *
14059
+ * ## The rate is served with its denominator or not at all
14060
+ *
14061
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
14062
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
14063
+ * than yesterday" and was **flat across twelve hours** once divided by the
14064
+ * successes on the same path. A surface that publishes only the numerator
14065
+ * reproduces that mistake on every read.
14066
+ *
14067
+ * ## Shape
14068
+ *
14069
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
14070
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
14071
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
14072
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
14073
+ * a forked runner's entries reach hub-main over transport that already exists.
14074
+ * No new UDS message, no second registry (D3). The operator reads the assembled
14075
+ * result through `system.getFailureContributions`.
14076
+ */
14077
+ var FailureReasonCountSchema = object({
14078
+ /**
14079
+ * Why the attempt did not land, in the contributor's own vocabulary —
14080
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
14081
+ * strings that already appear in this repo's logs and, where one exists, the
14082
+ * same string the per-track `previewMissReason` records (D276): a second
14083
+ * vocabulary for the same loss would make the row and the counter
14084
+ * un-joinable.
14085
+ */
14086
+ reason: string(),
14087
+ count: number().int().nonnegative()
14088
+ });
14089
+ var FailureContributionSchema = object({
14090
+ /**
14091
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
14092
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
14093
+ * `unit` free: the families are owned by different addons and a shared enum
14094
+ * is a central list that rots invisibly.
14095
+ */
14096
+ family: string(),
14097
+ /**
14098
+ * The NUMERIC device id — the same value every log line carries as
14099
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
14100
+ * cannot name the camera must not emit the entry, because a fleet total
14101
+ * cannot answer the only question anybody asks of this surface.
14102
+ */
14103
+ deviceId: number().int().positive(),
14104
+ /**
14105
+ * A second dimension inside the family: the model / step id for an inference
14106
+ * timeout, so "which camera AND which model" is one read. Absent when the
14107
+ * family has a single variant.
14108
+ */
14109
+ variant: string().optional(),
14110
+ /**
14111
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
14112
+ * differencing two reads must drop the interval when it changes, because the
14113
+ * counter restarted from zero in a respawned runner. Same discipline as
14114
+ * `LoadContribution.startedAtMs`.
14115
+ */
14116
+ sinceMs: number(),
14117
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
14118
+ atMs: number(),
14119
+ /**
14120
+ * THE DENOMINATOR — every attempt on this path for this camera in the
14121
+ * window. A failure count published without it is the mistake this schema
14122
+ * exists to make impossible.
14123
+ */
14124
+ attempts: number().int().nonnegative(),
14125
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
14126
+ succeeded: number().int().nonnegative(),
14127
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
14128
+ reasons: array(FailureReasonCountSchema).readonly()
14129
+ });
14130
+ method(_void(), array(FailureContributionSchema).readonly());
14131
+ /**
13977
14132
  * filesystem-browse — per-node capability for browsing the node's local
13978
14133
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
13979
14134
  * are sandboxed to operator-configured allowed roots (D115). Used by the
@@ -14495,6 +14650,68 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }
14495
14650
  kind: "mutation",
14496
14651
  auth: "admin"
14497
14652
  });
14653
+ var LoadContributionSchema = object({
14654
+ role: _enum([
14655
+ "decode",
14656
+ "transcode",
14657
+ "recording",
14658
+ "streaming",
14659
+ "detection"
14660
+ ]),
14661
+ /**
14662
+ * The NUMERIC device id — the same value every log line carries as
14663
+ * `tags.deviceId`. `null` means this cost genuinely belongs to no single
14664
+ * camera (a shared pool), NOT that the contributor forgot to look it up: a
14665
+ * contributor that cannot name its camera must not emit the entry at all,
14666
+ * because an unnamed per-camera entry is indistinguishable from a shared one
14667
+ * and would quietly turn one camera's cost into everybody's.
14668
+ */
14669
+ deviceId: number().int().positive().nullable(),
14670
+ attribution: _enum([
14671
+ "measured",
14672
+ "accounted",
14673
+ "unattributable"
14674
+ ]),
14675
+ /**
14676
+ * What ONE entry is, in the contributor's own words — `615/high`,
14677
+ * `617/native`, `cuda:0 shared pool`. Free text because the unit differs per
14678
+ * family and inventing a common one would lose the only information that
14679
+ * makes two entries for the same camera distinguishable.
14680
+ */
14681
+ unit: string(),
14682
+ /**
14683
+ * The OS process this cost lives in, when there is one. Present so a
14684
+ * consumer can (a) tell two generations of the same unit apart across a
14685
+ * restart, and (b) subtract claimed processes from the node's process
14686
+ * snapshot to see what NOBODY claimed. Absent for an entry that owns no
14687
+ * process of its own.
14688
+ */
14689
+ pid: number().int().positive().optional(),
14690
+ /**
14691
+ * When this generation started. The pid's incarnation marker: a consumer
14692
+ * differencing {@link LoadContributionSchema.shape.cpuSeconds} must drop the
14693
+ * window when this changes, because the counter restarted from zero in a new
14694
+ * process.
14695
+ */
14696
+ startedAtMs: number().optional(),
14697
+ /**
14698
+ * CUMULATIVE CPU seconds this unit has consumed since it started — user +
14699
+ * system, read from the child's own `/proc/<pid>/stat` at the moment the
14700
+ * contribution is asked for.
14701
+ *
14702
+ * Cumulative and not a rate on purpose: a rate needs a window, a window
14703
+ * needs a sampler, and a new per-node sampler is the defect half of
14704
+ * `docs/architecture/load-ledger.md` documents. A counter can be differenced
14705
+ * by whoever already keeps a history; a rate cannot be un-averaged.
14706
+ *
14707
+ * Absent — never zero — on a node with no `/proc`, on a read failure, and on
14708
+ * an entry with no process.
14709
+ */
14710
+ cpuSeconds: number().optional(),
14711
+ /** Resident bytes of this unit's process, same source and same rules. */
14712
+ rssBytes: number().optional()
14713
+ });
14714
+ method(_void(), array(LoadContributionSchema).readonly());
14498
14715
  /**
14499
14716
  * `log-channels` — the capability an addon DECLARES its diagnostic channels
14500
14717
  * through. It stores nothing.
@@ -14571,176 +14788,6 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
14571
14788
  tags: record(string(), string()).optional()
14572
14789
  }), array(LogEntrySchema).readonly());
14573
14790
  /**
14574
- * `failure-contribution` — the capability an addon reports its OWN losses
14575
- * through, per camera, with the denominator attached. It stores nothing.
14576
- *
14577
- * ## The twin of `load-contribution`, and why it is a twin and not a field
14578
- *
14579
- * `load-contribution` answers *what did this camera COST*. This answers *what
14580
- * did this camera LOSE*. The reporting discipline is identical and deliberately
14581
- * copied: the contributor reports what it already knows, hub-main adds only
14582
- * `addonId`, nothing needs global knowledge, and there is no central list for
14583
- * somebody to forget to edit.
14584
- *
14585
- * They are not merged, because their invariants are opposites:
14586
- *
14587
- * - a `load-contribution` measurement is **absent, never zero** — a zero would
14588
- * claim a camera cost nothing, which is a measurement nobody made;
14589
- * - a `failure-contribution` zero is the **most valuable value on the
14590
- * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
14591
- * and it is exactly what an absent entry cannot say.
14592
- *
14593
- * Putting a loss counter on a cost entry would also break the reconciliation
14594
- * that gives `load-contribution` its point: contributions are subtracted from
14595
- * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
14596
- * has no process.
14597
- *
14598
- * ## Why not a log line, since the counters already exist
14599
- *
14600
- * Several of these paths already counted themselves — `CaptureScheduler`'s
14601
- * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
14602
- * ends in a log line, and a log line is the thing the operator asked to stop
14603
- * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
14604
- * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
14605
- * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
14606
- * media blackout were both diagnosed. The counters stay; this is where they can
14607
- * be READ.
14608
- *
14609
- * ## The rate is served with its denominator or not at all
14610
- *
14611
- * Every entry carries `attempts` and `succeeded`. A miss count alone is
14612
- * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
14613
- * than yesterday" and was **flat across twelve hours** once divided by the
14614
- * successes on the same path. A surface that publishes only the numerator
14615
- * reproduces that mistake on every read.
14616
- *
14617
- * ## Shape
14618
- *
14619
- * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
14620
- * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
14621
- * generated hooks, while `addons.listCapabilityProviders` still enumerates it
14622
- * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
14623
- * a forked runner's entries reach hub-main over transport that already exists.
14624
- * No new UDS message, no second registry (D3). The operator reads the assembled
14625
- * result through `system.getFailureContributions`.
14626
- */
14627
- var FailureReasonCountSchema = object({
14628
- /**
14629
- * Why the attempt did not land, in the contributor's own vocabulary —
14630
- * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
14631
- * strings that already appear in this repo's logs and, where one exists, the
14632
- * same string the per-track `previewMissReason` records (D276): a second
14633
- * vocabulary for the same loss would make the row and the counter
14634
- * un-joinable.
14635
- */
14636
- reason: string(),
14637
- count: number().int().nonnegative()
14638
- });
14639
- var FailureContributionSchema = object({
14640
- /**
14641
- * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
14642
- * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
14643
- * `unit` free: the families are owned by different addons and a shared enum
14644
- * is a central list that rots invisibly.
14645
- */
14646
- family: string(),
14647
- /**
14648
- * The NUMERIC device id — the same value every log line carries as
14649
- * `tags.deviceId`. Never nullable and never absent: a contributor that
14650
- * cannot name the camera must not emit the entry, because a fleet total
14651
- * cannot answer the only question anybody asks of this surface.
14652
- */
14653
- deviceId: number().int().positive(),
14654
- /**
14655
- * A second dimension inside the family: the model / step id for an inference
14656
- * timeout, so "which camera AND which model" is one read. Absent when the
14657
- * family has a single variant.
14658
- */
14659
- variant: string().optional(),
14660
- /**
14661
- * Epoch ms this counter started — the INCARNATION MARKER. A consumer
14662
- * differencing two reads must drop the interval when it changes, because the
14663
- * counter restarted from zero in a respawned runner. Same discipline as
14664
- * `LoadContribution.startedAtMs`.
14665
- */
14666
- sinceMs: number(),
14667
- /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
14668
- atMs: number(),
14669
- /**
14670
- * THE DENOMINATOR — every attempt on this path for this camera in the
14671
- * window. A failure count published without it is the mistake this schema
14672
- * exists to make impossible.
14673
- */
14674
- attempts: number().int().nonnegative(),
14675
- /** Attempts that landed. `attempts - succeeded` is the loss. */
14676
- succeeded: number().int().nonnegative(),
14677
- /** The loss, partitioned. Sums to `attempts - succeeded`. */
14678
- reasons: array(FailureReasonCountSchema).readonly()
14679
- });
14680
- method(_void(), array(FailureContributionSchema).readonly());
14681
- var LoadContributionSchema = object({
14682
- role: _enum([
14683
- "decode",
14684
- "transcode",
14685
- "recording",
14686
- "streaming",
14687
- "detection"
14688
- ]),
14689
- /**
14690
- * The NUMERIC device id — the same value every log line carries as
14691
- * `tags.deviceId`. `null` means this cost genuinely belongs to no single
14692
- * camera (a shared pool), NOT that the contributor forgot to look it up: a
14693
- * contributor that cannot name its camera must not emit the entry at all,
14694
- * because an unnamed per-camera entry is indistinguishable from a shared one
14695
- * and would quietly turn one camera's cost into everybody's.
14696
- */
14697
- deviceId: number().int().positive().nullable(),
14698
- attribution: _enum([
14699
- "measured",
14700
- "accounted",
14701
- "unattributable"
14702
- ]),
14703
- /**
14704
- * What ONE entry is, in the contributor's own words — `615/high`,
14705
- * `617/native`, `cuda:0 shared pool`. Free text because the unit differs per
14706
- * family and inventing a common one would lose the only information that
14707
- * makes two entries for the same camera distinguishable.
14708
- */
14709
- unit: string(),
14710
- /**
14711
- * The OS process this cost lives in, when there is one. Present so a
14712
- * consumer can (a) tell two generations of the same unit apart across a
14713
- * restart, and (b) subtract claimed processes from the node's process
14714
- * snapshot to see what NOBODY claimed. Absent for an entry that owns no
14715
- * process of its own.
14716
- */
14717
- pid: number().int().positive().optional(),
14718
- /**
14719
- * When this generation started. The pid's incarnation marker: a consumer
14720
- * differencing {@link LoadContributionSchema.shape.cpuSeconds} must drop the
14721
- * window when this changes, because the counter restarted from zero in a new
14722
- * process.
14723
- */
14724
- startedAtMs: number().optional(),
14725
- /**
14726
- * CUMULATIVE CPU seconds this unit has consumed since it started — user +
14727
- * system, read from the child's own `/proc/<pid>/stat` at the moment the
14728
- * contribution is asked for.
14729
- *
14730
- * Cumulative and not a rate on purpose: a rate needs a window, a window
14731
- * needs a sampler, and a new per-node sampler is the defect half of
14732
- * `docs/architecture/load-ledger.md` documents. A counter can be differenced
14733
- * by whoever already keeps a history; a rate cannot be un-averaged.
14734
- *
14735
- * Absent — never zero — on a node with no `/proc`, on a read failure, and on
14736
- * an entry with no process.
14737
- */
14738
- cpuSeconds: number().optional(),
14739
- /** Resident bytes of this unit's process, same source and same rules. */
14740
- rssBytes: number().optional()
14741
- });
14742
- method(_void(), array(LoadContributionSchema).readonly());
14743
- /**
14744
14791
  * `login-method` — collection cap through which auth addons contribute
14745
14792
  * their pre-auth login surfaces to the login page. This is the SINGLE,
14746
14793
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
@@ -19478,12 +19525,53 @@ var MediaFileKindEnum = _enum([
19478
19525
  "keyFrameSmall",
19479
19526
  "thumbnailSmall"
19480
19527
  ]);
19528
+ /**
19529
+ * One media row ON THE WIRE: what it is, how big it is, and WHERE ITS BYTES
19530
+ * ARE — never the bytes themselves.
19531
+ *
19532
+ * ## Why `url` and not `base64`
19533
+ *
19534
+ * Measured on the live hub 2026-08-30: `getTrackMedia {trackId, deviceId}`
19535
+ * with no `kinds` returned 6 rows / **3 597 219 B**, of which `keyFrame` alone
19536
+ * was **2 824 077 B** — one full-resolution frame, base64, so +33 % on the
19537
+ * wire. Forty events is ~144 MB. Every byte of it was read off disk,
19538
+ * base64-encoded, held whole in a unary tRPC envelope, and materialised in
19539
+ * hub-main's heap on the way past — for an `<img>` that would have cached it.
19540
+ *
19541
+ * `url` points at the `event-media` data plane
19542
+ * (`/addon/<addonId>/event-media/<storedKey>`), which serves the same blob
19543
+ * with an ETag and `Cache-Control: immutable`, honours conditional GETs, can
19544
+ * render a `?variant=thumb`, and streams. The hub gate in front of it requires
19545
+ * a bearer or the session cookie (`access: 'authenticated'`), so the bytes are
19546
+ * no less protected than they were inside a `view`-level cap response — see
19547
+ * `data-plane-access.ts` for the rule and the one gap it does not close
19548
+ * (per-device scoping).
19549
+ *
19550
+ * The URL is built from the row's **stored** key, which is not always its
19551
+ * published `kind`: a track's face/plate crop is stored as `crop` under
19552
+ * `('face'|'plate', '<prefix>-<trackId>')` and published as
19553
+ * `faceCrop`/`plateCrop`. `MediaStore.getByKey` knows only the stored key.
19554
+ *
19555
+ * ## `base64` is TRANSITIONAL and is going away
19556
+ *
19557
+ * It is still populated for one reason: the deployed viewer's track-detail
19558
+ * HERO tile reads it (`use-track-media-entry.ts` → `parseMediaFiles`, which
19559
+ * REQUIRES the field), and a row without it parses as a FAILED read — the red
19560
+ * triangle — not as absence. Removing the field before that viewer ships is an
19561
+ * outage, not a cleanup. Once the viewer takes its hero bytes from `url`,
19562
+ * delete this line and the `withBytes` pass-through in
19563
+ * `analytics-query-facade.ts`; nothing else reads it.
19564
+ */
19481
19565
  var MediaFileSchema = object({
19482
19566
  key: string(),
19483
19567
  kind: MediaFileKindEnum,
19484
- base64: string(),
19485
19568
  sizeBytes: number(),
19486
19569
  timestamp: number()
19570
+ }).extend({
19571
+ /** `/addon/<addonId>/event-media/<encoded stored key>`. Always present. */
19572
+ url: string(),
19573
+ /** @deprecated Transitional — see the schema docblock. Use {@link url}. */
19574
+ base64: string()
19487
19575
  });
19488
19576
  /**
19489
19577
  * One media row WITHOUT its bytes.
@@ -19495,7 +19583,9 @@ var MediaFileSchema = object({
19495
19583
  * blocks the whole view.
19496
19584
  *
19497
19585
  * `sizeBytes` is carried because it is what lets a client decide between the
19498
- * stored blob and a `?variant=thumb` rendering without fetching either.
19586
+ * stored blob and a `?variant=thumb` rendering without fetching either, and
19587
+ * `url` because a client that had to build the plane path itself is a second
19588
+ * copy of a route — the embed, the viewer and the admin UI each grew one.
19499
19589
  */
19500
19590
  var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
19501
19591
  /**
@@ -20184,6 +20274,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
20184
20274
  }), array(MediaFileSchema).readonly()), method(object({
20185
20275
  trackId: string(),
20186
20276
  deviceId: number()
20277
+ }), array(MediaFileInfoSchema).readonly()), method(object({
20278
+ eventId: string(),
20279
+ deviceId: number()
20187
20280
  }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
20188
20281
  kind: "mutation",
20189
20282
  auth: "admin"
@@ -25182,10 +25275,24 @@ var FaceClusterSchema = object({
25182
25275
  size: number().int(),
25183
25276
  cohesion: number()
25184
25277
  });
25278
+ /**
25279
+ * One gallery media row: what the crop is, how big it is, and WHERE its bytes
25280
+ * are — never the bytes.
25281
+ *
25282
+ * `base64` was deleted here rather than deprecated. `MediaFile.base64` (the
25283
+ * track/event contract) is still populated because a deployed viewer requires
25284
+ * the field to parse a row at all; this method has no such reader. Its ONE
25285
+ * caller is the admin UI's detail modal, which was building
25286
+ * `data:image/jpeg;base64,…` from a row whose `key` sat right beside it, in a
25287
+ * dialog already rendering its key FRAME from the `event-media` plane.
25288
+ *
25289
+ * `url` is `/addon/<addonId>/event-media/<encoded key>`. The plane resolves a
25290
+ * media key directly, so this needed no new plane and no new access decision.
25291
+ */
25185
25292
  var MediaFileLiteSchema$1 = object({
25186
25293
  key: string(),
25187
25294
  kind: string(),
25188
- base64: string(),
25295
+ url: string(),
25189
25296
  sizeBytes: number(),
25190
25297
  timestamp: number()
25191
25298
  });
@@ -28207,10 +28314,24 @@ var PlateInfoSchema = object({
28207
28314
  */
28208
28315
  cropUrl: string().optional()
28209
28316
  });
28317
+ /**
28318
+ * One gallery media row: what the crop is, how big it is, and WHERE its bytes
28319
+ * are — never the bytes.
28320
+ *
28321
+ * `base64` was deleted here rather than deprecated. `MediaFile.base64` (the
28322
+ * track/event contract) is still populated because a deployed viewer requires
28323
+ * the field to parse a row at all; this method has no such reader. Its ONE
28324
+ * caller is the admin UI's detail modal, which was building
28325
+ * `data:image/jpeg;base64,…` from a row whose `key` sat right beside it, in a
28326
+ * dialog already rendering its key FRAME from the `event-media` plane.
28327
+ *
28328
+ * `url` is `/addon/<addonId>/event-media/<encoded key>`. The plane resolves a
28329
+ * media key directly, so this needed no new plane and no new access decision.
28330
+ */
28210
28331
  var MediaFileLiteSchema = object({
28211
28332
  key: string(),
28212
28333
  kind: string(),
28213
- base64: string(),
28334
+ url: string(),
28214
28335
  sizeBytes: number(),
28215
28336
  timestamp: number()
28216
28337
  });
@@ -36107,6 +36228,12 @@ Object.freeze({
36107
36228
  addonId: null,
36108
36229
  access: "view"
36109
36230
  },
36231
+ "pipelineAnalytics.listEventMedia": {
36232
+ capName: "pipeline-analytics",
36233
+ capScope: "device",
36234
+ addonId: null,
36235
+ access: "view"
36236
+ },
36110
36237
  "pipelineAnalytics.listGroups": {
36111
36238
  capName: "pipeline-analytics",
36112
36239
  capScope: "device",
@@ -39730,6 +39857,11 @@ Object.freeze({
39730
39857
  form: "array",
39731
39858
  optional: false
39732
39859
  }],
39860
+ "pipelineAnalytics.listEventMedia": [{
39861
+ name: "deviceId",
39862
+ form: "single",
39863
+ optional: false
39864
+ }],
39733
39865
  "pipelineAnalytics.listGroups": [{
39734
39866
  name: "deviceIds",
39735
39867
  form: "array",
package/dist/addon.mjs CHANGED
@@ -8822,6 +8822,21 @@ var RelocateJobSchema = object({
8822
8822
  bytesMoved: number().int(),
8823
8823
  /** Total files discovered up front; null while (or when) unknown. */
8824
8824
  filesTotal: number().int().nullable(),
8825
+ /**
8826
+ * Rows this run CORRECTED while moving them — a durable mutation the move
8827
+ * made that nobody asked for, so it is reported where the operator reads the
8828
+ * job rather than only in a log line.
8829
+ *
8830
+ * A footage segment records its byte count in its own NAME, and the durable
8831
+ * hour row derives its aggregates from those names. A file that does not
8832
+ * match its name therefore makes the ledger's sums — and with them quota and
8833
+ * pressure eviction — wrong by the difference, and only a rename can fix it.
8834
+ * On 2026-08-30 one such row also stalled a 110 749-file drain permanently.
8835
+ *
8836
+ * Absent on lanes where the question has no meaning: a media blob's size is
8837
+ * in its row, not in its name, so `MediaRelocateEngine` never reconciles one.
8838
+ */
8839
+ rowsReconciled: number().int().nonnegative().optional(),
8825
8840
  startedAt: number(),
8826
8841
  finishedAt: number().nullable(),
8827
8842
  error: string().nullable()
@@ -8890,14 +8905,42 @@ var RelocateMediaInputSchema = object({
8890
8905
  /** Omitted = `move`, the pre-existing behaviour. */
8891
8906
  mode: MediaRelocateModeSchema.optional()
8892
8907
  });
8893
- /** How many rows still carry NO `locationId` — the population a repoint would
8894
- * silently re-aim at a disk that does not hold their bytes. Zero is the only
8895
- * value that permits a non-blocking `eventMedia` cutover. */
8896
- var UnstampedEventMediaCountSchema = object({
8897
- media: number().int().nonnegative(),
8898
- retrainFrames: number().int().nonnegative(),
8899
- total: number().int().nonnegative()
8908
+ /**
8909
+ * The unstamped population of ONE collection — split, because the gate and the
8910
+ * operator ask two different questions and only one of them has to be cheap.
8911
+ *
8912
+ * `present` is the GATE: "is there at least one row that would be orphaned by a
8913
+ * repoint". It is a single indexed seek to the first matching row, so it stays
8914
+ * answerable on a saturated disk and answers in O(log n) precisely in the state
8915
+ * that matters — after a seal, when the population is empty.
8916
+ *
8917
+ * `rows` is the NUMBER, for the refusal message and the operator's sense of
8918
+ * scale. It is a second, indexed `COUNT(*)`, and `null` means **not
8919
+ * measurable** — never zero. `{ present: true, rows: null }` is a legitimate
8920
+ * and useful answer: "there are some, and this read could not say how many"
8921
+ * still refuses the cutover, which is the whole job.
8922
+ */
8923
+ var UnstampedRowsSchema = object({
8924
+ present: boolean(),
8925
+ rows: number().int().nonnegative().nullable()
8900
8926
  });
8927
+ /**
8928
+ * How many rows still carry NO `locationId` — the population a repoint would
8929
+ * silently re-aim at a disk that does not hold their bytes.
8930
+ *
8931
+ * **`null` = the count could not be taken**, and it is NOT permission to cut
8932
+ * over. The gate opens on a measured absence and on nothing else; an unread
8933
+ * collection and an empty one are different facts, and this repo has already
8934
+ * paid for conflating them (`RelocateResidueSchema`, D295).
8935
+ */
8936
+ var UnstampedEventMediaCountSchema = object({
8937
+ media: UnstampedRowsSchema,
8938
+ retrainFrames: UnstampedRowsSchema,
8939
+ /** True when EITHER collection holds one. The refusal reads this. */
8940
+ anyPresent: boolean(),
8941
+ /** Sum across both, or `null` when either lane could not be counted. */
8942
+ total: number().int().nonnegative().nullable()
8943
+ }).nullable();
8901
8944
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8902
8945
  /** The independently selectable logical storage classes — every class
8903
8946
  * `storage.listLocationDeclarations` reports, so an operator never meets a
@@ -9008,6 +9051,10 @@ var StorageMigrationMoveProgressSchema = object({
9008
9051
  /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
9009
9052
  filesTotal: number().int().nonnegative().nullable(),
9010
9053
  bytesMoved: number().int().nonnegative(),
9054
+ /** Rows the mover corrected while moving them — see `RelocateJob`. Absent on
9055
+ * a lane that cannot reconcile. A migration that silently rewrote durable
9056
+ * rows would be the same failure as one that silently skipped them. */
9057
+ rowsReconciled: number().int().nonnegative().optional(),
9011
9058
  /** The MOVER's start, not the migration's: a drain restarted after an addon
9012
9059
  * crash gets a new mover, and a rate computed from the migration's start
9013
9060
  * would silently average in the time nothing was running. */
@@ -13973,6 +14020,114 @@ method(object({
13973
14020
  height: number()
13974
14021
  }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
13975
14022
  /**
14023
+ * `failure-contribution` — the capability an addon reports its OWN losses
14024
+ * through, per camera, with the denominator attached. It stores nothing.
14025
+ *
14026
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
14027
+ *
14028
+ * `load-contribution` answers *what did this camera COST*. This answers *what
14029
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
14030
+ * copied: the contributor reports what it already knows, hub-main adds only
14031
+ * `addonId`, nothing needs global knowledge, and there is no central list for
14032
+ * somebody to forget to edit.
14033
+ *
14034
+ * They are not merged, because their invariants are opposites:
14035
+ *
14036
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
14037
+ * claim a camera cost nothing, which is a measurement nobody made;
14038
+ * - a `failure-contribution` zero is the **most valuable value on the
14039
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
14040
+ * and it is exactly what an absent entry cannot say.
14041
+ *
14042
+ * Putting a loss counter on a cost entry would also break the reconciliation
14043
+ * that gives `load-contribution` its point: contributions are subtracted from
14044
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
14045
+ * has no process.
14046
+ *
14047
+ * ## Why not a log line, since the counters already exist
14048
+ *
14049
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
14050
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
14051
+ * ends in a log line, and a log line is the thing the operator asked to stop
14052
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
14053
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
14054
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
14055
+ * media blackout were both diagnosed. The counters stay; this is where they can
14056
+ * be READ.
14057
+ *
14058
+ * ## The rate is served with its denominator or not at all
14059
+ *
14060
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
14061
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
14062
+ * than yesterday" and was **flat across twelve hours** once divided by the
14063
+ * successes on the same path. A surface that publishes only the numerator
14064
+ * reproduces that mistake on every read.
14065
+ *
14066
+ * ## Shape
14067
+ *
14068
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
14069
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
14070
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
14071
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
14072
+ * a forked runner's entries reach hub-main over transport that already exists.
14073
+ * No new UDS message, no second registry (D3). The operator reads the assembled
14074
+ * result through `system.getFailureContributions`.
14075
+ */
14076
+ var FailureReasonCountSchema = object({
14077
+ /**
14078
+ * Why the attempt did not land, in the contributor's own vocabulary —
14079
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
14080
+ * strings that already appear in this repo's logs and, where one exists, the
14081
+ * same string the per-track `previewMissReason` records (D276): a second
14082
+ * vocabulary for the same loss would make the row and the counter
14083
+ * un-joinable.
14084
+ */
14085
+ reason: string(),
14086
+ count: number().int().nonnegative()
14087
+ });
14088
+ var FailureContributionSchema = object({
14089
+ /**
14090
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
14091
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
14092
+ * `unit` free: the families are owned by different addons and a shared enum
14093
+ * is a central list that rots invisibly.
14094
+ */
14095
+ family: string(),
14096
+ /**
14097
+ * The NUMERIC device id — the same value every log line carries as
14098
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
14099
+ * cannot name the camera must not emit the entry, because a fleet total
14100
+ * cannot answer the only question anybody asks of this surface.
14101
+ */
14102
+ deviceId: number().int().positive(),
14103
+ /**
14104
+ * A second dimension inside the family: the model / step id for an inference
14105
+ * timeout, so "which camera AND which model" is one read. Absent when the
14106
+ * family has a single variant.
14107
+ */
14108
+ variant: string().optional(),
14109
+ /**
14110
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
14111
+ * differencing two reads must drop the interval when it changes, because the
14112
+ * counter restarted from zero in a respawned runner. Same discipline as
14113
+ * `LoadContribution.startedAtMs`.
14114
+ */
14115
+ sinceMs: number(),
14116
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
14117
+ atMs: number(),
14118
+ /**
14119
+ * THE DENOMINATOR — every attempt on this path for this camera in the
14120
+ * window. A failure count published without it is the mistake this schema
14121
+ * exists to make impossible.
14122
+ */
14123
+ attempts: number().int().nonnegative(),
14124
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
14125
+ succeeded: number().int().nonnegative(),
14126
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
14127
+ reasons: array(FailureReasonCountSchema).readonly()
14128
+ });
14129
+ method(_void(), array(FailureContributionSchema).readonly());
14130
+ /**
13976
14131
  * filesystem-browse — per-node capability for browsing the node's local
13977
14132
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
13978
14133
  * are sandboxed to operator-configured allowed roots (D115). Used by the
@@ -14494,6 +14649,68 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }
14494
14649
  kind: "mutation",
14495
14650
  auth: "admin"
14496
14651
  });
14652
+ var LoadContributionSchema = object({
14653
+ role: _enum([
14654
+ "decode",
14655
+ "transcode",
14656
+ "recording",
14657
+ "streaming",
14658
+ "detection"
14659
+ ]),
14660
+ /**
14661
+ * The NUMERIC device id — the same value every log line carries as
14662
+ * `tags.deviceId`. `null` means this cost genuinely belongs to no single
14663
+ * camera (a shared pool), NOT that the contributor forgot to look it up: a
14664
+ * contributor that cannot name its camera must not emit the entry at all,
14665
+ * because an unnamed per-camera entry is indistinguishable from a shared one
14666
+ * and would quietly turn one camera's cost into everybody's.
14667
+ */
14668
+ deviceId: number().int().positive().nullable(),
14669
+ attribution: _enum([
14670
+ "measured",
14671
+ "accounted",
14672
+ "unattributable"
14673
+ ]),
14674
+ /**
14675
+ * What ONE entry is, in the contributor's own words — `615/high`,
14676
+ * `617/native`, `cuda:0 shared pool`. Free text because the unit differs per
14677
+ * family and inventing a common one would lose the only information that
14678
+ * makes two entries for the same camera distinguishable.
14679
+ */
14680
+ unit: string(),
14681
+ /**
14682
+ * The OS process this cost lives in, when there is one. Present so a
14683
+ * consumer can (a) tell two generations of the same unit apart across a
14684
+ * restart, and (b) subtract claimed processes from the node's process
14685
+ * snapshot to see what NOBODY claimed. Absent for an entry that owns no
14686
+ * process of its own.
14687
+ */
14688
+ pid: number().int().positive().optional(),
14689
+ /**
14690
+ * When this generation started. The pid's incarnation marker: a consumer
14691
+ * differencing {@link LoadContributionSchema.shape.cpuSeconds} must drop the
14692
+ * window when this changes, because the counter restarted from zero in a new
14693
+ * process.
14694
+ */
14695
+ startedAtMs: number().optional(),
14696
+ /**
14697
+ * CUMULATIVE CPU seconds this unit has consumed since it started — user +
14698
+ * system, read from the child's own `/proc/<pid>/stat` at the moment the
14699
+ * contribution is asked for.
14700
+ *
14701
+ * Cumulative and not a rate on purpose: a rate needs a window, a window
14702
+ * needs a sampler, and a new per-node sampler is the defect half of
14703
+ * `docs/architecture/load-ledger.md` documents. A counter can be differenced
14704
+ * by whoever already keeps a history; a rate cannot be un-averaged.
14705
+ *
14706
+ * Absent — never zero — on a node with no `/proc`, on a read failure, and on
14707
+ * an entry with no process.
14708
+ */
14709
+ cpuSeconds: number().optional(),
14710
+ /** Resident bytes of this unit's process, same source and same rules. */
14711
+ rssBytes: number().optional()
14712
+ });
14713
+ method(_void(), array(LoadContributionSchema).readonly());
14497
14714
  /**
14498
14715
  * `log-channels` — the capability an addon DECLARES its diagnostic channels
14499
14716
  * through. It stores nothing.
@@ -14570,176 +14787,6 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
14570
14787
  tags: record(string(), string()).optional()
14571
14788
  }), array(LogEntrySchema).readonly());
14572
14789
  /**
14573
- * `failure-contribution` — the capability an addon reports its OWN losses
14574
- * through, per camera, with the denominator attached. It stores nothing.
14575
- *
14576
- * ## The twin of `load-contribution`, and why it is a twin and not a field
14577
- *
14578
- * `load-contribution` answers *what did this camera COST*. This answers *what
14579
- * did this camera LOSE*. The reporting discipline is identical and deliberately
14580
- * copied: the contributor reports what it already knows, hub-main adds only
14581
- * `addonId`, nothing needs global knowledge, and there is no central list for
14582
- * somebody to forget to edit.
14583
- *
14584
- * They are not merged, because their invariants are opposites:
14585
- *
14586
- * - a `load-contribution` measurement is **absent, never zero** — a zero would
14587
- * claim a camera cost nothing, which is a measurement nobody made;
14588
- * - a `failure-contribution` zero is the **most valuable value on the
14589
- * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
14590
- * and it is exactly what an absent entry cannot say.
14591
- *
14592
- * Putting a loss counter on a cost entry would also break the reconciliation
14593
- * that gives `load-contribution` its point: contributions are subtracted from
14594
- * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
14595
- * has no process.
14596
- *
14597
- * ## Why not a log line, since the counters already exist
14598
- *
14599
- * Several of these paths already counted themselves — `CaptureScheduler`'s
14600
- * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
14601
- * ends in a log line, and a log line is the thing the operator asked to stop
14602
- * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
14603
- * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
14604
- * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
14605
- * media blackout were both diagnosed. The counters stay; this is where they can
14606
- * be READ.
14607
- *
14608
- * ## The rate is served with its denominator or not at all
14609
- *
14610
- * Every entry carries `attempts` and `succeeded`. A miss count alone is
14611
- * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
14612
- * than yesterday" and was **flat across twelve hours** once divided by the
14613
- * successes on the same path. A surface that publishes only the numerator
14614
- * reproduces that mistake on every read.
14615
- *
14616
- * ## Shape
14617
- *
14618
- * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
14619
- * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
14620
- * generated hooks, while `addons.listCapabilityProviders` still enumerates it
14621
- * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
14622
- * a forked runner's entries reach hub-main over transport that already exists.
14623
- * No new UDS message, no second registry (D3). The operator reads the assembled
14624
- * result through `system.getFailureContributions`.
14625
- */
14626
- var FailureReasonCountSchema = object({
14627
- /**
14628
- * Why the attempt did not land, in the contributor's own vocabulary —
14629
- * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
14630
- * strings that already appear in this repo's logs and, where one exists, the
14631
- * same string the per-track `previewMissReason` records (D276): a second
14632
- * vocabulary for the same loss would make the row and the counter
14633
- * un-joinable.
14634
- */
14635
- reason: string(),
14636
- count: number().int().nonnegative()
14637
- });
14638
- var FailureContributionSchema = object({
14639
- /**
14640
- * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
14641
- * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
14642
- * `unit` free: the families are owned by different addons and a shared enum
14643
- * is a central list that rots invisibly.
14644
- */
14645
- family: string(),
14646
- /**
14647
- * The NUMERIC device id — the same value every log line carries as
14648
- * `tags.deviceId`. Never nullable and never absent: a contributor that
14649
- * cannot name the camera must not emit the entry, because a fleet total
14650
- * cannot answer the only question anybody asks of this surface.
14651
- */
14652
- deviceId: number().int().positive(),
14653
- /**
14654
- * A second dimension inside the family: the model / step id for an inference
14655
- * timeout, so "which camera AND which model" is one read. Absent when the
14656
- * family has a single variant.
14657
- */
14658
- variant: string().optional(),
14659
- /**
14660
- * Epoch ms this counter started — the INCARNATION MARKER. A consumer
14661
- * differencing two reads must drop the interval when it changes, because the
14662
- * counter restarted from zero in a respawned runner. Same discipline as
14663
- * `LoadContribution.startedAtMs`.
14664
- */
14665
- sinceMs: number(),
14666
- /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
14667
- atMs: number(),
14668
- /**
14669
- * THE DENOMINATOR — every attempt on this path for this camera in the
14670
- * window. A failure count published without it is the mistake this schema
14671
- * exists to make impossible.
14672
- */
14673
- attempts: number().int().nonnegative(),
14674
- /** Attempts that landed. `attempts - succeeded` is the loss. */
14675
- succeeded: number().int().nonnegative(),
14676
- /** The loss, partitioned. Sums to `attempts - succeeded`. */
14677
- reasons: array(FailureReasonCountSchema).readonly()
14678
- });
14679
- method(_void(), array(FailureContributionSchema).readonly());
14680
- var LoadContributionSchema = object({
14681
- role: _enum([
14682
- "decode",
14683
- "transcode",
14684
- "recording",
14685
- "streaming",
14686
- "detection"
14687
- ]),
14688
- /**
14689
- * The NUMERIC device id — the same value every log line carries as
14690
- * `tags.deviceId`. `null` means this cost genuinely belongs to no single
14691
- * camera (a shared pool), NOT that the contributor forgot to look it up: a
14692
- * contributor that cannot name its camera must not emit the entry at all,
14693
- * because an unnamed per-camera entry is indistinguishable from a shared one
14694
- * and would quietly turn one camera's cost into everybody's.
14695
- */
14696
- deviceId: number().int().positive().nullable(),
14697
- attribution: _enum([
14698
- "measured",
14699
- "accounted",
14700
- "unattributable"
14701
- ]),
14702
- /**
14703
- * What ONE entry is, in the contributor's own words — `615/high`,
14704
- * `617/native`, `cuda:0 shared pool`. Free text because the unit differs per
14705
- * family and inventing a common one would lose the only information that
14706
- * makes two entries for the same camera distinguishable.
14707
- */
14708
- unit: string(),
14709
- /**
14710
- * The OS process this cost lives in, when there is one. Present so a
14711
- * consumer can (a) tell two generations of the same unit apart across a
14712
- * restart, and (b) subtract claimed processes from the node's process
14713
- * snapshot to see what NOBODY claimed. Absent for an entry that owns no
14714
- * process of its own.
14715
- */
14716
- pid: number().int().positive().optional(),
14717
- /**
14718
- * When this generation started. The pid's incarnation marker: a consumer
14719
- * differencing {@link LoadContributionSchema.shape.cpuSeconds} must drop the
14720
- * window when this changes, because the counter restarted from zero in a new
14721
- * process.
14722
- */
14723
- startedAtMs: number().optional(),
14724
- /**
14725
- * CUMULATIVE CPU seconds this unit has consumed since it started — user +
14726
- * system, read from the child's own `/proc/<pid>/stat` at the moment the
14727
- * contribution is asked for.
14728
- *
14729
- * Cumulative and not a rate on purpose: a rate needs a window, a window
14730
- * needs a sampler, and a new per-node sampler is the defect half of
14731
- * `docs/architecture/load-ledger.md` documents. A counter can be differenced
14732
- * by whoever already keeps a history; a rate cannot be un-averaged.
14733
- *
14734
- * Absent — never zero — on a node with no `/proc`, on a read failure, and on
14735
- * an entry with no process.
14736
- */
14737
- cpuSeconds: number().optional(),
14738
- /** Resident bytes of this unit's process, same source and same rules. */
14739
- rssBytes: number().optional()
14740
- });
14741
- method(_void(), array(LoadContributionSchema).readonly());
14742
- /**
14743
14790
  * `login-method` — collection cap through which auth addons contribute
14744
14791
  * their pre-auth login surfaces to the login page. This is the SINGLE,
14745
14792
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
@@ -19477,12 +19524,53 @@ var MediaFileKindEnum = _enum([
19477
19524
  "keyFrameSmall",
19478
19525
  "thumbnailSmall"
19479
19526
  ]);
19527
+ /**
19528
+ * One media row ON THE WIRE: what it is, how big it is, and WHERE ITS BYTES
19529
+ * ARE — never the bytes themselves.
19530
+ *
19531
+ * ## Why `url` and not `base64`
19532
+ *
19533
+ * Measured on the live hub 2026-08-30: `getTrackMedia {trackId, deviceId}`
19534
+ * with no `kinds` returned 6 rows / **3 597 219 B**, of which `keyFrame` alone
19535
+ * was **2 824 077 B** — one full-resolution frame, base64, so +33 % on the
19536
+ * wire. Forty events is ~144 MB. Every byte of it was read off disk,
19537
+ * base64-encoded, held whole in a unary tRPC envelope, and materialised in
19538
+ * hub-main's heap on the way past — for an `<img>` that would have cached it.
19539
+ *
19540
+ * `url` points at the `event-media` data plane
19541
+ * (`/addon/<addonId>/event-media/<storedKey>`), which serves the same blob
19542
+ * with an ETag and `Cache-Control: immutable`, honours conditional GETs, can
19543
+ * render a `?variant=thumb`, and streams. The hub gate in front of it requires
19544
+ * a bearer or the session cookie (`access: 'authenticated'`), so the bytes are
19545
+ * no less protected than they were inside a `view`-level cap response — see
19546
+ * `data-plane-access.ts` for the rule and the one gap it does not close
19547
+ * (per-device scoping).
19548
+ *
19549
+ * The URL is built from the row's **stored** key, which is not always its
19550
+ * published `kind`: a track's face/plate crop is stored as `crop` under
19551
+ * `('face'|'plate', '<prefix>-<trackId>')` and published as
19552
+ * `faceCrop`/`plateCrop`. `MediaStore.getByKey` knows only the stored key.
19553
+ *
19554
+ * ## `base64` is TRANSITIONAL and is going away
19555
+ *
19556
+ * It is still populated for one reason: the deployed viewer's track-detail
19557
+ * HERO tile reads it (`use-track-media-entry.ts` → `parseMediaFiles`, which
19558
+ * REQUIRES the field), and a row without it parses as a FAILED read — the red
19559
+ * triangle — not as absence. Removing the field before that viewer ships is an
19560
+ * outage, not a cleanup. Once the viewer takes its hero bytes from `url`,
19561
+ * delete this line and the `withBytes` pass-through in
19562
+ * `analytics-query-facade.ts`; nothing else reads it.
19563
+ */
19480
19564
  var MediaFileSchema = object({
19481
19565
  key: string(),
19482
19566
  kind: MediaFileKindEnum,
19483
- base64: string(),
19484
19567
  sizeBytes: number(),
19485
19568
  timestamp: number()
19569
+ }).extend({
19570
+ /** `/addon/<addonId>/event-media/<encoded stored key>`. Always present. */
19571
+ url: string(),
19572
+ /** @deprecated Transitional — see the schema docblock. Use {@link url}. */
19573
+ base64: string()
19486
19574
  });
19487
19575
  /**
19488
19576
  * One media row WITHOUT its bytes.
@@ -19494,7 +19582,9 @@ var MediaFileSchema = object({
19494
19582
  * blocks the whole view.
19495
19583
  *
19496
19584
  * `sizeBytes` is carried because it is what lets a client decide between the
19497
- * stored blob and a `?variant=thumb` rendering without fetching either.
19585
+ * stored blob and a `?variant=thumb` rendering without fetching either, and
19586
+ * `url` because a client that had to build the plane path itself is a second
19587
+ * copy of a route — the embed, the viewer and the admin UI each grew one.
19498
19588
  */
19499
19589
  var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
19500
19590
  /**
@@ -20183,6 +20273,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
20183
20273
  }), array(MediaFileSchema).readonly()), method(object({
20184
20274
  trackId: string(),
20185
20275
  deviceId: number()
20276
+ }), array(MediaFileInfoSchema).readonly()), method(object({
20277
+ eventId: string(),
20278
+ deviceId: number()
20186
20279
  }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
20187
20280
  kind: "mutation",
20188
20281
  auth: "admin"
@@ -25181,10 +25274,24 @@ var FaceClusterSchema = object({
25181
25274
  size: number().int(),
25182
25275
  cohesion: number()
25183
25276
  });
25277
+ /**
25278
+ * One gallery media row: what the crop is, how big it is, and WHERE its bytes
25279
+ * are — never the bytes.
25280
+ *
25281
+ * `base64` was deleted here rather than deprecated. `MediaFile.base64` (the
25282
+ * track/event contract) is still populated because a deployed viewer requires
25283
+ * the field to parse a row at all; this method has no such reader. Its ONE
25284
+ * caller is the admin UI's detail modal, which was building
25285
+ * `data:image/jpeg;base64,…` from a row whose `key` sat right beside it, in a
25286
+ * dialog already rendering its key FRAME from the `event-media` plane.
25287
+ *
25288
+ * `url` is `/addon/<addonId>/event-media/<encoded key>`. The plane resolves a
25289
+ * media key directly, so this needed no new plane and no new access decision.
25290
+ */
25184
25291
  var MediaFileLiteSchema$1 = object({
25185
25292
  key: string(),
25186
25293
  kind: string(),
25187
- base64: string(),
25294
+ url: string(),
25188
25295
  sizeBytes: number(),
25189
25296
  timestamp: number()
25190
25297
  });
@@ -28206,10 +28313,24 @@ var PlateInfoSchema = object({
28206
28313
  */
28207
28314
  cropUrl: string().optional()
28208
28315
  });
28316
+ /**
28317
+ * One gallery media row: what the crop is, how big it is, and WHERE its bytes
28318
+ * are — never the bytes.
28319
+ *
28320
+ * `base64` was deleted here rather than deprecated. `MediaFile.base64` (the
28321
+ * track/event contract) is still populated because a deployed viewer requires
28322
+ * the field to parse a row at all; this method has no such reader. Its ONE
28323
+ * caller is the admin UI's detail modal, which was building
28324
+ * `data:image/jpeg;base64,…` from a row whose `key` sat right beside it, in a
28325
+ * dialog already rendering its key FRAME from the `event-media` plane.
28326
+ *
28327
+ * `url` is `/addon/<addonId>/event-media/<encoded key>`. The plane resolves a
28328
+ * media key directly, so this needed no new plane and no new access decision.
28329
+ */
28209
28330
  var MediaFileLiteSchema = object({
28210
28331
  key: string(),
28211
28332
  kind: string(),
28212
- base64: string(),
28333
+ url: string(),
28213
28334
  sizeBytes: number(),
28214
28335
  timestamp: number()
28215
28336
  });
@@ -36106,6 +36227,12 @@ Object.freeze({
36106
36227
  addonId: null,
36107
36228
  access: "view"
36108
36229
  },
36230
+ "pipelineAnalytics.listEventMedia": {
36231
+ capName: "pipeline-analytics",
36232
+ capScope: "device",
36233
+ addonId: null,
36234
+ access: "view"
36235
+ },
36109
36236
  "pipelineAnalytics.listGroups": {
36110
36237
  capName: "pipeline-analytics",
36111
36238
  capScope: "device",
@@ -39729,6 +39856,11 @@ Object.freeze({
39729
39856
  form: "array",
39730
39857
  optional: false
39731
39858
  }],
39859
+ "pipelineAnalytics.listEventMedia": [{
39860
+ name: "deviceId",
39861
+ form: "single",
39862
+ optional: false
39863
+ }],
39732
39864
  "pipelineAnalytics.listGroups": [{
39733
39865
  name: "deviceIds",
39734
39866
  form: "array",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-tuya",
3
- "version": "0.2.45",
3
+ "version": "0.2.47",
4
4
  "description": "Tuya / Smart Life device-provider addon for CamStack — account-onboarded (Tuya IoT cloud fetch of device localKeys) + LOCAL DP control via the @apocaliss92/nodetuya encrypted-LAN client, exposing switch / water-heater-family kettle entities",
5
5
  "keywords": [
6
6
  "camstack",