@dcrays/dcgchat-test 0.3.9 → 0.3.11

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.9",
3
+ "version": "0.3.11",
4
4
  "type": "module",
5
5
  "description": "OpenClaw channel plugin for 书灵墨宝 (WebSocket)",
6
6
  "main": "index.ts",
package/src/bot.ts CHANGED
@@ -424,7 +424,7 @@ export async function handleDcgchatMessage(msg: InboundMessage, accountId: strin
424
424
  }
425
425
  }
426
426
  }
427
- // safeSendFinal('end')
427
+ safeSendFinal('end')
428
428
  clearSentMediaKeys(msg.content.message_id)
429
429
 
430
430
  // 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",
@@ -169,9 +183,9 @@ export const dcgchatPlugin: ChannelPlugin<ResolvedDcgchatAccount> = {
169
183
  }
170
184
  },
171
185
  sendMedia: async (ctx) => {
172
- const sk = getCurrentSessionKey()
173
- const msgCtx = getEffectiveMsgParams('sk')
174
- await sendDcgchatMedia({ sessionKey: sk ?? '', mediaUrl: ctx.mediaUrl ?? '' })
186
+ const msgCtx = getEffectiveMsgParams(ctx.to)
187
+ dcgLogger(`channel sendMedia to ${ctx.to} ${ctx.mediaUrl?.slice(0, 50)}`)
188
+ await sendDcgchatMedia({ sessionKey: ctx.to ?? '', mediaUrl: ctx.mediaUrl ?? '' })
175
189
  return {
176
190
  channel: "dcgchat-test",
177
191
  messageId: `dcg-${Date.now()}`,
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)) {