@ray-js/t-agent-plugin-aistream 0.2.0-beta.19 → 0.2.0-beta.20

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.
@@ -1,4 +1,4 @@
1
- import { AudioBody, ConnectStateBody, EventBody, FileBody, ImageBody, RecordAmplitudesBody, SessionStateBody, TextBody, VideoBody } from '../AIStreamTypes';
1
+ import { AudioBody, ConnectStateBody, EventBody, FileBody, ImageBody, SessionStateBody, TextBody, VideoBody } from '../AIStreamTypes';
2
2
  export type AIStreamDataEntry = {
3
3
  type: 'text';
4
4
  body: TextBody;
@@ -23,9 +23,6 @@ export type AIStreamDataEntry = {
23
23
  } | {
24
24
  type: 'sessionState';
25
25
  body: SessionStateBody;
26
- } | {
27
- type: 'amplitudes';
28
- body: RecordAmplitudesBody;
29
26
  };
30
27
  export interface AIStreamObserverOptions {
31
28
  sessionState?: boolean;
@@ -38,7 +35,6 @@ export interface AIStreamObserverOptions {
38
35
  image?: boolean;
39
36
  dataChannels?: string[];
40
37
  sessionId?: string;
41
- amplitudes?: boolean;
42
38
  }
43
39
  export declare class AIStreamObserverPool {
44
40
  isStarted: boolean;
@@ -3,9 +3,9 @@ import "core-js/modules/esnext.iterator.constructor.js";
3
3
  import "core-js/modules/esnext.iterator.for-each.js";
4
4
  import "core-js/modules/web.dom-collections.iterator.js";
5
5
  import { ConnectState, EventType, SessionState, StreamFlag } from '../AIStreamTypes';
6
- import { listenAudioReceived, listenConnectStateChanged, listenEventReceived, listenImageReceived, listenRecordAmplitudes, listenSessionStateChanged, listenTextReceived } from './ttt';
6
+ import { listenAudioReceived, listenConnectStateChanged, listenEventReceived, listenImageReceived, listenSessionStateChanged, listenTextReceived } from './ttt';
7
7
  import logger from './logger';
8
- const types = ['connectionState', 'sessionState', 'event', 'text', 'audio', 'video', 'file', 'image', 'amplitudes'];
8
+ const types = ['connectionState', 'sessionState', 'event', 'text', 'audio', 'video', 'file', 'image'];
9
9
  export class AIStreamObserverPool {
10
10
  constructor() {
11
11
  _defineProperty(this, "isStarted", false);
@@ -18,8 +18,7 @@ export class AIStreamObserverPool {
18
18
  audio: new Set(),
19
19
  video: new Set(),
20
20
  file: new Set(),
21
- image: new Set(),
22
- amplitudes: new Set()
21
+ image: new Set()
23
22
  };
24
23
  }
25
24
  start() {
@@ -27,21 +26,19 @@ export class AIStreamObserverPool {
27
26
  return;
28
27
  }
29
28
  const handle = entry => {
29
+ var _entry$body;
30
30
  const observers = this.observerMap[entry.type];
31
31
  let state = '';
32
- if (entry.type !== 'amplitudes') {
33
- var _entry$body;
34
- if (entry.type === 'connectionState') {
35
- state = "".concat(ConnectState[entry.body.connectState], " ").concat(entry.body.code || '');
36
- } else if (entry.type === 'sessionState') {
37
- state = "".concat(SessionState[entry.body.sessionState], " ").concat(entry.body.code || '');
38
- } else if (entry.type === 'event') {
39
- state = "".concat(EventType[entry.body.eventType]);
40
- } else if ((_entry$body = entry.body) !== null && _entry$body !== void 0 && _entry$body.streamFlag) {
41
- state = "".concat(StreamFlag[entry.body.streamFlag]);
42
- }
43
- logger.debug("Pool received: %c".concat(observers.size ? '⊕' : '×').concat(entry.type, " ").concat(state), 'background: black; color: white', entry);
32
+ if (entry.type === 'connectionState') {
33
+ state = "".concat(ConnectState[entry.body.connectState], " ").concat(entry.body.code || '');
34
+ } else if (entry.type === 'sessionState') {
35
+ state = "".concat(SessionState[entry.body.sessionState], " ").concat(entry.body.code || '');
36
+ } else if (entry.type === 'event') {
37
+ state = "".concat(EventType[entry.body.eventType]);
38
+ } else if ((_entry$body = entry.body) !== null && _entry$body !== void 0 && _entry$body.streamFlag) {
39
+ state = "".concat(StreamFlag[entry.body.streamFlag]);
44
40
  }
41
+ logger.debug("Pool received: %c".concat(observers.size ? '⊕' : '×').concat(entry.type, " ").concat(state), 'background: black; color: white', entry);
45
42
  observers.forEach(observer => {
46
43
  if (entry.type === 'text' || entry.type === 'audio' || entry.type === 'video' || entry.type === 'file' || entry.type === 'image') {
47
44
  const {
@@ -81,9 +78,6 @@ export class AIStreamObserverPool {
81
78
  })), listenImageReceived(body => handle({
82
79
  type: 'image',
83
80
  body
84
- })), listenRecordAmplitudes(body => handle({
85
- type: 'amplitudes',
86
- body
87
81
  }))
88
82
  // listenVideoReceived(body => handle({ type: 'video', body })),
89
83
  // listenFileReceived(body => handle({ type: 'file', body })),
@@ -102,8 +96,7 @@ export class AIStreamObserverPool {
102
96
  audio: new Set(),
103
97
  video: new Set(),
104
98
  file: new Set(),
105
- image: new Set(),
106
- amplitudes: new Set()
99
+ image: new Set()
107
100
  };
108
101
  }
109
102
  connect(observer) {
@@ -9,8 +9,8 @@ import "core-js/modules/esnext.iterator.map.js";
9
9
  import "core-js/modules/web.dom-collections.iterator.js";
10
10
  import { BubbleTileStatus, ChatMessageStatus, createHooks, EmitterEvent } from '@ray-js/t-agent';
11
11
  import { messageAppraise } from './utils/apis';
12
- import { AIStreamObserver, getAccountInfo, getCurrentHomeInfo, runTTTAction, sendBlocksToAIStream } from './utils';
13
- import { BizCode, ConnectClientType, ConnectState } from './AIStreamTypes';
12
+ import { getAccountInfo, getCurrentHomeInfo, runTTTAction, sendBlocksToAIStream } from './utils';
13
+ import { BizCode, ConnectClientType } from './AIStreamTypes';
14
14
  import { ChatHistoryLocalStore } from './ChatHistoryStore';
15
15
  import { DEFAULT_TOKEN_API, DEFAULT_TOKEN_API_VERSION, globalAIStreamClient } from './global';
16
16
  import logger from './utils/logger';
@@ -110,20 +110,6 @@ export function withAIStream() {
110
110
  logger.error('earlyStart failed', error);
111
111
  });
112
112
  }
113
- const observer = new AIStreamObserver(data => {
114
- if (data.type === 'amplitudes') {
115
- ui.emitEvent('amplitudes', data);
116
- } else if (data.type === 'connectionState') {
117
- ui.emitEvent('networkChange', {
118
- online: data.body.connectState === ConnectState.CONNECTED
119
- });
120
- }
121
- }, globalAIStreamClient.pool);
122
- observer.observe({
123
- connectionState: true,
124
- amplitudes: true
125
- });
126
- await session.set('AIStream.observer', observer);
127
113
  });
128
114
  const getHistoryStore = () => {
129
115
  const historyStore = session.get('AIStream.historyStore');
@@ -405,10 +391,6 @@ export function withAIStream() {
405
391
  };
406
392
  });
407
393
  onAgentDispose(async () => {
408
- const observer = session.get('AIStream.observer');
409
- if (observer) {
410
- observer.disconnect();
411
- }
412
394
  const streamSession = session.get('AIStream.streamSession');
413
395
 
414
396
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/t-agent-plugin-aistream",
3
- "version": "0.2.0-beta.19",
3
+ "version": "0.2.0-beta.20",
4
4
  "author": "Tuya.inc",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -35,5 +35,5 @@
35
35
  "devDependencies": {
36
36
  "@types/url-parse": "^1.4.11"
37
37
  },
38
- "gitHead": "0db50eef90b217b739bab1d824e4c6b2d495a169"
38
+ "gitHead": "517ce9d6aec8ac6a1ade692df773750d0c7738cf"
39
39
  }