@ebowwa/codespaces-types 0.1.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/LICENSE +21 -0
- package/README.md +68 -0
- package/dist/index.d.ts +436 -0
- package/dist/index.js +96 -0
- package/dist/resources.d.ts +68 -0
- package/dist/resources.js +113 -0
- package/dist/schemas/resources.d.ts +165 -0
- package/dist/schemas/resources.js +123 -0
- package/dist/terminal-websocket.d.ts +108 -0
- package/dist/terminal-websocket.js +37 -0
- package/dist/time.d.ts +6 -0
- package/dist/time.js +27 -0
- package/dist/user/distributions.d.ts +14 -0
- package/dist/user/distributions.js +14 -0
- package/dist/validation.d.ts +43 -0
- package/dist/validation.js +80 -0
- package/package.json +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ebowwa Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# @ebowwa/codespaces-types
|
|
2
|
+
|
|
3
|
+
Shared TypeScript type definitions for Codespaces packages.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @ebowwa/codespaces-types
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
This package contains shared type definitions used across various Codespaces packages:
|
|
14
|
+
|
|
15
|
+
### Main Types
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import {
|
|
19
|
+
Environment,
|
|
20
|
+
EnvironmentStatus,
|
|
21
|
+
HetznerServerType,
|
|
22
|
+
HetznerLocation,
|
|
23
|
+
// ... and more
|
|
24
|
+
} from '@ebowwa/codespaces-types';
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Resource Parsing
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { parseResources, parseCPU, parseMemory } from '@ebowwa/codespaces-types/resources';
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Terminal WebSocket Types
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import {
|
|
37
|
+
ClientToServerMessage,
|
|
38
|
+
ServerToClientMessage,
|
|
39
|
+
WebSocketCloseCode
|
|
40
|
+
} from '@ebowwa/codespaces-types/terminal-websocket';
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Time Formatting
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { formatElapsedTime } from '@ebowwa/codespaces-types/time';
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Validation
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import {
|
|
53
|
+
EnvironmentNameSchema,
|
|
54
|
+
validateEnvironmentName
|
|
55
|
+
} from '@ebowwa/codespaces-types/validation';
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Features
|
|
59
|
+
|
|
60
|
+
- **Shared Types**: Common interfaces for environments, Hetzner API, and more
|
|
61
|
+
- **Resource Parsing**: Utilities for parsing CPU, memory, disk, and GPU usage
|
|
62
|
+
- **WebSocket Types**: Terminal WebSocket message types for real-time communication
|
|
63
|
+
- **Validation**: Zod schemas for validating environment names, SSH keys, and API tokens
|
|
64
|
+
- **Time Utilities**: Functions for formatting elapsed time
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,436 @@
|
|
|
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
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared type definitions for frontend and server
|
|
3
|
+
*/
|
|
4
|
+
// ============================================================================
|
|
5
|
+
// Application Types
|
|
6
|
+
// ============================================================================
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Shared Status Enums
|
|
9
|
+
// ============================================================================
|
|
10
|
+
/**
|
|
11
|
+
* Environment status - used by Environment interface and HetznerServer mapping
|
|
12
|
+
*
|
|
13
|
+
* Hetzner API returns: "running" | "stopped" | "starting" | "stopping" | "initializing"
|
|
14
|
+
* Environment uses subset: "running" | "stopped" | "creating" | "deleting"
|
|
15
|
+
*
|
|
16
|
+
* Mapping:
|
|
17
|
+
* - "running" → "running"
|
|
18
|
+
* - "stopped" → "stopped"
|
|
19
|
+
* - "starting" → "creating"
|
|
20
|
+
* - "stopping" → "deleting"
|
|
21
|
+
* - "initializing" → "creating"
|
|
22
|
+
*/
|
|
23
|
+
export var EnvironmentStatus;
|
|
24
|
+
(function (EnvironmentStatus) {
|
|
25
|
+
EnvironmentStatus["Running"] = "running";
|
|
26
|
+
EnvironmentStatus["Stopped"] = "stopped";
|
|
27
|
+
EnvironmentStatus["Creating"] = "creating";
|
|
28
|
+
EnvironmentStatus["Deleting"] = "deleting";
|
|
29
|
+
// Additional Hetzner server statuses (for API compatibility)
|
|
30
|
+
EnvironmentStatus["Starting"] = "starting";
|
|
31
|
+
EnvironmentStatus["Stopping"] = "stopping";
|
|
32
|
+
EnvironmentStatus["Initializing"] = "initializing";
|
|
33
|
+
})(EnvironmentStatus || (EnvironmentStatus = {}));
|
|
34
|
+
/**
|
|
35
|
+
* Action status - used by HetznerAction
|
|
36
|
+
*/
|
|
37
|
+
export var ActionStatus;
|
|
38
|
+
(function (ActionStatus) {
|
|
39
|
+
ActionStatus["Running"] = "running";
|
|
40
|
+
ActionStatus["Success"] = "success";
|
|
41
|
+
ActionStatus["Error"] = "error";
|
|
42
|
+
})(ActionStatus || (ActionStatus = {}));
|
|
43
|
+
/**
|
|
44
|
+
* Volume status - used by HetznerVolume
|
|
45
|
+
*/
|
|
46
|
+
export var VolumeStatus;
|
|
47
|
+
(function (VolumeStatus) {
|
|
48
|
+
VolumeStatus["Creating"] = "creating";
|
|
49
|
+
VolumeStatus["Available"] = "available";
|
|
50
|
+
VolumeStatus["Deleting"] = "deleting";
|
|
51
|
+
})(VolumeStatus || (VolumeStatus = {}));
|
|
52
|
+
/**
|
|
53
|
+
* Ralph Loop status - used by RalphLoop interface
|
|
54
|
+
*/
|
|
55
|
+
export var LoopStatus;
|
|
56
|
+
(function (LoopStatus) {
|
|
57
|
+
LoopStatus["Running"] = "running";
|
|
58
|
+
LoopStatus["Stopped"] = "stopped";
|
|
59
|
+
LoopStatus["Error"] = "error";
|
|
60
|
+
LoopStatus["Completed"] = "completed";
|
|
61
|
+
})(LoopStatus || (LoopStatus = {}));
|
|
62
|
+
/**
|
|
63
|
+
* Get the location object from an environment
|
|
64
|
+
* @param env - The environment object
|
|
65
|
+
* @returns The location object or null
|
|
66
|
+
*/
|
|
67
|
+
export function getEnvLocation(env) {
|
|
68
|
+
if (!env)
|
|
69
|
+
return null;
|
|
70
|
+
return env.location || null;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get the region name (short format like "nbg1") from an environment
|
|
74
|
+
* @param env - The environment object
|
|
75
|
+
* @returns The region name (e.g., "nbg1") or "Unknown"
|
|
76
|
+
*/
|
|
77
|
+
export function getEnvRegionName(env) {
|
|
78
|
+
if (!env)
|
|
79
|
+
return "Unknown";
|
|
80
|
+
return env.location?.name || "Unknown";
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get a human-readable location label with city and country
|
|
84
|
+
* @param env - The environment object
|
|
85
|
+
* @returns A formatted location string (e.g., "Nuremberg, DE" or "nbg1" as fallback)
|
|
86
|
+
*/
|
|
87
|
+
export function getEnvLocationLabel(env) {
|
|
88
|
+
if (!env)
|
|
89
|
+
return "Unknown";
|
|
90
|
+
// Show city, country for better UX
|
|
91
|
+
if (env.location?.city && env.location?.country) {
|
|
92
|
+
return `${env.location.city}, ${env.location.country}`;
|
|
93
|
+
}
|
|
94
|
+
// Fallback to location name
|
|
95
|
+
return env.location?.name || "Unknown";
|
|
96
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
};
|