@camstack/addon-provider-homeassistant 1.2.50 → 1.2.52

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
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_dist = require("./dist-C0k9HqhA.js");
2
+ const require_dist = require("./dist-nBclHVR_.js");
3
3
  let node_crypto = require("node:crypto");
4
4
  let node_zlib = require("node:zlib");
5
5
  //#region src/ha-device-source.ts
package/dist/addon.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as presenceCapability, A as controlCapability, At as EventCategory, B as humiditySensorCapability, C as buildAddonRouteProvider, Ct as number, D as colorCapability, Dt as union, E as climateControlCapability, Et as string, F as eventEmitterCapability, G as motionCapability, H as lawnMowerControlCapability, I as fanControlCapability, J as notifierCapability, K as normalizeUnit, L as floodCapability, M as deviceAdoptionCapability, O as connectivityCapability, Ot as unknown, P as enumSensorCapability, Q as prepareNotification, R as gasCapability, S as brokerCapability, St as literal, T as carbonMonoxideCapability, Tt as record, U as lockControlCapability, V as imageCapability, W as mediaPlayerCapability, Y as numericSensorCapability, Z as powerMeterCapability, _ as automationControlCapability, _t as createEvent, at as temperatureSensorCapability, b as binaryCapability, bt as array, ct as valveCapability, d as TargetSchema, dt as weatherCapability, et as pressureSensorCapability, f as accessoriesCapability, ft as errMsg, g as ambientLightSensorCapability, gt as DeviceType, h as alarmPanelCapability, ht as DeviceRole, it as tamperCapability, j as coverCapability, k as contactCapability, kt as url, lt as vibrationCapability, m as airQualitySensorCapability, mt as DeviceFeature, n as BaseDevice, nt as smokeCapability, ot as updateCapability, p as addonRoutesCapability, q as notificationOutputCapability, r as BaseDeviceProvider, rt as switchCapability, s as EnumSensorDateTimeFormatSchema, st as vacuumControlCapability, tt as scriptRunnerCapability, ut as waterHeaterCapability, v as batteryCapability, w as buttonCapability, wt as object, x as brightnessCapability, xt as discriminatedUnion, y as bestLocationMatch, yt as _enum, z as humidifierCapability } from "./dist-D-btrtuv.mjs";
1
+ import { $ as presenceCapability, A as controlCapability, At as EventCategory, B as humiditySensorCapability, C as buildAddonRouteProvider, Ct as number, D as colorCapability, Dt as union, E as climateControlCapability, Et as string, F as eventEmitterCapability, G as motionCapability, H as lawnMowerControlCapability, I as fanControlCapability, J as notifierCapability, K as normalizeUnit, L as floodCapability, M as deviceAdoptionCapability, O as connectivityCapability, Ot as unknown, P as enumSensorCapability, Q as prepareNotification, R as gasCapability, S as brokerCapability, St as literal, T as carbonMonoxideCapability, Tt as record, U as lockControlCapability, V as imageCapability, W as mediaPlayerCapability, Y as numericSensorCapability, Z as powerMeterCapability, _ as automationControlCapability, _t as createEvent, at as temperatureSensorCapability, b as binaryCapability, bt as array, ct as valveCapability, d as TargetSchema, dt as weatherCapability, et as pressureSensorCapability, f as accessoriesCapability, ft as errMsg, g as ambientLightSensorCapability, gt as DeviceType, h as alarmPanelCapability, ht as DeviceRole, it as tamperCapability, j as coverCapability, k as contactCapability, kt as url, lt as vibrationCapability, m as airQualitySensorCapability, mt as DeviceFeature, n as BaseDevice, nt as smokeCapability, ot as updateCapability, p as addonRoutesCapability, q as notificationOutputCapability, r as BaseDeviceProvider, rt as switchCapability, s as EnumSensorDateTimeFormatSchema, st as vacuumControlCapability, tt as scriptRunnerCapability, ut as waterHeaterCapability, v as batteryCapability, w as buttonCapability, wt as object, x as brightnessCapability, xt as discriminatedUnion, y as bestLocationMatch, yt as _enum, z as humidifierCapability } from "./dist-Dm7hAzfd.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { brotliCompressSync, deflateSync, gzipSync } from "node:zlib";
4
4
  //#region src/ha-device-source.ts
@@ -5915,6 +5915,40 @@ var BaseAddon = class {
5915
5915
  deviceSettingsSchema() {
5916
5916
  return null;
5917
5917
  }
5918
+ /**
5919
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5920
+ * ARE the configuration of its integration.
5921
+ *
5922
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5923
+ * operator should find on the addon's integration page (System →
5924
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5925
+ * addon. Empty (the default) means the addon has no integration-level
5926
+ * settings and no such surface is offered — this is opt-in, because whether
5927
+ * an addon's configuration IS its integration's configuration depends on the
5928
+ * nature of the integration.
5929
+ *
5930
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5931
+ * the ONE global schema, in the ONE addon store, written by the ONE
5932
+ * `updateGlobalSettings` path. There is deliberately no
5933
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5934
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5935
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5936
+ *
5937
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5938
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5939
+ * removed with the reason recorded at
5940
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5941
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5942
+ * marker sprinkled across sections also has to borrow a field that already
5943
+ * means something else; borrowing `section.tab` put the literal word
5944
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5945
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5946
+ * supersedes D268). One declaration, in one place, next to the schema whose
5947
+ * ids it names.
5948
+ */
5949
+ integrationSettingSections() {
5950
+ return [];
5951
+ }
5918
5952
  async getGlobalSettings(overlay, cap, nodeId) {
5919
5953
  const schema = this.globalSettingsSchema(cap);
5920
5954
  if (!schema) return { sections: [] };
@@ -5925,6 +5959,55 @@ var BaseAddon = class {
5925
5959
  } : projected);
5926
5960
  }
5927
5961
  /**
5962
+ * The integration-level view of this addon's settings: exactly the sections
5963
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
5964
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
5965
+ *
5966
+ * Returns `null` when the addon declared nothing — an addon that opts out has
5967
+ * no integration settings surface at all, rather than an empty one that reads
5968
+ * as a failed load.
5969
+ *
5970
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
5971
+ * and not in whichever UI happens to render this:
5972
+ *
5973
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
5974
+ * shown here is the same field, with the same bare key, that the addon's
5975
+ * own page shows. There is no integration-specific writer — callers save
5976
+ * through `updateGlobalSettings` — so a second store key is unreachable,
5977
+ * not merely discouraged.
5978
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
5979
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
5980
+ * such a field silently picked would be a wrong answer for the operator
5981
+ * who opened the page (D266).
5982
+ * 3. **No silent typo.** A declared id that names no section throws. The
5983
+ * alternative — skip it — turns a rename into a surface that quietly
5984
+ * empties, which looks exactly like an addon with nothing to configure.
5985
+ */
5986
+ async getIntegrationSettings(nodeId) {
5987
+ const declared = this.integrationSettingSections();
5988
+ if (declared.length === 0) return null;
5989
+ const schema = this.globalSettingsSchema();
5990
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
5991
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
5992
+ const sections = [];
5993
+ for (const id of declared) {
5994
+ const section = byId.get(id);
5995
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
5996
+ const fields = dropPerNodeFields(section.fields);
5997
+ if (fields.length === 0) continue;
5998
+ sections.push({
5999
+ ...section,
6000
+ fields
6001
+ });
6002
+ }
6003
+ if (sections.length === 0) return null;
6004
+ const projected = await this.resolveGlobalStore(nodeId);
6005
+ return hydrateSchema({
6006
+ ...schema,
6007
+ sections
6008
+ }, projected);
6009
+ }
6010
+ /**
5928
6011
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5929
6012
  * every `perNode: true` field carries THAT node's scoped value on its bare
5930
6013
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6228,6 +6311,41 @@ var BaseAddon = class {
6228
6311
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6229
6312
  * don't declare `perNode` and are excluded by the `in` narrowing.
6230
6313
  */
6314
+ /**
6315
+ * The same fields with every `perNode: true` one removed, recursing into layout
6316
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6317
+ * with no child is dropped rather than rendered empty.
6318
+ *
6319
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6320
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6321
+ */
6322
+ function dropPerNodeFields(fields) {
6323
+ const kept = [];
6324
+ for (const field of fields) {
6325
+ if (field.type === "group") {
6326
+ const inner = dropPerNodeFields(field.fields);
6327
+ if (inner.length > 0) kept.push({
6328
+ ...field,
6329
+ fields: inner
6330
+ });
6331
+ continue;
6332
+ }
6333
+ if (field.type === "sub-tabs") {
6334
+ const tabs = field.tabs.map((tab) => ({
6335
+ ...tab,
6336
+ fields: dropPerNodeFields(tab.fields)
6337
+ })).filter((tab) => tab.fields.length > 0);
6338
+ if (tabs.length > 0) kept.push({
6339
+ ...field,
6340
+ tabs
6341
+ });
6342
+ continue;
6343
+ }
6344
+ if ("perNode" in field && field.perNode === true) continue;
6345
+ kept.push(field);
6346
+ }
6347
+ return kept;
6348
+ }
6231
6349
  function collectPerNodeFieldKeys(fields) {
6232
6350
  const collected = [];
6233
6351
  for (const field of fields) {
@@ -9620,6 +9738,9 @@ method(object({
9620
9738
  kind: "mutation",
9621
9739
  auth: "admin"
9622
9740
  }), method(object({
9741
+ addonId: string(),
9742
+ nodeId: string().optional()
9743
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9623
9744
  addonId: string(),
9624
9745
  deviceId: number(),
9625
9746
  nodeId: string().optional()
@@ -13704,6 +13825,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13704
13825
  limit: number().optional(),
13705
13826
  tags: record(string(), string()).optional()
13706
13827
  }), array(LogEntrySchema).readonly());
13828
+ /**
13829
+ * `failure-contribution` — the capability an addon reports its OWN losses
13830
+ * through, per camera, with the denominator attached. It stores nothing.
13831
+ *
13832
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13833
+ *
13834
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13835
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13836
+ * copied: the contributor reports what it already knows, hub-main adds only
13837
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13838
+ * somebody to forget to edit.
13839
+ *
13840
+ * They are not merged, because their invariants are opposites:
13841
+ *
13842
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13843
+ * claim a camera cost nothing, which is a measurement nobody made;
13844
+ * - a `failure-contribution` zero is the **most valuable value on the
13845
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13846
+ * and it is exactly what an absent entry cannot say.
13847
+ *
13848
+ * Putting a loss counter on a cost entry would also break the reconciliation
13849
+ * that gives `load-contribution` its point: contributions are subtracted from
13850
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13851
+ * has no process.
13852
+ *
13853
+ * ## Why not a log line, since the counters already exist
13854
+ *
13855
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13856
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13857
+ * ends in a log line, and a log line is the thing the operator asked to stop
13858
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13859
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13860
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13861
+ * media blackout were both diagnosed. The counters stay; this is where they can
13862
+ * be READ.
13863
+ *
13864
+ * ## The rate is served with its denominator or not at all
13865
+ *
13866
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13867
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13868
+ * than yesterday" and was **flat across twelve hours** once divided by the
13869
+ * successes on the same path. A surface that publishes only the numerator
13870
+ * reproduces that mistake on every read.
13871
+ *
13872
+ * ## Shape
13873
+ *
13874
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13875
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13876
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13877
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13878
+ * a forked runner's entries reach hub-main over transport that already exists.
13879
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13880
+ * result through `system.getFailureContributions`.
13881
+ */
13882
+ var FailureReasonCountSchema = object({
13883
+ /**
13884
+ * Why the attempt did not land, in the contributor's own vocabulary —
13885
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13886
+ * strings that already appear in this repo's logs and, where one exists, the
13887
+ * same string the per-track `previewMissReason` records (D276): a second
13888
+ * vocabulary for the same loss would make the row and the counter
13889
+ * un-joinable.
13890
+ */
13891
+ reason: string(),
13892
+ count: number().int().nonnegative()
13893
+ });
13894
+ var FailureContributionSchema = object({
13895
+ /**
13896
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13897
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13898
+ * `unit` free: the families are owned by different addons and a shared enum
13899
+ * is a central list that rots invisibly.
13900
+ */
13901
+ family: string(),
13902
+ /**
13903
+ * The NUMERIC device id — the same value every log line carries as
13904
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13905
+ * cannot name the camera must not emit the entry, because a fleet total
13906
+ * cannot answer the only question anybody asks of this surface.
13907
+ */
13908
+ deviceId: number().int().positive(),
13909
+ /**
13910
+ * A second dimension inside the family: the model / step id for an inference
13911
+ * timeout, so "which camera AND which model" is one read. Absent when the
13912
+ * family has a single variant.
13913
+ */
13914
+ variant: string().optional(),
13915
+ /**
13916
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13917
+ * differencing two reads must drop the interval when it changes, because the
13918
+ * counter restarted from zero in a respawned runner. Same discipline as
13919
+ * `LoadContribution.startedAtMs`.
13920
+ */
13921
+ sinceMs: number(),
13922
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13923
+ atMs: number(),
13924
+ /**
13925
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13926
+ * window. A failure count published without it is the mistake this schema
13927
+ * exists to make impossible.
13928
+ */
13929
+ attempts: number().int().nonnegative(),
13930
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13931
+ succeeded: number().int().nonnegative(),
13932
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13933
+ reasons: array(FailureReasonCountSchema).readonly()
13934
+ });
13935
+ method(_void(), array(FailureContributionSchema).readonly());
13707
13936
  var LoadContributionSchema = object({
13708
13937
  role: _enum([
13709
13938
  "decode",
@@ -18324,6 +18553,20 @@ var TrackSchema = object({
18324
18553
  * `=== true` and render nothing otherwise — never infer "no rider".
18325
18554
  */
18326
18555
  hasRider: boolean().optional(),
18556
+ /**
18557
+ * WHY this track ended without a NATIVE best-shot tile
18558
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
18559
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
18560
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
18561
+ * the late-keyFrame upgrade when a native tile lands after all. The
18562
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
18563
+ * tile is a face/plate stand-in, a raster crop, or an icon.
18564
+ *
18565
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
18566
+ * that predates the field, and every track whose tile landed native all
18567
+ * omit it. Render nothing when absent.
18568
+ */
18569
+ previewMissReason: string().optional(),
18327
18570
  ...TrackFlagFields,
18328
18571
  ...TrackRetrainFields
18329
18572
  });
@@ -29588,6 +29831,13 @@ var LoggingSettingsPatchSchema = object({
29588
29831
  * anyone but its owner.
29589
29832
  */
29590
29833
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
29834
+ /**
29835
+ * One per-camera failure counter, plus WHO reported it.
29836
+ *
29837
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
29838
+ * the hub as it enumerates providers, never by the contributor.
29839
+ */
29840
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
29591
29841
  var GetLoggingSettingsInputSchema = object({
29592
29842
  scopeNodeId: string().optional(),
29593
29843
  /**
@@ -29646,7 +29896,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
29646
29896
  }), method(_void(), SiteLocationStatusSchema, {
29647
29897
  kind: "mutation",
29648
29898
  auth: "admin"
29649
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
29899
+ }), 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, {
29650
29900
  kind: "mutation",
29651
29901
  auth: "admin"
29652
29902
  });
@@ -31968,6 +32218,12 @@ Object.freeze({
31968
32218
  addonId: null,
31969
32219
  access: "view"
31970
32220
  },
32221
+ "addonSettings.getIntegrationSettings": {
32222
+ capName: "addon-settings",
32223
+ capScope: "system",
32224
+ addonId: null,
32225
+ access: "view"
32226
+ },
31971
32227
  "addonSettings.updateDeviceSettings": {
31972
32228
  capName: "addon-settings",
31973
32229
  capScope: "system",
@@ -33630,6 +33886,12 @@ Object.freeze({
33630
33886
  addonId: null,
33631
33887
  access: "create"
33632
33888
  },
33889
+ "failureContribution.list": {
33890
+ capName: "failure-contribution",
33891
+ capScope: "system",
33892
+ addonId: null,
33893
+ access: "view"
33894
+ },
33633
33895
  "fanControl.setDirection": {
33634
33896
  capName: "fan-control",
33635
33897
  capScope: "device",
@@ -36936,6 +37198,12 @@ Object.freeze({
36936
37198
  addonId: null,
36937
37199
  access: "create"
36938
37200
  },
37201
+ "system.getFailureContributions": {
37202
+ capName: "system",
37203
+ capScope: "system",
37204
+ addonId: null,
37205
+ access: "view"
37206
+ },
36939
37207
  "system.getLoadContributions": {
36940
37208
  capName: "system",
36941
37209
  capScope: "system",
@@ -5915,6 +5915,40 @@ var BaseAddon = class {
5915
5915
  deviceSettingsSchema() {
5916
5916
  return null;
5917
5917
  }
5918
+ /**
5919
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5920
+ * ARE the configuration of its integration.
5921
+ *
5922
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5923
+ * operator should find on the addon's integration page (System →
5924
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5925
+ * addon. Empty (the default) means the addon has no integration-level
5926
+ * settings and no such surface is offered — this is opt-in, because whether
5927
+ * an addon's configuration IS its integration's configuration depends on the
5928
+ * nature of the integration.
5929
+ *
5930
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5931
+ * the ONE global schema, in the ONE addon store, written by the ONE
5932
+ * `updateGlobalSettings` path. There is deliberately no
5933
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5934
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5935
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5936
+ *
5937
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5938
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5939
+ * removed with the reason recorded at
5940
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5941
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5942
+ * marker sprinkled across sections also has to borrow a field that already
5943
+ * means something else; borrowing `section.tab` put the literal word
5944
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5945
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5946
+ * supersedes D268). One declaration, in one place, next to the schema whose
5947
+ * ids it names.
5948
+ */
5949
+ integrationSettingSections() {
5950
+ return [];
5951
+ }
5918
5952
  async getGlobalSettings(overlay, cap, nodeId) {
5919
5953
  const schema = this.globalSettingsSchema(cap);
5920
5954
  if (!schema) return { sections: [] };
@@ -5925,6 +5959,55 @@ var BaseAddon = class {
5925
5959
  } : projected);
5926
5960
  }
5927
5961
  /**
5962
+ * The integration-level view of this addon's settings: exactly the sections
5963
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
5964
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
5965
+ *
5966
+ * Returns `null` when the addon declared nothing — an addon that opts out has
5967
+ * no integration settings surface at all, rather than an empty one that reads
5968
+ * as a failed load.
5969
+ *
5970
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
5971
+ * and not in whichever UI happens to render this:
5972
+ *
5973
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
5974
+ * shown here is the same field, with the same bare key, that the addon's
5975
+ * own page shows. There is no integration-specific writer — callers save
5976
+ * through `updateGlobalSettings` — so a second store key is unreachable,
5977
+ * not merely discouraged.
5978
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
5979
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
5980
+ * such a field silently picked would be a wrong answer for the operator
5981
+ * who opened the page (D266).
5982
+ * 3. **No silent typo.** A declared id that names no section throws. The
5983
+ * alternative — skip it — turns a rename into a surface that quietly
5984
+ * empties, which looks exactly like an addon with nothing to configure.
5985
+ */
5986
+ async getIntegrationSettings(nodeId) {
5987
+ const declared = this.integrationSettingSections();
5988
+ if (declared.length === 0) return null;
5989
+ const schema = this.globalSettingsSchema();
5990
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
5991
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
5992
+ const sections = [];
5993
+ for (const id of declared) {
5994
+ const section = byId.get(id);
5995
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
5996
+ const fields = dropPerNodeFields(section.fields);
5997
+ if (fields.length === 0) continue;
5998
+ sections.push({
5999
+ ...section,
6000
+ fields
6001
+ });
6002
+ }
6003
+ if (sections.length === 0) return null;
6004
+ const projected = await this.resolveGlobalStore(nodeId);
6005
+ return hydrateSchema({
6006
+ ...schema,
6007
+ sections
6008
+ }, projected);
6009
+ }
6010
+ /**
5928
6011
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5929
6012
  * every `perNode: true` field carries THAT node's scoped value on its bare
5930
6013
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6228,6 +6311,41 @@ var BaseAddon = class {
6228
6311
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6229
6312
  * don't declare `perNode` and are excluded by the `in` narrowing.
6230
6313
  */
6314
+ /**
6315
+ * The same fields with every `perNode: true` one removed, recursing into layout
6316
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6317
+ * with no child is dropped rather than rendered empty.
6318
+ *
6319
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6320
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6321
+ */
6322
+ function dropPerNodeFields(fields) {
6323
+ const kept = [];
6324
+ for (const field of fields) {
6325
+ if (field.type === "group") {
6326
+ const inner = dropPerNodeFields(field.fields);
6327
+ if (inner.length > 0) kept.push({
6328
+ ...field,
6329
+ fields: inner
6330
+ });
6331
+ continue;
6332
+ }
6333
+ if (field.type === "sub-tabs") {
6334
+ const tabs = field.tabs.map((tab) => ({
6335
+ ...tab,
6336
+ fields: dropPerNodeFields(tab.fields)
6337
+ })).filter((tab) => tab.fields.length > 0);
6338
+ if (tabs.length > 0) kept.push({
6339
+ ...field,
6340
+ tabs
6341
+ });
6342
+ continue;
6343
+ }
6344
+ if ("perNode" in field && field.perNode === true) continue;
6345
+ kept.push(field);
6346
+ }
6347
+ return kept;
6348
+ }
6231
6349
  function collectPerNodeFieldKeys(fields) {
6232
6350
  const collected = [];
6233
6351
  for (const field of fields) {
@@ -9620,6 +9738,9 @@ method(object({
9620
9738
  kind: "mutation",
9621
9739
  auth: "admin"
9622
9740
  }), method(object({
9741
+ addonId: string(),
9742
+ nodeId: string().optional()
9743
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9623
9744
  addonId: string(),
9624
9745
  deviceId: number(),
9625
9746
  nodeId: string().optional()
@@ -13704,6 +13825,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13704
13825
  limit: number().optional(),
13705
13826
  tags: record(string(), string()).optional()
13706
13827
  }), array(LogEntrySchema).readonly());
13828
+ /**
13829
+ * `failure-contribution` — the capability an addon reports its OWN losses
13830
+ * through, per camera, with the denominator attached. It stores nothing.
13831
+ *
13832
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13833
+ *
13834
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13835
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13836
+ * copied: the contributor reports what it already knows, hub-main adds only
13837
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13838
+ * somebody to forget to edit.
13839
+ *
13840
+ * They are not merged, because their invariants are opposites:
13841
+ *
13842
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13843
+ * claim a camera cost nothing, which is a measurement nobody made;
13844
+ * - a `failure-contribution` zero is the **most valuable value on the
13845
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13846
+ * and it is exactly what an absent entry cannot say.
13847
+ *
13848
+ * Putting a loss counter on a cost entry would also break the reconciliation
13849
+ * that gives `load-contribution` its point: contributions are subtracted from
13850
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13851
+ * has no process.
13852
+ *
13853
+ * ## Why not a log line, since the counters already exist
13854
+ *
13855
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13856
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13857
+ * ends in a log line, and a log line is the thing the operator asked to stop
13858
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13859
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13860
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13861
+ * media blackout were both diagnosed. The counters stay; this is where they can
13862
+ * be READ.
13863
+ *
13864
+ * ## The rate is served with its denominator or not at all
13865
+ *
13866
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13867
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13868
+ * than yesterday" and was **flat across twelve hours** once divided by the
13869
+ * successes on the same path. A surface that publishes only the numerator
13870
+ * reproduces that mistake on every read.
13871
+ *
13872
+ * ## Shape
13873
+ *
13874
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13875
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13876
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13877
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13878
+ * a forked runner's entries reach hub-main over transport that already exists.
13879
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13880
+ * result through `system.getFailureContributions`.
13881
+ */
13882
+ var FailureReasonCountSchema = object({
13883
+ /**
13884
+ * Why the attempt did not land, in the contributor's own vocabulary —
13885
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13886
+ * strings that already appear in this repo's logs and, where one exists, the
13887
+ * same string the per-track `previewMissReason` records (D276): a second
13888
+ * vocabulary for the same loss would make the row and the counter
13889
+ * un-joinable.
13890
+ */
13891
+ reason: string(),
13892
+ count: number().int().nonnegative()
13893
+ });
13894
+ var FailureContributionSchema = object({
13895
+ /**
13896
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13897
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13898
+ * `unit` free: the families are owned by different addons and a shared enum
13899
+ * is a central list that rots invisibly.
13900
+ */
13901
+ family: string(),
13902
+ /**
13903
+ * The NUMERIC device id — the same value every log line carries as
13904
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13905
+ * cannot name the camera must not emit the entry, because a fleet total
13906
+ * cannot answer the only question anybody asks of this surface.
13907
+ */
13908
+ deviceId: number().int().positive(),
13909
+ /**
13910
+ * A second dimension inside the family: the model / step id for an inference
13911
+ * timeout, so "which camera AND which model" is one read. Absent when the
13912
+ * family has a single variant.
13913
+ */
13914
+ variant: string().optional(),
13915
+ /**
13916
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13917
+ * differencing two reads must drop the interval when it changes, because the
13918
+ * counter restarted from zero in a respawned runner. Same discipline as
13919
+ * `LoadContribution.startedAtMs`.
13920
+ */
13921
+ sinceMs: number(),
13922
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13923
+ atMs: number(),
13924
+ /**
13925
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13926
+ * window. A failure count published without it is the mistake this schema
13927
+ * exists to make impossible.
13928
+ */
13929
+ attempts: number().int().nonnegative(),
13930
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13931
+ succeeded: number().int().nonnegative(),
13932
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13933
+ reasons: array(FailureReasonCountSchema).readonly()
13934
+ });
13935
+ method(_void(), array(FailureContributionSchema).readonly());
13707
13936
  var LoadContributionSchema = object({
13708
13937
  role: _enum([
13709
13938
  "decode",
@@ -18324,6 +18553,20 @@ var TrackSchema = object({
18324
18553
  * `=== true` and render nothing otherwise — never infer "no rider".
18325
18554
  */
18326
18555
  hasRider: boolean().optional(),
18556
+ /**
18557
+ * WHY this track ended without a NATIVE best-shot tile
18558
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
18559
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
18560
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
18561
+ * the late-keyFrame upgrade when a native tile lands after all. The
18562
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
18563
+ * tile is a face/plate stand-in, a raster crop, or an icon.
18564
+ *
18565
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
18566
+ * that predates the field, and every track whose tile landed native all
18567
+ * omit it. Render nothing when absent.
18568
+ */
18569
+ previewMissReason: string().optional(),
18327
18570
  ...TrackFlagFields,
18328
18571
  ...TrackRetrainFields
18329
18572
  });
@@ -29588,6 +29831,13 @@ var LoggingSettingsPatchSchema = object({
29588
29831
  * anyone but its owner.
29589
29832
  */
29590
29833
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
29834
+ /**
29835
+ * One per-camera failure counter, plus WHO reported it.
29836
+ *
29837
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
29838
+ * the hub as it enumerates providers, never by the contributor.
29839
+ */
29840
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
29591
29841
  var GetLoggingSettingsInputSchema = object({
29592
29842
  scopeNodeId: string().optional(),
29593
29843
  /**
@@ -29646,7 +29896,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
29646
29896
  }), method(_void(), SiteLocationStatusSchema, {
29647
29897
  kind: "mutation",
29648
29898
  auth: "admin"
29649
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
29899
+ }), 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, {
29650
29900
  kind: "mutation",
29651
29901
  auth: "admin"
29652
29902
  });
@@ -31968,6 +32218,12 @@ Object.freeze({
31968
32218
  addonId: null,
31969
32219
  access: "view"
31970
32220
  },
32221
+ "addonSettings.getIntegrationSettings": {
32222
+ capName: "addon-settings",
32223
+ capScope: "system",
32224
+ addonId: null,
32225
+ access: "view"
32226
+ },
31971
32227
  "addonSettings.updateDeviceSettings": {
31972
32228
  capName: "addon-settings",
31973
32229
  capScope: "system",
@@ -33630,6 +33886,12 @@ Object.freeze({
33630
33886
  addonId: null,
33631
33887
  access: "create"
33632
33888
  },
33889
+ "failureContribution.list": {
33890
+ capName: "failure-contribution",
33891
+ capScope: "system",
33892
+ addonId: null,
33893
+ access: "view"
33894
+ },
33633
33895
  "fanControl.setDirection": {
33634
33896
  capName: "fan-control",
33635
33897
  capScope: "device",
@@ -36936,6 +37198,12 @@ Object.freeze({
36936
37198
  addonId: null,
36937
37199
  access: "create"
36938
37200
  },
37201
+ "system.getFailureContributions": {
37202
+ capName: "system",
37203
+ capScope: "system",
37204
+ addonId: null,
37205
+ access: "view"
37206
+ },
36939
37207
  "system.getLoadContributions": {
36940
37208
  capName: "system",
36941
37209
  capScope: "system",
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  //#endregion
6
- const require_dist = require("../dist-C0k9HqhA.js");
6
+ const require_dist = require("../dist-nBclHVR_.js");
7
7
  let node_crypto = require("node:crypto");
8
8
  //#region src/ha-export/topics.ts
9
9
  /**
@@ -1,4 +1,4 @@
1
- import { At as EventCategory, C as buildAddonRouteProvider, Et as string, N as deviceExportCapability, X as oauthIntegrationCapability, a as COCO_TO_MACRO, c as FanDirectionSchema, i as CAMERA_SWITCH_ORDER, l as HvacModeSchema, o as CameraSwitchIdSchema, p as addonRoutesCapability, pt as BaseAddon, t as AlarmArmModeSchema, u as MediaPlayerRepeatSchema, vt as nodePin } from "../dist-D-btrtuv.mjs";
1
+ import { At as EventCategory, C as buildAddonRouteProvider, Et as string, N as deviceExportCapability, X as oauthIntegrationCapability, a as COCO_TO_MACRO, c as FanDirectionSchema, i as CAMERA_SWITCH_ORDER, l as HvacModeSchema, o as CameraSwitchIdSchema, p as addonRoutesCapability, pt as BaseAddon, t as AlarmArmModeSchema, u as MediaPlayerRepeatSchema, vt as nodePin } from "../dist-Dm7hAzfd.mjs";
2
2
  import { createHmac, timingSafeEqual } from "node:crypto";
3
3
  //#region src/ha-export/topics.ts
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-homeassistant",
3
- "version": "1.2.50",
3
+ "version": "1.2.52",
4
4
  "description": "Home Assistant device provider addon for CamStack",
5
5
  "keywords": [
6
6
  "camstack",