(deps: ServerDependencies, ptyId: string)
| 808 | } |
| 809 | |
| 810 | setAborted(); |
| 811 | |
| 812 | try { |
| 813 | await kiloClient.abortSession({ sessionId: session.kiloSessionId }); |
| 814 | logToFile(`job/abort: aborted kilo session ${session.kiloSessionId}`); |
| 815 | } catch (error) { |
| 816 | const msg = error instanceof Error ? error.message : String(error); |
| 817 | logToFile(`job/abort: abort request failed (continuing): ${msg}`); |
| 818 | } |
| 819 | |
| 820 | state.sendToIngest({ |
| 821 | streamEventType: 'interrupted', |
| 822 | data: { reason: 'aborted via API' }, |
| 823 | timestamp: new Date().toISOString(), |
| 824 | }); |
| 825 | |
| 826 | state.clearAllMessages(); |
| 827 | triggerDrainAndClose(); |
| 828 | |
| 829 | return jsonResponse({ status: 'aborted' }); |
| 830 | }; |
| 831 | } |
| 832 | |
| 833 | function createPtyCreateHandler(config: ServerConfig, deps: ServerDependencies) { |
| 834 | return async (req: Request): Promise<Response> => { |
| 835 | let body: PtyCreateBody; |
| 836 | try { |
| 837 | body = await readJsonBody<PtyCreateBody>(req, {}); |
| 838 | } catch { |
| 839 | return errorResponse('INVALID_REQUEST', 'Invalid JSON body', 400); |
| 840 | } |
| 841 | |
| 842 | let size: WrapperPtySize | null; |
| 843 | try { |
| 844 | size = parsePtySize(body); |
| 845 | } catch (error) { |
| 846 | return errorResponse( |
| 847 | 'INVALID_REQUEST', |
no test coverage detected