pi-web-search-and-fetch
Web search and fetch extension for pi coding agent
Package details
Install pi-web-search-and-fetch from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-web-search-and-fetch- Package
pi-web-search-and-fetch- Version
1.1.0- Published
- Oct 5, 2026
- Downloads
- 317/mo · 206/wk
- Author
- xinaps
- License
- MIT
- Types
- extension
- Size
- 217.8 KB
- Dependencies
- 2 dependencies · 4 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-web-search-and-fetch 🌐⚡
Empower your pi coding agent with real-time web intelligence: instant neural search, clean Markdown page extraction, and autonomous deep research.
pi-web-search-and-fetch transforms your pi coding agent into an autonomous web researcher. Say goodbye to outdated training cutoffs and missing documentation — equip your LLM with enterprise-grade web search, high-fidelity webpage retrieval, and multi-query deep synthesis. Built with a modular multi-provider engine, an interactive /ws terminal dashboard, and seamless zero-conflict integration with pi-requesty-provider.
⚡ Superpowers & Features
- 🔍 Real-Time Neural Web Search (
web_search) — Search the live web with semantic and category filtering (news,github,research paper,pdf,company,tweet,financial report) to break past knowledge cutoffs. - 📄 High-Fidelity Web Fetch (
web_fetch) — Instantly retrieve live documentation, articles, and repositories, converting raw HTML into clean, token-optimized Markdown. - 🧠 Autonomous Deep Research (
web_deep_search) — Multi-angle iterative exploration that executes parallel queries and synthesizes multi-source findings for complex inquiries. - 🎛️ Interactive TUI Control Hub (
/ws) — Full-featured terminal dashboard to toggle tools on the fly, switch provider backends, and configure API keys with smooth keyboard controls. - 🚀 Zero-Config Instant Start — Works immediately out of the box with Exa's public MCP endpoint (no API key required) or plug in your own
EXA_API_KEYfor unlimited bandwidth and deep search. - 🔌 Decoupled Multi-Provider Architecture — Independent capability interfaces (
SearchProvider,FetchProvider,DeepSearchProvider). Mix and match providers freely or implement custom engines with minimal boilerplate. - 🤝 Smart
pi-requesty-providerSynergy — Automatically coordinates withpi-requesty-providerto detect native server-side search models, preventing duplicate searches while keeping markdown extraction active. - 🔒 Secure Credential Management — Stores API keys safely in
~/.pi/agent/auth.jsonwith strict0o600file permissions.
✅ Compatibility
This extension is compatible with and verified against pi 1.0.3 — the latest stable release. The full test suite and the TypeScript typecheck pass against pi 1.0.3.
The supported peer dependency range is ^0.84 || ^1.0.0, so it works with both the 0.84.x and 1.0.x lines of pi.
🚀 Quick Installation
From npm (Recommended)
pi install npm:pi-web-search-and-fetch
From GitHub
pi install git:github.com/xinaps-dev/pi-web-search-and-fetch
Local Development
# Clone and build
git clone https://github.com/xinaps-dev/pi-web-search-and-fetch.git
cd pi-web-search-and-fetch
pnpm install
# Run locally in pi
pi -e ./
🎮 Getting Started & The /ws Control Hub
Managing your web tools is effortless with the unified /ws command.
Interactive Hub Dashboard
Run /ws inside pi to open the interactive TUI Control Panel:
┌───────────────────────────────────────────────────────────┐
│ 🌐 Web Search and Fetch - Control Panel │
├───────────────────────────────────────────────────────────┤
│ [✓] Search (web_search) : ON (Provider: exa) │
│ [✓] Fetch (web_fetch) : ON (Provider: exa) │
│ [ ] Deep Search (deep) : OFF (Provider: exa) │
│ │
│ Actions: │
│ > Assign Providers (3-tool wizard) │
│ > Configure Active Provider (Exa API Key / Mode) │
│ > View Detailed Status │
│ > Exit │
└───────────────────────────────────────────────────────────┘
- Navigate: Use
↑/↓arrow keys to browse options. - Toggle / Select: Press
SpaceorEnterto toggle tools or trigger configuration wizards. - Close: Press
Escor selectExit.
Text-Mode Subcommands
Prefer the keyboard? Every hub action is also available as a direct command:
/ws Open the interactive control hub
/ws status Show the detailed status report
/ws search on|off Enable/disable web_search
/ws fetch on|off Enable/disable web_fetch
/ws deep on|off Enable/disable web_deep_search
/ws provider <tool> <id|none> Assign a provider (tool: search|fetch|deep)
/ws provider Interactive provider assignment wizard
/ws config [providerId] Configure a provider (e.g. Exa API key)
/ws help Show usage help
🛠️ Standardized LLM Tools
pi-web-search-and-fetch registers 3 powerful tools with the Pi agent harness:
1. web_search (Enabled by default)
Performs real-time web searches and returns structured results with titles, URLs, snippets, publication dates, and citations.
| Parameter | Type | Required | Description |
|---|---|---|---|
query |
string |
Yes | Search keywords or natural language question |
numResults |
number |
No | Number of results to return (default: 10) |
category |
string |
No | Content category (company, research_paper, news, pdf, github, tweet, personal_site) |
includeDomains |
string[] |
No | Restrict results to these domains |
excludeDomains |
string[] |
No | Exclude these domains from the results |
startPublishedDate |
string |
No | Only return results published on or after this ISO date |
endPublishedDate |
string |
No | Only return results published on or before this ISO date |
similarUrl |
string |
No | When provided, returns pages similar to that URL (Exa find-similar) |
2. web_fetch (Enabled by default)
Fetches full web page content from known URLs and converts it into clean, LLM-ready Markdown. Supports batch fetching of multiple pages in a single call.
| Parameter | Type | Required | Description |
|---|---|---|---|
urls |
string | string[] |
Yes* | One or multiple webpage URLs to fetch |
url |
string |
No | Single-URL compatibility alias for urls |
maxCharacters |
number |
No | Maximum extracted content length per page (default: 5,000) |
* At least one of urls or url must be provided.
3. web_deep_search (Optional — disabled by default)
Agentic multi-query web research that executes parallel queries and synthesizes multi-source findings, or answers directly via Exa's answer tool when available. Requires your own EXA_API_KEY. Enable it from the /ws hub or with /ws deep on.
| Parameter | Type | Required | Description |
|---|---|---|---|
query |
string |
Yes | Primary research question |
numSources |
number |
No | Reference sources to consult (default: 5) |
includeText |
boolean |
No | Include text extracts from cited sources (default: true) |
numResults |
number |
No | Results per query; overrides numSources (default: 10) |
category |
string |
No | Content category filter |
additionalQueries |
string[] |
No | Supplementary parallel sub-queries |
⚙️ Configuration & Key Storage
Extension Configuration: ~/.pi/agent/pi-web-search-and-fetch.json
Persistent settings are stored cleanly in your agent directory:
{
"search": {
"enabled": true,
"provider": "exa"
},
"fetch": {
"enabled": true,
"provider": "exa"
},
"deepSearch": {
"enabled": false,
"provider": "exa"
},
"providers": {
"exa": {
"useApiKey": true
}
}
}
Authentication & API Keys: ~/.pi/agent/auth.json
API keys are read and stored using Pi's standard authentication store (~/.pi/agent/auth.json) with strict 0o600 file permissions:
{
"exa": {
"type": "api_key",
"key": "your-exa-api-key-here"
}
}
Key Resolution Hierarchy for Exa:
- Public MCP Tier: If
useApiKey: false, uses Exa's public endpoint (free, no key required). - Authenticated Tier: If
useApiKey: true:- Checks
~/.pi/agent/auth.json(exa.key). - Falls back to
EXA_API_KEYenvironment variable.
- Checks
Manage keys from pi with /ws config exa (or /ws → Configure Active Provider). Note that web_deep_search always requires its own API key: it is not available in the public free mode.
🧩 Provider Architecture
pi-web-search-and-fetch is designed with a fully decoupled capability model:
┌────────────────────────────────────────────────────────┐
│ ProviderRegistry │
├────────────────────────────────────────────────────────┤
│ SearchProvider │ FetchProvider │ DeepSearch │
│ - exa │ - exa │ - exa │
│ - (custom search) │ - (custom fetch)│ - (custom) │
└────────────────────────────────────────────────────────┘
Implementing a Custom Provider
Easily create and register custom providers conforming to ProviderModule:
import type {
ProviderModule,
SearchProvider,
FetchProvider,
DeepSearchProvider,
SearchResponse,
FetchResponse,
} from "pi-web-search-and-fetch";
export const myCustomProvider: ProviderModule = {
id: "custom",
name: "My Custom Provider",
description: "Custom web search and scraper",
capabilities: ["search", "fetch"],
searchProvider: {
id: "custom",
name: "My Custom Provider",
description: "Search via Custom API",
supportsApiKey: true,
requiresApiKey: true,
async search(query, options, signal): Promise<SearchResponse> {
// Implement search logic...
return {
query,
provider: "custom",
results: [
{ title: "Example", url: "https://example.com", snippet: "..." }
],
};
},
},
fetchProvider: {
id: "custom",
name: "My Custom Provider",
description: "Fetch via Custom Scraper",
supportsApiKey: false,
requiresApiKey: false,
async fetch(url, options, signal): Promise<FetchResponse> {
// Implement fetch logic...
return {
url,
provider: "custom",
content: "# Example Page Content\n\n...",
};
},
},
};
🤝 pi-requesty-provider Smart Synergy
When used alongside pi-requesty-provider:
pi-web-search-and-fetchinspects~/.pi/agent/pi-requesty.jsonand evaluates the active session model onsession_startandmodel_select.- If Requesty has native search enabled (
nativeSearch: true) inpi-requesty-providerand the active model supports server-side search grounding,pi-web-search-and-fetchautomatically suppressesweb_searchto prevent duplicate web queries and token waste. web_fetchremains fully active, allowing your agent to extract and inspect complete web pages on demand.
🧪 Development & Testing
# Run all unit and integration tests
pnpm test
# Run TypeScript typecheck
pnpm typecheck
📄 License
This project is licensed under the MIT License © xinaps.