@camstack/addon-provider-reolink 1.2.59 → 1.2.61

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
@@ -5943,6 +5943,40 @@ var BaseAddon = class {
5943
5943
  deviceSettingsSchema() {
5944
5944
  return null;
5945
5945
  }
5946
+ /**
5947
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5948
+ * ARE the configuration of its integration.
5949
+ *
5950
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5951
+ * operator should find on the addon's integration page (System →
5952
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5953
+ * addon. Empty (the default) means the addon has no integration-level
5954
+ * settings and no such surface is offered — this is opt-in, because whether
5955
+ * an addon's configuration IS its integration's configuration depends on the
5956
+ * nature of the integration.
5957
+ *
5958
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5959
+ * the ONE global schema, in the ONE addon store, written by the ONE
5960
+ * `updateGlobalSettings` path. There is deliberately no
5961
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5962
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5963
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5964
+ *
5965
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5966
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5967
+ * removed with the reason recorded at
5968
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5969
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5970
+ * marker sprinkled across sections also has to borrow a field that already
5971
+ * means something else; borrowing `section.tab` put the literal word
5972
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5973
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5974
+ * supersedes D268). One declaration, in one place, next to the schema whose
5975
+ * ids it names.
5976
+ */
5977
+ integrationSettingSections() {
5978
+ return [];
5979
+ }
5946
5980
  async getGlobalSettings(overlay, cap, nodeId) {
5947
5981
  const schema = this.globalSettingsSchema(cap);
5948
5982
  if (!schema) return { sections: [] };
@@ -5953,6 +5987,55 @@ var BaseAddon = class {
5953
5987
  } : projected);
5954
5988
  }
5955
5989
  /**
5990
+ * The integration-level view of this addon's settings: exactly the sections
5991
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
5992
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
5993
+ *
5994
+ * Returns `null` when the addon declared nothing — an addon that opts out has
5995
+ * no integration settings surface at all, rather than an empty one that reads
5996
+ * as a failed load.
5997
+ *
5998
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
5999
+ * and not in whichever UI happens to render this:
6000
+ *
6001
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
6002
+ * shown here is the same field, with the same bare key, that the addon's
6003
+ * own page shows. There is no integration-specific writer — callers save
6004
+ * through `updateGlobalSettings` — so a second store key is unreachable,
6005
+ * not merely discouraged.
6006
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
6007
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
6008
+ * such a field silently picked would be a wrong answer for the operator
6009
+ * who opened the page (D266).
6010
+ * 3. **No silent typo.** A declared id that names no section throws. The
6011
+ * alternative — skip it — turns a rename into a surface that quietly
6012
+ * empties, which looks exactly like an addon with nothing to configure.
6013
+ */
6014
+ async getIntegrationSettings(nodeId) {
6015
+ const declared = this.integrationSettingSections();
6016
+ if (declared.length === 0) return null;
6017
+ const schema = this.globalSettingsSchema();
6018
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
6019
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
6020
+ const sections = [];
6021
+ for (const id of declared) {
6022
+ const section = byId.get(id);
6023
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6024
+ const fields = dropPerNodeFields(section.fields);
6025
+ if (fields.length === 0) continue;
6026
+ sections.push({
6027
+ ...section,
6028
+ fields
6029
+ });
6030
+ }
6031
+ if (sections.length === 0) return null;
6032
+ const projected = await this.resolveGlobalStore(nodeId);
6033
+ return hydrateSchema({
6034
+ ...schema,
6035
+ sections
6036
+ }, projected);
6037
+ }
6038
+ /**
5956
6039
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5957
6040
  * every `perNode: true` field carries THAT node's scoped value on its bare
5958
6041
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6256,6 +6339,41 @@ var BaseAddon = class {
6256
6339
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6257
6340
  * don't declare `perNode` and are excluded by the `in` narrowing.
6258
6341
  */
6342
+ /**
6343
+ * The same fields with every `perNode: true` one removed, recursing into layout
6344
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6345
+ * with no child is dropped rather than rendered empty.
6346
+ *
6347
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6348
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6349
+ */
6350
+ function dropPerNodeFields(fields) {
6351
+ const kept = [];
6352
+ for (const field of fields) {
6353
+ if (field.type === "group") {
6354
+ const inner = dropPerNodeFields(field.fields);
6355
+ if (inner.length > 0) kept.push({
6356
+ ...field,
6357
+ fields: inner
6358
+ });
6359
+ continue;
6360
+ }
6361
+ if (field.type === "sub-tabs") {
6362
+ const tabs = field.tabs.map((tab) => ({
6363
+ ...tab,
6364
+ fields: dropPerNodeFields(tab.fields)
6365
+ })).filter((tab) => tab.fields.length > 0);
6366
+ if (tabs.length > 0) kept.push({
6367
+ ...field,
6368
+ tabs
6369
+ });
6370
+ continue;
6371
+ }
6372
+ if ("perNode" in field && field.perNode === true) continue;
6373
+ kept.push(field);
6374
+ }
6375
+ return kept;
6376
+ }
6259
6377
  function collectPerNodeFieldKeys(fields) {
6260
6378
  const collected = [];
6261
6379
  for (const field of fields) {
@@ -9863,6 +9981,9 @@ method(object({
9863
9981
  kind: "mutation",
9864
9982
  auth: "admin"
9865
9983
  }), method(object({
9984
+ addonId: string(),
9985
+ nodeId: string().optional()
9986
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9866
9987
  addonId: string(),
9867
9988
  deviceId: number(),
9868
9989
  nodeId: string().optional()
@@ -13844,6 +13965,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13844
13965
  limit: number().optional(),
13845
13966
  tags: record(string(), string()).optional()
13846
13967
  }), array(LogEntrySchema).readonly());
13968
+ /**
13969
+ * `failure-contribution` — the capability an addon reports its OWN losses
13970
+ * through, per camera, with the denominator attached. It stores nothing.
13971
+ *
13972
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13973
+ *
13974
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13975
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13976
+ * copied: the contributor reports what it already knows, hub-main adds only
13977
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13978
+ * somebody to forget to edit.
13979
+ *
13980
+ * They are not merged, because their invariants are opposites:
13981
+ *
13982
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13983
+ * claim a camera cost nothing, which is a measurement nobody made;
13984
+ * - a `failure-contribution` zero is the **most valuable value on the
13985
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13986
+ * and it is exactly what an absent entry cannot say.
13987
+ *
13988
+ * Putting a loss counter on a cost entry would also break the reconciliation
13989
+ * that gives `load-contribution` its point: contributions are subtracted from
13990
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13991
+ * has no process.
13992
+ *
13993
+ * ## Why not a log line, since the counters already exist
13994
+ *
13995
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13996
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13997
+ * ends in a log line, and a log line is the thing the operator asked to stop
13998
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13999
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
14000
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
14001
+ * media blackout were both diagnosed. The counters stay; this is where they can
14002
+ * be READ.
14003
+ *
14004
+ * ## The rate is served with its denominator or not at all
14005
+ *
14006
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
14007
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
14008
+ * than yesterday" and was **flat across twelve hours** once divided by the
14009
+ * successes on the same path. A surface that publishes only the numerator
14010
+ * reproduces that mistake on every read.
14011
+ *
14012
+ * ## Shape
14013
+ *
14014
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
14015
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
14016
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
14017
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
14018
+ * a forked runner's entries reach hub-main over transport that already exists.
14019
+ * No new UDS message, no second registry (D3). The operator reads the assembled
14020
+ * result through `system.getFailureContributions`.
14021
+ */
14022
+ var FailureReasonCountSchema = object({
14023
+ /**
14024
+ * Why the attempt did not land, in the contributor's own vocabulary —
14025
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
14026
+ * strings that already appear in this repo's logs and, where one exists, the
14027
+ * same string the per-track `previewMissReason` records (D276): a second
14028
+ * vocabulary for the same loss would make the row and the counter
14029
+ * un-joinable.
14030
+ */
14031
+ reason: string(),
14032
+ count: number().int().nonnegative()
14033
+ });
14034
+ var FailureContributionSchema = object({
14035
+ /**
14036
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
14037
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
14038
+ * `unit` free: the families are owned by different addons and a shared enum
14039
+ * is a central list that rots invisibly.
14040
+ */
14041
+ family: string(),
14042
+ /**
14043
+ * The NUMERIC device id — the same value every log line carries as
14044
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
14045
+ * cannot name the camera must not emit the entry, because a fleet total
14046
+ * cannot answer the only question anybody asks of this surface.
14047
+ */
14048
+ deviceId: number().int().positive(),
14049
+ /**
14050
+ * A second dimension inside the family: the model / step id for an inference
14051
+ * timeout, so "which camera AND which model" is one read. Absent when the
14052
+ * family has a single variant.
14053
+ */
14054
+ variant: string().optional(),
14055
+ /**
14056
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
14057
+ * differencing two reads must drop the interval when it changes, because the
14058
+ * counter restarted from zero in a respawned runner. Same discipline as
14059
+ * `LoadContribution.startedAtMs`.
14060
+ */
14061
+ sinceMs: number(),
14062
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
14063
+ atMs: number(),
14064
+ /**
14065
+ * THE DENOMINATOR — every attempt on this path for this camera in the
14066
+ * window. A failure count published without it is the mistake this schema
14067
+ * exists to make impossible.
14068
+ */
14069
+ attempts: number().int().nonnegative(),
14070
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
14071
+ succeeded: number().int().nonnegative(),
14072
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
14073
+ reasons: array(FailureReasonCountSchema).readonly()
14074
+ });
14075
+ method(_void(), array(FailureContributionSchema).readonly());
13847
14076
  var LoadContributionSchema = object({
13848
14077
  role: _enum([
13849
14078
  "decode",
@@ -18434,6 +18663,20 @@ var TrackSchema = object({
18434
18663
  * `=== true` and render nothing otherwise — never infer "no rider".
18435
18664
  */
18436
18665
  hasRider: boolean().optional(),
18666
+ /**
18667
+ * WHY this track ended without a NATIVE best-shot tile
18668
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
18669
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
18670
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
18671
+ * the late-keyFrame upgrade when a native tile lands after all. The
18672
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
18673
+ * tile is a face/plate stand-in, a raster crop, or an icon.
18674
+ *
18675
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
18676
+ * that predates the field, and every track whose tile landed native all
18677
+ * omit it. Render nothing when absent.
18678
+ */
18679
+ previewMissReason: string().optional(),
18437
18680
  ...TrackFlagFields,
18438
18681
  ...TrackRetrainFields
18439
18682
  });
@@ -29998,6 +30241,13 @@ var LoggingSettingsPatchSchema = object({
29998
30241
  * anyone but its owner.
29999
30242
  */
30000
30243
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
30244
+ /**
30245
+ * One per-camera failure counter, plus WHO reported it.
30246
+ *
30247
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
30248
+ * the hub as it enumerates providers, never by the contributor.
30249
+ */
30250
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
30001
30251
  var GetLoggingSettingsInputSchema = object({
30002
30252
  scopeNodeId: string().optional(),
30003
30253
  /**
@@ -30056,7 +30306,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
30056
30306
  }), method(_void(), SiteLocationStatusSchema, {
30057
30307
  kind: "mutation",
30058
30308
  auth: "admin"
30059
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
30309
+ }), 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, {
30060
30310
  kind: "mutation",
30061
30311
  auth: "admin"
30062
30312
  });
@@ -32545,6 +32795,12 @@ Object.freeze({
32545
32795
  addonId: null,
32546
32796
  access: "view"
32547
32797
  },
32798
+ "addonSettings.getIntegrationSettings": {
32799
+ capName: "addon-settings",
32800
+ capScope: "system",
32801
+ addonId: null,
32802
+ access: "view"
32803
+ },
32548
32804
  "addonSettings.updateDeviceSettings": {
32549
32805
  capName: "addon-settings",
32550
32806
  capScope: "system",
@@ -34207,6 +34463,12 @@ Object.freeze({
34207
34463
  addonId: null,
34208
34464
  access: "create"
34209
34465
  },
34466
+ "failureContribution.list": {
34467
+ capName: "failure-contribution",
34468
+ capScope: "system",
34469
+ addonId: null,
34470
+ access: "view"
34471
+ },
34210
34472
  "fanControl.setDirection": {
34211
34473
  capName: "fan-control",
34212
34474
  capScope: "device",
@@ -37513,6 +37775,12 @@ Object.freeze({
37513
37775
  addonId: null,
37514
37776
  access: "create"
37515
37777
  },
37778
+ "system.getFailureContributions": {
37779
+ capName: "system",
37780
+ capScope: "system",
37781
+ addonId: null,
37782
+ access: "view"
37783
+ },
37516
37784
  "system.getLoadContributions": {
37517
37785
  capName: "system",
37518
37786
  capScope: "system",
@@ -240899,6 +241167,12 @@ var ReolinkEmailPushServer = class {
240899
241167
  //#endregion
240900
241168
  //#region src/email-push-schema.ts
240901
241169
  /**
241170
+ * The ids of the sections above, in render order — the value the addon hands
241171
+ * to `BaseAddon.integrationSettingSections()`. Exported so the declaration and
241172
+ * the schema cannot drift: core throws if an id here names no section.
241173
+ */
241174
+ var EMAIL_PUSH_SECTION_IDS = ["email-push", "email-push-auth"];
241175
+ /**
240902
241176
  * Addon-level settings UI for the Reolink email/SMTP push intake.
240903
241177
  *
240904
241178
  * Rendered under the provider's addon settings (Cluster → addon config).
@@ -240910,6 +241184,28 @@ var ReolinkEmailPushServer = class {
240910
241184
  * `requiresRestart` is intentionally NOT set — the provider handles the
240911
241185
  * restart itself in `onConfigChanged` (a targeted SMTP rebind, not a full
240912
241186
  * addon teardown).
241187
+ *
241188
+ * ── These sections ARE the Reolink integration's configuration ──────────
241189
+ *
241190
+ * Both are declared in `ReolinkAddon.integrationSettingSections()`, so core
241191
+ * serves them on System → Integrations → Reolink. The operator looks for "the
241192
+ * Reolink SMTP port" under Reolink; this puts it there.
241193
+ *
241194
+ * They EARN that placement, and the reason is the test any future declaration
241195
+ * must pass: they configure ONE SMTP server in ONE provider process, serving
241196
+ * every Reolink camera at once. There is no per-camera copy to confuse them
241197
+ * with, which is exactly why a per-camera home would be nonsense and a
241198
+ * per-integration home is correct. A setting that differs per camera belongs
241199
+ * in `deviceSettingsSchema`, never here.
241200
+ *
241201
+ * The declaration does not move the values: they remain the same bare keys in
241202
+ * the same addon store, still reachable from System → Settings, still written
241203
+ * by `updateGlobalSettings` — there is no integration-specific writer at all.
241204
+ * See ADR-0269.
241205
+ *
241206
+ * `tab` is deliberately NOT used to express this. It means "how to group this
241207
+ * visually", and an earlier design that overloaded it put the literal word
241208
+ * "integration" into an operator-facing tab bar (D268 → D269).
240913
241209
  */
240914
241210
  function buildEmailPushSettingsSchema(recommendedHost) {
240915
241211
  return { sections: [{
@@ -241278,9 +241574,30 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
241278
241574
  this.ctx.logger.warn("email-push: restart after settings change failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
241279
241575
  });
241280
241576
  }
241281
- async getGlobalSettings() {
241282
- const raw = await this.resolveGlobalStore();
241283
- return hydrateSchema(buildEmailPushSettingsSchema(listLanHosts()[0] ?? "127.0.0.1"), raw);
241577
+ /**
241578
+ * The addon's global settings schema.
241579
+ *
241580
+ * This used to override `getGlobalSettings()` wholesale, on the belief that a
241581
+ * dynamic `recommendedHost` could not come from a static schema declaration.
241582
+ * It can: `listLanHosts()` is synchronous, so the schema builder runs here
241583
+ * and `BaseAddon.getGlobalSettings` does the identical
241584
+ * `resolveGlobalStore` + `hydrateSchema` the override did by hand.
241585
+ *
241586
+ * Declaring the SCHEMA rather than overriding the GETTER is what lets core
241587
+ * serve `getIntegrationSettings()` — it selects the declared sections out of
241588
+ * this schema, so an addon that hides its schema behind a getter has nothing
241589
+ * for core to select from.
241590
+ */
241591
+ globalSettingsSchema() {
241592
+ return buildEmailPushSettingsSchema(listLanHosts()[0] ?? "127.0.0.1");
241593
+ }
241594
+ /**
241595
+ * Both email-push sections ARE this integration's configuration — one SMTP
241596
+ * server serving every Reolink camera. See `email-push-schema.ts` for why
241597
+ * that earns a per-integration home and not a per-camera one.
241598
+ */
241599
+ integrationSettingSections() {
241600
+ return EMAIL_PUSH_SECTION_IDS;
241284
241601
  }
241285
241602
  async onInitialize() {
241286
241603
  const regs = await super.onInitialize();
package/dist/addon.mjs CHANGED
@@ -5938,6 +5938,40 @@ var BaseAddon = class {
5938
5938
  deviceSettingsSchema() {
5939
5939
  return null;
5940
5940
  }
5941
+ /**
5942
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5943
+ * ARE the configuration of its integration.
5944
+ *
5945
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5946
+ * operator should find on the addon's integration page (System →
5947
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5948
+ * addon. Empty (the default) means the addon has no integration-level
5949
+ * settings and no such surface is offered — this is opt-in, because whether
5950
+ * an addon's configuration IS its integration's configuration depends on the
5951
+ * nature of the integration.
5952
+ *
5953
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5954
+ * the ONE global schema, in the ONE addon store, written by the ONE
5955
+ * `updateGlobalSettings` path. There is deliberately no
5956
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5957
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5958
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5959
+ *
5960
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5961
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5962
+ * removed with the reason recorded at
5963
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5964
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5965
+ * marker sprinkled across sections also has to borrow a field that already
5966
+ * means something else; borrowing `section.tab` put the literal word
5967
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5968
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5969
+ * supersedes D268). One declaration, in one place, next to the schema whose
5970
+ * ids it names.
5971
+ */
5972
+ integrationSettingSections() {
5973
+ return [];
5974
+ }
5941
5975
  async getGlobalSettings(overlay, cap, nodeId) {
5942
5976
  const schema = this.globalSettingsSchema(cap);
5943
5977
  if (!schema) return { sections: [] };
@@ -5948,6 +5982,55 @@ var BaseAddon = class {
5948
5982
  } : projected);
5949
5983
  }
5950
5984
  /**
5985
+ * The integration-level view of this addon's settings: exactly the sections
5986
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
5987
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
5988
+ *
5989
+ * Returns `null` when the addon declared nothing — an addon that opts out has
5990
+ * no integration settings surface at all, rather than an empty one that reads
5991
+ * as a failed load.
5992
+ *
5993
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
5994
+ * and not in whichever UI happens to render this:
5995
+ *
5996
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
5997
+ * shown here is the same field, with the same bare key, that the addon's
5998
+ * own page shows. There is no integration-specific writer — callers save
5999
+ * through `updateGlobalSettings` — so a second store key is unreachable,
6000
+ * not merely discouraged.
6001
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
6002
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
6003
+ * such a field silently picked would be a wrong answer for the operator
6004
+ * who opened the page (D266).
6005
+ * 3. **No silent typo.** A declared id that names no section throws. The
6006
+ * alternative — skip it — turns a rename into a surface that quietly
6007
+ * empties, which looks exactly like an addon with nothing to configure.
6008
+ */
6009
+ async getIntegrationSettings(nodeId) {
6010
+ const declared = this.integrationSettingSections();
6011
+ if (declared.length === 0) return null;
6012
+ const schema = this.globalSettingsSchema();
6013
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
6014
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
6015
+ const sections = [];
6016
+ for (const id of declared) {
6017
+ const section = byId.get(id);
6018
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6019
+ const fields = dropPerNodeFields(section.fields);
6020
+ if (fields.length === 0) continue;
6021
+ sections.push({
6022
+ ...section,
6023
+ fields
6024
+ });
6025
+ }
6026
+ if (sections.length === 0) return null;
6027
+ const projected = await this.resolveGlobalStore(nodeId);
6028
+ return hydrateSchema({
6029
+ ...schema,
6030
+ sections
6031
+ }, projected);
6032
+ }
6033
+ /**
5951
6034
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5952
6035
  * every `perNode: true` field carries THAT node's scoped value on its bare
5953
6036
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6251,6 +6334,41 @@ var BaseAddon = class {
6251
6334
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6252
6335
  * don't declare `perNode` and are excluded by the `in` narrowing.
6253
6336
  */
6337
+ /**
6338
+ * The same fields with every `perNode: true` one removed, recursing into layout
6339
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6340
+ * with no child is dropped rather than rendered empty.
6341
+ *
6342
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6343
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6344
+ */
6345
+ function dropPerNodeFields(fields) {
6346
+ const kept = [];
6347
+ for (const field of fields) {
6348
+ if (field.type === "group") {
6349
+ const inner = dropPerNodeFields(field.fields);
6350
+ if (inner.length > 0) kept.push({
6351
+ ...field,
6352
+ fields: inner
6353
+ });
6354
+ continue;
6355
+ }
6356
+ if (field.type === "sub-tabs") {
6357
+ const tabs = field.tabs.map((tab) => ({
6358
+ ...tab,
6359
+ fields: dropPerNodeFields(tab.fields)
6360
+ })).filter((tab) => tab.fields.length > 0);
6361
+ if (tabs.length > 0) kept.push({
6362
+ ...field,
6363
+ tabs
6364
+ });
6365
+ continue;
6366
+ }
6367
+ if ("perNode" in field && field.perNode === true) continue;
6368
+ kept.push(field);
6369
+ }
6370
+ return kept;
6371
+ }
6254
6372
  function collectPerNodeFieldKeys(fields) {
6255
6373
  const collected = [];
6256
6374
  for (const field of fields) {
@@ -9858,6 +9976,9 @@ method(object({
9858
9976
  kind: "mutation",
9859
9977
  auth: "admin"
9860
9978
  }), method(object({
9979
+ addonId: string(),
9980
+ nodeId: string().optional()
9981
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9861
9982
  addonId: string(),
9862
9983
  deviceId: number(),
9863
9984
  nodeId: string().optional()
@@ -13839,6 +13960,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13839
13960
  limit: number().optional(),
13840
13961
  tags: record(string(), string()).optional()
13841
13962
  }), array(LogEntrySchema).readonly());
13963
+ /**
13964
+ * `failure-contribution` — the capability an addon reports its OWN losses
13965
+ * through, per camera, with the denominator attached. It stores nothing.
13966
+ *
13967
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13968
+ *
13969
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13970
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13971
+ * copied: the contributor reports what it already knows, hub-main adds only
13972
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13973
+ * somebody to forget to edit.
13974
+ *
13975
+ * They are not merged, because their invariants are opposites:
13976
+ *
13977
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13978
+ * claim a camera cost nothing, which is a measurement nobody made;
13979
+ * - a `failure-contribution` zero is the **most valuable value on the
13980
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13981
+ * and it is exactly what an absent entry cannot say.
13982
+ *
13983
+ * Putting a loss counter on a cost entry would also break the reconciliation
13984
+ * that gives `load-contribution` its point: contributions are subtracted from
13985
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13986
+ * has no process.
13987
+ *
13988
+ * ## Why not a log line, since the counters already exist
13989
+ *
13990
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13991
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13992
+ * ends in a log line, and a log line is the thing the operator asked to stop
13993
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13994
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13995
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13996
+ * media blackout were both diagnosed. The counters stay; this is where they can
13997
+ * be READ.
13998
+ *
13999
+ * ## The rate is served with its denominator or not at all
14000
+ *
14001
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
14002
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
14003
+ * than yesterday" and was **flat across twelve hours** once divided by the
14004
+ * successes on the same path. A surface that publishes only the numerator
14005
+ * reproduces that mistake on every read.
14006
+ *
14007
+ * ## Shape
14008
+ *
14009
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
14010
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
14011
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
14012
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
14013
+ * a forked runner's entries reach hub-main over transport that already exists.
14014
+ * No new UDS message, no second registry (D3). The operator reads the assembled
14015
+ * result through `system.getFailureContributions`.
14016
+ */
14017
+ var FailureReasonCountSchema = object({
14018
+ /**
14019
+ * Why the attempt did not land, in the contributor's own vocabulary —
14020
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
14021
+ * strings that already appear in this repo's logs and, where one exists, the
14022
+ * same string the per-track `previewMissReason` records (D276): a second
14023
+ * vocabulary for the same loss would make the row and the counter
14024
+ * un-joinable.
14025
+ */
14026
+ reason: string(),
14027
+ count: number().int().nonnegative()
14028
+ });
14029
+ var FailureContributionSchema = object({
14030
+ /**
14031
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
14032
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
14033
+ * `unit` free: the families are owned by different addons and a shared enum
14034
+ * is a central list that rots invisibly.
14035
+ */
14036
+ family: string(),
14037
+ /**
14038
+ * The NUMERIC device id — the same value every log line carries as
14039
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
14040
+ * cannot name the camera must not emit the entry, because a fleet total
14041
+ * cannot answer the only question anybody asks of this surface.
14042
+ */
14043
+ deviceId: number().int().positive(),
14044
+ /**
14045
+ * A second dimension inside the family: the model / step id for an inference
14046
+ * timeout, so "which camera AND which model" is one read. Absent when the
14047
+ * family has a single variant.
14048
+ */
14049
+ variant: string().optional(),
14050
+ /**
14051
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
14052
+ * differencing two reads must drop the interval when it changes, because the
14053
+ * counter restarted from zero in a respawned runner. Same discipline as
14054
+ * `LoadContribution.startedAtMs`.
14055
+ */
14056
+ sinceMs: number(),
14057
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
14058
+ atMs: number(),
14059
+ /**
14060
+ * THE DENOMINATOR — every attempt on this path for this camera in the
14061
+ * window. A failure count published without it is the mistake this schema
14062
+ * exists to make impossible.
14063
+ */
14064
+ attempts: number().int().nonnegative(),
14065
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
14066
+ succeeded: number().int().nonnegative(),
14067
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
14068
+ reasons: array(FailureReasonCountSchema).readonly()
14069
+ });
14070
+ method(_void(), array(FailureContributionSchema).readonly());
13842
14071
  var LoadContributionSchema = object({
13843
14072
  role: _enum([
13844
14073
  "decode",
@@ -18429,6 +18658,20 @@ var TrackSchema = object({
18429
18658
  * `=== true` and render nothing otherwise — never infer "no rider".
18430
18659
  */
18431
18660
  hasRider: boolean().optional(),
18661
+ /**
18662
+ * WHY this track ended without a NATIVE best-shot tile
18663
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
18664
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
18665
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
18666
+ * the late-keyFrame upgrade when a native tile lands after all. The
18667
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
18668
+ * tile is a face/plate stand-in, a raster crop, or an icon.
18669
+ *
18670
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
18671
+ * that predates the field, and every track whose tile landed native all
18672
+ * omit it. Render nothing when absent.
18673
+ */
18674
+ previewMissReason: string().optional(),
18432
18675
  ...TrackFlagFields,
18433
18676
  ...TrackRetrainFields
18434
18677
  });
@@ -29993,6 +30236,13 @@ var LoggingSettingsPatchSchema = object({
29993
30236
  * anyone but its owner.
29994
30237
  */
29995
30238
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
30239
+ /**
30240
+ * One per-camera failure counter, plus WHO reported it.
30241
+ *
30242
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
30243
+ * the hub as it enumerates providers, never by the contributor.
30244
+ */
30245
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
29996
30246
  var GetLoggingSettingsInputSchema = object({
29997
30247
  scopeNodeId: string().optional(),
29998
30248
  /**
@@ -30051,7 +30301,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
30051
30301
  }), method(_void(), SiteLocationStatusSchema, {
30052
30302
  kind: "mutation",
30053
30303
  auth: "admin"
30054
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
30304
+ }), 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, {
30055
30305
  kind: "mutation",
30056
30306
  auth: "admin"
30057
30307
  });
@@ -32540,6 +32790,12 @@ Object.freeze({
32540
32790
  addonId: null,
32541
32791
  access: "view"
32542
32792
  },
32793
+ "addonSettings.getIntegrationSettings": {
32794
+ capName: "addon-settings",
32795
+ capScope: "system",
32796
+ addonId: null,
32797
+ access: "view"
32798
+ },
32543
32799
  "addonSettings.updateDeviceSettings": {
32544
32800
  capName: "addon-settings",
32545
32801
  capScope: "system",
@@ -34202,6 +34458,12 @@ Object.freeze({
34202
34458
  addonId: null,
34203
34459
  access: "create"
34204
34460
  },
34461
+ "failureContribution.list": {
34462
+ capName: "failure-contribution",
34463
+ capScope: "system",
34464
+ addonId: null,
34465
+ access: "view"
34466
+ },
34205
34467
  "fanControl.setDirection": {
34206
34468
  capName: "fan-control",
34207
34469
  capScope: "device",
@@ -37508,6 +37770,12 @@ Object.freeze({
37508
37770
  addonId: null,
37509
37771
  access: "create"
37510
37772
  },
37773
+ "system.getFailureContributions": {
37774
+ capName: "system",
37775
+ capScope: "system",
37776
+ addonId: null,
37777
+ access: "view"
37778
+ },
37511
37779
  "system.getLoadContributions": {
37512
37780
  capName: "system",
37513
37781
  capScope: "system",
@@ -240879,6 +241147,12 @@ var ReolinkEmailPushServer = class {
240879
241147
  //#endregion
240880
241148
  //#region src/email-push-schema.ts
240881
241149
  /**
241150
+ * The ids of the sections above, in render order — the value the addon hands
241151
+ * to `BaseAddon.integrationSettingSections()`. Exported so the declaration and
241152
+ * the schema cannot drift: core throws if an id here names no section.
241153
+ */
241154
+ var EMAIL_PUSH_SECTION_IDS = ["email-push", "email-push-auth"];
241155
+ /**
240882
241156
  * Addon-level settings UI for the Reolink email/SMTP push intake.
240883
241157
  *
240884
241158
  * Rendered under the provider's addon settings (Cluster → addon config).
@@ -240890,6 +241164,28 @@ var ReolinkEmailPushServer = class {
240890
241164
  * `requiresRestart` is intentionally NOT set — the provider handles the
240891
241165
  * restart itself in `onConfigChanged` (a targeted SMTP rebind, not a full
240892
241166
  * addon teardown).
241167
+ *
241168
+ * ── These sections ARE the Reolink integration's configuration ──────────
241169
+ *
241170
+ * Both are declared in `ReolinkAddon.integrationSettingSections()`, so core
241171
+ * serves them on System → Integrations → Reolink. The operator looks for "the
241172
+ * Reolink SMTP port" under Reolink; this puts it there.
241173
+ *
241174
+ * They EARN that placement, and the reason is the test any future declaration
241175
+ * must pass: they configure ONE SMTP server in ONE provider process, serving
241176
+ * every Reolink camera at once. There is no per-camera copy to confuse them
241177
+ * with, which is exactly why a per-camera home would be nonsense and a
241178
+ * per-integration home is correct. A setting that differs per camera belongs
241179
+ * in `deviceSettingsSchema`, never here.
241180
+ *
241181
+ * The declaration does not move the values: they remain the same bare keys in
241182
+ * the same addon store, still reachable from System → Settings, still written
241183
+ * by `updateGlobalSettings` — there is no integration-specific writer at all.
241184
+ * See ADR-0269.
241185
+ *
241186
+ * `tab` is deliberately NOT used to express this. It means "how to group this
241187
+ * visually", and an earlier design that overloaded it put the literal word
241188
+ * "integration" into an operator-facing tab bar (D268 → D269).
240893
241189
  */
240894
241190
  function buildEmailPushSettingsSchema(recommendedHost) {
240895
241191
  return { sections: [{
@@ -241258,9 +241554,30 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
241258
241554
  this.ctx.logger.warn("email-push: restart after settings change failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
241259
241555
  });
241260
241556
  }
241261
- async getGlobalSettings() {
241262
- const raw = await this.resolveGlobalStore();
241263
- return hydrateSchema(buildEmailPushSettingsSchema(listLanHosts()[0] ?? "127.0.0.1"), raw);
241557
+ /**
241558
+ * The addon's global settings schema.
241559
+ *
241560
+ * This used to override `getGlobalSettings()` wholesale, on the belief that a
241561
+ * dynamic `recommendedHost` could not come from a static schema declaration.
241562
+ * It can: `listLanHosts()` is synchronous, so the schema builder runs here
241563
+ * and `BaseAddon.getGlobalSettings` does the identical
241564
+ * `resolveGlobalStore` + `hydrateSchema` the override did by hand.
241565
+ *
241566
+ * Declaring the SCHEMA rather than overriding the GETTER is what lets core
241567
+ * serve `getIntegrationSettings()` — it selects the declared sections out of
241568
+ * this schema, so an addon that hides its schema behind a getter has nothing
241569
+ * for core to select from.
241570
+ */
241571
+ globalSettingsSchema() {
241572
+ return buildEmailPushSettingsSchema(listLanHosts()[0] ?? "127.0.0.1");
241573
+ }
241574
+ /**
241575
+ * Both email-push sections ARE this integration's configuration — one SMTP
241576
+ * server serving every Reolink camera. See `email-push-schema.ts` for why
241577
+ * that earns a per-integration home and not a per-camera one.
241578
+ */
241579
+ integrationSettingSections() {
241580
+ return EMAIL_PUSH_SECTION_IDS;
241264
241581
  }
241265
241582
  async onInitialize() {
241266
241583
  const regs = await super.onInitialize();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-reolink",
3
- "version": "1.2.59",
3
+ "version": "1.2.61",
4
4
  "description": "Reolink camera device provider addon for CamStack — native Baichuan protocol",
5
5
  "keywords": [
6
6
  "camstack",