@hedgehog2026/ciwei-ai 1.0.2 → 1.0.3
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/index.ts +2 -2
- package/openclaw.plugin.json +5 -5
- package/package.json +7 -7
- package/src/channel.ts +20 -20
- package/src/runtime.ts +1 -1
package/index.ts
CHANGED
|
@@ -7,13 +7,13 @@ import { setCiweiAIRuntime } from "./src/runtime";
|
|
|
7
7
|
* ciweiAI
|
|
8
8
|
*/
|
|
9
9
|
const plugin: any = {
|
|
10
|
-
id: "
|
|
10
|
+
id: "ciwei-ai",
|
|
11
11
|
name: "ciwei AI Channel",
|
|
12
12
|
description: "Custom WebSocket-based channel for Ciwei AI",
|
|
13
13
|
configSchema: emptyPluginConfigSchema(),
|
|
14
14
|
|
|
15
15
|
register(api: OpenClawPluginApi): void {
|
|
16
|
-
console.log("[
|
|
16
|
+
console.log("[ciwei-ai] Registering plugin...");
|
|
17
17
|
setCiweiAIRuntime(api.runtime);
|
|
18
18
|
|
|
19
19
|
api.registerChannel({ plugin: ciweiAIPlugin });
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "
|
|
3
|
-
"name": "
|
|
4
|
-
"version": "1.0.
|
|
2
|
+
"id": "ciwei-ai",
|
|
3
|
+
"name": "ciwei-ai",
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"description": "Custom WebSocket-based channel plugin for Ciwei AI app",
|
|
6
6
|
"entry": "./index.ts",
|
|
7
7
|
"type": "channel",
|
|
8
8
|
"channels": [
|
|
9
|
-
"
|
|
9
|
+
"ciwei-ai"
|
|
10
10
|
],
|
|
11
11
|
"configSchema": {
|
|
12
12
|
"type": "object",
|
|
13
13
|
"additionalProperties": false,
|
|
14
14
|
"properties": {}
|
|
15
15
|
}
|
|
16
|
-
}
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hedgehog2026/ciwei-ai",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "ciwei AI WebSocket channel for OpenClaw",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bot",
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"clawdbot",
|
|
9
9
|
"openclaw",
|
|
10
10
|
"stream",
|
|
11
|
-
"
|
|
11
|
+
"ciwei-ai"
|
|
12
12
|
],
|
|
13
|
-
"repository": "github:
|
|
13
|
+
"repository": "github:hedgehog-finance/ciwei-ai",
|
|
14
14
|
"main": "index.ts",
|
|
15
15
|
"type": "module",
|
|
16
|
-
"author": "
|
|
16
|
+
"author": "Hedgehog Finance",
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"ws": "^8.16.0",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"./index.ts"
|
|
33
33
|
],
|
|
34
34
|
"channels": [
|
|
35
|
-
"
|
|
35
|
+
"ciwei-ai"
|
|
36
36
|
],
|
|
37
37
|
"installDependencies": true,
|
|
38
38
|
"channel": {
|
|
39
|
-
"id": "
|
|
39
|
+
"id": "ciwei-ai",
|
|
40
40
|
"label": "ciwei AI",
|
|
41
41
|
"selectionLabel": "ciwei AI",
|
|
42
|
-
"docsPath": "/channels/
|
|
42
|
+
"docsPath": "/channels/ciwei-ai",
|
|
43
43
|
"blurb": "ciwei AI Custom Relay Channel.",
|
|
44
44
|
"order": 100
|
|
45
45
|
}
|
package/src/channel.ts
CHANGED
|
@@ -36,21 +36,21 @@ function getCurrentTimestamp(): number {
|
|
|
36
36
|
* Ciwei AI Channel Plugin
|
|
37
37
|
* accountId + token
|
|
38
38
|
*
|
|
39
|
-
* "
|
|
39
|
+
* "ciwei-ai": {
|
|
40
40
|
* "enabled": true,
|
|
41
41
|
* "accountId": "13333333333",
|
|
42
42
|
* "token": "your-token"
|
|
43
43
|
* }
|
|
44
44
|
*/
|
|
45
45
|
export const ciweiAIPlugin: ChannelPlugin<CiweiAIResolvedAccount> = {
|
|
46
|
-
id: "
|
|
46
|
+
id: "ciwei-ai",
|
|
47
47
|
|
|
48
48
|
meta: {
|
|
49
|
-
id: "
|
|
49
|
+
id: "ciwei-ai",
|
|
50
50
|
label: "Ciwei AI",
|
|
51
51
|
selectionLabel: "Ciwei AI",
|
|
52
52
|
blurb: "Custom WebSocket relay channel for Ciwei AI",
|
|
53
|
-
docsPath: "/channels/
|
|
53
|
+
docsPath: "/channels/ciwei-ai",
|
|
54
54
|
order: 100,
|
|
55
55
|
},
|
|
56
56
|
|
|
@@ -66,7 +66,7 @@ export const ciweiAIPlugin: ChannelPlugin<CiweiAIResolvedAccount> = {
|
|
|
66
66
|
|
|
67
67
|
config: {
|
|
68
68
|
listAccountIds: (cfg: OpenClawConfig): string[] => {
|
|
69
|
-
const channelConfig = cfg.channels?.
|
|
69
|
+
const channelConfig = cfg.channels?.['ciwei-ai'];
|
|
70
70
|
if (!channelConfig) return [];
|
|
71
71
|
|
|
72
72
|
if (channelConfig.accountId) {
|
|
@@ -84,7 +84,7 @@ export const ciweiAIPlugin: ChannelPlugin<CiweiAIResolvedAccount> = {
|
|
|
84
84
|
},
|
|
85
85
|
|
|
86
86
|
resolveAccount: (cfg: OpenClawConfig, accountId?: string | null): CiweiAIResolvedAccount => {
|
|
87
|
-
const channelConfig = cfg.channels?.
|
|
87
|
+
const channelConfig = cfg.channels?.['ciwei-ai'];
|
|
88
88
|
|
|
89
89
|
if (channelConfig?.accountId) {
|
|
90
90
|
const id = channelConfig.accountId;
|
|
@@ -122,7 +122,7 @@ export const ciweiAIPlugin: ChannelPlugin<CiweiAIResolvedAccount> = {
|
|
|
122
122
|
},
|
|
123
123
|
|
|
124
124
|
defaultAccountId: (cfg: OpenClawConfig): string => {
|
|
125
|
-
const channelConfig = (cfg as any)?.channels?.
|
|
125
|
+
const channelConfig = (cfg as any)?.channels?.['ciwei-ai'];
|
|
126
126
|
return channelConfig?.accountId || "default";
|
|
127
127
|
},
|
|
128
128
|
},
|
|
@@ -150,12 +150,12 @@ export const ciweiAIPlugin: ChannelPlugin<CiweiAIResolvedAccount> = {
|
|
|
150
150
|
isClosing = true;
|
|
151
151
|
|
|
152
152
|
if (heartbeatInterval) clearInterval(heartbeatInterval);
|
|
153
|
-
log?.info?.(`[
|
|
153
|
+
log?.info?.(`[ciwei-ai][${accountId}] Stopping gateway...`);
|
|
154
154
|
|
|
155
155
|
try {
|
|
156
156
|
ws?.close();
|
|
157
157
|
} catch (err: any) {
|
|
158
|
-
log?.warn?.(`[
|
|
158
|
+
log?.warn?.(`[ciwei-ai][${accountId}] Error during close: ${err.message}`);
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
ctx.setStatus({
|
|
@@ -170,11 +170,11 @@ export const ciweiAIPlugin: ChannelPlugin<CiweiAIResolvedAccount> = {
|
|
|
170
170
|
const connect = () => {
|
|
171
171
|
if (isClosing) return;
|
|
172
172
|
|
|
173
|
-
log?.info?.(`[
|
|
173
|
+
log?.info?.(`[ciwei-ai][${accountId}] Connecting to relay: ${relayUrl}`);
|
|
174
174
|
ws = new WebSocket(relayUrl);
|
|
175
175
|
|
|
176
176
|
ws.on("open", () => {
|
|
177
|
-
log?.info?.(`[
|
|
177
|
+
log?.info?.(`[ciwei-ai][${accountId}] Connected successfully.`);
|
|
178
178
|
ctx.setStatus({
|
|
179
179
|
...ctx.getStatus(),
|
|
180
180
|
running: true,
|
|
@@ -211,7 +211,7 @@ export const ciweiAIPlugin: ChannelPlugin<CiweiAIResolvedAccount> = {
|
|
|
211
211
|
To: chatId,
|
|
212
212
|
SessionKey: `ws:${chatId}`,
|
|
213
213
|
AccountId: String(accountId),
|
|
214
|
-
Provider: "
|
|
214
|
+
Provider: "ciwei-ai",
|
|
215
215
|
MessageSid: id,
|
|
216
216
|
});
|
|
217
217
|
|
|
@@ -220,10 +220,10 @@ export const ciweiAIPlugin: ChannelPlugin<CiweiAIResolvedAccount> = {
|
|
|
220
220
|
|
|
221
221
|
// 1. Enable block streaming for this specific channel
|
|
222
222
|
streamingCfg.channels = streamingCfg.channels || {};
|
|
223
|
-
streamingCfg.channels
|
|
224
|
-
streamingCfg.channels.
|
|
223
|
+
streamingCfg.channels['ciwei-ai'] = streamingCfg.channels['ciwei-ai'] || {};
|
|
224
|
+
streamingCfg.channels['ciwei-ai'].blockStreaming = true;
|
|
225
225
|
// Also enable preview streaming as fallback
|
|
226
|
-
streamingCfg.channels.
|
|
226
|
+
streamingCfg.channels['ciwei-ai'].streaming = "block";
|
|
227
227
|
|
|
228
228
|
// 2. Configure agents to emit chunks as they arrive instead of bundling
|
|
229
229
|
streamingCfg.agents = streamingCfg.agents || {};
|
|
@@ -286,12 +286,12 @@ export const ciweiAIPlugin: ChannelPlugin<CiweiAIResolvedAccount> = {
|
|
|
286
286
|
}
|
|
287
287
|
});
|
|
288
288
|
} catch (err: any) {
|
|
289
|
-
log?.error?.(`[
|
|
289
|
+
log?.error?.(`[ciwei-ai][${accountId}] Dispatch error: ${err.message}`);
|
|
290
290
|
}
|
|
291
291
|
});
|
|
292
292
|
|
|
293
293
|
ws.on("error", (err) => {
|
|
294
|
-
log?.error?.(`[
|
|
294
|
+
log?.error?.(`[ciwei-ai][${accountId}] WebSocket error: ${err.message}`);
|
|
295
295
|
ctx.setStatus({
|
|
296
296
|
...ctx.getStatus(),
|
|
297
297
|
lastError: `Connection error: ${err.message}`,
|
|
@@ -301,7 +301,7 @@ export const ciweiAIPlugin: ChannelPlugin<CiweiAIResolvedAccount> = {
|
|
|
301
301
|
ws.on("close", (code, reason) => {
|
|
302
302
|
if (heartbeatInterval) clearInterval(heartbeatInterval);
|
|
303
303
|
if (!isClosing) {
|
|
304
|
-
log?.warn?.(`[
|
|
304
|
+
log?.warn?.(`[ciwei-ai][${accountId}] Connection dropped (code=${code}). Retrying in 5s...`);
|
|
305
305
|
ctx.setStatus({
|
|
306
306
|
...ctx.getStatus(),
|
|
307
307
|
running: false,
|
|
@@ -314,7 +314,7 @@ export const ciweiAIPlugin: ChannelPlugin<CiweiAIResolvedAccount> = {
|
|
|
314
314
|
connect();
|
|
315
315
|
|
|
316
316
|
abortSignal?.addEventListener("abort", () => {
|
|
317
|
-
log?.info?.(`[
|
|
317
|
+
log?.info?.(`[ciwei-ai][${accountId}] Abort signal received`);
|
|
318
318
|
stopClient();
|
|
319
319
|
});
|
|
320
320
|
|
|
@@ -342,7 +342,7 @@ export const ciweiAIPlugin: ChannelPlugin<CiweiAIResolvedAccount> = {
|
|
|
342
342
|
if (!account.configured) {
|
|
343
343
|
return [
|
|
344
344
|
{
|
|
345
|
-
channel: "
|
|
345
|
+
channel: "ciwei-ai",
|
|
346
346
|
accountId: account.accountId,
|
|
347
347
|
kind: "config" as const,
|
|
348
348
|
message: "Account not configured (missing relay token)",
|
package/src/runtime.ts
CHANGED
|
@@ -8,7 +8,7 @@ export function setCiweiAIRuntime(next: PluginRuntime): void {
|
|
|
8
8
|
|
|
9
9
|
export function getCiweiAIRuntime(): PluginRuntime {
|
|
10
10
|
if (!runtime) {
|
|
11
|
-
throw new Error("
|
|
11
|
+
throw new Error("ciwei-ai runtime not initialized");
|
|
12
12
|
}
|
|
13
13
|
return runtime;
|
|
14
14
|
}
|