Skip to content

Commit 3ae9dab

Browse files
committed
refactor: rename browser routing subresources config
Shorten the browser_routing allowlist field to subresources so the direct-to-VM configuration stays concise while keeping the same routing behavior. Made-with: Cursor
1 parent de0476f commit 3ae9dab

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

examples/browser_routing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
def main() -> None:
7-
with Kernel(browser_routing=BrowserRoutingConfig(enabled=True, direct_to_vm_subresources=("process",))) as client:
7+
with Kernel(browser_routing=BrowserRoutingConfig(enabled=True, subresources=("process",))) as client:
88
browser = client.browsers.create(headless=True)
99
try:
1010
client.browsers.process.exec(browser.session_id, command="uname", args=["-a"])

src/kernel/lib/browser_scoped/routing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class BrowserRoute:
2020
@dataclass
2121
class BrowserRoutingConfig:
2222
enabled: bool = False
23-
direct_to_vm_subresources: tuple[str, ...] = field(default_factory=tuple)
23+
subresources: tuple[str, ...] = field(default_factory=tuple)
2424

2525

2626
class BrowserRouteCache:
@@ -75,7 +75,7 @@ def rewrite_direct_vm_options(
7575
return options
7676

7777
session_id, subresource, suffix = match
78-
if subresource not in set(config.direct_to_vm_subresources):
78+
if subresource not in set(config.subresources):
7979
return options
8080

8181
route = cache.get(session_id)

tests/test_browser_routing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_routes_allowlisted_browser_subresources_directly_to_vm() -> None:
4646
with Kernel(
4747
base_url=base_url,
4848
api_key=api_key,
49-
browser_routing=BrowserRoutingConfig(enabled=True, direct_to_vm_subresources=("process",)),
49+
browser_routing=BrowserRoutingConfig(enabled=True, subresources=("process",)),
5050
_strict_response_validation=True,
5151
) as client:
5252
_cache_browser(client)
@@ -67,7 +67,7 @@ def test_skips_direct_vm_routing_outside_allowlist() -> None:
6767
with Kernel(
6868
base_url=base_url,
6969
api_key=api_key,
70-
browser_routing=BrowserRoutingConfig(enabled=True, direct_to_vm_subresources=("computer",)),
70+
browser_routing=BrowserRoutingConfig(enabled=True, subresources=("computer",)),
7171
_strict_response_validation=True,
7272
) as client:
7373
_cache_browser(client)

0 commit comments

Comments
 (0)