@ynhcj/xiaoyi-channel 0.0.45-beta → 0.0.46-beta
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/bot.js +14 -12
- package/package.json +1 -1
package/dist/src/bot.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getXYRuntime } from "./runtime.js";
|
|
2
2
|
import { createXYReplyDispatcher } from "./reply-dispatcher.js";
|
|
3
3
|
import { parseA2AMessage, extractTextFromParts, extractFileParts, extractPushId, extractTriggerData } from "./parser.js";
|
|
4
|
+
import { downloadFilesFromParts } from "./file-download.js";
|
|
4
5
|
import { resolveXYConfig } from "./config.js";
|
|
5
6
|
import { sendStatusUpdate, sendClearContextResponse, sendTasksCancelResponse, sendA2AResponse } from "./formatter.js";
|
|
6
7
|
import { registerSession, unregisterSession, runWithSessionContext } from "./tools/session-manager.js";
|
|
@@ -172,9 +173,9 @@ export async function handleXYMessage(params) {
|
|
|
172
173
|
// Extract text and files from parts
|
|
173
174
|
const text = extractTextFromParts(parsed.parts);
|
|
174
175
|
const fileParts = extractFileParts(parsed.parts);
|
|
175
|
-
//
|
|
176
|
-
|
|
177
|
-
const mediaPayload = buildXYMediaPayload(
|
|
176
|
+
// Download files to local disk
|
|
177
|
+
const downloadedFiles = await downloadFilesFromParts(fileParts);
|
|
178
|
+
const mediaPayload = buildXYMediaPayload(downloadedFiles);
|
|
178
179
|
// Resolve envelope format options (following feishu pattern)
|
|
179
180
|
const envelopeOptions = core.channel.reply.resolveEnvelopeFormatOptions(cfg);
|
|
180
181
|
// Build message body with speaker prefix (following feishu pattern)
|
|
@@ -318,18 +319,19 @@ export async function handleXYMessage(params) {
|
|
|
318
319
|
/**
|
|
319
320
|
* Build media payload for inbound context.
|
|
320
321
|
* Following feishu pattern: buildFeishuMediaPayload().
|
|
321
|
-
*
|
|
322
|
+
*
|
|
323
|
+
* @param mediaList - Downloaded files with local paths
|
|
322
324
|
*/
|
|
323
|
-
function buildXYMediaPayload(
|
|
324
|
-
const first =
|
|
325
|
-
const
|
|
326
|
-
const mediaTypes =
|
|
325
|
+
function buildXYMediaPayload(mediaList) {
|
|
326
|
+
const first = mediaList[0];
|
|
327
|
+
const mediaPaths = mediaList.map((media) => media.path);
|
|
328
|
+
const mediaTypes = mediaList.map((media) => media.mimeType).filter(Boolean);
|
|
327
329
|
return {
|
|
328
|
-
MediaPath: first?.
|
|
330
|
+
MediaPath: first?.path,
|
|
329
331
|
MediaType: first?.mimeType,
|
|
330
|
-
MediaUrl: first?.
|
|
331
|
-
MediaPaths:
|
|
332
|
-
MediaUrls:
|
|
332
|
+
MediaUrl: first?.path,
|
|
333
|
+
MediaPaths: mediaPaths.length > 0 ? mediaPaths : undefined,
|
|
334
|
+
MediaUrls: mediaPaths.length > 0 ? mediaPaths : undefined,
|
|
333
335
|
MediaTypes: mediaTypes.length > 0 ? mediaTypes : undefined,
|
|
334
336
|
};
|
|
335
337
|
}
|