npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@browserbasehq/tuna

v0.1.0

Published

JavaScript SDK for Stagehand driver.

Readme

Stagehand SDK Client (JavaScript)

TypeScript SDK for controlling the Stagehand extension through ModCDP.

Run

From the repository root:

pnpm install
pnpm --filter @browserbasehq/tuna example:basic

Or from this directory:

pnpm example:basic

For the CI smoke flow that exercises raw CDP, ModCDP, and GitHub summary output:

node --experimental-strip-types tests/e2e/basic_flow.ts

Usage

import { Browser, Locator, Page, StagehandClient } from "@browserbasehq/tuna";

const client = new StagehandClient({
  // Pass at most one launch source:
  // cdp_url: "http://127.0.0.1:9222",
  // cdp_url: "ws://127.0.0.1:9222/devtools/browser/<id>",
  // local_browser_launch_options: {
  //   executable_path: "/Applications/Chromium.app/Contents/MacOS/Chromium",
  // },
  // browserbase_session_create_params: {
  //   browserbase_api_key: process.env.BROWSERBASE_API_KEY,
  // },
});

await client.connect();

client.on("Target.targetInfoChanged", console.log);

console.log(await client.Browser.getVersion());
console.log(await client.Target.getTargets());
console.log(await client.Mod.evaluate({ expression: "chrome.runtime.id" }));

const browser: Browser = client.browser;
const page: Page = await browser.newPage({ url: "https://example.com" });
const page2: Page = await page.goto({ url: "https://browserbase.com" });
console.log(page2.url);
console.log(await browser.pages({ url: page2.url }));

const body: Locator = await page.locate({ css: "body" });
console.log(await body.info());

await client.close();

Launch Sources

connect() accepts exactly one effective launch source:

  • cdp_url: an existing browser CDP endpoint. http://... URLs are resolved through /json/version; ws://... and wss://... URLs are used directly.
  • local_browser_launch_options: launches local Chromium or Chrome Canary with CDP enabled. CHROME_PATH can provide the executable path. STAGEHAND_SDK_CDP_PORT fixes the debugging port for editor attach workflows.
  • browserbase_session_create_params.browserbase_api_key: asks ModCDP to create a Browserbase session. BROWSERBASE_EXTENSION_ID reuses an uploaded extension; otherwise the SDK rebuilds the extension output and ModCDP uploads/installs it.

If no launch source is passed, connect() reads .env/process.env; it uses BROWSERBASE_API_KEY when present, otherwise it launches local Chromium/Canary.

Extension Paths

The default extension directory is:

src/extension/.output/chrome-mv3

If that output does not exist, the SDK falls back to:

dist/extension/chrome-mv3

When the default .output/chrome-mv3 path is used and rebuild_extension !== false, the SDK runs the extension package build before connecting. The prepared extension manifest points at the deterministic ModCDP bootstrap service worker:

stagehand-modcdp/background.js

The original WXT service worker is moved to:

stagehand-main/background.js

The client trusts and waits for stagehand-modcdp/background.js with globalThis.__stagehand_modcdp_ready === true.

Routing

Default client routes:

{
  "Mod.*": "service_worker",
  "Custom.*": "service_worker",
  "Stagehand.*": "service_worker",
  "*.*": "service_worker",
}

Default extension service-worker routes:

{
  "Mod.*": "service_worker",
  "Custom.*": "service_worker",
  "Stagehand.*": "service_worker",
  "*.*": "loopback_cdp",
}

Stagehand SDK routes are fixed: Stagehand and ModCDP commands go through the extension service worker, and native CDP commands go from the service worker to loopback CDP.

Debugging

The checked-in VS Code tasks set:

STAGEHAND_DEBUG_WAIT_FOR_ENTER=1
STAGEHAND_SDK_CDP_PORT=9230

The smoke test at tests/e2e/basic_flow.ts prints [debug] Browser ready. Press Enter to continue. after the extension is connected, so DevTools can inspect chrome-extension://*/background.js before the flow continues.