dsh-mesh-node 0.0.2 → 0.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mesh-node",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Mesh server for dsh-mesh: expose a machine to peer DSH nodes over MCP/HTTPS, with delegation and optional desktop-control tools.",
5
5
  "type": "module",
6
6
  "private": false,
@@ -0,0 +1,57 @@
1
+ // @generated hardware:本机硬件概况(CPU / 内存 / 磁盘 / OS),供 mesh_self、host_self 与 UI 使用
2
+ // [why] 2026-11-09 用户反馈 AI 网络面板很多设备没有内存/系统版本/磁盘信息:
3
+ // 之前只有 survey 快照采集过本机硬件,远端节点协议里没有这些字段。
4
+ // 现在统一由各节点 mesh server 在 host_self / mesh_self 里上报,UI 即可展示全部设备。
5
+ import { arch, cpus, freemem, hostname, platform, release, totalmem, uptime } from 'node:os'
6
+ import { statfsSync } from 'node:fs'
7
+
8
+ const GiB = 1024 ** 3
9
+ const round1 = (n) => Math.round(Number(n) / GiB * 10) / 10
10
+
11
+ function osLabel() {
12
+ const p = platform()
13
+ const r = String(release() || '')
14
+ if (p === 'win32') {
15
+ const build = Number(String(r).split('.')[2] || 0)
16
+ const name = build >= 22000 ? 'Windows 11' : 'Windows 10'
17
+ return `${name} (${r})`
18
+ }
19
+ if (p === 'darwin') return 'macOS ' + r
20
+ if (p === 'linux') return 'Linux ' + r
21
+ return `${p} ${r}`.trim()
22
+ }
23
+
24
+ /** 系统盘 / 根分区容量(Windows 取 SystemDrive,其他取 /)。失败时 disk=null。 */
25
+ function diskInfo() {
26
+ const path = process.platform === 'win32' ? `${process.env.SystemDrive || 'C:'}\\` : '/'
27
+ try {
28
+ const st = statfsSync(path)
29
+ const blockSize = Number(st.bsize || 4096)
30
+ return {
31
+ path,
32
+ totalGB: round1(Number(st.blocks) * blockSize),
33
+ freeGB: round1(Number(st.bavail) * blockSize)
34
+ }
35
+ } catch {
36
+ return null
37
+ }
38
+ }
39
+
40
+ /** 稳定、跨平台的硬件概况(纯只读,不含任何个人/凭据数据)。 */
41
+ export function hardwareInfo() {
42
+ const list = cpus()
43
+ const first = list[0] || {}
44
+ return {
45
+ hostname: hostname(),
46
+ platform: platform(),
47
+ release: release(),
48
+ arch: arch(),
49
+ os: osLabel(),
50
+ cpuModel: String(first.model || '').trim(),
51
+ cpuCores: list.length,
52
+ memTotalGB: round1(totalmem()),
53
+ memFreeGB: round1(freemem()),
54
+ disk: diskInfo(),
55
+ uptimeSec: Math.round(uptime())
56
+ }
57
+ }
package/src/tools/core.js CHANGED
@@ -3,6 +3,7 @@ import { basename } from 'node:path'
3
3
  import { z } from 'zod'
4
4
  import { MESH_VERSION, configPath } from '../core/config.js'
5
5
  import { describeCert } from '../core/tls.js'
6
+ import { hardwareInfo } from '../core/hardware.js'
6
7
  import { auditPath, auditSummary } from '../core/audit.js'
7
8
  import { ok } from '../core/result.js'
8
9
 
@@ -30,6 +31,7 @@ export function buildCore(ctx) {
30
31
  configPath: configPath(ctx.home),
31
32
  auditPath: auditPath(ctx.home)
32
33
  },
34
+ hardware: hardwareInfo(),
33
35
  host: {
34
36
  hostname: hostname(),
35
37
  platform: platform(),
package/src/tools/host.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod'
2
+ import { hardwareInfo } from '../core/hardware.js'
2
3
  import { createHostClient, hostInstances, hostTokenPath, HostError } from '../core/host-agent.js'
3
4
  import { buildSessionProfile, classifySession, sessionBlock } from '../core/session-profile.js'
4
5
  import { fail, ok } from '../core/result.js'
@@ -91,7 +92,8 @@ export function buildHost(ctx) {
91
92
  inputSchema: z.object({ instance: instanceSchema }),
92
93
  handler: async ({ instance }) => {
93
94
  try {
94
- return ok(await hostClient(ctx, instance).self())
95
+ const data = await hostClient(ctx, instance).self()
96
+ return ok({ ...data, hardware: hardwareInfo() })
95
97
  } catch (error) {
96
98
  return hostError(error)
97
99
  }