merge
This commit is contained in:
commit
e9e9d7e119
3
.gitignore
vendored
3
.gitignore
vendored
@ -13,4 +13,5 @@ resources/ocr/*.js
|
|||||||
resources/ocr/*.wasm
|
resources/ocr/*.wasm
|
||||||
resources/renderer
|
resources/renderer
|
||||||
resources/service
|
resources/service
|
||||||
*.traineddata
|
*.traineddata
|
||||||
|
.turbo
|
||||||
|
7
.vscode/settings.json
vendored
7
.vscode/settings.json
vendored
@ -10,7 +10,10 @@
|
|||||||
},
|
},
|
||||||
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
|
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
|
||||||
"typescript.tsc.autoDetect": "off",
|
"typescript.tsc.autoDetect": "off",
|
||||||
|
|
||||||
"i18n-haru.root": "renderer/src/i18n",
|
"i18n-haru.root": "renderer/src/i18n",
|
||||||
"i18n-haru.main": "zh"
|
"i18n-haru.main": "zh",
|
||||||
|
"i18n-ally.localesPaths": [
|
||||||
|
"renderer/src/i18n"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
11
README.md
11
README.md
@ -145,10 +145,7 @@ B <--mcp--> m(MCP Server)
|
|||||||
启动 dev server
|
启动 dev server
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
## linux
|
npm run dev
|
||||||
./dev.sh
|
|
||||||
## windows
|
|
||||||
./dev.ps1
|
|
||||||
```
|
```
|
||||||
|
|
||||||
> 端口占用: 8282 (renderer) + 8081 (service)
|
> 端口占用: 8282 (renderer) + 8081 (service)
|
||||||
@ -163,11 +160,7 @@ B <--mcp--> m(MCP Server)
|
|||||||
|
|
||||||
负载部署
|
负载部署
|
||||||
```bash
|
```bash
|
||||||
## linux
|
npm run build
|
||||||
./build_service.sh
|
|
||||||
|
|
||||||
## windows
|
|
||||||
./build_service.ps1
|
|
||||||
```
|
```
|
||||||
|
|
||||||
and just press f5, いただきます
|
and just press f5, いただきます
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
# 安装 renderer 依赖
|
## 安装 renderer 依赖
|
||||||
Set-Location renderer
|
#Set-Location renderer
|
||||||
npm i
|
#npm i
|
||||||
Set-Location ..
|
#Set-Location ..
|
||||||
|
#
|
||||||
# 安装 service 依赖并打补丁
|
## 安装 service 依赖并打补丁
|
||||||
Set-Location service
|
#Set-Location service
|
||||||
npm i
|
#npm i
|
||||||
node patch-mcp-sdk.js
|
#node patch-mcp-sdk.js
|
||||||
Set-Location ..
|
#Set-Location ..
|
||||||
|
|
||||||
Set-Location servers
|
Set-Location servers
|
||||||
uv sync
|
uv sync
|
||||||
Set-Location ..
|
Set-Location ..
|
||||||
|
|
||||||
# 安装根目录依赖
|
# 安装根目录依赖
|
||||||
npm i
|
npm i
|
||||||
|
|
||||||
|
npm run prepare:ocr
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
cd renderer && npm i && cd ..
|
cd servers && uv sync && cd ..
|
||||||
cd service && npm i && cd ..
|
|
||||||
cd servers && uv sync
|
|
||||||
npm i
|
npm i
|
||||||
npm run prepare:ocr
|
npm run prepare:ocr
|
||||||
|
15563
package-lock.json
generated
15563
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
16
package.json
16
package.json
@ -212,7 +212,18 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"workspaces": [
|
||||||
|
"service",
|
||||||
|
"renderer",
|
||||||
|
"software"
|
||||||
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"dev": "turbo dev --filter=!@openmcp/electron",
|
||||||
|
"dev:electron": "turbo dev --filter=@openmcp/electron",
|
||||||
|
"dev:all": "turbo dev",
|
||||||
|
"build": "turbo build --filter=!@openmcp/electron",
|
||||||
|
"build:electron": "turbo build --filter=@openmcp/electron",
|
||||||
|
"build:all": "turbo build",
|
||||||
"vscode:prepublish": "webpack --mode production",
|
"vscode:prepublish": "webpack --mode production",
|
||||||
"compile": "tsc -p ./",
|
"compile": "tsc -p ./",
|
||||||
"watch": "tsc -watch -p ./",
|
"watch": "tsc -watch -p ./",
|
||||||
@ -224,6 +235,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@modelcontextprotocol/sdk": "^1.10.2",
|
"@modelcontextprotocol/sdk": "^1.10.2",
|
||||||
|
"@openmcp/service": "*",
|
||||||
"@seald-io/nedb": "^4.1.1",
|
"@seald-io/nedb": "^4.1.1",
|
||||||
"axios": "^1.7.7",
|
"axios": "^1.7.7",
|
||||||
"bson": "^6.8.0",
|
"bson": "^6.8.0",
|
||||||
@ -242,8 +254,10 @@
|
|||||||
"fork-ts-checker-webpack-plugin": "^9.1.0",
|
"fork-ts-checker-webpack-plugin": "^9.1.0",
|
||||||
"null-loader": "^4.0.1",
|
"null-loader": "^4.0.1",
|
||||||
"ts-loader": "^9.5.1",
|
"ts-loader": "^9.5.1",
|
||||||
|
"turbo": "^2.5.3",
|
||||||
"typescript": "^5.4.2",
|
"typescript": "^5.4.2",
|
||||||
"webpack": "^5.99.5",
|
"webpack": "^5.99.5",
|
||||||
"webpack-cli": "^5.1.4"
|
"webpack-cli": "^5.1.4"
|
||||||
}
|
},
|
||||||
|
"packageManager": "npm@10.0.0"
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "test-vite",
|
"name": "@openmcp/renderer",
|
||||||
"version": "0.0.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"postbuild": "node scripts/post-build.mjs",
|
||||||
|
"lint": "vue-cli-service lint",
|
||||||
"serve": "vite",
|
"serve": "vite",
|
||||||
"serve:website": "vite --mode website",
|
"serve:website": "vite --mode website",
|
||||||
"build": "run-p type-check \"build-only {@}\" --",
|
"build": "run-p type-check \"build-only {@}\" --",
|
||||||
|
43
renderer/scripts/post-build.mjs
Normal file
43
renderer/scripts/post-build.mjs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import fsPath from 'node:path';
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import * as process from "node:process";
|
||||||
|
|
||||||
|
function createDirIfExists(filePath) {
|
||||||
|
if (!fs.existsSync(filePath)) {
|
||||||
|
fs.mkdirSync(filePath, { recursive: true })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function recreateDir(filePath) {
|
||||||
|
if (fs.existsSync(filePath)) {
|
||||||
|
fs.rmSync(filePath, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.mkdirSync(filePath, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentDir = process.cwd();
|
||||||
|
// 确保上级目录的 openmcp-sdk 存在
|
||||||
|
const openMCPSdkPath = fsPath.join(currentDir, '..', 'openmcp-sdk')
|
||||||
|
createDirIfExists(openMCPSdkPath);
|
||||||
|
|
||||||
|
const sdkRenderPath = fsPath.join(openMCPSdkPath, 'renderer');
|
||||||
|
recreateDir(sdkRenderPath);
|
||||||
|
|
||||||
|
const sourceDist = fsPath.join(currentDir, 'dist');
|
||||||
|
|
||||||
|
// 如果源目录不存在则报错
|
||||||
|
if (!fs.existsSync(sourceDist)) {
|
||||||
|
throw new Error(`Source directory not found: ${sourceDist}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.cpSync(sourceDist, sdkRenderPath, { recursive: true })
|
||||||
|
|
||||||
|
// electron目录
|
||||||
|
const electronOpenMcpSdkPath = fsPath.join(currentDir, '..', 'software', 'openmcp-sdk');
|
||||||
|
createDirIfExists(electronOpenMcpSdkPath);
|
||||||
|
|
||||||
|
const electronRendererPath = fsPath.join(electronOpenMcpSdkPath, 'renderer');
|
||||||
|
recreateDir(electronRendererPath);
|
||||||
|
|
||||||
|
fs.cpSync(sourceDist, electronRendererPath, { recursive: true })
|
5023
service/package-lock.json
generated
5023
service/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,13 +1,16 @@
|
|||||||
{
|
{
|
||||||
"name": "openmcp-service",
|
"name": "@openmcp/service",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
"type": "commonjs",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"serve": "ts-node-dev --respawn --transpile-only src/main.ts",
|
"postinstall": "npm run build",
|
||||||
|
"dev": "ts-node-dev --respawn --transpile-only src/main.ts",
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"build:watch": "tsc --watch",
|
"build:watch": "tsc --watch",
|
||||||
|
"postbuild": "node ./scripts/post-build.mjs",
|
||||||
"start": "node dist/main.js",
|
"start": "node dist/main.js",
|
||||||
"start:prod": "NODE_ENV=production node dist/main.js",
|
"start:prod": "NODE_ENV=production node dist/main.js",
|
||||||
"debug": "node --inspect -r ts-node/register src/main.ts",
|
"debug": "node --inspect -r ts-node/register src/main.ts",
|
||||||
|
33
service/scripts/post-build.mjs
Normal file
33
service/scripts/post-build.mjs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import fs from "node:fs";
|
||||||
|
import process from "node:process";
|
||||||
|
import fsPath from "node:path";
|
||||||
|
|
||||||
|
function createDirIfExists(filePath) {
|
||||||
|
if (!fs.existsSync(filePath)) {
|
||||||
|
fs.mkdirSync(filePath, { recursive: true })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function recreateDir(filePath) {
|
||||||
|
if (fs.existsSync(filePath)) {
|
||||||
|
fs.rmSync(filePath, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.mkdirSync(filePath, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentDir = process.cwd();
|
||||||
|
const sourceDist = fsPath.join(currentDir, 'dist');
|
||||||
|
|
||||||
|
// 如果源目录不存在则报错
|
||||||
|
if (!fs.existsSync(sourceDist)) {
|
||||||
|
throw new Error(`Source directory not found: ${sourceDist}`)
|
||||||
|
}
|
||||||
|
// electron目录
|
||||||
|
const electronOpenMcpSdkPath = fsPath.join(currentDir, '..', 'software', 'openmcp-sdk');
|
||||||
|
createDirIfExists(electronOpenMcpSdkPath);
|
||||||
|
|
||||||
|
const electronServicePath = fsPath.join(electronOpenMcpSdkPath, 'service');
|
||||||
|
recreateDir(electronServicePath);
|
||||||
|
|
||||||
|
fs.cpSync(sourceDist, electronServicePath, { recursive: true })
|
@ -9,7 +9,8 @@
|
|||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"declarationMap": true,
|
"declarationMap": true,
|
||||||
"experimentalDecorators": true
|
"experimentalDecorators": true,
|
||||||
|
"moduleResolution": "node"
|
||||||
},
|
},
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": [
|
"@/*": [
|
||||||
@ -18,4 +19,4 @@
|
|||||||
},
|
},
|
||||||
"include": ["src/**/*"],
|
"include": ["src/**/*"],
|
||||||
"exclude": ["node_modules", "src/main.ts"] // 排除 main.ts
|
"exclude": ["node_modules", "src/main.ts"] // 排除 main.ts
|
||||||
}
|
}
|
||||||
|
5437
software/package-lock.json
generated
5437
software/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "openmcp-electron",
|
"name": "@openmcp/electron",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/main.js",
|
"main": "dist/main.js",
|
||||||
@ -13,6 +13,7 @@
|
|||||||
"email": "1193466151@qq.com"
|
"email": "1193466151@qq.com"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@openmcp/service": "*",
|
||||||
"@modelcontextprotocol/sdk": "^1.10.2",
|
"@modelcontextprotocol/sdk": "^1.10.2",
|
||||||
"@seald-io/nedb": "^4.1.1",
|
"@seald-io/nedb": "^4.1.1",
|
||||||
"axios": "^1.7.7",
|
"axios": "^1.7.7",
|
||||||
|
@ -33,7 +33,7 @@ function createWindow(): void {
|
|||||||
const option = getInitConnectionOption();
|
const option = getInitConnectionOption();
|
||||||
|
|
||||||
// 注册消息接受的管线
|
// 注册消息接受的管线
|
||||||
webview.onDidReceiveMessage((message: any) => {
|
webview.onDidReceiveMessage((message: any) => {
|
||||||
console.info(`command: [${message.command || 'No Command'}]`);
|
console.info(`command: [${message.command || 'No Command'}]`);
|
||||||
|
|
||||||
const { command, data } = message;
|
const { command, data } = message;
|
||||||
@ -51,7 +51,7 @@ function createWindow(): void {
|
|||||||
url: option.url,
|
url: option.url,
|
||||||
oauth: option.oauth || ''
|
oauth: option.oauth || ''
|
||||||
};
|
};
|
||||||
|
|
||||||
const launchResult = {
|
const launchResult = {
|
||||||
code: 200,
|
code: 200,
|
||||||
msg: launchResultMessage
|
msg: launchResultMessage
|
||||||
@ -63,11 +63,11 @@ function createWindow(): void {
|
|||||||
});
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'electron/update-connection-sigature':
|
case 'electron/update-connection-sigature':
|
||||||
updateConnectionOption(data);
|
updateConnectionOption(data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
OpenMCPService.routeMessage(command, data, webview);
|
OpenMCPService.routeMessage(command, data, webview);
|
||||||
break;
|
break;
|
||||||
@ -94,4 +94,4 @@ app.whenReady().then(() => {
|
|||||||
|
|
||||||
app.on('window-all-closed', function () {
|
app.on('window-all-closed', function () {
|
||||||
if (process.platform !== 'darwin') app.quit()
|
if (process.platform !== 'darwin') app.quit()
|
||||||
})
|
})
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as OpenMCPService from '../openmcp-sdk/service';
|
import * as OpenMCPService from '@openmcp/service';
|
||||||
import { launch } from './common/entry';
|
import { launch } from './common/entry';
|
||||||
|
|
||||||
export function activate(context: vscode.ExtensionContext) {
|
export function activate(context: vscode.ExtensionContext) {
|
||||||
@ -19,4 +19,4 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
|
|
||||||
export function deactivate() {
|
export function deactivate() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,18 +2,18 @@ import * as vscode from 'vscode';
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as fspath from 'path';
|
import * as fspath from 'path';
|
||||||
import { IConnectionItem, ILaunchSigature, panels, updateInstalledConnectionConfig, updateWorkspaceConnectionConfig } from '../global';
|
import { IConnectionItem, ILaunchSigature, panels, updateInstalledConnectionConfig, updateWorkspaceConnectionConfig } from '../global';
|
||||||
import * as OpenMCPService from '../../openmcp-sdk/service';
|
import * as OpenMCPService from '@openmcp/service';
|
||||||
|
|
||||||
export function getWebviewContent(context: vscode.ExtensionContext, panel: vscode.WebviewPanel): string | undefined {
|
export function getWebviewContent(context: vscode.ExtensionContext, panel: vscode.WebviewPanel): string | undefined {
|
||||||
const viewRoot = fspath.join(context.extensionPath, 'openmcp-sdk', 'renderer');
|
const viewRoot = fspath.join(context.extensionPath, 'openmcp-sdk', 'renderer');
|
||||||
const htmlIndexPath = fspath.join(viewRoot, 'index.html');
|
const htmlIndexPath = fspath.join(viewRoot, 'index.html');
|
||||||
const html = fs.readFileSync(htmlIndexPath, { encoding: 'utf-8' })?.replace(/(<link.+?href="|<script.+?src="|<img.+?src="|url\()(.+?)(\)|")/g, (m, $1, $2) => {
|
const html = fs.readFileSync(htmlIndexPath, { encoding: 'utf-8' })?.replace(/(<link.+?href="|<script.+?src="|<img.+?src="|url\()(.+?)(\)|")/g, (m, $1, $2) => {
|
||||||
const absLocalPath = fspath.resolve(viewRoot, $2);
|
const absLocalPath = fspath.resolve(viewRoot, $2);
|
||||||
const webviewUri = panel.webview.asWebviewUri(vscode.Uri.file(absLocalPath));
|
const webviewUri = panel.webview.asWebviewUri(vscode.Uri.file(absLocalPath));
|
||||||
|
|
||||||
const replaceHref = $1 + webviewUri?.toString() + '"';
|
const replaceHref = $1 + webviewUri?.toString() + '"';
|
||||||
return replaceHref;
|
return replaceHref;
|
||||||
});
|
});
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,9 +56,9 @@ export function revealOpenMcpWebviewPanel(
|
|||||||
|
|
||||||
|
|
||||||
// 设置HTML内容
|
// 设置HTML内容
|
||||||
const html = getWebviewContent(context, panel);
|
const html = getWebviewContent(context, panel);
|
||||||
panel.webview.html = html || '';
|
panel.webview.html = html || '';
|
||||||
panel.iconPath = vscode.Uri.file(fspath.join(context.extensionPath, 'openmcp-sdk', 'renderer', 'images', 'openmcp.png'));
|
panel.iconPath = vscode.Uri.file(fspath.join(context.extensionPath, 'openmcp-sdk', 'renderer', 'images', 'openmcp.png'));
|
||||||
|
|
||||||
// 处理来自webview的消息
|
// 处理来自webview的消息
|
||||||
panel.webview.onDidReceiveMessage(message => {
|
panel.webview.onDidReceiveMessage(message => {
|
||||||
@ -79,7 +79,7 @@ export function revealOpenMcpWebviewPanel(
|
|||||||
url: option.url,
|
url: option.url,
|
||||||
oauth: option.oauth || ''
|
oauth: option.oauth || ''
|
||||||
};
|
};
|
||||||
|
|
||||||
const launchResult = {
|
const launchResult = {
|
||||||
code: 200,
|
code: 200,
|
||||||
msg: launchResultMessage
|
msg: launchResultMessage
|
||||||
@ -91,7 +91,7 @@ export function revealOpenMcpWebviewPanel(
|
|||||||
});
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'vscode/update-connection-sigature':
|
case 'vscode/update-connection-sigature':
|
||||||
if (type === 'installed') {
|
if (type === 'installed') {
|
||||||
updateInstalledConnectionConfig(panelKey, data);
|
updateInstalledConnectionConfig(panelKey, data);
|
||||||
@ -101,7 +101,7 @@ export function revealOpenMcpWebviewPanel(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
OpenMCPService.routeMessage(command, data, panel.webview);
|
OpenMCPService.routeMessage(command, data, panel.webview);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
turbo.json
Normal file
22
turbo.json
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://turborepo.com/schema.json",
|
||||||
|
"tasks": {
|
||||||
|
"dev": {
|
||||||
|
"persistent": true,
|
||||||
|
"cache": false
|
||||||
|
},
|
||||||
|
"build": {
|
||||||
|
"dependsOn": ["^build"],
|
||||||
|
"outputs": ["dist/**"]
|
||||||
|
},
|
||||||
|
"@openmcp/electron#dev": {
|
||||||
|
"dependsOn": ["@openmcp/renderer#build", "@openmcp/service#build"],
|
||||||
|
"persistent": true,
|
||||||
|
"cache": false
|
||||||
|
},
|
||||||
|
"@openmcp/electron#build": {
|
||||||
|
"dependsOn": ["@openmcp/renderer#build", "@openmcp/service#build"],
|
||||||
|
"outputs": ["dist/**"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user