@cherrystudio/web-search

中文文档
0.5.0发布于 2026/10/29AGPL-3.0-onlyTypeScriptESM + CJS近 30 天下载 1706

Portable web search provider protocols with host-owned transports and policies

原始使用文档
文档目录3 节
  1. Entries
  2. Transport and errors
  3. Distribution and development

@cherrystudio/web-search

Portable protocols for the existing Cherry Studio web-search providers. Applications inject networking and explicitly choose provider capabilities; they keep settings, credential storage, key rotation, region detection, retries, fallback, local page extraction, and lifecycle ownership.

import { createWebSearchClient } from '@cherrystudio/web-search'
import { tavily } from '@cherrystudio/web-search/providers/tavily'

const client = createWebSearchClient({
  transport: hostTransport,
  providers: [{ provider: tavily, capabilities: ['searchKeywords'] }]
})

const response = await client.execute({
  providerId: 'tavily',
  capability: 'searchKeywords',
  input: 'Cherry Studio',
  config: { maxResults: 5 },
  credentials: { apiKey: selectedApiKey },
  signal,
  timeoutMs: 30_000
})

hostTransport, selectedApiKey, and signal belong to the application. Each call executes one input against one provider, without implicit retries. Results contain providerId, capability, input, and results with title, url, content, sourceInput, and optional truncated.

Entries

EntryContents
RootClient, validation, errors, provider vocabulary, and public types
/catalogImmutable remote provider metadata and per-capability public endpoints
/providers/<id>One protocol module: zhipu, tavily, searxng, exa, exa-mcp, bocha, querit, jina, firecrawl, crawl4ai, parallel, serply, yuanbao, deepseek, searchapi, desearch
/tools/configPure endpoint override merging; explicit empty overrides stay empty
/tools/url-filterOptional URL-rule filtering with diagnostics returned to the caller
/tools/contentOptional token/character slicing; the application allocates total budgets

Provider entry exports use their ID as the named export, except exa-mcp, which exports exaMcp. SearXNG additionally exports discoverSearxngEngines; Jina exports getJinaHostCandidates and JINA_MIRROR_HOSTS. Importing the root does not import all protocol modules or content slicing.

SearXNG discovery is explicit and uses the same error, cancellation, and timeout contract as search. Its errors use the searxng/searchKeywords context. Search returns snippets and never automatically downloads result pages. Jina candidate selection is pure; the package does not detect region or retry another endpoint.

apiHost: undefined uses a public default, which for Crawl4AI is the Cloud host https://api.crawl4ai.com. An explicit empty address fails validation. SearXNG has no default deployment. Local fetch and Desktop DuckDuckGo remain host-owned.

Querit accepts API hosts with or without /v1 and numeric-string response codes. Crawl4AI uses the Cloud /scrape protocol for crawl4ai.com and its subdomains, requiring an API key. Other hosts retain the self-hosted /md protocol with an optional token.

Yuanbao rounds maxResults up to the next supported Cnt value (10–50), then applies the requested limit locally. excludeDomains sends up to five distinct domain names through Site; invalid domain entries are omitted. Hosts retain full URL-rule filtering. Yuanbao-only useDefaultResultCount: true omits Cnt for lite-tier compatibility without disabling Site or the local limit. The protocol itself never retries.

Transport and errors

Implement WebSearchTransport.request with the host network stack. Requests contain a complete URL, headers, an already serialized optional body, signal, and optional timeoutMs. Return all HTTP statuses, lowercase response headers, and bodyText; do not parse JSON or encode the body again. Keep URL paths and query encoding intact.

The transport owns timeout enforcement from sending until the body is consumed, forwards cancellation to the actual request, and releases timers/listeners. Omitting timeoutMs retains host defaults. Throw WebSearchTransportError to report network, timeout, cancellation, body-read, or unclassified failures. An abort without an aborted caller signal is not global cancellation.

execute throws WebSearchError. Its kind distinguishes configuration, network, timeout, cancellation, HTTP, provider failure, invalid response, and unknown failure. code, status, providerCode, retryAfter, and requestId support application policy. toJSON() omits causes, raw responses, headers, and credentials. Cancellations retain the AbortError name; timeouts retain TimeoutError. Application-facing messages and retry decisions remain host-owned.

The MCP module supports finite JSON/SSE responses and existing Exa search Text/Highlights and page text formats. Successful result.content: [] or the upstream message No search results found. Please try a different query. means zero search hits. Blank or unrecognized responses are errors, and empty page content is always an error. It does not manage MCP connections, sessions, or streaming subscriptions.

Distribution and development

All public entries ship ESM/CJS and matching declarations, including a react-native export condition. The source has no Node, Electron, React Native, Expo, or application imports. Import resolution checks do not replace consuming-app platform acceptance. Output targets ES2020 and uses standard URL/URLSearchParams and the host cancellation signal; networking stays injected.

Desktop consumes workspace:* as a development dependency through source aliases, so the portable implementation is bundled with the application. Its explicit capability profile filters shared metadata. Mobile must install an exact published version and commit its lockfile. Initial workspace version 0.0.0 is a placeholder; the minor Changeset prepares 0.1.0. During 0.x, breaking API changes require a minor release; compatible fixes use patch releases. Host allowlists prevent new capabilities from being enabled implicitly.

The release workflow explicitly builds and checks this package. test:package checks a built tarball outside the workspace, module formats, declarations, and portable import resolution.

pnpm --filter @cherrystudio/web-search test -- src/__tests__/protocols.test.ts
pnpm --filter @cherrystudio/web-search test:package

These are opt-in development commands. test:package includes compilation and network-backed installation. Follow the current task's authorization rules before running either command.

License: AGPL-3.0-only, preserving the source repository license. Confirm licensing and maintainers before the initial public release.

版本与发布记录

@cherrystudio/web-search 共发布 6 个版本,首次发布于 2026/10/17;过去 12 个月发布了 6 个版本。

版本发布日期距今
0.5.0latest2026/10/2911 天前
0.4.02026/10/2813 天前
0.3.02026/10/2218 天前
0.2.02026/10/1723 天前
0.1.02026/10/1723 天前
0.0.0-stage2026/10/1723 天前

关于 @cherrystudio/web-search 的常见问题

@cherrystudio/web-search 是什么?

Portable web search provider protocols with host-owned transports and policies

如何安装 @cherrystudio/web-search?

在项目目录运行 npm install @cherrystudio/web-search,或使用 pnpm add / yarn add / bun add。

@cherrystudio/web-search 支持 TypeScript 吗?

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

@cherrystudio/web-search 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@cherrystudio/web-search 可以商用吗?

@cherrystudio/web-search 使用 AGPL-3.0-only 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@cherrystudio/web-search 的下载量有多少?

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

@cherrystudio/web-search 还在维护吗?

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