v0.2.0 · Open Source · MIT
One TypeScript interface. Five cloud providers.
Zero vendor lock-in.
Quick Start
pnpm add @sandbank.dev/core @sandbank.dev/daytonaimport { createProvider } from '@sandbank.dev/core'
import { DaytonaAdapter } from '@sandbank.dev/daytona'
const provider = createProvider(
new DaytonaAdapter({ apiKey: process.env.DAYTONA_API_KEY })
)
const sandbox = await provider.create({ image: 'node:22' })
const result = await sandbox.exec('echo "Hello from the sandbox"')
console.log(result.stdout) // Hello from the sandbox
await provider.destroy(sandbox.id)Adapters
Same interface. Swap with one line.
Provider Hot-Swap
// Switch from Daytona to Fly.io — zero code change
import { FlyioAdapter } from '@sandbank.dev/flyio'
const provider = createProvider(
new FlyioAdapter({
apiToken: process.env.FLY_API_TOKEN,
appName: 'my-sandbox-pool',
})
)
// Same API — create, exec, destroy
const sandbox = await provider.create({ image: 'python:3.12' })
await sandbox.exec('pip install numpy && python -c "import numpy; print(numpy.__version__)"')Capability Detection
import { withStreaming, withPortExpose, withSnapshot } from '@sandbank.dev/core'
// Check capabilities at runtime
if (provider.capabilities.has('port.expose')) {
const portSandbox = withPortExpose(sandbox)!
const { url } = await portSandbox.exposePort(3000)
console.log(`Preview: ${url}`)
}
// Safe narrowing — returns null if unsupported
const streamable = withStreaming(sandbox)
if (streamable) {
const stream = await streamable.execStream('tail -f /var/log/app.log')
}Service Layer
Serverless PostgreSQL for AI agents via db9.ai. Credentials auto-injected into sandboxes. Shared databases enable multi-agent memory, task coordination, and semantic search.
import { createProvider } from '@sandbank.dev/core'
import { DaytonaAdapter } from '@sandbank.dev/daytona'
import { Db9ServiceAdapter } from '@sandbank.dev/db9'
const compute = createProvider(new DaytonaAdapter({ apiKey: '...' }))
const db9 = new Db9ServiceAdapter({ token: process.env.DB9_TOKEN! })
// Create a database — credentials auto-injected into sandbox
const db = await db9.createService({ type: 'postgres', name: 'my-app' })
const sandbox = await compute.create({
image: 'node:22',
env: db.credentials.env, // DATABASE_URL, PGHOST, PGPORT, ...
})
await sandbox.exec('psql $DATABASE_URL -c "SELECT version()"')Service adapters implement ServiceProvider — a separate interface from compute adapters. Compute runs your code. Services provide the data layer.
Multi-Agent
import { createSession } from '@sandbank.dev/core'
const session = await createSession({
provider,
relay: { type: 'memory' },
})
const architect = await session.spawn('architect', { image: 'node:22' })
const developer = await session.spawn('developer', { image: 'node:22' })
// Shared context — visible to all sandboxes
await session.context.set('spec', {
endpoints: ['/users', '/posts'],
database: 'postgresql',
})
// Wait for all agents to complete
const results = await session.waitForAll()
console.log(results) // [{ name: 'architect', status: 'success' }, ...]Inside the Sandbox
// Code running inside the sandbox
import { connect } from '@sandbank.dev/agent'
const session = await connect() // auto-reads env vars
session.on('message', async (msg) => {
if (msg.type === 'task') {
const result = await executeTask(msg.payload)
await session.send(msg.from, 'task_result', result)
}
})
// Signal completion
await session.complete({ status: 'success', summary: 'Built 3 endpoints' })Packages
Service Layer