@chrysb/alphaclaw 0.3.2-beta.2 → 0.3.2-beta.3

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.
@@ -361,7 +361,7 @@ export const WatchdogTab = ({
361
361
  onToggle=${() => setMemoryExpanded(true)}
362
362
  />
363
363
  <${ResourceBar}
364
- label="Disk"
364
+ label=${`Disk${r.disk?.path ? ` (${r.disk.path})` : ""}`}
365
365
  percent=${r.disk?.percent}
366
366
  detail=${`${formatBytes(r.disk?.usedBytes)} / ${formatBytes(r.disk?.totalBytes)}`}
367
367
  />
@@ -1,6 +1,7 @@
1
1
  const os = require("os");
2
2
  const fs = require("fs");
3
3
  const { execSync } = require("child_process");
4
+ const { kRootDir } = require("./constants");
4
5
 
5
6
  const readCgroupFile = (filePath) => {
6
7
  try {
@@ -76,6 +77,23 @@ const getProcessUsage = (pid) => {
76
77
  return null;
77
78
  };
78
79
 
80
+ const readDiskUsage = () => {
81
+ const paths = [kRootDir, "/data", "/"];
82
+ for (const diskPath of paths) {
83
+ try {
84
+ const stat = fs.statfsSync(diskPath);
85
+ return {
86
+ usedBytes: stat.bsize * (stat.blocks - stat.bfree),
87
+ totalBytes: stat.bsize * stat.blocks,
88
+ path: diskPath,
89
+ };
90
+ } catch {
91
+ // Try next path.
92
+ }
93
+ }
94
+ return { usedBytes: null, totalBytes: null, path: null };
95
+ };
96
+
79
97
  let prevCpuSnapshot = null;
80
98
  let prevCpuSnapshotAt = 0;
81
99
 
@@ -86,15 +104,7 @@ const getSystemResources = ({ gatewayPid = null } = {}) => {
86
104
  totalBytes: cgroupMem?.totalBytes ?? os.totalmem(),
87
105
  };
88
106
 
89
- let diskUsedBytes = null;
90
- let diskTotalBytes = null;
91
- try {
92
- const stat = fs.statfsSync("/");
93
- diskTotalBytes = stat.bsize * stat.blocks;
94
- diskUsedBytes = stat.bsize * (stat.blocks - stat.bfree);
95
- } catch {
96
- // statfsSync unavailable
97
- }
107
+ const diskUsage = readDiskUsage();
98
108
 
99
109
  const cgroupCpu = parseCgroupCpu();
100
110
  let cpuPercent = null;
@@ -129,10 +139,11 @@ const getSystemResources = ({ gatewayPid = null } = {}) => {
129
139
  : null,
130
140
  },
131
141
  disk: {
132
- usedBytes: diskUsedBytes,
133
- totalBytes: diskTotalBytes,
134
- percent: diskTotalBytes
135
- ? Math.round((diskUsedBytes / diskTotalBytes) * 1000) / 10
142
+ usedBytes: diskUsage.usedBytes,
143
+ totalBytes: diskUsage.totalBytes,
144
+ path: diskUsage.path,
145
+ percent: diskUsage.totalBytes
146
+ ? Math.round((diskUsage.usedBytes / diskUsage.totalBytes) * 1000) / 10
136
147
  : null,
137
148
  },
138
149
  cpu: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chrysb/alphaclaw",
3
- "version": "0.3.2-beta.2",
3
+ "version": "0.3.2-beta.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },