@camstack/addon-provider-tuya 0.2.38 → 0.2.39

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
@@ -14304,6 +14304,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
14304
14304
  limit: number().optional(),
14305
14305
  tags: record(string(), string()).optional()
14306
14306
  }), array(LogEntrySchema).readonly());
14307
+ /**
14308
+ * `failure-contribution` — the capability an addon reports its OWN losses
14309
+ * through, per camera, with the denominator attached. It stores nothing.
14310
+ *
14311
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
14312
+ *
14313
+ * `load-contribution` answers *what did this camera COST*. This answers *what
14314
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
14315
+ * copied: the contributor reports what it already knows, hub-main adds only
14316
+ * `addonId`, nothing needs global knowledge, and there is no central list for
14317
+ * somebody to forget to edit.
14318
+ *
14319
+ * They are not merged, because their invariants are opposites:
14320
+ *
14321
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
14322
+ * claim a camera cost nothing, which is a measurement nobody made;
14323
+ * - a `failure-contribution` zero is the **most valuable value on the
14324
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
14325
+ * and it is exactly what an absent entry cannot say.
14326
+ *
14327
+ * Putting a loss counter on a cost entry would also break the reconciliation
14328
+ * that gives `load-contribution` its point: contributions are subtracted from
14329
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
14330
+ * has no process.
14331
+ *
14332
+ * ## Why not a log line, since the counters already exist
14333
+ *
14334
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
14335
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
14336
+ * ends in a log line, and a log line is the thing the operator asked to stop
14337
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
14338
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
14339
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
14340
+ * media blackout were both diagnosed. The counters stay; this is where they can
14341
+ * be READ.
14342
+ *
14343
+ * ## The rate is served with its denominator or not at all
14344
+ *
14345
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
14346
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
14347
+ * than yesterday" and was **flat across twelve hours** once divided by the
14348
+ * successes on the same path. A surface that publishes only the numerator
14349
+ * reproduces that mistake on every read.
14350
+ *
14351
+ * ## Shape
14352
+ *
14353
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
14354
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
14355
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
14356
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
14357
+ * a forked runner's entries reach hub-main over transport that already exists.
14358
+ * No new UDS message, no second registry (D3). The operator reads the assembled
14359
+ * result through `system.getFailureContributions`.
14360
+ */
14361
+ var FailureReasonCountSchema = object({
14362
+ /**
14363
+ * Why the attempt did not land, in the contributor's own vocabulary —
14364
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
14365
+ * strings that already appear in this repo's logs and, where one exists, the
14366
+ * same string the per-track `previewMissReason` records (D276): a second
14367
+ * vocabulary for the same loss would make the row and the counter
14368
+ * un-joinable.
14369
+ */
14370
+ reason: string(),
14371
+ count: number().int().nonnegative()
14372
+ });
14373
+ var FailureContributionSchema = object({
14374
+ /**
14375
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
14376
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
14377
+ * `unit` free: the families are owned by different addons and a shared enum
14378
+ * is a central list that rots invisibly.
14379
+ */
14380
+ family: string(),
14381
+ /**
14382
+ * The NUMERIC device id — the same value every log line carries as
14383
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
14384
+ * cannot name the camera must not emit the entry, because a fleet total
14385
+ * cannot answer the only question anybody asks of this surface.
14386
+ */
14387
+ deviceId: number().int().positive(),
14388
+ /**
14389
+ * A second dimension inside the family: the model / step id for an inference
14390
+ * timeout, so "which camera AND which model" is one read. Absent when the
14391
+ * family has a single variant.
14392
+ */
14393
+ variant: string().optional(),
14394
+ /**
14395
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
14396
+ * differencing two reads must drop the interval when it changes, because the
14397
+ * counter restarted from zero in a respawned runner. Same discipline as
14398
+ * `LoadContribution.startedAtMs`.
14399
+ */
14400
+ sinceMs: number(),
14401
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
14402
+ atMs: number(),
14403
+ /**
14404
+ * THE DENOMINATOR — every attempt on this path for this camera in the
14405
+ * window. A failure count published without it is the mistake this schema
14406
+ * exists to make impossible.
14407
+ */
14408
+ attempts: number().int().nonnegative(),
14409
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
14410
+ succeeded: number().int().nonnegative(),
14411
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
14412
+ reasons: array(FailureReasonCountSchema).readonly()
14413
+ });
14414
+ method(_void(), array(FailureContributionSchema).readonly());
14307
14415
  var LoadContributionSchema = object({
14308
14416
  role: _enum([
14309
14417
  "decode",
@@ -18894,6 +19002,20 @@ var TrackSchema = object({
18894
19002
  * `=== true` and render nothing otherwise — never infer "no rider".
18895
19003
  */
18896
19004
  hasRider: boolean().optional(),
19005
+ /**
19006
+ * WHY this track ended without a NATIVE best-shot tile
19007
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
19008
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
19009
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
19010
+ * the late-keyFrame upgrade when a native tile lands after all. The
19011
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
19012
+ * tile is a face/plate stand-in, a raster crop, or an icon.
19013
+ *
19014
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
19015
+ * that predates the field, and every track whose tile landed native all
19016
+ * omit it. Render nothing when absent.
19017
+ */
19018
+ previewMissReason: string().optional(),
18897
19019
  ...TrackFlagFields,
18898
19020
  ...TrackRetrainFields
18899
19021
  });
@@ -30077,6 +30199,13 @@ var LoggingSettingsPatchSchema = object({
30077
30199
  * anyone but its owner.
30078
30200
  */
30079
30201
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
30202
+ /**
30203
+ * One per-camera failure counter, plus WHO reported it.
30204
+ *
30205
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
30206
+ * the hub as it enumerates providers, never by the contributor.
30207
+ */
30208
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
30080
30209
  var GetLoggingSettingsInputSchema = object({
30081
30210
  scopeNodeId: string().optional(),
30082
30211
  /**
@@ -30135,7 +30264,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
30135
30264
  }), method(_void(), SiteLocationStatusSchema, {
30136
30265
  kind: "mutation",
30137
30266
  auth: "admin"
30138
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
30267
+ }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(_void(), array(ReportedFailureContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
30139
30268
  kind: "mutation",
30140
30269
  auth: "admin"
30141
30270
  });
@@ -34125,6 +34254,12 @@ Object.freeze({
34125
34254
  addonId: null,
34126
34255
  access: "create"
34127
34256
  },
34257
+ "failureContribution.list": {
34258
+ capName: "failure-contribution",
34259
+ capScope: "system",
34260
+ addonId: null,
34261
+ access: "view"
34262
+ },
34128
34263
  "fanControl.setDirection": {
34129
34264
  capName: "fan-control",
34130
34265
  capScope: "device",
@@ -37431,6 +37566,12 @@ Object.freeze({
37431
37566
  addonId: null,
37432
37567
  access: "create"
37433
37568
  },
37569
+ "system.getFailureContributions": {
37570
+ capName: "system",
37571
+ capScope: "system",
37572
+ addonId: null,
37573
+ access: "view"
37574
+ },
37434
37575
  "system.getLoadContributions": {
37435
37576
  capName: "system",
37436
37577
  capScope: "system",
package/dist/addon.mjs CHANGED
@@ -14303,6 +14303,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
14303
14303
  limit: number().optional(),
14304
14304
  tags: record(string(), string()).optional()
14305
14305
  }), array(LogEntrySchema).readonly());
14306
+ /**
14307
+ * `failure-contribution` — the capability an addon reports its OWN losses
14308
+ * through, per camera, with the denominator attached. It stores nothing.
14309
+ *
14310
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
14311
+ *
14312
+ * `load-contribution` answers *what did this camera COST*. This answers *what
14313
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
14314
+ * copied: the contributor reports what it already knows, hub-main adds only
14315
+ * `addonId`, nothing needs global knowledge, and there is no central list for
14316
+ * somebody to forget to edit.
14317
+ *
14318
+ * They are not merged, because their invariants are opposites:
14319
+ *
14320
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
14321
+ * claim a camera cost nothing, which is a measurement nobody made;
14322
+ * - a `failure-contribution` zero is the **most valuable value on the
14323
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
14324
+ * and it is exactly what an absent entry cannot say.
14325
+ *
14326
+ * Putting a loss counter on a cost entry would also break the reconciliation
14327
+ * that gives `load-contribution` its point: contributions are subtracted from
14328
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
14329
+ * has no process.
14330
+ *
14331
+ * ## Why not a log line, since the counters already exist
14332
+ *
14333
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
14334
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
14335
+ * ends in a log line, and a log line is the thing the operator asked to stop
14336
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
14337
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
14338
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
14339
+ * media blackout were both diagnosed. The counters stay; this is where they can
14340
+ * be READ.
14341
+ *
14342
+ * ## The rate is served with its denominator or not at all
14343
+ *
14344
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
14345
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
14346
+ * than yesterday" and was **flat across twelve hours** once divided by the
14347
+ * successes on the same path. A surface that publishes only the numerator
14348
+ * reproduces that mistake on every read.
14349
+ *
14350
+ * ## Shape
14351
+ *
14352
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
14353
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
14354
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
14355
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
14356
+ * a forked runner's entries reach hub-main over transport that already exists.
14357
+ * No new UDS message, no second registry (D3). The operator reads the assembled
14358
+ * result through `system.getFailureContributions`.
14359
+ */
14360
+ var FailureReasonCountSchema = object({
14361
+ /**
14362
+ * Why the attempt did not land, in the contributor's own vocabulary —
14363
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
14364
+ * strings that already appear in this repo's logs and, where one exists, the
14365
+ * same string the per-track `previewMissReason` records (D276): a second
14366
+ * vocabulary for the same loss would make the row and the counter
14367
+ * un-joinable.
14368
+ */
14369
+ reason: string(),
14370
+ count: number().int().nonnegative()
14371
+ });
14372
+ var FailureContributionSchema = object({
14373
+ /**
14374
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
14375
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
14376
+ * `unit` free: the families are owned by different addons and a shared enum
14377
+ * is a central list that rots invisibly.
14378
+ */
14379
+ family: string(),
14380
+ /**
14381
+ * The NUMERIC device id — the same value every log line carries as
14382
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
14383
+ * cannot name the camera must not emit the entry, because a fleet total
14384
+ * cannot answer the only question anybody asks of this surface.
14385
+ */
14386
+ deviceId: number().int().positive(),
14387
+ /**
14388
+ * A second dimension inside the family: the model / step id for an inference
14389
+ * timeout, so "which camera AND which model" is one read. Absent when the
14390
+ * family has a single variant.
14391
+ */
14392
+ variant: string().optional(),
14393
+ /**
14394
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
14395
+ * differencing two reads must drop the interval when it changes, because the
14396
+ * counter restarted from zero in a respawned runner. Same discipline as
14397
+ * `LoadContribution.startedAtMs`.
14398
+ */
14399
+ sinceMs: number(),
14400
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
14401
+ atMs: number(),
14402
+ /**
14403
+ * THE DENOMINATOR — every attempt on this path for this camera in the
14404
+ * window. A failure count published without it is the mistake this schema
14405
+ * exists to make impossible.
14406
+ */
14407
+ attempts: number().int().nonnegative(),
14408
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
14409
+ succeeded: number().int().nonnegative(),
14410
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
14411
+ reasons: array(FailureReasonCountSchema).readonly()
14412
+ });
14413
+ method(_void(), array(FailureContributionSchema).readonly());
14306
14414
  var LoadContributionSchema = object({
14307
14415
  role: _enum([
14308
14416
  "decode",
@@ -18893,6 +19001,20 @@ var TrackSchema = object({
18893
19001
  * `=== true` and render nothing otherwise — never infer "no rider".
18894
19002
  */
18895
19003
  hasRider: boolean().optional(),
19004
+ /**
19005
+ * WHY this track ended without a NATIVE best-shot tile
19006
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
19007
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
19008
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
19009
+ * the late-keyFrame upgrade when a native tile lands after all. The
19010
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
19011
+ * tile is a face/plate stand-in, a raster crop, or an icon.
19012
+ *
19013
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
19014
+ * that predates the field, and every track whose tile landed native all
19015
+ * omit it. Render nothing when absent.
19016
+ */
19017
+ previewMissReason: string().optional(),
18896
19018
  ...TrackFlagFields,
18897
19019
  ...TrackRetrainFields
18898
19020
  });
@@ -30076,6 +30198,13 @@ var LoggingSettingsPatchSchema = object({
30076
30198
  * anyone but its owner.
30077
30199
  */
30078
30200
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
30201
+ /**
30202
+ * One per-camera failure counter, plus WHO reported it.
30203
+ *
30204
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
30205
+ * the hub as it enumerates providers, never by the contributor.
30206
+ */
30207
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
30079
30208
  var GetLoggingSettingsInputSchema = object({
30080
30209
  scopeNodeId: string().optional(),
30081
30210
  /**
@@ -30134,7 +30263,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
30134
30263
  }), method(_void(), SiteLocationStatusSchema, {
30135
30264
  kind: "mutation",
30136
30265
  auth: "admin"
30137
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
30266
+ }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(_void(), array(ReportedFailureContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
30138
30267
  kind: "mutation",
30139
30268
  auth: "admin"
30140
30269
  });
@@ -34124,6 +34253,12 @@ Object.freeze({
34124
34253
  addonId: null,
34125
34254
  access: "create"
34126
34255
  },
34256
+ "failureContribution.list": {
34257
+ capName: "failure-contribution",
34258
+ capScope: "system",
34259
+ addonId: null,
34260
+ access: "view"
34261
+ },
34127
34262
  "fanControl.setDirection": {
34128
34263
  capName: "fan-control",
34129
34264
  capScope: "device",
@@ -37430,6 +37565,12 @@ Object.freeze({
37430
37565
  addonId: null,
37431
37566
  access: "create"
37432
37567
  },
37568
+ "system.getFailureContributions": {
37569
+ capName: "system",
37570
+ capScope: "system",
37571
+ addonId: null,
37572
+ access: "view"
37573
+ },
37433
37574
  "system.getLoadContributions": {
37434
37575
  capName: "system",
37435
37576
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-tuya",
3
- "version": "0.2.38",
3
+ "version": "0.2.39",
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",