@ebowwa/codespaces-types 1.4.1 → 1.4.2
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/compile/index.js +245 -115
- package/compile/resources.js +86 -105
- package/compile/terminal-websocket.js +28 -39
- package/compile/time.js +24 -28
- package/compile/validation.js +40 -80
- package/package.json +1 -1
- package/runtime/ai.js +286 -468
- package/runtime/api.js +452 -677
- package/runtime/database.js +64 -90
- package/runtime/env.js +34 -57
- package/runtime/glm.js +14 -26
- package/runtime/index.js +882 -26
- package/runtime/ssh.js +31 -43
package/compile/index.js
CHANGED
|
@@ -1,126 +1,256 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __reExport = (target, mod, secondTarget) => {
|
|
8
|
+
for (let key of __getOwnPropNames(mod))
|
|
9
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
10
|
+
__defProp(target, key, {
|
|
11
|
+
get: () => mod[key],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
if (secondTarget) {
|
|
15
|
+
for (let key of __getOwnPropNames(mod))
|
|
16
|
+
if (!__hasOwnProp.call(secondTarget, key) && key !== "default")
|
|
17
|
+
__defProp(secondTarget, key, {
|
|
18
|
+
get: () => mod[key],
|
|
19
|
+
enumerable: true
|
|
20
|
+
});
|
|
21
|
+
return secondTarget;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
25
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
26
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
27
|
+
for (let key of __getOwnPropNames(mod))
|
|
28
|
+
if (!__hasOwnProp.call(to, key))
|
|
29
|
+
__defProp(to, key, {
|
|
30
|
+
get: () => mod[key],
|
|
31
|
+
enumerable: true
|
|
32
|
+
});
|
|
33
|
+
return to;
|
|
18
34
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
35
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
36
|
+
var __export = (target, all) => {
|
|
37
|
+
for (var name in all)
|
|
38
|
+
__defProp(target, name, {
|
|
39
|
+
get: all[name],
|
|
40
|
+
enumerable: true,
|
|
41
|
+
configurable: true,
|
|
42
|
+
set: (newValue) => all[name] = () => newValue
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// compile/terminal-websocket.js
|
|
47
|
+
var require_terminal_websocket = __commonJS((exports) => {
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.WebSocketCloseCode = undefined;
|
|
50
|
+
exports.WebSocketCloseCode = {
|
|
51
|
+
NORMAL_CLOSURE: 1000,
|
|
52
|
+
ENDPOINT_GOING_AWAY: 1001,
|
|
53
|
+
PROTOCOL_ERROR: 1002,
|
|
54
|
+
UNSUPPORTED_DATA: 1003,
|
|
55
|
+
NO_STATUS_RECEIVED: 1005,
|
|
56
|
+
ABNORMAL_CLOSURE: 1006,
|
|
57
|
+
INVALID_FRAME_PAYLOAD_DATA: 1007,
|
|
58
|
+
POLICY_VIOLATION: 1008,
|
|
59
|
+
MESSAGE_TOO_BIG: 1009,
|
|
60
|
+
MISSING_MANDATORY_EXTENSION: 1010,
|
|
61
|
+
INTERNAL_ERROR: 1011,
|
|
62
|
+
SERVICE_RESTART: 1012,
|
|
63
|
+
TRY_AGAIN_LATER: 1013,
|
|
64
|
+
SESSION_NOT_FOUND: 4001,
|
|
65
|
+
SESSION_ALREADY_CLOSED: 4002,
|
|
66
|
+
INVALID_MESSAGE_FORMAT: 4003,
|
|
67
|
+
AUTHENTICATION_FAILED: 4004,
|
|
68
|
+
CONNECTION_TIMEOUT: 4005,
|
|
69
|
+
SESSION_LIMIT_REACHED: 4006,
|
|
70
|
+
INVALID_HOST: 4007,
|
|
71
|
+
SSH_CONNECTION_FAILED: 4008,
|
|
72
|
+
NETWORK_BLOCKED: 4009
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// compile/resources.js
|
|
77
|
+
var require_resources = __commonJS((exports) => {
|
|
78
|
+
var __assign = exports && exports.__assign || function() {
|
|
79
|
+
__assign = Object.assign || function(t) {
|
|
80
|
+
for (var s, i = 1, n = arguments.length;i < n; i++) {
|
|
81
|
+
s = arguments[i];
|
|
82
|
+
for (var p in s)
|
|
83
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
84
|
+
t[p] = s[p];
|
|
85
|
+
}
|
|
86
|
+
return t;
|
|
87
|
+
};
|
|
88
|
+
return __assign.apply(this, arguments);
|
|
89
|
+
};
|
|
90
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
91
|
+
exports.parseCPU = parseCPU;
|
|
92
|
+
exports.parseMemory = parseMemory;
|
|
93
|
+
exports.parseDisk = parseDisk;
|
|
94
|
+
exports.parseGPU = parseGPU;
|
|
95
|
+
exports.parseResources = parseResources;
|
|
96
|
+
function parseCPU(raw) {
|
|
97
|
+
if (!raw || typeof raw !== "string") {
|
|
98
|
+
return 0;
|
|
99
|
+
}
|
|
100
|
+
var num = parseFloat(raw);
|
|
101
|
+
if (isNaN(num)) {
|
|
102
|
+
console.warn("Invalid CPU value:", raw);
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
return Math.round(num * 10) / 10;
|
|
106
|
+
}
|
|
107
|
+
function parseMemory(raw) {
|
|
108
|
+
if (!raw || typeof raw !== "string") {
|
|
109
|
+
return { percent: 0, used: "0 GB", total: "0 GB" };
|
|
110
|
+
}
|
|
111
|
+
var parts = raw.split(/\s+/);
|
|
112
|
+
if (parts.length < 3) {
|
|
113
|
+
console.warn("Invalid memory output:", raw);
|
|
114
|
+
return { percent: 0, used: "0 GB", total: "0 GB" };
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
percent: Math.round(parseFloat(parts[0]) * 10) / 10,
|
|
118
|
+
used: "".concat((parseFloat(parts[1]) || 0).toFixed(1), " GB"),
|
|
119
|
+
total: "".concat((parseFloat(parts[2]) || 0).toFixed(1), " GB")
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function parseDisk(raw) {
|
|
123
|
+
var _a;
|
|
124
|
+
if (!raw || typeof raw !== "string") {
|
|
125
|
+
return { percent: 0, used: "0 GB", total: "0 GB" };
|
|
126
|
+
}
|
|
127
|
+
var parts = raw.split(/\s+/);
|
|
128
|
+
var percent = parseFloat(((_a = parts[0]) === null || _a === undefined ? undefined : _a.replace("%", "")) || "0") || 0;
|
|
129
|
+
var formatSize = function(size) {
|
|
130
|
+
if (size.endsWith("G") || size.endsWith("M") || size.endsWith("K")) {
|
|
131
|
+
return size.replace(/([GMK])$/, " $1B");
|
|
132
|
+
}
|
|
133
|
+
return size;
|
|
134
|
+
};
|
|
135
|
+
return {
|
|
136
|
+
percent: Math.round(percent),
|
|
137
|
+
used: formatSize(parts[1] || "0 GB"),
|
|
138
|
+
total: formatSize(parts[2] || "0 GB")
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function parseGPU(raw) {
|
|
142
|
+
if (!raw || raw === "NOGPU" || raw === "0" || !raw.trim()) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
var parts = raw.split(",").map(function(s) {
|
|
146
|
+
return s.trim();
|
|
147
|
+
});
|
|
148
|
+
if (parts.length < 3) {
|
|
149
|
+
console.warn("Invalid GPU output:", raw);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
gpuPercent: parseFloat(parts[0]) || 0,
|
|
154
|
+
gpuMemoryUsed: "".concat((parseFloat(parts[1]) / 1024).toFixed(1), " GB"),
|
|
155
|
+
gpuMemoryTotal: "".concat((parseFloat(parts[2]) / 1024).toFixed(1), " GB")
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function parseResources(raw) {
|
|
159
|
+
var cpu = parseCPU(raw.cpu);
|
|
160
|
+
var memory = parseMemory(raw.memory);
|
|
161
|
+
var disk = parseDisk(raw.disk);
|
|
162
|
+
var gpu = parseGPU(raw.gpu);
|
|
163
|
+
return __assign({
|
|
164
|
+
cpu,
|
|
165
|
+
memory: memory.percent,
|
|
166
|
+
disk: disk.percent,
|
|
167
|
+
gpu: raw.gpu,
|
|
168
|
+
network: raw.network,
|
|
169
|
+
loadavg: raw.loadavg,
|
|
170
|
+
processes: raw.processes,
|
|
171
|
+
connections: raw.connections,
|
|
172
|
+
ports: raw.ports,
|
|
173
|
+
cpuPercent: cpu,
|
|
174
|
+
memoryPercent: memory.percent,
|
|
175
|
+
memoryUsed: memory.used,
|
|
176
|
+
memoryTotal: memory.total,
|
|
177
|
+
diskPercent: disk.percent,
|
|
178
|
+
diskUsed: disk.used,
|
|
179
|
+
diskTotal: disk.total
|
|
180
|
+
}, gpu && {
|
|
181
|
+
gpuPercent: gpu.gpuPercent,
|
|
182
|
+
gpuMemoryUsed: gpu.gpuMemoryUsed,
|
|
183
|
+
gpuMemoryTotal: gpu.gpuMemoryTotal
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// compile/index.ts
|
|
189
|
+
var exports_compile = {};
|
|
190
|
+
__export(exports_compile, {
|
|
191
|
+
getEnvRegionName: () => getEnvRegionName,
|
|
192
|
+
getEnvLocationLabel: () => getEnvLocationLabel,
|
|
193
|
+
getEnvLocation: () => getEnvLocation,
|
|
194
|
+
VolumeStatus: () => VolumeStatus,
|
|
195
|
+
LoopStatus: () => LoopStatus,
|
|
196
|
+
EnvironmentStatus: () => EnvironmentStatus,
|
|
197
|
+
ActionStatus: () => ActionStatus
|
|
198
|
+
});
|
|
199
|
+
__reExport(exports_compile, __toESM(require_terminal_websocket(), 1));
|
|
200
|
+
__reExport(exports_compile, __toESM(require_resources(), 1));
|
|
51
201
|
var EnvironmentStatus;
|
|
52
|
-
(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
})(EnvironmentStatus || (exports.EnvironmentStatus = EnvironmentStatus = {}));
|
|
62
|
-
/**
|
|
63
|
-
* Action status - used by HetznerAction
|
|
64
|
-
*/
|
|
202
|
+
((EnvironmentStatus2) => {
|
|
203
|
+
EnvironmentStatus2["Running"] = "running";
|
|
204
|
+
EnvironmentStatus2["Stopped"] = "stopped";
|
|
205
|
+
EnvironmentStatus2["Creating"] = "creating";
|
|
206
|
+
EnvironmentStatus2["Deleting"] = "deleting";
|
|
207
|
+
EnvironmentStatus2["Starting"] = "starting";
|
|
208
|
+
EnvironmentStatus2["Stopping"] = "stopping";
|
|
209
|
+
EnvironmentStatus2["Initializing"] = "initializing";
|
|
210
|
+
})(EnvironmentStatus ||= {});
|
|
65
211
|
var ActionStatus;
|
|
66
|
-
(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
})(ActionStatus
|
|
71
|
-
/**
|
|
72
|
-
* Volume status - used by HetznerVolume
|
|
73
|
-
*/
|
|
212
|
+
((ActionStatus2) => {
|
|
213
|
+
ActionStatus2["Running"] = "running";
|
|
214
|
+
ActionStatus2["Success"] = "success";
|
|
215
|
+
ActionStatus2["Error"] = "error";
|
|
216
|
+
})(ActionStatus ||= {});
|
|
74
217
|
var VolumeStatus;
|
|
75
|
-
(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
})(VolumeStatus
|
|
80
|
-
/**
|
|
81
|
-
* Ralph Loop status - used by RalphLoop interface
|
|
82
|
-
*/
|
|
218
|
+
((VolumeStatus2) => {
|
|
219
|
+
VolumeStatus2["Creating"] = "creating";
|
|
220
|
+
VolumeStatus2["Available"] = "available";
|
|
221
|
+
VolumeStatus2["Deleting"] = "deleting";
|
|
222
|
+
})(VolumeStatus ||= {});
|
|
83
223
|
var LoopStatus;
|
|
84
|
-
(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
})(LoopStatus
|
|
90
|
-
/**
|
|
91
|
-
* Get the location object from an environment
|
|
92
|
-
* @param env - The environment object
|
|
93
|
-
* @returns The location object or null
|
|
94
|
-
*/
|
|
224
|
+
((LoopStatus2) => {
|
|
225
|
+
LoopStatus2["Running"] = "running";
|
|
226
|
+
LoopStatus2["Stopped"] = "stopped";
|
|
227
|
+
LoopStatus2["Error"] = "error";
|
|
228
|
+
LoopStatus2["Completed"] = "completed";
|
|
229
|
+
})(LoopStatus ||= {});
|
|
95
230
|
function getEnvLocation(env) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
231
|
+
if (!env)
|
|
232
|
+
return null;
|
|
233
|
+
return env.location || null;
|
|
99
234
|
}
|
|
100
|
-
/**
|
|
101
|
-
* Get the region name (short format like "nbg1") from an environment
|
|
102
|
-
* @param env - The environment object
|
|
103
|
-
* @returns The region name (e.g., "nbg1") or "Unknown"
|
|
104
|
-
*/
|
|
105
235
|
function getEnvRegionName(env) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return ((_a = env.location) === null || _a === void 0 ? void 0 : _a.name) || "Unknown";
|
|
236
|
+
if (!env)
|
|
237
|
+
return "Unknown";
|
|
238
|
+
return env.location?.name || "Unknown";
|
|
110
239
|
}
|
|
111
|
-
/**
|
|
112
|
-
* Get a human-readable location label with city and country
|
|
113
|
-
* @param env - The environment object
|
|
114
|
-
* @returns A formatted location string (e.g., "Nuremberg, DE" or "nbg1" as fallback)
|
|
115
|
-
*/
|
|
116
240
|
function getEnvLocationLabel(env) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
// Fallback to location name
|
|
125
|
-
return ((_c = env.location) === null || _c === void 0 ? void 0 : _c.name) || "Unknown";
|
|
241
|
+
if (!env)
|
|
242
|
+
return "Unknown";
|
|
243
|
+
if (env.location?.city && env.location?.country) {
|
|
244
|
+
return `${env.location.city}, ${env.location.country}`;
|
|
245
|
+
}
|
|
246
|
+
return env.location?.name || "Unknown";
|
|
126
247
|
}
|
|
248
|
+
export {
|
|
249
|
+
getEnvRegionName,
|
|
250
|
+
getEnvLocationLabel,
|
|
251
|
+
getEnvLocation,
|
|
252
|
+
VolumeStatus,
|
|
253
|
+
LoopStatus,
|
|
254
|
+
EnvironmentStatus,
|
|
255
|
+
ActionStatus
|
|
256
|
+
};
|
package/compile/resources.js
CHANGED
|
@@ -1,116 +1,97 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Shared resource parsing utilities
|
|
4
|
-
*/
|
|
5
|
-
var __assign = (this && this.__assign) || function () {
|
|
6
|
-
__assign = Object.assign || function(t) {
|
|
7
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
-
s = arguments[i];
|
|
9
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
-
t[p] = s[p];
|
|
11
|
-
}
|
|
12
|
-
return t;
|
|
13
|
-
};
|
|
14
|
-
return __assign.apply(this, arguments);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.parseCPU = parseCPU;
|
|
18
|
-
exports.parseMemory = parseMemory;
|
|
19
|
-
exports.parseDisk = parseDisk;
|
|
20
|
-
exports.parseGPU = parseGPU;
|
|
21
|
-
exports.parseResources = parseResources;
|
|
22
|
-
/**
|
|
23
|
-
* Parse CPU usage from raw output with validation
|
|
24
|
-
*/
|
|
1
|
+
// @bun
|
|
2
|
+
// compile/resources.ts
|
|
25
3
|
function parseCPU(raw) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
4
|
+
if (!raw || typeof raw !== "string") {
|
|
5
|
+
return 0;
|
|
6
|
+
}
|
|
7
|
+
const num = parseFloat(raw);
|
|
8
|
+
if (isNaN(num)) {
|
|
9
|
+
console.warn("Invalid CPU value:", raw);
|
|
10
|
+
return 0;
|
|
11
|
+
}
|
|
12
|
+
return Math.round(num * 10) / 10;
|
|
35
13
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Parse memory usage from raw output with validation
|
|
38
|
-
* Returns: { percent, used, total }
|
|
39
|
-
*/
|
|
40
14
|
function parseMemory(raw) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
15
|
+
if (!raw || typeof raw !== "string") {
|
|
16
|
+
return { percent: 0, used: "0 GB", total: "0 GB" };
|
|
17
|
+
}
|
|
18
|
+
const parts = raw.split(/\s+/);
|
|
19
|
+
if (parts.length < 3) {
|
|
20
|
+
console.warn("Invalid memory output:", raw);
|
|
21
|
+
return { percent: 0, used: "0 GB", total: "0 GB" };
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
percent: Math.round(parseFloat(parts[0]) * 10) / 10,
|
|
25
|
+
used: `${(parseFloat(parts[1]) || 0).toFixed(1)} GB`,
|
|
26
|
+
total: `${(parseFloat(parts[2]) || 0).toFixed(1)} GB`
|
|
27
|
+
};
|
|
54
28
|
}
|
|
55
|
-
/**
|
|
56
|
-
* Parse disk usage from raw output with validation
|
|
57
|
-
* Handles formats like "4% 2.8G 75G" -> adds space before unit
|
|
58
|
-
*/
|
|
59
29
|
function parseDisk(raw) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
30
|
+
if (!raw || typeof raw !== "string") {
|
|
31
|
+
return { percent: 0, used: "0 GB", total: "0 GB" };
|
|
32
|
+
}
|
|
33
|
+
const parts = raw.split(/\s+/);
|
|
34
|
+
const percent = parseFloat(parts[0]?.replace("%", "") || "0") || 0;
|
|
35
|
+
const formatSize = (size) => {
|
|
36
|
+
if (size.endsWith("G") || size.endsWith("M") || size.endsWith("K")) {
|
|
37
|
+
return size.replace(/([GMK])$/, " $1B");
|
|
63
38
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return size;
|
|
72
|
-
};
|
|
73
|
-
return {
|
|
74
|
-
percent: Math.round(percent),
|
|
75
|
-
used: formatSize(parts[1] || '0 GB'),
|
|
76
|
-
total: formatSize(parts[2] || '0 GB'),
|
|
77
|
-
};
|
|
39
|
+
return size;
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
percent: Math.round(percent),
|
|
43
|
+
used: formatSize(parts[1] || "0 GB"),
|
|
44
|
+
total: formatSize(parts[2] || "0 GB")
|
|
45
|
+
};
|
|
78
46
|
}
|
|
79
|
-
/**
|
|
80
|
-
* Parse GPU usage from raw output with validation
|
|
81
|
-
* Returns undefined if no GPU present
|
|
82
|
-
*/
|
|
83
47
|
function parseGPU(raw) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
};
|
|
48
|
+
if (!raw || raw === "NOGPU" || raw === "0" || !raw.trim()) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const parts = raw.split(",").map((s) => s.trim());
|
|
52
|
+
if (parts.length < 3) {
|
|
53
|
+
console.warn("Invalid GPU output:", raw);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
gpuPercent: parseFloat(parts[0]) || 0,
|
|
58
|
+
gpuMemoryUsed: `${(parseFloat(parts[1]) / 1024).toFixed(1)} GB`,
|
|
59
|
+
gpuMemoryTotal: `${(parseFloat(parts[2]) / 1024).toFixed(1)} GB`
|
|
60
|
+
};
|
|
98
61
|
}
|
|
99
|
-
/**
|
|
100
|
-
* Parse all resources from raw command outputs
|
|
101
|
-
*/
|
|
102
62
|
function parseResources(raw) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
63
|
+
const cpu = parseCPU(raw.cpu);
|
|
64
|
+
const memory = parseMemory(raw.memory);
|
|
65
|
+
const disk = parseDisk(raw.disk);
|
|
66
|
+
const gpu = parseGPU(raw.gpu);
|
|
67
|
+
return {
|
|
68
|
+
cpu,
|
|
69
|
+
memory: memory.percent,
|
|
70
|
+
disk: disk.percent,
|
|
71
|
+
gpu: raw.gpu,
|
|
72
|
+
network: raw.network,
|
|
73
|
+
loadavg: raw.loadavg,
|
|
74
|
+
processes: raw.processes,
|
|
75
|
+
connections: raw.connections,
|
|
76
|
+
ports: raw.ports,
|
|
77
|
+
cpuPercent: cpu,
|
|
78
|
+
memoryPercent: memory.percent,
|
|
79
|
+
memoryUsed: memory.used,
|
|
80
|
+
memoryTotal: memory.total,
|
|
81
|
+
diskPercent: disk.percent,
|
|
82
|
+
diskUsed: disk.used,
|
|
83
|
+
diskTotal: disk.total,
|
|
84
|
+
...gpu && {
|
|
85
|
+
gpuPercent: gpu.gpuPercent,
|
|
86
|
+
gpuMemoryUsed: gpu.gpuMemoryUsed,
|
|
87
|
+
gpuMemoryTotal: gpu.gpuMemoryTotal
|
|
88
|
+
}
|
|
89
|
+
};
|
|
116
90
|
}
|
|
91
|
+
export {
|
|
92
|
+
parseResources,
|
|
93
|
+
parseMemory,
|
|
94
|
+
parseGPU,
|
|
95
|
+
parseDisk,
|
|
96
|
+
parseCPU
|
|
97
|
+
};
|
|
@@ -1,40 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// Application-specific codes (3000-4999)
|
|
30
|
-
// Terminal-specific codes (4000-4099)
|
|
31
|
-
SESSION_NOT_FOUND: 4001,
|
|
32
|
-
SESSION_ALREADY_CLOSED: 4002,
|
|
33
|
-
INVALID_MESSAGE_FORMAT: 4003,
|
|
34
|
-
AUTHENTICATION_FAILED: 4004,
|
|
35
|
-
CONNECTION_TIMEOUT: 4005,
|
|
36
|
-
SESSION_LIMIT_REACHED: 4006,
|
|
37
|
-
INVALID_HOST: 4007,
|
|
38
|
-
SSH_CONNECTION_FAILED: 4008,
|
|
39
|
-
NETWORK_BLOCKED: 4009, // Network is blocking Hetzner/VPS IPs
|
|
1
|
+
// @bun
|
|
2
|
+
// compile/terminal-websocket.ts
|
|
3
|
+
var WebSocketCloseCode = {
|
|
4
|
+
NORMAL_CLOSURE: 1000,
|
|
5
|
+
ENDPOINT_GOING_AWAY: 1001,
|
|
6
|
+
PROTOCOL_ERROR: 1002,
|
|
7
|
+
UNSUPPORTED_DATA: 1003,
|
|
8
|
+
NO_STATUS_RECEIVED: 1005,
|
|
9
|
+
ABNORMAL_CLOSURE: 1006,
|
|
10
|
+
INVALID_FRAME_PAYLOAD_DATA: 1007,
|
|
11
|
+
POLICY_VIOLATION: 1008,
|
|
12
|
+
MESSAGE_TOO_BIG: 1009,
|
|
13
|
+
MISSING_MANDATORY_EXTENSION: 1010,
|
|
14
|
+
INTERNAL_ERROR: 1011,
|
|
15
|
+
SERVICE_RESTART: 1012,
|
|
16
|
+
TRY_AGAIN_LATER: 1013,
|
|
17
|
+
SESSION_NOT_FOUND: 4001,
|
|
18
|
+
SESSION_ALREADY_CLOSED: 4002,
|
|
19
|
+
INVALID_MESSAGE_FORMAT: 4003,
|
|
20
|
+
AUTHENTICATION_FAILED: 4004,
|
|
21
|
+
CONNECTION_TIMEOUT: 4005,
|
|
22
|
+
SESSION_LIMIT_REACHED: 4006,
|
|
23
|
+
INVALID_HOST: 4007,
|
|
24
|
+
SSH_CONNECTION_FAILED: 4008,
|
|
25
|
+
NETWORK_BLOCKED: 4009
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
WebSocketCloseCode
|
|
40
29
|
};
|