Sandbox session allocation broker for managing isolated execution environments.
Part of the Urule ecosystem — the open-source coordination layer for AI agents.
- Provider-based architecture -- pluggable runtime providers with a common
RuntimeProviderinterface - Session management -- allocate, query, and terminate sandbox sessions per workspace
- Task execution -- run commands inside allocated sessions with environment variables, timeouts, and working directories
- Capability discovery -- each provider declares its capabilities (GPU, browser, network, concurrency)
- Mock provider included for development and testing
- Fastify REST API with health check
npm install
npm run build
npm startOr for development with hot reload:
npm run devThe server starts on port 4500 by default.
curl -X POST http://localhost:4500/api/v1/sessions \
-H 'Content-Type: application/json' \
-d '{
"workspaceId": "ws-1",
"runtimeProfile": "node-20",
"provider": "mock"
}'curl http://localhost:4500/api/v1/sessions/SESSION_ID/statuscurl -X DELETE http://localhost:4500/api/v1/sessions/SESSION_IDcurl http://localhost:4500/api/v1/runtimes| Method | Path | Description |
|---|---|---|
POST |
/api/v1/sessions |
Allocate a new sandbox session |
GET |
/api/v1/sessions/:sessionId/status |
Get session status |
DELETE |
/api/v1/sessions/:sessionId |
Terminate a session |
GET |
/api/v1/runtimes |
List available runtime providers and their capabilities |
GET |
/healthz |
Health check |
Implement the RuntimeProvider interface and register it with the SessionManager:
import type { RuntimeProvider, SessionConfig, Session, Task, TaskResult, RuntimeCapabilities } from '@urule/runtime-broker';
export class DockerProvider implements RuntimeProvider {
readonly name = 'docker';
async createSession(config: SessionConfig): Promise<Session> {
// Spin up a Docker container for the workspace
}
async destroySession(sessionId: string): Promise<void> {
// Stop and remove the container
}
async executeTask(sessionId: string, task: Task): Promise<TaskResult> {
// Run a command inside the container
}
getCapabilities(): RuntimeCapabilities {
return {
hasGpu: false,
hasBrowser: true,
hasNetwork: true,
maxConcurrentTasks: 8,
};
}
}Then register it in server.ts:
sessionManager.registerProvider(new DockerProvider());| Type | Description |
|---|---|
RuntimeProvider |
Interface: createSession, destroySession, executeTask, getCapabilities |
SessionConfig |
{ workspaceId, runtimeProfile, env? } |
Session |
{ sessionId, status, createdAt } |
Task |
{ command, env?, timeout?, workdir? } |
TaskResult |
{ exitCode, stdout, stderr } |
RuntimeCapabilities |
{ hasGpu, hasBrowser, hasNetwork, maxConcurrentTasks } |
| Variable | Default | Description |
|---|---|---|
PORT |
4500 |
Server port |
NATS_URL |
nats://localhost:4222 |
NATS server URL |
REGISTRY_URL |
http://localhost:4400 |
Urule registry service URL |
See CONTRIBUTING.md for development setup and guidelines.
Apache-2.0