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

@agent-sh/harness-websearch

v0.7.0

Published

WebSearch tool for AI agent harnesses — zero-config keyless web search (Mojeek/Marginalia/Wikipedia fallback chain) with optional Brave/Tavily/SearXNG backends, SSRF defense, declarative query controls, result-count cap, and a discriminated result surface

Downloads

162

Readme

@agent-sh/harness-websearch

Web search for AI agent harnesses — works with no API key and no setup. With nothing configured it queries a bundled keyless fallback chain (Mojeek → Marginalia → Wikipedia) and returns the first backend that has results. Optionally upgrade to Brave/Tavily (API key) or a self-hosted SearXNG for higher coverage — same tool, same output. Tool-layer SSRF defense, declarative provider-neutral query controls, a result-count cap, engine provenance, and a discriminated result surface.

Part of the @agent-sh/harness-* monorepo — see the top-level README for architectural context and the full tool surface. WebSearch finds URLs; webfetch reads them. They compose.

Install

npm install @agent-sh/harness-websearch

Requires Node ≥ 20.

Usage

Zero-config — keyless, just works:

import { websearch } from "@agent-sh/harness-websearch";

const session = {
  permissions: { roots: [], sensitivePatterns: [], unsafeAllowSearchWithoutHook: true },
};

const r = await websearch({ query: "rust async runtime benchmarks", count: 5 }, session);
// r.meta.engine tells you which backend served the results (e.g. "mojeek").

Upgrade to a reliable keyed provider, or a self-hosted SearXNG:

// Brave (recommended; free tier at api-dashboard.search.brave.com):
const braveSession = { ...session, braveApiKey: process.env.BRAVE_API_KEY };

// Self-hosted SearXNG (loopback opt-in since it's usually on localhost):
const searxngSession = { ...session, searxngUrl: "http://127.0.0.1:8888", allowLoopback: true };

// An explicit backend is exclusive by default; opt into the keyless tail as a backstop:
const withFallback = { ...braveSession, fallbackToKeyless: true };

Notes:

  • disableMojeek: true drops the Mojeek scrape engine (its robots.txt disallows /search; the documented Marginalia/Wikipedia APIs remain).
  • snippetCap tunes the per-result snippet length (default 240 chars; clamped 80–600) to trade detail for tokens.
  • When the leading backend returns fewer than count, the tool gathers and merges results across the chain (de-duplicating the same page by normalized URL) until the quota is met; a backend that already satisfies count short-circuits. Merged results are ranked by Reciprocal Rank Fusion + engine weights (a page multiple engines agree on is boosted; a niche/encyclopedic backstop won't outrank broad web), name the contributing engines in the header, and tag each result with its source.
  • Output is compact ranked text: a WEB "query" · engine (class) · N results header then numbered entries; the engine's coverage class (general web / indie/small-web index / encyclopedic) and per-result age (when the backend provides it) are shown so the model can judge source quality and freshness. Parse meta/results, not the output string.
  • Zero hits is a normal kind: "empty" result, not an error.

Contract

The full contract — input shape, output discriminated-union, error codes, permission model, and acceptance tests — lives in agent-knowledge/design/websearch.md. Changes to this package must stay in sync with that spec.

License

MIT © Avi Fenesh