@ray-js/t-agent-plugin-aistream 0.2.8-beta.3 → 0.2.8-beta.4

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.
@@ -216,52 +216,39 @@ export function withBuildIn(options) {
216
216
  // 音频包结束时,往气泡里插入一个语音播放按钮(BubbleToolTile)。
217
217
  // 只持久化播放所需的音频参数,不含 playing 状态。
218
218
  //
219
- // 注意:音频按流式分多包下发,格式头(codecType/sampleRate/channels/bitDepth)
220
- // 只在 START 包里携带,END 包通常只带最终的 path/pts。因此不能只取 END 包,
221
- // 需要按音频流 id(part.id 在同一段音频的所有分包间一致)聚合,
222
- // START 包的格式参数与 END 包的 path 合并后再建 tile,
223
- // 否则持久化后点击播放时格式参数会全部丢失,只剩 path。
219
+ // 注意:音频按流式分多包下发,播放所需的完整参数(path + 格式头
220
+ // codecType/sampleRate/channels/bitDepth)只在首包(START/ONLY_ONE)携带;
221
+ // 后续 END 等包里这些字段是 0(而非 null/undefined),会污染数据。
222
+ // 因此只取每段音频的首包,丢弃后续包,按音频流 id(part.id 在同一段音频的
223
+ // 所有分包间一致)去重。
224
224
  onAttachmentsEnd((parts, respMsg) => {
225
225
  const audioMap = new Map();
226
226
  parts.forEach(i => {
227
- var _audio$path, _audio$pts, _audio$codecType, _audio$sampleRate, _audio$channels, _audio$bitDepth;
228
227
  if (i.attachmentType !== 'audio') {
229
228
  return;
230
229
  }
231
230
  const audio = i.attachment;
232
- const entry = audioMap.get(i.id) || {
233
- audio: {},
234
- complete: false
235
- };
236
231
 
237
- // 合并各分包:后到的非空字段覆盖,空字段保留先前值(END 包不会用 undefined 覆盖掉格式参数)
238
- entry.audio = {
239
- path: (_audio$path = audio.path) !== null && _audio$path !== void 0 ? _audio$path : entry.audio.path,
240
- pts: (_audio$pts = audio.pts) !== null && _audio$pts !== void 0 ? _audio$pts : entry.audio.pts,
241
- codecType: (_audio$codecType = audio.codecType) !== null && _audio$codecType !== void 0 ? _audio$codecType : entry.audio.codecType,
242
- sampleRate: (_audio$sampleRate = audio.sampleRate) !== null && _audio$sampleRate !== void 0 ? _audio$sampleRate : entry.audio.sampleRate,
243
- channels: (_audio$channels = audio.channels) !== null && _audio$channels !== void 0 ? _audio$channels : entry.audio.channels,
244
- bitDepth: (_audio$bitDepth = audio.bitDepth) !== null && _audio$bitDepth !== void 0 ? _audio$bitDepth : entry.audio.bitDepth
245
- };
246
- if (audio.streamFlag === StreamFlag.ONLY_ONE || audio.streamFlag === StreamFlag.END) {
247
- entry.complete = true;
248
- // END 包的 path 是最终完整文件,确保覆盖
249
- if (audio.path) {
250
- entry.audio.path = audio.path;
251
- }
232
+ // 只接收首包,后续包直接丢弃
233
+ if (audio.streamFlag !== StreamFlag.START && audio.streamFlag !== StreamFlag.ONLY_ONE) {
234
+ return;
252
235
  }
253
- audioMap.set(i.id, entry);
254
- });
255
- audioMap.forEach(_ref => {
256
- let {
257
- audio,
258
- complete
259
- } = _ref;
260
- if (complete) {
261
- respMsg.bubble.addTile('bubbleTool', {
262
- audio
263
- });
236
+ if (audioMap.has(i.id)) {
237
+ return;
264
238
  }
239
+ audioMap.set(i.id, {
240
+ path: audio.path,
241
+ pts: audio.pts,
242
+ codecType: audio.codecType,
243
+ sampleRate: audio.sampleRate,
244
+ channels: audio.channels,
245
+ bitDepth: audio.bitDepth
246
+ });
247
+ });
248
+ audioMap.forEach(audio => {
249
+ respMsg.bubble.addTile('bubbleTool', {
250
+ audio
251
+ });
265
252
  });
266
253
  });
267
254
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/t-agent-plugin-aistream",
3
- "version": "0.2.8-beta.3",
3
+ "version": "0.2.8-beta.4",
4
4
  "author": "Tuya.inc",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -36,5 +36,5 @@
36
36
  "devDependencies": {
37
37
  "@types/url-parse": "^1.4.11"
38
38
  },
39
- "gitHead": "938bc0c7da7d23dbbad8c3c14c97e5f4007f06f7"
39
+ "gitHead": "556407c77bdeb9f879a8bb9e89184fc62e4c8bd0"
40
40
  }