MCPcopy
hub / github.com/coder/mux / createHeadlessEnvironment

Function createHeadlessEnvironment

src/node/bench/headlessEnvironment.ts:94–129  ·  view source on GitHub ↗
(
  options: CreateHeadlessEnvironmentOptions = {}
)

Source from the content-addressed store, hash-verified

92}
93
94export async function createHeadlessEnvironment(
95 options: CreateHeadlessEnvironmentOptions = {}
96): Promise<HeadlessEnvironment> {
97 const { rootDir, dispose: disposeRootDir } = await establishRootDir(options.rootDir);
98
99 const config = new Config(rootDir);
100
101 const { window: mockWindow, sentEvents } = createMockBrowserWindow();
102
103 const mockedElectron = createIPCMock();
104 assertMockedElectron(mockedElectron);
105 const mockIpcMainModule = mockedElectron.ipcMain;
106 const mockIpcRendererModule = mockedElectron.ipcRenderer;
107
108 const services = new ServiceContainer(config);
109 // Headless bench environment has no interactive host-key dialog
110 setOpenSSHHostKeyPolicyMode("headless-fallback");
111 await services.initialize();
112 services.windowService.setMainWindow(mockWindow);
113
114 const dispose = async () => {
115 sentEvents.length = 0;
116 await disposeRootDir();
117 };
118
119 return {
120 config,
121 services,
122 mockIpcMain: mockIpcMainModule,
123 mockIpcRenderer: mockIpcRendererModule,
124 mockWindow,
125 sentEvents,
126 rootDir,
127 dispose,
128 };
129}

Callers

nothing calls this directly

Calls 6

initializeMethod · 0.95
establishRootDirFunction · 0.85
assertMockedElectronFunction · 0.85
setMainWindowMethod · 0.80
createMockBrowserWindowFunction · 0.70

Tested by

no test coverage detected