28 lines
644 B
TypeScript
28 lines
644 B
TypeScript
import { installWindowInterface } from './tools'
|
|
import { installWebhooks } from './WebhookStore'
|
|
|
|
let cleanup: (() => void) | null = null
|
|
let bootstrapping: Promise<(() => void)> | null = null
|
|
|
|
export async function startMcpRuntime(): Promise<() => void> {
|
|
if (cleanup) {
|
|
return cleanup
|
|
}
|
|
|
|
if (!bootstrapping) {
|
|
bootstrapping = (async () => {
|
|
installWindowInterface()
|
|
const webhookCleanup = await installWebhooks()
|
|
cleanup = () => {
|
|
webhookCleanup()
|
|
cleanup = null
|
|
bootstrapping = null
|
|
}
|
|
bootstrapping = null
|
|
return cleanup
|
|
})()
|
|
}
|
|
|
|
return await bootstrapping
|
|
}
|