@dcrays/dcgchat-test 0.3.9 → 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 +1 -1
- package/src/bot.ts +2 -1
- package/src/channel.ts +17 -3
- package/src/skill.ts +2 -0
package/package.json
CHANGED
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
|
-
|
|
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
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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",
|
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)) {
|