@saltpub/xiaojiu-agent-bridge 0.1.0
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 +25 -0
- package/LICENSE +21 -0
- package/README.md +161 -0
- package/bin/xiaojiu-agent-bridge.mjs +2 -0
- package/dist/cli.js +16731 -0
- package/dist/index.d.ts +165 -0
- package/dist/index.js +681 -0
- package/package.json +119 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# xiaojiu-agent-bridge
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Highlights
|
|
6
|
+
|
|
7
|
+
- Add npm Registry update checks with a 24-hour local cache.
|
|
8
|
+
- Add `update` and `changelog` CLI commands for version visibility.
|
|
9
|
+
- Publish the package under the public `@saltpub` organization scope.
|
|
10
|
+
- Verify the npm tarball contains no private repository metadata or source files.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- npm-based update notices for interactive terminal sessions.
|
|
15
|
+
- Structured update metadata in the published package manifest.
|
|
16
|
+
- Local release notes available through `xiaojiu-agent-bridge changelog`.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- Use the package manifest version for Agent protocol client information.
|
|
21
|
+
- Keep update state separate from profile and runtime state.
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- Prevent private repository URLs, credentials, and source artifacts from entering the npm package.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Xiaojiu Agent Bridge contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="./assets/readme/hero.gif" width="100%" alt="Xiaojiu Agent Bridge routes a Xiaojiu message through the local bridge runtime to one of five local coding-agent CLIs and returns the reply to the same Xiaojiu session">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<sub>静态 SVG 回退:Xiaojiu 消息 → 本机 CLI Agent → 回到同一会话 · <a href="./assets/readme/hero.svg">查看完整路由图</a></sub>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
# xiaojiu-agent-bridge
|
|
10
|
+
|
|
11
|
+
在 Xiaojiu 里发一句私聊或群内 `@` 消息,让本机的 Claude Code、Codex CLI、Pi、OpenCode 或 OMP 在指定工作目录执行;Markdown 或卡片结果回到同一个会话。
|
|
12
|
+
|
|
13
|
+
> 本地优先的消息桥:不自建后端,把 Xiaojiu 的聊天入口接到你已经安装好的 coding-agent CLI。
|
|
14
|
+
|
|
15
|
+
## 你会得到什么
|
|
16
|
+
|
|
17
|
+
- **从聊天开始**:接收 `message_receive` 与 `card_action_trigger` Webhook,快速确认后异步处理。
|
|
18
|
+
- **会话不丢上下文**:按聊天 / 话题 scope 保存 Agent 会话、工作目录与运行状态。
|
|
19
|
+
- **一套入口,多种 Agent**:统一适配 Claude Code、Codex CLI、Pi、OpenCode 和 OMP。
|
|
20
|
+
- **可控地运行**:合并连续输入,执行访问控制、超时、中断、恢复和附件缓存。
|
|
21
|
+
- **结果回到原处**:以 Markdown 或消息卡片回复;流式输出通过更新消息模拟。
|
|
22
|
+
- **团队可管理**:用 profile、后台服务和本机 Web 控制台管理多套 Bot 配置。
|
|
23
|
+
|
|
24
|
+
## 先看一条消息的完整路径
|
|
25
|
+
|
|
26
|
+
下面是项目机制示意,不是生产环境截图:
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
Xiaojiu Webhook
|
|
30
|
+
│ message_receive / card_action_trigger
|
|
31
|
+
▼
|
|
32
|
+
HTTP 校验 · header.id 去重 · 立即 200
|
|
33
|
+
▼
|
|
34
|
+
消息合并 · scope · 运行策略 · 工作目录
|
|
35
|
+
▼
|
|
36
|
+
RunExecutor → AgentAdapter → 本机 CLI 子进程
|
|
37
|
+
▼
|
|
38
|
+
RunState → Markdown / 卡片 → Xiaojiu 会话
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
每个 scope 同时最多运行一个任务;全局子进程池默认最多 10 个运行,范围为 1–50。共享服务器可托管多个 profile,并按 App ID 分发事件。
|
|
42
|
+
|
|
43
|
+
## 快速开始
|
|
44
|
+
|
|
45
|
+
### 环境要求
|
|
46
|
+
|
|
47
|
+
- Node.js `>= 20.12.0`
|
|
48
|
+
- pnpm `10`(源码开发)
|
|
49
|
+
- 已安装并登录至少一个本地 Agent:`claude`、`codex`、`pi`、`opencode` 或 `omp`
|
|
50
|
+
- 一个 Xiaojiu Bot,以及 Xiaojiu 能访问的 HTTP/HTTPS 回调地址
|
|
51
|
+
|
|
52
|
+
### 安装与构建
|
|
53
|
+
|
|
54
|
+
从 npm 安装稳定版:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm install -g @saltpub/xiaojiu-agent-bridge
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
源码开发:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pnpm install
|
|
64
|
+
pnpm typecheck
|
|
65
|
+
pnpm build
|
|
66
|
+
npm install -g .
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 启动第一个 profile
|
|
70
|
+
|
|
71
|
+
把占位符换成你的 Bot 凭据与 Bot Owner 工号:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
xiaojiu-agent-bridge run \
|
|
75
|
+
--app-id <app-id> \
|
|
76
|
+
--app-secret <app-secret> \
|
|
77
|
+
--owner <staff-no>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
启动后在 Xiaojiu 私聊 Bot 发送 `/status`,即可确认 profile、Agent、工作目录和运行状态。平台地址、凭据、事件订阅与回调安全见 [`docs/xiaojiu.md`](./docs/xiaojiu.md)。
|
|
81
|
+
|
|
82
|
+
## 多 profile 与服务
|
|
83
|
+
|
|
84
|
+
需要在同一台机器上管理多个 Agent 时,先创建 profile:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
xiaojiu-agent-bridge profile create claude --agent claude --owner <staff-no>
|
|
88
|
+
xiaojiu-agent-bridge profile create codex --agent codex --owner <staff-no>
|
|
89
|
+
xiaojiu-agent-bridge profile list
|
|
90
|
+
xiaojiu-agent-bridge profile use claude
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
一次 `start` / `run` 只上线一个 bot。默认共用 9699 时,第二个 `start --profile` 会加入已有监听,而不是再起一套服务。用 `ps` 查看各进程的端口和在线 bot。
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
xiaojiu-agent-bridge start
|
|
97
|
+
xiaojiu-agent-bridge start --profile codex
|
|
98
|
+
xiaojiu-agent-bridge ps
|
|
99
|
+
xiaojiu-agent-bridge status
|
|
100
|
+
xiaojiu-agent-bridge stop
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
需要本机网页时加 `--web-ui`。`start` 会按操作系统注册服务:macOS 使用 launchd,Linux 使用 systemd,Windows 使用任务计划程序。也可以用 `kill <id|pid|#>` 停止指定进程。
|
|
104
|
+
|
|
105
|
+
## Xiaojiu 内命令
|
|
106
|
+
|
|
107
|
+
| 命令 | 作用 |
|
|
108
|
+
| --- | --- |
|
|
109
|
+
| `/new`、`/reset` | 清空当前会话 |
|
|
110
|
+
| `/status` | 查看 profile、Agent、工作目录和运行状态 |
|
|
111
|
+
| `/agent <claude\|codex\|pi\|opencode\|omp>` | 空闲时切换当前 profile 的 Agent |
|
|
112
|
+
| `/cd <path>` | 切换工作目录并重置会话 |
|
|
113
|
+
| `/ws list`、`/ws save <name>`、`/ws use <name>` | 管理命名工作空间 |
|
|
114
|
+
| `/resume` | 恢复兼容的历史会话 |
|
|
115
|
+
| `/invite user @某人` | 允许用户私聊使用 |
|
|
116
|
+
| `/invite admin @某人` | 添加管理员 |
|
|
117
|
+
| `/invite group` | 允许当前群或频道使用 |
|
|
118
|
+
| `/remove user @某人`、`/remove admin @某人`、`/remove group` | 移除访问资格 |
|
|
119
|
+
| `/stop` | 停止当前任务 |
|
|
120
|
+
| `/timeout [N\|off\|default]` | 调整当前会话超时 |
|
|
121
|
+
| `/doctor [描述]` | 执行低敏诊断 |
|
|
122
|
+
| `/help` | 显示帮助 |
|
|
123
|
+
|
|
124
|
+
## 配置与安全
|
|
125
|
+
|
|
126
|
+
默认配置目录为 `~/.xiaojiu-agent-bridge`,可通过 `XIAOJIU_BRIDGE_HOME` 修改。Webhook 默认监听 `0.0.0.0:9699`,默认 profile 回调路径为 `/webhook/<profile>`。
|
|
127
|
+
|
|
128
|
+
生产部署请使用 HTTPS、不可猜测的回调路径、`header.appId` 校验和反向代理访问控制。不要把 App Secret、回调密钥、访问令牌或原始 prompt 写进配置、日志或聊天。
|
|
129
|
+
|
|
130
|
+
密钥由 bridge 加密存储;如需迁移 profile,可使用 `profile export`,并谨慎处理包含 secrets 的导出内容。
|
|
131
|
+
|
|
132
|
+
## 版本更新
|
|
133
|
+
|
|
134
|
+
CLI 在交互式终端中每 24 小时异步检查一次 npm Registry,不阻塞当前命令。也可以手动检查和查看随包发布的更新记录:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
xiaojiu-agent-bridge update --check
|
|
138
|
+
xiaojiu-agent-bridge changelog
|
|
139
|
+
npm install -g @saltpub/xiaojiu-agent-bridge@latest
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
设置 `XIAOJIU_BRIDGE_NO_UPDATE_CHECK=1` 可以关闭自动检查。CI、非交互终端和管道输出不会显示更新提示。
|
|
143
|
+
|
|
144
|
+
## 开发验证
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
pnpm vitest run tests/unit/channel tests/integration/channel
|
|
148
|
+
pnpm typecheck
|
|
149
|
+
pnpm test
|
|
150
|
+
pnpm build
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
没有真实 Xiaojiu 凭据时,只能验证本地契约和模拟 HTTP 流程。发布包只包含 `dist`、`bin`、`README.md`、`CHANGELOG.md` 与 `LICENSE`;平台级接入资料保留在 [`docs/xiaojiu.md`](./docs/xiaojiu.md)。
|
|
154
|
+
|
|
155
|
+
## 边界
|
|
156
|
+
|
|
157
|
+
会议智能体、云文档评论、账号切换和 WebSocket 重连等上游能力已从本项目移除,不支持对应命令或流程。本项目不包含独立后端、数据库或面向 Xiaojiu 用户的前端;`web/` 只构建本机管理控制台。
|
|
158
|
+
|
|
159
|
+
## License
|
|
160
|
+
|
|
161
|
+
MIT。原项目许可证保留在 [`LICENSE`](./LICENSE)。
|