pi-dent-web-search
A pi extension whose WebSearch tool searches the web through Exa, Perplexity, Brave, Google (Gemini grounding) or DuckDuckGo and returns ranked links and snippets
Package details
Install pi-dent-web-search from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-dent-web-search- Package
pi-dent-web-search- Version
0.1.3- Published
- Nov 28, 2026
- Downloads
- 592/mo · 592/wk
- Author
- dralban68
- License
- MIT
- Types
- extension
- Size
- 85.2 KB
- Dependencies
- 2 dependencies · 5 peers
Pi manifest JSON
{
"extensions": [
"./index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-dent-web-search
A pi extension that gives the agent one tool, WebSearch: a query in, ranked links and snippets
out. pi-dent bundles it; pi-dent-web-fetch's WebFetch reads the pages it finds.
Why
An agent needs a search engine, but each one needs its own key, costs differently and fails
differently. So the backend is a setting: Exa, Perplexity, Brave and Google, plus DuckDuckGo,
which needs no key. auto falls back from one backend to the next, so one rate-limited service
doesn't stop the search.
The tool returns links and snippets only: no answer written by a model, and no page fetching. The agent sees where each claim comes from and decides which pages to read. This also keeps each call cheap and its result short. Titles and snippets come from the open web, so the tool treats them as untrusted text: it strips their HTML and the invisible characters that can hide a prompt injection.
How it works
- Parameters:
query,count(the most results to return), and optionallybackend(a backend name orauto),site(one domain) andrecency(day,week,monthoryear). auto: tries each backend that has a key, inwebSearch.order(default Exa, Perplexity, Brave, Google, DuckDuckGo). The first with results wins, and the tool result lists the backends that failed or were skipped. A backend named inbackendgets no fallback: its failure is the tool error.- Google: searches through Gemini's search grounding, because Google's Custom Search JSON API is closed to new customers. The Gemini API can't restrict a search to a site, so the tool drops results from other domains afterwards.
- DuckDuckGo: has no API, so the tool reads its HTML results page. It works on a best-effort basis: DuckDuckGo's bot check can block a whole IP address for minutes.
- Results: only
httpandhttpsURLs are kept, deduplicated by URL without the fragment. - Limits: each backend call is bounded in time and in response size (web-search.md, requests and failures), and the result count is capped (web-search.md, order and count). API keys never appear in tool results, errors or notices.
The exact rules are in specs/web-search.md.
Using it
pi-dent bundles it. To use it on its own:
pi install npm:pi-dent-web-search
DuckDuckGo works without a key. For another backend, set its key in the environment:
EXA_API_KEY, PERPLEXITY_API_KEY, BRAVE_API_KEY, or GEMINI_API_KEY or GOOGLE_API_KEY. You
can also set it under the webSearch key of pi-dent.conf (~/.pi/pi-dent/, or
.pi/pi-dent/ in a project):
{
"webSearch": {
"order": ["brave", "duckduckgo"],
"brave": { "apiKey": "${env.MY_BRAVE_KEY}" },
},
}
All settings are in web-search.md, configuration. The extension requires Node 26 or later.
Documentation
specs/web-search.md: what the tool does, and its settings.docs/backends.md: the API facts each backend relies on, with links. Read it before changing a backend.AGENTS.md: how to work on the repository.
License
MIT, see LICENSE.