@dcrays/dcgchat-test 0.2.28 → 0.2.29

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.2.28",
3
+ "version": "0.2.29",
4
4
  "type": "module",
5
5
  "description": "OpenClaw channel plugin for 书灵墨宝 (WebSocket)",
6
6
  "main": "index.ts",
@@ -16,12 +16,6 @@
16
16
  "websocket",
17
17
  "ai"
18
18
  ],
19
- "scripts": {
20
- "typecheck": "tsc --noEmit",
21
- "build:production": "npx tsx scripts/build.ts production",
22
- "build:prod": "npx tsx scripts/build.ts production",
23
- "build:test": "npx tsx scripts/build.ts test"
24
- },
25
19
  "dependencies": {
26
20
  "ali-oss": "file:src/libs/ali-oss-6.23.0.tgz",
27
21
  "axios": "file:src/libs/axios-1.13.6.tgz",
package/src/bot.ts CHANGED
@@ -9,7 +9,7 @@ import { generateSignUrl } from './request/api.js'
9
9
  import { extractMobookFiles } from './utils/searchFile.js'
10
10
  import { createMsgContext, sendChunk, sendFinal, sendText as sendTextMsg, sendError } from './transport.js'
11
11
  import { dcgLogger } from './utils/log.js'
12
- import { emptyToolText } from './utils/constant.js'
12
+ import { channelInfo, systemCommand, interruptCommand, ENV } from './utils/constant.js'
13
13
 
14
14
  type MediaInfo = {
15
15
  path: string
@@ -229,7 +229,7 @@ export async function handleDcgchatMessage(msg: InboundMessage, accountId: strin
229
229
  humanDelay: core.channel.reply.resolveHumanDelayConfig(config, route.agentId),
230
230
  onReplyStart: async () => {},
231
231
  deliver: async (payload: ReplyPayload, info) => {
232
- dcgLogger(`[deliver]: kind=${info.kind}, text=${payload.text?.length ?? 0} chars`)
232
+ dcgLogger(`[deliver]: kind=${info.kind}, text=${payload.text?.length ?? 0} chars, ${payload.text?.slice(0, 100)}`)
233
233
  // Media from the outbound pipeline (post-streaming)
234
234
  const mediaList = resolveReplyMediaList(payload)
235
235
  for (const mediaUrl of mediaList) {
@@ -238,6 +238,7 @@ export async function handleDcgchatMessage(msg: InboundMessage, accountId: strin
238
238
  sentMediaKeys.add(key)
239
239
  await sendDcgchatMedia({ msgCtx, mediaUrl, text: '' })
240
240
  }
241
+ sendFinal(msgCtx)
241
242
  },
242
243
  onError: (err: unknown, info: { kind: string }) => {
243
244
  dcgLogger(`${info.kind} reply failed: ${String(err)}`, 'error')
@@ -247,7 +248,7 @@ export async function handleDcgchatMessage(msg: InboundMessage, accountId: strin
247
248
 
248
249
  let wasAborted = false
249
250
  try {
250
- if (emptyToolText.includes(text?.trim())) {
251
+ if (systemCommand.includes(text?.trim())) {
251
252
  dcgLogger(`dispatching /new`)
252
253
  await core.channel.reply.dispatchReplyFromConfig({
253
254
  ctx: ctxPayload,
@@ -258,6 +259,11 @@ export async function handleDcgchatMessage(msg: InboundMessage, accountId: strin
258
259
  onModelSelected: prefixContext.onModelSelected
259
260
  }
260
261
  })
262
+ } else if (interruptCommand.includes(text?.trim())) {
263
+ dcgLogger(`interrupt command: ${text}`)
264
+ abortMobookappGeneration(conversationId)
265
+ sendFinal(msgCtx)
266
+ return
261
267
  } else {
262
268
  dcgLogger(`dispatching to agent (session=${route.sessionKey})`)
263
269
  await core.channel.reply.dispatchReplyFromConfig({
@@ -311,10 +317,13 @@ export async function handleDcgchatMessage(msg: InboundMessage, accountId: strin
311
317
  activeGenerations.delete(conversationId)
312
318
  }
313
319
  }
314
-
315
- markRunComplete()
320
+ try {
321
+ markRunComplete()
322
+ } catch (err) {
323
+ dcgLogger(` markRunComplete error: ${String(err)}`, 'error')
324
+ }
316
325
  markDispatchIdle()
317
- if (!emptyToolText.includes(text?.trim())) {
326
+ if (![...systemCommand, ...interruptCommand].includes(text?.trim())) {
318
327
  for (const file of extractMobookFiles(completeText)) {
319
328
  let resolved = file
320
329
  if (!fs.existsSync(resolved)) {
package/src/monitor.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import type { ClawdbotConfig, RuntimeEnv } from 'openclaw/plugin-sdk'
2
2
  import WebSocket from 'ws'
3
- import { abortMobookappGeneration, handleDcgchatMessage } from './bot.js'
3
+ import { handleDcgchatMessage } from './bot.js'
4
4
  import { resolveAccount } from './channel.js'
5
5
  import { setWsConnection, getOpenClawConfig } from './utils/global.js'
6
6
  import type { InboundMessage } from './types.js'
7
7
  import { setMsgParams, setMsgStatus } from './utils/global.js'
8
8
  import { installSkill, uninstallSkill } from './skill.js'
9
9
  import { dcgLogger } from './utils/log.js'
10
- import { emptyToolText } from './utils/constant.js'
10
+ import { ignoreToolCommand } from './utils/constant.js'
11
11
 
12
12
  export type MonitorDcgchatOpts = {
13
13
  config?: ClawdbotConfig
@@ -30,7 +30,7 @@ function buildConnectUrl(account: Record<string, string>): string {
30
30
  }
31
31
 
32
32
  export async function monitorDcgchatProvider(opts: MonitorDcgchatOpts): Promise<void> {
33
- const { runtime, abortSignal, accountId } = opts
33
+ const { abortSignal, accountId } = opts
34
34
 
35
35
  const config = getOpenClawConfig()
36
36
  if (!config) {
@@ -110,16 +110,9 @@ export async function monitorDcgchatProvider(opts: MonitorDcgchatOpts): Promise<
110
110
 
111
111
  if (parsed.messageType == 'openclaw_bot_chat') {
112
112
  const msg = parsed as unknown as InboundMessage
113
- if (!emptyToolText.includes(msg.content.text?.trim())) {
113
+ if (!ignoreToolCommand.includes(msg.content.text?.trim())) {
114
114
  setMsgStatus('running')
115
115
  }
116
- if (msg.content.text === '/stop') {
117
- const rawConvId = msg.content.session_id as string | undefined
118
- const conversationId = rawConvId || `${accountId}:${account.botToken}`
119
- abortMobookappGeneration(conversationId)
120
- dcgLogger(`abort conversationId=${conversationId}`)
121
- return
122
- }
123
116
  // 设置获取用户消息消息参数
124
117
  setMsgParams({
125
118
  userId: msg._userId,
package/src/tool.ts CHANGED
@@ -83,7 +83,7 @@ export function monitoringToolMessage(api: OpenClawPluginApi) {
83
83
  api.on(item.event as PluginHookName, (event: any) => {
84
84
  const status = getMsgStatus()
85
85
  if (status === 'running') {
86
- dcgLogger(`工具调用结果: ~ event:${item.event} ${JSON.stringify(event)}`)
86
+ dcgLogger(`工具调用结果: ~ event:${item.event}`)
87
87
  if (['after_tool_call', 'before_tool_call'].includes(item.event)) {
88
88
  const { result: _result, ...rest } = event
89
89
  const text = JSON.stringify({
package/src/transport.ts CHANGED
@@ -95,7 +95,7 @@ export function sendChunk(ctx: DcgchatMsgContext, text: string): boolean {
95
95
  }
96
96
 
97
97
  export function sendFinal(ctx: DcgchatMsgContext): boolean {
98
- dcgLogger(` message handling complete`)
98
+ dcgLogger(` message handling complete state: final`)
99
99
  return wsSend(ctx, { response: '', state: 'final' })
100
100
  }
101
101
 
@@ -1,4 +1,7 @@
1
1
  export const ENV: 'production' | 'test' | 'develop' = 'test'
2
2
 
3
3
 
4
- export const emptyToolText = ['/new', '/search', '/stop', '/abort', '/queue interrupt']
4
+ export const systemCommand = ['/new', '/status']
5
+ export const interruptCommand = ['/stop']
6
+
7
+ export const ignoreToolCommand = ['/search', '/abort', '/queue interrupt', ...systemCommand, ...interruptCommand]