@wolido/pi-anysearch

AnySearch AI search API extension for pi

Packages

Package details

extension

Install @wolido/pi-anysearch from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@wolido/pi-anysearch
Package
@wolido/pi-anysearch
Version
0.2.1
Published
Sep 15, 2026
Downloads
210/mo · 11/wk
Author
wolido
License
MIT
Types
extension
Size
28.3 KB
Dependencies
0 dependencies · 3 peers
Pi manifest JSON
{
  "extensions": [
    "./src/index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

@wolido/pi-anysearch

AnySearch AI search extension for pi. It wraps the AnySearch vertical search API — 40 curated capability domains (finance, academic, legal, security, health, travel, ...) — as four LLM tools, with authentication, MCP session handling and output truncation taken care of.

Tools

Tool Purpose
anysearch_search Vertical web search. Optional capability tag (e.g. finance.quote, academic.search, code.doc, security.vuln), zone (cn/intl), language, tag-specific params, format and max_results (1–20).
anysearch_batch_search Run several queries in parallel with shared options; returns one aggregated result set.
anysearch_extract Fetch a URL and return its readable content as markdown (via AnySearch's MCP extract tool).
anysearch_domains List the curated sub-domains under a top-level capability domain (via MCP get_sub_domains); useful for discovering valid tags.

Search and batch results include titles, URLs, snippets, extracted content and total_results / search_time_ms metadata. Oversized outputs are truncated to pi's tool output limits, byte-safely for multi-byte text.

Installation

pi install npm:@wolido/pi-anysearch

For local development, load the extension directly from the repo:

pi -e /path/to/pi-anysearch/src/index.ts

Configuration

The API key is resolved on first tool execution, with the following precedence (first hit wins):

  1. Environment variableANYSEARCH_API_KEY

    export ANYSEARCH_API_KEY="sk-..."
    
  2. Project config<project>/.pi/pi-anysearch/config.json

    { "apiKey": "sk-..." }
    

    Read only when the project is trusted by pi; config files from untrusted projects are ignored so a malicious repository cannot inject an API key.

    ⚠️ This file contains a plaintext key — add .pi/pi-anysearch/config.json to your project's .gitignore.

  3. Global config~/.pi/agent/pi-anysearch/config.json (same JSON format)

  4. Anonymous mode — no key found: requests are sent without an Authorization header and are rate-limited by the AnySearch service.

Get a key at anysearch.ai.

Development

npm install
npm test           # vitest, 63 tests
npm run typecheck  # tsc --noEmit

Layout:

  • src/anysearch.ts — AnySearch client: POST /v1/search envelope API plus a stateful MCP Streamable HTTP session (initializenotifications/initializedtools/call) for extract/domains.
  • src/config.ts — API key resolution (env → trusted project config → global config → anonymous).
  • src/index.ts — pi extension factory registering the four tools (TypeBox schemas via StringEnum for provider compatibility); clients are created lazily and cached per cwd + trust state.
  • tests/ — vitest suite with a mock fetch/MCP harness (tests/helpers/).

License

MIT © 2026 liuyu