Skip to main content

A lightweight agent runtime that turns any machine into an AI-agent-ready compute target

Project description

agent-runtime

A lightweight agent runtime that turns any machine into an AI-agent-ready compute target. Zero dependencies. Self-updating. Works with any ACP-compatible coding agent.

What is this?

agent-runtime is a sidecar you install on any machine (Dev Box, VM, cloud instance) to make it remotely controllable by AI coding agents. It provides:

  • Async command serverPOST /exec → job ID, GET /jobs/{id} → poll for results
  • WebSocket terminal — interactive ConPTY sessions over WebSocket (xterm.js compatible)
  • ACP client — structured Agent Client Protocol communication with any ACP agent
  • Self-updatingPOST /update triggers graceful upgrade via pip
  • Devtunnel integration — persistent tunnels, token rotation, challenge-code registration
  • API key auth — auto-generated keys, persisted across restarts

Install

# Core (zero dependencies)
pip install agent-runtime

# With interactive terminal support (Windows)
pip install agent-runtime[terminal]

Quick Start

# Start the server
agent-server

# Start on a custom port
agent-server --port 9090

# Start with devtunnel + auto-registration
agent-server --wrapper --tunnel --register https://your-dashboard.example.com

# Start with self-update wrapper
agent-server --wrapper

API

Command Execution

# Submit a command
curl -X POST http://localhost:8585/exec \
  -H "X-API-Key: $KEY" \
  -H "Content-Type: application/json" \
  -d '{"command": "echo hello", "workdir": "/path/to/repo", "timeout": 300}'
# → {"jobId": "abc123", "status": "pending"}

# Poll for results
curl http://localhost:8585/jobs/abc123 -H "X-API-Key: $KEY"
# → {"status": "completed", "exitCode": 0, "stdout": "hello\n", ...}

# Nudge a stalled process (writes to stdin)
curl -X POST http://localhost:8585/jobs/abc123/nudge -H "X-API-Key: $KEY"

ACP Mode

Submit commands in ACP mode for structured output from any ACP-compatible agent:

curl -X POST http://localhost:8585/exec \
  -H "X-API-Key: $KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "mode": "acp",
    "agent": "copilot --acp --stdio",
    "prompt": "Implement the login feature",
    "workdir": "/path/to/repo"
  }'

ACP responses include structured events, tool calls, and session IDs instead of raw stdout.

Health Check

curl http://localhost:8585/health
# → {"status": "ok", "version": "0.1.0", "acp_supported": true, ...}

ACP Client (Standalone)

The headless ACP client can be used independently for driving any ACP agent from Python:

from agent_runtime.acp_client import run_acp_session_sync, HeadlessApprovePolicy

result = run_acp_session_sync(
    agent_cmd=["copilot", "--acp", "--stdio"],
    prompt="Refactor the auth module",
    workdir="/path/to/repo",
    timeout=600,
    permission_policy=HeadlessApprovePolicy("/path/to/repo"),
)

print(result.output_text)       # Agent's response
print(result.session_id)        # For session continuity
print(result.tool_calls)        # Structured tool call data
print(result.stop_reason)       # "end_turn", "timeout", "error"

Architecture

┌─────────────────────────────────────────────────────┐
│  Your Orchestrator / Dashboard / CI                  │
│  (any HTTP client)                                   │
└────────┬─────────────────────┬──────────────────────┘
         │ HTTP                 │ WebSocket
         ▼                     ▼
┌─────────────────────────────────────────────────────┐
│  agent-runtime (on the target machine)               │
│                                                      │
│  ┌───────────────────┐  ┌─────────────────────────┐ │
│  │ Command Server     │  │ Terminal Server          │ │
│  │ :8585              │  │ :8586 (WebSocket)        │ │
│  │                    │  │                          │ │
│  │ POST /exec         │  │ ConPTY ↔ xterm.js       │ │
│  │ GET /jobs/{id}     │  │ JSON input/raw output    │ │
│  │ POST /nudge        │  │ Resize, idle timeout     │ │
│  │ POST /update       │  │ Max 2 sessions           │ │
│  └───────────────────┘  └─────────────────────────┘ │
│                                                      │
│  ┌─────────────────────────────────────────────────┐ │
│  │ ACP Client (headless)                            │ │
│  │ JSON-RPC over stdio → any ACP agent              │ │
│  │ Permission policies, session continuity          │ │
│  └─────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────┘

Key Design Decisions

  • Zero runtime dependencies — stdlib-only Python. Terminal extras are opt-in.
  • Async job pattern — fire-and-forget commands avoid tunnel timeout issues.
  • Self-updating — exit code 42 triggers pip upgrade + restart via the wrapper loop.
  • Security — auto-generated API keys, workdir-scoped permission policies, path traversal protection.

Configuration

Environment Variable Default Description
DEVPILOT_AGENT_API_KEY auto-generated API key for authenticating requests
DEVPILOT_TUNNEL_URL Devtunnel URL (set automatically with --tunnel)
DEVPILOT_TUNNEL_TOKEN Devtunnel access token

License

Apache 2.0 — see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

devpilot_agent-0.1.0.tar.gz (32.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

devpilot_agent-0.1.0-py3-none-any.whl (29.6 kB view details)

Uploaded Python 3

File details

Details for the file devpilot_agent-0.1.0.tar.gz.

File metadata

  • Download URL: devpilot_agent-0.1.0.tar.gz
  • Upload date:
  • Size: 32.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for devpilot_agent-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8c77c4325748686bae866188132a116d0125e6ae80a52ae7c572d90380537d10
MD5 26af89635dd0d7ae8104d556c2f4842d
BLAKE2b-256 1dcc7642d662ccf14e0e0bbef985f7cb76dbffdd5c501325f4e99a5f2a065828

See more details on using hashes here.

File details

Details for the file devpilot_agent-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: devpilot_agent-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 29.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for devpilot_agent-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b04d66fdfe06b03d49f9f3691d7d1fa150d4db7ce31aa1df290e88fa18c7e61
MD5 bd1877cc2c63bed5641daf771ffa7b45
BLAKE2b-256 8a424ab7748f1384f83e5930a324608ddfbb15a912fe8ddff5cc187c1e02c3e3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page