@ynhcj/xiaoyi-channel 0.0.229-next → 0.0.231-next
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/dist/src/reply-dispatcher.js +12 -20
- package/package.json +1 -1
|
@@ -203,33 +203,25 @@ export function createXYReplyDispatcher(params) {
|
|
|
203
203
|
scopedLog().log(`[DELIVER SKIP] Empty text, skipping`);
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
|
-
// 捕获权威最终文本(canonical
|
|
207
|
-
//
|
|
208
|
-
//
|
|
209
|
-
//
|
|
210
|
-
// SYSTEM_MARK),如 ACP 绑定会话投递的 "Session ids resolved"
|
|
211
|
-
// 诊断通知 —— 它会在同一 run 内尾随真实答案以 kind=final 投递,
|
|
212
|
-
// 若被捕获,最终帧会把客户端气泡里的答案整体替换成通知文本。
|
|
206
|
+
// 捕获权威最终文本(canonical),供 onIdle 拼接最终帧。
|
|
207
|
+
// 真正的 assistant 回复带有 assistantMessageIndex 元数据,系统通知
|
|
208
|
+
// (如 ⚙️ Session ids resolved. 诊断通知)没有此字段。assistant
|
|
209
|
+
// 回复始终可信,系统通知仅在没有已捕获答案时作为兜底(如纯报错场景)。
|
|
213
210
|
if (info?.kind === "final" && !payload.isCompactionNotice) {
|
|
214
|
-
|
|
215
|
-
|
|
211
|
+
const isAssistantReply = info?.assistantMessageIndex !== undefined;
|
|
212
|
+
if (isAssistantReply || !finalReplyText) {
|
|
213
|
+
finalReplyText = text;
|
|
214
|
+
scopedLog().log(`[DELIVER] Captured final reply text, length=${finalReplyText.length}${isAssistantReply ? "" : " (fallback)"}`);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
scopedLog().log(`[DELIVER] Skip non-assistant notification, keeping finalReplyText length=${finalReplyText.length}`);
|
|
218
|
+
}
|
|
216
219
|
}
|
|
217
220
|
// onPartialReply 已经通过 append:false 全量发送了所有文本,deliver 不再重复发送
|
|
218
221
|
if (hasSentResponse) {
|
|
219
222
|
scopedLog().log(`[DELIVER SKIP] Already sent via onPartialReply`);
|
|
220
223
|
return;
|
|
221
224
|
}
|
|
222
|
-
hasSentResponse = true;
|
|
223
|
-
// 非流式回退路径(onPartialReply 未触发时)
|
|
224
|
-
await sendA2AResponse({
|
|
225
|
-
config,
|
|
226
|
-
sessionId,
|
|
227
|
-
taskId: getActiveTaskId(),
|
|
228
|
-
messageId: getActiveMessageId(),
|
|
229
|
-
text,
|
|
230
|
-
append: true,
|
|
231
|
-
final: false,
|
|
232
|
-
});
|
|
233
225
|
}
|
|
234
226
|
catch (deliverError) {
|
|
235
227
|
scopedLog().error(`Failed to deliver message:`, deliverError);
|