$ account browserbase
This is a proof-of-concept Next.js application that demonstrates a web-browsing AI agent. Users submit a natural language goal (e.g., 'What is NVIDIA stock price?'), and the system creates a Browserbase browser session, then uses an LLM (Claude via Anthropic) to plan and execute steps (navigate, click, extract) via Stagehand. The frontend displays the agent's reasoning steps and a live browser view. The code is tightly coupled to Browserbase and Stagehand SDKs, with the agent loop split between client-side orchestration (ChatFeed) and server-side API routes. It is a simple, functional demo but lacks tests, modularity, and is no longer maintained (moved to another repo).
Stagehand is a Python SDK for the Stagehand API, an AI-driven browser automation framework. The SDK provides sync and async clients (`Stagehand`, `AsyncStagehand`) that interact with remote or local browser sessions via natural language commands like `observe`, `act`, `extract`, and `execute`. It supports both cloud-based (via REST API) and local execution modes, the latter using a compiled SEA binary managed by `SeaServerManager`. The codebase is primarily auto-generated by Stainless from an OpenAPI spec, with hand-written custom modules for session binding, binary management, and local server orchestration. The architecture follows a resource-based client pattern: the main client holds resource objects (e.g., `sessions`) that expose typed methods returning Pydantic models. Request parameters are defined as `TypedDict` subclasses with camelCase aliases, and responses are deserialized into strongly-typed models. The SDK includes comprehensive error handling (hierarchy of `APIError` subclasses), configurable retries and timeouts, SSE streaming support, and Pydantic v1/v2 compatibility. External dependencies include `httpx` for HTTP, `pydantic` for models, and optional `aiohttp`, `playwright`, or `pydoll` for advanced browser control. Key entry points are the `Stagehand` and `AsyncStagehand` classes, which can be instantiated with an API key and base URL. Sessions are started via `client.sessions.start()`, then methods like `session.act()`, `session.extract()`, `session.observe()`, and `session.execute()` perform browser automation tasks. The `_custom/session.py` module wraps the generated resource to provide a bound session object with page-aware frame handling. The SDK also ships a `_sea` binary for local execution, packaged via custom Hatch build hooks.