surfagent 1.0.1 → 1.0.3
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/CLAUDE.md +48 -34
- package/README.md +1 -1
- package/package.json +1 -1
- package/scripts/start-chrome.sh +0 -33
package/CLAUDE.md
CHANGED
|
@@ -1,36 +1,43 @@
|
|
|
1
|
+
## IMPORTANT: Never kill Chrome
|
|
2
|
+
|
|
3
|
+
`surfagent` launches a **separate Chrome window** with its own profile. The user's personal Chrome stays untouched. NEVER run `pkill Chrome`, `killall Chrome`, or any command that kills Chrome processes. If you need to restart the debug session, use `surfagent start` — it will launch a new one without affecting anything.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
1
7
|
## Critical Rule: Always Close Unused Tabs
|
|
2
8
|
|
|
3
9
|
After completing any task, close tabs you no longer need:
|
|
4
10
|
```bash
|
|
5
|
-
|
|
6
|
-
|
|
11
|
+
curl -X POST localhost:3456/click -H 'Content-Type: application/json' -d '{"tab":"0","text":"close"}'
|
|
12
|
+
# Or via CLI:
|
|
13
|
+
node dist/browser.js close all
|
|
7
14
|
```
|
|
8
15
|
|
|
9
16
|
---
|
|
10
17
|
|
|
11
18
|
## Setup
|
|
12
19
|
|
|
13
|
-
### Start
|
|
14
|
-
|
|
15
|
-
Chrome 136+ blocks remote debugging on the default profile for security. Use a separate profile with your cookies copied:
|
|
20
|
+
### Start everything (one command)
|
|
16
21
|
|
|
17
22
|
```bash
|
|
18
|
-
|
|
19
|
-
./scripts/start-chrome.sh
|
|
20
|
-
|
|
21
|
-
# Or manually:
|
|
22
|
-
pkill -9 "Google Chrome"
|
|
23
|
-
mkdir -p /tmp/chrome-cdp/Default
|
|
24
|
-
cp ~/Library/Application\ Support/Google/Chrome/Default/Cookies /tmp/chrome-cdp/Default/
|
|
25
|
-
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
|
|
26
|
-
--user-data-dir=/tmp/chrome-cdp \
|
|
27
|
-
--remote-debugging-port=9222
|
|
23
|
+
surfagent start
|
|
28
24
|
```
|
|
29
25
|
|
|
30
|
-
|
|
26
|
+
This will:
|
|
27
|
+
1. Check if Chrome debug session is already running on port 9222
|
|
28
|
+
2. If not, launch a **new Chrome window** with a separate profile (`/tmp/surfagent-chrome`)
|
|
29
|
+
3. Copy cookies from the user's default Chrome profile (preserves logins)
|
|
30
|
+
4. Start the API server on `http://localhost:3456`
|
|
31
|
+
|
|
32
|
+
The user's personal Chrome browser is NOT affected. A second Chrome window will appear — this is the debug session that the API controls.
|
|
33
|
+
|
|
34
|
+
### Other commands
|
|
31
35
|
|
|
32
36
|
```bash
|
|
33
|
-
|
|
37
|
+
surfagent start # Chrome + API (recommended)
|
|
38
|
+
surfagent chrome # Launch Chrome debug session only
|
|
39
|
+
surfagent api # Start API only (Chrome must already be running)
|
|
40
|
+
surfagent health # Check if Chrome and API are running
|
|
34
41
|
```
|
|
35
42
|
|
|
36
43
|
---
|
|
@@ -69,6 +76,9 @@ curl -X POST localhost:3456/eval -H 'Content-Type: application/json' -d '{"tab":
|
|
|
69
76
|
# Bring tab to front
|
|
70
77
|
curl -X POST localhost:3456/focus -H 'Content-Type: application/json' -d '{"tab":"0"}'
|
|
71
78
|
|
|
79
|
+
# Captcha detection and interaction (experimental)
|
|
80
|
+
curl -X POST localhost:3456/captcha -H 'Content-Type: application/json' -d '{"tab":"0","action":"detect"}'
|
|
81
|
+
|
|
72
82
|
# List tabs
|
|
73
83
|
curl localhost:3456/tabs
|
|
74
84
|
|
|
@@ -113,21 +123,22 @@ node dist/browser.js close all # Close all tabs except first
|
|
|
113
123
|
## Architecture
|
|
114
124
|
|
|
115
125
|
```
|
|
116
|
-
|
|
117
|
-
│
|
|
118
|
-
├──
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
126
|
+
surfagent start
|
|
127
|
+
│
|
|
128
|
+
├── Launches Chrome (separate window, separate profile)
|
|
129
|
+
│ └── --remote-debugging-port=9222
|
|
130
|
+
│ --user-data-dir=/tmp/surfagent-chrome
|
|
131
|
+
│
|
|
132
|
+
└── Starts API Server (:3456)
|
|
133
|
+
│
|
|
134
|
+
├── src/api/recon.ts (page reconnaissance)
|
|
135
|
+
├── src/api/act.ts (fill, click, scroll, read, navigate, eval, captcha)
|
|
136
|
+
└── src/api/server.ts (HTTP routing)
|
|
137
|
+
│
|
|
138
|
+
└── src/chrome/ (CDP connection layer)
|
|
139
|
+
│
|
|
140
|
+
▼
|
|
141
|
+
Chrome (:9222) ← separate window, user's Chrome untouched
|
|
131
142
|
```
|
|
132
143
|
|
|
133
144
|
---
|
|
@@ -135,8 +146,11 @@ API Server (:3456) CLI (node dist/browser.js)
|
|
|
135
146
|
## Troubleshooting
|
|
136
147
|
|
|
137
148
|
**"Cannot connect to Chrome"**
|
|
138
|
-
-
|
|
139
|
-
-
|
|
149
|
+
- Run `surfagent start` — it handles everything
|
|
150
|
+
- If Chrome is already running with debug mode, use `surfagent api` to just start the API
|
|
151
|
+
|
|
152
|
+
**A second Chrome window appeared**
|
|
153
|
+
- This is expected. `surfagent` runs its own Chrome with a separate profile. Your personal Chrome is not affected. Close the surfagent Chrome window when you're done.
|
|
140
154
|
|
|
141
155
|
**Elements not found**
|
|
142
156
|
- Always `/recon` first to see what's available
|
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ npm install -g surfagent
|
|
|
11
11
|
surfagent start
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
That's it. Chrome opens with debug mode
|
|
14
|
+
That's it. A **new Chrome window** opens with debug mode — your personal Chrome is not affected. The API starts on `http://localhost:3456` and your agent can start calling it immediately.
|
|
15
15
|
|
|
16
16
|
### Other commands
|
|
17
17
|
|
package/package.json
CHANGED
package/scripts/start-chrome.sh
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Start Chrome with remote debugging enabled
|
|
4
|
-
# Uses a separate profile with copied auth data (required for Chrome 136+)
|
|
5
|
-
|
|
6
|
-
PORT=${1:-9222}
|
|
7
|
-
MAIN_PROFILE="$HOME/Library/Application Support/Google/Chrome/Default"
|
|
8
|
-
DEBUG_PROFILE="/tmp/chrome-cdp"
|
|
9
|
-
|
|
10
|
-
echo "Setting up Chrome debug profile..."
|
|
11
|
-
|
|
12
|
-
# Create debug profile directory
|
|
13
|
-
mkdir -p "$DEBUG_PROFILE/Default"
|
|
14
|
-
|
|
15
|
-
# Copy auth data from main profile (preserves your logins)
|
|
16
|
-
cp "$MAIN_PROFILE/Cookies" "$DEBUG_PROFILE/Default/" 2>/dev/null
|
|
17
|
-
cp "$MAIN_PROFILE/Login Data" "$DEBUG_PROFILE/Default/" 2>/dev/null
|
|
18
|
-
cp "$MAIN_PROFILE/Login Data For Account" "$DEBUG_PROFILE/Default/" 2>/dev/null
|
|
19
|
-
|
|
20
|
-
echo "Starting Chrome with remote debugging on port $PORT..."
|
|
21
|
-
echo "Note: This uses a separate profile with your login cookies copied over."
|
|
22
|
-
echo ""
|
|
23
|
-
|
|
24
|
-
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
|
|
25
|
-
--user-data-dir="$DEBUG_PROFILE" \
|
|
26
|
-
--remote-debugging-port=$PORT \
|
|
27
|
-
--disable-save-password-bubble \
|
|
28
|
-
--disable-popup-blocking \
|
|
29
|
-
--disable-notifications \
|
|
30
|
-
--disable-infobars \
|
|
31
|
-
--disable-translate \
|
|
32
|
-
--disable-features=PasswordManager,AutofillSaveCardBubble,TranslateUI \
|
|
33
|
-
--password-store=basic
|