debug-agent 0.2.6

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 282c047d0e86a70412110ecbd1a3579ee8a71af4b2743de37a4769242df6b634
4
+ data.tar.gz: ba97cf4ae8a5757f70c5bf261e5b5b34fb5d752a5543e9b4c657db5fdfc299bf
5
+ SHA512:
6
+ metadata.gz: 0b68399b6dd5fe9d83f9369a9ab896bde2c2d6941a3d8d531b6721427f21b96643e9e8b3793a7da31984b34da7ed79779ba43a30bcbf57e6c20b8451831482f0
7
+ data.tar.gz: c4dc62c89f4bfd0100dae01b636130cc0316b5bc1f2981db85d52a8e360a997bf755851187719be8a88f4e05faf443bbc7c535d83b29011ba4c4b2fd8582cb89
data/README.md ADDED
@@ -0,0 +1,144 @@
1
+ # Ruby Debug Agent
2
+
3
+ An AI-powered runtime debugging agent that embeds directly into your Ruby application. Add one gem, configure an LLM key, and chat with your live app at `/agent` to inspect GC, ObjectSpace, threads, routes, process info, HTTP requests, and more.
4
+
5
+ ## Quick Start
6
+
7
+ ### 1. Install
8
+
9
+ ```bash
10
+ # Gemfile
11
+ gem 'debug-agent', github: 'topcheer/ruby-debug-agent'
12
+ ```
13
+
14
+ Or install directly:
15
+
16
+ ```bash
17
+ gem install debug-agent --source https://github.com/topcheer/ruby-debug-agent
18
+ ```
19
+
20
+ ### 2. Integrate (Sinatra)
21
+
22
+ ```ruby
23
+ require 'sinatra/base'
24
+ require 'debug_agent'
25
+
26
+ class MyApp < Sinatra::Base
27
+ # One line to integrate
28
+ register DebugAgent::Middleware
29
+ end
30
+ ```
31
+
32
+ ### 3. Configure LLM
33
+
34
+ ```bash
35
+ export LLM_API_KEY=your-key
36
+ export LLM_BASE_URL=https://open.bigmodel.cn/api/coding/paas/v4 # default
37
+ export LLM_MODEL=glm-5.2 # default
38
+ ```
39
+
40
+ Supports any OpenAI-compatible endpoint.
41
+
42
+ ### 4. Run and open
43
+
44
+ ```
45
+ http://localhost:4567/agent
46
+ ```
47
+
48
+ ## Features
49
+
50
+ - **Streaming AI responses** with real-time tool call badges (pending / success / error)
51
+ - **Context compression** — automatically summarizes old conversation when token limit is approached
52
+ - **Dark-themed chat UI** with full markdown rendering (tables, code blocks, lists)
53
+ - **Max tool rounds** (25) with forced final summary when limit is reached
54
+ - **26 diagnostic tools** across 8 inspectors
55
+
56
+ ## Inspectors & Tools (26)
57
+
58
+ ### GC Inspector
59
+ | Tool | Description |
60
+ |------|-------------|
61
+ | `get_gc_stats` | GC.stat details: count, heap pages, slots, total allocated objects |
62
+ | `get_gc_profiler` | GC::Profiler data if available |
63
+ | `force_gc` | Trigger full GC (GC.start full_mark: true) |
64
+
65
+ ### ObjectSpace Inspector
66
+ | Tool | Description |
67
+ |------|-------------|
68
+ | `get_object_space_stats` | ObjectSpace.count_objects summary by type |
69
+ | `get_memory_size` | Total memory size of all objects (memsize_of_all) |
70
+ | `get_object_count_by_class` | Top N classes by instance count |
71
+
72
+ ### Thread Inspector
73
+ | Tool | Description |
74
+ |------|-------------|
75
+ | `get_thread_list` | List all threads with status and backtrace summary |
76
+ | `get_thread_count` | Thread count |
77
+ | `get_main_thread_info` | Main thread priority, status |
78
+
79
+ ### Route Inspector
80
+ | Tool | Description |
81
+ |------|-------------|
82
+ | `get_routes` | Discover Sinatra/Rails routes |
83
+ | `get_middleware_stack` | List Rack middleware |
84
+
85
+ ### Process Inspector
86
+ | Tool | Description |
87
+ |------|-------------|
88
+ | `get_process_info` | PID, ppid, platform, Ruby version, uptime |
89
+ | `get_cpu_time` | Process.times() user/sys CPU time |
90
+ | `get_environment_variables` | Environment variables (masked secrets) |
91
+
92
+ ### Runtime Inspector
93
+ | Tool | Description |
94
+ |------|-------------|
95
+ | `get_ruby_info` | Ruby version, engine, platform, RUBYOPT |
96
+ | `get_memory_info` | RSS memory usage |
97
+ | `get_load_average` | System load average |
98
+
99
+ ### HTTP Tracker Inspector
100
+ | Tool | Description |
101
+ |------|-------------|
102
+ | `get_recent_requests` | Recent HTTP requests ring buffer |
103
+ | `get_slow_requests` | Slowest requests by duration |
104
+ | `get_error_requests` | Error requests (4xx/5xx) |
105
+ | `get_request_stats` | P50/P95/P99 latency, error rate |
106
+
107
+ ### System Inspector
108
+ | Tool | Description |
109
+ |------|-------------|
110
+ | `get_system_info` | Hostname, CPU cores, disk |
111
+ | `get_disk_usage` | Disk usage for working directory |
112
+ | `get_file_descriptors` | Open file descriptor count |
113
+
114
+ ## Custom Tools
115
+
116
+ ```ruby
117
+ require 'debug_agent'
118
+
119
+ DebugAgent.register_tool('check_redis', 'Check Redis connection') do
120
+ { connected: true }
121
+ end
122
+ ```
123
+
124
+ ## Configuration
125
+
126
+ | Env Var | Default | Description |
127
+ |---------|---------|-------------|
128
+ | `LLM_BASE_URL` | `https://open.bigmodel.cn/api/coding/paas/v4` | LLM endpoint |
129
+ | `LLM_API_KEY` | (required) | API key |
130
+ | `LLM_MODEL` | `glm-5.2` | Model name |
131
+ | `LLM_MAX_TOOL_ROUNDS` | `25` | Max tool-calling rounds |
132
+ | `LLM_CONTEXT_WINDOW_TOKENS` | `100000` | Context window size |
133
+
134
+ ## Run the Demo
135
+
136
+ ```bash
137
+ export LLM_API_KEY=your-key
138
+ cd demo && ruby -I../lib app.rb
139
+ # Open http://localhost:4567/agent
140
+ ```
141
+
142
+ ## License
143
+
144
+ MIT