aerograph-sdk 0.2.0__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.
- aerograph_sdk-0.2.0/.gitignore +37 -0
- aerograph_sdk-0.2.0/PKG-INFO +63 -0
- aerograph_sdk-0.2.0/README.md +36 -0
- aerograph_sdk-0.2.0/examples/minimal_trace.py +108 -0
- aerograph_sdk-0.2.0/pyproject.toml +53 -0
- aerograph_sdk-0.2.0/src/aerograph_sdk/__init__.py +25 -0
- aerograph_sdk-0.2.0/src/aerograph_sdk/contracts/__init__.py +83 -0
- aerograph_sdk-0.2.0/src/aerograph_sdk/contracts/generated.py +564 -0
- aerograph_sdk-0.2.0/src/aerograph_sdk/events.py +423 -0
- aerograph_sdk-0.2.0/src/aerograph_sdk/ids.py +38 -0
- aerograph_sdk-0.2.0/src/aerograph_sdk/json_normalize.py +60 -0
- aerograph_sdk-0.2.0/src/aerograph_sdk/recorder.py +669 -0
- aerograph_sdk-0.2.0/src/aerograph_sdk/state_hash.py +183 -0
- aerograph_sdk-0.2.0/tests/__init__.py +1 -0
- aerograph_sdk-0.2.0/tests/integration/test_api_emission.py +27 -0
- aerograph_sdk-0.2.0/tests/test_emitter.py +337 -0
- aerograph_sdk-0.2.0/tests/test_event_ordering.py +134 -0
- aerograph_sdk-0.2.0/tests/test_state_hash_parity.py +163 -0
- aerograph_sdk-0.2.0/tests/test_trace_event_models.py +281 -0
- aerograph_sdk-0.2.0/tests_integration/__init__.py +1 -0
- aerograph_sdk-0.2.0/tests_integration/test_collector_smoke.py +148 -0
- aerograph_sdk-0.2.0/tools/check_generated_contracts.py +148 -0
- aerograph_sdk-0.2.0/tools/datamodel-codegen.toml +30 -0
- aerograph_sdk-0.2.0/tools/generate_contracts.py +145 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
node_modules/
|
|
2
|
+
dist/
|
|
3
|
+
build/
|
|
4
|
+
.vite/
|
|
5
|
+
coverage/
|
|
6
|
+
*.log
|
|
7
|
+
.env*
|
|
8
|
+
.specify/
|
|
9
|
+
apps/collector/data/
|
|
10
|
+
.DS_Store
|
|
11
|
+
.github/agents
|
|
12
|
+
.github/prompts
|
|
13
|
+
.github/copilot-instructions.md
|
|
14
|
+
Thumbs.db
|
|
15
|
+
.agents/
|
|
16
|
+
apps/collector/data/
|
|
17
|
+
|
|
18
|
+
# Python
|
|
19
|
+
__pycache__/
|
|
20
|
+
*.py[cod]
|
|
21
|
+
.venv/
|
|
22
|
+
venv/
|
|
23
|
+
*.egg-info/
|
|
24
|
+
.pytest_cache/
|
|
25
|
+
.mypy_cache/
|
|
26
|
+
.ruff_cache/
|
|
27
|
+
.DS_Store
|
|
28
|
+
Thumbs.db
|
|
29
|
+
*.tmp
|
|
30
|
+
*.swp
|
|
31
|
+
.vscode/
|
|
32
|
+
.idea/
|
|
33
|
+
specs/
|
|
34
|
+
docs/architecture
|
|
35
|
+
.vscode/
|
|
36
|
+
AGENTS.md
|
|
37
|
+
uv.lock
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aerograph-sdk
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Python SDK for AeroGraph — emit trace events from Python agent workflows.
|
|
5
|
+
Project-URL: Homepage, https://github.com/SGcpu/AeroGraph
|
|
6
|
+
Project-URL: Repository, https://github.com/SGcpu/AeroGraph
|
|
7
|
+
Project-URL: Issues, https://github.com/SGcpu/AeroGraph/issues
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
Keywords: aerograph,agent,ai,observability,tracing
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Requires-Dist: httpx>=0.27.0
|
|
20
|
+
Requires-Dist: pydantic>=2.0.0
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: datamodel-code-generator>=0.25.0; extra == 'dev'
|
|
23
|
+
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest-httpx>=0.30.0; extra == 'dev'
|
|
25
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# aerograph-sdk
|
|
29
|
+
|
|
30
|
+
Python SDK for [AeroGraph](https://github.com/SGcpu/AeroGraph) — the open-source flight recorder for AI agent workflows.
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install aerograph-sdk
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Quickstart
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from aerograph_sdk import FlightRecorder
|
|
42
|
+
|
|
43
|
+
recorder = FlightRecorder(
|
|
44
|
+
endpoint="http://localhost:4317",
|
|
45
|
+
actor={"id": "my-agent", "name": "My Agent"},
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
# Emit events
|
|
49
|
+
prompt_event = recorder.prompt(parent_span_id=None, text="What is AeroGraph?")
|
|
50
|
+
recorder.response(parent_span_id=prompt_event.spanId, text="AeroGraph records agent traces.")
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Features
|
|
54
|
+
|
|
55
|
+
- Emit 10 event kinds: `prompt`, `response`, `tool_call`, `tool_result`, `handoff`, `error`, `note`, `state_snapshot`, `retriever`, `checkpoint`
|
|
56
|
+
- Sync and async emission via `httpx`
|
|
57
|
+
- Batch emission with deterministic event ordering
|
|
58
|
+
- Cross-language hash compatibility with the TypeScript SDK
|
|
59
|
+
- Pydantic v2 contract validation
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
Apache-2.0
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# aerograph-sdk
|
|
2
|
+
|
|
3
|
+
Python SDK for [AeroGraph](https://github.com/SGcpu/AeroGraph) — the open-source flight recorder for AI agent workflows.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install aerograph-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quickstart
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from aerograph_sdk import FlightRecorder
|
|
15
|
+
|
|
16
|
+
recorder = FlightRecorder(
|
|
17
|
+
endpoint="http://localhost:4317",
|
|
18
|
+
actor={"id": "my-agent", "name": "My Agent"},
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
# Emit events
|
|
22
|
+
prompt_event = recorder.prompt(parent_span_id=None, text="What is AeroGraph?")
|
|
23
|
+
recorder.response(parent_span_id=prompt_event.spanId, text="AeroGraph records agent traces.")
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
- Emit 10 event kinds: `prompt`, `response`, `tool_call`, `tool_result`, `handoff`, `error`, `note`, `state_snapshot`, `retriever`, `checkpoint`
|
|
29
|
+
- Sync and async emission via `httpx`
|
|
30
|
+
- Batch emission with deterministic event ordering
|
|
31
|
+
- Cross-language hash compatibility with the TypeScript SDK
|
|
32
|
+
- Pydantic v2 contract validation
|
|
33
|
+
|
|
34
|
+
## License
|
|
35
|
+
|
|
36
|
+
Apache-2.0
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"""
|
|
2
|
+
python/aerograph-sdk/examples/minimal_trace.py
|
|
3
|
+
|
|
4
|
+
Minimal runnable example demonstrating the AeroGraph Python SDK.
|
|
5
|
+
|
|
6
|
+
Usage:
|
|
7
|
+
# Start the collector first:
|
|
8
|
+
# npm run dev -w apps-collector (from repo root)
|
|
9
|
+
|
|
10
|
+
cd python/aerograph-sdk
|
|
11
|
+
pip install -e .
|
|
12
|
+
python examples/minimal_trace.py
|
|
13
|
+
|
|
14
|
+
Expected output:
|
|
15
|
+
[AeroGraph] Trace ID: t_...
|
|
16
|
+
[AeroGraph] Emitted prompt → s_...
|
|
17
|
+
[AeroGraph] Emitted response → s_...
|
|
18
|
+
[AeroGraph] Done. View trace at: http://localhost:5173/traces/t_...
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
import sys
|
|
24
|
+
|
|
25
|
+
from aerograph_sdk import FlightRecorder
|
|
26
|
+
|
|
27
|
+
# ---------------------------------------------------------------------------
|
|
28
|
+
# Configuration
|
|
29
|
+
# ---------------------------------------------------------------------------
|
|
30
|
+
|
|
31
|
+
COLLECTOR_URL = "http://localhost:4317"
|
|
32
|
+
ACTOR = {"id": "demo-agent", "name": "Demo Agent"}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def run() -> None:
|
|
36
|
+
recorder = FlightRecorder(
|
|
37
|
+
endpoint=COLLECTOR_URL,
|
|
38
|
+
actor=ACTOR,
|
|
39
|
+
)
|
|
40
|
+
print(f"[AeroGraph] Trace ID: {recorder.trace_id}")
|
|
41
|
+
|
|
42
|
+
# --- Emit a minimal prompt/response trace ---
|
|
43
|
+
root_span = recorder.new_span_id()
|
|
44
|
+
|
|
45
|
+
try:
|
|
46
|
+
prompt_event = recorder.prompt(
|
|
47
|
+
parent_span_id=None,
|
|
48
|
+
span_id=root_span,
|
|
49
|
+
text="What is AeroGraph?",
|
|
50
|
+
title="User query",
|
|
51
|
+
)
|
|
52
|
+
print(f"[AeroGraph] Emitted prompt → {prompt_event.spanId}")
|
|
53
|
+
|
|
54
|
+
response_event = recorder.response(
|
|
55
|
+
parent_span_id=root_span,
|
|
56
|
+
text=(
|
|
57
|
+
"AeroGraph is an open-source flight recorder for AI agent workflows. "
|
|
58
|
+
"It captures every prompt, response, tool call, and handoff as a "
|
|
59
|
+
"structured trace you can visualize and inspect."
|
|
60
|
+
),
|
|
61
|
+
title="Agent response",
|
|
62
|
+
)
|
|
63
|
+
print(f"[AeroGraph] Emitted response → {response_event.spanId}")
|
|
64
|
+
|
|
65
|
+
# --- Emit a tool call + result ---
|
|
66
|
+
tool_call_event = recorder.tool_call(
|
|
67
|
+
parent_span_id=root_span,
|
|
68
|
+
tool_id="search-tool",
|
|
69
|
+
tool_name="SearchTool",
|
|
70
|
+
input={"query": "AeroGraph observability"},
|
|
71
|
+
)
|
|
72
|
+
print(f"[AeroGraph] Emitted tool_call → {tool_call_event.spanId}")
|
|
73
|
+
|
|
74
|
+
recorder.tool_result(
|
|
75
|
+
parent_span_id=tool_call_event.spanId,
|
|
76
|
+
tool_id="search-tool",
|
|
77
|
+
tool_name="SearchTool",
|
|
78
|
+
output={"results": ["result1", "result2"]},
|
|
79
|
+
)
|
|
80
|
+
print("[AeroGraph] Emitted tool_result")
|
|
81
|
+
|
|
82
|
+
# --- Emit a state snapshot with hash ---
|
|
83
|
+
full_state = {"question": "What is AeroGraph?", "step": 1, "complete": True}
|
|
84
|
+
snap_event = recorder.state_snapshot(
|
|
85
|
+
parent_span_id=root_span,
|
|
86
|
+
node_name="answerNode",
|
|
87
|
+
full_state=full_state,
|
|
88
|
+
)
|
|
89
|
+
print(
|
|
90
|
+
f"[AeroGraph] Emitted state_snapshot (hash={snap_event.payload.stateHash})"
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
print(
|
|
94
|
+
f"\n[AeroGraph] Done. View trace at: http://localhost:5173/traces/{recorder.trace_id}"
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
except Exception as e:
|
|
98
|
+
print(f"[AeroGraph] Error: {e}", file=sys.stderr)
|
|
99
|
+
print(
|
|
100
|
+
"[AeroGraph] Is the collector running? "
|
|
101
|
+
"Start it with: npm run dev -w apps-collector",
|
|
102
|
+
file=sys.stderr,
|
|
103
|
+
)
|
|
104
|
+
sys.exit(1)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
if __name__ == "__main__":
|
|
108
|
+
run()
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "aerograph-sdk"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Python SDK for AeroGraph — emit trace events from Python agent workflows."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "Apache-2.0" }
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
keywords = ["ai", "agent", "tracing", "observability", "aerograph"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"License :: OSI Approved :: Apache Software License",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.10",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Topic :: Software Development :: Libraries",
|
|
22
|
+
]
|
|
23
|
+
dependencies = [
|
|
24
|
+
"httpx>=0.27.0",
|
|
25
|
+
"pydantic>=2.0.0",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.optional-dependencies]
|
|
29
|
+
dev = [
|
|
30
|
+
"pytest>=8.0.0",
|
|
31
|
+
"pytest-asyncio>=0.24.0",
|
|
32
|
+
"pytest-httpx>=0.30.0",
|
|
33
|
+
"datamodel-code-generator>=0.25.0",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
Homepage = "https://github.com/SGcpu/AeroGraph"
|
|
38
|
+
Repository = "https://github.com/SGcpu/AeroGraph"
|
|
39
|
+
Issues = "https://github.com/SGcpu/AeroGraph/issues"
|
|
40
|
+
|
|
41
|
+
[tool.hatch.build.targets.wheel]
|
|
42
|
+
packages = ["src/aerograph_sdk"]
|
|
43
|
+
|
|
44
|
+
[tool.pytest.ini_options]
|
|
45
|
+
testpaths = ["tests"]
|
|
46
|
+
asyncio_mode = "auto"
|
|
47
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
48
|
+
markers = [
|
|
49
|
+
"integration: marks tests as integration tests (requires external services)",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[tool.hatch.metadata]
|
|
53
|
+
allow-direct-references = true
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""
|
|
2
|
+
python/aerograph-sdk/src/aerograph_sdk/__init__.py
|
|
3
|
+
|
|
4
|
+
Public API for the aerograph-sdk package.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from aerograph_sdk.recorder import FlightRecorder, EmissionError
|
|
8
|
+
from aerograph_sdk.ids import new_trace_id, new_span_id
|
|
9
|
+
from aerograph_sdk.state_hash import get_deterministic_state_hash, compute_state_diff
|
|
10
|
+
from aerograph_sdk.events import compare_trace_events, sort_trace_events_deterministic
|
|
11
|
+
from aerograph_sdk.contracts import SCHEMA_VERSION
|
|
12
|
+
|
|
13
|
+
__version__ = "0.2.0"
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"FlightRecorder",
|
|
17
|
+
"EmissionError",
|
|
18
|
+
"new_trace_id",
|
|
19
|
+
"new_span_id",
|
|
20
|
+
"get_deterministic_state_hash",
|
|
21
|
+
"compute_state_diff",
|
|
22
|
+
"compare_trace_events",
|
|
23
|
+
"sort_trace_events_deterministic",
|
|
24
|
+
"SCHEMA_VERSION",
|
|
25
|
+
]
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""
|
|
2
|
+
python/aerograph-sdk/src/aerograph_sdk/contracts/__init__.py
|
|
3
|
+
|
|
4
|
+
Public exports from the contracts subpackage.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from aerograph_sdk.contracts.generated import (
|
|
8
|
+
SCHEMA_VERSION,
|
|
9
|
+
TraceEventKind,
|
|
10
|
+
TraceEventStatus,
|
|
11
|
+
ActorKind,
|
|
12
|
+
LinkRel,
|
|
13
|
+
Actor,
|
|
14
|
+
AgentActor,
|
|
15
|
+
ToolActor,
|
|
16
|
+
SystemActor,
|
|
17
|
+
TraceLink,
|
|
18
|
+
StreamingTelemetry,
|
|
19
|
+
PromptPayload,
|
|
20
|
+
ResponsePayload,
|
|
21
|
+
ToolCallPayload,
|
|
22
|
+
ToolResultPayload,
|
|
23
|
+
HandoffPayload,
|
|
24
|
+
ErrorPayload,
|
|
25
|
+
RetrieverDocument,
|
|
26
|
+
RetrieverPayload,
|
|
27
|
+
StateSnapshotPayload,
|
|
28
|
+
CheckpointPayload,
|
|
29
|
+
PromptEvent,
|
|
30
|
+
ResponseEvent,
|
|
31
|
+
ToolCallEvent,
|
|
32
|
+
ToolResultEvent,
|
|
33
|
+
HandoffEvent,
|
|
34
|
+
ErrorEvent,
|
|
35
|
+
NoteEvent,
|
|
36
|
+
StateSnapshotEvent,
|
|
37
|
+
RetrieverEvent,
|
|
38
|
+
CheckpointEvent,
|
|
39
|
+
TraceEvent,
|
|
40
|
+
TraceMeta,
|
|
41
|
+
Trace,
|
|
42
|
+
TraceWithMeta,
|
|
43
|
+
TraceListResponse,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
__all__ = [
|
|
47
|
+
"SCHEMA_VERSION",
|
|
48
|
+
"TraceEventKind",
|
|
49
|
+
"TraceEventStatus",
|
|
50
|
+
"ActorKind",
|
|
51
|
+
"LinkRel",
|
|
52
|
+
"Actor",
|
|
53
|
+
"AgentActor",
|
|
54
|
+
"ToolActor",
|
|
55
|
+
"SystemActor",
|
|
56
|
+
"TraceLink",
|
|
57
|
+
"StreamingTelemetry",
|
|
58
|
+
"PromptPayload",
|
|
59
|
+
"ResponsePayload",
|
|
60
|
+
"ToolCallPayload",
|
|
61
|
+
"ToolResultPayload",
|
|
62
|
+
"HandoffPayload",
|
|
63
|
+
"ErrorPayload",
|
|
64
|
+
"RetrieverDocument",
|
|
65
|
+
"RetrieverPayload",
|
|
66
|
+
"StateSnapshotPayload",
|
|
67
|
+
"CheckpointPayload",
|
|
68
|
+
"PromptEvent",
|
|
69
|
+
"ResponseEvent",
|
|
70
|
+
"ToolCallEvent",
|
|
71
|
+
"ToolResultEvent",
|
|
72
|
+
"HandoffEvent",
|
|
73
|
+
"ErrorEvent",
|
|
74
|
+
"NoteEvent",
|
|
75
|
+
"StateSnapshotEvent",
|
|
76
|
+
"RetrieverEvent",
|
|
77
|
+
"CheckpointEvent",
|
|
78
|
+
"TraceEvent",
|
|
79
|
+
"TraceMeta",
|
|
80
|
+
"Trace",
|
|
81
|
+
"TraceWithMeta",
|
|
82
|
+
"TraceListResponse",
|
|
83
|
+
]
|