computesdk 1.8.7 → 1.9.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/README.md CHANGED
@@ -22,7 +22,8 @@
22
22
  ComputeSDK is a free and open-source toolkit for running other people's code in your applications. Think of it as the "AI SDK for compute" - providing a consistent TypeScript interface whether you're using Blaxel, E2B, Vercel, or Daytona.
23
23
 
24
24
  **Why ComputeSDK?**
25
- - 🔄 **Provider-agnostic** - Switch between Blaxel, E2B, Vercel, Daytona and more (coming soon) without code changes
25
+ - 🔄 **Provider-agnostic** - Switch between Blaxel, E2B, Vercel, Daytona, Modal, CodeSandbox and more without code changes
26
+ - ⚡ **Zero-config mode** - Auto-detect provider from environment variables
26
27
  - 🛡️ **Security-first** - Isolated sandboxes protect your infrastructure
27
28
  - ⚡ **Developer experience** - Simple, TypeScript-native API
28
29
  - 🌍 **Production-ready** - Used by teams building the next generation of developer tools
@@ -36,10 +37,12 @@ ComputeSDK is a free and open-source toolkit for running other people's code in
36
37
 
37
38
  ## Features
38
39
 
39
- - 🚀 **Multi-provider support** - Blaxel, E2B, Vercel, Daytona
40
+ - 🚀 **Multi-provider support** - Blaxel, E2B, Vercel, Daytona, Modal, CodeSandbox
41
+ - ⚡ **Zero-config mode** - Auto-detect provider from environment variables
40
42
  - 📁 **Filesystem operations** - Read, write, create directories across providers
41
- - 🖥️ **Terminal support** - Interactive PTY terminals (E2B)
42
- - ⚡ **Command execution** - Run shell commands directly
43
+ - 🖥️ **Terminal support** - Interactive PTY terminals with exec mode
44
+ - ⚡ **Command execution** - Run shell commands with PTY or exec mode
45
+ - 🔧 **Type-safe commands** - Build shell commands with `@computesdk/cmd`
43
46
  - 🛡️ **Type-safe** - Full TypeScript support with comprehensive error handling
44
47
  - 📦 **Modular** - Install only the providers you need
45
48
  - 🔧 **Extensible** - Easy to add custom providers
@@ -55,8 +58,10 @@ npm install computesdk
55
58
  # Add your preferred provider
56
59
  npm install @computesdk/blaxel # For AI-powered code execution
57
60
  npm install @computesdk/e2b # For data science and Python
58
- npm install @computesdk/vercel # For web-scale Node.js/Python
61
+ npm install @computesdk/vercel # For web-scale Node.js/Python
59
62
  npm install @computesdk/daytona # For development workspaces
63
+ npm install @computesdk/modal # For GPU-accelerated Python workloads
64
+ npm install @computesdk/codesandbox # For collaborative sandboxes
60
65
 
61
66
  # Frontend integration (optional)
62
67
  npm install @computesdk/ui # React hooks and utilities
@@ -70,6 +75,8 @@ export BLAXEL_WORKSPACE=your_workspace
70
75
  # or E2B_API_KEY=your_api_key
71
76
  # or VERCEL_TOKEN=your_token
72
77
  # or DAYTONA_API_KEY=your_key
78
+ # or MODAL_TOKEN_ID=your_token_id and MODAL_TOKEN_SECRET=your_token_secret
79
+ # or CODESANDBOX_TOKEN=your_token
73
80
  ```
74
81
 
75
82
  ## Quick Start
@@ -79,15 +86,15 @@ import { compute } from 'computesdk';
79
86
  import { blaxel } from '@computesdk/blaxel';
80
87
 
81
88
  // Set default provider
82
- compute.setConfig({
83
- provider: blaxel({
89
+ compute.setConfig({
90
+ provider: blaxel({
84
91
  apiKey: process.env.BLAXEL_API_KEY,
85
92
  workspace: process.env.BLAXEL_WORKSPACE
86
- })
93
+ })
87
94
  });
88
95
 
89
96
  // Create a sandbox
90
- const sandbox = await compute.sandbox.create({});
97
+ const sandbox = await compute.sandbox.create();
91
98
 
92
99
  // Execute code
93
100
  const result = await sandbox.runCode('print("Hello World!")');
@@ -97,6 +104,37 @@ console.log(result.stdout); // "Hello World!"
97
104
  await compute.sandbox.destroy(sandbox.sandboxId);
98
105
  ```
99
106
 
107
+ ## Zero-Config Mode
108
+
109
+ ComputeSDK can automatically detect and configure your provider from environment variables:
110
+
111
+ ```bash
112
+ # Set your ComputeSDK API key
113
+ export COMPUTESDK_API_KEY=your_computesdk_api_key
114
+
115
+ # Set credentials for your provider (auto-detected)
116
+ export E2B_API_KEY=your_e2b_key
117
+ # or export DAYTONA_API_KEY=your_daytona_key
118
+ # or export MODAL_TOKEN_ID=xxx MODAL_TOKEN_SECRET=xxx
119
+ ```
120
+
121
+ ```typescript
122
+ import { compute } from 'computesdk';
123
+
124
+ // No provider configuration needed - auto-detected from environment!
125
+ const sandbox = await compute.sandbox.create();
126
+ const result = await sandbox.runCode('print("Hello World!")');
127
+ console.log(result.stdout);
128
+ ```
129
+
130
+ Provider detection order: E2B → Railway → Daytona → Modal → Runloop → Vercel → Cloudflare → CodeSandbox → Blaxel
131
+
132
+ You can also explicitly set the provider:
133
+
134
+ ```bash
135
+ export COMPUTESDK_PROVIDER=e2b
136
+ ```
137
+
100
138
  ## Provider Setup
101
139
 
102
140
  ### Blaxel - AI-Powered Code Execution
@@ -119,7 +157,7 @@ compute.setConfig({
119
157
  })
120
158
  });
121
159
 
122
- const sandbox = await compute.sandbox.create({});
160
+ const sandbox = await compute.sandbox.create();
123
161
 
124
162
  // Execute code with AI assistance
125
163
  const result = await sandbox.runCode(`
@@ -149,7 +187,7 @@ compute.setConfig({
149
187
  provider: e2b({ apiKey: process.env.E2B_API_KEY })
150
188
  });
151
189
 
152
- const sandbox = await compute.sandbox.create({});
190
+ const sandbox = await compute.sandbox.create();
153
191
 
154
192
  // Execute Python with data science libraries
155
193
  const result = await sandbox.runCode(`
@@ -192,7 +230,7 @@ compute.setConfig({
192
230
  provider: vercel({ runtime: 'node' })
193
231
  });
194
232
 
195
- const sandbox = await compute.sandbox.create({});
233
+ const sandbox = await compute.sandbox.create();
196
234
 
197
235
  // Execute Node.js or Python
198
236
  const result = await sandbox.runCode(`
@@ -220,7 +258,7 @@ compute.setConfig({
220
258
  provider: daytona({ apiKey: process.env.DAYTONA_API_KEY })
221
259
  });
222
260
 
223
- const sandbox = await compute.sandbox.create({});
261
+ const sandbox = await compute.sandbox.create();
224
262
 
225
263
  // Execute in development workspace
226
264
  const result = await sandbox.runCode(`
@@ -424,7 +462,7 @@ function CodeExecutor() {
424
462
 
425
463
  ```typescript
426
464
  try {
427
- const sandbox = await compute.sandbox.create({});
465
+ const sandbox = await compute.sandbox.create();
428
466
  const result = await sandbox.runCode('invalid code');
429
467
  } catch (error) {
430
468
  console.error('Execution failed:', error.message);
@@ -441,7 +479,7 @@ import { e2b } from '@computesdk/e2b';
441
479
 
442
480
  compute.setConfig({ provider: e2b({ apiKey: process.env.E2B_API_KEY }) });
443
481
 
444
- const sandbox = await compute.sandbox.create({});
482
+ const sandbox = await compute.sandbox.create();
445
483
 
446
484
  // Create project structure
447
485
  await sandbox.filesystem.mkdir('/analysis');
@@ -512,7 +550,7 @@ import { daytona } from '@computesdk/daytona';
512
550
  async function processData(provider: any) {
513
551
  compute.setConfig({ provider });
514
552
 
515
- const sandbox = await compute.sandbox.create({});
553
+ const sandbox = await compute.sandbox.create();
516
554
 
517
555
  // Create workspace
518
556
  await sandbox.filesystem.mkdir('/workspace');
@@ -565,13 +603,56 @@ console.log('Daytona result:', daytonaResult);
565
603
  ComputeSDK uses separate provider packages:
566
604
 
567
605
  ```bash
606
+ npm install @computesdk/blaxel # Blaxel provider
568
607
  npm install @computesdk/e2b # E2B provider
569
- npm install @computesdk/vercel # Vercel provider
608
+ npm install @computesdk/vercel # Vercel provider
570
609
  npm install @computesdk/daytona # Daytona provider
610
+ npm install @computesdk/modal # Modal provider
611
+ npm install @computesdk/codesandbox # CodeSandbox provider
571
612
  ```
572
613
 
573
614
  Each provider implements the same interface but may support different capabilities (filesystem, terminal, etc.).
574
615
 
616
+ ## Utility Packages
617
+
618
+ Additional packages for enhanced functionality:
619
+
620
+ ```bash
621
+ npm install @computesdk/cmd # Type-safe shell command builders
622
+ npm install @computesdk/client # Universal sandbox client (browser/Node.js)
623
+ npm install @computesdk/events # Event storage and real-time streaming
624
+ npm install @computesdk/workbench # Interactive REPL for sandbox testing
625
+ ```
626
+
627
+ ### @computesdk/cmd - Type-Safe Commands
628
+
629
+ Build shell commands with full TypeScript support:
630
+
631
+ ```typescript
632
+ import { npm, git, mkdir, cmd } from '@computesdk/cmd';
633
+
634
+ // Type-safe command builders
635
+ await sandbox.runCommand(npm.install('express'));
636
+ await sandbox.runCommand(git.clone('https://github.com/user/repo'));
637
+ await sandbox.runCommand(mkdir('/app/src'));
638
+
639
+ // With options
640
+ await sandbox.runCommand(cmd(npm.run('dev'), { cwd: '/app', background: true }));
641
+ ```
642
+
643
+ ### @computesdk/workbench - Interactive REPL
644
+
645
+ Test sandbox operations interactively:
646
+
647
+ ```bash
648
+ npx workbench
649
+
650
+ # Commands autocomplete!
651
+ workbench> npm.install('express')
652
+ workbench> git.clone('https://github.com/user/repo')
653
+ workbench> ls('/home')
654
+ ```
655
+
575
656
  ## Custom Providers
576
657
 
577
658
  Create custom providers using the factory: