Skip to content

Commit dba503e

Browse files
committed
refactor: drop browser-scoped wrapper clients
Move browser raw HTTP and direct-to-VM routing onto the main browsers resource so the SDK uses the shared browser route cache instead of a generated wrapper layer. Made-with: Cursor
1 parent ca5d188 commit dba503e

12 files changed

Lines changed: 561 additions & 2863 deletions

File tree

examples/browser_scoped.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
"""Example: browser-scoped client for browser VM process exec and raw HTTP."""
1+
"""Example: direct-to-VM browser routing for process exec and raw HTTP."""
22

3-
from kernel import Kernel
3+
from kernel import BrowserRoutingConfig, Kernel
44

55

66
def main() -> None:
7-
with Kernel() as client:
7+
with Kernel(browser_routing=BrowserRoutingConfig(enabled=True, direct_to_vm_subresources=("process",))) as client:
88
browser = client.browsers.create(headless=True)
99
try:
10-
scoped = client.for_browser(browser)
10+
client.prime_browser_route_cache(browser)
1111

12-
scoped.process.exec(command="uname", args=["-a"])
12+
client.browsers.process.exec(browser.session_id, command="uname", args=["-a"])
1313

14-
response = scoped.request("GET", "https://example.com")
14+
response = client.browsers.request(browser.session_id, "GET", "https://example.com")
1515
print("status", response.status_code)
1616

17-
with scoped.stream("GET", "https://example.com") as streamed:
17+
with client.browsers.stream(browser.session_id, "GET", "https://example.com") as streamed:
1818
print("streamed-bytes", len(streamed.read()))
1919
finally:
2020
client.browsers.delete_by_id(browser.session_id)

0 commit comments

Comments
 (0)