Metadata-Version: 2.4
Name: agent-webkit-server
Version: 0.2.0
Summary: Server-side toolkit for the Claude Agent SDK over HTTP+SSE: session lifecycle, permission routing, SDK bridge, plus bundled FastAPI and Postgres adapters.
Project-URL: Homepage, https://github.com/BlitzJB/agent-webkit
Project-URL: Documentation, https://github.com/BlitzJB/agent-webkit#readme
Project-URL: Source, https://github.com/BlitzJB/agent-webkit
Project-URL: Issues, https://github.com/BlitzJB/agent-webkit/issues
Author: BlitzJB
License-Expression: MIT
License-File: LICENSE
Keywords: agent-sdk,anthropic,claude,fastapi,sse
Classifier: Development Status :: 3 - Alpha
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
Requires-Dist: claude-agent-sdk<0.2.0,>=0.1.0
Requires-Dist: pydantic<3.0,>=2.0
Provides-Extra: dev
Requires-Dist: httpx>=0.27; extra == 'dev'
Requires-Dist: hypothesis>=6.100; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
Requires-Dist: pytest-timeout>=2.3; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Provides-Extra: fastapi
Requires-Dist: fastapi>=0.110; extra == 'fastapi'
Requires-Dist: uvicorn>=0.27; extra == 'fastapi'
Provides-Extra: postgres
Requires-Dist: asyncpg>=0.29; extra == 'postgres'
Description-Content-Type: text/markdown

# agent-webkit-server

Server-side toolkit for exposing the [Claude Agent SDK](https://code.claude.com/docs/en/agent-sdk/python) over HTTP+SSE. One Python package; bundled adapters cover the common deployment shapes.

## Install

```bash
pip install agent-webkit-server                # core only
pip install "agent-webkit-server[fastapi]"     # + FastAPI HTTP adapter
pip install "agent-webkit-server[postgres]"    # + PgSessionStore
pip install "agent-webkit-server[fastapi,postgres]"
```

## Core

Framework-agnostic primitives — no FastAPI, no asyncpg until you opt in.

```python
from agent_webkit_server import PROTOCOL_VERSION
from agent_webkit_server.session import SessionRegistry, SessionConfig
from agent_webkit_server.event_log import EventLog
from agent_webkit_server.sdk_bridge import (
    PermissionRouter,
    build_can_use_tool,
    translate_sdk_messages,
)
```

These pieces are what you'd otherwise reimplement: per-session inbound queue + receive-loop, append-only event log with multi-subscriber fan-out, permission/AskUserQuestion correlation router, the `can_use_tool` wiring, and the SDK→wire-event translator.

## FastAPI adapter

```python
from agent_webkit_server.adapters.fastapi import create_app
from agent_webkit_server.auth import AuthConfig

app = create_app(auth=AuthConfig.from_env())
```

Exposes:
- `POST /sessions`
- `GET /sessions/{id}/stream` (SSE, with `Last-Event-ID` resume)
- `POST /sessions/{id}/input` (every inbound message type)
- `DELETE /sessions/{id}`

## Postgres adapter (`PgSessionStore`)

Plug into the SDK directly via `ClaudeAgentOptions(session_store=...)`:

```python
from claude_agent_sdk import ClaudeAgentOptions, ClaudeSDKClient
from agent_webkit_server.adapters.pg_session_store import PgSessionStore

store = await PgSessionStore.connect("postgresql://...")
options = ClaudeAgentOptions(session_store=store, resume=session_id)
client = ClaudeSDKClient(options=options)
```

Passes the SDK's published `run_session_store_conformance` suite plus adapter-specific contracts (uuid idempotency, concurrent-append serialization, multi-tenant isolation).

## Wire protocol

Documented in [`docs/wire-protocol.md`](../../docs/wire-protocol.md). The Pydantic models in `agent_webkit_server.models` are the canonical schema.
