@draht/pods 2026.4.5 → 2026.4.25
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 +70 -70
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @draht/pods
|
|
2
2
|
|
|
3
3
|
Deploy and manage LLMs on GPU pods with automatic vLLM configuration for agentic workloads.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
bun add -g @draht/
|
|
8
|
+
bun add -g @draht/pods
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
## What is
|
|
11
|
+
## What is draht-pods?
|
|
12
12
|
|
|
13
|
-
`
|
|
13
|
+
`draht-pods` simplifies running large language models on remote GPU pods. It automatically:
|
|
14
14
|
- Sets up vLLM on fresh Ubuntu pods
|
|
15
15
|
- Configures tool calling for agentic models (Qwen, GPT-OSS, GLM, etc.)
|
|
16
16
|
- Manages multiple models on the same pod with "smart" GPU allocation
|
|
@@ -25,17 +25,17 @@ export HF_TOKEN=your_huggingface_token # Get from https://huggingface.co/se
|
|
|
25
25
|
export DRAHT_API_KEY=your_api_key # Any string you want for API authentication
|
|
26
26
|
|
|
27
27
|
# Setup a DataCrunch pod with NFS storage (models path auto-extracted)
|
|
28
|
-
|
|
28
|
+
draht-pods pods setup dc1 "ssh root@1.2.3.4" \
|
|
29
29
|
--mount "sudo mount -t nfs -o nconnect=16 nfs.fin-02.datacrunch.io:/your-pseudo /mnt/hf-models"
|
|
30
30
|
|
|
31
31
|
# Start a model (automatic configuration for known models)
|
|
32
|
-
|
|
32
|
+
draht-pods start Qwen/Qwen2.5-Coder-32B-Instruct --name qwen
|
|
33
33
|
|
|
34
34
|
# Send a single message to the model
|
|
35
|
-
|
|
35
|
+
draht-pods agent qwen "What is the Fibonacci sequence?"
|
|
36
36
|
|
|
37
37
|
# Interactive chat mode with file system tools
|
|
38
|
-
|
|
38
|
+
draht-pods agent qwen -i
|
|
39
39
|
|
|
40
40
|
# Use with any OpenAI-compatible client
|
|
41
41
|
export OPENAI_BASE_URL='http://1.2.3.4:8001/v1'
|
|
@@ -77,16 +77,16 @@ export OPENAI_API_KEY=$DRAHT_API_KEY
|
|
|
77
77
|
### Pod Management
|
|
78
78
|
|
|
79
79
|
```bash
|
|
80
|
-
|
|
80
|
+
draht-pods pods setup <name> "<ssh>" [options] # Setup new pod
|
|
81
81
|
--mount "<mount_command>" # Run mount command during setup
|
|
82
82
|
--models-path <path> # Override extracted path (optional)
|
|
83
83
|
--vllm release|nightly|gpt-oss # vLLM version (default: release)
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
draht-pods pods # List all configured pods
|
|
86
|
+
draht-pods pods active <name> # Switch active pod
|
|
87
|
+
draht-pods pods remove <name> # Remove pod from local config
|
|
88
|
+
draht-pods shell [<name>] # SSH into pod
|
|
89
|
+
draht-pods ssh [<name>] "<command>" # Run command on pod
|
|
90
90
|
```
|
|
91
91
|
|
|
92
92
|
**Note**: When using `--mount`, the models path is automatically extracted from the mount command's target directory. You only need `--models-path` if not using `--mount` or to override the extracted path.
|
|
@@ -100,25 +100,25 @@ pi ssh [<name>] "<command>" # Run command on pod
|
|
|
100
100
|
### Model Management
|
|
101
101
|
|
|
102
102
|
```bash
|
|
103
|
-
|
|
103
|
+
draht-pods start <model> --name <name> [options] # Start a model
|
|
104
104
|
--memory <percent> # GPU memory: 30%, 50%, 90% (default: 90%)
|
|
105
105
|
--context <size> # Context window: 4k, 8k, 16k, 32k, 64k, 128k
|
|
106
106
|
--gpus <count> # Number of GPUs to use (predefined models only)
|
|
107
107
|
--pod <name> # Target specific pod (overrides active)
|
|
108
108
|
--vllm <args...> # Pass custom args directly to vLLM
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
draht-pods stop [<name>] # Stop model (or all if no name given)
|
|
111
|
+
draht-pods list # List running models with status
|
|
112
|
+
draht-pods logs <name> # Stream model logs (tail -f)
|
|
113
113
|
```
|
|
114
114
|
|
|
115
115
|
### Agent & Chat Interface
|
|
116
116
|
|
|
117
117
|
```bash
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
118
|
+
draht-pods agent <name> "<message>" # Single message to model
|
|
119
|
+
draht-pods agent <name> "<msg1>" "<msg2>" # Multiple messages in sequence
|
|
120
|
+
draht-pods agent <name> -i # Interactive chat mode
|
|
121
|
+
draht-pods agent <name> -i -c # Continue previous session
|
|
122
122
|
|
|
123
123
|
# Standalone OpenAI-compatible agent (works with any API)
|
|
124
124
|
draht --base-url http://localhost:8000/v1 --model llama-3.1 "Hello"
|
|
@@ -131,39 +131,39 @@ The agent includes tools for file operations (read, list, bash, glob, rg) to tes
|
|
|
131
131
|
|
|
132
132
|
## Predefined Model Configurations
|
|
133
133
|
|
|
134
|
-
`
|
|
134
|
+
`draht-pods` includes predefined configurations for popular agentic models, so you do not have to specify `--vllm` arguments manually. `draht-pods` will also check if the model you selected can actually run on your pod with respect to the number of GPUs and available VRAM. Run `draht-pods start` without additional arguments to see a list of predefined models that can run on the active pod.
|
|
135
135
|
|
|
136
136
|
### Qwen Models
|
|
137
137
|
```bash
|
|
138
138
|
# Qwen2.5-Coder-32B - Excellent coding model, fits on single H100/H200
|
|
139
|
-
|
|
139
|
+
draht-pods start Qwen/Qwen2.5-Coder-32B-Instruct --name qwen
|
|
140
140
|
|
|
141
141
|
# Qwen3-Coder-30B - Advanced reasoning with tool use
|
|
142
|
-
|
|
142
|
+
draht-pods start Qwen/Qwen3-Coder-30B-A3B-Instruct --name qwen3
|
|
143
143
|
|
|
144
144
|
# Qwen3-Coder-480B - State-of-the-art on 8xH200 (data-parallel mode)
|
|
145
|
-
|
|
145
|
+
draht-pods start Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8 --name qwen-480b
|
|
146
146
|
```
|
|
147
147
|
|
|
148
148
|
### GPT-OSS Models
|
|
149
149
|
```bash
|
|
150
150
|
# Requires special vLLM build during setup
|
|
151
|
-
|
|
151
|
+
draht-pods pods setup gpt-pod "ssh root@1.2.3.4" --models-path /workspace --vllm gpt-oss
|
|
152
152
|
|
|
153
153
|
# GPT-OSS-20B - Fits on 16GB+ VRAM
|
|
154
|
-
|
|
154
|
+
draht-pods start openai/gpt-oss-20b --name gpt20
|
|
155
155
|
|
|
156
156
|
# GPT-OSS-120B - Needs 60GB+ VRAM
|
|
157
|
-
|
|
157
|
+
draht-pods start openai/gpt-oss-120b --name gpt120
|
|
158
158
|
```
|
|
159
159
|
|
|
160
160
|
### GLM Models
|
|
161
161
|
```bash
|
|
162
162
|
# GLM-4.5 - Requires 8-16 GPUs, includes thinking mode
|
|
163
|
-
|
|
163
|
+
draht-pods start zai-org/GLM-4.5 --name glm
|
|
164
164
|
|
|
165
165
|
# GLM-4.5-Air - Smaller version, 1-2 GPUs
|
|
166
|
-
|
|
166
|
+
draht-pods start zai-org/GLM-4.5-Air --name glm-air
|
|
167
167
|
```
|
|
168
168
|
|
|
169
169
|
### Custom Models with --vllm
|
|
@@ -172,15 +172,15 @@ For models not in the predefined list, use `--vllm` to pass arguments directly t
|
|
|
172
172
|
|
|
173
173
|
```bash
|
|
174
174
|
# DeepSeek with custom settings
|
|
175
|
-
|
|
175
|
+
draht-pods start deepseek-ai/DeepSeek-V3 --name deepseek --vllm \
|
|
176
176
|
--tensor-parallel-size 4 --trust-remote-code
|
|
177
177
|
|
|
178
178
|
# Mistral with pipeline parallelism
|
|
179
|
-
|
|
179
|
+
draht-pods start mistralai/Mixtral-8x22B-Instruct-v0.1 --name mixtral --vllm \
|
|
180
180
|
--tensor-parallel-size 8 --pipeline-parallel-size 2
|
|
181
181
|
|
|
182
182
|
# Any model with specific tool parser
|
|
183
|
-
|
|
183
|
+
draht-pods start some/model --name mymodel --vllm \
|
|
184
184
|
--tool-call-parser hermes --enable-auto-tool-choice
|
|
185
185
|
```
|
|
186
186
|
|
|
@@ -198,10 +198,10 @@ DataCrunch offers the best experience with shared NFS storage across pods:
|
|
|
198
198
|
- Share the SFS with the instance
|
|
199
199
|
- Get SSH command from dashboard
|
|
200
200
|
|
|
201
|
-
### 3. Setup with
|
|
201
|
+
### 3. Setup with draht-pods
|
|
202
202
|
```bash
|
|
203
203
|
# Get mount command from DataCrunch dashboard
|
|
204
|
-
|
|
204
|
+
draht-pods pods setup dc1 "ssh root@instance.datacrunch.io" \
|
|
205
205
|
--mount "sudo mount -t nfs -o nconnect=16 nfs.fin-02.datacrunch.io:/your-pseudo /mnt/hf-models"
|
|
206
206
|
|
|
207
207
|
# Models automatically stored in /mnt/hf-models (extracted from mount command)
|
|
@@ -226,34 +226,34 @@ RunPod offers good persistent storage with network volumes:
|
|
|
226
226
|
- Attach your volume to `/runpod-volume`
|
|
227
227
|
- Get SSH command from pod details
|
|
228
228
|
|
|
229
|
-
### 3. Setup with
|
|
229
|
+
### 3. Setup with draht-pods
|
|
230
230
|
```bash
|
|
231
231
|
# With network volume
|
|
232
|
-
|
|
232
|
+
draht-pods pods setup runpod "ssh root@pod.runpod.io" --models-path /runpod-volume
|
|
233
233
|
|
|
234
234
|
# Or use workspace (persists with pod but not shareable)
|
|
235
|
-
|
|
235
|
+
draht-pods pods setup runpod "ssh root@pod.runpod.io" --models-path /workspace
|
|
236
236
|
```
|
|
237
237
|
|
|
238
238
|
|
|
239
239
|
## Multi-GPU Support
|
|
240
240
|
|
|
241
241
|
### Automatic GPU Assignment
|
|
242
|
-
When running multiple models,
|
|
242
|
+
When running multiple models, draht-pods automatically assigns them to different GPUs:
|
|
243
243
|
```bash
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
244
|
+
draht-pods start model1 --name m1 # Auto-assigns to GPU 0
|
|
245
|
+
draht-pods start model2 --name m2 # Auto-assigns to GPU 1
|
|
246
|
+
draht-pods start model3 --name m3 # Auto-assigns to GPU 2
|
|
247
247
|
```
|
|
248
248
|
|
|
249
249
|
### Specify GPU Count for Predefined Models
|
|
250
250
|
For predefined models with multiple configurations, use `--gpus` to control GPU usage:
|
|
251
251
|
```bash
|
|
252
252
|
# Run Qwen on 1 GPU instead of all available
|
|
253
|
-
|
|
253
|
+
draht-pods start Qwen/Qwen2.5-Coder-32B-Instruct --name qwen --gpus 1
|
|
254
254
|
|
|
255
255
|
# Run GLM-4.5 on 8 GPUs (if it has an 8-GPU config)
|
|
256
|
-
|
|
256
|
+
draht-pods start zai-org/GLM-4.5 --name glm --gpus 8
|
|
257
257
|
```
|
|
258
258
|
|
|
259
259
|
If the model doesn't have a configuration for the requested GPU count, you'll see available options.
|
|
@@ -262,11 +262,11 @@ If the model doesn't have a configuration for the requested GPU count, you'll se
|
|
|
262
262
|
For models that don't fit on a single GPU:
|
|
263
263
|
```bash
|
|
264
264
|
# Use all available GPUs
|
|
265
|
-
|
|
265
|
+
draht-pods start meta-llama/Llama-3.1-70B-Instruct --name llama70b --vllm \
|
|
266
266
|
--tensor-parallel-size 4
|
|
267
267
|
|
|
268
268
|
# Specific GPU count
|
|
269
|
-
|
|
269
|
+
draht-pods start Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8 --name qwen480 --vllm \
|
|
270
270
|
--data-parallel-size 8 --enable-expert-parallel
|
|
271
271
|
```
|
|
272
272
|
|
|
@@ -279,7 +279,7 @@ from openai import OpenAI
|
|
|
279
279
|
|
|
280
280
|
client = OpenAI(
|
|
281
281
|
base_url="http://your-pod-ip:8001/v1",
|
|
282
|
-
api_key="your-
|
|
282
|
+
api_key="your-api-key"
|
|
283
283
|
)
|
|
284
284
|
|
|
285
285
|
# Chat completion with tool calling
|
|
@@ -308,7 +308,7 @@ response = client.chat.completions.create(
|
|
|
308
308
|
|
|
309
309
|
## Standalone Agent CLI
|
|
310
310
|
|
|
311
|
-
`
|
|
311
|
+
`draht-pods` includes a standalone OpenAI-compatible agent that can work with any API:
|
|
312
312
|
|
|
313
313
|
```bash
|
|
314
314
|
# Install globally to get draht command
|
|
@@ -345,7 +345,7 @@ The agent supports:
|
|
|
345
345
|
|
|
346
346
|
## Tool Calling Support
|
|
347
347
|
|
|
348
|
-
`
|
|
348
|
+
`draht-pods` automatically configures appropriate tool calling parsers for known models:
|
|
349
349
|
|
|
350
350
|
- **Qwen models**: `hermes` parser (Qwen3-Coder uses `qwen3_coder`)
|
|
351
351
|
- **GLM models**: `glm4_moe` parser with reasoning support
|
|
@@ -354,7 +354,7 @@ The agent supports:
|
|
|
354
354
|
|
|
355
355
|
To disable tool calling:
|
|
356
356
|
```bash
|
|
357
|
-
|
|
357
|
+
draht-pods start model --name mymodel --vllm --disable-tool-call-parser
|
|
358
358
|
```
|
|
359
359
|
|
|
360
360
|
## Memory and Context Management
|
|
@@ -374,7 +374,7 @@ Sets maximum input + output tokens:
|
|
|
374
374
|
Example for coding workload:
|
|
375
375
|
```bash
|
|
376
376
|
# Large context for code analysis, moderate concurrency
|
|
377
|
-
|
|
377
|
+
draht-pods start Qwen/Qwen2.5-Coder-32B-Instruct --name coder \
|
|
378
378
|
--context 64k --memory 70%
|
|
379
379
|
```
|
|
380
380
|
|
|
@@ -386,10 +386,10 @@ The interactive agent mode (`-i`) saves sessions for each project directory:
|
|
|
386
386
|
|
|
387
387
|
```bash
|
|
388
388
|
# Start new session
|
|
389
|
-
|
|
389
|
+
draht-pods agent qwen -i
|
|
390
390
|
|
|
391
391
|
# Continue previous session (maintains chat history)
|
|
392
|
-
|
|
392
|
+
draht-pods agent qwen -i -c
|
|
393
393
|
```
|
|
394
394
|
|
|
395
395
|
Sessions are stored in `~/.draht/sessions/` organized by project path and include:
|
|
@@ -432,13 +432,13 @@ Each line is a complete JSON object representing an event:
|
|
|
432
432
|
### Model Won't Start
|
|
433
433
|
```bash
|
|
434
434
|
# Check GPU usage
|
|
435
|
-
|
|
435
|
+
draht-pods ssh "nvidia-smi"
|
|
436
436
|
|
|
437
437
|
# Check if port is in use
|
|
438
|
-
|
|
438
|
+
draht-pods list
|
|
439
439
|
|
|
440
440
|
# Force stop all models
|
|
441
|
-
|
|
441
|
+
draht-pods stop
|
|
442
442
|
```
|
|
443
443
|
|
|
444
444
|
### Tool Calling Issues
|
|
@@ -452,16 +452,16 @@ Some models (Llama, Mistral) require HuggingFace access approval. Visit the mode
|
|
|
452
452
|
### vLLM Build Issues
|
|
453
453
|
If using `--vllm nightly` fails, try:
|
|
454
454
|
- Use `--vllm release` for stable version
|
|
455
|
-
- Check CUDA compatibility with `
|
|
455
|
+
- Check CUDA compatibility with `draht-pods ssh "nvidia-smi"`
|
|
456
456
|
|
|
457
457
|
### Agent Not Finding Messages
|
|
458
458
|
If the agent shows configuration instead of your message, ensure quotes around messages with special characters:
|
|
459
459
|
```bash
|
|
460
460
|
# Good
|
|
461
|
-
|
|
461
|
+
draht-pods agent qwen "What is this file about?"
|
|
462
462
|
|
|
463
463
|
# Bad (shell might interpret special chars)
|
|
464
|
-
|
|
464
|
+
draht-pods agent qwen What is this file about?
|
|
465
465
|
```
|
|
466
466
|
|
|
467
467
|
## Advanced Usage
|
|
@@ -469,15 +469,15 @@ pi agent qwen What is this file about?
|
|
|
469
469
|
### Working with Multiple Pods
|
|
470
470
|
```bash
|
|
471
471
|
# Override active pod for any command
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
472
|
+
draht-pods start model --name test --pod dev-pod
|
|
473
|
+
draht-pods list --pod prod-pod
|
|
474
|
+
draht-pods stop test --pod dev-pod
|
|
475
475
|
```
|
|
476
476
|
|
|
477
477
|
### Custom vLLM Arguments
|
|
478
478
|
```bash
|
|
479
479
|
# Pass any vLLM argument after --vllm
|
|
480
|
-
|
|
480
|
+
draht-pods start model --name custom --vllm \
|
|
481
481
|
--quantization awq \
|
|
482
482
|
--enable-prefix-caching \
|
|
483
483
|
--max-num-seqs 256 \
|
|
@@ -487,13 +487,13 @@ pi start model --name custom --vllm \
|
|
|
487
487
|
### Monitoring
|
|
488
488
|
```bash
|
|
489
489
|
# Watch GPU utilization
|
|
490
|
-
|
|
490
|
+
draht-pods ssh "watch -n 1 nvidia-smi"
|
|
491
491
|
|
|
492
492
|
# Check model downloads
|
|
493
|
-
|
|
493
|
+
draht-pods ssh "du -sh ~/.cache/huggingface/hub/*"
|
|
494
494
|
|
|
495
495
|
# View all logs
|
|
496
|
-
|
|
496
|
+
draht-pods ssh "ls -la ~/.vllm_logs/"
|
|
497
497
|
|
|
498
498
|
# Check agent session history
|
|
499
499
|
ls -la ~/.draht/sessions/
|
|
@@ -503,9 +503,9 @@ ls -la ~/.draht/sessions/
|
|
|
503
503
|
|
|
504
504
|
- `HF_TOKEN` - HuggingFace token for model downloads
|
|
505
505
|
- `DRAHT_API_KEY` - API key for vLLM endpoints
|
|
506
|
-
- `DRAHT_CONFIG_DIR` - Config directory (default: `~/.
|
|
507
|
-
- `OPENAI_API_KEY` - Used by `
|
|
506
|
+
- `DRAHT_CONFIG_DIR` - Config directory (default: `~/.draht`)
|
|
507
|
+
- `OPENAI_API_KEY` - Used by `draht-agent` when no `--api-key` provided
|
|
508
508
|
|
|
509
509
|
## License
|
|
510
510
|
|
|
511
|
-
MIT
|
|
511
|
+
MIT
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"","sourcesContent":["#!/usr/bin/env node\nimport chalk from \"chalk\";\nimport { spawn } from \"child_process\";\nimport { readFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport { listModels, showKnownModels, startModel, stopAllModels, stopModel, viewLogs } from \"./commands/models.js\";\nimport { listPods, removePodCommand, setupPod, switchActivePod } from \"./commands/pods.js\";\nimport { promptModel } from \"./commands/prompt.js\";\nimport { getActivePod, loadConfig } from \"./config.js\";\nimport { sshExecStream } from \"./ssh.js\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\nconst packageJson = JSON.parse(readFileSync(join(__dirname, \"../package.json\"), \"utf-8\"));\n\nfunction printHelp() {\n\tconsole.log(`pi v${packageJson.version} - Manage vLLM deployments on GPU pods\n\nPod Management:\n pi pods setup <name> \"<ssh>\" --mount \"<mount>\" Setup pod with mount command\n Options:\n --vllm release Install latest vLLM release >=0.10.0 (default)\n --vllm nightly Install vLLM nightly build (latest features)\n --vllm gpt-oss Install vLLM 0.10.1+gptoss with PyTorch nightly (GPT-OSS only)\n pi pods List all pods (* = active)\n pi pods active <name> Switch active pod\n pi pods remove <name> Remove pod from local config\n pi shell [<name>] Open shell on pod (active or specified)\n pi ssh [<name>] \"<command>\" Run SSH command on pod\n\nModel Management:\n pi start <model> --name <name> [options] Start a model\n --memory <percent> GPU memory allocation (30%, 50%, 90%)\n --context <size> Context window (4k, 8k, 16k, 32k, 64k, 128k)\n --gpus <count> Number of GPUs to use (predefined models only)\n --vllm <args...> Pass remaining args to vLLM (ignores other options)\n pi stop [<name>] Stop model (or all if no name)\n pi list List running models\n pi logs <name> Stream model logs\n pi agent <name> [\"<message>\"...] [options] Chat with model using agent & tools\n pi agent <name> [options] Interactive chat mode\n --continue, -c Continue previous session\n --json Output as JSONL\n (All pi-agent options are supported)\n\n All model commands support --pod <name> to override the active pod.\n\nEnvironment:\n HF_TOKEN HuggingFace token for model downloads\n PI_API_KEY API key for vLLM endpoints\n PI_CONFIG_DIR Config directory (default: ~/.pi)`);\n}\n\n// Parse command line arguments\nconst args = process.argv.slice(2);\n\nif (args.length === 0 || args[0] === \"--help\" || args[0] === \"-h\") {\n\tprintHelp();\n\tprocess.exit(0);\n}\n\nif (args[0] === \"--version\" || args[0] === \"-v\") {\n\tconsole.log(packageJson.version);\n\tprocess.exit(0);\n}\n\nconst command = args[0];\nconst subcommand = args[1];\n\n// Main command handler\ntry {\n\t// Handle \"pi pods\" commands\n\tif (command === \"pods\") {\n\t\tif (!subcommand) {\n\t\t\t// pi pods - list all pods\n\t\t\tlistPods();\n\t\t} else if (subcommand === \"setup\") {\n\t\t\t// pi pods setup <name> \"<ssh>\" [--mount \"<mount>\"] [--models-path <path>] [--vllm release|nightly|gpt-oss]\n\t\t\tconst name = args[2];\n\t\t\tconst sshCmd = args[3];\n\n\t\t\tif (!name || !sshCmd) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t'Usage: pi pods setup <name> \"<ssh>\" [--mount \"<mount>\"] [--models-path <path>] [--vllm release|nightly|gpt-oss]',\n\t\t\t\t);\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\t// Parse options\n\t\t\tconst options: { mount?: string; modelsPath?: string; vllm?: \"release\" | \"nightly\" | \"gpt-oss\" } = {};\n\t\t\tfor (let i = 4; i < args.length; i++) {\n\t\t\t\tif (args[i] === \"--mount\" && i + 1 < args.length) {\n\t\t\t\t\toptions.mount = args[i + 1];\n\t\t\t\t\ti++;\n\t\t\t\t} else if (args[i] === \"--models-path\" && i + 1 < args.length) {\n\t\t\t\t\toptions.modelsPath = args[i + 1];\n\t\t\t\t\ti++;\n\t\t\t\t} else if (args[i] === \"--vllm\" && i + 1 < args.length) {\n\t\t\t\t\tconst vllmType = args[i + 1];\n\t\t\t\t\tif (vllmType === \"release\" || vllmType === \"nightly\" || vllmType === \"gpt-oss\") {\n\t\t\t\t\t\toptions.vllm = vllmType;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.error(chalk.red(`Invalid vLLM type: ${vllmType}`));\n\t\t\t\t\t\tconsole.error(\"Valid options: release, nightly, gpt-oss\");\n\t\t\t\t\t\tprocess.exit(1);\n\t\t\t\t\t}\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If --mount provided but no --models-path, try to extract path from mount command\n\t\t\tif (options.mount && !options.modelsPath) {\n\t\t\t\t// Extract last part of mount command as models path\n\t\t\t\tconst parts = options.mount.trim().split(\" \");\n\t\t\t\tconst lastPart = parts[parts.length - 1];\n\t\t\t\tif (lastPart?.startsWith(\"/\")) {\n\t\t\t\t\toptions.modelsPath = lastPart;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait setupPod(name, sshCmd, options);\n\t\t} else if (subcommand === \"active\") {\n\t\t\t// pi pods active <name>\n\t\t\tconst name = args[2];\n\t\t\tif (!name) {\n\t\t\t\tconsole.error(\"Usage: pi pods active <name>\");\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\tswitchActivePod(name);\n\t\t} else if (subcommand === \"remove\") {\n\t\t\t// pi pods remove <name>\n\t\t\tconst name = args[2];\n\t\t\tif (!name) {\n\t\t\t\tconsole.error(\"Usage: pi pods remove <name>\");\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\tremovePodCommand(name);\n\t\t} else {\n\t\t\tconsole.error(`Unknown pods subcommand: ${subcommand}`);\n\t\t\tprocess.exit(1);\n\t\t}\n\t} else {\n\t\t// Parse --pod override for model commands\n\t\tlet podOverride: string | undefined;\n\t\tconst podIndex = args.indexOf(\"--pod\");\n\t\tif (podIndex !== -1 && podIndex + 1 < args.length) {\n\t\t\tpodOverride = args[podIndex + 1];\n\t\t\t// Remove --pod and its value from args\n\t\t\targs.splice(podIndex, 2);\n\t\t}\n\n\t\t// Handle SSH/shell commands and model commands\n\t\tswitch (command) {\n\t\t\tcase \"shell\": {\n\t\t\t\t// pi shell [<name>] - open interactive shell\n\t\t\t\tconst podName = args[1];\n\t\t\t\tlet podInfo: { name: string; pod: import(\"./types.js\").Pod } | null = null;\n\n\t\t\t\tif (podName) {\n\t\t\t\t\tconst config = loadConfig();\n\t\t\t\t\tconst pod = config.pods[podName];\n\t\t\t\t\tif (pod) {\n\t\t\t\t\t\tpodInfo = { name: podName, pod };\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tpodInfo = getActivePod();\n\t\t\t\t}\n\n\t\t\t\tif (!podInfo) {\n\t\t\t\t\tif (podName) {\n\t\t\t\t\t\tconsole.error(chalk.red(`Pod '${podName}' not found`));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.error(chalk.red(\"No active pod. Use 'pi pods active <name>' to set one.\"));\n\t\t\t\t\t}\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\tconsole.log(chalk.green(`Connecting to pod '${podInfo.name}'...`));\n\n\t\t\t\t// Execute SSH in interactive mode\n\t\t\t\tconst sshArgs = podInfo.pod.ssh.split(\" \").slice(1); // Remove 'ssh' from command\n\t\t\t\tconst sshProcess = spawn(\"ssh\", sshArgs, {\n\t\t\t\t\tstdio: \"inherit\",\n\t\t\t\t\tenv: process.env,\n\t\t\t\t});\n\n\t\t\t\tsshProcess.on(\"exit\", (code) => {\n\t\t\t\t\tprocess.exit(code || 0);\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"ssh\": {\n\t\t\t\t// pi ssh [<name>] \"<command>\" - run command via SSH\n\t\t\t\tlet podName: string | undefined;\n\t\t\t\tlet sshCommand: string;\n\n\t\t\t\tif (args.length === 2) {\n\t\t\t\t\t// pi ssh \"<command>\" - use active pod\n\t\t\t\t\tsshCommand = args[1];\n\t\t\t\t} else if (args.length === 3) {\n\t\t\t\t\t// pi ssh <name> \"<command>\"\n\t\t\t\t\tpodName = args[1];\n\t\t\t\t\tsshCommand = args[2];\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error('Usage: pi ssh [<name>] \"<command>\"');\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\tlet podInfo: { name: string; pod: import(\"./types.js\").Pod } | null = null;\n\n\t\t\t\tif (podName) {\n\t\t\t\t\tconst config = loadConfig();\n\t\t\t\t\tconst pod = config.pods[podName];\n\t\t\t\t\tif (pod) {\n\t\t\t\t\t\tpodInfo = { name: podName, pod };\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tpodInfo = getActivePod();\n\t\t\t\t}\n\n\t\t\t\tif (!podInfo) {\n\t\t\t\t\tif (podName) {\n\t\t\t\t\t\tconsole.error(chalk.red(`Pod '${podName}' not found`));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.error(chalk.red(\"No active pod. Use 'pi pods active <name>' to set one.\"));\n\t\t\t\t\t}\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\tconsole.log(chalk.gray(`Running on pod '${podInfo.name}': ${sshCommand}`));\n\n\t\t\t\t// Execute command and stream output\n\t\t\t\tconst exitCode = await sshExecStream(podInfo.pod.ssh, sshCommand);\n\t\t\t\tprocess.exit(exitCode);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"start\": {\n\t\t\t\t// pi start <model> --name <name> [options]\n\t\t\t\tconst modelId = args[1];\n\t\t\t\tif (!modelId) {\n\t\t\t\t\t// Show available models\n\t\t\t\t\tawait showKnownModels();\n\t\t\t\t\tprocess.exit(0);\n\t\t\t\t}\n\n\t\t\t\t// Parse options\n\t\t\t\tlet name: string | undefined;\n\t\t\t\tlet memory: string | undefined;\n\t\t\t\tlet context: string | undefined;\n\t\t\t\tlet gpus: number | undefined;\n\t\t\t\tconst vllmArgs: string[] = [];\n\t\t\t\tlet inVllmArgs = false;\n\n\t\t\t\tfor (let i = 2; i < args.length; i++) {\n\t\t\t\t\tif (inVllmArgs) {\n\t\t\t\t\t\tvllmArgs.push(args[i]);\n\t\t\t\t\t} else if (args[i] === \"--name\" && i + 1 < args.length) {\n\t\t\t\t\t\tname = args[i + 1];\n\t\t\t\t\t\ti++;\n\t\t\t\t\t} else if (args[i] === \"--memory\" && i + 1 < args.length) {\n\t\t\t\t\t\tmemory = args[i + 1];\n\t\t\t\t\t\ti++;\n\t\t\t\t\t} else if (args[i] === \"--context\" && i + 1 < args.length) {\n\t\t\t\t\t\tcontext = args[i + 1];\n\t\t\t\t\t\ti++;\n\t\t\t\t\t} else if (args[i] === \"--gpus\" && i + 1 < args.length) {\n\t\t\t\t\t\tgpus = parseInt(args[i + 1], 10);\n\t\t\t\t\t\tif (Number.isNaN(gpus) || gpus < 1) {\n\t\t\t\t\t\t\tconsole.error(chalk.red(\"--gpus must be a positive number\"));\n\t\t\t\t\t\t\tprocess.exit(1);\n\t\t\t\t\t\t}\n\t\t\t\t\t\ti++;\n\t\t\t\t\t} else if (args[i] === \"--vllm\") {\n\t\t\t\t\t\tinVllmArgs = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!name) {\n\t\t\t\t\tconsole.error(\"--name is required\");\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\t// Warn if --vllm is used with other parameters\n\t\t\t\tif (vllmArgs.length > 0 && (memory || context || gpus)) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\tchalk.yellow(\"⚠ Warning: --memory, --context, and --gpus are ignored when --vllm is specified\"),\n\t\t\t\t\t);\n\t\t\t\t\tconsole.log(chalk.yellow(\" Using only custom vLLM arguments\"));\n\t\t\t\t\tconsole.log(\"\");\n\t\t\t\t}\n\n\t\t\t\tawait startModel(modelId, name, {\n\t\t\t\t\tpod: podOverride,\n\t\t\t\t\tmemory,\n\t\t\t\t\tcontext,\n\t\t\t\t\tgpus,\n\t\t\t\t\tvllmArgs: vllmArgs.length > 0 ? vllmArgs : undefined,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"stop\": {\n\t\t\t\t// pi stop [name] - stop specific model or all models\n\t\t\t\tconst name = args[1];\n\t\t\t\tif (!name) {\n\t\t\t\t\t// Stop all models on the active pod\n\t\t\t\t\tawait stopAllModels({ pod: podOverride });\n\t\t\t\t} else {\n\t\t\t\t\tawait stopModel(name, { pod: podOverride });\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"list\":\n\t\t\t\t// pi list\n\t\t\t\tawait listModels({ pod: podOverride });\n\t\t\t\tbreak;\n\t\t\tcase \"logs\": {\n\t\t\t\t// pi logs <name>\n\t\t\t\tconst name = args[1];\n\t\t\t\tif (!name) {\n\t\t\t\t\tconsole.error(\"Usage: pi logs <name>\");\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\t\t\t\tawait viewLogs(name, { pod: podOverride });\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"agent\": {\n\t\t\t\t// pi agent <name> [messages...] [options]\n\t\t\t\tconst name = args[1];\n\t\t\t\tif (!name) {\n\t\t\t\t\tconsole.error(\"Usage: pi agent <name> [messages...] [options]\");\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\tconst apiKey = process.env.PI_API_KEY;\n\n\t\t\t\t// Pass all args after the model name\n\t\t\t\tconst agentArgs = args.slice(2);\n\n\t\t\t\t// If no messages provided, it's interactive mode\n\t\t\t\tawait promptModel(name, agentArgs, {\n\t\t\t\t\tpod: podOverride,\n\t\t\t\t\tapiKey,\n\t\t\t\t}).catch(() => {\n\t\t\t\t\t// Error already handled in promptModel, just exit cleanly\n\t\t\t\t\tprocess.exit(0);\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tconsole.error(`Unknown command: ${command}`);\n\t\t\t\tprintHelp();\n\t\t\t\tprocess.exit(1);\n\t\t}\n\t}\n} catch (error) {\n\tconsole.error(\"Error:\", error);\n\tprocess.exit(1);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"","sourcesContent":["#!/usr/bin/env node\nimport chalk from \"chalk\";\nimport { spawn } from \"child_process\";\nimport { readFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport { listModels, showKnownModels, startModel, stopAllModels, stopModel, viewLogs } from \"./commands/models.js\";\nimport { listPods, removePodCommand, setupPod, switchActivePod } from \"./commands/pods.js\";\nimport { promptModel } from \"./commands/prompt.js\";\nimport { getActivePod, loadConfig } from \"./config.js\";\nimport { sshExecStream } from \"./ssh.js\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\nconst packageJson = JSON.parse(readFileSync(join(__dirname, \"../package.json\"), \"utf-8\"));\n\nfunction printHelp() {\n\tconsole.log(`pi v${packageJson.version} - Manage vLLM deployments on GPU pods\n\nPod Management:\n pi pods setup <name> \"<ssh>\" --mount \"<mount>\" Setup pod with mount command\n Options:\n --vllm release Install latest vLLM release >=0.10.0 (default)\n --vllm nightly Install vLLM nightly build (latest features)\n --vllm gpt-oss Install vLLM 0.10.1+gptoss with PyTorch nightly (GPT-OSS only)\n pi pods List all pods (* = active)\n pi pods active <name> Switch active pod\n pi pods remove <name> Remove pod from local config\n pi shell [<name>] Open shell on pod (active or specified)\n pi ssh [<name>] \"<command>\" Run SSH command on pod\n\nModel Management:\n pi start <model> --name <name> [options] Start a model\n --memory <percent> GPU memory allocation (30%, 50%, 90%)\n --context <size> Context window (4k, 8k, 16k, 32k, 64k, 128k)\n --gpus <count> Number of GPUs to use (predefined models only)\n --vllm <args...> Pass remaining args to vLLM (ignores other options)\n pi stop [<name>] Stop model (or all if no name)\n pi list List running models\n pi logs <name> Stream model logs\n pi agent <name> [\"<message>\"...] [options] Chat with model using agent & tools\n pi agent <name> [options] Interactive chat mode\n --continue, -c Continue previous session\n --json Output as JSONL\n (All draht-agent options are supported)\n\n All model commands support --pod <name> to override the active pod.\n\nEnvironment:\n HF_TOKEN HuggingFace token for model downloads\n PI_API_KEY API key for vLLM endpoints\n PI_CONFIG_DIR Config directory (default: ~/.pi)`);\n}\n\n// Parse command line arguments\nconst args = process.argv.slice(2);\n\nif (args.length === 0 || args[0] === \"--help\" || args[0] === \"-h\") {\n\tprintHelp();\n\tprocess.exit(0);\n}\n\nif (args[0] === \"--version\" || args[0] === \"-v\") {\n\tconsole.log(packageJson.version);\n\tprocess.exit(0);\n}\n\nconst command = args[0];\nconst subcommand = args[1];\n\n// Main command handler\ntry {\n\t// Handle \"pi pods\" commands\n\tif (command === \"pods\") {\n\t\tif (!subcommand) {\n\t\t\t// pi pods - list all pods\n\t\t\tlistPods();\n\t\t} else if (subcommand === \"setup\") {\n\t\t\t// pi pods setup <name> \"<ssh>\" [--mount \"<mount>\"] [--models-path <path>] [--vllm release|nightly|gpt-oss]\n\t\t\tconst name = args[2];\n\t\t\tconst sshCmd = args[3];\n\n\t\t\tif (!name || !sshCmd) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t'Usage: pi pods setup <name> \"<ssh>\" [--mount \"<mount>\"] [--models-path <path>] [--vllm release|nightly|gpt-oss]',\n\t\t\t\t);\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\t// Parse options\n\t\t\tconst options: { mount?: string; modelsPath?: string; vllm?: \"release\" | \"nightly\" | \"gpt-oss\" } = {};\n\t\t\tfor (let i = 4; i < args.length; i++) {\n\t\t\t\tif (args[i] === \"--mount\" && i + 1 < args.length) {\n\t\t\t\t\toptions.mount = args[i + 1];\n\t\t\t\t\ti++;\n\t\t\t\t} else if (args[i] === \"--models-path\" && i + 1 < args.length) {\n\t\t\t\t\toptions.modelsPath = args[i + 1];\n\t\t\t\t\ti++;\n\t\t\t\t} else if (args[i] === \"--vllm\" && i + 1 < args.length) {\n\t\t\t\t\tconst vllmType = args[i + 1];\n\t\t\t\t\tif (vllmType === \"release\" || vllmType === \"nightly\" || vllmType === \"gpt-oss\") {\n\t\t\t\t\t\toptions.vllm = vllmType;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.error(chalk.red(`Invalid vLLM type: ${vllmType}`));\n\t\t\t\t\t\tconsole.error(\"Valid options: release, nightly, gpt-oss\");\n\t\t\t\t\t\tprocess.exit(1);\n\t\t\t\t\t}\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If --mount provided but no --models-path, try to extract path from mount command\n\t\t\tif (options.mount && !options.modelsPath) {\n\t\t\t\t// Extract last part of mount command as models path\n\t\t\t\tconst parts = options.mount.trim().split(\" \");\n\t\t\t\tconst lastPart = parts[parts.length - 1];\n\t\t\t\tif (lastPart?.startsWith(\"/\")) {\n\t\t\t\t\toptions.modelsPath = lastPart;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait setupPod(name, sshCmd, options);\n\t\t} else if (subcommand === \"active\") {\n\t\t\t// pi pods active <name>\n\t\t\tconst name = args[2];\n\t\t\tif (!name) {\n\t\t\t\tconsole.error(\"Usage: pi pods active <name>\");\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\tswitchActivePod(name);\n\t\t} else if (subcommand === \"remove\") {\n\t\t\t// pi pods remove <name>\n\t\t\tconst name = args[2];\n\t\t\tif (!name) {\n\t\t\t\tconsole.error(\"Usage: pi pods remove <name>\");\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\tremovePodCommand(name);\n\t\t} else {\n\t\t\tconsole.error(`Unknown pods subcommand: ${subcommand}`);\n\t\t\tprocess.exit(1);\n\t\t}\n\t} else {\n\t\t// Parse --pod override for model commands\n\t\tlet podOverride: string | undefined;\n\t\tconst podIndex = args.indexOf(\"--pod\");\n\t\tif (podIndex !== -1 && podIndex + 1 < args.length) {\n\t\t\tpodOverride = args[podIndex + 1];\n\t\t\t// Remove --pod and its value from args\n\t\t\targs.splice(podIndex, 2);\n\t\t}\n\n\t\t// Handle SSH/shell commands and model commands\n\t\tswitch (command) {\n\t\t\tcase \"shell\": {\n\t\t\t\t// pi shell [<name>] - open interactive shell\n\t\t\t\tconst podName = args[1];\n\t\t\t\tlet podInfo: { name: string; pod: import(\"./types.js\").Pod } | null = null;\n\n\t\t\t\tif (podName) {\n\t\t\t\t\tconst config = loadConfig();\n\t\t\t\t\tconst pod = config.pods[podName];\n\t\t\t\t\tif (pod) {\n\t\t\t\t\t\tpodInfo = { name: podName, pod };\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tpodInfo = getActivePod();\n\t\t\t\t}\n\n\t\t\t\tif (!podInfo) {\n\t\t\t\t\tif (podName) {\n\t\t\t\t\t\tconsole.error(chalk.red(`Pod '${podName}' not found`));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.error(chalk.red(\"No active pod. Use 'pi pods active <name>' to set one.\"));\n\t\t\t\t\t}\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\tconsole.log(chalk.green(`Connecting to pod '${podInfo.name}'...`));\n\n\t\t\t\t// Execute SSH in interactive mode\n\t\t\t\tconst sshArgs = podInfo.pod.ssh.split(\" \").slice(1); // Remove 'ssh' from command\n\t\t\t\tconst sshProcess = spawn(\"ssh\", sshArgs, {\n\t\t\t\t\tstdio: \"inherit\",\n\t\t\t\t\tenv: process.env,\n\t\t\t\t});\n\n\t\t\t\tsshProcess.on(\"exit\", (code) => {\n\t\t\t\t\tprocess.exit(code || 0);\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"ssh\": {\n\t\t\t\t// pi ssh [<name>] \"<command>\" - run command via SSH\n\t\t\t\tlet podName: string | undefined;\n\t\t\t\tlet sshCommand: string;\n\n\t\t\t\tif (args.length === 2) {\n\t\t\t\t\t// pi ssh \"<command>\" - use active pod\n\t\t\t\t\tsshCommand = args[1];\n\t\t\t\t} else if (args.length === 3) {\n\t\t\t\t\t// pi ssh <name> \"<command>\"\n\t\t\t\t\tpodName = args[1];\n\t\t\t\t\tsshCommand = args[2];\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error('Usage: pi ssh [<name>] \"<command>\"');\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\tlet podInfo: { name: string; pod: import(\"./types.js\").Pod } | null = null;\n\n\t\t\t\tif (podName) {\n\t\t\t\t\tconst config = loadConfig();\n\t\t\t\t\tconst pod = config.pods[podName];\n\t\t\t\t\tif (pod) {\n\t\t\t\t\t\tpodInfo = { name: podName, pod };\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tpodInfo = getActivePod();\n\t\t\t\t}\n\n\t\t\t\tif (!podInfo) {\n\t\t\t\t\tif (podName) {\n\t\t\t\t\t\tconsole.error(chalk.red(`Pod '${podName}' not found`));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.error(chalk.red(\"No active pod. Use 'pi pods active <name>' to set one.\"));\n\t\t\t\t\t}\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\tconsole.log(chalk.gray(`Running on pod '${podInfo.name}': ${sshCommand}`));\n\n\t\t\t\t// Execute command and stream output\n\t\t\t\tconst exitCode = await sshExecStream(podInfo.pod.ssh, sshCommand);\n\t\t\t\tprocess.exit(exitCode);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"start\": {\n\t\t\t\t// pi start <model> --name <name> [options]\n\t\t\t\tconst modelId = args[1];\n\t\t\t\tif (!modelId) {\n\t\t\t\t\t// Show available models\n\t\t\t\t\tawait showKnownModels();\n\t\t\t\t\tprocess.exit(0);\n\t\t\t\t}\n\n\t\t\t\t// Parse options\n\t\t\t\tlet name: string | undefined;\n\t\t\t\tlet memory: string | undefined;\n\t\t\t\tlet context: string | undefined;\n\t\t\t\tlet gpus: number | undefined;\n\t\t\t\tconst vllmArgs: string[] = [];\n\t\t\t\tlet inVllmArgs = false;\n\n\t\t\t\tfor (let i = 2; i < args.length; i++) {\n\t\t\t\t\tif (inVllmArgs) {\n\t\t\t\t\t\tvllmArgs.push(args[i]);\n\t\t\t\t\t} else if (args[i] === \"--name\" && i + 1 < args.length) {\n\t\t\t\t\t\tname = args[i + 1];\n\t\t\t\t\t\ti++;\n\t\t\t\t\t} else if (args[i] === \"--memory\" && i + 1 < args.length) {\n\t\t\t\t\t\tmemory = args[i + 1];\n\t\t\t\t\t\ti++;\n\t\t\t\t\t} else if (args[i] === \"--context\" && i + 1 < args.length) {\n\t\t\t\t\t\tcontext = args[i + 1];\n\t\t\t\t\t\ti++;\n\t\t\t\t\t} else if (args[i] === \"--gpus\" && i + 1 < args.length) {\n\t\t\t\t\t\tgpus = parseInt(args[i + 1], 10);\n\t\t\t\t\t\tif (Number.isNaN(gpus) || gpus < 1) {\n\t\t\t\t\t\t\tconsole.error(chalk.red(\"--gpus must be a positive number\"));\n\t\t\t\t\t\t\tprocess.exit(1);\n\t\t\t\t\t\t}\n\t\t\t\t\t\ti++;\n\t\t\t\t\t} else if (args[i] === \"--vllm\") {\n\t\t\t\t\t\tinVllmArgs = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!name) {\n\t\t\t\t\tconsole.error(\"--name is required\");\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\t// Warn if --vllm is used with other parameters\n\t\t\t\tif (vllmArgs.length > 0 && (memory || context || gpus)) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\tchalk.yellow(\"⚠ Warning: --memory, --context, and --gpus are ignored when --vllm is specified\"),\n\t\t\t\t\t);\n\t\t\t\t\tconsole.log(chalk.yellow(\" Using only custom vLLM arguments\"));\n\t\t\t\t\tconsole.log(\"\");\n\t\t\t\t}\n\n\t\t\t\tawait startModel(modelId, name, {\n\t\t\t\t\tpod: podOverride,\n\t\t\t\t\tmemory,\n\t\t\t\t\tcontext,\n\t\t\t\t\tgpus,\n\t\t\t\t\tvllmArgs: vllmArgs.length > 0 ? vllmArgs : undefined,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"stop\": {\n\t\t\t\t// pi stop [name] - stop specific model or all models\n\t\t\t\tconst name = args[1];\n\t\t\t\tif (!name) {\n\t\t\t\t\t// Stop all models on the active pod\n\t\t\t\t\tawait stopAllModels({ pod: podOverride });\n\t\t\t\t} else {\n\t\t\t\t\tawait stopModel(name, { pod: podOverride });\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"list\":\n\t\t\t\t// pi list\n\t\t\t\tawait listModels({ pod: podOverride });\n\t\t\t\tbreak;\n\t\t\tcase \"logs\": {\n\t\t\t\t// pi logs <name>\n\t\t\t\tconst name = args[1];\n\t\t\t\tif (!name) {\n\t\t\t\t\tconsole.error(\"Usage: pi logs <name>\");\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\t\t\t\tawait viewLogs(name, { pod: podOverride });\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"agent\": {\n\t\t\t\t// pi agent <name> [messages...] [options]\n\t\t\t\tconst name = args[1];\n\t\t\t\tif (!name) {\n\t\t\t\t\tconsole.error(\"Usage: pi agent <name> [messages...] [options]\");\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\tconst apiKey = process.env.PI_API_KEY;\n\n\t\t\t\t// Pass all args after the model name\n\t\t\t\tconst agentArgs = args.slice(2);\n\n\t\t\t\t// If no messages provided, it's interactive mode\n\t\t\t\tawait promptModel(name, agentArgs, {\n\t\t\t\t\tpod: podOverride,\n\t\t\t\t\tapiKey,\n\t\t\t\t}).catch(() => {\n\t\t\t\t\t// Error already handled in promptModel, just exit cleanly\n\t\t\t\t\tprocess.exit(0);\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tconsole.error(`Unknown command: ${command}`);\n\t\t\t\tprintHelp();\n\t\t\t\tprocess.exit(1);\n\t\t}\n\t}\n} catch (error) {\n\tconsole.error(\"Error:\", error);\n\tprocess.exit(1);\n}\n"]}
|
package/dist/cli.js
CHANGED
|
@@ -40,7 +40,7 @@ Model Management:
|
|
|
40
40
|
pi agent <name> [options] Interactive chat mode
|
|
41
41
|
--continue, -c Continue previous session
|
|
42
42
|
--json Output as JSONL
|
|
43
|
-
(All
|
|
43
|
+
(All draht-agent options are supported)
|
|
44
44
|
|
|
45
45
|
All model commands support --pod <name> to override the active pod.
|
|
46
46
|
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,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,CAAC;IAC/B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC","sourcesContent":["#!/usr/bin/env node\nimport chalk from \"chalk\";\nimport { spawn } from \"child_process\";\nimport { readFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport { listModels, showKnownModels, startModel, stopAllModels, stopModel, viewLogs } from \"./commands/models.js\";\nimport { listPods, removePodCommand, setupPod, switchActivePod } from \"./commands/pods.js\";\nimport { promptModel } from \"./commands/prompt.js\";\nimport { getActivePod, loadConfig } from \"./config.js\";\nimport { sshExecStream } from \"./ssh.js\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\nconst packageJson = JSON.parse(readFileSync(join(__dirname, \"../package.json\"), \"utf-8\"));\n\nfunction printHelp() {\n\tconsole.log(`pi v${packageJson.version} - Manage vLLM deployments on GPU pods\n\nPod Management:\n pi pods setup <name> \"<ssh>\" --mount \"<mount>\" Setup pod with mount command\n Options:\n --vllm release Install latest vLLM release >=0.10.0 (default)\n --vllm nightly Install vLLM nightly build (latest features)\n --vllm gpt-oss Install vLLM 0.10.1+gptoss with PyTorch nightly (GPT-OSS only)\n pi pods List all pods (* = active)\n pi pods active <name> Switch active pod\n pi pods remove <name> Remove pod from local config\n pi shell [<name>] Open shell on pod (active or specified)\n pi ssh [<name>] \"<command>\" Run SSH command on pod\n\nModel Management:\n pi start <model> --name <name> [options] Start a model\n --memory <percent> GPU memory allocation (30%, 50%, 90%)\n --context <size> Context window (4k, 8k, 16k, 32k, 64k, 128k)\n --gpus <count> Number of GPUs to use (predefined models only)\n --vllm <args...> Pass remaining args to vLLM (ignores other options)\n pi stop [<name>] Stop model (or all if no name)\n pi list List running models\n pi logs <name> Stream model logs\n pi agent <name> [\"<message>\"...] [options] Chat with model using agent & tools\n pi agent <name> [options] Interactive chat mode\n --continue, -c Continue previous session\n --json Output as JSONL\n (All pi-agent options are supported)\n\n All model commands support --pod <name> to override the active pod.\n\nEnvironment:\n HF_TOKEN HuggingFace token for model downloads\n PI_API_KEY API key for vLLM endpoints\n PI_CONFIG_DIR Config directory (default: ~/.pi)`);\n}\n\n// Parse command line arguments\nconst args = process.argv.slice(2);\n\nif (args.length === 0 || args[0] === \"--help\" || args[0] === \"-h\") {\n\tprintHelp();\n\tprocess.exit(0);\n}\n\nif (args[0] === \"--version\" || args[0] === \"-v\") {\n\tconsole.log(packageJson.version);\n\tprocess.exit(0);\n}\n\nconst command = args[0];\nconst subcommand = args[1];\n\n// Main command handler\ntry {\n\t// Handle \"pi pods\" commands\n\tif (command === \"pods\") {\n\t\tif (!subcommand) {\n\t\t\t// pi pods - list all pods\n\t\t\tlistPods();\n\t\t} else if (subcommand === \"setup\") {\n\t\t\t// pi pods setup <name> \"<ssh>\" [--mount \"<mount>\"] [--models-path <path>] [--vllm release|nightly|gpt-oss]\n\t\t\tconst name = args[2];\n\t\t\tconst sshCmd = args[3];\n\n\t\t\tif (!name || !sshCmd) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t'Usage: pi pods setup <name> \"<ssh>\" [--mount \"<mount>\"] [--models-path <path>] [--vllm release|nightly|gpt-oss]',\n\t\t\t\t);\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\t// Parse options\n\t\t\tconst options: { mount?: string; modelsPath?: string; vllm?: \"release\" | \"nightly\" | \"gpt-oss\" } = {};\n\t\t\tfor (let i = 4; i < args.length; i++) {\n\t\t\t\tif (args[i] === \"--mount\" && i + 1 < args.length) {\n\t\t\t\t\toptions.mount = args[i + 1];\n\t\t\t\t\ti++;\n\t\t\t\t} else if (args[i] === \"--models-path\" && i + 1 < args.length) {\n\t\t\t\t\toptions.modelsPath = args[i + 1];\n\t\t\t\t\ti++;\n\t\t\t\t} else if (args[i] === \"--vllm\" && i + 1 < args.length) {\n\t\t\t\t\tconst vllmType = args[i + 1];\n\t\t\t\t\tif (vllmType === \"release\" || vllmType === \"nightly\" || vllmType === \"gpt-oss\") {\n\t\t\t\t\t\toptions.vllm = vllmType;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.error(chalk.red(`Invalid vLLM type: ${vllmType}`));\n\t\t\t\t\t\tconsole.error(\"Valid options: release, nightly, gpt-oss\");\n\t\t\t\t\t\tprocess.exit(1);\n\t\t\t\t\t}\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If --mount provided but no --models-path, try to extract path from mount command\n\t\t\tif (options.mount && !options.modelsPath) {\n\t\t\t\t// Extract last part of mount command as models path\n\t\t\t\tconst parts = options.mount.trim().split(\" \");\n\t\t\t\tconst lastPart = parts[parts.length - 1];\n\t\t\t\tif (lastPart?.startsWith(\"/\")) {\n\t\t\t\t\toptions.modelsPath = lastPart;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait setupPod(name, sshCmd, options);\n\t\t} else if (subcommand === \"active\") {\n\t\t\t// pi pods active <name>\n\t\t\tconst name = args[2];\n\t\t\tif (!name) {\n\t\t\t\tconsole.error(\"Usage: pi pods active <name>\");\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\tswitchActivePod(name);\n\t\t} else if (subcommand === \"remove\") {\n\t\t\t// pi pods remove <name>\n\t\t\tconst name = args[2];\n\t\t\tif (!name) {\n\t\t\t\tconsole.error(\"Usage: pi pods remove <name>\");\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\tremovePodCommand(name);\n\t\t} else {\n\t\t\tconsole.error(`Unknown pods subcommand: ${subcommand}`);\n\t\t\tprocess.exit(1);\n\t\t}\n\t} else {\n\t\t// Parse --pod override for model commands\n\t\tlet podOverride: string | undefined;\n\t\tconst podIndex = args.indexOf(\"--pod\");\n\t\tif (podIndex !== -1 && podIndex + 1 < args.length) {\n\t\t\tpodOverride = args[podIndex + 1];\n\t\t\t// Remove --pod and its value from args\n\t\t\targs.splice(podIndex, 2);\n\t\t}\n\n\t\t// Handle SSH/shell commands and model commands\n\t\tswitch (command) {\n\t\t\tcase \"shell\": {\n\t\t\t\t// pi shell [<name>] - open interactive shell\n\t\t\t\tconst podName = args[1];\n\t\t\t\tlet podInfo: { name: string; pod: import(\"./types.js\").Pod } | null = null;\n\n\t\t\t\tif (podName) {\n\t\t\t\t\tconst config = loadConfig();\n\t\t\t\t\tconst pod = config.pods[podName];\n\t\t\t\t\tif (pod) {\n\t\t\t\t\t\tpodInfo = { name: podName, pod };\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tpodInfo = getActivePod();\n\t\t\t\t}\n\n\t\t\t\tif (!podInfo) {\n\t\t\t\t\tif (podName) {\n\t\t\t\t\t\tconsole.error(chalk.red(`Pod '${podName}' not found`));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.error(chalk.red(\"No active pod. Use 'pi pods active <name>' to set one.\"));\n\t\t\t\t\t}\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\tconsole.log(chalk.green(`Connecting to pod '${podInfo.name}'...`));\n\n\t\t\t\t// Execute SSH in interactive mode\n\t\t\t\tconst sshArgs = podInfo.pod.ssh.split(\" \").slice(1); // Remove 'ssh' from command\n\t\t\t\tconst sshProcess = spawn(\"ssh\", sshArgs, {\n\t\t\t\t\tstdio: \"inherit\",\n\t\t\t\t\tenv: process.env,\n\t\t\t\t});\n\n\t\t\t\tsshProcess.on(\"exit\", (code) => {\n\t\t\t\t\tprocess.exit(code || 0);\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"ssh\": {\n\t\t\t\t// pi ssh [<name>] \"<command>\" - run command via SSH\n\t\t\t\tlet podName: string | undefined;\n\t\t\t\tlet sshCommand: string;\n\n\t\t\t\tif (args.length === 2) {\n\t\t\t\t\t// pi ssh \"<command>\" - use active pod\n\t\t\t\t\tsshCommand = args[1];\n\t\t\t\t} else if (args.length === 3) {\n\t\t\t\t\t// pi ssh <name> \"<command>\"\n\t\t\t\t\tpodName = args[1];\n\t\t\t\t\tsshCommand = args[2];\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error('Usage: pi ssh [<name>] \"<command>\"');\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\tlet podInfo: { name: string; pod: import(\"./types.js\").Pod } | null = null;\n\n\t\t\t\tif (podName) {\n\t\t\t\t\tconst config = loadConfig();\n\t\t\t\t\tconst pod = config.pods[podName];\n\t\t\t\t\tif (pod) {\n\t\t\t\t\t\tpodInfo = { name: podName, pod };\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tpodInfo = getActivePod();\n\t\t\t\t}\n\n\t\t\t\tif (!podInfo) {\n\t\t\t\t\tif (podName) {\n\t\t\t\t\t\tconsole.error(chalk.red(`Pod '${podName}' not found`));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.error(chalk.red(\"No active pod. Use 'pi pods active <name>' to set one.\"));\n\t\t\t\t\t}\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\tconsole.log(chalk.gray(`Running on pod '${podInfo.name}': ${sshCommand}`));\n\n\t\t\t\t// Execute command and stream output\n\t\t\t\tconst exitCode = await sshExecStream(podInfo.pod.ssh, sshCommand);\n\t\t\t\tprocess.exit(exitCode);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"start\": {\n\t\t\t\t// pi start <model> --name <name> [options]\n\t\t\t\tconst modelId = args[1];\n\t\t\t\tif (!modelId) {\n\t\t\t\t\t// Show available models\n\t\t\t\t\tawait showKnownModels();\n\t\t\t\t\tprocess.exit(0);\n\t\t\t\t}\n\n\t\t\t\t// Parse options\n\t\t\t\tlet name: string | undefined;\n\t\t\t\tlet memory: string | undefined;\n\t\t\t\tlet context: string | undefined;\n\t\t\t\tlet gpus: number | undefined;\n\t\t\t\tconst vllmArgs: string[] = [];\n\t\t\t\tlet inVllmArgs = false;\n\n\t\t\t\tfor (let i = 2; i < args.length; i++) {\n\t\t\t\t\tif (inVllmArgs) {\n\t\t\t\t\t\tvllmArgs.push(args[i]);\n\t\t\t\t\t} else if (args[i] === \"--name\" && i + 1 < args.length) {\n\t\t\t\t\t\tname = args[i + 1];\n\t\t\t\t\t\ti++;\n\t\t\t\t\t} else if (args[i] === \"--memory\" && i + 1 < args.length) {\n\t\t\t\t\t\tmemory = args[i + 1];\n\t\t\t\t\t\ti++;\n\t\t\t\t\t} else if (args[i] === \"--context\" && i + 1 < args.length) {\n\t\t\t\t\t\tcontext = args[i + 1];\n\t\t\t\t\t\ti++;\n\t\t\t\t\t} else if (args[i] === \"--gpus\" && i + 1 < args.length) {\n\t\t\t\t\t\tgpus = parseInt(args[i + 1], 10);\n\t\t\t\t\t\tif (Number.isNaN(gpus) || gpus < 1) {\n\t\t\t\t\t\t\tconsole.error(chalk.red(\"--gpus must be a positive number\"));\n\t\t\t\t\t\t\tprocess.exit(1);\n\t\t\t\t\t\t}\n\t\t\t\t\t\ti++;\n\t\t\t\t\t} else if (args[i] === \"--vllm\") {\n\t\t\t\t\t\tinVllmArgs = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!name) {\n\t\t\t\t\tconsole.error(\"--name is required\");\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\t// Warn if --vllm is used with other parameters\n\t\t\t\tif (vllmArgs.length > 0 && (memory || context || gpus)) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\tchalk.yellow(\"⚠ Warning: --memory, --context, and --gpus are ignored when --vllm is specified\"),\n\t\t\t\t\t);\n\t\t\t\t\tconsole.log(chalk.yellow(\" Using only custom vLLM arguments\"));\n\t\t\t\t\tconsole.log(\"\");\n\t\t\t\t}\n\n\t\t\t\tawait startModel(modelId, name, {\n\t\t\t\t\tpod: podOverride,\n\t\t\t\t\tmemory,\n\t\t\t\t\tcontext,\n\t\t\t\t\tgpus,\n\t\t\t\t\tvllmArgs: vllmArgs.length > 0 ? vllmArgs : undefined,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"stop\": {\n\t\t\t\t// pi stop [name] - stop specific model or all models\n\t\t\t\tconst name = args[1];\n\t\t\t\tif (!name) {\n\t\t\t\t\t// Stop all models on the active pod\n\t\t\t\t\tawait stopAllModels({ pod: podOverride });\n\t\t\t\t} else {\n\t\t\t\t\tawait stopModel(name, { pod: podOverride });\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"list\":\n\t\t\t\t// pi list\n\t\t\t\tawait listModels({ pod: podOverride });\n\t\t\t\tbreak;\n\t\t\tcase \"logs\": {\n\t\t\t\t// pi logs <name>\n\t\t\t\tconst name = args[1];\n\t\t\t\tif (!name) {\n\t\t\t\t\tconsole.error(\"Usage: pi logs <name>\");\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\t\t\t\tawait viewLogs(name, { pod: podOverride });\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"agent\": {\n\t\t\t\t// pi agent <name> [messages...] [options]\n\t\t\t\tconst name = args[1];\n\t\t\t\tif (!name) {\n\t\t\t\t\tconsole.error(\"Usage: pi agent <name> [messages...] [options]\");\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\tconst apiKey = process.env.PI_API_KEY;\n\n\t\t\t\t// Pass all args after the model name\n\t\t\t\tconst agentArgs = args.slice(2);\n\n\t\t\t\t// If no messages provided, it's interactive mode\n\t\t\t\tawait promptModel(name, agentArgs, {\n\t\t\t\t\tpod: podOverride,\n\t\t\t\t\tapiKey,\n\t\t\t\t}).catch(() => {\n\t\t\t\t\t// Error already handled in promptModel, just exit cleanly\n\t\t\t\t\tprocess.exit(0);\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tconsole.error(`Unknown command: ${command}`);\n\t\t\t\tprintHelp();\n\t\t\t\tprocess.exit(1);\n\t\t}\n\t}\n} catch (error) {\n\tconsole.error(\"Error:\", error);\n\tprocess.exit(1);\n}\n"]}
|
|
1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,CAAC;IACF,CAAC;AACF,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IAChB,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC/B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC","sourcesContent":["#!/usr/bin/env node\nimport chalk from \"chalk\";\nimport { spawn } from \"child_process\";\nimport { readFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport { listModels, showKnownModels, startModel, stopAllModels, stopModel, viewLogs } from \"./commands/models.js\";\nimport { listPods, removePodCommand, setupPod, switchActivePod } from \"./commands/pods.js\";\nimport { promptModel } from \"./commands/prompt.js\";\nimport { getActivePod, loadConfig } from \"./config.js\";\nimport { sshExecStream } from \"./ssh.js\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\nconst packageJson = JSON.parse(readFileSync(join(__dirname, \"../package.json\"), \"utf-8\"));\n\nfunction printHelp() {\n\tconsole.log(`pi v${packageJson.version} - Manage vLLM deployments on GPU pods\n\nPod Management:\n pi pods setup <name> \"<ssh>\" --mount \"<mount>\" Setup pod with mount command\n Options:\n --vllm release Install latest vLLM release >=0.10.0 (default)\n --vllm nightly Install vLLM nightly build (latest features)\n --vllm gpt-oss Install vLLM 0.10.1+gptoss with PyTorch nightly (GPT-OSS only)\n pi pods List all pods (* = active)\n pi pods active <name> Switch active pod\n pi pods remove <name> Remove pod from local config\n pi shell [<name>] Open shell on pod (active or specified)\n pi ssh [<name>] \"<command>\" Run SSH command on pod\n\nModel Management:\n pi start <model> --name <name> [options] Start a model\n --memory <percent> GPU memory allocation (30%, 50%, 90%)\n --context <size> Context window (4k, 8k, 16k, 32k, 64k, 128k)\n --gpus <count> Number of GPUs to use (predefined models only)\n --vllm <args...> Pass remaining args to vLLM (ignores other options)\n pi stop [<name>] Stop model (or all if no name)\n pi list List running models\n pi logs <name> Stream model logs\n pi agent <name> [\"<message>\"...] [options] Chat with model using agent & tools\n pi agent <name> [options] Interactive chat mode\n --continue, -c Continue previous session\n --json Output as JSONL\n (All draht-agent options are supported)\n\n All model commands support --pod <name> to override the active pod.\n\nEnvironment:\n HF_TOKEN HuggingFace token for model downloads\n PI_API_KEY API key for vLLM endpoints\n PI_CONFIG_DIR Config directory (default: ~/.pi)`);\n}\n\n// Parse command line arguments\nconst args = process.argv.slice(2);\n\nif (args.length === 0 || args[0] === \"--help\" || args[0] === \"-h\") {\n\tprintHelp();\n\tprocess.exit(0);\n}\n\nif (args[0] === \"--version\" || args[0] === \"-v\") {\n\tconsole.log(packageJson.version);\n\tprocess.exit(0);\n}\n\nconst command = args[0];\nconst subcommand = args[1];\n\n// Main command handler\ntry {\n\t// Handle \"pi pods\" commands\n\tif (command === \"pods\") {\n\t\tif (!subcommand) {\n\t\t\t// pi pods - list all pods\n\t\t\tlistPods();\n\t\t} else if (subcommand === \"setup\") {\n\t\t\t// pi pods setup <name> \"<ssh>\" [--mount \"<mount>\"] [--models-path <path>] [--vllm release|nightly|gpt-oss]\n\t\t\tconst name = args[2];\n\t\t\tconst sshCmd = args[3];\n\n\t\t\tif (!name || !sshCmd) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t'Usage: pi pods setup <name> \"<ssh>\" [--mount \"<mount>\"] [--models-path <path>] [--vllm release|nightly|gpt-oss]',\n\t\t\t\t);\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\t// Parse options\n\t\t\tconst options: { mount?: string; modelsPath?: string; vllm?: \"release\" | \"nightly\" | \"gpt-oss\" } = {};\n\t\t\tfor (let i = 4; i < args.length; i++) {\n\t\t\t\tif (args[i] === \"--mount\" && i + 1 < args.length) {\n\t\t\t\t\toptions.mount = args[i + 1];\n\t\t\t\t\ti++;\n\t\t\t\t} else if (args[i] === \"--models-path\" && i + 1 < args.length) {\n\t\t\t\t\toptions.modelsPath = args[i + 1];\n\t\t\t\t\ti++;\n\t\t\t\t} else if (args[i] === \"--vllm\" && i + 1 < args.length) {\n\t\t\t\t\tconst vllmType = args[i + 1];\n\t\t\t\t\tif (vllmType === \"release\" || vllmType === \"nightly\" || vllmType === \"gpt-oss\") {\n\t\t\t\t\t\toptions.vllm = vllmType;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.error(chalk.red(`Invalid vLLM type: ${vllmType}`));\n\t\t\t\t\t\tconsole.error(\"Valid options: release, nightly, gpt-oss\");\n\t\t\t\t\t\tprocess.exit(1);\n\t\t\t\t\t}\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If --mount provided but no --models-path, try to extract path from mount command\n\t\t\tif (options.mount && !options.modelsPath) {\n\t\t\t\t// Extract last part of mount command as models path\n\t\t\t\tconst parts = options.mount.trim().split(\" \");\n\t\t\t\tconst lastPart = parts[parts.length - 1];\n\t\t\t\tif (lastPart?.startsWith(\"/\")) {\n\t\t\t\t\toptions.modelsPath = lastPart;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait setupPod(name, sshCmd, options);\n\t\t} else if (subcommand === \"active\") {\n\t\t\t// pi pods active <name>\n\t\t\tconst name = args[2];\n\t\t\tif (!name) {\n\t\t\t\tconsole.error(\"Usage: pi pods active <name>\");\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\tswitchActivePod(name);\n\t\t} else if (subcommand === \"remove\") {\n\t\t\t// pi pods remove <name>\n\t\t\tconst name = args[2];\n\t\t\tif (!name) {\n\t\t\t\tconsole.error(\"Usage: pi pods remove <name>\");\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\tremovePodCommand(name);\n\t\t} else {\n\t\t\tconsole.error(`Unknown pods subcommand: ${subcommand}`);\n\t\t\tprocess.exit(1);\n\t\t}\n\t} else {\n\t\t// Parse --pod override for model commands\n\t\tlet podOverride: string | undefined;\n\t\tconst podIndex = args.indexOf(\"--pod\");\n\t\tif (podIndex !== -1 && podIndex + 1 < args.length) {\n\t\t\tpodOverride = args[podIndex + 1];\n\t\t\t// Remove --pod and its value from args\n\t\t\targs.splice(podIndex, 2);\n\t\t}\n\n\t\t// Handle SSH/shell commands and model commands\n\t\tswitch (command) {\n\t\t\tcase \"shell\": {\n\t\t\t\t// pi shell [<name>] - open interactive shell\n\t\t\t\tconst podName = args[1];\n\t\t\t\tlet podInfo: { name: string; pod: import(\"./types.js\").Pod } | null = null;\n\n\t\t\t\tif (podName) {\n\t\t\t\t\tconst config = loadConfig();\n\t\t\t\t\tconst pod = config.pods[podName];\n\t\t\t\t\tif (pod) {\n\t\t\t\t\t\tpodInfo = { name: podName, pod };\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tpodInfo = getActivePod();\n\t\t\t\t}\n\n\t\t\t\tif (!podInfo) {\n\t\t\t\t\tif (podName) {\n\t\t\t\t\t\tconsole.error(chalk.red(`Pod '${podName}' not found`));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.error(chalk.red(\"No active pod. Use 'pi pods active <name>' to set one.\"));\n\t\t\t\t\t}\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\tconsole.log(chalk.green(`Connecting to pod '${podInfo.name}'...`));\n\n\t\t\t\t// Execute SSH in interactive mode\n\t\t\t\tconst sshArgs = podInfo.pod.ssh.split(\" \").slice(1); // Remove 'ssh' from command\n\t\t\t\tconst sshProcess = spawn(\"ssh\", sshArgs, {\n\t\t\t\t\tstdio: \"inherit\",\n\t\t\t\t\tenv: process.env,\n\t\t\t\t});\n\n\t\t\t\tsshProcess.on(\"exit\", (code) => {\n\t\t\t\t\tprocess.exit(code || 0);\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"ssh\": {\n\t\t\t\t// pi ssh [<name>] \"<command>\" - run command via SSH\n\t\t\t\tlet podName: string | undefined;\n\t\t\t\tlet sshCommand: string;\n\n\t\t\t\tif (args.length === 2) {\n\t\t\t\t\t// pi ssh \"<command>\" - use active pod\n\t\t\t\t\tsshCommand = args[1];\n\t\t\t\t} else if (args.length === 3) {\n\t\t\t\t\t// pi ssh <name> \"<command>\"\n\t\t\t\t\tpodName = args[1];\n\t\t\t\t\tsshCommand = args[2];\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error('Usage: pi ssh [<name>] \"<command>\"');\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\tlet podInfo: { name: string; pod: import(\"./types.js\").Pod } | null = null;\n\n\t\t\t\tif (podName) {\n\t\t\t\t\tconst config = loadConfig();\n\t\t\t\t\tconst pod = config.pods[podName];\n\t\t\t\t\tif (pod) {\n\t\t\t\t\t\tpodInfo = { name: podName, pod };\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tpodInfo = getActivePod();\n\t\t\t\t}\n\n\t\t\t\tif (!podInfo) {\n\t\t\t\t\tif (podName) {\n\t\t\t\t\t\tconsole.error(chalk.red(`Pod '${podName}' not found`));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.error(chalk.red(\"No active pod. Use 'pi pods active <name>' to set one.\"));\n\t\t\t\t\t}\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\tconsole.log(chalk.gray(`Running on pod '${podInfo.name}': ${sshCommand}`));\n\n\t\t\t\t// Execute command and stream output\n\t\t\t\tconst exitCode = await sshExecStream(podInfo.pod.ssh, sshCommand);\n\t\t\t\tprocess.exit(exitCode);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"start\": {\n\t\t\t\t// pi start <model> --name <name> [options]\n\t\t\t\tconst modelId = args[1];\n\t\t\t\tif (!modelId) {\n\t\t\t\t\t// Show available models\n\t\t\t\t\tawait showKnownModels();\n\t\t\t\t\tprocess.exit(0);\n\t\t\t\t}\n\n\t\t\t\t// Parse options\n\t\t\t\tlet name: string | undefined;\n\t\t\t\tlet memory: string | undefined;\n\t\t\t\tlet context: string | undefined;\n\t\t\t\tlet gpus: number | undefined;\n\t\t\t\tconst vllmArgs: string[] = [];\n\t\t\t\tlet inVllmArgs = false;\n\n\t\t\t\tfor (let i = 2; i < args.length; i++) {\n\t\t\t\t\tif (inVllmArgs) {\n\t\t\t\t\t\tvllmArgs.push(args[i]);\n\t\t\t\t\t} else if (args[i] === \"--name\" && i + 1 < args.length) {\n\t\t\t\t\t\tname = args[i + 1];\n\t\t\t\t\t\ti++;\n\t\t\t\t\t} else if (args[i] === \"--memory\" && i + 1 < args.length) {\n\t\t\t\t\t\tmemory = args[i + 1];\n\t\t\t\t\t\ti++;\n\t\t\t\t\t} else if (args[i] === \"--context\" && i + 1 < args.length) {\n\t\t\t\t\t\tcontext = args[i + 1];\n\t\t\t\t\t\ti++;\n\t\t\t\t\t} else if (args[i] === \"--gpus\" && i + 1 < args.length) {\n\t\t\t\t\t\tgpus = parseInt(args[i + 1], 10);\n\t\t\t\t\t\tif (Number.isNaN(gpus) || gpus < 1) {\n\t\t\t\t\t\t\tconsole.error(chalk.red(\"--gpus must be a positive number\"));\n\t\t\t\t\t\t\tprocess.exit(1);\n\t\t\t\t\t\t}\n\t\t\t\t\t\ti++;\n\t\t\t\t\t} else if (args[i] === \"--vllm\") {\n\t\t\t\t\t\tinVllmArgs = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!name) {\n\t\t\t\t\tconsole.error(\"--name is required\");\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\t// Warn if --vllm is used with other parameters\n\t\t\t\tif (vllmArgs.length > 0 && (memory || context || gpus)) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\tchalk.yellow(\"⚠ Warning: --memory, --context, and --gpus are ignored when --vllm is specified\"),\n\t\t\t\t\t);\n\t\t\t\t\tconsole.log(chalk.yellow(\" Using only custom vLLM arguments\"));\n\t\t\t\t\tconsole.log(\"\");\n\t\t\t\t}\n\n\t\t\t\tawait startModel(modelId, name, {\n\t\t\t\t\tpod: podOverride,\n\t\t\t\t\tmemory,\n\t\t\t\t\tcontext,\n\t\t\t\t\tgpus,\n\t\t\t\t\tvllmArgs: vllmArgs.length > 0 ? vllmArgs : undefined,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"stop\": {\n\t\t\t\t// pi stop [name] - stop specific model or all models\n\t\t\t\tconst name = args[1];\n\t\t\t\tif (!name) {\n\t\t\t\t\t// Stop all models on the active pod\n\t\t\t\t\tawait stopAllModels({ pod: podOverride });\n\t\t\t\t} else {\n\t\t\t\t\tawait stopModel(name, { pod: podOverride });\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"list\":\n\t\t\t\t// pi list\n\t\t\t\tawait listModels({ pod: podOverride });\n\t\t\t\tbreak;\n\t\t\tcase \"logs\": {\n\t\t\t\t// pi logs <name>\n\t\t\t\tconst name = args[1];\n\t\t\t\tif (!name) {\n\t\t\t\t\tconsole.error(\"Usage: pi logs <name>\");\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\t\t\t\tawait viewLogs(name, { pod: podOverride });\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"agent\": {\n\t\t\t\t// pi agent <name> [messages...] [options]\n\t\t\t\tconst name = args[1];\n\t\t\t\tif (!name) {\n\t\t\t\t\tconsole.error(\"Usage: pi agent <name> [messages...] [options]\");\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\tconst apiKey = process.env.PI_API_KEY;\n\n\t\t\t\t// Pass all args after the model name\n\t\t\t\tconst agentArgs = args.slice(2);\n\n\t\t\t\t// If no messages provided, it's interactive mode\n\t\t\t\tawait promptModel(name, agentArgs, {\n\t\t\t\t\tpod: podOverride,\n\t\t\t\t\tapiKey,\n\t\t\t\t}).catch(() => {\n\t\t\t\t\t// Error already handled in promptModel, just exit cleanly\n\t\t\t\t\tprocess.exit(0);\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tconsole.error(`Unknown command: ${command}`);\n\t\t\t\tprintHelp();\n\t\t\t\tprocess.exit(1);\n\t\t}\n\t}\n} catch (error) {\n\tconsole.error(\"Error:\", error);\n\tprocess.exit(1);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draht/pods",
|
|
3
|
-
"version": "2026.4.
|
|
3
|
+
"version": "2026.4.25",
|
|
4
4
|
"description": "CLI tool for managing vLLM deployments on GPU pods",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"node": ">=20.0.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@draht/agent-core": "
|
|
36
|
+
"@draht/agent-core": "workspace:*",
|
|
37
37
|
"chalk": "^5.5.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {}
|