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

Function createAbortHandler

services/cloud-agent-next/wrapper/src/server.ts:728–758  ·  view source on GitHub ↗
(deps: ServerDependencies, triggerDrainAndClose: () => void)

Source from the content-addressed store, hash-verified

726 }
727 };
728}
729
730/**
731 * The interactions this session currently waits on, as the Worker's
732 * `getPendingInteractions` read needs them: the same Kilo state the `connected`
733 * snapshot replays, filtered to this session's root Kilo session.
734 *
735 * A legacy `agent_*` Cloud Agent session keeps no pending set of its own — its
736 * Durable Object is only told about `question.asked`/`permission.asked` as
737 * events — so the wrapper is the only place that read can come from. A session
738 * with no bound Kilo session yet has nothing pending.
739 */
740export function createPendingInteractionsHandler(deps: ServerDependencies) {
741 return async (): Promise<Response> => {
742 const { state, kiloClient } = deps;
743
744 if (!state.hasSession) {
745 return errorResponse('NO_SESSION', 'No session context', 400);
746 }
747
748 const kiloSessionId = state.currentSession?.kiloSessionId;
749 if (!kiloSessionId) {
750 return jsonResponse({ questions: [], permissions: [] });
751 }
752
753 try {
754 const [questions, permissions] = await Promise.all([
755 kiloClient.getQuestions(),
756 kiloClient.getPermissions(),
757 ]);
758 return jsonResponse({
759 questions: questions.filter(question => question.sessionID === kiloSessionId),
760 permissions: permissions.filter(permission => permission.sessionID === kiloSessionId),
761 });

Callers 2

server.test.tsFile · 0.85
createFetchHandlerFunction · 0.85

Calls 6

logToFileFunction · 0.85
triggerDrainAndCloseFunction · 0.85
sendToIngestMethod · 0.80
clearAllMessagesMethod · 0.80
errorResponseFunction · 0.70
jsonResponseFunction · 0.70

Tested by

no test coverage detected