@ynhcj/xiaoyi 2.5.4 → 2.5.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 +207 -207
- package/dist/channel.js +498 -454
- package/openclaw.plugin.json +9 -9
- package/package.json +1 -1
- package/xiaoyi.js +1 -1
- package/dist/session-manager.d.ts +0 -78
- package/dist/session-manager.js +0 -258
package/README.md
CHANGED
|
@@ -1,207 +1,207 @@
|
|
|
1
|
-
# @ynhcj/xiaoyichannel
|
|
2
|
-
|
|
3
|
-
XiaoYi channel plugin for OpenClaw with A2A protocol support.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- WebSocket-based connection to XiaoYi servers
|
|
8
|
-
- AK/SK authentication mechanism
|
|
9
|
-
- A2A (Agent-to-Agent) message protocol support
|
|
10
|
-
- Automatic reconnection with exponential backoff
|
|
11
|
-
- Heartbeat mechanism for connection health monitoring
|
|
12
|
-
- Full integration with OpenClaw's message routing and session management
|
|
13
|
-
|
|
14
|
-
## Installation
|
|
15
|
-
|
|
16
|
-
Install the plugin in your OpenClaw project:
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
openclaw plugins install @ynhcj/xiaoyichannel@1.0.0
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## Configuration
|
|
23
|
-
|
|
24
|
-
After installation, add the XiaoYi channel configuration to your `openclaw.json` (or `.openclawd.json`):
|
|
25
|
-
|
|
26
|
-
```json
|
|
27
|
-
{
|
|
28
|
-
"channels": {
|
|
29
|
-
"xiaoyi": {
|
|
30
|
-
"enabled": true,
|
|
31
|
-
"accounts": {
|
|
32
|
-
"default": {
|
|
33
|
-
"enabled": true,
|
|
34
|
-
"wsUrl": "wss://hag.com/ws/link",
|
|
35
|
-
"ak": "your-access-key",
|
|
36
|
-
"sk": "your-secret-key",
|
|
37
|
-
"agentId": "your-agent-id"
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
"agents": {
|
|
43
|
-
"bindings": [
|
|
44
|
-
{
|
|
45
|
-
"agentId": "main",
|
|
46
|
-
"match": {
|
|
47
|
-
"channel": "xiaoyi",
|
|
48
|
-
"accountId": "default"
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
]
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### Configuration Parameters
|
|
57
|
-
|
|
58
|
-
- `wsUrl`: WebSocket server URL (e.g., `wss://hag.com/ws/link`)
|
|
59
|
-
- `ak`: Access Key for authentication
|
|
60
|
-
- `sk`: Secret Key for authentication
|
|
61
|
-
- `agentId`: Your agent identifier
|
|
62
|
-
|
|
63
|
-
### Multiple Accounts
|
|
64
|
-
|
|
65
|
-
You can configure multiple XiaoYi accounts:
|
|
66
|
-
|
|
67
|
-
```json
|
|
68
|
-
{
|
|
69
|
-
"channels": {
|
|
70
|
-
"xiaoyi": {
|
|
71
|
-
"enabled": true,
|
|
72
|
-
"accounts": {
|
|
73
|
-
"account1": {
|
|
74
|
-
"enabled": true,
|
|
75
|
-
"wsUrl": "wss://hag.com/ws/link",
|
|
76
|
-
"ak": "ak1",
|
|
77
|
-
"sk": "sk1",
|
|
78
|
-
"agentId": "agent1"
|
|
79
|
-
},
|
|
80
|
-
"account2": {
|
|
81
|
-
"enabled": true,
|
|
82
|
-
"wsUrl": "wss://hag.com/ws/link",
|
|
83
|
-
"ak": "ak2",
|
|
84
|
-
"sk": "sk2",
|
|
85
|
-
"agentId": "agent2"
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
## A2A Protocol
|
|
94
|
-
|
|
95
|
-
This plugin implements the A2A (Agent-to-Agent) message protocol as specified in the [Huawei Message Stream documentation](https://developer.huawei.com/consumer/cn/doc/service/message-stream-0000002505761434).
|
|
96
|
-
|
|
97
|
-
### Message Structure
|
|
98
|
-
|
|
99
|
-
**Incoming Request Message:**
|
|
100
|
-
```json
|
|
101
|
-
{
|
|
102
|
-
"sessionId": "session-123",
|
|
103
|
-
"messageId": "msg-456",
|
|
104
|
-
"timestamp": 1234567890,
|
|
105
|
-
"sender": {
|
|
106
|
-
"id": "user-id",
|
|
107
|
-
"name": "User Name",
|
|
108
|
-
"type": "user"
|
|
109
|
-
},
|
|
110
|
-
"content": {
|
|
111
|
-
"type": "text",
|
|
112
|
-
"text": "Hello, agent!"
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
**Outgoing Response Message:**
|
|
118
|
-
```json
|
|
119
|
-
{
|
|
120
|
-
"sessionId": "session-123",
|
|
121
|
-
"messageId": "msg-789",
|
|
122
|
-
"timestamp": 1234567891,
|
|
123
|
-
"agentId": "your-agent-id",
|
|
124
|
-
"sender": {
|
|
125
|
-
"id": "your-agent-id",
|
|
126
|
-
"name": "OpenClaw Agent",
|
|
127
|
-
"type": "agent"
|
|
128
|
-
},
|
|
129
|
-
"content": {
|
|
130
|
-
"type": "text",
|
|
131
|
-
"text": "Hello! How can I help you?"
|
|
132
|
-
},
|
|
133
|
-
"status": "success"
|
|
134
|
-
}
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
## Authentication
|
|
138
|
-
|
|
139
|
-
The plugin uses AK/SK authentication as specified in the [Huawei Push Message documentation](https://developer.huawei.com/consumer/cn/doc/service/pushmessage-0000002505761436).
|
|
140
|
-
|
|
141
|
-
The authentication signature is generated using HMAC-SHA256:
|
|
142
|
-
|
|
143
|
-
```
|
|
144
|
-
signature = HMAC-SHA256(SK, "ak={AK}×tamp={TIMESTAMP}")
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
## Connection Management
|
|
148
|
-
|
|
149
|
-
The plugin automatically manages WebSocket connections with the following features:
|
|
150
|
-
|
|
151
|
-
- **Automatic Reconnection**: Reconnects automatically on connection loss with exponential backoff
|
|
152
|
-
- **Heartbeat Monitoring**: Sends ping messages every 30 seconds to keep the connection alive
|
|
153
|
-
- **Connection Health**: Monitors connection status and reports health via OpenClaw's status system
|
|
154
|
-
- **Max Retry Limit**: Stops reconnection attempts after 10 failed attempts
|
|
155
|
-
|
|
156
|
-
## Session Management
|
|
157
|
-
|
|
158
|
-
The plugin integrates with OpenClaw's session management system:
|
|
159
|
-
|
|
160
|
-
- Sessions are scoped by `sessionId` from incoming A2A messages
|
|
161
|
-
- Each conversation maintains its own session context
|
|
162
|
-
- Session keys are automatically generated based on OpenClaw's configuration
|
|
163
|
-
|
|
164
|
-
## Usage
|
|
165
|
-
|
|
166
|
-
Once configured, the plugin will:
|
|
167
|
-
|
|
168
|
-
1. Automatically connect to the XiaoYi WebSocket server on startup
|
|
169
|
-
2. Authenticate using the provided AK/SK credentials
|
|
170
|
-
3. Receive incoming messages via WebSocket
|
|
171
|
-
4. Route messages to the appropriate OpenClaw agent
|
|
172
|
-
5. Send agent responses back through the WebSocket connection
|
|
173
|
-
|
|
174
|
-
## Troubleshooting
|
|
175
|
-
|
|
176
|
-
### Connection Issues
|
|
177
|
-
|
|
178
|
-
Check the OpenClaw logs for connection status:
|
|
179
|
-
|
|
180
|
-
```bash
|
|
181
|
-
openclaw logs
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
### Authentication Failures
|
|
185
|
-
|
|
186
|
-
Verify your AK/SK credentials are correct and have the necessary permissions.
|
|
187
|
-
|
|
188
|
-
### Message Delivery
|
|
189
|
-
|
|
190
|
-
Ensure your `agentId` is correctly configured and matches your XiaoYi account settings.
|
|
191
|
-
|
|
192
|
-
## Development
|
|
193
|
-
|
|
194
|
-
To build the plugin from source:
|
|
195
|
-
|
|
196
|
-
```bash
|
|
197
|
-
npm install
|
|
198
|
-
npm run build
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
## License
|
|
202
|
-
|
|
203
|
-
MIT
|
|
204
|
-
|
|
205
|
-
## Support
|
|
206
|
-
|
|
207
|
-
For issues and questions, please visit the [GitHub repository](https://github.com/ynhcj/xiaoyichannel).
|
|
1
|
+
# @ynhcj/xiaoyichannel
|
|
2
|
+
|
|
3
|
+
XiaoYi channel plugin for OpenClaw with A2A protocol support.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- WebSocket-based connection to XiaoYi servers
|
|
8
|
+
- AK/SK authentication mechanism
|
|
9
|
+
- A2A (Agent-to-Agent) message protocol support
|
|
10
|
+
- Automatic reconnection with exponential backoff
|
|
11
|
+
- Heartbeat mechanism for connection health monitoring
|
|
12
|
+
- Full integration with OpenClaw's message routing and session management
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
Install the plugin in your OpenClaw project:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
openclaw plugins install @ynhcj/xiaoyichannel@1.0.0
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Configuration
|
|
23
|
+
|
|
24
|
+
After installation, add the XiaoYi channel configuration to your `openclaw.json` (or `.openclawd.json`):
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"channels": {
|
|
29
|
+
"xiaoyi": {
|
|
30
|
+
"enabled": true,
|
|
31
|
+
"accounts": {
|
|
32
|
+
"default": {
|
|
33
|
+
"enabled": true,
|
|
34
|
+
"wsUrl": "wss://hag.com/ws/link",
|
|
35
|
+
"ak": "your-access-key",
|
|
36
|
+
"sk": "your-secret-key",
|
|
37
|
+
"agentId": "your-agent-id"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"agents": {
|
|
43
|
+
"bindings": [
|
|
44
|
+
{
|
|
45
|
+
"agentId": "main",
|
|
46
|
+
"match": {
|
|
47
|
+
"channel": "xiaoyi",
|
|
48
|
+
"accountId": "default"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Configuration Parameters
|
|
57
|
+
|
|
58
|
+
- `wsUrl`: WebSocket server URL (e.g., `wss://hag.com/ws/link`)
|
|
59
|
+
- `ak`: Access Key for authentication
|
|
60
|
+
- `sk`: Secret Key for authentication
|
|
61
|
+
- `agentId`: Your agent identifier
|
|
62
|
+
|
|
63
|
+
### Multiple Accounts
|
|
64
|
+
|
|
65
|
+
You can configure multiple XiaoYi accounts:
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"channels": {
|
|
70
|
+
"xiaoyi": {
|
|
71
|
+
"enabled": true,
|
|
72
|
+
"accounts": {
|
|
73
|
+
"account1": {
|
|
74
|
+
"enabled": true,
|
|
75
|
+
"wsUrl": "wss://hag.com/ws/link",
|
|
76
|
+
"ak": "ak1",
|
|
77
|
+
"sk": "sk1",
|
|
78
|
+
"agentId": "agent1"
|
|
79
|
+
},
|
|
80
|
+
"account2": {
|
|
81
|
+
"enabled": true,
|
|
82
|
+
"wsUrl": "wss://hag.com/ws/link",
|
|
83
|
+
"ak": "ak2",
|
|
84
|
+
"sk": "sk2",
|
|
85
|
+
"agentId": "agent2"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## A2A Protocol
|
|
94
|
+
|
|
95
|
+
This plugin implements the A2A (Agent-to-Agent) message protocol as specified in the [Huawei Message Stream documentation](https://developer.huawei.com/consumer/cn/doc/service/message-stream-0000002505761434).
|
|
96
|
+
|
|
97
|
+
### Message Structure
|
|
98
|
+
|
|
99
|
+
**Incoming Request Message:**
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"sessionId": "session-123",
|
|
103
|
+
"messageId": "msg-456",
|
|
104
|
+
"timestamp": 1234567890,
|
|
105
|
+
"sender": {
|
|
106
|
+
"id": "user-id",
|
|
107
|
+
"name": "User Name",
|
|
108
|
+
"type": "user"
|
|
109
|
+
},
|
|
110
|
+
"content": {
|
|
111
|
+
"type": "text",
|
|
112
|
+
"text": "Hello, agent!"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Outgoing Response Message:**
|
|
118
|
+
```json
|
|
119
|
+
{
|
|
120
|
+
"sessionId": "session-123",
|
|
121
|
+
"messageId": "msg-789",
|
|
122
|
+
"timestamp": 1234567891,
|
|
123
|
+
"agentId": "your-agent-id",
|
|
124
|
+
"sender": {
|
|
125
|
+
"id": "your-agent-id",
|
|
126
|
+
"name": "OpenClaw Agent",
|
|
127
|
+
"type": "agent"
|
|
128
|
+
},
|
|
129
|
+
"content": {
|
|
130
|
+
"type": "text",
|
|
131
|
+
"text": "Hello! How can I help you?"
|
|
132
|
+
},
|
|
133
|
+
"status": "success"
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Authentication
|
|
138
|
+
|
|
139
|
+
The plugin uses AK/SK authentication as specified in the [Huawei Push Message documentation](https://developer.huawei.com/consumer/cn/doc/service/pushmessage-0000002505761436).
|
|
140
|
+
|
|
141
|
+
The authentication signature is generated using HMAC-SHA256:
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
signature = HMAC-SHA256(SK, "ak={AK}×tamp={TIMESTAMP}")
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Connection Management
|
|
148
|
+
|
|
149
|
+
The plugin automatically manages WebSocket connections with the following features:
|
|
150
|
+
|
|
151
|
+
- **Automatic Reconnection**: Reconnects automatically on connection loss with exponential backoff
|
|
152
|
+
- **Heartbeat Monitoring**: Sends ping messages every 30 seconds to keep the connection alive
|
|
153
|
+
- **Connection Health**: Monitors connection status and reports health via OpenClaw's status system
|
|
154
|
+
- **Max Retry Limit**: Stops reconnection attempts after 10 failed attempts
|
|
155
|
+
|
|
156
|
+
## Session Management
|
|
157
|
+
|
|
158
|
+
The plugin integrates with OpenClaw's session management system:
|
|
159
|
+
|
|
160
|
+
- Sessions are scoped by `sessionId` from incoming A2A messages
|
|
161
|
+
- Each conversation maintains its own session context
|
|
162
|
+
- Session keys are automatically generated based on OpenClaw's configuration
|
|
163
|
+
|
|
164
|
+
## Usage
|
|
165
|
+
|
|
166
|
+
Once configured, the plugin will:
|
|
167
|
+
|
|
168
|
+
1. Automatically connect to the XiaoYi WebSocket server on startup
|
|
169
|
+
2. Authenticate using the provided AK/SK credentials
|
|
170
|
+
3. Receive incoming messages via WebSocket
|
|
171
|
+
4. Route messages to the appropriate OpenClaw agent
|
|
172
|
+
5. Send agent responses back through the WebSocket connection
|
|
173
|
+
|
|
174
|
+
## Troubleshooting
|
|
175
|
+
|
|
176
|
+
### Connection Issues
|
|
177
|
+
|
|
178
|
+
Check the OpenClaw logs for connection status:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
openclaw logs
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Authentication Failures
|
|
185
|
+
|
|
186
|
+
Verify your AK/SK credentials are correct and have the necessary permissions.
|
|
187
|
+
|
|
188
|
+
### Message Delivery
|
|
189
|
+
|
|
190
|
+
Ensure your `agentId` is correctly configured and matches your XiaoYi account settings.
|
|
191
|
+
|
|
192
|
+
## Development
|
|
193
|
+
|
|
194
|
+
To build the plugin from source:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
npm install
|
|
198
|
+
npm run build
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## License
|
|
202
|
+
|
|
203
|
+
MIT
|
|
204
|
+
|
|
205
|
+
## Support
|
|
206
|
+
|
|
207
|
+
For issues and questions, please visit the [GitHub repository](https://github.com/ynhcj/xiaoyichannel).
|