Metadata-Version: 2.4
Name: tai-daf-sdk
Version: 2.0.0a1
Summary: Python SDK for DAF (Declarative Agentic Framework) — thin MCP client
Author-email: DAF Team <dev@example.com>
License: MIT
Project-URL: Homepage, https://github.com/your-org/tai-daf-sdk
Project-URL: Repository, https://github.com/your-org/tai-daf-sdk
Keywords: ai,agents,llm,framework,sdk
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.24.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: python-dotenv>=1.0.0
Requires-Dist: mcp<2,>=1.10.0
Provides-Extra: test
Requires-Dist: pytest>=7.0.0; extra == "test"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "test"
Requires-Dist: pytest-cov>=4.0.0; extra == "test"
Provides-Extra: lint
Requires-Dist: black==26.3.1; extra == "lint"
Requires-Dist: ruff>=0.1.0; extra == "lint"
Requires-Dist: mypy>=1.0.0; extra == "lint"
Requires-Dist: types-requests>=2.32.0; extra == "lint"
Requires-Dist: bandit[toml]>=1.8.0; extra == "lint"
Requires-Dist: pip-audit>=2.7.0; extra == "lint"
Requires-Dist: pre-commit>=3.7.0; extra == "lint"
Provides-Extra: dev
Requires-Dist: tai-daf-sdk[lint,test]; extra == "dev"

# DAF SDK

Python SDK for **DAF (Declarative Agentic Framework)** — a platform for building, managing, and orchestrating AI agents and multi-agent teams.

**SDK 2.0 (SDK-MCP-R1 + R2)** is a **thin MCP client** with a **codegen-typed** surface: `client.<resource>.<method>()` maps to `daf_<method>_<resource>`, returns Pydantic models when the MCP tool has an `output_schema`, and stays in sync via catalog drift CI.

## Features

- **Thin MCP dispatch** — Any `client.<resource>.<method>(**kwargs)` → `daf_<method>_<resource>` (no per-resource SDK modules)
- **Typed returns (R2)** — Generated `models.py` / `_tool_registry.py` wrap tool results; unknown tools fail fast
- **IDE stubs** — Generated `types.py` TypedDicts + `client.pyi` for kwargs autocomplete
- **Sync & Async** — `DAF` and `AsyncDAF` share the same public surface
- **Streaming** — `client.stream(tool_name, args)` yields MCP notification/progress events
- **Catalog sync CI** — Daily drift check opens a PR when the backend MCP catalog changes

## Requirements

- Python 3.10+
- Running DAF backend with MCP endpoint (`{base_url}/mcp`)

## Installation

```bash
pip install tai-daf-sdk
```

Or install from source:

```bash
git clone https://github.com/your-org/tai-daf-sdk.git
cd tai-daf-sdk
pip install -e ".[dev]"
```

## Quick Start

```python
from tai_daf_sdk import DAF
from tai_daf_sdk.models import ListAgentsResponse

with DAF(base_url="http://localhost:8012", api_key="daf_your_api_key") as client:
    # → MCP tool daf_list_agents; ListAgentsResponse when output_schema exists
    agents = client.agents.list()
    assert isinstance(agents, ListAgentsResponse)
    print(agents)

    # Stream a long-running tool (manual API — not codegen'd)
    for event in client.stream("daf_test_agent", {"name_or_id": "assistant", "sample_input": "Hi"}):
        print(event)
```

### Async

```python
from tai_daf_sdk import AsyncDAF

async with AsyncDAF(base_url="http://localhost:8012", api_key="daf_...") as client:
    agents = await client.agents.list()
```

### Authentication

```python
# Explicit API key
client = DAF(base_url="http://localhost:8012", api_key="daf_...")

# Or set DAF_API_KEY in the environment (resolved by MCP transport)
```

Optional advanced: set `DAF_MCP_STDIO_COMMAND` to use stdio MCP instead of HTTP.

### Regenerating typed surface (do not hand-edit)

Generated files (`tai_daf_sdk/models.py`, `types.py`, `_tool_registry.py`, `client.pyi`) are **codegen-only**:

```bash
python -m tai_daf_sdk.codegen \
  --mcp-url https://tai-daf-sdk-backend-dev.azurewebsites.net/mcp \
  --api-key "$DAF_API_KEY" \
  --out tai_daf_sdk/
```

Offline / tests:

```bash
python -m tai_daf_sdk.codegen --catalog-json tests/fixtures/mcp_list_tools_golden.json --out tai_daf_sdk/
```

IDE autocomplete uses `tai_daf_sdk/client.pyi` + TypedDicts in `tai_daf_sdk/types.py`.

### 1.x → 2.0 note

```text
1.x:  agents = client.agents.list()   # list[Agent]
2.0:  result = client.agents.list()   # ListAgentsResponse (or dict if no output_schema)
```

REST mode and hand-maintained resource modules are removed from 2.0 (see `1.x-maintenance` branch). Full migration guide arrives in R3.

## Development

```bash
pip install -e ".[dev]"
pytest tests -q
# Live MCP (optional):
# pytest -m mcp -v
```

## License

MIT
