Skip to content

feat: add browser-scoped session client#93

Open
rgarcia wants to merge 9 commits intonextfrom
raf/browser-scoped-client
Open

feat: add browser-scoped session client#93
rgarcia wants to merge 9 commits intonextfrom
raf/browser-scoped-client

Conversation

@rgarcia
Copy link
Copy Markdown
Contributor

@rgarcia rgarcia commented Apr 13, 2026

Summary

  • add kernel.for_browser(...) and async_kernel.for_browser(...) to create browser-scoped clients from browser session responses
  • route browser subresource methods through the session base_url so callers stop repeating the browser id
  • expose raw HTTP through browser.request(...) and browser.stream(...) while keeping the internal /curl/raw transport path hidden
  • add focused tests for metro routing, JWT extraction, and browser-scoped raw HTTP behavior

Test plan

  • uv run python -m pytest tests/test_browser_scoped.py -o addopts= -q

Made with Cursor


Note

Medium Risk
Adds a new client surface (Kernel.for_browser) that rewrites request routing to per-session base_url and injects JWT/query params, which could impact request correctness and auth if mis-generated or mis-parsed.

Overview
Adds Kernel.for_browser(...) / AsyncKernel.for_browser(...) to create a browser-scoped client that calls browser session subresources (e.g. process, fs, computer, etc.) without requiring an explicit id, by injecting the session id and routing requests via the session’s base_url.

Introduces kernel.lib.browser_scoped with a session-local HTTP client that strips the /browsers/{id} prefix, plus request()/stream() helpers that proxy arbitrary HTTP via the internal /curl/raw endpoint while preventing user params from overriding reserved jwt/url query keys.

Adds an AST-based generator (scripts/generate_browser_scoped.py) and committed generated_bindings.py for the bound resources, wires generation into scripts/lint, updates browser response docstrings for base_url, and adds targeted tests for routing, JWT extraction, and reserved-param behavior.

Reviewed by Cursor Bugbot for commit 8f1d506. Bugbot is set up for automated code reviews on this repo. Configure here.

Bind browser subresource calls to a browser session's base_url and expose raw HTTP through request and stream helpers so metro-routed access feels like normal httpx usage.

Made-with: Cursor
@firetiger-agent
Copy link
Copy Markdown

Firetiger deploy monitoring skipped

This PR didn't match the auto-monitor filter configured on your GitHub connection:

Any PR that changes the kernel API. Monitor changes to API endpoints (packages/api/cmd/api/) and Temporal workflows (packages/api/lib/temporal) in the kernel repo

Reason: PR adds browser-scoped session client functionality but does not appear to modify API endpoints (packages/api/cmd/api/) or Temporal workflows (packages/api/lib/temporal) as specified in the filter.

To monitor this PR anyway, reply with @firetiger monitor this.

Prevent browser-scoped raw HTTP helpers from letting user params override internal routing query keys, and clean up wording around browser session base_url routing.

Made-with: Cursor
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issue. You can view the agent here.

Reviewed by Cursor Bugbot for commit cfa07c9. Configure here.

rgarcia added 7 commits April 13, 2026 14:19
Keep the browser-scoped request helpers aligned with repo linting and reserve internal raw-request query keys without exposing implementation details.

Made-with: Cursor
Keep the browser-scoped test file aligned with the repo lint configuration so the follow-up typing fixes pass CI.

Made-with: Cursor
Tighten browser-scoped helper typing and test casts so the Python SDK passes the repository's lint and pyright checks cleanly.

Made-with: Cursor
Replace the handwritten Python browser-scoped façade with deterministic generated bindings from the browser resource graph, and enforce regeneration during lint.

Made-with: Cursor
Keep the browser-scoped Python generator compatible with the repo lint pipeline by suppressing strict pyright diagnostics that are not meaningful for the AST-walking build script.

Made-with: Cursor
Keep the Python generator and generated browser-scoped façade aligned with pyright and mypy so the deterministic regeneration path passes the repo lint pipeline.

Made-with: Cursor
Sort the generator script imports and keep the deterministic browser-scoped generation path aligned with the repo lint pipeline.

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant