dsh-mesh-ui 0.0.2 → 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.
package/lib/client.js CHANGED
@@ -1249,6 +1249,11 @@ function deviceLinkState(data, peer, lanMap) {
1249
1249
  var localTunnelAll = tunnelNames
1250
1250
  var memText = hw.memTotalGB ? ((hw.memFreeGB != null ? hw.memFreeGB : '?') + ' / ' + hw.memTotalGB + ' GB') : '—'
1251
1251
  var cpuText = hw.cpuModel ? hw.cpuModel + ' · ' + (hw.cpuCores || '?') + ' 线程' : '—'
1252
+ function diskText(d) {
1253
+ if (!d || d.totalGB == null) return '—'
1254
+ var p = String(d.path || '').replace(/[\\/]+$/, '')
1255
+ return (d.freeGB != null ? d.freeGB : '?') + ' / ' + d.totalGB + ' GB' + (p ? ' (' + p + ')' : '')
1256
+ }
1252
1257
 
1253
1258
  var devices = [{
1254
1259
  key: 'local',
@@ -1258,6 +1263,7 @@ function deviceLinkState(data, peer, lanMap) {
1258
1263
  ['操作系统', hw.os || '—'],
1259
1264
  ['CPU', cpuText],
1260
1265
  ['内存', memText],
1266
+ ['磁盘', diskText(hw.disk)],
1261
1267
  ['DSH 实例', localUp + '/' + instances.length + ' 在线'],
1262
1268
  ['会话 / 运行', sessions + ' / ' + running],
1263
1269
  ['模型', model],
@@ -1267,12 +1273,16 @@ function deviceLinkState(data, peer, lanMap) {
1267
1273
  ]
1268
1274
  }].concat(peers.map(function (peer) {
1269
1275
  var t = peer.tunnel || {}
1276
+ var hwp = peer.hardware || {}
1270
1277
  return {
1271
1278
  key: 'peer:' + peer.name,
1272
1279
  name: nodeDisplay(peerDeviceKey(peer.name)),
1273
1280
  up: Boolean(peer.up),
1274
1281
  rows: [
1275
- ['操作系统', peer.os || '—'],
1282
+ ['操作系统', hwp.os || peer.os || '—'],
1283
+ ['CPU', hwp.cpuModel ? hwp.cpuModel + ' · ' + (hwp.cpuCores || '?') + ' 线程' : '—'],
1284
+ ['内存', hwp.memTotalGB ? ((hwp.memFreeGB != null ? hwp.memFreeGB : '?') + ' / ' + hwp.memTotalGB + ' GB') : '—'],
1285
+ ['磁盘', diskText(hwp.disk)],
1276
1286
  ['运行时长', uptimeText(peer.uptimeSec)],
1277
1287
  ['DSH 实例', (peer.instancesCount || 0) + ' 个(' + ((peer.instancesList || []).map(function (x) { return x.port + (x.up ? '✓' : '✗') }).join(' ') || '—') + ')'],
1278
1288
  ['会话 / 运行', (peer.sessions || 0) + ' / ' + (peer.running || 0)],
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
 
@@ -447,6 +460,7 @@ export async function collect(repo) {
447
460
  sessions: stats.sessions,
448
461
  running: stats.running,
449
462
  hostname: self?.node?.hostname || '',
463
+ hardware: self?.hardware || null,
450
464
  release: self?.node?.release || '',
451
465
  os: osLabel(self?.node?.platform, self?.node?.release),
452
466
  uptimeSec: overviewByNode[peer.name]?.uptimeSec ?? null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mesh-ui",
3
- "version": "0.0.2",
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",