openclaw-xiaoyou 1.2.1 → 1.2.3
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/docs/SKILL.md +32 -32
- package/package.json +1 -1
- package/src/channel.ts +72 -18
package/docs/SKILL.md
CHANGED
|
@@ -5,48 +5,48 @@ description: Use when users want to install, upgrade, uninstall, configure, or t
|
|
|
5
5
|
|
|
6
6
|
# 小优 Channel 安装入口
|
|
7
7
|
|
|
8
|
-
小优 channel
|
|
8
|
+
小优 channel 安装、升级、卸载统一使用远程脚本�?
|
|
9
9
|
|
|
10
10
|
```bash
|
|
11
|
-
https://d10.tfdl.net/public/2026-05-06/
|
|
11
|
+
https://d10.tfdl.net/public/2026-05-06/14dbf63d-d0aa-4b5d-bdd6-47eddb455f36/install-xiaoyou.sh
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
不要�?OpenClaw 的底层安装命令拆散执行。除非远程脚本失败且需要排障,否则直接调用 `install-xiaoyou.sh`�?
|
|
15
15
|
|
|
16
|
-
##
|
|
16
|
+
## 触发�?
|
|
17
17
|
|
|
18
18
|
- "安装小优" / "小优安装"
|
|
19
19
|
- "小优接入" / "接入小优"
|
|
20
20
|
- "配置 xiaoyou" / "xiaoyou 配置"
|
|
21
21
|
- "升级小优" / "更新小优"
|
|
22
22
|
- "卸载小优" / "移除小优"
|
|
23
|
-
- "
|
|
23
|
+
- "我想用小�? / "启用小优"
|
|
24
24
|
- "小优 channel" / "xiaoyou channel"
|
|
25
25
|
|
|
26
26
|
## 标准执行
|
|
27
27
|
|
|
28
|
-
优先直接通过 `curl | bash`
|
|
28
|
+
优先直接通过 `curl | bash` 执行远程脚本�?
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
|
-
curl -fsSL https://d10.tfdl.net/public/2026-05-06/
|
|
31
|
+
curl -fsSL https://d10.tfdl.net/public/2026-05-06/14dbf63d-d0aa-4b5d-bdd6-47eddb455f36/install-xiaoyou.sh | bash -s -- --ws-url ws://aiws-sim.haiersmarthomes.com:11055/xiaoyou/claw --token <AccessToken>
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
### 参数说明
|
|
35
35
|
|
|
36
36
|
| 参数 | 必填 | 说明 |
|
|
37
37
|
|------|------|------|
|
|
38
|
-
| `--ws-url <url>` |
|
|
39
|
-
| `--token <token>` |
|
|
40
|
-
| `--version <ver>` |
|
|
41
|
-
| `--check-only` |
|
|
42
|
-
| `uninstall` |
|
|
38
|
+
| `--ws-url <url>` | �?首次安装 | 企业 WebSocket 服务地址,默�?`ws://aiws-sim.haiersmarthomes.com:11055/xiaoyou/claw` |
|
|
39
|
+
| `--token <token>` | �?首次安装 | 企业服务认证 Token |
|
|
40
|
+
| `--version <ver>` | �?| 指定 openclaw-xiaoyou 版本,默�?latest |
|
|
41
|
+
| `--check-only` | �?| 只输出计划,不执行真实改�?|
|
|
42
|
+
| `uninstall` | �?| 卸载小优 channel |
|
|
43
43
|
|
|
44
44
|
### 首次安装
|
|
45
45
|
|
|
46
|
-
用户必须提供 `--ws-url`
|
|
46
|
+
用户必须提供 `--ws-url` �?`--token`�?
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
|
-
curl -fsSL https://d10.tfdl.net/public/2026-05-06/
|
|
49
|
+
curl -fsSL https://d10.tfdl.net/public/2026-05-06/14dbf63d-d0aa-4b5d-bdd6-47eddb455f36/install-xiaoyou.sh | bash -s -- --ws-url ws://aiws-sim.haiersmarthomes.com:11055/xiaoyou/claw --token my-enterprise-token
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
### 升级
|
|
@@ -54,30 +54,30 @@ curl -fsSL https://d10.tfdl.net/public/2026-05-06/e466d49d-4c5c-4fca-88dd-d69a38
|
|
|
54
54
|
已安装后的升级可以不传参数,脚本会复用现有配置:
|
|
55
55
|
|
|
56
56
|
```bash
|
|
57
|
-
curl -fsSL https://d10.tfdl.net/public/2026-05-06/
|
|
57
|
+
curl -fsSL https://d10.tfdl.net/public/2026-05-06/14dbf63d-d0aa-4b5d-bdd6-47eddb455f36/install-xiaoyou.sh | bash -s --
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
如果升级时传�?`--ws-url` �?`--token`,会覆盖现有配置�?
|
|
61
61
|
|
|
62
62
|
### 指定版本
|
|
63
63
|
|
|
64
64
|
```bash
|
|
65
|
-
curl -fsSL https://d10.tfdl.net/public/2026-05-06/
|
|
65
|
+
curl -fsSL https://d10.tfdl.net/public/2026-05-06/14dbf63d-d0aa-4b5d-bdd6-47eddb455f36/install-xiaoyou.sh | bash -s -- --version 1.0.2 --ws-url ws://aiws-sim.haiersmarthomes.com:11055/xiaoyou/claw --token my-token
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
## 卸载
|
|
69
69
|
|
|
70
70
|
```bash
|
|
71
|
-
curl -fsSL https://d10.tfdl.net/public/2026-05-06/
|
|
71
|
+
curl -fsSL https://d10.tfdl.net/public/2026-05-06/14dbf63d-d0aa-4b5d-bdd6-47eddb455f36/install-xiaoyou.sh | bash -s -- uninstall
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
卸载会删�?xiaoyou channel 配置、插件记录和扩展目录�?
|
|
75
75
|
|
|
76
76
|
## 预检
|
|
77
77
|
|
|
78
78
|
```bash
|
|
79
|
-
curl -fsSL https://d10.tfdl.net/public/2026-05-06/
|
|
80
|
-
curl -fsSL https://d10.tfdl.net/public/2026-05-06/
|
|
79
|
+
curl -fsSL https://d10.tfdl.net/public/2026-05-06/14dbf63d-d0aa-4b5d-bdd6-47eddb455f36/install-xiaoyou.sh | bash -s -- --check-only
|
|
80
|
+
curl -fsSL https://d10.tfdl.net/public/2026-05-06/14dbf63d-d0aa-4b5d-bdd6-47eddb455f36/install-xiaoyou.sh | bash -s -- uninstall --check-only
|
|
81
81
|
```
|
|
82
82
|
|
|
83
83
|
## 失败处理
|
|
@@ -89,22 +89,22 @@ curl -fsSL https://d10.tfdl.net/public/2026-05-06/e466d49d-4c5c-4fca-88dd-d69a38
|
|
|
89
89
|
| 缺少 `--token` | 要求用户提供企业服务认证 Token |
|
|
90
90
|
| 未检测到 OpenClaw | 提示用户先安装并启动 OpenClaw |
|
|
91
91
|
| npm latest 查询失败 | 可让脚本继续幂等安装,或指定 `--version` |
|
|
92
|
-
| wsUrl
|
|
92
|
+
| wsUrl 格式不合�?| 地址必须�?`ws://` �?`wss://` 开�?|
|
|
93
93
|
|
|
94
|
-
##
|
|
94
|
+
## 脚本做了什�?
|
|
95
95
|
|
|
96
|
-
1.
|
|
97
|
-
2. 安装/升级 `openclaw-xiaoyou` 插件(`openclaw plugins install openclaw-xiaoyou@latest
|
|
98
|
-
3. 写入 channel
|
|
96
|
+
1. 检�?OpenClaw 是否已安装并运行
|
|
97
|
+
2. 安装/升级 `openclaw-xiaoyou` 插件(`openclaw plugins install openclaw-xiaoyou@latest`�?
|
|
98
|
+
3. 写入 channel 配置�?`~/.openclaw/openclaw.json`�?
|
|
99
99
|
- `channels.xiaoyou.enabled = true`
|
|
100
100
|
- `channels.xiaoyou.wsUrl = <用户提供的地址>`
|
|
101
|
-
- `channels.xiaoyou.authToken =
|
|
101
|
+
- `channels.xiaoyou.authToken = <用户提供�?token>`
|
|
102
102
|
- `channels.xiaoyou.dmSecurity = open`
|
|
103
|
-
4. 检查插件状态和 gateway
|
|
103
|
+
4. 检查插件状态和 gateway 运行状�?
|
|
104
104
|
|
|
105
105
|
## 完成定义
|
|
106
106
|
|
|
107
|
-
-
|
|
108
|
-
-
|
|
109
|
-
- 安装场景下,`openclaw xiaoyou status` 显示 connected
|
|
110
|
-
- 企业服务端能收到来自 xiaoyou
|
|
107
|
+
- 脚本退出码�?0�?
|
|
108
|
+
- 日志显示安装、升级或卸载流程完成�?
|
|
109
|
+
- 安装场景下,`openclaw xiaoyou status` 显示 connected�?
|
|
110
|
+
- 企业服务端能收到来自 xiaoyou 插件�?WebSocket 连接�?
|
package/package.json
CHANGED
package/src/channel.ts
CHANGED
|
@@ -100,9 +100,8 @@ export const xiayouPlugin = {
|
|
|
100
100
|
startAccount: async (ctx: any) => {
|
|
101
101
|
const { account, cfg, log } = ctx;
|
|
102
102
|
|
|
103
|
-
//
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
// 使用 register 时注入的 runtime(有 channel.reply 等完整 API)
|
|
104
|
+
// 注意:ctx.runtime 只有 log/error/exit,不能用它覆盖
|
|
106
105
|
const section = account?.config || getChannelConfig(cfg);
|
|
107
106
|
const logger = log || console;
|
|
108
107
|
|
|
@@ -128,24 +127,79 @@ export const xiayouPlugin = {
|
|
|
128
127
|
account: resolved,
|
|
129
128
|
logger,
|
|
130
129
|
onMessage: async (msg) => {
|
|
131
|
-
const
|
|
132
|
-
if (!
|
|
133
|
-
logger.error("[xiaoyou] runtime not available, cannot dispatch");
|
|
130
|
+
const rt = getRuntime();
|
|
131
|
+
if (!rt || !rt.channel) {
|
|
132
|
+
logger.error("[xiaoyou] runtime.channel not available, cannot dispatch");
|
|
134
133
|
return;
|
|
135
134
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
135
|
+
|
|
136
|
+
const senderId = msg.senderId;
|
|
137
|
+
const senderName = msg.senderName ?? msg.senderId;
|
|
138
|
+
const conversationId = msg.conversationId;
|
|
139
|
+
const text = msg.text ?? "";
|
|
140
|
+
const accountId = account?.accountId || "default";
|
|
141
|
+
|
|
142
|
+
// 1. 路由
|
|
143
|
+
const route = rt.channel.routing.resolveAgentRoute({
|
|
144
|
+
cfg: getChannelConfig(cfg) || {},
|
|
145
|
+
channel: "xiaoyou",
|
|
146
|
+
accountId,
|
|
147
|
+
peer: { kind: "direct", id: senderId },
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// 2. 格式化入站消息
|
|
151
|
+
const fromLabel = `${senderName} (${senderId})`;
|
|
152
|
+
const envelopeOptions = rt.channel.reply.resolveEnvelopeFormatOptions(cfg);
|
|
153
|
+
const body = rt.channel.reply.formatInboundEnvelope({
|
|
154
|
+
channel: "Xiaoyou",
|
|
155
|
+
from: fromLabel,
|
|
156
|
+
timestamp: Date.now(),
|
|
157
|
+
body: text,
|
|
141
158
|
chatType: "direct",
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
159
|
+
sender: { name: senderName, id: senderId },
|
|
160
|
+
envelope: envelopeOptions,
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
// 3. 构建上下文
|
|
164
|
+
const inboundCtx = rt.channel.reply.finalizeInboundContext({
|
|
165
|
+
Body: body,
|
|
166
|
+
RawBody: text,
|
|
167
|
+
CommandBody: text,
|
|
168
|
+
From: conversationId,
|
|
169
|
+
To: conversationId,
|
|
170
|
+
SessionKey: route.sessionKey,
|
|
171
|
+
AccountId: accountId,
|
|
172
|
+
ChatType: "direct",
|
|
173
|
+
ConversationLabel: fromLabel,
|
|
174
|
+
SenderName: senderName,
|
|
175
|
+
SenderId: senderId,
|
|
176
|
+
Provider: "xiaoyou",
|
|
177
|
+
Surface: "xiaoyou",
|
|
178
|
+
MessageSid: `xiaoyou-${Date.now()}`,
|
|
179
|
+
Timestamp: Date.now(),
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// 4. 分发并获取回复
|
|
183
|
+
await rt.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
|
|
184
|
+
ctx: inboundCtx,
|
|
185
|
+
cfg,
|
|
186
|
+
dispatcherOptions: {
|
|
187
|
+
responsePrefix: "",
|
|
188
|
+
deliver: async (payload: any) => {
|
|
189
|
+
const textToSend = payload.markdown || payload.text;
|
|
190
|
+
if (!textToSend) return;
|
|
191
|
+
if (_client && _client.isConnected()) {
|
|
192
|
+
_client.sendReply({
|
|
193
|
+
type: "reply",
|
|
194
|
+
conversationId,
|
|
195
|
+
messageId: `xiaoyou-${Date.now()}`,
|
|
196
|
+
text: textToSend,
|
|
197
|
+
timestamp: Date.now(),
|
|
198
|
+
});
|
|
199
|
+
logger.info(`[xiaoyou] reply sent to ${conversationId}`);
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
},
|
|
149
203
|
});
|
|
150
204
|
},
|
|
151
205
|
});
|