@ywfe/openclaw-plugin-caryscloud-im 0.0.12 → 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/INTEGRATION.md +15 -15
- package/README.md +15 -20
- package/install.sh +51 -16
- package/package.json +1 -1
package/INTEGRATION.md
CHANGED
|
@@ -106,8 +106,8 @@ openclaw channels add --channel caryscloud-im \
|
|
|
106
106
|
|
|
107
107
|
| 参数 | 说明 | 示例 |
|
|
108
108
|
|------|------|------|
|
|
109
|
-
| `--
|
|
110
|
-
| `--
|
|
109
|
+
| `--http-url` | WebSocket 服务器地址 | `wss://api.example.com/ws` |
|
|
110
|
+
| `--user-id` | 目标用户 ID | `user123` |
|
|
111
111
|
|
|
112
112
|
#### 可选参数
|
|
113
113
|
|
|
@@ -115,37 +115,37 @@ openclaw channels add --channel caryscloud-im \
|
|
|
115
115
|
|------|------|--------|
|
|
116
116
|
| `--account` | 账号标识符 | `default` |
|
|
117
117
|
| `--name` | 显示名称 | - |
|
|
118
|
-
| `--
|
|
119
|
-
| `--
|
|
120
|
-
| `--
|
|
121
|
-
| `--
|
|
118
|
+
| `--token` | 认证令牌 | - |
|
|
119
|
+
| `--device-name` | 设备 UUID | 自动生成 |
|
|
120
|
+
| `--webhook-path` | 头像 URL | - |
|
|
121
|
+
| `--auto-discover-channels` | 启用连接测试消息 | `false` |
|
|
122
122
|
|
|
123
123
|
#### 使用示例
|
|
124
124
|
|
|
125
125
|
**最简配置:**
|
|
126
126
|
```bash
|
|
127
127
|
openclaw channels add --channel caryscloud-im \
|
|
128
|
-
--
|
|
129
|
-
--
|
|
128
|
+
--http-url wss://api.example.com/ws \
|
|
129
|
+
--user-id user123
|
|
130
130
|
```
|
|
131
131
|
|
|
132
132
|
**生产环境配置:**
|
|
133
133
|
```bash
|
|
134
134
|
openclaw channels add --channel caryscloud-im \
|
|
135
|
-
--
|
|
136
|
-
--
|
|
135
|
+
--http-url wss://prod.example.com/ws \
|
|
136
|
+
--user-id prod-user-001 \
|
|
137
137
|
--account production \
|
|
138
138
|
--name "Production Bot" \
|
|
139
|
-
--
|
|
140
|
-
--
|
|
141
|
-
--
|
|
139
|
+
--token "prod-token-xyz" \
|
|
140
|
+
--device-name "openclaw-prod-001" \
|
|
141
|
+
--auto-discover-channels
|
|
142
142
|
```
|
|
143
143
|
|
|
144
144
|
**开发环境配置:**
|
|
145
145
|
```bash
|
|
146
146
|
openclaw channels add --channel caryscloud-im \
|
|
147
|
-
--
|
|
148
|
-
--
|
|
147
|
+
--http-url ws://localhost:8080/ws \
|
|
148
|
+
--user-id dev-user-001 \
|
|
149
149
|
--account development \
|
|
150
150
|
--name "Dev Bot"
|
|
151
151
|
```
|
package/README.md
CHANGED
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
CarysCloud OpenClaw 的 WebSocket 频道插件 - 通过 WebSocket (wss://) 连接实现双向消息传递。
|
|
4
4
|
|
|
5
|
-
## 📚 文档导航
|
|
6
|
-
|
|
7
|
-
- **[接入指南 (INTEGRATION.md)](./INTEGRATION.md)** - 详细的接入步骤、配置说明和服务器要求
|
|
8
|
-
- **[README.md](./README.md)** - 本文档,功能介绍和快速开始
|
|
9
|
-
|
|
10
5
|
## 功能特性
|
|
11
6
|
|
|
12
7
|
- ✅ 支持 wss:// 协议的 WebSocket 连接
|
|
@@ -47,9 +42,9 @@ chmod +x install.sh
|
|
|
47
42
|
|
|
48
43
|
安装脚本会自动:
|
|
49
44
|
- ✅ 检查 OpenClaw CLI 是否已安装
|
|
50
|
-
- ✅
|
|
51
|
-
- ✅ 清理旧的频道配置
|
|
45
|
+
- ✅ 清理旧的插件配置和目录
|
|
52
46
|
- ✅ 安装最新版本插件
|
|
47
|
+
- ✅ 添加插件到允许列表
|
|
53
48
|
- ✅ 启动交互式配置向导
|
|
54
49
|
|
|
55
50
|
#### 方式 2:手动安装
|
|
@@ -108,34 +103,34 @@ openclaw channels add --channel caryscloud-im \
|
|
|
108
103
|
```
|
|
109
104
|
|
|
110
105
|
**必需参数:**
|
|
111
|
-
- `--
|
|
112
|
-
- `--
|
|
106
|
+
- `--http-url <url>`: WebSocket 服务器地址(必须以 ws:// 或 wss:// 开头)
|
|
107
|
+
- `--user-id <id>`: 目标用户 ID
|
|
113
108
|
|
|
114
109
|
**可选参数:**
|
|
115
110
|
- `--account <id>`: 账号标识符(默认为 "default")
|
|
116
111
|
- `--name <name>`: 显示名称
|
|
117
|
-
- `--
|
|
118
|
-
- `--
|
|
119
|
-
- `--
|
|
120
|
-
- `--
|
|
112
|
+
- `--token <token>`: 认证令牌
|
|
113
|
+
- `--device-name <name>`: 设备 UUID
|
|
114
|
+
- `--webhook-path <path>`: 头像 URL
|
|
115
|
+
- `--auto-discover-channels`: 启用连接测试消息
|
|
121
116
|
|
|
122
117
|
**示例:**
|
|
123
118
|
|
|
124
119
|
```bash
|
|
125
120
|
# 最简配置
|
|
126
121
|
openclaw channels add --channel caryscloud-im \
|
|
127
|
-
--
|
|
128
|
-
--
|
|
122
|
+
--http-url wss://api.example.com/ws \
|
|
123
|
+
--user-id user123
|
|
129
124
|
|
|
130
125
|
# 完整配置
|
|
131
126
|
openclaw channels add --channel caryscloud-im \
|
|
132
|
-
--
|
|
133
|
-
--
|
|
127
|
+
--http-url wss://api.example.com/ws \
|
|
128
|
+
--user-id user123 \
|
|
134
129
|
--account production \
|
|
135
130
|
--name "Production Bot" \
|
|
136
|
-
--
|
|
137
|
-
--
|
|
138
|
-
--
|
|
131
|
+
--token "secret-token-xyz" \
|
|
132
|
+
--device-name "openclaw-prod-001" \
|
|
133
|
+
--auto-discover-channels
|
|
139
134
|
```
|
|
140
135
|
|
|
141
136
|
#### 方式 2:交互式向导
|
package/install.sh
CHANGED
|
@@ -31,6 +31,7 @@ print_step() {
|
|
|
31
31
|
|
|
32
32
|
PLUGIN_NAME="@ywfe/openclaw-plugin-caryscloud-im"
|
|
33
33
|
PLUGIN_ID="openclaw-plugin-caryscloud-im"
|
|
34
|
+
OPENCLAW_CONFIG_FILE="$HOME/.openclaw/openclaw.json"
|
|
34
35
|
|
|
35
36
|
echo ""
|
|
36
37
|
print_info "OpenClaw CarysCloud IM Plugin 一键安装"
|
|
@@ -45,33 +46,43 @@ fi
|
|
|
45
46
|
print_success "找到 OpenClaw CLI"
|
|
46
47
|
echo ""
|
|
47
48
|
|
|
48
|
-
print_step "
|
|
49
|
-
if
|
|
50
|
-
|
|
51
|
-
openclaw plugins uninstall "$PLUGIN_ID" || true
|
|
52
|
-
|
|
53
|
-
OPENCLAW_CONFIG_FILE="$HOME/.openclaw/openclaw.json"
|
|
54
|
-
if [ -f "$OPENCLAW_CONFIG_FILE" ]; then
|
|
55
|
-
print_step "清理旧的频道配置..."
|
|
56
|
-
node -e "
|
|
49
|
+
print_step "清理无效的插件配置..."
|
|
50
|
+
if [ -f "$OPENCLAW_CONFIG_FILE" ]; then
|
|
51
|
+
node -e "
|
|
57
52
|
const fs = require('fs');
|
|
58
53
|
const configFile = '$OPENCLAW_CONFIG_FILE';
|
|
59
54
|
try {
|
|
60
55
|
const content = fs.readFileSync(configFile, 'utf8');
|
|
61
56
|
const config = JSON.parse(content);
|
|
57
|
+
|
|
58
|
+
// 清理无效的 plugins.allow
|
|
59
|
+
if (config.plugins && config.plugins.allow) {
|
|
60
|
+
const idx = config.plugins.allow.indexOf('$PLUGIN_ID');
|
|
61
|
+
if (idx > -1) {
|
|
62
|
+
config.plugins.allow.splice(idx, 1);
|
|
63
|
+
console.log('已从 plugins.allow 中移除 $PLUGIN_ID');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// 清理频道配置
|
|
62
68
|
if (config.channels && config.channels['caryscloud-im']) {
|
|
63
69
|
delete config.channels['caryscloud-im'];
|
|
64
|
-
fs.writeFileSync(configFile, JSON.stringify(config, null, 2));
|
|
65
70
|
console.log('已删除旧的 caryscloud-im 频道配置');
|
|
66
71
|
}
|
|
72
|
+
|
|
73
|
+
fs.writeFileSync(configFile, JSON.stringify(config, null, 2));
|
|
74
|
+
console.log('配置清理完成');
|
|
67
75
|
} catch (e) {
|
|
68
|
-
console.error('
|
|
76
|
+
console.error('配置清理失败:', e.message);
|
|
69
77
|
}
|
|
70
78
|
"
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
fi
|
|
80
|
+
|
|
81
|
+
PLUGIN_DIR="$HOME/.openclaw/extensions/openclaw-plugin-caryscloud-im"
|
|
82
|
+
if [ -d "$PLUGIN_DIR" ]; then
|
|
83
|
+
print_step "删除旧的插件目录..."
|
|
84
|
+
rm -rf "$PLUGIN_DIR"
|
|
85
|
+
print_success "已删除旧的插件目录"
|
|
75
86
|
fi
|
|
76
87
|
|
|
77
88
|
print_step "安装插件: $PLUGIN_NAME"
|
|
@@ -84,11 +95,35 @@ if [ $INSTALL_EXIT_CODE -eq 0 ]; then
|
|
|
84
95
|
print_success "插件安装成功!"
|
|
85
96
|
echo ""
|
|
86
97
|
|
|
98
|
+
print_step "配置 OpenClaw 允许加载插件..."
|
|
99
|
+
node -e "
|
|
100
|
+
const fs = require('fs');
|
|
101
|
+
const configFile = '$HOME/.openclaw/openclaw.json';
|
|
102
|
+
try {
|
|
103
|
+
const content = fs.readFileSync(configFile, 'utf8');
|
|
104
|
+
const config = JSON.parse(content);
|
|
105
|
+
if (!config.plugins) config.plugins = {};
|
|
106
|
+
if (!config.plugins.allow) config.plugins.allow = [];
|
|
107
|
+
if (!config.plugins.allow.includes('$PLUGIN_ID')) {
|
|
108
|
+
config.plugins.allow.push('$PLUGIN_ID');
|
|
109
|
+
}
|
|
110
|
+
fs.writeFileSync(configFile, JSON.stringify(config, null, 2));
|
|
111
|
+
console.log('已添加插件到允许列表');
|
|
112
|
+
} catch (e) {
|
|
113
|
+
console.error('配置失败:', e.message);
|
|
114
|
+
}
|
|
115
|
+
"
|
|
116
|
+
echo ""
|
|
117
|
+
|
|
87
118
|
print_step "启动频道配置向导..."
|
|
88
119
|
echo ""
|
|
89
120
|
sleep 1
|
|
90
121
|
|
|
91
|
-
|
|
122
|
+
if [ -t 0 ]; then
|
|
123
|
+
openclaw channels add
|
|
124
|
+
else
|
|
125
|
+
openclaw channels add < /dev/tty
|
|
126
|
+
fi
|
|
92
127
|
|
|
93
128
|
echo ""
|
|
94
129
|
print_success "=========================================="
|