dsh-mesh-ui 0.0.3 → 0.0.4

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 (2) hide show
  1. package/lib/collect.js +17 -4
  2. package/package.json +1 -1
package/lib/collect.js CHANGED
@@ -14,7 +14,7 @@
14
14
  // 归宿:reusable(dsh-mesh/plugin/dsh-mesh-ui/lib/collect.js)
15
15
 
16
16
  import { execFile } from 'node:child_process'
17
- import { existsSync, readdirSync, readFileSync } from 'node:fs'
17
+ import { existsSync, readdirSync, readFileSync, statfsSync } from 'node:fs'
18
18
  import { lookup as dnsLookup } from 'node:dns/promises'
19
19
  import { arch as osArch, cpus as osCpus, freemem as osFreemem, homedir, platform as osPlatform, release as osRelease, totalmem as osTotalmem } from 'node:os'
20
20
  import { join } from 'node:path'
@@ -167,7 +167,19 @@ function gb(bytes) {
167
167
  return Math.round((Number(bytes || 0) / 1024 / 1024 / 1024) * 10) / 10
168
168
  }
169
169
 
170
- /** 本机硬件概况(远端拿不到,需要 host_self 扩展;先只给本机)。 */
170
+ /** 本机系统盘 / 根分区容量(与远端 hardware.disk 结构一致)。 */
171
+ function localDisk() {
172
+ try {
173
+ const path = process.platform === 'win32' ? `${process.env.SystemDrive || 'C:'}\\` : '/'
174
+ const st = statfsSync(path)
175
+ const blockSize = Number(st.bsize || 4096)
176
+ return { path, totalGB: gb(Number(st.blocks) * blockSize), freeGB: gb(Number(st.bavail) * blockSize) }
177
+ } catch {
178
+ return null
179
+ }
180
+ }
181
+
182
+ /** 本机硬件概况(本机直采;远端由 host_self 的 hardware 字段提供)。 */
171
183
  function localHardware() {
172
184
  const cpuList = osCpus()
173
185
  const first = cpuList[0] || {}
@@ -177,7 +189,8 @@ function localHardware() {
177
189
  cpuModel: String(first.model || '').replace(/\s+/g, ' ').trim(),
178
190
  cpuCores: cpuList.length,
179
191
  memTotalGB: gb(osTotalmem()),
180
- memFreeGB: gb(osFreemem())
192
+ memFreeGB: gb(osFreemem()),
193
+ disk: localDisk()
181
194
  }
182
195
  }
183
196
 
@@ -446,7 +459,7 @@ export async function collect(repo) {
446
459
  instancesList: remoteByNode[peer.name] || [],
447
460
  sessions: stats.sessions,
448
461
  running: stats.running,
449
- hostname: self?.node?.hostname || '',
462
+ hostname: self?.node?.hostname || '',
450
463
  hardware: self?.hardware || null,
451
464
  release: self?.node?.release || '',
452
465
  os: osLabel(self?.node?.platform, self?.node?.release),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mesh-ui",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "DSH settings-page panel for dsh-mesh: AI network topology, peer health, and delegation panel. Read-only; data is collected from the local mesh CLI.",
5
5
  "icon": "icon.svg",
6
6
  "type": "module",