@camstack/server 1.2.789 → 1.2.791

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 (131) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/agent/agent-child-manifest.js +39 -0
  3. package/dist/agent/agent-hub-registration.js +11 -1
  4. package/dist/agent/forward-to-hub.js +43 -0
  5. package/dist/agent/main.js +31 -81
  6. package/dist/agent/stale-addon-gate.js +70 -34
  7. package/dist/api/trpc/device-config-secret-redaction.js +14 -1
  8. package/dist/api/trpc/generated-cap-mounts.js +1 -6
  9. package/dist/api/trpc/generated-cap-routers.js +1245 -1417
  10. package/dist/api/trpc/localized-schema-paths.js +1 -0
  11. package/dist/core/addon/addon-registry.service.js +25 -33
  12. package/dist/core/addon/addon-settings-provider.js +57 -0
  13. package/dist/core/addon/boot-health-snapshot.js +0 -28
  14. package/dist/core/addon/{hub-spawn-gate.js → hub-addon-support.js} +12 -35
  15. package/dist/core/moleculer/moleculer.service.js +2 -13
  16. package/dist/core/moleculer/runner-hosted-on-node.js +23 -0
  17. package/dist/core/updates/required-addon-update.js +1 -1
  18. package/package.json +20 -11
  19. package/system/dist/addon-runner.js +22 -0
  20. package/system/dist/addon-runner.mjs +22 -0
  21. package/system/dist/{agent-https-szf2FU49.mjs → agent-https-BmVaVskH.mjs} +1 -1
  22. package/system/dist/{agent-https-jJDe-XNl.js → agent-https-DOs15BCJ.js} +1 -1
  23. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  24. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  25. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  26. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  27. package/system/dist/builtins/alerts/alerts.addon.d.ts +8 -0
  28. package/system/dist/builtins/alerts/alerts.addon.js +72 -1
  29. package/system/dist/builtins/alerts/alerts.addon.mjs +72 -1
  30. package/system/dist/builtins/autotrack/autotrack.addon.d.ts +7 -7
  31. package/system/dist/builtins/autotrack/index.js +15 -8
  32. package/system/dist/builtins/autotrack/index.mjs +15 -8
  33. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  34. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  35. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  36. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  37. package/system/dist/builtins/camera-grid/index.js +1 -1
  38. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  39. package/system/dist/builtins/composer/composer.addon.js +3 -3
  40. package/system/dist/builtins/composer/composer.addon.mjs +3 -3
  41. package/system/dist/builtins/console-logging/index.js +1 -1
  42. package/system/dist/builtins/console-logging/index.mjs +1 -1
  43. package/system/dist/builtins/core-blocks/core-blocks.addon.js +11 -5
  44. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +11 -5
  45. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  46. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  47. package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
  48. package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  49. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  50. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  51. package/system/dist/builtins/keychain/index.js +4 -4
  52. package/system/dist/builtins/keychain/index.mjs +4 -4
  53. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  54. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  55. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  56. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  57. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  58. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  59. package/system/dist/builtins/loki-logging/index.js +1 -1
  60. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  61. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  62. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  63. package/system/dist/builtins/platform-probe/index.js +1 -1
  64. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  65. package/system/dist/builtins/record-entries/index.js +1 -1
  66. package/system/dist/builtins/record-entries/index.mjs +1 -1
  67. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.d.ts +4 -10
  68. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +16 -9
  69. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +16 -9
  70. package/system/dist/builtins/snapshot/index.js +1 -1
  71. package/system/dist/builtins/snapshot/index.mjs +1 -1
  72. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  73. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  74. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  75. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  76. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  77. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  78. package/system/dist/builtins/storage-orchestrator/access-guards.d.ts +1 -1
  79. package/system/dist/builtins/storage-orchestrator/custom-actions.d.ts +11 -0
  80. package/system/dist/builtins/storage-orchestrator/index.d.ts +1 -0
  81. package/system/dist/builtins/storage-orchestrator/index.js +2 -0
  82. package/system/dist/builtins/storage-orchestrator/index.mjs +2 -2
  83. package/system/dist/builtins/storage-orchestrator/location-instances.d.ts +72 -0
  84. package/system/dist/builtins/storage-orchestrator/location-repoint-move.d.ts +1 -1
  85. package/system/dist/builtins/storage-orchestrator/location-secret-refs.d.ts +26 -0
  86. package/system/dist/builtins/storage-orchestrator/location-store.d.ts +28 -2
  87. package/system/dist/builtins/storage-orchestrator/migrations/index.d.ts +9 -2
  88. package/system/dist/builtins/storage-orchestrator/migrations/legacy-location-secret-refs.d.ts +13 -0
  89. package/system/dist/builtins/storage-orchestrator/migrations/location-secret-ports.d.ts +15 -0
  90. package/system/dist/builtins/storage-orchestrator/migrations/location-secrets-to-record.d.ts +57 -0
  91. package/system/dist/builtins/storage-orchestrator/provider-discovery.d.ts +10 -13
  92. package/system/dist/builtins/storage-orchestrator/record-kinds.d.ts +6 -0
  93. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +39 -8
  94. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +954 -131
  95. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +954 -132
  96. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.service.d.ts +8 -0
  97. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  98. package/system/dist/builtins/system-config/system-config.addon.mjs +284 -284
  99. package/system/dist/builtins/winston-logging/index.js +112 -3
  100. package/system/dist/builtins/winston-logging/index.mjs +112 -3
  101. package/system/dist/builtins/winston-logging/migrations/index.d.ts +8 -0
  102. package/system/dist/builtins/winston-logging/migrations/node-fields.d.ts +43 -0
  103. package/system/dist/builtins/winston-logging/winston-logging.addon.d.ts +10 -2
  104. package/system/dist/{capture-engine-DNHgjQot.js → capture-engine-BVpkq9Mv.js} +1 -1
  105. package/system/dist/{capture-engine-BsKY_3xa.mjs → capture-engine-D-oUDtX5.mjs} +1 -1
  106. package/system/dist/{composition-sources-BRdGsbVT.mjs → composition-sources-Br7JhpbD.mjs} +1 -1
  107. package/system/dist/{composition-sources-BgO0GQYW.js → composition-sources-DKCbVA67.js} +1 -1
  108. package/system/dist/{constants-CQeMrR4f.mjs → constants-Bl0Qxbek.mjs} +1 -1
  109. package/system/dist/{constants-C3jGKQSQ.js → constants-CJVY-mUq.js} +1 -1
  110. package/system/dist/{device-ca-ByVi5eUC.mjs → device-ca-BeDGy8NK.mjs} +1 -1
  111. package/system/dist/{device-ca-D3y6wGmn.js → device-ca-i8EbKp3q.js} +1 -1
  112. package/system/dist/{dist-BsQA6-0i.mjs → dist-CPUbgRkb.mjs} +395 -425
  113. package/system/dist/{dist-BRI-Mwx0.js → dist-Ddkk4Dqq.js} +412 -424
  114. package/system/dist/file-host-worker.js +1 -1
  115. package/system/dist/file-host-worker.mjs +1 -1
  116. package/system/dist/{hub-mdns-ciao-8dJTW2LI.mjs → hub-mdns-ciao-DgF4SifE.mjs} +2 -2
  117. package/system/dist/{hub-mdns-ciao-Ry_Jpljx.js → hub-mdns-ciao-lHRHbXqV.js} +2 -2
  118. package/system/dist/index.js +151 -53
  119. package/system/dist/index.mjs +151 -55
  120. package/system/dist/kernel/addon-health-monitor.d.ts +0 -21
  121. package/system/dist/kernel/index.d.ts +2 -0
  122. package/system/dist/kernel/transport/child-cap-protocol.d.ts +1 -1
  123. package/system/dist/kernel/transport/runner-of-addon.d.ts +2 -0
  124. package/system/dist/kernel/unsupported-addon-tracker.d.ts +74 -0
  125. package/system/dist/{legacy-integration-rows-door-CjXTbmvH.mjs → legacy-integration-rows-door-9JSt493H.mjs} +1 -1
  126. package/system/dist/{legacy-integration-rows-door-D5BdSNla.js → legacy-integration-rows-door-n9GIUxgq.js} +1 -1
  127. package/system/dist/{restore-archive-GoWJMdHy.js → restore-archive-BDvLSZtj.js} +1 -1
  128. package/system/dist/{restore-archive-vn4co_kf.mjs → restore-archive-Dh3XnCR1.mjs} +82 -82
  129. package/system/dist/{wal-maintenance-CadfiGWy.mjs → wal-maintenance-BQJAmAwS.mjs} +0 -0
  130. package/system/dist/{wal-maintenance-sSlXJm4k.js → wal-maintenance-CWlz_qRq.js} +0 -0
  131. package/system/package.json +4 -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-BRI-Mwx0.js");
6
+ const require_dist = require("../../dist-Ddkk4Dqq.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");
@@ -14,6 +14,95 @@ let winston = require("winston");
14
14
  winston = require_chunk.__toESM(winston);
15
15
  let winston_daily_rotate_file = require("winston-daily-rotate-file");
16
16
  winston_daily_rotate_file = require_chunk.__toESM(winston_daily_rotate_file);
17
+ //#region src/builtins/winston-logging/migrations/node-fields.ts
18
+ /**
19
+ * The log level and the retention of the rotated files are facts of ONE node: each node writes
20
+ * its own files (D986). They were stored once, as bare rows `<addonId>.<key>`; a node's row is
21
+ * `<addonId>.<key>@<nodeId>` carrying `nodeId`, and a node never falls back to a bare row. The
22
+ * engine's ledger holds one row per migration id for the whole cluster, so the ONE plan writes
23
+ * the rows of every node in `ports.nodeIds()`; a node that joins later starts from the schema
24
+ * default (the rule for any node setting).
25
+ *
26
+ * A bare row is COPIED (the bare row stays for a release) and a value already on a node row is
27
+ * never overwritten (a seed never overwrites). Idempotent: with every node row copied the plan
28
+ * is empty.
29
+ */
30
+ /** The canonical settings table: one row per key, id `<addonId>.<key>`. */
31
+ var ADDON_SETTINGS_TABLE = "addon-settings";
32
+ var nodeKeyOf = (key, nodeId) => `${key}@${nodeId}`;
33
+ async function planNodeFields(addonId, keys, ports) {
34
+ const nodes = await ports.nodeIds();
35
+ const stored = await ports.readStored([...keys, ...nodes.flatMap((nodeId) => keys.map((key) => nodeKeyOf(key, nodeId)))]);
36
+ const sets = {};
37
+ for (const nodeId of nodes) for (const key of keys) {
38
+ const target = nodeKeyOf(key, nodeId);
39
+ if (!(key in stored) || target in stored) continue;
40
+ sets[`${addonId}.${target}`] = {
41
+ addonId,
42
+ key: target,
43
+ value: stored[key],
44
+ nodeId
45
+ };
46
+ }
47
+ const ids = Object.keys(sets);
48
+ if (ids.length === 0) return { edits: [] };
49
+ return { edits: [{
50
+ op: "setKeys",
51
+ scope: ADDON_SETTINGS_TABLE,
52
+ values: sets,
53
+ precondition: require_dist.preconditionOf(Object.fromEntries(ids.map((id) => [id, null])))
54
+ }] };
55
+ }
56
+ /**
57
+ * The port's read over an addon's three-way key read: each of `keys` that has a row, raw. A key
58
+ * the store could not answer for throws, so the migration fails instead of treating a failed read
59
+ * as "nothing to copy".
60
+ */
61
+ async function readRawKeys(read, addonId, keys) {
62
+ const found = {};
63
+ for (const key of keys) {
64
+ const answer = await read(key);
65
+ if (answer.kind === "unreadable") throw new Error(`${addonId}: the setting ${key} cannot be read (${answer.reason})`);
66
+ if (answer.kind === "present") found[key] = answer.value;
67
+ }
68
+ return found;
69
+ }
70
+ /**
71
+ * Every node the hub knows (online or not) plus this one. A node the directory does not list
72
+ * yet is this one while it boots. Throws when the directory cannot be read or is `complete: false`: a copy that missed
73
+ * a node must fail, not report done.
74
+ */
75
+ async function clusterNodeIds(directory, localNodeId) {
76
+ const answer = await directory();
77
+ if (!answer.complete) throw new Error("the node directory is incomplete (no history read answered): not copying");
78
+ const listed = answer.nodes.map((node) => node.id);
79
+ const self = (localNodeId ?? "hub").split("/")[0] ?? "hub";
80
+ return [...new Set([self === "" ? "hub" : self, ...listed])];
81
+ }
82
+ //#endregion
83
+ //#region src/builtins/winston-logging/migrations/index.ts
84
+ var WINSTON_LOGGING_ID = "winston-logging";
85
+ var SETTINGS_PER_NODE_ID = "winston-logging/2026-11-07-settings-per-node";
86
+ /** The two fields of the form: how much THIS node's files hold and for how long. */
87
+ var WINSTON_NODE_KEYS = ["level", "retentionDays"];
88
+ /** The `winston-logging` catalogue (D987): offered to the engine when the addon initialises. */
89
+ var ADDON_MIGRATIONS = [{
90
+ meta: {
91
+ id: SETTINGS_PER_NODE_ID,
92
+ owner: WINSTON_LOGGING_ID,
93
+ level: "addon-state",
94
+ seq: 1,
95
+ dependsOn: [],
96
+ store: "settings",
97
+ scope: "per-node",
98
+ onFailure: "tolerate",
99
+ bodyKind: "plan",
100
+ description: "Copy the log level and the retention to a node row for every node; the bare rows stay for a release",
101
+ fixtureMark: "a setting key the migration does not know"
102
+ },
103
+ plan: (ports) => planNodeFields(WINSTON_LOGGING_ID, WINSTON_NODE_KEYS, ports)
104
+ }];
105
+ //#endregion
17
106
  //#region src/builtins/winston-logging/log-file-read-client.ts
18
107
  /**
19
108
  * The parent side of the rotated-file reader thread (D898).
@@ -233,7 +322,8 @@ var WinstonDestination = class {
233
322
  //#region src/builtins/winston-logging/winston-logging.addon.ts
234
323
  /**
235
324
  * Winston logging addon — rotated log files + console output.
236
- * Settings appear under Cluster → NodeDetail → Settings.
325
+ * Its settings are node settings (D986): each node writes its own files, so the level and the
326
+ * retention are rows `<key>@<nodeId>`, drawn under Cluster → NodeDetail → Settings.
237
327
  */
238
328
  var WinstonLoggingAddon = class extends require_dist.BaseAddon {
239
329
  destination = null;
@@ -243,7 +333,18 @@ var WinstonLoggingAddon = class extends require_dist.BaseAddon {
243
333
  retentionDays: 30
244
334
  });
245
335
  }
336
+ /**
337
+ * Copy the bare level and retention to a node row of every node (D986, D987), then re-resolve
338
+ * the config so this boot opens its files with the node values.
339
+ */
340
+ async migrateNodeFields() {
341
+ if ((await this.runMigrations(require_dist.defineAddonMigrations(ADDON_MIGRATIONS, {
342
+ readStored: (keys) => readRawKeys((key) => this.readStoredGlobalKey(key), "winston-logging", keys),
343
+ nodeIds: () => clusterNodeIds(() => this.ctx.api.nodes.directory.query(), this.ctx.kernel.localNodeId)
344
+ }))).applied.length > 0) await this.resolveConfig();
345
+ }
246
346
  async onInitialize() {
347
+ await this.migrateNodeFields();
247
348
  const logsDir = node_path.default.join(this.ctx.nodeDataDir, "logs");
248
349
  this.destination = new WinstonDestination();
249
350
  await this.destination.initialize({
@@ -264,7 +365,13 @@ var WinstonLoggingAddon = class extends require_dist.BaseAddon {
264
365
  if (!this.destination) throw new Error("Winston not initialized");
265
366
  return this.destination;
266
367
  }
267
- globalSettingsSchema() {
368
+ scopedSettingsCapabilities() {
369
+ return ["log-destination"];
370
+ }
371
+ async nodeSettingsSchema(cap) {
372
+ return cap === "log-destination" ? this.nodeSchema() : null;
373
+ }
374
+ nodeSchema() {
268
375
  return this.schema({ sections: [{
269
376
  id: "winston-logging",
270
377
  title: "Logging",
@@ -275,6 +382,7 @@ var WinstonLoggingAddon = class extends require_dist.BaseAddon {
275
382
  fields: [this.field({
276
383
  type: "select",
277
384
  key: "level",
385
+ perNode: true,
278
386
  label: "Log Level",
279
387
  labelKey: "server:globalSettings.s_winston-logging.level.label",
280
388
  default: "info",
@@ -303,6 +411,7 @@ var WinstonLoggingAddon = class extends require_dist.BaseAddon {
303
411
  }), this.field({
304
412
  type: "number",
305
413
  key: "retentionDays",
414
+ perNode: true,
306
415
  label: "Retention (days)",
307
416
  labelKey: "server:globalSettings.s_winston-logging.retentionDays.label",
308
417
  description: "Number of days to keep rotated log files before deletion",
@@ -1,4 +1,4 @@
1
- import { Lo as BaseAddon, fi as logDestinationCapability } from "../../dist-BsQA6-0i.mjs";
1
+ import { Bo as BaseAddon, Ns as defineAddonMigrations, pi as logDestinationCapability, qi as preconditionOf } from "../../dist-CPUbgRkb.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";
@@ -7,6 +7,95 @@ import path from "node:path";
7
7
  import { Worker } from "node:worker_threads";
8
8
  import * as winston from "winston";
9
9
  import DailyRotateFile from "winston-daily-rotate-file";
10
+ //#region src/builtins/winston-logging/migrations/node-fields.ts
11
+ /**
12
+ * The log level and the retention of the rotated files are facts of ONE node: each node writes
13
+ * its own files (D986). They were stored once, as bare rows `<addonId>.<key>`; a node's row is
14
+ * `<addonId>.<key>@<nodeId>` carrying `nodeId`, and a node never falls back to a bare row. The
15
+ * engine's ledger holds one row per migration id for the whole cluster, so the ONE plan writes
16
+ * the rows of every node in `ports.nodeIds()`; a node that joins later starts from the schema
17
+ * default (the rule for any node setting).
18
+ *
19
+ * A bare row is COPIED (the bare row stays for a release) and a value already on a node row is
20
+ * never overwritten (a seed never overwrites). Idempotent: with every node row copied the plan
21
+ * is empty.
22
+ */
23
+ /** The canonical settings table: one row per key, id `<addonId>.<key>`. */
24
+ var ADDON_SETTINGS_TABLE = "addon-settings";
25
+ var nodeKeyOf = (key, nodeId) => `${key}@${nodeId}`;
26
+ async function planNodeFields(addonId, keys, ports) {
27
+ const nodes = await ports.nodeIds();
28
+ const stored = await ports.readStored([...keys, ...nodes.flatMap((nodeId) => keys.map((key) => nodeKeyOf(key, nodeId)))]);
29
+ const sets = {};
30
+ for (const nodeId of nodes) for (const key of keys) {
31
+ const target = nodeKeyOf(key, nodeId);
32
+ if (!(key in stored) || target in stored) continue;
33
+ sets[`${addonId}.${target}`] = {
34
+ addonId,
35
+ key: target,
36
+ value: stored[key],
37
+ nodeId
38
+ };
39
+ }
40
+ const ids = Object.keys(sets);
41
+ if (ids.length === 0) return { edits: [] };
42
+ return { edits: [{
43
+ op: "setKeys",
44
+ scope: ADDON_SETTINGS_TABLE,
45
+ values: sets,
46
+ precondition: preconditionOf(Object.fromEntries(ids.map((id) => [id, null])))
47
+ }] };
48
+ }
49
+ /**
50
+ * The port's read over an addon's three-way key read: each of `keys` that has a row, raw. A key
51
+ * the store could not answer for throws, so the migration fails instead of treating a failed read
52
+ * as "nothing to copy".
53
+ */
54
+ async function readRawKeys(read, addonId, keys) {
55
+ const found = {};
56
+ for (const key of keys) {
57
+ const answer = await read(key);
58
+ if (answer.kind === "unreadable") throw new Error(`${addonId}: the setting ${key} cannot be read (${answer.reason})`);
59
+ if (answer.kind === "present") found[key] = answer.value;
60
+ }
61
+ return found;
62
+ }
63
+ /**
64
+ * Every node the hub knows (online or not) plus this one. A node the directory does not list
65
+ * yet is this one while it boots. Throws when the directory cannot be read or is `complete: false`: a copy that missed
66
+ * a node must fail, not report done.
67
+ */
68
+ async function clusterNodeIds(directory, localNodeId) {
69
+ const answer = await directory();
70
+ if (!answer.complete) throw new Error("the node directory is incomplete (no history read answered): not copying");
71
+ const listed = answer.nodes.map((node) => node.id);
72
+ const self = (localNodeId ?? "hub").split("/")[0] ?? "hub";
73
+ return [...new Set([self === "" ? "hub" : self, ...listed])];
74
+ }
75
+ //#endregion
76
+ //#region src/builtins/winston-logging/migrations/index.ts
77
+ var WINSTON_LOGGING_ID = "winston-logging";
78
+ var SETTINGS_PER_NODE_ID = "winston-logging/2026-11-07-settings-per-node";
79
+ /** The two fields of the form: how much THIS node's files hold and for how long. */
80
+ var WINSTON_NODE_KEYS = ["level", "retentionDays"];
81
+ /** The `winston-logging` catalogue (D987): offered to the engine when the addon initialises. */
82
+ var ADDON_MIGRATIONS = [{
83
+ meta: {
84
+ id: SETTINGS_PER_NODE_ID,
85
+ owner: WINSTON_LOGGING_ID,
86
+ level: "addon-state",
87
+ seq: 1,
88
+ dependsOn: [],
89
+ store: "settings",
90
+ scope: "per-node",
91
+ onFailure: "tolerate",
92
+ bodyKind: "plan",
93
+ description: "Copy the log level and the retention to a node row for every node; the bare rows stay for a release",
94
+ fixtureMark: "a setting key the migration does not know"
95
+ },
96
+ plan: (ports) => planNodeFields(WINSTON_LOGGING_ID, WINSTON_NODE_KEYS, ports)
97
+ }];
98
+ //#endregion
10
99
  //#region src/builtins/winston-logging/log-file-read-client.ts
11
100
  /**
12
101
  * The parent side of the rotated-file reader thread (D898).
@@ -226,7 +315,8 @@ var WinstonDestination = class {
226
315
  //#region src/builtins/winston-logging/winston-logging.addon.ts
227
316
  /**
228
317
  * Winston logging addon — rotated log files + console output.
229
- * Settings appear under Cluster → NodeDetail → Settings.
318
+ * Its settings are node settings (D986): each node writes its own files, so the level and the
319
+ * retention are rows `<key>@<nodeId>`, drawn under Cluster → NodeDetail → Settings.
230
320
  */
231
321
  var WinstonLoggingAddon = class extends BaseAddon {
232
322
  destination = null;
@@ -236,7 +326,18 @@ var WinstonLoggingAddon = class extends BaseAddon {
236
326
  retentionDays: 30
237
327
  });
238
328
  }
329
+ /**
330
+ * Copy the bare level and retention to a node row of every node (D986, D987), then re-resolve
331
+ * the config so this boot opens its files with the node values.
332
+ */
333
+ async migrateNodeFields() {
334
+ if ((await this.runMigrations(defineAddonMigrations(ADDON_MIGRATIONS, {
335
+ readStored: (keys) => readRawKeys((key) => this.readStoredGlobalKey(key), "winston-logging", keys),
336
+ nodeIds: () => clusterNodeIds(() => this.ctx.api.nodes.directory.query(), this.ctx.kernel.localNodeId)
337
+ }))).applied.length > 0) await this.resolveConfig();
338
+ }
239
339
  async onInitialize() {
340
+ await this.migrateNodeFields();
240
341
  const logsDir = path.join(this.ctx.nodeDataDir, "logs");
241
342
  this.destination = new WinstonDestination();
242
343
  await this.destination.initialize({
@@ -257,7 +358,13 @@ var WinstonLoggingAddon = class extends BaseAddon {
257
358
  if (!this.destination) throw new Error("Winston not initialized");
258
359
  return this.destination;
259
360
  }
260
- globalSettingsSchema() {
361
+ scopedSettingsCapabilities() {
362
+ return ["log-destination"];
363
+ }
364
+ async nodeSettingsSchema(cap) {
365
+ return cap === "log-destination" ? this.nodeSchema() : null;
366
+ }
367
+ nodeSchema() {
261
368
  return this.schema({ sections: [{
262
369
  id: "winston-logging",
263
370
  title: "Logging",
@@ -268,6 +375,7 @@ var WinstonLoggingAddon = class extends BaseAddon {
268
375
  fields: [this.field({
269
376
  type: "select",
270
377
  key: "level",
378
+ perNode: true,
271
379
  label: "Log Level",
272
380
  labelKey: "server:globalSettings.s_winston-logging.level.label",
273
381
  default: "info",
@@ -296,6 +404,7 @@ var WinstonLoggingAddon = class extends BaseAddon {
296
404
  }), this.field({
297
405
  type: "number",
298
406
  key: "retentionDays",
407
+ perNode: true,
299
408
  label: "Retention (days)",
300
409
  labelKey: "server:globalSettings.s_winston-logging.retentionDays.label",
301
410
  description: "Number of days to keep rotated log files before deletion",
@@ -0,0 +1,8 @@
1
+ import type { AddonMigration } from "@camstack/types";
2
+ import { type NodeFieldsPorts } from "./node-fields.js";
3
+ export declare const WINSTON_LOGGING_ID = "winston-logging";
4
+ export declare const SETTINGS_PER_NODE_ID = "winston-logging/2026-11-07-settings-per-node";
5
+ /** The two fields of the form: how much THIS node's files hold and for how long. */
6
+ export declare const WINSTON_NODE_KEYS: readonly string[];
7
+ /** The `winston-logging` catalogue (D987): offered to the engine when the addon initialises. */
8
+ export declare const ADDON_MIGRATIONS: readonly AddonMigration<NodeFieldsPorts>[];
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The log level and the retention of the rotated files are facts of ONE node: each node writes
3
+ * its own files (D986). They were stored once, as bare rows `<addonId>.<key>`; a node's row is
4
+ * `<addonId>.<key>@<nodeId>` carrying `nodeId`, and a node never falls back to a bare row. The
5
+ * engine's ledger holds one row per migration id for the whole cluster, so the ONE plan writes
6
+ * the rows of every node in `ports.nodeIds()`; a node that joins later starts from the schema
7
+ * default (the rule for any node setting).
8
+ *
9
+ * A bare row is COPIED (the bare row stays for a release) and a value already on a node row is
10
+ * never overwritten (a seed never overwrites). Idempotent: with every node row copied the plan
11
+ * is empty.
12
+ */
13
+ import { type MigrationPlan, type StoredKeyRead } from "@camstack/types";
14
+ /** The canonical settings table: one row per key, id `<addonId>.<key>`. */
15
+ export declare const ADDON_SETTINGS_TABLE = "addon-settings";
16
+ export interface NodeFieldsPorts {
17
+ /**
18
+ * The addon's rows as stored (markers kept, nothing resolved), for each of `keys` that has a
19
+ * row; a key without one is left out. Throws when the store cannot be read.
20
+ */
21
+ readStored(keys: readonly string[]): Promise<Readonly<Record<string, unknown>>>;
22
+ /** Every node the field is copied to. Throws when the cluster's nodes cannot be listed. */
23
+ nodeIds(): Promise<readonly string[]>;
24
+ }
25
+ export declare const nodeKeyOf: (key: string, nodeId: string) => string;
26
+ export declare function planNodeFields(addonId: string, keys: readonly string[], ports: NodeFieldsPorts): Promise<MigrationPlan>;
27
+ /**
28
+ * The port's read over an addon's three-way key read: each of `keys` that has a row, raw. A key
29
+ * the store could not answer for throws, so the migration fails instead of treating a failed read
30
+ * as "nothing to copy".
31
+ */
32
+ export declare function readRawKeys(read: (key: string) => Promise<StoredKeyRead>, addonId: string, keys: readonly string[]): Promise<Record<string, unknown>>;
33
+ /**
34
+ * Every node the hub knows (online or not) plus this one. A node the directory does not list
35
+ * yet is this one while it boots. Throws when the directory cannot be read or is `complete: false`: a copy that missed
36
+ * a node must fail, not report done.
37
+ */
38
+ export declare function clusterNodeIds(directory: () => Promise<{
39
+ readonly nodes: readonly {
40
+ readonly id: string;
41
+ }[];
42
+ readonly complete: boolean;
43
+ }>, localNodeId: string | undefined): Promise<readonly string[]>;
@@ -7,14 +7,22 @@ interface WinstonConfig {
7
7
  }
8
8
  /**
9
9
  * Winston logging addon — rotated log files + console output.
10
- * Settings appear under Cluster → NodeDetail → Settings.
10
+ * Its settings are node settings (D986): each node writes its own files, so the level and the
11
+ * retention are rows `<key>@<nodeId>`, drawn under Cluster → NodeDetail → Settings.
11
12
  */
12
13
  export declare class WinstonLoggingAddon extends BaseAddon<WinstonConfig> {
13
14
  private destination;
14
15
  constructor();
16
+ /**
17
+ * Copy the bare level and retention to a node row of every node (D986, D987), then re-resolve
18
+ * the config so this boot opens its files with the node values.
19
+ */
20
+ private migrateNodeFields;
15
21
  protected onInitialize(): Promise<ProviderRegistration[]>;
16
22
  protected onShutdown(): Promise<void>;
17
23
  getDestination(): WinstonDestination;
18
- protected globalSettingsSchema(): ConfigUISchema;
24
+ protected override scopedSettingsCapabilities(): readonly string[];
25
+ protected override nodeSettingsSchema(cap: string): Promise<ConfigUISchema | null>;
26
+ private nodeSchema;
19
27
  }
20
28
  export {};
@@ -1,4 +1,4 @@
1
- const require_dist = require("./dist-BRI-Mwx0.js");
1
+ const require_dist = require("./dist-Ddkk4Dqq.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 { Ko as HISTORY_DEFAULT_MIN_INTERVAL_MS, wc as DeviceType, zs as historyItemFieldPath } from "./dist-BsQA6-0i.mjs";
1
+ import { Dc as DeviceType, Hs as historyItemFieldPath, Yo as HISTORY_DEFAULT_MIN_INTERVAL_MS } from "./dist-CPUbgRkb.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
- import { Tc as errMsg, yo as compositionSourceKey } from "./dist-BsQA6-0i.mjs";
1
+ import { Oc as errMsg, So as compositionSourceKey } from "./dist-CPUbgRkb.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
- const require_dist = require("./dist-BRI-Mwx0.js");
1
+ const require_dist = require("./dist-Ddkk4Dqq.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 { Cs as buildSecretRef } from "./dist-BsQA6-0i.mjs";
1
+ import { Es as buildSecretRef } from "./dist-CPUbgRkb.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-BRI-Mwx0.js").buildSecretRef({
2
+ var MESH_CA_KEY_REF = require("./dist-Ddkk4Dqq.js").buildSecretRef({
3
3
  owner: "system",
4
4
  scope: { kind: "global" },
5
5
  fieldPath: "meshCaKey"
@@ -1,4 +1,4 @@
1
- import { Cs as buildSecretRef, G as DEVICE_SAN_USER_PREFIX, W as DEVICE_SAN_CREDENTIAL_PREFIX } from "./dist-BsQA6-0i.mjs";
1
+ import { Es as buildSecretRef, G as DEVICE_SAN_USER_PREFIX, W as DEVICE_SAN_CREDENTIAL_PREFIX } from "./dist-CPUbgRkb.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
@@ -1,4 +1,4 @@
1
- const require_dist = require("./dist-BRI-Mwx0.js");
1
+ const require_dist = require("./dist-Ddkk4Dqq.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