silicon-browser 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,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,157 @@
1
+ Metadata-Version: 2.4
2
+ Name: silicon-browser
3
+ Version: 0.1.0
4
+ Summary: Terminal-native browser CLI for AI agents, powered by Steel Browser.
5
+ Keywords: browser,automation,steel,cli,ai-agents,playwright
6
+ License-Expression: Apache-2.0
7
+ License-File: LICENSE
8
+ Classifier: Environment :: Console
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Topic :: Internet :: WWW/HTTP :: Browsers
12
+ Requires-Dist: playwright>=1.60.0
13
+ Requires-Dist: python-dotenv>=1.2.2
14
+ Requires-Dist: rich>=15.0.0
15
+ Requires-Dist: steel-sdk>=0.17.0
16
+ Requires-Dist: typer>=0.26.5
17
+ Requires-Python: >=3.10
18
+ Project-URL: Homepage, https://github.com/saket1225/silicon-browser
19
+ Project-URL: Repository, https://github.com/saket1225/silicon-browser
20
+ Description-Content-Type: text/markdown
21
+
22
+ # Silicon Browser
23
+
24
+ A terminal-native browser CLI for AI agents — same command surface as the
25
+ original [silicon-browser](https://github.com/unlikefraction/silicon-browser),
26
+ but every browser runs in the cloud on [Steel](https://docs.steel.dev). No local
27
+ Chromium, no stealth-patch maintenance: Steel provides the browser, fingerprinting,
28
+ proxies, and CAPTCHA solving; Silicon Browser gives you a fast, scriptable CLI on
29
+ top with a stable `@ref` element model and shareable remote-access links.
30
+
31
+ ## How it works
32
+
33
+ - Each named session is a **Steel cloud browser**, driven over CDP via Playwright.
34
+ - The browser lives in Steel's cloud and persists between commands; Silicon Browser
35
+ keeps a small local state file per session (`~/.silicon-browser/sessions/<name>.json`)
36
+ recording the session id, active tab, and the last snapshot's `@ref → element` map.
37
+ - Every command opens a short-lived CDP connection, does its work, and disconnects.
38
+ Disconnecting does **not** end the cloud browser — only `close` (or the session
39
+ timeout) does.
40
+
41
+ ## Install
42
+
43
+ Install directly from GitHub (no clone needed):
44
+
45
+ ```bash
46
+ uv tool install git+https://github.com/saket1225/silicon-browser.git
47
+ # or: pipx install git+https://github.com/saket1225/silicon-browser.git
48
+ ```
49
+
50
+ Or from a local clone:
51
+
52
+ ```bash
53
+ git clone https://github.com/saket1225/silicon-browser.git
54
+ cd silicon-browser
55
+ uv tool install . # or: pipx install .
56
+ ```
57
+
58
+ Then set your key and verify:
59
+
60
+ ```bash
61
+ export STEEL_API_KEY=ste-... # or put it in a .env file
62
+ silicon-browser install # verifies your key + connectivity
63
+ ```
64
+
65
+ > Get a key at [app.steel.dev](https://app.steel.dev). Note that session/link
66
+ > lifetimes are capped by your Steel plan (e.g. 15 min on the hobby plan); Silicon
67
+ > Browser clamps to your plan's maximum automatically and tells you when it does.
68
+
69
+ ## Usage
70
+
71
+ ```bash
72
+ silicon-browser open example.com # start a session and navigate
73
+ silicon-browser snapshot -i # list interactive elements with @refs
74
+ silicon-browser click @e1 # click by ref
75
+ silicon-browser fill @e2 "hello" # fill an input
76
+ silicon-browser type "search query" # keystroke-level typing
77
+ silicon-browser get text @e3 # extract text / html / value
78
+ silicon-browser screenshot # saved under ~/.silicon-browser/screenshots
79
+ silicon-browser evaluate "document.title"
80
+ silicon-browser tabs # list tabs
81
+ silicon-browser tab new example.org # open / switch tabs
82
+ silicon-browser tab select 0
83
+ silicon-browser close # release the cloud browser
84
+ ```
85
+
86
+ ### Commands
87
+
88
+ | Command | Description |
89
+ |---|---|
90
+ | `open <url>` | Navigate (starts a session if none active) |
91
+ | `snapshot [-i] [--json]` | Accessibility tree with `@refs`; `-i` = interactive only |
92
+ | `click @ref` | Click an element |
93
+ | `fill @ref "text"` | Fill an input |
94
+ | `type "text" [--delay ms]` | Type at the keyboard level |
95
+ | `select @ref "value"` | Select a dropdown option |
96
+ | `hover @ref` | Hover an element |
97
+ | `scroll [down\|up\|top\|bottom] [--amount px]` | Scroll the page |
98
+ | `get text\|html\|value @ref` | Extract from an element |
99
+ | `screenshot [path] [--full-page]` | Capture a screenshot |
100
+ | `evaluate "js"` | Run JavaScript, print the result |
101
+ | `tabs` / `tab new [url]` / `tab select <n>` | Manage tabs |
102
+ | `share [--expiry min] [--view-only] [--new]` | **Remote access link** (see below) |
103
+ | `status` / `sessions` | Inspect sessions |
104
+ | `profile list\|save <name>\|delete <name>` | Persistent identities |
105
+ | `close` | Release the cloud browser |
106
+ | `install` | Verify Steel credentials |
107
+
108
+ ### Global options
109
+
110
+ `--session/-s <name>` (parallel sessions) · `--profile <name>` ·
111
+ `--incognito` · `--proxy <url>` · `--user-agent <ua>` · `--solve-captcha`
112
+
113
+ ## Remote access links
114
+
115
+ Generate a shareable link to watch — or take control of — the live cloud browser:
116
+
117
+ ```bash
118
+ silicon-browser share # interactive link, expires in 60 min
119
+ silicon-browser share --expiry 30 # custom expiry (minutes)
120
+ silicon-browser share --view-only # watch only, no control
121
+ silicon-browser share --new --expiry 120 # fresh session dedicated to the link
122
+ ```
123
+
124
+ The link's lifetime **is** the Steel session timeout, so the expiry is enforced
125
+ server-side: when it elapses, Steel tears the browser down and the link stops
126
+ working. The default is **60 minutes** (clamped to your plan's maximum if lower).
127
+
128
+ - **Interactive** (default): recipients can click and type in the live browser.
129
+ - **View-only** (`--view-only`): recipients can watch but not control.
130
+
131
+ Because Steel fixes a session's timeout at creation, `share` on an *existing*
132
+ session reports that session's real expiry; use `--new` to mint a fresh session
133
+ with exactly the expiry you ask for.
134
+
135
+ ## Profiles
136
+
137
+ A profile saves a session's cookies + local/session storage + IndexedDB so identity
138
+ persists across sessions:
139
+
140
+ ```bash
141
+ silicon-browser --profile work open github.com # reuse saved context
142
+ silicon-browser --profile work close # context is saved on close
143
+ silicon-browser profile list
144
+ ```
145
+
146
+ ## Configuration
147
+
148
+ | Variable | Purpose |
149
+ |---|---|
150
+ | `STEEL_API_KEY` | Your Steel API key (required) |
151
+ | `STEEL_BASE_URL` | Override the Steel API base URL (self-hosted Steel) |
152
+ | `STEEL_CONNECT_URL` | Override the CDP connect host (self-hosted Steel) |
153
+ | `SILICON_BROWSER_HOME` | State directory (default `~/.silicon-browser`) |
154
+
155
+ ## License
156
+
157
+ Apache-2.0
@@ -0,0 +1,136 @@
1
+ # Silicon Browser
2
+
3
+ A terminal-native browser CLI for AI agents — same command surface as the
4
+ original [silicon-browser](https://github.com/unlikefraction/silicon-browser),
5
+ but every browser runs in the cloud on [Steel](https://docs.steel.dev). No local
6
+ Chromium, no stealth-patch maintenance: Steel provides the browser, fingerprinting,
7
+ proxies, and CAPTCHA solving; Silicon Browser gives you a fast, scriptable CLI on
8
+ top with a stable `@ref` element model and shareable remote-access links.
9
+
10
+ ## How it works
11
+
12
+ - Each named session is a **Steel cloud browser**, driven over CDP via Playwright.
13
+ - The browser lives in Steel's cloud and persists between commands; Silicon Browser
14
+ keeps a small local state file per session (`~/.silicon-browser/sessions/<name>.json`)
15
+ recording the session id, active tab, and the last snapshot's `@ref → element` map.
16
+ - Every command opens a short-lived CDP connection, does its work, and disconnects.
17
+ Disconnecting does **not** end the cloud browser — only `close` (or the session
18
+ timeout) does.
19
+
20
+ ## Install
21
+
22
+ Install directly from GitHub (no clone needed):
23
+
24
+ ```bash
25
+ uv tool install git+https://github.com/saket1225/silicon-browser.git
26
+ # or: pipx install git+https://github.com/saket1225/silicon-browser.git
27
+ ```
28
+
29
+ Or from a local clone:
30
+
31
+ ```bash
32
+ git clone https://github.com/saket1225/silicon-browser.git
33
+ cd silicon-browser
34
+ uv tool install . # or: pipx install .
35
+ ```
36
+
37
+ Then set your key and verify:
38
+
39
+ ```bash
40
+ export STEEL_API_KEY=ste-... # or put it in a .env file
41
+ silicon-browser install # verifies your key + connectivity
42
+ ```
43
+
44
+ > Get a key at [app.steel.dev](https://app.steel.dev). Note that session/link
45
+ > lifetimes are capped by your Steel plan (e.g. 15 min on the hobby plan); Silicon
46
+ > Browser clamps to your plan's maximum automatically and tells you when it does.
47
+
48
+ ## Usage
49
+
50
+ ```bash
51
+ silicon-browser open example.com # start a session and navigate
52
+ silicon-browser snapshot -i # list interactive elements with @refs
53
+ silicon-browser click @e1 # click by ref
54
+ silicon-browser fill @e2 "hello" # fill an input
55
+ silicon-browser type "search query" # keystroke-level typing
56
+ silicon-browser get text @e3 # extract text / html / value
57
+ silicon-browser screenshot # saved under ~/.silicon-browser/screenshots
58
+ silicon-browser evaluate "document.title"
59
+ silicon-browser tabs # list tabs
60
+ silicon-browser tab new example.org # open / switch tabs
61
+ silicon-browser tab select 0
62
+ silicon-browser close # release the cloud browser
63
+ ```
64
+
65
+ ### Commands
66
+
67
+ | Command | Description |
68
+ |---|---|
69
+ | `open <url>` | Navigate (starts a session if none active) |
70
+ | `snapshot [-i] [--json]` | Accessibility tree with `@refs`; `-i` = interactive only |
71
+ | `click @ref` | Click an element |
72
+ | `fill @ref "text"` | Fill an input |
73
+ | `type "text" [--delay ms]` | Type at the keyboard level |
74
+ | `select @ref "value"` | Select a dropdown option |
75
+ | `hover @ref` | Hover an element |
76
+ | `scroll [down\|up\|top\|bottom] [--amount px]` | Scroll the page |
77
+ | `get text\|html\|value @ref` | Extract from an element |
78
+ | `screenshot [path] [--full-page]` | Capture a screenshot |
79
+ | `evaluate "js"` | Run JavaScript, print the result |
80
+ | `tabs` / `tab new [url]` / `tab select <n>` | Manage tabs |
81
+ | `share [--expiry min] [--view-only] [--new]` | **Remote access link** (see below) |
82
+ | `status` / `sessions` | Inspect sessions |
83
+ | `profile list\|save <name>\|delete <name>` | Persistent identities |
84
+ | `close` | Release the cloud browser |
85
+ | `install` | Verify Steel credentials |
86
+
87
+ ### Global options
88
+
89
+ `--session/-s <name>` (parallel sessions) · `--profile <name>` ·
90
+ `--incognito` · `--proxy <url>` · `--user-agent <ua>` · `--solve-captcha`
91
+
92
+ ## Remote access links
93
+
94
+ Generate a shareable link to watch — or take control of — the live cloud browser:
95
+
96
+ ```bash
97
+ silicon-browser share # interactive link, expires in 60 min
98
+ silicon-browser share --expiry 30 # custom expiry (minutes)
99
+ silicon-browser share --view-only # watch only, no control
100
+ silicon-browser share --new --expiry 120 # fresh session dedicated to the link
101
+ ```
102
+
103
+ The link's lifetime **is** the Steel session timeout, so the expiry is enforced
104
+ server-side: when it elapses, Steel tears the browser down and the link stops
105
+ working. The default is **60 minutes** (clamped to your plan's maximum if lower).
106
+
107
+ - **Interactive** (default): recipients can click and type in the live browser.
108
+ - **View-only** (`--view-only`): recipients can watch but not control.
109
+
110
+ Because Steel fixes a session's timeout at creation, `share` on an *existing*
111
+ session reports that session's real expiry; use `--new` to mint a fresh session
112
+ with exactly the expiry you ask for.
113
+
114
+ ## Profiles
115
+
116
+ A profile saves a session's cookies + local/session storage + IndexedDB so identity
117
+ persists across sessions:
118
+
119
+ ```bash
120
+ silicon-browser --profile work open github.com # reuse saved context
121
+ silicon-browser --profile work close # context is saved on close
122
+ silicon-browser profile list
123
+ ```
124
+
125
+ ## Configuration
126
+
127
+ | Variable | Purpose |
128
+ |---|---|
129
+ | `STEEL_API_KEY` | Your Steel API key (required) |
130
+ | `STEEL_BASE_URL` | Override the Steel API base URL (self-hosted Steel) |
131
+ | `STEEL_CONNECT_URL` | Override the CDP connect host (self-hosted Steel) |
132
+ | `SILICON_BROWSER_HOME` | State directory (default `~/.silicon-browser`) |
133
+
134
+ ## License
135
+
136
+ Apache-2.0
@@ -0,0 +1,35 @@
1
+ [project]
2
+ name = "silicon-browser"
3
+ version = "0.1.0"
4
+ description = "Terminal-native browser CLI for AI agents, powered by Steel Browser."
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ license = "Apache-2.0"
8
+ license-files = ["LICENSE"]
9
+ keywords = ["browser", "automation", "steel", "cli", "ai-agents", "playwright"]
10
+ classifiers = [
11
+ "Environment :: Console",
12
+ "Intended Audience :: Developers",
13
+ "Programming Language :: Python :: 3",
14
+ "Topic :: Internet :: WWW/HTTP :: Browsers",
15
+ ]
16
+ urls = { Homepage = "https://github.com/saket1225/silicon-browser", Repository = "https://github.com/saket1225/silicon-browser" }
17
+ dependencies = [
18
+ "playwright>=1.60.0",
19
+ "python-dotenv>=1.2.2",
20
+ "rich>=15.0.0",
21
+ "steel-sdk>=0.17.0",
22
+ "typer>=0.26.5",
23
+ ]
24
+
25
+ [project.scripts]
26
+ silicon-browser = "silicon_browser.cli:run"
27
+
28
+ [build-system]
29
+ requires = ["uv_build>=0.9.28,<0.10.0"]
30
+ build-backend = "uv_build"
31
+
32
+ [dependency-groups]
33
+ dev = [
34
+ "pytest>=8.0.0",
35
+ ]
@@ -0,0 +1,3 @@
1
+ """Silicon Browser — terminal-native browser CLI for AI agents, powered by Steel."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,92 @@
1
+ """Playwright connection over Steel's remote CDP endpoint.
2
+
3
+ Every command opens a short-lived CDP connection to the (already running) Steel
4
+ browser, does its work, persists any state changes, and disconnects. Closing the
5
+ Playwright connection does **not** end the Steel session — that only happens on
6
+ an explicit ``close``/``release`` or when the session timeout elapses.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from contextlib import contextmanager
12
+ from dataclasses import dataclass
13
+ from typing import Iterator
14
+
15
+ from playwright.sync_api import Browser, BrowserContext, Page, sync_playwright
16
+
17
+ from .config import get_api_key, get_connect_url
18
+ from .state import SessionState
19
+
20
+ NAV_TIMEOUT_MS = 30_000
21
+ ACTION_TIMEOUT_MS = 15_000
22
+
23
+
24
+ class BrowserError(Exception):
25
+ """Raised when the remote browser cannot be reached or driven."""
26
+
27
+
28
+ @dataclass
29
+ class Connection:
30
+ browser: Browser
31
+ context: BrowserContext
32
+ page: Page
33
+ state: SessionState
34
+
35
+
36
+ def _cdp_url(state: SessionState) -> str:
37
+ key = get_api_key()
38
+ base = state.websocket_url
39
+ override = get_connect_url()
40
+ if override:
41
+ # Replace just the scheme+host for self-hosted Steel, keep the query.
42
+ from urllib.parse import urlparse, urlunparse
43
+
44
+ ws = urlparse(base)
45
+ ov = urlparse(override)
46
+ base = urlunparse((ov.scheme or ws.scheme, ov.netloc, ws.path,
47
+ ws.params, ws.query, ws.fragment))
48
+ sep = "&" if "?" in base else "?"
49
+ return f"{base}{sep}apiKey={key}"
50
+
51
+
52
+ def _active_page(context: BrowserContext, state: SessionState) -> Page:
53
+ pages = context.pages
54
+ if not pages:
55
+ return context.new_page()
56
+ idx = state.active_tab
57
+ if idx < 0 or idx >= len(pages):
58
+ idx = len(pages) - 1
59
+ state.active_tab = idx
60
+ return pages[idx]
61
+
62
+
63
+ @contextmanager
64
+ def connect(state: SessionState) -> Iterator[Connection]:
65
+ """Connect to the session's remote browser and yield the active page.
66
+
67
+ State is saved automatically on clean exit.
68
+ """
69
+ with sync_playwright() as p:
70
+ try:
71
+ browser = p.chromium.connect_over_cdp(_cdp_url(state))
72
+ except Exception as exc: # noqa: BLE001
73
+ raise BrowserError(
74
+ f"Could not connect to the Steel session ({state.session_id}). "
75
+ "It may have expired — run `silicon-browser open <url>` to start a "
76
+ f"new one.\n underlying error: {exc}"
77
+ ) from exc
78
+
79
+ contexts = browser.contexts
80
+ context = contexts[0] if contexts else browser.new_context()
81
+ # Fail loudly rather than hang forever on a stuck navigation/action.
82
+ context.set_default_navigation_timeout(NAV_TIMEOUT_MS)
83
+ context.set_default_timeout(ACTION_TIMEOUT_MS)
84
+ page = _active_page(context, state)
85
+ try:
86
+ yield Connection(browser=browser, context=context, page=page, state=state)
87
+ state.save()
88
+ finally:
89
+ try:
90
+ browser.close()
91
+ except Exception: # noqa: BLE001
92
+ pass