Skip to content

Commit 78c57ff

Browse files
authored
feat: Aggregation next-remoter, Erase tiny-robot, LLM yuichi remoter management, Upgrade tool and registerTool (#27)
* feat: 对接 ai-sdk 抹平LLM的差异 * feat: 更新AgentModelProvider以改善工具调用信息的显示和处理逻辑 * feat: 更新AgentModelProvider以增强工具调用信息的参数显示和处理逻辑 * feat: 使用ai-sdk对接ant-design-x 对话框组件 * feat: 添加docs构建脚本 * feat: 更新自动部署工作流和配置,支持多分支触发及基础路径设置 * feat: 更新路由配置,设置基础路径为'/tiny-vue-mcp/' * feat: 优化对话框组件的条件渲染逻辑,使用isAntDesignX变量替代路由查询参数 * feat: 添加生成GeminiNano的功能 * feat: 在对话框组件中添加错误信息显示,优化消息映射逻辑 * feat: 替换LLM请求接口 * feat: 集成next-remoter,消除tiny-robot,LLM统一由remoter管理 * chore: 升级版本 * fix: 更新组件类型定义,简化导入语法
1 parent 668a2ee commit 78c57ff

File tree

25 files changed

+141
-860
lines changed

25 files changed

+141
-860
lines changed

.github/workflows/auto-deploy-site.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# GitHub Actions 工作流定义文件
2-
# 本文件定义了自动构建和部署VitePress站点到GitHub Pages的完整流程
3-
name: Deploy VitePress site to Pages
2+
# 本文件定义了自动构建和部署站点到GitHub Pages的完整流程
3+
name: Deploy site to Pages
44

55
on:
66
# 触发条件1: 当有代码推送到main分支时自动触发工作流
@@ -61,13 +61,18 @@ jobs:
6161

6262
# 步骤7: 构建站点
6363
- name: Build site
64-
run: pnpm run build # 执行构建命令,生成静态网站文件
64+
run: pnpm run build:docs # 执行构建命令,生成静态网站文件
65+
66+
- name: Repair build artifact
67+
run: |
68+
sudo chmod -R 777 ./docs/dist
69+
cp ./docs/dist/index.html ./docs/dist/404.html
6570
6671
# 步骤8: 上传构建产物
6772
- name: Upload build artifact
6873
uses: actions/upload-pages-artifact@v3
6974
with:
70-
path: dist # 上传dist目录作为部署内容
75+
path: docs/dist # 上传dist目录作为部署内容
7176

7277
# 第二个任务: 部署到GitHub Pages
7378
deploy:

README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,3 @@ pnpm build
4141
1.`packages/mcp` 中开发MCP配置
4242
2.`docs` 中预览和测试MCP配置
4343
3. 运行 `pnpm build` 构建MCP配置
44-
45-
### 如何体验?
46-
47-
体验方式有两种(环境变量和本地缓存,优先级:环境变量 > 本地缓存):
48-
49-
1.`docs/.env` 中配置 `VITE_LLM_API_KEY` (LLM大模型的API_KEY 目前只支持兼容OpenAI协议的大模型) 和 `VITE_LLM_URL` (LLM大模型的URL) 后,运行 `pnpm dev` 即可体验。
50-
2. 如果不想配置环境变量,页面启动后会提示用户填写LLM信息,填写后会自动保存到本地缓存,下次启动时会自动加载(如果填写的api_key和url不正确,请清空本地缓存后刷新页面)。
51-
52-
![填写LLM信息](/docs/public/llm.png)

docs/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
VITE_LLM_API_KEY=
1+
VITE_LLM_API_KEY=sk-85276270e75f45139cda35c2ba445b3c
22
VITE_LLM_URL=https://api.deepseek.com/v1

docs/components.d.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,19 @@ export {}
77

88
declare module 'vue' {
99
export interface GlobalComponents {
10-
ReactiveMarkdown: typeof import('./src/components/ReactiveMarkdown.vue')['default']
11-
RouterLink: typeof import('vue-router')['RouterLink']
12-
RouterView: typeof import('vue-router')['RouterView']
13-
TinyBaseSelect: typeof import('@opentiny/vue-base-select')['default']
14-
TinyButton: typeof import('@opentiny/vue-button')['default']
15-
TinyDialogBox: typeof import('@opentiny/vue-dialog-box')['default']
16-
TinyForm: typeof import('@opentiny/vue-form')['default']
17-
TinyFormItem: typeof import('@opentiny/vue-form-item')['default']
18-
TinyGrid: typeof import('@opentiny/vue-grid')['default']
19-
TinyGridColumn: typeof import('@opentiny/vue-grid-column')['default']
20-
TinyImage: typeof import('@opentiny/vue-image')['default']
21-
TinyInput: typeof import('@opentiny/vue-input')['default']
22-
TinyOption: typeof import('@opentiny/vue-option')['default']
23-
TinyQrCode: typeof import('@opentiny/vue-qr-code')['default']
24-
TinyRobotChat: typeof import('./src/components/tiny-robot-chat.vue')['default']
25-
TinyTag: typeof import('@opentiny/vue-tag')['default']
26-
TinyTree: typeof import('@opentiny/vue-tree')['default']
10+
RouterLink: (typeof import('vue-router'))['RouterLink']
11+
RouterView: (typeof import('vue-router'))['RouterView']
12+
TinyBaseSelect: (typeof import('@opentiny/vue-base-select'))['default']
13+
TinyButton: (typeof import('@opentiny/vue-button'))['default']
14+
TinyDialogBox: (typeof import('@opentiny/vue-dialog-box'))['default']
15+
TinyForm: (typeof import('@opentiny/vue-form'))['default']
16+
TinyFormItem: (typeof import('@opentiny/vue-form-item'))['default']
17+
TinyGrid: (typeof import('@opentiny/vue-grid'))['default']
18+
TinyGridColumn: (typeof import('@opentiny/vue-grid-column'))['default']
19+
TinyInput: (typeof import('@opentiny/vue-input'))['default']
20+
TinyOption: (typeof import('@opentiny/vue-option'))['default']
21+
TinyRobotChat: (typeof import('./src/components/tiny-robot-chat.vue'))['default']
22+
TinyTag: (typeof import('@opentiny/vue-tag'))['default']
23+
TinyTree: (typeof import('@opentiny/vue-tree'))['default']
2724
}
2825
}

docs/package.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,14 @@
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
8-
"build": "vue-tsc -b && vite build",
8+
"build": "vite build",
99
"preview": "vite preview"
1010
},
1111
"dependencies": {
12-
"@modelcontextprotocol/sdk": "^1.11.0",
13-
"@stagewise/toolbar-vue": "^0.2.0",
14-
"@opentiny/tiny-robot": "0.3.0-alpha.3",
15-
"@opentiny/tiny-robot-kit": "0.3.0-alpha.3",
16-
"@opentiny/tiny-robot-svgs": "0.3.0-alpha.3",
1712
"@opentiny/icons": "^0.1.3",
1813
"@opentiny/tiny-vue-mcp": "workspace:*",
19-
"@opentiny/next-sdk": "0.0.1-alpha.5",
14+
"@opentiny/next-remoter": "0.0.1-alpha.7",
15+
"@opentiny/next-sdk": "~0.1.0",
2016
"@opentiny/vue": "^3.24.0",
2117
"@opentiny/vue-icon": "^3.24.0",
2218
"@opentiny/vue-locale": "^3.24.0",
@@ -31,6 +27,7 @@
3127
"devDependencies": {
3228
"@opentiny/unplugin-tiny-vue": "^1.0.0",
3329
"@types/node": "^22.15.16",
30+
"@vitejs/plugin-vue-jsx": "^5.0.1",
3431
"@types/vue": "^2.0.0",
3532
"@vitejs/plugin-vue": "^5.2.2",
3633
"@vue/tsconfig": "^0.7.0",

docs/src/App.vue

Lines changed: 55 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,66 @@
11
<template>
2-
<div class="header"></div>
3-
<div class="app-container">
4-
<!-- 主体内容区域 -->
5-
<div class="main-content">
6-
<router-view />
7-
</div>
8-
<div class="right-panel" :class="{ collapsed: !showTinyRobot }">
9-
<div class="right-panel-header">智能助手操作区</div>
10-
<tiny-robot-chat />
11-
</div>
12-
<IconAi @click="showTinyRobot = !showTinyRobot" class="style-settings-icon"></IconAi>
13-
<tiny-dialog-box
14-
v-model:visible="boxVisibility"
15-
:close-on-click-modal="false"
16-
title="请填写您的LLM信息"
17-
:show-close="false"
18-
width="30%"
19-
>
20-
<div>
21-
<tiny-form ref="formRef" :model="createData" label-width="120px">
22-
<tiny-form-item label="LLM URL" prop="llmUrl" :rules="{ required: true, messages: '必填', trigger: 'blur' }">
23-
<tiny-input v-model="createData.llmUrl"></tiny-input>
24-
</tiny-form-item>
25-
<tiny-form-item
26-
label="API Key"
27-
prop="llmApiKey"
28-
:rules="{ required: true, messages: '必填', trigger: 'blur' }"
29-
>
30-
<tiny-input v-model="createData.llmApiKey"></tiny-input>
31-
</tiny-form-item>
32-
<tiny-form-item>
33-
<tiny-button @click="submit" type="primary">保存</tiny-button>
34-
</tiny-form-item>
35-
</tiny-form>
36-
</div>
37-
</tiny-dialog-box>
2+
<div>
3+
<router-view />
4+
<TinyRemoter sessionId="78b66563-95c0-4839-8007-e8af634dd657" />
385
</div>
396
</template>
407

418
<script setup lang="ts">
42-
import '@opentiny/icons/style/all.css'
43-
import TinyRobotChat from './components/tiny-robot-chat.vue'
44-
import { showTinyRobot } from './composable/utils'
45-
import { IconAi } from '@opentiny/tiny-robot-svgs'
46-
import { reactive, ref } from 'vue'
47-
import { $local, isEnvLLMDefined, isLocalLLMDefined } from './composable/utils'
48-
const boxVisibility = ref(false)
49-
const formRef = ref()
50-
const createData = reactive({
51-
llmUrl: $local.llmUrl || import.meta.env.VITE_LLM_URL,
52-
llmApiKey: $local.llmApiKey || import.meta.env.VITE_LLM_API_KEY
53-
})
54-
55-
const submit = () => {
56-
formRef.value.validate().then(() => {
57-
$local.llmUrl = createData.llmUrl
58-
$local.llmApiKey = createData.llmApiKey
59-
boxVisibility.value = false
60-
window.location.reload()
61-
})
9+
import { TinyRemoter } from '@opentiny/next-remoter'
10+
import { WebMcpClient, createMessageChannelPairTransport } from '@opentiny/next-sdk'
11+
import type { Transport } from '@opentiny/next-sdk'
12+
import { AGENT_ROOT } from './const'
13+
import { provide } from 'vue'
14+
15+
const [serverTransport, clientTransport] = createMessageChannelPairTransport()
16+
17+
// 定义 MCP Server 的能力
18+
const capabilities = {
19+
prompts: { listChanged: true },
20+
resources: { subscribe: true, listChanged: true },
21+
tools: { listChanged: true },
22+
completions: {},
23+
logging: {}
6224
}
6325
64-
if (!isEnvLLMDefined && !isLocalLLMDefined) {
65-
boxVisibility.value = true
26+
const mcpServer: {
27+
transport: Transport | null
28+
capabilities: Record<string, any>
29+
} = {
30+
transport: serverTransport,
31+
capabilities
6632
}
33+
34+
provide('mcpServer', mcpServer)
35+
36+
serverTransport.onerror = (error) => {
37+
console.error(`ServerTransport error:`, error)
38+
}
39+
40+
const createProxyTransport = async () => {
41+
const client = new WebMcpClient(
42+
{ name: 'mcp-web-client', version: '1.0.0' },
43+
{ capabilities: { roots: { listChanged: true }, sampling: {}, elicitation: {} } }
44+
)
45+
// @ts-expect-error client
46+
window.client = client
47+
await client.connect(clientTransport)
48+
49+
const { sessionId } = await client.connect({
50+
url: AGENT_ROOT + 'mcp',
51+
sessionId: '78b66563-95c0-4839-8007-e8af634dd657',
52+
agent: true,
53+
onError: (error: Error) => {
54+
console.error('Connect proxy error:', error)
55+
}
56+
})
57+
58+
console.log('sessionId', sessionId)
59+
60+
window.addEventListener('pagehide', client.onPagehide)
61+
}
62+
63+
createProxyTransport()
6764
</script>
6865

6966
<style scoped>

docs/src/components/ReactiveMarkdown.vue

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)