@opentiny/next-remoter 0.2.2 → 0.2.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.
- package/README.md +839 -76
- package/dist/components/BubbleImageRenderer.vue.d.ts +15 -0
- package/dist/components/TinyRobotChat.vue.d.ts +303 -0
- package/dist/components/tokenUsage.vue.d.ts +46 -0
- package/dist/composable/CustomAgentModelProvider.d.ts +1 -23
- package/dist/composable/streamVisitor.d.ts +75 -0
- package/dist/composable/useConversationHistory.d.ts +24 -0
- package/dist/composable/useMessageRoles.d.ts +54 -0
- package/dist/composable/usePluginSession.d.ts +25 -0
- package/dist/composable/useSkill.d.ts +21 -22
- package/dist/multimodal/index.d.ts +6 -0
- package/dist/multimodal/useMultimodal.d.ts +210 -0
- package/dist/multimodal/utils.d.ts +23 -0
- package/dist/next-remoter-runtime.es.js +199151 -190389
- package/dist/next-remoter.cjs.js +49 -70
- package/dist/next-remoter.css +1 -1
- package/dist/next-remoter.es.js +14501 -13937
- package/dist/style.css +1 -1
- package/dist/types/model-config.d.ts +14 -0
- package/package.json +26 -7
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
2
|
+
content: string;
|
|
3
|
+
}>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
4
|
+
content: string;
|
|
5
|
+
}>>> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
6
|
+
export default _default;
|
|
7
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
8
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
9
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
10
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
11
|
+
} : {
|
|
12
|
+
type: import('vue').PropType<T[K]>;
|
|
13
|
+
required: true;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { TrSender, PluginInfo } from '@opentiny/tiny-robot';
|
|
2
|
+
import { STATUS } from '@opentiny/tiny-robot-kit';
|
|
3
|
+
import { Ref, ComponentInstance } from 'vue';
|
|
4
|
+
import { ICustomAgentModelProviderLlmConfig } from '../types/type';
|
|
5
|
+
import { MenuItemConfig, McpServerConfig } from '@opentiny/next-sdk';
|
|
6
|
+
import { UnifiedModelConfig } from '../types/model-config';
|
|
7
|
+
|
|
8
|
+
declare function __VLS_template(): Readonly<{
|
|
9
|
+
welcome(): any;
|
|
10
|
+
suggestions(): any;
|
|
11
|
+
operations(): any;
|
|
12
|
+
'header-actions'(): any;
|
|
13
|
+
}> & {
|
|
14
|
+
welcome(): any;
|
|
15
|
+
suggestions(): any;
|
|
16
|
+
operations(): any;
|
|
17
|
+
'header-actions'(): any;
|
|
18
|
+
};
|
|
19
|
+
declare const __VLS_component: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
20
|
+
fullscreen: import('vue').PropType<any>;
|
|
21
|
+
show: import('vue').PropType<any>;
|
|
22
|
+
selectedModelId: import('vue').PropType<any>;
|
|
23
|
+
genUiAble: import('vue').PropType<any>;
|
|
24
|
+
enabledTools: import('vue').PropType<any>;
|
|
25
|
+
/** 必传的会话id */
|
|
26
|
+
sessionId: {
|
|
27
|
+
type: StringConstructor;
|
|
28
|
+
default: string;
|
|
29
|
+
};
|
|
30
|
+
/** 后端的代理服务器地址 */
|
|
31
|
+
agentRoot: {
|
|
32
|
+
type: StringConstructor;
|
|
33
|
+
default: string;
|
|
34
|
+
};
|
|
35
|
+
/** 系统提示词 */
|
|
36
|
+
systemPrompt: {
|
|
37
|
+
type: StringConstructor;
|
|
38
|
+
default: string;
|
|
39
|
+
};
|
|
40
|
+
/** 左上角的标题 */
|
|
41
|
+
title: {
|
|
42
|
+
type: StringConstructor;
|
|
43
|
+
default: string;
|
|
44
|
+
};
|
|
45
|
+
/** 语言 en-US、zh-CN */
|
|
46
|
+
locale: {
|
|
47
|
+
type: StringConstructor;
|
|
48
|
+
default: string;
|
|
49
|
+
};
|
|
50
|
+
remoteUrl: {
|
|
51
|
+
type: StringConstructor;
|
|
52
|
+
};
|
|
53
|
+
menuItems: {
|
|
54
|
+
type: () => MenuItemConfig[];
|
|
55
|
+
};
|
|
56
|
+
qrCodeUrl: {
|
|
57
|
+
type: StringConstructor;
|
|
58
|
+
};
|
|
59
|
+
/** 悬浮AI图标的地址 */
|
|
60
|
+
AILogoUrl: {
|
|
61
|
+
type: StringConstructor;
|
|
62
|
+
};
|
|
63
|
+
/** 展示模式: 'remoter' | 'chat-dialog'
|
|
64
|
+
* 遥控器模式: 自动在右下角显示一个AI图标,点击展开多个菜单项。
|
|
65
|
+
* 对话框模式: 直接显示一个对话框界面
|
|
66
|
+
* */
|
|
67
|
+
mode: {
|
|
68
|
+
type: StringConstructor;
|
|
69
|
+
default: string;
|
|
70
|
+
};
|
|
71
|
+
/** 大语言模型配置对象 */
|
|
72
|
+
llmConfig: {
|
|
73
|
+
type: () => ICustomAgentModelProviderLlmConfig | undefined;
|
|
74
|
+
default: undefined;
|
|
75
|
+
};
|
|
76
|
+
/** 设置组件运行在普通页面还是浏览器的扩展中 */
|
|
77
|
+
inBrowserExt: {
|
|
78
|
+
type: BooleanConstructor;
|
|
79
|
+
default: boolean;
|
|
80
|
+
};
|
|
81
|
+
/** 生成式UI 需要引入的组件。生成式UI内置了一批组件,如果需要引入新组件,需要通过这里导入。
|
|
82
|
+
* 参考示例: shallowReactive({TinyUser, TinyAlert }) */
|
|
83
|
+
genUiComponents: {
|
|
84
|
+
type: ObjectConstructor;
|
|
85
|
+
default: () => {};
|
|
86
|
+
};
|
|
87
|
+
/** 自定义 MCP 市场服务列表一般是后台的mcp工具常驻存在 */
|
|
88
|
+
customMarketMcpServers: {
|
|
89
|
+
type: () => PluginInfo[];
|
|
90
|
+
default: () => never[];
|
|
91
|
+
};
|
|
92
|
+
/** MCP 服务器配置:业界格式 { "服务器名称": McpServerConfig },name 即对象的 key */
|
|
93
|
+
mcpServers: {
|
|
94
|
+
type: () => Record<string, McpServerConfig>;
|
|
95
|
+
default: undefined;
|
|
96
|
+
};
|
|
97
|
+
/** LLM 配置数组,每一项基于 llmConfig 格式,额外包含 id、label、icon、isDefault、useReActMode 字段 */
|
|
98
|
+
llmConfigs: {
|
|
99
|
+
type: () => UnifiedModelConfig[];
|
|
100
|
+
default: undefined;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* 用户层传入的 skill .md 模块(Record<path, content>,如 Vite import.meta.glob 得到的结果),
|
|
104
|
+
* 由 remoter 调用 next-sdk 的 skill 能力处理:生成 systemPrompt 技能说明、内置 get_skill_content 工具,大模型可自动识别并加载技能
|
|
105
|
+
*/
|
|
106
|
+
skills: {
|
|
107
|
+
type: () => Record<string, string>;
|
|
108
|
+
default: undefined;
|
|
109
|
+
};
|
|
110
|
+
/** 布局模式:支持所有 CSS position 属性值 'static' | 'relative' | 'absolute' | 'fixed' | 'sticky' */
|
|
111
|
+
layoutMode: {
|
|
112
|
+
type: () => "static" | "relative" | "absolute" | "fixed" | "sticky";
|
|
113
|
+
default: string;
|
|
114
|
+
};
|
|
115
|
+
}>, {
|
|
116
|
+
/** 大模型代理 */
|
|
117
|
+
agent: import('@opentiny/next-sdk').AgentModelProvider;
|
|
118
|
+
/** 欢迎图标 */
|
|
119
|
+
welcomeIcon: import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
120
|
+
[key: string]: any;
|
|
121
|
+
}>;
|
|
122
|
+
/** 对话消息 */
|
|
123
|
+
messages: Ref<import('@opentiny/tiny-robot-kit').ChatMessage[], import('@opentiny/tiny-robot-kit').ChatMessage[]>;
|
|
124
|
+
/** 对话消息状态 */
|
|
125
|
+
messageState: {
|
|
126
|
+
status: STATUS;
|
|
127
|
+
errorMsg: string | null;
|
|
128
|
+
};
|
|
129
|
+
/** 对话卡片的角色配置 */
|
|
130
|
+
roles: {
|
|
131
|
+
assistant: {
|
|
132
|
+
type: string;
|
|
133
|
+
placement: string;
|
|
134
|
+
avatar: import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
135
|
+
[key: string]: any;
|
|
136
|
+
}>;
|
|
137
|
+
maxWidth: string;
|
|
138
|
+
customContentField: string;
|
|
139
|
+
slots: {
|
|
140
|
+
footer: ({ index }: {
|
|
141
|
+
index: number;
|
|
142
|
+
}) => "" | import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
143
|
+
[key: string]: any;
|
|
144
|
+
}>;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
user: {
|
|
148
|
+
placement: string;
|
|
149
|
+
avatar: import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
150
|
+
[key: string]: any;
|
|
151
|
+
}>;
|
|
152
|
+
maxWidth: string;
|
|
153
|
+
customContentField: string;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
/** 输入框的文本 */
|
|
157
|
+
inputMessage: Ref<string, string>;
|
|
158
|
+
/** 输入框组件的实例 */
|
|
159
|
+
senderRef: Ref<ComponentInstance<typeof TrSender>>;
|
|
160
|
+
/** 取消发送 */
|
|
161
|
+
abortRequest: () => void;
|
|
162
|
+
/** 发送消息 */
|
|
163
|
+
sendMessage: (content?: import('@opentiny/tiny-robot-kit').ChatMessage["content"], clearInput?: boolean) => Promise<void>;
|
|
164
|
+
/** 向插件市场添加一个server */
|
|
165
|
+
loadMcpServerToPlugin: (serverName: string, mcpServer: McpServerConfig) => Promise<void>;
|
|
166
|
+
/** 处理客户端断开连接 */
|
|
167
|
+
handleClientDisconnected: (serverName: string) => Promise<{
|
|
168
|
+
id: string;
|
|
169
|
+
name: string;
|
|
170
|
+
icon: string;
|
|
171
|
+
description: string;
|
|
172
|
+
enabled: boolean;
|
|
173
|
+
expanded?: boolean | undefined;
|
|
174
|
+
tools: {
|
|
175
|
+
id: string;
|
|
176
|
+
name: string;
|
|
177
|
+
description: string;
|
|
178
|
+
enabled: boolean;
|
|
179
|
+
}[];
|
|
180
|
+
addState?: import('@opentiny/tiny-robot').PluginAddState | undefined;
|
|
181
|
+
category?: string | undefined;
|
|
182
|
+
} | null>;
|
|
183
|
+
/** 添加消息 */
|
|
184
|
+
addMessage: (message: import('@opentiny/tiny-robot-kit').ChatMessage | import('@opentiny/tiny-robot-kit').ChatMessage[]) => void;
|
|
185
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
186
|
+
fullscreen: import('vue').PropType<any>;
|
|
187
|
+
show: import('vue').PropType<any>;
|
|
188
|
+
selectedModelId: import('vue').PropType<any>;
|
|
189
|
+
genUiAble: import('vue').PropType<any>;
|
|
190
|
+
enabledTools: import('vue').PropType<any>;
|
|
191
|
+
/** 必传的会话id */
|
|
192
|
+
sessionId: {
|
|
193
|
+
type: StringConstructor;
|
|
194
|
+
default: string;
|
|
195
|
+
};
|
|
196
|
+
/** 后端的代理服务器地址 */
|
|
197
|
+
agentRoot: {
|
|
198
|
+
type: StringConstructor;
|
|
199
|
+
default: string;
|
|
200
|
+
};
|
|
201
|
+
/** 系统提示词 */
|
|
202
|
+
systemPrompt: {
|
|
203
|
+
type: StringConstructor;
|
|
204
|
+
default: string;
|
|
205
|
+
};
|
|
206
|
+
/** 左上角的标题 */
|
|
207
|
+
title: {
|
|
208
|
+
type: StringConstructor;
|
|
209
|
+
default: string;
|
|
210
|
+
};
|
|
211
|
+
/** 语言 en-US、zh-CN */
|
|
212
|
+
locale: {
|
|
213
|
+
type: StringConstructor;
|
|
214
|
+
default: string;
|
|
215
|
+
};
|
|
216
|
+
remoteUrl: {
|
|
217
|
+
type: StringConstructor;
|
|
218
|
+
};
|
|
219
|
+
menuItems: {
|
|
220
|
+
type: () => MenuItemConfig[];
|
|
221
|
+
};
|
|
222
|
+
qrCodeUrl: {
|
|
223
|
+
type: StringConstructor;
|
|
224
|
+
};
|
|
225
|
+
/** 悬浮AI图标的地址 */
|
|
226
|
+
AILogoUrl: {
|
|
227
|
+
type: StringConstructor;
|
|
228
|
+
};
|
|
229
|
+
/** 展示模式: 'remoter' | 'chat-dialog'
|
|
230
|
+
* 遥控器模式: 自动在右下角显示一个AI图标,点击展开多个菜单项。
|
|
231
|
+
* 对话框模式: 直接显示一个对话框界面
|
|
232
|
+
* */
|
|
233
|
+
mode: {
|
|
234
|
+
type: StringConstructor;
|
|
235
|
+
default: string;
|
|
236
|
+
};
|
|
237
|
+
/** 大语言模型配置对象 */
|
|
238
|
+
llmConfig: {
|
|
239
|
+
type: () => ICustomAgentModelProviderLlmConfig | undefined;
|
|
240
|
+
default: undefined;
|
|
241
|
+
};
|
|
242
|
+
/** 设置组件运行在普通页面还是浏览器的扩展中 */
|
|
243
|
+
inBrowserExt: {
|
|
244
|
+
type: BooleanConstructor;
|
|
245
|
+
default: boolean;
|
|
246
|
+
};
|
|
247
|
+
/** 生成式UI 需要引入的组件。生成式UI内置了一批组件,如果需要引入新组件,需要通过这里导入。
|
|
248
|
+
* 参考示例: shallowReactive({TinyUser, TinyAlert }) */
|
|
249
|
+
genUiComponents: {
|
|
250
|
+
type: ObjectConstructor;
|
|
251
|
+
default: () => {};
|
|
252
|
+
};
|
|
253
|
+
/** 自定义 MCP 市场服务列表一般是后台的mcp工具常驻存在 */
|
|
254
|
+
customMarketMcpServers: {
|
|
255
|
+
type: () => PluginInfo[];
|
|
256
|
+
default: () => never[];
|
|
257
|
+
};
|
|
258
|
+
/** MCP 服务器配置:业界格式 { "服务器名称": McpServerConfig },name 即对象的 key */
|
|
259
|
+
mcpServers: {
|
|
260
|
+
type: () => Record<string, McpServerConfig>;
|
|
261
|
+
default: undefined;
|
|
262
|
+
};
|
|
263
|
+
/** LLM 配置数组,每一项基于 llmConfig 格式,额外包含 id、label、icon、isDefault、useReActMode 字段 */
|
|
264
|
+
llmConfigs: {
|
|
265
|
+
type: () => UnifiedModelConfig[];
|
|
266
|
+
default: undefined;
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* 用户层传入的 skill .md 模块(Record<path, content>,如 Vite import.meta.glob 得到的结果),
|
|
270
|
+
* 由 remoter 调用 next-sdk 的 skill 能力处理:生成 systemPrompt 技能说明、内置 get_skill_content 工具,大模型可自动识别并加载技能
|
|
271
|
+
*/
|
|
272
|
+
skills: {
|
|
273
|
+
type: () => Record<string, string>;
|
|
274
|
+
default: undefined;
|
|
275
|
+
};
|
|
276
|
+
/** 布局模式:支持所有 CSS position 属性值 'static' | 'relative' | 'absolute' | 'fixed' | 'sticky' */
|
|
277
|
+
layoutMode: {
|
|
278
|
+
type: () => "static" | "relative" | "absolute" | "fixed" | "sticky";
|
|
279
|
+
default: string;
|
|
280
|
+
};
|
|
281
|
+
}>> & Readonly<{}>, {
|
|
282
|
+
title: string;
|
|
283
|
+
systemPrompt: string;
|
|
284
|
+
mode: string;
|
|
285
|
+
sessionId: string;
|
|
286
|
+
llmConfig: ICustomAgentModelProviderLlmConfig | undefined;
|
|
287
|
+
mcpServers: Record<string, McpServerConfig>;
|
|
288
|
+
agentRoot: string;
|
|
289
|
+
locale: string;
|
|
290
|
+
inBrowserExt: boolean;
|
|
291
|
+
genUiComponents: Record<string, any>;
|
|
292
|
+
customMarketMcpServers: PluginInfo[];
|
|
293
|
+
llmConfigs: UnifiedModelConfig[];
|
|
294
|
+
skills: Record<string, string>;
|
|
295
|
+
layoutMode: "absolute" | "fixed" | "static" | "relative" | "sticky";
|
|
296
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
297
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
298
|
+
export default _default;
|
|
299
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
300
|
+
new (): {
|
|
301
|
+
$slots: S;
|
|
302
|
+
};
|
|
303
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { PropType } from 'vue';
|
|
2
|
+
|
|
3
|
+
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
4
|
+
usage: {
|
|
5
|
+
type: PropType<{
|
|
6
|
+
inputTokens: number;
|
|
7
|
+
outputTokens: number;
|
|
8
|
+
totalTokens: number;
|
|
9
|
+
inputTokenDetails?: {
|
|
10
|
+
cacheReadTokens?: number;
|
|
11
|
+
};
|
|
12
|
+
outputTokenDetails?: {
|
|
13
|
+
reasoningTokens?: number;
|
|
14
|
+
};
|
|
15
|
+
}>;
|
|
16
|
+
default: string;
|
|
17
|
+
};
|
|
18
|
+
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
19
|
+
usage: {
|
|
20
|
+
type: PropType<{
|
|
21
|
+
inputTokens: number;
|
|
22
|
+
outputTokens: number;
|
|
23
|
+
totalTokens: number;
|
|
24
|
+
inputTokenDetails?: {
|
|
25
|
+
cacheReadTokens?: number;
|
|
26
|
+
};
|
|
27
|
+
outputTokenDetails?: {
|
|
28
|
+
reasoningTokens?: number;
|
|
29
|
+
};
|
|
30
|
+
}>;
|
|
31
|
+
default: string;
|
|
32
|
+
};
|
|
33
|
+
}>> & Readonly<{}>, {
|
|
34
|
+
usage: {
|
|
35
|
+
inputTokens: number;
|
|
36
|
+
outputTokens: number;
|
|
37
|
+
totalTokens: number;
|
|
38
|
+
inputTokenDetails?: {
|
|
39
|
+
cacheReadTokens?: number;
|
|
40
|
+
};
|
|
41
|
+
outputTokenDetails?: {
|
|
42
|
+
reasoningTokens?: number;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
46
|
+
export default _default;
|
|
@@ -13,7 +13,7 @@ export declare class CustomAgentModelProvider extends BaseModelProvider {
|
|
|
13
13
|
llmConfig: ICustomAgentModelProviderLlmConfig;
|
|
14
14
|
/** 生成式UI启用状态 */
|
|
15
15
|
isGenuiEnabled?: Ref<boolean>;
|
|
16
|
-
constructor(config: AIModelConfig,
|
|
16
|
+
constructor(config: AIModelConfig, systemPrompt: string, llmConfig?: ICustomAgentModelProviderLlmConfig);
|
|
17
17
|
/**
|
|
18
18
|
* 更新大语言模型配置
|
|
19
19
|
* Update LLM configuration
|
|
@@ -31,28 +31,6 @@ export declare class CustomAgentModelProvider extends BaseModelProvider {
|
|
|
31
31
|
useReActMode?: boolean;
|
|
32
32
|
llm?: ProviderV2;
|
|
33
33
|
}): void;
|
|
34
|
-
/**
|
|
35
|
-
* 处理文本流数据
|
|
36
|
-
* @param part 流数据部分
|
|
37
|
-
* @param handler 流处理器
|
|
38
|
-
* @param textId 文本ID
|
|
39
|
-
* @returns 更新后的文本ID
|
|
40
|
-
*/
|
|
41
|
-
private handleTextStream;
|
|
42
|
-
/**
|
|
43
|
-
* 处理工具流数据
|
|
44
|
-
* @param part 流数据部分
|
|
45
|
-
* @param handler 流处理器
|
|
46
|
-
*/
|
|
47
|
-
private handleToolStream;
|
|
48
|
-
/**
|
|
49
|
-
* 处理文本流数据
|
|
50
|
-
* @param part 流数据部分
|
|
51
|
-
* @param handler 流处理器
|
|
52
|
-
* @param textId 文本ID
|
|
53
|
-
* @returns 更新后的文本ID
|
|
54
|
-
*/
|
|
55
|
-
private handleReasonStream;
|
|
56
34
|
/**
|
|
57
35
|
* 清理消息数组中的旧快照消息,只保留最新的快照
|
|
58
36
|
* @param messages 消息数组
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { FinishReason, LanguageModelRequestMetadata, LanguageModelUsage, StreamTextResult } from 'ai';
|
|
2
|
+
|
|
3
|
+
export interface StreamVisitorOption {
|
|
4
|
+
debug?: boolean;
|
|
5
|
+
onStart?: (content: StartContent) => void;
|
|
6
|
+
onStep?: (content: StepContent) => void;
|
|
7
|
+
onReasoning?: (content: ReasoningContent) => void;
|
|
8
|
+
onText?: (content: TextContent) => void;
|
|
9
|
+
onTool?: (content: ToolContent) => void;
|
|
10
|
+
onFinish?: () => void;
|
|
11
|
+
}
|
|
12
|
+
export interface StartContent {
|
|
13
|
+
running: boolean;
|
|
14
|
+
steps: StepContent[];
|
|
15
|
+
finishReason?: FinishReason;
|
|
16
|
+
totalUsage?: LanguageModelUsage;
|
|
17
|
+
/** 工具内部异常的错误信息 */
|
|
18
|
+
error?: any;
|
|
19
|
+
}
|
|
20
|
+
export interface StepContent {
|
|
21
|
+
running: boolean;
|
|
22
|
+
contents: (TextContent | ReasoningContent | ToolContent)[];
|
|
23
|
+
finishReason?: FinishReason;
|
|
24
|
+
/** 本轮对话的消耗 */
|
|
25
|
+
usage?: LanguageModelUsage;
|
|
26
|
+
/** 包含本轮对话的请求体 */
|
|
27
|
+
request: LanguageModelRequestMetadata;
|
|
28
|
+
}
|
|
29
|
+
export interface TextContent {
|
|
30
|
+
type: 'text';
|
|
31
|
+
id: string;
|
|
32
|
+
running: boolean;
|
|
33
|
+
text: string;
|
|
34
|
+
}
|
|
35
|
+
export interface ReasoningContent {
|
|
36
|
+
type: 'reasoning';
|
|
37
|
+
id: string;
|
|
38
|
+
running: boolean;
|
|
39
|
+
text: string;
|
|
40
|
+
}
|
|
41
|
+
export interface ToolContent {
|
|
42
|
+
type: 'tool';
|
|
43
|
+
id: string;
|
|
44
|
+
running: boolean;
|
|
45
|
+
toolCallId: string;
|
|
46
|
+
title: string;
|
|
47
|
+
toolName: string;
|
|
48
|
+
/** 不确定输入参数的工具调用 */
|
|
49
|
+
dynamic: boolean | undefined;
|
|
50
|
+
/** 生成tool 调用参数的动态字符串, 在调用 tool 之前,会保存json结果到input属性中 */
|
|
51
|
+
inputStr: string;
|
|
52
|
+
/** 工具参数对象 */
|
|
53
|
+
input: any;
|
|
54
|
+
/** 工具返回值对象 */
|
|
55
|
+
output: any;
|
|
56
|
+
/** 工具内部异常的错误信息 */
|
|
57
|
+
error?: any;
|
|
58
|
+
}
|
|
59
|
+
/** ai-sdk@v6 的流消息访问者, 暴露响应式的数据,它随着流消息到来逐渐的变化
|
|
60
|
+
* @example
|
|
61
|
+
* const stream = await toolLoopAgent.stream({prompt:'xxxx'})
|
|
62
|
+
* const visitor= new StreamVisitor({
|
|
63
|
+
* onStart(content){
|
|
64
|
+
* -- 保存这个content
|
|
65
|
+
* }
|
|
66
|
+
* })
|
|
67
|
+
*
|
|
68
|
+
* await visitor.traverse(stream)
|
|
69
|
+
* const result = await visitor.traverse(stream) // 或者保存此处的 result 的Ref响应数据
|
|
70
|
+
*/
|
|
71
|
+
export declare class StreamVisitor {
|
|
72
|
+
option: StreamVisitorOption;
|
|
73
|
+
constructor(option?: StreamVisitorOption);
|
|
74
|
+
traverse(stream: StreamTextResult<{}, never>): Promise<import('vue').Ref<StartContent | undefined, StartContent | undefined>>;
|
|
75
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 会话历史管理 Composable
|
|
3
|
+
* 用于管理历史会话的创建、切换、更新、删除等操作
|
|
4
|
+
*/
|
|
5
|
+
export declare function useConversationHistory(options: {
|
|
6
|
+
createConversation: () => void;
|
|
7
|
+
switchConversation: (id: string) => void;
|
|
8
|
+
deleteConversation: (id: string) => void;
|
|
9
|
+
getCurrentConversation: () => any;
|
|
10
|
+
abortRequest: () => void;
|
|
11
|
+
conversationState: any;
|
|
12
|
+
customAgentProvider: any;
|
|
13
|
+
}): {
|
|
14
|
+
showHistory: import('vue').Ref<boolean, boolean>;
|
|
15
|
+
handleCreateConversation: () => void;
|
|
16
|
+
handleHistorySelect: (item: {
|
|
17
|
+
id: string;
|
|
18
|
+
}) => void;
|
|
19
|
+
handleHistoryUpdateTitle: (title: string, item: any) => void;
|
|
20
|
+
handleHistoryDelete: (action: any, item: {
|
|
21
|
+
id: string;
|
|
22
|
+
}) => void;
|
|
23
|
+
scrollToBottom: () => void;
|
|
24
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 消息角色 UI 配置 Composable
|
|
5
|
+
* 用于定义消息气泡的外观、头像、操作按钮等 UI 配置
|
|
6
|
+
*/
|
|
7
|
+
export declare function useMessageRoles(options: {
|
|
8
|
+
messages: Ref<any[]>;
|
|
9
|
+
messageState: any;
|
|
10
|
+
inputMessage: Ref<string>;
|
|
11
|
+
handleSendMessage: (inputValue: string, attachmentsContent?: any[]) => Promise<boolean>;
|
|
12
|
+
}): {
|
|
13
|
+
aiAvatar: import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
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, {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}>;
|
|
22
|
+
roles: {
|
|
23
|
+
assistant: {
|
|
24
|
+
type: string;
|
|
25
|
+
placement: string;
|
|
26
|
+
avatar: import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
}>;
|
|
29
|
+
maxWidth: string;
|
|
30
|
+
customContentField: string;
|
|
31
|
+
slots: {
|
|
32
|
+
footer: ({ index }: {
|
|
33
|
+
index: number;
|
|
34
|
+
}) => "" | import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
}>;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
user: {
|
|
40
|
+
placement: string;
|
|
41
|
+
avatar: import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
}>;
|
|
44
|
+
maxWidth: string;
|
|
45
|
+
customContentField: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
copyingStates: Ref<Record<string, boolean>, Record<string, boolean>>;
|
|
49
|
+
isProcessing: import('vue').ComputedRef<boolean>;
|
|
50
|
+
latestAssistantMessageIndex: import('vue').ComputedRef<any>;
|
|
51
|
+
copyTooltipContent: (messageIndex?: number) => "复制" | "复制成功";
|
|
52
|
+
copyMessageToClipboard: (index: number) => Promise<void>;
|
|
53
|
+
regenerateMessage: (index: number) => Promise<void>;
|
|
54
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { MenuItemConfig } from '@opentiny/next-sdk';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 插件会话管理 Composable
|
|
6
|
+
* 用于处理 sessionId 相关的所有逻辑:扫码添加插件、识别码输入、遥控器初始化等
|
|
7
|
+
*/
|
|
8
|
+
export declare function usePluginSession(options: {
|
|
9
|
+
sessionId: Ref<string>;
|
|
10
|
+
agentRoot: string;
|
|
11
|
+
mode: string;
|
|
12
|
+
qrCodeUrl?: string;
|
|
13
|
+
remoteUrl?: string;
|
|
14
|
+
menuItems?: MenuItemConfig[];
|
|
15
|
+
AILogoUrl?: string;
|
|
16
|
+
show: Ref<boolean>;
|
|
17
|
+
addPluginFromScan: (sessionId: string, agentRoot: string) => Promise<boolean>;
|
|
18
|
+
inputMessage: Ref<string>;
|
|
19
|
+
}): {
|
|
20
|
+
handleScanSuccess: (sessionIdValue: string) => Promise<void>;
|
|
21
|
+
handleSessionIdInput: (input: string) => Promise<boolean>;
|
|
22
|
+
initialize: () => void;
|
|
23
|
+
initializeRemoter: () => void;
|
|
24
|
+
watchSessionIdChanges: () => void;
|
|
25
|
+
};
|
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { SkillMeta } from '@opentiny/next-sdk';
|
|
2
3
|
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
export interface UseSkillWithToolsOptions {
|
|
5
|
+
/** 用户层传入的 skill .md 模块(key 路径,value 内容),由 next-sdk 处理;大模型通过 get_skill_content 自动识别并加载技能 */
|
|
6
|
+
skillsRef?: Ref<Record<string, string> | undefined>;
|
|
7
|
+
/** 基础系统提示词 */
|
|
8
|
+
systemPrompt: string;
|
|
9
|
+
/** CustomAgentModelProvider 实例,用于写 systemPrompt、合并 extraTools */
|
|
10
|
+
customAgentProvider: any;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Skills 与工具组合 Composable(仅最新方案)
|
|
14
|
+
* 基于 skills + next-sdk:拼入 systemPrompt 技能说明、注入 get_skill_content 工具,无 @ 提及
|
|
15
|
+
*/
|
|
16
|
+
export declare function useSkillWithTools(options: UseSkillWithToolsOptions): {
|
|
17
|
+
processSkillMentions: () => Promise<{
|
|
18
|
+
shouldBlock: boolean;
|
|
19
|
+
skillItems: never[];
|
|
15
20
|
}>;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
top: number;
|
|
20
|
-
left: number;
|
|
21
|
-
}) => void;
|
|
22
|
-
selectSkill: (skill: SkillOption) => void;
|
|
23
|
-
closeSkillSelector: () => void;
|
|
24
|
-
handleKeyDown: (e: KeyboardEvent) => void;
|
|
21
|
+
skillPromptPart: import('vue').ComputedRef<string>;
|
|
22
|
+
skillTools: import('vue').ComputedRef<import('@opentiny/next-sdk').SkillToolsSet>;
|
|
23
|
+
skillOverviews: import('vue').ComputedRef<SkillMeta[]>;
|
|
25
24
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 多模态消息功能导出
|
|
3
|
+
*/
|
|
4
|
+
export { useMultimodal, useMultimodalWithModel, convertAttachmentsToContent } from './useMultimodal';
|
|
5
|
+
export type { MultimodalConfig, MultimodalOptionsWithModel } from './useMultimodal';
|
|
6
|
+
export { fileToBase64, isImageFile, validateFileSize } from './utils';
|