openclaw-xiaoyou 1.0.6 → 1.0.7
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/package.json +1 -1
- package/src/channel.ts +30 -10
package/package.json
CHANGED
package/src/channel.ts
CHANGED
|
@@ -21,12 +21,21 @@ export function getRuntime() { return _runtime; }
|
|
|
21
21
|
|
|
22
22
|
// ─── Config Adapter ──────────────────────────────────
|
|
23
23
|
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
function getChannelConfig(cfg: any): any {
|
|
25
|
+
return cfg?.channels?.xiaoyou ?? {};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function resolveAccount(cfg: any, accountId?: string | null): any {
|
|
29
|
+
const section = getChannelConfig(cfg);
|
|
30
|
+
const id = accountId || "default";
|
|
31
|
+
const configured = Boolean(section.wsUrl);
|
|
27
32
|
|
|
28
33
|
return {
|
|
29
|
-
|
|
34
|
+
accountId: id,
|
|
35
|
+
config: section,
|
|
36
|
+
enabled: section.enabled !== false,
|
|
37
|
+
configured,
|
|
38
|
+
wsUrl: section.wsUrl ?? "",
|
|
30
39
|
authToken: section.authToken ?? "",
|
|
31
40
|
allowFrom: section.allowFrom ?? [],
|
|
32
41
|
dmPolicy: section.dmSecurity,
|
|
@@ -38,7 +47,7 @@ function resolveAccount(cfg: any): ResolvedAccount {
|
|
|
38
47
|
}
|
|
39
48
|
|
|
40
49
|
function inspectAccount(cfg: any) {
|
|
41
|
-
const section = cfg
|
|
50
|
+
const section = getChannelConfig(cfg);
|
|
42
51
|
return {
|
|
43
52
|
enabled: Boolean(section?.wsUrl),
|
|
44
53
|
configured: Boolean(section?.wsUrl),
|
|
@@ -47,7 +56,7 @@ function inspectAccount(cfg: any) {
|
|
|
47
56
|
}
|
|
48
57
|
|
|
49
58
|
function listAccountIds(cfg: any): string[] {
|
|
50
|
-
const section = cfg
|
|
59
|
+
const section = getChannelConfig(cfg);
|
|
51
60
|
if (section?.wsUrl) return ["default"];
|
|
52
61
|
return [];
|
|
53
62
|
}
|
|
@@ -104,9 +113,18 @@ export const xiayouPlugin = {
|
|
|
104
113
|
gateway: {
|
|
105
114
|
start: async ({ account, config, logger }: any) => {
|
|
106
115
|
const resolved: ResolvedAccount =
|
|
107
|
-
typeof account
|
|
116
|
+
typeof account?.wsUrl === "string"
|
|
108
117
|
? account
|
|
109
|
-
:
|
|
118
|
+
: {
|
|
119
|
+
wsUrl: account?.config?.wsUrl ?? "",
|
|
120
|
+
authToken: account?.config?.authToken ?? "",
|
|
121
|
+
allowFrom: account?.config?.allowFrom ?? [],
|
|
122
|
+
dmPolicy: account?.config?.dmSecurity,
|
|
123
|
+
reconnectIntervalMs: account?.config?.reconnectIntervalMs ?? 3000,
|
|
124
|
+
maxReconnectAttempts: account?.config?.maxReconnectAttempts ?? 0,
|
|
125
|
+
heartbeatIntervalMs: account?.config?.heartbeatIntervalMs ?? 30000,
|
|
126
|
+
heartbeatTimeoutMs: account?.config?.heartbeatTimeoutMs ?? 10000,
|
|
127
|
+
};
|
|
110
128
|
|
|
111
129
|
// 断开已有连接
|
|
112
130
|
if (_client) _client.disconnect();
|
|
@@ -184,9 +202,11 @@ export const xiayouPlugin = {
|
|
|
184
202
|
status: {
|
|
185
203
|
describe: async ({ account }: any) => {
|
|
186
204
|
const issues: Array<{ severity: string; message: string }> = [];
|
|
205
|
+
const wsUrl = account?.wsUrl ?? account?.config?.wsUrl;
|
|
206
|
+
const authToken = account?.authToken ?? account?.config?.authToken;
|
|
187
207
|
|
|
188
|
-
if (!
|
|
189
|
-
if (!
|
|
208
|
+
if (!wsUrl) issues.push({ severity: "error", message: "wsUrl not configured" });
|
|
209
|
+
if (!authToken) issues.push({ severity: "warning", message: "authToken not set" });
|
|
190
210
|
if (!_client || !_client.isConnected()) issues.push({ severity: "error", message: "WebSocket not connected" });
|
|
191
211
|
|
|
192
212
|
return {
|