diff --git a/apps/server/src/main/kotlin/com/correx/apps/server/ServerModule.kt b/apps/server/src/main/kotlin/com/correx/apps/server/ServerModule.kt index a0b47f77..f5e292b4 100644 --- a/apps/server/src/main/kotlin/com/correx/apps/server/ServerModule.kt +++ b/apps/server/src/main/kotlin/com/correx/apps/server/ServerModule.kt @@ -23,6 +23,8 @@ import com.correx.core.kernel.orchestration.OrchestrationConfig import com.correx.core.kernel.orchestration.OrchestrationRepository import com.correx.core.router.RouterFacade import com.correx.core.sessions.DefaultSessionRepository +import com.correx.core.sessions.SessionSummary +import com.correx.core.sessions.SessionSummaryProjector import com.correx.core.tools.registry.ToolRegistry import com.correx.core.events.orchestration.OrchestrationStatus import kotlinx.datetime.Clock @@ -224,6 +226,13 @@ class ServerModule( } } + private val sessionSummaryProjector = SessionSummaryProjector() + + fun listSessionSummaries(): List = + eventStore.allSessionIds().map { sessionId -> + sessionSummaryProjector.project(sessionId, eventStore.readFrom(sessionId, fromSequence = 0L)) + } + private fun preRegisterPendingApprovals() { val projector = ApprovalProjector(DefaultApprovalReducer()) eventStore.allSessionIds().forEach { sessionId -> diff --git a/apps/server/src/main/kotlin/com/correx/apps/server/routes/SessionRoutes.kt b/apps/server/src/main/kotlin/com/correx/apps/server/routes/SessionRoutes.kt index f99ca519..1c77481f 100644 --- a/apps/server/src/main/kotlin/com/correx/apps/server/routes/SessionRoutes.kt +++ b/apps/server/src/main/kotlin/com/correx/apps/server/routes/SessionRoutes.kt @@ -21,7 +21,15 @@ import java.util.* data class StartSessionRequest(val workflowId: String, val config: SessionConfigDto? = null) @Serializable -data class SessionSummaryResponse(val sessionId: String, val status: String) +data class SessionSummaryResponse( + val sessionId: String, + val status: String, + val intent: String? = null, + val workflowId: String? = null, + val stageCount: Int = 0, + val createdAt: String? = null, + val lastActivityAt: String? = null, +) @Serializable data class SessionStateResponse(val sessionId: String, val status: String, val createdAt: String?) @@ -37,7 +45,20 @@ private val log = LoggerFactory.getLogger("com.correx.apps.server.routes.Session fun Route.sessionRoutes(module: ServerModule) { val streamHandler = SessionStreamHandler(module) route("/sessions") { - get { call.respond(emptyList()) } + get { + val summaries = module.listSessionSummaries().map { s -> + SessionSummaryResponse( + sessionId = s.sessionId.value, + status = s.status, + intent = s.intent, + workflowId = s.workflowId, + stageCount = s.stageCount, + createdAt = s.createdAt?.toString(), + lastActivityAt = s.lastActivityAt?.toString(), + ) + } + call.respond(summaries) + } startSessionRoute(module) route("/{id}") { getSessionRoute(module)