Metadata-Version: 2.4
Name: wacp
Version: 2.0.3
Summary: WACP (Web Agent Client Protocol) — turn any backend into an AI-agent-friendly system.
License: MIT
Project-URL: Changelog, https://github.com/AriJai/ai-web/blob/main/sdk/CHANGELOG.md
Keywords: ai,sdk,wacp,fastapi,flask,django,agent,api,llm
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Framework :: FastAPI
Classifier: Framework :: Flask
Classifier: Framework :: Django
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: pydantic>=2.0.0
Provides-Extra: fastapi
Requires-Dist: fastapi>=0.100.0; extra == "fastapi"
Provides-Extra: flask
Requires-Dist: flask>=2.0.0; extra == "flask"
Provides-Extra: django
Requires-Dist: django>=4.0.0; extra == "django"
Provides-Extra: dev
Requires-Dist: uvicorn[standard]>=0.22.0; extra == "dev"
Requires-Dist: httpx>=0.24.0; extra == "dev"

# WACP Python SDK (`wacp`)

**Version: 2.0.3**

```bash
pip install wacp
```

One package, all frameworks. Same function name everywhere:

```python
from wacp.fastapi import wacp_router   # FastAPI
from wacp.flask import wacp_router     # Flask
from wacp.django import wacp_router    # Django
```

Only `pydantic` is installed as a dependency. Your framework (fastapi/flask/django) must already be in your environment.

---

## Quick start — FastAPI

```python
from fastapi import FastAPI
from wacp.fastapi import wacp_router

app = FastAPI()

app.include_router(
    wacp_router(
        app,
        base_dir="ai",
        discover=True,
    )
)
```

## Quick start — Flask

```python
from flask import Flask
from wacp.flask import wacp_router

app = Flask(__name__)

app.register_blueprint(
    wacp_router(
        app,
        base_dir="ai",
        discover=True,
    )
)
```

## Quick start — Django

```python
# urls.py
from wacp.django import wacp_router

urlpatterns = [
    # ... your routes ...
] + wacp_router(base_dir="ai", discover=True, urlconf="myproject.urls")
```

---

If `ai/config/` does not exist, the SDK **auto-scaffolds** starter JSON files + a setup guide on first boot.

---

## Package layout

```text
wacp/
  core/          # config, scaffold, search, types (shared across all frameworks)
  fastapi/       # FastAPI adapter (wacp_router, FastAPIDiscovery)
  flask/         # Flask adapter (wacp_router, FlaskDiscovery)
  django/        # Django adapter (wacp_router, DjangoDiscovery)
```

---

## Routes

| Method | Path | Purpose |
|--------|------|---------|
| GET | `/ai` | Entry: app info, navigation, quick access |
| GET | `/ai/all` | Flat list of endpoints (`?page=&limit=` optional) |
| GET | `/ai/category` | Category index |
| GET | `/ai/category/{id}` | Endpoints in a category |
| GET | `/ai/endpoint/{id}` | Full endpoint detail |
| GET | `/ai/docs` | Docs index |
| GET | `/ai/docs/{filename}` | Raw doc content |
| GET | `/ai/search?q=` | Lexical search |

---

## Discovery

Each adapter supports `discover=True` which scans your app's routes and writes `config/_discovered.json`:

- **FastAPI**: `wacp_router(app, discover=True)`
- **Flask**: `wacp_router(app, discover=True)`
- **Django**: `wacp_router(discover=True, urlconf="myproject.urls")`

The file is never served and never merged — copy blocks into your `endpoints.json`.

---

## Search & pagination

Lightweight lexical search via `GET /ai/search?q=...`.
List routes accept optional `?page=&limit=`.

---

## License

MIT
