browser-handoff 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.
Files changed (28) hide show
  1. browser_handoff-0.1.0/.gitignore +220 -0
  2. browser_handoff-0.1.0/LICENSE +21 -0
  3. browser_handoff-0.1.0/PKG-INFO +233 -0
  4. browser_handoff-0.1.0/README.md +201 -0
  5. browser_handoff-0.1.0/browser_handoff/__init__.py +46 -0
  6. browser_handoff-0.1.0/browser_handoff/config/__init__.py +10 -0
  7. browser_handoff-0.1.0/browser_handoff/config/loader.py +102 -0
  8. browser_handoff-0.1.0/browser_handoff/detection/__init__.py +172 -0
  9. browser_handoff-0.1.0/browser_handoff/detection/base.py +70 -0
  10. browser_handoff-0.1.0/browser_handoff/detection/combinators.py +193 -0
  11. browser_handoff-0.1.0/browser_handoff/detection/content.py +142 -0
  12. browser_handoff-0.1.0/browser_handoff/detection/element.py +248 -0
  13. browser_handoff-0.1.0/browser_handoff/detection/llm.py +176 -0
  14. browser_handoff-0.1.0/browser_handoff/detection/url.py +183 -0
  15. browser_handoff-0.1.0/browser_handoff/handoff.py +376 -0
  16. browser_handoff-0.1.0/browser_handoff/notifiers/__init__.py +44 -0
  17. browser_handoff-0.1.0/browser_handoff/notifiers/base.py +50 -0
  18. browser_handoff-0.1.0/browser_handoff/notifiers/discord.py +165 -0
  19. browser_handoff-0.1.0/browser_handoff/notifiers/email.py +148 -0
  20. browser_handoff-0.1.0/browser_handoff/notifiers/slack.py +136 -0
  21. browser_handoff-0.1.0/browser_handoff/scenario.py +47 -0
  22. browser_handoff-0.1.0/browser_handoff/server/__init__.py +12 -0
  23. browser_handoff-0.1.0/browser_handoff/server/config.py +67 -0
  24. browser_handoff-0.1.0/browser_handoff/server/session.py +44 -0
  25. browser_handoff-0.1.0/browser_handoff/server/streaming.py +552 -0
  26. browser_handoff-0.1.0/browser_handoff/templates/intervention.html +410 -0
  27. browser_handoff-0.1.0/browser_handoff/templates/notification.jinja +7 -0
  28. browser_handoff-0.1.0/pyproject.toml +74 -0
@@ -0,0 +1,220 @@
1
+ .claude
2
+
3
+ # Byte-compiled / optimized / DLL files
4
+ __pycache__/
5
+ *.py[codz]
6
+ *$py.class
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ build/
14
+ develop-eggs/
15
+ dist/
16
+ downloads/
17
+ eggs/
18
+ .eggs/
19
+ lib/
20
+ lib64/
21
+ parts/
22
+ sdist/
23
+ var/
24
+ wheels/
25
+ share/python-wheels/
26
+ *.egg-info/
27
+ .installed.cfg
28
+ *.egg
29
+ MANIFEST
30
+
31
+ # PyInstaller
32
+ # Usually these files are written by a python script from a template
33
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
34
+ *.manifest
35
+ *.spec
36
+
37
+ # Installer logs
38
+ pip-log.txt
39
+ pip-delete-this-directory.txt
40
+
41
+ # Unit test / coverage reports
42
+ htmlcov/
43
+ .tox/
44
+ .nox/
45
+ .coverage
46
+ .coverage.*
47
+ .cache
48
+ nosetests.xml
49
+ coverage.xml
50
+ *.cover
51
+ *.py.cover
52
+ .hypothesis/
53
+ .pytest_cache/
54
+ cover/
55
+
56
+ # Translations
57
+ *.mo
58
+ *.pot
59
+
60
+ # Django stuff:
61
+ *.log
62
+ local_settings.py
63
+ db.sqlite3
64
+ db.sqlite3-journal
65
+
66
+ # Flask stuff:
67
+ instance/
68
+ .webassets-cache
69
+
70
+ # Scrapy stuff:
71
+ .scrapy
72
+
73
+ # Sphinx documentation
74
+ docs/_build/
75
+
76
+ # PyBuilder
77
+ .pybuilder/
78
+ target/
79
+
80
+ # Jupyter Notebook
81
+ .ipynb_checkpoints
82
+
83
+ # IPython
84
+ profile_default/
85
+ ipython_config.py
86
+
87
+ # pyenv
88
+ # For a library or package, you might want to ignore these files since the code is
89
+ # intended to run in multiple environments; otherwise, check them in:
90
+ # .python-version
91
+
92
+ # pipenv
93
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
95
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
96
+ # install all needed dependencies.
97
+ # Pipfile.lock
98
+
99
+ # UV
100
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
101
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
102
+ # commonly ignored for libraries.
103
+ # uv.lock
104
+
105
+ # poetry
106
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
107
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
108
+ # commonly ignored for libraries.
109
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
110
+ # poetry.lock
111
+ # poetry.toml
112
+
113
+ # pdm
114
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
115
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
116
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
117
+ # pdm.lock
118
+ # pdm.toml
119
+ .pdm-python
120
+ .pdm-build/
121
+
122
+ # pixi
123
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
124
+ # pixi.lock
125
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
126
+ # in the .venv directory. It is recommended not to include this directory in version control.
127
+ .pixi
128
+
129
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
130
+ __pypackages__/
131
+
132
+ # Celery stuff
133
+ celerybeat-schedule
134
+ celerybeat.pid
135
+
136
+ # Redis
137
+ *.rdb
138
+ *.aof
139
+ *.pid
140
+
141
+ # RabbitMQ
142
+ mnesia/
143
+ rabbitmq/
144
+ rabbitmq-data/
145
+
146
+ # ActiveMQ
147
+ activemq-data/
148
+
149
+ # SageMath parsed files
150
+ *.sage.py
151
+
152
+ # Environments
153
+ .env
154
+ .envrc
155
+ .venv
156
+ env/
157
+ venv/
158
+ ENV/
159
+ env.bak/
160
+ venv.bak/
161
+
162
+ # Spyder project settings
163
+ .spyderproject
164
+ .spyproject
165
+
166
+ # Rope project settings
167
+ .ropeproject
168
+
169
+ # mkdocs documentation
170
+ /site
171
+
172
+ # mypy
173
+ .mypy_cache/
174
+ .dmypy.json
175
+ dmypy.json
176
+
177
+ # Pyre type checker
178
+ .pyre/
179
+
180
+ # pytype static type analyzer
181
+ .pytype/
182
+
183
+ # Cython debug symbols
184
+ cython_debug/
185
+
186
+ # PyCharm
187
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
188
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
189
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
190
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
191
+ # .idea/
192
+
193
+ # Abstra
194
+ # Abstra is an AI-powered process automation framework.
195
+ # Ignore directories containing user credentials, local state, and settings.
196
+ # Learn more at https://abstra.io/docs
197
+ .abstra/
198
+
199
+ # Visual Studio Code
200
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
201
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
202
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
203
+ # you could uncomment the following to ignore the entire vscode folder
204
+ # .vscode/
205
+ # Temporary file for partial code execution
206
+ tempCodeRunnerFile.py
207
+
208
+ # Ruff stuff:
209
+ .ruff_cache/
210
+
211
+ # PyPI configuration file
212
+ .pypirc
213
+
214
+ # Marimo
215
+ marimo/_static/
216
+ marimo/_lsp/
217
+ __marimo__/
218
+
219
+ # Streamlit
220
+ .streamlit/secrets.toml
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 synacktra
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,233 @@
1
+ Metadata-Version: 2.4
2
+ Name: browser-handoff
3
+ Version: 0.1.0
4
+ Summary: Pause Playwright automation, hand the browser to a human, resume when they're done.
5
+ Project-URL: Homepage, https://github.com/synacktraa/browser-handoff
6
+ Project-URL: Repository, https://github.com/synacktraa/browser-handoff
7
+ Project-URL: Issues, https://github.com/synacktraa/browser-handoff/issues
8
+ Author-email: Harsh Verma <synacktra.work@gmail.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: automation,browser,handoff,human-in-the-loop,intervention,playwright,streaming
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Framework :: AsyncIO
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Internet :: WWW/HTTP :: Browsers
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Topic :: Software Development :: Testing
23
+ Requires-Python: >=3.12
24
+ Requires-Dist: fastapi>=0.115
25
+ Requires-Dist: jinja2>=3.1
26
+ Requires-Dist: playwright>=1.40
27
+ Requires-Dist: pyyaml>=6.0
28
+ Requires-Dist: uvicorn[standard]>=0.32
29
+ Provides-Extra: llm
30
+ Requires-Dist: litellm>=1.0; extra == 'llm'
31
+ Description-Content-Type: text/markdown
32
+
33
+ # browser-handoff
34
+
35
+ Pause your browser automation, hand the page to a human, resume when they're done.
36
+
37
+ When automation hits something only a human should do — login, 2FA, OAuth consent, payment, identity check — `browser-handoff` streams the live browser to an operator over the web, waits for them to finish, then gives control back to your script.
38
+
39
+ ## Install
40
+
41
+ ```bash
42
+ pip install browser-handoff
43
+ ```
44
+
45
+ LLM-based detection (optional): `pip install browser-handoff[llm]`
46
+
47
+ ## 30-second example
48
+
49
+ ```python
50
+ from playwright.async_api import async_playwright
51
+ from browser_handoff import Handoff, Scenario
52
+ from browser_handoff.detection import Detection
53
+
54
+ handoff = Handoff(
55
+ scenarios=[
56
+ Scenario(
57
+ name="login",
58
+ trigger=Detection.url(path_contains=["/login"]),
59
+ complete=Detection.url(path_contains=["/dashboard"]),
60
+ ),
61
+ ],
62
+ )
63
+
64
+ async with async_playwright() as pw:
65
+ browser = await pw.chromium.launch(headless=False)
66
+ page = await browser.new_page()
67
+ await page.goto("https://example.com/start")
68
+
69
+ result = await handoff.run(page, timeout=30)
70
+ if result.was_blocked and not result.timed_out:
71
+ print(f"Human completed: {result.scenario_name}")
72
+
73
+ # Continue automation
74
+ await page.click("#continue")
75
+ ```
76
+
77
+ ## How it works
78
+
79
+ A `Scenario` is a pair: a `trigger` that says "stop, a human is needed" and a `complete` that says "OK, they're done."
80
+
81
+ `handoff.run(page, timeout=...)` watches the page for any scenario's trigger. If none fires within `timeout` seconds, it returns `HandoffResult(was_blocked=False)` and your script keeps going. If one fires, it starts a local streaming server, surfaces the URL (printed to logs and pushed to your notifiers), and waits until the matching `complete` condition matches — or until `server.completion_timeout` elapses, in which case the result has `timed_out=True`. `handoff.run` never raises on completion timeout; check the result.
82
+
83
+ ## Scope: what this is *not*
84
+
85
+ `browser-handoff` is for flows gated by **credentials or session state** — login pages, 2FA prompts, OAuth consent screens, payment forms, identity verification, T&C acceptance.
86
+
87
+ It is **not** an anti-bot bypass. Sites that fingerprint Playwright/CDP sessions as automation will keep refusing the flow even after a human solves a CAPTCHA, Cloudflare Turnstile, or similar challenge — the session itself is flagged, not the response. If that's your problem, you need an anti-detection browser, not a handoff tool.
88
+
89
+ ## Detection
90
+
91
+ `Detection` is the factory for conditions:
92
+
93
+ ```python
94
+ Detection.url(host_equals=["accounts.google.com"], path_contains=["/oauth"])
95
+ Detection.element(present=["input[type=password]"], visible=[".consent-modal"], missing=[".user-menu"])
96
+ Detection.content(title_contains=["Sign In"], body_matches=[r"verify.*you"])
97
+ Detection.llm(model="anthropic/claude-sonnet-4-5", condition="Login form is visible")
98
+ ```
99
+
100
+ Combine them:
101
+
102
+ ```python
103
+ Detection.any([d1, d2]) # OR
104
+ Detection.all([d1, d2]) # AND
105
+ Detection.not_(d1) # NOT
106
+ ```
107
+
108
+ ## Notifications
109
+
110
+ Optional. Each notifier gets the stream URL when a handoff starts.
111
+
112
+ ```python
113
+ from browser_handoff.notifiers import DiscordNotifier, EmailNotifier, SlackNotifier
114
+
115
+ Handoff(
116
+ scenarios=[...],
117
+ notifiers=[
118
+ SlackNotifier(webhook_url="https://hooks.slack.com/..."),
119
+ DiscordNotifier(webhook_url="https://discord.com/api/webhooks/..."),
120
+ EmailNotifier(
121
+ smtp_host="smtp.gmail.com", smtp_port=587,
122
+ username="bot@x.com", password="...",
123
+ to=["ops@x.com"],
124
+ ),
125
+ ],
126
+ )
127
+ ```
128
+
129
+ ## Server
130
+
131
+ Defaults to `127.0.0.1:8080` (loopback only) with a 10-minute human-completion budget. Set `host="0.0.0.0"` to expose on the LAN — e.g. for phone access or tunnel forwarding.
132
+
133
+ ```python
134
+ from browser_handoff import ServerConfig
135
+
136
+ Handoff(
137
+ scenarios=[...],
138
+ server=ServerConfig(
139
+ host="127.0.0.1", # "0.0.0.0" to expose on LAN
140
+ port=8080,
141
+ public_base="https://my-tunnel.example.com", # what notifiers link to
142
+ completion_timeout=600, # max human wait (s)
143
+ jpeg_quality=75,
144
+ every_nth_frame=1,
145
+ ),
146
+ )
147
+ ```
148
+
149
+ ## Config files
150
+
151
+ JSON or YAML, with `${VAR}` interpolation:
152
+
153
+ <table>
154
+ <tr><th>JSON</th><th>YAML</th></tr>
155
+ <tr>
156
+ <td>
157
+
158
+ ```json
159
+ {
160
+ "scenarios": [{
161
+ "name": "login",
162
+ "trigger": {
163
+ "type": "any",
164
+ "conditions": [
165
+ { "type": "url",
166
+ "path_contains": ["/login"] },
167
+ { "type": "element",
168
+ "present": ["input[type=password]"] }
169
+ ]
170
+ },
171
+ "complete": {
172
+ "type": "not",
173
+ "condition": {
174
+ "type": "url",
175
+ "path_contains": ["/login"]
176
+ }
177
+ }
178
+ }],
179
+ "server": {
180
+ "port": 8080,
181
+ "public_base": "${HANDOFF_URL}"
182
+ },
183
+ "notifiers": [
184
+ { "type": "slack",
185
+ "webhook_url": "${SLACK_WEBHOOK}" }
186
+ ]
187
+ }
188
+ ```
189
+
190
+ </td>
191
+ <td>
192
+
193
+ ```yaml
194
+ scenarios:
195
+ - name: login
196
+ trigger:
197
+ type: any
198
+ conditions:
199
+ - type: url
200
+ path_contains: ["/login"]
201
+ - type: element
202
+ present: ["input[type=password]"]
203
+ complete:
204
+ type: not
205
+ condition:
206
+ type: url
207
+ path_contains: ["/login"]
208
+
209
+ server:
210
+ port: 8080
211
+ public_base: ${HANDOFF_URL}
212
+
213
+ notifiers:
214
+ - type: slack
215
+ webhook_url: ${SLACK_WEBHOOK}
216
+ ```
217
+
218
+ </td>
219
+ </tr>
220
+ </table>
221
+
222
+ ```python
223
+ handoff = Handoff.from_file("handoff.yaml")
224
+ # or: Handoff.from_json(s) / Handoff.from_yaml(s) / Handoff.from_dict(d)
225
+ ```
226
+
227
+ ## Examples
228
+
229
+ See [`examples/claude_oauth_login_handoff.py`](examples/claude_oauth_login_handoff.py) for a working Claude OAuth flow that pairs `browser-handoff` with [`ccauth`](https://github.com/synacktraa/ccauth).
230
+
231
+ ## License
232
+
233
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,201 @@
1
+ # browser-handoff
2
+
3
+ Pause your browser automation, hand the page to a human, resume when they're done.
4
+
5
+ When automation hits something only a human should do — login, 2FA, OAuth consent, payment, identity check — `browser-handoff` streams the live browser to an operator over the web, waits for them to finish, then gives control back to your script.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pip install browser-handoff
11
+ ```
12
+
13
+ LLM-based detection (optional): `pip install browser-handoff[llm]`
14
+
15
+ ## 30-second example
16
+
17
+ ```python
18
+ from playwright.async_api import async_playwright
19
+ from browser_handoff import Handoff, Scenario
20
+ from browser_handoff.detection import Detection
21
+
22
+ handoff = Handoff(
23
+ scenarios=[
24
+ Scenario(
25
+ name="login",
26
+ trigger=Detection.url(path_contains=["/login"]),
27
+ complete=Detection.url(path_contains=["/dashboard"]),
28
+ ),
29
+ ],
30
+ )
31
+
32
+ async with async_playwright() as pw:
33
+ browser = await pw.chromium.launch(headless=False)
34
+ page = await browser.new_page()
35
+ await page.goto("https://example.com/start")
36
+
37
+ result = await handoff.run(page, timeout=30)
38
+ if result.was_blocked and not result.timed_out:
39
+ print(f"Human completed: {result.scenario_name}")
40
+
41
+ # Continue automation
42
+ await page.click("#continue")
43
+ ```
44
+
45
+ ## How it works
46
+
47
+ A `Scenario` is a pair: a `trigger` that says "stop, a human is needed" and a `complete` that says "OK, they're done."
48
+
49
+ `handoff.run(page, timeout=...)` watches the page for any scenario's trigger. If none fires within `timeout` seconds, it returns `HandoffResult(was_blocked=False)` and your script keeps going. If one fires, it starts a local streaming server, surfaces the URL (printed to logs and pushed to your notifiers), and waits until the matching `complete` condition matches — or until `server.completion_timeout` elapses, in which case the result has `timed_out=True`. `handoff.run` never raises on completion timeout; check the result.
50
+
51
+ ## Scope: what this is *not*
52
+
53
+ `browser-handoff` is for flows gated by **credentials or session state** — login pages, 2FA prompts, OAuth consent screens, payment forms, identity verification, T&C acceptance.
54
+
55
+ It is **not** an anti-bot bypass. Sites that fingerprint Playwright/CDP sessions as automation will keep refusing the flow even after a human solves a CAPTCHA, Cloudflare Turnstile, or similar challenge — the session itself is flagged, not the response. If that's your problem, you need an anti-detection browser, not a handoff tool.
56
+
57
+ ## Detection
58
+
59
+ `Detection` is the factory for conditions:
60
+
61
+ ```python
62
+ Detection.url(host_equals=["accounts.google.com"], path_contains=["/oauth"])
63
+ Detection.element(present=["input[type=password]"], visible=[".consent-modal"], missing=[".user-menu"])
64
+ Detection.content(title_contains=["Sign In"], body_matches=[r"verify.*you"])
65
+ Detection.llm(model="anthropic/claude-sonnet-4-5", condition="Login form is visible")
66
+ ```
67
+
68
+ Combine them:
69
+
70
+ ```python
71
+ Detection.any([d1, d2]) # OR
72
+ Detection.all([d1, d2]) # AND
73
+ Detection.not_(d1) # NOT
74
+ ```
75
+
76
+ ## Notifications
77
+
78
+ Optional. Each notifier gets the stream URL when a handoff starts.
79
+
80
+ ```python
81
+ from browser_handoff.notifiers import DiscordNotifier, EmailNotifier, SlackNotifier
82
+
83
+ Handoff(
84
+ scenarios=[...],
85
+ notifiers=[
86
+ SlackNotifier(webhook_url="https://hooks.slack.com/..."),
87
+ DiscordNotifier(webhook_url="https://discord.com/api/webhooks/..."),
88
+ EmailNotifier(
89
+ smtp_host="smtp.gmail.com", smtp_port=587,
90
+ username="bot@x.com", password="...",
91
+ to=["ops@x.com"],
92
+ ),
93
+ ],
94
+ )
95
+ ```
96
+
97
+ ## Server
98
+
99
+ Defaults to `127.0.0.1:8080` (loopback only) with a 10-minute human-completion budget. Set `host="0.0.0.0"` to expose on the LAN — e.g. for phone access or tunnel forwarding.
100
+
101
+ ```python
102
+ from browser_handoff import ServerConfig
103
+
104
+ Handoff(
105
+ scenarios=[...],
106
+ server=ServerConfig(
107
+ host="127.0.0.1", # "0.0.0.0" to expose on LAN
108
+ port=8080,
109
+ public_base="https://my-tunnel.example.com", # what notifiers link to
110
+ completion_timeout=600, # max human wait (s)
111
+ jpeg_quality=75,
112
+ every_nth_frame=1,
113
+ ),
114
+ )
115
+ ```
116
+
117
+ ## Config files
118
+
119
+ JSON or YAML, with `${VAR}` interpolation:
120
+
121
+ <table>
122
+ <tr><th>JSON</th><th>YAML</th></tr>
123
+ <tr>
124
+ <td>
125
+
126
+ ```json
127
+ {
128
+ "scenarios": [{
129
+ "name": "login",
130
+ "trigger": {
131
+ "type": "any",
132
+ "conditions": [
133
+ { "type": "url",
134
+ "path_contains": ["/login"] },
135
+ { "type": "element",
136
+ "present": ["input[type=password]"] }
137
+ ]
138
+ },
139
+ "complete": {
140
+ "type": "not",
141
+ "condition": {
142
+ "type": "url",
143
+ "path_contains": ["/login"]
144
+ }
145
+ }
146
+ }],
147
+ "server": {
148
+ "port": 8080,
149
+ "public_base": "${HANDOFF_URL}"
150
+ },
151
+ "notifiers": [
152
+ { "type": "slack",
153
+ "webhook_url": "${SLACK_WEBHOOK}" }
154
+ ]
155
+ }
156
+ ```
157
+
158
+ </td>
159
+ <td>
160
+
161
+ ```yaml
162
+ scenarios:
163
+ - name: login
164
+ trigger:
165
+ type: any
166
+ conditions:
167
+ - type: url
168
+ path_contains: ["/login"]
169
+ - type: element
170
+ present: ["input[type=password]"]
171
+ complete:
172
+ type: not
173
+ condition:
174
+ type: url
175
+ path_contains: ["/login"]
176
+
177
+ server:
178
+ port: 8080
179
+ public_base: ${HANDOFF_URL}
180
+
181
+ notifiers:
182
+ - type: slack
183
+ webhook_url: ${SLACK_WEBHOOK}
184
+ ```
185
+
186
+ </td>
187
+ </tr>
188
+ </table>
189
+
190
+ ```python
191
+ handoff = Handoff.from_file("handoff.yaml")
192
+ # or: Handoff.from_json(s) / Handoff.from_yaml(s) / Handoff.from_dict(d)
193
+ ```
194
+
195
+ ## Examples
196
+
197
+ See [`examples/claude_oauth_login_handoff.py`](examples/claude_oauth_login_handoff.py) for a working Claude OAuth flow that pairs `browser-handoff` with [`ccauth`](https://github.com/synacktraa/ccauth).
198
+
199
+ ## License
200
+
201
+ MIT — see [LICENSE](LICENSE).