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

onchain-agent-search

v0.3.3

Published

Isomorphic search client

Readme

@agent-infra/search

An isomorphic search client that unifies multiple search providers into a single API.

Features

  • Multi-provider support: Use Browser Search, Bing Search, or Tavily with the same interface
  • Unified API: Consistent response format across all providers
  • Configurable: Customize search parameters for each provider
  • Type-safe: Full TypeScript support with comprehensive type definitions

Installation

npm install @agent-infra/search
# or
yarn add @agent-infra/search
# or
pnpm add @agent-infra/search

Usage

Basic Search

import { Search, SearchProvider } from '@agent-infra/search';

// Create a search client with your preferred provider
const client = new SearchClient({
  provider: SearchProvider.BingSearch,
  providerConfig: {
    apiKey: 'YOUR_API_KEY',
  },
});

// Perform a search
const results = await client.search({
  query: 'climate change',
  limit: 5,
});

console.log(results);

Switch Between Providers

import { Search, SearchProvider } from '@agent-infra/search';

// Create search instances for different providers
const bingSearch = new SearchClient({
  provider: SearchProvider.BingSearch,
  providerConfig: {
    apiKey: 'YOUR_BING_API_KEY',
  },
});

const tavilySearch = new SearchClient({
  provider: SearchProvider.Tavily,
  providerConfig: {
    apiKey: 'YOUR_TAVILY_API_KEY',
  },
});

// Use browser search in browser environments
const browserSearch = new SearchClient({
  provider: SearchProvider.BrowserSearch,
  providerConfig: {
    // ... browser search config
  },
});

// Use the appropriate client based on your needs
const results = await bingSearch.search({
  query: 'UI-TARS',
});

With Environment Variables

// Set in your `.zshrc` or `.bash_profile`:
// BING_SEARCH_API_KEY=your-api-key
// BING_SEARCH_API_BASE_URL=your-api-base-url

import { Search, SearchProvider } from '@agent-infra/search';

const client = new SearchClient({
  provider: SearchProvider.BingSearch,
});

const results = await client.search({
  query: 'UI-TARS',
});

API Reference

Search Client

constructor(config: SearchConfig)

Configuration options:

interface SearchConfig {
  provider: SearchProvider;
  providerConfig?: {
    [key: string]: any;
  };
  logger?: Logger;
}

enum SearchProvider {
  BingSearch = 'bing',
  Tavily = 'tavily',
  BrowserSearch = 'browser',
}

search Method

  async search(
    options: CommonSearchOptions,
    originalOptions?: Partial<SearchProviderSearchOptionsMap[T]>,
  ): Promise<SearchResult>

Common search options:

export interface CommonSearchOptions {
  /**
   * Search query
   */
  query: string;
  /**
   * Max search count
   */
  count?: number;
}

Response Type

export type PageResult = {
  title: string;
  url: string;
  content: string;
};

export interface SearchResult {
  pages: PageResult[];
}

Provider-Specific Options

Bing Search

const client = new SearchClient({
  provider: SearchProvider.BingSearch,
  providerConfig: {
    apiKey: 'YOUR_API_KEY',
    mkt: 'en-US',
  },
});

const results = await client.search(
  {
    query: 'UI-TARS',
    count: 5,
  },
  // Pass Bing-specific parameter via 2nd parameter
  {
    mkt: 'zh-CN', // Market code
  },
);

Tavily

const search = new SearchClient({
  provider: SearchProvider.Tavily,
  providerConfig: {
    apiKey: 'YOUR_API_KEY',
  },
});

const results = await search.search(
  {
    query: 'latest research papers',
  },
  // Tavily-specific parameters
  {
    searchDepth: 'advanced',
    includeRawContent: true,
  },
);

Browser Search

// Only available in browser environments
const client = new SearchClient({
  provider: SearchProvider.BrowserSearch,
});

const results = await client.search(
  {
    query: 'UI-TARS',
    count: 5,
  },
  // BrowserSearch-specific parameters
  {
    concurrency: 3,
  },
);

Examples

See examples.

License

Copyright (c) 2025 ByteDance, Inc. and its affiliates.

Licensed under the Apache License, Version 2.0.