@opentiny/next-remoter 0.2.3 → 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/dist/components/BubbleImageRenderer.vue.d.ts +15 -0
- package/dist/components/TinyRobotChat.vue.d.ts +48 -11
- package/dist/components/tokenUsage.vue.d.ts +18 -6
- package/dist/composable/CustomAgentModelProvider.d.ts +0 -22
- 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 +245188 -236604
- package/dist/next-remoter.cjs.js +49 -71
- package/dist/next-remoter.css +1 -1
- package/dist/next-remoter.es.js +14541 -14077
- package/dist/style.css +1 -1
- package/dist/types/model-config.d.ts +14 -0
- package/package.json +9 -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
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { TrSender, PluginInfo
|
|
1
|
+
import { TrSender, PluginInfo } from '@opentiny/tiny-robot';
|
|
2
2
|
import { STATUS } from '@opentiny/tiny-robot-kit';
|
|
3
3
|
import { Ref, ComponentInstance } from 'vue';
|
|
4
4
|
import { ICustomAgentModelProviderLlmConfig } from '../types/type';
|
|
5
|
-
import { MenuItemConfig } from '@opentiny/next-sdk';
|
|
5
|
+
import { MenuItemConfig, McpServerConfig } from '@opentiny/next-sdk';
|
|
6
6
|
import { UnifiedModelConfig } from '../types/model-config';
|
|
7
7
|
|
|
8
8
|
declare function __VLS_template(): Readonly<{
|
|
@@ -84,19 +84,28 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
84
84
|
type: ObjectConstructor;
|
|
85
85
|
default: () => {};
|
|
86
86
|
};
|
|
87
|
-
/** 自定义 MCP
|
|
87
|
+
/** 自定义 MCP 市场服务列表一般是后台的mcp工具常驻存在 */
|
|
88
88
|
customMarketMcpServers: {
|
|
89
89
|
type: () => PluginInfo[];
|
|
90
90
|
default: () => never[];
|
|
91
91
|
};
|
|
92
|
+
/** MCP 服务器配置:业界格式 { "服务器名称": McpServerConfig },name 即对象的 key */
|
|
93
|
+
mcpServers: {
|
|
94
|
+
type: () => Record<string, McpServerConfig>;
|
|
95
|
+
default: undefined;
|
|
96
|
+
};
|
|
92
97
|
/** LLM 配置数组,每一项基于 llmConfig 格式,额外包含 id、label、icon、isDefault、useReActMode 字段 */
|
|
93
98
|
llmConfigs: {
|
|
94
99
|
type: () => UnifiedModelConfig[];
|
|
95
100
|
default: undefined;
|
|
96
101
|
};
|
|
102
|
+
/**
|
|
103
|
+
* 用户层传入的 skill .md 模块(Record<path, content>,如 Vite import.meta.glob 得到的结果),
|
|
104
|
+
* 由 remoter 调用 next-sdk 的 skill 能力处理:生成 systemPrompt 技能说明、内置 get_skill_content 工具,大模型可自动识别并加载技能
|
|
105
|
+
*/
|
|
97
106
|
skills: {
|
|
98
|
-
type: () =>
|
|
99
|
-
default:
|
|
107
|
+
type: () => Record<string, string>;
|
|
108
|
+
default: undefined;
|
|
100
109
|
};
|
|
101
110
|
/** 布局模式:支持所有 CSS position 属性值 'static' | 'relative' | 'absolute' | 'fixed' | 'sticky' */
|
|
102
111
|
layoutMode: {
|
|
@@ -129,7 +138,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
129
138
|
customContentField: string;
|
|
130
139
|
slots: {
|
|
131
140
|
footer: ({ index }: {
|
|
132
|
-
index:
|
|
141
|
+
index: number;
|
|
133
142
|
}) => "" | import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
134
143
|
[key: string]: any;
|
|
135
144
|
}>;
|
|
@@ -141,6 +150,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
141
150
|
[key: string]: any;
|
|
142
151
|
}>;
|
|
143
152
|
maxWidth: string;
|
|
153
|
+
customContentField: string;
|
|
144
154
|
};
|
|
145
155
|
};
|
|
146
156
|
/** 输入框的文本 */
|
|
@@ -152,7 +162,24 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
152
162
|
/** 发送消息 */
|
|
153
163
|
sendMessage: (content?: import('@opentiny/tiny-robot-kit').ChatMessage["content"], clearInput?: boolean) => Promise<void>;
|
|
154
164
|
/** 向插件市场添加一个server */
|
|
155
|
-
loadMcpServerToPlugin: (serverName: string, mcpServer:
|
|
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>;
|
|
156
183
|
/** 添加消息 */
|
|
157
184
|
addMessage: (message: import('@opentiny/tiny-robot-kit').ChatMessage | import('@opentiny/tiny-robot-kit').ChatMessage[]) => void;
|
|
158
185
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
@@ -223,19 +250,28 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
223
250
|
type: ObjectConstructor;
|
|
224
251
|
default: () => {};
|
|
225
252
|
};
|
|
226
|
-
/** 自定义 MCP
|
|
253
|
+
/** 自定义 MCP 市场服务列表一般是后台的mcp工具常驻存在 */
|
|
227
254
|
customMarketMcpServers: {
|
|
228
255
|
type: () => PluginInfo[];
|
|
229
256
|
default: () => never[];
|
|
230
257
|
};
|
|
258
|
+
/** MCP 服务器配置:业界格式 { "服务器名称": McpServerConfig },name 即对象的 key */
|
|
259
|
+
mcpServers: {
|
|
260
|
+
type: () => Record<string, McpServerConfig>;
|
|
261
|
+
default: undefined;
|
|
262
|
+
};
|
|
231
263
|
/** LLM 配置数组,每一项基于 llmConfig 格式,额外包含 id、label、icon、isDefault、useReActMode 字段 */
|
|
232
264
|
llmConfigs: {
|
|
233
265
|
type: () => UnifiedModelConfig[];
|
|
234
266
|
default: undefined;
|
|
235
267
|
};
|
|
268
|
+
/**
|
|
269
|
+
* 用户层传入的 skill .md 模块(Record<path, content>,如 Vite import.meta.glob 得到的结果),
|
|
270
|
+
* 由 remoter 调用 next-sdk 的 skill 能力处理:生成 systemPrompt 技能说明、内置 get_skill_content 工具,大模型可自动识别并加载技能
|
|
271
|
+
*/
|
|
236
272
|
skills: {
|
|
237
|
-
type: () =>
|
|
238
|
-
default:
|
|
273
|
+
type: () => Record<string, string>;
|
|
274
|
+
default: undefined;
|
|
239
275
|
};
|
|
240
276
|
/** 布局模式:支持所有 CSS position 属性值 'static' | 'relative' | 'absolute' | 'fixed' | 'sticky' */
|
|
241
277
|
layoutMode: {
|
|
@@ -248,13 +284,14 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
248
284
|
mode: string;
|
|
249
285
|
sessionId: string;
|
|
250
286
|
llmConfig: ICustomAgentModelProviderLlmConfig | undefined;
|
|
287
|
+
mcpServers: Record<string, McpServerConfig>;
|
|
251
288
|
agentRoot: string;
|
|
252
|
-
skills: MentionItem[];
|
|
253
289
|
locale: string;
|
|
254
290
|
inBrowserExt: boolean;
|
|
255
291
|
genUiComponents: Record<string, any>;
|
|
256
292
|
customMarketMcpServers: PluginInfo[];
|
|
257
293
|
llmConfigs: UnifiedModelConfig[];
|
|
294
|
+
skills: Record<string, string>;
|
|
258
295
|
layoutMode: "absolute" | "fixed" | "static" | "relative" | "sticky";
|
|
259
296
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
260
297
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
@@ -3,32 +3,44 @@ import { PropType } from 'vue';
|
|
|
3
3
|
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
4
4
|
usage: {
|
|
5
5
|
type: PropType<{
|
|
6
|
-
cachedInputTokens: number;
|
|
7
6
|
inputTokens: number;
|
|
8
|
-
reasoningTokens: number;
|
|
9
7
|
outputTokens: number;
|
|
10
8
|
totalTokens: number;
|
|
9
|
+
inputTokenDetails?: {
|
|
10
|
+
cacheReadTokens?: number;
|
|
11
|
+
};
|
|
12
|
+
outputTokenDetails?: {
|
|
13
|
+
reasoningTokens?: number;
|
|
14
|
+
};
|
|
11
15
|
}>;
|
|
12
16
|
default: string;
|
|
13
17
|
};
|
|
14
18
|
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
15
19
|
usage: {
|
|
16
20
|
type: PropType<{
|
|
17
|
-
cachedInputTokens: number;
|
|
18
21
|
inputTokens: number;
|
|
19
|
-
reasoningTokens: number;
|
|
20
22
|
outputTokens: number;
|
|
21
23
|
totalTokens: number;
|
|
24
|
+
inputTokenDetails?: {
|
|
25
|
+
cacheReadTokens?: number;
|
|
26
|
+
};
|
|
27
|
+
outputTokenDetails?: {
|
|
28
|
+
reasoningTokens?: number;
|
|
29
|
+
};
|
|
22
30
|
}>;
|
|
23
31
|
default: string;
|
|
24
32
|
};
|
|
25
33
|
}>> & Readonly<{}>, {
|
|
26
34
|
usage: {
|
|
27
|
-
cachedInputTokens: number;
|
|
28
35
|
inputTokens: number;
|
|
29
|
-
reasoningTokens: number;
|
|
30
36
|
outputTokens: number;
|
|
31
37
|
totalTokens: number;
|
|
38
|
+
inputTokenDetails?: {
|
|
39
|
+
cacheReadTokens?: number;
|
|
40
|
+
};
|
|
41
|
+
outputTokenDetails?: {
|
|
42
|
+
reasoningTokens?: number;
|
|
43
|
+
};
|
|
32
44
|
};
|
|
33
45
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
34
46
|
export default _default;
|
|
@@ -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';
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { ComputedRef, Ref } from 'vue';
|
|
2
|
+
import { Attachment } from '@opentiny/tiny-robot';
|
|
3
|
+
import { UnifiedModelConfig } from '../types/model-config';
|
|
4
|
+
|
|
5
|
+
export interface MultimodalConfig {
|
|
6
|
+
/** 最大文件大小(MB) - 支持响应式 */
|
|
7
|
+
maxFileSize?: number | ComputedRef<number>;
|
|
8
|
+
/** 支持的文件类型(MIME类型前缀,如 'image/') - 支持响应式 */
|
|
9
|
+
supportedTypes?: string[] | ComputedRef<string[]>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 多模态配置(完整版本,支持模型感知)
|
|
13
|
+
*/
|
|
14
|
+
export interface MultimodalOptionsWithModel {
|
|
15
|
+
/** 当前选中的模型 */
|
|
16
|
+
selectedModel: Ref<UnifiedModelConfig | undefined>;
|
|
17
|
+
/** 当前选中的模型 ID */
|
|
18
|
+
selectedModelId: Ref<string | undefined>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 将附件转换为多模态消息内容(AI SDK 格式)
|
|
22
|
+
* @param attachments 附件列表
|
|
23
|
+
* @returns Promise<Array> 多模态消息内容数组
|
|
24
|
+
*/
|
|
25
|
+
export declare function convertAttachmentsToContent(attachments: Attachment[]): Promise<any[]>;
|
|
26
|
+
/**
|
|
27
|
+
* 多模态消息 Composable(基础版本)
|
|
28
|
+
* 适用于不需要模型感知的场景
|
|
29
|
+
*/
|
|
30
|
+
export declare function useMultimodal(config?: MultimodalConfig): {
|
|
31
|
+
attachments: Ref<({
|
|
32
|
+
url: string;
|
|
33
|
+
size: number;
|
|
34
|
+
rawFile?: {
|
|
35
|
+
readonly lastModified: number;
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly webkitRelativePath: string;
|
|
38
|
+
readonly size: number;
|
|
39
|
+
readonly type: string;
|
|
40
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
41
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
42
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
43
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
44
|
+
text: () => Promise<string>;
|
|
45
|
+
} | undefined;
|
|
46
|
+
id?: string | undefined;
|
|
47
|
+
name?: string | undefined;
|
|
48
|
+
status?: import('@opentiny/tiny-robot').FileStatus | undefined;
|
|
49
|
+
fileType?: import('@opentiny/tiny-robot').FileType | undefined;
|
|
50
|
+
message?: string | undefined;
|
|
51
|
+
} | {
|
|
52
|
+
rawFile: {
|
|
53
|
+
readonly lastModified: number;
|
|
54
|
+
readonly name: string;
|
|
55
|
+
readonly webkitRelativePath: string;
|
|
56
|
+
readonly size: number;
|
|
57
|
+
readonly type: string;
|
|
58
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
59
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
60
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
61
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
62
|
+
text: () => Promise<string>;
|
|
63
|
+
};
|
|
64
|
+
url?: string | undefined;
|
|
65
|
+
size?: number | undefined;
|
|
66
|
+
id?: string | undefined;
|
|
67
|
+
name?: string | undefined;
|
|
68
|
+
status?: import('@opentiny/tiny-robot').FileStatus | undefined;
|
|
69
|
+
fileType?: import('@opentiny/tiny-robot').FileType | undefined;
|
|
70
|
+
message?: string | undefined;
|
|
71
|
+
})[], Attachment[] | ({
|
|
72
|
+
url: string;
|
|
73
|
+
size: number;
|
|
74
|
+
rawFile?: {
|
|
75
|
+
readonly lastModified: number;
|
|
76
|
+
readonly name: string;
|
|
77
|
+
readonly webkitRelativePath: string;
|
|
78
|
+
readonly size: number;
|
|
79
|
+
readonly type: string;
|
|
80
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
81
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
82
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
83
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
84
|
+
text: () => Promise<string>;
|
|
85
|
+
} | undefined;
|
|
86
|
+
id?: string | undefined;
|
|
87
|
+
name?: string | undefined;
|
|
88
|
+
status?: import('@opentiny/tiny-robot').FileStatus | undefined;
|
|
89
|
+
fileType?: import('@opentiny/tiny-robot').FileType | undefined;
|
|
90
|
+
message?: string | undefined;
|
|
91
|
+
} | {
|
|
92
|
+
rawFile: {
|
|
93
|
+
readonly lastModified: number;
|
|
94
|
+
readonly name: string;
|
|
95
|
+
readonly webkitRelativePath: string;
|
|
96
|
+
readonly size: number;
|
|
97
|
+
readonly type: string;
|
|
98
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
99
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
100
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
101
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
102
|
+
text: () => Promise<string>;
|
|
103
|
+
};
|
|
104
|
+
url?: string | undefined;
|
|
105
|
+
size?: number | undefined;
|
|
106
|
+
id?: string | undefined;
|
|
107
|
+
name?: string | undefined;
|
|
108
|
+
status?: import('@opentiny/tiny-robot').FileStatus | undefined;
|
|
109
|
+
fileType?: import('@opentiny/tiny-robot').FileType | undefined;
|
|
110
|
+
message?: string | undefined;
|
|
111
|
+
})[]>;
|
|
112
|
+
handleFilesSelected: (files: File[]) => Promise<void>;
|
|
113
|
+
clearAttachments: () => void;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* 多模态消息 Composable(完整版本)
|
|
117
|
+
* 集成模型感知、自动验证、切换处理等高级功能
|
|
118
|
+
*
|
|
119
|
+
* @param options 包含选中的模型和模型ID
|
|
120
|
+
* @returns 多模态功能的完整API
|
|
121
|
+
*/
|
|
122
|
+
export declare function useMultimodalWithModel(options: MultimodalOptionsWithModel): {
|
|
123
|
+
hasMultimodalSupport: ComputedRef<boolean>;
|
|
124
|
+
attachments: Ref<({
|
|
125
|
+
url: string;
|
|
126
|
+
size: number;
|
|
127
|
+
rawFile?: {
|
|
128
|
+
readonly lastModified: number;
|
|
129
|
+
readonly name: string;
|
|
130
|
+
readonly webkitRelativePath: string;
|
|
131
|
+
readonly size: number;
|
|
132
|
+
readonly type: string;
|
|
133
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
134
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
135
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
136
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
137
|
+
text: () => Promise<string>;
|
|
138
|
+
} | undefined;
|
|
139
|
+
id?: string | undefined;
|
|
140
|
+
name?: string | undefined;
|
|
141
|
+
status?: import('@opentiny/tiny-robot').FileStatus | undefined;
|
|
142
|
+
fileType?: import('@opentiny/tiny-robot').FileType | undefined;
|
|
143
|
+
message?: string | undefined;
|
|
144
|
+
} | {
|
|
145
|
+
rawFile: {
|
|
146
|
+
readonly lastModified: number;
|
|
147
|
+
readonly name: string;
|
|
148
|
+
readonly webkitRelativePath: string;
|
|
149
|
+
readonly size: number;
|
|
150
|
+
readonly type: string;
|
|
151
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
152
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
153
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
154
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
155
|
+
text: () => Promise<string>;
|
|
156
|
+
};
|
|
157
|
+
url?: string | undefined;
|
|
158
|
+
size?: number | undefined;
|
|
159
|
+
id?: string | undefined;
|
|
160
|
+
name?: string | undefined;
|
|
161
|
+
status?: import('@opentiny/tiny-robot').FileStatus | undefined;
|
|
162
|
+
fileType?: import('@opentiny/tiny-robot').FileType | undefined;
|
|
163
|
+
message?: string | undefined;
|
|
164
|
+
})[], Attachment[] | ({
|
|
165
|
+
url: string;
|
|
166
|
+
size: number;
|
|
167
|
+
rawFile?: {
|
|
168
|
+
readonly lastModified: number;
|
|
169
|
+
readonly name: string;
|
|
170
|
+
readonly webkitRelativePath: string;
|
|
171
|
+
readonly size: number;
|
|
172
|
+
readonly type: string;
|
|
173
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
174
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
175
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
176
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
177
|
+
text: () => Promise<string>;
|
|
178
|
+
} | undefined;
|
|
179
|
+
id?: string | undefined;
|
|
180
|
+
name?: string | undefined;
|
|
181
|
+
status?: import('@opentiny/tiny-robot').FileStatus | undefined;
|
|
182
|
+
fileType?: import('@opentiny/tiny-robot').FileType | undefined;
|
|
183
|
+
message?: string | undefined;
|
|
184
|
+
} | {
|
|
185
|
+
rawFile: {
|
|
186
|
+
readonly lastModified: number;
|
|
187
|
+
readonly name: string;
|
|
188
|
+
readonly webkitRelativePath: string;
|
|
189
|
+
readonly size: number;
|
|
190
|
+
readonly type: string;
|
|
191
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
192
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
193
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
194
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
195
|
+
text: () => Promise<string>;
|
|
196
|
+
};
|
|
197
|
+
url?: string | undefined;
|
|
198
|
+
size?: number | undefined;
|
|
199
|
+
id?: string | undefined;
|
|
200
|
+
name?: string | undefined;
|
|
201
|
+
status?: import('@opentiny/tiny-robot').FileStatus | undefined;
|
|
202
|
+
fileType?: import('@opentiny/tiny-robot').FileType | undefined;
|
|
203
|
+
message?: string | undefined;
|
|
204
|
+
})[]>;
|
|
205
|
+
onFilesSelected: (files: File[]) => void;
|
|
206
|
+
checkCanSendAttachments: () => boolean;
|
|
207
|
+
processAttachments: () => Promise<any[]>;
|
|
208
|
+
cleanupAttachments: () => void;
|
|
209
|
+
clearAttachments: () => void;
|
|
210
|
+
};
|