This commit is contained in:
锦恢 2025-05-17 00:49:37 +08:00
commit e9e9d7e119
19 changed files with 15223 additions and 11017 deletions

3
.gitignore vendored
View File

@ -13,4 +13,5 @@ resources/ocr/*.js
resources/ocr/*.wasm
resources/renderer
resources/service
*.traineddata
*.traineddata
.turbo

View File

@ -10,7 +10,10 @@
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off",
"i18n-haru.root": "renderer/src/i18n",
"i18n-haru.main": "zh"
"i18n-haru.main": "zh",
"i18n-ally.localesPaths": [
"renderer/src/i18n"
]
}

View File

@ -145,10 +145,7 @@ B <--mcp--> m(MCP Server)
启动 dev server
```bash
## linux
./dev.sh
## windows
./dev.ps1
npm run dev
```
> 端口占用: 8282 (renderer) + 8081 (service)
@ -163,11 +160,7 @@ B <--mcp--> m(MCP Server)
负载部署
```bash
## linux
./build_service.sh
## windows
./build_service.ps1
npm run build
```
and just press f5, いただきます

View File

@ -1,17 +1,19 @@
# 安装 renderer 依赖
Set-Location renderer
npm i
Set-Location ..
# 安装 service 依赖并打补丁
Set-Location service
npm i
node patch-mcp-sdk.js
Set-Location ..
## 安装 renderer 依赖
#Set-Location renderer
#npm i
#Set-Location ..
#
## 安装 service 依赖并打补丁
#Set-Location service
#npm i
#node patch-mcp-sdk.js
#Set-Location ..
Set-Location servers
uv sync
Set-Location ..
# 安装根目录依赖
npm i
npm i
npm run prepare:ocr

View File

@ -1,5 +1,3 @@
cd renderer && npm i && cd ..
cd service && npm i && cd ..
cd servers && uv sync
cd servers && uv sync && cd ..
npm i
npm run prepare:ocr
npm run prepare:ocr

15563
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -212,7 +212,18 @@
]
}
},
"workspaces": [
"service",
"renderer",
"software"
],
"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",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
@ -224,6 +235,7 @@
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.10.2",
"@openmcp/service": "*",
"@seald-io/nedb": "^4.1.1",
"axios": "^1.7.7",
"bson": "^6.8.0",
@ -242,8 +254,10 @@
"fork-ts-checker-webpack-plugin": "^9.1.0",
"null-loader": "^4.0.1",
"ts-loader": "^9.5.1",
"turbo": "^2.5.3",
"typescript": "^5.4.2",
"webpack": "^5.99.5",
"webpack-cli": "^5.1.4"
}
},
"packageManager": "npm@10.0.0"
}

View File

@ -1,9 +1,12 @@
{
"name": "test-vite",
"version": "0.0.0",
"name": "@openmcp/renderer",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"postbuild": "node scripts/post-build.mjs",
"lint": "vue-cli-service lint",
"serve": "vite",
"serve:website": "vite --mode website",
"build": "run-p type-check \"build-only {@}\" --",

View 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

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,16 @@
{
"name": "openmcp-service",
"name": "@openmcp/service",
"version": "0.0.1",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "commonjs",
"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:watch": "tsc --watch",
"postbuild": "node ./scripts/post-build.mjs",
"start": "node dist/main.js",
"start:prod": "NODE_ENV=production node dist/main.js",
"debug": "node --inspect -r ts-node/register src/main.ts",

View 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 })

View File

@ -9,7 +9,8 @@
"outDir": "./dist",
"declaration": true,
"declarationMap": true,
"experimentalDecorators": true
"experimentalDecorators": true,
"moduleResolution": "node"
},
"paths": {
"@/*": [
@ -18,4 +19,4 @@
},
"include": ["src/**/*"],
"exclude": ["node_modules", "src/main.ts"] // main.ts
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
{
"name": "openmcp-electron",
"name": "@openmcp/electron",
"version": "0.0.1",
"description": "",
"main": "dist/main.js",
@ -13,6 +13,7 @@
"email": "1193466151@qq.com"
},
"dependencies": {
"@openmcp/service": "*",
"@modelcontextprotocol/sdk": "^1.10.2",
"@seald-io/nedb": "^4.1.1",
"axios": "^1.7.7",

View File

@ -33,7 +33,7 @@ function createWindow(): void {
const option = getInitConnectionOption();
// 注册消息接受的管线
webview.onDidReceiveMessage((message: any) => {
webview.onDidReceiveMessage((message: any) => {
console.info(`command: [${message.command || 'No Command'}]`);
const { command, data } = message;
@ -51,7 +51,7 @@ function createWindow(): void {
url: option.url,
oauth: option.oauth || ''
};
const launchResult = {
code: 200,
msg: launchResultMessage
@ -63,11 +63,11 @@ function createWindow(): void {
});
break;
case 'electron/update-connection-sigature':
updateConnectionOption(data);
break;
default:
OpenMCPService.routeMessage(command, data, webview);
break;
@ -94,4 +94,4 @@ app.whenReady().then(() => {
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})
})

View File

@ -1,5 +1,5 @@
import * as vscode from 'vscode';
import * as OpenMCPService from '../openmcp-sdk/service';
import * as OpenMCPService from '@openmcp/service';
import { launch } from './common/entry';
export function activate(context: vscode.ExtensionContext) {
@ -19,4 +19,4 @@ export function activate(context: vscode.ExtensionContext) {
export function deactivate() {
}
}

View File

@ -2,18 +2,18 @@ import * as vscode from 'vscode';
import * as fs from 'fs';
import * as fspath from 'path';
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 {
const viewRoot = fspath.join(context.extensionPath, 'openmcp-sdk', 'renderer');
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 absLocalPath = fspath.resolve(viewRoot, $2);
const absLocalPath = fspath.resolve(viewRoot, $2);
const webviewUri = panel.webview.asWebviewUri(vscode.Uri.file(absLocalPath));
const replaceHref = $1 + webviewUri?.toString() + '"';
return replaceHref;
});
});
return html;
}
@ -56,9 +56,9 @@ export function revealOpenMcpWebviewPanel(
// 设置HTML内容
const html = getWebviewContent(context, panel);
const html = getWebviewContent(context, panel);
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的消息
panel.webview.onDidReceiveMessage(message => {
@ -79,7 +79,7 @@ export function revealOpenMcpWebviewPanel(
url: option.url,
oauth: option.oauth || ''
};
const launchResult = {
code: 200,
msg: launchResultMessage
@ -91,7 +91,7 @@ export function revealOpenMcpWebviewPanel(
});
break;
case 'vscode/update-connection-sigature':
if (type === 'installed') {
updateInstalledConnectionConfig(panelKey, data);
@ -101,7 +101,7 @@ export function revealOpenMcpWebviewPanel(
break;
default:
OpenMCPService.routeMessage(command, data, panel.webview);
OpenMCPService.routeMessage(command, data, panel.webview);
break;
}

22
turbo.json Normal file
View 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/**"]
}
}
}