axonpush 0.0.1__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.
- axonpush-0.0.1/.gitignore +13 -0
- axonpush-0.0.1/.python-version +1 -0
- axonpush-0.0.1/LICENSE +21 -0
- axonpush-0.0.1/PKG-INFO +258 -0
- axonpush-0.0.1/README.md +214 -0
- axonpush-0.0.1/pyproject.toml +65 -0
- axonpush-0.0.1/src/axonpush/__init__.py +48 -0
- axonpush-0.0.1/src/axonpush/_auth.py +24 -0
- axonpush-0.0.1/src/axonpush/_http.py +121 -0
- axonpush-0.0.1/src/axonpush/_tracing.py +52 -0
- axonpush-0.0.1/src/axonpush/_version.py +1 -0
- axonpush-0.0.1/src/axonpush/client.py +102 -0
- axonpush-0.0.1/src/axonpush/exceptions.py +37 -0
- axonpush-0.0.1/src/axonpush/integrations/__init__.py +7 -0
- axonpush-0.0.1/src/axonpush/integrations/anthropic.py +184 -0
- axonpush-0.0.1/src/axonpush/integrations/crewai.py +132 -0
- axonpush-0.0.1/src/axonpush/integrations/langchain.py +250 -0
- axonpush-0.0.1/src/axonpush/integrations/openai_agents.py +133 -0
- axonpush-0.0.1/src/axonpush/models/__init__.py +26 -0
- axonpush-0.0.1/src/axonpush/models/apps.py +19 -0
- axonpush-0.0.1/src/axonpush/models/channels.py +20 -0
- axonpush-0.0.1/src/axonpush/models/common.py +8 -0
- axonpush-0.0.1/src/axonpush/models/events.py +49 -0
- axonpush-0.0.1/src/axonpush/models/traces.py +33 -0
- axonpush-0.0.1/src/axonpush/models/webhooks.py +51 -0
- axonpush-0.0.1/src/axonpush/py.typed +0 -0
- axonpush-0.0.1/src/axonpush/realtime/__init__.py +3 -0
- axonpush-0.0.1/src/axonpush/realtime/sse.py +86 -0
- axonpush-0.0.1/src/axonpush/realtime/websocket.py +210 -0
- axonpush-0.0.1/src/axonpush/resources/__init__.py +18 -0
- axonpush-0.0.1/src/axonpush/resources/apps.py +69 -0
- axonpush-0.0.1/src/axonpush/resources/channels.py +107 -0
- axonpush-0.0.1/src/axonpush/resources/events.py +109 -0
- axonpush-0.0.1/src/axonpush/resources/traces.py +52 -0
- axonpush-0.0.1/src/axonpush/resources/webhooks.py +96 -0
- axonpush-0.0.1/tests/__init__.py +0 -0
- axonpush-0.0.1/tests/conftest.py +40 -0
- axonpush-0.0.1/tests/test_async.py +69 -0
- axonpush-0.0.1/tests/test_client.py +36 -0
- axonpush-0.0.1/tests/test_resources/__init__.py +0 -0
- axonpush-0.0.1/tests/test_resources/test_apps.py +14 -0
- axonpush-0.0.1/tests/test_resources/test_channels.py +28 -0
- axonpush-0.0.1/tests/test_resources/test_events.py +88 -0
- axonpush-0.0.1/tests/test_resources/test_traces.py +64 -0
- axonpush-0.0.1/tests/test_resources/test_webhooks.py +45 -0
- axonpush-0.0.1/tests/test_sse.py +126 -0
- axonpush-0.0.1/tests/test_websocket.py +82 -0
- axonpush-0.0.1/uv.lock +4795 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.13
|
axonpush-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 AxonPush
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
axonpush-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: axonpush
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Python SDK for AxonPush — real-time event infrastructure for AI agent systems
|
|
5
|
+
Author: AxonPush
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Framework :: Pydantic :: 2
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Typing :: Typed
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Requires-Dist: httpx-sse<1.0,>=0.4.0
|
|
18
|
+
Requires-Dist: httpx<1.0,>=0.25.0
|
|
19
|
+
Requires-Dist: pydantic<3.0,>=2.0
|
|
20
|
+
Requires-Dist: requests>=2.32.5
|
|
21
|
+
Provides-Extra: all
|
|
22
|
+
Requires-Dist: anthropic>=0.30.0; extra == 'all'
|
|
23
|
+
Requires-Dist: crewai>=0.50.0; extra == 'all'
|
|
24
|
+
Requires-Dist: langchain-core>=0.1.0; extra == 'all'
|
|
25
|
+
Requires-Dist: openai-agents>=0.1.0; extra == 'all'
|
|
26
|
+
Requires-Dist: python-socketio[asyncio-client]<6.0,>=5.10; extra == 'all'
|
|
27
|
+
Provides-Extra: anthropic
|
|
28
|
+
Requires-Dist: anthropic>=0.30.0; extra == 'anthropic'
|
|
29
|
+
Provides-Extra: crewai
|
|
30
|
+
Requires-Dist: crewai>=0.50.0; extra == 'crewai'
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
34
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: respx>=0.21; extra == 'dev'
|
|
36
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
37
|
+
Provides-Extra: langchain
|
|
38
|
+
Requires-Dist: langchain-core>=0.1.0; extra == 'langchain'
|
|
39
|
+
Provides-Extra: openai-agents
|
|
40
|
+
Requires-Dist: openai-agents>=0.1.0; extra == 'openai-agents'
|
|
41
|
+
Provides-Extra: websocket
|
|
42
|
+
Requires-Dist: python-socketio[asyncio-client]<6.0,>=5.10; extra == 'websocket'
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
|
|
45
|
+
# axonpush
|
|
46
|
+
|
|
47
|
+
Python SDK for [AxonPush](https://axonpush.com) — real-time event infrastructure for AI agent systems.
|
|
48
|
+
|
|
49
|
+
Publish, subscribe, trace, and deliver agent events with sub-100ms latency. Drop-in integrations for LangChain, OpenAI Agents SDK, Claude/Anthropic, and CrewAI.
|
|
50
|
+
|
|
51
|
+
## Install
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install axonpush
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
With framework integrations:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install axonpush[langchain] # LangChain/LangGraph
|
|
61
|
+
pip install axonpush[openai-agents] # OpenAI Agents SDK
|
|
62
|
+
pip install axonpush[anthropic] # Claude/Anthropic
|
|
63
|
+
pip install axonpush[crewai] # CrewAI
|
|
64
|
+
pip install axonpush[all] # Everything
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Quick Start
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from axonpush import AxonPush, EventType
|
|
71
|
+
|
|
72
|
+
with AxonPush(api_key="ak_...", tenant_id="1", base_url="https://...") as client:
|
|
73
|
+
# Publish an event
|
|
74
|
+
event = client.events.publish(
|
|
75
|
+
"web_search",
|
|
76
|
+
{"query": "AI agent frameworks"},
|
|
77
|
+
channel_id=1,
|
|
78
|
+
agent_id="researcher",
|
|
79
|
+
trace_id="tr_run_42",
|
|
80
|
+
event_type=EventType.AGENT_TOOL_CALL_START,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
# List events
|
|
84
|
+
events = client.events.list(channel_id=1)
|
|
85
|
+
|
|
86
|
+
# Get a trace summary
|
|
87
|
+
summary = client.traces.get_summary("tr_run_42")
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Async
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from axonpush import AsyncAxonPush
|
|
94
|
+
|
|
95
|
+
async with AsyncAxonPush(api_key="ak_...", tenant_id="1", base_url="https://...") as client:
|
|
96
|
+
event = await client.events.publish(
|
|
97
|
+
"web_search",
|
|
98
|
+
{"query": "AI agents"},
|
|
99
|
+
channel_id=1,
|
|
100
|
+
agent_id="researcher",
|
|
101
|
+
event_type="agent.tool_call.start",
|
|
102
|
+
)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Framework Integrations
|
|
106
|
+
|
|
107
|
+
### LangChain / LangGraph
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from axonpush import AxonPush
|
|
111
|
+
from axonpush.integrations.langchain import AxonPushCallbackHandler
|
|
112
|
+
|
|
113
|
+
client = AxonPush(api_key="ak_...", tenant_id="1", base_url="https://...")
|
|
114
|
+
handler = AxonPushCallbackHandler(client, channel_id=1, agent_id="my-agent")
|
|
115
|
+
|
|
116
|
+
# All chain/tool/LLM events are published automatically
|
|
117
|
+
chain.invoke({"input": "..."}, config={"callbacks": [handler]})
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### OpenAI Agents SDK
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from axonpush import AsyncAxonPush
|
|
124
|
+
from axonpush.integrations.openai_agents import AxonPushRunHooks
|
|
125
|
+
|
|
126
|
+
client = AsyncAxonPush(api_key="ak_...", tenant_id="1", base_url="https://...")
|
|
127
|
+
hooks = AxonPushRunHooks(client, channel_id=1)
|
|
128
|
+
|
|
129
|
+
result = await Runner.run(agent, input="...", hooks=hooks)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Claude / Anthropic
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
from axonpush import AxonPush
|
|
136
|
+
from axonpush.integrations.anthropic import AxonPushAnthropicTracer
|
|
137
|
+
|
|
138
|
+
client = AxonPush(api_key="ak_...", tenant_id="1", base_url="https://...")
|
|
139
|
+
tracer = AxonPushAnthropicTracer(client, channel_id=1)
|
|
140
|
+
|
|
141
|
+
# Wraps messages.create() — auto-emits events for tool_use, text, turns
|
|
142
|
+
response = tracer.create_message(
|
|
143
|
+
anthropic_client,
|
|
144
|
+
model="claude-sonnet-4-20250514",
|
|
145
|
+
messages=[{"role": "user", "content": "Hello"}],
|
|
146
|
+
)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### CrewAI
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
from axonpush import AxonPush
|
|
153
|
+
from axonpush.integrations.crewai import AxonPushCrewCallbacks
|
|
154
|
+
|
|
155
|
+
client = AxonPush(api_key="ak_...", tenant_id="1", base_url="https://...")
|
|
156
|
+
callbacks = AxonPushCrewCallbacks(client, channel_id=1)
|
|
157
|
+
|
|
158
|
+
callbacks.on_crew_start()
|
|
159
|
+
result = Crew(
|
|
160
|
+
agents=[...],
|
|
161
|
+
tasks=[...],
|
|
162
|
+
step_callback=callbacks.on_step,
|
|
163
|
+
task_callback=callbacks.on_task_complete,
|
|
164
|
+
).kickoff()
|
|
165
|
+
callbacks.on_crew_end(result)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Real-Time Subscriptions
|
|
169
|
+
|
|
170
|
+
axonpush supports two real-time subscription mechanisms: **SSE** (Server-Sent Events) and **WebSocket** (Socket.IO).
|
|
171
|
+
|
|
172
|
+
### SSE (Server-Sent Events)
|
|
173
|
+
|
|
174
|
+
SSE is the simplest way to consume events in real time — no extra dependencies required.
|
|
175
|
+
|
|
176
|
+
#### Subscribe to all events on a channel
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
from axonpush import AxonPush
|
|
180
|
+
|
|
181
|
+
with AxonPush(api_key="ak_...", tenant_id="1", base_url="https://...") as client:
|
|
182
|
+
with client.channels.subscribe_sse(channel_id=1) as sub:
|
|
183
|
+
for event in sub:
|
|
184
|
+
print(event.agent_id, event.identifier, event.payload)
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
#### Subscribe to a specific event identifier
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
with client.channels.subscribe_event_sse(channel_id=1, event_identifier="web_search") as sub:
|
|
191
|
+
for event in sub:
|
|
192
|
+
print(event.payload)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
#### Filter by agent, event type, or trace
|
|
196
|
+
|
|
197
|
+
All SSE methods accept optional filters to narrow the event stream:
|
|
198
|
+
|
|
199
|
+
```python
|
|
200
|
+
with client.channels.subscribe_sse(
|
|
201
|
+
channel_id=1,
|
|
202
|
+
agent_id="researcher",
|
|
203
|
+
event_type=EventType.AGENT_ERROR,
|
|
204
|
+
trace_id="tr_run_42",
|
|
205
|
+
) as sub:
|
|
206
|
+
for event in sub:
|
|
207
|
+
print(f"[{event.agent_id}] {event.identifier}: {event.payload}")
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### WebSocket (Socket.IO)
|
|
211
|
+
|
|
212
|
+
WebSocket subscriptions are callback-based and support bidirectional communication (subscribe, publish, unsubscribe).
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
pip install axonpush[websocket]
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
#### Sync
|
|
219
|
+
|
|
220
|
+
```python
|
|
221
|
+
ws = client.connect_websocket()
|
|
222
|
+
ws.on_event(lambda e: print(e.agent_id, e.payload))
|
|
223
|
+
ws.subscribe(channel_id=1, event_type="agent.tool_call.start")
|
|
224
|
+
ws.wait() # blocks until disconnected
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
#### Async
|
|
228
|
+
|
|
229
|
+
```python
|
|
230
|
+
ws = await async_client.connect_websocket()
|
|
231
|
+
ws.on_event(lambda e: print(e.agent_id, e.payload))
|
|
232
|
+
await ws.subscribe(channel_id=1, event_type="agent.tool_call.start")
|
|
233
|
+
await ws.wait()
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
#### Publish and unsubscribe via WebSocket
|
|
237
|
+
|
|
238
|
+
```python
|
|
239
|
+
ws.publish(channel_id=1, identifier="status", payload={"step": "done"}, agent_id="worker")
|
|
240
|
+
ws.unsubscribe(channel_id=1)
|
|
241
|
+
ws.disconnect()
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Resources
|
|
245
|
+
|
|
246
|
+
The client exposes Stripe-style resource objects:
|
|
247
|
+
|
|
248
|
+
| Resource | Methods |
|
|
249
|
+
|---|---|
|
|
250
|
+
| `client.events` | `publish()`, `list()` |
|
|
251
|
+
| `client.channels` | `create()`, `get()`, `update()`, `delete()`, `subscribe_sse()` |
|
|
252
|
+
| `client.apps` | `create()`, `get()`, `list()`, `update()`, `delete()` |
|
|
253
|
+
| `client.webhooks` | `create_endpoint()`, `list_endpoints()`, `delete_endpoint()`, `get_deliveries()` |
|
|
254
|
+
| `client.traces` | `list()`, `get_events()`, `get_summary()` |
|
|
255
|
+
|
|
256
|
+
## License
|
|
257
|
+
|
|
258
|
+
MIT
|
axonpush-0.0.1/README.md
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# axonpush
|
|
2
|
+
|
|
3
|
+
Python SDK for [AxonPush](https://axonpush.com) — real-time event infrastructure for AI agent systems.
|
|
4
|
+
|
|
5
|
+
Publish, subscribe, trace, and deliver agent events with sub-100ms latency. Drop-in integrations for LangChain, OpenAI Agents SDK, Claude/Anthropic, and CrewAI.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install axonpush
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
With framework integrations:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install axonpush[langchain] # LangChain/LangGraph
|
|
17
|
+
pip install axonpush[openai-agents] # OpenAI Agents SDK
|
|
18
|
+
pip install axonpush[anthropic] # Claude/Anthropic
|
|
19
|
+
pip install axonpush[crewai] # CrewAI
|
|
20
|
+
pip install axonpush[all] # Everything
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from axonpush import AxonPush, EventType
|
|
27
|
+
|
|
28
|
+
with AxonPush(api_key="ak_...", tenant_id="1", base_url="https://...") as client:
|
|
29
|
+
# Publish an event
|
|
30
|
+
event = client.events.publish(
|
|
31
|
+
"web_search",
|
|
32
|
+
{"query": "AI agent frameworks"},
|
|
33
|
+
channel_id=1,
|
|
34
|
+
agent_id="researcher",
|
|
35
|
+
trace_id="tr_run_42",
|
|
36
|
+
event_type=EventType.AGENT_TOOL_CALL_START,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
# List events
|
|
40
|
+
events = client.events.list(channel_id=1)
|
|
41
|
+
|
|
42
|
+
# Get a trace summary
|
|
43
|
+
summary = client.traces.get_summary("tr_run_42")
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Async
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from axonpush import AsyncAxonPush
|
|
50
|
+
|
|
51
|
+
async with AsyncAxonPush(api_key="ak_...", tenant_id="1", base_url="https://...") as client:
|
|
52
|
+
event = await client.events.publish(
|
|
53
|
+
"web_search",
|
|
54
|
+
{"query": "AI agents"},
|
|
55
|
+
channel_id=1,
|
|
56
|
+
agent_id="researcher",
|
|
57
|
+
event_type="agent.tool_call.start",
|
|
58
|
+
)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Framework Integrations
|
|
62
|
+
|
|
63
|
+
### LangChain / LangGraph
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from axonpush import AxonPush
|
|
67
|
+
from axonpush.integrations.langchain import AxonPushCallbackHandler
|
|
68
|
+
|
|
69
|
+
client = AxonPush(api_key="ak_...", tenant_id="1", base_url="https://...")
|
|
70
|
+
handler = AxonPushCallbackHandler(client, channel_id=1, agent_id="my-agent")
|
|
71
|
+
|
|
72
|
+
# All chain/tool/LLM events are published automatically
|
|
73
|
+
chain.invoke({"input": "..."}, config={"callbacks": [handler]})
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### OpenAI Agents SDK
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from axonpush import AsyncAxonPush
|
|
80
|
+
from axonpush.integrations.openai_agents import AxonPushRunHooks
|
|
81
|
+
|
|
82
|
+
client = AsyncAxonPush(api_key="ak_...", tenant_id="1", base_url="https://...")
|
|
83
|
+
hooks = AxonPushRunHooks(client, channel_id=1)
|
|
84
|
+
|
|
85
|
+
result = await Runner.run(agent, input="...", hooks=hooks)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Claude / Anthropic
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from axonpush import AxonPush
|
|
92
|
+
from axonpush.integrations.anthropic import AxonPushAnthropicTracer
|
|
93
|
+
|
|
94
|
+
client = AxonPush(api_key="ak_...", tenant_id="1", base_url="https://...")
|
|
95
|
+
tracer = AxonPushAnthropicTracer(client, channel_id=1)
|
|
96
|
+
|
|
97
|
+
# Wraps messages.create() — auto-emits events for tool_use, text, turns
|
|
98
|
+
response = tracer.create_message(
|
|
99
|
+
anthropic_client,
|
|
100
|
+
model="claude-sonnet-4-20250514",
|
|
101
|
+
messages=[{"role": "user", "content": "Hello"}],
|
|
102
|
+
)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### CrewAI
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from axonpush import AxonPush
|
|
109
|
+
from axonpush.integrations.crewai import AxonPushCrewCallbacks
|
|
110
|
+
|
|
111
|
+
client = AxonPush(api_key="ak_...", tenant_id="1", base_url="https://...")
|
|
112
|
+
callbacks = AxonPushCrewCallbacks(client, channel_id=1)
|
|
113
|
+
|
|
114
|
+
callbacks.on_crew_start()
|
|
115
|
+
result = Crew(
|
|
116
|
+
agents=[...],
|
|
117
|
+
tasks=[...],
|
|
118
|
+
step_callback=callbacks.on_step,
|
|
119
|
+
task_callback=callbacks.on_task_complete,
|
|
120
|
+
).kickoff()
|
|
121
|
+
callbacks.on_crew_end(result)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Real-Time Subscriptions
|
|
125
|
+
|
|
126
|
+
axonpush supports two real-time subscription mechanisms: **SSE** (Server-Sent Events) and **WebSocket** (Socket.IO).
|
|
127
|
+
|
|
128
|
+
### SSE (Server-Sent Events)
|
|
129
|
+
|
|
130
|
+
SSE is the simplest way to consume events in real time — no extra dependencies required.
|
|
131
|
+
|
|
132
|
+
#### Subscribe to all events on a channel
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
from axonpush import AxonPush
|
|
136
|
+
|
|
137
|
+
with AxonPush(api_key="ak_...", tenant_id="1", base_url="https://...") as client:
|
|
138
|
+
with client.channels.subscribe_sse(channel_id=1) as sub:
|
|
139
|
+
for event in sub:
|
|
140
|
+
print(event.agent_id, event.identifier, event.payload)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
#### Subscribe to a specific event identifier
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
with client.channels.subscribe_event_sse(channel_id=1, event_identifier="web_search") as sub:
|
|
147
|
+
for event in sub:
|
|
148
|
+
print(event.payload)
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
#### Filter by agent, event type, or trace
|
|
152
|
+
|
|
153
|
+
All SSE methods accept optional filters to narrow the event stream:
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
with client.channels.subscribe_sse(
|
|
157
|
+
channel_id=1,
|
|
158
|
+
agent_id="researcher",
|
|
159
|
+
event_type=EventType.AGENT_ERROR,
|
|
160
|
+
trace_id="tr_run_42",
|
|
161
|
+
) as sub:
|
|
162
|
+
for event in sub:
|
|
163
|
+
print(f"[{event.agent_id}] {event.identifier}: {event.payload}")
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### WebSocket (Socket.IO)
|
|
167
|
+
|
|
168
|
+
WebSocket subscriptions are callback-based and support bidirectional communication (subscribe, publish, unsubscribe).
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
pip install axonpush[websocket]
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
#### Sync
|
|
175
|
+
|
|
176
|
+
```python
|
|
177
|
+
ws = client.connect_websocket()
|
|
178
|
+
ws.on_event(lambda e: print(e.agent_id, e.payload))
|
|
179
|
+
ws.subscribe(channel_id=1, event_type="agent.tool_call.start")
|
|
180
|
+
ws.wait() # blocks until disconnected
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
#### Async
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
ws = await async_client.connect_websocket()
|
|
187
|
+
ws.on_event(lambda e: print(e.agent_id, e.payload))
|
|
188
|
+
await ws.subscribe(channel_id=1, event_type="agent.tool_call.start")
|
|
189
|
+
await ws.wait()
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
#### Publish and unsubscribe via WebSocket
|
|
193
|
+
|
|
194
|
+
```python
|
|
195
|
+
ws.publish(channel_id=1, identifier="status", payload={"step": "done"}, agent_id="worker")
|
|
196
|
+
ws.unsubscribe(channel_id=1)
|
|
197
|
+
ws.disconnect()
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Resources
|
|
201
|
+
|
|
202
|
+
The client exposes Stripe-style resource objects:
|
|
203
|
+
|
|
204
|
+
| Resource | Methods |
|
|
205
|
+
|---|---|
|
|
206
|
+
| `client.events` | `publish()`, `list()` |
|
|
207
|
+
| `client.channels` | `create()`, `get()`, `update()`, `delete()`, `subscribe_sse()` |
|
|
208
|
+
| `client.apps` | `create()`, `get()`, `list()`, `update()`, `delete()` |
|
|
209
|
+
| `client.webhooks` | `create_endpoint()`, `list_endpoints()`, `delete_endpoint()`, `get_deliveries()` |
|
|
210
|
+
| `client.traces` | `list()`, `get_events()`, `get_summary()` |
|
|
211
|
+
|
|
212
|
+
## License
|
|
213
|
+
|
|
214
|
+
MIT
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "axonpush"
|
|
3
|
+
version = "0.0.1"
|
|
4
|
+
description = "Python SDK for AxonPush — real-time event infrastructure for AI agent systems"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
requires-python = ">=3.10"
|
|
8
|
+
authors = [{ name = "AxonPush" }]
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Development Status :: 4 - Beta",
|
|
11
|
+
"Typing :: Typed",
|
|
12
|
+
"Framework :: Pydantic :: 2",
|
|
13
|
+
"Programming Language :: Python :: 3",
|
|
14
|
+
"Programming Language :: Python :: 3.10",
|
|
15
|
+
"Programming Language :: Python :: 3.11",
|
|
16
|
+
"Programming Language :: Python :: 3.12",
|
|
17
|
+
"Programming Language :: Python :: 3.13",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
dependencies = [
|
|
21
|
+
"httpx>=0.25.0,<1.0",
|
|
22
|
+
"pydantic>=2.0,<3.0",
|
|
23
|
+
"httpx-sse>=0.4.0,<1.0",
|
|
24
|
+
"requests>=2.32.5",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.optional-dependencies]
|
|
28
|
+
websocket = ["python-socketio[asyncio_client]>=5.10,<6.0"]
|
|
29
|
+
langchain = ["langchain-core>=0.1.0"]
|
|
30
|
+
openai-agents = ["openai-agents>=0.1.0"]
|
|
31
|
+
anthropic = ["anthropic>=0.30.0"]
|
|
32
|
+
crewai = ["crewai>=0.50.0"]
|
|
33
|
+
all = [
|
|
34
|
+
"axonpush[websocket]",
|
|
35
|
+
"axonpush[langchain]",
|
|
36
|
+
"axonpush[openai-agents]",
|
|
37
|
+
"axonpush[anthropic]",
|
|
38
|
+
"axonpush[crewai]",
|
|
39
|
+
]
|
|
40
|
+
dev = [
|
|
41
|
+
"pytest>=8.0",
|
|
42
|
+
"pytest-asyncio>=0.23",
|
|
43
|
+
"respx>=0.21",
|
|
44
|
+
"ruff>=0.4",
|
|
45
|
+
"mypy>=1.10",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[build-system]
|
|
49
|
+
requires = ["hatchling"]
|
|
50
|
+
build-backend = "hatchling.build"
|
|
51
|
+
|
|
52
|
+
[tool.hatch.build.targets.wheel]
|
|
53
|
+
packages = ["src/axonpush"]
|
|
54
|
+
|
|
55
|
+
[tool.ruff]
|
|
56
|
+
target-version = "py310"
|
|
57
|
+
line-length = 100
|
|
58
|
+
|
|
59
|
+
[tool.mypy]
|
|
60
|
+
python_version = "3.10"
|
|
61
|
+
strict = true
|
|
62
|
+
|
|
63
|
+
[tool.pytest.ini_options]
|
|
64
|
+
asyncio_mode = "auto"
|
|
65
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""AxonPush — Python SDK for real-time event infrastructure for AI agent systems."""
|
|
2
|
+
|
|
3
|
+
from axonpush._tracing import TraceContext, get_or_create_trace
|
|
4
|
+
from axonpush._version import __version__
|
|
5
|
+
from axonpush.client import AsyncAxonPush, AxonPush
|
|
6
|
+
from axonpush.exceptions import (
|
|
7
|
+
AuthenticationError,
|
|
8
|
+
AxonPushError,
|
|
9
|
+
ForbiddenError,
|
|
10
|
+
NotFoundError,
|
|
11
|
+
RateLimitError,
|
|
12
|
+
ServerError,
|
|
13
|
+
ValidationError,
|
|
14
|
+
)
|
|
15
|
+
from axonpush.models.apps import App
|
|
16
|
+
from axonpush.models.channels import Channel
|
|
17
|
+
from axonpush.models.events import Event, EventType
|
|
18
|
+
from axonpush.models.traces import TraceListItem, TraceSummary
|
|
19
|
+
from axonpush.models.webhooks import DeliveryStatus, WebhookDelivery, WebhookEndpoint
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
# Clients
|
|
23
|
+
"AxonPush",
|
|
24
|
+
"AsyncAxonPush",
|
|
25
|
+
# Models
|
|
26
|
+
"App",
|
|
27
|
+
"Channel",
|
|
28
|
+
"DeliveryStatus",
|
|
29
|
+
"Event",
|
|
30
|
+
"EventType",
|
|
31
|
+
"TraceListItem",
|
|
32
|
+
"TraceSummary",
|
|
33
|
+
"WebhookDelivery",
|
|
34
|
+
"WebhookEndpoint",
|
|
35
|
+
# Tracing
|
|
36
|
+
"TraceContext",
|
|
37
|
+
"get_or_create_trace",
|
|
38
|
+
# Exceptions
|
|
39
|
+
"AuthenticationError",
|
|
40
|
+
"AxonPushError",
|
|
41
|
+
"ForbiddenError",
|
|
42
|
+
"NotFoundError",
|
|
43
|
+
"RateLimitError",
|
|
44
|
+
"ServerError",
|
|
45
|
+
"ValidationError",
|
|
46
|
+
# Meta
|
|
47
|
+
"__version__",
|
|
48
|
+
]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class AuthConfig:
|
|
5
|
+
"""Immutable auth configuration. Thread-safe (read-only after construction)."""
|
|
6
|
+
|
|
7
|
+
__slots__ = ("api_key", "tenant_id", "base_url")
|
|
8
|
+
|
|
9
|
+
def __init__(
|
|
10
|
+
self,
|
|
11
|
+
api_key: str,
|
|
12
|
+
tenant_id: str,
|
|
13
|
+
base_url: str,
|
|
14
|
+
) -> None:
|
|
15
|
+
self.api_key = api_key
|
|
16
|
+
self.tenant_id = tenant_id
|
|
17
|
+
self.base_url = base_url.rstrip("/")
|
|
18
|
+
|
|
19
|
+
def headers(self) -> dict[str, str]:
|
|
20
|
+
return {
|
|
21
|
+
"X-API-Key": self.api_key,
|
|
22
|
+
"x-tenant-id": self.tenant_id,
|
|
23
|
+
"Content-Type": "application/json",
|
|
24
|
+
}
|