@camstack/addon-provider-wyze 0.2.41 → 0.2.43

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
@@ -5948,6 +5948,40 @@ var BaseAddon = class {
5948
5948
  deviceSettingsSchema() {
5949
5949
  return null;
5950
5950
  }
5951
+ /**
5952
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5953
+ * ARE the configuration of its integration.
5954
+ *
5955
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5956
+ * operator should find on the addon's integration page (System →
5957
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5958
+ * addon. Empty (the default) means the addon has no integration-level
5959
+ * settings and no such surface is offered — this is opt-in, because whether
5960
+ * an addon's configuration IS its integration's configuration depends on the
5961
+ * nature of the integration.
5962
+ *
5963
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5964
+ * the ONE global schema, in the ONE addon store, written by the ONE
5965
+ * `updateGlobalSettings` path. There is deliberately no
5966
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5967
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5968
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5969
+ *
5970
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5971
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5972
+ * removed with the reason recorded at
5973
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5974
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5975
+ * marker sprinkled across sections also has to borrow a field that already
5976
+ * means something else; borrowing `section.tab` put the literal word
5977
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5978
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5979
+ * supersedes D268). One declaration, in one place, next to the schema whose
5980
+ * ids it names.
5981
+ */
5982
+ integrationSettingSections() {
5983
+ return [];
5984
+ }
5951
5985
  async getGlobalSettings(overlay, cap, nodeId) {
5952
5986
  const schema = this.globalSettingsSchema(cap);
5953
5987
  if (!schema) return { sections: [] };
@@ -5958,6 +5992,55 @@ var BaseAddon = class {
5958
5992
  } : projected);
5959
5993
  }
5960
5994
  /**
5995
+ * The integration-level view of this addon's settings: exactly the sections
5996
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
5997
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
5998
+ *
5999
+ * Returns `null` when the addon declared nothing — an addon that opts out has
6000
+ * no integration settings surface at all, rather than an empty one that reads
6001
+ * as a failed load.
6002
+ *
6003
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
6004
+ * and not in whichever UI happens to render this:
6005
+ *
6006
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
6007
+ * shown here is the same field, with the same bare key, that the addon's
6008
+ * own page shows. There is no integration-specific writer — callers save
6009
+ * through `updateGlobalSettings` — so a second store key is unreachable,
6010
+ * not merely discouraged.
6011
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
6012
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
6013
+ * such a field silently picked would be a wrong answer for the operator
6014
+ * who opened the page (D266).
6015
+ * 3. **No silent typo.** A declared id that names no section throws. The
6016
+ * alternative — skip it — turns a rename into a surface that quietly
6017
+ * empties, which looks exactly like an addon with nothing to configure.
6018
+ */
6019
+ async getIntegrationSettings(nodeId) {
6020
+ const declared = this.integrationSettingSections();
6021
+ if (declared.length === 0) return null;
6022
+ const schema = this.globalSettingsSchema();
6023
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
6024
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
6025
+ const sections = [];
6026
+ for (const id of declared) {
6027
+ const section = byId.get(id);
6028
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6029
+ const fields = dropPerNodeFields(section.fields);
6030
+ if (fields.length === 0) continue;
6031
+ sections.push({
6032
+ ...section,
6033
+ fields
6034
+ });
6035
+ }
6036
+ if (sections.length === 0) return null;
6037
+ const projected = await this.resolveGlobalStore(nodeId);
6038
+ return hydrateSchema({
6039
+ ...schema,
6040
+ sections
6041
+ }, projected);
6042
+ }
6043
+ /**
5961
6044
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5962
6045
  * every `perNode: true` field carries THAT node's scoped value on its bare
5963
6046
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6261,6 +6344,41 @@ var BaseAddon = class {
6261
6344
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6262
6345
  * don't declare `perNode` and are excluded by the `in` narrowing.
6263
6346
  */
6347
+ /**
6348
+ * The same fields with every `perNode: true` one removed, recursing into layout
6349
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6350
+ * with no child is dropped rather than rendered empty.
6351
+ *
6352
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6353
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6354
+ */
6355
+ function dropPerNodeFields(fields) {
6356
+ const kept = [];
6357
+ for (const field of fields) {
6358
+ if (field.type === "group") {
6359
+ const inner = dropPerNodeFields(field.fields);
6360
+ if (inner.length > 0) kept.push({
6361
+ ...field,
6362
+ fields: inner
6363
+ });
6364
+ continue;
6365
+ }
6366
+ if (field.type === "sub-tabs") {
6367
+ const tabs = field.tabs.map((tab) => ({
6368
+ ...tab,
6369
+ fields: dropPerNodeFields(tab.fields)
6370
+ })).filter((tab) => tab.fields.length > 0);
6371
+ if (tabs.length > 0) kept.push({
6372
+ ...field,
6373
+ tabs
6374
+ });
6375
+ continue;
6376
+ }
6377
+ if ("perNode" in field && field.perNode === true) continue;
6378
+ kept.push(field);
6379
+ }
6380
+ return kept;
6381
+ }
6264
6382
  function collectPerNodeFieldKeys(fields) {
6265
6383
  const collected = [];
6266
6384
  for (const field of fields) {
@@ -9430,6 +9548,9 @@ method(object({
9430
9548
  kind: "mutation",
9431
9549
  auth: "admin"
9432
9550
  }), method(object({
9551
+ addonId: string(),
9552
+ nodeId: string().optional()
9553
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9433
9554
  addonId: string(),
9434
9555
  deviceId: number(),
9435
9556
  nodeId: string().optional()
@@ -13395,6 +13516,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13395
13516
  limit: number().optional(),
13396
13517
  tags: record(string(), string()).optional()
13397
13518
  }), array(LogEntrySchema).readonly());
13519
+ /**
13520
+ * `failure-contribution` — the capability an addon reports its OWN losses
13521
+ * through, per camera, with the denominator attached. It stores nothing.
13522
+ *
13523
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13524
+ *
13525
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13526
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13527
+ * copied: the contributor reports what it already knows, hub-main adds only
13528
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13529
+ * somebody to forget to edit.
13530
+ *
13531
+ * They are not merged, because their invariants are opposites:
13532
+ *
13533
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13534
+ * claim a camera cost nothing, which is a measurement nobody made;
13535
+ * - a `failure-contribution` zero is the **most valuable value on the
13536
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13537
+ * and it is exactly what an absent entry cannot say.
13538
+ *
13539
+ * Putting a loss counter on a cost entry would also break the reconciliation
13540
+ * that gives `load-contribution` its point: contributions are subtracted from
13541
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13542
+ * has no process.
13543
+ *
13544
+ * ## Why not a log line, since the counters already exist
13545
+ *
13546
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13547
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13548
+ * ends in a log line, and a log line is the thing the operator asked to stop
13549
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13550
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13551
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13552
+ * media blackout were both diagnosed. The counters stay; this is where they can
13553
+ * be READ.
13554
+ *
13555
+ * ## The rate is served with its denominator or not at all
13556
+ *
13557
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13558
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13559
+ * than yesterday" and was **flat across twelve hours** once divided by the
13560
+ * successes on the same path. A surface that publishes only the numerator
13561
+ * reproduces that mistake on every read.
13562
+ *
13563
+ * ## Shape
13564
+ *
13565
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13566
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13567
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13568
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13569
+ * a forked runner's entries reach hub-main over transport that already exists.
13570
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13571
+ * result through `system.getFailureContributions`.
13572
+ */
13573
+ var FailureReasonCountSchema = object({
13574
+ /**
13575
+ * Why the attempt did not land, in the contributor's own vocabulary —
13576
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13577
+ * strings that already appear in this repo's logs and, where one exists, the
13578
+ * same string the per-track `previewMissReason` records (D276): a second
13579
+ * vocabulary for the same loss would make the row and the counter
13580
+ * un-joinable.
13581
+ */
13582
+ reason: string(),
13583
+ count: number().int().nonnegative()
13584
+ });
13585
+ var FailureContributionSchema = object({
13586
+ /**
13587
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13588
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13589
+ * `unit` free: the families are owned by different addons and a shared enum
13590
+ * is a central list that rots invisibly.
13591
+ */
13592
+ family: string(),
13593
+ /**
13594
+ * The NUMERIC device id — the same value every log line carries as
13595
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13596
+ * cannot name the camera must not emit the entry, because a fleet total
13597
+ * cannot answer the only question anybody asks of this surface.
13598
+ */
13599
+ deviceId: number().int().positive(),
13600
+ /**
13601
+ * A second dimension inside the family: the model / step id for an inference
13602
+ * timeout, so "which camera AND which model" is one read. Absent when the
13603
+ * family has a single variant.
13604
+ */
13605
+ variant: string().optional(),
13606
+ /**
13607
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13608
+ * differencing two reads must drop the interval when it changes, because the
13609
+ * counter restarted from zero in a respawned runner. Same discipline as
13610
+ * `LoadContribution.startedAtMs`.
13611
+ */
13612
+ sinceMs: number(),
13613
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13614
+ atMs: number(),
13615
+ /**
13616
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13617
+ * window. A failure count published without it is the mistake this schema
13618
+ * exists to make impossible.
13619
+ */
13620
+ attempts: number().int().nonnegative(),
13621
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13622
+ succeeded: number().int().nonnegative(),
13623
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13624
+ reasons: array(FailureReasonCountSchema).readonly()
13625
+ });
13626
+ method(_void(), array(FailureContributionSchema).readonly());
13398
13627
  var LoadContributionSchema = object({
13399
13628
  role: _enum([
13400
13629
  "decode",
@@ -17985,6 +18214,20 @@ var TrackSchema = object({
17985
18214
  * `=== true` and render nothing otherwise — never infer "no rider".
17986
18215
  */
17987
18216
  hasRider: boolean().optional(),
18217
+ /**
18218
+ * WHY this track ended without a NATIVE best-shot tile
18219
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
18220
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
18221
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
18222
+ * the late-keyFrame upgrade when a native tile lands after all. The
18223
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
18224
+ * tile is a face/plate stand-in, a raster crop, or an icon.
18225
+ *
18226
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
18227
+ * that predates the field, and every track whose tile landed native all
18228
+ * omit it. Render nothing when absent.
18229
+ */
18230
+ previewMissReason: string().optional(),
17988
18231
  ...TrackFlagFields,
17989
18232
  ...TrackRetrainFields
17990
18233
  });
@@ -29272,6 +29515,13 @@ var LoggingSettingsPatchSchema = object({
29272
29515
  * anyone but its owner.
29273
29516
  */
29274
29517
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
29518
+ /**
29519
+ * One per-camera failure counter, plus WHO reported it.
29520
+ *
29521
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
29522
+ * the hub as it enumerates providers, never by the contributor.
29523
+ */
29524
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
29275
29525
  var GetLoggingSettingsInputSchema = object({
29276
29526
  scopeNodeId: string().optional(),
29277
29527
  /**
@@ -29330,7 +29580,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
29330
29580
  }), method(_void(), SiteLocationStatusSchema, {
29331
29581
  kind: "mutation",
29332
29582
  auth: "admin"
29333
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
29583
+ }), 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, {
29334
29584
  kind: "mutation",
29335
29585
  auth: "admin"
29336
29586
  });
@@ -31652,6 +31902,12 @@ Object.freeze({
31652
31902
  addonId: null,
31653
31903
  access: "view"
31654
31904
  },
31905
+ "addonSettings.getIntegrationSettings": {
31906
+ capName: "addon-settings",
31907
+ capScope: "system",
31908
+ addonId: null,
31909
+ access: "view"
31910
+ },
31655
31911
  "addonSettings.updateDeviceSettings": {
31656
31912
  capName: "addon-settings",
31657
31913
  capScope: "system",
@@ -33314,6 +33570,12 @@ Object.freeze({
33314
33570
  addonId: null,
33315
33571
  access: "create"
33316
33572
  },
33573
+ "failureContribution.list": {
33574
+ capName: "failure-contribution",
33575
+ capScope: "system",
33576
+ addonId: null,
33577
+ access: "view"
33578
+ },
33317
33579
  "fanControl.setDirection": {
33318
33580
  capName: "fan-control",
33319
33581
  capScope: "device",
@@ -36620,6 +36882,12 @@ Object.freeze({
36620
36882
  addonId: null,
36621
36883
  access: "create"
36622
36884
  },
36885
+ "system.getFailureContributions": {
36886
+ capName: "system",
36887
+ capScope: "system",
36888
+ addonId: null,
36889
+ access: "view"
36890
+ },
36623
36891
  "system.getLoadContributions": {
36624
36892
  capName: "system",
36625
36893
  capScope: "system",
package/dist/addon.mjs CHANGED
@@ -5927,6 +5927,40 @@ var BaseAddon = class {
5927
5927
  deviceSettingsSchema() {
5928
5928
  return null;
5929
5929
  }
5930
+ /**
5931
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5932
+ * ARE the configuration of its integration.
5933
+ *
5934
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5935
+ * operator should find on the addon's integration page (System →
5936
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5937
+ * addon. Empty (the default) means the addon has no integration-level
5938
+ * settings and no such surface is offered — this is opt-in, because whether
5939
+ * an addon's configuration IS its integration's configuration depends on the
5940
+ * nature of the integration.
5941
+ *
5942
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5943
+ * the ONE global schema, in the ONE addon store, written by the ONE
5944
+ * `updateGlobalSettings` path. There is deliberately no
5945
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5946
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5947
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5948
+ *
5949
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5950
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5951
+ * removed with the reason recorded at
5952
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5953
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5954
+ * marker sprinkled across sections also has to borrow a field that already
5955
+ * means something else; borrowing `section.tab` put the literal word
5956
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5957
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5958
+ * supersedes D268). One declaration, in one place, next to the schema whose
5959
+ * ids it names.
5960
+ */
5961
+ integrationSettingSections() {
5962
+ return [];
5963
+ }
5930
5964
  async getGlobalSettings(overlay, cap, nodeId) {
5931
5965
  const schema = this.globalSettingsSchema(cap);
5932
5966
  if (!schema) return { sections: [] };
@@ -5937,6 +5971,55 @@ var BaseAddon = class {
5937
5971
  } : projected);
5938
5972
  }
5939
5973
  /**
5974
+ * The integration-level view of this addon's settings: exactly the sections
5975
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
5976
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
5977
+ *
5978
+ * Returns `null` when the addon declared nothing — an addon that opts out has
5979
+ * no integration settings surface at all, rather than an empty one that reads
5980
+ * as a failed load.
5981
+ *
5982
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
5983
+ * and not in whichever UI happens to render this:
5984
+ *
5985
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
5986
+ * shown here is the same field, with the same bare key, that the addon's
5987
+ * own page shows. There is no integration-specific writer — callers save
5988
+ * through `updateGlobalSettings` — so a second store key is unreachable,
5989
+ * not merely discouraged.
5990
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
5991
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
5992
+ * such a field silently picked would be a wrong answer for the operator
5993
+ * who opened the page (D266).
5994
+ * 3. **No silent typo.** A declared id that names no section throws. The
5995
+ * alternative — skip it — turns a rename into a surface that quietly
5996
+ * empties, which looks exactly like an addon with nothing to configure.
5997
+ */
5998
+ async getIntegrationSettings(nodeId) {
5999
+ const declared = this.integrationSettingSections();
6000
+ if (declared.length === 0) return null;
6001
+ const schema = this.globalSettingsSchema();
6002
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
6003
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
6004
+ const sections = [];
6005
+ for (const id of declared) {
6006
+ const section = byId.get(id);
6007
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6008
+ const fields = dropPerNodeFields(section.fields);
6009
+ if (fields.length === 0) continue;
6010
+ sections.push({
6011
+ ...section,
6012
+ fields
6013
+ });
6014
+ }
6015
+ if (sections.length === 0) return null;
6016
+ const projected = await this.resolveGlobalStore(nodeId);
6017
+ return hydrateSchema({
6018
+ ...schema,
6019
+ sections
6020
+ }, projected);
6021
+ }
6022
+ /**
5940
6023
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5941
6024
  * every `perNode: true` field carries THAT node's scoped value on its bare
5942
6025
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6240,6 +6323,41 @@ var BaseAddon = class {
6240
6323
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6241
6324
  * don't declare `perNode` and are excluded by the `in` narrowing.
6242
6325
  */
6326
+ /**
6327
+ * The same fields with every `perNode: true` one removed, recursing into layout
6328
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6329
+ * with no child is dropped rather than rendered empty.
6330
+ *
6331
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6332
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6333
+ */
6334
+ function dropPerNodeFields(fields) {
6335
+ const kept = [];
6336
+ for (const field of fields) {
6337
+ if (field.type === "group") {
6338
+ const inner = dropPerNodeFields(field.fields);
6339
+ if (inner.length > 0) kept.push({
6340
+ ...field,
6341
+ fields: inner
6342
+ });
6343
+ continue;
6344
+ }
6345
+ if (field.type === "sub-tabs") {
6346
+ const tabs = field.tabs.map((tab) => ({
6347
+ ...tab,
6348
+ fields: dropPerNodeFields(tab.fields)
6349
+ })).filter((tab) => tab.fields.length > 0);
6350
+ if (tabs.length > 0) kept.push({
6351
+ ...field,
6352
+ tabs
6353
+ });
6354
+ continue;
6355
+ }
6356
+ if ("perNode" in field && field.perNode === true) continue;
6357
+ kept.push(field);
6358
+ }
6359
+ return kept;
6360
+ }
6243
6361
  function collectPerNodeFieldKeys(fields) {
6244
6362
  const collected = [];
6245
6363
  for (const field of fields) {
@@ -9409,6 +9527,9 @@ method(object({
9409
9527
  kind: "mutation",
9410
9528
  auth: "admin"
9411
9529
  }), method(object({
9530
+ addonId: string(),
9531
+ nodeId: string().optional()
9532
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9412
9533
  addonId: string(),
9413
9534
  deviceId: number(),
9414
9535
  nodeId: string().optional()
@@ -13374,6 +13495,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13374
13495
  limit: number().optional(),
13375
13496
  tags: record(string(), string()).optional()
13376
13497
  }), array(LogEntrySchema).readonly());
13498
+ /**
13499
+ * `failure-contribution` — the capability an addon reports its OWN losses
13500
+ * through, per camera, with the denominator attached. It stores nothing.
13501
+ *
13502
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13503
+ *
13504
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13505
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13506
+ * copied: the contributor reports what it already knows, hub-main adds only
13507
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13508
+ * somebody to forget to edit.
13509
+ *
13510
+ * They are not merged, because their invariants are opposites:
13511
+ *
13512
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13513
+ * claim a camera cost nothing, which is a measurement nobody made;
13514
+ * - a `failure-contribution` zero is the **most valuable value on the
13515
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13516
+ * and it is exactly what an absent entry cannot say.
13517
+ *
13518
+ * Putting a loss counter on a cost entry would also break the reconciliation
13519
+ * that gives `load-contribution` its point: contributions are subtracted from
13520
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13521
+ * has no process.
13522
+ *
13523
+ * ## Why not a log line, since the counters already exist
13524
+ *
13525
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13526
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13527
+ * ends in a log line, and a log line is the thing the operator asked to stop
13528
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13529
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13530
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13531
+ * media blackout were both diagnosed. The counters stay; this is where they can
13532
+ * be READ.
13533
+ *
13534
+ * ## The rate is served with its denominator or not at all
13535
+ *
13536
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13537
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13538
+ * than yesterday" and was **flat across twelve hours** once divided by the
13539
+ * successes on the same path. A surface that publishes only the numerator
13540
+ * reproduces that mistake on every read.
13541
+ *
13542
+ * ## Shape
13543
+ *
13544
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13545
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13546
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13547
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13548
+ * a forked runner's entries reach hub-main over transport that already exists.
13549
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13550
+ * result through `system.getFailureContributions`.
13551
+ */
13552
+ var FailureReasonCountSchema = object({
13553
+ /**
13554
+ * Why the attempt did not land, in the contributor's own vocabulary —
13555
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13556
+ * strings that already appear in this repo's logs and, where one exists, the
13557
+ * same string the per-track `previewMissReason` records (D276): a second
13558
+ * vocabulary for the same loss would make the row and the counter
13559
+ * un-joinable.
13560
+ */
13561
+ reason: string(),
13562
+ count: number().int().nonnegative()
13563
+ });
13564
+ var FailureContributionSchema = object({
13565
+ /**
13566
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13567
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13568
+ * `unit` free: the families are owned by different addons and a shared enum
13569
+ * is a central list that rots invisibly.
13570
+ */
13571
+ family: string(),
13572
+ /**
13573
+ * The NUMERIC device id — the same value every log line carries as
13574
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13575
+ * cannot name the camera must not emit the entry, because a fleet total
13576
+ * cannot answer the only question anybody asks of this surface.
13577
+ */
13578
+ deviceId: number().int().positive(),
13579
+ /**
13580
+ * A second dimension inside the family: the model / step id for an inference
13581
+ * timeout, so "which camera AND which model" is one read. Absent when the
13582
+ * family has a single variant.
13583
+ */
13584
+ variant: string().optional(),
13585
+ /**
13586
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13587
+ * differencing two reads must drop the interval when it changes, because the
13588
+ * counter restarted from zero in a respawned runner. Same discipline as
13589
+ * `LoadContribution.startedAtMs`.
13590
+ */
13591
+ sinceMs: number(),
13592
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13593
+ atMs: number(),
13594
+ /**
13595
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13596
+ * window. A failure count published without it is the mistake this schema
13597
+ * exists to make impossible.
13598
+ */
13599
+ attempts: number().int().nonnegative(),
13600
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13601
+ succeeded: number().int().nonnegative(),
13602
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13603
+ reasons: array(FailureReasonCountSchema).readonly()
13604
+ });
13605
+ method(_void(), array(FailureContributionSchema).readonly());
13377
13606
  var LoadContributionSchema = object({
13378
13607
  role: _enum([
13379
13608
  "decode",
@@ -17964,6 +18193,20 @@ var TrackSchema = object({
17964
18193
  * `=== true` and render nothing otherwise — never infer "no rider".
17965
18194
  */
17966
18195
  hasRider: boolean().optional(),
18196
+ /**
18197
+ * WHY this track ended without a NATIVE best-shot tile
18198
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
18199
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
18200
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
18201
+ * the late-keyFrame upgrade when a native tile lands after all. The
18202
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
18203
+ * tile is a face/plate stand-in, a raster crop, or an icon.
18204
+ *
18205
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
18206
+ * that predates the field, and every track whose tile landed native all
18207
+ * omit it. Render nothing when absent.
18208
+ */
18209
+ previewMissReason: string().optional(),
17967
18210
  ...TrackFlagFields,
17968
18211
  ...TrackRetrainFields
17969
18212
  });
@@ -29251,6 +29494,13 @@ var LoggingSettingsPatchSchema = object({
29251
29494
  * anyone but its owner.
29252
29495
  */
29253
29496
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
29497
+ /**
29498
+ * One per-camera failure counter, plus WHO reported it.
29499
+ *
29500
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
29501
+ * the hub as it enumerates providers, never by the contributor.
29502
+ */
29503
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
29254
29504
  var GetLoggingSettingsInputSchema = object({
29255
29505
  scopeNodeId: string().optional(),
29256
29506
  /**
@@ -29309,7 +29559,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
29309
29559
  }), method(_void(), SiteLocationStatusSchema, {
29310
29560
  kind: "mutation",
29311
29561
  auth: "admin"
29312
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
29562
+ }), 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, {
29313
29563
  kind: "mutation",
29314
29564
  auth: "admin"
29315
29565
  });
@@ -31631,6 +31881,12 @@ Object.freeze({
31631
31881
  addonId: null,
31632
31882
  access: "view"
31633
31883
  },
31884
+ "addonSettings.getIntegrationSettings": {
31885
+ capName: "addon-settings",
31886
+ capScope: "system",
31887
+ addonId: null,
31888
+ access: "view"
31889
+ },
31634
31890
  "addonSettings.updateDeviceSettings": {
31635
31891
  capName: "addon-settings",
31636
31892
  capScope: "system",
@@ -33293,6 +33549,12 @@ Object.freeze({
33293
33549
  addonId: null,
33294
33550
  access: "create"
33295
33551
  },
33552
+ "failureContribution.list": {
33553
+ capName: "failure-contribution",
33554
+ capScope: "system",
33555
+ addonId: null,
33556
+ access: "view"
33557
+ },
33296
33558
  "fanControl.setDirection": {
33297
33559
  capName: "fan-control",
33298
33560
  capScope: "device",
@@ -36599,6 +36861,12 @@ Object.freeze({
36599
36861
  addonId: null,
36600
36862
  access: "create"
36601
36863
  },
36864
+ "system.getFailureContributions": {
36865
+ capName: "system",
36866
+ capScope: "system",
36867
+ addonId: null,
36868
+ access: "view"
36869
+ },
36602
36870
  "system.getLoadContributions": {
36603
36871
  capName: "system",
36604
36872
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-wyze",
3
- "version": "0.2.41",
3
+ "version": "0.2.43",
4
4
  "description": "Wyze camera device-provider addon for CamStack — wraps the @apocaliss92/wyze-bridge-js P2P/DTLS client, feeding the stream-broker via the pull-rfc4571 lazy-publish path (a structural twin of addon-provider-reolink)",
5
5
  "keywords": [
6
6
  "camstack",