@robinpath/cli 1.75.0 → 1.76.0
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/README.md +111 -111
- package/dist/cli.mjs +7 -3
- package/modules/_helpers.js +33 -33
- package/modules/assert.js +270 -270
- package/modules/buffer.js +245 -245
- package/modules/child.js +176 -176
- package/modules/crypto.js +352 -352
- package/modules/dns.js +146 -146
- package/modules/events.js +174 -174
- package/modules/file.js +361 -361
- package/modules/http.js +268 -268
- package/modules/index.js +76 -76
- package/modules/net.js +189 -189
- package/modules/os.js +219 -219
- package/modules/path.js +162 -162
- package/modules/process.js +214 -214
- package/modules/stream.js +322 -322
- package/modules/string_decoder.js +106 -106
- package/modules/timer.js +167 -167
- package/modules/tls.js +264 -264
- package/modules/tty.js +169 -169
- package/modules/url.js +189 -189
- package/modules/util.js +275 -275
- package/modules/zlib.js +126 -126
- package/package.json +1 -1
package/modules/os.js
CHANGED
|
@@ -1,219 +1,219 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Native OS module for RobinPath.
|
|
3
|
-
* Wraps Node.js os module for system information.
|
|
4
|
-
*/
|
|
5
|
-
import {
|
|
6
|
-
hostname, cpus, totalmem, freemem, networkInterfaces,
|
|
7
|
-
tmpdir, homedir, type, release, uptime, loadavg,
|
|
8
|
-
userInfo, platform, arch, endianness, machine, version as osVersion, EOL
|
|
9
|
-
} from 'node:os';
|
|
10
|
-
|
|
11
|
-
export const OsFunctions = {
|
|
12
|
-
|
|
13
|
-
hostname: () => hostname(),
|
|
14
|
-
|
|
15
|
-
cpus: () => {
|
|
16
|
-
return cpus().map(cpu => ({
|
|
17
|
-
model: cpu.model,
|
|
18
|
-
speed: cpu.speed,
|
|
19
|
-
times: cpu.times
|
|
20
|
-
}));
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
cpuCount: () => cpus().length,
|
|
24
|
-
|
|
25
|
-
totalmem: () => totalmem(),
|
|
26
|
-
|
|
27
|
-
freemem: () => freemem(),
|
|
28
|
-
|
|
29
|
-
usedmem: () => totalmem() - freemem(),
|
|
30
|
-
|
|
31
|
-
memoryInfo: () => {
|
|
32
|
-
const total = totalmem();
|
|
33
|
-
const free = freemem();
|
|
34
|
-
return {
|
|
35
|
-
total,
|
|
36
|
-
free,
|
|
37
|
-
used: total - free,
|
|
38
|
-
percentUsed: Math.round((total - free) / total * 10000) / 100
|
|
39
|
-
};
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
networkInterfaces: () => {
|
|
43
|
-
const ifaces = networkInterfaces();
|
|
44
|
-
const result = {};
|
|
45
|
-
for (const [name, addrs] of Object.entries(ifaces)) {
|
|
46
|
-
result[name] = addrs.map(addr => ({
|
|
47
|
-
address: addr.address,
|
|
48
|
-
netmask: addr.netmask,
|
|
49
|
-
family: addr.family,
|
|
50
|
-
mac: addr.mac,
|
|
51
|
-
internal: addr.internal,
|
|
52
|
-
cidr: addr.cidr
|
|
53
|
-
}));
|
|
54
|
-
}
|
|
55
|
-
return result;
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
tmpdir: () => tmpdir(),
|
|
59
|
-
|
|
60
|
-
homedir: () => homedir(),
|
|
61
|
-
|
|
62
|
-
type: () => type(),
|
|
63
|
-
|
|
64
|
-
release: () => release(),
|
|
65
|
-
|
|
66
|
-
uptime: () => uptime(),
|
|
67
|
-
|
|
68
|
-
loadavg: () => loadavg(),
|
|
69
|
-
|
|
70
|
-
userInfo: () => {
|
|
71
|
-
const info = userInfo();
|
|
72
|
-
return {
|
|
73
|
-
username: info.username,
|
|
74
|
-
uid: info.uid,
|
|
75
|
-
gid: info.gid,
|
|
76
|
-
shell: info.shell,
|
|
77
|
-
homedir: info.homedir
|
|
78
|
-
};
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
platform: () => platform(),
|
|
82
|
-
|
|
83
|
-
arch: () => arch(),
|
|
84
|
-
|
|
85
|
-
endianness: () => endianness(),
|
|
86
|
-
|
|
87
|
-
machine: () => {
|
|
88
|
-
if (typeof machine === 'function') return machine();
|
|
89
|
-
return arch();
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
version: () => {
|
|
93
|
-
if (typeof osVersion === 'function') return osVersion();
|
|
94
|
-
return release();
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
eol: () => EOL
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export const OsFunctionMetadata = {
|
|
101
|
-
hostname: {
|
|
102
|
-
description: 'Get the operating system hostname',
|
|
103
|
-
parameters: [],
|
|
104
|
-
returnType: 'string', returnDescription: 'Hostname', example: 'os.hostname'
|
|
105
|
-
},
|
|
106
|
-
cpus: {
|
|
107
|
-
description: 'Get CPU information for each core',
|
|
108
|
-
parameters: [],
|
|
109
|
-
returnType: 'array', returnDescription: 'Array of CPU info objects', example: 'os.cpus'
|
|
110
|
-
},
|
|
111
|
-
cpuCount: {
|
|
112
|
-
description: 'Get number of CPU cores',
|
|
113
|
-
parameters: [],
|
|
114
|
-
returnType: 'number', returnDescription: 'Number of CPU cores', example: 'os.cpuCount'
|
|
115
|
-
},
|
|
116
|
-
totalmem: {
|
|
117
|
-
description: 'Get total system memory in bytes',
|
|
118
|
-
parameters: [],
|
|
119
|
-
returnType: 'number', returnDescription: 'Total memory in bytes', example: 'os.totalmem'
|
|
120
|
-
},
|
|
121
|
-
freemem: {
|
|
122
|
-
description: 'Get free system memory in bytes',
|
|
123
|
-
parameters: [],
|
|
124
|
-
returnType: 'number', returnDescription: 'Free memory in bytes', example: 'os.freemem'
|
|
125
|
-
},
|
|
126
|
-
usedmem: {
|
|
127
|
-
description: 'Get used system memory in bytes',
|
|
128
|
-
parameters: [],
|
|
129
|
-
returnType: 'number', returnDescription: 'Used memory in bytes', example: 'os.usedmem'
|
|
130
|
-
},
|
|
131
|
-
memoryInfo: {
|
|
132
|
-
description: 'Get detailed memory info (total, free, used, percentUsed)',
|
|
133
|
-
parameters: [],
|
|
134
|
-
returnType: 'object', returnDescription: 'Memory info object', example: 'os.memoryInfo'
|
|
135
|
-
},
|
|
136
|
-
networkInterfaces: {
|
|
137
|
-
description: 'Get network interface information',
|
|
138
|
-
parameters: [],
|
|
139
|
-
returnType: 'object', returnDescription: 'Object with interface names and address arrays', example: 'os.networkInterfaces'
|
|
140
|
-
},
|
|
141
|
-
tmpdir: {
|
|
142
|
-
description: 'Get the OS temporary directory',
|
|
143
|
-
parameters: [],
|
|
144
|
-
returnType: 'string', returnDescription: 'Temp directory path', example: 'os.tmpdir'
|
|
145
|
-
},
|
|
146
|
-
homedir: {
|
|
147
|
-
description: 'Get the current user home directory',
|
|
148
|
-
parameters: [],
|
|
149
|
-
returnType: 'string', returnDescription: 'Home directory path', example: 'os.homedir'
|
|
150
|
-
},
|
|
151
|
-
type: {
|
|
152
|
-
description: 'Get the operating system name',
|
|
153
|
-
parameters: [],
|
|
154
|
-
returnType: 'string', returnDescription: 'OS name (Linux, Darwin, Windows_NT)', example: 'os.type'
|
|
155
|
-
},
|
|
156
|
-
release: {
|
|
157
|
-
description: 'Get the OS release version',
|
|
158
|
-
parameters: [],
|
|
159
|
-
returnType: 'string', returnDescription: 'Release string', example: 'os.release'
|
|
160
|
-
},
|
|
161
|
-
uptime: {
|
|
162
|
-
description: 'Get system uptime in seconds',
|
|
163
|
-
parameters: [],
|
|
164
|
-
returnType: 'number', returnDescription: 'Uptime in seconds', example: 'os.uptime'
|
|
165
|
-
},
|
|
166
|
-
loadavg: {
|
|
167
|
-
description: 'Get load averages (1, 5, 15 minute)',
|
|
168
|
-
parameters: [],
|
|
169
|
-
returnType: 'array', returnDescription: 'Array of 3 load average numbers', example: 'os.loadavg'
|
|
170
|
-
},
|
|
171
|
-
userInfo: {
|
|
172
|
-
description: 'Get current user information',
|
|
173
|
-
parameters: [],
|
|
174
|
-
returnType: 'object', returnDescription: 'Object with username, uid, gid, shell, homedir', example: 'os.userInfo'
|
|
175
|
-
},
|
|
176
|
-
platform: {
|
|
177
|
-
description: 'Get the operating system platform',
|
|
178
|
-
parameters: [],
|
|
179
|
-
returnType: 'string', returnDescription: 'Platform (win32, darwin, linux)', example: 'os.platform'
|
|
180
|
-
},
|
|
181
|
-
arch: {
|
|
182
|
-
description: 'Get the CPU architecture',
|
|
183
|
-
parameters: [],
|
|
184
|
-
returnType: 'string', returnDescription: 'Architecture (x64, arm64)', example: 'os.arch'
|
|
185
|
-
},
|
|
186
|
-
endianness: {
|
|
187
|
-
description: 'Get CPU endianness',
|
|
188
|
-
parameters: [],
|
|
189
|
-
returnType: 'string', returnDescription: 'BE or LE', example: 'os.endianness'
|
|
190
|
-
},
|
|
191
|
-
machine: {
|
|
192
|
-
description: 'Get the machine type',
|
|
193
|
-
parameters: [],
|
|
194
|
-
returnType: 'string', returnDescription: 'Machine type string', example: 'os.machine'
|
|
195
|
-
},
|
|
196
|
-
version: {
|
|
197
|
-
description: 'Get the OS version string',
|
|
198
|
-
parameters: [],
|
|
199
|
-
returnType: 'string', returnDescription: 'OS version', example: 'os.version'
|
|
200
|
-
},
|
|
201
|
-
eol: {
|
|
202
|
-
description: 'Get the platform-specific end-of-line marker',
|
|
203
|
-
parameters: [],
|
|
204
|
-
returnType: 'string', returnDescription: 'EOL string (\\n or \\r\\n)', example: 'os.eol'
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
export const OsModuleMetadata = {
|
|
209
|
-
description: 'Operating system information: hostname, CPUs, memory, network, platform, and more',
|
|
210
|
-
methods: Object.keys(OsFunctions)
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
export default {
|
|
214
|
-
name: 'os',
|
|
215
|
-
functions: OsFunctions,
|
|
216
|
-
functionMetadata: OsFunctionMetadata,
|
|
217
|
-
moduleMetadata: OsModuleMetadata,
|
|
218
|
-
global: false
|
|
219
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Native OS module for RobinPath.
|
|
3
|
+
* Wraps Node.js os module for system information.
|
|
4
|
+
*/
|
|
5
|
+
import {
|
|
6
|
+
hostname, cpus, totalmem, freemem, networkInterfaces,
|
|
7
|
+
tmpdir, homedir, type, release, uptime, loadavg,
|
|
8
|
+
userInfo, platform, arch, endianness, machine, version as osVersion, EOL
|
|
9
|
+
} from 'node:os';
|
|
10
|
+
|
|
11
|
+
export const OsFunctions = {
|
|
12
|
+
|
|
13
|
+
hostname: () => hostname(),
|
|
14
|
+
|
|
15
|
+
cpus: () => {
|
|
16
|
+
return cpus().map(cpu => ({
|
|
17
|
+
model: cpu.model,
|
|
18
|
+
speed: cpu.speed,
|
|
19
|
+
times: cpu.times
|
|
20
|
+
}));
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
cpuCount: () => cpus().length,
|
|
24
|
+
|
|
25
|
+
totalmem: () => totalmem(),
|
|
26
|
+
|
|
27
|
+
freemem: () => freemem(),
|
|
28
|
+
|
|
29
|
+
usedmem: () => totalmem() - freemem(),
|
|
30
|
+
|
|
31
|
+
memoryInfo: () => {
|
|
32
|
+
const total = totalmem();
|
|
33
|
+
const free = freemem();
|
|
34
|
+
return {
|
|
35
|
+
total,
|
|
36
|
+
free,
|
|
37
|
+
used: total - free,
|
|
38
|
+
percentUsed: Math.round((total - free) / total * 10000) / 100
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
networkInterfaces: () => {
|
|
43
|
+
const ifaces = networkInterfaces();
|
|
44
|
+
const result = {};
|
|
45
|
+
for (const [name, addrs] of Object.entries(ifaces)) {
|
|
46
|
+
result[name] = addrs.map(addr => ({
|
|
47
|
+
address: addr.address,
|
|
48
|
+
netmask: addr.netmask,
|
|
49
|
+
family: addr.family,
|
|
50
|
+
mac: addr.mac,
|
|
51
|
+
internal: addr.internal,
|
|
52
|
+
cidr: addr.cidr
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
tmpdir: () => tmpdir(),
|
|
59
|
+
|
|
60
|
+
homedir: () => homedir(),
|
|
61
|
+
|
|
62
|
+
type: () => type(),
|
|
63
|
+
|
|
64
|
+
release: () => release(),
|
|
65
|
+
|
|
66
|
+
uptime: () => uptime(),
|
|
67
|
+
|
|
68
|
+
loadavg: () => loadavg(),
|
|
69
|
+
|
|
70
|
+
userInfo: () => {
|
|
71
|
+
const info = userInfo();
|
|
72
|
+
return {
|
|
73
|
+
username: info.username,
|
|
74
|
+
uid: info.uid,
|
|
75
|
+
gid: info.gid,
|
|
76
|
+
shell: info.shell,
|
|
77
|
+
homedir: info.homedir
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
platform: () => platform(),
|
|
82
|
+
|
|
83
|
+
arch: () => arch(),
|
|
84
|
+
|
|
85
|
+
endianness: () => endianness(),
|
|
86
|
+
|
|
87
|
+
machine: () => {
|
|
88
|
+
if (typeof machine === 'function') return machine();
|
|
89
|
+
return arch();
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
version: () => {
|
|
93
|
+
if (typeof osVersion === 'function') return osVersion();
|
|
94
|
+
return release();
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
eol: () => EOL
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const OsFunctionMetadata = {
|
|
101
|
+
hostname: {
|
|
102
|
+
description: 'Get the operating system hostname',
|
|
103
|
+
parameters: [],
|
|
104
|
+
returnType: 'string', returnDescription: 'Hostname', example: 'os.hostname'
|
|
105
|
+
},
|
|
106
|
+
cpus: {
|
|
107
|
+
description: 'Get CPU information for each core',
|
|
108
|
+
parameters: [],
|
|
109
|
+
returnType: 'array', returnDescription: 'Array of CPU info objects', example: 'os.cpus'
|
|
110
|
+
},
|
|
111
|
+
cpuCount: {
|
|
112
|
+
description: 'Get number of CPU cores',
|
|
113
|
+
parameters: [],
|
|
114
|
+
returnType: 'number', returnDescription: 'Number of CPU cores', example: 'os.cpuCount'
|
|
115
|
+
},
|
|
116
|
+
totalmem: {
|
|
117
|
+
description: 'Get total system memory in bytes',
|
|
118
|
+
parameters: [],
|
|
119
|
+
returnType: 'number', returnDescription: 'Total memory in bytes', example: 'os.totalmem'
|
|
120
|
+
},
|
|
121
|
+
freemem: {
|
|
122
|
+
description: 'Get free system memory in bytes',
|
|
123
|
+
parameters: [],
|
|
124
|
+
returnType: 'number', returnDescription: 'Free memory in bytes', example: 'os.freemem'
|
|
125
|
+
},
|
|
126
|
+
usedmem: {
|
|
127
|
+
description: 'Get used system memory in bytes',
|
|
128
|
+
parameters: [],
|
|
129
|
+
returnType: 'number', returnDescription: 'Used memory in bytes', example: 'os.usedmem'
|
|
130
|
+
},
|
|
131
|
+
memoryInfo: {
|
|
132
|
+
description: 'Get detailed memory info (total, free, used, percentUsed)',
|
|
133
|
+
parameters: [],
|
|
134
|
+
returnType: 'object', returnDescription: 'Memory info object', example: 'os.memoryInfo'
|
|
135
|
+
},
|
|
136
|
+
networkInterfaces: {
|
|
137
|
+
description: 'Get network interface information',
|
|
138
|
+
parameters: [],
|
|
139
|
+
returnType: 'object', returnDescription: 'Object with interface names and address arrays', example: 'os.networkInterfaces'
|
|
140
|
+
},
|
|
141
|
+
tmpdir: {
|
|
142
|
+
description: 'Get the OS temporary directory',
|
|
143
|
+
parameters: [],
|
|
144
|
+
returnType: 'string', returnDescription: 'Temp directory path', example: 'os.tmpdir'
|
|
145
|
+
},
|
|
146
|
+
homedir: {
|
|
147
|
+
description: 'Get the current user home directory',
|
|
148
|
+
parameters: [],
|
|
149
|
+
returnType: 'string', returnDescription: 'Home directory path', example: 'os.homedir'
|
|
150
|
+
},
|
|
151
|
+
type: {
|
|
152
|
+
description: 'Get the operating system name',
|
|
153
|
+
parameters: [],
|
|
154
|
+
returnType: 'string', returnDescription: 'OS name (Linux, Darwin, Windows_NT)', example: 'os.type'
|
|
155
|
+
},
|
|
156
|
+
release: {
|
|
157
|
+
description: 'Get the OS release version',
|
|
158
|
+
parameters: [],
|
|
159
|
+
returnType: 'string', returnDescription: 'Release string', example: 'os.release'
|
|
160
|
+
},
|
|
161
|
+
uptime: {
|
|
162
|
+
description: 'Get system uptime in seconds',
|
|
163
|
+
parameters: [],
|
|
164
|
+
returnType: 'number', returnDescription: 'Uptime in seconds', example: 'os.uptime'
|
|
165
|
+
},
|
|
166
|
+
loadavg: {
|
|
167
|
+
description: 'Get load averages (1, 5, 15 minute)',
|
|
168
|
+
parameters: [],
|
|
169
|
+
returnType: 'array', returnDescription: 'Array of 3 load average numbers', example: 'os.loadavg'
|
|
170
|
+
},
|
|
171
|
+
userInfo: {
|
|
172
|
+
description: 'Get current user information',
|
|
173
|
+
parameters: [],
|
|
174
|
+
returnType: 'object', returnDescription: 'Object with username, uid, gid, shell, homedir', example: 'os.userInfo'
|
|
175
|
+
},
|
|
176
|
+
platform: {
|
|
177
|
+
description: 'Get the operating system platform',
|
|
178
|
+
parameters: [],
|
|
179
|
+
returnType: 'string', returnDescription: 'Platform (win32, darwin, linux)', example: 'os.platform'
|
|
180
|
+
},
|
|
181
|
+
arch: {
|
|
182
|
+
description: 'Get the CPU architecture',
|
|
183
|
+
parameters: [],
|
|
184
|
+
returnType: 'string', returnDescription: 'Architecture (x64, arm64)', example: 'os.arch'
|
|
185
|
+
},
|
|
186
|
+
endianness: {
|
|
187
|
+
description: 'Get CPU endianness',
|
|
188
|
+
parameters: [],
|
|
189
|
+
returnType: 'string', returnDescription: 'BE or LE', example: 'os.endianness'
|
|
190
|
+
},
|
|
191
|
+
machine: {
|
|
192
|
+
description: 'Get the machine type',
|
|
193
|
+
parameters: [],
|
|
194
|
+
returnType: 'string', returnDescription: 'Machine type string', example: 'os.machine'
|
|
195
|
+
},
|
|
196
|
+
version: {
|
|
197
|
+
description: 'Get the OS version string',
|
|
198
|
+
parameters: [],
|
|
199
|
+
returnType: 'string', returnDescription: 'OS version', example: 'os.version'
|
|
200
|
+
},
|
|
201
|
+
eol: {
|
|
202
|
+
description: 'Get the platform-specific end-of-line marker',
|
|
203
|
+
parameters: [],
|
|
204
|
+
returnType: 'string', returnDescription: 'EOL string (\\n or \\r\\n)', example: 'os.eol'
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export const OsModuleMetadata = {
|
|
209
|
+
description: 'Operating system information: hostname, CPUs, memory, network, platform, and more',
|
|
210
|
+
methods: Object.keys(OsFunctions)
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export default {
|
|
214
|
+
name: 'os',
|
|
215
|
+
functions: OsFunctions,
|
|
216
|
+
functionMetadata: OsFunctionMetadata,
|
|
217
|
+
moduleMetadata: OsModuleMetadata,
|
|
218
|
+
global: false
|
|
219
|
+
};
|