@camstack/server 1.2.782 → 1.2.784

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 (65) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/package.json +14 -9
  3. package/system/dist/addon-utils.js +1 -1
  4. package/system/dist/addon-utils.mjs +1 -1
  5. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +2 -2
  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 +2 -2
  8. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  9. package/system/dist/builtins/alerts/alerts.addon.d.ts +6 -0
  10. package/system/dist/builtins/alerts/alerts.addon.js +240 -17
  11. package/system/dist/builtins/alerts/alerts.addon.mjs +264 -50
  12. package/system/dist/builtins/alerts/runner-alert.d.ts +6 -1
  13. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +5 -5
  14. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +3 -3
  15. package/system/dist/builtins/camera-grid/index.js +1 -1
  16. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  17. package/system/dist/builtins/core-blocks/core-blocks.addon.js +3 -3
  18. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +2 -2
  19. package/system/dist/builtins/keychain/index.js +1 -1
  20. package/system/dist/builtins/keychain/index.mjs +1 -1
  21. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +3 -3
  22. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +2 -2
  23. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  24. package/system/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
  25. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  26. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  27. package/system/dist/builtins/native-metrics/native-metrics.addon.js +2 -2
  28. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +2 -2
  29. package/system/dist/builtins/platform-probe/index.js +2 -2
  30. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  31. package/system/dist/builtins/snapshot/index.js +1 -1
  32. package/system/dist/builtins/snapshot/index.mjs +1 -1
  33. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +3 -3
  34. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +2 -2
  35. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  36. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  37. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  38. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  39. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +2 -2
  40. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +2 -2
  41. package/system/dist/builtins/system-config/system-config.addon.js +4 -4
  42. package/system/dist/builtins/system-config/system-config.addon.mjs +3 -3
  43. package/system/dist/builtins/winston-logging/index.js +1 -1
  44. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  45. package/system/dist/file-host-worker.js +1 -1
  46. package/system/dist/file-host-worker.mjs +1 -1
  47. package/system/dist/{hub-mdns-ciao-DHlokCDH.js → hub-mdns-ciao-DYD3STlf.js} +3 -3
  48. package/system/dist/{hub-mdns-ciao-DWzAoaKF.mjs → hub-mdns-ciao-VOfs7CqC.mjs} +3 -3
  49. package/system/dist/index.js +29 -112
  50. package/system/dist/index.mjs +23 -106
  51. package/system/dist/kernel/moleculer/process-service.d.ts +3 -0
  52. package/system/dist/kernel/moleculer/runner-failure-info.d.ts +13 -0
  53. package/system/dist/log-file-read-worker.js +1 -1
  54. package/system/dist/log-file-read-worker.mjs +1 -1
  55. package/system/package.json +1 -1
  56. package/system/dist/{agent-https-kG6BvwKf.js → agent-https-BobAhSU6.js} +1 -1
  57. package/system/dist/{agent-https-CEBLv9BA.mjs → agent-https-Ds3-zbz-.mjs} +1 -1
  58. package/system/dist/{custom-action-registry-oHl1xltx.mjs → custom-action-registry-B9zFBNVa.mjs} +3 -3
  59. package/system/dist/{custom-action-registry-JuMHGKEc.js → custom-action-registry-CmWpSeMS.js} +3 -3
  60. package/system/dist/{log-file-read-protocol-D0WcLbIV.js → log-file-read-protocol-DSV_vQRb.js} +2 -2
  61. package/system/dist/{log-file-read-protocol-B7M3X3bT.mjs → log-file-read-protocol-hTaAsYlX.mjs} +1 -1
  62. package/system/dist/{restore-archive-CfET1ups.mjs → restore-archive-B2l00XlI.mjs} +4 -4
  63. package/system/dist/{restore-archive-ChBlqNSj.js → restore-archive-BCXQaw89.js} +6 -6
  64. package/system/dist/{wal-maintenance-CNSrfmr8.js → wal-maintenance-Z4MNv6Vn.js} +0 -0
  65. package/system/dist/{wal-maintenance-Bg3rwpny.mjs → wal-maintenance-bvjbNKbx.mjs} +0 -0
package/CHANGELOG.md CHANGED
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.2.784] - 2026-11-06
11
+
12
+ ### Changed
13
+
14
+ - Rebuilt against updated dependencies.
15
+
16
+ ## [1.2.783] - 2026-11-06
17
+
18
+ ### Changed
19
+
20
+ - Rebuilt against updated dependencies.
21
+
10
22
  ## [1.2.782] - 2026-11-06
11
23
 
12
24
  ### Changed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/server",
3
- "version": "1.2.782",
3
+ "version": "1.2.784",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -66,8 +66,13 @@
66
66
  ],
67
67
  "requires": {
68
68
  "addons": {
69
- "@camstack/addon-admin-ui": ">=1.2.596",
70
- "@camstack/addon-agent-ui": ">=1.2.331"
69
+ "@camstack/addon-admin-ui": ">=1.2.597",
70
+ "@camstack/addon-agent-ui": ">=1.2.332",
71
+ "@camstack/addon-google-services": ">=0.2.40",
72
+ "@camstack/addon-import-alexa": ">=0.2.191",
73
+ "@camstack/addon-notifiers": ">=1.2.630",
74
+ "@camstack/addon-post-analysis": ">=1.2.672",
75
+ "@camstack/addon-provider-homeassistant": ">=1.2.666"
71
76
  },
72
77
  "wrapper": {
73
78
  "desktop": ">=0.0.1",
@@ -76,19 +81,19 @@
76
81
  }
77
82
  },
78
83
  "dependencies": {
79
- "@camstack/addon-admin-ui": "1.2.596",
80
- "@camstack/addon-agent-ui": "1.2.331",
84
+ "@camstack/addon-admin-ui": "1.2.597",
85
+ "@camstack/addon-agent-ui": "1.2.332",
81
86
  "@camstack/addon-auth": "1.2.176",
82
87
  "@camstack/addon-benchmark": "1.2.311",
83
88
  "@camstack/addon-decoder-nodeav": "1.2.146",
84
- "@camstack/addon-notifiers": "1.2.628",
89
+ "@camstack/addon-notifiers": "1.2.630",
85
90
  "@camstack/addon-pipeline": "1.2.642",
86
91
  "@camstack/addon-pipeline-orchestrator": "1.2.662",
87
- "@camstack/addon-post-analysis": "1.2.671",
92
+ "@camstack/addon-post-analysis": "1.2.672",
88
93
  "@camstack/develop": "0.1.46",
89
94
  "@camstack/sdk": "1.2.155",
90
- "@camstack/types": "1.2.509",
91
- "@camstack/ui-library": "1.2.389",
95
+ "@camstack/types": "1.2.510",
96
+ "@camstack/ui-library": "1.2.390",
92
97
  "@fastify/compress": "^9.0.0",
93
98
  "@fastify/cookie": "^11.0.2",
94
99
  "@fastify/cors": "^11.2.0",
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("./chunk-Cek0wNdY.js");
3
- const require_custom_action_registry = require("./custom-action-registry-JuMHGKEc.js");
3
+ const require_custom_action_registry = require("./custom-action-registry-CmWpSeMS.js");
4
4
  const require_snapshot_courtesy = require("./snapshot-courtesy-D_C5-nC0.js");
5
5
  exports.COURTESY_DEFAULT_WIDTH = require_snapshot_courtesy.COURTESY_DEFAULT_WIDTH;
6
6
  exports.CustomActionRegistry = require_custom_action_registry.CustomActionRegistry;
@@ -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-B9zFBNVa.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 };
@@ -6,10 +6,10 @@ const require_chunk = require("../../chunk-Cek0wNdY.js");
6
6
  const require_dist = require("../../dist-CA672buZ.js");
7
7
  const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
8
8
  let node_crypto = require("node:crypto");
9
- let node_path = require("node:path");
10
- node_path = require_chunk.__toESM(node_path);
11
9
  let node_fs = require("node:fs");
12
10
  node_fs = require_chunk.__toESM(node_fs);
11
+ let node_path = require("node:path");
12
+ node_path = require_chunk.__toESM(node_path);
13
13
  //#region src/builtins/addon-pages-aggregator/dedupe-pages.ts
14
14
  /** Stable identity for an addon page, independent of which node reported it. */
15
15
  function pageKey(info) {
@@ -1,8 +1,8 @@
1
1
  import { Ao as BaseAddon, _c as EventCategory, gc as errMsg, un as addonPagesCapability } from "../../dist-W0Eyg7Fm.mjs";
2
2
  import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
- import * as path$1 from "node:path";
5
4
  import * as fs$1 from "node:fs";
5
+ import * as path$1 from "node:path";
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) {
@@ -6,10 +6,10 @@ const require_chunk = require("../../chunk-Cek0wNdY.js");
6
6
  const require_dist = require("../../dist-CA672buZ.js");
7
7
  const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
8
8
  let node_crypto = require("node:crypto");
9
- let node_path = require("node:path");
10
- node_path = require_chunk.__toESM(node_path);
11
9
  let node_fs = require("node:fs");
12
10
  node_fs = require_chunk.__toESM(node_fs);
11
+ let node_path = require("node:path");
12
+ node_path = require_chunk.__toESM(node_path);
13
13
  //#region src/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.ts
14
14
  /**
15
15
  * Addon Widgets Aggregator — hub-local builtin that owns the singleton
@@ -1,8 +1,8 @@
1
1
  import { Ao as BaseAddon, _c as EventCategory, fn as addonWidgetsCapability, gc as errMsg } from "../../dist-W0Eyg7Fm.mjs";
2
2
  import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
- import * as path$1 from "node:path";
5
4
  import * as fs$1 from "node:fs";
5
+ import * as path$1 from "node:path";
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
@@ -138,6 +138,12 @@ export declare class AlertCenterAddon extends BaseAddon<AlertCenterConfig> {
138
138
  * their `stream.online` under the per-device id.
139
139
  */
140
140
  private dismissLegacyStreamCards;
141
+ /**
142
+ * The operator-facing name of a runner: a core block's `name`, an addon's
143
+ * manifest name. Bounded and never throwing - the alert must go out with the
144
+ * id when the lookup is slow or fails (D49).
145
+ */
146
+ private resolveRunnerName;
141
147
  private resolveDeviceName;
142
148
  private buildMessage;
143
149
  private emitAlert;
@@ -2,9 +2,14 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- require("../../chunk-Cek0wNdY.js");
5
+ const require_chunk = require("../../chunk-Cek0wNdY.js");
6
6
  const require_dist = require("../../dist-CA672buZ.js");
7
7
  const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
8
+ let node_fs = require("node:fs");
9
+ node_fs = require_chunk.__toESM(node_fs);
10
+ let node_path = require("node:path");
11
+ node_path = require_chunk.__toESM(node_path);
12
+ let _camstack_types_addon = require("@camstack/types/addon");
8
13
  //#region src/builtins/alerts/alert-episode-policy.ts
9
14
  /**
10
15
  * When does an alert open a new EPISODE, and which edge of it is announced?
@@ -114,6 +119,152 @@ function selectOverflow(alerts, maxAlerts) {
114
119
  return [...byAge.filter((a) => a.read), ...byAge.filter((a) => !a.read)].slice(0, excess).map((a) => a.id);
115
120
  }
116
121
  //#endregion
122
+ //#region src/logging/log-redactor.ts
123
+ var REDACTED = "***";
124
+ /** Credential-named keys. Substring, case-insensitive; only STRING values are replaced. */
125
+ var SECRET_KEY_SUBSTRINGS = [
126
+ "password",
127
+ "passwd",
128
+ "secret",
129
+ "token",
130
+ "apikey",
131
+ "api_key",
132
+ "authkey",
133
+ "auth_key",
134
+ "privatekey",
135
+ "private_key",
136
+ "passphrase",
137
+ "credential",
138
+ "cookie"
139
+ ];
140
+ /** True when a meta key names a credential. */
141
+ function isCredentialKeyName(key) {
142
+ const lower = key.toLowerCase();
143
+ return SECRET_KEY_SUBSTRINGS.some((needle) => lower.includes(needle));
144
+ }
145
+ var URL_IN_TEXT = /\b[a-z][a-z0-9+.-]*:\/\/[^\s"'<>`]+/gi;
146
+ /** A root-relative path WITH a query, as request logs print it. */
147
+ var RELATIVE_URL_IN_TEXT = /(^|[\s"'(=])(\/[^\s"'<>`?]*\?[^\s"'<>`]+)/g;
148
+ var CREDENTIAL_FLAG = /(--(?:token|auth-?key|password|passwd|pass|secret|api-?key|access-?token|refresh-?token)(?:=|\s+))(\S+)/gi;
149
+ /** Redact one free-form string. */
150
+ function redactLogText(text) {
151
+ let out = (0, _camstack_types_addon.scrubKnownSecrets)(text);
152
+ if (out.includes("://")) out = out.replace(URL_IN_TEXT, (url) => (0, _camstack_types_addon.maskUrlCredentials)(url));
153
+ if (out.includes("/") && out.includes("?") && out.includes("=")) out = out.replace(RELATIVE_URL_IN_TEXT, (_m, lead, path) => `${lead}${(0, _camstack_types_addon.maskUrlCredentials)(path)}`);
154
+ if (out.includes("--")) out = out.replace(CREDENTIAL_FLAG, (_m, flag, value) => value.startsWith("‹secret:") ? `${flag}${value}` : `${flag}${REDACTED}`);
155
+ return out;
156
+ }
157
+ /** Bounds on the meta walk — a log line is not a place to traverse a graph. */
158
+ var MAX_DEPTH = 8;
159
+ var MAX_NODES = 2e3;
160
+ /**
161
+ * Redact a value, returning the SAME reference when nothing in it changed —
162
+ * most lines carry clean meta, and copying every one would put an allocation
163
+ * per log line on hub-main's event loop.
164
+ */
165
+ function redactValue(value, depth, budget, seen) {
166
+ if (budget.nodes++ > MAX_NODES) return value;
167
+ if (typeof value === "string") return redactLogText(value);
168
+ if (value === null || typeof value !== "object") return value;
169
+ if (depth >= MAX_DEPTH || seen.has(value)) return value;
170
+ if (value instanceof Error) {
171
+ const message = redactLogText(value.message);
172
+ return message === value.message ? value : message;
173
+ }
174
+ if (value instanceof Date || ArrayBuffer.isView(value) || value instanceof ArrayBuffer) return value;
175
+ seen.add(value);
176
+ if (Array.isArray(value)) {
177
+ let copy = null;
178
+ for (let i = 0; i < value.length; i++) {
179
+ const item = value[i];
180
+ const next = redactValue(item, depth + 1, budget, seen);
181
+ if (next !== item) {
182
+ copy ??= [...value];
183
+ copy[i] = next;
184
+ }
185
+ }
186
+ return copy ?? value;
187
+ }
188
+ let copy = null;
189
+ for (const [key, child] of Object.entries(value)) {
190
+ const next = typeof child === "string" && child.length > 0 && isCredentialKeyName(key) ? REDACTED : redactValue(child, depth + 1, budget, seen);
191
+ if (next !== child) {
192
+ copy ??= { ...value };
193
+ copy[key] = next;
194
+ }
195
+ }
196
+ return copy ?? value;
197
+ }
198
+ /** Redact a `meta` record; the same object back when it was already clean. */
199
+ function redactLogMeta(meta) {
200
+ const out = redactValue(meta, 0, { nodes: 0 }, /* @__PURE__ */ new WeakSet());
201
+ if (out === meta) return meta;
202
+ return out !== null && typeof out === "object" && !Array.isArray(out) ? Object.fromEntries(Object.entries(out)) : meta;
203
+ }
204
+ /** Redact a whole entry: message and meta. Tags are identifiers, left alone. */
205
+ function redactLogEntry(entry) {
206
+ const message = redactLogText(entry.message);
207
+ const meta = entry.meta !== void 0 ? redactLogMeta(entry.meta) : void 0;
208
+ if (message === entry.message && meta === entry.meta) return entry;
209
+ return {
210
+ ...entry,
211
+ message,
212
+ ...meta !== void 0 ? { meta } : {}
213
+ };
214
+ }
215
+ //#endregion
216
+ //#region src/kernel/moleculer/runner-failure-info.ts
217
+ /**
218
+ * What the hub knows about a runner that gave up, read at the moment it
219
+ * gives up: the operator-facing name (from the package manifest on disk) and
220
+ * the real cause (the runner's own last stderr line). Both travel in the
221
+ * `addon.runner-failed` / `addon.runner-refused` payload so every alert and
222
+ * notification built from the event names the same thing, with no lookup.
223
+ */
224
+ /** Opening words of the breaker's own `addon.crashed` text. It describes the breaker, never the cause. */
225
+ var CRASH_BREAKER_ERROR_PREFIX = "Crash circuit-breaker tripped";
226
+ var MAX_CAUSE_LENGTH = 300;
227
+ var INIT_FAILED = /Init failed for "[^"]*":\s*(.+)$/;
228
+ /** The cause out of one stderr line: the text after `Init failed for "<id>":`, else the line itself. */
229
+ function causeOfStderrLine(line) {
230
+ const trimmed = line.trim();
231
+ if (trimmed.length === 0) return void 0;
232
+ return (INIT_FAILED.exec(trimmed)?.[1] ?? trimmed).slice(0, MAX_CAUSE_LENGTH);
233
+ }
234
+ /** Fold a stderr chunk into the runner's last known cause. An `Init failed` line outranks later noise. */
235
+ function lastCauseAfterChunk(previous, chunk) {
236
+ let cause = previous;
237
+ for (const line of chunk.split("\n")) {
238
+ const text = causeOfStderrLine(line);
239
+ if (text === void 0) continue;
240
+ const fromInit = INIT_FAILED.test(line.trim());
241
+ if (fromInit || cause === void 0 || !cause.fromInit) cause = {
242
+ text: redactLogText(text),
243
+ fromInit
244
+ };
245
+ }
246
+ return cause;
247
+ }
248
+ /** Manifest display name of the runner: the addon whose id is the runner's, else the only addon hosted. */
249
+ function readRunnerDisplayName(addonDirs, runnerId) {
250
+ const names = [];
251
+ for (const dir of addonDirs) try {
252
+ const raw = JSON.parse(node_fs.readFileSync(node_path.join(dir, "package.json"), "utf-8"));
253
+ const camstack = typeof raw === "object" && raw !== null ? Reflect.get(raw, "camstack") : null;
254
+ const addons = typeof camstack === "object" && camstack !== null ? Reflect.get(camstack, "addons") : null;
255
+ if (!Array.isArray(addons)) continue;
256
+ for (const entry of addons) {
257
+ const id = typeof entry === "object" && entry !== null ? Reflect.get(entry, "id") : null;
258
+ const name = typeof entry === "object" && entry !== null ? Reflect.get(entry, "name") : null;
259
+ if (typeof id === "string" && typeof name === "string" && name.trim().length > 0) names.push({
260
+ id,
261
+ name: name.trim()
262
+ });
263
+ }
264
+ } catch {}
265
+ return names.find((n) => n.id === runnerId)?.name ?? (names.length === 1 ? names[0]?.name : void 0);
266
+ }
267
+ //#endregion
117
268
  //#region src/builtins/alerts/runner-alert.ts
118
269
  var RUNNER_ALERT_CATEGORIES = [
119
270
  "process.crashed",
@@ -156,10 +307,13 @@ function foldRunnerEvent(previous, category, data, key, now) {
156
307
  addonIds: []
157
308
  };
158
309
  const addonIds = [...new Set([...base.addonIds, ...strList(data, "addonIds")])];
310
+ const displayName = base.displayName ?? str(data, "displayName");
311
+ const named = displayName !== void 0 ? { displayName } : {};
159
312
  const count = base.count + 1;
160
313
  switch (category) {
161
314
  case "addon.runner-refused": return {
162
315
  ...base,
316
+ ...named,
163
317
  state: "refused",
164
318
  count,
165
319
  addonIds,
@@ -169,15 +323,23 @@ function foldRunnerEvent(previous, category, data, key, now) {
169
323
  case "addon.runner-failed": {
170
324
  if (base.state === "refused") return {
171
325
  ...base,
326
+ ...named,
172
327
  count,
173
328
  addonIds
174
329
  };
175
330
  const crashes = data["crashesInWindow"];
331
+ const cause = str(data, "lastError");
332
+ const exitCode = data["exitCode"];
333
+ const signal = str(data, "signal");
176
334
  return {
177
335
  ...base,
336
+ ...named,
178
337
  state: "failed",
179
338
  count,
180
339
  addonIds,
340
+ ...cause !== void 0 ? { lastError: cause } : {},
341
+ ...typeof exitCode === "number" ? { exitCode } : {},
342
+ ...signal !== void 0 ? { signal } : {},
181
343
  ...typeof crashes === "number" ? { crashesInWindow: crashes } : {}
182
344
  };
183
345
  }
@@ -186,35 +348,55 @@ function foldRunnerEvent(previous, category, data, key, now) {
186
348
  const addonId = str(data, "addonId");
187
349
  return {
188
350
  ...base,
351
+ ...named,
189
352
  count,
190
353
  addonIds: addonId !== void 0 ? [...new Set([...addonIds, addonId])] : addonIds,
191
- ...error !== void 0 ? { lastError: error } : {}
354
+ ...error !== void 0 && !error.startsWith("Crash circuit-breaker tripped") ? { lastError: error } : {}
192
355
  };
193
356
  }
194
357
  case "process.crashed": return {
195
358
  ...base,
359
+ ...named,
196
360
  count,
197
361
  addonIds
198
362
  };
199
363
  }
200
364
  }
365
+ /** `Core block "TV" (core-block-x)`, `Addon "Reolink" (reolink)`; the bare id when no name is known. */
366
+ function runnerLabel(record) {
367
+ const { displayName, runnerId } = record;
368
+ if (displayName === void 0) return `"${runnerId}"`;
369
+ return `${runnerId.startsWith("core-block-") ? "Core block" : "Addon"} "${displayName}" (${runnerId})`;
370
+ }
371
+ /** `: <cause>`; with no cause known, how the process left (`: exit code 1`), else nothing. */
372
+ function failureCause(record) {
373
+ if (record.lastError !== void 0) return `: ${record.lastError}`;
374
+ if (record.signal !== void 0) return `: killed by ${record.signal}`;
375
+ if (record.exitCode !== void 0) return `: exit code ${String(record.exitCode)}`;
376
+ return "";
377
+ }
201
378
  function renderRunnerAlert(record) {
202
- const where = record.nodeId === "hub" ? record.runnerId : `${record.runnerId} on ${record.nodeId}`;
379
+ const named = record.displayName !== void 0;
380
+ const on = record.nodeId === "hub" ? "" : ` on ${record.nodeId}`;
381
+ const label = `${runnerLabel(record)}${on}`;
203
382
  switch (record.state) {
204
383
  case "refused": return {
205
384
  severity: "critical",
206
385
  title: "Addon refused to start",
207
- message: `${where}: refused - ${record.reason ?? "no reason reported"}${record.remedy !== void 0 ? ` ${record.remedy}` : ""}`
208
- };
209
- case "failed": return {
210
- severity: "critical",
211
- title: "Addon crash loop",
212
- message: `Runner "${where}" gave up${record.crashesInWindow !== void 0 ? ` after ${String(record.crashesInWindow)} crashes` : ""}${record.addonIds.length > 0 ? ` (addons: ${record.addonIds.join(", ")})` : ""} - ${String(record.count)} events`
386
+ message: `${named ? label : `${record.runnerId}${on}`}: refused - ${record.reason ?? "no reason reported"}${record.remedy !== void 0 ? ` ${record.remedy}` : ""}`
213
387
  };
388
+ case "failed": {
389
+ const others = record.addonIds.filter((id) => id !== record.runnerId);
390
+ return {
391
+ severity: "critical",
392
+ title: "Addon crash loop",
393
+ message: `${named ? label : `Runner ${label}`} gave up${record.crashesInWindow !== void 0 ? ` after ${String(record.crashesInWindow)} crashes` : ""}${failureCause(record)}${others.length > 0 ? ` (addons: ${others.join(", ")})` : ""} - ${String(record.count)} events`
394
+ };
395
+ }
214
396
  case "crashed": return {
215
397
  severity: "error",
216
398
  title: "Addon crashed",
217
- message: `Addon "${where}" crashed${record.lastError !== void 0 ? `: ${record.lastError}` : ""}${record.count > 1 ? ` (${String(record.count)} events)` : ""}`
399
+ message: `${named ? label : `Addon ${label}`} crashed${record.lastError !== void 0 ? `: ${record.lastError}` : ""}${record.count > 1 ? ` (${String(record.count)} events)` : ""}`
218
400
  };
219
401
  }
220
402
  }
@@ -674,6 +856,9 @@ function parseRunnerRecord(value) {
674
856
  since: typeof rec["since"] === "number" ? rec["since"] : 0,
675
857
  count: rec["count"],
676
858
  addonIds: rec["addonIds"].filter((x) => typeof x === "string"),
859
+ ...typeof rec["displayName"] === "string" ? { displayName: rec["displayName"] } : {},
860
+ ...typeof rec["exitCode"] === "number" ? { exitCode: rec["exitCode"] } : {},
861
+ ...typeof rec["signal"] === "string" ? { signal: rec["signal"] } : {},
677
862
  ...typeof rec["lastError"] === "string" ? { lastError: rec["lastError"] } : {},
678
863
  ...typeof rec["reason"] === "string" ? { reason: rec["reason"] } : {},
679
864
  ...typeof rec["remedy"] === "string" ? { remedy: rec["remedy"] } : {},
@@ -687,6 +872,8 @@ function parseAlert(record) {
687
872
  ...record.data
688
873
  });
689
874
  }
875
+ /** Upper bound on the name lookup of a runner alert; past it the alert names the id. */
876
+ var RUNNER_NAME_LOOKUP_MS = 1500;
690
877
  var DEFAULT_CONFIG = {
691
878
  maxAlerts: 500,
692
879
  retentionDays: 30
@@ -987,7 +1174,12 @@ var AlertCenterAddon = class extends require_dist.BaseAddon {
987
1174
  if (key === null) return;
988
1175
  const alertId = runnerAlertId(key.nodeId, key.runnerId);
989
1176
  const previous = await this.readRunnerRecord(alertId);
990
- const record = foldRunnerEvent(previous, category, event.data, key, Date.now());
1177
+ const folded = foldRunnerEvent(previous, category, event.data, key, Date.now());
1178
+ const displayName = folded.displayName ?? await this.resolveRunnerName(key.runnerId, folded.addonIds);
1179
+ const record = displayName === void 0 ? folded : {
1180
+ ...folded,
1181
+ displayName
1182
+ };
991
1183
  const rendered = renderRunnerAlert(record);
992
1184
  const existing = await this.readAlertRaw(alertId);
993
1185
  const now = Date.now();
@@ -1534,6 +1726,36 @@ var AlertCenterAddon = class extends require_dist.BaseAddon {
1534
1726
  this.ctx.logger?.debug("legacy stream cards: sweep failed", { meta: { error: require_dist.errMsg(err) } });
1535
1727
  }
1536
1728
  }
1729
+ /**
1730
+ * The operator-facing name of a runner: a core block's `name`, an addon's
1731
+ * manifest name. Bounded and never throwing - the alert must go out with the
1732
+ * id when the lookup is slow or fails (D49).
1733
+ */
1734
+ async resolveRunnerName(runnerId, addonIds) {
1735
+ const lookup = async () => {
1736
+ if (runnerId.startsWith("core-block-")) {
1737
+ const { block } = await this.ctx.api.coreBlocks.get.query({ blockId: runnerId.slice(require_dist.CORE_BLOCK_ADDON_PREFIX.length) });
1738
+ return block?.name;
1739
+ }
1740
+ const hosted = addonIds.length === 1 ? addonIds[0] : void 0;
1741
+ return (await this.ctx.api.addons.list.query()).find((i) => i.manifest.id === runnerId || i.manifest.id === hosted)?.manifest.name;
1742
+ };
1743
+ let timer;
1744
+ try {
1745
+ const trimmed = (await Promise.race([lookup(), new Promise((resolve) => {
1746
+ timer = setTimeout(() => resolve(void 0), RUNNER_NAME_LOOKUP_MS);
1747
+ })]))?.trim();
1748
+ return trimmed !== void 0 && trimmed.length > 0 ? trimmed : void 0;
1749
+ } catch (err) {
1750
+ this.ctx.logger?.debug("resolveRunnerName failed, showing the runner id", { meta: {
1751
+ runnerId,
1752
+ error: require_dist.errMsg(err)
1753
+ } });
1754
+ return;
1755
+ } finally {
1756
+ if (timer !== void 0) clearTimeout(timer);
1757
+ }
1758
+ }
1537
1759
  async resolveDeviceName(deviceId) {
1538
1760
  try {
1539
1761
  const device = await this.ctx.api.deviceManager.getDevice.query({ deviceId });
@@ -1551,12 +1773,6 @@ var AlertCenterAddon = class extends require_dist.BaseAddon {
1551
1773
  const error = data.error;
1552
1774
  const processId = data.processId;
1553
1775
  switch (category) {
1554
- case "addon.crashed": return `Addon "${addonId ?? "unknown"}" crashed${error ? `: ${error}` : ""}`;
1555
- case "addon.runner-failed": {
1556
- const runnerId = typeof data.runnerId === "string" ? data.runnerId : "unknown";
1557
- const addonIds = Array.isArray(data.addonIds) ? data.addonIds.filter((x) => typeof x === "string").join(", ") : "";
1558
- return `Runner "${runnerId}" gave up${addonIds.length > 0 ? ` (addons: ${addonIds})` : ""}`;
1559
- }
1560
1776
  case "addon.error": return `Addon "${addonId ?? "unknown"}" error${error ? `: ${error}` : ""}`;
1561
1777
  case "addon.installed": return `Addon "${addonId ?? "unknown"}" installed`;
1562
1778
  case "addon.updated": {
@@ -1721,3 +1937,10 @@ var AlertCenterAddon = class extends require_dist.BaseAddon {
1721
1937
  //#endregion
1722
1938
  exports.AlertCenterAddon = AlertCenterAddon;
1723
1939
  exports.default = AlertCenterAddon;
1940
+ exports.CRASH_BREAKER_ERROR_PREFIX = CRASH_BREAKER_ERROR_PREFIX;
1941
+ exports.isCredentialKeyName = isCredentialKeyName;
1942
+ exports.lastCauseAfterChunk = lastCauseAfterChunk;
1943
+ exports.readRunnerDisplayName = readRunnerDisplayName;
1944
+ exports.redactLogEntry = redactLogEntry;
1945
+ exports.redactLogMeta = redactLogMeta;
1946
+ exports.redactLogText = redactLogText;