@different-ai/opencode-browser 1.0.5 → 2.0.1

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/README.md CHANGED
@@ -1,61 +1,47 @@
1
1
  # OpenCode Browser
2
2
 
3
- Browser automation for [OpenCode](https://github.com/opencode-ai/opencode) via Chrome extension + Native Messaging.
3
+ Browser automation plugin for [OpenCode](https://github.com/opencode-ai/opencode).
4
4
 
5
- **Inspired by Claude in Chrome** - Anthropic's browser extension that lets Claude Code test code directly in the browser and see client-side errors via console logs. This project brings similar capabilities to OpenCode.
5
+ Control your real Chrome browser with existing logins, cookies, and bookmarks. No DevTools Protocol, no security prompts.
6
6
 
7
7
  ## Why?
8
8
 
9
- Get access to your fully credentialed chrome instance to perform privileged web operations.
9
+ Chrome 136+ blocks `--remote-debugging-port` on your default profile for security reasons. DevTools-based automation (like Playwright) triggers a security prompt every time.
10
10
 
11
- Chrome 136+ blocks `--remote-debugging-port` on your default profile for security reasons. This means DevTools-based automation (like Playwright or chrome-devtools-mcp) triggers a security prompt every time.
12
-
13
- OpenCode Browser bypasses this entirely using Chrome's Native Messaging API - the same approach Claude uses. Your automation works with your existing browser session, logins, and bookmarks. No prompts. No separate profiles.
11
+ OpenCode Browser uses a simple WebSocket connection between an OpenCode plugin and a Chrome extension. Your automation works with your existing browser session - no prompts, no separate profiles.
14
12
 
15
13
  ## Installation
16
14
 
17
15
  ```bash
18
- npx opencode-browser install
16
+ npx @different-ai/opencode-browser install
19
17
  ```
20
18
 
21
19
  The installer will:
22
20
  1. Copy the extension to `~/.opencode-browser/extension/`
23
- 2. Open Chrome for you to load the extension
24
- 3. Register the native messaging host
25
- 4. Optionally update your `opencode.json`
26
-
27
- ## Manual Setup
28
-
29
- If you prefer manual installation:
30
-
31
- 1. **Load the extension**
32
- - Go to `chrome://extensions`
33
- - Enable "Developer mode"
34
- - Click "Load unpacked" and select `~/.opencode-browser/extension/`
35
- - Copy the extension ID
36
-
37
- 2. **Run the installer** to register the native host:
38
- ```bash
39
- npx opencode-browser install
40
- ```
41
-
42
- 3. **Add to opencode.json**:
43
- ```json
44
- {
45
- "mcp": {
46
- "browser": {
47
- "type": "local",
48
- "command": ["npx", "opencode-browser", "start"],
49
- "enabled": true
50
- }
51
- }
52
- }
53
- ```
21
+ 2. Guide you to load the extension in Chrome
22
+ 3. Update your `opencode.json` to use the plugin
23
+
24
+ ## Configuration
25
+
26
+ Add to your `opencode.json`:
27
+
28
+ ```json
29
+ {
30
+ "plugin": ["@different-ai/opencode-browser"]
31
+ }
32
+ ```
33
+
34
+ Then load the extension in Chrome:
35
+ 1. Go to `chrome://extensions`
36
+ 2. Enable "Developer mode"
37
+ 3. Click "Load unpacked" and select `~/.opencode-browser/extension/`
54
38
 
55
39
  ## Available Tools
56
40
 
57
41
  | Tool | Description |
58
42
  |------|-------------|
43
+ | `browser_status` | Check if browser is available or locked |
44
+ | `browser_kill_session` | Take over from another OpenCode session |
59
45
  | `browser_navigate` | Navigate to a URL |
60
46
  | `browser_click` | Click an element by CSS selector |
61
47
  | `browser_type` | Type text into an input field |
@@ -66,34 +52,74 @@ If you prefer manual installation:
66
52
  | `browser_wait` | Wait for a duration |
67
53
  | `browser_execute` | Run JavaScript in page context |
68
54
 
55
+ ## Multi-Session Support
56
+
57
+ Only one OpenCode session can use the browser at a time. This prevents conflicts when you have multiple terminals open.
58
+
59
+ - `browser_status` - Check who has the lock
60
+ - `browser_kill_session` - Kill the other session and take over
61
+
62
+ In your prompts, you can say:
63
+ - "If browser is locked, kill the session and proceed"
64
+ - "If browser is locked, skip this task"
65
+
69
66
  ## Architecture
70
67
 
71
68
  ```
72
- OpenCode ──MCP──> server.js ──Unix Socket──> host.js ──Native Messaging──> Chrome Extension
73
-
74
-
75
- chrome.tabs
76
- chrome.scripting
69
+ OpenCode Plugin ◄──WebSocket:19222──► Chrome Extension
70
+
71
+ └── Lock file └── chrome.tabs, chrome.scripting
72
+ ```
73
+
74
+ **Two components:**
75
+ 1. OpenCode plugin (runs WebSocket server, defines tools)
76
+ 2. Chrome extension (connects to plugin, executes commands)
77
+
78
+ **No daemon. No MCP server. No native messaging host.**
79
+
80
+ ## Upgrading from v1.x
81
+
82
+ v2.0 is a complete rewrite with a simpler architecture:
83
+
84
+ 1. Run `npx @different-ai/opencode-browser install` (cleans up old daemon automatically)
85
+ 2. Replace MCP config with plugin config in `opencode.json`:
86
+
87
+ ```diff
88
+ - "mcp": {
89
+ - "browser": {
90
+ - "type": "local",
91
+ - "command": ["npx", "@different-ai/opencode-browser", "start"],
92
+ - "enabled": true
93
+ - }
94
+ - }
95
+ + "plugin": ["@different-ai/opencode-browser"]
77
96
  ```
78
97
 
79
- - **server.js** - MCP server that OpenCode connects to
80
- - **host.js** - Native messaging host launched by Chrome
81
- - **extension/** - Chrome extension with browser automation tools
98
+ 3. Restart OpenCode
82
99
 
83
- No DevTools Protocol = No security prompts.
100
+ ## Troubleshooting
101
+
102
+ **"Chrome extension not connected"**
103
+ - Make sure Chrome is running
104
+ - Check that the extension is loaded and enabled
105
+ - Click the extension icon to see connection status
106
+
107
+ **"Browser locked by another session"**
108
+ - Use `browser_kill_session` to take over
109
+ - Or close the other OpenCode session
110
+
111
+ **"Failed to start WebSocket server"**
112
+ - Port 19222 may be in use
113
+ - Check if another OpenCode session is running
84
114
 
85
115
  ## Uninstall
86
116
 
87
117
  ```bash
88
- npx opencode-browser uninstall
118
+ npx @different-ai/opencode-browser uninstall
89
119
  ```
90
120
 
91
121
  Then remove the extension from Chrome and delete `~/.opencode-browser/` if desired.
92
122
 
93
- ## Logs
94
-
95
- Logs are written to `~/.opencode-browser/logs/browser-mcp-host.log`
96
-
97
123
  ## Platform Support
98
124
 
99
125
  - macOS ✓