-
Notifications
You must be signed in to change notification settings - Fork 85
Feat/acp protocol #184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feat/acp protocol #184
Changes from 5 commits
646d01b
1ae42d8
72ea8f7
48d668b
992bbb3
094f86e
c8c51f3
947163f
76eaacb
cb93eaa
fd08d6f
012d76e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| # ACP Gateway Plugin — Setup Guide | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ### 1. Install acp-sdk | ||
|
|
||
| ```bash | ||
| uv pip install acp-sdk | ||
| ``` | ||
|
|
||
| ### 2. Configure a Model Provider (Optional — for full agent execution) | ||
|
|
||
| The ACP Gateway works with any model Code Puppy supports. For testing with OpenRouter: | ||
|
|
||
| **a) Get an API key from [openrouter.ai](https://openrouter.ai)** | ||
|
|
||
| **b) Export it:** | ||
| ```bash | ||
| export OPENROUTER_API_KEY="sk-or-v1-your-key-here" | ||
| ``` | ||
|
|
||
| **c) Copy the example models config:** | ||
| ```bash | ||
| cp code_puppy/plugins/acp_gateway/extra_models.example.json ~/.code_puppy/extra_models.json | ||
| ``` | ||
|
|
||
| ### 3. Environment Variables | ||
|
|
||
| | Variable | Default | Description | | ||
| |----------|---------|-------------| | ||
| | `ACP_ENABLED` | `true` | Enable/disable ACP Gateway | | ||
| | `ACP_HOST` | `0.0.0.0` | Bind host | | ||
| | `ACP_PORT` | `9001` | Bind port | | ||
| | `OPENROUTER_API_KEY` | — | OpenRouter API key (if using OpenRouter) | | ||
|
Comment on lines
+29
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The setup guide uses 🔧 Suggested fix | `ACP_ENABLED` | `true` | Enable/disable ACP Gateway |
+| `ACP_TRANSPORT` | `http` | Transport to use: `http` or `stdio` |
| `ACP_HOST` | `0.0.0.0` | Bind host |🤖 Prompt for AI Agents |
||
|
|
||
| ### 4. Launch | ||
|
|
||
| ```bash | ||
| export ACP_ENABLED=true | ||
| uv run code-puppy -i | ||
| ``` | ||
|
|
||
| ACP Gateway starts automatically on port 9001. | ||
|
|
||
| ### 5. Verify | ||
|
|
||
| ```bash | ||
| # Health check | ||
| curl http://127.0.0.1:9001/ping | ||
|
|
||
| # List agents | ||
| curl http://127.0.0.1:9001/agents | ||
|
|
||
| # Swagger docs | ||
| open http://127.0.0.1:9001/docs | ||
|
|
||
| # Send a prompt | ||
| curl -X POST http://127.0.0.1:9001/runs \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{ | ||
| "agent_name": "code-puppy", | ||
| "input": [{"parts": [{"content": "Hello ACP!", "content_type": "text/plain"}]}] | ||
| }' | ||
| ``` | ||
|
|
||
| ### 6. Standalone Test (no LLM needed) | ||
|
|
||
| ```bash | ||
| python test_acp_local.py | ||
| ``` | ||
|
|
||
| ## Architecture | ||
|
|
||
| ``` | ||
| Code Puppy CLI Process | ||
| └─ Startup callback | ||
| └─ Background thread (daemon) | ||
| └─ uvicorn serving ACP on :9001 | ||
| └─ acp-sdk FastAPI app | ||
| └─ /agents, /runs, /ping, /docs | ||
| ``` | ||
|
|
||
| ## Files | ||
|
|
||
| | File | Purpose | | ||
| |------|--------| | ||
| | `config.py` | ACPConfig from env vars | | ||
| | `agent_adapter.py` | Dynamic agent discovery | | ||
| | `acp_server.py` | ACP server with all agents | | ||
| | `run_engine.py` | Execution engine + RunRegistry | | ||
| | `session_store.py` | Multi-turn session management | | ||
| | `hitl_bridge.py` | Human-in-the-loop Await/Resume | | ||
| | `event_store.py` | Run progress event tracking | | ||
| | `register_callbacks.py` | Startup/shutdown hooks | | ||
|
|
||
| ## stdio Transport | ||
|
|
||
| Subprocess-based communication via stdin/stdout. No port needed. | ||
|
|
||
| ### Launch | ||
|
|
||
| ```bash | ||
| python -m code_puppy.plugins.acp_gateway # direct | ||
| ./run.sh stdio # via launcher | ||
| ``` | ||
|
|
||
| ### Protocol | ||
|
|
||
| Newline-delimited JSON-RPC 2.0. Logs go to stderr. | ||
|
|
||
| ```json | ||
| → {"jsonrpc": "2.0", "method": "ping", "id": 1} | ||
| ← {"jsonrpc": "2.0", "result": {"status": "ok", "transport": "stdio"}, "id": 1} | ||
| ``` | ||
|
|
||
| ### Methods | ||
|
|
||
| | Method | Params | Description | | ||
| |--------|--------|-------------| | ||
| | `ping` | — | Health check | | ||
| | `agents/list` | — | List all agents | | ||
| | `agents/get` | `{name}` | Get agent metadata | | ||
| | `runs/create` | `{agent_name, input}` | Sync run | | ||
| | `runs/create_async` | `{agent_name, input}` | Async run | | ||
| | `runs/get` | `{run_id}` | Poll async run | | ||
| | `runs/cancel` | `{run_id}` | Cancel run | | ||
|
|
||
| ### Orchestrator config | ||
|
|
||
| ```json | ||
| {"type": "stdio", "command": "python", "args": ["-m", "code_puppy.plugins.acp_gateway"]} | ||
| ``` | ||
|
|
||
| ### Test | ||
|
|
||
| ```bash | ||
| echo '{"jsonrpc":"2.0","method":"ping","id":1}' | python -m code_puppy.plugins.acp_gateway | ||
| python test_acp_stdio.py | ||
| ``` | ||
|
|
||
| ## Architecture (updated) | ||
|
|
||
| ``` | ||
| Code Puppy | ||
| └─ register_callbacks.py | ||
| ├─ ACP_TRANSPORT=http → uvicorn :9001 (background thread) | ||
| └─ ACP_TRANSPORT=stdio → stdin/stdout JSON-RPC (background thread) | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| """ACP Gateway Plugin. | ||
|
|
||
| Exposes Code Puppy as an ACP (Agent Communication Protocol) server, | ||
| allowing external agents and tools to communicate with Code Puppy | ||
| via the standardized ACP protocol. | ||
|
|
||
| The plugin gracefully degrades — if `acp-sdk` is not installed, | ||
| Code Puppy starts normally with a warning log. | ||
| """ | ||
|
|
||
| __version__ = "0.1.0" | ||
| __description__ = "ACP Gateway plugin for Code Puppy" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| """Allow running ACP stdio server as: python -m code_puppy.plugins.acp_gateway""" | ||
|
|
||
| from code_puppy.plugins.acp_gateway.stdio_server import main | ||
|
|
||
| if __name__ == "__main__": | ||
| main() |
Uh oh!
There was an error while loading. Please reload this page.