surf-cli 2.0.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 +426 -0
- package/dist/content/accessibility-tree.js +11 -0
- package/dist/content/accessibility-tree.js.map +1 -0
- package/dist/content/visual-indicator.js +111 -0
- package/dist/content/visual-indicator.js.map +1 -0
- package/dist/icons/icon-128.png +0 -0
- package/dist/icons/icon-16.png +0 -0
- package/dist/icons/icon-48.png +0 -0
- package/dist/manifest.json +70 -0
- package/dist/options/options.html +30 -0
- package/dist/options/options.js +30 -0
- package/dist/options/options.js.map +1 -0
- package/dist/service-worker/index.js +156 -0
- package/dist/service-worker/index.js.map +1 -0
- package/dist/service-worker-loader.js +1 -0
- package/native/CHANGELOG.md +136 -0
- package/native/README.md +141 -0
- package/native/chatgpt-client.cjs +455 -0
- package/native/cli.cjs +2424 -0
- package/native/config.cjs +87 -0
- package/native/device-presets.cjs +211 -0
- package/native/formatters/network.cjs +402 -0
- package/native/gemini-client.cjs +637 -0
- package/native/host-helpers.cjs +989 -0
- package/native/host-wrapper.py +15 -0
- package/native/host.cjs +1271 -0
- package/native/host.sh +2 -0
- package/native/mcp-server.cjs +511 -0
- package/native/network-store.cjs +851 -0
- package/native/perplexity-client.cjs +561 -0
- package/native/protocol.cjs +27 -0
- package/native/test-host.py +41 -0
- package/native/tests/cli-tests.sh +115 -0
- package/package.json +70 -0
- package/scripts/install-native-host.cjs +308 -0
- package/scripts/uninstall-native-host.cjs +194 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './service-worker/index.js';
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to surf CLI will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [2.2.0] - 2026-01-07
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- Network capture: `network`, `network.stats`, `network.origins`, `network.get`, `network.clear`, `network.export`
|
|
9
|
+
- Filtering by method, status, URL, content-type
|
|
10
|
+
- Export formats: curl, raw JSON, URL list
|
|
11
|
+
- Persistence to `/tmp/surf/` (configurable via `SURF_NETWORK_PATH`)
|
|
12
|
+
|
|
13
|
+
## [2.1.0] - 2025-12-30
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
**ChatGPT Integration**
|
|
18
|
+
- `chatgpt <query>` - Send prompt to ChatGPT using browser cookies (no API key)
|
|
19
|
+
- `--with-page` - Include current page context
|
|
20
|
+
- `--model` - Specify model (gpt-4o, o1, etc.)
|
|
21
|
+
- `--timeout` - Custom timeout (default: 45 minutes)
|
|
22
|
+
- File attachments coming soon
|
|
23
|
+
|
|
24
|
+
**Gemini Integration (Coming Soon)**
|
|
25
|
+
- `gemini <query>` - Command structure ready, implementation pending
|
|
26
|
+
|
|
27
|
+
**Request Queue**
|
|
28
|
+
- AI requests are queued sequentially with 2s minimum delay between requests
|
|
29
|
+
- Prevents rate limiting when making multiple AI queries
|
|
30
|
+
|
|
31
|
+
### Technical Changes
|
|
32
|
+
- New `chatgpt-client.cjs` module for ChatGPT browser automation
|
|
33
|
+
- Extension: `GET_CHATGPT_COOKIES`, `GET_GOOGLE_COOKIES` handlers
|
|
34
|
+
- Extension: `CHATGPT_NEW_TAB`, `CHATGPT_CLOSE_TAB`, `CHATGPT_CDP_COMMAND`, `CHATGPT_EVALUATE` handlers
|
|
35
|
+
- CDP controller: Added public `sendCommand()` method
|
|
36
|
+
|
|
37
|
+
## [2.0.0] - 2025-12-27
|
|
38
|
+
|
|
39
|
+
### Breaking Changes
|
|
40
|
+
- Removed snake_case command aliases (use dot-notation instead)
|
|
41
|
+
- `read_page` -> `page.read`
|
|
42
|
+
- `list_tabs` -> `tab.list`
|
|
43
|
+
- `wait_for_element` -> `wait.element`
|
|
44
|
+
- `javascript_tool` -> `js`
|
|
45
|
+
- And others (see REMOVED_COMMANDS in cli.cjs for full list)
|
|
46
|
+
- Removed all single-letter short flags for consistency
|
|
47
|
+
- Use `--output` instead of `-o`
|
|
48
|
+
- Use `--ref` instead of `-r`
|
|
49
|
+
- Use `--annotate` instead of `-a`
|
|
50
|
+
- Use `--fullpage` instead of `-f`
|
|
51
|
+
- Migration hints shown when using old command names
|
|
52
|
+
|
|
53
|
+
### Added
|
|
54
|
+
|
|
55
|
+
**Navigation**
|
|
56
|
+
- `back` - Go back in browser history
|
|
57
|
+
- `forward` - Go forward in browser history
|
|
58
|
+
- `tab.reload` - Reload tab (with `--hard` for cache bypass)
|
|
59
|
+
|
|
60
|
+
**Tab Groups**
|
|
61
|
+
- `tab.group` - Create or add to tab group
|
|
62
|
+
- `tab.ungroup` - Remove tabs from group
|
|
63
|
+
- `tab.groups` - List all tab groups
|
|
64
|
+
|
|
65
|
+
**Zoom Control**
|
|
66
|
+
- `zoom` - Get current zoom level
|
|
67
|
+
- `zoom <level>` - Set zoom (e.g., `zoom 1.5` for 150%)
|
|
68
|
+
- `zoom --reset` - Reset to default zoom
|
|
69
|
+
|
|
70
|
+
**Cookies**
|
|
71
|
+
- `cookie.list` - List cookies for current domain
|
|
72
|
+
- `cookie.get` - Get specific cookie by name
|
|
73
|
+
- `cookie.set` - Set a cookie
|
|
74
|
+
- `cookie.clear` - Clear specific cookie or all (`--all`)
|
|
75
|
+
|
|
76
|
+
**Search**
|
|
77
|
+
- `search <term>` - Search for text in page (alias: `find`)
|
|
78
|
+
- Returns match refs, context, and element associations
|
|
79
|
+
|
|
80
|
+
**Batch Execution**
|
|
81
|
+
- `batch --actions '[...]'` - Execute multiple actions
|
|
82
|
+
- `batch --file workflow.json` - Load actions from file
|
|
83
|
+
|
|
84
|
+
**Bookmarks**
|
|
85
|
+
- `bookmark.add` - Bookmark current page
|
|
86
|
+
- `bookmark.remove` - Remove bookmark for current page
|
|
87
|
+
- `bookmark.list` - List bookmarks
|
|
88
|
+
|
|
89
|
+
**History**
|
|
90
|
+
- `history.list` - Recent browser history
|
|
91
|
+
- `history.search <query>` - Search history
|
|
92
|
+
|
|
93
|
+
**Screenshot Enhancements**
|
|
94
|
+
- `--annotate` - Draw element labels on screenshot
|
|
95
|
+
- `--fullpage` - Capture entire scrollable page
|
|
96
|
+
- `--max-height` - Limit fullpage capture height (default: 4000px)
|
|
97
|
+
- Extension UI automatically hidden during capture
|
|
98
|
+
|
|
99
|
+
**Aliases**
|
|
100
|
+
- `snap` -> `screenshot` (auto-saves to /tmp if no output specified)
|
|
101
|
+
- `read` -> `page.read`
|
|
102
|
+
- `find` -> `search`
|
|
103
|
+
- `go` -> `navigate`
|
|
104
|
+
|
|
105
|
+
**Discovery Features**
|
|
106
|
+
- `--find <query>` - Fuzzy search for commands
|
|
107
|
+
- `--about <topic>` - Learn about a topic
|
|
108
|
+
|
|
109
|
+
**Help System**
|
|
110
|
+
- `--help` - Basic help with common commands
|
|
111
|
+
- `--help-full` - Complete command reference
|
|
112
|
+
- `--help-topic <topic>` - Topic-specific guide
|
|
113
|
+
- Command-level help with examples
|
|
114
|
+
|
|
115
|
+
**Other**
|
|
116
|
+
- `--version` - Show version
|
|
117
|
+
- `click 100 200` - Positional coordinates for click
|
|
118
|
+
- `click --selector ".btn" --index 2` - Click nth element matching selector
|
|
119
|
+
|
|
120
|
+
### Changed
|
|
121
|
+
- Primary argument support for commands:
|
|
122
|
+
- `wait.element <selector>` (was `--selector`)
|
|
123
|
+
- `wait.url <pattern>` (was `--pattern`)
|
|
124
|
+
- `click <ref>` with e-prefix detection (e.g., `click e5`)
|
|
125
|
+
- Help output includes usage examples for all commands
|
|
126
|
+
- `dialog.dismiss --all` for repeatedly dismissing dialogs
|
|
127
|
+
- Fullpage screenshot delay increased to 300ms for lazy-loaded content
|
|
128
|
+
- Error messages standardized to terse format for AI consumption
|
|
129
|
+
|
|
130
|
+
### Fixed
|
|
131
|
+
- `--limit 0` now correctly returns empty results (was defaulting to max)
|
|
132
|
+
- Screenshot always hides extension UI (was conditional on `--clean` flag)
|
|
133
|
+
|
|
134
|
+
## [1.x] - Previous Releases
|
|
135
|
+
|
|
136
|
+
See git history for changes before v2.0.0.
|
package/native/README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Surf Native Host
|
|
2
|
+
|
|
3
|
+
Native messaging host that bridges CLI commands to the Chrome extension via Unix socket.
|
|
4
|
+
|
|
5
|
+
## Architecture
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
CLI (surf) → Unix Socket (/tmp/surf.sock) → Native Host → Chrome Extension → CDP
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Files
|
|
12
|
+
|
|
13
|
+
| File | Purpose |
|
|
14
|
+
|------|---------|
|
|
15
|
+
| `host.cjs` | Main native host with socket server and tool handling |
|
|
16
|
+
| `cli.cjs` | CLI tool for browser automation |
|
|
17
|
+
| `chatgpt-client.cjs` | ChatGPT browser automation client |
|
|
18
|
+
| `protocol.cjs` | Chrome native messaging protocol helpers |
|
|
19
|
+
| `host-wrapper.py` | Python wrapper for native host execution |
|
|
20
|
+
| `host.sh` | Shell script to start the host |
|
|
21
|
+
|
|
22
|
+
## Setup
|
|
23
|
+
|
|
24
|
+
1. Install the native host manifest:
|
|
25
|
+
```bash
|
|
26
|
+
npm run install:native <extension-id>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or manually:
|
|
30
|
+
```bash
|
|
31
|
+
mkdir -p ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts
|
|
32
|
+
cat > ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.anthropic.pi_chrome.json << EOF
|
|
33
|
+
{
|
|
34
|
+
"name": "com.anthropic.pi_chrome",
|
|
35
|
+
"description": "Surf CLI Native Host",
|
|
36
|
+
"path": "$PWD/host-wrapper.py",
|
|
37
|
+
"type": "stdio",
|
|
38
|
+
"allowed_origins": ["chrome-extension://YOUR_EXTENSION_ID/"]
|
|
39
|
+
}
|
|
40
|
+
EOF
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
2. Start the native host:
|
|
44
|
+
```bash
|
|
45
|
+
node host.cjs
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The host creates a Unix socket at `/tmp/surf.sock`.
|
|
49
|
+
|
|
50
|
+
## CLI Reference
|
|
51
|
+
|
|
52
|
+
See the main [README](../README.md) for full CLI documentation.
|
|
53
|
+
|
|
54
|
+
### Quick Reference
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
surf go "https://example.com" # Navigate
|
|
58
|
+
surf read # Get accessibility tree
|
|
59
|
+
surf click e5 # Click element
|
|
60
|
+
surf type "hello" --submit # Type and submit
|
|
61
|
+
surf snap # Screenshot to /tmp
|
|
62
|
+
surf chatgpt "explain this" # Query ChatGPT
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Global Options
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
--tab-id <id> # Target specific tab
|
|
69
|
+
--json # Output raw JSON
|
|
70
|
+
--soft-fail # Warn instead of error on restricted pages
|
|
71
|
+
--no-screenshot # Skip auto-screenshot after actions
|
|
72
|
+
--full # Full resolution screenshots
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Protocol
|
|
76
|
+
|
|
77
|
+
### Tool Request
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"type": "tool_request",
|
|
82
|
+
"method": "execute_tool",
|
|
83
|
+
"params": {
|
|
84
|
+
"tool": "TOOL_NAME",
|
|
85
|
+
"args": { ... },
|
|
86
|
+
"tabId": 123
|
|
87
|
+
},
|
|
88
|
+
"id": "unique-request-id"
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Tool Response (Success)
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"type": "tool_response",
|
|
97
|
+
"id": "unique-request-id",
|
|
98
|
+
"result": {
|
|
99
|
+
"content": [
|
|
100
|
+
{ "type": "text", "text": "Result message" }
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Tool Response (With Image)
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"type": "tool_response",
|
|
111
|
+
"id": "unique-request-id",
|
|
112
|
+
"result": {
|
|
113
|
+
"content": [
|
|
114
|
+
{ "type": "text", "text": "Screenshot captured" },
|
|
115
|
+
{ "type": "image", "data": "base64...", "mimeType": "image/png" }
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Tool Response (Error)
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"type": "tool_response",
|
|
126
|
+
"id": "unique-request-id",
|
|
127
|
+
"error": {
|
|
128
|
+
"content": [{ "type": "text", "text": "Error message" }]
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Troubleshooting
|
|
134
|
+
|
|
135
|
+
| Issue | Solution |
|
|
136
|
+
|-------|----------|
|
|
137
|
+
| Socket not found | Ensure `node host.cjs` is running |
|
|
138
|
+
| No response | Check extension is loaded in Chrome |
|
|
139
|
+
| "Content script not loaded" | Navigate to a page first |
|
|
140
|
+
| "Cannot control this page" | Page is restricted (chrome://, extensions) - use `--soft-fail` |
|
|
141
|
+
| Slow first operation | Normal - CDP debugger attachment takes ~100-500ms |
|