@ray-js/t-agent-plugin-aistream 0.2.7 → 0.2.8-beta.1
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/README-zh_CN.md +286 -95
- package/dist/AIStreamTypes.d.ts +39 -2
- package/dist/AIStreamTypes.js +5 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/mcp/McpServer.d.ts +11 -0
- package/dist/mcp/McpServer.js +162 -0
- package/dist/mcp/index.d.ts +3 -0
- package/dist/mcp/index.js +3 -0
- package/dist/mcp/types.d.ts +114 -0
- package/dist/mcp/types.js +1 -0
- package/dist/mcp/withMCP.d.ts +15 -0
- package/dist/mcp/withMCP.js +98 -0
- package/dist/utils/AIStream.d.ts +14 -1
- package/dist/utils/AIStream.js +34 -3
- package/dist/utils/defaultMock.js +285 -79
- package/dist/utils/mock.d.ts +14 -0
- package/dist/utils/object.d.ts +0 -1
- package/dist/utils/object.js +1 -24
- package/dist/utils/observer.d.ts +6 -2
- package/dist/utils/observer.js +17 -6
- package/dist/utils/sendMessage.js +2 -2
- package/dist/utils/track.js +2 -2
- package/dist/utils/ttt.d.ts +3 -2
- package/dist/utils/ttt.js +2 -1
- package/dist/withAIStream.d.ts +4 -1
- package/dist/withAIStream.js +11 -5
- package/package.json +2 -2
package/dist/utils/ttt.js
CHANGED
|
@@ -42,6 +42,7 @@ export const sendEventStart = promisify(ty.aistream.sendEventStart, true);
|
|
|
42
42
|
export const sendEventPayloadEnd = promisify(ty.aistream.sendEventPayloadEnd, true);
|
|
43
43
|
export const sendEventEnd = promisify(ty.aistream.sendEventEnd, true);
|
|
44
44
|
export const sendEventChatBreak = promisify(ty.aistream.sendEventChatBreak, true);
|
|
45
|
+
export const sendEventToAIStream = promisify(ty.aistream.sendEvent, true);
|
|
45
46
|
export const startRecordAndSendAudioData = promisify(ty.aistream.startRecordAndSendAudioData, true);
|
|
46
47
|
export const stopRecordAndSendAudioData = promisify(ty.aistream.stopRecordAndSendAudioData, true);
|
|
47
48
|
|
|
@@ -92,4 +93,4 @@ export const deleteRecordList = promisify(ty.aistream.deleteRecordList, true);
|
|
|
92
93
|
export const updateRecord = promisify(ty.aistream.updateRecord, true);
|
|
93
94
|
export const insertRecord = promisify(ty.aistream.insertRecord, true);
|
|
94
95
|
export const getNetworkType = promisify(ty.getNetworkType, true);
|
|
95
|
-
export const
|
|
96
|
+
export const sendTrackEvent = promisify(ty.event);
|
package/dist/withAIStream.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbortSignalObject, ChatAgent, ChatCardObject, ChatMessage, ChatMessageStatus, ChatTile, GetChatPluginHandler, InputBlock } from '@ray-js/t-agent';
|
|
2
2
|
import { TTTAction } from './utils';
|
|
3
|
-
import { AIStreamUserData, ConnectClientType, ReceivedTextSkillPacketBody } from './AIStreamTypes';
|
|
3
|
+
import { AIStreamUserData, ConnectClientType, ReceivedTextSkillPacketBody, SendAIStreamEventParams, SessionEventBody } from './AIStreamTypes';
|
|
4
4
|
import { ChatHistoryStore, StoredMessageObject } from './ChatHistoryStore';
|
|
5
5
|
export interface AIStreamOptions {
|
|
6
6
|
/** client 类型: 1-作为设备代理, 2-作为 App,3-作为开发者(行业 App) */
|
|
@@ -63,6 +63,7 @@ export interface AIStreamHooks {
|
|
|
63
63
|
}, result: {
|
|
64
64
|
userData: AIStreamUserData;
|
|
65
65
|
}) => void;
|
|
66
|
+
onSessionEventReceived: (event: SessionEventBody) => void;
|
|
66
67
|
}
|
|
67
68
|
export declare function withAIStream(options?: AIStreamOptions): (agent: ChatAgent) => {
|
|
68
69
|
hooks: import("hookable").Hookable<AIStreamHooks, import("hookable").HookKeys<AIStreamHooks>>;
|
|
@@ -92,6 +93,8 @@ export declare function withAIStream(options?: AIStreamOptions): (agent: ChatAge
|
|
|
92
93
|
onSkillsEnd: (fn: AIStreamHooks['onSkillsEnd']) => () => void;
|
|
93
94
|
onCardsReceived: (fn: AIStreamHooks['onCardsReceived']) => () => void;
|
|
94
95
|
onUserDataRead: (fn: AIStreamHooks['onUserDataRead']) => () => void;
|
|
96
|
+
onSessionEventReceived: (fn: AIStreamHooks['onSessionEventReceived']) => () => void;
|
|
97
|
+
sendEvent: (params: SendAIStreamEventParams) => Promise<null>;
|
|
95
98
|
onTTTAction: (fn: AIStreamHooks['onTTTAction']) => () => void;
|
|
96
99
|
getChatId: () => Promise<string>;
|
|
97
100
|
};
|
package/dist/withAIStream.js
CHANGED
|
@@ -16,12 +16,12 @@ function _asyncIterator(r) { var n, t, o, e = 2; for ("undefined" != typeof Symb
|
|
|
16
16
|
function AsyncFromSyncIterator(r) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var n = r.done; return Promise.resolve(r.value).then(function (r) { return { value: r, done: n }; }); } return AsyncFromSyncIterator = function (r) { this.s = r, this.n = r.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function () { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, return: function (r) { var n = this.s.return; return void 0 === n ? Promise.resolve({ value: r, done: !0 }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); }, throw: function (r) { var n = this.s.return; return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(r); }
|
|
17
17
|
import { BubbleTileStatus, ChatMessageStatus, createHooks, EmitterEvent } from '@ray-js/t-agent';
|
|
18
18
|
import { messageAppraise } from './utils/apis';
|
|
19
|
-
import { getAccountInfo, getCurrentHomeInfo, runTTTAction, sendBlocksToAIStream } from './utils';
|
|
19
|
+
import { getAccountInfo, getCurrentHomeInfo, runTTTAction, sendBlocksToAIStream, sendEventToAIStream } from './utils';
|
|
20
20
|
import { BizCode, ConnectClientType } from './AIStreamTypes';
|
|
21
21
|
import { DEFAULT_TOKEN_API, DEFAULT_TOKEN_API_VERSION, globalAIStreamClient } from './global';
|
|
22
22
|
import logger from './utils/logger';
|
|
23
23
|
import { ChatHistoryLocalStore } from './ChatHistoryLocalStore';
|
|
24
|
-
import {
|
|
24
|
+
import { deepmerge } from '@ray-js/t-agent';
|
|
25
25
|
import { trackEvent } from './utils/track';
|
|
26
26
|
export function withAIStream() {
|
|
27
27
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -110,6 +110,9 @@ export function withAIStream() {
|
|
|
110
110
|
return result.userData;
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
|
+
streamSession.on('sessionEvent', event => {
|
|
114
|
+
hooks.callHook('onSessionEventReceived', event);
|
|
115
|
+
});
|
|
113
116
|
await session.set('AIStream.streamSession', streamSession);
|
|
114
117
|
if (options.earlyStart) {
|
|
115
118
|
// 故意异步,不阻塞消息列表加载
|
|
@@ -255,9 +258,8 @@ export function withAIStream() {
|
|
|
255
258
|
await hooks.callHook('onUserDataRead', 'start-event', {
|
|
256
259
|
blocks
|
|
257
260
|
}, userDataResult);
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
deepMerge(userData, eventUserData);
|
|
261
|
+
let userData = deepmerge({}, userDataResult.userData);
|
|
262
|
+
userData = deepmerge(userData, eventUserData);
|
|
261
263
|
return userData;
|
|
262
264
|
}
|
|
263
265
|
});
|
|
@@ -659,6 +661,10 @@ export function withAIStream() {
|
|
|
659
661
|
onUserDataRead: fn => {
|
|
660
662
|
return hooks.hook('onUserDataRead', fn);
|
|
661
663
|
},
|
|
664
|
+
onSessionEventReceived: fn => {
|
|
665
|
+
return hooks.hook('onSessionEventReceived', fn);
|
|
666
|
+
},
|
|
667
|
+
sendEvent: params => sendEventToAIStream(params),
|
|
662
668
|
onTTTAction: fn => {
|
|
663
669
|
return hooks.hook('onTTTAction', fn);
|
|
664
670
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/t-agent-plugin-aistream",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8-beta.1",
|
|
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": "
|
|
38
|
+
"gitHead": "040499ca11aedda3246121f880807da0f8af3cc9"
|
|
39
39
|
}
|