Add session bootstrap client path

This commit is contained in:
OpenClaw committed 2026-03-07 22:44:02 +08:00
1 parent 82c6d27075
commit 0c7aefee42
4 files changed
+48

No files matched your search

@@ -530,6 +530,22 @@ class RemoteOpenClawRepository(
updateSessionPreview(sessionId, previewMessage(merged))
}
suspend fun fetchSessionBootstrap(sessionId: String): SessionDetailState {
val bootstrap = api.getSessionBootstrap(sessionId)
val timeline = bootstrap.messages.map { dto ->
MessageTimelineItem.RemoteMessage(dto.toDomainMessage())
}
return reduceSessionDetailState(
SessionDetailState(sessionId = bootstrap.sessionId),
SessionDetailEvent.BootstrapLoaded(
sessionId = bootstrap.sessionId,
timeline = timeline,
operations = emptyList(),
loadedAtMs = bootstrap.serverTs,
),
)
}
suspend fun retryAutoRecoverableMessages(sessionId: String): Boolean {
val candidates = messageStore[sessionId].orEmpty()
.filter { it.id in autoRetryMessageIds && it.isAutoRetryCandidate() }
@@ -51,6 +51,13 @@ class MobileGatewayApi(
}.body()
}
suspend fun getSessionBootstrap(sessionId: String): SessionBootstrapResponseDto {
val encodedId = sessionId.encodeURLPathPart()
return client.get("${baseUrl.trimEnd('/')}/api/sessions/$encodedId/bootstrap") {
authHeader()
}.body()
}
suspend fun sendMessage(sessionId: String, message: String): SendMessageResponseDto {
val encodedId = sessionId.encodeURLPathPart()
return client.post("${baseUrl.trimEnd('/')}/api/sessions/$encodedId/messages") {
@@ -74,6 +74,30 @@ data class UpdateDefaultAgentResponseDto(
val updatedAt: String,
)
@Serializable
data class SessionBootstrapResponseDto(
val sessionId: String,
val messages: List<ChatMessageDto> = emptyList(),
val operations: List<SessionBootstrapOperationDto> = emptyList(),
val streamState: String = "idle",
val serverTs: Long = 0,
)
@Serializable
data class SessionBootstrapOperationDto(
val opId: String,
val sessionId: String,
val type: String,
val state: String,
val createdAtMs: Long,
val clientRequestId: String,
val payloadSummary: String,
val attemptCount: Int = 0,
val lastError: String? = null,
val correlationToken: String? = null,
val materializedMessageIds: List<String> = emptyList(),
)
@Serializable
data class UploadAttachmentResponseDto(
@JsonNames("accepted", "accept")