(opts: BootExposureOpts = {})
| 147 | } |
| 148 | |
| 149 | async function bootExposure(opts: BootExposureOpts = {}): Promise<{ |
| 150 | server: RunningServer; |
| 151 | shutdownCalls: string[]; |
| 152 | }> { |
| 153 | process.env['KIMI_CODE_PASSWORD'] = 'test-pw'; |
| 154 | const { lockPath, homeDir } = tmpPaths(); |
| 155 | const shutdownCalls: string[] = []; |
| 156 | // Capture shutdown requests instead of exiting the process. |
| 157 | const noopShutdown = [ |
| 158 | IServerShutdownService, |
| 159 | { |
| 160 | _serviceBrand: undefined, |
| 161 | requestShutdown: async (reason: string) => { |
| 162 | shutdownCalls.push(reason); |
| 163 | }, |
| 164 | }, |
| 165 | ] as const; |
| 166 | const serviceOverrides: ServerStartOptions['serviceOverrides'] = [ |
| 167 | fixedTokenAuth(), |
| 168 | noopShutdown, |
| 169 | ]; |
| 170 | const server = await startServer({ |
| 171 | serviceOverrides, |
| 172 | host: opts.host ?? '0.0.0.0', |
| 173 | port: 0, |
| 174 | lockPath, |
| 175 | insecureNoTls: true, |
| 176 | allowRemoteShutdown: opts.allowRemoteShutdown, |
| 177 | allowRemoteTerminals: opts.allowRemoteTerminals, |
| 178 | logger: pino({ level: 'silent' }), |
| 179 | coreProcessOptions: { homeDir }, |
| 180 | }); |
| 181 | running.push(server); |
| 182 | return { server, shutdownCalls }; |
| 183 | } |
| 184 | |
| 185 | const terminalsUrl = (server: RunningServer): string => |
| 186 | `${server.address}/api/v1/sessions/some-session/terminals`; |
no test coverage detected