release: promote dev to main for v2.0.0 (#1426)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Lx-204 <15377891490@163.com>
Co-authored-by: AlexDev_ <56083016+alexdev03@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Nikhil Nair <32665919+nikhilnair31@users.noreply.github.com>
Co-authored-by: marciodps <95321123+marciodps@users.noreply.github.com>
Co-authored-by: ThomasCrund <39323104+ThomasCrund@users.noreply.github.com>
This commit is contained in:
m57
2026-10-01 11:19:09 +03:00
committed by GitHub
co-authored by Lx-204 AlexDev_ dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Nikhil Nair marciodps ThomasCrund
parent ed915d0816
commit 728daa9acd
315 changed files with 65173 additions and 7909 deletions
@@ -11,7 +11,9 @@ import com.m57.hermescontrol.R
import com.m57.hermescontrol.data.local.AuthManager
import com.m57.hermescontrol.data.session.ActiveSessionHolder
import com.m57.hermescontrol.data.ws.HermesWsClient
import com.m57.hermescontrol.data.ws.WsMethods
import com.m57.hermescontrol.data.ws.contract.PromptSubmitParams
import com.m57.hermescontrol.data.ws.contract.RpcMethods
import com.m57.hermescontrol.data.ws.contract.SessionResumeParams
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
@@ -25,6 +27,9 @@ open class NotificationReplyReceiver : BroadcastReceiver() {
const val EXTRA_SESSION_ID = "extra_session_id"
private const val REPLY_TIMEOUT_MS = 5_000L
/** Overall deadline for persisting and submitting one notification reply. */
private const val PERSISTENCE_TIMEOUT_MS = 5_000L
/**
* Turn-boundary read budget inside the reply deadline. Deliberately tight:
* the probe sits on the reply path, so a slow or unreachable gateway must
@@ -44,6 +49,9 @@ open class NotificationReplyReceiver : BroadcastReceiver() {
*/
internal open fun goAsyncCompat(): BroadcastReceiver.PendingResult = goAsync()
/** Overridable so tests can prove the timeout path without waiting 5s. */
internal open val persistenceTimeoutMs: Long get() = PERSISTENCE_TIMEOUT_MS
/**
* Test-friendly wrapper for notification creation. Override in tests to
* avoid [NotificationCompat.Builder.build()] calling Android framework
@@ -75,7 +83,7 @@ open class NotificationReplyReceiver : BroadcastReceiver() {
val pendingResult = goAsyncCompat()
replyScope.launch {
try {
withTimeout(5000L) {
withTimeout(persistenceTimeoutMs) {
withContext(Dispatchers.IO) {
val db =
com.m57.hermescontrol.data.local.HermesDatabase
@@ -103,12 +111,11 @@ open class NotificationReplyReceiver : BroadcastReceiver() {
val runtimeSessionId =
ActiveSessionHolder.resolveRuntimeSessionId(sessionId)
?: resumeSession(sessionId)
HermesWsClient
.request(
WsMethods.PROMPT_SUBMIT,
mapOf("session_id" to runtimeSessionId, "text" to replyText),
timeoutMs = REPLY_TIMEOUT_MS,
).await()
HermesWsClient.call(
method = RpcMethods.PROMPT_SUBMIT,
params = PromptSubmitParams(sessionId = runtimeSessionId, text = replyText),
timeoutMs = REPLY_TIMEOUT_MS,
)
val entity =
com.m57.hermescontrol.data.local.ChatMessageEntity(
@@ -146,24 +153,21 @@ open class NotificationReplyReceiver : BroadcastReceiver() {
}
private suspend fun resumeSession(storedSessionId: String): String {
val profile = AuthManager.activeProfileId.value
val profile = AuthManager.activeProfileId.value?.takeIf { it.isNotBlank() }
val params =
mutableMapOf<String, Any>(
"session_id" to storedSessionId,
"omit_messages" to true,
SessionResumeParams(
sessionId = storedSessionId,
omitMessages = true,
profile = profile,
)
if (!profile.isNullOrBlank()) {
params["profile"] = profile
}
val result =
HermesWsClient
.request(
WsMethods.SESSION_RESUME,
params,
timeoutMs = REPLY_TIMEOUT_MS,
).await() as? Map<*, *>
HermesWsClient.call(
method = RpcMethods.SESSION_RESUME,
params = params,
timeoutMs = REPLY_TIMEOUT_MS,
)
val runtimeSessionId =
(result?.get("session_id") as? String)?.takeIf { it.isNotBlank() }
result.sessionId?.takeIf { it.isNotBlank() }
?: error("Resume returned no runtime session id")
ActiveSessionHolder.set(runtimeSessionId, storedSessionId)
return runtimeSessionId