You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Update AGENTS.md with file tree diagram, client API reference, key file locations
- Rewrite README.md with features list, expanded quick start, API reference, error handling
- Standardize CODE_OF_CONDUCT.md and SECURITY.md across ecosystem
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
├── tests/ # Test suite with mocked HTTP responses
47
+
├── examples/ # Runnable example scripts
48
+
├── scripts/ # Boundary guards, tooling scripts
49
+
└── docs/ # Architecture documentation
50
+
```
31
51
32
52
## Conventions
33
53
@@ -78,6 +98,69 @@ Every public client method wraps its logic in a `_do()` closure passed to `with_
78
98
### Dual Client Pattern
79
99
`HawkClient` (sync) and `AsyncHawkClient` (async) are structurally identical. Every method exists on both. Sync uses `httpx.Client` + `with_retry_sync`; async uses `httpx.AsyncClient` + `with_retry`. When adding a new method, add it to both classes with identical signatures (minus `async`/`await`).
80
100
101
+
## Client API Reference
102
+
103
+
### HawkClient / AsyncHawkClient
104
+
105
+
Both clients share the same constructor and method signatures.
106
+
107
+
```python
108
+
HawkClient(
109
+
base_url: str="http://127.0.0.1:4590",
110
+
api_key: str|None=None,
111
+
retry_config: RetryConfig |None=None,
112
+
timeout: float=30.0,
113
+
pool_connections: int=10,
114
+
pool_maxsize: int=100,
115
+
)
116
+
```
117
+
118
+
**Methods:**
119
+
120
+
| Method | Path | Returns | Description |
121
+
|--------|------|---------|-------------|
122
+
|`health()`|`GET /v1/health`|`HealthResponse`| Check daemon connectivity and version |
123
+
|`chat(prompt)`|`POST /v1/chat`|`ChatResponse`| Send a prompt, get complete response |
124
+
|`chat_stream(prompt)`|`POST /v1/chat`|`StreamReader`| Send a prompt, stream SSE response |
125
+
|`get_session(session_id)`|`GET /v1/sessions/{id}`|`SessionDetail`| Get full session detail |
126
+
|`list_sessions()`|`GET /v1/sessions`|`list[SessionSummary]`| List active sessions |
127
+
|`delete_session(session_id)`|`DELETE /v1/sessions/{id}`|`None`| Delete a session |
128
+
|`list_messages(session_id)`|`GET /v1/sessions/{id}/messages`|`PaginatedResponse[Message]`| List messages with pagination |
129
+
|`stats()`|`GET /v1/stats`|`StatsResponse`| Get aggregated usage statistics |
130
+
131
+
### Typed Errors
132
+
133
+
All API errors inherit from `HawkAPIError`. Catch specific subclasses:
134
+
135
+
```python
136
+
from hawk import HawkAPIError, RateLimitError, AuthenticationError, NotFoundError
137
+
138
+
# HawkAPIError (base class)
139
+
# RateLimitError — 429, has .retry_after property
140
+
# AuthenticationError — 401
141
+
# ForbiddenError — 403
142
+
# BadRequestError — 400
143
+
# NotFoundError — 404
144
+
# InternalServerError — 500
145
+
# ServiceUnavailableError — 503
146
+
```
147
+
148
+
### StreamReader / AsyncStreamReader
149
+
150
+
```python
151
+
with HawkClient() as client:
152
+
with client.chat_stream("Hello") as stream:
153
+
# Iterate events
154
+
for event in stream.events():
155
+
print(event.data)
156
+
157
+
# Collect all text
158
+
text = stream.collect_text()
159
+
160
+
# Collect tool calls
161
+
calls = stream.collect_tool_calls()
162
+
```
163
+
81
164
## Testing Patterns
82
165
83
166
### HTTP Mocking
@@ -113,11 +196,14 @@ SSE body strings follow the format `"event: content\ndata: Hello\n\n"`. Tests ve
The Hawk SDK for Python provides an idiomatic client for interacting with the [Hawk](https://github.com/GrayCodeAI/hawk) daemon API. It supports both synchronous and async operations, including streaming.
15
+
The Hawk SDK for Python is the official client for interacting with the [Hawk](https://github.com/GrayCodeAI/hawk)
16
+
daemon API. It provides an idiomatic Python interface for chat, streaming, sessions,
17
+
stats, and agent orchestration. Both synchronous and async clients are provided, with
18
+
the same API surface on each.
16
19
17
20
## Features
18
21
19
-
-**Sync and async** - Use `HawkClient` or `AsyncHawkClient`
0 commit comments