agent-browser 0.15.1 → 0.15.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.
@@ -0,0 +1,212 @@
1
+ ---
2
+ name: electron
3
+ description: Automate Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify, etc.) using agent-browser via Chrome DevTools Protocol. Use when the user needs to interact with an Electron app, automate a desktop app, connect to a running app, control a native app, or test an Electron application. Triggers include "automate Slack app", "control VS Code", "interact with Discord app", "test this Electron app", "connect to desktop app", or any task requiring automation of a native Electron application.
4
+ allowed-tools: Bash(agent-browser:*), Bash(npx agent-browser:*)
5
+ ---
6
+
7
+ # Electron App Automation
8
+
9
+ Automate any Electron desktop app using agent-browser. Electron apps are built on Chromium and expose a Chrome DevTools Protocol (CDP) port that agent-browser can connect to, enabling the same snapshot-interact workflow used for web pages.
10
+
11
+ ## Core Workflow
12
+
13
+ 1. **Launch** the Electron app with remote debugging enabled
14
+ 2. **Connect** agent-browser to the CDP port
15
+ 3. **Snapshot** to discover interactive elements
16
+ 4. **Interact** using element refs
17
+ 5. **Re-snapshot** after navigation or state changes
18
+
19
+ ```bash
20
+ # Launch an Electron app with remote debugging
21
+ open -a "Slack" --args --remote-debugging-port=9222
22
+
23
+ # Connect agent-browser to the app
24
+ agent-browser connect 9222
25
+
26
+ # Standard workflow from here
27
+ agent-browser snapshot -i
28
+ agent-browser click @e5
29
+ agent-browser screenshot slack-desktop.png
30
+ ```
31
+
32
+ ## Launching Electron Apps with CDP
33
+
34
+ Every Electron app supports the `--remote-debugging-port` flag since it's built into Chromium.
35
+
36
+ ### macOS
37
+
38
+ ```bash
39
+ # Slack
40
+ open -a "Slack" --args --remote-debugging-port=9222
41
+
42
+ # VS Code
43
+ open -a "Visual Studio Code" --args --remote-debugging-port=9223
44
+
45
+ # Discord
46
+ open -a "Discord" --args --remote-debugging-port=9224
47
+
48
+ # Figma
49
+ open -a "Figma" --args --remote-debugging-port=9225
50
+
51
+ # Notion
52
+ open -a "Notion" --args --remote-debugging-port=9226
53
+
54
+ # Spotify
55
+ open -a "Spotify" --args --remote-debugging-port=9227
56
+ ```
57
+
58
+ ### Linux
59
+
60
+ ```bash
61
+ slack --remote-debugging-port=9222
62
+ code --remote-debugging-port=9223
63
+ discord --remote-debugging-port=9224
64
+ ```
65
+
66
+ ### Windows
67
+
68
+ ```bash
69
+ "C:\Users\%USERNAME%\AppData\Local\slack\slack.exe" --remote-debugging-port=9222
70
+ "C:\Users\%USERNAME%\AppData\Local\Programs\Microsoft VS Code\Code.exe" --remote-debugging-port=9223
71
+ ```
72
+
73
+ **Important:** If the app is already running, quit it first, then relaunch with the flag. The `--remote-debugging-port` flag must be present at launch time.
74
+
75
+ ## Connecting
76
+
77
+ ```bash
78
+ # Connect to a specific port
79
+ agent-browser connect 9222
80
+
81
+ # Or use --cdp on each command
82
+ agent-browser --cdp 9222 snapshot -i
83
+
84
+ # Auto-discover a running Chromium-based app
85
+ agent-browser --auto-connect snapshot -i
86
+ ```
87
+
88
+ After `connect`, all subsequent commands target the connected app without needing `--cdp`.
89
+
90
+ ## Tab Management
91
+
92
+ Electron apps often have multiple windows or webviews. Use tab commands to list and switch between them:
93
+
94
+ ```bash
95
+ # List all available targets (windows, webviews, etc.)
96
+ agent-browser tab
97
+
98
+ # Switch to a specific tab by index
99
+ agent-browser tab 2
100
+
101
+ # Switch by URL pattern
102
+ agent-browser tab --url "*settings*"
103
+ ```
104
+
105
+ ## Common Patterns
106
+
107
+ ### Inspect and Navigate an App
108
+
109
+ ```bash
110
+ open -a "Slack" --args --remote-debugging-port=9222
111
+ sleep 3 # Wait for app to start
112
+ agent-browser connect 9222
113
+ agent-browser snapshot -i
114
+ # Read the snapshot output to identify UI elements
115
+ agent-browser click @e10 # Navigate to a section
116
+ agent-browser snapshot -i # Re-snapshot after navigation
117
+ ```
118
+
119
+ ### Take Screenshots of Desktop Apps
120
+
121
+ ```bash
122
+ agent-browser connect 9222
123
+ agent-browser screenshot app-state.png
124
+ agent-browser screenshot --full full-app.png
125
+ agent-browser screenshot --annotate annotated-app.png
126
+ ```
127
+
128
+ ### Extract Data from a Desktop App
129
+
130
+ ```bash
131
+ agent-browser connect 9222
132
+ agent-browser snapshot -i
133
+ agent-browser get text @e5
134
+ agent-browser snapshot --json > app-state.json
135
+ ```
136
+
137
+ ### Fill Forms in Desktop Apps
138
+
139
+ ```bash
140
+ agent-browser connect 9222
141
+ agent-browser snapshot -i
142
+ agent-browser fill @e3 "search query"
143
+ agent-browser press Enter
144
+ agent-browser wait 1000
145
+ agent-browser snapshot -i
146
+ ```
147
+
148
+ ### Run Multiple Apps Simultaneously
149
+
150
+ Use named sessions to control multiple Electron apps at the same time:
151
+
152
+ ```bash
153
+ # Connect to Slack
154
+ agent-browser --session slack connect 9222
155
+
156
+ # Connect to VS Code
157
+ agent-browser --session vscode connect 9223
158
+
159
+ # Interact with each independently
160
+ agent-browser --session slack snapshot -i
161
+ agent-browser --session vscode snapshot -i
162
+ ```
163
+
164
+ ## Color Scheme
165
+
166
+ Playwright overrides the color scheme to `light` by default when connecting via CDP. To preserve dark mode:
167
+
168
+ ```bash
169
+ agent-browser connect 9222
170
+ agent-browser --color-scheme dark snapshot -i
171
+ ```
172
+
173
+ Or set it globally:
174
+
175
+ ```bash
176
+ AGENT_BROWSER_COLOR_SCHEME=dark agent-browser connect 9222
177
+ ```
178
+
179
+ ## Troubleshooting
180
+
181
+ ### "Connection refused" or "Cannot connect"
182
+
183
+ - Make sure the app was launched with `--remote-debugging-port=NNNN`
184
+ - If the app was already running, quit and relaunch with the flag
185
+ - Check that the port isn't in use by another process: `lsof -i :9222`
186
+
187
+ ### App launches but connect fails
188
+
189
+ - Wait a few seconds after launch before connecting (`sleep 3`)
190
+ - Some apps take time to initialize their webview
191
+
192
+ ### Elements not appearing in snapshot
193
+
194
+ - The app may use multiple webviews. Use `agent-browser tab` to list targets and switch to the right one
195
+ - Use `agent-browser snapshot -i -C` to include cursor-interactive elements (divs with onclick handlers)
196
+
197
+ ### Cannot type in input fields
198
+
199
+ - Try `agent-browser keyboard type "text"` to type at the current focus without a selector
200
+ - Some Electron apps use custom input components; use `agent-browser keyboard inserttext "text"` to bypass key events
201
+
202
+ ## Supported Apps
203
+
204
+ Any app built on Electron works, including:
205
+
206
+ - **Communication:** Slack, Discord, Microsoft Teams, Signal, Telegram Desktop
207
+ - **Development:** VS Code, GitHub Desktop, Postman, Insomnia
208
+ - **Design:** Figma, Notion, Obsidian
209
+ - **Media:** Spotify, Tidal
210
+ - **Productivity:** Todoist, Linear, 1Password
211
+
212
+ If an app is built with Electron, it supports `--remote-debugging-port` and can be automated with agent-browser.
@@ -0,0 +1,294 @@
1
+ ---
2
+ name: slack
3
+ description: Interact with Slack workspaces using browser automation. Use when the user needs to check unread channels, navigate Slack, send messages, extract data, find information, search conversations, or automate any Slack task. Triggers include "check my Slack", "what channels have unreads", "send a message to", "search Slack for", "extract from Slack", "find who said", or any task requiring programmatic Slack interaction.
4
+ allowed-tools: Bash(agent-browser:*), Bash(npx agent-browser:*)
5
+ ---
6
+
7
+ # Slack Automation
8
+
9
+ Interact with Slack workspaces to check messages, extract data, and automate common tasks.
10
+
11
+ ## Quick Start
12
+
13
+ Connect to an existing Slack browser session or open Slack:
14
+
15
+ ```bash
16
+ # Connect to existing session on port 9222 (typical for already-open Slack)
17
+ agent-browser connect 9222
18
+
19
+ # Or open Slack if not already running
20
+ agent-browser open https://app.slack.com
21
+ ```
22
+
23
+ Then take a snapshot to see what's available:
24
+
25
+ ```bash
26
+ agent-browser snapshot -i
27
+ ```
28
+
29
+ ## Core Workflow
30
+
31
+ 1. **Connect/Navigate**: Open or connect to Slack
32
+ 2. **Snapshot**: Get interactive elements with refs (`@e1`, `@e2`, etc.)
33
+ 3. **Navigate**: Click tabs, expand sections, or navigate to specific channels
34
+ 4. **Extract/Interact**: Read data or perform actions
35
+ 5. **Screenshot**: Capture evidence of findings
36
+
37
+ ```bash
38
+ # Example: Check unread channels
39
+ agent-browser connect 9222
40
+ agent-browser snapshot -i
41
+ # Look for "More unreads" button
42
+ agent-browser click @e21 # Ref for "More unreads" button
43
+ agent-browser screenshot slack-unreads.png
44
+ ```
45
+
46
+ ## Common Tasks
47
+
48
+ ### Checking Unread Messages
49
+
50
+ ```bash
51
+ # Connect to Slack
52
+ agent-browser connect 9222
53
+
54
+ # Take snapshot to locate unreads button
55
+ agent-browser snapshot -i
56
+
57
+ # Look for:
58
+ # - "More unreads" button (usually near top of sidebar)
59
+ # - "Unreads" toggle in Activity tab (shows unread count)
60
+ # - Channel names with badges/bold text indicating unreads
61
+
62
+ # Navigate to Activity tab to see all unreads in one view
63
+ agent-browser click @e14 # Activity tab (ref may vary)
64
+ agent-browser wait 1000
65
+ agent-browser screenshot activity-unreads.png
66
+
67
+ # Or check DMs tab
68
+ agent-browser click @e13 # DMs tab
69
+ agent-browser screenshot dms.png
70
+
71
+ # Or expand "More unreads" in sidebar
72
+ agent-browser click @e21 # More unreads button
73
+ agent-browser wait 500
74
+ agent-browser screenshot expanded-unreads.png
75
+ ```
76
+
77
+ ### Navigating to a Channel
78
+
79
+ ```bash
80
+ # Search for channel in sidebar or by name
81
+ agent-browser snapshot -i
82
+
83
+ # Look for channel name in the list (e.g., "engineering", "product-design")
84
+ # Click on the channel treeitem ref
85
+ agent-browser click @e94 # Example: engineering channel ref
86
+ agent-browser wait --load networkidle
87
+ agent-browser screenshot channel.png
88
+ ```
89
+
90
+ ### Finding Messages/Threads
91
+
92
+ ```bash
93
+ # Use Slack search
94
+ agent-browser snapshot -i
95
+ agent-browser click @e5 # Search button (typical ref)
96
+ agent-browser fill @e_search "keyword"
97
+ agent-browser press Enter
98
+ agent-browser wait --load networkidle
99
+ agent-browser screenshot search-results.png
100
+ ```
101
+
102
+ ### Extracting Channel Information
103
+
104
+ ```bash
105
+ # Get list of all visible channels
106
+ agent-browser snapshot --json > slack-snapshot.json
107
+
108
+ # Parse for channel names and metadata
109
+ # Look for treeitem elements with level=2 (sub-channels under sections)
110
+ ```
111
+
112
+ ### Checking Channel Details
113
+
114
+ ```bash
115
+ # Open a channel
116
+ agent-browser click @e_channel_ref
117
+ agent-browser wait 1000
118
+
119
+ # Get channel info (members, description, etc.)
120
+ agent-browser snapshot -i
121
+ agent-browser screenshot channel-details.png
122
+
123
+ # Scroll through messages
124
+ agent-browser scroll down 500
125
+ agent-browser screenshot channel-messages.png
126
+ ```
127
+
128
+ ### Taking Notes/Capturing State
129
+
130
+ When you need to document findings from Slack:
131
+
132
+ ```bash
133
+ # Take annotated screenshot (shows element numbers)
134
+ agent-browser screenshot --annotate slack-state.png
135
+
136
+ # Take full-page screenshot
137
+ agent-browser screenshot --full slack-full.png
138
+
139
+ # Get current URL for reference
140
+ agent-browser get url
141
+
142
+ # Get page title
143
+ agent-browser get title
144
+ ```
145
+
146
+ ## Sidebar Structure
147
+
148
+ Understanding Slack's sidebar helps you navigate efficiently:
149
+
150
+ ```
151
+ - Threads
152
+ - Huddles
153
+ - Drafts & sent
154
+ - Directories
155
+ - [Section Headers - External connections, Starred, Channels, etc.]
156
+ - [Channels listed as treeitems]
157
+ - Direct Messages
158
+ - [DMs listed]
159
+ - Apps
160
+ - [App shortcuts]
161
+ - [More unreads] button (toggles unread channels list)
162
+ ```
163
+
164
+ Key refs to look for:
165
+ - `@e12` - Home tab (usually)
166
+ - `@e13` - DMs tab
167
+ - `@e14` - Activity tab
168
+ - `@e5` - Search button
169
+ - `@e21` - More unreads button (varies by session)
170
+
171
+ ## Tabs in Slack
172
+
173
+ After clicking on a channel, you'll see tabs:
174
+ - **Messages** - Channel conversation
175
+ - **Files** - Shared files
176
+ - **Pins** - Pinned messages
177
+ - **Add canvas** - Collaborative canvas
178
+ - Other tabs depending on workspace setup
179
+
180
+ Click tab refs to switch views and get different information.
181
+
182
+ ## Extracting Data from Slack
183
+
184
+ ### Get Text Content
185
+
186
+ ```bash
187
+ # Get a message or element's text
188
+ agent-browser get text @e_message_ref
189
+ ```
190
+
191
+ ### Parse Accessibility Tree
192
+
193
+ ```bash
194
+ # Full snapshot as JSON for programmatic parsing
195
+ agent-browser snapshot --json > output.json
196
+
197
+ # Look for:
198
+ # - Channel names (name field in treeitem)
199
+ # - Message content (in listitem/document elements)
200
+ # - User names (button elements with user info)
201
+ # - Timestamps (link elements with time info)
202
+ ```
203
+
204
+ ### Count Unreads
205
+
206
+ ```bash
207
+ # After expanding unreads section:
208
+ agent-browser snapshot -i | grep -c "treeitem"
209
+ # Each treeitem with a channel name in the unreads section is one unread
210
+ ```
211
+
212
+ ## Best Practices
213
+
214
+ - **Connect to existing sessions**: Use `agent-browser connect 9222` if Slack is already open. This is faster than opening a new browser.
215
+ - **Take snapshots before clicking**: Always `snapshot -i` to identify refs before clicking buttons.
216
+ - **Re-snapshot after navigation**: After navigating to a new channel or section, take a fresh snapshot to find new refs.
217
+ - **Use JSON snapshots for parsing**: When you need to extract structured data, use `snapshot --json` for machine-readable output.
218
+ - **Pace interactions**: Add `sleep 1` between rapid interactions to let the UI update.
219
+ - **Check accessibility tree**: The accessibility tree shows what screen readers (and your automation) can see. If an element isn't in the snapshot, it may be hidden or require scrolling.
220
+ - **Scroll in sidebar**: Use `agent-browser scroll down 300 --selector ".p-sidebar"` to scroll within the Slack sidebar if channel list is long.
221
+
222
+ ## Limitations
223
+
224
+ - **Cannot access Slack API**: This uses browser automation, not the Slack API. No OAuth, webhooks, or bot tokens needed.
225
+ - **Session-specific**: Screenshots and snapshots are tied to the current browser session.
226
+ - **Rate limiting**: Slack may rate-limit rapid interactions. Add delays between commands if needed.
227
+ - **Workspace-specific**: You interact with your own workspace -- no cross-workspace automation.
228
+
229
+ ## Debugging
230
+
231
+ ### Check console for errors
232
+
233
+ ```bash
234
+ agent-browser console
235
+ agent-browser errors
236
+ ```
237
+
238
+ ### View raw HTML of an element
239
+
240
+ ```bash
241
+ # Snapshot shows the accessibility tree. If an element isn't there,
242
+ # it may not be interactive (e.g., div instead of button)
243
+ # Use snapshot -i -C to include cursor-interactive divs
244
+ agent-browser snapshot -i -C
245
+ ```
246
+
247
+ ### Get current page state
248
+
249
+ ```bash
250
+ agent-browser get url
251
+ agent-browser get title
252
+ agent-browser screenshot page-state.png
253
+ ```
254
+
255
+ ## Example: Full Unread Check
256
+
257
+ ```bash
258
+ #!/bin/bash
259
+
260
+ # Connect to Slack
261
+ agent-browser connect 9222
262
+
263
+ # Take initial snapshot
264
+ echo "=== Checking Slack unreads ==="
265
+ agent-browser snapshot -i > snapshot.txt
266
+
267
+ # Check Activity tab for unreads
268
+ agent-browser click @e14 # Activity tab
269
+ agent-browser wait 1000
270
+ agent-browser screenshot activity.png
271
+ ACTIVITY_RESULT=$(agent-browser get text @e_main_area)
272
+ echo "Activity: $ACTIVITY_RESULT"
273
+
274
+ # Check DMs
275
+ agent-browser click @e13 # DMs tab
276
+ agent-browser wait 1000
277
+ agent-browser screenshot dms.png
278
+
279
+ # Check unread channels in sidebar
280
+ agent-browser click @e21 # More unreads button
281
+ agent-browser wait 500
282
+ agent-browser snapshot -i > unreads-expanded.txt
283
+ agent-browser screenshot unreads.png
284
+
285
+ # Summary
286
+ echo "=== Summary ==="
287
+ echo "See activity.png, dms.png, and unreads.png for full details"
288
+ ```
289
+
290
+ ## References
291
+
292
+ - **Slack docs**: https://slack.com/help
293
+ - **Web experience**: https://app.slack.com
294
+ - **Keyboard shortcuts**: Type `?` in Slack for shortcut list