@dcrays/dcgchat-test 0.3.8 → 0.3.10

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.3.8",
3
+ "version": "0.3.10",
4
4
  "type": "module",
5
5
  "description": "OpenClaw channel plugin for 书灵墨宝 (WebSocket)",
6
6
  "main": "index.ts",
package/src/bot.ts CHANGED
@@ -301,6 +301,7 @@ export async function handleDcgchatMessage(msg: InboundMessage, accountId: strin
301
301
  }
302
302
  })
303
303
  } else if (interruptCommand.includes(text?.trim())) {
304
+ safeSendFinal('abort')
304
305
  dcgLogger(`interrupt command: ${text}`)
305
306
  sendText('会话已终止', outboundCtx)
306
307
  sessionStreamSuppressed.add(effectiveSessionKey)
@@ -424,7 +425,7 @@ export async function handleDcgchatMessage(msg: InboundMessage, accountId: strin
424
425
  }
425
426
  }
426
427
  }
427
- // safeSendFinal('end')
428
+ safeSendFinal('end')
428
429
  clearSentMediaKeys(msg.content.message_id)
429
430
 
430
431
  // Record session metadata
package/src/channel.ts CHANGED
@@ -158,9 +158,23 @@ export const dcgchatPlugin: ChannelPlugin<ResolvedDcgchatAccount> = {
158
158
  // }
159
159
  const outboundCtx = getEffectiveMsgParams(ctx.to)
160
160
  const messageId = getCronMessageId(ctx.to)
161
- const newCtx = messageId ? { ...outboundCtx, messageId } : outboundCtx
162
- wsSendRaw(newCtx, { response: ctx.text, is_finish: -1, message_tags: { source: 'channel' } })
163
- dcgLogger(`channel sendText to ${ctx.to} ${ctx.text?.slice(0, 50)}`)
161
+ if (outboundCtx?.sessionId) {
162
+ const newCtx = messageId ? { ...outboundCtx, messageId } : outboundCtx
163
+ wsSendRaw(newCtx, { response: ctx.text, is_finish: -1, message_tags: { source: 'channel' } })
164
+ dcgLogger(`channel sendText to ${ctx.to} ${ctx.text?.slice(0, 50)}`)
165
+ } else {
166
+ const sessionInfo = ctx.to.split(':')[1]
167
+ const sessionId = sessionInfo.split('-')[0]
168
+ const agentId = sessionInfo.split('-')[1]
169
+ const merged = mergeDefaultParams({
170
+ agentId: agentId,
171
+ sessionId: `${sessionId}`,
172
+ messageId: messageId,
173
+ is_finish: -1
174
+ })
175
+ dcgLogger(`channel sendText to ${ctx.to} ${ctx.text?.slice(0, 50)}`)
176
+ wsSendRaw(merged, { response: ctx.text })
177
+ }
164
178
  }
165
179
  return {
166
180
  channel: "dcgchat-test",
@@ -154,14 +154,14 @@ export function cronToolCall(event: { toolName: any; params: any; toolCallId: an
154
154
  const delivery = extractDelivery(params)
155
155
  if (!delivery) {
156
156
  dcgLogger(`[${LOG_TAG}] cron call (${toolCallId}) has no delivery config, skip.`)
157
- return undefined
157
+ return params
158
158
  }
159
159
  if (!needsBestEffort(delivery)) {
160
160
  dcgLogger(
161
161
  `[${LOG_TAG}] cron call (${toolCallId}) delivery does not need bestEffort ` +
162
162
  `(mode=${String(delivery.mode)}, channel=${String(delivery.channel)}, bestEffort=${String(delivery.bestEffort)}), skip.`
163
163
  )
164
- return undefined
164
+ return params
165
165
  }
166
166
 
167
167
  // ★ 核心:注入 bestEffort: true
@@ -173,15 +173,15 @@ export function cronToolCall(event: { toolName: any; params: any; toolCallId: an
173
173
 
174
174
  return { params: newParams }
175
175
  } else if (toolName === 'exec') {
176
- if (params.command.indexOf('cron create') || params.command.indexOf('cron add')) {
176
+ if (params.command.indexOf('cron create') > -1 || params.command.indexOf('cron add') > -1) {
177
177
  const newParams = JSON.parse(JSON.stringify(params)) as Record<string, unknown>
178
178
  newParams.command =
179
179
  params.command.replace('--json', '') + ` --session-key ${sk} --channel ${"dcgchat-test"} --to ${sk} --json`
180
180
  return { params: newParams }
181
181
  } else {
182
- return undefined
182
+ return params
183
183
  }
184
184
  }
185
185
 
186
- return undefined
186
+ return params
187
187
  }
package/src/skill.ts CHANGED
@@ -8,6 +8,7 @@ import { getWorkspaceDir } from './utils/global.js'
8
8
  import { getWsConnection } from './utils/global.js'
9
9
  import { dcgLogger } from './utils/log.js'
10
10
  import { isWsOpen } from './transport.js'
11
+ import { sendMessageToGateway } from './gateway/socket.js'
11
12
 
12
13
  type ISkillParams = {
13
14
  path: string
@@ -127,6 +128,7 @@ export async function installSkill(params: ISkillParams, msgContent: Record<stri
127
128
  })
128
129
  })
129
130
  sendEvent({ ...msgContent, status: 'ok' })
131
+ sendMessageToGateway(JSON.stringify({ method: 'skills.status', params: {} }))
130
132
  } catch (error) {
131
133
  // 如果安装失败,清理目录
132
134
  if (fs.existsSync(skillDir)) {