agentdna-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.
@@ -0,0 +1,37 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.egg-info/
6
+ dist/
7
+ build/
8
+ .eggs/
9
+ *.egg
10
+ .venv/
11
+ venv/
12
+ env/
13
+
14
+ # Node
15
+ node_modules/
16
+ *.tsbuildinfo
17
+ dist/
18
+
19
+ # IDE
20
+ .vscode/
21
+ .idea/
22
+ *.swp
23
+ *.swo
24
+ *~
25
+
26
+ # OS
27
+ .DS_Store
28
+ Thumbs.db
29
+
30
+ # Env
31
+ .env
32
+ .env.local
33
+ .env.*.local
34
+
35
+ # AgentDNA
36
+ agentdna.db
37
+ *.log
@@ -0,0 +1,197 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentdna-sdk
3
+ Version: 0.2.0
4
+ Summary: Sentry for AI Agents — one-line observability with local SQLite persistence
5
+ Project-URL: Homepage, https://github.com/mamoor123/agentdna
6
+ Project-URL: Documentation, https://github.com/mamoor123/agentdna#readme
7
+ Project-URL: Repository, https://github.com/mamoor123/agentdna
8
+ Project-URL: Issues, https://github.com/mamoor123/agentdna/issues
9
+ Author: mamoor123
10
+ License: Apache-2.0
11
+ Keywords: a2a,agents,ai,decorator,langchain,llm,mcp,monitoring,observability,openai
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: click>=8.0
23
+ Provides-Extra: dev
24
+ Requires-Dist: mypy>=1.0; extra == 'dev'
25
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
26
+ Requires-Dist: pytest>=7.0; extra == 'dev'
27
+ Requires-Dist: ruff>=0.4; extra == 'dev'
28
+ Provides-Extra: discovery
29
+ Requires-Dist: httpx>=0.27.0; extra == 'discovery'
30
+ Requires-Dist: pyyaml>=6.0; extra == 'discovery'
31
+ Provides-Extra: server
32
+ Requires-Dist: fastapi>=0.110.0; extra == 'server'
33
+ Requires-Dist: uvicorn>=0.29.0; extra == 'server'
34
+ Description-Content-Type: text/markdown
35
+
36
+ # 🧬 AgentDNA — Sentry for AI Agents
37
+
38
+ **One-line observability for any Python agent.** No framework required. No API key. No network calls.
39
+
40
+ ```bash
41
+ pip install agentdna
42
+ ```
43
+
44
+ ## Quick Start
45
+
46
+ ```python
47
+ from agentdna import observe, get_stats
48
+
49
+ @observe
50
+ def my_agent(prompt):
51
+ # your existing agent code
52
+ return llm.call(prompt)
53
+
54
+ my_agent("hello world")
55
+
56
+ # View stats (persists across restarts)
57
+ print(get_stats())
58
+ ```
59
+
60
+ That's it. One decorator. Full observability.
61
+
62
+ ## What You Get
63
+
64
+ ```
65
+ 📊 Stats: my_agent
66
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
67
+ Health: ✅ Healthy
68
+ Total calls: 42
69
+ Success rate: 97.6%
70
+ Failed calls: 1
71
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
72
+ Avg latency: 1250.5 ms
73
+ P50 latency: 980.0 ms
74
+ P95 latency: 2100.0 ms
75
+ P99 latency: 3500.0 ms
76
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
77
+ Errors:
78
+ Timeout: 1
79
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
80
+ ```
81
+
82
+ ## Features
83
+
84
+ - **📊 Call tracking** — total calls, success/failure rates
85
+ - **⏱️ Latency** — avg, p50, p95, p99 percentiles
86
+ - **❌ Error tracking** — error types and frequency
87
+ - **💾 SQLite persistence** — data survives restarts
88
+ - **🔒 100% local** — no network calls, no API key
89
+ - **🐍 Sync & async** — works with both
90
+ - **🖥️ CLI included** — `agentdna stats`
91
+
92
+ ## CLI
93
+
94
+ ```bash
95
+ agentdna stats # overview of all observed functions
96
+ agentdna stats my_agent # detailed view
97
+ agentdna stats --export json # export as JSON
98
+ agentdna stats --export csv # export as CSV
99
+ agentdna stats --reset # clear all data
100
+ ```
101
+
102
+ ## Usage
103
+
104
+ ### Basic
105
+
106
+ ```python
107
+ from agentdna import observe
108
+
109
+ @observe
110
+ def my_agent(prompt):
111
+ return llm.call(prompt)
112
+ ```
113
+
114
+ ### With Options
115
+
116
+ ```python
117
+ @observe(name="transcriber", tags={"version": "2.0", "model": "whisper"})
118
+ def transcribe(audio_path):
119
+ return whisper.transcribe(audio_path)
120
+ ```
121
+
122
+ ### Async Support
123
+
124
+ ```python
125
+ @observe
126
+ async def my_async_agent(prompt):
127
+ result = await llm.acall(prompt)
128
+ return result
129
+ ```
130
+
131
+ ### Get Stats Programmatically
132
+
133
+ ```python
134
+ from agentdna import get_stats
135
+
136
+ stats = get_stats("my_agent")
137
+ print(f"Success rate: {stats['success_rate']:.1%}")
138
+ print(f"P95 latency: {stats['p95_latency_ms']:.0f}ms")
139
+
140
+ # All functions
141
+ all_stats = get_stats()
142
+ for name, s in all_stats.items():
143
+ print(f"{name}: {s['total_calls']} calls")
144
+ ```
145
+
146
+ ### Export Stats
147
+
148
+ ```python
149
+ from agentdna import export_stats
150
+
151
+ json_str = export_stats(format="json")
152
+ csv_str = export_stats(format="csv")
153
+ ```
154
+
155
+ ## How It Works
156
+
157
+ 1. Decorator wraps your function
158
+ 2. Each call logs: timestamp, success/failure, latency, input/output sizes, errors
159
+ 3. Data batches to `~/.agentdna/observe.db` (SQLite, WAL mode)
160
+ 4. Read stats anytime via `get_stats()` or `agentdna stats`
161
+
162
+ **No dependencies** beyond Python stdlib. `click` is only needed for the CLI.
163
+
164
+ ## Data Location
165
+
166
+ Default: `~/.agentdna/observe.db`
167
+
168
+ Custom path:
169
+ ```python
170
+ import os
171
+ os.environ["AGENTDNA_DB_PATH"] = "/path/to/my/observe.db"
172
+ ```
173
+
174
+ ## Why AgentDNA?
175
+
176
+ | Without AgentDNA | With AgentDNA |
177
+ |-----------------|---------------|
178
+ | `print("done!")` | Track every call with latency + errors |
179
+ | Hope nothing breaks | Know exactly when and what breaks |
180
+ | Debug blind | P95 latency, error breakdown, trends |
181
+ | Lose data on restart | SQLite persistence |
182
+
183
+ ## Installation
184
+
185
+ ```bash
186
+ pip install agentdna
187
+ ```
188
+
189
+ Optional features:
190
+ ```bash
191
+ pip install agentdna[discovery] # agent discovery (httpx, PyYAML)
192
+ pip install agentdna[server] # run registry server (FastAPI)
193
+ ```
194
+
195
+ ## License
196
+
197
+ Apache 2.0
@@ -0,0 +1,162 @@
1
+ # 🧬 AgentDNA — Sentry for AI Agents
2
+
3
+ **One-line observability for any Python agent.** No framework required. No API key. No network calls.
4
+
5
+ ```bash
6
+ pip install agentdna
7
+ ```
8
+
9
+ ## Quick Start
10
+
11
+ ```python
12
+ from agentdna import observe, get_stats
13
+
14
+ @observe
15
+ def my_agent(prompt):
16
+ # your existing agent code
17
+ return llm.call(prompt)
18
+
19
+ my_agent("hello world")
20
+
21
+ # View stats (persists across restarts)
22
+ print(get_stats())
23
+ ```
24
+
25
+ That's it. One decorator. Full observability.
26
+
27
+ ## What You Get
28
+
29
+ ```
30
+ 📊 Stats: my_agent
31
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
32
+ Health: ✅ Healthy
33
+ Total calls: 42
34
+ Success rate: 97.6%
35
+ Failed calls: 1
36
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
37
+ Avg latency: 1250.5 ms
38
+ P50 latency: 980.0 ms
39
+ P95 latency: 2100.0 ms
40
+ P99 latency: 3500.0 ms
41
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
42
+ Errors:
43
+ Timeout: 1
44
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
45
+ ```
46
+
47
+ ## Features
48
+
49
+ - **📊 Call tracking** — total calls, success/failure rates
50
+ - **⏱️ Latency** — avg, p50, p95, p99 percentiles
51
+ - **❌ Error tracking** — error types and frequency
52
+ - **💾 SQLite persistence** — data survives restarts
53
+ - **🔒 100% local** — no network calls, no API key
54
+ - **🐍 Sync & async** — works with both
55
+ - **🖥️ CLI included** — `agentdna stats`
56
+
57
+ ## CLI
58
+
59
+ ```bash
60
+ agentdna stats # overview of all observed functions
61
+ agentdna stats my_agent # detailed view
62
+ agentdna stats --export json # export as JSON
63
+ agentdna stats --export csv # export as CSV
64
+ agentdna stats --reset # clear all data
65
+ ```
66
+
67
+ ## Usage
68
+
69
+ ### Basic
70
+
71
+ ```python
72
+ from agentdna import observe
73
+
74
+ @observe
75
+ def my_agent(prompt):
76
+ return llm.call(prompt)
77
+ ```
78
+
79
+ ### With Options
80
+
81
+ ```python
82
+ @observe(name="transcriber", tags={"version": "2.0", "model": "whisper"})
83
+ def transcribe(audio_path):
84
+ return whisper.transcribe(audio_path)
85
+ ```
86
+
87
+ ### Async Support
88
+
89
+ ```python
90
+ @observe
91
+ async def my_async_agent(prompt):
92
+ result = await llm.acall(prompt)
93
+ return result
94
+ ```
95
+
96
+ ### Get Stats Programmatically
97
+
98
+ ```python
99
+ from agentdna import get_stats
100
+
101
+ stats = get_stats("my_agent")
102
+ print(f"Success rate: {stats['success_rate']:.1%}")
103
+ print(f"P95 latency: {stats['p95_latency_ms']:.0f}ms")
104
+
105
+ # All functions
106
+ all_stats = get_stats()
107
+ for name, s in all_stats.items():
108
+ print(f"{name}: {s['total_calls']} calls")
109
+ ```
110
+
111
+ ### Export Stats
112
+
113
+ ```python
114
+ from agentdna import export_stats
115
+
116
+ json_str = export_stats(format="json")
117
+ csv_str = export_stats(format="csv")
118
+ ```
119
+
120
+ ## How It Works
121
+
122
+ 1. Decorator wraps your function
123
+ 2. Each call logs: timestamp, success/failure, latency, input/output sizes, errors
124
+ 3. Data batches to `~/.agentdna/observe.db` (SQLite, WAL mode)
125
+ 4. Read stats anytime via `get_stats()` or `agentdna stats`
126
+
127
+ **No dependencies** beyond Python stdlib. `click` is only needed for the CLI.
128
+
129
+ ## Data Location
130
+
131
+ Default: `~/.agentdna/observe.db`
132
+
133
+ Custom path:
134
+ ```python
135
+ import os
136
+ os.environ["AGENTDNA_DB_PATH"] = "/path/to/my/observe.db"
137
+ ```
138
+
139
+ ## Why AgentDNA?
140
+
141
+ | Without AgentDNA | With AgentDNA |
142
+ |-----------------|---------------|
143
+ | `print("done!")` | Track every call with latency + errors |
144
+ | Hope nothing breaks | Know exactly when and what breaks |
145
+ | Debug blind | P95 latency, error breakdown, trends |
146
+ | Lose data on restart | SQLite persistence |
147
+
148
+ ## Installation
149
+
150
+ ```bash
151
+ pip install agentdna
152
+ ```
153
+
154
+ Optional features:
155
+ ```bash
156
+ pip install agentdna[discovery] # agent discovery (httpx, PyYAML)
157
+ pip install agentdna[server] # run registry server (FastAPI)
158
+ ```
159
+
160
+ ## License
161
+
162
+ Apache 2.0
@@ -0,0 +1,85 @@
1
+ """
2
+ 🧬 AgentDNA — Sentry for AI Agents
3
+
4
+ One-line observability for any Python agent.
5
+ No framework required. No API key. No network calls.
6
+
7
+ Usage:
8
+ from agentdna import observe, get_stats
9
+
10
+ @observe
11
+ def my_agent(prompt):
12
+ return llm.call(prompt)
13
+
14
+ # Check stats anytime (persists across restarts)
15
+ print(get_stats())
16
+
17
+ # Or use the CLI:
18
+ # agentdna stats
19
+ # agentdna stats my_agent
20
+ """
21
+
22
+ __version__ = "0.2.0"
23
+
24
+ # ⭐ Primary exports — zero dependencies (uses only stdlib sqlite3)
25
+ from agentdna.plugins.observe import observe, get_stats, reset_stats, export_stats
26
+
27
+ # Everything else is lazy-imported to avoid requiring httpx/PyYAML
28
+ # for users who only want observability.
29
+
30
+
31
+ def __getattr__(name: str):
32
+ """Lazy imports — only load when actually used."""
33
+ _lazy = {
34
+ # Models
35
+ "Agent": ("agentdna.models", "Agent"),
36
+ "AgentSearchResult": ("agentdna.models", "AgentSearchResult"),
37
+ "Capability": ("agentdna.models", "Capability"),
38
+ "Pricing": ("agentdna.models", "Pricing"),
39
+ "TrustScore": ("agentdna.models", "TrustScore"),
40
+ "TaskResult": ("agentdna.models", "TaskResult"),
41
+ # Registry
42
+ "register_agent": ("agentdna.registry", "register_agent"),
43
+ "load_agent_card": ("agentdna.registry", "load_agent_card"),
44
+ "generate_agent_card": ("agentdna.registry", "generate_agent_card"),
45
+ # Discovery
46
+ "find_agent": ("agentdna.discovery", "find_agent"),
47
+ "search_agents": ("agentdna.discovery", "search_agents"),
48
+ # Marketplace
49
+ "hire_agent": ("agentdna.marketplace", "hire_agent"),
50
+ "hire_agent_sync": ("agentdna.marketplace", "hire_agent_sync"),
51
+ # Client
52
+ "AgentDNAClient": ("agentdna.client", "AgentDNAClient"),
53
+ }
54
+
55
+ if name in _lazy:
56
+ module_path, attr_name = _lazy[name]
57
+ from importlib import import_module
58
+ mod = import_module(module_path)
59
+ return getattr(mod, attr_name)
60
+
61
+ raise AttributeError(f"module 'agentdna' has no attribute {name!r}")
62
+
63
+
64
+ __all__ = [
65
+ # ⭐ Core — observability (zero dependencies)
66
+ "observe",
67
+ "get_stats",
68
+ "reset_stats",
69
+ "export_stats",
70
+ # Everything else (lazy, requires httpx/PyYAML)
71
+ "AgentDNAClient",
72
+ "Agent",
73
+ "AgentSearchResult",
74
+ "Capability",
75
+ "Pricing",
76
+ "TrustScore",
77
+ "TaskResult",
78
+ "register_agent",
79
+ "load_agent_card",
80
+ "generate_agent_card",
81
+ "find_agent",
82
+ "search_agents",
83
+ "hire_agent",
84
+ "hire_agent_sync",
85
+ ]