debug-agent-py 0.5.1__tar.gz → 0.6.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.
Files changed (54) hide show
  1. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/PKG-INFO +47 -6
  2. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/README.md +46 -5
  3. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/pyproject.toml +1 -1
  4. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/__init__.py +6 -0
  5. debug_agent_py-0.6.0/src/debug_agent/inspectors/config_inspector.py +157 -0
  6. debug_agent_py-0.6.0/src/debug_agent/inspectors/endpoint_test_inspector.py +374 -0
  7. debug_agent_py-0.6.0/src/debug_agent/inspectors/feature_flag_inspector.py +124 -0
  8. debug_agent_py-0.6.0/src/debug_agent/inspectors/locks_inspector.py +307 -0
  9. debug_agent_py-0.6.0/src/debug_agent/inspectors/migration_inspector.py +312 -0
  10. debug_agent_py-0.6.0/src/debug_agent/inspectors/pool_inspector.py +309 -0
  11. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent_py.egg-info/PKG-INFO +47 -6
  12. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent_py.egg-info/SOURCES.txt +6 -0
  13. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/setup.cfg +0 -0
  14. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/__init__.py +0 -0
  15. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/chat_session.py +0 -0
  16. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/config.py +0 -0
  17. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/context_compressor.py +0 -0
  18. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/engine.py +0 -0
  19. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/async_tasks.py +0 -0
  20. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/cache_inspector.py +0 -0
  21. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/celery.py +0 -0
  22. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/database.py +0 -0
  23. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/django.py +0 -0
  24. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/error_tracking.py +0 -0
  25. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/fastapi_ext.py +0 -0
  26. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/fd_inspector.py +0 -0
  27. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/flask_ext.py +0 -0
  28. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/framework.py +0 -0
  29. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/health_inspector.py +0 -0
  30. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/http_client_inspector.py +0 -0
  31. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/http_tracker.py +0 -0
  32. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/jinja2.py +0 -0
  33. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/logging_inspector.py +0 -0
  34. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/memory.py +0 -0
  35. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/metrics_inspector.py +0 -0
  36. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/modules.py +0 -0
  37. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/redis.py +0 -0
  38. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/runtime.py +0 -0
  39. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/scheduler_inspector.py +0 -0
  40. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/security_inspector.py +0 -0
  41. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/signals.py +0 -0
  42. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/system.py +0 -0
  43. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/threads.py +0 -0
  44. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/warnings_inspector.py +0 -0
  45. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/inspectors/websocket_inspector.py +0 -0
  46. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/llm_client.py +0 -0
  47. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/middleware.py +0 -0
  48. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/system_prompt_builder.py +0 -0
  49. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/tool_registry.py +0 -0
  50. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/web/__init__.py +0 -0
  51. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent/web/chat_page.py +0 -0
  52. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent_py.egg-info/dependency_links.txt +0 -0
  53. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent_py.egg-info/requires.txt +0 -0
  54. {debug_agent_py-0.5.1 → debug_agent_py-0.6.0}/src/debug_agent_py.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: debug-agent-py
3
- Version: 0.5.1
3
+ Version: 0.6.0
4
4
  Summary: AI-powered runtime debugging agent for Python web applications
5
5
  Author-email: ggcode <noreply@ggcode.dev>
6
6
  License: MIT
@@ -52,12 +52,12 @@ Requires-Dist: pytest; extra == "dev"
52
52
  # Python Debug Agent
53
53
 
54
54
  [![debug-agent-py](https://img.shields.io/pypi/v/debug-agent-py.svg)](https://pypi.org/project/debug-agent-py/)
55
- ![Tools](https://img.shields.io/badge/tools-82-blue)
56
- ![Inspectors](https://img.shields.io/badge/inspectors-27-green)
55
+ ![Tools](https://img.shields.io/badge/tools-99-blue)
56
+ ![Inspectors](https://img.shields.io/badge/inspectors-33-green)
57
57
  ![Python](https://img.shields.io/badge/Python-3.9%2B-3776AB)
58
58
  ![PyPI](https://img.shields.io/badge/PyPI-debug--agent--py-3776AB)
59
59
 
60
- An AI-powered runtime debugging agent that embeds directly into your Python web application. Add one dependency, configure an LLM key, and chat with your live app at `/agent` to inspect memory, threads, GC, modules, database connections, Redis, Django models/URLs, Celery tasks, Flask extensions, Jinja2 templates, signals, routes, HTTP requests, and more — **68 diagnostic tools across 24 inspectors**.
60
+ An AI-powered runtime debugging agent that embeds directly into your Python web application. Add one dependency, configure an LLM key, and chat with your live app at `/agent` to inspect memory, threads, GC, modules, database connections, Redis, Django models/URLs, Celery tasks, Flask extensions, Jinja2 templates, signals, routes, HTTP requests, and more — **99 diagnostic tools across 33 inspectors**.
61
61
 
62
62
  ## Version Support
63
63
 
@@ -115,11 +115,11 @@ http://localhost:8000/agent
115
115
  - **Context compression** — automatically summarizes old conversation when token limit is approached
116
116
  - **Dark-themed chat UI** with full markdown rendering (tables, code blocks, lists)
117
117
  - **Max tool rounds** (25) with forced final summary when limit is reached
118
- - **68 diagnostic tools** across **24 inspectors**
118
+ - **99 diagnostic tools** across **33 inspectors**
119
119
  - Works with Flask, FastAPI, and Django
120
120
  - Zero external dependencies (no Datadog, no Grafana, no APM)
121
121
 
122
- ## Inspectors & Tools (68)
122
+ ## Inspectors & Tools (99)
123
123
 
124
124
  ### Memory Inspector
125
125
  | Tool | Description |
@@ -280,6 +280,47 @@ http://localhost:8000/agent
280
280
  |------|-------------|
281
281
  | `get_warnings` | List captured Python warnings with category, message, and location |
282
282
 
283
+ ### Deadlock & Lock Contention Inspector (v0.6.0)
284
+ | Tool | Description |
285
+ |------|-------------|
286
+ | `get_lock_contention` | Threading lock contention stats (wait time, hold time, acquisition count) |
287
+ | `detect_deadlock` | Analyze all threads for deadlock patterns (circular wait detection) |
288
+ | `get_mutex_stats` | Per-lock statistics: total acquisitions, contentions, average wait time |
289
+
290
+ ### Database Migration Inspector (v0.6.0)
291
+ | Tool | Description |
292
+ |------|-------------|
293
+ | `get_migration_status` | Current schema version, applied count, last migration applied |
294
+ | `get_pending_migrations` | Migrations not yet applied (version, description, dependencies) |
295
+ | `get_migration_history` | Applied migration history (version, applied_at, duration_ms) |
296
+
297
+ ### Configuration Inspector (v0.6.0)
298
+ | Tool | Description |
299
+ |------|-------------|
300
+ | `get_config_snapshot` | All registered config values (sensitive keys masked) |
301
+ | `get_env_vars_masked` | Process environment variables with secret values redacted |
302
+ | `get_config_sources` | Config source hierarchy (env, file, defaults) with effective values |
303
+
304
+ ### Feature Flags Inspector (v0.6.0)
305
+ | Tool | Description |
306
+ |------|-------------|
307
+ | `get_feature_flags` | List all registered feature flags with current state |
308
+ | `evaluate_feature_flag` | Evaluate a specific flag for a given context/user |
309
+
310
+ ### Endpoint Testing Inspector (v0.6.0)
311
+ | Tool | Description |
312
+ |------|-------------|
313
+ | `test_endpoint` | Make an HTTP request to own app, return full response (status, headers, body) |
314
+ | `batch_test_endpoints` | Test multiple endpoints in one call with aggregated results |
315
+ | `get_endpoint_coverage` | Compare registered routes vs tested endpoints (coverage report) |
316
+
317
+ ### Connection Pool Inspector (v0.6.0)
318
+ | Tool | Description |
319
+ |------|-------------|
320
+ | `get_pool_details` | Detailed DB pool stats (pool size, checked-in, checked-out, overflow) |
321
+ | `detect_pool_leaks` | Heuristic leak detection (growing pool, high wait ratio, saturation) |
322
+ | `get_pool_wait_stats` | Connection acquire wait stats (avg, P95, max wait, timeout count) |
323
+
283
324
  ## Custom Tools
284
325
 
285
326
  ```python
@@ -1,12 +1,12 @@
1
1
  # Python Debug Agent
2
2
 
3
3
  [![debug-agent-py](https://img.shields.io/pypi/v/debug-agent-py.svg)](https://pypi.org/project/debug-agent-py/)
4
- ![Tools](https://img.shields.io/badge/tools-82-blue)
5
- ![Inspectors](https://img.shields.io/badge/inspectors-27-green)
4
+ ![Tools](https://img.shields.io/badge/tools-99-blue)
5
+ ![Inspectors](https://img.shields.io/badge/inspectors-33-green)
6
6
  ![Python](https://img.shields.io/badge/Python-3.9%2B-3776AB)
7
7
  ![PyPI](https://img.shields.io/badge/PyPI-debug--agent--py-3776AB)
8
8
 
9
- An AI-powered runtime debugging agent that embeds directly into your Python web application. Add one dependency, configure an LLM key, and chat with your live app at `/agent` to inspect memory, threads, GC, modules, database connections, Redis, Django models/URLs, Celery tasks, Flask extensions, Jinja2 templates, signals, routes, HTTP requests, and more — **68 diagnostic tools across 24 inspectors**.
9
+ An AI-powered runtime debugging agent that embeds directly into your Python web application. Add one dependency, configure an LLM key, and chat with your live app at `/agent` to inspect memory, threads, GC, modules, database connections, Redis, Django models/URLs, Celery tasks, Flask extensions, Jinja2 templates, signals, routes, HTTP requests, and more — **99 diagnostic tools across 33 inspectors**.
10
10
 
11
11
  ## Version Support
12
12
 
@@ -64,11 +64,11 @@ http://localhost:8000/agent
64
64
  - **Context compression** — automatically summarizes old conversation when token limit is approached
65
65
  - **Dark-themed chat UI** with full markdown rendering (tables, code blocks, lists)
66
66
  - **Max tool rounds** (25) with forced final summary when limit is reached
67
- - **68 diagnostic tools** across **24 inspectors**
67
+ - **99 diagnostic tools** across **33 inspectors**
68
68
  - Works with Flask, FastAPI, and Django
69
69
  - Zero external dependencies (no Datadog, no Grafana, no APM)
70
70
 
71
- ## Inspectors & Tools (68)
71
+ ## Inspectors & Tools (99)
72
72
 
73
73
  ### Memory Inspector
74
74
  | Tool | Description |
@@ -229,6 +229,47 @@ http://localhost:8000/agent
229
229
  |------|-------------|
230
230
  | `get_warnings` | List captured Python warnings with category, message, and location |
231
231
 
232
+ ### Deadlock & Lock Contention Inspector (v0.6.0)
233
+ | Tool | Description |
234
+ |------|-------------|
235
+ | `get_lock_contention` | Threading lock contention stats (wait time, hold time, acquisition count) |
236
+ | `detect_deadlock` | Analyze all threads for deadlock patterns (circular wait detection) |
237
+ | `get_mutex_stats` | Per-lock statistics: total acquisitions, contentions, average wait time |
238
+
239
+ ### Database Migration Inspector (v0.6.0)
240
+ | Tool | Description |
241
+ |------|-------------|
242
+ | `get_migration_status` | Current schema version, applied count, last migration applied |
243
+ | `get_pending_migrations` | Migrations not yet applied (version, description, dependencies) |
244
+ | `get_migration_history` | Applied migration history (version, applied_at, duration_ms) |
245
+
246
+ ### Configuration Inspector (v0.6.0)
247
+ | Tool | Description |
248
+ |------|-------------|
249
+ | `get_config_snapshot` | All registered config values (sensitive keys masked) |
250
+ | `get_env_vars_masked` | Process environment variables with secret values redacted |
251
+ | `get_config_sources` | Config source hierarchy (env, file, defaults) with effective values |
252
+
253
+ ### Feature Flags Inspector (v0.6.0)
254
+ | Tool | Description |
255
+ |------|-------------|
256
+ | `get_feature_flags` | List all registered feature flags with current state |
257
+ | `evaluate_feature_flag` | Evaluate a specific flag for a given context/user |
258
+
259
+ ### Endpoint Testing Inspector (v0.6.0)
260
+ | Tool | Description |
261
+ |------|-------------|
262
+ | `test_endpoint` | Make an HTTP request to own app, return full response (status, headers, body) |
263
+ | `batch_test_endpoints` | Test multiple endpoints in one call with aggregated results |
264
+ | `get_endpoint_coverage` | Compare registered routes vs tested endpoints (coverage report) |
265
+
266
+ ### Connection Pool Inspector (v0.6.0)
267
+ | Tool | Description |
268
+ |------|-------------|
269
+ | `get_pool_details` | Detailed DB pool stats (pool size, checked-in, checked-out, overflow) |
270
+ | `detect_pool_leaks` | Heuristic leak detection (growing pool, high wait ratio, saturation) |
271
+ | `get_pool_wait_stats` | Connection acquire wait stats (avg, P95, max wait, timeout count) |
272
+
232
273
  ## Custom Tools
233
274
 
234
275
  ```python
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "debug-agent-py"
7
- version = "0.5.1"
7
+ version = "0.6.0"
8
8
  description = "AI-powered runtime debugging agent for Python web applications"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -4,10 +4,13 @@ from debug_agent.inspectors import ( # noqa: F401
4
4
  async_tasks,
5
5
  cache_inspector,
6
6
  celery,
7
+ config_inspector,
7
8
  database,
8
9
  django,
10
+ endpoint_test_inspector,
9
11
  error_tracking,
10
12
  fastapi_ext,
13
+ feature_flag_inspector,
11
14
  fd_inspector,
12
15
  flask_ext,
13
16
  framework,
@@ -15,10 +18,13 @@ from debug_agent.inspectors import ( # noqa: F401
15
18
  http_client_inspector,
16
19
  http_tracker,
17
20
  jinja2,
21
+ locks_inspector,
18
22
  logging_inspector,
19
23
  memory,
20
24
  metrics_inspector,
25
+ migration_inspector,
21
26
  modules,
27
+ pool_inspector,
22
28
  redis,
23
29
  runtime,
24
30
  scheduler_inspector,
@@ -0,0 +1,157 @@
1
+ """Config inspector: configuration snapshots, env vars, and provenance.
2
+
3
+ Register config dicts at runtime so they can be introspected:
4
+
5
+ from debug_agent.inspectors.config_inspector import register_config
6
+ register_config("flask", {"DEBUG": True, "SQLALCHEMY_DATABASE_URI": "..."})
7
+
8
+ Sensitive keys (matching password|secret|token|api.?key|private.?key|credential)
9
+ are automatically masked as ``"***"``.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import os
15
+ import re
16
+ from typing import Any
17
+
18
+ from debug_agent.tool_registry import debug_tool, ToolParam
19
+
20
+
21
+ # ─── Registration ──────────────────────────────────────────────────────────────
22
+
23
+ _registered_configs: dict[str, dict[str, Any]] = {}
24
+
25
+ # Optional provenance tracking: config name -> { key -> source }
26
+ _config_sources: dict[str, dict[str, str]] = {}
27
+
28
+
29
+ def register_config(
30
+ name: str,
31
+ config_dict: dict[str, Any],
32
+ sources: dict[str, str] | None = None,
33
+ ) -> None:
34
+ """Register a config dict under *name*.
35
+
36
+ *sources* optionally maps keys to provenance labels (``"env"``,
37
+ ``"file"``, ``"default"``, ...).
38
+ """
39
+ _registered_configs[name] = dict(config_dict)
40
+ if sources:
41
+ _config_sources[name] = dict(sources)
42
+
43
+
44
+ # ─── Helpers ──────────────────────────────────────────────────────────────────
45
+
46
+ _SENSITIVE_RE = re.compile(r"password|secret|token|api.?key|private.?key|credential", re.IGNORECASE)
47
+
48
+
49
+ def _is_sensitive(key: str) -> bool:
50
+ return bool(_SENSITIVE_RE.search(str(key)))
51
+
52
+
53
+ def _mask(key: str, value: Any) -> Any:
54
+ if _is_sensitive(key):
55
+ return "***"
56
+ return value
57
+
58
+
59
+ def _mask_config(config: dict[str, Any]) -> dict[str, Any]:
60
+ return {k: _mask(k, v) for k, v in config.items()}
61
+
62
+
63
+ # ─── Tools ────────────────────────────────────────────────────────────────────
64
+
65
+
66
+ @debug_tool(
67
+ "get_config_snapshot",
68
+ "Get all registered config values with sensitive keys masked",
69
+ )
70
+ def get_config_snapshot() -> dict:
71
+ if not _registered_configs:
72
+ return {
73
+ "count": 0,
74
+ "configs": {},
75
+ "message": "No configs registered. Use register_config(name, config_dict).",
76
+ }
77
+
78
+ snapshot: dict[str, Any] = {}
79
+ for name, config in _registered_configs.items():
80
+ snapshot[name] = _mask_config(config)
81
+
82
+ # Count how many values were masked for transparency.
83
+ masked_total = 0
84
+ for config in _registered_configs.values():
85
+ for key in config:
86
+ if _is_sensitive(key):
87
+ masked_total += 1
88
+
89
+ return {
90
+ "count": len(snapshot),
91
+ "masked_values": masked_total,
92
+ "configs": snapshot,
93
+ }
94
+
95
+
96
+ @debug_tool(
97
+ "get_env_vars",
98
+ "Dump os.environ with optional prefix filter; sensitive values are masked",
99
+ )
100
+ def get_env_vars(
101
+ prefix: str | None = None,
102
+ ) -> dict:
103
+ env: dict[str, str] = {}
104
+ masked: list[str] = []
105
+
106
+ for key in sorted(os.environ):
107
+ if prefix and not key.startswith(prefix):
108
+ continue
109
+ if _is_sensitive(key):
110
+ env[key] = "***"
111
+ masked.append(key)
112
+ else:
113
+ env[key] = os.environ[key]
114
+
115
+ return {
116
+ "prefix": prefix or None,
117
+ "total": len(env),
118
+ "masked_count": len(masked),
119
+ "masked_keys": masked,
120
+ "variables": env,
121
+ }
122
+
123
+
124
+ @debug_tool(
125
+ "get_config_sources",
126
+ "Get config provenance — where each value came from (env, file, default)",
127
+ )
128
+ def get_config_sources(
129
+ name: str | None = None,
130
+ ) -> dict:
131
+ if name:
132
+ if name not in _registered_configs:
133
+ return {"error": f"No config registered with name '{name}'"}
134
+ sources = _config_sources.get(name, {})
135
+ result: dict[str, Any] = {}
136
+ for key in _registered_configs[name]:
137
+ result[key] = sources.get(key, "default")
138
+ return {"name": name, "sources": result}
139
+
140
+ if not _registered_configs:
141
+ return {
142
+ "count": 0,
143
+ "configs": {},
144
+ "message": "No configs registered.",
145
+ }
146
+
147
+ all_sources: dict[str, dict[str, str]] = {}
148
+ for cfg_name, config in _registered_configs.items():
149
+ sources = _config_sources.get(cfg_name, {})
150
+ all_sources[cfg_name] = {
151
+ key: sources.get(key, "default") for key in config
152
+ }
153
+
154
+ return {
155
+ "count": len(all_sources),
156
+ "configs": all_sources,
157
+ }