AAnvio
Reference ArchiveSource Docs

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

RuntimeIDUse Case
Claude Code Runtimeclaude-codeAnthropic CLI agent
Cursor RuntimecursorCursor agent via MCP/ACP
Codex RuntimecodexOpenAI Codex CLI (codex exec)
Antigravity RuntimeantigravityGoogle Antigravity CLI (agy -p)
Local RuntimelocalDirect 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: agy

Agent Runtime Binding

# workspace/agents/architect.yaml
spec:
  runtime:
    provider: cursor        # Override default
    fallback: local
  model:
    provider: anthropic
    model: claude-sonnet-4-20250514

Claude 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
FlagOfficial CLIAuth stored as
--claudeclaude setup-tokenOAuth token (Pro/Max)
--cursoragent loginCursor CLI session
--codexcodex login~/.codex/auth.json snapshot
--antigravityagy auth login (auto-installs CLI if missing)Google Sign-In / system keyring snapshot
--nousnone (browser 1-click) — local OAuth callback hostNous 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 network

Env: 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 hop

When 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

Rendering diagram…

Sequence: Agent Run via Cursor Runtime

Rendering diagram…

Code Execution Engine

Separate from agent runtime — executes code in controlled environments.

Supported Runtimes

RuntimeSandboxDefault
Shellprocess limitsYes
Pythonsubprocess + limitsYes
Node.jssubprocess + limitsYes
Gosubprocess + limitsYes
Dockercontainer sandboxOptional (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

ControlImplementation
SandboxingProcess isolation; Docker optional
LimitsCPU, memory, disk quotas
TimeoutsHard kill after timeoutMs
AuditingEvery execution logged to workspace/audit/executions/
NetworkDisabled by default; opt-in per tool
FilesystemScoped to workspace or worktree

Configuration

spec:
  execution:
    defaultTimeoutMs: 30000
    maxMemoryMb: 512
    networkEnabled: false
    docker:
      enabled: false
      image: anvio/sandbox:latest
    allowedRuntimes:
      - shell
      - python
      - node
      - go

Extension 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.

  1. Implement RuntimeProvider for new editor/agent CLIs
  2. Register via plugin manifest (type: runtime-provider)
  3. Implement CodeExecutor sandbox for new languages

Operational Runbook

ScenarioAction
Switch runtimeUpdate agent YAML spec.runtime.provider
Debug ACP connectionanvio runtime test cursor
Audit executionsanvio audit executions --last 24h
Kill runaway processanvio 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.

Edit on GitHub

Last updated on

On this page