@crvouga/mockingbird-service-tavily

中文文档
1.10.0发布于 2026/11/11MITTypeScriptES Module构建来源已验证近 30 天下载 2198

Scripted Tavily search and extraction without web crawling.

原始使用文档
文档目录6 节
  1. Install
  2. Usage
  3. Controls
  4. Verification
  5. Deliberately not modelled
  6. API

@crvouga/mockingbird-service-tavily

Local emulators. Real API contracts. Part of Mockingbird.

WIP scripted Tavily search and extraction. No public URLs are fetched. Contract references: Search, Extract and the exact tavily-python 0.7.17 AsyncTavilyClient source.

Install

bun add @crvouga/mockingbird-service-tavily

Usage

import { tavily } from "@tavily/core"
import { createServer } from "@crvouga/mockingbird-service-tavily/server"

// Test setup: script the results for one query.
const server = await createServer({
  searches: [{ query: "fixture", results: [
    { title: "Example", url: "https://example.test", content: "Synthetic", score: 0.9 },
  ] }],
})

// The Tavily SDK your application already uses. Only its base URL changes.
const client = tavily({ apiKey: "mock_tavily_key", apiBaseURL: server.url })
const { results } = await client.search("fixture")
console.log(results[0]?.title, results[0]?.url) // Example https://example.test

await server.close()

CLI: mockingbird-tavily serve --port 12130. Configure the SDK's base URL (apiBaseURL in @tavily/core, api_base_url in tavily-python); neither SDK has a required global endpoint environment variable. If your app reads TAVILY_API_KEY, set it to emulate_tavily_key in local tests. HTTP authentication is Bearer, exactly as emitted by AsyncTavilyClient 0.7.17, not a JSON api_key body field.

POST /search matches query fixtures, returns ranked hits in fixture order and respects max_results (0–20, default 10). topic, search_depth and time_range are accepted; optional fixture match fields select variants without running a ranking/date-filter model. More specific match objects win. include_answer true/basic/advanced includes the scripted answer. Missing queries return empty results. POST /extract accepts one URL or up to 20 URLs; successful content and per-URL errors remain separate. Unscripted URLs receive a synthetic retrieval failure, never a network request.

Controls

Options searches, extractions and apiKeys seed SQLite collections with exported SearchScript, Extraction and ApiKey records. Alternatively POST /__admin/state/searches with {id, value}; extraction records match their value.url (use any simple id); apiKeys ids must equal the synthetic key. Default key: mock_tavily_key. Key status quota yields 429; plan_limit 432; payg_limit 433. Invalid/missing keys return 401 with detail.error. No real credentials belong in fixture state. Search results may include scripted answer and response_time (numeric seconds, default zero).

The standard /__admin provides state, reset, Timeline, clock, journal, metrics, health and UI. Namespaces: x-mockingbird-namespace, /__admin/ns/name and Bearer credential mapping through PUT /__admin/credentials. Journals contain metadata only, not query text, content or credentials. No webhooks are emitted. Presets: invalid_key, quota_exceeded, plan_limit, payg_limit, internal_error, timeout (one-second latency), connection_drop. Generic faults also support deterministic latency. The clock is available for consumer workflows; no quota scheduler is simulated.

Verification

bun test runs acceptance, independent OpenAPI self-parity and divergence detection. bun scripts/sdk.ts runs exact tavily-python 0.7.17 using uv against the served emulator: AsyncTavilyClient search/extract, InvalidAPIKeyError, UsageLimitExceededError, ForbiddenError and TimeoutError. No real API key or crawl is used. bun run parity requires TAVILY_API_KEY and sends only an invalid missing-query request to compare validation status, never a search or extraction. Missing credentials exit 2. SDK tests are compatibility evidence, not live vendor search-result parity.

Deliberately not modelled

Real web crawling/search/ranking, generated answers, billing or quota accounting, image retrieval, date-window filtering beyond explicit scripted selectors, automatic parameters, advanced extraction formatting, crawl/map/research endpoints and precise vendor validation error prose. Empty fixture queries and unseeded URL failures are local test controls, not predictions of live search results. Extraction ordering follows input order; Tavily does not guarantee it. The response_time number follows the published field type; documentation example strings are not a guarantee of wire type.

API

Main runtime exports: TavilyAPI, TAVILY_NAMESPACE, createRuntime, TAVILY_PRESETS, document, operationIds, supportedOperationIds. Types: SearchHit, SearchScript, Extraction, ApiKey, TavilyAPIOptions, TavilyRuntimeOptions, TavilyRuntime. Server entry: createServer, DEFAULT_PORT, serveTarget; type TavilyServerOptions. CLI entry runs serve and exports no runtime values.

版本与发布记录

@crvouga/mockingbird-service-tavily 共发布 17 个版本,首次发布于 2026/10/05;过去 12 个月发布了 17 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.10.0latest2026/11/11今天
1.9.52026/11/038 天前
1.9.42026/11/038 天前
1.9.32026/11/038 天前
1.9.22026/11/038 天前
1.9.12026/11/038 天前

关于 @crvouga/mockingbird-service-tavily 的常见问题

@crvouga/mockingbird-service-tavily 是什么?

Scripted Tavily search and extraction without web crawling.

如何安装 @crvouga/mockingbird-service-tavily?

在项目目录运行 npm install @crvouga/mockingbird-service-tavily,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 mockingbird-tavily,可以用 npx mockingbird-tavily 直接运行。

@crvouga/mockingbird-service-tavily 支持 TypeScript 吗?

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

@crvouga/mockingbird-service-tavily 支持 ESM 还是 CommonJS?

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

@crvouga/mockingbird-service-tavily 可以商用吗?

@crvouga/mockingbird-service-tavily 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@crvouga/mockingbird-service-tavily 的下载量有多少?

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

@crvouga/mockingbird-service-tavily 还在维护吗?

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