@amaster.ai/pi-web-access

中文文档
0.1.37发布于 2026/11/09Apache-2.0TypeScriptES Module近 30 天下载 5929

Pi extension for web search, URL content extraction, and image search (Cloudflare, Tavily, Kimi, DeepSeek, Mimo, Z.AI, DashScope, Unsplash, and more)

原始使用文档
文档目录19 节
  1. Tools
  2. web_search
  3. web_fetch
  4. x_search
  5. image_search
  6. Structured tool results
  7. Providers
  8. DeepSeek Search and Fetch
  9. Cloudflare Web Search
  10. Configuration
  11. search
  12. fetch
  13. imageSearch
  14. providers
  15. Architecture
  16. Tool Registration Rules
  17. Install
  18. Development
  19. Tool failures

pi-web-access

pi-web-access preview

Pi extension for web search and URL content extraction.

Tools

web_search

Search the web for information. Also available via /web-search <query>. Registered when a keyed search provider is available, or when the keyless parallel provider is explicitly selected.

ParameterTypeRequiredDescription
querystringyesThe search query
maxResultsnumbernoMax results to return (default 5)
topic"general" | "news"noTopic category
timeRange"day" | "week" | "month" | "year"noRecency filter
includeDomainsstring[]noOnly include results from these domains
excludeDomainsstring[]noExclude results from these domains

web_fetch

Fetch a URL and return its content. Also available via /web-fetch <url> [extraction instructions]; instructions default to “Summarize this page.” when omitted. When fetch.summary is configured, the summary model processes the content using prompt; otherwise the fetched content is returned directly and prompt is retained for compatibility but ignored. Only registered when fetch.provider or fetch.summary is configured.

ParameterTypeRequiredDescription
urlstringyesPublic HTTP(S) URL; private, loopback, link-local, metadata, credentialed, and unsafe redirect destinations are rejected
promptstringyesInstructions for the configured summary model; retained for compatibility but ignored when fetch.summary is not configured

x_search

Search X (Twitter) for posts and social media content. Only registered when xai provider has an API key.

ParameterTypeRequiredDescription
querystringyesThe search query on X
allowedHandlesstring[]noOnly include posts from these handles (max 20)
excludedHandlesstring[]noExclude posts from these handles (max 20)
fromDatestringnoStart date (YYYY-MM-DD)
toDatestringnoEnd date (YYYY-MM-DD)

image_search

Search the web for images. Only registered when an image search provider (dashscope or unsplash) has an API key. Also invocable directly via the /image-search <query> command.

ParameterTypeRequiredDescription
querystringyesDescription of the images to search for

Structured tool results

On Pi runtimes with structured tool support, codemode receives objects from these tools instead of parsing their Markdown. web_search, x_search, and image_search return { provider, query, answer?, results, truncated }, where each source has title, url, content, and an optional score. web_fetch returns { url, title, content, truncated }; content is the summary when a summary model is configured. Readable tool results remain available.

Results are bounded and truncated indicates shortened text or omitted sources; retained source URLs are never shortened. Failed calls return { error } with isError: true, so scripts must check for error before reading result fields. Cancellation still aborts the call. Older Pi runtimes keep their text-result behavior.

Providers

ProviderSearchFetchX SearchImage SearchDefault Base URLEnv VarDefault Model
cloudflare✓✗✗✗https://api.cloudflare.com/client/v4CLOUDFLARE_API_TOKEN-
parallel✓✗✗✗https://search.parallel.ai/mcpno key-
tavily✓✓✗✗https://api.tavily.comTAVILY_API_KEY-
brave✓✗✗✗https://api.search.brave.comBRAVE_API_KEY-
firecrawl✓✓✗✗https://api.firecrawl.devFIRECRAWL_API_KEY-
kimi✓✗✗✗https://api.moonshot.cn/v1MOONSHOT_API_KEYkimi-k3
mimo✓✗✗✗https://api.xiaomimimo.com/v1MIMO_API_KEYmimo-v2.5-pro
zai✓✓✗✗https://api.z.aiZAI_API_KEY-
gemini✓✗✗✗https://generativelanguage.googleapis.com/v1betaGEMINI_API_KEYgemini-2.5-flash
perplexity✓✓✗✗https://api.perplexity.aiPERPLEXITY_API_KEYopenai/gpt-5.5
deepseek✓✓✗✗https://api.deepseek.comDEEPSEEK_API_KEY-
openrouter✓✓✗✗https://openrouter.ai/api/v1OPENROUTER_API_KEYopenai/gpt-4.1-mini
xai✓✗✓✗https://api.x.ai/v1XAI_API_KEYgrok-4.3
openai✓✗✗✗https://api.openai.com/v1OPENAI_API_KEYgpt-5.5
anthropic✓✓✗✗https://api.anthropic.com/v1ANTHROPIC_API_KEYclaude-sonnet-4-6
dashscope✓✓✗✓https://dashscope.aliyuncs.com/compatible-mode/v1DASHSCOPE_API_KEYqwen3.8-flash
unsplash✗✗✗✓https://api.unsplash.comUNSPLASH_ACCESS_KEY-
you✓✓✗✗https://ydc-index.ioYDC_API_KEY-

DeepSeek Search and Fetch

DeepSeek uses the Search and Fetch APIs: POST /v1/tools/search returns ranked sources with long summaries, and POST /v1/tools/fetch returns Markdown. Set search.provider and/or fetch.provider to "deepseek" and supply DEEPSEEK_API_KEY or providers.deepseek.apiKey. Existing DeepSeek settings continue to work; model is ignored and search no longer returns a synthesized answer. Both root and /v1 base URLs are supported.

Search requests use count (default 5, API limit 50) and need_content: false; fetch a result URL for its full body. Domain filters become site: / -site: syntax, and timeRange becomes an after:YYYY-MM-DD filter (1/7/30/365 days, UTC). The complete query, including filters, must contain 1–128 Unicode characters. topic is ignored; use query terms to search for news. Raw DeepSeek search syntax can also be included directly in the query.

Set search.provider to "cloudflare". The Cloudflare Web Search REST API requires an account ID, an API token with Workers AI: Read and AI Gateway: Read permissions, and an AI Gateway with credits or a stored provider key. The default gateway is default; the default search provider is ceramic.

{
  "pi-web-access": {
    "search": { "provider": "cloudflare" },
    "providers": {
      "cloudflare": {
        "apiKey": "${CLOUDFLARE_API_TOKEN}",
        "accountId": "${CLOUDFLARE_ACCOUNT_ID}",
        "gatewayId": "default",
        "searchProvider": "ceramic"
      }
    }
  }
}

apiKey and accountId fall back to CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID. Cloudflare is also eligible for automatic selection when both are available, after the existing search providers. Configure interpolated values in user or agent settings; trusted project settings do not expand environment variables.

Cloudflare-only provider settings:

FieldDescription
accountIdCloudflare account ID (required; environment fallback supported).
gatewayIdAI Gateway ID (default default).
searchProviderceramic, exa, or linkup (default ceramic).
byokAliasOptional alias of a provider key stored in AI Gateway. If it is missing on the gateway, the API fails rather than falling back to credits.

Requests use POST {baseUrl}/accounts/{accountId}/ai/websearch/. Queries must contain 1–1024 characters. maxResults defaults to 5 and is capped at 10; topic, timeRange, includeDomains, and excludeDomains are ignored because this API does not support them. Results contain titles, URLs, and description snippets, without a synthesized answer; large snippets are truncated. Cloudflare supports search only.

Custom Kimi base URLs must support both /chat/completions and /formulas/*.

You.com search returns web and news results in one call; topic: "news" prefers news results and applies a one-week freshness window. The Contents API (/v1/contents) returns clean Markdown for web_fetch. Get a key at you.com/platform/api-keys.

Custom DashScope base URLs must point to an OpenAI-compatible Responses API root — ${baseUrl}/responses is called for all capabilities. For the international site or a dedicated workspace endpoint, use e.g. https://dashscope-intl.aliyuncs.com/compatible-mode/v1. DashScope fetch uses the web_extractor tool and image search uses web_search_image; both are agent-style tools and can take minutes per call (default timeout 5 min, tune via timeoutMs). DashScope search supports only basic web search — includeDomains/excludeDomains filters are ignored.

Fetch fallback (when fetch.provider is not set): Jina Reader (r.jina.ai, free, JS-rendered) → local HTTP GET + turndown. Both stages, including destination and redirect DNS validation, share one timeoutMs deadline (30 seconds by default); Jina receives at most half that budget so a slow reader still leaves time for local fallback. Jina and local response bodies are capped at 2 MiB before text/HTML conversion, and oversized responses return a marked partial prefix. The partial flag survives summarization; use a focused search or browser inspection to recover missing evidence rather than repeat the same full fetch. Configured provider adapters retain their own response and timeout policies.

Configuration

Settings key: pi-web-access

Project .pi/settings.json values are loaded only after project trust is accepted and are not environment-interpolated. User and agent settings retain environment interpolation.

{
  "pi-web-access": {
    "search": {
      "provider": "kimi"
    },
    "fetch": {
      "provider": "zai",
      "summary": {
        "provider": "amaster",
        "model": "deepseek-v4-flash"
      }
    },
    "providers": {
      "kimi": {
        "apiKey": "AMASTER_API_KEY",
        "baseUrl": "https://credits.amaster.ai/v1"
      },
      "zai": {
        "apiKey": "${ZAI_API_KEY}"
      },
      "xai": {
        "apiKey": "${XAI_API_KEY}"
      }
    }
  }
}
FieldDescription
providerWhich provider to use for web search. Not set = auto-select first provider with key. Explicitly selecting parallel enables keyless search; otherwise no key means the tool is not registered.

fetch

FieldDescription
providerWhich provider to use for URL fetching. Not set = Jina Reader → local fallback.
summaryModel config for summarizing fetched content.
summary.providerModel provider name (resolved via pi model registry).
summary.modelModel id.

If neither fetch.provider nor fetch.summary is configured, web_fetch is not registered.

imageSearch

FieldDescription
providerWhich provider to use for image search (dashscope or unsplash). Not set = auto-select first provider with key. No key at all = tool not registered.

providers

Per-provider configuration. Each provider supports:

FieldDescription
apiKeyAPI key. User and agent settings support $ENV_VAR and ${ENV_VAR}; only the braced form supports :-fallback. Project settings keep placeholders literal.
baseUrlOverride the default API endpoint.
modelOverride the default model.
headersExtra headers merged into every request.

Environment variables serve as fallbacks when apiKey is not set in config.

Parallel is opt-in and supports search only: it never enables image search or web_fetch, and it does not perform URL fetching or extraction. When selected, search objectives and queries leave the machine for https://search.parallel.ai/mcp; this can include agent-generated repository context and user-supplied URLs contained in those objectives or queries. Existing automatic provider selection, provider order, and keyed provider behavior are unchanged.

Architecture

Each provider implements the WebProvider interface via BaseProvider:

// providers/base.ts
export interface WebProvider {
  readonly id: BuiltInProviderId;
  search(params: SearchParams, provider: ResolvedProvider): Promise<SearchResponse>;
  fetch(url: string, provider: ResolvedProvider): Promise<FetchResponse>;
  imageSearch(params: ImageSearchParams, provider: ResolvedProvider): Promise<SearchResponse>;
}

export abstract class BaseProvider implements WebProvider {
  abstract readonly id: BuiltInProviderId;
  // Default implementations throw "not supported"
  async search(...) { throw new Error(`${this.id} does not support web_search.`); }
  async fetch(...) { throw new Error(`${this.id} does not support web_fetch.`); }
  async imageSearch(...) { throw new Error(`${this.id} does not support image_search.`); }
}

Providers only override methods they support. Provider-specific capabilities (like XaiProvider.xsearch) are exposed as additional methods on the class.

Tool Registration Rules

  • web_search and /web-search <query> — registered when a search provider has an API key, or when keyless parallel is explicitly selected.
  • web_fetch and /web-fetch <url> [extraction instructions] — registered when fetch.provider or fetch.summary is configured.
  • x_search — registered when xai provider has an API key.
  • image_search — registered when an image search provider (dashscope, unsplash) has an API key; /image-search command is registered alongside it. An imageSearch.provider that doesn't support image search (e.g. "openai") is treated as unconfigured.
  • If none are configured, the extension loads silently with no tools registered.

Install

pi install npm:@amaster.ai/pi-web-access

Development

pnpm build      # tsc -b
pnpm typecheck  # tsc -b --pretty false
pnpm test       # vitest run src

Tool failures

web_search, web_fetch, x_search, and image_search return isError: true with a safe error message and errorCategory: timeout for request deadlines, http_error for recognized HTTP failures (with numeric httpStatus), network_error for recognized transport failures, cancelled for an upstream cancellation, configuration_error / invalid_request / invalid_response for vetted local validation failures, or request_failed for unclassified failures. Raw provider errors, response bodies, URLs, and credentials are excluded from these failure results and diagnostic logs. Caller cancellation propagates to the runtime. The /web-search, /web-fetch, and /image-search commands use the same safe messages and log categories. A timeout does not imply invalid provider configuration.

版本与发布记录

@amaster.ai/pi-web-access 共发布 106 个版本,首次发布于 2026/06/09;过去 12 个月发布了 106 个版本。

版本发布日期距今
0.1.37latest2026/11/09今天
0.1.2-beta.91beta2026/11/072 天前
0.1.2-beta.902026/11/062 天前
0.1.2-beta.892026/11/053 天前
0.1.2-beta.882026/11/054 天前
0.1.362026/11/054 天前

关于 @amaster.ai/pi-web-access 的常见问题

@amaster.ai/pi-web-access 是什么?

Pi extension for web search, URL content extraction, and image search (Cloudflare, Tavily, Kimi, DeepSeek, Mimo, Z.AI, DashScope, Unsplash, and more)

如何安装 @amaster.ai/pi-web-access?

在项目目录运行 npm install @amaster.ai/pi-web-access,或使用 pnpm add / yarn add / bun add。

@amaster.ai/pi-web-access 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@amaster.ai/pi-web-access 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@amaster.ai/pi-web-access 可以商用吗?

@amaster.ai/pi-web-access 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@amaster.ai/pi-web-access 的下载量有多少?

根据 npm 官方下载统计,@amaster.ai/pi-web-access 在 2026/10/06 – 2026/11/04 这 30 天内被下载 5,929 次,日均约 198 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@amaster.ai/pi-web-access 还在维护吗?

最新版本 0.1.37 发布于 2026/11/09(今天);至今共发布 106 个版本,其中过去 12 个月发布了 106 个;首次发布于 2026/06/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。