feat: docs update

This commit is contained in:
zhayujie
2026-02-27 16:03:47 +08:00
parent d891312032
commit 6db22827f2
97 changed files with 2801 additions and 1354 deletions

30
docs/tools/bash.mdx Normal file
View File

@@ -0,0 +1,30 @@
---
title: bash - 终端
description: 执行系统命令
---
# bash
在当前工作目录执行 Bash 命令,返回 stdout 和 stderr。`env_config` 中配置的 API Key 会自动注入到环境变量中。
## 依赖
无额外依赖,默认可用。
## 参数
| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `command` | string | 是 | 要执行的命令 |
| `timeout` | integer | 否 | 超时时间(秒) |
## 使用场景
- 安装软件包和依赖
- 运行代码和测试
- 部署应用和服务Nginx 配置、进程管理等)
- 系统运维和排查
<Frame>
<img src="https://cdn.link-ai.tech/doc/20260203121008.png" width="800" />
</Frame>

27
docs/tools/browser.mdx Normal file
View File

@@ -0,0 +1,27 @@
---
title: browser - 浏览器
description: 访问和操作网页
---
# browser
使用浏览器访问和操作网页,支持 JavaScript 渲染的动态页面。
## 依赖
| 依赖 | 安装命令 |
| --- | --- |
| `browser-use` ≥ 0.1.40 | `pip install browser-use` |
| `markdownify` | `pip install markdownify` |
| `playwright` + chromium | `pip install playwright && playwright install chromium` |
## 使用场景
- 访问指定 URL 获取页面内容
- 操作网页元素(点击、输入等)
- 验证部署后的网页效果
- 抓取需要 JS 渲染的动态内容
<Note>
浏览器工具依赖较重,如不需要可不安装。轻量的网页内容获取可使用 `web-fetch` 技能。
</Note>

26
docs/tools/edit.mdx Normal file
View File

@@ -0,0 +1,26 @@
---
title: edit - 文件编辑
description: 通过精确文本替换编辑文件
---
# edit
通过精确文本替换编辑文件。如果 `oldText` 为空则追加到文件末尾。
## 依赖
无额外依赖,默认可用。
## 参数
| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `path` | string | 是 | 文件路径 |
| `oldText` | string | 是 | 要替换的原始文本(为空时追加到末尾) |
| `newText` | string | 是 | 替换后的文本 |
## 使用场景
- 修改配置文件中的特定参数
- 修复代码中的 bug
- 在文件指定位置插入内容

38
docs/tools/env-config.mdx Normal file
View File

@@ -0,0 +1,38 @@
---
title: env_config - 环境变量
description: 管理 API Key 等秘钥配置
---
# env_config
管理工作空间 `.env` 文件中的环境变量API Key 等秘钥),支持通过对话安全地添加和更新。内置安全保护和脱敏策略。
## 依赖
| 依赖 | 安装命令 |
| --- | --- |
| `python-dotenv` ≥ 1.0.0 | `pip install python-dotenv>=1.0.0` |
安装扩展依赖时已包含:`pip3 install -r requirements-optional.txt`
## 参数
| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `action` | string | 是 | 操作类型:`get`、`set`、`list`、`delete` |
| `key` | string | 否 | 环境变量名称 |
| `value` | string | 否 | 环境变量值(仅 `set` 时需要) |
## 使用方式
直接告诉 Agent 需要配置的秘钥Agent 会自动调用该工具:
- "帮我配置 BOCHA_API_KEY"
- "设置 OPENAI_API_KEY 为 sk-xxx"
- "查看已配置的环境变量"
配置的秘钥会自动注入到 `bash` 工具的执行环境中。
<Frame>
<img src="https://cdn.link-ai.tech/doc/20260202234939.png" width="800" />
</Frame>

50
docs/tools/index.mdx Normal file
View File

@@ -0,0 +1,50 @@
---
title: 工具概览
description: CowAgent 内置工具系统
---
工具是 Agent 访问操作系统资源的核心能力。Agent 会根据任务需求智能选择和调用工具,完成文件操作、命令执行、联网搜索、定时任务等各类操作。工具实现在项目的 `agent/tools/` 目录下。
## 内置工具
以下工具默认可用,无需额外配置:
<CardGroup cols={2}>
<Card title="read - 文件读取" icon="file" href="/tools/read">
读取文件内容支持文本、图片、PDF
</Card>
<Card title="write - 文件写入" icon="pen" href="/tools/write">
创建或覆盖写入文件
</Card>
<Card title="edit - 文件编辑" icon="pen-to-square" href="/tools/edit">
通过精确文本替换编辑文件
</Card>
<Card title="ls - 目录列表" icon="folder-open" href="/tools/ls">
列出目录内容
</Card>
<Card title="bash - 终端" icon="terminal" href="/tools/bash">
执行系统命令
</Card>
<Card title="send - 文件发送" icon="paper-plane" href="/tools/send">
向用户发送文件或图片
</Card>
<Card title="memory - 记忆" icon="brain" href="/tools/memory">
搜索和读取长期记忆
</Card>
</CardGroup>
## 可选工具
以下工具需要安装额外依赖或配置 API Key 后启用:
<CardGroup cols={2}>
<Card title="env_config - 环境变量" icon="key" href="/tools/env-config">
管理 API Key 等秘钥配置
</Card>
<Card title="scheduler - 定时任务" icon="clock" href="/tools/scheduler">
创建和管理定时任务
</Card>
<Card title="web_search - 联网搜索" icon="magnifying-glass" href="/tools/web-search">
搜索互联网获取实时信息
</Card>
</CardGroup>

25
docs/tools/ls.mdx Normal file
View File

@@ -0,0 +1,25 @@
---
title: ls - 目录列表
description: 列出目录内容
---
# ls
列出目录内容,按字母排序,目录名带 `/` 后缀,包含隐藏文件。
## 依赖
无额外依赖,默认可用。
## 参数
| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `path` | string | 是 | 目录路径,相对路径基于工作空间目录 |
| `limit` | integer | 否 | 最大返回条目数,默认 500 |
## 使用场景
- 浏览项目结构
- 查找特定文件
- 检查目录是否存在

38
docs/tools/memory.mdx Normal file
View File

@@ -0,0 +1,38 @@
---
title: memory - 记忆
description: 搜索和读取长期记忆
---
# memory
记忆工具包含两个子工具:`memory_search`(搜索记忆)和 `memory_get`(读取记忆文件)。
## 依赖
无额外依赖,默认可用。由 Agent Core 的记忆系统管理。
## memory_search
搜索历史记忆,支持关键词和向量混合检索。
| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `query` | string | 是 | 搜索查询 |
## memory_get
读取特定记忆文件的内容。
| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `path` | string | 是 | 记忆文件的相对路径(如 `MEMORY.md`、`memory/2026-01-01.md` |
| `start_line` | integer | 否 | 起始行号 |
| `end_line` | integer | 否 | 结束行号 |
## 工作方式
Agent 会在以下场景自动调用记忆工具:
- 用户分享重要信息时 → 存储到记忆
- 需要参考历史信息时 → 搜索相关记忆
- 对话达到一定长度时 → 提取摘要存储

26
docs/tools/read.mdx Normal file
View File

@@ -0,0 +1,26 @@
---
title: read - 文件读取
description: 读取文件内容
---
# read
读取文件内容。支持文本文件、PDF 文件、图片(返回元数据)等格式。
## 依赖
无额外依赖,默认可用。
## 参数
| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `path` | string | 是 | 文件路径,相对路径基于工作空间目录 |
| `offset` | integer | 否 | 起始行号1-indexed负值表示从末尾读取 |
| `limit` | integer | 否 | 读取行数 |
## 使用场景
- 查看配置文件、日志文件
- 读取代码文件进行分析
- 检查图片/视频的文件信息

42
docs/tools/scheduler.mdx Normal file
View File

@@ -0,0 +1,42 @@
---
title: scheduler - 定时任务
description: 创建和管理定时任务
---
# scheduler
创建和管理动态定时任务,支持灵活的调度方式和执行模式。
## 依赖
| 依赖 | 安装命令 |
| --- | --- |
| `croniter` ≥ 2.0.0 | `pip install croniter>=2.0.0` |
安装核心依赖时已包含:`pip3 install -r requirements.txt`
## 调度方式
| 方式 | 说明 |
| --- | --- |
| 一次性任务 | 在指定时间执行一次 |
| 固定间隔 | 按固定时间间隔重复执行 |
| Cron 表达式 | 使用 Cron 语法定义复杂调度规则 |
## 执行模式
- **固定消息发送**:到达触发时间时发送预设消息
- **Agent 动态任务**:到达触发时间时由 Agent 智能执行任务
## 使用方式
通过自然语言即可创建和管理定时任务:
- "每天早上 9 点给我发天气预报"
- "每隔 2 小时检查一下服务器状态"
- "明天下午 3 点提醒我开会"
- "查看所有定时任务"
<Frame>
<img src="https://cdn.link-ai.tech/doc/20260202195402.png" width="800" />
</Frame>

25
docs/tools/send.mdx Normal file
View File

@@ -0,0 +1,25 @@
---
title: send - 文件发送
description: 向用户发送文件
---
# send
向用户发送文件(图片、视频、音频、文档等),当用户明确要求发送/分享文件时使用。
## 依赖
无额外依赖,默认可用。
## 参数
| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `path` | string | 是 | 文件路径,可以是绝对路径或相对于工作空间的路径 |
| `message` | string | 否 | 附带的消息说明 |
## 使用场景
- 将生成的代码或文档发送给用户
- 发送截图、图表
- 分享下载的文件

34
docs/tools/web-search.mdx Normal file
View File

@@ -0,0 +1,34 @@
---
title: web_search - 联网搜索
description: 搜索互联网获取实时信息
---
# web_search
搜索互联网获取实时信息、新闻、研究等内容。支持两个搜索后端,自动选择可用的后端。
## 依赖
需要配置至少一个搜索 API Key通过 `env_config` 工具或工作空间 `.env` 文件配置):
| 后端 | 环境变量 | 优先级 | 获取方式 |
| --- | --- | --- | --- |
| 博查搜索 | `BOCHA_API_KEY` | 优先使用 | [博查开放平台](https://open.bochaai.com/) |
| LinkAI 搜索 | `LINKAI_API_KEY` | 可选 | [LinkAI 控制台](https://link-ai.tech/console/interface) |
## 参数
| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `query` | string | 是 | 搜索关键词 |
| `count` | integer | 否 | 返回结果数量1-50默认 10 |
| `freshness` | string | 否 | 时间范围:`noLimit`、`oneDay`、`oneWeek`、`oneMonth`、`oneYear`,或日期范围如 `2025-01-01..2025-02-01` |
| `summary` | boolean | 否 | 是否返回页面摘要(默认 false |
## 使用场景
当用户询问最新信息、需要事实核查或获取实时数据时Agent 会自动调用此工具。
<Note>
如果未配置任何搜索 API Key该工具不会被加载。
</Note>

29
docs/tools/write.mdx Normal file
View File

@@ -0,0 +1,29 @@
---
title: write - 文件写入
description: 创建或覆盖写入文件
---
# write
写入内容到文件。文件不存在则自动创建,已存在则覆盖。自动创建父目录。
## 依赖
无额外依赖,默认可用。
## 参数
| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `path` | string | 是 | 文件路径 |
| `content` | string | 是 | 要写入的内容 |
## 使用场景
- 创建新的代码文件或脚本
- 生成配置文件
- 保存处理结果
<Note>
单次写入不应超过 10KB。对于大文件建议先创建骨架再使用 edit 工具分块添加内容。
</Note>