@dcrays/dcgchat-test 0.1.24 → 0.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcrays/dcgchat-test",
3
- "version": "0.1.24",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "OpenClaw channel plugin for 书灵墨宝 (WebSocket)",
6
6
  "main": "index.ts",
package/src/bot.ts CHANGED
@@ -89,6 +89,10 @@ export async function handleDcgchatMessage(params: {
89
89
  // @ts-ignore
90
90
  content: {
91
91
  bot_token: msg.content.bot_token,
92
+ domain_id: msg.content.domain_id,
93
+ app_id: msg.content.app_id,
94
+ bot_id: msg.content.bot_id,
95
+ agent_id: msg.content.agent_id,
92
96
  session_id: msg.content.session_id,
93
97
  message_id: msg.content.message_id,
94
98
  response: "[错误] 消息格式不正确",
@@ -170,7 +174,10 @@ export async function handleDcgchatMessage(params: {
170
174
  onReplyStart: async () => {},
171
175
  deliver: async (payload) => {
172
176
  log(`dcgchat[${accountId}][deliver]: received chunk, text length=${payload.text?.length || 0}`);
173
- const t = payload.text?.trim();
177
+ const t = payload.text?.trim().replaceAll(
178
+ "/root/.openclaw/workspace/moBooksAgentGenerate",
179
+ "/upload"
180
+ );
174
181
  if (t) {
175
182
  log(`dcgchat[${accountId}][deliver]: sending chunk to user ${msg._userId}, text="${t.slice(0, 50)}..."`);
176
183
  params.onChunk({
@@ -179,6 +186,10 @@ export async function handleDcgchatMessage(params: {
179
186
  source: "client",
180
187
  content: {
181
188
  bot_token: msg.content.bot_token,
189
+ domain_id: msg.content.domain_id,
190
+ app_id: msg.content.app_id,
191
+ bot_id: msg.content.bot_id,
192
+ agent_id: msg.content.agent_id,
182
193
  session_id: msg.content.session_id,
183
194
  message_id: msg.content.message_id,
184
195
  response: t,
@@ -215,6 +226,10 @@ export async function handleDcgchatMessage(params: {
215
226
  source: "client",
216
227
  content: {
217
228
  bot_token: msg.content.bot_token,
229
+ domain_id: msg.content.domain_id,
230
+ app_id: msg.content.app_id,
231
+ bot_id: msg.content.bot_id,
232
+ agent_id: msg.content.agent_id,
218
233
  session_id: msg.content.session_id,
219
234
  message_id: msg.content.message_id,
220
235
  response: '',
@@ -235,6 +250,10 @@ export async function handleDcgchatMessage(params: {
235
250
  source: "client",
236
251
  content: {
237
252
  bot_token: msg.content.bot_token,
253
+ domain_id: msg.content.domain_id,
254
+ app_id: msg.content.app_id,
255
+ bot_id: msg.content.bot_id,
256
+ agent_id: msg.content.agent_id,
238
257
  session_id: msg.content.session_id,
239
258
  message_id: msg.content.message_id,
240
259
  response: `[错误] ${err instanceof Error ? err.message : String(err)}`,
package/src/channel.ts CHANGED
@@ -8,8 +8,7 @@ import { logDcgchat } from "./log.js";
8
8
  import { getWsConnection } from "./connection.js";
9
9
  import { getMsgParams } from "./tool.js";
10
10
 
11
- const uploadRoot = resolve('/', "/upload");
12
- logDcgchat.info(`uploadRoot: ${uploadRoot}`);
11
+ const uploadRoot = resolve('/', "upload");
13
12
 
14
13
  function isPathInside(parentPath: string, targetPath: string): boolean {
15
14
  const relativePath = relative(parentPath, targetPath);
@@ -86,11 +85,9 @@ export const dcgchatPlugin: ChannelPlugin<ResolvedDcgchatAccount> = {
86
85
  // blockStreaming: true,
87
86
  },
88
87
  agentPrompt: {
89
- messageToolHints: () => {
90
- return [
91
- `- 如果有文件生成,直接将文件生成到${resolve('/', "/works")}文件夹下,并将文件发送给我`,
92
- ]
93
- },
88
+ messageToolHints: () => [
89
+ "- 如果有文件生成,直接将文件生成到根目录的/upload文件夹下,并将文件发送给我",
90
+ ],
94
91
  },
95
92
  reload: { configPrefixes: ["channels.dcgchat"] },
96
93
  configSchema: {
@@ -156,7 +153,14 @@ export const dcgchatPlugin: ChannelPlugin<ResolvedDcgchatAccount> = {
156
153
  source: "client",
157
154
  content: {
158
155
  bot_token: botToken,
159
- response: ctx.text,
156
+ domain_id: params.domainId,
157
+ app_id: params.appId,
158
+ bot_id: params.botId,
159
+ agent_id: params.agentId,
160
+ response: ctx.text.replaceAll(
161
+ "/root/.openclaw/workspace/moBooksAgentGenerate",
162
+ "/upload"
163
+ ),
160
164
  session_id: params.sessionId,
161
165
  message_id: params.messageId || Date.now().toString(),
162
166
  },
@@ -188,7 +192,14 @@ export const dcgchatPlugin: ChannelPlugin<ResolvedDcgchatAccount> = {
188
192
  source: "client",
189
193
  content: {
190
194
  bot_token: botToken,
191
- response: ctx.text,
195
+ domain_id: params.domainId,
196
+ app_id: params.appId,
197
+ bot_id: params.botId,
198
+ agent_id: params.agentId,
199
+ response: ctx.text.replaceAll(
200
+ "/root/.openclaw/workspace/moBooksAgentGenerate",
201
+ "/upload"
202
+ ),
192
203
  files: [{
193
204
  url: url,
194
205
  name: fileName,
package/src/monitor.ts CHANGED
@@ -117,6 +117,10 @@ export async function monitorDcgchatProvider(opts: MonitorDcgchatOpts): Promise<
117
117
  token: msg.content.bot_token,
118
118
  sessionId: msg.content.session_id,
119
119
  messageId: msg.content.message_id,
120
+ domainId: msg.content.domain_id,
121
+ appId: msg.content.app_id,
122
+ botId: msg.content.bot_id,
123
+ agentId: msg.content.agent_id,
120
124
  });
121
125
  await handleDcgchatMessage({
122
126
  cfg,
package/src/tool.ts CHANGED
@@ -5,9 +5,13 @@ import { logDcgchat } from "./log.js";
5
5
 
6
6
  let msgParams = {} as {
7
7
  userId: number;
8
- token: string
9
- sessionId: string
10
- messageId: string
8
+ token: string;
9
+ sessionId: string;
10
+ messageId: string;
11
+ domainId: string;
12
+ appId: string;
13
+ botId: string;
14
+ agentId: string;
11
15
  }
12
16
  let msgStatus: 'running' | 'finished' | '' = '';
13
17
  export function setMsgParams(params: any) {
@@ -44,16 +48,24 @@ export function monitoringToolMessage(api: OpenClawPluginApi) {
44
48
  message_id: params?.messageId || Date.now().toString()
45
49
  },
46
50
  }));
51
+ const text = JSON.stringify({
52
+ type: 'tool_call',
53
+ ...event
54
+ }).replaceAll(
55
+ "/root/.openclaw/workspace/moBooksAgentGenerate",
56
+ "/upload"
57
+ );
47
58
  ws.send(JSON.stringify({
48
59
  messageType: "openclaw_bot_chat",
49
60
  _userId: params?.userId,
50
61
  source: "client",
51
62
  content: {
52
63
  bot_token: params?.token,
53
- response: JSON.stringify({
54
- type: 'tool_call',
55
- ...event
56
- }),
64
+ domain_id: params?.domainId,
65
+ app_id: params?.appId,
66
+ bot_id: params?.botId,
67
+ agent_id: params?.agentId,
68
+ response: text,
57
69
  session_id:params?.sessionId,
58
70
  message_id: params?.messageId || Date.now().toString()
59
71
  },
package/src/types.ts CHANGED
@@ -39,6 +39,10 @@ export type InboundMessage = {
39
39
  // content: string;
40
40
  content: {
41
41
  bot_token: string;
42
+ domain_id?: string;
43
+ app_id?: string;
44
+ bot_id?: string;
45
+ agent_id?: string;
42
46
  session_id: string;
43
47
  message_id: string;
44
48
  text: string;
@@ -71,6 +75,10 @@ export type OutboundReply = {
71
75
  message_id: string; // ""
72
76
  response: string; // ""
73
77
  state: string; // final, chunk
78
+ domain_id?: string;
79
+ app_id?: string;
80
+ bot_id?: string;
81
+ agent_id?: string;
74
82
  };
75
83
  };
76
84