@opentiny/next-remoter 0.2.5 → 0.2.6-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/LICENSE +21 -0
- package/dist/components/TinyRobotChat.vue.d.ts +90 -5
- package/dist/composable/CustomAgentModelProvider.d.ts +11 -2
- package/dist/composable/promptManager.d.ts +18 -0
- package/dist/composable/useMessageRoles.d.ts +11 -11
- package/dist/composable/usePlugin.d.ts +7 -0
- package/dist/composable/useSkill.d.ts +0 -2
- package/dist/next-remoter-runtime.es.js +68137 -67577
- package/dist/next-remoter.cjs.js +50 -48
- package/dist/next-remoter.css +1 -1
- package/dist/next-remoter.es.js +8816 -8409
- package/dist/style.css +1 -1
- package/dist/types/model-config.d.ts +1 -0
- package/dist/types/type.d.ts +3 -6
- package/package.json +2 -2
- /package/dist/components/{tokenUsage.vue.d.ts → TokenUsage.vue.d.ts} +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 - present OpenTiny Authors.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TrSender, PluginInfo } from '@opentiny/tiny-robot';
|
|
2
2
|
import { STATUS } from '@opentiny/tiny-robot-kit';
|
|
3
|
-
import { Ref, ComponentInstance } from 'vue';
|
|
3
|
+
import { Ref, ComponentInstance, VNode } from 'vue';
|
|
4
4
|
import { ICustomAgentModelProviderLlmConfig } from '../types/type';
|
|
5
5
|
import { MenuItemConfig, McpServerConfig } from '@opentiny/next-sdk';
|
|
6
6
|
import { UnifiedModelConfig } from '../types/model-config';
|
|
@@ -60,6 +60,21 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
60
60
|
AILogoUrl: {
|
|
61
61
|
type: StringConstructor;
|
|
62
62
|
};
|
|
63
|
+
/** 角色user,assistant的头像配置, 值为 VNode, 比如: h(IconUser, { style: { fontSize: '32px' } }) */
|
|
64
|
+
roleAvatar: {
|
|
65
|
+
type: () => {
|
|
66
|
+
user: VNode;
|
|
67
|
+
assistant: VNode;
|
|
68
|
+
};
|
|
69
|
+
default: () => {
|
|
70
|
+
user: VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
71
|
+
[key: string]: any;
|
|
72
|
+
}>;
|
|
73
|
+
assistant: VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
74
|
+
[key: string]: any;
|
|
75
|
+
}>;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
63
78
|
/** 展示模式: 'remoter' | 'chat-dialog'
|
|
64
79
|
* 遥控器模式: 自动在右下角显示一个AI图标,点击展开多个菜单项。
|
|
65
80
|
* 对话框模式: 直接显示一个对话框界面
|
|
@@ -112,11 +127,15 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
112
127
|
type: () => "static" | "relative" | "absolute" | "fixed" | "sticky";
|
|
113
128
|
default: string;
|
|
114
129
|
};
|
|
130
|
+
debugStream: {
|
|
131
|
+
type: BooleanConstructor;
|
|
132
|
+
default: boolean;
|
|
133
|
+
};
|
|
115
134
|
}>, {
|
|
116
135
|
/** 大模型代理 */
|
|
117
136
|
agent: import('@opentiny/next-sdk').AgentModelProvider;
|
|
118
137
|
/** 欢迎图标 */
|
|
119
|
-
welcomeIcon:
|
|
138
|
+
welcomeIcon: VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
120
139
|
[key: string]: any;
|
|
121
140
|
}>;
|
|
122
141
|
/** 对话消息 */
|
|
@@ -131,7 +150,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
131
150
|
assistant: {
|
|
132
151
|
type: string;
|
|
133
152
|
placement: string;
|
|
134
|
-
avatar:
|
|
153
|
+
avatar: VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
135
154
|
[key: string]: any;
|
|
136
155
|
}>;
|
|
137
156
|
maxWidth: string;
|
|
@@ -139,14 +158,14 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
139
158
|
slots: {
|
|
140
159
|
footer: ({ index }: {
|
|
141
160
|
index: number;
|
|
142
|
-
}) => "" |
|
|
161
|
+
}) => "" | VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
143
162
|
[key: string]: any;
|
|
144
163
|
}>;
|
|
145
164
|
};
|
|
146
165
|
};
|
|
147
166
|
user: {
|
|
148
167
|
placement: string;
|
|
149
|
-
avatar:
|
|
168
|
+
avatar: VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
150
169
|
[key: string]: any;
|
|
151
170
|
}>;
|
|
152
171
|
maxWidth: string;
|
|
@@ -182,6 +201,48 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
182
201
|
} | null>;
|
|
183
202
|
/** 添加消息 */
|
|
184
203
|
addMessage: (message: import('@opentiny/tiny-robot-kit').ChatMessage | import('@opentiny/tiny-robot-kit').ChatMessage[]) => void;
|
|
204
|
+
/** 已安装的插件 */
|
|
205
|
+
installedPlugins: Ref<{
|
|
206
|
+
id: string;
|
|
207
|
+
name: string;
|
|
208
|
+
icon: string;
|
|
209
|
+
description: string;
|
|
210
|
+
enabled: boolean;
|
|
211
|
+
expanded?: boolean | undefined;
|
|
212
|
+
tools: {
|
|
213
|
+
id: string;
|
|
214
|
+
name: string;
|
|
215
|
+
description: string;
|
|
216
|
+
enabled: boolean;
|
|
217
|
+
}[];
|
|
218
|
+
addState?: import('@opentiny/tiny-robot').PluginAddState | undefined;
|
|
219
|
+
category?: string | undefined;
|
|
220
|
+
}[], PluginInfo[] | {
|
|
221
|
+
id: string;
|
|
222
|
+
name: string;
|
|
223
|
+
icon: string;
|
|
224
|
+
description: string;
|
|
225
|
+
enabled: boolean;
|
|
226
|
+
expanded?: boolean | undefined;
|
|
227
|
+
tools: {
|
|
228
|
+
id: string;
|
|
229
|
+
name: string;
|
|
230
|
+
description: string;
|
|
231
|
+
enabled: boolean;
|
|
232
|
+
}[];
|
|
233
|
+
addState?: import('@opentiny/tiny-robot').PluginAddState | undefined;
|
|
234
|
+
category?: string | undefined;
|
|
235
|
+
}[]>;
|
|
236
|
+
/** 添加插件核心方法 */
|
|
237
|
+
addPluginCore: (config: {
|
|
238
|
+
pluginId: string;
|
|
239
|
+
name: string;
|
|
240
|
+
description: string;
|
|
241
|
+
icon?: string;
|
|
242
|
+
mcpServer: McpServerConfig;
|
|
243
|
+
}) => Promise<boolean>;
|
|
244
|
+
/** 删除插件核心方法 */
|
|
245
|
+
deletePlugin: (plugin: PluginInfo) => Promise<void>;
|
|
185
246
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
186
247
|
fullscreen: import('vue').PropType<any>;
|
|
187
248
|
show: import('vue').PropType<any>;
|
|
@@ -226,6 +287,21 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
226
287
|
AILogoUrl: {
|
|
227
288
|
type: StringConstructor;
|
|
228
289
|
};
|
|
290
|
+
/** 角色user,assistant的头像配置, 值为 VNode, 比如: h(IconUser, { style: { fontSize: '32px' } }) */
|
|
291
|
+
roleAvatar: {
|
|
292
|
+
type: () => {
|
|
293
|
+
user: VNode;
|
|
294
|
+
assistant: VNode;
|
|
295
|
+
};
|
|
296
|
+
default: () => {
|
|
297
|
+
user: VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
298
|
+
[key: string]: any;
|
|
299
|
+
}>;
|
|
300
|
+
assistant: VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
301
|
+
[key: string]: any;
|
|
302
|
+
}>;
|
|
303
|
+
};
|
|
304
|
+
};
|
|
229
305
|
/** 展示模式: 'remoter' | 'chat-dialog'
|
|
230
306
|
* 遥控器模式: 自动在右下角显示一个AI图标,点击展开多个菜单项。
|
|
231
307
|
* 对话框模式: 直接显示一个对话框界面
|
|
@@ -278,6 +354,10 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
278
354
|
type: () => "static" | "relative" | "absolute" | "fixed" | "sticky";
|
|
279
355
|
default: string;
|
|
280
356
|
};
|
|
357
|
+
debugStream: {
|
|
358
|
+
type: BooleanConstructor;
|
|
359
|
+
default: boolean;
|
|
360
|
+
};
|
|
281
361
|
}>> & Readonly<{}>, {
|
|
282
362
|
title: string;
|
|
283
363
|
systemPrompt: string;
|
|
@@ -287,12 +367,17 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
287
367
|
mcpServers: Record<string, McpServerConfig>;
|
|
288
368
|
agentRoot: string;
|
|
289
369
|
locale: string;
|
|
370
|
+
roleAvatar: {
|
|
371
|
+
user: VNode;
|
|
372
|
+
assistant: VNode;
|
|
373
|
+
};
|
|
290
374
|
inBrowserExt: boolean;
|
|
291
375
|
genUiComponents: Record<string, any>;
|
|
292
376
|
customMarketMcpServers: PluginInfo[];
|
|
293
377
|
llmConfigs: UnifiedModelConfig[];
|
|
294
378
|
skills: Record<string, string>;
|
|
295
379
|
layoutMode: "absolute" | "fixed" | "static" | "relative" | "sticky";
|
|
380
|
+
debugStream: boolean;
|
|
296
381
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
297
382
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
298
383
|
export default _default;
|
|
@@ -3,16 +3,18 @@ import { Ref } from 'vue';
|
|
|
3
3
|
import { AgentModelProvider } from '@opentiny/next-sdk';
|
|
4
4
|
import { ICustomAgentModelProviderLlmConfig } from '../types/type';
|
|
5
5
|
import { ProviderV2 } from '@ai-sdk/provider';
|
|
6
|
+
import { PromptManager } from './promptManager';
|
|
6
7
|
|
|
7
8
|
/** Tiny-robot 所需要的自定义大语言的Provider */
|
|
8
9
|
export declare class CustomAgentModelProvider extends BaseModelProvider {
|
|
9
10
|
transport: any;
|
|
10
11
|
/** 一个 ai-sdk agent 封装 */
|
|
11
12
|
agent: AgentModelProvider;
|
|
12
|
-
|
|
13
|
+
promptManager: PromptManager;
|
|
13
14
|
llmConfig: ICustomAgentModelProviderLlmConfig;
|
|
14
15
|
/** 生成式UI启用状态 */
|
|
15
16
|
isGenuiEnabled?: Ref<boolean>;
|
|
17
|
+
debugStream: boolean;
|
|
16
18
|
constructor(config: AIModelConfig, systemPrompt: string, llmConfig?: ICustomAgentModelProviderLlmConfig);
|
|
17
19
|
/**
|
|
18
20
|
* 更新大语言模型配置
|
|
@@ -23,16 +25,23 @@ export declare class CustomAgentModelProvider extends BaseModelProvider {
|
|
|
23
25
|
* @param providerType 提供商类型
|
|
24
26
|
* @param useReActMode 是否使用 ReAct 模式
|
|
25
27
|
*/
|
|
26
|
-
updateLLMConfig({ modelId, baseURL, apiKey, providerType, useReActMode, llm, providerOptions }: {
|
|
28
|
+
updateLLMConfig({ modelId, baseURL, genuiUrl, apiKey, providerType, useReActMode, llm, providerOptions, headers }: {
|
|
27
29
|
modelId: string;
|
|
28
30
|
baseURL?: string;
|
|
31
|
+
genuiUrl?: string;
|
|
29
32
|
apiKey?: string;
|
|
30
33
|
providerType?: 'deepseek' | 'openai' | ((options: any) => ProviderV2);
|
|
31
34
|
useReActMode?: boolean;
|
|
32
35
|
llm?: ProviderV2;
|
|
33
36
|
/** 自定义请求体字段,会合并到 AI SDK streamText 的 providerOptions 中 */
|
|
34
37
|
providerOptions?: Record<string, any>;
|
|
38
|
+
/** 自定义请求 Header,透传给 ai-sdk Provider 实例 */
|
|
39
|
+
headers?: Record<string, string>;
|
|
35
40
|
}): void;
|
|
41
|
+
/**
|
|
42
|
+
* 清理消息数组中的 get-skill-content 工具调用结果
|
|
43
|
+
*/
|
|
44
|
+
cleanGetSkillContentToolResult(messages: any[]): void;
|
|
36
45
|
/**
|
|
37
46
|
* 清理消息数组中的旧快照消息,只保留最新的快照
|
|
38
47
|
* @param messages 消息数组
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare class PromptManager {
|
|
2
|
+
/** 固定系统提示词 */
|
|
3
|
+
private staticPrompt;
|
|
4
|
+
/** 元数据提示词 */
|
|
5
|
+
private skillMetaPrompt;
|
|
6
|
+
/** 临时系统提示词,比如: get-skill-content的返回值 */
|
|
7
|
+
private tempPrompt;
|
|
8
|
+
/** 返回全量的提示词 */
|
|
9
|
+
getSystemPrompt(): string;
|
|
10
|
+
/** 设置常驻提示词 */
|
|
11
|
+
setStatic(prompt: string): void;
|
|
12
|
+
/** 设置技能元数据提示词 */
|
|
13
|
+
setSkillMeta(prompt: string): void;
|
|
14
|
+
/** 设置临时值, 清除时传入空字符串即可,不再提供clearTemp */
|
|
15
|
+
setTemp(prompt: string): void;
|
|
16
|
+
/** 累增临时值,为多agent时预留 */
|
|
17
|
+
appendTemp(prompt: string): void;
|
|
18
|
+
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { Ref } from 'vue';
|
|
1
|
+
import { Ref, VNode } from 'vue';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* 消息角色 UI 配置 Composable
|
|
5
5
|
* 用于定义消息气泡的外观、头像、操作按钮等 UI 配置
|
|
6
6
|
*/
|
|
7
7
|
export declare function useMessageRoles(options: {
|
|
8
|
+
props: {
|
|
9
|
+
roleAvatar: {
|
|
10
|
+
user: VNode;
|
|
11
|
+
assistant: VNode;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
8
14
|
messages: Ref<any[]>;
|
|
9
15
|
messageState: any;
|
|
10
16
|
inputMessage: Ref<string>;
|
|
11
17
|
handleSendMessage: (inputValue: string, attachmentsContent?: any[]) => Promise<boolean>;
|
|
12
18
|
}): {
|
|
13
|
-
|
|
14
|
-
[key: string]: any;
|
|
15
|
-
}>;
|
|
16
|
-
userAvatar: import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
17
|
-
[key: string]: any;
|
|
18
|
-
}>;
|
|
19
|
-
welcomeIcon: import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
19
|
+
welcomeIcon: VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
20
20
|
[key: string]: any;
|
|
21
21
|
}>;
|
|
22
22
|
roles: {
|
|
23
23
|
assistant: {
|
|
24
24
|
type: string;
|
|
25
25
|
placement: string;
|
|
26
|
-
avatar:
|
|
26
|
+
avatar: VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
27
27
|
[key: string]: any;
|
|
28
28
|
}>;
|
|
29
29
|
maxWidth: string;
|
|
@@ -31,14 +31,14 @@ export declare function useMessageRoles(options: {
|
|
|
31
31
|
slots: {
|
|
32
32
|
footer: ({ index }: {
|
|
33
33
|
index: number;
|
|
34
|
-
}) => "" |
|
|
34
|
+
}) => "" | VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
35
35
|
[key: string]: any;
|
|
36
36
|
}>;
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
39
|
user: {
|
|
40
40
|
placement: string;
|
|
41
|
-
avatar:
|
|
41
|
+
avatar: VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
42
42
|
[key: string]: any;
|
|
43
43
|
}>;
|
|
44
44
|
maxWidth: string;
|
|
@@ -74,6 +74,13 @@ export declare function usePlugin(agent: any, enabledTools: Ref<Record<string, b
|
|
|
74
74
|
togglePlugin: (plugin: PluginInfo, enabled: boolean) => void;
|
|
75
75
|
toggleTool: (plugin: PluginInfo, toolId: string, enabled: boolean) => void;
|
|
76
76
|
deletePlugin: (plugin: PluginInfo) => Promise<void>;
|
|
77
|
+
addPluginCore: (config: {
|
|
78
|
+
pluginId: string;
|
|
79
|
+
name: string;
|
|
80
|
+
description: string;
|
|
81
|
+
icon?: string;
|
|
82
|
+
mcpServer: McpServerConfig;
|
|
83
|
+
}) => Promise<boolean>;
|
|
77
84
|
addPluginFromMarket: (plugin: PluginInfo) => Promise<void>;
|
|
78
85
|
addPluginFromScan: (sessionId: string, agentRoot: string) => Promise<boolean>;
|
|
79
86
|
handleClientDisconnected: (serverName: string) => Promise<{
|
|
@@ -4,8 +4,6 @@ import { SkillMeta } from '@opentiny/next-sdk';
|
|
|
4
4
|
export interface UseSkillWithToolsOptions {
|
|
5
5
|
/** 用户层传入的 skill .md 模块(key 路径,value 内容),由 next-sdk 处理;大模型通过 get_skill_content 自动识别并加载技能 */
|
|
6
6
|
skillsRef?: Ref<Record<string, string> | undefined>;
|
|
7
|
-
/** 基础系统提示词 */
|
|
8
|
-
systemPrompt: string;
|
|
9
7
|
/** CustomAgentModelProvider 实例,用于写 systemPrompt、合并 extraTools */
|
|
10
8
|
customAgentProvider: any;
|
|
11
9
|
}
|