@camstack/addon-import-alexa 0.2.36 → 0.2.38

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
@@ -5955,6 +5955,40 @@ var BaseAddon = class {
5955
5955
  deviceSettingsSchema() {
5956
5956
  return null;
5957
5957
  }
5958
+ /**
5959
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5960
+ * ARE the configuration of its integration.
5961
+ *
5962
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5963
+ * operator should find on the addon's integration page (System →
5964
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5965
+ * addon. Empty (the default) means the addon has no integration-level
5966
+ * settings and no such surface is offered — this is opt-in, because whether
5967
+ * an addon's configuration IS its integration's configuration depends on the
5968
+ * nature of the integration.
5969
+ *
5970
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5971
+ * the ONE global schema, in the ONE addon store, written by the ONE
5972
+ * `updateGlobalSettings` path. There is deliberately no
5973
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5974
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5975
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5976
+ *
5977
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5978
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5979
+ * removed with the reason recorded at
5980
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5981
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5982
+ * marker sprinkled across sections also has to borrow a field that already
5983
+ * means something else; borrowing `section.tab` put the literal word
5984
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5985
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5986
+ * supersedes D268). One declaration, in one place, next to the schema whose
5987
+ * ids it names.
5988
+ */
5989
+ integrationSettingSections() {
5990
+ return [];
5991
+ }
5958
5992
  async getGlobalSettings(overlay, cap, nodeId) {
5959
5993
  const schema = this.globalSettingsSchema(cap);
5960
5994
  if (!schema) return { sections: [] };
@@ -5965,6 +5999,55 @@ var BaseAddon = class {
5965
5999
  } : projected);
5966
6000
  }
5967
6001
  /**
6002
+ * The integration-level view of this addon's settings: exactly the sections
6003
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
6004
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
6005
+ *
6006
+ * Returns `null` when the addon declared nothing — an addon that opts out has
6007
+ * no integration settings surface at all, rather than an empty one that reads
6008
+ * as a failed load.
6009
+ *
6010
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
6011
+ * and not in whichever UI happens to render this:
6012
+ *
6013
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
6014
+ * shown here is the same field, with the same bare key, that the addon's
6015
+ * own page shows. There is no integration-specific writer — callers save
6016
+ * through `updateGlobalSettings` — so a second store key is unreachable,
6017
+ * not merely discouraged.
6018
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
6019
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
6020
+ * such a field silently picked would be a wrong answer for the operator
6021
+ * who opened the page (D266).
6022
+ * 3. **No silent typo.** A declared id that names no section throws. The
6023
+ * alternative — skip it — turns a rename into a surface that quietly
6024
+ * empties, which looks exactly like an addon with nothing to configure.
6025
+ */
6026
+ async getIntegrationSettings(nodeId) {
6027
+ const declared = this.integrationSettingSections();
6028
+ if (declared.length === 0) return null;
6029
+ const schema = this.globalSettingsSchema();
6030
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
6031
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
6032
+ const sections = [];
6033
+ for (const id of declared) {
6034
+ const section = byId.get(id);
6035
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6036
+ const fields = dropPerNodeFields(section.fields);
6037
+ if (fields.length === 0) continue;
6038
+ sections.push({
6039
+ ...section,
6040
+ fields
6041
+ });
6042
+ }
6043
+ if (sections.length === 0) return null;
6044
+ const projected = await this.resolveGlobalStore(nodeId);
6045
+ return hydrateSchema({
6046
+ ...schema,
6047
+ sections
6048
+ }, projected);
6049
+ }
6050
+ /**
5968
6051
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5969
6052
  * every `perNode: true` field carries THAT node's scoped value on its bare
5970
6053
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6268,6 +6351,41 @@ var BaseAddon = class {
6268
6351
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6269
6352
  * don't declare `perNode` and are excluded by the `in` narrowing.
6270
6353
  */
6354
+ /**
6355
+ * The same fields with every `perNode: true` one removed, recursing into layout
6356
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6357
+ * with no child is dropped rather than rendered empty.
6358
+ *
6359
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6360
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6361
+ */
6362
+ function dropPerNodeFields(fields) {
6363
+ const kept = [];
6364
+ for (const field of fields) {
6365
+ if (field.type === "group") {
6366
+ const inner = dropPerNodeFields(field.fields);
6367
+ if (inner.length > 0) kept.push({
6368
+ ...field,
6369
+ fields: inner
6370
+ });
6371
+ continue;
6372
+ }
6373
+ if (field.type === "sub-tabs") {
6374
+ const tabs = field.tabs.map((tab) => ({
6375
+ ...tab,
6376
+ fields: dropPerNodeFields(tab.fields)
6377
+ })).filter((tab) => tab.fields.length > 0);
6378
+ if (tabs.length > 0) kept.push({
6379
+ ...field,
6380
+ tabs
6381
+ });
6382
+ continue;
6383
+ }
6384
+ if ("perNode" in field && field.perNode === true) continue;
6385
+ kept.push(field);
6386
+ }
6387
+ return kept;
6388
+ }
6271
6389
  function collectPerNodeFieldKeys(fields) {
6272
6390
  const collected = [];
6273
6391
  for (const field of fields) {
@@ -9575,6 +9693,9 @@ method(object({
9575
9693
  kind: "mutation",
9576
9694
  auth: "admin"
9577
9695
  }), method(object({
9696
+ addonId: string(),
9697
+ nodeId: string().optional()
9698
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9578
9699
  addonId: string(),
9579
9700
  deviceId: number(),
9580
9701
  nodeId: string().optional()
@@ -13589,6 +13710,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13589
13710
  limit: number().optional(),
13590
13711
  tags: record(string(), string()).optional()
13591
13712
  }), array(LogEntrySchema).readonly());
13713
+ /**
13714
+ * `failure-contribution` — the capability an addon reports its OWN losses
13715
+ * through, per camera, with the denominator attached. It stores nothing.
13716
+ *
13717
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13718
+ *
13719
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13720
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13721
+ * copied: the contributor reports what it already knows, hub-main adds only
13722
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13723
+ * somebody to forget to edit.
13724
+ *
13725
+ * They are not merged, because their invariants are opposites:
13726
+ *
13727
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13728
+ * claim a camera cost nothing, which is a measurement nobody made;
13729
+ * - a `failure-contribution` zero is the **most valuable value on the
13730
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13731
+ * and it is exactly what an absent entry cannot say.
13732
+ *
13733
+ * Putting a loss counter on a cost entry would also break the reconciliation
13734
+ * that gives `load-contribution` its point: contributions are subtracted from
13735
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13736
+ * has no process.
13737
+ *
13738
+ * ## Why not a log line, since the counters already exist
13739
+ *
13740
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13741
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13742
+ * ends in a log line, and a log line is the thing the operator asked to stop
13743
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13744
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13745
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13746
+ * media blackout were both diagnosed. The counters stay; this is where they can
13747
+ * be READ.
13748
+ *
13749
+ * ## The rate is served with its denominator or not at all
13750
+ *
13751
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13752
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13753
+ * than yesterday" and was **flat across twelve hours** once divided by the
13754
+ * successes on the same path. A surface that publishes only the numerator
13755
+ * reproduces that mistake on every read.
13756
+ *
13757
+ * ## Shape
13758
+ *
13759
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13760
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13761
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13762
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13763
+ * a forked runner's entries reach hub-main over transport that already exists.
13764
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13765
+ * result through `system.getFailureContributions`.
13766
+ */
13767
+ var FailureReasonCountSchema = object({
13768
+ /**
13769
+ * Why the attempt did not land, in the contributor's own vocabulary —
13770
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13771
+ * strings that already appear in this repo's logs and, where one exists, the
13772
+ * same string the per-track `previewMissReason` records (D276): a second
13773
+ * vocabulary for the same loss would make the row and the counter
13774
+ * un-joinable.
13775
+ */
13776
+ reason: string(),
13777
+ count: number().int().nonnegative()
13778
+ });
13779
+ var FailureContributionSchema = object({
13780
+ /**
13781
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13782
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13783
+ * `unit` free: the families are owned by different addons and a shared enum
13784
+ * is a central list that rots invisibly.
13785
+ */
13786
+ family: string(),
13787
+ /**
13788
+ * The NUMERIC device id — the same value every log line carries as
13789
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13790
+ * cannot name the camera must not emit the entry, because a fleet total
13791
+ * cannot answer the only question anybody asks of this surface.
13792
+ */
13793
+ deviceId: number().int().positive(),
13794
+ /**
13795
+ * A second dimension inside the family: the model / step id for an inference
13796
+ * timeout, so "which camera AND which model" is one read. Absent when the
13797
+ * family has a single variant.
13798
+ */
13799
+ variant: string().optional(),
13800
+ /**
13801
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13802
+ * differencing two reads must drop the interval when it changes, because the
13803
+ * counter restarted from zero in a respawned runner. Same discipline as
13804
+ * `LoadContribution.startedAtMs`.
13805
+ */
13806
+ sinceMs: number(),
13807
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13808
+ atMs: number(),
13809
+ /**
13810
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13811
+ * window. A failure count published without it is the mistake this schema
13812
+ * exists to make impossible.
13813
+ */
13814
+ attempts: number().int().nonnegative(),
13815
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13816
+ succeeded: number().int().nonnegative(),
13817
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13818
+ reasons: array(FailureReasonCountSchema).readonly()
13819
+ });
13820
+ method(_void(), array(FailureContributionSchema).readonly());
13592
13821
  var LoadContributionSchema = object({
13593
13822
  role: _enum([
13594
13823
  "decode",
@@ -18179,6 +18408,20 @@ var TrackSchema = object({
18179
18408
  * `=== true` and render nothing otherwise — never infer "no rider".
18180
18409
  */
18181
18410
  hasRider: boolean().optional(),
18411
+ /**
18412
+ * WHY this track ended without a NATIVE best-shot tile
18413
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
18414
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
18415
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
18416
+ * the late-keyFrame upgrade when a native tile lands after all. The
18417
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
18418
+ * tile is a face/plate stand-in, a raster crop, or an icon.
18419
+ *
18420
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
18421
+ * that predates the field, and every track whose tile landed native all
18422
+ * omit it. Render nothing when absent.
18423
+ */
18424
+ previewMissReason: string().optional(),
18182
18425
  ...TrackFlagFields,
18183
18426
  ...TrackRetrainFields
18184
18427
  });
@@ -29371,6 +29614,13 @@ var LoggingSettingsPatchSchema = object({
29371
29614
  * anyone but its owner.
29372
29615
  */
29373
29616
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
29617
+ /**
29618
+ * One per-camera failure counter, plus WHO reported it.
29619
+ *
29620
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
29621
+ * the hub as it enumerates providers, never by the contributor.
29622
+ */
29623
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
29374
29624
  var GetLoggingSettingsInputSchema = object({
29375
29625
  scopeNodeId: string().optional(),
29376
29626
  /**
@@ -29429,7 +29679,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
29429
29679
  }), method(_void(), SiteLocationStatusSchema, {
29430
29680
  kind: "mutation",
29431
29681
  auth: "admin"
29432
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
29682
+ }), 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, {
29433
29683
  kind: "mutation",
29434
29684
  auth: "admin"
29435
29685
  });
@@ -31751,6 +32001,12 @@ Object.freeze({
31751
32001
  addonId: null,
31752
32002
  access: "view"
31753
32003
  },
32004
+ "addonSettings.getIntegrationSettings": {
32005
+ capName: "addon-settings",
32006
+ capScope: "system",
32007
+ addonId: null,
32008
+ access: "view"
32009
+ },
31754
32010
  "addonSettings.updateDeviceSettings": {
31755
32011
  capName: "addon-settings",
31756
32012
  capScope: "system",
@@ -33413,6 +33669,12 @@ Object.freeze({
33413
33669
  addonId: null,
33414
33670
  access: "create"
33415
33671
  },
33672
+ "failureContribution.list": {
33673
+ capName: "failure-contribution",
33674
+ capScope: "system",
33675
+ addonId: null,
33676
+ access: "view"
33677
+ },
33416
33678
  "fanControl.setDirection": {
33417
33679
  capName: "fan-control",
33418
33680
  capScope: "device",
@@ -36719,6 +36981,12 @@ Object.freeze({
36719
36981
  addonId: null,
36720
36982
  access: "create"
36721
36983
  },
36984
+ "system.getFailureContributions": {
36985
+ capName: "system",
36986
+ capScope: "system",
36987
+ addonId: null,
36988
+ access: "view"
36989
+ },
36722
36990
  "system.getLoadContributions": {
36723
36991
  capName: "system",
36724
36992
  capScope: "system",
package/dist/addon.mjs CHANGED
@@ -5955,6 +5955,40 @@ var BaseAddon = class {
5955
5955
  deviceSettingsSchema() {
5956
5956
  return null;
5957
5957
  }
5958
+ /**
5959
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5960
+ * ARE the configuration of its integration.
5961
+ *
5962
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5963
+ * operator should find on the addon's integration page (System →
5964
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5965
+ * addon. Empty (the default) means the addon has no integration-level
5966
+ * settings and no such surface is offered — this is opt-in, because whether
5967
+ * an addon's configuration IS its integration's configuration depends on the
5968
+ * nature of the integration.
5969
+ *
5970
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5971
+ * the ONE global schema, in the ONE addon store, written by the ONE
5972
+ * `updateGlobalSettings` path. There is deliberately no
5973
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5974
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5975
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5976
+ *
5977
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5978
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5979
+ * removed with the reason recorded at
5980
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5981
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5982
+ * marker sprinkled across sections also has to borrow a field that already
5983
+ * means something else; borrowing `section.tab` put the literal word
5984
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5985
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5986
+ * supersedes D268). One declaration, in one place, next to the schema whose
5987
+ * ids it names.
5988
+ */
5989
+ integrationSettingSections() {
5990
+ return [];
5991
+ }
5958
5992
  async getGlobalSettings(overlay, cap, nodeId) {
5959
5993
  const schema = this.globalSettingsSchema(cap);
5960
5994
  if (!schema) return { sections: [] };
@@ -5965,6 +5999,55 @@ var BaseAddon = class {
5965
5999
  } : projected);
5966
6000
  }
5967
6001
  /**
6002
+ * The integration-level view of this addon's settings: exactly the sections
6003
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
6004
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
6005
+ *
6006
+ * Returns `null` when the addon declared nothing — an addon that opts out has
6007
+ * no integration settings surface at all, rather than an empty one that reads
6008
+ * as a failed load.
6009
+ *
6010
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
6011
+ * and not in whichever UI happens to render this:
6012
+ *
6013
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
6014
+ * shown here is the same field, with the same bare key, that the addon's
6015
+ * own page shows. There is no integration-specific writer — callers save
6016
+ * through `updateGlobalSettings` — so a second store key is unreachable,
6017
+ * not merely discouraged.
6018
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
6019
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
6020
+ * such a field silently picked would be a wrong answer for the operator
6021
+ * who opened the page (D266).
6022
+ * 3. **No silent typo.** A declared id that names no section throws. The
6023
+ * alternative — skip it — turns a rename into a surface that quietly
6024
+ * empties, which looks exactly like an addon with nothing to configure.
6025
+ */
6026
+ async getIntegrationSettings(nodeId) {
6027
+ const declared = this.integrationSettingSections();
6028
+ if (declared.length === 0) return null;
6029
+ const schema = this.globalSettingsSchema();
6030
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
6031
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
6032
+ const sections = [];
6033
+ for (const id of declared) {
6034
+ const section = byId.get(id);
6035
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6036
+ const fields = dropPerNodeFields(section.fields);
6037
+ if (fields.length === 0) continue;
6038
+ sections.push({
6039
+ ...section,
6040
+ fields
6041
+ });
6042
+ }
6043
+ if (sections.length === 0) return null;
6044
+ const projected = await this.resolveGlobalStore(nodeId);
6045
+ return hydrateSchema({
6046
+ ...schema,
6047
+ sections
6048
+ }, projected);
6049
+ }
6050
+ /**
5968
6051
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5969
6052
  * every `perNode: true` field carries THAT node's scoped value on its bare
5970
6053
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6268,6 +6351,41 @@ var BaseAddon = class {
6268
6351
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6269
6352
  * don't declare `perNode` and are excluded by the `in` narrowing.
6270
6353
  */
6354
+ /**
6355
+ * The same fields with every `perNode: true` one removed, recursing into layout
6356
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6357
+ * with no child is dropped rather than rendered empty.
6358
+ *
6359
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6360
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6361
+ */
6362
+ function dropPerNodeFields(fields) {
6363
+ const kept = [];
6364
+ for (const field of fields) {
6365
+ if (field.type === "group") {
6366
+ const inner = dropPerNodeFields(field.fields);
6367
+ if (inner.length > 0) kept.push({
6368
+ ...field,
6369
+ fields: inner
6370
+ });
6371
+ continue;
6372
+ }
6373
+ if (field.type === "sub-tabs") {
6374
+ const tabs = field.tabs.map((tab) => ({
6375
+ ...tab,
6376
+ fields: dropPerNodeFields(tab.fields)
6377
+ })).filter((tab) => tab.fields.length > 0);
6378
+ if (tabs.length > 0) kept.push({
6379
+ ...field,
6380
+ tabs
6381
+ });
6382
+ continue;
6383
+ }
6384
+ if ("perNode" in field && field.perNode === true) continue;
6385
+ kept.push(field);
6386
+ }
6387
+ return kept;
6388
+ }
6271
6389
  function collectPerNodeFieldKeys(fields) {
6272
6390
  const collected = [];
6273
6391
  for (const field of fields) {
@@ -9575,6 +9693,9 @@ method(object({
9575
9693
  kind: "mutation",
9576
9694
  auth: "admin"
9577
9695
  }), method(object({
9696
+ addonId: string(),
9697
+ nodeId: string().optional()
9698
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9578
9699
  addonId: string(),
9579
9700
  deviceId: number(),
9580
9701
  nodeId: string().optional()
@@ -13589,6 +13710,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13589
13710
  limit: number().optional(),
13590
13711
  tags: record(string(), string()).optional()
13591
13712
  }), array(LogEntrySchema).readonly());
13713
+ /**
13714
+ * `failure-contribution` — the capability an addon reports its OWN losses
13715
+ * through, per camera, with the denominator attached. It stores nothing.
13716
+ *
13717
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13718
+ *
13719
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13720
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13721
+ * copied: the contributor reports what it already knows, hub-main adds only
13722
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13723
+ * somebody to forget to edit.
13724
+ *
13725
+ * They are not merged, because their invariants are opposites:
13726
+ *
13727
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13728
+ * claim a camera cost nothing, which is a measurement nobody made;
13729
+ * - a `failure-contribution` zero is the **most valuable value on the
13730
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13731
+ * and it is exactly what an absent entry cannot say.
13732
+ *
13733
+ * Putting a loss counter on a cost entry would also break the reconciliation
13734
+ * that gives `load-contribution` its point: contributions are subtracted from
13735
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13736
+ * has no process.
13737
+ *
13738
+ * ## Why not a log line, since the counters already exist
13739
+ *
13740
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13741
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13742
+ * ends in a log line, and a log line is the thing the operator asked to stop
13743
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13744
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13745
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13746
+ * media blackout were both diagnosed. The counters stay; this is where they can
13747
+ * be READ.
13748
+ *
13749
+ * ## The rate is served with its denominator or not at all
13750
+ *
13751
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13752
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13753
+ * than yesterday" and was **flat across twelve hours** once divided by the
13754
+ * successes on the same path. A surface that publishes only the numerator
13755
+ * reproduces that mistake on every read.
13756
+ *
13757
+ * ## Shape
13758
+ *
13759
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13760
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13761
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13762
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13763
+ * a forked runner's entries reach hub-main over transport that already exists.
13764
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13765
+ * result through `system.getFailureContributions`.
13766
+ */
13767
+ var FailureReasonCountSchema = object({
13768
+ /**
13769
+ * Why the attempt did not land, in the contributor's own vocabulary —
13770
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13771
+ * strings that already appear in this repo's logs and, where one exists, the
13772
+ * same string the per-track `previewMissReason` records (D276): a second
13773
+ * vocabulary for the same loss would make the row and the counter
13774
+ * un-joinable.
13775
+ */
13776
+ reason: string(),
13777
+ count: number().int().nonnegative()
13778
+ });
13779
+ var FailureContributionSchema = object({
13780
+ /**
13781
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13782
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13783
+ * `unit` free: the families are owned by different addons and a shared enum
13784
+ * is a central list that rots invisibly.
13785
+ */
13786
+ family: string(),
13787
+ /**
13788
+ * The NUMERIC device id — the same value every log line carries as
13789
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13790
+ * cannot name the camera must not emit the entry, because a fleet total
13791
+ * cannot answer the only question anybody asks of this surface.
13792
+ */
13793
+ deviceId: number().int().positive(),
13794
+ /**
13795
+ * A second dimension inside the family: the model / step id for an inference
13796
+ * timeout, so "which camera AND which model" is one read. Absent when the
13797
+ * family has a single variant.
13798
+ */
13799
+ variant: string().optional(),
13800
+ /**
13801
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13802
+ * differencing two reads must drop the interval when it changes, because the
13803
+ * counter restarted from zero in a respawned runner. Same discipline as
13804
+ * `LoadContribution.startedAtMs`.
13805
+ */
13806
+ sinceMs: number(),
13807
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13808
+ atMs: number(),
13809
+ /**
13810
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13811
+ * window. A failure count published without it is the mistake this schema
13812
+ * exists to make impossible.
13813
+ */
13814
+ attempts: number().int().nonnegative(),
13815
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13816
+ succeeded: number().int().nonnegative(),
13817
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13818
+ reasons: array(FailureReasonCountSchema).readonly()
13819
+ });
13820
+ method(_void(), array(FailureContributionSchema).readonly());
13592
13821
  var LoadContributionSchema = object({
13593
13822
  role: _enum([
13594
13823
  "decode",
@@ -18179,6 +18408,20 @@ var TrackSchema = object({
18179
18408
  * `=== true` and render nothing otherwise — never infer "no rider".
18180
18409
  */
18181
18410
  hasRider: boolean().optional(),
18411
+ /**
18412
+ * WHY this track ended without a NATIVE best-shot tile
18413
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
18414
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
18415
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
18416
+ * the late-keyFrame upgrade when a native tile lands after all. The
18417
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
18418
+ * tile is a face/plate stand-in, a raster crop, or an icon.
18419
+ *
18420
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
18421
+ * that predates the field, and every track whose tile landed native all
18422
+ * omit it. Render nothing when absent.
18423
+ */
18424
+ previewMissReason: string().optional(),
18182
18425
  ...TrackFlagFields,
18183
18426
  ...TrackRetrainFields
18184
18427
  });
@@ -29371,6 +29614,13 @@ var LoggingSettingsPatchSchema = object({
29371
29614
  * anyone but its owner.
29372
29615
  */
29373
29616
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
29617
+ /**
29618
+ * One per-camera failure counter, plus WHO reported it.
29619
+ *
29620
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
29621
+ * the hub as it enumerates providers, never by the contributor.
29622
+ */
29623
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
29374
29624
  var GetLoggingSettingsInputSchema = object({
29375
29625
  scopeNodeId: string().optional(),
29376
29626
  /**
@@ -29429,7 +29679,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
29429
29679
  }), method(_void(), SiteLocationStatusSchema, {
29430
29680
  kind: "mutation",
29431
29681
  auth: "admin"
29432
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
29682
+ }), 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, {
29433
29683
  kind: "mutation",
29434
29684
  auth: "admin"
29435
29685
  });
@@ -31751,6 +32001,12 @@ Object.freeze({
31751
32001
  addonId: null,
31752
32002
  access: "view"
31753
32003
  },
32004
+ "addonSettings.getIntegrationSettings": {
32005
+ capName: "addon-settings",
32006
+ capScope: "system",
32007
+ addonId: null,
32008
+ access: "view"
32009
+ },
31754
32010
  "addonSettings.updateDeviceSettings": {
31755
32011
  capName: "addon-settings",
31756
32012
  capScope: "system",
@@ -33413,6 +33669,12 @@ Object.freeze({
33413
33669
  addonId: null,
33414
33670
  access: "create"
33415
33671
  },
33672
+ "failureContribution.list": {
33673
+ capName: "failure-contribution",
33674
+ capScope: "system",
33675
+ addonId: null,
33676
+ access: "view"
33677
+ },
33416
33678
  "fanControl.setDirection": {
33417
33679
  capName: "fan-control",
33418
33680
  capScope: "device",
@@ -36719,6 +36981,12 @@ Object.freeze({
36719
36981
  addonId: null,
36720
36982
  access: "create"
36721
36983
  },
36984
+ "system.getFailureContributions": {
36985
+ capName: "system",
36986
+ capScope: "system",
36987
+ addonId: null,
36988
+ access: "view"
36989
+ },
36722
36990
  "system.getLoadContributions": {
36723
36991
  capName: "system",
36724
36992
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-import-alexa",
3
- "version": "0.2.36",
3
+ "version": "0.2.38",
4
4
  "description": "Alexa device-import provider for CamStack — imports the smart-home devices in a user's Alexa account via the unofficial alexa-remote2 cookie/token client (the inverse of the Alexa exporter)",
5
5
  "keywords": [
6
6
  "camstack",