@rlynicrisis/link 0.0.3 → 0.0.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/README.md +51 -21
- package/package.json +5 -1
- package/src/link/message.js +1621 -0
- package/src/onboarding.ts +20 -17
package/README.md
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
# OpenClaw Link Channel Plugin
|
|
2
2
|
|
|
3
|
-
这是一个 OpenClaw 的 Link
|
|
3
|
+
这是一个 OpenClaw 的 Link 消息服务接入插件,支持通过 TCP 协议连接到 Link/EMB 服务器,实现消息的接收与发送。
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- **协议支持**: 基于 TCP 的私有协议 (EMB Protocol V3),支持 Protobuf 消息序列化。
|
|
8
|
+
- **消息类型**:
|
|
9
|
+
- ✅ 文本消息 (Text)
|
|
10
|
+
- ✅ 文件消息 (File) - *需配合文件上传服务使用*
|
|
11
|
+
- **安全机制**:
|
|
12
|
+
- 🔒 **仅限己方消息**: 插件默认仅处理当前登录用户发送给自己的消息(即“文件传输助手”模式),忽略群聊和其他用户的私聊,确保数据安全。
|
|
13
|
+
- **连接管理**:
|
|
14
|
+
- 💓 自动心跳保活
|
|
15
|
+
- 🔄 断线自动重连
|
|
16
|
+
- 🎫 **Token 自动刷新**: 支持配置 `refreshToken` 和 `ssoUrl`,在 Token 过期时自动通过 SSO 接口刷新并重连。
|
|
10
17
|
|
|
11
18
|
## 安装与配置
|
|
12
19
|
|
|
@@ -19,29 +26,32 @@ npm install
|
|
|
19
26
|
npm run build
|
|
20
27
|
```
|
|
21
28
|
|
|
22
|
-
这将生成 `dist`
|
|
29
|
+
这将生成 `dist` 目录,包含编译后的插件代码。
|
|
23
30
|
|
|
24
31
|
### 2. 配置 OpenClaw
|
|
25
32
|
|
|
26
33
|
在您的 OpenClaw 主配置文件(通常是 `config.yaml` 或 `config.json`)中,添加以下内容:
|
|
27
34
|
|
|
28
|
-
####
|
|
29
|
-
如果 OpenClaw 支持本地插件加载,请确保插件路径被包含在加载列表中,或者将本插件发布/链接到 `node_modules`。
|
|
35
|
+
#### 频道配置 (Channel Config)
|
|
30
36
|
|
|
31
|
-
#### 频道配置
|
|
32
37
|
在 `channels` 部分添加 `link` 配置:
|
|
33
38
|
|
|
34
39
|
```yaml
|
|
35
40
|
channels:
|
|
36
41
|
link:
|
|
37
42
|
enabled: true
|
|
38
|
-
# Link 服务地址
|
|
39
|
-
host: "embtcpbeta.bingolink.biz"
|
|
40
|
-
|
|
43
|
+
# Link 服务地址 (格式: host:port)
|
|
44
|
+
host: "embtcpbeta.bingolink.biz:20081"
|
|
45
|
+
|
|
41
46
|
# 鉴权信息 (必填)
|
|
42
|
-
accessToken: "
|
|
43
|
-
|
|
44
|
-
#
|
|
47
|
+
accessToken: "your_access_token_here"
|
|
48
|
+
|
|
49
|
+
# Token 自动刷新配置 (可选,推荐配置)
|
|
50
|
+
refreshToken: "your_refresh_token_here"
|
|
51
|
+
ssoUrl: "https://sso.example.com" # SSO 服务地址
|
|
52
|
+
|
|
53
|
+
# 高级配置 (可选)
|
|
54
|
+
# heartbeatIntervalMs: 30000 # 心跳间隔,默认 30秒
|
|
45
55
|
# verifyInfo: # 如果需要覆盖默认生成的设备信息,可在此配置
|
|
46
56
|
# deviceName: "CustomBotName"
|
|
47
57
|
```
|
|
@@ -49,16 +59,36 @@ channels:
|
|
|
49
59
|
> **注意**:
|
|
50
60
|
> - `userId` 将自动从 `accessToken` (JWT) 中解析。
|
|
51
61
|
> - `deviceUID` 将根据机器特征自动生成,确保同一设备上的稳定性。
|
|
52
|
-
> -
|
|
62
|
+
> - `host` 参数现已支持 `host:port` 格式,无需单独配置 `port`。
|
|
63
|
+
|
|
64
|
+
## 开发调试
|
|
53
65
|
|
|
54
|
-
###
|
|
66
|
+
### 单元测试
|
|
55
67
|
|
|
56
|
-
|
|
68
|
+
运行所有单元测试:
|
|
57
69
|
|
|
58
|
-
|
|
70
|
+
```bash
|
|
71
|
+
npm test
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 手动连接测试
|
|
59
75
|
|
|
60
|
-
可以使用 `test/manual-connect.ts`
|
|
76
|
+
可以使用 `test/manual-connect.ts` 脚本单独测试连接和基本消息收发:
|
|
61
77
|
|
|
62
78
|
```bash
|
|
63
79
|
npx tsx test/manual-connect.ts
|
|
64
80
|
```
|
|
81
|
+
|
|
82
|
+
### 发送文件消息测试
|
|
83
|
+
|
|
84
|
+
测试发送文件类型消息(构造虚拟文件信息):
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npx tsx test/send-file.ts
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## 常见问题
|
|
91
|
+
|
|
92
|
+
- **消息发送失败 (Protobuf Error)**: 确保服务端支持 V3 协议,且 `MsgType` 枚举值与服务端定义一致(如 File=3)。
|
|
93
|
+
- **Token 过期**: 如果配置了 `refreshToken` 和 `ssoUrl`,插件会自动尝试刷新。否则需手动更新配置文件中的 `accessToken`。
|
|
94
|
+
- **无法收到消息**: 检查 `bot.ts` 中的安全过滤逻辑,确保发送者和接收者均为当前登录用户。
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rlynicrisis/link",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "OpenClaw Link channel plugin",
|
|
6
6
|
"files": [
|
|
7
7
|
"index.ts",
|
|
8
8
|
"src/**/*.ts",
|
|
9
|
+
"src/**/*.js",
|
|
9
10
|
"!src/**/__tests__/**",
|
|
10
11
|
"!src/**/*.test.ts",
|
|
11
12
|
"openclaw.plugin.json"
|
|
@@ -41,6 +42,9 @@
|
|
|
41
42
|
"label": "Link",
|
|
42
43
|
"selectionLabel": "Link Messaging Service",
|
|
43
44
|
"blurb": "Integration with Link messaging service.",
|
|
45
|
+
"onboarding": {
|
|
46
|
+
"kind": "manual"
|
|
47
|
+
},
|
|
44
48
|
"order": 100
|
|
45
49
|
},
|
|
46
50
|
"install": {
|