Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
78f2f82
feat: add A2A service and utilities for tasks and push
alDuncanson Dec 6, 2025
1a68a87
feat: build and pass custom AgentCard to A2A server
alDuncanson Dec 6, 2025
17d442d
feat: add push notification support to A2A server
alDuncanson Dec 6, 2025
941576e
wip: push notification support
alDuncanson Dec 6, 2025
a99dabd
docs: higher level to avoid slippage
alDuncanson Dec 8, 2025
05ec2d5
refactor: cleanup, organize code, and test
alDuncanson Dec 8, 2025
07161bb
fix: check for TextPart root when extracting text
alDuncanson Dec 8, 2025
a345505
refactor(cli): imports and silence noisy logs
alDuncanson Dec 8, 2025
b883d4d
refactor(cli): extract formatting utils to common module
alDuncanson Dec 8, 2025
9e3c485
chore: remove PyPI badge due to rate limiting
alDuncanson Dec 8, 2025
c0f0154
refactor(cli): agent card validation
alDuncanson Dec 8, 2025
3876e28
refactor(cli): move push commands under tasks group
alDuncanson Dec 9, 2025
cd52137
feat: print push notification info from config
alDuncanson Dec 9, 2025
24285e5
refactor(cli): major rewrite of command structure and output formatting
alDuncanson Dec 9, 2025
edd6dd4
chore: add download badge back, the rate limit might've been a one-off
alDuncanson Dec 10, 2025
76c4fa8
refactor: shorten and standardize CLI command docstrings
alDuncanson Dec 10, 2025
22f80c1
refact: remove raw json rpc attempted methods
alDuncanson Dec 10, 2025
3eb89df
fix: remove notification get command for now as its redundant
alDuncanson Dec 10, 2025
fe6605b
refactor: remove session get command
alDuncanson Dec 10, 2025
0070dc1
refactor: rename OutputContext to Output and update API
alDuncanson Dec 10, 2025
9879f4b
refactor: standardize CLI output handling
alDuncanson Dec 10, 2025
359f04a
chore: improve and standardize module docstrings
alDuncanson Dec 10, 2025
a94f7cd
refactor: Handler agent description and prompt
alDuncanson Dec 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 19 additions & 57 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,32 @@
# Agent Development Guide

## Commands
Use `just` for all development tasks:
## Quick Start

| Command | Description |
|---------|-------------|
| `just install` | Install dependencies |
| `just check` | Run lint, format, and typecheck |
| `just fix` | Auto-fix lint/format issues |
| `just test` | Run pytest test suite |
| `just server` | Start A2A server (port 8000) |
| `just tui` | Run TUI application |
| `just tui-dev` | Run TUI with Textual devtools |
| `just web` | Serve TUI as web app |
| `just console` | Run Textual devtools console |
| `just get-card` | Fetch agent card (CLI) |
| `just send` | Send message to agent (CLI) |
| `just validate` | Validate agent card (CLI) |
| `just version` | Show current version |
| `just bump` | Bump version (patch, minor, major) |
| `just tag` | Create git tag for current version |
| `just release` | Tag and push release to origin |
```bash
just install # Install dependencies
just check # Run lint, format, and typecheck
just test # Run tests
```

Run `just` to see all available commands.

## Project Structure

```
handler/
├── src/a2a_handler/ # Main package
│ ├── _version.py # Version string
│ ├── cli.py # CLI (rich-click)
│ ├── client.py # A2A protocol client (a2a-sdk)
│ ├── validation.py # Agent card validation utilities
│ ├── server.py # A2A server agent (google-adk, litellm)
│ ├── tui.py # TUI application (textual)
│ ├── common/ # Shared utilities (rich, logging)
│ │ ├── logging.py
│ │ └── printing.py
│ └── components/ # TUI components
└── tests/ # pytest tests
src/a2a_handler/
├── cli.py # CLI entry point
├── client.py # A2A protocol client
├── validation.py # Agent card validation
├── server.py # A2A server agent
├── tui.py # TUI application
├── common/ # Shared utilities
└── components/ # TUI components
```

## Code Style & Conventions
## Code Style

- **Python 3.11+** with full type hints
- **Formatting**: `ruff format` (black compatible)
- **Formatting**: `ruff format`
- **Linting**: `ruff check`
- **Type Checking**: `ty check`
- **Imports**: Standard → Third-party → Local
- **Testing**: pytest with pytest-asyncio for async tests

## Environment Variables

- `OLLAMA_API_BASE`: Ollama server URL (default: `http://localhost:11434`)
- `OLLAMA_MODEL`: Model to use (default: `qwen3`)

## A2A Protocol

The `a2a_handler.client` module provides A2A protocol logic:
- `build_http_client()` - Create configured HTTP client
- `fetch_agent_card()` - Retrieve agent metadata
- `send_message_to_agent()` - Send messages and get responses

## Key Dependencies

- **CLI**: `rich-click` (enhanced `click` with rich formatting)
- **Client**: `a2a-sdk`, `httpx`
- **Server**: `google-adk`, `litellm`, `uvicorn`
- **TUI**: `textual`
- **Common**: `rich`
- **Testing**: pytest with pytest-asyncio
65 changes: 7 additions & 58 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,78 +1,27 @@
# Contributing to Handler

## Architecture

Handler is a single Python package (`a2a-handler`) with all modules under `src/a2a_handler/`:

| Module | Description |
|--------|-------------|
| `cli.py` | CLI built with `rich-click`. Entry point: `handler` |
| `client.py` | A2A protocol client library using `a2a-sdk` |
| `validation.py` | Agent card validation utilities |
| `common/` | Shared utilities (logging, printing with `rich`) |
| `server.py` | Reference A2A agent using `google-adk` + `litellm` |
| `tui.py` | TUI application built with `textual` |
| `components/` | TUI components |

## Prerequisites

- **Python 3.11+**
- **[uv](https://github.com/astral-sh/uv)** for dependency management
- **[just](https://github.com/casey/just)** for running commands (recommended)
- **[Ollama](https://ollama.com/)** for running the reference server agent
- **[just](https://github.com/casey/just)** for running commands
- **[Ollama](https://ollama.com/)** for running the server agent

## Setup

```bash
git clone https://github.com/alDuncanson/handler.git
cd handler
just install # or: uv sync
just install
```

## Development Commands
## Development

| Command | Description |
|---------|-------------|
| `just install` | Install dependencies |
| `just check` | Run lint, format, and typecheck |
| `just fix` | Auto-fix lint/format issues |
| `just test` | Run pytest test suite |
| `just server` | Start A2A server on port 8000 |
| `just tui` | Run TUI application |
| `just tui-dev` | Run TUI with Textual devtools |
| `just web` | Serve TUI as web app |
| `just console` | Run Textual devtools console |
| `just get-card [url]` | Fetch agent card from URL |
| `just send [url] [msg]` | Send message to agent |
| `just validate [source]` | Validate agent card from URL or file |
| `just version` | Show current version |
| `just bump [level]` | Bump version (patch, minor, major) |
| `just tag` | Create git tag for current version |
| `just release` | Tag and push release to origin |
Run `just` to see all available commands.

## Code Style

- **Formatting**: `ruff format` (black compatible)
- **Formatting**: `ruff format`
- **Linting**: `ruff check`
- **Type Checking**: `ty check`
- **Imports**: Standard → Third-party → Local
- **Testing**: Add `pytest` tests for new functionality

## Environment Variables

| Variable | Default | Description |
|----------|---------|-------------|
| `OLLAMA_API_BASE` | `http://localhost:11434` | Ollama server URL |
| `OLLAMA_MODEL` | `qwen3` | Model for reference agent |

## A2A Protocol

The `a2a_handler.client` module provides the A2A protocol implementation:

```python
from a2a_handler.client import build_http_client, fetch_agent_card, send_message_to_agent

async with build_http_client() as client:
card = await fetch_agent_card("http://localhost:8000", client)
response = await send_message_to_agent("http://localhost:8000", "Hello", client)
```
- **Testing**: pytest
64 changes: 3 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,74 +27,16 @@ uvx --from a2a-handler handler

## Use

Then, you can use Handler:

```bash
handler
handler --help
```

If you don't have an A2A server to connect to, Handler provides a local A2A server agent:
To start a local A2A server agent (requires [Ollama](https://ollama.com/)):

```bash
handler server
```

> The server agent requires [Ollama](https://ollama.com/) to be running locally. By default it connects to `http://localhost:11434` and uses the `qwen3` model.
>
> 1. Install and run Ollama
> 2. Pull the model: `ollama pull qwen3`
> 3. (Optional) Configure via environment variables: `OLLAMA_API_BASE` and `OLLAMA_MODEL`

### TUI

Interactive terminal user interface:

```bash
handler tui
```

### CLI

#### Global Options

```bash
handler --verbose # Enable verbose logging output
handler --debug # Enable debug logging output
handler --help # Show help for any command
```

#### Commands

Fetch agent card from A2A server:

```bash
handler card http://localhost:8000
handler card http://localhost:8000 --output json # JSON output
```

Validate an agent card from a URL or file:

```bash
handler validate http://localhost:8000 # Validate from URL
handler validate ./agent-card.json # Validate from file
handler validate http://localhost:8000 --output json # JSON output
```

Send a message to an A2A agent:

```bash
handler send http://localhost:8000 "Hello World"
handler send http://localhost:8000 "Hello" --output json # JSON output
handler send http://localhost:8000 "Hello" --context-id abc # Conversation continuity
handler send http://localhost:8000 "Hello" --task-id xyz # Reference existing task
```

Show version:

```bash
handler version
```

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) for architecture and development instructions.
See [CONTRIBUTING.md](CONTRIBUTING.md).
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ build-backend = "uv_build"

[tool.uv.build-backend]
module-root = "src"

[tool.ruff.lint.per-file-ignores]
"src/a2a_handler/cli.py" = ["E402"]
5 changes: 4 additions & 1 deletion src/a2a_handler/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
"""Handler - A2A protocol client and TUI for agent interaction"""
"""Handler - A2A protocol client and TUI for agent interaction.

Provides CLI and TUI interfaces for communicating with A2A protocol agents.
"""

from importlib.metadata import version

Expand Down
Loading