@fastagent/cli 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -25
- package/cli.js +288 -286
- package/examples/fastagent.config.example.json +5 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
# @fastagent/cli
|
|
2
2
|
|
|
3
|
-
`@fastagent/cli` 是 FastAgent 的公开命令行工具。你可以用它在本地运行 FastAgent、接入内置 IM 通道、安装 skills,并使用一组面向长会话和自动化场景的工程化能力,例如记忆、上下文压缩、任务调度和 sandbox
|
|
3
|
+
`@fastagent/cli` 是 FastAgent 的公开命令行工具。你可以用它在本地运行 FastAgent、接入内置 IM 通道、安装 skills,并使用一组面向长会话和自动化场景的工程化能力,例如记忆、上下文压缩、任务调度和 sandbox 路由。
|
|
4
|
+
当前已 IM 通道包括完整的微信入站媒体处理、保守型非终态反馈、`/resume` 挂起恢复,以及会话内 `cron` / `send_im_media` 这类可主动回发 IM 的能力。
|
|
5
|
+
|
|
6
|
+
注意:npm 安装得到的是一个干净的 CLI/runtime 运行面,默认不预装任何 skills,也不捆绑任何第三方 MCP server / tool。内置 IM 通道和 CLI 自带能力可以直接使用;如果你需要额外的 skills 或 MCP 集成,需要在安装后自行添加或配置。
|
|
4
7
|
|
|
5
8
|
它适合这些场景:
|
|
6
9
|
|
|
7
|
-
- 把 FastAgent 作为本地 CLI agent
|
|
8
|
-
- 通过内置 IM 通道把 FastAgent 跑成 IM
|
|
9
|
-
- 在一个统一入口下使用文件、搜索、MCP、skills,以及记忆、上下文压缩、定时任务、计划清单和后台任务控制等工程化能力
|
|
10
|
+
- 把 FastAgent 作为本地 CLI agent 使用,通过ACP协议实现各类客户端。
|
|
11
|
+
- 通过内置 IM 通道把 FastAgent 跑成 IM 服务(内置微信接入)。
|
|
10
12
|
|
|
11
13
|
## 能力概览
|
|
12
14
|
|
|
13
15
|
当前版本主要聚焦长会话和自动化场景下的工程化运行能力:
|
|
14
16
|
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
17
|
+
- 文件读取、写入和编辑(read/write/edit)
|
|
18
|
+
- 文件搜索与内容搜索(glob/grep)
|
|
19
|
+
- 命令执行与进程管理(bash/powershell)
|
|
18
20
|
- MCP 工具接入与 MCP 资源读取
|
|
19
21
|
- skills 安装、发现和调用
|
|
20
22
|
- 记忆:从 project / user 记忆目录召回可复用的长期信息,并在稳定回合后沉淀新的记忆
|
|
21
|
-
-
|
|
23
|
+
- 上下文压缩:长会话自动压缩历史上下文
|
|
22
24
|
- 定时任务(`cron`):会话级持久化定时调度
|
|
23
|
-
-
|
|
25
|
+
- 计划清单:管理会话内的任务列表(task_**)
|
|
24
26
|
- 后台任务控制:查看、等待和停止子智能体 / 后台运行任务
|
|
27
|
+
- IM runtime:微信扫码登录、图片入模、语音转写复用、文件/视频持久化、typing状态、`/resume` 恢复、文件推送、会话内 `cron` 主动回发
|
|
25
28
|
- local / remote sandbox 运行模式
|
|
26
|
-
- IM runtime:微信扫码登录 / restore、图片入模、语音转写复用、文件/视频持久化、非终态进度/typing、`/resume` 恢复、`send_im_media`、会话内 `cron` 主动回发
|
|
27
29
|
|
|
28
30
|
这些能力很多会在运行时自动生效,当前并不都会以独立子命令的形式直接暴露。
|
|
29
31
|
|
|
@@ -72,10 +74,9 @@ fastagent doctor --config ./fastagent.config.json
|
|
|
72
74
|
- `fastagent --config ...` 裸命令会报固定错误;`--config` 当前必须和 runtime 命令或 `doctor` 一起使用。
|
|
73
75
|
- `fastagent --channel weixin --config ...` 会读取 `gateway`、`sandbox`、`imGateway`;`fastagent doctor --config ...` 只诊断 `sandbox.launcher`
|
|
74
76
|
- `sandbox` 整段都是可选的;只有 remote sandbox 需要从配置文件注入地址/API key,或 local sandbox 需要自定义 launcher 时才需要填写
|
|
75
|
-
-
|
|
76
|
-
- npm 发布包会附带整个 `examples/` 目录;当前配置示例文件是 `examples/fastagent.config.example.json`
|
|
77
|
+
- 当前配置示例文件是 `examples/fastagent.config.example.json`
|
|
77
78
|
|
|
78
|
-
|
|
79
|
+
示例最小配置(IM 通道运行):
|
|
79
80
|
|
|
80
81
|
```json
|
|
81
82
|
{
|
|
@@ -87,13 +88,6 @@ fastagent doctor --config ./fastagent.config.json
|
|
|
87
88
|
"userAgent": "fastagent-cli-example",
|
|
88
89
|
"apiKey": "<your-api-key>"
|
|
89
90
|
},
|
|
90
|
-
"sandbox": {
|
|
91
|
-
"remoteUrl": "http://127.0.0.1:8788",
|
|
92
|
-
"apiKey": "<sandbox-api-key>",
|
|
93
|
-
"launcher": {
|
|
94
|
-
"bin": "fastagent-sandbox"
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
91
|
"imGateway": {
|
|
98
92
|
"workspaceDir": "/abs/workspace",
|
|
99
93
|
"agentId": "agent-weixin-dev",
|
|
@@ -115,12 +109,9 @@ fastagent doctor --config ./fastagent.config.json
|
|
|
115
109
|
- 入站语音复用微信已提供的转写文本,不额外执行本地 STT
|
|
116
110
|
- 入站文件 / 视频持久化保存,当前不直接送入模型
|
|
117
111
|
- 文本模式输出
|
|
118
|
-
-
|
|
119
|
-
- `local` / `remote` sandbox 路由
|
|
112
|
+
- 媒体/文件出站(内置send_im_media等im专有工具)
|
|
120
113
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
### 启动前需要的环境变量
|
|
114
|
+
### 启动前需要的环境变量(如果不显式使用配置文件,需要设置环境变量)
|
|
124
115
|
|
|
125
116
|
必填:
|
|
126
117
|
|
|
@@ -183,6 +174,53 @@ fastagent --channel weixin --output jsonl
|
|
|
183
174
|
fastagent --channel weixin --sandbox remote --sandbox-url http://127.0.0.1:8788
|
|
184
175
|
```
|
|
185
176
|
|
|
177
|
+
### 使用 PM2 后台运行
|
|
178
|
+
|
|
179
|
+
如果你希望把 IM runtime 作为后台常驻服务托管,推荐使用 PM2。
|
|
180
|
+
|
|
181
|
+
先安装 PM2:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
npm install -g pm2
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
建议通过 `command -v fastagent` 取得可执行文件绝对路径,并显式使用 `--interpreter none`。这样 PM2 会把 `fastagent` 当成可执行程序,而不是当前目录下的 Node.js 脚本来加载。
|
|
188
|
+
|
|
189
|
+
使用配置文件启动:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
pm2 start "$(command -v fastagent)" --name fastagent-im --interpreter none -- --channel weixin --output jsonl --config ./fastagent.config.json
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
不使用配置文件时,也可以先导出必需环境变量,再启动:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
export IM_GATEWAY_WORKSPACE_DIR=/weixin-bot/workspace
|
|
199
|
+
export IM_GATEWAY_DATA_DIR=/weixin-bot/data
|
|
200
|
+
export IM_GATEWAY_AGENT_ID=weixin-bot
|
|
201
|
+
export IM_GATEWAY_ALLOW_ALL_PERMISSIONS=true
|
|
202
|
+
|
|
203
|
+
pm2 start "$(command -v fastagent)" --name fastagent-im --interpreter none -- --channel weixin --output jsonl
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
常用管理命令:
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
pm2 logs fastagent-im
|
|
210
|
+
pm2 status
|
|
211
|
+
pm2 restart fastagent-im
|
|
212
|
+
pm2 restart fastagent-im --update-env
|
|
213
|
+
pm2 stop fastagent-im
|
|
214
|
+
pm2 delete fastagent-im
|
|
215
|
+
pm2 save
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
说明:
|
|
219
|
+
|
|
220
|
+
- `fastagent-im` 只是示例进程名,对应 `--name fastagent-im`;你可以按自己的部署场景改成任意更清晰的名字,例如 `weixin-bot`、`fastagent-prod`。
|
|
221
|
+
- `--` 后面的参数会传给 `fastagent`;如果省略它,`--channel`、`--output`、`--config` 之类的参数可能会被 PM2 自己解析掉。
|
|
222
|
+
- 如果你修改的是 shell 环境变量而不是 `--config` 文件,重启时使用 `pm2 restart fastagent-im --update-env` 让新环境生效。
|
|
223
|
+
|
|
186
224
|
如果你要在 npm 安装态启用 `--sandbox local`,需要满足以下其一:
|
|
187
225
|
|
|
188
226
|
- 通过 `FASTAGENT_SANDBOX_RUNTIME_BIN` 和可选 `FASTAGENT_SANDBOX_RUNTIME_ARGS` 显式指定 launcher
|