@camstack/server 1.2.767 → 1.2.769

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 (90) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/package.json +14 -8
  3. package/system/dist/addon-runner.js +7 -1
  4. package/system/dist/addon-runner.mjs +7 -1
  5. package/system/dist/addon-utils.mjs +1 -1
  6. package/system/dist/{agent-https-D03iyjJk.mjs → agent-https-C_rkCAus.mjs} +1 -1
  7. package/system/dist/{agent-https-D62iihRo.js → agent-https-Cw5Wc_ip.js} +1 -1
  8. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  9. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +4 -4
  10. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  11. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +5 -5
  12. package/system/dist/builtins/alerts/alerts.addon.d.ts +15 -0
  13. package/system/dist/builtins/alerts/alerts.addon.js +104 -4
  14. package/system/dist/builtins/alerts/alerts.addon.mjs +104 -4
  15. package/system/dist/builtins/alerts/cluster-state-alerts.d.ts +32 -0
  16. package/system/dist/builtins/autotrack/index.js +1 -1
  17. package/system/dist/builtins/autotrack/index.mjs +1 -1
  18. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  19. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +5 -5
  20. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  21. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  22. package/system/dist/builtins/camera-grid/index.js +1 -1
  23. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  24. package/system/dist/builtins/composer/composer.addon.js +5 -4
  25. package/system/dist/builtins/composer/composer.addon.mjs +5 -4
  26. package/system/dist/builtins/console-logging/index.js +1 -1
  27. package/system/dist/builtins/console-logging/index.mjs +1 -1
  28. package/system/dist/builtins/core-blocks/core-blocks.addon.js +3 -3
  29. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
  30. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  31. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  32. package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
  33. package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  34. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  35. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  36. package/system/dist/builtins/keychain/index.js +3 -3
  37. package/system/dist/builtins/keychain/index.mjs +3 -3
  38. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  39. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  40. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  41. package/system/dist/builtins/local-auth/local-auth.addon.mjs +5 -5
  42. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  43. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  44. package/system/dist/builtins/loki-logging/index.js +1 -1
  45. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  46. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  47. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +10 -10
  48. package/system/dist/builtins/platform-probe/index.js +1 -1
  49. package/system/dist/builtins/platform-probe/index.mjs +10 -10
  50. package/system/dist/builtins/record-entries/index.js +1 -1
  51. package/system/dist/builtins/record-entries/index.mjs +1 -1
  52. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  53. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  54. package/system/dist/builtins/snapshot/index.js +1 -1
  55. package/system/dist/builtins/snapshot/index.mjs +1 -1
  56. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  57. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +20 -20
  58. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  59. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  60. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +2 -2
  61. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +2 -2
  62. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  63. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  64. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  65. package/system/dist/builtins/system-config/system-config.addon.mjs +115 -115
  66. package/system/dist/builtins/winston-logging/index.js +1 -1
  67. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  68. package/system/dist/{capture-engine-BpoL1zQ0.js → capture-engine-DXSWU1PY.js} +1 -1
  69. package/system/dist/{capture-engine-CYmRx0Ce.mjs → capture-engine-Kl46lSBi.mjs} +1 -1
  70. package/system/dist/{composition-sources-CknQxftO.mjs → composition-sources-ClCP809M.mjs} +1 -1
  71. package/system/dist/{composition-sources-B7VyYbEU.js → composition-sources-Cq0IeRv9.js} +1 -1
  72. package/system/dist/{constants-C9Gxs1jW.mjs → constants-CDxTuuXp.mjs} +1 -1
  73. package/system/dist/{constants-DJqUggkW.js → constants-CI5ySMIj.js} +1 -1
  74. package/system/dist/{coral-accelerators-DBlgWB8k.mjs → coral-accelerators-BW3OcrLD.mjs} +6 -6
  75. package/system/dist/{custom-action-registry-oHl1xltx.mjs → custom-action-registry-BIJZBObd.mjs} +37 -37
  76. package/system/dist/{device-ca-9BTS4o-T.js → device-ca-DPvU-3TE.js} +1 -1
  77. package/system/dist/{device-ca-D76OqRnW.mjs → device-ca-uRLJ8-jZ.mjs} +1 -1
  78. package/system/dist/{dist-DLVfdGSW.js → dist-BDixk7cu.js} +107 -29
  79. package/system/dist/{dist-BhR34kF8.mjs → dist-C_SNsYGY.mjs} +107 -29
  80. package/system/dist/file-host-worker.js +1 -1
  81. package/system/dist/file-host-worker.mjs +1 -1
  82. package/system/dist/{hub-mdns-ciao-DimaT9WQ.js → hub-mdns-ciao-7uRbexmH.js} +2 -2
  83. package/system/dist/{hub-mdns-ciao-i31GIYWP.mjs → hub-mdns-ciao-ea1EwFAF.mjs} +2 -2
  84. package/system/dist/index.js +14 -8
  85. package/system/dist/index.mjs +225 -219
  86. package/system/dist/{restore-archive-BkiXu43U.js → restore-archive-CpTnlXUA.js} +1 -1
  87. package/system/dist/{restore-archive-VoiEuTJN.mjs → restore-archive-D0y_tFM2.mjs} +94 -94
  88. package/system/dist/{wal-maintenance-DG2bwMif.mjs → wal-maintenance-BvxzVfje.mjs} +0 -0
  89. package/system/dist/{wal-maintenance-UQEtPem2.js → wal-maintenance-Dy4gxMdb.js} +0 -0
  90. package/system/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.2.769] - 2026-11-05
11
+
12
+ ### Changed
13
+
14
+ - A finished appliance cycle's duration excludes the stop delay, and a short pulse after a cycle no longer extends it
15
+
16
+ ### Fixed
17
+
18
+ - An agent-offline alert resolves when that agent is back online, and a system-restarting alert resolves when the restart completed or the node is back, even if the online event was dropped
19
+
20
+ ## [1.2.768] - 2026-11-04
21
+
22
+ ### Changed
23
+
24
+ - Rebuilt against updated dependencies.
25
+
10
26
  ## [1.2.767] - 2026-11-04
11
27
 
12
28
  ### Changed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/server",
3
- "version": "1.2.767",
3
+ "version": "1.2.769",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -66,8 +66,14 @@
66
66
  ],
67
67
  "requires": {
68
68
  "addons": {
69
- "@camstack/addon-admin-ui": ">=1.2.584",
70
- "@camstack/addon-pipeline-orchestrator": ">=1.2.659"
69
+ "@camstack/addon-admin-ui": ">=1.2.586",
70
+ "@camstack/addon-agent-ui": ">=1.2.326",
71
+ "@camstack/addon-export-alexa": ">=1.2.184",
72
+ "@camstack/addon-export-hap": ">=1.2.193",
73
+ "@camstack/addon-post-analysis": ">=1.2.668",
74
+ "@camstack/addon-provider-esphome": ">=0.1.11",
75
+ "@camstack/addon-provider-homeassistant": ">=1.2.660",
76
+ "@camstack/addon-provider-vesync": ">=0.2.150"
71
77
  },
72
78
  "wrapper": {
73
79
  "desktop": ">=0.0.1",
@@ -76,19 +82,19 @@
76
82
  }
77
83
  },
78
84
  "dependencies": {
79
- "@camstack/addon-admin-ui": "1.2.584",
80
- "@camstack/addon-agent-ui": "1.2.324",
85
+ "@camstack/addon-admin-ui": "1.2.586",
86
+ "@camstack/addon-agent-ui": "1.2.326",
81
87
  "@camstack/addon-auth": "1.2.175",
82
88
  "@camstack/addon-benchmark": "1.2.311",
83
89
  "@camstack/addon-decoder-nodeav": "1.2.145",
84
90
  "@camstack/addon-notifiers": "1.2.628",
85
91
  "@camstack/addon-pipeline": "1.2.640",
86
92
  "@camstack/addon-pipeline-orchestrator": "1.2.659",
87
- "@camstack/addon-post-analysis": "1.2.667",
93
+ "@camstack/addon-post-analysis": "1.2.668",
88
94
  "@camstack/develop": "0.1.44",
89
95
  "@camstack/sdk": "1.2.155",
90
- "@camstack/types": "1.2.499",
91
- "@camstack/ui-library": "1.2.382",
96
+ "@camstack/types": "1.2.500",
97
+ "@camstack/ui-library": "1.2.384",
92
98
  "@fastify/compress": "^9.0.0",
93
99
  "@fastify/cookie": "^11.0.2",
94
100
  "@fastify/cors": "^11.2.0",
@@ -6485,7 +6485,7 @@ function createBrokerDeviceManagerApi(opts) {
6485
6485
  }
6486
6486
  const lifecycleHost = device;
6487
6487
  const shrinkGate = new AccessoryShrinkGate();
6488
- const runReconcile = async () => {
6488
+ const runReconcileNow = async () => {
6489
6489
  try {
6490
6490
  await callDeviceManager(api, "registerDevice", {
6491
6491
  addonId,
@@ -6595,6 +6595,12 @@ function createBrokerDeviceManagerApi(opts) {
6595
6595
  });
6596
6596
  }
6597
6597
  };
6598
+ let reconcileChain = Promise.resolve();
6599
+ const runReconcile = () => {
6600
+ const run = reconcileChain.then(runReconcileNow, runReconcileNow);
6601
+ reconcileChain = run.then(() => void 0, () => void 0);
6602
+ return run;
6603
+ };
6598
6604
  const PROBE_TIMEOUT_MS = 3e4;
6599
6605
  const runProbe = async () => {
6600
6606
  if (typeof lifecycleHost.onProbe !== "function") return;
@@ -6430,7 +6430,7 @@ function createBrokerDeviceManagerApi(opts) {
6430
6430
  }
6431
6431
  const lifecycleHost = device;
6432
6432
  const shrinkGate = new AccessoryShrinkGate();
6433
- const runReconcile = async () => {
6433
+ const runReconcileNow = async () => {
6434
6434
  try {
6435
6435
  await callDeviceManager(api, "registerDevice", {
6436
6436
  addonId,
@@ -6540,6 +6540,12 @@ function createBrokerDeviceManagerApi(opts) {
6540
6540
  });
6541
6541
  }
6542
6542
  };
6543
+ let reconcileChain = Promise.resolve();
6544
+ const runReconcile = () => {
6545
+ const run = reconcileChain.then(runReconcileNow, runReconcileNow);
6546
+ reconcileChain = run.then(() => void 0, () => void 0);
6547
+ return run;
6548
+ };
6543
6549
  const PROBE_TIMEOUT_MS = 3e4;
6544
6550
  const runProbe = async () => {
6545
6551
  if (typeof lifecycleHost.onProbe !== "function") return;
@@ -1,3 +1,3 @@
1
- import { C as isModelDownloaded, S as isModelDownloadHttpError, _ as downloadFile, a as startEventLoopStallMonitor, f as ModelDownloadService, g as deleteModelFromDisk, h as collectModelFiles, i as attributeStall, l as parseRangeHeader, m as adoptModelRevisions, n as STALL_REPORT_MS, o as createFileDataPlaneHandler, p as ModelDownloadHttpError, r as STALL_TICK_MS, s as contentTypeFor, t as CustomActionRegistry, w as resolveFormatRevision, x as getModelFilePath, y as ensureModel } from "./custom-action-registry-oHl1xltx.mjs";
1
+ import { C as isModelDownloaded, S as isModelDownloadHttpError, _ as downloadFile, a as startEventLoopStallMonitor, f as ModelDownloadService, g as deleteModelFromDisk, h as collectModelFiles, i as attributeStall, l as parseRangeHeader, m as adoptModelRevisions, n as STALL_REPORT_MS, o as createFileDataPlaneHandler, p as ModelDownloadHttpError, r as STALL_TICK_MS, s as contentTypeFor, t as CustomActionRegistry, w as resolveFormatRevision, x as getModelFilePath, y as ensureModel } from "./custom-action-registry-BIJZBObd.mjs";
2
2
  import { i as renderCourtesyOverlayJpeg, n as courtesyCacheKey, r as renderCourtesyJpeg, t as COURTESY_DEFAULT_WIDTH } from "./snapshot-courtesy-CyFs1M3I.mjs";
3
3
  export { COURTESY_DEFAULT_WIDTH, CustomActionRegistry, ModelDownloadHttpError, ModelDownloadService, STALL_REPORT_MS, STALL_TICK_MS, adoptModelRevisions, attributeStall, collectModelFiles, contentTypeFor, courtesyCacheKey, createFileDataPlaneHandler, deleteModelFromDisk, downloadFile, ensureModel, getModelFilePath, isModelDownloadHttpError, isModelDownloaded, parseRangeHeader, renderCourtesyJpeg, renderCourtesyOverlayJpeg, resolveFormatRevision, startEventLoopStallMonitor };
@@ -1,4 +1,4 @@
1
- import { ys as defineRecordKinds } from "./dist-BhR34kF8.mjs";
1
+ import { ys as defineRecordKinds } from "./dist-C_SNsYGY.mjs";
2
2
  import { C as backdatedNotBefore, S as withUtcTimeEncoding, _ as NameConstraints, a as KeyUsageFlags, c as Pkcs10CertificateRequest, d as SubjectKeyIdentifierExtension, f as X509Certificate$1, g as GeneralSubtrees, h as GeneralSubtree, i as Extension, l as Pkcs10CertificateRequestGenerator, m as cryptoProvider, n as BasicConstraintsExtension, o as KeyUsagesExtension, p as X509CertificateGenerator, r as ExtendedKeyUsageExtension, s as PemConverter, t as AuthorityKeyIdentifierExtension, u as SubjectAlternativeNameExtension, v as GeneralName, x as AsnConvert } from "./x509.es-BRiJgOvu.mjs";
3
3
  import { z } from "zod";
4
4
  import { X509Certificate, createHash, createPrivateKey, randomBytes, webcrypto } from "node:crypto";
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require("./chunk-Cek0wNdY.js");
2
- const require_dist = require("./dist-DLVfdGSW.js");
2
+ const require_dist = require("./dist-BDixk7cu.js");
3
3
  const require_x509_es = require("./x509.es-WtnRNyYS.js");
4
4
  let zod = require("zod");
5
5
  let node_crypto = require("node:crypto");
@@ -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-DLVfdGSW.js");
6
+ const require_dist = require("../../dist-BDixk7cu.js");
7
7
  const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
8
8
  let node_crypto = require("node:crypto");
9
9
  let node_path = require("node:path");
@@ -1,8 +1,8 @@
1
- import { cn as addonPagesCapability, dc as EventCategory, uc as errMsg, wo as BaseAddon } from "../../dist-BhR34kF8.mjs";
1
+ import { cn as addonPagesCapability, dc as EventCategory, uc as errMsg, wo as BaseAddon } from "../../dist-C_SNsYGY.mjs";
2
2
  import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import * as path$1 from "node:path";
5
- import * as fs$1 from "node:fs";
5
+ import * as fs from "node:fs";
6
6
  //#region src/builtins/addon-pages-aggregator/dedupe-pages.ts
7
7
  /** Stable identity for an addon page, independent of which node reported it. */
8
8
  function pageKey(info) {
@@ -211,11 +211,11 @@ var AddonPagesAggregatorAddon = class extends BaseAddon {
211
211
  const bundlePath = this.resolveBundlePath(addonId, bundle);
212
212
  if (bundlePath === null) return `/api/addon-pages/${addonId}/${bundle}?v=${Math.floor(Date.now())}`;
213
213
  try {
214
- const stat = fs$1.statSync(bundlePath);
214
+ const stat = fs.statSync(bundlePath);
215
215
  const cacheKey = `${bundlePath}:${stat.size}:${stat.mtimeMs}`;
216
216
  let v = this.bundleHashCache.get(cacheKey);
217
217
  if (v === void 0) {
218
- v = createHash("sha1").update(fs$1.readFileSync(bundlePath)).digest("hex").slice(0, 12);
218
+ v = createHash("sha1").update(fs.readFileSync(bundlePath)).digest("hex").slice(0, 12);
219
219
  this.bundleHashCache.set(cacheKey, v);
220
220
  }
221
221
  return `/api/addon-pages/${addonId}/${bundle}?v=${v}`;
@@ -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-DLVfdGSW.js");
6
+ const require_dist = require("../../dist-BDixk7cu.js");
7
7
  const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
8
8
  let node_crypto = require("node:crypto");
9
9
  let node_path = require("node:path");
@@ -1,8 +1,8 @@
1
- import { dc as EventCategory, uc as errMsg, un as addonWidgetsCapability, wo as BaseAddon } from "../../dist-BhR34kF8.mjs";
1
+ import { dc as EventCategory, uc as errMsg, un as addonWidgetsCapability, wo as BaseAddon } from "../../dist-C_SNsYGY.mjs";
2
2
  import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import * as path$1 from "node:path";
5
- import * as fs$1 from "node:fs";
5
+ import * as fs from "node:fs";
6
6
  //#region src/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.ts
7
7
  /**
8
8
  * Addon Widgets Aggregator — hub-local builtin that owns the singleton
@@ -204,9 +204,9 @@ var AddonWidgetsAggregatorAddon = class extends BaseAddon {
204
204
  if (entryPath === null) return String(Math.floor(Date.now()));
205
205
  try {
206
206
  const dir = path$1.dirname(entryPath);
207
- const files = fs$1.readdirSync(dir).filter((f) => fs$1.statSync(path$1.join(dir, f)).isFile()).sort();
207
+ const files = fs.readdirSync(dir).filter((f) => fs.statSync(path$1.join(dir, f)).isFile()).sort();
208
208
  const cacheKey = `${dir}#${files.map((f) => {
209
- const s = fs$1.statSync(path$1.join(dir, f));
209
+ const s = fs.statSync(path$1.join(dir, f));
210
210
  return `${f}:${s.size}:${s.mtimeMs}`;
211
211
  }).join("|")}`;
212
212
  const cached = this.bundleHashCache.get(cacheKey);
@@ -214,7 +214,7 @@ var AddonWidgetsAggregatorAddon = class extends BaseAddon {
214
214
  const hash = createHash("sha1");
215
215
  for (const f of files) {
216
216
  hash.update(f);
217
- hash.update(fs$1.readFileSync(path$1.join(dir, f)));
217
+ hash.update(fs.readFileSync(path$1.join(dir, f)));
218
218
  }
219
219
  const digest = hash.digest("hex").slice(0, 12);
220
220
  this.bundleHashCache.set(cacheKey, digest);
@@ -31,6 +31,10 @@ export declare class AlertCenterAddon extends BaseAddon<AlertCenterConfig> {
31
31
  * alert yet" and open two episodes for it.
32
32
  */
33
33
  private eventChain;
34
+ /** Restarts this process has heard completed. The node list covers a dropped one. */
35
+ private restartCompletions;
36
+ private clusterReconcileTimer;
37
+ private enqueue;
34
38
  private handleEvent;
35
39
  private processEvent;
36
40
  private readRunnerRecord;
@@ -106,6 +110,17 @@ export declare class AlertCenterAddon extends BaseAddon<AlertCenterConfig> {
106
110
  * rule listens for `rule-broken`. One card per RULE; a new reason updates it.
107
111
  */
108
112
  private handleRuleBroken;
113
+ /** A heard completion. An older one must not close a restart announced after it. */
114
+ private noteRestartCompleted;
115
+ /**
116
+ * The node list says who is back (D49). A read that fails changes nothing.
117
+ * Not called from the handler that opens `system.restarting` — that event
118
+ * is emitted while the node is still up. The next read dismisses it once
119
+ * the list says the node is online. A heard `system.restart-completed`
120
+ * dismisses the matching alert even when the list has not flipped yet.
121
+ */
122
+ private reconcileClusterAlerts;
123
+ private readClusterNodes;
109
124
  /**
110
125
  * One card per faulted migration, from the ledger (D987, D11): the RPC read is
111
126
  * the authority and an event only says it may have changed. A read that fails
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-DLVfdGSW.js");
6
+ const require_dist = require("../../dist-BDixk7cu.js");
7
7
  const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
8
8
  //#region src/builtins/alerts/alert-episode-policy.ts
9
9
  /**
@@ -479,6 +479,39 @@ function planMigrationAlerts(ledger, open, now) {
479
479
  };
480
480
  }
481
481
  //#endregion
482
+ //#region src/builtins/alerts/cluster-state-alerts.ts
483
+ /** How often the centre re-reads the node list. An online event only hints. */
484
+ var CLUSTER_STATE_RECONCILE_MS = 3e4;
485
+ function text(value) {
486
+ return typeof value === "string" && value.length > 0 ? value : null;
487
+ }
488
+ /** The node an alert is about. `agent.offline` is keyed by `agentId` (older cards used `nodeId`). */
489
+ function subjectNodeId(alert) {
490
+ const meta = alert.metadata ?? {};
491
+ if (alert.category === "agent.offline") return text(meta["agentId"]) ?? text(meta["nodeId"]);
492
+ if (alert.category === "system.restarting") return text(meta["nodeId"]);
493
+ return null;
494
+ }
495
+ function requestedAtOf(alert) {
496
+ const raw = alert.metadata?.["requestedAt"];
497
+ return typeof raw === "number" ? raw : alert.createdAt;
498
+ }
499
+ function restartCompleted(alert, nodeId, completions) {
500
+ const requestedAt = requestedAtOf(alert);
501
+ return completions.some((completion) => completion.nodeId === nodeId && completion.requestedAt >= requestedAt);
502
+ }
503
+ function resolved(alert, online, completions) {
504
+ const nodeId = subjectNodeId(alert);
505
+ if (nodeId === null) return false;
506
+ if (alert.category === "agent.offline") return online.has(nodeId);
507
+ if (alert.category === "system.restarting") return online.has(nodeId) || restartCompleted(alert, nodeId, completions);
508
+ return false;
509
+ }
510
+ function planClusterStateDismissals(input) {
511
+ const online = new Set(input.nodes.filter((node) => node.isOnline).map((node) => node.id));
512
+ return input.alerts.filter((alert) => alert.status === "active" && resolved(alert, online, input.completions)).map((alert) => alert.id);
513
+ }
514
+ //#endregion
482
515
  //#region src/builtins/alerts/alerts.addon.ts
483
516
  var CATEGORY_MAPPINGS = {
484
517
  "addon.crashed": {
@@ -590,7 +623,8 @@ var SILENT_TRACKED_CATEGORIES = [
590
623
  "stream.online",
591
624
  "notification.rule-repaired",
592
625
  "migration.failed",
593
- "migration.applied"
626
+ "migration.applied",
627
+ "agent.online"
594
628
  ];
595
629
  /** The `stream.offline` reasons that are an outage (D883) — mirrors the broker's `isStreamOutageReason`. */
596
630
  var STREAM_OUTAGE_REASONS = [
@@ -727,6 +761,11 @@ var AlertCenterAddon = class extends require_dist.BaseAddon {
727
761
  this.unsubscribers = unsubs;
728
762
  this.dismissLegacyStreamCards(void 0);
729
763
  this.reconcileMigrationAlerts();
764
+ this.enqueue(() => this.reconcileClusterAlerts());
765
+ this.clusterReconcileTimer = setInterval(() => {
766
+ this.enqueue(() => this.reconcileClusterAlerts());
767
+ }, CLUSTER_STATE_RECONCILE_MS);
768
+ if (typeof this.clusterReconcileTimer.unref === "function") this.clusterReconcileTimer.unref();
730
769
  this.ctx.logger.info("Initialized", { meta: { trackedCategoriesCount: TRACKED_CATEGORIES.length } });
731
770
  return [{
732
771
  capability: require_dist.alertsCapability,
@@ -734,6 +773,10 @@ var AlertCenterAddon = class extends require_dist.BaseAddon {
734
773
  }];
735
774
  }
736
775
  async onShutdown() {
776
+ if (this.clusterReconcileTimer !== null) {
777
+ clearInterval(this.clusterReconcileTimer);
778
+ this.clusterReconcileTimer = null;
779
+ }
737
780
  for (const unsub of this.unsubscribers) unsub();
738
781
  this.unsubscribers = [];
739
782
  }
@@ -812,9 +855,16 @@ var AlertCenterAddon = class extends require_dist.BaseAddon {
812
855
  * alert yet" and open two episodes for it.
813
856
  */
814
857
  eventChain = Promise.resolve();
858
+ /** Restarts this process has heard completed. The node list covers a dropped one. */
859
+ restartCompletions = [];
860
+ clusterReconcileTimer = null;
861
+ enqueue(work) {
862
+ const run = this.eventChain.then(work, work);
863
+ this.eventChain = run;
864
+ return run;
865
+ }
815
866
  handleEvent(category, event) {
816
- this.eventChain = this.eventChain.then(() => this.processEvent(category, event));
817
- return this.eventChain;
867
+ return this.enqueue(() => this.processEvent(category, event));
818
868
  }
819
869
  async processEvent(category, event) {
820
870
  try {
@@ -870,6 +920,14 @@ var AlertCenterAddon = class extends require_dist.BaseAddon {
870
920
  await this.handleRuleRepaired(event);
871
921
  return;
872
922
  }
923
+ if (category === require_dist.EventCategory.AgentOnline) {
924
+ await this.reconcileClusterAlerts();
925
+ return;
926
+ }
927
+ if (category === require_dist.EventCategory.SystemRestartCompleted) {
928
+ this.noteRestartCompleted(event);
929
+ await this.reconcileClusterAlerts();
930
+ }
873
931
  const mapping = CATEGORY_MAPPINGS[category];
874
932
  if (!mapping) return;
875
933
  if (category === "addon.updated") {
@@ -1373,6 +1431,48 @@ var AlertCenterAddon = class extends require_dist.BaseAddon {
1373
1431
  };
1374
1432
  await this.emitAlert(alert);
1375
1433
  }
1434
+ /** A heard completion. An older one must not close a restart announced after it. */
1435
+ noteRestartCompleted(event) {
1436
+ const nodeId = typeof event.data["nodeId"] === "string" ? event.data["nodeId"] : null;
1437
+ if (nodeId === null || nodeId.length === 0) return;
1438
+ const requestedAt = typeof event.data["requestedAt"] === "number" ? event.data["requestedAt"] : Date.now();
1439
+ const next = [...this.restartCompletions, {
1440
+ nodeId,
1441
+ requestedAt
1442
+ }];
1443
+ this.restartCompletions = next.length > 64 ? next.slice(next.length - 64) : next;
1444
+ }
1445
+ /**
1446
+ * The node list says who is back (D49). A read that fails changes nothing.
1447
+ * Not called from the handler that opens `system.restarting` — that event
1448
+ * is emitted while the node is still up. The next read dismisses it once
1449
+ * the list says the node is online. A heard `system.restart-completed`
1450
+ * dismisses the matching alert even when the list has not flipped yet.
1451
+ */
1452
+ async reconcileClusterAlerts() {
1453
+ try {
1454
+ const nodes = await this.readClusterNodes();
1455
+ if (nodes === null) return;
1456
+ const ids = planClusterStateDismissals({
1457
+ alerts: await this.listAlerts({ limit: 1e3 }),
1458
+ nodes,
1459
+ completions: this.restartCompletions
1460
+ });
1461
+ for (const alertId of ids) await this.dismiss(alertId);
1462
+ if (ids.length === 0) return;
1463
+ this.ctx.logger?.info("cluster alerts resolved from the node list", { meta: { count: ids.length } });
1464
+ } catch (err) {
1465
+ this.ctx.logger?.warn("cluster alerts: reconcile failed", { meta: { error: require_dist.errMsg(err) } });
1466
+ }
1467
+ }
1468
+ async readClusterNodes() {
1469
+ try {
1470
+ return (await this.ctx.api.nodes.directory.query()).nodes;
1471
+ } catch (err) {
1472
+ this.ctx.logger?.warn("cluster alerts: reconcile skipped, the node list could not be read", { meta: { error: require_dist.errMsg(err) } });
1473
+ return null;
1474
+ }
1475
+ }
1376
1476
  /**
1377
1477
  * One card per faulted migration, from the ledger (D987, D11): the RPC read is
1378
1478
  * the authority and an event only says it may have changed. A read that fails
@@ -1,4 +1,4 @@
1
- import { Fr as isAlertEpisodeSeverity, Pr as isAlertEpisodeOpen, d as AlertSchema, dc as EventCategory, dn as alertEpisodeId, fn as alertEpisodePayload, ms as createEvent, pn as alertsCapability, uc as errMsg, wo as BaseAddon, ys as defineRecordKinds } from "../../dist-BhR34kF8.mjs";
1
+ import { Fr as isAlertEpisodeSeverity, Pr as isAlertEpisodeOpen, d as AlertSchema, dc as EventCategory, dn as alertEpisodeId, fn as alertEpisodePayload, ms as createEvent, pn as alertsCapability, uc as errMsg, wo as BaseAddon, ys as defineRecordKinds } from "../../dist-C_SNsYGY.mjs";
2
2
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
3
3
  //#region src/builtins/alerts/alert-episode-policy.ts
4
4
  /**
@@ -473,6 +473,39 @@ function planMigrationAlerts(ledger, open, now) {
473
473
  };
474
474
  }
475
475
  //#endregion
476
+ //#region src/builtins/alerts/cluster-state-alerts.ts
477
+ /** How often the centre re-reads the node list. An online event only hints. */
478
+ var CLUSTER_STATE_RECONCILE_MS = 3e4;
479
+ function text(value) {
480
+ return typeof value === "string" && value.length > 0 ? value : null;
481
+ }
482
+ /** The node an alert is about. `agent.offline` is keyed by `agentId` (older cards used `nodeId`). */
483
+ function subjectNodeId(alert) {
484
+ const meta = alert.metadata ?? {};
485
+ if (alert.category === "agent.offline") return text(meta["agentId"]) ?? text(meta["nodeId"]);
486
+ if (alert.category === "system.restarting") return text(meta["nodeId"]);
487
+ return null;
488
+ }
489
+ function requestedAtOf(alert) {
490
+ const raw = alert.metadata?.["requestedAt"];
491
+ return typeof raw === "number" ? raw : alert.createdAt;
492
+ }
493
+ function restartCompleted(alert, nodeId, completions) {
494
+ const requestedAt = requestedAtOf(alert);
495
+ return completions.some((completion) => completion.nodeId === nodeId && completion.requestedAt >= requestedAt);
496
+ }
497
+ function resolved(alert, online, completions) {
498
+ const nodeId = subjectNodeId(alert);
499
+ if (nodeId === null) return false;
500
+ if (alert.category === "agent.offline") return online.has(nodeId);
501
+ if (alert.category === "system.restarting") return online.has(nodeId) || restartCompleted(alert, nodeId, completions);
502
+ return false;
503
+ }
504
+ function planClusterStateDismissals(input) {
505
+ const online = new Set(input.nodes.filter((node) => node.isOnline).map((node) => node.id));
506
+ return input.alerts.filter((alert) => alert.status === "active" && resolved(alert, online, input.completions)).map((alert) => alert.id);
507
+ }
508
+ //#endregion
476
509
  //#region src/builtins/alerts/alerts.addon.ts
477
510
  var CATEGORY_MAPPINGS = {
478
511
  "addon.crashed": {
@@ -584,7 +617,8 @@ var SILENT_TRACKED_CATEGORIES = [
584
617
  "stream.online",
585
618
  "notification.rule-repaired",
586
619
  "migration.failed",
587
- "migration.applied"
620
+ "migration.applied",
621
+ "agent.online"
588
622
  ];
589
623
  /** The `stream.offline` reasons that are an outage (D883) — mirrors the broker's `isStreamOutageReason`. */
590
624
  var STREAM_OUTAGE_REASONS = [
@@ -721,6 +755,11 @@ var AlertCenterAddon = class extends BaseAddon {
721
755
  this.unsubscribers = unsubs;
722
756
  this.dismissLegacyStreamCards(void 0);
723
757
  this.reconcileMigrationAlerts();
758
+ this.enqueue(() => this.reconcileClusterAlerts());
759
+ this.clusterReconcileTimer = setInterval(() => {
760
+ this.enqueue(() => this.reconcileClusterAlerts());
761
+ }, CLUSTER_STATE_RECONCILE_MS);
762
+ if (typeof this.clusterReconcileTimer.unref === "function") this.clusterReconcileTimer.unref();
724
763
  this.ctx.logger.info("Initialized", { meta: { trackedCategoriesCount: TRACKED_CATEGORIES.length } });
725
764
  return [{
726
765
  capability: alertsCapability,
@@ -728,6 +767,10 @@ var AlertCenterAddon = class extends BaseAddon {
728
767
  }];
729
768
  }
730
769
  async onShutdown() {
770
+ if (this.clusterReconcileTimer !== null) {
771
+ clearInterval(this.clusterReconcileTimer);
772
+ this.clusterReconcileTimer = null;
773
+ }
731
774
  for (const unsub of this.unsubscribers) unsub();
732
775
  this.unsubscribers = [];
733
776
  }
@@ -806,9 +849,16 @@ var AlertCenterAddon = class extends BaseAddon {
806
849
  * alert yet" and open two episodes for it.
807
850
  */
808
851
  eventChain = Promise.resolve();
852
+ /** Restarts this process has heard completed. The node list covers a dropped one. */
853
+ restartCompletions = [];
854
+ clusterReconcileTimer = null;
855
+ enqueue(work) {
856
+ const run = this.eventChain.then(work, work);
857
+ this.eventChain = run;
858
+ return run;
859
+ }
809
860
  handleEvent(category, event) {
810
- this.eventChain = this.eventChain.then(() => this.processEvent(category, event));
811
- return this.eventChain;
861
+ return this.enqueue(() => this.processEvent(category, event));
812
862
  }
813
863
  async processEvent(category, event) {
814
864
  try {
@@ -864,6 +914,14 @@ var AlertCenterAddon = class extends BaseAddon {
864
914
  await this.handleRuleRepaired(event);
865
915
  return;
866
916
  }
917
+ if (category === EventCategory.AgentOnline) {
918
+ await this.reconcileClusterAlerts();
919
+ return;
920
+ }
921
+ if (category === EventCategory.SystemRestartCompleted) {
922
+ this.noteRestartCompleted(event);
923
+ await this.reconcileClusterAlerts();
924
+ }
867
925
  const mapping = CATEGORY_MAPPINGS[category];
868
926
  if (!mapping) return;
869
927
  if (category === "addon.updated") {
@@ -1367,6 +1425,48 @@ var AlertCenterAddon = class extends BaseAddon {
1367
1425
  };
1368
1426
  await this.emitAlert(alert);
1369
1427
  }
1428
+ /** A heard completion. An older one must not close a restart announced after it. */
1429
+ noteRestartCompleted(event) {
1430
+ const nodeId = typeof event.data["nodeId"] === "string" ? event.data["nodeId"] : null;
1431
+ if (nodeId === null || nodeId.length === 0) return;
1432
+ const requestedAt = typeof event.data["requestedAt"] === "number" ? event.data["requestedAt"] : Date.now();
1433
+ const next = [...this.restartCompletions, {
1434
+ nodeId,
1435
+ requestedAt
1436
+ }];
1437
+ this.restartCompletions = next.length > 64 ? next.slice(next.length - 64) : next;
1438
+ }
1439
+ /**
1440
+ * The node list says who is back (D49). A read that fails changes nothing.
1441
+ * Not called from the handler that opens `system.restarting` — that event
1442
+ * is emitted while the node is still up. The next read dismisses it once
1443
+ * the list says the node is online. A heard `system.restart-completed`
1444
+ * dismisses the matching alert even when the list has not flipped yet.
1445
+ */
1446
+ async reconcileClusterAlerts() {
1447
+ try {
1448
+ const nodes = await this.readClusterNodes();
1449
+ if (nodes === null) return;
1450
+ const ids = planClusterStateDismissals({
1451
+ alerts: await this.listAlerts({ limit: 1e3 }),
1452
+ nodes,
1453
+ completions: this.restartCompletions
1454
+ });
1455
+ for (const alertId of ids) await this.dismiss(alertId);
1456
+ if (ids.length === 0) return;
1457
+ this.ctx.logger?.info("cluster alerts resolved from the node list", { meta: { count: ids.length } });
1458
+ } catch (err) {
1459
+ this.ctx.logger?.warn("cluster alerts: reconcile failed", { meta: { error: errMsg(err) } });
1460
+ }
1461
+ }
1462
+ async readClusterNodes() {
1463
+ try {
1464
+ return (await this.ctx.api.nodes.directory.query()).nodes;
1465
+ } catch (err) {
1466
+ this.ctx.logger?.warn("cluster alerts: reconcile skipped, the node list could not be read", { meta: { error: errMsg(err) } });
1467
+ return null;
1468
+ }
1469
+ }
1370
1470
  /**
1371
1471
  * One card per faulted migration, from the ledger (D987, D11): the RPC read is
1372
1472
  * the authority and an event only says it may have changed. A read that fails
@@ -0,0 +1,32 @@
1
+ /**
2
+ * `agent.offline` and `system.restarting` close from the node list, not from
3
+ * a one-shot online or restart-completed event (D8, D49). The list is the
4
+ * authority: a node it does not name stays as it is — absence is not "back".
5
+ * A restart completion this process heard dismisses the matching restarting
6
+ * alert even while the list still says offline. A completion older than the
7
+ * alert does not.
8
+ */
9
+ import type { AlertStatus } from "@camstack/types";
10
+ /** How often the centre re-reads the node list. An online event only hints. */
11
+ export declare const CLUSTER_STATE_RECONCILE_MS = 3e4;
12
+ export interface ClusterNodeRow {
13
+ readonly id: string;
14
+ readonly isOnline: boolean;
15
+ }
16
+ export interface RestartCompletion {
17
+ readonly nodeId: string;
18
+ readonly requestedAt: number;
19
+ }
20
+ export interface ClusterAlertView {
21
+ readonly id: string;
22
+ readonly status: AlertStatus;
23
+ readonly category: string;
24
+ readonly createdAt: number;
25
+ readonly metadata?: Readonly<Record<string, unknown>>;
26
+ }
27
+ export interface ClusterStateReconcileInput {
28
+ readonly alerts: readonly ClusterAlertView[];
29
+ readonly nodes: readonly ClusterNodeRow[];
30
+ readonly completions: readonly RestartCompletion[];
31
+ }
32
+ export declare function planClusterStateDismissals(input: ClusterStateReconcileInput): readonly string[];
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-DLVfdGSW.js");
6
+ const require_dist = require("../../dist-BDixk7cu.js");
7
7
  //#region src/builtins/autotrack/autotrack-config.ts
8
8
  var DEFAULT_AUTOTRACK_LOOP_CONFIG = {
9
9
  deadZoneFraction: .5,
@@ -1,4 +1,4 @@
1
- import { As as isEvent, Ri as ptzAutotrackCapability, dc as EventCategory, tt as FIRST_LEVEL_MACRO_CLASSES, uc as errMsg, vn as bareAddonId, wo as BaseAddon } from "../../dist-BhR34kF8.mjs";
1
+ import { As as isEvent, Ri as ptzAutotrackCapability, dc as EventCategory, tt as FIRST_LEVEL_MACRO_CLASSES, uc as errMsg, vn as bareAddonId, wo as BaseAddon } from "../../dist-C_SNsYGY.mjs";
2
2
  //#region src/builtins/autotrack/autotrack-config.ts
3
3
  var DEFAULT_AUTOTRACK_LOOP_CONFIG = {
4
4
  deadZoneFraction: .5,
@@ -3,9 +3,9 @@ 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-DLVfdGSW.js");
6
+ const require_dist = require("../../dist-BDixk7cu.js");
7
7
  const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
8
- const require_restore_archive = require("../../restore-archive-BkiXu43U.js");
8
+ const require_restore_archive = require("../../restore-archive-CpTnlXUA.js");
9
9
  let node_crypto = require("node:crypto");
10
10
  let node_fs_promises = require("node:fs/promises");
11
11
  node_fs_promises = require_chunk.__toESM(node_fs_promises);