@zzedbot/yunzhijia 1.0.12 → 1.0.13

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.

Potentially problematic release.


This version of @zzedbot/yunzhijia might be problematic. Click here for more details.

@@ -1,104 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.yunzhijiaPlugin = void 0;
4
- // @ts-nocheck
5
- const plugin_sdk_1 = require("openclaw/plugin-sdk");
6
- const config_js_1 = require("./config.js");
7
- const webhook_js_1 = require("./webhook.js");
8
- // Simple channel meta for YunzhiJia
9
- const meta = {
10
- id: "yunzhijia",
11
- label: "YunzhiJia",
12
- selectionLabel: "YunzhiJia (Kingdee)",
13
- docsPath: "/channels/yunzhijia",
14
- blurb: "Kingdee YunzhiJia enterprise messaging integration",
15
- aliases: ["kingdee", "yzj"],
16
- };
17
- const yunzhijiaMessageActions = {
18
- listActions: () => ["send"],
19
- extractToolSend: () => null,
20
- handleAction: async ({ action, params, accountId, cfg }) => {
21
- if (action === "send") {
22
- const account = (0, config_js_1.getAccountConfig)(cfg, accountId ?? plugin_sdk_1.DEFAULT_ACCOUNT_ID);
23
- if (!account) {
24
- throw new Error(`YunzhiJia account not found: ${accountId}`);
25
- }
26
- const content = typeof params.message === "string" ? params.message : "";
27
- const result = await (0, webhook_js_1.sendWebhookMessage)(content, account.webhookToken);
28
- return { success: result.success };
29
- }
30
- throw new Error(`Action ${action} not supported for YunzhiJia`);
31
- },
32
- };
33
- exports.yunzhijiaPlugin = {
34
- id: "yunzhijia",
35
- meta: meta,
36
- capabilities: {
37
- chatTypes: ["direct", "group"],
38
- media: false,
39
- },
40
- configSchema: (0, plugin_sdk_1.buildChannelConfigSchema)({
41
- type: "object",
42
- properties: {
43
- appSecret: { type: "string" },
44
- webhookToken: { type: "string" },
45
- allowFrom: { type: "array", items: { type: "string" } },
46
- requireMention: { type: "boolean" },
47
- responsePrefix: { type: "string" },
48
- },
49
- required: ["appSecret", "webhookToken"],
50
- }),
51
- config: {
52
- listAccountIds: (cfg) => (0, config_js_1.listAccountIds)(cfg),
53
- resolveAccount: (cfg, accountId) => (0, config_js_1.getAccountConfig)(cfg, accountId ?? plugin_sdk_1.DEFAULT_ACCOUNT_ID) ?? {
54
- appSecret: "",
55
- webhookToken: "",
56
- },
57
- defaultAccountId: () => plugin_sdk_1.DEFAULT_ACCOUNT_ID,
58
- isConfigured: (account) => (0, config_js_1.isAccountConfigured)(account),
59
- describeAccount: (account) => ({
60
- accountId: plugin_sdk_1.DEFAULT_ACCOUNT_ID,
61
- enabled: account?.enabled !== false,
62
- configured: (0, config_js_1.isAccountConfigured)(account),
63
- }),
64
- },
65
- security: {
66
- resolveDmPolicy: ({ account }) => ({
67
- policy: account.requireMention !== false ? "pairing" : "open",
68
- allowFrom: account.allowFrom ?? [],
69
- allowFromPath: "channels.yunzhijia.allowFrom",
70
- normalizeEntry: (raw) => raw.replace(/^(yunzhijia|yzj):/i, ""),
71
- }),
72
- },
73
- actions: yunzhijiaMessageActions,
74
- outbound: {
75
- deliveryMode: "direct",
76
- textChunkLimit: 2000,
77
- sendText: async ({ to, text, accountId, cfg }) => {
78
- const account = (0, config_js_1.getAccountConfig)(cfg, accountId ?? plugin_sdk_1.DEFAULT_ACCOUNT_ID);
79
- if (!account) {
80
- throw new Error(`YunzhiJia account not found: ${accountId}`);
81
- }
82
- const result = await (0, webhook_js_1.sendWebhookMessage)(text, account.webhookToken);
83
- return {
84
- channel: "yunzhijia",
85
- messageId: result.messageId,
86
- timestamp: Date.now(),
87
- to,
88
- };
89
- },
90
- sendMedia: async ({ to, text, mediaUrl, accountId, cfg }) => {
91
- const combinedText = mediaUrl ? `${text || ""} ${mediaUrl}`.trim() : text;
92
- return await exports.yunzhijiaPlugin.outbound.sendText({
93
- to,
94
- text: combinedText,
95
- accountId,
96
- cfg,
97
- });
98
- },
99
- },
100
- gateway: {
101
- startAccount: async () => { },
102
- stopAccount: async () => { },
103
- },
104
- };
package/dist/plugin.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { type ChannelPlugin, type ResolvedYunzhiJiaAccount } from "openclaw/plugin-sdk";
2
- export declare const yunzhijiaPlugin: ChannelPlugin<ResolvedYunzhiJiaAccount>;
package/dist/plugin.js DELETED
@@ -1,272 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.yunzhijiaPlugin = void 0;
4
- const plugin_sdk_1 = require("openclaw/plugin-sdk");
5
- const http_js_1 = require("./http.js");
6
- const webhook_js_1 = require("./webhook.js");
7
- const config_js_1 = require("./config.js");
8
- const runtime_js_1 = require("./runtime.js");
9
- const meta = (0, plugin_sdk_1.getChatChannelMeta)("yunzhijia");
10
- // Register HTTP route for YunzhiJia webhook
11
- (0, plugin_sdk_1.registerPluginHttpRoute)("/receive", async (req, res, { config }) => {
12
- await (0, http_js_1.handleYunzhiJiaWebhook)(req, res, config.channels?.yunzhijia ?? {});
13
- });
14
- exports.yunzhijiaPlugin = {
15
- id: "yunzhijia",
16
- meta: {
17
- ...meta,
18
- displayName: "YunzhiJia",
19
- description: "Kingdee YunzhiJia enterprise messaging integration",
20
- quickstartAllowFrom: true,
21
- },
22
- capabilities: {
23
- chatTypes: ["direct", "channel"],
24
- polls: false,
25
- reactions: false,
26
- threads: false,
27
- media: true,
28
- nativeCommands: false,
29
- blockStreaming: false,
30
- },
31
- reload: { configPrefixes: ["channels.yunzhijia"] },
32
- configSchema: (0, plugin_sdk_1.buildChannelConfigSchema)(config_js_1.YunzhiJiaConfigSchema),
33
- config: {
34
- listAccountIds: (cfg) => {
35
- const yunzhijiaCfg = cfg.channels?.yunzhijia;
36
- if (!yunzhijiaCfg)
37
- return [config_js_1.DEFAULT_ACCOUNT_ID];
38
- const accountIds = Object.keys(yunzhijiaCfg.accounts || {});
39
- return accountIds.length > 0 ? accountIds : [config_js_1.DEFAULT_ACCOUNT_ID];
40
- },
41
- resolveAccount: (cfg, accountId) => {
42
- const yunzhijiaCfg = cfg.channels?.yunzhijia;
43
- if (!yunzhijiaCfg) {
44
- return {
45
- accountId,
46
- config: {},
47
- name: accountId === config_js_1.DEFAULT_ACCOUNT_ID ? "Default" : accountId,
48
- enabled: false,
49
- configured: false,
50
- };
51
- }
52
- const accountConfig = yunzhijiaCfg.accounts?.[accountId] ?? {
53
- webhookToken: yunzhijiaCfg.webhookToken,
54
- appSecret: yunzhijiaCfg.appSecret,
55
- enabled: yunzhijiaCfg.enabled,
56
- name: yunzhijiaCfg.name,
57
- requireMention: yunzhijiaCfg.requireMention,
58
- skipSignatureVerification: yunzhijiaCfg.skipSignatureVerification,
59
- };
60
- return {
61
- accountId,
62
- config: accountConfig,
63
- name: accountConfig.name ?? (accountId === config_js_1.DEFAULT_ACCOUNT_ID ? "Default" : accountId),
64
- enabled: accountConfig.enabled ?? true,
65
- configured: Boolean(accountConfig.webhookToken?.trim()),
66
- };
67
- },
68
- defaultAccountId: () => config_js_1.DEFAULT_ACCOUNT_ID,
69
- setAccountEnabled: ({ cfg, accountId, enabled }) => {
70
- // Implementation needed for proper account management
71
- const current = cfg.channels?.yunzhijia || {};
72
- if (accountId === config_js_1.DEFAULT_ACCOUNT_ID) {
73
- return {
74
- ...cfg,
75
- channels: {
76
- ...cfg.channels,
77
- yunzhijia: {
78
- ...current,
79
- enabled: enabled,
80
- },
81
- },
82
- };
83
- }
84
- return {
85
- ...cfg,
86
- channels: {
87
- ...cfg.channels,
88
- yunzhijia: {
89
- ...current,
90
- accounts: {
91
- ...current.accounts,
92
- [accountId]: {
93
- ...(current.accounts?.[accountId] || {}),
94
- enabled: enabled,
95
- },
96
- },
97
- },
98
- },
99
- };
100
- },
101
- deleteAccount: ({ cfg, accountId }) => {
102
- if (accountId === config_js_1.DEFAULT_ACCOUNT_ID) {
103
- const { webhookToken, appSecret, name, enabled, requireMention, ...rest } = cfg.channels?.yunzhijia || {};
104
- return {
105
- ...cfg,
106
- channels: {
107
- ...cfg.channels,
108
- yunzhijia: rest,
109
- },
110
- };
111
- }
112
- const accounts = { ...cfg.channels?.yunzhijia?.accounts };
113
- delete accounts[accountId];
114
- return {
115
- ...cfg,
116
- channels: {
117
- ...cfg.channels,
118
- yunzhijia: {
119
- ...cfg.channels?.yunzhijia,
120
- accounts,
121
- },
122
- },
123
- };
124
- },
125
- isConfigured: (account) => account.configured,
126
- describeAccount: (account) => ({
127
- accountId: account.accountId,
128
- name: account.name,
129
- enabled: account.enabled,
130
- configured: account.configured,
131
- }),
132
- resolveAllowFrom: ({ cfg, accountId }) => {
133
- const account = cfg.channels?.yunzhijia?.accounts?.[accountId] || cfg.channels?.yunzhijia;
134
- return account?.allowFrom || [];
135
- },
136
- formatAllowFrom: ({ allowFrom }) => allowFrom.map(String).filter(Boolean),
137
- },
138
- security: {
139
- resolveDmPolicy: ({ account }) => ({
140
- policy: "open",
141
- allowFrom: account.config.allowFrom || [],
142
- approveHint: "云之家频道已配置完成",
143
- normalizeEntry: (raw) => raw,
144
- }),
145
- collectWarnings: ({ account, cfg }) => {
146
- const warnings = [];
147
- if (!account.configured) {
148
- warnings.push("- YunzhiJia 账户未配置 webhookToken");
149
- }
150
- return warnings;
151
- },
152
- },
153
- messaging: {
154
- normalizeTarget: (target) => target,
155
- targetResolver: {
156
- looksLikeId: (target) => /^[a-zA-Z0-9]+$/.test(target),
157
- hint: "<user-id>",
158
- },
159
- },
160
- outbound: {
161
- deliveryMode: "direct",
162
- chunker: null,
163
- chunkerMode: "text",
164
- textChunkLimit: 3000,
165
- pollMaxOptions: 0,
166
- sendText: async ({ to, text, accountId, deps }) => {
167
- const account = deps?.resolveAccount?.(accountId);
168
- if (!account?.configured) {
169
- throw new Error(`YunzhiJia account ${accountId} is not configured`);
170
- }
171
- await (0, webhook_js_1.sendToYunzhiJiaWebhook)(text, account.config);
172
- return { channel: "yunzhijia", to };
173
- },
174
- sendMedia: async ({ to, text, mediaUrl, accountId, deps }) => {
175
- const account = deps?.resolveAccount?.(accountId);
176
- if (!account?.configured) {
177
- throw new Error(`YunzhiJia account ${accountId} is not configured`);
178
- }
179
- await (0, webhook_js_1.sendMediaToYunzhiJia)(text, mediaUrl, account.config);
180
- return { channel: "yunzhijia", to };
181
- },
182
- sendPoll: async () => {
183
- throw new Error("Polls are not supported by YunzhiJia");
184
- },
185
- },
186
- status: {
187
- defaultRuntime: {
188
- accountId: config_js_1.DEFAULT_ACCOUNT_ID,
189
- running: true,
190
- lastStartAt: null,
191
- lastStopAt: null,
192
- lastError: null,
193
- lastInboundAt: null,
194
- lastOutboundAt: null,
195
- },
196
- collectStatusIssues: () => [],
197
- buildChannelSummary: ({ snapshot }) => ({
198
- configured: snapshot.configured ?? false,
199
- running: snapshot.running ?? false,
200
- lastStartAt: snapshot.lastStartAt ?? null,
201
- lastStopAt: snapshot.lastStopAt ?? null,
202
- lastError: snapshot.lastError ?? null,
203
- lastInboundAt: snapshot.lastInboundAt ?? null,
204
- lastOutboundAt: snapshot.lastOutboundAt ?? null,
205
- }),
206
- probeAccount: async ({ account }) => {
207
- return {
208
- ok: account.configured,
209
- bot: { username: "YunzhiJia Bot" },
210
- application: null,
211
- };
212
- },
213
- auditAccount: async () => undefined,
214
- buildAccountSnapshot: ({ account, runtime }) => ({
215
- accountId: account.accountId,
216
- name: account.name,
217
- enabled: account.enabled,
218
- configured: account.configured,
219
- running: runtime?.running ?? false,
220
- lastStartAt: runtime?.lastStartAt ?? null,
221
- lastStopAt: runtime?.lastStopAt ?? null,
222
- lastError: runtime?.lastError ?? null,
223
- lastInboundAt: runtime?.lastInboundAt ?? null,
224
- lastOutboundAt: runtime?.lastOutboundAt ?? null,
225
- }),
226
- },
227
- gateway: {
228
- startAccount: async (ctx) => {
229
- ctx.log?.info(`[${ctx.accountId}] YunzhiJia provider started (webhook-based)`);
230
- // No actual gateway needed for webhook-based channels
231
- return Promise.resolve();
232
- },
233
- logoutAccount: async ({ accountId, cfg }) => {
234
- const nextCfg = { ...cfg };
235
- const nextYunzhiJia = cfg.channels?.yunzhijia ? { ...cfg.channels.yunzhijia } : undefined;
236
- let cleared = false;
237
- if (nextYunzhiJia) {
238
- if (accountId === config_js_1.DEFAULT_ACCOUNT_ID) {
239
- delete nextYunzhiJia.webhookToken;
240
- delete nextYunzhiJia.appSecret;
241
- cleared = true;
242
- }
243
- if (nextYunzhiJia.accounts && accountId in nextYunzhiJia.accounts) {
244
- const accountEntry = nextYunzhiJia.accounts[accountId];
245
- if (accountEntry) {
246
- delete accountEntry.webhookToken;
247
- delete accountEntry.appSecret;
248
- cleared = true;
249
- }
250
- }
251
- }
252
- if (cleared) {
253
- if (nextYunzhiJia && Object.keys(nextYunzhiJia).length > 0) {
254
- nextCfg.channels = { ...nextCfg.channels, yunzhijia: nextYunzhiJia };
255
- }
256
- else {
257
- const nextChannels = { ...nextCfg.channels };
258
- delete nextChannels.yunzhijia;
259
- if (Object.keys(nextChannels).length > 0) {
260
- nextCfg.channels = nextChannels;
261
- }
262
- else {
263
- delete nextCfg.channels;
264
- }
265
- }
266
- }
267
- const resolved = (0, runtime_js_1.getYunzhiJiaRuntime)().channel.config.resolveAccount(nextCfg, accountId);
268
- const loggedOut = !resolved.configured;
269
- return { cleared, loggedOut };
270
- },
271
- },
272
- };
@@ -1,17 +0,0 @@
1
- import type { YunzhiJiaIncomingMessage, YunzhiJiaAccountConfig } from "./types.js";
2
- /**
3
- * Process incoming YunzhiJia message
4
- *
5
- * @param message - The incoming message from YunzhiJia
6
- * @param signature - Signature from request header
7
- * @param sessionId - Session ID from request header
8
- * @param account - Account configuration
9
- * @param accountId - Account ID
10
- * @param config - OpenClaw configuration
11
- * @param runtime - Runtime environment
12
- * @returns Response for immediate reply (empty content for async processing)
13
- */
14
- export declare function processIncomingMessage(message: YunzhiJiaIncomingMessage, signature: string, sessionId: string, account: YunzhiJiaAccountConfig, accountId: string, config: OpenClawConfig, runtime: RuntimeEnv): Promise<{
15
- success: boolean;
16
- immediateResponse?: boolean;
17
- }>;
package/dist/receiver.js DELETED
@@ -1,110 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.processIncomingMessage = processIncomingMessage;
4
- const utils_js_1 = require("./utils.js");
5
- const webhook_js_1 = require("./webhook.js");
6
- const runtime_js_1 = require("./runtime.js");
7
- /**
8
- * Process incoming YunzhiJia message
9
- *
10
- * @param message - The incoming message from YunzhiJia
11
- * @param signature - Signature from request header
12
- * @param sessionId - Session ID from request header
13
- * @param account - Account configuration
14
- * @param accountId - Account ID
15
- * @param config - OpenClaw configuration
16
- * @param runtime - Runtime environment
17
- * @returns Response for immediate reply (empty content for async processing)
18
- */
19
- async function processIncomingMessage(message, signature, sessionId, account, accountId, config, runtime) {
20
- const logger = {
21
- info: (msg) => runtime.log?.(msg),
22
- warn: (msg) => runtime.log?.(msg),
23
- error: (msg) => runtime.error?.(msg),
24
- debug: (msg) => runtime.log?.(msg),
25
- };
26
- // Verify signature
27
- if (!(0, utils_js_1.verifySignature)(message, signature, account.appSecret)) {
28
- logger.warn("Invalid signature received");
29
- return { success: false };
30
- }
31
- // Check mention requirement
32
- if (account.requireMention !== false && !(0, utils_js_1.isBotMentioned)(message.content, message.robotName)) {
33
- logger.debug("Message does not mention bot, ignoring");
34
- return { success: true, immediateResponse: true };
35
- }
36
- // Extract clean content (remove bot mention)
37
- const cleanContent = (0, utils_js_1.extractCleanContent)(message.content, message.robotName);
38
- // Create session key for conversation tracking
39
- const sessionKey = (0, utils_js_1.createSessionKey)(sessionId, message.robotId);
40
- // Route to appropriate agent
41
- const route = (0, runtime_js_1.getYunzhiJiaRuntime)().channel.routing.resolveAgentRoute({
42
- cfg: config,
43
- channel: "yunzhijia",
44
- accountId,
45
- peer: {
46
- kind: "direct",
47
- id: message.operatorOpenid,
48
- },
49
- });
50
- // Create message context
51
- const ctxPayload = {
52
- Body: cleanContent,
53
- RawBody: message.content,
54
- CommandBody: cleanContent,
55
- From: `yunzhijia:user:${message.operatorOpenid}`,
56
- To: `yunzhijia:robot:${message.robotId}`,
57
- SessionKey: sessionKey,
58
- AccountId: accountId,
59
- ChatType: "direct",
60
- ConversationLabel: message.operatorName,
61
- SenderName: message.operatorName,
62
- SenderId: message.operatorOpenid,
63
- Provider: "yunzhijia",
64
- Surface: "yunzhijia",
65
- MessageSid: message.msgId,
66
- OriginatingChannel: "yunzhijia",
67
- OriginatingTo: `yunzhijia:robot:${message.robotId}`,
68
- Timestamp: message.time,
69
- };
70
- // Record inbound session
71
- const storePath = (0, runtime_js_1.getYunzhiJiaRuntime)().channel.session.resolveStorePath(config.session?.store, {
72
- agentId: route.agentId,
73
- });
74
- await (0, runtime_js_1.getYunzhiJiaRuntime)().channel.session.recordInboundSession({
75
- storePath,
76
- sessionKey: ctxPayload.SessionKey ?? sessionKey,
77
- ctx: ctxPayload,
78
- onRecordError: (err) => {
79
- logger.error(`Failed updating session meta: ${String(err)}`);
80
- },
81
- });
82
- // Dispatch to agent for processing
83
- const { onModelSelected, ...prefixOptions } = createReplyPrefixOptions({
84
- cfg: config,
85
- agentId: route.agentId,
86
- channel: "yunzhijia",
87
- accountId,
88
- });
89
- // Fire-and-forget processing
90
- void (0, runtime_js_1.getYunzhiJiaRuntime)().channel.reply.dispatchReplyWithBufferedBlockDispatcher({
91
- ctx: ctxPayload,
92
- cfg: config,
93
- dispatcherOptions: {
94
- ...prefixOptions,
95
- deliver: async (payload) => {
96
- if (!payload.text) {
97
- return;
98
- }
99
- await (0, webhook_js_1.sendWebhookMessage)(payload.text, account.webhookToken, logger);
100
- },
101
- },
102
- replyOptions: {
103
- onModelSelected,
104
- },
105
- }).catch((err) => {
106
- logger.error(`Message processing failed: ${String(err)}`);
107
- });
108
- // Return empty response for async processing (within 3-second timeout)
109
- return { success: true, immediateResponse: true };
110
- }
package/dist/runtime.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { PluginRuntime } from "openclaw/plugin-sdk";
2
- export declare function getYunzhiJiaRuntime(): PluginRuntime;
3
- export declare function setYunzhiJiaRuntime(runtime: PluginRuntime): void;
package/dist/runtime.js DELETED
@@ -1,16 +0,0 @@
1
- "use strict";
2
- // This file will be replaced by the actual OpenClaw runtime injection
3
- // during plugin loading. It serves as a type-safe placeholder.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.getYunzhiJiaRuntime = getYunzhiJiaRuntime;
6
- exports.setYunzhiJiaRuntime = setYunzhiJiaRuntime;
7
- let _runtime;
8
- function getYunzhiJiaRuntime() {
9
- if (!_runtime) {
10
- throw new Error("YunzhiJia runtime not initialized");
11
- }
12
- return _runtime;
13
- }
14
- function setYunzhiJiaRuntime(runtime) {
15
- _runtime = runtime;
16
- }
package/dist/test.d.ts DELETED
@@ -1,4 +0,0 @@
1
- declare function testSignature(): void;
2
- declare function testChannel(): Promise<void>;
3
- declare function runTests(): Promise<void>;
4
- export { testSignature, testChannel, runTests };
package/dist/test.js DELETED
@@ -1,76 +0,0 @@
1
- import { YunzhijiaChannel } from './channel';
2
- // 测试签名验证功能
3
- function testSignature() {
4
- console.log('Testing signature verification...');
5
- // 这里我们使用测试参数来验证签名逻辑
6
- const testSecret = 'test-secret';
7
- const testMessage = {
8
- robotId: 'test-robotId',
9
- robotName: 'test-robotName',
10
- operatorOpenid: 'test-userId',
11
- operatorName: 'test-userName',
12
- time: Date.now(),
13
- msgId: 'test-msgId',
14
- content: '你好,你能做什么呢?'
15
- };
16
- // 构建摘要信息
17
- const summaryInfo = [
18
- testMessage.robotId,
19
- testMessage.robotName,
20
- testMessage.operatorOpenid,
21
- testMessage.operatorName,
22
- testMessage.time.toString(),
23
- testMessage.msgId,
24
- testMessage.content
25
- ].join(',');
26
- // 使用HmacSHA1算法计算签名
27
- const crypto = require('crypto');
28
- const hmac = crypto.createHmac('sha1', testSecret);
29
- hmac.update(summaryInfo);
30
- const expectedSignature = hmac.digest('base64');
31
- console.log('Expected signature for test:', expectedSignature);
32
- console.log('Test message summary info:', summaryInfo);
33
- }
34
- // 创建一个简单的测试实例
35
- async function testChannel() {
36
- console.log('Testing Yunzhijia Channel...');
37
- const config = {
38
- appSecret: '698766b5e4b0674aec38f798',
39
- webhookUrl: 'https://www.yunzhijia.com/gateway/robot/webhook/send?yzjtype=12&yzjtoken=eb2ce932214c48b2a604cc7d4d6034b2',
40
- receiveEndpoint: '/receive'
41
- };
42
- const channel = new YunzhijiaChannel(config);
43
- // 不启动服务器,只测试类的功能
44
- console.log('Yunzhijia Channel created successfully!');
45
- // 测试消息处理
46
- const mockMessage = {
47
- type: 2,
48
- robotId: 'test-robot-id',
49
- robotName: 'Test Robot',
50
- operatorOpenid: 'test-user-openid',
51
- operatorName: 'Test User',
52
- time: Date.now(),
53
- msgId: 'test-message-id',
54
- content: 'Hello, this is a test message!'
55
- };
56
- console.log('Mock message processed.');
57
- // 测试会话管理
58
- await channel['updateSession']('test-session-id', mockMessage);
59
- console.log('Session updated.');
60
- // 测试OpenClaw处理模拟
61
- const response = await channel['simulateOpenClawProcessing']('Hello, how are you?');
62
- console.log('OpenClaw simulation response:', response);
63
- }
64
- // 运行测试
65
- async function runTests() {
66
- console.log('Running Yunzhijia Channel tests...\n');
67
- testSignature();
68
- console.log('');
69
- await testChannel();
70
- console.log('\nAll tests completed!');
71
- }
72
- // 如果直接运行此文件,则执行测试
73
- if (typeof require !== 'undefined' && require.main === module) {
74
- runTests().catch(console.error);
75
- }
76
- export { testSignature, testChannel, runTests };
package/dist/types.d.ts DELETED
@@ -1,53 +0,0 @@
1
- import type { ChannelId } from "openclaw/plugin-sdk";
2
- export type YunzhiJiaChannelId = ChannelId<"yunzhijia">;
3
- export interface YunzhiJiaAccountConfig {
4
- /** Webhook token for sending messages */
5
- webhookToken?: string;
6
- /** App secret for signature verification */
7
- appSecret?: string;
8
- /** Account name (optional) */
9
- name?: string;
10
- /** Whether this account is enabled */
11
- enabled?: boolean;
12
- /** Whether to require @mention to trigger the bot */
13
- requireMention?: boolean;
14
- /** Allowlist for direct messages */
15
- allowFrom?: Array<string | number>;
16
- /** Group policy configuration */
17
- groups?: Record<string, {
18
- requireMention?: boolean;
19
- }>;
20
- /** Whether to skip signature verification (for testing/development) */
21
- skipSignatureVerification?: boolean;
22
- }
23
- export interface YunzhiJiaConfig {
24
- /** Default account configuration */
25
- webhookToken?: string;
26
- appSecret?: string;
27
- enabled?: boolean;
28
- name?: string;
29
- requireMention?: boolean;
30
- allowFrom?: Array<string | number>;
31
- groups?: Record<string, {
32
- requireMention?: boolean;
33
- }>;
34
- /** Multiple account support */
35
- accounts?: Record<string, YunzhiJiaAccountConfig>;
36
- }
37
- export interface ResolvedYunzhiJiaAccount {
38
- accountId: string;
39
- config: YunzhiJiaAccountConfig;
40
- name: string;
41
- enabled: boolean;
42
- configured: boolean;
43
- }
44
- export interface YunzhiJiaIncomingMessage {
45
- type: number;
46
- robotId: string;
47
- robotName: string;
48
- operatorOpenid: string;
49
- operatorName: string;
50
- time: number;
51
- msgId: string;
52
- content: string;
53
- }
package/dist/types.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });