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

Function getSessionWithExistsCheck

apps/web/src/routers/cli-sessions-router.ts:178–216  ·  view source on GitHub ↗
(
  sessionId: string,
  userId: string,
  includeBlobUrls?: boolean
)

Source from the content-addressed store, hash-verified

176 includeBlobUrls?: boolean
177) {
178 const [session] = await db
179 .select()
180 .from(cliSessions)
181 .where(and(eq(cliSessions.session_id, sessionId), eq(cliSessions.kilo_user_id, userId)))
182 .limit(1);
183
184 if (!session) {
185 throw new TRPCError({
186 code: 'NOT_FOUND',
187 message: 'Session not found',
188 });
189 }
190
191 if (includeBlobUrls) {
192 const blobTypesToFetch: FileName[] = [];
193
194 if (session.api_conversation_history_blob_url)
195 blobTypesToFetch.push('api_conversation_history');
196 if (session.task_metadata_blob_url) blobTypesToFetch.push('task_metadata');
197 if (session.ui_messages_blob_url) blobTypesToFetch.push('ui_messages');
198 if (session.git_state_blob_url) blobTypesToFetch.push('git_state');
199
200 if (blobTypesToFetch.length > 0) {
201 const blobUrls = await generateSignedUrls(sessionId, 'sessions', blobTypesToFetch);
202
203 return {
204 ...session,
205 ...blobUrls,
206 };
207 }
208 }
209
210 return session;
211}
212
213interface ForkableSession {
214 source_id: string;
215 source_folder: FolderName;
216 title: string | null;
217 session_id: string | null;
218 version: number;
219}

Callers 2

getForkableSessionFunction · 0.85

Calls 3

generateSignedUrlsFunction · 0.90
pushMethod · 0.80
limitMethod · 0.65

Tested by

no test coverage detected