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

@parcha/agentrun-web

v0.1.0-beta.354

Published

Web search and web fetch for agents: providers asked in an order given as data, a breaker per provider, a per-run page cache read in parts, and a direct fetch through an injected public-host guard.

Readme

@parcha/agentrun-web

Web search and page fetch for AI agents, the ones behind AgentRun's web_search and web_fetch tools. You list the providers each tool asks, in order, and each call returns what the model reads with a receipt of who answered and what it cost.

Install

npm install @parcha/agentrun-web @parcha/pi-browser

It needs Node 24.22.3 or later. @parcha/pi-browser provides the guard that keeps fetches on public hosts (the guard).

A first search

No key needed: firecrawl-keyless and exa-keyless are those services' free use.

import { createWeb, searchText } from "@parcha/agentrun-web";
import { publicCheck, publicFetch, readPage } from "@parcha/pi-browser";

const web = createWeb({
  order: { search: ["firecrawl-keyless", "exa-keyless"], fetch: ["firecrawl-keyless", "direct"] },
  guard: { fetch: publicFetch, check: publicCheck, html: readPage },
});

const { answer, receipt } = await web.search({
  objective: "Where is Widgets, Inc. registered?",
  queries: ["widgets inc delaware", "widgets inc incorporation"],
  n: 5,
});
console.log(answer.results); // [{ url, title, snippet }, ...]
const forModel = searchText(answer); // what the model reads: the results, and a line asking it to cite the URLs it uses
  • objective: what you want found out, in a sentence. Required.
  • queries: up to 5 short keyword queries. With none, the objective is searched as written.
  • n: how many results, 1 to 25 (10 by default; keyless Exa gives at most 8).

The providers are asked in order; one that fails, finds nothing or is held by its breaker passes the search on. When none answers, the search answers { error }. Only a call of the wrong shape throws: web.search("text") is a TypeError that names the right call.

A first fetch

import { createWeb, webFetchText } from "@parcha/agentrun-web";
import { publicCheck, publicFetch, readPage } from "@parcha/pi-browser";

const web = createWeb({
  order: { search: ["firecrawl-keyless", "exa-keyless"], fetch: ["firecrawl-keyless", "direct"] },
  guard: { fetch: publicFetch, check: publicCheck, html: readPage },
});

const { answer } = await web.fetch("https://example.org/", { part: { maxChars: 5_000 } });
console.log(answer.title, answer.text);
const forModel = webFetchText(answer); // what the model reads: the page, and where the next part starts if there is more
if (answer.truncated) await web.fetch("https://example.org/", { part: { offset: answer.next_offset } });

A fetch reads a page once and answers it in parts: 20,000 characters by default, 50,000 at most, from the page's first 1,000,000. A web keeps up to 8 pages it has read, so the next part of one comes from that copy. When no page could be read, answer.ok is false and a fetch does not throw. answer.refused says why when the URL was refused before it was read (by the guard or by admit); answer.error says why for any other failure.

What a receipt tells you

Every call returns { answer, receipt }. The model reads the answer, as searchText(answer) or webFetchText(answer) makes it. The receipt is for you and your logs, and never holds a key. The first search above gives:

{
  "op": "search",
  "asked": "Where is Widgets, Inc. registered?",
  "queries": ["widgets inc delaware", "widgets inc incorporation"],
  "provider": "firecrawl-keyless",
  "tries": [{ "provider": "firecrawl-keyless", "outcome": "ok", "ms": 812 }],
  "classifier": "off",
  "wall": { "verdict": "unjudged" },
  "injection": "unjudged",
  "out": { "bytes": 1874, "chars": 1874 },
  "cost": { "usd": 0, "lines": [] }
}
  • op, asked, queries: the call: a search's objective and the queries sent, or a fetch's URL.
  • provider: whose answer this is, or null.
  • tries: each provider asked, in order: ok, empty (no results), error (with a typed failure) or held by its breaker. A search's tries say how long each took, in ms.
  • classifier: "off", or the judge's record: items in and kept, the model, tokens, cost and each item's score.
  • wall, injection: the page guard's verdicts, "unjudged" unless judge.pageGuard is on.
  • out: the size of what the model reads.
  • cost: the total in USD and one line per paid request sent. Keyless calls cost $0.
  • When they apply: cache: "hit" (a fetch from a page already read) and unsifted (with a judge, what the model would have read without it).

Providers and keys

| Provider | Search | Fetch | Key | |---|---|---|---| | firecrawl-keyless | yes | yes | none | | exa-keyless | yes | no | none | | parallel | yes | yes | PARALLEL_API_KEY | | exa | yes | yes | EXA_API_KEY | | firecrawl | yes | yes | FIRECRAWL_API_KEY | | native | yes | no | none: your model provider's own search, passed as native | | direct | no | yes | none: the page fetched through your guard |

The keyless ones are rate-limited and have daily limits. The package reads no environment variables: pass each key in keys. The names above are the variables AgentRun's server reads them from. A keyed provider with no key answers that the run holds none, and sends nothing.

import { createWeb } from "@parcha/agentrun-web";
import { publicCheck, publicFetch, readPage } from "@parcha/pi-browser";

const web = createWeb({
  order: { search: ["parallel", "exa-keyless"], fetch: ["parallel", "direct"] },
  keys: { parallel: process.env.PARALLEL_API_KEY },
  guard: { fetch: publicFetch, check: publicCheck, html: readPage },
});

const { receipt } = await web.search({ objective: "Where is Widgets, Inc. registered?" });
console.log(receipt.cost); // { usd: 0.001, lines: [{ name: "Parallel's search", by: "parallel", usd: 0.001, basis: "..." }] }

A keyed request is paid. To cap what a web spends, pass pay(fee, send): hold up to fee.usd and call send(heldUsd), or throw PaidRefused and the request is not sent. send answers what the request came to (a Sent: { billed, cost? }, or { unbilled: why }) and pay answers what the cap booked (a Charge); settledCharge and settledUsd, in @parcha/agentrun-web/server, are the rule a cap settles by. A 4xx other than a 408 is not billed, and its receipt line says so at $0: not billed (Parallel answered 400, which it does not bill). A request whose hold buys none is not sent: the call says the run's cap had too little left, and the next provider is asked. Each provider's settings, parameters and prices are in docs/providers.md.

The guard: public hosts only

The package holds no HTTP client that could reach a private address. A page fetched directly goes through guard.fetch, and a URL goes to a provider, keyed or keyless, only once guard.check passes it. pi-browser's guard refuses private, loopback, link-local and intranet addresses, ports other than 80 and 443, schemes other than http and https, and a redirect to any of those. With no guard, a fetch sends no URL anywhere.

import { createWeb } from "@parcha/agentrun-web";
import { publicCheck, publicFetch, readPage } from "@parcha/pi-browser";

const web = createWeb({
  order: { search: ["firecrawl-keyless", "exa-keyless"], fetch: ["firecrawl-keyless", "direct"] },
  guard: { fetch: publicFetch, check: publicCheck, html: readPage },
});

const { answer } = await web.fetch("http://[fd00:ec2::254]/latest/meta-data/");
console.log(answer.ok, answer.refused); // false "refused: fd00:ec2::254 is not a public host"

Any guard of the same shape works, as long as guard.check refuses every URL guard.fetch would. To limit reads per host or honour robots.txt, pass admit(host, url): it returns words to refuse a read, or nothing. A redirect to another host is admitted before it is followed, which needs pi-browser 0.1.0-beta.118 or later.

Bounds and breakers

  • A search has one deadline for all the providers it asks: 60 s (bounds.searchMs). One that fails leaves the next what is left of it. Keyless Firecrawl's own bound inside it is 30 s (bounds.firecrawlMs).
  • The guard's check of a URL and a judge's step each have 30 s (bounds.checkMs, bounds.decideMs); admit has 10 s (bounds.admitMs).
  • Pass signal in a call's options to stop it early.
  • An objective is cut at 1,000 characters and a query at 200. A page fetched directly is read to its first 5 MB.

Each provider has a breaker in a web for each tool, and one for its key across both. A rate limit holds the provider for the wait it names (60 s when it names none); a spent quota holds it until the reset it names, or for the life of the web. A held provider is skipped (held in tries) and the next one asked. When all are held, the search answers how long to wait, or that search is unavailable. web.destinations() lists each tool's providers and what holds each now. To carry holds from one web to the next, keep each hold that onHold(hold) is given and pass them back as holds.

Ranking and finding with Jev

A judge scores what the providers return. AgentRun ships Jev, from @parcha/agentrun-jev with a TypeSafe key. Install it beside the package: npm install @parcha/agentrun-jev.

import { createWeb, jevWebDecider } from "@parcha/agentrun-web";
import { JEV_PUBLISHED_PRICING, jevProvider } from "@parcha/agentrun-jev";
import { publicCheck, publicFetch, readPage } from "@parcha/pi-browser";

const jev = jevWebDecider({ key: process.env.TYPESAFE_API_KEY, jevProvider, price: JEV_PUBLISHED_PRICING });
const web = createWeb({
  order: { search: ["firecrawl-keyless", "exa-keyless"], fetch: ["firecrawl-keyless", "direct"] },
  guard: { fetch: publicFetch, check: publicCheck, html: readPage },
  judge: { decider: jev.decider },
});

const search = await web.search({ objective: "Where is Widgets, Inc. registered?", queries: ["widgets inc delaware"] });
console.log(search.answer.results); // [{ url, title, snippet, relevance: 0.95 }, ...], most relevant first
const page = await web.fetch("https://example.org/", { find: "the company's registration number", fallback: { maxChars: 20_000 } });
console.log(page.answer.found); // [{ offset, relevance, text }, ...], up to 8 chunks in page order

judge takes:

  • decider: what scores; or a function asked at each call for one (none: that call is not scored).
  • rank (the default): most relevant first, each result with its relevance (0 to 1), none left out. rank.trim: { keepWhole, chars, pick: "start" | "best" } cuts each snippet past the first keepWhole to chars.
  • drop: true, instead of rank: results scored unlikely are left out; the rest keep the provider's order.
  • find.chunks: how many chunks a find returns (8).
  • pageGuard: true: asks once per page whether it is a wall (a login, a paywall, a captcha) or holds instructions aimed at an AI reader, and warns the model. No page is dropped.

A fetch takes find or part, never both. If Jev fails or runs out of time, the results come back unsifted, the answer's sift line says why, and a find answers its fallback part. jevWebDecider sends the pinned model JEV_MODEL.

Entries

| Import | Holds | |---|---| | @parcha/agentrun-web | createWeb and every type it takes and gives, searchText, webFetchText, jevWebDecider, JEV_MODEL, breakers, searchBreaker, PaidRefused, WALLS, and the tools' descriptions and JSON Schemas (WEB_SEARCH_*, WEB_FETCH_*). | | @parcha/agentrun-web/server | What AgentRun's server builds on: prices, bounds, provider clients and the parts createWeb is made of. A caller of createWeb needs none of it. | | @parcha/agentrun-web/text-urls | The link finder (linksOf) for text that holds URLs, which AgentRun's console uses. |

Each WebConfig field is documented where it is declared, in dist/web.d.ts.