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

browse-agent-sdk

v0.0.2

Published

SDK for controlling Chrome browser via Browse Agent extension

Readme

browse-agent-sdk

Node.js SDK for controlling Chrome through the Browse Agent companion extension.

browse-agent-sdk runs a local WebSocket server in your Node.js app. The extension connects to it, authenticates (with or without a shared secret), and executes browser commands.

Installation

npm install browse-agent-sdk

Before You Start

This SDK requires the Browse Agent Chrome extension.

  1. Install/load the Browse Agent extension in Chrome.
  2. Open the extension popup and configure:
  • WebSocket URL: ws://127.0.0.1:9315
  • Shared Secret: optional. If set, it must match your SDK code.

Without the extension connection, SDK commands will not execute.

Quick Start

import { BrowserAgent } from 'browse-agent-sdk';

const agent = new BrowserAgent({
  secret: 'replace-with-your-shared-secret',
  port: 9315,
});

try {
  await agent.start();
  await agent.waitForConnection(60000);

  const nav = await agent.navigate('https://example.com');
  const title = await agent.evaluate('document.title', nav.tabId);
  console.log('Page title:', title.result);
} finally {
  await agent.stop();
}

Common Flow

const nav = await agent.navigate('https://example.com');

const content = await agent.getContent({ tabId: nav.tabId, format: 'text' });
console.log(content.content.slice(0, 200));

await agent.injectCSS('body { outline: 4px solid #00bcd4; }', nav.tabId);

const screenshot = await agent.screenshotVisible({ tabId: nav.tabId, format: 'png' });
console.log('base64 length:', screenshot.data.length);

BrowserAgent Options

| Option | Type | Default | Description | |---|---|---|---| | secret | string | '' | Optional shared HMAC secret used by SDK and extension | | port | number | 9315 | WebSocket server port | | host | string | 127.0.0.1 | WebSocket server host | | timeout | number | 30000 | Default command timeout (ms) |

API Reference

Lifecycle

  • start() - Start the SDK WebSocket server
  • waitForConnection(timeout?) - Wait until extension authenticates
  • stop() - Stop server and close all connections
  • isConnected - Connection/authentication state
  • onDisconnected(cb) - Register disconnect callback

Navigation

  • navigate(url, options?)
  • getContent(options?)
  • listTabs()
  • activateTab(tabId)
  • closeTab(tabId)

Page Execution

  • injectScript(code, tabId?)
  • injectCSS(code, tabId?)
  • evaluate(expression, tabId?)
  • getDOM(selector, options?)

Screenshots

  • screenshotFullPage(options?)
  • screenshotVisible(options?)
  • screenshotArea(clip, options?)
  • screenshot(options)

Low-level

  • sendCommand(command, timeout?) - Send a raw protocol command to the extension

Troubleshooting

  • waitForConnection() timeout:
  • Confirm extension is installed and enabled.
  • Confirm WebSocket URL matches your SDK config.
  • If using a shared secret, confirm extension and SDK values match.
  • Confirm your app is running and has called await agent.start().
  • Commands fail after connection:
  • Confirm the target tab still exists.
  • Use listTabs() to inspect available tabs and IDs.

Security Notes

  • The default host is localhost (127.0.0.1).
  • SDK and extension can authenticate without a secret, or with HMAC shared-secret mode.
  • If using shared-secret mode, use a strong secret and avoid committing it to source control.