@dcrays/dcgchat-test 0.2.7 → 0.2.8

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 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
- import { monitoringToolMessage } from "./src/tool.js";
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
- monitoringToolMessage(api);
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.7",
3
+ "version": "0.2.8",
4
4
  "type": "module",
5
5
  "description": "OpenClaw channel plugin for 书灵墨宝 (WebSocket)",
6
6
  "main": "index.ts",
package/src/bot.ts CHANGED
@@ -106,7 +106,7 @@ export async function handleDcgchatMessage(params: {
106
106
  const userId = msg._userId.toString();
107
107
  const text = msg.content.text?.trim();
108
108
 
109
- if (!text ) {
109
+ if (!text) {
110
110
  params.onChunk({
111
111
  messageType: "openclaw_bot_chat",
112
112
  _userId: msg._userId,
@@ -200,82 +200,93 @@ export async function handleDcgchatMessage(params: {
200
200
  onIdle: () => {},
201
201
  });
202
202
 
203
- log(`dcgchat[${accountId}]: dispatching to agent (session=${route.sessionKey})`);
204
-
205
- await core.channel.reply.dispatchReplyFromConfig({
206
- ctx: ctxPayload,
207
- cfg,
208
- dispatcher,
209
- replyOptions: {
210
- ...replyOptions,
211
- onModelSelected: prefixContext.onModelSelected,
212
- onPartialReply: async (payload: ReplyPayload) => {
213
- log(`dcgchat[${accountId}][deliver]: received chunk, text length=${payload.text?.length || 0}`);
214
- const mediaList =
203
+ if (text === '/new') {
204
+ log(`dcgchat[${accountId}]: skipping agent dispatch for /new`);
205
+ await core.channel.reply.dispatchReplyFromConfig({
206
+ ctx: ctxPayload,
207
+ cfg,
208
+ dispatcher,
209
+ replyOptions: {
210
+ ...replyOptions,
211
+ onModelSelected: prefixContext.onModelSelected
212
+ },
213
+ });
214
+ } else {
215
+ log(`dcgchat[${accountId}]: dispatching to agent (session=${route.sessionKey})`);
216
+ await core.channel.reply.dispatchReplyFromConfig({
217
+ ctx: ctxPayload,
218
+ cfg,
219
+ dispatcher,
220
+ replyOptions: {
221
+ ...replyOptions,
222
+ onModelSelected: prefixContext.onModelSelected,
223
+ onPartialReply: async (payload: ReplyPayload) => {
224
+ log(`dcgchat[${accountId}][deliver]: received chunk, text length=${payload.text?.length || 0}`);
225
+ const mediaList =
215
226
  payload.mediaUrls && payload.mediaUrls.length > 0
216
227
  ? payload.mediaUrls
217
228
  : payload.mediaUrl
218
229
  ? [payload.mediaUrl]
219
230
  : [];
220
- if (mediaList.length > 0) {
221
- const files = []
222
- for (let i = 0; i < mediaList.length; i++) {
223
- const file = mediaList[i]
224
- const fileName = file.split(/[\\/]/).pop() || ''
225
- const url = await ossUpload(file, msg.content.bot_token)
226
- files.push({
227
- url: url,
228
- name: fileName,
229
- })
231
+ if (mediaList.length > 0) {
232
+ const files = []
233
+ for (let i = 0; i < mediaList.length; i++) {
234
+ const file = mediaList[i]
235
+ const fileName = file.split(/[\\/]/).pop() || ''
236
+ const url = await ossUpload(file, msg.content.bot_token)
237
+ files.push({
238
+ url: url,
239
+ name: fileName,
240
+ })
241
+ }
242
+ params.onChunk({
243
+ messageType: "openclaw_bot_chat",
244
+ _userId: msg._userId,
245
+ source: "client",
246
+ content: {
247
+ bot_token: msg.content.bot_token,
248
+ domain_id: msg.content.domain_id,
249
+ app_id: msg.content.app_id,
250
+ bot_id: msg.content.bot_id,
251
+ agent_id: msg.content.agent_id,
252
+ session_id: msg.content.session_id,
253
+ message_id: msg.content.message_id,
254
+ response: '',
255
+ files: files,
256
+ state: 'chunk',
257
+ },
258
+ });
230
259
  }
231
- params.onChunk({
232
- messageType: "openclaw_bot_chat",
233
- _userId: msg._userId,
234
- source: "client",
235
- content: {
236
- bot_token: msg.content.bot_token,
237
- domain_id: msg.content.domain_id,
238
- app_id: msg.content.app_id,
239
- bot_id: msg.content.bot_id,
240
- agent_id: msg.content.agent_id,
241
- session_id: msg.content.session_id,
242
- message_id: msg.content.message_id,
243
- response: '',
244
- files: files,
245
- state: 'chunk',
246
- },
247
- });
248
- }
249
- if (payload.text) {
250
- log(`dcgchat[${accountId}][deliver]: sending chunk to user ${msg._userId}, text="${payload.text.slice(0, 50)}..."`);
251
- params.onChunk({
252
- messageType: "openclaw_bot_chat",
253
- _userId: msg._userId,
254
- source: "client",
255
- content: {
256
- bot_token: msg.content.bot_token,
257
- domain_id: msg.content.domain_id,
258
- app_id: msg.content.app_id,
259
- bot_id: msg.content.bot_id,
260
- agent_id: msg.content.agent_id,
261
- session_id: msg.content.session_id,
262
- message_id: msg.content.message_id,
263
- response: payload.text.replace(textChunk, ''),
264
- state: 'chunk',
265
- },
266
- });
267
- textChunk = payload.text
268
- log(`dcgchat[${accountId}][deliver]: chunk sent successfully`);
269
- } else if (payload.mediaUrl && payload.mediaUrls) {
270
-
260
+ if (payload.text) {
261
+ log(`dcgchat[${accountId}][deliver]: sending chunk to user ${msg._userId}, text="${payload.text.slice(0, 50)}..."`);
262
+ params.onChunk({
263
+ messageType: "openclaw_bot_chat",
264
+ _userId: msg._userId,
265
+ source: "client",
266
+ content: {
267
+ bot_token: msg.content.bot_token,
268
+ domain_id: msg.content.domain_id,
269
+ app_id: msg.content.app_id,
270
+ bot_id: msg.content.bot_id,
271
+ agent_id: msg.content.agent_id,
272
+ session_id: msg.content.session_id,
273
+ message_id: msg.content.message_id,
274
+ response: payload.text.replace(textChunk, ''),
275
+ state: 'chunk',
276
+ },
277
+ });
278
+ textChunk = payload.text
279
+ log(`dcgchat[${accountId}][deliver]: chunk sent successfully`);
280
+ } else if (payload.mediaUrl && payload.mediaUrls) {
271
281
 
272
- } else {
273
- log(`dcgchat[${accountId}][deliver]: skipping empty chunk`);
274
- }
275
- },
276
- },
277
- });
278
282
 
283
+ } else {
284
+ log(`dcgchat[${accountId}][deliver]: skipping empty chunk`);
285
+ }
286
+ },
287
+ },
288
+ });
289
+ }
279
290
  log(`dcgchat[${accountId}]: dispatch complete, sending final state`);
280
291
  params.onChunk({
281
292
  messageType: "openclaw_bot_chat",
package/src/channel.ts CHANGED
@@ -135,7 +135,7 @@ export const dcgchatPlugin: ChannelPlugin<ResolvedDcgchatAccount> = {
135
135
  state: 'final',
136
136
  },
137
137
  }));
138
- log(`dcgchat[${ctx.accountId}]: sendText to ${params.userId}, ${JSON.stringify(content)}`);
138
+ log(`dcgchat[${ctx.accountId}]: channel sendText to ${params.userId}, ${JSON.stringify(content)}`);
139
139
  } else {
140
140
  log(`[dcgchat][${ctx.accountId ?? DEFAULT_ACCOUNT_ID}] outbound -> ${ws?.readyState}: ${ctx.text}`);
141
141
  }
@@ -192,7 +192,7 @@ export const dcgchatPlugin: ChannelPlugin<ResolvedDcgchatAccount> = {
192
192
  name: fileName,
193
193
  }],
194
194
  session_id: params.sessionId || Date.now().toString(),
195
- message_id: params.messageId ||Date.now().toString(),
195
+ message_id: Date.now().toString(),
196
196
  },
197
197
  };
198
198
  ws.send(JSON.stringify(content));
@@ -207,7 +207,7 @@ export const dcgchatPlugin: ChannelPlugin<ResolvedDcgchatAccount> = {
207
207
  bot_id: params.botId,
208
208
  agent_id: params.agentId,
209
209
  ssession_id: params.sessionId,
210
- message_id: params.messageId || Date.now().toString(),
210
+ message_id: Date.now().toString(),
211
211
  response: '',
212
212
  state: 'final',
213
213
  },