@camstack/system 1.2.310 → 1.2.312

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 (68) hide show
  1. package/dist/addon-runner.js +6 -8
  2. package/dist/addon-runner.mjs +6 -8
  3. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  4. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  5. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  6. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  7. package/dist/builtins/alerts/alerts.addon.js +1 -1
  8. package/dist/builtins/alerts/alerts.addon.mjs +1 -1
  9. package/dist/builtins/autotrack/index.js +1 -1
  10. package/dist/builtins/autotrack/index.mjs +1 -1
  11. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
  12. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
  13. package/dist/builtins/camera-grid/index.js +1 -1
  14. package/dist/builtins/camera-grid/index.mjs +1 -1
  15. package/dist/builtins/composer/composer.addon.js +1 -1
  16. package/dist/builtins/composer/composer.addon.mjs +1 -1
  17. package/dist/builtins/console-logging/index.js +1 -1
  18. package/dist/builtins/console-logging/index.mjs +1 -1
  19. package/dist/builtins/core-blocks/core-blocks.addon.js +1 -1
  20. package/dist/builtins/core-blocks/core-blocks.addon.mjs +1 -1
  21. package/dist/builtins/device-manager/device-manager.addon.js +2 -2
  22. package/dist/builtins/device-manager/device-manager.addon.mjs +2 -2
  23. package/dist/builtins/doorbell/virtual-doorbell.addon.js +1 -1
  24. package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +1 -1
  25. package/dist/builtins/hub-forwarder/index.js +1 -1
  26. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  27. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  28. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  29. package/dist/builtins/local-auth/local-auth.addon.js +1 -1
  30. package/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
  31. package/dist/builtins/local-network/local-network.addon.js +1 -1
  32. package/dist/builtins/local-network/local-network.addon.mjs +1 -1
  33. package/dist/builtins/loki-logging/index.js +1 -1
  34. package/dist/builtins/loki-logging/index.mjs +1 -1
  35. package/dist/builtins/native-metrics/native-metrics.addon.js +10 -102
  36. package/dist/builtins/native-metrics/native-metrics.addon.mjs +4 -92
  37. package/dist/builtins/platform-probe/index.js +1 -1
  38. package/dist/builtins/platform-probe/index.mjs +1 -1
  39. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  40. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  41. package/dist/builtins/snapshot/index.js +1 -1
  42. package/dist/builtins/snapshot/index.mjs +1 -1
  43. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  44. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  45. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +0 -0
  46. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +0 -0
  47. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  48. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  49. package/dist/builtins/system-config/system-config.addon.js +1 -1
  50. package/dist/builtins/system-config/system-config.addon.mjs +1 -1
  51. package/dist/builtins/winston-logging/index.js +1 -1
  52. package/dist/builtins/winston-logging/index.mjs +1 -1
  53. package/dist/{child-cap-dispatch-BCJjUtXV.mjs → child-cap-dispatch-CHTiHbsv.mjs} +294 -10
  54. package/dist/{child-cap-dispatch-Be8e2cBP.js → child-cap-dispatch-Dyn_7ezH.js} +347 -9
  55. package/dist/{dist-B78pkrps.mjs → dist-Cj7pJmXq.mjs} +35 -4
  56. package/dist/{dist-Cy6DFFjs.js → dist-CkRwnhbo.js} +35 -4
  57. package/dist/index.js +88 -18
  58. package/dist/index.mjs +89 -20
  59. package/dist/kernel/index.d.ts +1 -0
  60. package/dist/kernel/moleculer/process-service.d.ts +9 -0
  61. package/dist/kernel/moleculer/runner-process-group.d.ts +92 -0
  62. package/dist/proc-stat-CbC55Kqi.mjs +92 -0
  63. package/dist/proc-stat-DL-WUOhl.js +127 -0
  64. package/dist/{resource-monitor-Vp0bPV3U.mjs → resource-monitor-B1v6E07R.mjs} +1 -1
  65. package/dist/{resource-monitor-LVE1BoLs.js → resource-monitor-DzNn_IZK.js} +5 -5
  66. package/dist/{retired-settings-keys-B4_hiWsm.mjs → retired-settings-keys-C1duPikd.mjs} +1 -1
  67. package/dist/{retired-settings-keys-D9sgD6Yg.js → retired-settings-keys-CGSuXhP8.js} +1 -1
  68. package/package.json +1 -1
@@ -0,0 +1,92 @@
1
+ import { readFile, readdir } from "node:fs/promises";
2
+ /**
3
+ * Parse one `/proc/<pid>/stat` line. `null` for a line that does not parse —
4
+ * a process that exited between the readdir and the read leaves a truncated
5
+ * or empty file, and that is normal, not an error.
6
+ */
7
+ function parseProcStat(line) {
8
+ const close = line.lastIndexOf(")");
9
+ const open = line.indexOf("(");
10
+ if (close < 0 || open < 0 || close < open) return null;
11
+ const pid = Number(line.slice(0, open).trim());
12
+ const comm = line.slice(open + 1, close);
13
+ const rest = line.slice(close + 1).trim().split(/\s+/);
14
+ const state = rest[0];
15
+ const ppid = Number(rest[1]);
16
+ const pgid = Number(rest[2]);
17
+ const utime = Number(rest[11]);
18
+ const stime = Number(rest[12]);
19
+ const startTicks = Number(rest[19]);
20
+ const rssPages = Number(rest[21]);
21
+ if (state === void 0 || state === "") return null;
22
+ if (![
23
+ pid,
24
+ ppid,
25
+ pgid,
26
+ utime,
27
+ stime,
28
+ startTicks,
29
+ rssPages
30
+ ].every(Number.isFinite)) return null;
31
+ return {
32
+ pid,
33
+ comm,
34
+ state,
35
+ ppid,
36
+ pgid,
37
+ ticks: utime + stime,
38
+ startTicks,
39
+ rssPages
40
+ };
41
+ }
42
+ function statusKb(status, key) {
43
+ const match = status.match(new RegExp(`^${key}:\\s+(\\d+)`, "m"));
44
+ return match ? parseInt(match[1], 10) * 1024 : void 0;
45
+ }
46
+ /** Read `VmRSS` / `RssAnon` / `RssFile` (kB in the file) out of `/proc/<pid>/status`. */
47
+ function parseProcStatusRss(status) {
48
+ return {
49
+ rssBytes: statusKb(status, "VmRSS"),
50
+ privateBytes: statusKb(status, "RssAnon"),
51
+ sharedBytes: statusKb(status, "RssFile")
52
+ };
53
+ }
54
+ /** Seconds the process has been alive — `ps etime`, whole seconds. */
55
+ function elapsedSecSince(input) {
56
+ return Math.max(0, Math.floor(input.uptimeSec - input.startTicks / 100));
57
+ }
58
+ /**
59
+ * `ps pcpu`: CPU time over elapsed time, as a percentage with one decimal.
60
+ *
61
+ * This is deliberately the LIFETIME average `ps` prints, not an instantaneous
62
+ * rate: the columns fed from it have always shown that quantity, and the
63
+ * instantaneous split is a different number with a different owner
64
+ * (`cpuMainPercent` / `cpuGcPercent` from `thread-cpu-sampler.ts`). A process
65
+ * with no elapsed window yet reports 0, never a division by zero.
66
+ */
67
+ function lifetimeCpuPercent(input) {
68
+ const elapsedSec = input.uptimeSec - input.startTicks / 100;
69
+ if (!(elapsedSec > 0)) return 0;
70
+ const cpuSec = input.ticks / 100;
71
+ return Math.round(cpuSec / elapsedSec * 1e3) / 10;
72
+ }
73
+ var PID_RE = /^\d+$/;
74
+ var nodeProcReader = {
75
+ listPids: async () => (await readdir("/proc")).filter((entry) => PID_RE.test(entry)).map((entry) => Number(entry)),
76
+ readStat: (pid) => readFile(`/proc/${pid}/stat`, "latin1"),
77
+ readStatus: (pid) => readFile(`/proc/${pid}/status`, "latin1"),
78
+ readCmdline: (pid) => readFile(`/proc/${pid}/cmdline`, "latin1"),
79
+ readUptimeSec: async () => {
80
+ const [first] = (await readFile("/proc/uptime", "latin1")).trim().split(/\s+/);
81
+ const seconds = Number(first);
82
+ if (!Number.isFinite(seconds)) throw new Error(`/proc/uptime unreadable: ${String(first)}`);
83
+ return seconds;
84
+ }
85
+ };
86
+ /** `ps command=`: argv joined by spaces, or `[comm]` when there is no argv. */
87
+ function commandFromCmdline(cmdline, comm) {
88
+ const joined = cmdline.split("\0").filter((part) => part.length > 0).join(" ");
89
+ return joined.length > 0 ? joined : `[${comm}]`;
90
+ }
91
+ //#endregion
92
+ export { parseProcStat as a, nodeProcReader as i, elapsedSecSince as n, parseProcStatusRss as o, lifetimeCpuPercent as r, commandFromCmdline as t };
@@ -0,0 +1,127 @@
1
+ let node_fs_promises = require("node:fs/promises");
2
+ /**
3
+ * Parse one `/proc/<pid>/stat` line. `null` for a line that does not parse —
4
+ * a process that exited between the readdir and the read leaves a truncated
5
+ * or empty file, and that is normal, not an error.
6
+ */
7
+ function parseProcStat(line) {
8
+ const close = line.lastIndexOf(")");
9
+ const open = line.indexOf("(");
10
+ if (close < 0 || open < 0 || close < open) return null;
11
+ const pid = Number(line.slice(0, open).trim());
12
+ const comm = line.slice(open + 1, close);
13
+ const rest = line.slice(close + 1).trim().split(/\s+/);
14
+ const state = rest[0];
15
+ const ppid = Number(rest[1]);
16
+ const pgid = Number(rest[2]);
17
+ const utime = Number(rest[11]);
18
+ const stime = Number(rest[12]);
19
+ const startTicks = Number(rest[19]);
20
+ const rssPages = Number(rest[21]);
21
+ if (state === void 0 || state === "") return null;
22
+ if (![
23
+ pid,
24
+ ppid,
25
+ pgid,
26
+ utime,
27
+ stime,
28
+ startTicks,
29
+ rssPages
30
+ ].every(Number.isFinite)) return null;
31
+ return {
32
+ pid,
33
+ comm,
34
+ state,
35
+ ppid,
36
+ pgid,
37
+ ticks: utime + stime,
38
+ startTicks,
39
+ rssPages
40
+ };
41
+ }
42
+ function statusKb(status, key) {
43
+ const match = status.match(new RegExp(`^${key}:\\s+(\\d+)`, "m"));
44
+ return match ? parseInt(match[1], 10) * 1024 : void 0;
45
+ }
46
+ /** Read `VmRSS` / `RssAnon` / `RssFile` (kB in the file) out of `/proc/<pid>/status`. */
47
+ function parseProcStatusRss(status) {
48
+ return {
49
+ rssBytes: statusKb(status, "VmRSS"),
50
+ privateBytes: statusKb(status, "RssAnon"),
51
+ sharedBytes: statusKb(status, "RssFile")
52
+ };
53
+ }
54
+ /** Seconds the process has been alive — `ps etime`, whole seconds. */
55
+ function elapsedSecSince(input) {
56
+ return Math.max(0, Math.floor(input.uptimeSec - input.startTicks / 100));
57
+ }
58
+ /**
59
+ * `ps pcpu`: CPU time over elapsed time, as a percentage with one decimal.
60
+ *
61
+ * This is deliberately the LIFETIME average `ps` prints, not an instantaneous
62
+ * rate: the columns fed from it have always shown that quantity, and the
63
+ * instantaneous split is a different number with a different owner
64
+ * (`cpuMainPercent` / `cpuGcPercent` from `thread-cpu-sampler.ts`). A process
65
+ * with no elapsed window yet reports 0, never a division by zero.
66
+ */
67
+ function lifetimeCpuPercent(input) {
68
+ const elapsedSec = input.uptimeSec - input.startTicks / 100;
69
+ if (!(elapsedSec > 0)) return 0;
70
+ const cpuSec = input.ticks / 100;
71
+ return Math.round(cpuSec / elapsedSec * 1e3) / 10;
72
+ }
73
+ var PID_RE = /^\d+$/;
74
+ var nodeProcReader = {
75
+ listPids: async () => (await (0, node_fs_promises.readdir)("/proc")).filter((entry) => PID_RE.test(entry)).map((entry) => Number(entry)),
76
+ readStat: (pid) => (0, node_fs_promises.readFile)(`/proc/${pid}/stat`, "latin1"),
77
+ readStatus: (pid) => (0, node_fs_promises.readFile)(`/proc/${pid}/status`, "latin1"),
78
+ readCmdline: (pid) => (0, node_fs_promises.readFile)(`/proc/${pid}/cmdline`, "latin1"),
79
+ readUptimeSec: async () => {
80
+ const [first] = (await (0, node_fs_promises.readFile)("/proc/uptime", "latin1")).trim().split(/\s+/);
81
+ const seconds = Number(first);
82
+ if (!Number.isFinite(seconds)) throw new Error(`/proc/uptime unreadable: ${String(first)}`);
83
+ return seconds;
84
+ }
85
+ };
86
+ /** `ps command=`: argv joined by spaces, or `[comm]` when there is no argv. */
87
+ function commandFromCmdline(cmdline, comm) {
88
+ const joined = cmdline.split("\0").filter((part) => part.length > 0).join(" ");
89
+ return joined.length > 0 ? joined : `[${comm}]`;
90
+ }
91
+ //#endregion
92
+ Object.defineProperty(exports, "commandFromCmdline", {
93
+ enumerable: true,
94
+ get: function() {
95
+ return commandFromCmdline;
96
+ }
97
+ });
98
+ Object.defineProperty(exports, "elapsedSecSince", {
99
+ enumerable: true,
100
+ get: function() {
101
+ return elapsedSecSince;
102
+ }
103
+ });
104
+ Object.defineProperty(exports, "lifetimeCpuPercent", {
105
+ enumerable: true,
106
+ get: function() {
107
+ return lifetimeCpuPercent;
108
+ }
109
+ });
110
+ Object.defineProperty(exports, "nodeProcReader", {
111
+ enumerable: true,
112
+ get: function() {
113
+ return nodeProcReader;
114
+ }
115
+ });
116
+ Object.defineProperty(exports, "parseProcStat", {
117
+ enumerable: true,
118
+ get: function() {
119
+ return parseProcStat;
120
+ }
121
+ });
122
+ Object.defineProperty(exports, "parseProcStatusRss", {
123
+ enumerable: true,
124
+ get: function() {
125
+ return parseProcStatusRss;
126
+ }
127
+ });
@@ -1,5 +1,5 @@
1
1
  import { r as __exportAll } from "./chunk-CNf5ZN-e.mjs";
2
- import { i as parseProcStatusRss, n as nodeProcReader, r as parseProcStat, t as lifetimeCpuPercent } from "./builtins/native-metrics/native-metrics.addon.mjs";
2
+ import { a as parseProcStat, i as nodeProcReader, o as parseProcStatusRss, r as lifetimeCpuPercent } from "./proc-stat-CbC55Kqi.mjs";
3
3
  import { execFile } from "node:child_process";
4
4
  import { platform } from "node:os";
5
5
  //#region src/process/resource-monitor.ts
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require("./chunk-Cek0wNdY.js");
2
- const require_builtins_native_metrics_native_metrics_addon = require("./builtins/native-metrics/native-metrics.addon.js");
2
+ const require_proc_stat = require("./proc-stat-DL-WUOhl.js");
3
3
  let node_child_process = require("node:child_process");
4
4
  let node_os = require("node:os");
5
5
  //#region src/process/resource-monitor.ts
@@ -22,7 +22,7 @@ function execPsForPids(pids) {
22
22
  }
23
23
  var defaultDeps = {
24
24
  platform: (0, node_os.platform)(),
25
- reader: require_builtins_native_metrics_native_metrics_addon.nodeProcReader,
25
+ reader: require_proc_stat.nodeProcReader,
26
26
  spawnPs: execPsForPids
27
27
  };
28
28
  function parsePsOutput(stdout) {
@@ -52,12 +52,12 @@ async function readProcPidStats(pid, uptimeSec, reader) {
52
52
  } catch {
53
53
  return null;
54
54
  }
55
- const parsed = require_builtins_native_metrics_native_metrics_addon.parseProcStat(stat);
55
+ const parsed = require_proc_stat.parseProcStat(stat);
56
56
  if (parsed === null) return null;
57
- const rss = require_builtins_native_metrics_native_metrics_addon.parseProcStatusRss(status);
57
+ const rss = require_proc_stat.parseProcStatusRss(status);
58
58
  if (rss.rssBytes === void 0) return null;
59
59
  return {
60
- cpu: require_builtins_native_metrics_native_metrics_addon.lifetimeCpuPercent({
60
+ cpu: require_proc_stat.lifetimeCpuPercent({
61
61
  ticks: parsed.ticks,
62
62
  startTicks: parsed.startTicks,
63
63
  uptimeSec
@@ -1,4 +1,4 @@
1
- import { Vn as asJsonObject } from "./dist-B78pkrps.mjs";
1
+ import { Vn as asJsonObject } from "./dist-Cj7pJmXq.mjs";
2
2
  //#region src/builtins/sqlite-storage/retired-settings-keys.ts
3
3
  /**
4
4
  * Is THIS node the one whose settings store is the cluster's authority?
@@ -1,4 +1,4 @@
1
- const require_dist = require("./dist-Cy6DFFjs.js");
1
+ const require_dist = require("./dist-CkRwnhbo.js");
2
2
  //#region src/builtins/sqlite-storage/retired-settings-keys.ts
3
3
  /**
4
4
  * Is THIS node the one whose settings store is the cluster's authority?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/system",
3
- "version": "1.2.310",
3
+ "version": "1.2.312",
4
4
  "description": "Core addon for CamStack — builtins, pipeline, process management, auth, logging, events",
5
5
  "keywords": [
6
6
  "camstack",