@framers/agentos-ext-web-search

中文文档
1.4.0发布于 2026/11/11Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 2.1万

Web search, research aggregation, and fact-checking tools for AgentOS

原始使用文档
文档目录13 节
  1. Installation
  2. Quick Start
  3. Environment Variables
  4. Options
  5. Searching from code
  6. Tools
  7. web_search
  8. research_aggregate
  9. fact_check
  10. Ranking
  11. Reranking with AgentOS
  12. Notes
  13. License

Web Search Extension for AgentOS

Professional web search, research aggregation, and fact-checking for AgentOS agents.

Supports Serper.dev, Tavily, Brave, SerpAPI, Firecrawl and SearXNG. A search asks the configured providers in that order and answers with the first one that returns without an error, even when it returns no results (a Tavily or Firecrawl request that times out returns no results). It moves to the next provider only when one throws an error or is past its rate limit, and falls back to DuckDuckGo, which needs no API key, when every configured provider did. English Wikipedia, which needs no key, answers a search pinned to it and multiSearch once a host enables it (see Options).

Installation

npm install @framers/agentos-ext-web-search

Quick Start

import { AgentOS } from '@framers/agentos';

const agentos = await AgentOS.create({
  extensionManifest: {
    packs: [
      {
        package: '@framers/agentos-ext-web-search',
        options: {
          // Any one of these is enough; configured providers are tried in the order above.
          serperApiKey: process.env.SERPER_API_KEY,
          tavilyApiKey: process.env.TAVILY_API_KEY,
          braveApiKey: process.env.BRAVE_API_KEY,
          serpApiKey: process.env.SERPAPI_API_KEY,
          firecrawlApiKey: process.env.FIRECRAWL_API_KEY,
          searxngUrl: process.env.SEARXNG_URL,
        },
      },
    ],
  },
});

Environment Variables

  • SERPER_API_KEY (optional)
  • SERPAPI_API_KEY (optional)
  • BRAVE_API_KEY (optional)
  • TAVILY_API_KEY (optional)
  • FIRECRAWL_API_KEY (optional)
  • SEARXNG_URL (optional, a SearXNG instance URL)

If none are set, the extension falls back to DuckDuckGo. Wikipedia needs no key and no variable: the wikipedia option enables it.

Options

Beside the keys above, the pack options and SearchProviderService's configuration take:

OptionWhat it doesWhen left out
wikipedia{ enabled, client, limiter?, origin?, timeoutMs? }: English Wikipedia's REST search through @framers/agentos-ext-public-sources' WikipediaSourceProvider. It needs no key. client ({ name, version, contact }) is sent as the User-Agent Wikimedia's policy asks for. limiter is the process's one SourceLimiter for the wiki: pass the same one to every service and every reader that calls it, since Wikimedia counts its limits per client. origin points the provider at another wiki or a stand-in; timeoutMs is each request's deadline.Off. Once enabled: a new SourceLimiter, https://en.wikipedia.org, 3,000 ms.
serperUrlSerper's search endpoint, such as a stand-in in a host's tests.https://google.serper.dev/search
tavilyUrlTavily's search endpoint.https://api.tavily.com/search
firecrawlUrlFirecrawl's search endpoint.https://api.firecrawl.dev/v1/search
tavily{ searchDepth: 'basic' | 'advanced' }, the search_depth Tavily is sent. include_answer and include_raw_content are false at either depth.advanced

The wikipedia provider is listed after every other configured provider. A search with no provider never asks it: it answers article titles alone, so a general query goes to the keyed providers and then to DuckDuckGo. Pin it with provider: 'wikipedia', or use multiSearch, which asks it beside the others. It answers each hit as { title, url, snippet: '', position }, the url built by public-sources' articleUrl, so decodeURIComponent of the path after /wiki/ gives the article's key back for a read through WikipediaSourceProvider.read.

Searching from code

import { SourceLimiter } from '@framers/agentos-ext-public-sources';
import { LimiterRefused, SearchFailed, SearchProviderService } from '@framers/agentos-ext-web-search';

// One limiter for the wiki in the process, shared with every other caller of it.
const wikiLimiter = new SourceLimiter();

const search = new SearchProviderService({
  tavilyApiKey: process.env.TAVILY_API_KEY,
  tavily: { searchDepth: 'basic' },
  wikipedia: {
    enabled: true,
    client: { name: 'MyApp', version: '1.2.0', contact: 'https://example.org/contact' },
    limiter: wikiLimiter,
  },
});

let sent = 0;
const controller = new AbortController();
try {
  const response = await search.search('Treaty of Versailles', {
    provider: 'wikipedia',
    maxResults: 2,
    signal: controller.signal,
    onSend: () => {
      sent += 1;
    },
  });
  // response.results[0]: { title: 'Treaty of Versailles', url: 'https://en.wikipedia.org/wiki/Treaty_of_Versailles', snippet: '', position: 1 }
} catch (error) {
  if (error instanceof LimiterRefused) {
    // Nothing was sent: error.reason is 'blocked', 'minute', 'wait' or 'caller'.
  } else if (error instanceof SearchFailed) {
    // error.provider is 'wikipedia'; error.status is the HTTP status, or null when none came.
  }
}

search(query, { maxResults, provider, category, signal, onSend }):

  • provider pins one provider: no other is tried and nothing falls back to DuckDuckGo. A pinned keyed provider that answers an error status throws its own Error. A pinned wikipedia search the limiter refuses throws public-sources' LimiterRefused, which this pack re-exports, and one that fails throws SearchFailed. The refusal is the one the host's limiter threw, reason and all, even from a limiter of another copy of public-sources. A search pinned to wikipedia on a service that did not enable it throws and sends nothing.
  • signal ends every provider request of the search, and the search rejects with the signal's reason. Tavily's and Firecrawl's own 15-second timers run beside it, and their own timeout answers no results. Without provider, an abort ends the search there: no next provider is asked, and DuckDuckGo is not.
  • onSend is awaited once before each provider is asked, before its request is sent. When it throws, nothing is sent, no other provider is asked, and the search rejects with what it threw. For wikipedia it runs once the limiter has granted the request, so a search the limiter refuses never runs it. A search can end refused after onSend has run, with nothing sent, when a 429 or a 503 blocked the limiter meanwhile or the spacing would wait past the limiter's waitMs.

A search with neither signal nor onSend sends the requests it sent before these options existed.

Tools

web_search

Search the web. provider pins one of serper, serpapi, brave, tavily, firecrawl, searxng or duckduckgo, and wikipedia on a service that enables it. The tool reads the service's providers when it is built: on a service without wikipedia, its schema's provider enum and its description leave Wikipedia out, and validateArgs refuses provider: 'wikipedia' as an invalid provider.

research_aggregate

Run multiple searches and aggregate results.

fact_check

Cross-check a claim across sources.

Ranking

With multiSearch: true (a tool input, or the pack option defaultMultiSearch: true for every tool), a query goes to every configured provider (the wikipedia provider among them when it is enabled) and DuckDuckGo in parallel. Results are merged by normalized URL and ordered by a confidence score built from how many providers returned the URL and where each placed it. The pack runs no reranking model and sends results to no reranking service.

Reranking with AgentOS

AgentOS reranks with a RerankerService (@framers/agentos/cognition/rag/reranking). Reranking is provider-agnostic: you register the providers you want, and rerankChain(query, chunks, chain) runs the chain's stages in order, each naming a provider id, a topK and optionally a model. A stage whose provider is not registered or not available is skipped, and a stage that throws leaves the previous order in place.

There are two ways to use it with web search:

  • This pack's results. The pack's tools do not call a reranker. To rerank what web_search returned, pass the results to rerankChain yourself, each as a chunk with an id, an originalDocumentId (the URL, for example) and its snippet as content.
  • AgentOS's own search. WebSearchService (@framers/agentos/cognition/web-search) is a separate search with its own providers (FirecrawlProvider, TavilyProvider, SerperProvider and BraveProvider, added with registerProvider), not this pack's. Given a reranker (a RerankerService) and a rerankChain, it reranks its fused results, sending each result's page content, or its snippet when it has none. If reranking fails, it returns the fused results unreranked.

AgentOS ships three reranking providers, all exported from @framers/agentos/cognition/rag/reranking. The table describes AgentOS at commit c46ff75; other versions can differ (at v0.10.40, the oldest AgentOS this pack declares, LlmJudgeReranker accepts a timeoutMs but does not apply it).

IdClassHow it scoresWhat leaves the processDefaultsOn failure
localLocalCrossEncoderRerankerA cross-encoder scores each query and document pair in process through Transformers.js (@huggingface/transformers, else @xenova/transformers, installed by the host).No query or document. The model is downloaded on first use and cached.Model cross-encoder/ms-marco-MiniLM-L-6-v2, device cpu, maxSequenceLength 512, batchSize 32.Not available when neither Transformers.js package is installed. A model that fails to load throws. A document whose scoring throws scores 0.
cohereCohereRerankerCohere's Rerank API scores the documents.The query and every document's full content, sent to <baseUrl>/v1/rerank with the apiKey.Model rerank-v3.5, baseUrl https://api.cohere.ai, timeout 30000 ms.Not available without an apiKey. A non-2xx answer or a timeout throws.
llm-judgeLlmJudgeRerankerA language model, called through the host's llmCallFn(system, user, model?), scores the first maxPointwiseDocuments documents 0 to 10 in batches, then ranks the best-scored ones in one call. Documents past maxPointwiseDocuments are left out of its answer.The query and the first 200 characters of each document, sent wherever the host's llmCallFn sends them.No model of its own: scoringModel and rankingModel are passed to llmCallFn as given. maxPointwiseDocuments 100, batchSize 10, pointwiseTopK 20, timeout 30000 ms a call.A batch whose call fails, times out or does not parse scores 0. A failed ranking call leaves the order to the scores.

See AgentOS's Reranking page and WebSearchService.ts.

Notes

  • Tools are read-only (no side effects).
  • Provider selection is automatic, based on which keys are configured and whether wikipedia is enabled.

License

Apache-2.0 © Frame.dev

版本与发布记录

@framers/agentos-ext-web-search 共发布 11 个版本,首次发布于 2026/02/06;过去 12 个月发布了 11 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.4.0latest2026/11/114 天前
1.3.62026/11/114 天前
1.3.52026/11/105 天前
1.3.42026/11/0115 天前
1.3.32026/10/2125 天前
1.3.22026/10/121 个月前

关于 @framers/agentos-ext-web-search 的常见问题

@framers/agentos-ext-web-search 是什么?

Web search, research aggregation, and fact-checking tools for AgentOS

如何安装 @framers/agentos-ext-web-search?

在项目目录运行 npm install @framers/agentos-ext-web-search,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@framers/agentos(>=0.10.40)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@framers/agentos-ext-web-search 支持 TypeScript 吗?

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

@framers/agentos-ext-web-search 支持 ESM 还是 CommonJS?

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

@framers/agentos-ext-web-search 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@framers/agentos-ext-web-search 可以商用吗?

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

@framers/agentos-ext-web-search 的下载量有多少?

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

@framers/agentos-ext-web-search 还在维护吗?

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