evan/pi-web
Web tools for pi coding agent. Registers two tools backed by a shared headless Firefox session that's kept warm for the lifetime of the pi process.
| Tool | Purpose |
|---|---|
web_search |
Search the web via Kagi (session token) or SearXNG (JSON API). |
web_fetch |
Fetch a URL and return readable markdown (Readability + Turndown). |
For raw HTTP responses, non-text content, or simple API calls, the LLM is steered toward bash + curl rather than web_fetch.
Search Providers
| Provider | How it works | Requires |
|---|---|---|
kagi |
Drives a headless Firefox session against kagi.com/search?token=…&q=… and scrapes results. |
Kagi session token, firefox, geckodriver |
searxng |
Calls a SearXNG instance's /search?format=json endpoint. |
A SearXNG base URL with JSON format enabled |
Config
Drop a JSON file at ~/.pi/pi-web/config.json:
{
"provider": "searxng",
"kagi": {
"token": "<your kagi session token>"
},
"searxng": {
"baseUrl": "https://search.example.com"
}
}
Env Var Overrides
| Variable | Overrides |
|---|---|
PI_WEB_PROVIDER |
provider |
KAGI_TOKEN |
kagi.token |
PI_WEB_SEARXNG_URL |
searxng.baseUrl |
Getting A Kagi Session Token
Open kagi.com, sign in, then go to Settings → Session Link. Copy the token= value from the link. Treat it like a password — it grants full account access.
Tools
web_search
| Arg | Type | Description |
|---|---|---|
query |
string | Search query text |
Returns a markdown list of ## [title](url)\n> description items.
web_fetch
| Arg | Type | Description |
|---|---|---|
url |
string | Absolute URL to fetch |
Returns markdown of the page. Pipeline:
- Navigate the shared Firefox session to the URL (15s timeout).
- Run Readability to extract the article subtree.
- If Readability finds nothing, fall back to the full
<body>. - Convert with Turndown.
- Truncate at 50KB with a clear marker.
Install
cd ~/.pi/agent/extensions/pi-web
npm install
pi picks up the extension via the pi.extensions entry in package.json.
Description
Languages
TypeScript
96.5%
Nix
3.5%