@opentiny/next-remoter 0.2.6 → 0.2.7

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 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';
@@ -22,10 +22,10 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
22
22
  selectedModelId: import('vue').PropType<any>;
23
23
  genUiAble: import('vue').PropType<any>;
24
24
  enabledTools: import('vue').PropType<any>;
25
- /** 必传的会话id */
25
+ /** 会话 id,可选;未传时仅显示「打开对话框」,不展示扫码等菜单 */
26
26
  sessionId: {
27
27
  type: StringConstructor;
28
- default: string;
28
+ default: undefined;
29
29
  };
30
30
  /** 后端的代理服务器地址 */
31
31
  agentRoot: {
@@ -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
  * 对话框模式: 直接显示一个对话框界面
@@ -71,7 +86,10 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
71
86
  /** 大语言模型配置对象 */
72
87
  llmConfig: {
73
88
  type: () => ICustomAgentModelProviderLlmConfig | undefined;
74
- default: undefined;
89
+ default: () => {
90
+ baseURL: string;
91
+ genuiUrl: string;
92
+ };
75
93
  };
76
94
  /** 设置组件运行在普通页面还是浏览器的扩展中 */
77
95
  inBrowserExt: {
@@ -112,11 +130,24 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
112
130
  type: () => "static" | "relative" | "absolute" | "fixed" | "sticky";
113
131
  default: string;
114
132
  };
133
+ debugStream: {
134
+ type: BooleanConstructor;
135
+ default: boolean;
136
+ };
137
+ /**
138
+ * 开启页面工具按需加载:仅当前激活路由对应的 withPageTools 工具对 LLM 可见,
139
+ * 并在插件面板中展示;未加载页面的工具不会暴露给模型,也不显示在面板上。
140
+ * 默认 false(关闭),需显式传入 :pageToolsOnDemand="true" 开启。
141
+ */
142
+ pageToolsOnDemand: {
143
+ type: BooleanConstructor;
144
+ default: boolean;
145
+ };
115
146
  }>, {
116
147
  /** 大模型代理 */
117
148
  agent: import('@opentiny/next-sdk').AgentModelProvider;
118
149
  /** 欢迎图标 */
119
- welcomeIcon: import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
150
+ welcomeIcon: VNode<import('vue').RendererNode, import('vue').RendererElement, {
120
151
  [key: string]: any;
121
152
  }>;
122
153
  /** 对话消息 */
@@ -131,7 +162,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
131
162
  assistant: {
132
163
  type: string;
133
164
  placement: string;
134
- avatar: import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
165
+ avatar: VNode<import('vue').RendererNode, import('vue').RendererElement, {
135
166
  [key: string]: any;
136
167
  }>;
137
168
  maxWidth: string;
@@ -139,14 +170,14 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
139
170
  slots: {
140
171
  footer: ({ index }: {
141
172
  index: number;
142
- }) => "" | import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
173
+ }) => "" | VNode<import('vue').RendererNode, import('vue').RendererElement, {
143
174
  [key: string]: any;
144
175
  }>;
145
176
  };
146
177
  };
147
178
  user: {
148
179
  placement: string;
149
- avatar: import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
180
+ avatar: VNode<import('vue').RendererNode, import('vue').RendererElement, {
150
181
  [key: string]: any;
151
182
  }>;
152
183
  maxWidth: string;
@@ -182,16 +213,58 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
182
213
  } | null>;
183
214
  /** 添加消息 */
184
215
  addMessage: (message: import('@opentiny/tiny-robot-kit').ChatMessage | import('@opentiny/tiny-robot-kit').ChatMessage[]) => void;
216
+ /** 已安装的插件 */
217
+ installedPlugins: Ref<{
218
+ id: string;
219
+ name: string;
220
+ icon: string;
221
+ description: string;
222
+ enabled: boolean;
223
+ expanded?: boolean | undefined;
224
+ tools: {
225
+ id: string;
226
+ name: string;
227
+ description: string;
228
+ enabled: boolean;
229
+ }[];
230
+ addState?: import('@opentiny/tiny-robot').PluginAddState | undefined;
231
+ category?: string | undefined;
232
+ }[], PluginInfo[] | {
233
+ id: string;
234
+ name: string;
235
+ icon: string;
236
+ description: string;
237
+ enabled: boolean;
238
+ expanded?: boolean | undefined;
239
+ tools: {
240
+ id: string;
241
+ name: string;
242
+ description: string;
243
+ enabled: boolean;
244
+ }[];
245
+ addState?: import('@opentiny/tiny-robot').PluginAddState | undefined;
246
+ category?: string | undefined;
247
+ }[]>;
248
+ /** 添加插件核心方法 */
249
+ addPluginCore: (config: {
250
+ pluginId: string;
251
+ name: string;
252
+ description: string;
253
+ icon?: string;
254
+ mcpServer: McpServerConfig;
255
+ }) => Promise<boolean>;
256
+ /** 删除插件核心方法 */
257
+ deletePlugin: (plugin: PluginInfo) => Promise<void>;
185
258
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
186
259
  fullscreen: import('vue').PropType<any>;
187
260
  show: import('vue').PropType<any>;
188
261
  selectedModelId: import('vue').PropType<any>;
189
262
  genUiAble: import('vue').PropType<any>;
190
263
  enabledTools: import('vue').PropType<any>;
191
- /** 必传的会话id */
264
+ /** 会话 id,可选;未传时仅显示「打开对话框」,不展示扫码等菜单 */
192
265
  sessionId: {
193
266
  type: StringConstructor;
194
- default: string;
267
+ default: undefined;
195
268
  };
196
269
  /** 后端的代理服务器地址 */
197
270
  agentRoot: {
@@ -226,6 +299,21 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
226
299
  AILogoUrl: {
227
300
  type: StringConstructor;
228
301
  };
302
+ /** 角色user,assistant的头像配置, 值为 VNode, 比如: h(IconUser, { style: { fontSize: '32px' } }) */
303
+ roleAvatar: {
304
+ type: () => {
305
+ user: VNode;
306
+ assistant: VNode;
307
+ };
308
+ default: () => {
309
+ user: VNode<import('vue').RendererNode, import('vue').RendererElement, {
310
+ [key: string]: any;
311
+ }>;
312
+ assistant: VNode<import('vue').RendererNode, import('vue').RendererElement, {
313
+ [key: string]: any;
314
+ }>;
315
+ };
316
+ };
229
317
  /** 展示模式: 'remoter' | 'chat-dialog'
230
318
  * 遥控器模式: 自动在右下角显示一个AI图标,点击展开多个菜单项。
231
319
  * 对话框模式: 直接显示一个对话框界面
@@ -237,7 +325,10 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
237
325
  /** 大语言模型配置对象 */
238
326
  llmConfig: {
239
327
  type: () => ICustomAgentModelProviderLlmConfig | undefined;
240
- default: undefined;
328
+ default: () => {
329
+ baseURL: string;
330
+ genuiUrl: string;
331
+ };
241
332
  };
242
333
  /** 设置组件运行在普通页面还是浏览器的扩展中 */
243
334
  inBrowserExt: {
@@ -278,6 +369,19 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
278
369
  type: () => "static" | "relative" | "absolute" | "fixed" | "sticky";
279
370
  default: string;
280
371
  };
372
+ debugStream: {
373
+ type: BooleanConstructor;
374
+ default: boolean;
375
+ };
376
+ /**
377
+ * 开启页面工具按需加载:仅当前激活路由对应的 withPageTools 工具对 LLM 可见,
378
+ * 并在插件面板中展示;未加载页面的工具不会暴露给模型,也不显示在面板上。
379
+ * 默认 false(关闭),需显式传入 :pageToolsOnDemand="true" 开启。
380
+ */
381
+ pageToolsOnDemand: {
382
+ type: BooleanConstructor;
383
+ default: boolean;
384
+ };
281
385
  }>> & Readonly<{}>, {
282
386
  title: string;
283
387
  systemPrompt: string;
@@ -287,12 +391,18 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
287
391
  mcpServers: Record<string, McpServerConfig>;
288
392
  agentRoot: string;
289
393
  locale: string;
394
+ roleAvatar: {
395
+ user: VNode;
396
+ assistant: VNode;
397
+ };
290
398
  inBrowserExt: boolean;
291
399
  genUiComponents: Record<string, any>;
292
400
  customMarketMcpServers: PluginInfo[];
293
401
  llmConfigs: UnifiedModelConfig[];
294
402
  skills: Record<string, string>;
295
403
  layoutMode: "absolute" | "fixed" | "static" | "relative" | "sticky";
404
+ debugStream: boolean;
405
+ pageToolsOnDemand: boolean;
296
406
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
297
407
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
298
408
  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
- systemPrompt: string;
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,9 +25,10 @@ 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, headers }: {
27
- modelId: string;
28
+ updateLLMConfig({ model, baseURL, genuiUrl, apiKey, providerType, useReActMode, llm, providerOptions, headers }: {
29
+ model: string;
28
30
  baseURL?: string;
31
+ genuiUrl?: string;
29
32
  apiKey?: string;
30
33
  providerType?: 'deepseek' | 'openai' | ((options: any) => ProviderV2);
31
34
  useReActMode?: boolean;
@@ -35,6 +38,10 @@ export declare class CustomAgentModelProvider extends BaseModelProvider {
35
38
  /** 自定义请求 Header,透传给 ai-sdk Provider 实例 */
36
39
  headers?: Record<string, string>;
37
40
  }): void;
41
+ /**
42
+ * 清理消息数组中的 get-skill-content 工具调用结果
43
+ */
44
+ cleanGetSkillContentToolResult(messages: any[]): void;
38
45
  /**
39
46
  * 清理消息数组中的旧快照消息,只保留最新的快照
40
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
- 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, {
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: import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
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
- }) => "" | import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
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: import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
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<{
@@ -6,7 +6,12 @@ import { MenuItemConfig } from '@opentiny/next-sdk';
6
6
  * 用于处理 sessionId 相关的所有逻辑:扫码添加插件、识别码输入、遥控器初始化等
7
7
  */
8
8
  export declare function usePluginSession(options: {
9
- sessionId: Ref<string>;
9
+ /**
10
+ * 会话 ID:
11
+ * - 初始为 undefined 或空字符串时:先渲染仅含「打开对话框」的 Logo
12
+ * - 后续变为非空字符串时:自动升级为带二维码 / 遥控器等完整菜单
13
+ */
14
+ sessionId: Ref<string | undefined>;
10
15
  agentRoot: string;
11
16
  mode: string;
12
17
  qrCodeUrl?: string;
@@ -0,0 +1,23 @@
1
+ import { Ref } from 'vue';
2
+ import { PluginInfo } from '@opentiny/tiny-robot';
3
+
4
+ /**
5
+ * 路由感知工具过滤 composable
6
+ *
7
+ * 支持两种场景:
8
+ * - 同窗口:业务页面与 Remoter 在同一 window,直接读取 getToolRouteMap/getActiveRoutes
9
+ * - iframe:Remoter 在 iframe 内,通过 remoter-ready 握手获取父窗口的路由状态,
10
+ * 并接收父窗口广播的 page-ready/page-leave,实现按需加载
11
+ *
12
+ * 默认关闭(enabled = false),需显式传入 :pageToolsOnDemand="true" 开启。
13
+ */
14
+ export declare function useRouteBasedTools(options: {
15
+ /** 是否启用路由感知模式,默认 false,支持运行时动态切换 */
16
+ enabled: Ref<boolean>;
17
+ /** 仅依赖 ignoreToolnames 的最小 Agent 约束 */
18
+ agent: {
19
+ ignoreToolnames: string[];
20
+ };
21
+ /** 已安装插件列表的响应式引用,用于同步 UI 开关状态 */
22
+ installedPlugins: Ref<PluginInfo[]>;
23
+ }): void;
@@ -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
  }