@ynhcj/xiaoyi 1.3.0 → 1.5.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/dist/channel.d.ts +8 -1
- package/dist/channel.js +11 -3
- package/dist/config-schema.d.ts +42 -0
- package/dist/config-schema.js +26 -0
- package/package.json +3 -2
package/dist/channel.d.ts
CHANGED
|
@@ -43,9 +43,16 @@ export declare const xiaoyiPlugin: {
|
|
|
43
43
|
sk: string;
|
|
44
44
|
agentId: string;
|
|
45
45
|
};
|
|
46
|
+
enabled: boolean;
|
|
46
47
|
}>;
|
|
47
48
|
defaultAccountId: (cfg: any) => string | undefined;
|
|
48
|
-
isConfigured: (account:
|
|
49
|
+
isConfigured: (account: any) => boolean;
|
|
50
|
+
describeAccount: (account: any) => {
|
|
51
|
+
accountId: any;
|
|
52
|
+
name: any;
|
|
53
|
+
enabled: any;
|
|
54
|
+
configured: boolean;
|
|
55
|
+
};
|
|
49
56
|
};
|
|
50
57
|
/**
|
|
51
58
|
* Outbound adapter - send messages
|
package/dist/channel.js
CHANGED
|
@@ -37,10 +37,9 @@ exports.xiaoyiPlugin = {
|
|
|
37
37
|
},
|
|
38
38
|
resolveAccount: async (ctx) => {
|
|
39
39
|
const resolvedAccountId = ctx.accountId || "default";
|
|
40
|
-
//
|
|
41
|
-
const channelConfig = ctx
|
|
40
|
+
// Access channelConfig from context
|
|
41
|
+
const channelConfig = ctx.channelConfig;
|
|
42
42
|
// If channel is not configured yet, return empty config
|
|
43
|
-
// This allows OpenClaw to detect it as unconfigured via isConfigured()
|
|
44
43
|
if (!channelConfig || !channelConfig.accounts) {
|
|
45
44
|
return {
|
|
46
45
|
accountId: resolvedAccountId,
|
|
@@ -51,6 +50,7 @@ exports.xiaoyiPlugin = {
|
|
|
51
50
|
sk: "",
|
|
52
51
|
agentId: "",
|
|
53
52
|
},
|
|
53
|
+
enabled: false,
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
const accountConfig = channelConfig.accounts[resolvedAccountId];
|
|
@@ -65,11 +65,13 @@ exports.xiaoyiPlugin = {
|
|
|
65
65
|
sk: "",
|
|
66
66
|
agentId: "",
|
|
67
67
|
},
|
|
68
|
+
enabled: false,
|
|
68
69
|
};
|
|
69
70
|
}
|
|
70
71
|
return {
|
|
71
72
|
accountId: resolvedAccountId,
|
|
72
73
|
config: accountConfig,
|
|
74
|
+
enabled: accountConfig.enabled !== false,
|
|
73
75
|
};
|
|
74
76
|
},
|
|
75
77
|
defaultAccountId: (cfg) => {
|
|
@@ -93,6 +95,12 @@ exports.xiaoyiPlugin = {
|
|
|
93
95
|
const hasAgentId = typeof config.agentId === 'string' && config.agentId.trim().length > 0;
|
|
94
96
|
return hasWsUrl && hasAk && hasSk && hasAgentId;
|
|
95
97
|
},
|
|
98
|
+
describeAccount: (account) => ({
|
|
99
|
+
accountId: account.accountId,
|
|
100
|
+
name: account.config?.name || 'XiaoYi',
|
|
101
|
+
enabled: account.enabled,
|
|
102
|
+
configured: Boolean(account.config?.wsUrl && account.config?.ak && account.config?.sk && account.config?.agentId),
|
|
103
|
+
}),
|
|
96
104
|
},
|
|
97
105
|
/**
|
|
98
106
|
* Outbound adapter - send messages
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* XiaoYi configuration schema using Zod
|
|
4
|
+
* Defines the structure for XiaoYi A2A protocol configuration
|
|
5
|
+
*/
|
|
6
|
+
export declare const XiaoYiConfigSchema: z.ZodObject<{
|
|
7
|
+
/** Account name (optional display name) */
|
|
8
|
+
name: z.ZodOptional<z.ZodString>;
|
|
9
|
+
/** Whether this channel is enabled */
|
|
10
|
+
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
11
|
+
/** WebSocket URL for A2A connection */
|
|
12
|
+
wsUrl: z.ZodOptional<z.ZodString>;
|
|
13
|
+
/** Access Key for authentication */
|
|
14
|
+
ak: z.ZodOptional<z.ZodString>;
|
|
15
|
+
/** Secret Key for authentication */
|
|
16
|
+
sk: z.ZodOptional<z.ZodString>;
|
|
17
|
+
/** Agent ID for this XiaoYi agent */
|
|
18
|
+
agentId: z.ZodOptional<z.ZodString>;
|
|
19
|
+
/** Enable debug logging */
|
|
20
|
+
debug: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
21
|
+
/** Multi-account configuration */
|
|
22
|
+
accounts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
debug: boolean;
|
|
26
|
+
accounts?: Record<string, unknown> | undefined;
|
|
27
|
+
name?: string | undefined;
|
|
28
|
+
wsUrl?: string | undefined;
|
|
29
|
+
ak?: string | undefined;
|
|
30
|
+
sk?: string | undefined;
|
|
31
|
+
agentId?: string | undefined;
|
|
32
|
+
}, {
|
|
33
|
+
accounts?: Record<string, unknown> | undefined;
|
|
34
|
+
name?: string | undefined;
|
|
35
|
+
enabled?: boolean | undefined;
|
|
36
|
+
wsUrl?: string | undefined;
|
|
37
|
+
ak?: string | undefined;
|
|
38
|
+
sk?: string | undefined;
|
|
39
|
+
agentId?: string | undefined;
|
|
40
|
+
debug?: boolean | undefined;
|
|
41
|
+
}>;
|
|
42
|
+
export type XiaoYiConfig = z.infer<typeof XiaoYiConfigSchema>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XiaoYiConfigSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/**
|
|
6
|
+
* XiaoYi configuration schema using Zod
|
|
7
|
+
* Defines the structure for XiaoYi A2A protocol configuration
|
|
8
|
+
*/
|
|
9
|
+
exports.XiaoYiConfigSchema = zod_1.z.object({
|
|
10
|
+
/** Account name (optional display name) */
|
|
11
|
+
name: zod_1.z.string().optional(),
|
|
12
|
+
/** Whether this channel is enabled */
|
|
13
|
+
enabled: zod_1.z.boolean().optional().default(true),
|
|
14
|
+
/** WebSocket URL for A2A connection */
|
|
15
|
+
wsUrl: zod_1.z.string().optional(),
|
|
16
|
+
/** Access Key for authentication */
|
|
17
|
+
ak: zod_1.z.string().optional(),
|
|
18
|
+
/** Secret Key for authentication */
|
|
19
|
+
sk: zod_1.z.string().optional(),
|
|
20
|
+
/** Agent ID for this XiaoYi agent */
|
|
21
|
+
agentId: zod_1.z.string().optional(),
|
|
22
|
+
/** Enable debug logging */
|
|
23
|
+
debug: zod_1.z.boolean().optional().default(false),
|
|
24
|
+
/** Multi-account configuration */
|
|
25
|
+
accounts: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
26
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ynhcj/xiaoyi",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "XiaoYi channel plugin for OpenClaw",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"ws": "^8.16.0"
|
|
43
|
+
"ws": "^8.16.0",
|
|
44
|
+
"zod": "^3.22.4"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@types/node": "^20.11.0",
|