@dcrays/dcgchat-test 0.4.11 → 0.4.12
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/channel.ts +9 -3
- package/src/cronToolCall.ts +6 -5
package/package.json
CHANGED
package/src/channel.ts
CHANGED
|
@@ -69,6 +69,12 @@ function normalizeSessionTarget(rawTo: string): string {
|
|
|
69
69
|
return getParamsMessage(cleaned)?.sessionKey?.trim() || cleaned
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
/** 出站返回的 chatId:含 `dcg-cron:` 时保留原始 `to`,便于下游识别定时投递 */
|
|
73
|
+
function outboundChatId(rawTo: string | undefined, normalizedTo: string): string {
|
|
74
|
+
const raw = rawTo?.trim() ?? ''
|
|
75
|
+
return raw.indexOf('dcg-cron:') >= 0 ? raw : normalizedTo
|
|
76
|
+
}
|
|
77
|
+
|
|
72
78
|
export async function sendDcgchatMedia(opts: DcgchatMediaSendOptions): Promise<void> {
|
|
73
79
|
const sessionKey = normalizeSessionTarget(opts.sessionKey ?? '')
|
|
74
80
|
const msgCtx = getOutboundMsgParams(sessionKey)
|
|
@@ -273,7 +279,7 @@ export const dcgchatPlugin: ChannelPlugin<ResolvedDcgchatAccount> = {
|
|
|
273
279
|
return {
|
|
274
280
|
channel: "dcgchat-test",
|
|
275
281
|
messageId: `${messageId}`,
|
|
276
|
-
chatId: to
|
|
282
|
+
chatId: outboundChatId(ctx.to, to)
|
|
277
283
|
}
|
|
278
284
|
},
|
|
279
285
|
sendMedia: async (ctx) => {
|
|
@@ -290,7 +296,7 @@ export const dcgchatPlugin: ChannelPlugin<ResolvedDcgchatAccount> = {
|
|
|
290
296
|
return {
|
|
291
297
|
channel: "dcgchat-test",
|
|
292
298
|
messageId,
|
|
293
|
-
chatId: to || ''
|
|
299
|
+
chatId: outboundChatId(ctx.to, to || '')
|
|
294
300
|
}
|
|
295
301
|
}
|
|
296
302
|
|
|
@@ -299,7 +305,7 @@ export const dcgchatPlugin: ChannelPlugin<ResolvedDcgchatAccount> = {
|
|
|
299
305
|
return {
|
|
300
306
|
channel: "dcgchat-test",
|
|
301
307
|
messageId,
|
|
302
|
-
chatId: to || ''
|
|
308
|
+
chatId: outboundChatId(ctx.to, to || '')
|
|
303
309
|
}
|
|
304
310
|
}
|
|
305
311
|
},
|
package/src/cronToolCall.ts
CHANGED
|
@@ -132,13 +132,14 @@ function injectBestEffort(params: Record<string, unknown>, sk: string): Record<s
|
|
|
132
132
|
return newParams
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
// job.delivery
|
|
135
|
+
// job.delivery(须改 job 内对象,勿写 newParams.delivery——顶层可能不存在)
|
|
136
136
|
const job = newParams.job as Record<string, unknown> | undefined
|
|
137
137
|
if (job?.delivery && typeof job.delivery === 'object') {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
138
|
+
const del = job.delivery as CronDelivery
|
|
139
|
+
del.bestEffort = true
|
|
140
|
+
del.to = `dcg-cron:${sk}`
|
|
141
|
+
del.accountId = agentId
|
|
142
|
+
del.channel = "dcgchat-test"
|
|
142
143
|
newParams.sessionKey = sk
|
|
143
144
|
return newParams
|
|
144
145
|
}
|