Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .github/workflows/auto-deploy-site.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# GitHub Actions 工作流定义文件
# 本文件定义了自动构建和部署VitePress站点到GitHub Pages的完整流程
name: Deploy VitePress site to Pages
# 本文件定义了自动构建和部署站点到GitHub Pages的完整流程
name: Deploy site to Pages

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

# 步骤7: 构建站点
- name: Build site
run: pnpm run build # 执行构建命令,生成静态网站文件
run: pnpm run build:docs # 执行构建命令,生成静态网站文件

- name: Repair build artifact
run: |
sudo chmod -R 777 ./docs/dist
cp ./docs/dist/index.html ./docs/dist/404.html

# 步骤8: 上传构建产物
- name: Upload build artifact
uses: actions/upload-pages-artifact@v3
with:
path: dist # 上传dist目录作为部署内容
path: docs/dist # 上传dist目录作为部署内容

# 第二个任务: 部署到GitHub Pages
deploy:
Expand Down
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,3 @@ pnpm build
1. 在 `packages/mcp` 中开发MCP配置
2. 在 `docs` 中预览和测试MCP配置
3. 运行 `pnpm build` 构建MCP配置

### 如何体验?

体验方式有两种(环境变量和本地缓存,优先级:环境变量 > 本地缓存):

1. 在 `docs/.env` 中配置 `VITE_LLM_API_KEY` (LLM大模型的API_KEY 目前只支持兼容OpenAI协议的大模型) 和 `VITE_LLM_URL` (LLM大模型的URL) 后,运行 `pnpm dev` 即可体验。
2. 如果不想配置环境变量,页面启动后会提示用户填写LLM信息,填写后会自动保存到本地缓存,下次启动时会自动加载(如果填写的api_key和url不正确,请清空本地缓存后刷新页面)。

![填写LLM信息](/docs/public/llm.png)
2 changes: 1 addition & 1 deletion docs/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VITE_LLM_API_KEY=
VITE_LLM_API_KEY=sk-85276270e75f45139cda35c2ba445b3c
VITE_LLM_URL=https://api.deepseek.com/v1
31 changes: 14 additions & 17 deletions docs/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@ export {}

declare module 'vue' {
export interface GlobalComponents {
ReactiveMarkdown: typeof import('./src/components/ReactiveMarkdown.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
TinyBaseSelect: typeof import('@opentiny/vue-base-select')['default']
TinyButton: typeof import('@opentiny/vue-button')['default']
TinyDialogBox: typeof import('@opentiny/vue-dialog-box')['default']
TinyForm: typeof import('@opentiny/vue-form')['default']
TinyFormItem: typeof import('@opentiny/vue-form-item')['default']
TinyGrid: typeof import('@opentiny/vue-grid')['default']
TinyGridColumn: typeof import('@opentiny/vue-grid-column')['default']
TinyImage: typeof import('@opentiny/vue-image')['default']
TinyInput: typeof import('@opentiny/vue-input')['default']
TinyOption: typeof import('@opentiny/vue-option')['default']
TinyQrCode: typeof import('@opentiny/vue-qr-code')['default']
TinyRobotChat: typeof import('./src/components/tiny-robot-chat.vue')['default']
TinyTag: typeof import('@opentiny/vue-tag')['default']
TinyTree: typeof import('@opentiny/vue-tree')['default']
RouterLink: (typeof import('vue-router'))['RouterLink']
RouterView: (typeof import('vue-router'))['RouterView']
TinyBaseSelect: (typeof import('@opentiny/vue-base-select'))['default']
TinyButton: (typeof import('@opentiny/vue-button'))['default']
TinyDialogBox: (typeof import('@opentiny/vue-dialog-box'))['default']
TinyForm: (typeof import('@opentiny/vue-form'))['default']
TinyFormItem: (typeof import('@opentiny/vue-form-item'))['default']
TinyGrid: (typeof import('@opentiny/vue-grid'))['default']
TinyGridColumn: (typeof import('@opentiny/vue-grid-column'))['default']
TinyInput: (typeof import('@opentiny/vue-input'))['default']
TinyOption: (typeof import('@opentiny/vue-option'))['default']
TinyRobotChat: (typeof import('./src/components/tiny-robot-chat.vue'))['default']
TinyTag: (typeof import('@opentiny/vue-tag'))['default']
TinyTree: (typeof import('@opentiny/vue-tree'))['default']
}
}
11 changes: 4 additions & 7 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc -b && vite build",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.11.0",
"@stagewise/toolbar-vue": "^0.2.0",
"@opentiny/tiny-robot": "0.3.0-alpha.3",
"@opentiny/tiny-robot-kit": "0.3.0-alpha.3",
"@opentiny/tiny-robot-svgs": "0.3.0-alpha.3",
"@opentiny/icons": "^0.1.3",
"@opentiny/tiny-vue-mcp": "workspace:*",
"@opentiny/next-sdk": "0.0.1-alpha.5",
"@opentiny/next-remoter": "0.0.1-alpha.7",
"@opentiny/next-sdk": "~0.1.0",
"@opentiny/vue": "^3.24.0",
"@opentiny/vue-icon": "^3.24.0",
"@opentiny/vue-locale": "^3.24.0",
Expand All @@ -31,6 +27,7 @@
"devDependencies": {
"@opentiny/unplugin-tiny-vue": "^1.0.0",
"@types/node": "^22.15.16",
"@vitejs/plugin-vue-jsx": "^5.0.1",
"@types/vue": "^2.0.0",
"@vitejs/plugin-vue": "^5.2.2",
"@vue/tsconfig": "^0.7.0",
Expand Down
113 changes: 55 additions & 58 deletions docs/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,69 +1,66 @@
<template>
<div class="header"></div>
<div class="app-container">
<!-- 主体内容区域 -->
<div class="main-content">
<router-view />
</div>
<div class="right-panel" :class="{ collapsed: !showTinyRobot }">
<div class="right-panel-header">智能助手操作区</div>
<tiny-robot-chat />
</div>
<IconAi @click="showTinyRobot = !showTinyRobot" class="style-settings-icon"></IconAi>
<tiny-dialog-box
v-model:visible="boxVisibility"
:close-on-click-modal="false"
title="请填写您的LLM信息"
:show-close="false"
width="30%"
>
<div>
<tiny-form ref="formRef" :model="createData" label-width="120px">
<tiny-form-item label="LLM URL" prop="llmUrl" :rules="{ required: true, messages: '必填', trigger: 'blur' }">
<tiny-input v-model="createData.llmUrl"></tiny-input>
</tiny-form-item>
<tiny-form-item
label="API Key"
prop="llmApiKey"
:rules="{ required: true, messages: '必填', trigger: 'blur' }"
>
<tiny-input v-model="createData.llmApiKey"></tiny-input>
</tiny-form-item>
<tiny-form-item>
<tiny-button @click="submit" type="primary">保存</tiny-button>
</tiny-form-item>
</tiny-form>
</div>
</tiny-dialog-box>
<div>
<router-view />
<TinyRemoter sessionId="78b66563-95c0-4839-8007-e8af634dd657" />
</div>
</template>

<script setup lang="ts">
import '@opentiny/icons/style/all.css'
import TinyRobotChat from './components/tiny-robot-chat.vue'
import { showTinyRobot } from './composable/utils'
import { IconAi } from '@opentiny/tiny-robot-svgs'
import { reactive, ref } from 'vue'
import { $local, isEnvLLMDefined, isLocalLLMDefined } from './composable/utils'
const boxVisibility = ref(false)
const formRef = ref()
const createData = reactive({
llmUrl: $local.llmUrl || import.meta.env.VITE_LLM_URL,
llmApiKey: $local.llmApiKey || import.meta.env.VITE_LLM_API_KEY
})

const submit = () => {
formRef.value.validate().then(() => {
$local.llmUrl = createData.llmUrl
$local.llmApiKey = createData.llmApiKey
boxVisibility.value = false
window.location.reload()
})
import { TinyRemoter } from '@opentiny/next-remoter'
import { WebMcpClient, createMessageChannelPairTransport } from '@opentiny/next-sdk'
import type { Transport } from '@opentiny/next-sdk'
import { AGENT_ROOT } from './const'
import { provide } from 'vue'

const [serverTransport, clientTransport] = createMessageChannelPairTransport()

// 定义 MCP Server 的能力
const capabilities = {
prompts: { listChanged: true },
resources: { subscribe: true, listChanged: true },
tools: { listChanged: true },
completions: {},
logging: {}
}

if (!isEnvLLMDefined && !isLocalLLMDefined) {
boxVisibility.value = true
const mcpServer: {
transport: Transport | null
capabilities: Record<string, any>
} = {
transport: serverTransport,
capabilities
}

provide('mcpServer', mcpServer)

serverTransport.onerror = (error) => {
console.error(`ServerTransport error:`, error)
}

const createProxyTransport = async () => {
const client = new WebMcpClient(
{ name: 'mcp-web-client', version: '1.0.0' },
{ capabilities: { roots: { listChanged: true }, sampling: {}, elicitation: {} } }
)
// @ts-expect-error client
window.client = client
await client.connect(clientTransport)

const { sessionId } = await client.connect({
url: AGENT_ROOT + 'mcp',
sessionId: '78b66563-95c0-4839-8007-e8af634dd657',
agent: true,
onError: (error: Error) => {
console.error('Connect proxy error:', error)
}
})

console.log('sessionId', sessionId)

window.addEventListener('pagehide', client.onPagehide)
}

createProxyTransport()
</script>

<style scoped>
Expand Down
10 changes: 0 additions & 10 deletions docs/src/components/ReactiveMarkdown.vue

This file was deleted.

Loading