@ray-js/t-agent 0.2.6-beta-8 → 0.2.7-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.
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import { ChatAgentPlugin } from './types';
|
|
2
1
|
import ChatAgent from './ChatAgent';
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
type ExtractSinglePluginType<T> = T extends (...args: any[]) => infer R ? R extends {
|
|
3
|
+
hooks?: any;
|
|
4
|
+
} ? Omit<R, 'hooks'> : R : never;
|
|
5
|
+
type ExtractPluginReturnType<T extends readonly any[]> = T extends readonly [
|
|
6
|
+
infer First,
|
|
7
|
+
...infer Rest
|
|
8
|
+
] ? ExtractSinglePluginType<First> & ExtractPluginReturnType<Rest> : Record<string, unknown>;
|
|
9
|
+
export declare function createChatAgent<T extends readonly ((...args: any[]) => any)[]>(...plugins: T): ChatAgent<ExtractPluginReturnType<T>> & {
|
|
10
|
+
plugins: ExtractPluginReturnType<T>;
|
|
11
|
+
};
|
|
12
|
+
export declare function applyChatAgentPlugins<T extends Record<string, unknown>, P extends readonly ((...args: any[]) => any)[]>(agent: ChatAgent<T>, ...plugins: P): ChatAgent<T & ExtractPluginReturnType<P>>;
|
|
6
13
|
export {};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import "core-js/modules/web.dom-collections.iterator.js";
|
|
2
2
|
import ChatAgent from './ChatAgent';
|
|
3
|
+
|
|
4
|
+
// 提取单个插件的返回类型(排除 hooks)
|
|
5
|
+
|
|
6
|
+
// 递归合并所有插件的返回类型
|
|
7
|
+
|
|
3
8
|
export function createChatAgent() {
|
|
4
9
|
const agent = new ChatAgent();
|
|
5
10
|
for (var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/t-agent",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7-beta.1",
|
|
4
4
|
"author": "Tuya.inc",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"build": "ray build --type=component --output dist",
|
|
27
27
|
"clean": "rimraf ./dist"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "d7754f9879a7ec837eb343ac759a08734cc789d3"
|
|
30
30
|
}
|