@camstack/addon-provider-tuya 0.2.37 → 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
@@ -6736,6 +6736,40 @@ var BaseAddon = class {
6736
6736
  deviceSettingsSchema() {
6737
6737
  return null;
6738
6738
  }
6739
+ /**
6740
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
6741
+ * ARE the configuration of its integration.
6742
+ *
6743
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
6744
+ * operator should find on the addon's integration page (System →
6745
+ * Integrations → <name>) rather than only in the cluster-wide list of every
6746
+ * addon. Empty (the default) means the addon has no integration-level
6747
+ * settings and no such surface is offered — this is opt-in, because whether
6748
+ * an addon's configuration IS its integration's configuration depends on the
6749
+ * nature of the integration.
6750
+ *
6751
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
6752
+ * the ONE global schema, in the ONE addon store, written by the ONE
6753
+ * `updateGlobalSettings` path. There is deliberately no
6754
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
6755
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
6756
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
6757
+ *
6758
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
6759
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
6760
+ * removed with the reason recorded at
6761
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
6762
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
6763
+ * marker sprinkled across sections also has to borrow a field that already
6764
+ * means something else; borrowing `section.tab` put the literal word
6765
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
6766
+ * GROUP this visually" and cannot also mean "where this lives" (D269
6767
+ * supersedes D268). One declaration, in one place, next to the schema whose
6768
+ * ids it names.
6769
+ */
6770
+ integrationSettingSections() {
6771
+ return [];
6772
+ }
6739
6773
  async getGlobalSettings(overlay, cap, nodeId) {
6740
6774
  const schema = this.globalSettingsSchema(cap);
6741
6775
  if (!schema) return { sections: [] };
@@ -6746,6 +6780,55 @@ var BaseAddon = class {
6746
6780
  } : projected);
6747
6781
  }
6748
6782
  /**
6783
+ * The integration-level view of this addon's settings: exactly the sections
6784
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
6785
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
6786
+ *
6787
+ * Returns `null` when the addon declared nothing — an addon that opts out has
6788
+ * no integration settings surface at all, rather than an empty one that reads
6789
+ * as a failed load.
6790
+ *
6791
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
6792
+ * and not in whichever UI happens to render this:
6793
+ *
6794
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
6795
+ * shown here is the same field, with the same bare key, that the addon's
6796
+ * own page shows. There is no integration-specific writer — callers save
6797
+ * through `updateGlobalSettings` — so a second store key is unreachable,
6798
+ * not merely discouraged.
6799
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
6800
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
6801
+ * such a field silently picked would be a wrong answer for the operator
6802
+ * who opened the page (D266).
6803
+ * 3. **No silent typo.** A declared id that names no section throws. The
6804
+ * alternative — skip it — turns a rename into a surface that quietly
6805
+ * empties, which looks exactly like an addon with nothing to configure.
6806
+ */
6807
+ async getIntegrationSettings(nodeId) {
6808
+ const declared = this.integrationSettingSections();
6809
+ if (declared.length === 0) return null;
6810
+ const schema = this.globalSettingsSchema();
6811
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
6812
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
6813
+ const sections = [];
6814
+ for (const id of declared) {
6815
+ const section = byId.get(id);
6816
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6817
+ const fields = dropPerNodeFields(section.fields);
6818
+ if (fields.length === 0) continue;
6819
+ sections.push({
6820
+ ...section,
6821
+ fields
6822
+ });
6823
+ }
6824
+ if (sections.length === 0) return null;
6825
+ const projected = await this.resolveGlobalStore(nodeId);
6826
+ return hydrateSchema({
6827
+ ...schema,
6828
+ sections
6829
+ }, projected);
6830
+ }
6831
+ /**
6749
6832
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
6750
6833
  * every `perNode: true` field carries THAT node's scoped value on its bare
6751
6834
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -7049,6 +7132,41 @@ var BaseAddon = class {
7049
7132
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
7050
7133
  * don't declare `perNode` and are excluded by the `in` narrowing.
7051
7134
  */
7135
+ /**
7136
+ * The same fields with every `perNode: true` one removed, recursing into layout
7137
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
7138
+ * with no child is dropped rather than rendered empty.
7139
+ *
7140
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
7141
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
7142
+ */
7143
+ function dropPerNodeFields(fields) {
7144
+ const kept = [];
7145
+ for (const field of fields) {
7146
+ if (field.type === "group") {
7147
+ const inner = dropPerNodeFields(field.fields);
7148
+ if (inner.length > 0) kept.push({
7149
+ ...field,
7150
+ fields: inner
7151
+ });
7152
+ continue;
7153
+ }
7154
+ if (field.type === "sub-tabs") {
7155
+ const tabs = field.tabs.map((tab) => ({
7156
+ ...tab,
7157
+ fields: dropPerNodeFields(tab.fields)
7158
+ })).filter((tab) => tab.fields.length > 0);
7159
+ if (tabs.length > 0) kept.push({
7160
+ ...field,
7161
+ tabs
7162
+ });
7163
+ continue;
7164
+ }
7165
+ if ("perNode" in field && field.perNode === true) continue;
7166
+ kept.push(field);
7167
+ }
7168
+ return kept;
7169
+ }
7052
7170
  function collectPerNodeFieldKeys(fields) {
7053
7171
  const collected = [];
7054
7172
  for (const field of fields) {
@@ -10218,6 +10336,9 @@ method(object({
10218
10336
  kind: "mutation",
10219
10337
  auth: "admin"
10220
10338
  }), method(object({
10339
+ addonId: string(),
10340
+ nodeId: string().optional()
10341
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
10221
10342
  addonId: string(),
10222
10343
  deviceId: number(),
10223
10344
  nodeId: string().optional()
@@ -14183,6 +14304,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
14183
14304
  limit: number().optional(),
14184
14305
  tags: record(string(), string()).optional()
14185
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());
14186
14415
  var LoadContributionSchema = object({
14187
14416
  role: _enum([
14188
14417
  "decode",
@@ -18773,6 +19002,20 @@ var TrackSchema = object({
18773
19002
  * `=== true` and render nothing otherwise — never infer "no rider".
18774
19003
  */
18775
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(),
18776
19019
  ...TrackFlagFields,
18777
19020
  ...TrackRetrainFields
18778
19021
  });
@@ -29956,6 +30199,13 @@ var LoggingSettingsPatchSchema = object({
29956
30199
  * anyone but its owner.
29957
30200
  */
29958
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() });
29959
30209
  var GetLoggingSettingsInputSchema = object({
29960
30210
  scopeNodeId: string().optional(),
29961
30211
  /**
@@ -30014,7 +30264,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
30014
30264
  }), method(_void(), SiteLocationStatusSchema, {
30015
30265
  kind: "mutation",
30016
30266
  auth: "admin"
30017
- }), 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, {
30018
30268
  kind: "mutation",
30019
30269
  auth: "admin"
30020
30270
  });
@@ -32336,6 +32586,12 @@ Object.freeze({
32336
32586
  addonId: null,
32337
32587
  access: "view"
32338
32588
  },
32589
+ "addonSettings.getIntegrationSettings": {
32590
+ capName: "addon-settings",
32591
+ capScope: "system",
32592
+ addonId: null,
32593
+ access: "view"
32594
+ },
32339
32595
  "addonSettings.updateDeviceSettings": {
32340
32596
  capName: "addon-settings",
32341
32597
  capScope: "system",
@@ -33998,6 +34254,12 @@ Object.freeze({
33998
34254
  addonId: null,
33999
34255
  access: "create"
34000
34256
  },
34257
+ "failureContribution.list": {
34258
+ capName: "failure-contribution",
34259
+ capScope: "system",
34260
+ addonId: null,
34261
+ access: "view"
34262
+ },
34001
34263
  "fanControl.setDirection": {
34002
34264
  capName: "fan-control",
34003
34265
  capScope: "device",
@@ -37304,6 +37566,12 @@ Object.freeze({
37304
37566
  addonId: null,
37305
37567
  access: "create"
37306
37568
  },
37569
+ "system.getFailureContributions": {
37570
+ capName: "system",
37571
+ capScope: "system",
37572
+ addonId: null,
37573
+ access: "view"
37574
+ },
37307
37575
  "system.getLoadContributions": {
37308
37576
  capName: "system",
37309
37577
  capScope: "system",
package/dist/addon.mjs CHANGED
@@ -6735,6 +6735,40 @@ var BaseAddon = class {
6735
6735
  deviceSettingsSchema() {
6736
6736
  return null;
6737
6737
  }
6738
+ /**
6739
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
6740
+ * ARE the configuration of its integration.
6741
+ *
6742
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
6743
+ * operator should find on the addon's integration page (System →
6744
+ * Integrations → <name>) rather than only in the cluster-wide list of every
6745
+ * addon. Empty (the default) means the addon has no integration-level
6746
+ * settings and no such surface is offered — this is opt-in, because whether
6747
+ * an addon's configuration IS its integration's configuration depends on the
6748
+ * nature of the integration.
6749
+ *
6750
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
6751
+ * the ONE global schema, in the ONE addon store, written by the ONE
6752
+ * `updateGlobalSettings` path. There is deliberately no
6753
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
6754
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
6755
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
6756
+ *
6757
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
6758
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
6759
+ * removed with the reason recorded at
6760
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
6761
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
6762
+ * marker sprinkled across sections also has to borrow a field that already
6763
+ * means something else; borrowing `section.tab` put the literal word
6764
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
6765
+ * GROUP this visually" and cannot also mean "where this lives" (D269
6766
+ * supersedes D268). One declaration, in one place, next to the schema whose
6767
+ * ids it names.
6768
+ */
6769
+ integrationSettingSections() {
6770
+ return [];
6771
+ }
6738
6772
  async getGlobalSettings(overlay, cap, nodeId) {
6739
6773
  const schema = this.globalSettingsSchema(cap);
6740
6774
  if (!schema) return { sections: [] };
@@ -6745,6 +6779,55 @@ var BaseAddon = class {
6745
6779
  } : projected);
6746
6780
  }
6747
6781
  /**
6782
+ * The integration-level view of this addon's settings: exactly the sections
6783
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
6784
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
6785
+ *
6786
+ * Returns `null` when the addon declared nothing — an addon that opts out has
6787
+ * no integration settings surface at all, rather than an empty one that reads
6788
+ * as a failed load.
6789
+ *
6790
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
6791
+ * and not in whichever UI happens to render this:
6792
+ *
6793
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
6794
+ * shown here is the same field, with the same bare key, that the addon's
6795
+ * own page shows. There is no integration-specific writer — callers save
6796
+ * through `updateGlobalSettings` — so a second store key is unreachable,
6797
+ * not merely discouraged.
6798
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
6799
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
6800
+ * such a field silently picked would be a wrong answer for the operator
6801
+ * who opened the page (D266).
6802
+ * 3. **No silent typo.** A declared id that names no section throws. The
6803
+ * alternative — skip it — turns a rename into a surface that quietly
6804
+ * empties, which looks exactly like an addon with nothing to configure.
6805
+ */
6806
+ async getIntegrationSettings(nodeId) {
6807
+ const declared = this.integrationSettingSections();
6808
+ if (declared.length === 0) return null;
6809
+ const schema = this.globalSettingsSchema();
6810
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
6811
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
6812
+ const sections = [];
6813
+ for (const id of declared) {
6814
+ const section = byId.get(id);
6815
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6816
+ const fields = dropPerNodeFields(section.fields);
6817
+ if (fields.length === 0) continue;
6818
+ sections.push({
6819
+ ...section,
6820
+ fields
6821
+ });
6822
+ }
6823
+ if (sections.length === 0) return null;
6824
+ const projected = await this.resolveGlobalStore(nodeId);
6825
+ return hydrateSchema({
6826
+ ...schema,
6827
+ sections
6828
+ }, projected);
6829
+ }
6830
+ /**
6748
6831
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
6749
6832
  * every `perNode: true` field carries THAT node's scoped value on its bare
6750
6833
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -7048,6 +7131,41 @@ var BaseAddon = class {
7048
7131
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
7049
7132
  * don't declare `perNode` and are excluded by the `in` narrowing.
7050
7133
  */
7134
+ /**
7135
+ * The same fields with every `perNode: true` one removed, recursing into layout
7136
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
7137
+ * with no child is dropped rather than rendered empty.
7138
+ *
7139
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
7140
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
7141
+ */
7142
+ function dropPerNodeFields(fields) {
7143
+ const kept = [];
7144
+ for (const field of fields) {
7145
+ if (field.type === "group") {
7146
+ const inner = dropPerNodeFields(field.fields);
7147
+ if (inner.length > 0) kept.push({
7148
+ ...field,
7149
+ fields: inner
7150
+ });
7151
+ continue;
7152
+ }
7153
+ if (field.type === "sub-tabs") {
7154
+ const tabs = field.tabs.map((tab) => ({
7155
+ ...tab,
7156
+ fields: dropPerNodeFields(tab.fields)
7157
+ })).filter((tab) => tab.fields.length > 0);
7158
+ if (tabs.length > 0) kept.push({
7159
+ ...field,
7160
+ tabs
7161
+ });
7162
+ continue;
7163
+ }
7164
+ if ("perNode" in field && field.perNode === true) continue;
7165
+ kept.push(field);
7166
+ }
7167
+ return kept;
7168
+ }
7051
7169
  function collectPerNodeFieldKeys(fields) {
7052
7170
  const collected = [];
7053
7171
  for (const field of fields) {
@@ -10217,6 +10335,9 @@ method(object({
10217
10335
  kind: "mutation",
10218
10336
  auth: "admin"
10219
10337
  }), method(object({
10338
+ addonId: string(),
10339
+ nodeId: string().optional()
10340
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
10220
10341
  addonId: string(),
10221
10342
  deviceId: number(),
10222
10343
  nodeId: string().optional()
@@ -14182,6 +14303,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
14182
14303
  limit: number().optional(),
14183
14304
  tags: record(string(), string()).optional()
14184
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());
14185
14414
  var LoadContributionSchema = object({
14186
14415
  role: _enum([
14187
14416
  "decode",
@@ -18772,6 +19001,20 @@ var TrackSchema = object({
18772
19001
  * `=== true` and render nothing otherwise — never infer "no rider".
18773
19002
  */
18774
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(),
18775
19018
  ...TrackFlagFields,
18776
19019
  ...TrackRetrainFields
18777
19020
  });
@@ -29955,6 +30198,13 @@ var LoggingSettingsPatchSchema = object({
29955
30198
  * anyone but its owner.
29956
30199
  */
29957
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() });
29958
30208
  var GetLoggingSettingsInputSchema = object({
29959
30209
  scopeNodeId: string().optional(),
29960
30210
  /**
@@ -30013,7 +30263,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
30013
30263
  }), method(_void(), SiteLocationStatusSchema, {
30014
30264
  kind: "mutation",
30015
30265
  auth: "admin"
30016
- }), 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, {
30017
30267
  kind: "mutation",
30018
30268
  auth: "admin"
30019
30269
  });
@@ -32335,6 +32585,12 @@ Object.freeze({
32335
32585
  addonId: null,
32336
32586
  access: "view"
32337
32587
  },
32588
+ "addonSettings.getIntegrationSettings": {
32589
+ capName: "addon-settings",
32590
+ capScope: "system",
32591
+ addonId: null,
32592
+ access: "view"
32593
+ },
32338
32594
  "addonSettings.updateDeviceSettings": {
32339
32595
  capName: "addon-settings",
32340
32596
  capScope: "system",
@@ -33997,6 +34253,12 @@ Object.freeze({
33997
34253
  addonId: null,
33998
34254
  access: "create"
33999
34255
  },
34256
+ "failureContribution.list": {
34257
+ capName: "failure-contribution",
34258
+ capScope: "system",
34259
+ addonId: null,
34260
+ access: "view"
34261
+ },
34000
34262
  "fanControl.setDirection": {
34001
34263
  capName: "fan-control",
34002
34264
  capScope: "device",
@@ -37303,6 +37565,12 @@ Object.freeze({
37303
37565
  addonId: null,
37304
37566
  access: "create"
37305
37567
  },
37568
+ "system.getFailureContributions": {
37569
+ capName: "system",
37570
+ capScope: "system",
37571
+ addonId: null,
37572
+ access: "view"
37573
+ },
37306
37574
  "system.getLoadContributions": {
37307
37575
  capName: "system",
37308
37576
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-tuya",
3
- "version": "0.2.37",
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",