@ohah/agent-devtools 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +483 -0
- package/SKILL.md +203 -0
- package/bin/agent-devtools.js +70 -0
- package/package.json +35 -0
- package/scripts/postinstall.js +123 -0
- package/skills/agent-devtools/SKILL.md +203 -0
- package/skills/agent-devtools/references/commands.md +104 -0
- package/skills/agent-devtools/references/debug-mode.md +39 -0
- package/skills/agent-devtools/references/patterns.md +82 -0
- package/skills/agent-devtools/templates/api-discovery.sh +25 -0
- package/skills/agent-devtools/templates/authenticated-session.sh +31 -0
- package/skills/agent-devtools/templates/form-automation.sh +21 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { execFileSync } from "node:child_process";
|
|
4
|
+
import { existsSync } from "node:fs";
|
|
5
|
+
import { join, dirname } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
|
|
8
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
|
|
10
|
+
function getPlatform() {
|
|
11
|
+
const platform = process.platform;
|
|
12
|
+
switch (platform) {
|
|
13
|
+
case "darwin":
|
|
14
|
+
return "darwin";
|
|
15
|
+
case "linux":
|
|
16
|
+
return "linux";
|
|
17
|
+
case "win32":
|
|
18
|
+
return "win32";
|
|
19
|
+
default:
|
|
20
|
+
throw new Error(`Unsupported platform: ${platform}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function getArch() {
|
|
25
|
+
const arch = process.arch;
|
|
26
|
+
switch (arch) {
|
|
27
|
+
case "arm64":
|
|
28
|
+
return "arm64";
|
|
29
|
+
case "x64":
|
|
30
|
+
return "x64";
|
|
31
|
+
default:
|
|
32
|
+
throw new Error(`Unsupported architecture: ${arch}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function getBinaryName(platform, arch) {
|
|
37
|
+
const ext = platform === "win32" ? ".exe" : "";
|
|
38
|
+
return `agent-devtools-${platform}-${arch}${ext}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const platform = getPlatform();
|
|
42
|
+
const arch = getArch();
|
|
43
|
+
const binaryName = getBinaryName(platform, arch);
|
|
44
|
+
const binaryPath = join(__dirname, binaryName);
|
|
45
|
+
|
|
46
|
+
if (!existsSync(binaryPath)) {
|
|
47
|
+
console.error(`Binary not found: ${binaryPath}`);
|
|
48
|
+
console.error("");
|
|
49
|
+
console.error("The native binary was not downloaded during installation.");
|
|
50
|
+
console.error("Try reinstalling:");
|
|
51
|
+
console.error(" npm install @ohah/agent-devtools");
|
|
52
|
+
console.error("");
|
|
53
|
+
console.error("Or build from source:");
|
|
54
|
+
console.error(" git clone https://github.com/ohah/agent-devtools");
|
|
55
|
+
console.error(" cd agent-devtools");
|
|
56
|
+
console.error(" zig build -Doptimize=ReleaseSafe");
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
execFileSync(binaryPath, process.argv.slice(2), {
|
|
62
|
+
stdio: "inherit",
|
|
63
|
+
env: process.env,
|
|
64
|
+
});
|
|
65
|
+
} catch (error) {
|
|
66
|
+
if (error.status !== null) {
|
|
67
|
+
process.exit(error.status);
|
|
68
|
+
}
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ohah/agent-devtools",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Browser DevTools CLI for AI agents — web debugging, API reverse engineering, network interception",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"bin",
|
|
8
|
+
"scripts",
|
|
9
|
+
"skills",
|
|
10
|
+
"SKILL.md"
|
|
11
|
+
],
|
|
12
|
+
"bin": {
|
|
13
|
+
"agent-devtools": "./bin/agent-devtools.js"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"postinstall": "node scripts/postinstall.js"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"browser",
|
|
20
|
+
"automation",
|
|
21
|
+
"ai",
|
|
22
|
+
"agent",
|
|
23
|
+
"devtools",
|
|
24
|
+
"cdp",
|
|
25
|
+
"chrome",
|
|
26
|
+
"testing",
|
|
27
|
+
"debugging"
|
|
28
|
+
],
|
|
29
|
+
"author": "ohah",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/ohah/agent-devtools"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { createWriteStream, chmodSync, existsSync, mkdirSync } from "node:fs";
|
|
2
|
+
import { join, dirname } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { get as httpsGet } from "node:https";
|
|
5
|
+
import { get as httpGet } from "node:http";
|
|
6
|
+
import { createRequire } from "node:module";
|
|
7
|
+
|
|
8
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
const pkg = require("../package.json");
|
|
11
|
+
|
|
12
|
+
function getPlatform() {
|
|
13
|
+
switch (process.platform) {
|
|
14
|
+
case "darwin":
|
|
15
|
+
return "darwin";
|
|
16
|
+
case "linux":
|
|
17
|
+
return "linux";
|
|
18
|
+
case "win32":
|
|
19
|
+
return "win32";
|
|
20
|
+
default:
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getArch() {
|
|
26
|
+
switch (process.arch) {
|
|
27
|
+
case "arm64":
|
|
28
|
+
return "arm64";
|
|
29
|
+
case "x64":
|
|
30
|
+
return "x64";
|
|
31
|
+
default:
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function getBinaryName(platform, arch) {
|
|
37
|
+
const ext = platform === "win32" ? ".exe" : "";
|
|
38
|
+
return `agent-devtools-${platform}-${arch}${ext}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function download(url) {
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
const client = url.startsWith("https") ? httpsGet : httpGet;
|
|
44
|
+
client(url, (response) => {
|
|
45
|
+
// Follow redirects (GitHub releases redirect to S3)
|
|
46
|
+
if (response.statusCode >= 300 && response.statusCode < 400 && response.headers.location) {
|
|
47
|
+
download(response.headers.location).then(resolve).catch(reject);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (response.statusCode !== 200) {
|
|
52
|
+
reject(new Error(`Download failed with status ${response.statusCode}: ${url}`));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
resolve(response);
|
|
57
|
+
}).on("error", reject);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function main() {
|
|
62
|
+
const platform = getPlatform();
|
|
63
|
+
const arch = getArch();
|
|
64
|
+
|
|
65
|
+
if (!platform || !arch) {
|
|
66
|
+
console.warn(`[agent-devtools] Unsupported platform: ${process.platform}-${process.arch}`);
|
|
67
|
+
console.warn("[agent-devtools] You can build from source: https://github.com/ohah/agent-devtools");
|
|
68
|
+
process.exit(0);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const binaryName = getBinaryName(platform, arch);
|
|
72
|
+
const binDir = join(__dirname, "..", "bin");
|
|
73
|
+
const binaryPath = join(binDir, binaryName);
|
|
74
|
+
|
|
75
|
+
// Skip if binary already exists (e.g., local development)
|
|
76
|
+
if (existsSync(binaryPath)) {
|
|
77
|
+
console.log(`[agent-devtools] Binary already exists: ${binaryName}`);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const version = pkg.version;
|
|
82
|
+
const url = `https://github.com/ohah/agent-devtools/releases/download/v${version}/${binaryName}`;
|
|
83
|
+
|
|
84
|
+
console.log(`[agent-devtools] Downloading ${binaryName} v${version}...`);
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
if (!existsSync(binDir)) {
|
|
88
|
+
mkdirSync(binDir, { recursive: true });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const response = await download(url);
|
|
92
|
+
const file = createWriteStream(binaryPath);
|
|
93
|
+
|
|
94
|
+
await new Promise((resolve, reject) => {
|
|
95
|
+
response.pipe(file);
|
|
96
|
+
file.on("finish", () => {
|
|
97
|
+
file.close(resolve);
|
|
98
|
+
});
|
|
99
|
+
file.on("error", reject);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// Make executable on Unix
|
|
103
|
+
if (platform !== "win32") {
|
|
104
|
+
chmodSync(binaryPath, 0o755);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
console.log(`[agent-devtools] Successfully installed ${binaryName}`);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
console.warn(`[agent-devtools] Failed to download binary: ${error.message}`);
|
|
110
|
+
console.warn("");
|
|
111
|
+
console.warn("You can build from source instead:");
|
|
112
|
+
console.warn(" git clone https://github.com/ohah/agent-devtools");
|
|
113
|
+
console.warn(" cd agent-devtools");
|
|
114
|
+
console.warn(" zig build -Doptimize=ReleaseSafe");
|
|
115
|
+
console.warn("");
|
|
116
|
+
console.warn("Then copy the binary to:");
|
|
117
|
+
console.warn(` ${binaryPath}`);
|
|
118
|
+
// Don't fail the install — the user can still build manually
|
|
119
|
+
process.exit(0);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
main();
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agent-devtools
|
|
3
|
+
description: Browser automation and web debugging CLI for AI agents. Use when the user needs to interact with websites, fill forms, click buttons, take screenshots, extract data, test web apps, inspect network traffic, reverse-engineer APIs, intercept requests, or record/diff network flows. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data", "test this web app", "login to a site", "inspect network requests", "find API endpoints", "mock an API", or any task requiring programmatic web interaction.
|
|
4
|
+
allowed-tools: Bash(agent-devtools:*), Bash(./zig-out/bin/agent-devtools:*)
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Browser Automation with agent-devtools
|
|
8
|
+
|
|
9
|
+
Controls Chrome/Chromium via CDP. Browser persists via background daemon across commands.
|
|
10
|
+
|
|
11
|
+
## Core Workflow
|
|
12
|
+
|
|
13
|
+
1. `agent-devtools open <url>` — navigate
|
|
14
|
+
2. `agent-devtools snapshot -i` — get interactive element refs
|
|
15
|
+
3. Use refs (`@e1`, `@e2`) to interact
|
|
16
|
+
4. Re-snapshot after navigation or DOM changes
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
agent-devtools open https://example.com/form
|
|
20
|
+
agent-devtools snapshot -i
|
|
21
|
+
# Output:
|
|
22
|
+
# - textbox "Email" [ref=e1]
|
|
23
|
+
# - textbox "Password" [ref=e2]
|
|
24
|
+
# - button "Submit" [ref=e3]
|
|
25
|
+
|
|
26
|
+
agent-devtools fill @e1 "user@example.com"
|
|
27
|
+
agent-devtools fill @e2 "password123"
|
|
28
|
+
agent-devtools click @e3
|
|
29
|
+
agent-devtools snapshot -i # Re-snapshot after submit
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Refs are invalidated on page changes.** Always re-snapshot after clicking links, submitting forms, or loading dynamic content.
|
|
33
|
+
|
|
34
|
+
## Commands
|
|
35
|
+
|
|
36
|
+
### Navigation
|
|
37
|
+
```
|
|
38
|
+
open <url> Navigate (aliases: navigate, goto)
|
|
39
|
+
back / forward History navigation
|
|
40
|
+
reload Reload page
|
|
41
|
+
close Close browser + daemon
|
|
42
|
+
url / title Get current URL / page title
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Snapshot + Interaction
|
|
46
|
+
```
|
|
47
|
+
snapshot -i Interactive elements only (recommended)
|
|
48
|
+
snapshot Full accessibility tree
|
|
49
|
+
click @e1 Click
|
|
50
|
+
dblclick @e1 Double-click
|
|
51
|
+
tap @e1 Touch tap
|
|
52
|
+
fill @e1 "text" Clear + type
|
|
53
|
+
type @e1 "text" Type (no clear)
|
|
54
|
+
press Enter Press key
|
|
55
|
+
hover / focus @e1 Hover or focus
|
|
56
|
+
select @e1 "val" Select dropdown
|
|
57
|
+
check / uncheck @e1 Checkbox
|
|
58
|
+
scroll down 500 Scroll (up/down/left/right)
|
|
59
|
+
drag @e1 @e2 Drag and drop
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Get Information
|
|
63
|
+
```
|
|
64
|
+
get text/html/value @e1 Element content
|
|
65
|
+
get attr @e1 href Attribute value
|
|
66
|
+
get url / get title Page info
|
|
67
|
+
is visible/enabled/checked @e1
|
|
68
|
+
boundingbox @e1 Bounding box {x,y,w,h}
|
|
69
|
+
styles @e1 color Computed CSS value
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Find Elements (without snapshot)
|
|
73
|
+
```
|
|
74
|
+
find role button Find by ARIA role
|
|
75
|
+
find text "Submit" Find by text content
|
|
76
|
+
find label "Email" Find by label
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Capture & Performance
|
|
80
|
+
```
|
|
81
|
+
screenshot [path] PNG screenshot
|
|
82
|
+
screenshot --annotate [path] Screenshot with @ref labels overlay
|
|
83
|
+
diff-screenshot <baseline> [current] [--threshold N] [--output path]
|
|
84
|
+
pdf [path] Save as PDF
|
|
85
|
+
eval <js> Run JavaScript
|
|
86
|
+
video start/stop [path] Record video (requires FFmpeg)
|
|
87
|
+
trace start/stop [path] Chrome DevTools trace
|
|
88
|
+
profiler start/stop [path] CPU profiler
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Network (unique feature)
|
|
92
|
+
```
|
|
93
|
+
network list [pattern] List requests (filter by URL)
|
|
94
|
+
network get <id> Full request/response with body
|
|
95
|
+
analyze API reverse engineering + schema
|
|
96
|
+
intercept mock "/api" '{}' Mock response
|
|
97
|
+
intercept fail "/api" Block request
|
|
98
|
+
intercept delay "/api" 3000 Delay request
|
|
99
|
+
har [file] Export HAR 1.2
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Wait
|
|
103
|
+
```
|
|
104
|
+
wait <ms> Wait milliseconds
|
|
105
|
+
waitforloadstate [ms] Wait for page load
|
|
106
|
+
waitfor network <pat> [ms] Wait for network request
|
|
107
|
+
waitfor console <pat> [ms] Wait for console message
|
|
108
|
+
waitfor error [ms] Wait for JS error
|
|
109
|
+
waitdownload [ms] Wait for download
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Settings
|
|
113
|
+
```
|
|
114
|
+
set viewport 1920 1080 Viewport size
|
|
115
|
+
set media dark Color scheme
|
|
116
|
+
set timezone Asia/Seoul Timezone
|
|
117
|
+
set locale ko-KR Locale
|
|
118
|
+
set device "iPhone 14" Device emulation
|
|
119
|
+
set useragent "..." User agent
|
|
120
|
+
set geolocation 37.5 127 Geolocation
|
|
121
|
+
set headers '{"X":"Y"}' HTTP headers
|
|
122
|
+
set offline on Offline mode
|
|
123
|
+
set ignore-https-errors Ignore cert errors
|
|
124
|
+
set permissions grant geo Grant permission
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Storage & State
|
|
128
|
+
```
|
|
129
|
+
cookies [list/set/get/clear] Cookies
|
|
130
|
+
storage local [key] localStorage
|
|
131
|
+
state save/load/list Save/restore cookies + storage
|
|
132
|
+
credentials <user> <pass> HTTP basic auth
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Tabs & Console
|
|
136
|
+
```
|
|
137
|
+
tab list / new / close / switch <n>
|
|
138
|
+
console list / clear
|
|
139
|
+
errors [clear]
|
|
140
|
+
dialog accept/dismiss/info
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Recording
|
|
144
|
+
```
|
|
145
|
+
record <name> Save network state
|
|
146
|
+
diff <name> Compare current vs recorded
|
|
147
|
+
replay <name> Navigate + diff
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Auth Vault
|
|
151
|
+
```
|
|
152
|
+
auth save <name> --url <url> --username <user> --password <pass>
|
|
153
|
+
auth login <name> Auto-login (navigate + fill + submit)
|
|
154
|
+
auth list / show / delete <name>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Security & Config
|
|
158
|
+
```
|
|
159
|
+
--proxy <url> Proxy server
|
|
160
|
+
--proxy-bypass <list> Proxy bypass list
|
|
161
|
+
--extension <path> Load Chrome extension
|
|
162
|
+
--allowed-domains <list> Restrict navigation domains
|
|
163
|
+
--content-boundaries Wrap output with boundary markers
|
|
164
|
+
--auto-connect Auto-discover running Chrome/Electron
|
|
165
|
+
agent-devtools.json Config file (project or ~/.agent-devtools/config.json)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Interactive Mode
|
|
169
|
+
|
|
170
|
+
`--interactive` for persistent sessions. Events stream automatically.
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
agent-devtools --interactive
|
|
174
|
+
> open https://example.com
|
|
175
|
+
< {"success":true}
|
|
176
|
+
< {"event":"network","url":"https://example.com/","method":"GET","status":200}
|
|
177
|
+
> snapshot -i
|
|
178
|
+
< {"success":true,"data":"- button \"Submit\" [ref=e1]\n"}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Debug Mode
|
|
182
|
+
|
|
183
|
+
`--debug` with `--interactive` — action commands automatically include triggered API requests and URL changes. Static resources filtered.
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
agent-devtools --interactive --debug
|
|
187
|
+
> click @e3
|
|
188
|
+
< {"success":true,"debug":{"new_requests":[{"url":"/api/login","method":"POST","status":200}],"url_changed":true}}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Deep-Dive Documentation
|
|
192
|
+
|
|
193
|
+
For detailed reference, see `references/`:
|
|
194
|
+
- [commands.md](references/commands.md) — Full command reference
|
|
195
|
+
- [debug-mode.md](references/debug-mode.md) — Debug mode details
|
|
196
|
+
- [patterns.md](references/patterns.md) — Common automation patterns
|
|
197
|
+
|
|
198
|
+
## Ready-to-Use Templates
|
|
199
|
+
|
|
200
|
+
Copy and customize these shell scripts from `templates/`:
|
|
201
|
+
- [form-automation.sh](templates/form-automation.sh) — Form fill + submit
|
|
202
|
+
- [authenticated-session.sh](templates/authenticated-session.sh) — Login + state persistence
|
|
203
|
+
- [api-discovery.sh](templates/api-discovery.sh) — API reverse engineering workflow
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Full Command Reference
|
|
2
|
+
|
|
3
|
+
## Navigation
|
|
4
|
+
| Command | Description |
|
|
5
|
+
|---|---|
|
|
6
|
+
| `open <url>` | Navigate (aliases: navigate, goto) |
|
|
7
|
+
| `back` / `forward` / `reload` | History navigation |
|
|
8
|
+
| `close` | Close browser + daemon |
|
|
9
|
+
| `url` / `title` | Get current URL / title |
|
|
10
|
+
| `content` / `setcontent <html>` | Get/set page HTML |
|
|
11
|
+
| `bringtofront` | Bring window to front |
|
|
12
|
+
|
|
13
|
+
## Snapshot + Interaction
|
|
14
|
+
| Command | Description |
|
|
15
|
+
|---|---|
|
|
16
|
+
| `snapshot -i` | Interactive elements only (recommended) |
|
|
17
|
+
| `snapshot` | Full accessibility tree |
|
|
18
|
+
| `click` / `dblclick` / `tap @ref` | Click / double-click / touch tap |
|
|
19
|
+
| `fill @ref "text"` | Clear + type |
|
|
20
|
+
| `type @ref "text"` | Type without clearing |
|
|
21
|
+
| `press <key>` | Press key (Enter, Tab, Escape) |
|
|
22
|
+
| `hover` / `focus @ref` | Hover / focus |
|
|
23
|
+
| `check` / `uncheck @ref` | Checkbox |
|
|
24
|
+
| `select @ref "val"` | Dropdown |
|
|
25
|
+
| `clear` / `selectall @ref` | Clear / select all text |
|
|
26
|
+
| `scroll <dir> [px]` | Scroll (up/down/left/right) |
|
|
27
|
+
| `scroll to <x> <y>` | Scroll to coordinates |
|
|
28
|
+
| `scrollintoview @ref` | Scroll element into view |
|
|
29
|
+
| `drag @from @to` | Drag and drop |
|
|
30
|
+
| `upload @ref <file>` | Upload file |
|
|
31
|
+
| `dispatch @ref <event>` | Dispatch DOM event |
|
|
32
|
+
| `highlight @ref` | Highlight with overlay |
|
|
33
|
+
|
|
34
|
+
## Get Information
|
|
35
|
+
| Command | Description |
|
|
36
|
+
|---|---|
|
|
37
|
+
| `get text/html/value @ref` | Element content |
|
|
38
|
+
| `get attr @ref <name>` | Attribute value |
|
|
39
|
+
| `is visible/enabled/checked @ref` | State check |
|
|
40
|
+
| `boundingbox @ref` | Bounding box |
|
|
41
|
+
| `styles @ref <prop>` | Computed CSS |
|
|
42
|
+
|
|
43
|
+
## Find Elements
|
|
44
|
+
| Command | Description |
|
|
45
|
+
|---|---|
|
|
46
|
+
| `find role/text/label/placeholder/testid <value>` | Semantic query |
|
|
47
|
+
|
|
48
|
+
## Capture
|
|
49
|
+
| Command | Description |
|
|
50
|
+
|---|---|
|
|
51
|
+
| `screenshot [path]` | PNG screenshot |
|
|
52
|
+
| `pdf [path]` | PDF export |
|
|
53
|
+
| `eval <js>` | Run JavaScript |
|
|
54
|
+
|
|
55
|
+
## Network
|
|
56
|
+
| Command | Description |
|
|
57
|
+
|---|---|
|
|
58
|
+
| `network list [pattern]` | List requests |
|
|
59
|
+
| `network get <id>` | Full request/response with body |
|
|
60
|
+
| `network clear` | Clear |
|
|
61
|
+
| `analyze` | API reverse engineering + schema |
|
|
62
|
+
| `intercept mock/fail/delay <pattern>` | Mock/block/delay |
|
|
63
|
+
| `intercept remove/list/clear` | Manage rules |
|
|
64
|
+
| `har [file]` | Export HAR 1.2 |
|
|
65
|
+
|
|
66
|
+
## Wait
|
|
67
|
+
| Command | Description |
|
|
68
|
+
|---|---|
|
|
69
|
+
| `wait <ms>` | Wait milliseconds |
|
|
70
|
+
| `waitforloadstate [ms]` | Page load |
|
|
71
|
+
| `waitforurl <pat> [ms]` | URL match |
|
|
72
|
+
| `waitforfunction <expr> [ms]` | JS condition |
|
|
73
|
+
| `waitfor network/console/error/dialog [ms]` | Event wait |
|
|
74
|
+
| `waitdownload [ms]` | Download complete |
|
|
75
|
+
|
|
76
|
+
## Settings
|
|
77
|
+
| Command | Description |
|
|
78
|
+
|---|---|
|
|
79
|
+
| `set viewport/media/offline` | Display settings |
|
|
80
|
+
| `set timezone/locale/geolocation` | Location emulation |
|
|
81
|
+
| `set device/useragent/headers` | Device/network |
|
|
82
|
+
| `set ignore-https-errors` | Cert errors |
|
|
83
|
+
| `set permissions grant <perm>` | Permissions |
|
|
84
|
+
|
|
85
|
+
## Storage
|
|
86
|
+
| Command | Description |
|
|
87
|
+
|---|---|
|
|
88
|
+
| `cookies list/set/get/clear` | Cookies |
|
|
89
|
+
| `storage local/session [key]` | Web storage |
|
|
90
|
+
| `state save/load/list` | Full state persistence |
|
|
91
|
+
| `credentials <user> <pass>` | HTTP auth |
|
|
92
|
+
|
|
93
|
+
## Other
|
|
94
|
+
| Command | Description |
|
|
95
|
+
|---|---|
|
|
96
|
+
| `tab list/new/close/switch/count` | Tab management |
|
|
97
|
+
| `console list/clear` | Console messages |
|
|
98
|
+
| `errors [clear]` | Page errors |
|
|
99
|
+
| `dialog accept/dismiss/info` | Dialog handling |
|
|
100
|
+
| `record/diff/replay <name>` | Network recording |
|
|
101
|
+
| `addscript <js>` / `addstyle <css>` | Page injection |
|
|
102
|
+
| `pause` / `resume` | JS debugging |
|
|
103
|
+
| `clipboard get/set` | Clipboard |
|
|
104
|
+
| `status` | Daemon status |
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Debug Mode
|
|
2
|
+
|
|
3
|
+
## Usage
|
|
4
|
+
```bash
|
|
5
|
+
agent-devtools --interactive --debug
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
## What it does
|
|
9
|
+
After action commands (click, fill, press, type, select, check, uncheck, tap, hover, drag, dispatch, open), debug mode automatically:
|
|
10
|
+
1. Queries daemon status before the action
|
|
11
|
+
2. Executes the action
|
|
12
|
+
3. Waits 500ms for async effects
|
|
13
|
+
4. Queries status again
|
|
14
|
+
5. If changes detected, fetches details and appends to response
|
|
15
|
+
|
|
16
|
+
## Response format
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"success": true,
|
|
20
|
+
"debug": {
|
|
21
|
+
"new_requests": [{"url": "/api/login", "method": "POST", "status": 200}],
|
|
22
|
+
"new_console": [{"type": "log", "text": "logged in"}],
|
|
23
|
+
"new_errors": [{"description": "TypeError: ..."}],
|
|
24
|
+
"url_changed": true
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Filtering
|
|
30
|
+
- Static resources (JS/CSS/images/fonts) are excluded
|
|
31
|
+
- Tracking pixels (gen_204, client_204) are excluded
|
|
32
|
+
- Only API requests are shown
|
|
33
|
+
|
|
34
|
+
## When to use
|
|
35
|
+
- **Development**: Use --debug to understand side effects of actions
|
|
36
|
+
- **Testing/CI**: Omit --debug for minimal output and faster execution
|
|
37
|
+
|
|
38
|
+
## Non-action commands
|
|
39
|
+
snapshot, screenshot, get, is, set, network, console, cookies, eval, wait — these are NOT affected by debug mode.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Common Automation Patterns
|
|
2
|
+
|
|
3
|
+
## Form Submission
|
|
4
|
+
```bash
|
|
5
|
+
agent-devtools open https://example.com/signup
|
|
6
|
+
agent-devtools snapshot -i
|
|
7
|
+
agent-devtools fill @e1 "Jane Doe"
|
|
8
|
+
agent-devtools fill @e2 "jane@example.com"
|
|
9
|
+
agent-devtools select @e3 "California"
|
|
10
|
+
agent-devtools check @e4
|
|
11
|
+
agent-devtools click @e5
|
|
12
|
+
agent-devtools snapshot -i # Verify result
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Login + State Persistence
|
|
16
|
+
```bash
|
|
17
|
+
agent-devtools open https://app.example.com/login
|
|
18
|
+
agent-devtools snapshot -i
|
|
19
|
+
agent-devtools fill @e1 "user@example.com"
|
|
20
|
+
agent-devtools fill @e2 "password123"
|
|
21
|
+
agent-devtools click @e3
|
|
22
|
+
agent-devtools wait 3000
|
|
23
|
+
agent-devtools state save auth
|
|
24
|
+
|
|
25
|
+
# Reuse later
|
|
26
|
+
agent-devtools state load auth
|
|
27
|
+
agent-devtools open https://app.example.com/dashboard
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## API Discovery
|
|
31
|
+
```bash
|
|
32
|
+
agent-devtools open https://app.example.com
|
|
33
|
+
agent-devtools snapshot -i
|
|
34
|
+
agent-devtools click @e3
|
|
35
|
+
agent-devtools network list /api
|
|
36
|
+
agent-devtools network get <requestId>
|
|
37
|
+
agent-devtools analyze
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Mock API for Testing
|
|
41
|
+
```bash
|
|
42
|
+
agent-devtools intercept mock "/api/users" '[{"id":1,"name":"Test"}]'
|
|
43
|
+
agent-devtools open https://app.example.com/users
|
|
44
|
+
agent-devtools snapshot -i
|
|
45
|
+
agent-devtools intercept clear
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Mobile Device Testing
|
|
49
|
+
```bash
|
|
50
|
+
agent-devtools set device "iPhone 14"
|
|
51
|
+
agent-devtools open https://example.com
|
|
52
|
+
agent-devtools snapshot -i
|
|
53
|
+
agent-devtools tap @e1
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Debug API Calls (--debug mode)
|
|
57
|
+
```bash
|
|
58
|
+
agent-devtools --interactive --debug
|
|
59
|
+
> open https://app.example.com
|
|
60
|
+
> snapshot -i
|
|
61
|
+
> click @e5
|
|
62
|
+
< {"success":true,"debug":{"new_requests":[{"url":"/api/login","method":"POST","status":200}],"url_changed":false}}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Parallel Sessions
|
|
66
|
+
```bash
|
|
67
|
+
agent-devtools --session=site1 open https://site-a.com
|
|
68
|
+
agent-devtools --session=site2 open https://site-b.com
|
|
69
|
+
agent-devtools --session=site1 snapshot -i
|
|
70
|
+
agent-devtools --session=site2 snapshot -i
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Connect to Existing Chrome
|
|
74
|
+
```bash
|
|
75
|
+
agent-devtools --port=9222 snapshot -i
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## E2E Test (CI)
|
|
79
|
+
```bash
|
|
80
|
+
cat tests/login.txt | agent-devtools --interactive
|
|
81
|
+
# exit 0 = pass, exit 1 = fail
|
|
82
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Template: API Discovery Workflow
|
|
3
|
+
# Usage: ./api-discovery.sh <app-url>
|
|
4
|
+
set -euo pipefail
|
|
5
|
+
APP_URL="${1:?Usage: $0 <app-url>}"
|
|
6
|
+
|
|
7
|
+
agent-devtools open "$APP_URL"
|
|
8
|
+
agent-devtools wait 3000
|
|
9
|
+
agent-devtools snapshot -i
|
|
10
|
+
|
|
11
|
+
# Interact with the app to trigger API calls
|
|
12
|
+
# agent-devtools click @e1
|
|
13
|
+
# agent-devtools wait 2000
|
|
14
|
+
|
|
15
|
+
# Discover APIs
|
|
16
|
+
echo "=== Network Requests ==="
|
|
17
|
+
agent-devtools network list /api
|
|
18
|
+
|
|
19
|
+
echo "=== API Analysis ==="
|
|
20
|
+
agent-devtools analyze
|
|
21
|
+
|
|
22
|
+
echo "=== HAR Export ==="
|
|
23
|
+
agent-devtools har api-capture.har
|
|
24
|
+
|
|
25
|
+
agent-devtools close
|