feat(server): real GET /sessions via SessionSummaryProjector
This commit is contained in:
@@ -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<SessionSummary> =
|
||||
eventStore.allSessionIds().map { sessionId ->
|
||||
sessionSummaryProjector.project(sessionId, eventStore.readFrom(sessionId, fromSequence = 0L))
|
||||
}
|
||||
|
||||
private fun preRegisterPendingApprovals() {
|
||||
val projector = ApprovalProjector(DefaultApprovalReducer())
|
||||
eventStore.allSessionIds().forEach { sessionId ->
|
||||
|
||||
@@ -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<SessionSummaryResponse>()) }
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user