@robinpath/cli 1.73.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 -0
- package/dist/cli.mjs +28256 -0
- package/modules/_helpers.js +33 -0
- package/modules/assert.js +270 -0
- package/modules/buffer.js +245 -0
- package/modules/child.js +176 -0
- package/modules/crypto.js +352 -0
- package/modules/dns.js +146 -0
- package/modules/events.js +174 -0
- package/modules/file.js +361 -0
- package/modules/http.js +268 -0
- package/modules/index.js +76 -0
- package/modules/net.js +189 -0
- package/modules/os.js +219 -0
- package/modules/path.js +162 -0
- package/modules/process.js +214 -0
- package/modules/stream.js +322 -0
- package/modules/string_decoder.js +106 -0
- package/modules/timer.js +167 -0
- package/modules/tls.js +264 -0
- package/modules/tty.js +169 -0
- package/modules/url.js +189 -0
- package/modules/util.js +275 -0
- package/modules/zlib.js +126 -0
- package/package.json +57 -0
package/modules/os.js
ADDED
|
@@ -0,0 +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
|
+
};
|
package/modules/path.js
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native path module for RobinPath.
|
|
3
|
+
* Wraps Node.js path operations.
|
|
4
|
+
*/
|
|
5
|
+
import { join, resolve, dirname, basename, extname, parse, format, relative, normalize, isAbsolute, sep, delimiter, posix, win32 } from 'node:path';
|
|
6
|
+
import { toStr, requireArgs } from './_helpers.js';
|
|
7
|
+
|
|
8
|
+
export const PathFunctions = {
|
|
9
|
+
|
|
10
|
+
join: (args) => {
|
|
11
|
+
return join(...args.map(a => toStr(a)));
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
resolve: (args) => {
|
|
15
|
+
return resolve(...args.map(a => toStr(a)));
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
dirname: (args) => {
|
|
19
|
+
requireArgs('path.dirname', args, 1);
|
|
20
|
+
return dirname(toStr(args[0]));
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
basename: (args) => {
|
|
24
|
+
requireArgs('path.basename', args, 1);
|
|
25
|
+
const ext = args[1] != null ? toStr(args[1]) : undefined;
|
|
26
|
+
return basename(toStr(args[0]), ext);
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
extname: (args) => {
|
|
30
|
+
requireArgs('path.extname', args, 1);
|
|
31
|
+
return extname(toStr(args[0]));
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
parse: (args) => {
|
|
35
|
+
requireArgs('path.parse', args, 1);
|
|
36
|
+
return parse(toStr(args[0]));
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
format: (args) => {
|
|
40
|
+
requireArgs('path.format', args, 1);
|
|
41
|
+
const obj = args[0];
|
|
42
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
43
|
+
throw new Error('path.format requires an object with root/dir/base/name/ext');
|
|
44
|
+
}
|
|
45
|
+
return format(obj);
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
relative: (args) => {
|
|
49
|
+
requireArgs('path.relative', args, 2);
|
|
50
|
+
return relative(toStr(args[0]), toStr(args[1]));
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
normalize: (args) => {
|
|
54
|
+
requireArgs('path.normalize', args, 1);
|
|
55
|
+
return normalize(toStr(args[0]));
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
isAbsolute: (args) => {
|
|
59
|
+
requireArgs('path.isAbsolute', args, 1);
|
|
60
|
+
return isAbsolute(toStr(args[0]));
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
sep: () => sep,
|
|
64
|
+
|
|
65
|
+
delimiter: () => delimiter,
|
|
66
|
+
|
|
67
|
+
toNamespacedPath: (args) => {
|
|
68
|
+
requireArgs('path.toNamespacedPath', args, 1);
|
|
69
|
+
// On Windows, converts to \\?\ prefix; on POSIX, returns unchanged
|
|
70
|
+
if (process.platform === 'win32') {
|
|
71
|
+
return '\\\\?\\' + resolve(toStr(args[0]));
|
|
72
|
+
}
|
|
73
|
+
return resolve(toStr(args[0]));
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const PathFunctionMetadata = {
|
|
78
|
+
join: {
|
|
79
|
+
description: 'Join path segments together',
|
|
80
|
+
parameters: [{ name: 'segments', dataType: 'string', description: 'Path segments', formInputType: 'text', required: true }],
|
|
81
|
+
returnType: 'string', returnDescription: 'Joined path', example: 'path.join "src" "modules" "test.js"'
|
|
82
|
+
},
|
|
83
|
+
resolve: {
|
|
84
|
+
description: 'Resolve path segments to an absolute path',
|
|
85
|
+
parameters: [{ name: 'segments', dataType: 'string', description: 'Path segments', formInputType: 'text', required: true }],
|
|
86
|
+
returnType: 'string', returnDescription: 'Absolute path', example: 'path.resolve "src" "file.js"'
|
|
87
|
+
},
|
|
88
|
+
dirname: {
|
|
89
|
+
description: 'Get directory name of a path',
|
|
90
|
+
parameters: [{ name: 'path', dataType: 'string', description: 'File path', formInputType: 'text', required: true }],
|
|
91
|
+
returnType: 'string', returnDescription: 'Directory name', example: 'path.dirname "/home/user/file.txt"'
|
|
92
|
+
},
|
|
93
|
+
basename: {
|
|
94
|
+
description: 'Get the last portion of a path',
|
|
95
|
+
parameters: [
|
|
96
|
+
{ name: 'path', dataType: 'string', description: 'File path', formInputType: 'text', required: true },
|
|
97
|
+
{ name: 'ext', dataType: 'string', description: 'Extension to strip', formInputType: 'text', required: false }
|
|
98
|
+
],
|
|
99
|
+
returnType: 'string', returnDescription: 'Base name', example: 'path.basename "/home/user/file.txt"'
|
|
100
|
+
},
|
|
101
|
+
extname: {
|
|
102
|
+
description: 'Get file extension',
|
|
103
|
+
parameters: [{ name: 'path', dataType: 'string', description: 'File path', formInputType: 'text', required: true }],
|
|
104
|
+
returnType: 'string', returnDescription: 'Extension (e.g. ".txt")', example: 'path.extname "file.txt"'
|
|
105
|
+
},
|
|
106
|
+
parse: {
|
|
107
|
+
description: 'Parse a path into components',
|
|
108
|
+
parameters: [{ name: 'path', dataType: 'string', description: 'File path', formInputType: 'text', required: true }],
|
|
109
|
+
returnType: 'object', returnDescription: 'Object with root, dir, base, name, ext', example: 'path.parse "/home/user/file.txt"'
|
|
110
|
+
},
|
|
111
|
+
format: {
|
|
112
|
+
description: 'Format a path object into a string',
|
|
113
|
+
parameters: [{ name: 'pathObject', dataType: 'object', description: 'Object with root/dir/base/name/ext', formInputType: 'json', required: true }],
|
|
114
|
+
returnType: 'string', returnDescription: 'Formatted path string', example: 'path.format $obj'
|
|
115
|
+
},
|
|
116
|
+
relative: {
|
|
117
|
+
description: 'Get relative path from one path to another',
|
|
118
|
+
parameters: [
|
|
119
|
+
{ name: 'from', dataType: 'string', description: 'Base path', formInputType: 'text', required: true },
|
|
120
|
+
{ name: 'to', dataType: 'string', description: 'Target path', formInputType: 'text', required: true }
|
|
121
|
+
],
|
|
122
|
+
returnType: 'string', returnDescription: 'Relative path', example: 'path.relative "/home" "/home/user/file.txt"'
|
|
123
|
+
},
|
|
124
|
+
normalize: {
|
|
125
|
+
description: 'Normalize a path (resolve . and ..)',
|
|
126
|
+
parameters: [{ name: 'path', dataType: 'string', description: 'Path to normalize', formInputType: 'text', required: true }],
|
|
127
|
+
returnType: 'string', returnDescription: 'Normalized path', example: 'path.normalize "/home/user/../file.txt"'
|
|
128
|
+
},
|
|
129
|
+
isAbsolute: {
|
|
130
|
+
description: 'Check if a path is absolute',
|
|
131
|
+
parameters: [{ name: 'path', dataType: 'string', description: 'Path to check', formInputType: 'text', required: true }],
|
|
132
|
+
returnType: 'boolean', returnDescription: 'true if absolute', example: 'path.isAbsolute "/home/user"'
|
|
133
|
+
},
|
|
134
|
+
sep: {
|
|
135
|
+
description: 'Get the platform-specific path separator',
|
|
136
|
+
parameters: [],
|
|
137
|
+
returnType: 'string', returnDescription: 'Path separator (/ or \\)', example: 'path.sep'
|
|
138
|
+
},
|
|
139
|
+
delimiter: {
|
|
140
|
+
description: 'Get the platform-specific path delimiter',
|
|
141
|
+
parameters: [],
|
|
142
|
+
returnType: 'string', returnDescription: 'Path delimiter (: or ;)', example: 'path.delimiter'
|
|
143
|
+
},
|
|
144
|
+
toNamespacedPath: {
|
|
145
|
+
description: 'Convert to namespaced path (Windows \\\\?\\ prefix)',
|
|
146
|
+
parameters: [{ name: 'path', dataType: 'string', description: 'Path to convert', formInputType: 'text', required: true }],
|
|
147
|
+
returnType: 'string', returnDescription: 'Namespaced path', example: 'path.toNamespacedPath "C:\\Users"'
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export const PathModuleMetadata = {
|
|
152
|
+
description: 'Path manipulation: join, resolve, parse, format, and platform-aware utilities',
|
|
153
|
+
methods: Object.keys(PathFunctions)
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export default {
|
|
157
|
+
name: 'path',
|
|
158
|
+
functions: PathFunctions,
|
|
159
|
+
functionMetadata: PathFunctionMetadata,
|
|
160
|
+
moduleMetadata: PathModuleMetadata,
|
|
161
|
+
global: false
|
|
162
|
+
};
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native process module for RobinPath.
|
|
3
|
+
* Exposes Node.js process information and control.
|
|
4
|
+
*/
|
|
5
|
+
import { toStr, toNum } from './_helpers.js';
|
|
6
|
+
|
|
7
|
+
export const ProcessFunctions = {
|
|
8
|
+
|
|
9
|
+
env: (args) => {
|
|
10
|
+
if (args.length === 0) return { ...process.env };
|
|
11
|
+
const key = toStr(args[0]);
|
|
12
|
+
if (args.length >= 2) {
|
|
13
|
+
// Set environment variable
|
|
14
|
+
process.env[key] = toStr(args[1]);
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return process.env[key] ?? null;
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
argv: () => {
|
|
21
|
+
return process.argv.slice(2);
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
exit: (args) => {
|
|
25
|
+
const code = args.length > 0 ? toNum(args[0], 0) : 0;
|
|
26
|
+
process.exit(code);
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
cwd: () => {
|
|
30
|
+
return process.cwd();
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
chdir: (args) => {
|
|
34
|
+
if (args.length < 1) throw new Error('process.chdir requires a directory path');
|
|
35
|
+
process.chdir(toStr(args[0]));
|
|
36
|
+
return process.cwd();
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
pid: () => {
|
|
40
|
+
return process.pid;
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
ppid: () => {
|
|
44
|
+
return process.ppid;
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
platform: () => {
|
|
48
|
+
return process.platform;
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
arch: () => {
|
|
52
|
+
return process.arch;
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
version: () => {
|
|
56
|
+
return process.version;
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
versions: () => {
|
|
60
|
+
return { ...process.versions };
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
memoryUsage: () => {
|
|
64
|
+
const mem = process.memoryUsage();
|
|
65
|
+
return {
|
|
66
|
+
rss: mem.rss,
|
|
67
|
+
heapTotal: mem.heapTotal,
|
|
68
|
+
heapUsed: mem.heapUsed,
|
|
69
|
+
external: mem.external,
|
|
70
|
+
arrayBuffers: mem.arrayBuffers
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
uptime: () => {
|
|
75
|
+
return process.uptime();
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
hrtime: () => {
|
|
79
|
+
const [s, ns] = process.hrtime();
|
|
80
|
+
return s * 1e9 + ns;
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
title: (args) => {
|
|
84
|
+
if (args.length > 0) {
|
|
85
|
+
process.title = toStr(args[0]);
|
|
86
|
+
}
|
|
87
|
+
return process.title;
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
execPath: () => {
|
|
91
|
+
return process.execPath;
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
cpuUsage: () => {
|
|
95
|
+
const usage = process.cpuUsage();
|
|
96
|
+
return { user: usage.user, system: usage.system };
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
resourceUsage: () => {
|
|
100
|
+
if (typeof process.resourceUsage === 'function') {
|
|
101
|
+
return process.resourceUsage();
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const ProcessFunctionMetadata = {
|
|
108
|
+
env: {
|
|
109
|
+
description: 'Get or set environment variables',
|
|
110
|
+
parameters: [
|
|
111
|
+
{ name: 'key', dataType: 'string', description: 'Variable name (omit to get all)', formInputType: 'text', required: false },
|
|
112
|
+
{ name: 'value', dataType: 'string', description: 'Value to set (omit to get)', formInputType: 'text', required: false }
|
|
113
|
+
],
|
|
114
|
+
returnType: 'any', returnDescription: 'Variable value, all variables, or true on set', example: 'process.env "PATH"'
|
|
115
|
+
},
|
|
116
|
+
argv: {
|
|
117
|
+
description: 'Get command-line arguments',
|
|
118
|
+
parameters: [],
|
|
119
|
+
returnType: 'array', returnDescription: 'Array of argument strings', example: 'process.argv'
|
|
120
|
+
},
|
|
121
|
+
exit: {
|
|
122
|
+
description: 'Exit the process with a code',
|
|
123
|
+
parameters: [{ name: 'code', dataType: 'number', description: 'Exit code (default: 0)', formInputType: 'number', required: false, defaultValue: 0 }],
|
|
124
|
+
returnType: 'null', returnDescription: 'Does not return', example: 'process.exit 1'
|
|
125
|
+
},
|
|
126
|
+
cwd: {
|
|
127
|
+
description: 'Get current working directory',
|
|
128
|
+
parameters: [],
|
|
129
|
+
returnType: 'string', returnDescription: 'Current working directory', example: 'process.cwd'
|
|
130
|
+
},
|
|
131
|
+
chdir: {
|
|
132
|
+
description: 'Change current working directory',
|
|
133
|
+
parameters: [{ name: 'directory', dataType: 'string', description: 'Directory to change to', formInputType: 'text', required: true }],
|
|
134
|
+
returnType: 'string', returnDescription: 'New working directory', example: 'process.chdir "/home/user"'
|
|
135
|
+
},
|
|
136
|
+
pid: {
|
|
137
|
+
description: 'Get process ID',
|
|
138
|
+
parameters: [],
|
|
139
|
+
returnType: 'number', returnDescription: 'Process ID', example: 'process.pid'
|
|
140
|
+
},
|
|
141
|
+
ppid: {
|
|
142
|
+
description: 'Get parent process ID',
|
|
143
|
+
parameters: [],
|
|
144
|
+
returnType: 'number', returnDescription: 'Parent process ID', example: 'process.ppid'
|
|
145
|
+
},
|
|
146
|
+
platform: {
|
|
147
|
+
description: 'Get operating system platform',
|
|
148
|
+
parameters: [],
|
|
149
|
+
returnType: 'string', returnDescription: 'Platform (win32, darwin, linux)', example: 'process.platform'
|
|
150
|
+
},
|
|
151
|
+
arch: {
|
|
152
|
+
description: 'Get CPU architecture',
|
|
153
|
+
parameters: [],
|
|
154
|
+
returnType: 'string', returnDescription: 'Architecture (x64, arm64, etc.)', example: 'process.arch'
|
|
155
|
+
},
|
|
156
|
+
version: {
|
|
157
|
+
description: 'Get Node.js version',
|
|
158
|
+
parameters: [],
|
|
159
|
+
returnType: 'string', returnDescription: 'Version string', example: 'process.version'
|
|
160
|
+
},
|
|
161
|
+
versions: {
|
|
162
|
+
description: 'Get version strings of Node.js and its dependencies',
|
|
163
|
+
parameters: [],
|
|
164
|
+
returnType: 'object', returnDescription: 'Object with version strings', example: 'process.versions'
|
|
165
|
+
},
|
|
166
|
+
memoryUsage: {
|
|
167
|
+
description: 'Get memory usage statistics',
|
|
168
|
+
parameters: [],
|
|
169
|
+
returnType: 'object', returnDescription: 'Object with rss, heapTotal, heapUsed, external', example: 'process.memoryUsage'
|
|
170
|
+
},
|
|
171
|
+
uptime: {
|
|
172
|
+
description: 'Get process uptime in seconds',
|
|
173
|
+
parameters: [],
|
|
174
|
+
returnType: 'number', returnDescription: 'Uptime in seconds', example: 'process.uptime'
|
|
175
|
+
},
|
|
176
|
+
hrtime: {
|
|
177
|
+
description: 'Get high-resolution time in nanoseconds',
|
|
178
|
+
parameters: [],
|
|
179
|
+
returnType: 'number', returnDescription: 'Time in nanoseconds', example: 'process.hrtime'
|
|
180
|
+
},
|
|
181
|
+
title: {
|
|
182
|
+
description: 'Get or set process title',
|
|
183
|
+
parameters: [{ name: 'title', dataType: 'string', description: 'New title (omit to get)', formInputType: 'text', required: false }],
|
|
184
|
+
returnType: 'string', returnDescription: 'Process title', example: 'process.title "MyApp"'
|
|
185
|
+
},
|
|
186
|
+
execPath: {
|
|
187
|
+
description: 'Get path to the Node.js executable',
|
|
188
|
+
parameters: [],
|
|
189
|
+
returnType: 'string', returnDescription: 'Executable path', example: 'process.execPath'
|
|
190
|
+
},
|
|
191
|
+
cpuUsage: {
|
|
192
|
+
description: 'Get CPU usage (user and system microseconds)',
|
|
193
|
+
parameters: [],
|
|
194
|
+
returnType: 'object', returnDescription: 'Object with user and system CPU time', example: 'process.cpuUsage'
|
|
195
|
+
},
|
|
196
|
+
resourceUsage: {
|
|
197
|
+
description: 'Get resource usage statistics',
|
|
198
|
+
parameters: [],
|
|
199
|
+
returnType: 'object', returnDescription: 'Resource usage object', example: 'process.resourceUsage'
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
export const ProcessModuleMetadata = {
|
|
204
|
+
description: 'Process information and control: env, argv, pid, memory, CPU, and more',
|
|
205
|
+
methods: Object.keys(ProcessFunctions)
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export default {
|
|
209
|
+
name: 'process',
|
|
210
|
+
functions: ProcessFunctions,
|
|
211
|
+
functionMetadata: ProcessFunctionMetadata,
|
|
212
|
+
moduleMetadata: ProcessModuleMetadata,
|
|
213
|
+
global: false
|
|
214
|
+
};
|