@computesdk/codesandbox 1.5.46 → 1.5.47

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.
Files changed (2) hide show
  1. package/README.md +12 -71
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -19,60 +19,10 @@ export CSB_API_KEY=your_api_key_here
19
19
 
20
20
  ## Quick Start
21
21
 
22
- ### Gateway Mode (Recommended)
23
-
24
- Use the gateway for zero-config auto-detection:
25
-
26
- ```typescript
27
- import { compute } from 'computesdk';
28
-
29
- // Auto-detects CodeSandbox from CSB_API_KEY environment variable
30
- const sandbox = await compute.sandbox.create();
31
-
32
- // Execute JavaScript/Node.js code
33
- const result = await sandbox.runCommand(`node - <<'JS'
34
- const message = "Hello from CodeSandbox!";
35
- console.log(message);
36
-
37
- const data = { users: 3, tasks: 15 };
38
- console.log(JSON.stringify(data, null, 2));
39
- JS`);
40
-
41
- console.log(result.stdout);
42
- // Output:
43
- // Hello from CodeSandbox!
44
- // {
45
- // "users": 3,
46
- // "tasks": 15
47
- // }
48
-
49
- // Execute Python code
50
- const pythonResult = await sandbox.runCommand(`python - <<'PY'
51
- import json
52
- data = {"framework": "CodeSandbox", "language": "Python"}
53
- print(json.dumps(data, indent=2))
54
- print(f"Running in: {data['framework']}")
55
- PY`);
56
-
57
- console.log(pythonResult.stdout);
58
- // Output:
59
- // {
60
- // "framework": "CodeSandbox",
61
- // "language": "Python"
62
- // }
63
- // Running in: CodeSandbox
64
-
65
- await sandbox.destroy();
66
- ```
67
-
68
- ### Direct Mode
69
-
70
- For direct SDK usage without the gateway:
71
-
72
22
  ```typescript
73
23
  import { codesandbox } from '@computesdk/codesandbox';
74
24
 
75
- const compute = codesandbox({
25
+ const compute = codesandbox({
76
26
  apiKey: process.env.CSB_API_KEY,
77
27
  templateId: 'universal', // Optional: specify template
78
28
  timeout: 600000 // 10 minutes
@@ -102,8 +52,8 @@ interface CodesandboxConfig {
102
52
  apiKey?: string;
103
53
  /** Template to use for new sandboxes (defaults to universal template) */
104
54
  templateId?: string;
105
- /** Default runtime environment */
106
- runtime?: 'python' | 'node';
55
+ /** Default runtime environment (e.g. 'node', 'python') */
56
+ runtime?: string;
107
57
  /** Execution timeout in milliseconds */
108
58
  timeout?: number;
109
59
  }
@@ -111,28 +61,26 @@ interface CodesandboxConfig {
111
61
 
112
62
  ## Features
113
63
 
114
- - ✅ **Code Execution** - Python and Node.js runtime support
115
64
  - ✅ **Command Execution** - Run shell commands in sandbox
116
65
  - ✅ **Filesystem Operations** - Full file system access via CodeSandbox API
117
66
  - ✅ **Template Support** - Create sandboxes from custom templates
118
- - ✅ **Auto Runtime Detection** - Automatically detects Python vs Node.js
119
67
  - ✅ **Development Environment** - Full development setup with package managers
120
68
  - ✅ **Persistence** - Files persist across hibernation/resume cycles
121
69
  - ✅ **Snapshot/Resume** - Fast sandbox restoration from snapshots
122
70
 
123
71
  ## API Reference
124
72
 
125
- ### Code Execution
73
+ ### Command Execution
126
74
 
127
75
  ```typescript
128
- // Execute Node.js code
76
+ // Run Node.js code via heredoc
129
77
  const result = await sandbox.runCommand(`node - <<'JS'
130
78
  const fs = require('fs');
131
79
  const data = { timestamp: Date.now() };
132
80
  console.log('Processing data:', JSON.stringify(data));
133
81
  JS`);
134
82
 
135
- // Execute Python code
83
+ // Run Python code via heredoc
136
84
  const result = await sandbox.runCommand(`python - <<'PY'
137
85
  import datetime
138
86
  import json
@@ -141,24 +89,17 @@ data = {'timestamp': datetime.datetime.now().isoformat()}
141
89
  print('Processing data:', json.dumps(data))
142
90
  PY`);
143
91
 
144
- // Auto-detection (based on code patterns)
145
- const result = await sandbox.runCommand('python -c "print(\"Auto-detected as Python\")"');
146
- ```
147
-
148
- ### Command Execution
149
-
150
- ```typescript
151
92
  // List files
152
- const result = await sandbox.runCommand('ls', ['-la']);
93
+ const result = await sandbox.runCommand('ls -la');
153
94
 
154
95
  // Install Node.js packages
155
- const result = await sandbox.runCommand('npm', ['install', 'lodash']);
96
+ const result = await sandbox.runCommand('npm install lodash');
156
97
 
157
98
  // Install Python packages
158
- const result = await sandbox.runCommand('pip', ['install', 'requests']);
99
+ const result = await sandbox.runCommand('pip install requests');
159
100
 
160
101
  // Run development server
161
- const result = await sandbox.runCommand('npm', ['run', 'dev']);
102
+ const result = await sandbox.runCommand('npm run dev');
162
103
  ```
163
104
 
164
105
  ### Filesystem Operations
@@ -202,10 +143,10 @@ const info = await sandbox.getInfo();
202
143
  console.log(info.id, info.provider, info.status);
203
144
 
204
145
  // Resume existing sandbox
205
- const existing = await compute.sandbox.getById(provider, 'sandbox-id');
146
+ const existing = await compute.sandbox.getById('sandbox-id');
206
147
 
207
148
  // Hibernate sandbox (saves state)
208
- await compute.sandbox.destroy(provider, 'sandbox-id'); // Actually hibernates
149
+ await compute.sandbox.destroy('sandbox-id'); // Actually hibernates
209
150
 
210
151
  // Note: CodeSandbox doesn't support listing all sandboxes
211
152
  // Each sandbox is managed individually
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@computesdk/codesandbox",
3
- "version": "1.5.46",
3
+ "version": "1.5.47",
4
4
  "description": "CodeSandbox provider for ComputeSDK - fast browser-compatible sandboxes with npm and Python support",
5
5
  "author": "Garrison",
6
6
  "license": "MIT",
@@ -19,8 +19,8 @@
19
19
  ],
20
20
  "dependencies": {
21
21
  "@codesandbox/sdk": "^2.4.2",
22
- "@computesdk/provider": "2.0.0",
23
- "computesdk": "4.0.0"
22
+ "@computesdk/provider": "2.1.0",
23
+ "computesdk": "4.1.0"
24
24
  },
25
25
  "keywords": [
26
26
  "computesdk",