@dcrays/dcgchat-test 0.2.19 → 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/package.json +6 -3
- package/src/bot.ts +4 -4
- package/src/tool.ts +12 -8
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/bot.ts
CHANGED
|
@@ -316,7 +316,7 @@ export async function handleDcgchatMessage(params: {
|
|
|
316
316
|
|
|
317
317
|
const route = core.channel.routing.resolveAgentRoute({
|
|
318
318
|
cfg,
|
|
319
|
-
channel: "dcgchat
|
|
319
|
+
channel: "dcgchat",
|
|
320
320
|
accountId: account.accountId,
|
|
321
321
|
peer: { kind: "direct", id: userId },
|
|
322
322
|
});
|
|
@@ -353,13 +353,13 @@ export async function handleDcgchatMessage(params: {
|
|
|
353
353
|
ChatType: "direct",
|
|
354
354
|
SenderName: userId,
|
|
355
355
|
SenderId: userId,
|
|
356
|
-
Provider: "dcgchat
|
|
357
|
-
Surface: "dcgchat
|
|
356
|
+
Provider: "dcgchat" as const,
|
|
357
|
+
Surface: "dcgchat" as const,
|
|
358
358
|
MessageSid: msg.content.message_id,
|
|
359
359
|
Timestamp: Date.now(),
|
|
360
360
|
WasMentioned: true,
|
|
361
361
|
CommandAuthorized: true,
|
|
362
|
-
OriginatingChannel: "dcgchat
|
|
362
|
+
OriginatingChannel: "dcgchat" as const,
|
|
363
363
|
OriginatingTo: `user:${userId}`,
|
|
364
364
|
...mediaPayload,
|
|
365
365
|
});
|
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
|
}
|