@dcrays/dcgchat-test 0.2.18 → 0.2.20
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/package.json +6 -3
- package/src/tool.ts +12 -8
package/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
|
|
2
2
|
import { emptyPluginConfigSchema } from "openclaw/plugin-sdk";
|
|
3
3
|
import { dcgchatPlugin } from "./src/channel.js";
|
|
4
4
|
import { setDcgchatRuntime, setWorkspaceDir } from "./src/runtime.js";
|
|
5
|
-
|
|
5
|
+
import { monitoringToolMessage } from "./src/tool.js";
|
|
6
6
|
|
|
7
7
|
const plugin = {
|
|
8
8
|
id: "dcgchat-test",
|
|
@@ -11,7 +11,7 @@ const plugin = {
|
|
|
11
11
|
configSchema: emptyPluginConfigSchema(),
|
|
12
12
|
register(api: OpenClawPluginApi) {
|
|
13
13
|
setDcgchatRuntime(api.runtime);
|
|
14
|
-
|
|
14
|
+
monitoringToolMessage(api);
|
|
15
15
|
api.registerChannel({ plugin: dcgchatPlugin });
|
|
16
16
|
api.registerTool((ctx) => {
|
|
17
17
|
const workspaceDir = ctx.workspaceDir;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcrays/dcgchat-test",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.20",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "OpenClaw channel plugin for 书灵墨宝 (WebSocket)",
|
|
6
6
|
"main": "index.ts",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"ali-oss": "file:src/libs/ali-oss-6.23.0.tgz",
|
|
24
24
|
"axios": "file:src/libs/axios-1.13.6.tgz",
|
|
25
|
-
"ws": "file:src/libs/ws-8.19.0.tgz",
|
|
26
25
|
"md5": "file:src/libs/md5-2.3.0.tgz",
|
|
27
|
-
"unzipper": "file:src/libs/unzipper-0.12.3.tgz"
|
|
26
|
+
"unzipper": "file:src/libs/unzipper-0.12.3.tgz",
|
|
27
|
+
"ws": "file:src/libs/ws-8.19.0.tgz"
|
|
28
28
|
},
|
|
29
29
|
"openclaw": {
|
|
30
30
|
"extensions": [
|
|
@@ -44,5 +44,8 @@
|
|
|
44
44
|
"localPath": "extensions/dcgchat",
|
|
45
45
|
"defaultChoice": "npm"
|
|
46
46
|
}
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"openclaw": "^2026.3.13"
|
|
47
50
|
}
|
|
48
51
|
}
|
package/src/tool.ts
CHANGED
|
@@ -28,18 +28,20 @@ export function setMsgStatus(status: 'running' | 'finished' | '') {
|
|
|
28
28
|
export function getMsgStatus() {
|
|
29
29
|
return msgStatus;
|
|
30
30
|
}
|
|
31
|
-
let
|
|
31
|
+
let toolCallId = '';
|
|
32
32
|
let toolName = '';
|
|
33
33
|
export function monitoringToolMessage(api: OpenClawPluginApi) {
|
|
34
34
|
api.on("after_tool_call", (event) => {
|
|
35
35
|
const ws = getWsConnection()
|
|
36
36
|
const params = getMsgParams();
|
|
37
37
|
const status = getMsgStatus();
|
|
38
|
-
|
|
38
|
+
|
|
39
|
+
// 去除重复的工具调用结果字段
|
|
40
|
+
const { result: _result, ...rest } = event;
|
|
41
|
+
const log = api.runtime?.log ?? api.log ?? console.log;
|
|
39
42
|
if (ws?.readyState === WebSocket.OPEN && status === 'running') {
|
|
40
|
-
const log = api.runtime?.log ?? api.log;
|
|
41
43
|
// @ts-ignore
|
|
42
|
-
if (!
|
|
44
|
+
if (!toolCallId || toolCallId !== event.toolCallId || !toolName || toolName !== event.toolName) {
|
|
43
45
|
ws.send(JSON.stringify({
|
|
44
46
|
messageType: "openclaw_bot_chat",
|
|
45
47
|
_userId: params?.userId,
|
|
@@ -55,7 +57,7 @@ export function monitoringToolMessage(api: OpenClawPluginApi) {
|
|
|
55
57
|
const text = JSON.stringify({
|
|
56
58
|
type: 'tool_call',
|
|
57
59
|
specialIdentification: 'dcgchat_tool_call_special_identification',
|
|
58
|
-
...
|
|
60
|
+
...rest
|
|
59
61
|
});
|
|
60
62
|
ws.send(JSON.stringify({
|
|
61
63
|
messageType: "openclaw_bot_chat",
|
|
@@ -74,7 +76,7 @@ export function monitoringToolMessage(api: OpenClawPluginApi) {
|
|
|
74
76
|
},
|
|
75
77
|
}));
|
|
76
78
|
// @ts-ignore
|
|
77
|
-
if (!
|
|
79
|
+
if (!toolCallId || toolCallId !== event.toolCallId || !toolName || toolName !== event.toolName) {
|
|
78
80
|
ws.send(JSON.stringify({
|
|
79
81
|
messageType: "openclaw_bot_chat",
|
|
80
82
|
_userId: params?.userId,
|
|
@@ -87,9 +89,11 @@ export function monitoringToolMessage(api: OpenClawPluginApi) {
|
|
|
87
89
|
},
|
|
88
90
|
}));
|
|
89
91
|
}
|
|
90
|
-
|
|
92
|
+
toolCallId = event.toolCallId;
|
|
91
93
|
toolName = event.toolName;
|
|
92
|
-
log?.(`dcgchat[${params?.sessionId}]:11111111 tool message to ${params?.sessionId}, ${JSON.stringify(
|
|
94
|
+
log?.(`dcgchat[${params?.sessionId}]:11111111 tool message to ${params?.sessionId}, ${JSON.stringify(rest)}`);
|
|
95
|
+
} else {
|
|
96
|
+
log?.(`dcgchat[${params?.sessionId}]:22222222 tool ${status} message to ${ws?.readyState}, ${JSON.stringify(rest)}`);
|
|
93
97
|
}
|
|
94
98
|
});
|
|
95
99
|
}
|