@camstack/addon-terminal 0.1.42 → 0.1.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/addon.js CHANGED
@@ -5948,6 +5948,40 @@ var BaseAddon = class {
5948
5948
  deviceSettingsSchema() {
5949
5949
  return null;
5950
5950
  }
5951
+ /**
5952
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5953
+ * ARE the configuration of its integration.
5954
+ *
5955
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5956
+ * operator should find on the addon's integration page (System →
5957
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5958
+ * addon. Empty (the default) means the addon has no integration-level
5959
+ * settings and no such surface is offered — this is opt-in, because whether
5960
+ * an addon's configuration IS its integration's configuration depends on the
5961
+ * nature of the integration.
5962
+ *
5963
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5964
+ * the ONE global schema, in the ONE addon store, written by the ONE
5965
+ * `updateGlobalSettings` path. There is deliberately no
5966
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5967
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5968
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5969
+ *
5970
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5971
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5972
+ * removed with the reason recorded at
5973
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5974
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5975
+ * marker sprinkled across sections also has to borrow a field that already
5976
+ * means something else; borrowing `section.tab` put the literal word
5977
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5978
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5979
+ * supersedes D268). One declaration, in one place, next to the schema whose
5980
+ * ids it names.
5981
+ */
5982
+ integrationSettingSections() {
5983
+ return [];
5984
+ }
5951
5985
  async getGlobalSettings(overlay, cap, nodeId) {
5952
5986
  const schema = this.globalSettingsSchema(cap);
5953
5987
  if (!schema) return { sections: [] };
@@ -5958,6 +5992,55 @@ var BaseAddon = class {
5958
5992
  } : projected);
5959
5993
  }
5960
5994
  /**
5995
+ * The integration-level view of this addon's settings: exactly the sections
5996
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
5997
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
5998
+ *
5999
+ * Returns `null` when the addon declared nothing — an addon that opts out has
6000
+ * no integration settings surface at all, rather than an empty one that reads
6001
+ * as a failed load.
6002
+ *
6003
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
6004
+ * and not in whichever UI happens to render this:
6005
+ *
6006
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
6007
+ * shown here is the same field, with the same bare key, that the addon's
6008
+ * own page shows. There is no integration-specific writer — callers save
6009
+ * through `updateGlobalSettings` — so a second store key is unreachable,
6010
+ * not merely discouraged.
6011
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
6012
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
6013
+ * such a field silently picked would be a wrong answer for the operator
6014
+ * who opened the page (D266).
6015
+ * 3. **No silent typo.** A declared id that names no section throws. The
6016
+ * alternative — skip it — turns a rename into a surface that quietly
6017
+ * empties, which looks exactly like an addon with nothing to configure.
6018
+ */
6019
+ async getIntegrationSettings(nodeId) {
6020
+ const declared = this.integrationSettingSections();
6021
+ if (declared.length === 0) return null;
6022
+ const schema = this.globalSettingsSchema();
6023
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
6024
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
6025
+ const sections = [];
6026
+ for (const id of declared) {
6027
+ const section = byId.get(id);
6028
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6029
+ const fields = dropPerNodeFields(section.fields);
6030
+ if (fields.length === 0) continue;
6031
+ sections.push({
6032
+ ...section,
6033
+ fields
6034
+ });
6035
+ }
6036
+ if (sections.length === 0) return null;
6037
+ const projected = await this.resolveGlobalStore(nodeId);
6038
+ return hydrateSchema({
6039
+ ...schema,
6040
+ sections
6041
+ }, projected);
6042
+ }
6043
+ /**
5961
6044
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5962
6045
  * every `perNode: true` field carries THAT node's scoped value on its bare
5963
6046
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6261,6 +6344,41 @@ var BaseAddon = class {
6261
6344
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6262
6345
  * don't declare `perNode` and are excluded by the `in` narrowing.
6263
6346
  */
6347
+ /**
6348
+ * The same fields with every `perNode: true` one removed, recursing into layout
6349
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6350
+ * with no child is dropped rather than rendered empty.
6351
+ *
6352
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6353
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6354
+ */
6355
+ function dropPerNodeFields(fields) {
6356
+ const kept = [];
6357
+ for (const field of fields) {
6358
+ if (field.type === "group") {
6359
+ const inner = dropPerNodeFields(field.fields);
6360
+ if (inner.length > 0) kept.push({
6361
+ ...field,
6362
+ fields: inner
6363
+ });
6364
+ continue;
6365
+ }
6366
+ if (field.type === "sub-tabs") {
6367
+ const tabs = field.tabs.map((tab) => ({
6368
+ ...tab,
6369
+ fields: dropPerNodeFields(tab.fields)
6370
+ })).filter((tab) => tab.fields.length > 0);
6371
+ if (tabs.length > 0) kept.push({
6372
+ ...field,
6373
+ tabs
6374
+ });
6375
+ continue;
6376
+ }
6377
+ if ("perNode" in field && field.perNode === true) continue;
6378
+ kept.push(field);
6379
+ }
6380
+ return kept;
6381
+ }
6264
6382
  function collectPerNodeFieldKeys(fields) {
6265
6383
  const collected = [];
6266
6384
  for (const field of fields) {
@@ -9497,6 +9615,9 @@ method(object({
9497
9615
  kind: "mutation",
9498
9616
  auth: "admin"
9499
9617
  }), method(object({
9618
+ addonId: string(),
9619
+ nodeId: string().optional()
9620
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9500
9621
  addonId: string(),
9501
9622
  deviceId: number(),
9502
9623
  nodeId: string().optional()
@@ -13390,6 +13511,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13390
13511
  limit: number().optional(),
13391
13512
  tags: record(string(), string()).optional()
13392
13513
  }), array(LogEntrySchema).readonly());
13514
+ /**
13515
+ * `failure-contribution` — the capability an addon reports its OWN losses
13516
+ * through, per camera, with the denominator attached. It stores nothing.
13517
+ *
13518
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13519
+ *
13520
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13521
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13522
+ * copied: the contributor reports what it already knows, hub-main adds only
13523
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13524
+ * somebody to forget to edit.
13525
+ *
13526
+ * They are not merged, because their invariants are opposites:
13527
+ *
13528
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13529
+ * claim a camera cost nothing, which is a measurement nobody made;
13530
+ * - a `failure-contribution` zero is the **most valuable value on the
13531
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13532
+ * and it is exactly what an absent entry cannot say.
13533
+ *
13534
+ * Putting a loss counter on a cost entry would also break the reconciliation
13535
+ * that gives `load-contribution` its point: contributions are subtracted from
13536
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13537
+ * has no process.
13538
+ *
13539
+ * ## Why not a log line, since the counters already exist
13540
+ *
13541
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13542
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13543
+ * ends in a log line, and a log line is the thing the operator asked to stop
13544
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13545
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13546
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13547
+ * media blackout were both diagnosed. The counters stay; this is where they can
13548
+ * be READ.
13549
+ *
13550
+ * ## The rate is served with its denominator or not at all
13551
+ *
13552
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13553
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13554
+ * than yesterday" and was **flat across twelve hours** once divided by the
13555
+ * successes on the same path. A surface that publishes only the numerator
13556
+ * reproduces that mistake on every read.
13557
+ *
13558
+ * ## Shape
13559
+ *
13560
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13561
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13562
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13563
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13564
+ * a forked runner's entries reach hub-main over transport that already exists.
13565
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13566
+ * result through `system.getFailureContributions`.
13567
+ */
13568
+ var FailureReasonCountSchema = object({
13569
+ /**
13570
+ * Why the attempt did not land, in the contributor's own vocabulary —
13571
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13572
+ * strings that already appear in this repo's logs and, where one exists, the
13573
+ * same string the per-track `previewMissReason` records (D276): a second
13574
+ * vocabulary for the same loss would make the row and the counter
13575
+ * un-joinable.
13576
+ */
13577
+ reason: string(),
13578
+ count: number().int().nonnegative()
13579
+ });
13580
+ var FailureContributionSchema = object({
13581
+ /**
13582
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13583
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13584
+ * `unit` free: the families are owned by different addons and a shared enum
13585
+ * is a central list that rots invisibly.
13586
+ */
13587
+ family: string(),
13588
+ /**
13589
+ * The NUMERIC device id — the same value every log line carries as
13590
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13591
+ * cannot name the camera must not emit the entry, because a fleet total
13592
+ * cannot answer the only question anybody asks of this surface.
13593
+ */
13594
+ deviceId: number().int().positive(),
13595
+ /**
13596
+ * A second dimension inside the family: the model / step id for an inference
13597
+ * timeout, so "which camera AND which model" is one read. Absent when the
13598
+ * family has a single variant.
13599
+ */
13600
+ variant: string().optional(),
13601
+ /**
13602
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13603
+ * differencing two reads must drop the interval when it changes, because the
13604
+ * counter restarted from zero in a respawned runner. Same discipline as
13605
+ * `LoadContribution.startedAtMs`.
13606
+ */
13607
+ sinceMs: number(),
13608
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13609
+ atMs: number(),
13610
+ /**
13611
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13612
+ * window. A failure count published without it is the mistake this schema
13613
+ * exists to make impossible.
13614
+ */
13615
+ attempts: number().int().nonnegative(),
13616
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13617
+ succeeded: number().int().nonnegative(),
13618
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13619
+ reasons: array(FailureReasonCountSchema).readonly()
13620
+ });
13621
+ method(_void(), array(FailureContributionSchema).readonly());
13393
13622
  var LoadContributionSchema = object({
13394
13623
  role: _enum([
13395
13624
  "decode",
@@ -17980,6 +18209,20 @@ var TrackSchema = object({
17980
18209
  * `=== true` and render nothing otherwise — never infer "no rider".
17981
18210
  */
17982
18211
  hasRider: boolean().optional(),
18212
+ /**
18213
+ * WHY this track ended without a NATIVE best-shot tile
18214
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
18215
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
18216
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
18217
+ * the late-keyFrame upgrade when a native tile lands after all. The
18218
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
18219
+ * tile is a face/plate stand-in, a raster crop, or an icon.
18220
+ *
18221
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
18222
+ * that predates the field, and every track whose tile landed native all
18223
+ * omit it. Render nothing when absent.
18224
+ */
18225
+ previewMissReason: string().optional(),
17983
18226
  ...TrackFlagFields,
17984
18227
  ...TrackRetrainFields
17985
18228
  });
@@ -29303,6 +29546,13 @@ var LoggingSettingsPatchSchema = object({
29303
29546
  * anyone but its owner.
29304
29547
  */
29305
29548
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
29549
+ /**
29550
+ * One per-camera failure counter, plus WHO reported it.
29551
+ *
29552
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
29553
+ * the hub as it enumerates providers, never by the contributor.
29554
+ */
29555
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
29306
29556
  var GetLoggingSettingsInputSchema = object({
29307
29557
  scopeNodeId: string().optional(),
29308
29558
  /**
@@ -29361,7 +29611,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
29361
29611
  }), method(_void(), SiteLocationStatusSchema, {
29362
29612
  kind: "mutation",
29363
29613
  auth: "admin"
29364
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
29614
+ }), 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, {
29365
29615
  kind: "mutation",
29366
29616
  auth: "admin"
29367
29617
  });
@@ -31681,6 +31931,12 @@ Object.freeze({
31681
31931
  addonId: null,
31682
31932
  access: "view"
31683
31933
  },
31934
+ "addonSettings.getIntegrationSettings": {
31935
+ capName: "addon-settings",
31936
+ capScope: "system",
31937
+ addonId: null,
31938
+ access: "view"
31939
+ },
31684
31940
  "addonSettings.updateDeviceSettings": {
31685
31941
  capName: "addon-settings",
31686
31942
  capScope: "system",
@@ -33343,6 +33599,12 @@ Object.freeze({
33343
33599
  addonId: null,
33344
33600
  access: "create"
33345
33601
  },
33602
+ "failureContribution.list": {
33603
+ capName: "failure-contribution",
33604
+ capScope: "system",
33605
+ addonId: null,
33606
+ access: "view"
33607
+ },
33346
33608
  "fanControl.setDirection": {
33347
33609
  capName: "fan-control",
33348
33610
  capScope: "device",
@@ -36649,6 +36911,12 @@ Object.freeze({
36649
36911
  addonId: null,
36650
36912
  access: "create"
36651
36913
  },
36914
+ "system.getFailureContributions": {
36915
+ capName: "system",
36916
+ capScope: "system",
36917
+ addonId: null,
36918
+ access: "view"
36919
+ },
36652
36920
  "system.getLoadContributions": {
36653
36921
  capName: "system",
36654
36922
  capScope: "system",
package/dist/addon.mjs CHANGED
@@ -5925,6 +5925,40 @@ var BaseAddon = class {
5925
5925
  deviceSettingsSchema() {
5926
5926
  return null;
5927
5927
  }
5928
+ /**
5929
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5930
+ * ARE the configuration of its integration.
5931
+ *
5932
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5933
+ * operator should find on the addon's integration page (System →
5934
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5935
+ * addon. Empty (the default) means the addon has no integration-level
5936
+ * settings and no such surface is offered — this is opt-in, because whether
5937
+ * an addon's configuration IS its integration's configuration depends on the
5938
+ * nature of the integration.
5939
+ *
5940
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5941
+ * the ONE global schema, in the ONE addon store, written by the ONE
5942
+ * `updateGlobalSettings` path. There is deliberately no
5943
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5944
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5945
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5946
+ *
5947
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5948
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5949
+ * removed with the reason recorded at
5950
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5951
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5952
+ * marker sprinkled across sections also has to borrow a field that already
5953
+ * means something else; borrowing `section.tab` put the literal word
5954
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5955
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5956
+ * supersedes D268). One declaration, in one place, next to the schema whose
5957
+ * ids it names.
5958
+ */
5959
+ integrationSettingSections() {
5960
+ return [];
5961
+ }
5928
5962
  async getGlobalSettings(overlay, cap, nodeId) {
5929
5963
  const schema = this.globalSettingsSchema(cap);
5930
5964
  if (!schema) return { sections: [] };
@@ -5935,6 +5969,55 @@ var BaseAddon = class {
5935
5969
  } : projected);
5936
5970
  }
5937
5971
  /**
5972
+ * The integration-level view of this addon's settings: exactly the sections
5973
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
5974
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
5975
+ *
5976
+ * Returns `null` when the addon declared nothing — an addon that opts out has
5977
+ * no integration settings surface at all, rather than an empty one that reads
5978
+ * as a failed load.
5979
+ *
5980
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
5981
+ * and not in whichever UI happens to render this:
5982
+ *
5983
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
5984
+ * shown here is the same field, with the same bare key, that the addon's
5985
+ * own page shows. There is no integration-specific writer — callers save
5986
+ * through `updateGlobalSettings` — so a second store key is unreachable,
5987
+ * not merely discouraged.
5988
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
5989
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
5990
+ * such a field silently picked would be a wrong answer for the operator
5991
+ * who opened the page (D266).
5992
+ * 3. **No silent typo.** A declared id that names no section throws. The
5993
+ * alternative — skip it — turns a rename into a surface that quietly
5994
+ * empties, which looks exactly like an addon with nothing to configure.
5995
+ */
5996
+ async getIntegrationSettings(nodeId) {
5997
+ const declared = this.integrationSettingSections();
5998
+ if (declared.length === 0) return null;
5999
+ const schema = this.globalSettingsSchema();
6000
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
6001
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
6002
+ const sections = [];
6003
+ for (const id of declared) {
6004
+ const section = byId.get(id);
6005
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6006
+ const fields = dropPerNodeFields(section.fields);
6007
+ if (fields.length === 0) continue;
6008
+ sections.push({
6009
+ ...section,
6010
+ fields
6011
+ });
6012
+ }
6013
+ if (sections.length === 0) return null;
6014
+ const projected = await this.resolveGlobalStore(nodeId);
6015
+ return hydrateSchema({
6016
+ ...schema,
6017
+ sections
6018
+ }, projected);
6019
+ }
6020
+ /**
5938
6021
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5939
6022
  * every `perNode: true` field carries THAT node's scoped value on its bare
5940
6023
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6238,6 +6321,41 @@ var BaseAddon = class {
6238
6321
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6239
6322
  * don't declare `perNode` and are excluded by the `in` narrowing.
6240
6323
  */
6324
+ /**
6325
+ * The same fields with every `perNode: true` one removed, recursing into layout
6326
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6327
+ * with no child is dropped rather than rendered empty.
6328
+ *
6329
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6330
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6331
+ */
6332
+ function dropPerNodeFields(fields) {
6333
+ const kept = [];
6334
+ for (const field of fields) {
6335
+ if (field.type === "group") {
6336
+ const inner = dropPerNodeFields(field.fields);
6337
+ if (inner.length > 0) kept.push({
6338
+ ...field,
6339
+ fields: inner
6340
+ });
6341
+ continue;
6342
+ }
6343
+ if (field.type === "sub-tabs") {
6344
+ const tabs = field.tabs.map((tab) => ({
6345
+ ...tab,
6346
+ fields: dropPerNodeFields(tab.fields)
6347
+ })).filter((tab) => tab.fields.length > 0);
6348
+ if (tabs.length > 0) kept.push({
6349
+ ...field,
6350
+ tabs
6351
+ });
6352
+ continue;
6353
+ }
6354
+ if ("perNode" in field && field.perNode === true) continue;
6355
+ kept.push(field);
6356
+ }
6357
+ return kept;
6358
+ }
6241
6359
  function collectPerNodeFieldKeys(fields) {
6242
6360
  const collected = [];
6243
6361
  for (const field of fields) {
@@ -9474,6 +9592,9 @@ method(object({
9474
9592
  kind: "mutation",
9475
9593
  auth: "admin"
9476
9594
  }), method(object({
9595
+ addonId: string(),
9596
+ nodeId: string().optional()
9597
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9477
9598
  addonId: string(),
9478
9599
  deviceId: number(),
9479
9600
  nodeId: string().optional()
@@ -13367,6 +13488,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13367
13488
  limit: number().optional(),
13368
13489
  tags: record(string(), string()).optional()
13369
13490
  }), array(LogEntrySchema).readonly());
13491
+ /**
13492
+ * `failure-contribution` — the capability an addon reports its OWN losses
13493
+ * through, per camera, with the denominator attached. It stores nothing.
13494
+ *
13495
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13496
+ *
13497
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13498
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13499
+ * copied: the contributor reports what it already knows, hub-main adds only
13500
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13501
+ * somebody to forget to edit.
13502
+ *
13503
+ * They are not merged, because their invariants are opposites:
13504
+ *
13505
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13506
+ * claim a camera cost nothing, which is a measurement nobody made;
13507
+ * - a `failure-contribution` zero is the **most valuable value on the
13508
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13509
+ * and it is exactly what an absent entry cannot say.
13510
+ *
13511
+ * Putting a loss counter on a cost entry would also break the reconciliation
13512
+ * that gives `load-contribution` its point: contributions are subtracted from
13513
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13514
+ * has no process.
13515
+ *
13516
+ * ## Why not a log line, since the counters already exist
13517
+ *
13518
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13519
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13520
+ * ends in a log line, and a log line is the thing the operator asked to stop
13521
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13522
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13523
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13524
+ * media blackout were both diagnosed. The counters stay; this is where they can
13525
+ * be READ.
13526
+ *
13527
+ * ## The rate is served with its denominator or not at all
13528
+ *
13529
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13530
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13531
+ * than yesterday" and was **flat across twelve hours** once divided by the
13532
+ * successes on the same path. A surface that publishes only the numerator
13533
+ * reproduces that mistake on every read.
13534
+ *
13535
+ * ## Shape
13536
+ *
13537
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13538
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13539
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13540
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13541
+ * a forked runner's entries reach hub-main over transport that already exists.
13542
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13543
+ * result through `system.getFailureContributions`.
13544
+ */
13545
+ var FailureReasonCountSchema = object({
13546
+ /**
13547
+ * Why the attempt did not land, in the contributor's own vocabulary —
13548
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13549
+ * strings that already appear in this repo's logs and, where one exists, the
13550
+ * same string the per-track `previewMissReason` records (D276): a second
13551
+ * vocabulary for the same loss would make the row and the counter
13552
+ * un-joinable.
13553
+ */
13554
+ reason: string(),
13555
+ count: number().int().nonnegative()
13556
+ });
13557
+ var FailureContributionSchema = object({
13558
+ /**
13559
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13560
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13561
+ * `unit` free: the families are owned by different addons and a shared enum
13562
+ * is a central list that rots invisibly.
13563
+ */
13564
+ family: string(),
13565
+ /**
13566
+ * The NUMERIC device id — the same value every log line carries as
13567
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13568
+ * cannot name the camera must not emit the entry, because a fleet total
13569
+ * cannot answer the only question anybody asks of this surface.
13570
+ */
13571
+ deviceId: number().int().positive(),
13572
+ /**
13573
+ * A second dimension inside the family: the model / step id for an inference
13574
+ * timeout, so "which camera AND which model" is one read. Absent when the
13575
+ * family has a single variant.
13576
+ */
13577
+ variant: string().optional(),
13578
+ /**
13579
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13580
+ * differencing two reads must drop the interval when it changes, because the
13581
+ * counter restarted from zero in a respawned runner. Same discipline as
13582
+ * `LoadContribution.startedAtMs`.
13583
+ */
13584
+ sinceMs: number(),
13585
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13586
+ atMs: number(),
13587
+ /**
13588
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13589
+ * window. A failure count published without it is the mistake this schema
13590
+ * exists to make impossible.
13591
+ */
13592
+ attempts: number().int().nonnegative(),
13593
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13594
+ succeeded: number().int().nonnegative(),
13595
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13596
+ reasons: array(FailureReasonCountSchema).readonly()
13597
+ });
13598
+ method(_void(), array(FailureContributionSchema).readonly());
13370
13599
  var LoadContributionSchema = object({
13371
13600
  role: _enum([
13372
13601
  "decode",
@@ -17957,6 +18186,20 @@ var TrackSchema = object({
17957
18186
  * `=== true` and render nothing otherwise — never infer "no rider".
17958
18187
  */
17959
18188
  hasRider: boolean().optional(),
18189
+ /**
18190
+ * WHY this track ended without a NATIVE best-shot tile
18191
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
18192
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
18193
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
18194
+ * the late-keyFrame upgrade when a native tile lands after all. The
18195
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
18196
+ * tile is a face/plate stand-in, a raster crop, or an icon.
18197
+ *
18198
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
18199
+ * that predates the field, and every track whose tile landed native all
18200
+ * omit it. Render nothing when absent.
18201
+ */
18202
+ previewMissReason: string().optional(),
17960
18203
  ...TrackFlagFields,
17961
18204
  ...TrackRetrainFields
17962
18205
  });
@@ -29280,6 +29523,13 @@ var LoggingSettingsPatchSchema = object({
29280
29523
  * anyone but its owner.
29281
29524
  */
29282
29525
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
29526
+ /**
29527
+ * One per-camera failure counter, plus WHO reported it.
29528
+ *
29529
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
29530
+ * the hub as it enumerates providers, never by the contributor.
29531
+ */
29532
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
29283
29533
  var GetLoggingSettingsInputSchema = object({
29284
29534
  scopeNodeId: string().optional(),
29285
29535
  /**
@@ -29338,7 +29588,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
29338
29588
  }), method(_void(), SiteLocationStatusSchema, {
29339
29589
  kind: "mutation",
29340
29590
  auth: "admin"
29341
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
29591
+ }), 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, {
29342
29592
  kind: "mutation",
29343
29593
  auth: "admin"
29344
29594
  });
@@ -31658,6 +31908,12 @@ Object.freeze({
31658
31908
  addonId: null,
31659
31909
  access: "view"
31660
31910
  },
31911
+ "addonSettings.getIntegrationSettings": {
31912
+ capName: "addon-settings",
31913
+ capScope: "system",
31914
+ addonId: null,
31915
+ access: "view"
31916
+ },
31661
31917
  "addonSettings.updateDeviceSettings": {
31662
31918
  capName: "addon-settings",
31663
31919
  capScope: "system",
@@ -33320,6 +33576,12 @@ Object.freeze({
33320
33576
  addonId: null,
33321
33577
  access: "create"
33322
33578
  },
33579
+ "failureContribution.list": {
33580
+ capName: "failure-contribution",
33581
+ capScope: "system",
33582
+ addonId: null,
33583
+ access: "view"
33584
+ },
33323
33585
  "fanControl.setDirection": {
33324
33586
  capName: "fan-control",
33325
33587
  capScope: "device",
@@ -36626,6 +36888,12 @@ Object.freeze({
36626
36888
  addonId: null,
36627
36889
  access: "create"
36628
36890
  },
36891
+ "system.getFailureContributions": {
36892
+ capName: "system",
36893
+ capScope: "system",
36894
+ addonId: null,
36895
+ access: "view"
36896
+ },
36629
36897
  "system.getLoadContributions": {
36630
36898
  capName: "system",
36631
36899
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-terminal",
3
- "version": "0.1.42",
3
+ "version": "0.1.44",
4
4
  "description": "Interactive terminal sessions (pty + xterm) as a CamStack addon",
5
5
  "keywords": [
6
6
  "camstack",