a2a-handler 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. a2a_handler-0.1.2/.actrc +1 -0
  2. a2a_handler-0.1.2/.github/workflows/ci.yml +38 -0
  3. a2a_handler-0.1.2/.github/workflows/release.yml +89 -0
  4. a2a_handler-0.1.2/.gitignore +54 -0
  5. a2a_handler-0.1.2/AGENTS.md +61 -0
  6. a2a_handler-0.1.2/CONTRIBUTING.md +72 -0
  7. a2a_handler-0.1.2/LICENSE +674 -0
  8. a2a_handler-0.1.2/PKG-INFO +12 -0
  9. a2a_handler-0.1.2/README.md +70 -0
  10. a2a_handler-0.1.2/assets/handler-tui.png +0 -0
  11. a2a_handler-0.1.2/justfile +68 -0
  12. a2a_handler-0.1.2/packages/cli/pyproject.toml +21 -0
  13. a2a_handler-0.1.2/packages/cli/src/handler_cli/__init__.py +1 -0
  14. a2a_handler-0.1.2/packages/cli/src/handler_cli/cli.py +214 -0
  15. a2a_handler-0.1.2/packages/client/pyproject.toml +17 -0
  16. a2a_handler-0.1.2/packages/client/src/handler_client/__init__.py +11 -0
  17. a2a_handler-0.1.2/packages/client/src/handler_client/client.py +128 -0
  18. a2a_handler-0.1.2/packages/common/pyproject.toml +15 -0
  19. a2a_handler-0.1.2/packages/common/src/handler_common/__init__.py +29 -0
  20. a2a_handler-0.1.2/packages/common/src/handler_common/_version.py +3 -0
  21. a2a_handler-0.1.2/packages/common/src/handler_common/logging.py +80 -0
  22. a2a_handler-0.1.2/packages/common/src/handler_common/printing.py +78 -0
  23. a2a_handler-0.1.2/packages/server/pyproject.toml +23 -0
  24. a2a_handler-0.1.2/packages/server/src/handler_server/__init__.py +1 -0
  25. a2a_handler-0.1.2/packages/server/src/handler_server/server.py +88 -0
  26. a2a_handler-0.1.2/pyproject.toml +41 -0
  27. a2a_handler-0.1.2/src/a2a_handler/__init__.py +7 -0
  28. a2a_handler-0.1.2/src/a2a_handler/components/__init__.py +14 -0
  29. a2a_handler-0.1.2/src/a2a_handler/components/agent_card.py +231 -0
  30. a2a_handler-0.1.2/src/a2a_handler/components/contact.py +34 -0
  31. a2a_handler-0.1.2/src/a2a_handler/components/footer.py +16 -0
  32. a2a_handler-0.1.2/src/a2a_handler/components/input.py +32 -0
  33. a2a_handler-0.1.2/src/a2a_handler/components/messages.py +90 -0
  34. a2a_handler-0.1.2/src/a2a_handler/pyproject.toml +17 -0
  35. a2a_handler-0.1.2/src/a2a_handler/tui.py +238 -0
  36. a2a_handler-0.1.2/src/a2a_handler/tui.tcss +211 -0
  37. a2a_handler-0.1.2/tests/__init__.py +1 -0
  38. a2a_handler-0.1.2/tests/test_tui.py +16 -0
@@ -0,0 +1 @@
1
+ --container-architecture=linux/amd64
@@ -0,0 +1,38 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ check:
11
+ name: Check
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - name: Checkout source code
15
+ uses: actions/checkout@v4
16
+
17
+ - name: Install uv
18
+ uses: astral-sh/setup-uv@v5
19
+ with:
20
+ enable-cache: true
21
+
22
+ - name: Set up Python
23
+ run: uv python install
24
+
25
+ - name: Install dependencies
26
+ run: uv sync --all-extras --dev
27
+
28
+ - name: Lint with Ruff
29
+ run: uv run ruff check .
30
+
31
+ - name: Format check with Ruff
32
+ run: uv run ruff format --check .
33
+
34
+ - name: Type check with ty
35
+ run: uv run ty check
36
+
37
+ - name: Run tests
38
+ run: uv run pytest
@@ -0,0 +1,89 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ permissions:
9
+ contents: write
10
+ discussions: write
11
+ id-token: write
12
+
13
+ jobs:
14
+ release:
15
+ name: Create Release
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - name: Checkout source code
19
+ uses: actions/checkout@v5
20
+
21
+ - name: Install uv
22
+ uses: astral-sh/setup-uv@v7
23
+ with:
24
+ enable-cache: true
25
+
26
+ - name: Set up Python
27
+ run: uv python install
28
+
29
+ - name: Install dependencies
30
+ run: uv sync --all-extras --dev
31
+
32
+ - name: Run checks
33
+ run: |
34
+ uv run ruff check .
35
+ uv run ruff format --check .
36
+ uv run ty check
37
+
38
+ - name: Run tests
39
+ run: uv run pytest
40
+
41
+ - name: Extract version from tag
42
+ id: version
43
+ run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
44
+
45
+ - name: Verify version matches
46
+ run: |
47
+ FILE_VERSION=$(grep -oP '__version__ = "\K[^"]+' packages/common/src/handler_common/_version.py)
48
+ TAG_VERSION=${{ steps.version.outputs.VERSION }}
49
+ if [ "$FILE_VERSION" != "$TAG_VERSION" ]; then
50
+ echo "Error: Version mismatch! File: $FILE_VERSION, Tag: $TAG_VERSION"
51
+ exit 1
52
+ fi
53
+
54
+ - name: Build packages
55
+ run: uv build
56
+
57
+ - name: Upload build artifacts
58
+ uses: actions/upload-artifact@v4
59
+ with:
60
+ name: dist
61
+ path: dist/
62
+
63
+ - name: Create GitHub Release
64
+ uses: softprops/action-gh-release@v2
65
+ with:
66
+ generate_release_notes: true
67
+ discussion_category_name: Announcements
68
+ files: dist/*
69
+ env:
70
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71
+
72
+ publish:
73
+ name: Publish to PyPI
74
+ runs-on: ubuntu-latest
75
+ needs: release
76
+ environment:
77
+ name: pypi
78
+ steps:
79
+ - name: Download build artifacts
80
+ uses: actions/download-artifact@v4
81
+ with:
82
+ name: dist
83
+ path: dist/
84
+
85
+ - name: Install uv
86
+ uses: astral-sh/setup-uv@v7
87
+
88
+ - name: Publish to PyPI
89
+ run: uv publish
@@ -0,0 +1,54 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+
23
+ # Virtual Environment
24
+ .venv/
25
+ venv/
26
+ ENV/
27
+ env/
28
+
29
+ # IDE
30
+ .vscode/
31
+ .idea/
32
+ *.swp
33
+ *.swo
34
+ *~
35
+
36
+ # OS
37
+ .DS_Store
38
+ Thumbs.db
39
+
40
+ # Environment
41
+ .env
42
+ .env.local
43
+
44
+ # Testing
45
+ .pytest_cache/
46
+ .coverage
47
+ htmlcov/
48
+
49
+ # UV
50
+ .uv/
51
+ uv.lock
52
+
53
+ # Logs
54
+ *.log
@@ -0,0 +1,61 @@
1
+ # Agent Development Guide
2
+
3
+ ## Commands
4
+ Use `just` for all development tasks:
5
+
6
+ | Command | Description |
7
+ |---------|-------------|
8
+ | `just install` | Install dependencies |
9
+ | `just check` | Run lint, format, and typecheck |
10
+ | `just fix` | Auto-fix lint/format issues |
11
+ | `just test` | Run pytest test suite |
12
+ | `just server` | Start A2A server (port 8000) |
13
+ | `just tui` | Run TUI application |
14
+ | `just tui-dev` | Run TUI with Textual devtools |
15
+ | `just web` | Serve TUI as web app |
16
+ | `just console` | Run Textual devtools console |
17
+ | `just get-card` | Fetch agent card (CLI) |
18
+ | `just send` | Send message to agent (CLI) |
19
+ | `just version` | Show current version |
20
+
21
+ ## Project Structure
22
+
23
+ ```
24
+ handler/
25
+ ├── packages/
26
+ │ ├── cli/ # handler-cli: CLI tool (click, httpx)
27
+ │ ├── client/ # handler-client: A2A protocol wrapper (a2a-sdk)
28
+ │ ├── common/ # handler-common: Shared utilities (rich, logging)
29
+ │ └── server/ # handler-server: Reference A2A server (google-adk, litellm)
30
+ ├── src/handler/ # handler-app: TUI application (textual)
31
+ └── tests/ # pytest tests
32
+ ```
33
+
34
+ ## Code Style & Conventions
35
+
36
+ - **Python 3.11+** with full type hints
37
+ - **Formatting**: `ruff format` (black compatible)
38
+ - **Linting**: `ruff check`
39
+ - **Type Checking**: `ty check`
40
+ - **Imports**: Standard → Third-party → Local
41
+ - **Testing**: pytest with pytest-asyncio for async tests
42
+
43
+ ## Environment Variables
44
+
45
+ - `OLLAMA_API_BASE`: Ollama server URL (default: `http://localhost:11434`)
46
+ - `OLLAMA_MODEL`: Model to use (default: `qwen3`)
47
+
48
+ ## A2A Protocol
49
+
50
+ The `packages/client` library encapsulates A2A protocol logic:
51
+ - `build_http_client()` - Create configured HTTP client
52
+ - `fetch_agent_card()` - Retrieve agent metadata
53
+ - `send_message_to_agent()` - Send messages and get responses
54
+
55
+ ## Key Dependencies
56
+
57
+ - **CLI**: `click`, `httpx`
58
+ - **Client**: `a2a-sdk`, `httpx`
59
+ - **Server**: `google-adk`, `litellm`, `uvicorn`
60
+ - **TUI**: `textual`
61
+ - **Common**: `rich`
@@ -0,0 +1,72 @@
1
+ # Contributing to Handler
2
+
3
+ ## Architecture
4
+
5
+ Handler is a [uv managed workspace](https://docs.astral.sh/uv/concepts/projects/workspaces/) with five packages:
6
+
7
+ | Package | Name | Description |
8
+ |---------|------|-------------|
9
+ | `packages/cli` | `handler-cli` | CLI built with `click`. Entry point: `handler` |
10
+ | `packages/client` | `handler-client` | A2A protocol client library using `a2a-sdk` |
11
+ | `packages/common` | `handler-common` | Shared utilities (logging, printing with `rich`) |
12
+ | `packages/server` | `handler-server` | Reference A2A agent using `google-adk` + `litellm` |
13
+ | `src/handler` | `handler-app` | TUI application built with `textual` |
14
+
15
+ ## Prerequisites
16
+
17
+ - **Python 3.11+**
18
+ - **[uv](https://github.com/astral-sh/uv)** for dependency management
19
+ - **[just](https://github.com/casey/just)** for running commands (recommended)
20
+ - **[Ollama](https://ollama.com/)** for running the reference server agent
21
+
22
+ ## Setup
23
+
24
+ ```bash
25
+ git clone https://github.com/alDuncanson/handler.git
26
+ cd handler
27
+ just install # or: uv sync
28
+ ```
29
+
30
+ ## Development Commands
31
+
32
+ | Command | Description |
33
+ |---------|-------------|
34
+ | `just install` | Install dependencies |
35
+ | `just check` | Run lint, format, and typecheck |
36
+ | `just fix` | Auto-fix lint/format issues |
37
+ | `just test` | Run pytest test suite |
38
+ | `just server` | Start A2A server on port 8000 |
39
+ | `just tui` | Run TUI application |
40
+ | `just tui-dev` | Run TUI with Textual devtools |
41
+ | `just web` | Serve TUI as web app |
42
+ | `just console` | Run Textual devtools console |
43
+ | `just get-card [url]` | Fetch agent card from URL |
44
+ | `just send [url] [msg]` | Send message to agent |
45
+ | `just version` | Show current version |
46
+
47
+ ## Code Style
48
+
49
+ - **Formatting**: `ruff format` (black compatible)
50
+ - **Linting**: `ruff check`
51
+ - **Type Checking**: `ty check`
52
+ - **Imports**: Standard → Third-party → Local
53
+ - **Testing**: Add `pytest` tests for new functionality
54
+
55
+ ## Environment Variables
56
+
57
+ | Variable | Default | Description |
58
+ |----------|---------|-------------|
59
+ | `OLLAMA_API_BASE` | `http://localhost:11434` | Ollama server URL |
60
+ | `OLLAMA_MODEL` | `qwen3` | Model for reference agent |
61
+
62
+ ## A2A Protocol
63
+
64
+ The `packages/client` library provides the A2A protocol implementation:
65
+
66
+ ```python
67
+ from handler_client import build_http_client, fetch_agent_card, send_message_to_agent
68
+
69
+ async with build_http_client() as client:
70
+ card = await fetch_agent_card("http://localhost:8000", client)
71
+ response = await send_message_to_agent("http://localhost:8000", "Hello", client)
72
+ ```