Runtime Providers & Code Execution
Vendor-agnostic runtime layer that decouples Anvio from any single coding agent (Claude Code, Cursor, Codex, local models).
5 min read
This is a migrated reference document from the original Anvio source repo. Content is preserved as-is; canonical documentation lives in the sections above in the sidebar.
Original path: docs/30-runtime-providers.md
Vendor-agnostic runtime layer that decouples Anvio from any single coding agent (Claude Code, Cursor, Codex, local models).
RuntimeProvider Port
// packages/core/src/ports/runtime-provider.port.ts (planned)
interface RuntimeProvider {
readonly runtimeId: string; // claude-code | cursor | codex | local
capabilities(): RuntimeCapabilities;
run(request: RuntimeRequest): Promise<RuntimeResult>;
stream(request: RuntimeRequest): AsyncIterable<RuntimeStreamEvent>;
// Optional: editor-specific features
executeTool?(call: ToolCall): Promise<ToolResult>;
getWorkspaceContext?(): Promise<WorkspaceContext>;
}
interface RuntimeCapabilities {
supportsTools: boolean;
supportsStreaming: boolean;
supportsSubagents: boolean;
supportsMcp: boolean;
supportedLanguages: string[];
}Implementations
| Runtime | ID | Use Case |
|---|---|---|
| Claude Code Runtime | claude-code | Anthropic CLI agent |
| Cursor Runtime | cursor | Cursor agent via MCP/ACP |
| Codex Runtime | codex | OpenAI Codex CLI (codex exec) |
| Antigravity Runtime | antigravity | Google Antigravity CLI (agy -p) |
| Local Runtime | local | Direct model provider (default Level 1) |
Configuration
# workspace/anvio.yaml
spec:
runtime:
default: local
providers:
local:
enabled: true
cursor:
enabled: false
acp:
endpoint: http://localhost:8765
claude-code:
enabled: false
binary: claude
codex:
enabled: false
binary: codex
antigravity:
enabled: false
binary: agyAgent Runtime Binding
# workspace/agents/architect.yaml
spec:
runtime:
provider: cursor # Override default
fallback: local
model:
provider: anthropic
model: claude-sonnet-4-20250514Claude Code OAuth (subscription auth)
Claude Code runtime uses @anthropic-ai/claude-agent-sdk with OAuth — not ANTHROPIC_API_KEY. See ADR 0009.
# Unified vendor login (recommended)
anvio setup-token --claude
anvio setup-token --cursor
anvio setup-token --codex
anvio setup-token --antigravity
anvio setup-token --nous
anvio setup-token --list
# Per-user OAuth on one workspace
export ANVIO_CONNECTION_ENCRYPTION_KEY=your-secret
anvio setup-token --claude --user alice
anvio setup-token --codex --user bob
anvio setup-token --antigravity --user carol
# Verify runtime OAuth
anvio runtime test claude-code
anvio runtime test codex
anvio runtime test antigravity| Flag | Official CLI | Auth stored as |
|---|---|---|
--claude | claude setup-token | OAuth token (Pro/Max) |
--cursor | agent login | Cursor CLI session |
--codex | codex login | ~/.codex/auth.json snapshot |
--antigravity | agy auth login (auto-installs CLI if missing) | Google Sign-In / system keyring snapshot |
--nous | none (browser 1-click) — local OAuth callback host | Nous Portal access token (model + tools grant) |
Optional: --token TOKEN (claude/codex/antigravity/nous), --binary NAME (custom CLI path), --no-install (skip Antigravity auto-install).
Antigravity CLI: github.com/google-antigravity/antigravity-cli · antigravity.google/product/antigravity-cli
Nous Portal OAuth (1-click model + tools)
Unlike the other vendors, Nous Portal has no
official CLI — anvio setup-token --nous spins up a local OAuth callback host
(same primitive as anvio connect login-host) and prints an authorize URL to
open in a browser:
anvio setup-token --nous # prints authorize URL, waits for callback
anvio setup-token --nous --token TOKEN # headless — paste a token from the portal UI
ANVIO_NOUS_MOCK=1 anvio setup-token --nous # dev/test — synthetic token, no networkEnv: NOUS_PORTAL_URL (defaults to the public portal). The stored connection
(service: nous) currently gates access only — no nous model-provider row
in the routing catalog yet (see ROADMAP).
Agent binding:
spec:
runtime:
provider: claude-code # or cursor | codex | antigravity
fallbacks: [cursor, codex, local] # chain A → B → C (auth failover)
# fallback: local # shorthand single hopWhen fallback: local, the model block is used only if Claude Code OAuth is unavailable.
Server/Docker OAuth: see ADR 0009 — Docker, server, and headless OAuth.
Architecture
Sequence: Agent Run via Cursor Runtime
Code Execution Engine
Separate from agent runtime — executes code in controlled environments.
Supported Runtimes
| Runtime | Sandbox | Default |
|---|---|---|
| Shell | process limits | Yes |
| Python | subprocess + limits | Yes |
| Node.js | subprocess + limits | Yes |
| Go | subprocess + limits | Yes |
| Docker | container sandbox | Optional (Level 3) |
Execution Port
interface CodeExecutor {
execute(request: CodeExecutionRequest): Promise<CodeExecutionResult>;
}
interface CodeExecutionRequest {
runtime: 'shell' | 'python' | 'node' | 'go' | 'docker';
code: string;
cwd?: string;
env?: Record<string, string>;
timeoutMs: number;
memoryLimitMb?: number;
networkEnabled?: boolean;
}
interface CodeExecutionResult {
exitCode: number;
stdout: string;
stderr: string;
durationMs: number;
auditId: string;
}Security Requirements
| Control | Implementation |
|---|---|
| Sandboxing | Process isolation; Docker optional |
| Limits | CPU, memory, disk quotas |
| Timeouts | Hard kill after timeoutMs |
| Auditing | Every execution logged to workspace/audit/executions/ |
| Network | Disabled by default; opt-in per tool |
| Filesystem | Scoped to workspace or worktree |
Configuration
spec:
execution:
defaultTimeoutMs: 30000
maxMemoryMb: 512
networkEnabled: false
docker:
enabled: false
image: anvio/sandbox:latest
allowedRuntimes:
- shell
- python
- node
- goExtension Guide
Status (2026-10-25): items below that mention a plugin or plugin manifest describe design intent. Anvio has no plugin system (ROADMAP T-058); extending this subsystem today means changing the package code.
- Implement
RuntimeProviderfor new editor/agent CLIs - Register via plugin manifest (
type: runtime-provider) - Implement
CodeExecutorsandbox for new languages
Operational Runbook
| Scenario | Action |
|---|---|
| Switch runtime | Update agent YAML spec.runtime.provider |
| Debug ACP connection | anvio runtime test cursor |
| Audit executions | anvio audit executions --last 24h |
| Kill runaway process | anvio execution kill <auditId> |
Package Boundaries
- Runtime port:
packages/core/src/ports/runtime-provider.port.ts - Runtimes:
packages/runtimes/src/\{local,cursor,claude-code,codex\}/ - Execution:
packages/execution/src/code-executor.ts - Sandbox:
packages/execution/src/sandbox/
Design Constraint
No editor-specific logic in core. All Cursor/VS Code/Windsurf specifics live in packages/runtimes and packages/acp.
Last updated on