@computesdk/blaxel 1.6.11 → 1.6.12
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 +12 -56
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -10,27 +10,6 @@ npm install @computesdk/blaxel
|
|
|
10
10
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
13
|
-
### Gateway Mode (Recommended)
|
|
14
|
-
|
|
15
|
-
Use the gateway for zero-config auto-detection:
|
|
16
|
-
|
|
17
|
-
```typescript
|
|
18
|
-
import { compute } from 'computesdk';
|
|
19
|
-
|
|
20
|
-
// Auto-detects Blaxel from BL_WORKSPACE/BL_API_KEY environment variables
|
|
21
|
-
const sandbox = await compute.sandbox.create();
|
|
22
|
-
|
|
23
|
-
// Execute command
|
|
24
|
-
const result = await sandbox.runCommand('node -e "console.log(\"Hello from Blaxel!\")"');
|
|
25
|
-
console.log(result.stdout); // "Hello from Blaxel!"
|
|
26
|
-
|
|
27
|
-
await sandbox.destroy();
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### Direct Mode
|
|
31
|
-
|
|
32
|
-
For direct SDK usage without the gateway:
|
|
33
|
-
|
|
34
13
|
```typescript
|
|
35
14
|
import { blaxel } from '@computesdk/blaxel';
|
|
36
15
|
|
|
@@ -94,10 +73,8 @@ The provider automatically selects images based on runtime:
|
|
|
94
73
|
|
|
95
74
|
## Features
|
|
96
75
|
|
|
97
|
-
- ✅ **
|
|
98
|
-
- ✅ **Command Execution** - Run shell commands with background support
|
|
76
|
+
- ✅ **Command Execution** - Run shell commands with background support and stdout/stderr streaming
|
|
99
77
|
- ✅ **Filesystem Operations** - Full file system access (read, write, mkdir, ls, rm)
|
|
100
|
-
- ✅ **Auto Runtime Detection** - Automatically detects Python vs Node.js from code patterns
|
|
101
78
|
- ✅ **Custom Images** - Support for custom Docker images
|
|
102
79
|
- ✅ **Memory Configuration** - Configurable memory allocation
|
|
103
80
|
- ✅ **Preview URLs** - Public/private preview URLs with TTL, custom domains, and headers
|
|
@@ -110,37 +87,30 @@ The provider automatically selects images based on runtime:
|
|
|
110
87
|
|
|
111
88
|
## API Reference
|
|
112
89
|
|
|
113
|
-
###
|
|
90
|
+
### Command Execution
|
|
114
91
|
|
|
115
92
|
```typescript
|
|
116
|
-
//
|
|
93
|
+
// Run Python code via heredoc
|
|
117
94
|
const result = await sandbox.runCommand(`python - <<'PY'
|
|
118
95
|
import json
|
|
119
96
|
data = {"message": "Hello from Python"}
|
|
120
97
|
print(json.dumps(data))
|
|
121
98
|
PY`);
|
|
122
99
|
|
|
123
|
-
//
|
|
100
|
+
// Run Node.js code via heredoc
|
|
124
101
|
const result = await sandbox.runCommand(`node - <<'JS'
|
|
125
102
|
const data = { message: "Hello from Node.js" };
|
|
126
103
|
console.log(JSON.stringify(data));
|
|
127
104
|
JS`);
|
|
128
105
|
|
|
129
|
-
// Auto-detection (based on code patterns)
|
|
130
|
-
const result = await sandbox.runCommand('python -c "print(\"Auto-detected as Python\")"');
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
### Command Execution
|
|
134
|
-
|
|
135
|
-
```typescript
|
|
136
106
|
// List files
|
|
137
|
-
const result = await sandbox.runCommand('ls
|
|
107
|
+
const result = await sandbox.runCommand('ls -la');
|
|
138
108
|
|
|
139
109
|
// Install packages
|
|
140
|
-
const result = await sandbox.runCommand('pip
|
|
110
|
+
const result = await sandbox.runCommand('pip install requests');
|
|
141
111
|
|
|
142
112
|
// Run background process
|
|
143
|
-
const bgResult = await sandbox.runCommand('npm
|
|
113
|
+
const bgResult = await sandbox.runCommand('npm start', { background: true });
|
|
144
114
|
console.log('Process started in background');
|
|
145
115
|
```
|
|
146
116
|
|
|
@@ -174,13 +144,11 @@ await sandbox.filesystem.remove('/tmp/hello.py');
|
|
|
174
144
|
```typescript
|
|
175
145
|
// Get sandbox info
|
|
176
146
|
const info = await sandbox.getInfo();
|
|
177
|
-
console.log(info.id, info.provider, info.status
|
|
147
|
+
console.log(info.id, info.provider, info.status);
|
|
178
148
|
// Status: 'running', 'stopped', or 'error'
|
|
179
|
-
// Runtime: Automatically detected from image name
|
|
180
149
|
|
|
181
150
|
// Create with specific configuration
|
|
182
151
|
const sandbox = await provider.sandbox.create({
|
|
183
|
-
runtime: 'python', // Selects appropriate image
|
|
184
152
|
timeout: 1800000, // 30 minutes in milliseconds (converted to "1800s")
|
|
185
153
|
envs: { // Environment variables
|
|
186
154
|
API_KEY: 'secret-key',
|
|
@@ -316,9 +284,9 @@ const advancedUrl = await sandbox.getUrl({
|
|
|
316
284
|
> 📚 You can also [connect to sandboxes remotely from a terminal](https://docs.blaxel.ai/Sandboxes/Overview#connect-to-a-sandbox-with-a-terminal) for direct access
|
|
317
285
|
|
|
318
286
|
```typescript
|
|
319
|
-
import {
|
|
287
|
+
import { blaxel } from '@computesdk/blaxel';
|
|
320
288
|
|
|
321
|
-
const compute =
|
|
289
|
+
const compute = blaxel({
|
|
322
290
|
workspace: 'your-workspace',
|
|
323
291
|
apiKey: 'your-key',
|
|
324
292
|
memory: 4096,
|
|
@@ -356,18 +324,6 @@ const preview = await instance.previews.create({
|
|
|
356
324
|
});
|
|
357
325
|
```
|
|
358
326
|
|
|
359
|
-
## Runtime Detection
|
|
360
|
-
|
|
361
|
-
The provider automatically detects the runtime based on code patterns:
|
|
362
|
-
|
|
363
|
-
**Python indicators:**
|
|
364
|
-
- `print(` statements
|
|
365
|
-
- `import` statements
|
|
366
|
-
- `def` function definitions
|
|
367
|
-
- Python-specific syntax (`f"`, `f'`, `__`, `sys.`, `json.`)
|
|
368
|
-
|
|
369
|
-
**Default:** Node.js for all other cases
|
|
370
|
-
|
|
371
327
|
## Error Handling
|
|
372
328
|
|
|
373
329
|
```typescript
|
|
@@ -482,7 +438,7 @@ const compute = blaxel({
|
|
|
482
438
|
const sandbox = await compute.sandbox.create();
|
|
483
439
|
|
|
484
440
|
// Install dependencies
|
|
485
|
-
await sandbox.runCommand('pip
|
|
441
|
+
await sandbox.runCommand('pip install requests beautifulsoup4');
|
|
486
442
|
|
|
487
443
|
// Scrape website
|
|
488
444
|
const result = await sandbox.runCommand(`python - <<'PY'
|
|
@@ -542,7 +498,7 @@ server.listen(3000, () => {
|
|
|
542
498
|
`);
|
|
543
499
|
|
|
544
500
|
// Start server in background
|
|
545
|
-
await sandbox.runCommand('node
|
|
501
|
+
await sandbox.runCommand('node /tmp/server.js', { background: true });
|
|
546
502
|
|
|
547
503
|
// Get the preview URL (public by default)
|
|
548
504
|
const url = await sandbox.getUrl({ port: 3000 });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@computesdk/blaxel",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.12",
|
|
4
4
|
"description": "Blaxel provider for ComputeSDK - lightweight cloud sandboxes for code execution",
|
|
5
5
|
"author": "ComputeSDK",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@blaxel/core": "^0.2.75",
|
|
22
|
-
"@computesdk/provider": "2.
|
|
23
|
-
"computesdk": "4.
|
|
22
|
+
"@computesdk/provider": "2.1.0",
|
|
23
|
+
"computesdk": "4.1.0"
|
|
24
24
|
},
|
|
25
25
|
"keywords": [
|
|
26
26
|
"computesdk",
|