@camstack/system 1.0.5 → 1.0.7

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.
@@ -1,6 +1,15 @@
1
1
  export interface PidStats {
2
2
  cpu: number;
3
3
  memory: number;
4
+ /**
5
+ * Private anonymous resident bytes (Linux RssAnon) — per-process V8 heap +
6
+ * native allocs NOT shared across processes. The meaningful "what this runner
7
+ * actually costs" number (RSS double-counts the shared mmap'd framework).
8
+ * undefined where /proc/<pid>/status is unavailable (e.g. macOS).
9
+ */
10
+ privateBytes?: number;
11
+ /** Shared file-backed resident bytes (Linux RssFile). undefined on macOS. */
12
+ sharedBytes?: number;
4
13
  }
5
14
  /**
6
15
  * Get CPU% and memory RSS for one or more PIDs.
@@ -1,10 +1,28 @@
1
1
  import { r as __exportAll } from "./chunk-CNf5ZN-e.mjs";
2
+ import * as fs from "node:fs";
2
3
  import { execFile } from "node:child_process";
3
4
  //#region src/process/resource-monitor.ts
4
5
  var resource_monitor_exports = /* @__PURE__ */ __exportAll({
5
6
  getPidStats: () => getPidStats,
6
7
  getSinglePidStats: () => getSinglePidStats
7
8
  });
9
+ /**
10
+ * Read RssAnon / RssFile (KB) from /proc/<pid>/status. Linux-only; returns
11
+ * undefined fields anywhere /proc is absent. Cheap (one small file read).
12
+ */
13
+ function readProcRss(pid) {
14
+ try {
15
+ const status = fs.readFileSync(`/proc/${pid}/status`, "utf8");
16
+ const anon = status.match(/^RssAnon:\s+(\d+)/m);
17
+ const file = status.match(/^RssFile:\s+(\d+)/m);
18
+ return {
19
+ privateBytes: anon ? parseInt(anon[1], 10) * 1024 : void 0,
20
+ sharedBytes: file ? parseInt(file[1], 10) * 1024 : void 0
21
+ };
22
+ } catch {
23
+ return {};
24
+ }
25
+ }
8
26
  function execPsForPids(pids) {
9
27
  return new Promise((resolve, reject) => {
10
28
  execFile("ps", [
@@ -31,7 +49,8 @@ function parsePsOutput(stdout) {
31
49
  if (isNaN(pid) || isNaN(cpu) || isNaN(rssKb)) continue;
32
50
  result.set(pid, {
33
51
  cpu: Math.round(cpu * 10) / 10,
34
- memory: rssKb * 1024
52
+ memory: rssKb * 1024,
53
+ ...readProcRss(pid)
35
54
  });
36
55
  }
37
56
  return result;
@@ -1,10 +1,29 @@
1
1
  const require_chunk = require("./chunk-Cek0wNdY.js");
2
+ let node_fs = require("node:fs");
3
+ node_fs = require_chunk.__toESM(node_fs);
2
4
  let node_child_process = require("node:child_process");
3
5
  //#region src/process/resource-monitor.ts
4
6
  var resource_monitor_exports = /* @__PURE__ */ require_chunk.__exportAll({
5
7
  getPidStats: () => getPidStats,
6
8
  getSinglePidStats: () => getSinglePidStats
7
9
  });
10
+ /**
11
+ * Read RssAnon / RssFile (KB) from /proc/<pid>/status. Linux-only; returns
12
+ * undefined fields anywhere /proc is absent. Cheap (one small file read).
13
+ */
14
+ function readProcRss(pid) {
15
+ try {
16
+ const status = node_fs.readFileSync(`/proc/${pid}/status`, "utf8");
17
+ const anon = status.match(/^RssAnon:\s+(\d+)/m);
18
+ const file = status.match(/^RssFile:\s+(\d+)/m);
19
+ return {
20
+ privateBytes: anon ? parseInt(anon[1], 10) * 1024 : void 0,
21
+ sharedBytes: file ? parseInt(file[1], 10) * 1024 : void 0
22
+ };
23
+ } catch {
24
+ return {};
25
+ }
26
+ }
8
27
  function execPsForPids(pids) {
9
28
  return new Promise((resolve, reject) => {
10
29
  (0, node_child_process.execFile)("ps", [
@@ -31,7 +50,8 @@ function parsePsOutput(stdout) {
31
50
  if (isNaN(pid) || isNaN(cpu) || isNaN(rssKb)) continue;
32
51
  result.set(pid, {
33
52
  cpu: Math.round(cpu * 10) / 10,
34
- memory: rssKb * 1024
53
+ memory: rssKb * 1024,
54
+ ...readProcRss(pid)
35
55
  });
36
56
  }
37
57
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/system",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Core addon for CamStack — builtins, pipeline, process management, auth, logging, events",
5
5
  "keywords": [
6
6
  "camstack",
@@ -23,6 +23,11 @@
23
23
  "import": "./dist/index.mjs",
24
24
  "require": "./dist/index.js"
25
25
  },
26
+ "./addon-utils": {
27
+ "types": "./dist/addon-utils.d.ts",
28
+ "import": "./dist/addon-utils.mjs",
29
+ "require": "./dist/addon-utils.js"
30
+ },
26
31
  "./package.json": "./package.json"
27
32
  },
28
33
  "camstack": {