@saltpub/agent-bridge 0.1.0 → 0.1.2
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/CHANGELOG.md +496 -463
- package/README.md +214 -214
- package/dist/channels/release/catalog.json +1 -1
- package/dist/channels/release/node_modules/@saltpub/channel-feishu/dist/index.js +7 -9
- package/dist/cli.js +169 -168
- package/dist/index.js +4 -4
- package/dist/launcher.js +7 -7
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,214 +1,214 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<img src="./assets/readme/hero.gif" width="100%" alt="agent-bridge 将八个 IM 渠道的消息经插件、Host 与 OAR runtime 交给六种本机 coding agent,再把 Markdown 或卡片回复送回原会话">
|
|
3
|
-
</p>
|
|
4
|
-
|
|
5
|
-
<p align="center">
|
|
6
|
-
<a href="#快速开始">快速开始</a> ·
|
|
7
|
-
<a href="./docs/channel/INDEX.md">渠道文档</a> ·
|
|
8
|
-
<a href="./docs/architecture/overview.md">架构说明</a>
|
|
9
|
-
</p>
|
|
10
|
-
|
|
11
|
-
> **本地优先的多渠道 coding-agent 桥。** 在 IM 里发出任务,让已经安装并登录的 Agent 在指定工作目录执行,结果回到同一个会话;不需要独立的云端后端或数据库。
|
|
12
|
-
|
|
13
|
-
## 一套入口,本机执行
|
|
14
|
-
|
|
15
|
-
**八个内置连接器**:
|
|
16
|
-
[Xiaojiu](./docs/xiaojiu.md) · [微信](./docs/channel/wechat.md) · [钉钉](./docs/channel/dingtalk.md) · [飞书](./docs/channel/feishu-comments.md) · [Telegram](./docs/channel/telegram.md) · [Slack](./docs/channel/slack.md) · [Discord](./docs/channel/discord.md) · [LINE](./docs/channel/line.md)
|
|
17
|
-
|
|
18
|
-
**六种本机 Agent**:Claude Code、Codex CLI、Pi、OpenCode、OMP、Grok。运行与恢复统一经过 OAR runtime,不由 bridge 直接拼装 CLI 子进程。
|
|
19
|
-
|
|
20
|
-
- **会话跟着 Scope 走**:按 profile、账号、会话与话题保存原生会话引用、工作目录和运行状态;每个 Scope 同时只运行一个主任务。
|
|
21
|
-
- **渠道差异留在插件里**:Webhook、WebSocket 或长轮询都归一化为统一的 `InboundEvent`,宿主只依赖 Plugin SDK。
|
|
22
|
-
- **回复仍在原处**:文本、Markdown 或卡片经原连接器投递;支持流式更新的渠道复用同一条回复,LINE 等渠道采用最终回复。
|
|
23
|
-
- **多套配置在本机管理**:用 profile 区分渠道账号、Agent 和工作目录,通过 CLI、后台服务或本机 Web 控制台管理。
|
|
24
|
-
|
|
25
|
-
## 一条消息如何往返
|
|
26
|
-
|
|
27
|
-
```text
|
|
28
|
-
Connector plugin
|
|
29
|
-
→ InboundEvent → inbox.accept(去重、授权、持久化)
|
|
30
|
-
→ intake dispatch(合并连续输入,斜杠命令优先)
|
|
31
|
-
→ Scope kernel → OAR runtime → 本机 Agent
|
|
32
|
-
→ SessionView → Markdown / card → connector send
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-

|
|
36
|
-
|
|
37
|
-
Webhook 类连接器先确认收件,Agent 工作异步执行。以小九为例,`message_receive` 与 `card_action_trigger` 进入同一套授权、调度和会话链路。运行中可使用独立旁问,访问名单、回调操作和工作目录都有明确边界。
|
|
38
|
-
|
|
39
|
-
小九共享连接器按话题分别续聊;首次进入话题可补入最近 40 条消息,引用可携带一级附件,Codex 可读取通过字节校验的图片。详见[聊天上下文与媒体](./docs/channel/webhook-and-rest.md#共享连接器的聊天上下文与媒体)。
|
|
40
|
-
|
|
41
|
-
## 快速开始
|
|
42
|
-
|
|
43
|
-
### 1. 准备环境
|
|
44
|
-
|
|
45
|
-
- Node.js `>=24.0.0`;源码开发使用 pnpm `10.33.0`。
|
|
46
|
-
- 至少一个已安装并登录的本地 Agent:`claude`、`codex`、`pi`、`opencode`、`omp` 或 `grok`。
|
|
47
|
-
- 对应渠道的 Bot 或应用凭据;小九等 Webhook 渠道还需要平台可访问的 HTTP/HTTPS 回调地址。
|
|
48
|
-
|
|
49
|
-
### 2. 安装并打开本机控制台
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
npm install -g @saltpub/agent-bridge
|
|
53
|
-
agent-bridge web
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
首次打开空的 `AGENT_BRIDGE_HOME` 时,控制台会加载内置渠道。在「渠道管理」选择「添加渠道」,填写 profile 名称并完成平台接入;保持终端运行。若要手动复制本机控制台地址,使用 `agent-bridge web --print`。
|
|
57
|
-
|
|
58
|
-
- **Xiaojiu**:填写 App ID 与 App Secret,接入后配置消息回调,见[小九接入说明](./docs/xiaojiu.md)。
|
|
59
|
-
- **钉钉**:填写 Client ID、Client Secret 与 Robot Code,见[钉钉接入说明](./docs/channel/dingtalk.md)。
|
|
60
|
-
- **飞书 / 微信**:扫描页面二维码并确认;等待期间可以取消后重试。
|
|
61
|
-
- **Telegram / Slack / Discord / LINE**:从各自[渠道文档](./docs/channel/INDEX.md)查看 Token、权限与平台设置。
|
|
62
|
-
|
|
63
|
-
控制台可查看并单独启停 profile;「基础配置」维护 Agent、模型、回复、运行限制与访问控制,「渠道配置」维护平台参数,「日常管理」维护各会话的目录、提示词和群提及覆盖。控制台 URL 含本机访问令牌,请只在本机打开。
|
|
64
|
-
|
|
65
|
-
<details>
|
|
66
|
-
<summary><strong>使用 CLI 创建与管理系统服务</strong></summary>
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
agent-bridge onboarding
|
|
70
|
-
agent-bridge profile create team --agent codex --workspace <工作目录>
|
|
71
|
-
agent-bridge setup --profile team --plugin <已批准插件的ID> --config <渠道配置文件>
|
|
72
|
-
agent-bridge run --profile team --web
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
`setup` 通过插件验证配置和账号身份。飞书应用注册使用 `feishu-setup --profile team`,微信扫码使用 `wechat-setup --profile team`。已有部署的迁移见[运维文档](./docs/operations/process-and-service.md)。
|
|
76
|
-
|
|
77
|
-
每个 profile 绑定一个渠道账号;同一控制端口的 profile 加入同一监听器。后台运行由每个 `AGENT_BRIDGE_HOME` 的唯一系统服务统一管理,多控制端口可以由该服务内的多个监听器承载。
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
|
-
agent-bridge profile list
|
|
81
|
-
agent-bridge ps
|
|
82
|
-
agent-bridge profile autostart team
|
|
83
|
-
agent-bridge start --profile team
|
|
84
|
-
agent-bridge status --profile team
|
|
85
|
-
agent-bridge stop --profile team
|
|
86
|
-
agent-bridge unregister --profile team
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
`kill <uid>` 下线指定在线实例。裸 `start/stop/restart` 操作全部 autostart profile;带 `--profile` 时只操作目标。`run` 始终前台运行单个 profile。系统服务适配器覆盖 Windows 任务计划程序、macOS launchd 和 Linux systemd user;空 autostart 集合保留服务注册但禁用开机启动,`profile autostart <name>` 也可在控制台中切换。
|
|
90
|
-
|
|
91
|
-
</details>
|
|
92
|
-
|
|
93
|
-
<details>
|
|
94
|
-
<summary><strong>聊天内命令</strong></summary>
|
|
95
|
-
|
|
96
|
-
| 命令 | 作用 |
|
|
97
|
-
| --- | --- |
|
|
98
|
-
| `/new`、`/reset` | 清空当前会话 |
|
|
99
|
-
| `/status` | 查看 profile、Agent、工作目录和运行状态 |
|
|
100
|
-
| `/btw [问题]` | 向正在运行的任务旁路提问,不执行工具、不写入历史 |
|
|
101
|
-
| `/agent <claude\|codex\|pi\|opencode\|omp\|grok>` | 空闲时切换当前 profile 的 Agent |
|
|
102
|
-
| `/cd <path>` | 切换工作目录并重置会话 |
|
|
103
|
-
| `/ws list`、`/ws save <name>`、`/ws use <name>` | 管理当前会话的命名工作空间 |
|
|
104
|
-
| `/resume [数量]`、`/resume previous` | 查看兼容历史或恢复当前 Scope 的上一会话 |
|
|
105
|
-
| `/resume use <候选标识>` | 在支持的宿主中精确恢复候选会话 |
|
|
106
|
-
| `/invite user @某人`、`/invite admin @某人` | 添加用户或管理员 |
|
|
107
|
-
| `/invite group` | 允许当前群或频道使用 |
|
|
108
|
-
| `/remove user @某人`、`/remove admin @某人`、`/remove group` | 移除访问资格 |
|
|
109
|
-
| `/stop` | 停止当前任务 |
|
|
110
|
-
| `/timeout [N\|off\|default]` | 调整当前会话超时 |
|
|
111
|
-
| `/doctor [描述]` | 执行低敏诊断 |
|
|
112
|
-
| `/help` | 显示帮助 |
|
|
113
|
-
|
|
114
|
-
连续输入的合并与同轮插入能力因 Agent 协议而异;引用消息会进入下一轮。群聊仅发起者与管理员可发起任务,进程级 `/btw` 独立限额为 2。
|
|
115
|
-
|
|
116
|
-
</details>
|
|
117
|
-
|
|
118
|
-
## 配置、安全与边界
|
|
119
|
-
|
|
120
|
-
配置默认位于 `~/.agent-bridge`,可通过 `AGENT_BRIDGE_HOME` 修改。渠道密钥使用每套 profile 的加密 keystore;迁移时谨慎处理包含 secrets 的 `profile export` 内容。不要把 App Secret、回调密钥、访问令牌或原始 prompt 写入日志或聊天。
|
|
121
|
-
|
|
122
|
-
生产部署应使用 HTTPS、不可猜测的回调路径、`header.appId` 校验和反向代理访问控制。卡片操作使用绑定运行、Scope、操作者与策略版本的限时签名授权,不能只凭回调里的命令字段放行。
|
|
123
|
-
|
|
124
|
-
会话通过原生 conversation 文档与精确 nativeRef 恢复,排队输入由 bridge 持久保存。当前运行不会追溯应用控制台稍后保存的 Bot/会话提示词,也不使用旧版自动上下文重建或共享 memory;数据职责见[上下文管理](./docs/runtime/context-management.md)。
|
|
125
|
-
|
|
126
|
-
旧小九服务中的会议、云文档和个人 OAuth **已从本项目移除**,小九连接器**不支持**这些入口。飞书连接器按当前账号与入口权限组合会议、评论和用户授权。各平台已发布行为的验证范围见[连接器文档](./docs/channel/INDEX.md);没有真实凭据时,本地契约测试不等同于生产平台验收。
|
|
127
|
-
|
|
128
|
-
<details>
|
|
129
|
-
<summary><strong>版本更新与旧配置迁移</strong></summary>
|
|
130
|
-
|
|
131
|
-
```bash
|
|
132
|
-
agent-bridge migrate
|
|
133
|
-
agent-bridge update
|
|
134
|
-
agent-bridge update --check
|
|
135
|
-
agent-bridge changelog
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
`migrate` 可迁移旧版 `agent-bridge` 与 `xiaojiu-agent-bridge` 配置,详见[配置迁移](./docs/operations/offline-migration.md)。
|
|
139
|
-
|
|
140
|
-
CLI 在支持的交互式终端中每 24 小时检查一次 npm Registry,不阻塞命令启动。`update --check` 只查询;`update` 展示稳定版更新说明并安装精确的官方 registry 版本。有会话运行时更新会被拒绝;daemon 或 launcher 托管的安装按各自机制切换,前台 `run` 与控制台进程需要先手动停止。
|
|
141
|
-
|
|
142
|
-
设置 `AGENT_BRIDGE_NO_UPDATE_CHECK=1` 可关闭自动检查。CI、非交互终端和管道输出不会显示更新提示。
|
|
143
|
-
|
|
144
|
-
</details>
|
|
145
|
-
|
|
146
|
-
<details>
|
|
147
|
-
<summary><strong>库:渲染公共 API(RenderInput)</strong></summary>
|
|
148
|
-
|
|
149
|
-
主包把会话视图与投递状态转换为通用 ViewModel 或文本。小九卡片渲染使用 `renderCard(renderViewModel(input))`。
|
|
150
|
-
|
|
151
|
-
```ts
|
|
152
|
-
import {
|
|
153
|
-
renderViewModel,
|
|
154
|
-
renderText,
|
|
155
|
-
initialSessionView,
|
|
156
|
-
reduceSessionView,
|
|
157
|
-
streamsOf,
|
|
158
|
-
type RenderInput,
|
|
159
|
-
type ReplyDeliveryState,
|
|
160
|
-
type SessionView,
|
|
161
|
-
} from '@saltpub/agent-bridge';
|
|
162
|
-
import { renderCard } from '@saltpub/channel-xiaojiu/renderer';
|
|
163
|
-
|
|
164
|
-
// records 可跨多个原生 epoch;第三参必须传每条 record 所属流的 epoch 键。
|
|
165
|
-
let view: SessionView = initialSessionView();
|
|
166
|
-
for (const stream of streamsOf(records)) {
|
|
167
|
-
for (const record of stream.records) {
|
|
168
|
-
view = reduceSessionView(view, record, stream.streamId);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const delivery: ReplyDeliveryState = {
|
|
173
|
-
replyId: 'reply-1',
|
|
174
|
-
turnId: 'turn-1',
|
|
175
|
-
state: 'sent', // draft | claimed | sent | ambiguous
|
|
176
|
-
receipt: { messageId: 'om-1', receivedAt: Date.now() },
|
|
177
|
-
error: null,
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
const input: RenderInput = { view, delivery };
|
|
181
|
-
const card = renderCard(renderViewModel(input));
|
|
182
|
-
const text = renderText(input);
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
运行卡可以带终止按钮。已有回调签发器的宿主可绑定当前运行的授权;传入 `stopRequested: true` 后按钮变灰,完成、中断或投递结果未知时移除按钮。
|
|
186
|
-
|
|
187
|
-
```ts
|
|
188
|
-
function renderManagedCard(
|
|
189
|
-
input: RenderInput,
|
|
190
|
-
signForThisRun: (action: 'stop') => string,
|
|
191
|
-
stopRequested = false,
|
|
192
|
-
) {
|
|
193
|
-
return renderCard(renderViewModel(input), { signCallback: signForThisRun, stopRequested });
|
|
194
|
-
}
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
宿主负责签发并校验绑定运行、会话和操作者的令牌,同时检查有效期与防重放。`delivery.state === 'ambiguous'` 表示回执未确认,必须按投递失败处理。旧版渲染合同的迁移说明见 [CHANGELOG](./CHANGELOG.md)。
|
|
198
|
-
|
|
199
|
-
</details>
|
|
200
|
-
|
|
201
|
-
## 开发与验证
|
|
202
|
-
|
|
203
|
-
```bash
|
|
204
|
-
pnpm install
|
|
205
|
-
pnpm typecheck
|
|
206
|
-
pnpm test
|
|
207
|
-
pnpm build
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
源码目录可用 `pnpm cli web`
|
|
211
|
-
|
|
212
|
-
## License
|
|
213
|
-
|
|
214
|
-
[MIT](./LICENSE)。
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="./assets/readme/hero.gif" width="100%" alt="agent-bridge 将八个 IM 渠道的消息经插件、Host 与 OAR runtime 交给六种本机 coding agent,再把 Markdown 或卡片回复送回原会话">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="#快速开始">快速开始</a> ·
|
|
7
|
+
<a href="./docs/channel/INDEX.md">渠道文档</a> ·
|
|
8
|
+
<a href="./docs/architecture/overview.md">架构说明</a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
> **本地优先的多渠道 coding-agent 桥。** 在 IM 里发出任务,让已经安装并登录的 Agent 在指定工作目录执行,结果回到同一个会话;不需要独立的云端后端或数据库。
|
|
12
|
+
|
|
13
|
+
## 一套入口,本机执行
|
|
14
|
+
|
|
15
|
+
**八个内置连接器**:
|
|
16
|
+
[Xiaojiu](./docs/xiaojiu.md) · [微信](./docs/channel/wechat.md) · [钉钉](./docs/channel/dingtalk.md) · [飞书](./docs/channel/feishu-comments.md) · [Telegram](./docs/channel/telegram.md) · [Slack](./docs/channel/slack.md) · [Discord](./docs/channel/discord.md) · [LINE](./docs/channel/line.md)
|
|
17
|
+
|
|
18
|
+
**六种本机 Agent**:Claude Code、Codex CLI、Pi、OpenCode、OMP、Grok。运行与恢复统一经过 OAR runtime,不由 bridge 直接拼装 CLI 子进程。
|
|
19
|
+
|
|
20
|
+
- **会话跟着 Scope 走**:按 profile、账号、会话与话题保存原生会话引用、工作目录和运行状态;每个 Scope 同时只运行一个主任务。
|
|
21
|
+
- **渠道差异留在插件里**:Webhook、WebSocket 或长轮询都归一化为统一的 `InboundEvent`,宿主只依赖 Plugin SDK。
|
|
22
|
+
- **回复仍在原处**:文本、Markdown 或卡片经原连接器投递;支持流式更新的渠道复用同一条回复,LINE 等渠道采用最终回复。
|
|
23
|
+
- **多套配置在本机管理**:用 profile 区分渠道账号、Agent 和工作目录,通过 CLI、后台服务或本机 Web 控制台管理。
|
|
24
|
+
|
|
25
|
+
## 一条消息如何往返
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
Connector plugin
|
|
29
|
+
→ InboundEvent → inbox.accept(去重、授权、持久化)
|
|
30
|
+
→ intake dispatch(合并连续输入,斜杠命令优先)
|
|
31
|
+
→ Scope kernel → OAR runtime → 本机 Agent
|
|
32
|
+
→ SessionView → Markdown / card → connector send
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+

|
|
36
|
+
|
|
37
|
+
Webhook 类连接器先确认收件,Agent 工作异步执行。以小九为例,`message_receive` 与 `card_action_trigger` 进入同一套授权、调度和会话链路。运行中可使用独立旁问,访问名单、回调操作和工作目录都有明确边界。
|
|
38
|
+
|
|
39
|
+
小九共享连接器按话题分别续聊;首次进入话题可补入最近 40 条消息,引用可携带一级附件,Codex 可读取通过字节校验的图片。详见[聊天上下文与媒体](./docs/channel/webhook-and-rest.md#共享连接器的聊天上下文与媒体)。
|
|
40
|
+
|
|
41
|
+
## 快速开始
|
|
42
|
+
|
|
43
|
+
### 1. 准备环境
|
|
44
|
+
|
|
45
|
+
- Node.js `>=24.0.0`;源码开发使用 pnpm `10.33.0`。
|
|
46
|
+
- 至少一个已安装并登录的本地 Agent:`claude`、`codex`、`pi`、`opencode`、`omp` 或 `grok`。
|
|
47
|
+
- 对应渠道的 Bot 或应用凭据;小九等 Webhook 渠道还需要平台可访问的 HTTP/HTTPS 回调地址。
|
|
48
|
+
|
|
49
|
+
### 2. 安装并打开本机控制台
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm install -g @saltpub/agent-bridge
|
|
53
|
+
agent-bridge web
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
首次打开空的 `AGENT_BRIDGE_HOME` 时,控制台会加载内置渠道。在「渠道管理」选择「添加渠道」,填写 profile 名称并完成平台接入;保持终端运行。若要手动复制本机控制台地址,使用 `agent-bridge web --print`。
|
|
57
|
+
|
|
58
|
+
- **Xiaojiu**:填写 App ID 与 App Secret,接入后配置消息回调,见[小九接入说明](./docs/xiaojiu.md)。
|
|
59
|
+
- **钉钉**:填写 Client ID、Client Secret 与 Robot Code,见[钉钉接入说明](./docs/channel/dingtalk.md)。
|
|
60
|
+
- **飞书 / 微信**:扫描页面二维码并确认;等待期间可以取消后重试。
|
|
61
|
+
- **Telegram / Slack / Discord / LINE**:从各自[渠道文档](./docs/channel/INDEX.md)查看 Token、权限与平台设置。
|
|
62
|
+
|
|
63
|
+
控制台可查看并单独启停 profile;「基础配置」维护 Agent、模型、回复、运行限制与访问控制,「渠道配置」维护平台参数,「日常管理」维护各会话的目录、提示词和群提及覆盖。控制台 URL 含本机访问令牌,请只在本机打开。
|
|
64
|
+
|
|
65
|
+
<details>
|
|
66
|
+
<summary><strong>使用 CLI 创建与管理系统服务</strong></summary>
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
agent-bridge onboarding
|
|
70
|
+
agent-bridge profile create team --agent codex --workspace <工作目录>
|
|
71
|
+
agent-bridge setup --profile team --plugin <已批准插件的ID> --config <渠道配置文件>
|
|
72
|
+
agent-bridge run --profile team --web
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`setup` 通过插件验证配置和账号身份。飞书应用注册使用 `feishu-setup --profile team`,微信扫码使用 `wechat-setup --profile team`。已有部署的迁移见[运维文档](./docs/operations/process-and-service.md)。
|
|
76
|
+
|
|
77
|
+
每个 profile 绑定一个渠道账号;同一控制端口的 profile 加入同一监听器。后台运行由每个 `AGENT_BRIDGE_HOME` 的唯一系统服务统一管理,多控制端口可以由该服务内的多个监听器承载。
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
agent-bridge profile list
|
|
81
|
+
agent-bridge ps
|
|
82
|
+
agent-bridge profile autostart team
|
|
83
|
+
agent-bridge start --profile team
|
|
84
|
+
agent-bridge status --profile team
|
|
85
|
+
agent-bridge stop --profile team
|
|
86
|
+
agent-bridge unregister --profile team
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`kill <uid>` 下线指定在线实例。裸 `start/stop/restart` 操作全部 autostart profile;带 `--profile` 时只操作目标。`run` 始终前台运行单个 profile。系统服务适配器覆盖 Windows 任务计划程序、macOS launchd 和 Linux systemd user;空 autostart 集合保留服务注册但禁用开机启动,`profile autostart <name>` 也可在控制台中切换。
|
|
90
|
+
|
|
91
|
+
</details>
|
|
92
|
+
|
|
93
|
+
<details>
|
|
94
|
+
<summary><strong>聊天内命令</strong></summary>
|
|
95
|
+
|
|
96
|
+
| 命令 | 作用 |
|
|
97
|
+
| --- | --- |
|
|
98
|
+
| `/new`、`/reset` | 清空当前会话 |
|
|
99
|
+
| `/status` | 查看 profile、Agent、工作目录和运行状态 |
|
|
100
|
+
| `/btw [问题]` | 向正在运行的任务旁路提问,不执行工具、不写入历史 |
|
|
101
|
+
| `/agent <claude\|codex\|pi\|opencode\|omp\|grok>` | 空闲时切换当前 profile 的 Agent |
|
|
102
|
+
| `/cd <path>` | 切换工作目录并重置会话 |
|
|
103
|
+
| `/ws list`、`/ws save <name>`、`/ws use <name>` | 管理当前会话的命名工作空间 |
|
|
104
|
+
| `/resume [数量]`、`/resume previous` | 查看兼容历史或恢复当前 Scope 的上一会话 |
|
|
105
|
+
| `/resume use <候选标识>` | 在支持的宿主中精确恢复候选会话 |
|
|
106
|
+
| `/invite user @某人`、`/invite admin @某人` | 添加用户或管理员 |
|
|
107
|
+
| `/invite group` | 允许当前群或频道使用 |
|
|
108
|
+
| `/remove user @某人`、`/remove admin @某人`、`/remove group` | 移除访问资格 |
|
|
109
|
+
| `/stop` | 停止当前任务 |
|
|
110
|
+
| `/timeout [N\|off\|default]` | 调整当前会话超时 |
|
|
111
|
+
| `/doctor [描述]` | 执行低敏诊断 |
|
|
112
|
+
| `/help` | 显示帮助 |
|
|
113
|
+
|
|
114
|
+
连续输入的合并与同轮插入能力因 Agent 协议而异;引用消息会进入下一轮。群聊仅发起者与管理员可发起任务,进程级 `/btw` 独立限额为 2。
|
|
115
|
+
|
|
116
|
+
</details>
|
|
117
|
+
|
|
118
|
+
## 配置、安全与边界
|
|
119
|
+
|
|
120
|
+
配置默认位于 `~/.agent-bridge`,可通过 `AGENT_BRIDGE_HOME` 修改。渠道密钥使用每套 profile 的加密 keystore;迁移时谨慎处理包含 secrets 的 `profile export` 内容。不要把 App Secret、回调密钥、访问令牌或原始 prompt 写入日志或聊天。
|
|
121
|
+
|
|
122
|
+
生产部署应使用 HTTPS、不可猜测的回调路径、`header.appId` 校验和反向代理访问控制。卡片操作使用绑定运行、Scope、操作者与策略版本的限时签名授权,不能只凭回调里的命令字段放行。
|
|
123
|
+
|
|
124
|
+
会话通过原生 conversation 文档与精确 nativeRef 恢复,排队输入由 bridge 持久保存。当前运行不会追溯应用控制台稍后保存的 Bot/会话提示词,也不使用旧版自动上下文重建或共享 memory;数据职责见[上下文管理](./docs/runtime/context-management.md)。
|
|
125
|
+
|
|
126
|
+
旧小九服务中的会议、云文档和个人 OAuth **已从本项目移除**,小九连接器**不支持**这些入口。飞书连接器按当前账号与入口权限组合会议、评论和用户授权。各平台已发布行为的验证范围见[连接器文档](./docs/channel/INDEX.md);没有真实凭据时,本地契约测试不等同于生产平台验收。
|
|
127
|
+
|
|
128
|
+
<details>
|
|
129
|
+
<summary><strong>版本更新与旧配置迁移</strong></summary>
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
agent-bridge migrate
|
|
133
|
+
agent-bridge update
|
|
134
|
+
agent-bridge update --check
|
|
135
|
+
agent-bridge changelog
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
`migrate` 可迁移旧版 `agent-bridge` 与 `xiaojiu-agent-bridge` 配置,详见[配置迁移](./docs/operations/offline-migration.md)。
|
|
139
|
+
|
|
140
|
+
CLI 在支持的交互式终端中每 24 小时检查一次 npm Registry,不阻塞命令启动。`update --check` 只查询;`update` 展示稳定版更新说明并安装精确的官方 registry 版本。有会话运行时更新会被拒绝;daemon 或 launcher 托管的安装按各自机制切换,前台 `run` 与控制台进程需要先手动停止。
|
|
141
|
+
|
|
142
|
+
设置 `AGENT_BRIDGE_NO_UPDATE_CHECK=1` 可关闭自动检查。CI、非交互终端和管道输出不会显示更新提示。
|
|
143
|
+
|
|
144
|
+
</details>
|
|
145
|
+
|
|
146
|
+
<details>
|
|
147
|
+
<summary><strong>库:渲染公共 API(RenderInput)</strong></summary>
|
|
148
|
+
|
|
149
|
+
主包把会话视图与投递状态转换为通用 ViewModel 或文本。小九卡片渲染使用 `renderCard(renderViewModel(input))`。
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
import {
|
|
153
|
+
renderViewModel,
|
|
154
|
+
renderText,
|
|
155
|
+
initialSessionView,
|
|
156
|
+
reduceSessionView,
|
|
157
|
+
streamsOf,
|
|
158
|
+
type RenderInput,
|
|
159
|
+
type ReplyDeliveryState,
|
|
160
|
+
type SessionView,
|
|
161
|
+
} from '@saltpub/agent-bridge';
|
|
162
|
+
import { renderCard } from '@saltpub/channel-xiaojiu/renderer';
|
|
163
|
+
|
|
164
|
+
// records 可跨多个原生 epoch;第三参必须传每条 record 所属流的 epoch 键。
|
|
165
|
+
let view: SessionView = initialSessionView();
|
|
166
|
+
for (const stream of streamsOf(records)) {
|
|
167
|
+
for (const record of stream.records) {
|
|
168
|
+
view = reduceSessionView(view, record, stream.streamId);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const delivery: ReplyDeliveryState = {
|
|
173
|
+
replyId: 'reply-1',
|
|
174
|
+
turnId: 'turn-1',
|
|
175
|
+
state: 'sent', // draft | claimed | sent | ambiguous
|
|
176
|
+
receipt: { messageId: 'om-1', receivedAt: Date.now() },
|
|
177
|
+
error: null,
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const input: RenderInput = { view, delivery };
|
|
181
|
+
const card = renderCard(renderViewModel(input));
|
|
182
|
+
const text = renderText(input);
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
运行卡可以带终止按钮。已有回调签发器的宿主可绑定当前运行的授权;传入 `stopRequested: true` 后按钮变灰,完成、中断或投递结果未知时移除按钮。
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
function renderManagedCard(
|
|
189
|
+
input: RenderInput,
|
|
190
|
+
signForThisRun: (action: 'stop') => string,
|
|
191
|
+
stopRequested = false,
|
|
192
|
+
) {
|
|
193
|
+
return renderCard(renderViewModel(input), { signCallback: signForThisRun, stopRequested });
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
宿主负责签发并校验绑定运行、会话和操作者的令牌,同时检查有效期与防重放。`delivery.state === 'ambiguous'` 表示回执未确认,必须按投递失败处理。旧版渲染合同的迁移说明见 [CHANGELOG](./CHANGELOG.md)。
|
|
198
|
+
|
|
199
|
+
</details>
|
|
200
|
+
|
|
201
|
+
## 开发与验证
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
pnpm install
|
|
205
|
+
pnpm typecheck
|
|
206
|
+
pnpm test
|
|
207
|
+
pnpm build
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
源码目录可用 `pnpm cli web` 启动控制台。测试与发布见[开发文档](./docs/development/testing-and-release.md),领域术语见[词表](./CONTEXT.md)。
|
|
211
|
+
|
|
212
|
+
## License
|
|
213
|
+
|
|
214
|
+
[MIT](./LICENSE)。
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"pin": {
|
|
43
43
|
"package": "@saltpub/channel-feishu",
|
|
44
44
|
"version": "3.0.0",
|
|
45
|
-
"integrity": "sha256-tree-v1:
|
|
45
|
+
"integrity": "sha256-tree-v1:661d9432039677c516ae9e4497af436e80865b03596ca47f1db2978698c50192",
|
|
46
46
|
"path": "node_modules/@saltpub/channel-feishu"
|
|
47
47
|
}
|
|
48
48
|
},
|
|
@@ -1366,8 +1366,7 @@ var SnapshotCot = class {
|
|
|
1366
1366
|
const current = this.currentText;
|
|
1367
1367
|
if (!current) return;
|
|
1368
1368
|
emit("TEXT_MESSAGE_END", { messageId: current.messageId });
|
|
1369
|
-
current.
|
|
1370
|
-
current.closed = true;
|
|
1369
|
+
current.phase = "closed";
|
|
1371
1370
|
this.currentText = void 0;
|
|
1372
1371
|
};
|
|
1373
1372
|
const reasoningDelta = snapshot.reasoning.content.startsWith(this.reasoningSent) ? snapshot.reasoning.content.slice(this.reasoningSent.length) : "";
|
|
@@ -1385,27 +1384,26 @@ var SnapshotCot = class {
|
|
|
1385
1384
|
for (const part of snapshot.parts) {
|
|
1386
1385
|
if (part.kind === "text") {
|
|
1387
1386
|
const previous2 = this.texts.get(part.id);
|
|
1388
|
-
const state2 = previous2 ?? { messageId: `text-${this.delivery}-${++this.textIndex}`, sent: "",
|
|
1387
|
+
const state2 = previous2 ?? { messageId: `text-${this.delivery}-${++this.textIndex}`, sent: "", phase: "new" };
|
|
1389
1388
|
const delta = part.text.startsWith(state2.sent) ? part.text.slice(state2.sent.length) : "";
|
|
1390
|
-
if (!
|
|
1389
|
+
if (!previous2 || delta || part.streaming && state2.phase === "new") {
|
|
1391
1390
|
closeReasoning();
|
|
1392
1391
|
if (!this.textStepOpen) {
|
|
1393
1392
|
this.textStepOpen = true;
|
|
1394
1393
|
emit("STEP_STARTED", { stepId: this.finalStepId, stepName: "\u8F93\u51FA\u8FC7\u7A0B" });
|
|
1395
1394
|
}
|
|
1396
|
-
if (
|
|
1395
|
+
if (state2.phase !== "closed") {
|
|
1397
1396
|
if (this.currentText !== state2) closeText();
|
|
1398
|
-
if (
|
|
1399
|
-
state2.
|
|
1397
|
+
if (state2.phase !== "open") {
|
|
1398
|
+
state2.phase = "open";
|
|
1400
1399
|
this.currentText = state2;
|
|
1401
1400
|
emit("TEXT_MESSAGE_START", { messageId: state2.messageId, role: "assistant" });
|
|
1402
1401
|
}
|
|
1403
1402
|
if (delta) emit("TEXT_MESSAGE_CONTENT", { messageId: state2.messageId, delta: truncate(delta, COT_TEXT_MAX) });
|
|
1404
1403
|
}
|
|
1405
1404
|
}
|
|
1406
|
-
if (!part.streaming && state2.open) closeText();
|
|
1405
|
+
if (!part.streaming && state2.phase === "open") closeText();
|
|
1407
1406
|
state2.sent = part.text;
|
|
1408
|
-
state2.seen = true;
|
|
1409
1407
|
this.texts.set(part.id, state2);
|
|
1410
1408
|
continue;
|
|
1411
1409
|
}
|