Runloop
Runloop provider for ComputeSDK - Execute code in cloud-based devboxes with full development environments.
Installation
Section titled “Installation”npm install @computesdk/runloopWith ComputeSDK
Section titled “With ComputeSDK”import { createCompute } from 'computesdk';
import { runloop } from '@computesdk/runloop';
// Set as default provider
const compute = createCompute({
provider: runloop({ apiKey: process.env.RUNLOOP_API_KEY }),
apiKey: process.env.COMPUTESDK_API_KEY
});
// Create devbox
const sandbox = await compute.sandbox.create();
// Get instance
const instance = sandbox.getInstance();
// Execute commands
const result = await sandbox.runCommand('python', ['-c', 'print("Hello from Runloop!")']);
console.log(result.stdout); // "Hello from Runloop!"
// Clean up
await compute.sandbox.destroy(sandbox.sandboxId);Configuration
Section titled “Configuration”Environment Variables
Section titled “Environment Variables”export RUNLOOP_API_KEY=your_runloop_api_key_hereConfiguration Options
Section titled “Configuration Options”interface RunloopConfig {
/** Runloop API key - if not provided, will use RUNLOOP_API_KEY env var */
apiKey?: string;
/** Execution timeout in milliseconds */
timeout?: number;
}Snapshot Management
Section titled “Snapshot Management”Create and restore devbox snapshots:
// Create snapshot of current devbox state
const snapshot = await compute.snapshot.create(sandbox.sandboxId, {
name: 'after-setup',
metadata: {
description: 'Devbox after initial setup and package installation',
packages: ['numpy', 'pandas', 'flask']
}
});
// Create new devbox from snapshot
const restoredSandbox = await compute.sandbox.create({
options: { templateId: snapshot.id }
});
// List all snapshots
const snapshots = await compute.snapshot.list();
// Delete snapshot
await compute.snapshot.delete(snapshot.id);SDK Reference Links:
Section titled “SDK Reference Links:”- Code Execution - Execute code snippets in various runtimes
- Command Execution - Run shell commands and scripts
- Filesystem Operations - Read, write, and manage files in sandboxes
- Sandbox Management - Create, list, and destroy sandboxes
- Error Handling - Handle command failures and runtime errors
- Web Framework Integration - Integrate with Express, Next.js, and other frameworks