cortico-world-astrbot 1.1.3 → 1.1.5
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 +60 -50
- package/README.md +152 -152
- package/package.json +63 -63
- package/src/world.ts +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,50 +1,60 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## 1.1.
|
|
4
|
-
|
|
5
|
-
-
|
|
6
|
-
-
|
|
7
|
-
|
|
8
|
-
## 1.1.
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
## 1.
|
|
19
|
-
|
|
20
|
-
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
- `
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.1.5
|
|
4
|
+
|
|
5
|
+
- npm 侧 1.1.4 被 staged,按之前的做法换号重发;内容与 1.1.4 相同。
|
|
6
|
+
- 与插件 `astrbot_plugin_cortico_bridge` 1.2.3 配套。
|
|
7
|
+
|
|
8
|
+
## 1.1.4
|
|
9
|
+
|
|
10
|
+
- 整理源码格式:把之前编辑时并到一行的 import、类声明和 onNotice 拆回去,行为与 1.1.3 一致。
|
|
11
|
+
- 与插件 `astrbot_plugin_cortico_bridge` 1.2.3 配套:工具清单、参数签名、可调工具通知都在本版里。
|
|
12
|
+
|
|
13
|
+
## 1.1.3
|
|
14
|
+
|
|
15
|
+
- 工具清单带参数签名(query_lyrics_by_name(song_name)),模型不用猜参数名。
|
|
16
|
+
- 环境提示词加一条通用策略:能直接用工具做的事,不要绕道去操作屏幕或凭记忆编。
|
|
17
|
+
|
|
18
|
+
## 1.1.2
|
|
19
|
+
|
|
20
|
+
- 工具清单为空时明确提示「如果主人刚开过,调 astrbot_status 看最新清单」——避免开完工具还要重启。
|
|
21
|
+
|
|
22
|
+
## 1.1.1
|
|
23
|
+
|
|
24
|
+
- 新增 `astrbot_call_tool`:按名字调用 AstrBot 上启用的工具,用**触发这一轮的那条消息**的身份执行(群友就是群友,管理员工具会被 AstrBot 自己的权限层拦下)。
|
|
25
|
+
- 握手后接收桥下发的 `tools` 清单,列进环境提示词;`astrbot_status` 也会报当前可用的工具。
|
|
26
|
+
- 桥在管理页保存白名单后会重推清单,不用重连。
|
|
27
|
+
|
|
28
|
+
## 1.0.4
|
|
29
|
+
|
|
30
|
+
- README 修正协议说明:`capabilities.images` 只在 `hello` 帧里自报,`ready` 帧不带;并说明它只在重连时刷新。
|
|
31
|
+
- 补上实机验证环境(Cortico 0.2.8 / Coopanion 0.2.12)。
|
|
32
|
+
|
|
33
|
+
## 1.0.3
|
|
34
|
+
|
|
35
|
+
- 加心跳与静默检测:休眠唤醒、切换网络、对端进程消失时,socket 可能「开着但永远没有下文」,而 `close` 事件不会来。现在每 20 秒 ping 一次,60 秒没有任何往来就主动重建,不再静默丢消息。
|
|
36
|
+
|
|
37
|
+
## 1.0.2
|
|
38
|
+
|
|
39
|
+
- 桥的 `error` 事件只认现役 socket:重启时旧连接迟到的错误不再被当成新连接的错误记一条。
|
|
40
|
+
- `start()` 先撤掉挂起的重连定时器。之前退避等待期间重新连接,会同时留下两条 socket(桥会把旧的踢掉,但会多一次握手)。
|
|
41
|
+
|
|
42
|
+
## 1.0.1
|
|
43
|
+
|
|
44
|
+
- 加上扩展图标(`cortico.icon`),首发时市场卡片是空白的。
|
|
45
|
+
|
|
46
|
+
## 1.0.0
|
|
47
|
+
|
|
48
|
+
首个公开版本。
|
|
49
|
+
|
|
50
|
+
- 通过 AstrBot 侧的桥接入 QQ:QQ 账号、白名单与全部插件仍归 AstrBot,Cortico 的人格只负责说什么。
|
|
51
|
+
- 两种消息范围:`mention`(默认)只投递被 @ 或叫到称呼的消息,`all` 群里每条都投递;私聊一律投递。
|
|
52
|
+
- 工具:`astrbot_send_message`(文字、图片、引用回复)、`astrbot_status`、`astrbot_read_history`(最近 / 关键词 / 发送者 / 会话)。
|
|
53
|
+
- 图片双向:端点能读图就传原图,否则由桥用视觉模型转述;也可以只要占位。
|
|
54
|
+
- 群通知:撤回(带被撤回的原文)、戳一戳(戳到自己显示「你」)、入群、退群、管理员变更、上传文件;只排队不唤醒。
|
|
55
|
+
- 主人身份来自桥自报的 AstrBot 管理员名单,不另设名单;截图授权随发言人实时变化。
|
|
56
|
+
- 断线按指数退避重连,超时与失败不拖垮装配。
|
|
57
|
+
|
|
58
|
+
## 0.1.0
|
|
59
|
+
|
|
60
|
+
内部试用版:消息推送、发消息、查状态、重连。
|
package/README.md
CHANGED
|
@@ -1,152 +1,152 @@
|
|
|
1
|
-
# cortico-world-astrbot
|
|
2
|
-
|
|
3
|
-
<img src="./assets/icon.png" width="88" alt="AstrBot · QQ" align="right">
|
|
4
|
-
|
|
5
|
-
让 Cortico 的人格 Bot 进 QQ 群说话,同时把 QQ 账号与插件能力留在 AstrBot 手里。
|
|
6
|
-
|
|
7
|
-
**当前版本:1.1.
|
|
8
|
-
|
|
9
|
-
项目地址:[as124da1231/cortico-world-astrbot](https://github.com/as124da1231/cortico-world-astrbot)。
|
|
10
|
-
|
|
11
|
-
已在 **Cortico 0.2.8 / Coopanion 0.2.12** 上实机验证:文字、图片(单图与多图)、撤回/戳一戳通知、断线重连。
|
|
12
|
-
|
|
13
|
-
## 为什么是这样一个形状
|
|
14
|
-
|
|
15
|
-
Cortico 自带的 `qq` World 能直接连 OneBot 协议端,但它只做收发消息。如果你的 QQ 号上已经有一整套 AstrBot 插件(画图、点歌、战绩查询、媒体解析……),换掉那套生态的代价很高。
|
|
16
|
-
|
|
17
|
-
这个 World 因此不碰 QQ:它连的是 **AstrBot 侧的一个桥**,由桥负责 QQ 收发。分工是:
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
QQ 群
|
|
21
|
-
│ OneBot v11
|
|
22
|
-
▼
|
|
23
|
-
AstrBot(现有连接、现有插件,都不动)
|
|
24
|
-
│ OnLLMRequestEvent 钩子拦截
|
|
25
|
-
▼
|
|
26
|
-
插件① astrbot_plugin_cortico_bridge ← 服务器侧,Python
|
|
27
|
-
│ WebSocket(AstrBot 当服务端)
|
|
28
|
-
▼
|
|
29
|
-
插件② cortico-world-astrbot ← 本包,Cortico 侧,TypeScript
|
|
30
|
-
│ pushEvent / 工具回执
|
|
31
|
-
▼
|
|
32
|
-
Cortico Core(Persona、Memory、事件流)
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
**方向为什么是「AstrBot 当服务端」**:服务器通常有公网地址,家用机器通常没有。让能被动接受连接的一方当服务端,就不必再搭内网穿透。
|
|
36
|
-
|
|
37
|
-
## 安装前要知道
|
|
38
|
-
|
|
39
|
-
这个 World 只负责「说话」,它离不开服务器侧的另一个包:
|
|
40
|
-
|
|
41
|
-
| 侧 | 包 | 装在哪 |
|
|
42
|
-
|---|---|---|
|
|
43
|
-
| QQ 侧 | [`astrbot_plugin_cortico_bridge`](https://github.com/as124da1231/astrbot_plugin_cortico_bridge) | AstrBot 的插件目录 |
|
|
44
|
-
| Cortico 侧 | `cortico-world-astrbot`(本包) | Cortico 的 `extensions/` |
|
|
45
|
-
|
|
46
|
-
两个包按同一版协议 v1 通信,**必须都装**,单独装哪一半都不通。先装 AstrBot 插件、拿到它的地址和 token,再来填本包的 `wsUrl` / `token`。
|
|
47
|
-
|
|
48
|
-
QQ 账号走的是 OneBot 这类非官方协议,账号有被限制的风险——这个风险来自 QQ 接入方式本身,与本包无关,装之前请自行判断。
|
|
49
|
-
|
|
50
|
-
## 安装
|
|
51
|
-
|
|
52
|
-
从扩展市场的卡片安装,或:
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
corepack pnpm add cortico-world-astrbot
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
装完后在部署的 `config.json` 里把 `worlds.astrbot.enabled` 打开(也可以在 WebUI 的 AstrBot 页里打开),填好 `wsUrl` 与 `token`,重启进程。
|
|
59
|
-
|
|
60
|
-
## 它做什么
|
|
61
|
-
|
|
62
|
-
- 把桥送来的群消息变成 Cortico 事件(`astrbot.message`),图片按端点的多模态能力传原图或转成文字描述。
|
|
63
|
-
- 提供 `astrbot_send_message`,让 bot 能把话(文字、图片或两者)发回群里。
|
|
64
|
-
- 提供 `astrbot_status`,查连接状态与见过的会话。
|
|
65
|
-
- 提供 `astrbot_read_history`,按关键词或发送者回查自己见过的 QQ 消息。
|
|
66
|
-
- 把撤回、戳一戳、入退群、管理员变更、传文件这类通知译成人话,当作上下文记下(不单独唤醒 bot)。
|
|
67
|
-
- 桥断了自动按指数退避重连。
|
|
68
|
-
|
|
69
|
-
## 它不做什么
|
|
70
|
-
|
|
71
|
-
- 不连 QQ、不碰 OneBot、不管账号。
|
|
72
|
-
- 不管群名单与白名单——那些仍归 AstrBot,它决定把哪些群的消息转过来。
|
|
73
|
-
- 不管理 bot 的记忆或人格;那是 Persona 的事。
|
|
74
|
-
|
|
75
|
-
## 配置
|
|
76
|
-
|
|
77
|
-
全部在部署的 `config.json` 的 `worlds.astrbot` 段,也可以在 WebUI 的 AstrBot 页里改。
|
|
78
|
-
|
|
79
|
-
| 键 | 说明 |
|
|
80
|
-
|---|---|
|
|
81
|
-
| `enabled` | 挂载开关,默认关闭 |
|
|
82
|
-
| `wsUrl` | 桥的地址,如 `ws://<服务器IP>:17999`。空串表示还没配置 |
|
|
83
|
-
| `token` | 与桥一致的校验 token,留空表示不校验 |
|
|
84
|
-
| `mode` | `mention`(默认)只在被 @ 或叫到称呼时送进来;`all` 每条群消息都送进来,要不要说话由 bot 自己决定 |
|
|
85
|
-
| `nameAliases` | 除 @ 之外算作「叫我」的称呼,逗号分隔,例如 `Coo,库` |
|
|
86
|
-
| `reconnectBaseMs` / `reconnectMaxMs` | 重连退避的起点与封顶 |
|
|
87
|
-
| `maxSendsPerMinute` | 每分钟发送上限,防止刷屏;0 表示不限 |
|
|
88
|
-
|
|
89
|
-
`wsUrl`、`token` 是建立连接时用的,改完要重启本 World 才生效;`mode`、`nameAliases`、`maxSendsPerMinute` 热改即生效。
|
|
90
|
-
|
|
91
|
-
## 桥的协议
|
|
92
|
-
|
|
93
|
-
一条 WS 连接,JSON 帧。连接建立后客户端先发握手,并自报能力:
|
|
94
|
-
|
|
95
|
-
```json
|
|
96
|
-
{ "t": "hello", "v": 1, "token": "…", "name": "Cortico",
|
|
97
|
-
"capabilities": { "images": true } }
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
`capabilities.images` 表示本端模型能直接读图;为真时桥才附原图,否则自己转成文字。
|
|
101
|
-
这个值由 Cortico 侧按当前端点的多模态能力算出来,只在**每次重连握手时**刷新——中途改了端点设置要等重连(或重启进程)才生效。
|
|
102
|
-
|
|
103
|
-
桥推给客户端:
|
|
104
|
-
|
|
105
|
-
```json
|
|
106
|
-
{ "t": "ready", "v": 1, "self": { "id": "…", "name": "…" }, "admins": ["42"] }
|
|
107
|
-
|
|
108
|
-
{ "t": "msg", "id": "消息id", "ts": "2026-10-26T10:00:00+08:00",
|
|
109
|
-
"conv": { "kind": "group", "id": "123456", "name": "群名" },
|
|
110
|
-
"sender": { "id": "42", "name": "群昵称" },
|
|
111
|
-
"text": "正文", "mentioned": false,
|
|
112
|
-
"role": "admin", "can": { "screenshot": true },
|
|
113
|
-
"images": [{ "mime": "image/jpeg", "base64": "…" }] }
|
|
114
|
-
|
|
115
|
-
{ "t": "msg", "kind": "notice", "id": "", "ref": "被撤回的消息id",
|
|
116
|
-
"conv": { "kind": "group", "id": "123456", "name": "群名" },
|
|
117
|
-
"text": "[撤回] 小小铃 撤回了一条消息", "mentioned": false }
|
|
118
|
-
|
|
119
|
-
{ "t": "notice", "kind": "qq-offline", "text": "QQ 侧已掉线" }
|
|
120
|
-
|
|
121
|
-
{ "t": "ack", "rid": "a-1", "ok": true }
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
`admins` 就是 AstrBot 的管理员名单,World 据此给出「主人」标记与截图授权——不在两边各维护一份名单。
|
|
125
|
-
|
|
126
|
-
客户端发给桥:
|
|
127
|
-
|
|
128
|
-
```json
|
|
129
|
-
{ "t": "send", "rid": "a-1",
|
|
130
|
-
"conv": { "kind": "group", "id": "123456" },
|
|
131
|
-
"text": "要发的话", "replyTo": "可选的消息id",
|
|
132
|
-
"image": { "mime": "image/jpeg", "base64": "…" } }
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
`conv.kind` 取 `group` 或 `private`。`mentioned` 由桥判断并如实告知(@ 到了,或正文出现配置的称呼)。`image` 可省略;`text` 与 `image` 至少给一个。
|
|
136
|
-
|
|
137
|
-
## 开发
|
|
138
|
-
|
|
139
|
-
```bash
|
|
140
|
-
corepack pnpm install
|
|
141
|
-
corepack pnpm typecheck
|
|
142
|
-
corepack pnpm test
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
装进实例验证(在 Cortico 检出根下):
|
|
146
|
-
|
|
147
|
-
```bash
|
|
148
|
-
corepack pnpm describe:extension <本包目录>
|
|
149
|
-
corepack pnpm check:extension <本包目录>
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
需要 Node 22 以上。
|
|
1
|
+
# cortico-world-astrbot
|
|
2
|
+
|
|
3
|
+
<img src="./assets/icon.png" width="88" alt="AstrBot · QQ" align="right">
|
|
4
|
+
|
|
5
|
+
让 Cortico 的人格 Bot 进 QQ 群说话,同时把 QQ 账号与插件能力留在 AstrBot 手里。
|
|
6
|
+
|
|
7
|
+
**当前版本:1.1.5**(更新内容见 [CHANGELOG.md](CHANGELOG.md))
|
|
8
|
+
|
|
9
|
+
项目地址:[as124da1231/cortico-world-astrbot](https://github.com/as124da1231/cortico-world-astrbot)。
|
|
10
|
+
|
|
11
|
+
已在 **Cortico 0.2.8 / Coopanion 0.2.12** 上实机验证:文字、图片(单图与多图)、撤回/戳一戳通知、断线重连。
|
|
12
|
+
|
|
13
|
+
## 为什么是这样一个形状
|
|
14
|
+
|
|
15
|
+
Cortico 自带的 `qq` World 能直接连 OneBot 协议端,但它只做收发消息。如果你的 QQ 号上已经有一整套 AstrBot 插件(画图、点歌、战绩查询、媒体解析……),换掉那套生态的代价很高。
|
|
16
|
+
|
|
17
|
+
这个 World 因此不碰 QQ:它连的是 **AstrBot 侧的一个桥**,由桥负责 QQ 收发。分工是:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
QQ 群
|
|
21
|
+
│ OneBot v11
|
|
22
|
+
▼
|
|
23
|
+
AstrBot(现有连接、现有插件,都不动)
|
|
24
|
+
│ OnLLMRequestEvent 钩子拦截
|
|
25
|
+
▼
|
|
26
|
+
插件① astrbot_plugin_cortico_bridge ← 服务器侧,Python
|
|
27
|
+
│ WebSocket(AstrBot 当服务端)
|
|
28
|
+
▼
|
|
29
|
+
插件② cortico-world-astrbot ← 本包,Cortico 侧,TypeScript
|
|
30
|
+
│ pushEvent / 工具回执
|
|
31
|
+
▼
|
|
32
|
+
Cortico Core(Persona、Memory、事件流)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**方向为什么是「AstrBot 当服务端」**:服务器通常有公网地址,家用机器通常没有。让能被动接受连接的一方当服务端,就不必再搭内网穿透。
|
|
36
|
+
|
|
37
|
+
## 安装前要知道
|
|
38
|
+
|
|
39
|
+
这个 World 只负责「说话」,它离不开服务器侧的另一个包:
|
|
40
|
+
|
|
41
|
+
| 侧 | 包 | 装在哪 |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
| QQ 侧 | [`astrbot_plugin_cortico_bridge`](https://github.com/as124da1231/astrbot_plugin_cortico_bridge) | AstrBot 的插件目录 |
|
|
44
|
+
| Cortico 侧 | `cortico-world-astrbot`(本包) | Cortico 的 `extensions/` |
|
|
45
|
+
|
|
46
|
+
两个包按同一版协议 v1 通信,**必须都装**,单独装哪一半都不通。先装 AstrBot 插件、拿到它的地址和 token,再来填本包的 `wsUrl` / `token`。
|
|
47
|
+
|
|
48
|
+
QQ 账号走的是 OneBot 这类非官方协议,账号有被限制的风险——这个风险来自 QQ 接入方式本身,与本包无关,装之前请自行判断。
|
|
49
|
+
|
|
50
|
+
## 安装
|
|
51
|
+
|
|
52
|
+
从扩展市场的卡片安装,或:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
corepack pnpm add cortico-world-astrbot
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
装完后在部署的 `config.json` 里把 `worlds.astrbot.enabled` 打开(也可以在 WebUI 的 AstrBot 页里打开),填好 `wsUrl` 与 `token`,重启进程。
|
|
59
|
+
|
|
60
|
+
## 它做什么
|
|
61
|
+
|
|
62
|
+
- 把桥送来的群消息变成 Cortico 事件(`astrbot.message`),图片按端点的多模态能力传原图或转成文字描述。
|
|
63
|
+
- 提供 `astrbot_send_message`,让 bot 能把话(文字、图片或两者)发回群里。
|
|
64
|
+
- 提供 `astrbot_status`,查连接状态与见过的会话。
|
|
65
|
+
- 提供 `astrbot_read_history`,按关键词或发送者回查自己见过的 QQ 消息。
|
|
66
|
+
- 把撤回、戳一戳、入退群、管理员变更、传文件这类通知译成人话,当作上下文记下(不单独唤醒 bot)。
|
|
67
|
+
- 桥断了自动按指数退避重连。
|
|
68
|
+
|
|
69
|
+
## 它不做什么
|
|
70
|
+
|
|
71
|
+
- 不连 QQ、不碰 OneBot、不管账号。
|
|
72
|
+
- 不管群名单与白名单——那些仍归 AstrBot,它决定把哪些群的消息转过来。
|
|
73
|
+
- 不管理 bot 的记忆或人格;那是 Persona 的事。
|
|
74
|
+
|
|
75
|
+
## 配置
|
|
76
|
+
|
|
77
|
+
全部在部署的 `config.json` 的 `worlds.astrbot` 段,也可以在 WebUI 的 AstrBot 页里改。
|
|
78
|
+
|
|
79
|
+
| 键 | 说明 |
|
|
80
|
+
|---|---|
|
|
81
|
+
| `enabled` | 挂载开关,默认关闭 |
|
|
82
|
+
| `wsUrl` | 桥的地址,如 `ws://<服务器IP>:17999`。空串表示还没配置 |
|
|
83
|
+
| `token` | 与桥一致的校验 token,留空表示不校验 |
|
|
84
|
+
| `mode` | `mention`(默认)只在被 @ 或叫到称呼时送进来;`all` 每条群消息都送进来,要不要说话由 bot 自己决定 |
|
|
85
|
+
| `nameAliases` | 除 @ 之外算作「叫我」的称呼,逗号分隔,例如 `Coo,库` |
|
|
86
|
+
| `reconnectBaseMs` / `reconnectMaxMs` | 重连退避的起点与封顶 |
|
|
87
|
+
| `maxSendsPerMinute` | 每分钟发送上限,防止刷屏;0 表示不限 |
|
|
88
|
+
|
|
89
|
+
`wsUrl`、`token` 是建立连接时用的,改完要重启本 World 才生效;`mode`、`nameAliases`、`maxSendsPerMinute` 热改即生效。
|
|
90
|
+
|
|
91
|
+
## 桥的协议
|
|
92
|
+
|
|
93
|
+
一条 WS 连接,JSON 帧。连接建立后客户端先发握手,并自报能力:
|
|
94
|
+
|
|
95
|
+
```json
|
|
96
|
+
{ "t": "hello", "v": 1, "token": "…", "name": "Cortico",
|
|
97
|
+
"capabilities": { "images": true } }
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`capabilities.images` 表示本端模型能直接读图;为真时桥才附原图,否则自己转成文字。
|
|
101
|
+
这个值由 Cortico 侧按当前端点的多模态能力算出来,只在**每次重连握手时**刷新——中途改了端点设置要等重连(或重启进程)才生效。
|
|
102
|
+
|
|
103
|
+
桥推给客户端:
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{ "t": "ready", "v": 1, "self": { "id": "…", "name": "…" }, "admins": ["42"] }
|
|
107
|
+
|
|
108
|
+
{ "t": "msg", "id": "消息id", "ts": "2026-10-26T10:00:00+08:00",
|
|
109
|
+
"conv": { "kind": "group", "id": "123456", "name": "群名" },
|
|
110
|
+
"sender": { "id": "42", "name": "群昵称" },
|
|
111
|
+
"text": "正文", "mentioned": false,
|
|
112
|
+
"role": "admin", "can": { "screenshot": true },
|
|
113
|
+
"images": [{ "mime": "image/jpeg", "base64": "…" }] }
|
|
114
|
+
|
|
115
|
+
{ "t": "msg", "kind": "notice", "id": "", "ref": "被撤回的消息id",
|
|
116
|
+
"conv": { "kind": "group", "id": "123456", "name": "群名" },
|
|
117
|
+
"text": "[撤回] 小小铃 撤回了一条消息", "mentioned": false }
|
|
118
|
+
|
|
119
|
+
{ "t": "notice", "kind": "qq-offline", "text": "QQ 侧已掉线" }
|
|
120
|
+
|
|
121
|
+
{ "t": "ack", "rid": "a-1", "ok": true }
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`admins` 就是 AstrBot 的管理员名单,World 据此给出「主人」标记与截图授权——不在两边各维护一份名单。
|
|
125
|
+
|
|
126
|
+
客户端发给桥:
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{ "t": "send", "rid": "a-1",
|
|
130
|
+
"conv": { "kind": "group", "id": "123456" },
|
|
131
|
+
"text": "要发的话", "replyTo": "可选的消息id",
|
|
132
|
+
"image": { "mime": "image/jpeg", "base64": "…" } }
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
`conv.kind` 取 `group` 或 `private`。`mentioned` 由桥判断并如实告知(@ 到了,或正文出现配置的称呼)。`image` 可省略;`text` 与 `image` 至少给一个。
|
|
136
|
+
|
|
137
|
+
## 开发
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
corepack pnpm install
|
|
141
|
+
corepack pnpm typecheck
|
|
142
|
+
corepack pnpm test
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
装进实例验证(在 Cortico 检出根下):
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
corepack pnpm describe:extension <本包目录>
|
|
149
|
+
corepack pnpm check:extension <本包目录>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
需要 Node 22 以上。
|
package/package.json
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "cortico-world-astrbot",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"description": "Cortico World: join QQ conversations through an AstrBot bridge, so the bot keeps AstrBot's plugins while a Cortico persona drives the talking",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"author": "as124da1231",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/as124da1231/cortico-world-astrbot.git"
|
|
11
|
-
},
|
|
12
|
-
"homepage": "https://github.com/as124da1231/cortico-world-astrbot#readme",
|
|
13
|
-
"bugs": {
|
|
14
|
-
"url": "https://github.com/as124da1231/cortico-world-astrbot/issues"
|
|
15
|
-
},
|
|
16
|
-
"keywords": [
|
|
17
|
-
"cortico-world",
|
|
18
|
-
"cortico",
|
|
19
|
-
"astrbot",
|
|
20
|
-
"qq",
|
|
21
|
-
"bridge"
|
|
22
|
-
],
|
|
23
|
-
"engines": {
|
|
24
|
-
"node": ">=22"
|
|
25
|
-
},
|
|
26
|
-
"packageManager": "pnpm@11.28.6",
|
|
27
|
-
"main": "./src/index.ts",
|
|
28
|
-
"cortico": {
|
|
29
|
-
"kind": "world",
|
|
30
|
-
"api": 6,
|
|
31
|
-
"displayName": "AstrBot · QQ",
|
|
32
|
-
"icon": "assets/icon.png",
|
|
33
|
-
"tags": [
|
|
34
|
-
"apps",
|
|
35
|
-
"external-setup",
|
|
36
|
-
"unofficial-api"
|
|
37
|
-
],
|
|
38
|
-
"describe": "describe.json"
|
|
39
|
-
},
|
|
40
|
-
"files": [
|
|
41
|
-
"src",
|
|
42
|
-
"assets",
|
|
43
|
-
"README.md",
|
|
44
|
-
"CHANGELOG.md",
|
|
45
|
-
"describe.json",
|
|
46
|
-
"LICENSE"
|
|
47
|
-
],
|
|
48
|
-
"scripts": {
|
|
49
|
-
"test": "vitest run",
|
|
50
|
-
"typecheck": "tsc --noEmit"
|
|
51
|
-
},
|
|
52
|
-
"dependencies": {
|
|
53
|
-
"ws": "^8.18.0"
|
|
54
|
-
},
|
|
55
|
-
"devDependencies": {
|
|
56
|
-
"@types/node": "^22.10.0",
|
|
57
|
-
"@types/ws": "^8.5.13",
|
|
58
|
-
"cortico": "^0.2.7",
|
|
59
|
-
"tsx": "^4.19.2",
|
|
60
|
-
"typescript": "^5.7.2",
|
|
61
|
-
"vitest": "^2.1.8"
|
|
62
|
-
}
|
|
63
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "cortico-world-astrbot",
|
|
3
|
+
"version": "1.1.5",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Cortico World: join QQ conversations through an AstrBot bridge, so the bot keeps AstrBot's plugins while a Cortico persona drives the talking",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "as124da1231",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/as124da1231/cortico-world-astrbot.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/as124da1231/cortico-world-astrbot#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/as124da1231/cortico-world-astrbot/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"cortico-world",
|
|
18
|
+
"cortico",
|
|
19
|
+
"astrbot",
|
|
20
|
+
"qq",
|
|
21
|
+
"bridge"
|
|
22
|
+
],
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=22"
|
|
25
|
+
},
|
|
26
|
+
"packageManager": "pnpm@11.28.6",
|
|
27
|
+
"main": "./src/index.ts",
|
|
28
|
+
"cortico": {
|
|
29
|
+
"kind": "world",
|
|
30
|
+
"api": 6,
|
|
31
|
+
"displayName": "AstrBot · QQ",
|
|
32
|
+
"icon": "assets/icon.png",
|
|
33
|
+
"tags": [
|
|
34
|
+
"apps",
|
|
35
|
+
"external-setup",
|
|
36
|
+
"unofficial-api"
|
|
37
|
+
],
|
|
38
|
+
"describe": "describe.json"
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"src",
|
|
42
|
+
"assets",
|
|
43
|
+
"README.md",
|
|
44
|
+
"CHANGELOG.md",
|
|
45
|
+
"describe.json",
|
|
46
|
+
"LICENSE"
|
|
47
|
+
],
|
|
48
|
+
"scripts": {
|
|
49
|
+
"test": "vitest run",
|
|
50
|
+
"typecheck": "tsc --noEmit"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"ws": "^8.18.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^22.10.0",
|
|
57
|
+
"@types/ws": "^8.5.13",
|
|
58
|
+
"cortico": "^0.2.7",
|
|
59
|
+
"tsx": "^4.19.2",
|
|
60
|
+
"typescript": "^5.7.2",
|
|
61
|
+
"vitest": "^2.1.8"
|
|
62
|
+
}
|
|
63
|
+
}
|
package/src/world.ts
CHANGED
|
@@ -25,7 +25,8 @@ import {
|
|
|
25
25
|
type Conv,
|
|
26
26
|
type OutgoingImage,
|
|
27
27
|
type ToolInfo,
|
|
28
|
-
} from './driver.ts';
|
|
28
|
+
} from './driver.ts';
|
|
29
|
+
import { convOfEvent, renderLatest, renderSearch } from './history.ts';
|
|
29
30
|
|
|
30
31
|
const ENV_PROMPT_FILE = fileURLToPath(new URL('./ENV_PROMPT.md', import.meta.url));
|
|
31
32
|
|
|
@@ -162,7 +163,8 @@ export const CALL_TOOL_DECL: Omit<ToolDef, 'handler'> = {
|
|
|
162
163
|
},
|
|
163
164
|
};
|
|
164
165
|
|
|
165
|
-
export class AstrbotWorld implements World {
|
|
166
|
+
export class AstrbotWorld implements World {
|
|
167
|
+
readonly id = 'astrbot';
|
|
166
168
|
|
|
167
169
|
private opts: AstrbotWorldOptions;
|
|
168
170
|
private host?: WorldHost;
|
|
@@ -328,7 +330,8 @@ export class AstrbotWorld implements World { readonly id = 'astrbot';
|
|
|
328
330
|
}
|
|
329
331
|
this.toolsSeen = true;
|
|
330
332
|
});
|
|
331
|
-
driver.onNotice((notice) => {
|
|
333
|
+
driver.onNotice((notice) => {
|
|
334
|
+
void host
|
|
332
335
|
.pushEvent({
|
|
333
336
|
type: 'astrbot.notice',
|
|
334
337
|
ts: notice.ts ?? nowIso(this.opts.timezone),
|