@ebowwa/codespaces-types 1.1.0 → 1.2.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/{dist/compile → compile}/index.js +41 -15
- package/compile/index.ts +553 -0
- package/compile/resources.js +116 -0
- package/compile/resources.ts +157 -0
- package/compile/schemas/resources.js +127 -0
- package/compile/schemas/resources.ts +144 -0
- package/{dist/compile → compile}/terminal-websocket.js +4 -1
- package/compile/terminal-websocket.ts +133 -0
- package/compile/time.js +30 -0
- package/compile/time.ts +32 -0
- package/{dist/compile → compile}/user/distributions.js +0 -1
- package/{dist/compile/user/distributions.d.ts → compile/user/distributions.ts} +0 -1
- package/{dist/compile → compile}/validation.js +23 -17
- package/compile/validation.ts +98 -0
- package/index.js +21 -0
- package/index.ts +5 -0
- package/package.json +38 -45
- package/runtime/ai.js +505 -0
- package/runtime/ai.ts +501 -0
- package/runtime/api.js +677 -0
- package/runtime/api.ts +857 -0
- package/runtime/database.js +94 -0
- package/runtime/database.ts +107 -0
- package/runtime/env.js +63 -0
- package/runtime/env.ts +68 -0
- package/{dist/runtime → runtime}/glm.js +7 -4
- package/runtime/glm.ts +36 -0
- package/runtime/index.js +28 -0
- package/{dist/runtime/index.js → runtime/index.ts} +1 -0
- package/runtime/ssh.js +47 -0
- package/runtime/ssh.ts +58 -0
- package/README.md +0 -65
- package/dist/compile/index.d.ts +0 -437
- package/dist/compile/index.d.ts.map +0 -1
- package/dist/compile/resources.d.ts +0 -69
- package/dist/compile/resources.d.ts.map +0 -1
- package/dist/compile/resources.js +0 -113
- package/dist/compile/schemas/resources.d.ts +0 -166
- package/dist/compile/schemas/resources.d.ts.map +0 -1
- package/dist/compile/schemas/resources.js +0 -123
- package/dist/compile/terminal-websocket.d.ts +0 -109
- package/dist/compile/terminal-websocket.d.ts.map +0 -1
- package/dist/compile/time.d.ts +0 -7
- package/dist/compile/time.d.ts.map +0 -1
- package/dist/compile/time.js +0 -27
- package/dist/compile/user/distributions.d.ts.map +0 -1
- package/dist/compile/validation.d.ts +0 -44
- package/dist/compile/validation.d.ts.map +0 -1
- package/dist/runtime/ai.d.ts +0 -1336
- package/dist/runtime/ai.d.ts.map +0 -1
- package/dist/runtime/ai.js +0 -416
- package/dist/runtime/api.d.ts +0 -1304
- package/dist/runtime/api.d.ts.map +0 -1
- package/dist/runtime/api.js +0 -673
- package/dist/runtime/database.d.ts +0 -376
- package/dist/runtime/database.d.ts.map +0 -1
- package/dist/runtime/database.js +0 -91
- package/dist/runtime/env.d.ts +0 -121
- package/dist/runtime/env.d.ts.map +0 -1
- package/dist/runtime/env.js +0 -54
- package/dist/runtime/glm.d.ts +0 -17
- package/dist/runtime/glm.d.ts.map +0 -1
- package/dist/runtime/index.d.ts +0 -13
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/ssh.d.ts +0 -111
- package/dist/runtime/ssh.d.ts.map +0 -1
- package/dist/runtime/ssh.js +0 -44
package/dist/compile/index.d.ts
DELETED
|
@@ -1,437 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared type definitions for frontend and server
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Hetzner server type with pricing information
|
|
6
|
-
*/
|
|
7
|
-
export interface HetznerServerType {
|
|
8
|
-
id: number;
|
|
9
|
-
name: string;
|
|
10
|
-
description: string;
|
|
11
|
-
cores: number;
|
|
12
|
-
memory: number;
|
|
13
|
-
disk: number;
|
|
14
|
-
deprecated?: boolean;
|
|
15
|
-
prices: Array<{
|
|
16
|
-
location: string | null;
|
|
17
|
-
price_hourly: {
|
|
18
|
-
net: string;
|
|
19
|
-
gross: string;
|
|
20
|
-
};
|
|
21
|
-
price_monthly: {
|
|
22
|
-
net: string;
|
|
23
|
-
gross: string;
|
|
24
|
-
};
|
|
25
|
-
}>;
|
|
26
|
-
storage_type: "local" | "network";
|
|
27
|
-
cpu_type: "shared" | "dedicated";
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Hetzner location/datacenter
|
|
31
|
-
*/
|
|
32
|
-
export interface HetznerLocation {
|
|
33
|
-
id: number;
|
|
34
|
-
name: string;
|
|
35
|
-
description: string;
|
|
36
|
-
country: string;
|
|
37
|
-
city: string;
|
|
38
|
-
latitude: number;
|
|
39
|
-
longitude: number;
|
|
40
|
-
network_zone: string;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Hetzner datacenter (specific facility within a location)
|
|
44
|
-
* Previously backend-only, now shared for full object graph preservation
|
|
45
|
-
*/
|
|
46
|
-
export interface HetznerDatacenter {
|
|
47
|
-
id: number;
|
|
48
|
-
name: string;
|
|
49
|
-
description: string;
|
|
50
|
-
location: HetznerLocation;
|
|
51
|
-
supported_server_types?: Array<{
|
|
52
|
-
id: number;
|
|
53
|
-
name: string;
|
|
54
|
-
}> | null;
|
|
55
|
-
available_server_types?: Array<{
|
|
56
|
-
id: number;
|
|
57
|
-
name: string;
|
|
58
|
-
}>;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Environment status - used by Environment interface and HetznerServer mapping
|
|
62
|
-
*
|
|
63
|
-
* Hetzner API returns: "running" | "stopped" | "starting" | "stopping" | "initializing"
|
|
64
|
-
* Environment uses subset: "running" | "stopped" | "creating" | "deleting"
|
|
65
|
-
*
|
|
66
|
-
* Mapping:
|
|
67
|
-
* - "running" → "running"
|
|
68
|
-
* - "stopped" → "stopped"
|
|
69
|
-
* - "starting" → "creating"
|
|
70
|
-
* - "stopping" → "deleting"
|
|
71
|
-
* - "initializing" → "creating"
|
|
72
|
-
*/
|
|
73
|
-
export declare enum EnvironmentStatus {
|
|
74
|
-
Running = "running",
|
|
75
|
-
Stopped = "stopped",
|
|
76
|
-
Creating = "creating",
|
|
77
|
-
Deleting = "deleting",
|
|
78
|
-
Starting = "starting",
|
|
79
|
-
Stopping = "stopping",
|
|
80
|
-
Initializing = "initializing"
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Action status - used by HetznerAction
|
|
84
|
-
*/
|
|
85
|
-
export declare enum ActionStatus {
|
|
86
|
-
Running = "running",
|
|
87
|
-
Success = "success",
|
|
88
|
-
Error = "error"
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Volume status - used by HetznerVolume
|
|
92
|
-
*/
|
|
93
|
-
export declare enum VolumeStatus {
|
|
94
|
-
Creating = "creating",
|
|
95
|
-
Available = "available",
|
|
96
|
-
Deleting = "deleting"
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Ralph Loop status - used by RalphLoop interface
|
|
100
|
-
*/
|
|
101
|
-
export declare enum LoopStatus {
|
|
102
|
-
Running = "running",
|
|
103
|
-
Stopped = "stopped",
|
|
104
|
-
Error = "error",
|
|
105
|
-
Completed = "completed"
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Active port on a server
|
|
109
|
-
*/
|
|
110
|
-
export interface ActivePort {
|
|
111
|
-
port: number;
|
|
112
|
-
protocol: "tcp" | "udp";
|
|
113
|
-
service?: string;
|
|
114
|
-
state: "open" | "closed" | "filtered";
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Base permissions structure shared by Environment and EnvironmentMetadata
|
|
118
|
-
*/
|
|
119
|
-
export interface BasePermissions {
|
|
120
|
-
seedConfig?: {
|
|
121
|
-
sourceEnvironmentId?: string;
|
|
122
|
-
dependencySnapshot?: string;
|
|
123
|
-
setupScript?: string;
|
|
124
|
-
};
|
|
125
|
-
logins?: {
|
|
126
|
-
github?: {
|
|
127
|
-
enabled: boolean;
|
|
128
|
-
username?: string;
|
|
129
|
-
tokenScopes?: string[];
|
|
130
|
-
};
|
|
131
|
-
doppler?: {
|
|
132
|
-
enabled: boolean;
|
|
133
|
-
project?: string;
|
|
134
|
-
config?: string;
|
|
135
|
-
};
|
|
136
|
-
tailscale?: {
|
|
137
|
-
enabled: boolean;
|
|
138
|
-
authKey?: string;
|
|
139
|
-
hostname?: string;
|
|
140
|
-
};
|
|
141
|
-
};
|
|
142
|
-
vpns?: Array<{
|
|
143
|
-
name: string;
|
|
144
|
-
type: "wireguard" | "openvpn" | "tailscale";
|
|
145
|
-
config: string;
|
|
146
|
-
connected: boolean;
|
|
147
|
-
}>;
|
|
148
|
-
plugins?: Record<string, ClaudeCodePlugin>;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Base fields shared by Environment and EnvironmentMetadata
|
|
152
|
-
*/
|
|
153
|
-
export interface EnvironmentBase {
|
|
154
|
-
id: string;
|
|
155
|
-
description?: string;
|
|
156
|
-
project?: string;
|
|
157
|
-
owner?: string;
|
|
158
|
-
purpose?: string;
|
|
159
|
-
environmentType?: "development" | "staging" | "production" | "testing";
|
|
160
|
-
hoursActive?: number;
|
|
161
|
-
lastActive?: string;
|
|
162
|
-
activePorts?: ActivePort[];
|
|
163
|
-
/** Cloud-init bootstrap status */
|
|
164
|
-
bootstrapStatus?: "bootstrapping" | "ready" | "failed";
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Claude Code hook event types
|
|
168
|
-
*/
|
|
169
|
-
export type HookEventType = "SessionStart" | "UserPromptSubmit" | "PreToolUse" | "PostToolUse" | "PreCommand" | "PostCommand" | "Stop" | "Error" | "FileChange";
|
|
170
|
-
/**
|
|
171
|
-
* Claude Code hook configuration
|
|
172
|
-
*/
|
|
173
|
-
export interface ClaudeCodeHook {
|
|
174
|
-
event: HookEventType;
|
|
175
|
-
description?: string;
|
|
176
|
-
command?: string;
|
|
177
|
-
output?: {
|
|
178
|
-
allow?: boolean;
|
|
179
|
-
context?: string;
|
|
180
|
-
modifyInput?: string;
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Claude Code agent configuration
|
|
185
|
-
*/
|
|
186
|
-
export interface ClaudeCodeAgent {
|
|
187
|
-
name: string;
|
|
188
|
-
description?: string;
|
|
189
|
-
instructions?: string;
|
|
190
|
-
model?: string;
|
|
191
|
-
temperature?: number;
|
|
192
|
-
maxTokens?: number;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Claude Code command configuration
|
|
196
|
-
*/
|
|
197
|
-
export interface ClaudeCodeCommand {
|
|
198
|
-
name: string;
|
|
199
|
-
description?: string;
|
|
200
|
-
instructions?: string;
|
|
201
|
-
agent?: string;
|
|
202
|
-
shouldConfirm?: boolean;
|
|
203
|
-
parameters?: Record<string, {
|
|
204
|
-
type: "string" | "boolean" | "number" | "array";
|
|
205
|
-
description?: string;
|
|
206
|
-
required?: boolean;
|
|
207
|
-
default?: unknown;
|
|
208
|
-
}>;
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Claude Code skill configuration
|
|
212
|
-
*/
|
|
213
|
-
export interface ClaudeCodeSkill {
|
|
214
|
-
name: string;
|
|
215
|
-
description?: string;
|
|
216
|
-
instructions?: string;
|
|
217
|
-
trigger?: {
|
|
218
|
-
patterns?: string[];
|
|
219
|
-
fileTypes?: string[];
|
|
220
|
-
always?: boolean;
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* MCP (Model Context Protocol) Server Configuration
|
|
225
|
-
*
|
|
226
|
-
* === LAYER 2: CLI Wrapper Plugin System ===
|
|
227
|
-
*
|
|
228
|
-
* MCP is NOT part of the OpenAI protocol (Layer 1).
|
|
229
|
-
* It's a separate plugin system for exposing tools/resources to AI models.
|
|
230
|
-
*
|
|
231
|
-
* These types are defined but NOT yet implemented in cheapspaces.
|
|
232
|
-
*
|
|
233
|
-
* Reference Implementation: tools/continue/core/context/mcp/
|
|
234
|
-
*
|
|
235
|
-
* Potential MCP Tools for Cheapspaces:
|
|
236
|
-
* - hetzner_create: Create new server (wrap HetznerClient.createServer())
|
|
237
|
-
* - hetzner_delete: Delete server (wrap HetznerClient.deleteServer())
|
|
238
|
-
* - hetzner_power: Power on/off (wrap powerOn/powerOff)
|
|
239
|
-
* - ssh_exec: Execute remote command (wrap execSSH())
|
|
240
|
-
* - ssh_upload: Upload file via SCP (wrap scpUpload())
|
|
241
|
-
* - ssh_download: Download file via SCP (wrap scpDownload())
|
|
242
|
-
* - resources_get: Get resource usage (wrap getResources())
|
|
243
|
-
*
|
|
244
|
-
* To implement (Layer 2 only):
|
|
245
|
-
* 1. Create MCPManagerSingleton (see continue's pattern)
|
|
246
|
-
* 2. Create MCPConnection wrapper for stdio/HTTP servers
|
|
247
|
-
* 3. Expose Hetzner/SSH operations as MCP tools
|
|
248
|
-
* 4. Integrate with AI chat for tool calling
|
|
249
|
-
*/
|
|
250
|
-
export interface MCPServerConfig {
|
|
251
|
-
name: string;
|
|
252
|
-
command: string;
|
|
253
|
-
args?: string[];
|
|
254
|
-
env?: Record<string, string>;
|
|
255
|
-
cwd?: string;
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Claude Code plugin configuration
|
|
259
|
-
*/
|
|
260
|
-
export interface ClaudeCodePlugin {
|
|
261
|
-
enabled: boolean;
|
|
262
|
-
name?: string;
|
|
263
|
-
description?: string;
|
|
264
|
-
version?: string;
|
|
265
|
-
author?: string;
|
|
266
|
-
commands?: ClaudeCodeCommand[];
|
|
267
|
-
agents?: ClaudeCodeAgent[];
|
|
268
|
-
skills?: ClaudeCodeSkill[];
|
|
269
|
-
hooks?: ClaudeCodeHook[];
|
|
270
|
-
mcpServers?: MCPServerConfig[];
|
|
271
|
-
config?: Record<string, unknown>;
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* Server image information
|
|
275
|
-
*/
|
|
276
|
-
export interface ServerImage {
|
|
277
|
-
id: number;
|
|
278
|
-
name: string;
|
|
279
|
-
description: string;
|
|
280
|
-
type: "snapshot" | "backup" | "system";
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Environment data - shared between frontend and server
|
|
284
|
-
*/
|
|
285
|
-
export interface Environment extends EnvironmentBase {
|
|
286
|
-
name: string;
|
|
287
|
-
status: EnvironmentStatus.Running | EnvironmentStatus.Stopped | EnvironmentStatus.Creating | EnvironmentStatus.Deleting;
|
|
288
|
-
progress?: number;
|
|
289
|
-
serverId: number;
|
|
290
|
-
serverType: string;
|
|
291
|
-
image: ServerImage;
|
|
292
|
-
location?: HetznerLocation;
|
|
293
|
-
datacenter?: HetznerDatacenter;
|
|
294
|
-
ipv4: string | null;
|
|
295
|
-
ipv6: string | null;
|
|
296
|
-
createdAt: string;
|
|
297
|
-
lastUsed: string | null;
|
|
298
|
-
tags: string[];
|
|
299
|
-
resources?: {
|
|
300
|
-
cpuPercent: number;
|
|
301
|
-
memoryPercent: number;
|
|
302
|
-
memoryUsed: string;
|
|
303
|
-
memoryTotal: string;
|
|
304
|
-
diskPercent: number;
|
|
305
|
-
diskUsed: string;
|
|
306
|
-
diskTotal: string;
|
|
307
|
-
gpuPercent?: number;
|
|
308
|
-
gpuMemoryUsed?: string;
|
|
309
|
-
gpuMemoryTotal?: string;
|
|
310
|
-
lastUpdated?: string;
|
|
311
|
-
};
|
|
312
|
-
nodeAgent?: NodeAgentInfo;
|
|
313
|
-
permissions?: BasePermissions & {
|
|
314
|
-
skills?: Array<{
|
|
315
|
-
name: string;
|
|
316
|
-
enabled: boolean;
|
|
317
|
-
config?: Record<string, unknown>;
|
|
318
|
-
}>;
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* Get the location object from an environment
|
|
323
|
-
* @param env - The environment object
|
|
324
|
-
* @returns The location object or null
|
|
325
|
-
*/
|
|
326
|
-
export declare function getEnvLocation(env: Environment | undefined | null): HetznerLocation | null;
|
|
327
|
-
/**
|
|
328
|
-
* Get the region name (short format like "nbg1") from an environment
|
|
329
|
-
* @param env - The environment object
|
|
330
|
-
* @returns The region name (e.g., "nbg1") or "Unknown"
|
|
331
|
-
*/
|
|
332
|
-
export declare function getEnvRegionName(env: Environment | undefined | null): string;
|
|
333
|
-
/**
|
|
334
|
-
* Get a human-readable location label with city and country
|
|
335
|
-
* @param env - The environment object
|
|
336
|
-
* @returns A formatted location string (e.g., "Nuremberg, DE" or "nbg1" as fallback)
|
|
337
|
-
*/
|
|
338
|
-
export declare function getEnvLocationLabel(env: Environment | undefined | null): string;
|
|
339
|
-
/**
|
|
340
|
-
* Environment metadata for storage
|
|
341
|
-
* Extends EnvironmentBase with storage-specific fields
|
|
342
|
-
*/
|
|
343
|
-
export interface EnvironmentMetadata extends EnvironmentBase {
|
|
344
|
-
sshKeyPath?: string;
|
|
345
|
-
permissions?: BasePermissions;
|
|
346
|
-
updatedAt?: string;
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* Node Agent - Ralph Loop orchestration service running on each VPS
|
|
350
|
-
*/
|
|
351
|
-
/**
|
|
352
|
-
* Git worktree information
|
|
353
|
-
*/
|
|
354
|
-
export interface Worktree {
|
|
355
|
-
id: string;
|
|
356
|
-
branch: string;
|
|
357
|
-
commit: string;
|
|
358
|
-
path: string;
|
|
359
|
-
created?: string;
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* Ralph Loop status and progress
|
|
363
|
-
*/
|
|
364
|
-
export interface RalphLoop {
|
|
365
|
-
id: string;
|
|
366
|
-
worktree_id: string;
|
|
367
|
-
iteration: number;
|
|
368
|
-
max_iterations: number;
|
|
369
|
-
status: LoopStatus;
|
|
370
|
-
started_at: string;
|
|
371
|
-
last_activity?: string;
|
|
372
|
-
recent_commits?: Array<{
|
|
373
|
-
hash: string;
|
|
374
|
-
message: string;
|
|
375
|
-
}>;
|
|
376
|
-
prompt?: string;
|
|
377
|
-
completion_promise?: string | null;
|
|
378
|
-
project_path?: string;
|
|
379
|
-
git_info?: {
|
|
380
|
-
remote: string | null;
|
|
381
|
-
branch: string | null;
|
|
382
|
-
};
|
|
383
|
-
phase?: "planning" | "executing" | "review" | "complete";
|
|
384
|
-
current_task?: string | null;
|
|
385
|
-
total_subtasks?: number;
|
|
386
|
-
completed_subtasks?: number;
|
|
387
|
-
subtasks?: Array<{
|
|
388
|
-
id: string;
|
|
389
|
-
title: string;
|
|
390
|
-
status: "pending" | "in_progress" | "completed";
|
|
391
|
-
}>;
|
|
392
|
-
}
|
|
393
|
-
/**
|
|
394
|
-
* Node Agent capacity metrics (system resources)
|
|
395
|
-
*/
|
|
396
|
-
export interface NodeCapacity {
|
|
397
|
-
cpu_percent: number;
|
|
398
|
-
memory_percent: number;
|
|
399
|
-
disk_percent: number;
|
|
400
|
-
claude_cpu_total?: number;
|
|
401
|
-
claude_process_count?: number;
|
|
402
|
-
}
|
|
403
|
-
/**
|
|
404
|
-
* Active Claude Code process info
|
|
405
|
-
*/
|
|
406
|
-
export interface ClaudeCodeProcess {
|
|
407
|
-
pid: number;
|
|
408
|
-
worktreeId?: string;
|
|
409
|
-
loopId?: string;
|
|
410
|
-
startTime: string;
|
|
411
|
-
command: string;
|
|
412
|
-
cpuPercent: number;
|
|
413
|
-
memoryPercent: number;
|
|
414
|
-
}
|
|
415
|
-
/**
|
|
416
|
-
* Node Agent status response
|
|
417
|
-
*/
|
|
418
|
-
export interface NodeAgentStatus {
|
|
419
|
-
node_id: string;
|
|
420
|
-
hostname: string;
|
|
421
|
-
tailscale_ip: string;
|
|
422
|
-
capacity: NodeCapacity;
|
|
423
|
-
worktrees: Worktree[];
|
|
424
|
-
ralph_loops: RalphLoop[];
|
|
425
|
-
active_claude_processes?: ClaudeCodeProcess[];
|
|
426
|
-
}
|
|
427
|
-
/**
|
|
428
|
-
* Node Agent connection info for UI display
|
|
429
|
-
*/
|
|
430
|
-
export interface NodeAgentInfo {
|
|
431
|
-
running: boolean;
|
|
432
|
-
port?: number;
|
|
433
|
-
status?: NodeAgentStatus;
|
|
434
|
-
lastChecked?: string;
|
|
435
|
-
error?: string;
|
|
436
|
-
}
|
|
437
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../compile/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC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,GAAG,WAAW,CAAC;KACjD,CAAC,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,YAAY,CAAC;IACvB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,WAAW,EAAE,SAAS,EAAE,CAAC;IACzB,uBAAuB,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAC/C;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared resource parsing utilities
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Parse CPU usage from raw output with validation
|
|
6
|
-
*/
|
|
7
|
-
export declare function parseCPU(raw: string | undefined): number;
|
|
8
|
-
/**
|
|
9
|
-
* Parse memory usage from raw output with validation
|
|
10
|
-
* Returns: { percent, used, total }
|
|
11
|
-
*/
|
|
12
|
-
export declare function parseMemory(raw: string | undefined): {
|
|
13
|
-
percent: number;
|
|
14
|
-
used: string;
|
|
15
|
-
total: string;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Parse disk usage from raw output with validation
|
|
19
|
-
* Handles formats like "4% 2.8G 75G" -> adds space before unit
|
|
20
|
-
*/
|
|
21
|
-
export declare function parseDisk(raw: string | undefined): {
|
|
22
|
-
percent: number;
|
|
23
|
-
used: string;
|
|
24
|
-
total: string;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Parse GPU usage from raw output with validation
|
|
28
|
-
* Returns undefined if no GPU present
|
|
29
|
-
*/
|
|
30
|
-
export declare function parseGPU(raw: string | undefined): {
|
|
31
|
-
gpuPercent: number;
|
|
32
|
-
gpuMemoryUsed: string;
|
|
33
|
-
gpuMemoryTotal: string;
|
|
34
|
-
} | undefined;
|
|
35
|
-
/**
|
|
36
|
-
* Parse all resources from raw command outputs
|
|
37
|
-
*/
|
|
38
|
-
export declare function parseResources(raw: {
|
|
39
|
-
cpu?: string;
|
|
40
|
-
memory?: string;
|
|
41
|
-
disk?: string;
|
|
42
|
-
gpu?: string;
|
|
43
|
-
network?: string;
|
|
44
|
-
loadavg?: string;
|
|
45
|
-
processes?: string;
|
|
46
|
-
connections?: string;
|
|
47
|
-
ports?: string;
|
|
48
|
-
}): {
|
|
49
|
-
cpu: number;
|
|
50
|
-
memory: number;
|
|
51
|
-
disk: number;
|
|
52
|
-
gpu?: string;
|
|
53
|
-
network?: string;
|
|
54
|
-
loadavg?: string;
|
|
55
|
-
processes?: string;
|
|
56
|
-
connections?: string;
|
|
57
|
-
ports?: string;
|
|
58
|
-
cpuPercent: number;
|
|
59
|
-
memoryPercent: number;
|
|
60
|
-
memoryUsed: string;
|
|
61
|
-
memoryTotal: string;
|
|
62
|
-
diskPercent: number;
|
|
63
|
-
diskUsed: string;
|
|
64
|
-
diskTotal: string;
|
|
65
|
-
gpuPercent?: number;
|
|
66
|
-
gpuMemoryUsed?: string;
|
|
67
|
-
gpuMemoryTotal?: string;
|
|
68
|
-
};
|
|
69
|
-
//# sourceMappingURL=resources.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../compile/resources.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAUxD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAerG;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAoBnG;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAiBnI;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE;IAClC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,GAAG;IACF,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAgCA"}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared resource parsing utilities
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Parse CPU usage from raw output with validation
|
|
6
|
-
*/
|
|
7
|
-
export function parseCPU(raw) {
|
|
8
|
-
if (!raw || typeof raw !== 'string') {
|
|
9
|
-
return 0;
|
|
10
|
-
}
|
|
11
|
-
const num = parseFloat(raw);
|
|
12
|
-
if (isNaN(num)) {
|
|
13
|
-
console.warn('Invalid CPU value:', raw);
|
|
14
|
-
return 0;
|
|
15
|
-
}
|
|
16
|
-
return Math.round(num * 10) / 10;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Parse memory usage from raw output with validation
|
|
20
|
-
* Returns: { percent, used, total }
|
|
21
|
-
*/
|
|
22
|
-
export function parseMemory(raw) {
|
|
23
|
-
if (!raw || typeof raw !== 'string') {
|
|
24
|
-
return { percent: 0, used: '0 GB', total: '0 GB' };
|
|
25
|
-
}
|
|
26
|
-
const parts = raw.split(/\s+/);
|
|
27
|
-
if (parts.length < 3) {
|
|
28
|
-
console.warn('Invalid memory output:', raw);
|
|
29
|
-
return { percent: 0, used: '0 GB', total: '0 GB' };
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
percent: Math.round(parseFloat(parts[0]) * 10) / 10,
|
|
33
|
-
used: `${(parseFloat(parts[1]) || 0).toFixed(1)} GB`,
|
|
34
|
-
total: `${(parseFloat(parts[2]) || 0).toFixed(1)} GB`,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Parse disk usage from raw output with validation
|
|
39
|
-
* Handles formats like "4% 2.8G 75G" -> adds space before unit
|
|
40
|
-
*/
|
|
41
|
-
export function parseDisk(raw) {
|
|
42
|
-
if (!raw || typeof raw !== 'string') {
|
|
43
|
-
return { percent: 0, used: '0 GB', total: '0 GB' };
|
|
44
|
-
}
|
|
45
|
-
const parts = raw.split(/\s+/);
|
|
46
|
-
const percent = parseFloat(parts[0]?.replace('%', '') || '0') || 0;
|
|
47
|
-
// Format "2.8G" -> "2.8 GB" for consistency
|
|
48
|
-
const formatSize = (size) => {
|
|
49
|
-
if (size.endsWith('G') || size.endsWith('M') || size.endsWith('K')) {
|
|
50
|
-
return size.replace(/([GMK])$/, ' $1B');
|
|
51
|
-
}
|
|
52
|
-
return size;
|
|
53
|
-
};
|
|
54
|
-
return {
|
|
55
|
-
percent: Math.round(percent),
|
|
56
|
-
used: formatSize(parts[1] || '0 GB'),
|
|
57
|
-
total: formatSize(parts[2] || '0 GB'),
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Parse GPU usage from raw output with validation
|
|
62
|
-
* Returns undefined if no GPU present
|
|
63
|
-
*/
|
|
64
|
-
export function parseGPU(raw) {
|
|
65
|
-
if (!raw || raw === 'NOGPU' || raw === '0' || !raw.trim()) {
|
|
66
|
-
return undefined;
|
|
67
|
-
}
|
|
68
|
-
const parts = raw.split(',').map(s => s.trim());
|
|
69
|
-
if (parts.length < 3) {
|
|
70
|
-
console.warn('Invalid GPU output:', raw);
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
// nvidia-smi returns values in MB, convert to GB
|
|
74
|
-
return {
|
|
75
|
-
gpuPercent: parseFloat(parts[0]) || 0,
|
|
76
|
-
gpuMemoryUsed: `${(parseFloat(parts[1]) / 1024).toFixed(1)} GB`,
|
|
77
|
-
gpuMemoryTotal: `${(parseFloat(parts[2]) / 1024).toFixed(1)} GB`,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Parse all resources from raw command outputs
|
|
82
|
-
*/
|
|
83
|
-
export function parseResources(raw) {
|
|
84
|
-
const cpu = parseCPU(raw.cpu);
|
|
85
|
-
const memory = parseMemory(raw.memory);
|
|
86
|
-
const disk = parseDisk(raw.disk);
|
|
87
|
-
const gpu = parseGPU(raw.gpu);
|
|
88
|
-
return {
|
|
89
|
-
// Raw values for metrics storage
|
|
90
|
-
cpu,
|
|
91
|
-
memory: memory.percent,
|
|
92
|
-
disk: disk.percent,
|
|
93
|
-
gpu: raw.gpu,
|
|
94
|
-
network: raw.network,
|
|
95
|
-
loadavg: raw.loadavg,
|
|
96
|
-
processes: raw.processes,
|
|
97
|
-
connections: raw.connections,
|
|
98
|
-
ports: raw.ports,
|
|
99
|
-
// Parsed values for API response
|
|
100
|
-
cpuPercent: cpu,
|
|
101
|
-
memoryPercent: memory.percent,
|
|
102
|
-
memoryUsed: memory.used,
|
|
103
|
-
memoryTotal: memory.total,
|
|
104
|
-
diskPercent: disk.percent,
|
|
105
|
-
diskUsed: disk.used,
|
|
106
|
-
diskTotal: disk.total,
|
|
107
|
-
...(gpu && {
|
|
108
|
-
gpuPercent: gpu.gpuPercent,
|
|
109
|
-
gpuMemoryUsed: gpu.gpuMemoryUsed,
|
|
110
|
-
gpuMemoryTotal: gpu.gpuMemoryTotal,
|
|
111
|
-
}),
|
|
112
|
-
};
|
|
113
|
-
}
|