Metadata-Version: 2.4
Name: acp-ai
Version: 0.2.0
Summary: Agent Control Plane — SDK and CLI for governed agent execution with a local Docker stack.
Author: Raja Datascientist
License-Expression: MIT
Project-URL: Homepage, https://github.com/raja-datascientist/ACP
Project-URL: Documentation, https://github.com/raja-datascientist/ACP/tree/main/sdk/python
Project-URL: Repository, https://github.com/raja-datascientist/ACP
Project-URL: Issues, https://github.com/raja-datascientist/ACP/issues
Keywords: ai,agents,governance,policy,opa,control-plane
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.31
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: build>=1.0; extra == "dev"
Requires-Dist: twine>=5.0; extra == "dev"
Dynamic: license-file

# ACP Control Plane — Python SDK + CLI

**PyPI:** `acp-ai` · **Import:** `acp`

One pip install gives you a **local governance stack**: intercept tool calls, evaluate **your** OPA/Rego rules, persist audit + agent registry in Postgres, and view everything in the dashboard.

**Requires:** [Docker Desktop](https://docs.docker.com/get-docker/) (Compose v2). All `acp` commands run in your **terminal** (Terminal.app, iTerm, or the IDE integrated terminal).

---

## Install (terminal)

```bash
pip install acp-ai
acp doctor
```

---

## First-time setup (terminal)

Run these in order from **any directory** (home folder is fine):

```bash
# 1. Create your editable policy folder (~/.acp/policies)
acp init

# 2. Start local stack: Postgres + OPA + interceptor + dashboard
acp up --build

# 3. Open governance dashboard in browser
acp dashboard
```

| Command | What it does | Where it runs |
|---------|--------------|---------------|
| **`acp init`** | Creates `~/.acp/policies/` with starter `.rego` files + `HOW_TO_ADD_RULES.md` | **Your terminal** |
| **`acp up --build`** | Starts Docker containers (first time builds interceptor image) | **Your terminal** (needs Docker running) |
| **`acp up`** | Starts stack without rebuild (after first `--build`) | **Your terminal** |
| **`acp down`** | Stops containers | **Your terminal** |
| **`acp status`** | Container + health check status | **Your terminal** |
| **`acp dashboard`** | Opens http://localhost:3090/dashboard/ | **Your terminal** |
| **`acp doctor`** | Checks Docker + package install | **Your terminal** |

---

## Your rules (editable after pip install)

Policies are **yours**, not locked inside the package:

```
~/.acp/policies/
├── HOW_TO_ADD_RULES.md
├── router.rego                 ← route tools → policies
├── rbac.rego                   ← JWT roles → tools
├── mortgage_application.rego   ← commented sample (loan submit)
└── mortgage_underwriting.rego  ← commented sample (score_loan / escalate)
```

Edit files in `~/.acp/policies/`, then restart:

```bash
acp down && acp up
```

Custom policy path (optional):

```bash
export ACP_POLICIES_DIR=/path/to/my/policies
acp up
```

---

## Use in your agent project (any framework)

In **your project folder** (separate from ACP), activate a venv and use the SDK:

```python
import os
from acp import governed_tool

os.environ.setdefault("ACP_INTERCEPTOR_URL", "http://localhost:8080")

@governed_tool(agent_id="my-agent", tool="my_tool_api", action="run_action")
def my_tool(amount: int) -> str:
    return f"ok:{amount}"
```

Works with CrewAI, Strands, LangGraph, or plain Python.

Register agents via dashboard **Agent Registry** or `POST /api/v1/agents`.

---

## Local URLs

| URL | Purpose |
|-----|---------|
| http://localhost:3090/dashboard/ | **Dashboard** (events, policies, registry, approvals) |
| http://localhost:8080 | Interceptor API (`/tool-call`, `/api/v1/*`) |

---

## What Docker starts

| Service | Role |
|---------|------|
| **Postgres** | Audit log, agent registry, approvals |
| **OPA** | Evaluates your Rego from `~/.acp/policies/` |
| **Interceptor** | PEP — `POST /tool-call`, JWT, registry |
| **Dashboard** | Governance UI |
| **Gateway** | Single origin on `:3090` |

Also on disk: `~/.acp/jwt/` (dev RS256 keys), `~/.acp/runtime/` (compose + images).

---

## Maintainers (ACP monorepo)

```bash
cd sdk/python
./scripts/sync_bundle.sh
./scripts/publish_pypi.sh
twine upload dist/*
```
