MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / createPtyCreateHandler

Function createPtyCreateHandler

services/cloud-agent-next/wrapper/src/server.ts:760–808  ·  view source on GitHub ↗
(config: ServerConfig, deps: ServerDependencies)

Source from the content-addressed store, hash-verified

758 return jsonResponse({
759 questions: questions.filter(question => question.sessionID === kiloSessionId),
760 permissions: permissions.filter(permission => permission.sessionID === kiloSessionId),
761 });
762 } catch (error) {
763 const msg = error instanceof Error ? error.message : String(error);
764 logToFile(`job/pending-interactions: failed: ${msg}`);
765 return errorResponse('KILO_STATE_ERROR', `Failed to read pending interactions: ${msg}`, 500);
766 }
767 };
768}
769
770export function createAnswerQuestionHandler(deps: ServerDependencies) {
771 return async (req: Request): Promise<Response> => {
772 const { state, kiloClient } = deps;
773
774 if (!state.hasSession) {
775 return errorResponse('NO_SESSION', 'No session context', 400);
776 }
777
778 let body: AnswerQuestionBody;
779 try {
780 body = (await req.json()) as AnswerQuestionBody;
781 } catch {
782 return errorResponse('INVALID_REQUEST', 'Invalid JSON body', 400);
783 }
784
785 if (!body.questionId || !body.answers) {
786 return errorResponse('INVALID_REQUEST', 'questionId and answers are required', 400);
787 }
788
789 try {
790 const success = await kiloClient.answerQuestion(body.questionId, body.answers);
791 state.updateActivity();
792 logToFile(`job/answer-question: questionId=${body.questionId}`);
793 return jsonResponse({ status: 'answered', success });
794 } catch (error) {
795 const msg = error instanceof Error ? error.message : String(error);
796 logToFile(`job/answer-question: failed: ${msg}`);
797 return errorResponse('QUESTION_ERROR', `Failed to answer question: ${msg}`, 500);
798 }
799 };
800}
801
802export function createRejectQuestionHandler(deps: ServerDependencies) {
803 return async (req: Request): Promise<Response> => {
804 const { state, kiloClient } = deps;
805
806 if (!state.hasSession) {
807 return errorResponse('NO_SESSION', 'No session context', 400);
808 }
809
810 let body: RejectQuestionBody;
811 try {

Callers 1

createFetchHandlerFunction · 0.85

Calls 4

parsePtySizeFunction · 0.85
logToFileFunction · 0.85
errorResponseFunction · 0.70
jsonResponseFunction · 0.70

Tested by

no test coverage detected