Skip to content

feat(core): 新增 stello_web_search 和 stello_web_fetch 内置 tool #53

@uchouT

Description

@uchouT

背景

当前内置 tool 只有 stello_create_sessionactivate_skill。LLM Agent 在实际使用中经常需要搜索和访问外部 API,但直接使用 fetch/curl 等本地工具在 SaaS 多租户场景下不安全(SSRF、cookie 泄漏、网络环境暴露)。

方案

新增两个内置 tool,通过 Provider 接口注入实现,走服务端代理模式。

新增内置 tool

  • stello_web_search — 搜索引擎查询,返回结构化结果列表
  • stello_web_fetch — 无状态 HTTP 请求代理,每次请求独立

新增 Provider 接口(注入点)

interface SearchProvider {
  search(query: string, options?: { limit?: number }): Promise<{
    results: Array<{ title: string; url: string; snippet: string }>
  }>
}

interface HttpProvider {
  fetch(request: { url: string; method?: string; headers?: Record<string, string>; body?: string }): Promise<{
    status: number; headers: Record<string, string>; body: string
  }>
}

核心约束

  • 无状态:HttpProvider 禁止保留 cookies / session / redirect chain,每次请求完全独立,多用户场景下防止状态泄漏
  • 按需注入:Provider 未注入时对应 tool 不出现在 LLM 可用工具列表中(同 activate_skill 在无 skills 时的行为)
  • 响应处理:HTML 提取正文(去 script/style/nav)、JSON 直传、截断超长响应、拒绝二进制内容
  • 注入位置StelloAgentConfig 层,与 LLMAdapter 同级

实现路径

  1. 定义 SearchProviderHttpProvider 接口
  2. 扩展 createBuiltinToolEntries 接收可选 providers
  3. 实现 tool 定义和 execute 逻辑(含响应处理)
  4. StelloAgentConfig 新增 providers 注入点
  5. 可选:提供本地开发用的默认实现(node fetch wrapper)

关联

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions