feat(search): web-search 接线本机 SearXNG 兜底 + 显式开关(她不再拿一把用不了的锤子)
主人报的故障:她调 web-search 必失败(no search endpoint configured)。根因两条:组合根从未注入 WithSearchEndpoint + 配置层根本没有搜索配置项。 - internal/config/websearch.go:WEB_SEARCH_ENDPOINT(默认本机兜底 http://127.0.0.1:38471)+ WEB_SEARCH_TIMEOUT;ResolveEndpoint() 三态裁决(可用/显式关闭/非法),非法值启动即报错 - cmd/cyrene/wire_io_tools.go:组合根唯一的 io 选项装配点;端点不可用 ⇒ WithoutSearch() + 带 source 的 WARN(只记键名与原因,不打印 URL 值) - plugins/tools/io:新增 WithoutSearch()(**根本不进注册面** ⇒ 模型看不见)+ WithSearchTimeout();协议解析逻辑一字未动 - 隐蔽坑(额外查出并修):SearXNG 对 /?q= 回 308 → /search,重定向那一跳走**共享 SSRF 白名单** ⇒ 只注入端点照样被拦。改为**只给 web-search 一件**加宽自己的客户端与白名单,共享白名单与 http/web-fetch 客户端一字未动(有测试钉住它仍拒绝本机网关地址) - .env.example 新增 2 键 + 注释说明「空串/off/none = 不注册」 - 真机 e2e 两次绿(SearXNG 返回 9 条);变异:不注入端点 / 关闭态仍注册 / 默认值改错 / 不并入端点主机 / 重定向用共享白名单 ⇒ 5 条全红
This commit is contained in:
1 parent
8e56163418
commit
8e6c77ad10
11 files changed
+1137
-20
No files matched your search
@@ -20,7 +20,13 @@
|
||||
// - http: GET/POST only, timeouts, response truncation and SSRF protection
|
||||
// (loopback/private/link-local addresses and localhost are refused unless
|
||||
// the host is on an explicit allowlist).
|
||||
// - web-search: requires a configured search endpoint, otherwise a clear error.
|
||||
// - web-search: queries the configured SearXNG-compatible endpoint. When no
|
||||
// usable endpoint is configured the composition root passes WithoutSearch, so
|
||||
// the tool is not registered at all — the model never sees a tool that could
|
||||
// only error. The endpoint itself is operator configuration (the model only
|
||||
// supplies the query), hence its host is trusted by this tool alone: a
|
||||
// loopback fallback endpoint stays reachable without widening the shared
|
||||
// http/web-fetch allowlist.
|
||||
// - web-fetch: size- and content-type-limited readable text extraction.
|
||||
// - knowledge: RAG lookup over the runtime memory retriever; a clear message
|
||||
// when no knowledge base is configured.
|
||||
|
||||
Reference in new issue
Block a user