( sessionId: string, userId: string, includeBlobUrls?: boolean )
| 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 | |
| 213 | interface ForkableSession { |
| 214 | source_id: string; |
| 215 | source_folder: FolderName; |
| 216 | title: string | null; |
| 217 | session_id: string | null; |
| 218 | version: number; |
| 219 | } |
no test coverage detected