@computesdk/vercel 1.6.7 → 1.6.8

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 +50 -49
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -35,20 +35,16 @@ export VERCEL_PROJECT_ID=your_project_id_here
35
35
 
36
36
  Get your token from [Vercel Account Tokens](https://vercel.com/account/tokens)
37
37
 
38
- ## Usage
38
+ ## Quick Start
39
39
 
40
- ### With ComputeSDK
40
+ ### Gateway Mode (Recommended)
41
41
 
42
- ```typescript
43
- import { createCompute } from 'computesdk';
44
- import { vercel } from '@computesdk/vercel';
42
+ Use the gateway for zero-config auto-detection:
45
43
 
46
- // Set as default provider
47
- const compute = createCompute({
48
- provider: vercel({ runtime: 'node' })
49
- });
44
+ ```typescript
45
+ import { compute } from 'computesdk';
50
46
 
51
- // Create sandbox
47
+ // Auto-detects Vercel from VERCEL_OIDC_TOKEN or VERCEL_TOKEN environment variables
52
48
  const sandbox = await compute.sandbox.create();
53
49
 
54
50
  // Execute Node.js code
@@ -59,26 +55,30 @@ console.log(result.stdout); // "Hello from Vercel!"
59
55
  const pythonResult = await sandbox.runCode('print("Hello from Python!")', 'python');
60
56
  console.log(pythonResult.stdout); // "Hello from Python!"
61
57
 
62
- // Clean up
63
- await compute.sandbox.destroy(sandbox.sandboxId);
58
+ await sandbox.destroy();
64
59
  ```
65
60
 
66
- ### Direct Usage
61
+ ### Direct Mode
62
+
63
+ For direct SDK usage without the gateway:
67
64
 
68
65
  ```typescript
69
66
  import { vercel } from '@computesdk/vercel';
70
67
 
71
- // Create provider with explicit config
72
- const provider = vercel({
73
- token: 'your-token',
74
- teamId: 'your-team-id',
75
- projectId: 'your-project-id',
68
+ const compute = vercel({
69
+ token: process.env.VERCEL_TOKEN,
70
+ teamId: process.env.VERCEL_TEAM_ID,
71
+ projectId: process.env.VERCEL_PROJECT_ID,
76
72
  runtime: 'python',
77
73
  timeout: 600000 // 10 minutes
78
74
  });
79
75
 
80
- // Use with compute singleton
81
- const sandbox = await compute.sandbox.create({ provider });
76
+ const sandbox = await compute.sandbox.create();
77
+
78
+ const result = await sandbox.runCode('console.log("Hello from Vercel!");');
79
+ console.log(result.stdout);
80
+
81
+ await sandbox.destroy();
82
82
  ```
83
83
 
84
84
  ## Configuration
@@ -215,7 +215,16 @@ The provider automatically detects the runtime based on code patterns:
215
215
  ## Error Handling
216
216
 
217
217
  ```typescript
218
+ import { vercel } from '@computesdk/vercel';
219
+
218
220
  try {
221
+ const compute = vercel({
222
+ token: process.env.VERCEL_TOKEN,
223
+ teamId: process.env.VERCEL_TEAM_ID,
224
+ projectId: process.env.VERCEL_PROJECT_ID
225
+ });
226
+ const sandbox = await compute.sandbox.create();
227
+
219
228
  const result = await sandbox.runCode('invalid code');
220
229
  } catch (error) {
221
230
  if (error.message.includes('Missing Vercel authentication')) {
@@ -230,30 +239,15 @@ try {
230
239
  }
231
240
  ```
232
241
 
233
- ## Web Framework Integration
234
-
235
- Use with web frameworks via the request handler:
236
-
237
- ```typescript
238
- import { handleComputeRequest } from 'computesdk';
239
- import { vercel } from '@computesdk/vercel';
240
-
241
- export async function POST(request: Request) {
242
- return handleComputeRequest({
243
- request,
244
- provider: vercel({ runtime: 'node' })
245
- });
246
- }
247
- ```
248
-
249
242
  ## Examples
250
243
 
251
244
  ### Node.js Web Server Simulation
252
245
 
253
246
  ```typescript
254
- const sandbox = await compute.sandbox.create({
255
- provider: vercel({ runtime: 'node' })
256
- });
247
+ import { vercel } from '@computesdk/vercel';
248
+
249
+ const compute = vercel({ runtime: 'node' });
250
+ const sandbox = await compute.sandbox.create();
257
251
 
258
252
  const result = await sandbox.runCode(`
259
253
  const http = require('http');
@@ -281,14 +275,16 @@ console.log('Response:', JSON.stringify(response, null, 2));
281
275
  `);
282
276
 
283
277
  console.log(result.stdout);
278
+ await sandbox.destroy();
284
279
  ```
285
280
 
286
281
  ### Python Data Processing
287
282
 
288
283
  ```typescript
289
- const sandbox = await compute.sandbox.create({
290
- provider: vercel({ runtime: 'python' })
291
- });
284
+ import { vercel } from '@computesdk/vercel';
285
+
286
+ const compute = vercel({ runtime: 'python' });
287
+ const sandbox = await compute.sandbox.create();
292
288
 
293
289
  const result = await sandbox.runCode(`
294
290
  import json
@@ -324,14 +320,16 @@ for product, revenue in sorted(product_sales.items(), key=lambda x: x[1], revers
324
320
  `);
325
321
 
326
322
  console.log(result.stdout);
323
+ await sandbox.destroy();
327
324
  ```
328
325
 
329
326
  ### Filesystem Operations Pipeline
330
327
 
331
328
  ```typescript
332
- const sandbox = await compute.sandbox.create({
333
- provider: vercel({ runtime: 'python' })
334
- });
329
+ import { vercel } from '@computesdk/vercel';
330
+
331
+ const compute = vercel({ runtime: 'python' });
332
+ const sandbox = await compute.sandbox.create();
335
333
 
336
334
  // Create project structure
337
335
  await sandbox.filesystem.mkdir('/tmp/project');
@@ -435,15 +433,17 @@ console.log('Generated files:');
435
433
  outputFiles.forEach(file => {
436
434
  console.log(` ${file.name} (${file.size} bytes)`);
437
435
  });
436
+
437
+ await sandbox.destroy();
438
438
  ```
439
439
 
440
440
  ### Package Installation and Usage
441
441
 
442
442
  ```typescript
443
- // Node.js example with package installation
444
- const sandbox = await compute.sandbox.create({
445
- provider: vercel({ runtime: 'node' })
446
- });
443
+ import { vercel } from '@computesdk/vercel';
444
+
445
+ const compute = vercel({ runtime: 'node' });
446
+ const sandbox = await compute.sandbox.create();
447
447
 
448
448
  // Install lodash
449
449
  const installResult = await sandbox.runCommand('npm', ['install', 'lodash']);
@@ -473,6 +473,7 @@ console.log('Oldest person:', oldest.name);
473
473
  `);
474
474
 
475
475
  console.log(result.stdout);
476
+ await sandbox.destroy();
476
477
  ```
477
478
 
478
479
  ## Best Practices
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@computesdk/vercel",
3
- "version": "1.6.7",
3
+ "version": "1.6.8",
4
4
  "description": "Vercel Sandbox provider for ComputeSDK - serverless code execution for Python and Node.js on Vercel's edge network",
5
5
  "author": "Garrison",
6
6
  "license": "MIT",
@@ -20,8 +20,8 @@
20
20
  "dependencies": {
21
21
  "@vercel/sandbox": "^0.0.13",
22
22
  "ms": "^2.1.3",
23
- "@computesdk/provider": "1.0.1",
24
- "computesdk": "1.10.1"
23
+ "@computesdk/provider": "1.0.2",
24
+ "computesdk": "1.10.2"
25
25
  },
26
26
  "keywords": [
27
27
  "computesdk",