browser-automation-cli 0.1.0__tar.gz

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,155 @@
1
+ # Agent Setup Guide
2
+
3
+ > **For agent integration, see [SKILL.md](./SKILL.md) for usage patterns. Add the SKILL.md to your local setup as part of your skills configuration.**
4
+
5
+ This document explains how to set up Browser CLI for users and integrate it into your agent workflow.
6
+
7
+ ## Setup (One-time)
8
+
9
+ Preferred setup (published package):
10
+
11
+ ```bash
12
+ pipx install browser-cli
13
+
14
+ # If "command not found" after install:
15
+ # export PATH="$HOME/.local/bin:$PATH"
16
+
17
+ browser install
18
+ ```
19
+
20
+ If package is not published yet (install from Git):
21
+
22
+ ```bash
23
+ pipx install "git+https://github.com/<your-org>/<your-repo>.git"
24
+ browser install
25
+ ```
26
+
27
+ From local checkout (developer path):
28
+
29
+ ```bash
30
+ bash ./setup.sh
31
+ ```
32
+
33
+ ## Starting the Daemon
34
+
35
+ The daemon must be running before any browser actions work. Start it with:
36
+
37
+ ```bash
38
+ browser-daemon
39
+ ```
40
+
41
+ **Important:** The daemon opens a visible browser window. It must remain running.
42
+
43
+ ## Session Lifecycle
44
+
45
+ 1. **Create session** - User manually logs into sites:
46
+ ```bash
47
+ browser create
48
+ ```
49
+
50
+ 2. **Use session** - Agent performs actions:
51
+ ```bash
52
+ browser <session_id> navigate github.com/user/repo
53
+ browser <session_id> snapshot
54
+ ```
55
+
56
+ 3. **Share session** - Multiple agents can use the same session ID
57
+
58
+ 4. **Delete when done**:
59
+ ```bash
60
+ browser delete <session_id>
61
+ ```
62
+
63
+ ## Agent Workflow Example
64
+
65
+ ```bash
66
+ # 1. Create session, user logs in manually
67
+ browser create
68
+ # → returns session_id like "abc12345"
69
+
70
+ # 2. Navigate and inspect
71
+ browser abc12345 navigate github.com/user/repo
72
+ browser abc12345 snapshot
73
+ # → returns elements array
74
+
75
+ # 3. Interact
76
+ browser abc12345 click "button.submit"
77
+ browser abc12345 type "input[name=message]" "Hello"
78
+ browser abc12345 screenshot
79
+
80
+ # 4. Agent parses JSON output to decide next steps
81
+ ```
82
+
83
+ ## Output Format
84
+
85
+ All actions return JSON:
86
+ ```json
87
+ {
88
+ "success": true,
89
+ "url": "https://github.com/user/repo",
90
+ "title": "Repository"
91
+ }
92
+ ```
93
+
94
+ For `snapshot`:
95
+ ```json
96
+ {
97
+ "success": true,
98
+ "elements": [
99
+ {"ref": "el_0", "tag": "a", "text": "README", "href": "..."},
100
+ {"ref": "el_1", "tag": "button", "text": "Submit", "name": null}
101
+ ]
102
+ }
103
+ ```
104
+
105
+ For `screenshot`:
106
+ ```json
107
+ {
108
+ "success": true,
109
+ "image": "base64encodedstring..."
110
+ }
111
+ ```
112
+
113
+ ## Shell Integration
114
+
115
+ Agents can call the CLI via subprocess. Example patterns:
116
+
117
+ ```python
118
+ import subprocess
119
+ import json
120
+
121
+ result = subprocess.run(
122
+ ["browser", "abc12345", "snapshot"],
123
+ capture_output=True,
124
+ text=True
125
+ )
126
+ data = json.loads(result.stdout)
127
+ ```
128
+
129
+ ```typescript
130
+ import { execSync } from 'child_process';
131
+
132
+ const output = execSync(`browser abc12345 snapshot`);
133
+ const data = JSON.parse(output.toString());
134
+ ```
135
+
136
+ ## Sharing Sessions Between Agents
137
+
138
+ Sessions persist until explicitly deleted. Multiple agents can reference the same session:
139
+
140
+ ```bash
141
+ # Agent A creates session
142
+ browser create
143
+ # → abc12345
144
+
145
+ # Agent B uses same session
146
+ browser abc12345 navigate github.com
147
+ ```
148
+
149
+ ## Key Points
150
+
151
+ - Daemon runs once, handles multiple sessions
152
+ - User manually authenticates (no credentials in code)
153
+ - Session IDs are 8-character hex strings
154
+ - Browser window stays open for the session duration
155
+ - Actions are blocking (not parallel within a session)
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Browser CLI Maintainers
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,22 @@
1
+ .PHONY: install daemon cli help
2
+
3
+ help:
4
+ @echo "Browser CLI - Usage"
5
+ @echo ""
6
+ @echo " make install Install dependencies and commands"
7
+ @echo " make daemon Start the browser daemon (background)"
8
+ @echo " browser create Create new session"
9
+ @echo " browser list List sessions"
10
+ @echo " browser <id> <cmd> Run command on session"
11
+
12
+ install:
13
+ @pip install playwright
14
+ @playwright install chromium
15
+ @pip install -e .
16
+
17
+ daemon:
18
+ @browser-daemon
19
+
20
+ start-daemon:
21
+ @browser-daemon &
22
+ @echo "Daemon started in background"
@@ -0,0 +1,211 @@
1
+ Metadata-Version: 2.4
2
+ Name: browser-automation-cli
3
+ Version: 0.1.0
4
+ Summary: Lightweight browser automation daemon with CLI
5
+ Project-URL: Homepage, https://github.com/<your-org>/<your-repo>
6
+ Project-URL: Repository, https://github.com/<your-org>/<your-repo>
7
+ Author: Browser CLI Maintainers
8
+ License: MIT License
9
+
10
+ Copyright (c) 2026 Browser CLI Maintainers
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+ License-File: LICENSE.txt
30
+ Keywords: agent,automation,browser,cli,playwright
31
+ Requires-Python: >=3.10
32
+ Requires-Dist: playwright>=1.40.0
33
+ Description-Content-Type: text/markdown
34
+
35
+ # Browser CLI
36
+
37
+ > **If you are an LLM, see [AGENTS.md](./AGENTS.md) for quick setup instructions.**
38
+
39
+ ---
40
+
41
+ ## If you are a human
42
+
43
+ ### Install
44
+
45
+ Preferred (published package):
46
+
47
+ ```bash
48
+ pipx install browser-cli
49
+ browser install
50
+ ```
51
+
52
+ Without publishing (install directly from Git):
53
+
54
+ ```bash
55
+ pipx install "git+https://github.com/<your-org>/<your-repo>.git"
56
+ browser install
57
+ ```
58
+
59
+ From a local checkout:
60
+
61
+ ```bash
62
+ bash ./setup.sh
63
+ ```
64
+
65
+ Manual dev install (fallback):
66
+
67
+ ```bash
68
+ pip install -e .
69
+ browser install
70
+ ```
71
+
72
+ ### Start the daemon
73
+
74
+ In a terminal:
75
+
76
+ ```bash
77
+ browser-daemon
78
+ ```
79
+
80
+ A browser window will open. Keep this running.
81
+
82
+ ### Create a session
83
+
84
+ In another terminal:
85
+
86
+ ```bash
87
+ browser create
88
+ ```
89
+
90
+ This opens a fresh browser window. Manually log into any sites you need (GitHub, Jira, etc.).
91
+
92
+ ### Run browser actions
93
+
94
+ ```bash
95
+ # Navigate to a site
96
+ browser <session_id> navigate github.com/user/repo
97
+
98
+ # Get page elements
99
+ browser <session_id> snapshot
100
+
101
+ # Click an element
102
+ browser <session_id> click ".readme"
103
+
104
+ # Take a screenshot
105
+ browser <session_id> screenshot
106
+
107
+ # Type text
108
+ browser <session_id> type "input[name=search]" "query"
109
+ ```
110
+
111
+ ### List active sessions
112
+
113
+ ```bash
114
+ browser list
115
+ ```
116
+
117
+ ### Delete a session
118
+
119
+ ```bash
120
+ browser delete <session_id>
121
+ ```
122
+
123
+ ### Stop the daemon
124
+
125
+ Press `Ctrl+C` in the terminal running `browser-daemon`.
126
+
127
+ ---
128
+
129
+ ## Commands Reference
130
+
131
+ ### Standalone (No Daemon)
132
+
133
+ **Capture Command:**
134
+
135
+ Uses JPEG format for efficient file sizes (~10x smaller than PNG).
136
+
137
+ ```bash
138
+ browser capture <url> [options]
139
+ ```
140
+
141
+ **Options:**
142
+ - `-f, --full-page` - Capture full scrollable page (default: viewport only)
143
+ - `-o, --output <path>` - Custom output path
144
+
145
+ **Examples:**
146
+ ```bash
147
+ # Quick viewport screenshot (fastest, smallest file)
148
+ browser capture https://example.com
149
+
150
+ # Full page screenshot
151
+ browser capture https://example.com -f
152
+
153
+ # Save to custom location
154
+ browser capture https://example.com -o ./my-screenshot.jpg
155
+
156
+ # Full page + custom path
157
+ browser capture https://example.com -f -o ./full-page.jpg
158
+
159
+ # Capture localhost
160
+ browser capture http://localhost:3000
161
+ browser capture http://127.0.0.1:8080/dashboard
162
+ ```
163
+
164
+ ### Daemon Commands
165
+
166
+ | Command | Description |
167
+ |---------|-------------|
168
+ | `browser install` | Install Chromium runtime |
169
+ | `browser create` | Create new session (opens browser for login) |
170
+ | `browser list` | List active sessions |
171
+ | `browser <id> navigate <url>` | Navigate to URL |
172
+ | `browser <id> snapshot [selector]` | Get page elements |
173
+ | `browser <id> click <selector>` | Click element |
174
+ | `browser <id> type <selector> <text>` | Type text |
175
+ | `browser <id> hover <selector>` | Hover element |
176
+ | `browser <id> select <selector> <value>` | Select dropdown option |
177
+ | `browser <id> press <key>` | Press keyboard key |
178
+ | `browser <id> screenshot [selector]` | Take screenshot |
179
+ | `browser <id> back` | Go back |
180
+ | `browser <id> forward` | Go forward |
181
+ | `browser <id> delete` | Delete session |
182
+
183
+ ## Troubleshooting
184
+
185
+ **"Command not found: browser" or "browser: command not found"**
186
+
187
+ If `pipx install` succeeded but commands aren't found, your shell may not have `~/.local/bin` in PATH:
188
+
189
+ ```bash
190
+ # Quick fix (current session only)
191
+ export PATH="$HOME/.local/bin:$PATH"
192
+
193
+ # Permanent fix (add to shell config)
194
+ echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc # or ~/.bashrc
195
+ source ~/.zshrc # apply immediately
196
+ ```
197
+
198
+ **"Daemon not running"**
199
+ ```bash
200
+ browser-daemon
201
+ ```
202
+
203
+ **Browser doesn't open**
204
+ ```bash
205
+ browser install
206
+ ```
207
+
208
+ **Session not found**
209
+ ```bash
210
+ browser list
211
+ ```
@@ -0,0 +1,177 @@
1
+ # Browser CLI
2
+
3
+ > **If you are an LLM, see [AGENTS.md](./AGENTS.md) for quick setup instructions.**
4
+
5
+ ---
6
+
7
+ ## If you are a human
8
+
9
+ ### Install
10
+
11
+ Preferred (published package):
12
+
13
+ ```bash
14
+ pipx install browser-cli
15
+ browser install
16
+ ```
17
+
18
+ Without publishing (install directly from Git):
19
+
20
+ ```bash
21
+ pipx install "git+https://github.com/<your-org>/<your-repo>.git"
22
+ browser install
23
+ ```
24
+
25
+ From a local checkout:
26
+
27
+ ```bash
28
+ bash ./setup.sh
29
+ ```
30
+
31
+ Manual dev install (fallback):
32
+
33
+ ```bash
34
+ pip install -e .
35
+ browser install
36
+ ```
37
+
38
+ ### Start the daemon
39
+
40
+ In a terminal:
41
+
42
+ ```bash
43
+ browser-daemon
44
+ ```
45
+
46
+ A browser window will open. Keep this running.
47
+
48
+ ### Create a session
49
+
50
+ In another terminal:
51
+
52
+ ```bash
53
+ browser create
54
+ ```
55
+
56
+ This opens a fresh browser window. Manually log into any sites you need (GitHub, Jira, etc.).
57
+
58
+ ### Run browser actions
59
+
60
+ ```bash
61
+ # Navigate to a site
62
+ browser <session_id> navigate github.com/user/repo
63
+
64
+ # Get page elements
65
+ browser <session_id> snapshot
66
+
67
+ # Click an element
68
+ browser <session_id> click ".readme"
69
+
70
+ # Take a screenshot
71
+ browser <session_id> screenshot
72
+
73
+ # Type text
74
+ browser <session_id> type "input[name=search]" "query"
75
+ ```
76
+
77
+ ### List active sessions
78
+
79
+ ```bash
80
+ browser list
81
+ ```
82
+
83
+ ### Delete a session
84
+
85
+ ```bash
86
+ browser delete <session_id>
87
+ ```
88
+
89
+ ### Stop the daemon
90
+
91
+ Press `Ctrl+C` in the terminal running `browser-daemon`.
92
+
93
+ ---
94
+
95
+ ## Commands Reference
96
+
97
+ ### Standalone (No Daemon)
98
+
99
+ **Capture Command:**
100
+
101
+ Uses JPEG format for efficient file sizes (~10x smaller than PNG).
102
+
103
+ ```bash
104
+ browser capture <url> [options]
105
+ ```
106
+
107
+ **Options:**
108
+ - `-f, --full-page` - Capture full scrollable page (default: viewport only)
109
+ - `-o, --output <path>` - Custom output path
110
+
111
+ **Examples:**
112
+ ```bash
113
+ # Quick viewport screenshot (fastest, smallest file)
114
+ browser capture https://example.com
115
+
116
+ # Full page screenshot
117
+ browser capture https://example.com -f
118
+
119
+ # Save to custom location
120
+ browser capture https://example.com -o ./my-screenshot.jpg
121
+
122
+ # Full page + custom path
123
+ browser capture https://example.com -f -o ./full-page.jpg
124
+
125
+ # Capture localhost
126
+ browser capture http://localhost:3000
127
+ browser capture http://127.0.0.1:8080/dashboard
128
+ ```
129
+
130
+ ### Daemon Commands
131
+
132
+ | Command | Description |
133
+ |---------|-------------|
134
+ | `browser install` | Install Chromium runtime |
135
+ | `browser create` | Create new session (opens browser for login) |
136
+ | `browser list` | List active sessions |
137
+ | `browser <id> navigate <url>` | Navigate to URL |
138
+ | `browser <id> snapshot [selector]` | Get page elements |
139
+ | `browser <id> click <selector>` | Click element |
140
+ | `browser <id> type <selector> <text>` | Type text |
141
+ | `browser <id> hover <selector>` | Hover element |
142
+ | `browser <id> select <selector> <value>` | Select dropdown option |
143
+ | `browser <id> press <key>` | Press keyboard key |
144
+ | `browser <id> screenshot [selector]` | Take screenshot |
145
+ | `browser <id> back` | Go back |
146
+ | `browser <id> forward` | Go forward |
147
+ | `browser <id> delete` | Delete session |
148
+
149
+ ## Troubleshooting
150
+
151
+ **"Command not found: browser" or "browser: command not found"**
152
+
153
+ If `pipx install` succeeded but commands aren't found, your shell may not have `~/.local/bin` in PATH:
154
+
155
+ ```bash
156
+ # Quick fix (current session only)
157
+ export PATH="$HOME/.local/bin:$PATH"
158
+
159
+ # Permanent fix (add to shell config)
160
+ echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc # or ~/.bashrc
161
+ source ~/.zshrc # apply immediately
162
+ ```
163
+
164
+ **"Daemon not running"**
165
+ ```bash
166
+ browser-daemon
167
+ ```
168
+
169
+ **Browser doesn't open**
170
+ ```bash
171
+ browser install
172
+ ```
173
+
174
+ **Session not found**
175
+ ```bash
176
+ browser list
177
+ ```