@camstack/server 1.2.870 → 1.2.871

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.
Files changed (89) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/api/trpc/generated-cap-mounts.js +2 -1
  3. package/dist/api/trpc/generated-cap-routers.js +15 -1
  4. package/package.json +14 -14
  5. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  6. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  7. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  8. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  9. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  10. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  11. package/system/dist/builtins/autotrack/index.js +1 -1
  12. package/system/dist/builtins/autotrack/index.mjs +1 -1
  13. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  14. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  15. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  16. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  17. package/system/dist/builtins/camera-grid/index.js +1 -1
  18. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  19. package/system/dist/builtins/composer/composer.addon.js +4 -4
  20. package/system/dist/builtins/composer/composer.addon.mjs +4 -4
  21. package/system/dist/builtins/console-logging/index.js +1 -1
  22. package/system/dist/builtins/console-logging/index.mjs +1 -1
  23. package/system/dist/builtins/core-blocks/core-blocks.addon.js +3 -3
  24. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
  25. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  26. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  27. package/system/dist/builtins/device-manager/device-manager.addon.js +2 -2
  28. package/system/dist/builtins/device-manager/device-manager.addon.mjs +2 -2
  29. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  30. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  31. package/system/dist/builtins/keychain/index.js +4 -4
  32. package/system/dist/builtins/keychain/index.mjs +4 -4
  33. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  34. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  35. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  36. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  37. package/system/dist/builtins/local-network/local-network.addon.js +3 -3
  38. package/system/dist/builtins/local-network/local-network.addon.mjs +3 -3
  39. package/system/dist/builtins/loki-logging/index.js +1 -1
  40. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  41. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  42. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  43. package/system/dist/builtins/platform-probe/index.js +1 -1
  44. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  45. package/system/dist/builtins/record-entries/index.js +1 -1
  46. package/system/dist/builtins/record-entries/index.mjs +1 -1
  47. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  48. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  49. package/system/dist/builtins/snapshot/index.js +1 -1
  50. package/system/dist/builtins/snapshot/index.mjs +1 -1
  51. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  52. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  53. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  54. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  55. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  56. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  57. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  58. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  59. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  60. package/system/dist/builtins/system-config/system-config.addon.mjs +284 -284
  61. package/system/dist/builtins/winston-logging/index.js +1 -1
  62. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  63. package/system/dist/{capture-engine-DvcUjBD4.js → capture-engine-BNeKmvyo.js} +1 -1
  64. package/system/dist/{capture-engine-4BFlpvJV.mjs → capture-engine-BYuDoU5P.mjs} +1 -1
  65. package/system/dist/{composition-sources-CWKwokvg.js → composition-sources-52ZtkEBw.js} +1 -1
  66. package/system/dist/{composition-sources-DU-LtoTH.mjs → composition-sources-DQwbBMG1.mjs} +1 -1
  67. package/system/dist/{constants-C7shrFbd.mjs → constants-RWobCEGs.mjs} +1 -1
  68. package/system/dist/{constants-BHEbtnlN.js → constants-jwecWQuN.js} +1 -1
  69. package/system/dist/{device-ca-CRIb8o13.js → device-ca-Bkujp9Cx.js} +1 -1
  70. package/system/dist/{device-ca-DN7M71Qy.mjs → device-ca-DFi1axk5.mjs} +1 -1
  71. package/system/dist/{dist-Co_TBjrT.js → dist-8pvVkKh4.js} +259 -3
  72. package/system/dist/{dist-C_8yolmP.mjs → dist-B15a2506.mjs} +259 -3
  73. package/system/dist/file-host-worker.js +1 -1
  74. package/system/dist/file-host-worker.mjs +1 -1
  75. package/system/dist/{hub-identity-BoelHayw.mjs → hub-identity-3uLEvGsn.mjs} +1 -1
  76. package/system/dist/{hub-identity-D6YKdl9L.js → hub-identity-C3ijBf-E.js} +1 -1
  77. package/system/dist/{hub-mdns-ciao-C7vrLh6K.js → hub-mdns-ciao-BUL3yLqz.js} +2 -2
  78. package/system/dist/{hub-mdns-ciao-CFIA6g7n.mjs → hub-mdns-ciao-Ch6HwlRl.mjs} +2 -2
  79. package/system/dist/index.js +8 -8
  80. package/system/dist/index.mjs +8 -8
  81. package/system/dist/{legacy-integration-rows-door-D3JEzzQB.js → legacy-integration-rows-door-BtRtvXfK.js} +1 -1
  82. package/system/dist/{legacy-integration-rows-door-uKx33PTT.mjs → legacy-integration-rows-door-ChF97F5x.mjs} +1 -1
  83. package/system/dist/{rename-composition-block-Bqk6u7Q6.js → rename-composition-block-CHIIBly8.js} +1 -1
  84. package/system/dist/{rename-composition-block-CvevOCur.mjs → rename-composition-block-DfsNTQ2H.mjs} +1 -1
  85. package/system/dist/{restore-archive-eHXLFCxW.js → restore-archive-8o1pcPFB.js} +1 -1
  86. package/system/dist/{restore-archive-BZ45H1RA.mjs → restore-archive-B3y3I9SV.mjs} +82 -82
  87. package/system/dist/{wal-maintenance-BHFm-B-H.js → wal-maintenance-Cv6MfFm9.js} +0 -0
  88. package/system/dist/{wal-maintenance-D80Zkary.mjs → wal-maintenance-DxtgYuYM.mjs} +0 -0
  89. package/system/package.json +1 -1
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-Co_TBjrT.js");
6
+ const require_dist = require("../../dist-8pvVkKh4.js");
7
7
  const require_formatter = require("../../formatter-xbxeV4GD.js");
8
8
  const require_log_file_read_protocol = require("../../log-file-read-protocol-DSV_vQRb.js");
9
9
  let node_path = require("node:path");
@@ -1,4 +1,4 @@
1
- import { Fc as defineAddonMigrations, Is as BaseAddon, Vi as logDestinationCapability, xa as preconditionOf } from "../../dist-C_8yolmP.mjs";
1
+ import { Fc as defineAddonMigrations, Is as BaseAddon, Vi as logDestinationCapability, xa as preconditionOf } from "../../dist-B15a2506.mjs";
2
2
  import { t as formatLogLine } from "../../formatter-DkYZ4LXp.mjs";
3
3
  import { a as LogFileIndexStore, i as serveRead, n as isFromReader, t as CancelBook } from "../../log-file-read-protocol-hTaAsYlX.mjs";
4
4
  import { createRequire } from "node:module";
@@ -1,4 +1,4 @@
1
- const require_dist = require("./dist-Co_TBjrT.js");
1
+ const require_dist = require("./dist-8pvVkKh4.js");
2
2
  //#region src/builtins/device-history/store/series-registry.ts
3
3
  function subjectIdOf(subject) {
4
4
  return subject.kind === "device" ? `d:${subject.deviceId}` : `n:${subject.nodeId}`;
@@ -1,4 +1,4 @@
1
- import { Fl as DeviceType, Gc as historyItemFieldPath, Ks as HISTORY_DEFAULT_MIN_INTERVAL_MS } from "./dist-C_8yolmP.mjs";
1
+ import { Fl as DeviceType, Gc as historyItemFieldPath, Ks as HISTORY_DEFAULT_MIN_INTERVAL_MS } from "./dist-B15a2506.mjs";
2
2
  //#region src/builtins/device-history/store/series-registry.ts
3
3
  function subjectIdOf(subject) {
4
4
  return subject.kind === "device" ? `d:${subject.deviceId}` : `n:${subject.nodeId}`;
@@ -1,4 +1,4 @@
1
- const require_dist = require("./dist-Co_TBjrT.js");
1
+ const require_dist = require("./dist-8pvVkKh4.js");
2
2
  //#region src/builtins/shared/device-state-changed.ts
3
3
  /** Structural narrowing helper for untrusted bus payloads. */
4
4
  function isRecord(value) {
@@ -1,4 +1,4 @@
1
- import { Il as errMsg, _s as compositionSourceKey } from "./dist-C_8yolmP.mjs";
1
+ import { Il as errMsg, _s as compositionSourceKey } from "./dist-B15a2506.mjs";
2
2
  //#region src/builtins/shared/device-state-changed.ts
3
3
  /** Structural narrowing helper for untrusted bus payloads. */
4
4
  function isRecord(value) {
@@ -1,4 +1,4 @@
1
- import { Ec as buildSecretRef } from "./dist-C_8yolmP.mjs";
1
+ import { Ec as buildSecretRef } from "./dist-B15a2506.mjs";
2
2
  /** `secret://system/global/meshCaKey` — EC P-256 PKCS#8 PEM of the hub mesh CA. */
3
3
  var MESH_CA_KEY_REF = buildSecretRef({
4
4
  owner: "system",
@@ -1,5 +1,5 @@
1
1
  /** `secret://system/global/meshCaKey` — EC P-256 PKCS#8 PEM of the hub mesh CA. */
2
- var MESH_CA_KEY_REF = require("./dist-Co_TBjrT.js").buildSecretRef({
2
+ var MESH_CA_KEY_REF = require("./dist-8pvVkKh4.js").buildSecretRef({
3
3
  owner: "system",
4
4
  scope: { kind: "global" },
5
5
  fieldPath: "meshCaKey"
@@ -1,4 +1,4 @@
1
- const require_dist = require("./dist-Co_TBjrT.js");
1
+ const require_dist = require("./dist-8pvVkKh4.js");
2
2
  const require_x509_es = require("./x509.es-WtnRNyYS.js");
3
3
  let node_crypto = require("node:crypto");
4
4
  //#region src/auth/jwt-signing-key.ts
@@ -1,4 +1,4 @@
1
- import { Ec as buildSecretRef, K as DEVICE_SAN_CREDENTIAL_PREFIX, q as DEVICE_SAN_USER_PREFIX } from "./dist-C_8yolmP.mjs";
1
+ import { Ec as buildSecretRef, K as DEVICE_SAN_CREDENTIAL_PREFIX, q as DEVICE_SAN_USER_PREFIX } from "./dist-B15a2506.mjs";
2
2
  import { C as backdatedNotBefore, S as withUtcTimeEncoding, a as KeyUsageFlags, d as SubjectKeyIdentifierExtension, f as X509Certificate$1, m as cryptoProvider, n as BasicConstraintsExtension, o as KeyUsagesExtension, p as X509CertificateGenerator, r as ExtendedKeyUsageExtension, s as PemConverter, t as AuthorityKeyIdentifierExtension, u as SubjectAlternativeNameExtension } from "./x509.es-BRiJgOvu.mjs";
3
3
  import { X509Certificate, createPublicKey, randomBytes, verify, webcrypto } from "node:crypto";
4
4
  //#region src/auth/jwt-signing-key.ts
@@ -1274,7 +1274,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1274
1274
  */
1275
1275
  var COMPOSED_DEVICE_STABLE_ID_PREFIX = "composed-";
1276
1276
  //#endregion
1277
- //#region ../types/dist/sleep-DbhT0DWV.mjs
1277
+ //#region ../types/dist/sleep-BnR9qGOv.mjs
1278
1278
  /**
1279
1279
  * The audio chunk plane's byte format, and the ONE expansion from a coded
1280
1280
  * window to float samples (D455).
@@ -15042,6 +15042,30 @@ var CAP_VOCABULARY_BY_NAME = {
15042
15042
  icon: "wifi-off"
15043
15043
  }]
15044
15044
  },
15045
+ "error": {
15046
+ scope: "device",
15047
+ noun: {
15048
+ en: "Fault",
15049
+ it: "Guasto"
15050
+ },
15051
+ state: [{
15052
+ kind: "boolean",
15053
+ field: "active",
15054
+ label: {
15055
+ en: "Fault",
15056
+ it: "Guasto"
15057
+ },
15058
+ whenTrue: {
15059
+ en: "When {device} reports a fault",
15060
+ it: "Quando {device} segnala un guasto"
15061
+ },
15062
+ whenFalse: {
15063
+ en: "When the fault of {device} clears",
15064
+ it: "Quando il guasto di {device} si risolve"
15065
+ },
15066
+ icon: "triangle-alert"
15067
+ }]
15068
+ },
15045
15069
  "doorbell": {
15046
15070
  scope: "device",
15047
15071
  noun: {
@@ -16076,6 +16100,7 @@ var CAP_NAMES = Object.freeze([
16076
16100
  "embedding-encoder",
16077
16101
  "energy-system",
16078
16102
  "enum-sensor",
16103
+ "error",
16079
16104
  "event-emitter",
16080
16105
  "face-gallery",
16081
16106
  "failure-contribution",
@@ -16966,6 +16991,29 @@ Object.freeze({
16966
16991
  "path": "timestamp",
16967
16992
  "valueType": "boolean"
16968
16993
  }],
16994
+ "error": [
16995
+ {
16996
+ "path": "active",
16997
+ "valueType": "boolean"
16998
+ },
16999
+ {
17000
+ "path": "code",
17001
+ "valueType": "string"
17002
+ },
17003
+ {
17004
+ "path": "label",
17005
+ "valueType": "string"
17006
+ },
17007
+ {
17008
+ "path": "severity",
17009
+ "valueType": "enum",
17010
+ "enumValues": ["warning", "error"]
17011
+ },
17012
+ {
17013
+ "path": "since",
17014
+ "valueType": "number"
17015
+ }
17016
+ ],
16969
17017
  "event-emitter": [
16970
17018
  {
16971
17019
  "path": "lastEvent.deviceId",
@@ -64467,7 +64515,7 @@ function groupTemplate(id) {
64467
64515
  }
64468
64516
  /**
64469
64517
  * Cap history catalog, projected from every `*.cap.ts` `history` block.
64470
- * 45 caps with series (104 series), 38 caps answered `'none'`.
64518
+ * 45 caps with series (104 series), 39 caps answered `'none'`.
64471
64519
  * Field keys are `runtimeState` paths (`a.b` into fixed objects only).
64472
64520
  */
64473
64521
  var HISTORY_CATALOG = {
@@ -73498,6 +73546,85 @@ var enumSensorCapability = {
73498
73546
  }]
73499
73547
  }
73500
73548
  };
73549
+ /** How loudly a fault wants the operator. Both tiers raise the attention event. */
73550
+ var DeviceErrorSeveritySchema = zod.z.enum(["warning", "error"]);
73551
+ /** One fault of a device that can raise several at once. */
73552
+ var DeviceFaultSchema = zod.z.object({
73553
+ /** The device's own code, as the vendor names it. */
73554
+ code: zod.z.string(),
73555
+ /** Already translated by the provider (it owns the vendor vocabulary). */
73556
+ label: zod.z.string(),
73557
+ severity: DeviceErrorSeveritySchema
73558
+ });
73559
+ /**
73560
+ * The fault a device reports right now. One slice per device.
73561
+ *
73562
+ * `active` is tri-state: `null` is "the provider has not read it yet" and is
73563
+ * never drawn as "no fault" nor as a fault (D315, D393). The provider filters
73564
+ * what is not a fault (a completion or reminder code) BEFORE it writes `true`.
73565
+ *
73566
+ * The cap's name is the key a template reads (`{{ alias.error.label }}`, D1021).
73567
+ */
73568
+ var ErrorStatusSchema = zod.z.object({
73569
+ active: zod.z.boolean().nullable(),
73570
+ /** The code of the principal fault; `null` when none (or unknown). */
73571
+ code: zod.z.string().nullable(),
73572
+ /** The principal fault's words, provider-translated; `null` when none. */
73573
+ label: zod.z.string().nullable(),
73574
+ severity: DeviceErrorSeveritySchema,
73575
+ /** Ms epoch the current fault started; `null` when none or not known. */
73576
+ since: zod.z.number().nullable(),
73577
+ /** Every fault, for a device that raises several. The principal is the first. */
73578
+ faults: zod.z.array(DeviceFaultSchema).optional(),
73579
+ /** Ms epoch of the last read the provider made of the fault. */
73580
+ lastFetchedAt: zod.z.number()
73581
+ });
73582
+ /** The slice before the provider has read anything: unknown, not "fine". */
73583
+ var ERROR_STATUS_COLD = {
73584
+ active: null,
73585
+ code: null,
73586
+ label: null,
73587
+ severity: "error",
73588
+ since: null,
73589
+ lastFetchedAt: 0
73590
+ };
73591
+ var errorCapability = {
73592
+ name: "error",
73593
+ scope: "device",
73594
+ deviceNative: true,
73595
+ mode: "singleton",
73596
+ methods: {},
73597
+ status: {
73598
+ schema: ErrorStatusSchema,
73599
+ kind: "push",
73600
+ empty: ERROR_STATUS_COLD
73601
+ },
73602
+ runtimeState: ErrorStatusSchema,
73603
+ /**
73604
+ * Runtime-state durability: **restored** — the previous observation is what
73605
+ * lets the first reading after a restart be a COMPARISON: a fault that was
73606
+ * already open must not announce itself a second time.
73607
+ *
73608
+ * See `RuntimeStateDurability`. Enforced by
73609
+ * `scripts/check-runtime-state-durability.ts`.
73610
+ */
73611
+ durability: "restored",
73612
+ volatileStateFields: ["lastFetchedAt"],
73613
+ /** The fault itself is carried by the attention alerts; no series is recorded. */
73614
+ history: "none",
73615
+ vocabulary: {
73616
+ noun: t("Fault", "Guasto"),
73617
+ order: 5265,
73618
+ state: [{
73619
+ kind: "boolean",
73620
+ field: "active",
73621
+ label: t("Fault", "Guasto"),
73622
+ whenTrue: t("When {device} reports a fault", "Quando {device} segnala un guasto"),
73623
+ whenFalse: t("When the fault of {device} clears", "Quando il guasto di {device} si risolve"),
73624
+ icon: "triangle-alert"
73625
+ }]
73626
+ }
73627
+ };
73501
73628
  var IdentitySchema = zod.z.object({
73502
73629
  id: zod.z.string(),
73503
73630
  name: zod.z.string(),
@@ -110086,6 +110213,7 @@ var ALL_CAPABILITY_DEFINITIONS = [
110086
110213
  embeddingEncoderCapability,
110087
110214
  energySystemCapability,
110088
110215
  enumSensorCapability,
110216
+ errorCapability,
110089
110217
  eventEmitterCapability,
110090
110218
  faceGalleryCapability,
110091
110219
  failureContributionCapability,
@@ -112821,6 +112949,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
112821
112949
  doorbell: doorbellCapability,
112822
112950
  energySystem: energySystemCapability,
112823
112951
  enumSensor: enumSensorCapability,
112952
+ error: errorCapability,
112824
112953
  eventEmitter: eventEmitterCapability,
112825
112954
  fanControl: fanControlCapability,
112826
112955
  featureProbe: featureProbeCapability,
@@ -112882,6 +113011,54 @@ var DEVICE_LOCAL_STATE_CAPS = {
112882
113011
  zoneRules: zoneRulesCapability,
112883
113012
  zones: zonesCapability
112884
113013
  };
113014
+ /**
113015
+ * The edge between two readings, or `null` for no edge.
113016
+ *
113017
+ * - `null`/cold → `true` is a START (a fault already open at boot is one);
113018
+ * - `true` → `false` is a RESOLVE;
113019
+ * - an UNKNOWN reading (`active: null`) is never an edge, in either direction —
113020
+ * a failed read must neither raise nor close an episode (D393, D49);
113021
+ * - `true` → `true` is the same episode, whatever the code did.
113022
+ */
113023
+ function deviceErrorEdge(previous, next) {
113024
+ if (next.active === true && previous?.active !== true) return "start";
113025
+ if (next.active === false && previous?.active === true) return "resolve";
113026
+ return null;
113027
+ }
113028
+ function deviceErrorAlertId(deviceId) {
113029
+ return `device-error:${String(deviceId)}`;
113030
+ }
113031
+ /** The alert that opens an episode. `since` is the fault's own start, else `now`. */
113032
+ function buildDeviceErrorAlert(deviceId, deviceName, status, now) {
113033
+ const label = status.label ?? status.code ?? "Fault";
113034
+ const startedAt = status.since ?? now;
113035
+ const alertId = deviceErrorAlertId(deviceId);
113036
+ return {
113037
+ id: alertId,
113038
+ category: "device.error",
113039
+ severity: "critical",
113040
+ title: `${deviceName}: ${label}`,
113041
+ message: `${deviceName} reports a fault: ${label}.`,
113042
+ action: {
113043
+ label: "Open device",
113044
+ href: `/devices/${String(deviceId)}`,
113045
+ navigation: "app"
113046
+ },
113047
+ status: "active",
113048
+ read: false,
113049
+ createdAt: now,
113050
+ updatedAt: now,
113051
+ source: {
113052
+ type: "device",
113053
+ id: String(deviceId)
113054
+ },
113055
+ metadata: {
113056
+ episodeId: `${alertId}@${String(startedAt)}`,
113057
+ code: status.code,
113058
+ deviceSeverity: status.severity
113059
+ }
113060
+ };
113061
+ }
112885
113062
  var BaseDevice = class {
112886
113063
  id;
112887
113064
  stableId;
@@ -113181,6 +113358,68 @@ var BaseDevice = class {
113181
113358
  } catch (err) {}
113182
113359
  }
113183
113360
  /**
113361
+ * Declare that this device can report a fault (the `error` cap). The slice
113362
+ * starts UNKNOWN — a restored slice is kept, so a fault that was open before
113363
+ * a restart is compared, not announced again.
113364
+ */
113365
+ registerErrorCap() {
113366
+ this.ctx.registerNativeCap?.(errorCapability, {});
113367
+ if (this.runtimeState.getCapState(errorCapability.name) === void 0) this.setCapSlice(errorCapability, ERROR_STATUS_COLD);
113368
+ }
113369
+ /**
113370
+ * Publish the device's fault. The slice is written; on an EDGE (a fault
113371
+ * starts, or one resolves) an attention episode opens or closes through the
113372
+ * alerts cap, which the notification center announces as
113373
+ * `device-attention-required` / `-resolved`. An unknown reading is never an
113374
+ * edge. No rule exists by default: it notifies when the operator makes one.
113375
+ */
113376
+ async publishError(reading) {
113377
+ const previous = this.getCapSlice(errorCapability);
113378
+ if (reading.active === null && previous !== null && previous.active !== null) return;
113379
+ const now = Date.now();
113380
+ const edge = deviceErrorEdge(previous, reading);
113381
+ const next = edge === "start" && reading.since === null ? {
113382
+ ...reading,
113383
+ since: now
113384
+ } : reading;
113385
+ this.setCapSlice(errorCapability, next);
113386
+ if (edge === null) return;
113387
+ const alerts = this.ctx.api.alerts;
113388
+ if (alerts === void 0) {
113389
+ this.ctx.logger.warn("device error: attention event skipped — alerts capability missing", {
113390
+ tags: { deviceId: this.id },
113391
+ meta: { edge }
113392
+ });
113393
+ return;
113394
+ }
113395
+ try {
113396
+ if (edge === "start") await alerts.emit.mutate(buildDeviceErrorAlert(this.id, this.name, next, now));
113397
+ else await alerts.update.mutate({
113398
+ alertId: deviceErrorAlertId(this.id),
113399
+ patch: {
113400
+ status: "completed",
113401
+ read: true,
113402
+ updatedAt: now
113403
+ }
113404
+ });
113405
+ this.ctx.logger.info(`device error: ${edge === "start" ? "raised" : "resolved"}`, {
113406
+ tags: { deviceId: this.id },
113407
+ meta: {
113408
+ code: next.code,
113409
+ label: next.label
113410
+ }
113411
+ });
113412
+ } catch (err) {
113413
+ this.ctx.logger.warn("device error: attention event failed", {
113414
+ tags: { deviceId: this.id },
113415
+ meta: {
113416
+ edge,
113417
+ error: errMsg(err)
113418
+ }
113419
+ });
113420
+ }
113421
+ }
113422
+ /**
113184
113423
  * Typed read-through to a cap-keyed runtime-state slice. Drivers
113185
113424
  * call `this.getCapSlice(batteryCapability)` and the return type
113186
113425
  * is inferred from the cap's `runtimeState` Zod schema — no string
@@ -121284,6 +121523,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
121284
121523
  access: "view",
121285
121524
  role: "viewer"
121286
121525
  },
121526
+ "error.getStatus": {
121527
+ capName: "error",
121528
+ capScope: "device",
121529
+ addonId: null,
121530
+ access: "view",
121531
+ role: "viewer"
121532
+ },
121287
121533
  "eventEmitter.getStatus": {
121288
121534
  capName: "event-emitter",
121289
121535
  capScope: "device",
@@ -128767,6 +129013,7 @@ var CAP_NAMES_WITH_STATUS = [
128767
129013
  "doorbell",
128768
129014
  "energy-system",
128769
129015
  "enum-sensor",
129016
+ "error",
128770
129017
  "event-emitter",
128771
129018
  "fan-control",
128772
129019
  "feature-probe",
@@ -129810,6 +130057,11 @@ Object.freeze({
129810
130057
  form: "single",
129811
130058
  optional: false
129812
130059
  }],
130060
+ "error.getStatus": [{
130061
+ name: "deviceId",
130062
+ form: "single",
130063
+ optional: false
130064
+ }],
129813
130065
  "eventEmitter.getStatus": [{
129814
130066
  name: "deviceId",
129815
130067
  form: "single",
@@ -131979,7 +132231,7 @@ Object.freeze({
131979
132231
  });
131980
132232
  /**
131981
132233
  * Per-cap runtime-state policy, projected from every `*.cap.ts` that declares
131982
- * `runtimeState`. 84 caps: 42 `restored`, 42 `session`.
132234
+ * `runtimeState`. 85 caps: 43 `restored`, 42 `session`.
131983
132235
  *
131984
132236
  * A cap absent from this map has no runtime-state slice at all. A cap PRESENT
131985
132237
  * with `durability: 'session'` has one and has decided not to keep it.
@@ -132082,6 +132334,10 @@ var RUNTIME_STATE_POLICY = {
132082
132334
  durability: "restored",
132083
132335
  volatileFields: ["lastFetchedAt", "timestamp"]
132084
132336
  },
132337
+ "error": {
132338
+ durability: "restored",
132339
+ volatileFields: ["lastFetchedAt"]
132340
+ },
132085
132341
  "event-emitter": {
132086
132342
  durability: "session",
132087
132343
  volatileFields: []