MCPcopy
hub / github.com/xpf0000/FlyEnv / initForkManager

Method initForkManager

src/main/Application.ts:205–243  ·  view source on GitHub ↗

* 初始化 Fork 管理器

()

Source from the content-addressed store, hash-verified

203 * 初始化 Fork 管理器
204 */
205 private initForkManager() {
206 this.forkManager = new ForkManager(join(__dirname, './fork.mjs'))
207 this.forkManager.on(({ key, info }: { key: string; info: any }) => {
208 if (key === 'App-Need-Init-FlyEnv-Helper') {
209 AppHelper.needInstall()
210 return
211 }
212 this.windowManager.sendCommandTo(this.mainWindow!, key, key, info)
213 })
214 ServiceProcessManager.forkManager = this.forkManager
215
216 // 服务运行态变更时,广播给 render,使「非本端发起」(MCP / 托盘 / 其它窗口)的启停也能同步到 UI
217 ServiceProcessManager.onStatusChange((status) => {
218 if (!this.mainWindow) {
219 return
220 }
221 this.windowManager.sendCommandTo(this.mainWindow, 'APP-MCP-Notify', 'APP-MCP-Notify', {
222 type: 'service-status-changed',
223 ...status
224 })
225 })
226
227 // MCP Server 需要 forkManager 句柄,在此创建并注入
228 this.mcpServer = new MCPServer(this.forkManager, this.mcpConfigManager, this.configManager)
229 this.ipcHandler.updateDependencies({ forkManager: this.forkManager, mcpServer: this.mcpServer })
230 startMcpOnLaunchIfNeeded(this.mcpConfigManager, this.mcpServer).catch(() => {})
231
232 // MCP 通知统一通过 ServiceVersionManager 中转,再广播给渲染进程
233 ServiceVersionManager.onMcpNotify((payload) => {
234 if (this.mainWindow) {
235 this.windowManager.sendCommandTo(
236 this.mainWindow,
237 'APP-MCP-Notify',
238 'APP-MCP-Notify',
239 payload
240 )
241 }
242 })
243 }
244
245 /**
246 * 设置 SiteSucker 回调

Callers 1

constructorMethod · 0.95

Calls 8

startMcpOnLaunchIfNeededFunction · 0.90
needInstallMethod · 0.80
sendCommandToMethod · 0.80
onStatusChangeMethod · 0.80
updateDependenciesMethod · 0.80
catchMethod · 0.80
onMcpNotifyMethod · 0.80
onMethod · 0.45

Tested by

no test coverage detected