hypha-debugger 0.1.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.
- hypha_debugger-0.1.0/PKG-INFO +287 -0
- hypha_debugger-0.1.0/README.md +259 -0
- hypha_debugger-0.1.0/hypha_debugger/__init__.py +16 -0
- hypha_debugger-0.1.0/hypha_debugger/debugger.py +253 -0
- hypha_debugger-0.1.0/hypha_debugger/services/__init__.py +0 -0
- hypha_debugger-0.1.0/hypha_debugger/services/execute.py +105 -0
- hypha_debugger-0.1.0/hypha_debugger/services/filesystem.py +132 -0
- hypha_debugger-0.1.0/hypha_debugger/services/info.py +52 -0
- hypha_debugger-0.1.0/hypha_debugger/services/inspect_vars.py +153 -0
- hypha_debugger-0.1.0/hypha_debugger/utils/__init__.py +0 -0
- hypha_debugger-0.1.0/hypha_debugger/utils/env.py +71 -0
- hypha_debugger-0.1.0/hypha_debugger.egg-info/PKG-INFO +287 -0
- hypha_debugger-0.1.0/hypha_debugger.egg-info/SOURCES.txt +17 -0
- hypha_debugger-0.1.0/hypha_debugger.egg-info/dependency_links.txt +1 -0
- hypha_debugger-0.1.0/hypha_debugger.egg-info/requires.txt +9 -0
- hypha_debugger-0.1.0/hypha_debugger.egg-info/top_level.txt +1 -0
- hypha_debugger-0.1.0/pyproject.toml +49 -0
- hypha_debugger-0.1.0/setup.cfg +4 -0
- hypha_debugger-0.1.0/tests/test_services.py +77 -0
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hypha-debugger
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Injectable debugger for Python processes and AI agents, powered by Hypha RPC
|
|
5
|
+
Author: Amun AI AB
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/amun-ai/hypha-debugger
|
|
8
|
+
Project-URL: Repository, https://github.com/amun-ai/hypha-debugger
|
|
9
|
+
Keywords: debugger,hypha,rpc,remote-debugging,ai-agent
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Software Development :: Debuggers
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
Requires-Dist: hypha-rpc>=0.20.0
|
|
22
|
+
Requires-Dist: pydantic>=2.0
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
25
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
|
|
26
|
+
Provides-Extra: full
|
|
27
|
+
Requires-Dist: psutil>=5.9; extra == "full"
|
|
28
|
+
|
|
29
|
+
# Hypha Debugger
|
|
30
|
+
|
|
31
|
+
A lightweight, injectable debugger for web pages and Python processes, powered by [Hypha](https://github.com/amun-ai/hypha) RPC. Designed for AI agent workflows — inject a debugger, get a URL, call it remotely.
|
|
32
|
+
|
|
33
|
+
**No browser extension required.** Just import and start.
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
┌─────────────────────────┐ ┌──────────────┐ ┌─────────────────────────┐
|
|
37
|
+
│ Target (Browser/Python) │ ──WS──▶ │ Hypha Server │ ◀──WS── │ Remote Client │
|
|
38
|
+
│ │ │ │ │ (curl / Python / Agent) │
|
|
39
|
+
│ - Registers debug svc │ │ Routes RPC │ │ - Calls debug functions │
|
|
40
|
+
│ - Executes remote code │ │ messages │ │ - Takes screenshots │
|
|
41
|
+
│ - Returns results │ │ │ │ - Queries DOM/state │
|
|
42
|
+
└─────────────────────────┘ └──────────────┘ └─────────────────────────┘
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## JavaScript (Browser)
|
|
46
|
+
|
|
47
|
+
[](https://www.npmjs.com/package/hypha-debugger)
|
|
48
|
+
|
|
49
|
+
Inject into any web page to enable remote DOM inspection, screenshots, JavaScript execution, and React component tree inspection.
|
|
50
|
+
|
|
51
|
+
### Quick Start
|
|
52
|
+
|
|
53
|
+
**Via CDN (easiest):**
|
|
54
|
+
|
|
55
|
+
```html
|
|
56
|
+
<script src="https://cdn.jsdelivr.net/npm/hypha-rpc@0.20.97/dist/hypha-rpc-websocket.min.js"></script>
|
|
57
|
+
<script src="https://cdn.jsdelivr.net/npm/hypha-debugger/dist/hypha-debugger.min.js"></script>
|
|
58
|
+
<script>
|
|
59
|
+
hyphaDebugger.startDebugger({ server_url: 'https://hypha.aicell.io' });
|
|
60
|
+
</script>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Via npm:**
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npm install hypha-debugger hypha-rpc
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
```javascript
|
|
70
|
+
import { startDebugger } from 'hypha-debugger';
|
|
71
|
+
|
|
72
|
+
const session = await startDebugger({
|
|
73
|
+
server_url: 'https://hypha.aicell.io',
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
console.log(session.service_url); // HTTP endpoint for remote calls
|
|
77
|
+
console.log(session.token); // JWT token for authentication
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### What You Get
|
|
81
|
+
|
|
82
|
+
After starting, the debugger prints:
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
[hypha-debugger] Connected to https://hypha.aicell.io
|
|
86
|
+
[hypha-debugger] Service URL: https://hypha.aicell.io/ws-xxx/services/clientId:web-debugger
|
|
87
|
+
[hypha-debugger] Token: eyJ...
|
|
88
|
+
[hypha-debugger] Test it:
|
|
89
|
+
curl 'https://hypha.aicell.io/ws-xxx/services/clientId:web-debugger/get_page_info' -H 'Authorization: Bearer eyJ...'
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
A floating debug overlay (🐛) appears on the page with connection status, service URL (with copy button), and a live log of remote operations.
|
|
93
|
+
|
|
94
|
+
### Service Functions (JavaScript)
|
|
95
|
+
|
|
96
|
+
All functions are callable via the HTTP URL or Hypha RPC:
|
|
97
|
+
|
|
98
|
+
| Function | Description |
|
|
99
|
+
|----------|-------------|
|
|
100
|
+
| `get_page_info()` | URL, title, viewport size, detected frameworks, performance timing |
|
|
101
|
+
| `get_console_logs(level?, limit?)` | Captured console output (log/warn/error/info) |
|
|
102
|
+
| `query_dom(selector, limit?)` | Query elements by CSS selector — returns tag, text, attributes, bounds |
|
|
103
|
+
| `click_element(selector)` | Click an element |
|
|
104
|
+
| `fill_input(selector, value)` | Set value of input/textarea/select (works with React) |
|
|
105
|
+
| `scroll_to(target)` | Scroll to element (CSS selector) or position ({x, y}) |
|
|
106
|
+
| `get_computed_styles(selector, properties?)` | Get computed CSS styles |
|
|
107
|
+
| `get_element_bounds(selector)` | Get bounding rectangle and visibility |
|
|
108
|
+
| `take_screenshot(selector?, format?, scale?)` | Capture page/element as base64 PNG/JPEG |
|
|
109
|
+
| `execute_script(code, timeout_ms?)` | Execute arbitrary JavaScript, return result |
|
|
110
|
+
| `navigate(url)` | Navigate to URL |
|
|
111
|
+
| `go_back()` / `go_forward()` / `reload()` | Browser history navigation |
|
|
112
|
+
| `get_react_tree(selector?, max_depth?)` | Inspect React component tree (fiber-based) — names, props, state |
|
|
113
|
+
|
|
114
|
+
### Calling via curl
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Get page info
|
|
118
|
+
curl 'SERVICE_URL/get_page_info' -H 'Authorization: Bearer TOKEN'
|
|
119
|
+
|
|
120
|
+
# Take a screenshot
|
|
121
|
+
curl 'SERVICE_URL/take_screenshot' -H 'Authorization: Bearer TOKEN'
|
|
122
|
+
|
|
123
|
+
# Execute JavaScript
|
|
124
|
+
curl -X POST 'SERVICE_URL/execute_script' \
|
|
125
|
+
-H 'Authorization: Bearer TOKEN' \
|
|
126
|
+
-H 'Content-Type: application/json' \
|
|
127
|
+
-d '{"code": "document.title"}'
|
|
128
|
+
|
|
129
|
+
# Query DOM
|
|
130
|
+
curl -X POST 'SERVICE_URL/query_dom' \
|
|
131
|
+
-H 'Authorization: Bearer TOKEN' \
|
|
132
|
+
-H 'Content-Type: application/json' \
|
|
133
|
+
-d '{"selector": "button"}'
|
|
134
|
+
|
|
135
|
+
# Click a button
|
|
136
|
+
curl -X POST 'SERVICE_URL/click_element' \
|
|
137
|
+
-H 'Authorization: Bearer TOKEN' \
|
|
138
|
+
-H 'Content-Type: application/json' \
|
|
139
|
+
-d '{"selector": "#submit-btn"}'
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Calling via Python
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
from hypha_rpc import connect_to_server
|
|
146
|
+
|
|
147
|
+
server = await connect_to_server({
|
|
148
|
+
"server_url": "https://hypha.aicell.io",
|
|
149
|
+
"workspace": "WORKSPACE",
|
|
150
|
+
"token": "TOKEN",
|
|
151
|
+
})
|
|
152
|
+
debugger = await server.get_service("web-debugger")
|
|
153
|
+
|
|
154
|
+
info = await debugger.get_page_info()
|
|
155
|
+
screenshot = await debugger.take_screenshot()
|
|
156
|
+
result = await debugger.execute_script(code="document.title")
|
|
157
|
+
tree = await debugger.get_react_tree()
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Configuration
|
|
161
|
+
|
|
162
|
+
```javascript
|
|
163
|
+
await startDebugger({
|
|
164
|
+
server_url: 'https://hypha.aicell.io', // Required
|
|
165
|
+
workspace: 'my-workspace', // Optional, auto-assigned
|
|
166
|
+
token: 'jwt-token', // Optional
|
|
167
|
+
service_id: 'web-debugger', // Default: 'web-debugger'
|
|
168
|
+
service_name: 'Web Debugger', // Default: 'Web Debugger'
|
|
169
|
+
show_ui: true, // Default: true (floating overlay)
|
|
170
|
+
visibility: 'public', // 'public' | 'protected' | 'unlisted'
|
|
171
|
+
});
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Python
|
|
177
|
+
|
|
178
|
+
[](https://pypi.org/project/hypha-debugger/)
|
|
179
|
+
|
|
180
|
+
Inject into any Python process to enable remote code execution, variable inspection, file browsing, and process monitoring.
|
|
181
|
+
|
|
182
|
+
### Quick Start
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
pip install hypha-debugger
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Async:**
|
|
189
|
+
|
|
190
|
+
```python
|
|
191
|
+
import asyncio
|
|
192
|
+
from hypha_debugger import start_debugger
|
|
193
|
+
|
|
194
|
+
async def main():
|
|
195
|
+
session = await start_debugger(server_url="https://hypha.aicell.io")
|
|
196
|
+
print(session.service_url) # HTTP endpoint
|
|
197
|
+
print(session.token) # JWT token
|
|
198
|
+
await session.serve_forever()
|
|
199
|
+
|
|
200
|
+
asyncio.run(main())
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**Sync (scripts, notebooks):**
|
|
204
|
+
|
|
205
|
+
```python
|
|
206
|
+
from hypha_debugger import start_debugger_sync
|
|
207
|
+
|
|
208
|
+
session = start_debugger_sync(server_url="https://hypha.aicell.io")
|
|
209
|
+
# Debugger runs in background, main thread continues
|
|
210
|
+
print(session.service_url)
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### What You Get
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
[hypha-debugger] Connected to https://hypha.aicell.io
|
|
217
|
+
[hypha-debugger] Service URL: https://hypha.aicell.io/ws-xxx/services/clientId:py-debugger
|
|
218
|
+
[hypha-debugger] Token: eyJ...
|
|
219
|
+
[hypha-debugger] Test it:
|
|
220
|
+
curl 'https://hypha.aicell.io/ws-xxx/services/clientId:py-debugger/get_process_info' -H 'Authorization: Bearer eyJ...'
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Service Functions (Python)
|
|
224
|
+
|
|
225
|
+
| Function | Description |
|
|
226
|
+
|----------|-------------|
|
|
227
|
+
| `get_process_info()` | PID, CWD, Python version, hostname, platform, memory usage |
|
|
228
|
+
| `execute_code(code, namespace?)` | Execute arbitrary Python code, return stdout/stderr/result |
|
|
229
|
+
| `get_variable(name, namespace?)` | Inspect a variable — type, value, shape (for numpy), keys (for dicts) |
|
|
230
|
+
| `list_variables(namespace?, filter?)` | List variables in scope |
|
|
231
|
+
| `get_stack_trace()` | Stack trace of all threads |
|
|
232
|
+
| `list_files(path?, pattern?)` | List files in directory (sandboxed to CWD) |
|
|
233
|
+
| `read_file(path, max_lines?, encoding?)` | Read a file (sandboxed to CWD) |
|
|
234
|
+
| `get_installed_packages(filter?)` | List installed pip packages |
|
|
235
|
+
|
|
236
|
+
### Calling via curl
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
# Get process info
|
|
240
|
+
curl 'SERVICE_URL/get_process_info' -H 'Authorization: Bearer TOKEN'
|
|
241
|
+
|
|
242
|
+
# Execute Python code
|
|
243
|
+
curl -X POST 'SERVICE_URL/execute_code' \
|
|
244
|
+
-H 'Authorization: Bearer TOKEN' \
|
|
245
|
+
-H 'Content-Type: application/json' \
|
|
246
|
+
-d '{"code": "2 + 2"}'
|
|
247
|
+
|
|
248
|
+
# List files
|
|
249
|
+
curl 'SERVICE_URL/list_files' -H 'Authorization: Bearer TOKEN'
|
|
250
|
+
|
|
251
|
+
# Read a file
|
|
252
|
+
curl -X POST 'SERVICE_URL/read_file' \
|
|
253
|
+
-H 'Authorization: Bearer TOKEN' \
|
|
254
|
+
-H 'Content-Type: application/json' \
|
|
255
|
+
-d '{"path": "main.py"}'
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Calling via Python (remote client)
|
|
259
|
+
|
|
260
|
+
```python
|
|
261
|
+
from hypha_rpc import connect_to_server
|
|
262
|
+
|
|
263
|
+
server = await connect_to_server({
|
|
264
|
+
"server_url": "https://hypha.aicell.io",
|
|
265
|
+
"workspace": "WORKSPACE",
|
|
266
|
+
"token": "TOKEN",
|
|
267
|
+
})
|
|
268
|
+
debugger = await server.get_service("py-debugger")
|
|
269
|
+
|
|
270
|
+
info = await debugger.get_process_info()
|
|
271
|
+
result = await debugger.execute_code(code="import sys; sys.version")
|
|
272
|
+
files = await debugger.list_files()
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## How It Works
|
|
278
|
+
|
|
279
|
+
1. Your target (browser page or Python process) connects to a [Hypha server](https://github.com/amun-ai/hypha) via WebSocket
|
|
280
|
+
2. It registers an RPC service with schema-annotated functions
|
|
281
|
+
3. The debugger prints a **Service URL** and **Token**
|
|
282
|
+
4. Remote clients call service functions via HTTP REST or Hypha RPC WebSocket
|
|
283
|
+
5. All functions have JSON Schema annotations, making them compatible with LLM/AI agent tool calling
|
|
284
|
+
|
|
285
|
+
## License
|
|
286
|
+
|
|
287
|
+
MIT
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
# Hypha Debugger
|
|
2
|
+
|
|
3
|
+
A lightweight, injectable debugger for web pages and Python processes, powered by [Hypha](https://github.com/amun-ai/hypha) RPC. Designed for AI agent workflows — inject a debugger, get a URL, call it remotely.
|
|
4
|
+
|
|
5
|
+
**No browser extension required.** Just import and start.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
┌─────────────────────────┐ ┌──────────────┐ ┌─────────────────────────┐
|
|
9
|
+
│ Target (Browser/Python) │ ──WS──▶ │ Hypha Server │ ◀──WS── │ Remote Client │
|
|
10
|
+
│ │ │ │ │ (curl / Python / Agent) │
|
|
11
|
+
│ - Registers debug svc │ │ Routes RPC │ │ - Calls debug functions │
|
|
12
|
+
│ - Executes remote code │ │ messages │ │ - Takes screenshots │
|
|
13
|
+
│ - Returns results │ │ │ │ - Queries DOM/state │
|
|
14
|
+
└─────────────────────────┘ └──────────────┘ └─────────────────────────┘
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## JavaScript (Browser)
|
|
18
|
+
|
|
19
|
+
[](https://www.npmjs.com/package/hypha-debugger)
|
|
20
|
+
|
|
21
|
+
Inject into any web page to enable remote DOM inspection, screenshots, JavaScript execution, and React component tree inspection.
|
|
22
|
+
|
|
23
|
+
### Quick Start
|
|
24
|
+
|
|
25
|
+
**Via CDN (easiest):**
|
|
26
|
+
|
|
27
|
+
```html
|
|
28
|
+
<script src="https://cdn.jsdelivr.net/npm/hypha-rpc@0.20.97/dist/hypha-rpc-websocket.min.js"></script>
|
|
29
|
+
<script src="https://cdn.jsdelivr.net/npm/hypha-debugger/dist/hypha-debugger.min.js"></script>
|
|
30
|
+
<script>
|
|
31
|
+
hyphaDebugger.startDebugger({ server_url: 'https://hypha.aicell.io' });
|
|
32
|
+
</script>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Via npm:**
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install hypha-debugger hypha-rpc
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
import { startDebugger } from 'hypha-debugger';
|
|
43
|
+
|
|
44
|
+
const session = await startDebugger({
|
|
45
|
+
server_url: 'https://hypha.aicell.io',
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
console.log(session.service_url); // HTTP endpoint for remote calls
|
|
49
|
+
console.log(session.token); // JWT token for authentication
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### What You Get
|
|
53
|
+
|
|
54
|
+
After starting, the debugger prints:
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
[hypha-debugger] Connected to https://hypha.aicell.io
|
|
58
|
+
[hypha-debugger] Service URL: https://hypha.aicell.io/ws-xxx/services/clientId:web-debugger
|
|
59
|
+
[hypha-debugger] Token: eyJ...
|
|
60
|
+
[hypha-debugger] Test it:
|
|
61
|
+
curl 'https://hypha.aicell.io/ws-xxx/services/clientId:web-debugger/get_page_info' -H 'Authorization: Bearer eyJ...'
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
A floating debug overlay (🐛) appears on the page with connection status, service URL (with copy button), and a live log of remote operations.
|
|
65
|
+
|
|
66
|
+
### Service Functions (JavaScript)
|
|
67
|
+
|
|
68
|
+
All functions are callable via the HTTP URL or Hypha RPC:
|
|
69
|
+
|
|
70
|
+
| Function | Description |
|
|
71
|
+
|----------|-------------|
|
|
72
|
+
| `get_page_info()` | URL, title, viewport size, detected frameworks, performance timing |
|
|
73
|
+
| `get_console_logs(level?, limit?)` | Captured console output (log/warn/error/info) |
|
|
74
|
+
| `query_dom(selector, limit?)` | Query elements by CSS selector — returns tag, text, attributes, bounds |
|
|
75
|
+
| `click_element(selector)` | Click an element |
|
|
76
|
+
| `fill_input(selector, value)` | Set value of input/textarea/select (works with React) |
|
|
77
|
+
| `scroll_to(target)` | Scroll to element (CSS selector) or position ({x, y}) |
|
|
78
|
+
| `get_computed_styles(selector, properties?)` | Get computed CSS styles |
|
|
79
|
+
| `get_element_bounds(selector)` | Get bounding rectangle and visibility |
|
|
80
|
+
| `take_screenshot(selector?, format?, scale?)` | Capture page/element as base64 PNG/JPEG |
|
|
81
|
+
| `execute_script(code, timeout_ms?)` | Execute arbitrary JavaScript, return result |
|
|
82
|
+
| `navigate(url)` | Navigate to URL |
|
|
83
|
+
| `go_back()` / `go_forward()` / `reload()` | Browser history navigation |
|
|
84
|
+
| `get_react_tree(selector?, max_depth?)` | Inspect React component tree (fiber-based) — names, props, state |
|
|
85
|
+
|
|
86
|
+
### Calling via curl
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# Get page info
|
|
90
|
+
curl 'SERVICE_URL/get_page_info' -H 'Authorization: Bearer TOKEN'
|
|
91
|
+
|
|
92
|
+
# Take a screenshot
|
|
93
|
+
curl 'SERVICE_URL/take_screenshot' -H 'Authorization: Bearer TOKEN'
|
|
94
|
+
|
|
95
|
+
# Execute JavaScript
|
|
96
|
+
curl -X POST 'SERVICE_URL/execute_script' \
|
|
97
|
+
-H 'Authorization: Bearer TOKEN' \
|
|
98
|
+
-H 'Content-Type: application/json' \
|
|
99
|
+
-d '{"code": "document.title"}'
|
|
100
|
+
|
|
101
|
+
# Query DOM
|
|
102
|
+
curl -X POST 'SERVICE_URL/query_dom' \
|
|
103
|
+
-H 'Authorization: Bearer TOKEN' \
|
|
104
|
+
-H 'Content-Type: application/json' \
|
|
105
|
+
-d '{"selector": "button"}'
|
|
106
|
+
|
|
107
|
+
# Click a button
|
|
108
|
+
curl -X POST 'SERVICE_URL/click_element' \
|
|
109
|
+
-H 'Authorization: Bearer TOKEN' \
|
|
110
|
+
-H 'Content-Type: application/json' \
|
|
111
|
+
-d '{"selector": "#submit-btn"}'
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Calling via Python
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
from hypha_rpc import connect_to_server
|
|
118
|
+
|
|
119
|
+
server = await connect_to_server({
|
|
120
|
+
"server_url": "https://hypha.aicell.io",
|
|
121
|
+
"workspace": "WORKSPACE",
|
|
122
|
+
"token": "TOKEN",
|
|
123
|
+
})
|
|
124
|
+
debugger = await server.get_service("web-debugger")
|
|
125
|
+
|
|
126
|
+
info = await debugger.get_page_info()
|
|
127
|
+
screenshot = await debugger.take_screenshot()
|
|
128
|
+
result = await debugger.execute_script(code="document.title")
|
|
129
|
+
tree = await debugger.get_react_tree()
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Configuration
|
|
133
|
+
|
|
134
|
+
```javascript
|
|
135
|
+
await startDebugger({
|
|
136
|
+
server_url: 'https://hypha.aicell.io', // Required
|
|
137
|
+
workspace: 'my-workspace', // Optional, auto-assigned
|
|
138
|
+
token: 'jwt-token', // Optional
|
|
139
|
+
service_id: 'web-debugger', // Default: 'web-debugger'
|
|
140
|
+
service_name: 'Web Debugger', // Default: 'Web Debugger'
|
|
141
|
+
show_ui: true, // Default: true (floating overlay)
|
|
142
|
+
visibility: 'public', // 'public' | 'protected' | 'unlisted'
|
|
143
|
+
});
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Python
|
|
149
|
+
|
|
150
|
+
[](https://pypi.org/project/hypha-debugger/)
|
|
151
|
+
|
|
152
|
+
Inject into any Python process to enable remote code execution, variable inspection, file browsing, and process monitoring.
|
|
153
|
+
|
|
154
|
+
### Quick Start
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
pip install hypha-debugger
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Async:**
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
import asyncio
|
|
164
|
+
from hypha_debugger import start_debugger
|
|
165
|
+
|
|
166
|
+
async def main():
|
|
167
|
+
session = await start_debugger(server_url="https://hypha.aicell.io")
|
|
168
|
+
print(session.service_url) # HTTP endpoint
|
|
169
|
+
print(session.token) # JWT token
|
|
170
|
+
await session.serve_forever()
|
|
171
|
+
|
|
172
|
+
asyncio.run(main())
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Sync (scripts, notebooks):**
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
from hypha_debugger import start_debugger_sync
|
|
179
|
+
|
|
180
|
+
session = start_debugger_sync(server_url="https://hypha.aicell.io")
|
|
181
|
+
# Debugger runs in background, main thread continues
|
|
182
|
+
print(session.service_url)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### What You Get
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
[hypha-debugger] Connected to https://hypha.aicell.io
|
|
189
|
+
[hypha-debugger] Service URL: https://hypha.aicell.io/ws-xxx/services/clientId:py-debugger
|
|
190
|
+
[hypha-debugger] Token: eyJ...
|
|
191
|
+
[hypha-debugger] Test it:
|
|
192
|
+
curl 'https://hypha.aicell.io/ws-xxx/services/clientId:py-debugger/get_process_info' -H 'Authorization: Bearer eyJ...'
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Service Functions (Python)
|
|
196
|
+
|
|
197
|
+
| Function | Description |
|
|
198
|
+
|----------|-------------|
|
|
199
|
+
| `get_process_info()` | PID, CWD, Python version, hostname, platform, memory usage |
|
|
200
|
+
| `execute_code(code, namespace?)` | Execute arbitrary Python code, return stdout/stderr/result |
|
|
201
|
+
| `get_variable(name, namespace?)` | Inspect a variable — type, value, shape (for numpy), keys (for dicts) |
|
|
202
|
+
| `list_variables(namespace?, filter?)` | List variables in scope |
|
|
203
|
+
| `get_stack_trace()` | Stack trace of all threads |
|
|
204
|
+
| `list_files(path?, pattern?)` | List files in directory (sandboxed to CWD) |
|
|
205
|
+
| `read_file(path, max_lines?, encoding?)` | Read a file (sandboxed to CWD) |
|
|
206
|
+
| `get_installed_packages(filter?)` | List installed pip packages |
|
|
207
|
+
|
|
208
|
+
### Calling via curl
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
# Get process info
|
|
212
|
+
curl 'SERVICE_URL/get_process_info' -H 'Authorization: Bearer TOKEN'
|
|
213
|
+
|
|
214
|
+
# Execute Python code
|
|
215
|
+
curl -X POST 'SERVICE_URL/execute_code' \
|
|
216
|
+
-H 'Authorization: Bearer TOKEN' \
|
|
217
|
+
-H 'Content-Type: application/json' \
|
|
218
|
+
-d '{"code": "2 + 2"}'
|
|
219
|
+
|
|
220
|
+
# List files
|
|
221
|
+
curl 'SERVICE_URL/list_files' -H 'Authorization: Bearer TOKEN'
|
|
222
|
+
|
|
223
|
+
# Read a file
|
|
224
|
+
curl -X POST 'SERVICE_URL/read_file' \
|
|
225
|
+
-H 'Authorization: Bearer TOKEN' \
|
|
226
|
+
-H 'Content-Type: application/json' \
|
|
227
|
+
-d '{"path": "main.py"}'
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Calling via Python (remote client)
|
|
231
|
+
|
|
232
|
+
```python
|
|
233
|
+
from hypha_rpc import connect_to_server
|
|
234
|
+
|
|
235
|
+
server = await connect_to_server({
|
|
236
|
+
"server_url": "https://hypha.aicell.io",
|
|
237
|
+
"workspace": "WORKSPACE",
|
|
238
|
+
"token": "TOKEN",
|
|
239
|
+
})
|
|
240
|
+
debugger = await server.get_service("py-debugger")
|
|
241
|
+
|
|
242
|
+
info = await debugger.get_process_info()
|
|
243
|
+
result = await debugger.execute_code(code="import sys; sys.version")
|
|
244
|
+
files = await debugger.list_files()
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## How It Works
|
|
250
|
+
|
|
251
|
+
1. Your target (browser page or Python process) connects to a [Hypha server](https://github.com/amun-ai/hypha) via WebSocket
|
|
252
|
+
2. It registers an RPC service with schema-annotated functions
|
|
253
|
+
3. The debugger prints a **Service URL** and **Token**
|
|
254
|
+
4. Remote clients call service functions via HTTP REST or Hypha RPC WebSocket
|
|
255
|
+
5. All functions have JSON Schema annotations, making them compatible with LLM/AI agent tool calling
|
|
256
|
+
|
|
257
|
+
## License
|
|
258
|
+
|
|
259
|
+
MIT
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""
|
|
2
|
+
hypha-debugger: Injectable debugger for Python processes, powered by Hypha RPC.
|
|
3
|
+
|
|
4
|
+
Usage (async):
|
|
5
|
+
from hypha_debugger import start_debugger
|
|
6
|
+
session = await start_debugger(server_url="https://hypha.aicell.io")
|
|
7
|
+
|
|
8
|
+
Usage (sync):
|
|
9
|
+
from hypha_debugger import start_debugger_sync
|
|
10
|
+
session = start_debugger_sync(server_url="https://hypha.aicell.io")
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from hypha_debugger.debugger import start_debugger, start_debugger_sync, DebugSession
|
|
14
|
+
|
|
15
|
+
__version__ = "0.1.0"
|
|
16
|
+
__all__ = ["start_debugger", "start_debugger_sync", "DebugSession", "__version__"]
|