sloth-d2c-mcp 1.0.4-beta97 → 1.0.4-beta99
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/cli/run.js +4 -1
- package/cli/sloth-server.log +11698 -0
- package/dist/build/index.js +3 -1
- package/dist/build/plugin/loader.js +19 -4
- package/dist/build/plugin/types.js +6 -1
- package/dist/build/server.js +3 -3
- package/dist/interceptor-web/dist/build-report.json +1 -1
- package/dist/interceptor-web/dist/detail.html +1 -1
- package/dist/interceptor-web/dist/index.html +1 -1
- package/package.json +3 -3
package/dist/build/index.js
CHANGED
|
@@ -30,8 +30,10 @@ const spawnServerProcess = async () => {
|
|
|
30
30
|
const { fileURLToPath } = await import('node:url');
|
|
31
31
|
// 获取当前脚本路径(兼容 Node.js 18)
|
|
32
32
|
const scriptPath = fileURLToPath(import.meta.url);
|
|
33
|
+
// 指向scriptPath目录下的log
|
|
34
|
+
const logPath = path.resolve(path.dirname(scriptPath), 'sloth-server.log');
|
|
33
35
|
// 后台启动子进程
|
|
34
|
-
const child = spawn(process.execPath, [scriptPath, '--server'], {
|
|
36
|
+
const child = spawn(process.execPath, [scriptPath, '--server', '--log=' + logPath], {
|
|
35
37
|
detached: true,
|
|
36
38
|
stdio: 'ignore',
|
|
37
39
|
env: { ...process.env, NODE_ENV: 'cli' }
|
|
@@ -3,6 +3,7 @@ import { promises as fs } from 'fs';
|
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
import envPaths from 'env-paths';
|
|
6
|
+
import { PLUGIN_HOOKS } from './types.js';
|
|
6
7
|
import { createRequire } from 'module';
|
|
7
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
8
9
|
const __dirname = path.dirname(__filename);
|
|
@@ -235,7 +236,12 @@ export async function loadWorkspacePlugins(workspaceRoot) {
|
|
|
235
236
|
const pluginModule = await import(localPluginPath);
|
|
236
237
|
const plugin = {
|
|
237
238
|
name: pluginName,
|
|
238
|
-
|
|
239
|
+
// 只取出PluginHooks
|
|
240
|
+
...PLUGIN_HOOKS.reduce((acc, hookName) => {
|
|
241
|
+
acc[hookName] = (pluginModule.default || pluginModule)[hookName];
|
|
242
|
+
return acc;
|
|
243
|
+
}, {}),
|
|
244
|
+
// ...(pluginModule.default || pluginModule),
|
|
239
245
|
_config: pluginConfig,
|
|
240
246
|
};
|
|
241
247
|
plugins.push(plugin);
|
|
@@ -265,7 +271,10 @@ export async function loadWorkspacePlugins(workspaceRoot) {
|
|
|
265
271
|
console.log('pluginModule', pluginModule);
|
|
266
272
|
const plugin = {
|
|
267
273
|
name: pluginName,
|
|
268
|
-
...(
|
|
274
|
+
...PLUGIN_HOOKS.reduce((acc, hookName) => {
|
|
275
|
+
acc[hookName] = (pluginModule.default || pluginModule)[hookName];
|
|
276
|
+
return acc;
|
|
277
|
+
}, {}),
|
|
269
278
|
_config: pluginConfig,
|
|
270
279
|
};
|
|
271
280
|
plugins.push(plugin);
|
|
@@ -301,7 +310,10 @@ export async function loadAllPlugins() {
|
|
|
301
310
|
console.log('pluginConfig', pluginConfig);
|
|
302
311
|
const plugin = {
|
|
303
312
|
name: packageName,
|
|
304
|
-
...(
|
|
313
|
+
...PLUGIN_HOOKS.reduce((acc, hookName) => {
|
|
314
|
+
acc[hookName] = (pluginModule.default || pluginModule)[hookName];
|
|
315
|
+
return acc;
|
|
316
|
+
}, {}),
|
|
305
317
|
_config: pluginConfig,
|
|
306
318
|
};
|
|
307
319
|
plugins.push(plugin);
|
|
@@ -322,7 +334,10 @@ export async function loadPlugin(packageName) {
|
|
|
322
334
|
const pluginModule = await import(packageName);
|
|
323
335
|
const plugin = {
|
|
324
336
|
name: packageName,
|
|
325
|
-
...(
|
|
337
|
+
...PLUGIN_HOOKS.reduce((acc, hookName) => {
|
|
338
|
+
acc[hookName] = (pluginModule.default || pluginModule)[hookName];
|
|
339
|
+
return acc;
|
|
340
|
+
}, {}),
|
|
326
341
|
};
|
|
327
342
|
console.log(`[sloth] 插件 ${packageName} 加载成功`);
|
|
328
343
|
return plugin;
|
package/dist/build/server.js
CHANGED
|
@@ -1018,8 +1018,6 @@ export async function startHttpServer(port = PORT, mcpServer, configManagerInsta
|
|
|
1018
1018
|
return;
|
|
1019
1019
|
}
|
|
1020
1020
|
const renderer = pluginRenderer.default.renderConfigForm;
|
|
1021
|
-
console.log('pluginRenderer.default', pluginRenderer.default);
|
|
1022
|
-
console.log('renderer', renderer);
|
|
1023
1021
|
res.type('application/javascript; charset=utf-8').send(renderer);
|
|
1024
1022
|
});
|
|
1025
1023
|
// ==================== 组件映射相关接口 ====================
|
|
@@ -2056,7 +2054,9 @@ export async function getUserInput(payload) {
|
|
|
2056
2054
|
Logger.log('Socket 客户端已连接');
|
|
2057
2055
|
const workspaceRoot = fileManager.getWorkspaceRoot();
|
|
2058
2056
|
// 注册 token 并等待响应,同时传递 extra 数据给主进程
|
|
2059
|
-
const
|
|
2057
|
+
const socketParams = { workspaceRoot, plugins: pluginManager.getPlugins() };
|
|
2058
|
+
Logger.log('socketParams', socketParams);
|
|
2059
|
+
const responsePromise = socketClient.registerToken(token, socketParams);
|
|
2060
2060
|
// 打开浏览器
|
|
2061
2061
|
await open(authUrl);
|
|
2062
2062
|
// 等待认证响应
|