@ynhcj/xiaoyi 0.0.1-beta
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 -0
- package/dist/auth.d.ts +36 -0
- package/dist/auth.js +111 -0
- package/dist/channel.d.ts +189 -0
- package/dist/channel.js +354 -0
- package/dist/config-schema.d.ts +46 -0
- package/dist/config-schema.js +28 -0
- package/dist/file-download.d.ts +17 -0
- package/dist/file-download.js +69 -0
- package/dist/file-handler.d.ts +36 -0
- package/dist/file-handler.js +113 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +49 -0
- package/dist/onboarding.d.ts +6 -0
- package/dist/onboarding.js +167 -0
- package/dist/push.d.ts +28 -0
- package/dist/push.js +135 -0
- package/dist/runtime.d.ts +191 -0
- package/dist/runtime.js +438 -0
- package/dist/types.d.ts +280 -0
- package/dist/types.js +8 -0
- package/dist/websocket.d.ts +219 -0
- package/dist/websocket.js +1068 -0
- package/dist/xiaoyi-media.d.ts +81 -0
- package/dist/xiaoyi-media.js +216 -0
- package/dist/xy-bot.d.ts +19 -0
- package/dist/xy-bot.js +277 -0
- package/dist/xy-client.d.ts +26 -0
- package/dist/xy-client.js +78 -0
- package/dist/xy-config.d.ts +18 -0
- package/dist/xy-config.js +37 -0
- package/dist/xy-formatter.d.ts +94 -0
- package/dist/xy-formatter.js +303 -0
- package/dist/xy-monitor.d.ts +17 -0
- package/dist/xy-monitor.js +194 -0
- package/dist/xy-parser.d.ts +49 -0
- package/dist/xy-parser.js +109 -0
- package/dist/xy-reply-dispatcher.d.ts +17 -0
- package/dist/xy-reply-dispatcher.js +308 -0
- package/dist/xy-tools/session-manager.d.ts +29 -0
- package/dist/xy-tools/session-manager.js +80 -0
- package/dist/xy-utils/config-manager.d.ts +26 -0
- package/dist/xy-utils/config-manager.js +61 -0
- package/dist/xy-utils/crypto.d.ts +8 -0
- package/dist/xy-utils/crypto.js +21 -0
- package/dist/xy-utils/logger.d.ts +6 -0
- package/dist/xy-utils/logger.js +37 -0
- package/dist/xy-utils/session.d.ts +34 -0
- package/dist/xy-utils/session.js +55 -0
- package/openclaw.plugin.json +9 -0
- package/package.json +73 -0
- package/xiaoyi.js +1 -0
package/README.md
ADDED
|
@@ -0,0 +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).
|
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AuthCredentials } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Generate authentication signature using AK/SK mechanism
|
|
4
|
+
* Based on: https://developer.huawei.com/consumer/cn/doc/service/pushmessage-0000002505761436
|
|
5
|
+
*
|
|
6
|
+
* Signature format: Base64(HMAC-SHA256(secretKey, ts))
|
|
7
|
+
*/
|
|
8
|
+
export declare class XiaoYiAuth {
|
|
9
|
+
private ak;
|
|
10
|
+
private sk;
|
|
11
|
+
private agentId;
|
|
12
|
+
constructor(ak: string, sk: string, agentId: string);
|
|
13
|
+
/**
|
|
14
|
+
* Generate authentication credentials with signature
|
|
15
|
+
*/
|
|
16
|
+
generateAuthCredentials(): AuthCredentials;
|
|
17
|
+
/**
|
|
18
|
+
* Generate HMAC-SHA256 signature
|
|
19
|
+
* Format: Base64(HMAC-SHA256(secretKey, ts))
|
|
20
|
+
* Reference: https://developer.huawei.com/consumer/cn/doc/service/pushmessage-0000002505761436
|
|
21
|
+
* @param timestamp - Timestamp as string (e.g., "1514764800000")
|
|
22
|
+
*/
|
|
23
|
+
private generateSignature;
|
|
24
|
+
/**
|
|
25
|
+
* Verify if credentials are valid
|
|
26
|
+
*/
|
|
27
|
+
verifyCredentials(credentials: AuthCredentials): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Generate authentication headers for WebSocket connection
|
|
30
|
+
*/
|
|
31
|
+
generateAuthHeaders(): Record<string, string>;
|
|
32
|
+
/**
|
|
33
|
+
* Generate authentication message for WebSocket (legacy, kept for compatibility)
|
|
34
|
+
*/
|
|
35
|
+
generateAuthMessage(): any;
|
|
36
|
+
}
|
package/dist/auth.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.XiaoYiAuth = void 0;
|
|
37
|
+
const crypto = __importStar(require("crypto"));
|
|
38
|
+
/**
|
|
39
|
+
* Generate authentication signature using AK/SK mechanism
|
|
40
|
+
* Based on: https://developer.huawei.com/consumer/cn/doc/service/pushmessage-0000002505761436
|
|
41
|
+
*
|
|
42
|
+
* Signature format: Base64(HMAC-SHA256(secretKey, ts))
|
|
43
|
+
*/
|
|
44
|
+
class XiaoYiAuth {
|
|
45
|
+
constructor(ak, sk, agentId) {
|
|
46
|
+
this.ak = ak;
|
|
47
|
+
this.sk = sk;
|
|
48
|
+
this.agentId = agentId;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Generate authentication credentials with signature
|
|
52
|
+
*/
|
|
53
|
+
generateAuthCredentials() {
|
|
54
|
+
const timestamp = Date.now();
|
|
55
|
+
const signature = this.generateSignature(timestamp.toString());
|
|
56
|
+
return {
|
|
57
|
+
ak: this.ak,
|
|
58
|
+
sk: this.sk,
|
|
59
|
+
timestamp,
|
|
60
|
+
signature,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Generate HMAC-SHA256 signature
|
|
65
|
+
* Format: Base64(HMAC-SHA256(secretKey, ts))
|
|
66
|
+
* Reference: https://developer.huawei.com/consumer/cn/doc/service/pushmessage-0000002505761436
|
|
67
|
+
* @param timestamp - Timestamp as string (e.g., "1514764800000")
|
|
68
|
+
*/
|
|
69
|
+
generateSignature(timestamp) {
|
|
70
|
+
// HMAC-SHA256(secretKey, ts)
|
|
71
|
+
const hmac = crypto.createHmac("sha256", this.sk);
|
|
72
|
+
hmac.update(timestamp);
|
|
73
|
+
const digest = hmac.digest();
|
|
74
|
+
// Base64 encode
|
|
75
|
+
return digest.toString("base64");
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Verify if credentials are valid
|
|
79
|
+
*/
|
|
80
|
+
verifyCredentials(credentials) {
|
|
81
|
+
const expectedSignature = this.generateSignature(credentials.timestamp.toString());
|
|
82
|
+
return credentials.signature === expectedSignature;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Generate authentication headers for WebSocket connection
|
|
86
|
+
*/
|
|
87
|
+
generateAuthHeaders() {
|
|
88
|
+
const timestamp = Date.now();
|
|
89
|
+
const signature = this.generateSignature(timestamp.toString());
|
|
90
|
+
return {
|
|
91
|
+
"x-access-key": this.ak,
|
|
92
|
+
"x-sign": signature,
|
|
93
|
+
"x-ts": timestamp.toString(),
|
|
94
|
+
"x-agent-id": this.agentId,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Generate authentication message for WebSocket (legacy, kept for compatibility)
|
|
99
|
+
*/
|
|
100
|
+
generateAuthMessage() {
|
|
101
|
+
const credentials = this.generateAuthCredentials();
|
|
102
|
+
return {
|
|
103
|
+
type: "auth",
|
|
104
|
+
ak: credentials.ak,
|
|
105
|
+
agentId: this.agentId,
|
|
106
|
+
timestamp: credentials.timestamp,
|
|
107
|
+
signature: credentials.signature,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.XiaoYiAuth = XiaoYiAuth;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import type { ChannelOutboundContext, ChannelGatewayContext, OpenClawConfig } from "openclaw/dist/plugin-sdk/index.js";
|
|
2
|
+
type OutboundDeliveryResult = {
|
|
3
|
+
channel: string;
|
|
4
|
+
messageId: string;
|
|
5
|
+
chatId?: string;
|
|
6
|
+
channelId?: string;
|
|
7
|
+
roomId?: string;
|
|
8
|
+
conversationId?: string;
|
|
9
|
+
timestamp?: number;
|
|
10
|
+
meta?: Record<string, unknown>;
|
|
11
|
+
};
|
|
12
|
+
import { XiaoYiChannelConfig } from "./types.js";
|
|
13
|
+
/**
|
|
14
|
+
* Resolved XiaoYi account configuration (single account mode)
|
|
15
|
+
*/
|
|
16
|
+
export interface ResolvedXiaoYiAccount {
|
|
17
|
+
accountId: string;
|
|
18
|
+
config: XiaoYiChannelConfig;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* XiaoYi Channel Plugin
|
|
22
|
+
* Implements OpenClaw ChannelPlugin interface for XiaoYi A2A protocol
|
|
23
|
+
* Single account mode only
|
|
24
|
+
*/
|
|
25
|
+
export declare const xiaoyiPlugin: {
|
|
26
|
+
id: string;
|
|
27
|
+
meta: {
|
|
28
|
+
id: string;
|
|
29
|
+
label: string;
|
|
30
|
+
selectionLabel: string;
|
|
31
|
+
docsPath: string;
|
|
32
|
+
blurb: string;
|
|
33
|
+
aliases: string[];
|
|
34
|
+
};
|
|
35
|
+
capabilities: {
|
|
36
|
+
chatTypes: string[];
|
|
37
|
+
polls: boolean;
|
|
38
|
+
reactions: boolean;
|
|
39
|
+
threads: boolean;
|
|
40
|
+
media: boolean;
|
|
41
|
+
nativeCommands: boolean;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Config schema for UI form rendering
|
|
45
|
+
*/
|
|
46
|
+
configSchema: {
|
|
47
|
+
schema: {
|
|
48
|
+
type: string;
|
|
49
|
+
properties: {
|
|
50
|
+
enabled: {
|
|
51
|
+
type: string;
|
|
52
|
+
default: boolean;
|
|
53
|
+
description: string;
|
|
54
|
+
};
|
|
55
|
+
wsUrl1: {
|
|
56
|
+
type: string;
|
|
57
|
+
default: string;
|
|
58
|
+
description: string;
|
|
59
|
+
};
|
|
60
|
+
wsUrl2: {
|
|
61
|
+
type: string;
|
|
62
|
+
default: string;
|
|
63
|
+
description: string;
|
|
64
|
+
};
|
|
65
|
+
ak: {
|
|
66
|
+
type: string;
|
|
67
|
+
description: string;
|
|
68
|
+
};
|
|
69
|
+
sk: {
|
|
70
|
+
type: string;
|
|
71
|
+
description: string;
|
|
72
|
+
};
|
|
73
|
+
agentId: {
|
|
74
|
+
type: string;
|
|
75
|
+
description: string;
|
|
76
|
+
};
|
|
77
|
+
debug: {
|
|
78
|
+
type: string;
|
|
79
|
+
default: boolean;
|
|
80
|
+
description: string;
|
|
81
|
+
};
|
|
82
|
+
apiId: {
|
|
83
|
+
type: string;
|
|
84
|
+
default: string;
|
|
85
|
+
description: string;
|
|
86
|
+
};
|
|
87
|
+
pushId: {
|
|
88
|
+
type: string;
|
|
89
|
+
default: string;
|
|
90
|
+
description: string;
|
|
91
|
+
};
|
|
92
|
+
taskTimeoutMs: {
|
|
93
|
+
type: string;
|
|
94
|
+
default: number;
|
|
95
|
+
description: string;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
onboarding: any;
|
|
101
|
+
/**
|
|
102
|
+
* Config adapter - single account mode
|
|
103
|
+
*/
|
|
104
|
+
config: {
|
|
105
|
+
listAccountIds: (cfg: OpenClawConfig) => string[];
|
|
106
|
+
resolveAccount: (cfg: OpenClawConfig, accountId?: string | null) => {
|
|
107
|
+
accountId: string;
|
|
108
|
+
config: XiaoYiChannelConfig;
|
|
109
|
+
enabled: boolean;
|
|
110
|
+
};
|
|
111
|
+
defaultAccountId: (cfg: OpenClawConfig) => string;
|
|
112
|
+
isConfigured: (account: any, cfg: OpenClawConfig) => boolean;
|
|
113
|
+
isEnabled: (account: any, cfg: OpenClawConfig) => boolean;
|
|
114
|
+
disabledReason: (account: any, cfg: OpenClawConfig) => string;
|
|
115
|
+
unconfiguredReason: (account: any, cfg: OpenClawConfig) => string;
|
|
116
|
+
describeAccount: (account: any, cfg: OpenClawConfig) => {
|
|
117
|
+
accountId: any;
|
|
118
|
+
name: string;
|
|
119
|
+
enabled: any;
|
|
120
|
+
configured: boolean;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Gateway adapter - manage connections
|
|
125
|
+
* Using xy-monitor for message handling (xy_channel architecture)
|
|
126
|
+
*/
|
|
127
|
+
gateway: {
|
|
128
|
+
startAccount: (ctx: ChannelGatewayContext<ResolvedXiaoYiAccount>) => Promise<void>;
|
|
129
|
+
stopAccount: (ctx: ChannelGatewayContext<ResolvedXiaoYiAccount>) => Promise<void>;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Outbound adapter - send messages via push
|
|
133
|
+
*/
|
|
134
|
+
outbound: {
|
|
135
|
+
deliveryMode: string;
|
|
136
|
+
textChunkLimit: number;
|
|
137
|
+
resolveTarget: ({ cfg, to, accountId, mode }: any) => {
|
|
138
|
+
ok: boolean;
|
|
139
|
+
to: any;
|
|
140
|
+
};
|
|
141
|
+
sendText: (ctx: ChannelOutboundContext) => Promise<OutboundDeliveryResult>;
|
|
142
|
+
sendMedia: (ctx: ChannelOutboundContext) => Promise<OutboundDeliveryResult>;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Messaging adapter - normalize targets
|
|
146
|
+
* In new openclaw version, normalizeTarget receives a string and returns a normalized string
|
|
147
|
+
*/
|
|
148
|
+
messaging: {
|
|
149
|
+
normalizeTarget: (raw: string) => string;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Status adapter - health checks
|
|
153
|
+
* Using buildAccountSnapshot for compatibility with new openclaw version
|
|
154
|
+
*/
|
|
155
|
+
status: {
|
|
156
|
+
buildAccountSnapshot: (params: {
|
|
157
|
+
account: ResolvedXiaoYiAccount;
|
|
158
|
+
cfg: OpenClawConfig;
|
|
159
|
+
runtime?: any;
|
|
160
|
+
probe?: unknown;
|
|
161
|
+
audit?: unknown;
|
|
162
|
+
}) => Promise<{
|
|
163
|
+
accountId: string;
|
|
164
|
+
state: "offline";
|
|
165
|
+
lastEventAt: number;
|
|
166
|
+
issues: {
|
|
167
|
+
severity: "error";
|
|
168
|
+
message: string;
|
|
169
|
+
}[];
|
|
170
|
+
lastInboundAt?: undefined;
|
|
171
|
+
} | {
|
|
172
|
+
accountId: string;
|
|
173
|
+
state: "ready";
|
|
174
|
+
lastEventAt: number;
|
|
175
|
+
lastInboundAt: number;
|
|
176
|
+
issues?: undefined;
|
|
177
|
+
} | {
|
|
178
|
+
accountId: string;
|
|
179
|
+
state: "authenticating";
|
|
180
|
+
lastEventAt: number;
|
|
181
|
+
issues: {
|
|
182
|
+
severity: "warning";
|
|
183
|
+
message: string;
|
|
184
|
+
}[];
|
|
185
|
+
lastInboundAt?: undefined;
|
|
186
|
+
}>;
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
export {};
|