Skip to content

feat(tool-runtime): add optional Firecrawl web search provider - #160

Open
JuampiHernandez wants to merge 1 commit into
limecloud:mainfrom
JuampiHernandez:add-firecrawl-search
Open

JuampiHernandez wants to merge 1 commit into
limecloud:mainfrom
JuampiHernandez:add-firecrawl-search

Conversation

@JuampiHernandez

Copy link
Copy Markdown

Hi, I'm Juan from the Firecrawl team. Lime's search fallback chain looked like a good fit for Firecrawl search, so I wanted to offer it as an optional provider.

变更摘要

  • Adds Firecrawl as an optional provider for the local WebSearch tool in tool-runtime. It calls Firecrawl /v2/search (POST https://api.firecrawl.dev/v2/search with a Bearer key, limit 10) and maps data.web[] to the existing SearchResult (title, url, description as the snippet). A result with no title uses its URL, and a result with no URL is skipped.
  • User-visible change: one optional env var, FIRECRAWL_API_KEY. When it is unset or blank, the default chain is exactly what it is today and Firecrawl is never called. When it is set, firecrawl joins the default chain in second place, and every existing provider keeps its relative order. WEB_SEARCH_PROVIDER=firecrawl or WEB_SEARCH_PROVIDER_PRIORITY can also select it, like the other providers. A failed request (missing key, HTTP error, bad JSON) is a single-provider error, in Chinese like the existing ones, and the chain moves on.
  • Owner: lime-rs/crates/tool-runtime/src/web_search.rs and web_search/support.rs. The Firecrawl request and response mapping live in a new web_search/firecrawl.rs, included like support.rs, and the tests in a new web_search/firecrawl_tests.rs module, so web_search.rs only gains the provider dispatch arm. serve_once in the existing test module is now pub(super) so the new module can reuse it. Docs: the env table in README.md and README.zh-CN.md, and the search section of internal/aiprompts/architecture.md. Nothing deleted, no new dependency (reqwest and serde_json are already used by the crate). Contributed under the repository's GPL-3.0 license.

i18n 影响

  • 无用户可见文案变化
  • 有用户可见文案变化,已在 PR 描述中列出 namespace
  • 自动翻译 / locale 资源变更,仅作为 PR 草案,不覆盖 source locale

新增 / 变更 namespace

  • None

术语确认

  • 已对照 internal/roadmap/i18n/glossary.md
  • 专名、产品名、Agent 术语、Browser Runtime 术语已保持一致

验证

  • npm run i18n:check
  • npm run verify:local
  • 其他:cargo test -p tool-runtime --lib (all pass, including the new web_search::firecrawl_tests), cargo clippy -p tool-runtime --lib --tests (no warnings on changed lines), cargo fmt -p tool-runtime -- --check, and node scripts/governance/check-architecture-confirmation.mjs against this description (ok). Run on Linux with Rust 1.100.0 and the rusty_v8 artifacts from scripts/lib/rusty-v8-artifacts.mjs.

Live runs through execute_web_search in Live mode with a real Firecrawl key:

  • WEB_SEARCH_PROVIDER=firecrawl: selected_provider is firecrawl with real results (docs.rs/tokio, tokio.rs).
  • Default chain with FIRECRAWL_API_KEY set: the first provider reports its missing key, then firecrawl answers.
  • FIRECRAWL_API_KEY unset: configured_priority matches main exactly and multi_search_engine answers.
  • Invalid key: the firecrawl attempt records the 401 and the chain falls through. The key doesn't appear in the output or metadata.

Not run: npm run verify:local, npm run test:contracts and npm run verify:gui-smoke (no GUI on that machine). On Linux, building tool-runtime needed a local, uncommitted ignore.workspace = true in lime-rs/crates/linux-sandbox/Cargo.toml, because bwrap.rs uses ignore:: without declaring it. That happens on unchanged main too and isn't part of this PR.

架构图确认

  • 本次不属于重大架构变更

非重大原因:不适用;按仓库对 tool-runtime 敏感路径的门禁分类进行架构确认。实际范围是 web_search 内一个可选搜索提供商,没有新增协议、持久化或 runtime。

  • 本次属于重大架构变更,已更新 internal/aiprompts/architecture.md 和相关执行计划

架构影响:tool-runtime::web_search 的 provider selection 在 FIRECRAWL_API_KEY 非空时加入 firecrawl,位置紧接默认链路第一项;请求与响应适配留在 web_search 内,失败沿既有回退链和工具结果投影;不改变模型 Provider 控制面、权限或存储 owner。

架构图更新章节:internal/aiprompts/architecture.md 的“6.3 Provider 与工具组”本地网页搜索链路,新增可选 Firecrawl /v2/search adapter 一行和一段说明。

责任开发者确认:贡献者已核对目录归属、数据流、依赖方向、协议边界与定向回归,请维护者审阅时复核。

  • 已核对目录归属、数据流、依赖方向、协议边界和验证门禁

备注

  • One thing worth your call: FIRECRAWL_API_KEY is the name the Firecrawl CLI and SDKs also read, so someone who already has it set will see firecrawl join the default chain. If you'd rather keep it opt-in only (selected through WEB_SEARCH_PROVIDER / WEB_SEARCH_PROVIDER_PRIORITY), it's a small change and I'm happy to make it.
  • The same Firecrawl key also works with Firecrawl Alexandria, for example its research paper APIs, if a research-focused search mode is ever useful here. This PR does not touch that.

FIRECRAWL_API_KEY adds a firecrawl provider that calls Firecrawl
/v2/search. It joins the default fallback chain only when the key is
set, right after the first provider, and every existing provider keeps
its order. WEB_SEARCH_PROVIDER and WEB_SEARCH_PROVIDER_PRIORITY can also
select it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant