6 files changed
+111
-27
No files matched your search
@@ -3,6 +3,9 @@ package com.m57.hermescontrol.data.ws
|
||||
import android.util.Log
|
||||
import com.m57.hermescontrol.data.model.SubagentListResponse
|
||||
import com.m57.hermescontrol.data.model.SubagentTailResponse
|
||||
import com.m57.hermescontrol.data.ws.contract.RpcMethods
|
||||
import com.m57.hermescontrol.data.ws.contract.SessionIdParams
|
||||
import com.m57.hermescontrol.data.ws.contract.SubagentTailParams
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonArray
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
@@ -33,12 +36,11 @@ object SubagentRepository {
|
||||
if (sessionId.isBlank()) return null
|
||||
return try {
|
||||
val result =
|
||||
HermesWsClient
|
||||
.request(
|
||||
WsMethods.SUBAGENT_LIST,
|
||||
mapOf("session_id" to sessionId),
|
||||
suppressErrorEvent = true,
|
||||
).await()
|
||||
HermesWsClient.call(
|
||||
RpcMethods.SUBAGENT_LIST,
|
||||
SessionIdParams(sessionId),
|
||||
suppressErrorEvent = true,
|
||||
)
|
||||
decode<SubagentListResponse>(result)
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "subagent.list request failed for session $sessionId: ${e.message}")
|
||||
@@ -58,18 +60,12 @@ object SubagentRepository {
|
||||
): SubagentTailResponse? {
|
||||
// Contract (SubagentIdParams): session_id and subagent_id are required, extra keys forbidden (#1379).
|
||||
if (subagentId.isBlank() || sessionId.isBlank()) return null
|
||||
val params =
|
||||
mapOf<String, Any>(
|
||||
"session_id" to sessionId,
|
||||
"subagent_id" to subagentId,
|
||||
)
|
||||
val result =
|
||||
HermesWsClient
|
||||
.request(
|
||||
WsMethods.SUBAGENT_TAIL,
|
||||
params,
|
||||
suppressErrorEvent = true,
|
||||
).await()
|
||||
HermesWsClient.call(
|
||||
RpcMethods.SUBAGENT_TAIL,
|
||||
SubagentTailParams(sessionId, subagentId),
|
||||
suppressErrorEvent = true,
|
||||
)
|
||||
return decode<SubagentTailResponse>(result)
|
||||
}
|
||||
|
||||
|
||||
@@ -331,6 +331,22 @@ object RpcMethods {
|
||||
JsonElement.serializer(),
|
||||
)
|
||||
|
||||
// Passthrough JsonElement results: callers keep their existing legacy decoders.
|
||||
val SUBAGENT_LIST: RpcMethod<SessionIdParams, JsonElement> =
|
||||
RpcMethod(
|
||||
WsMethods.SUBAGENT_LIST,
|
||||
SessionIdParams.serializer(),
|
||||
JsonElement.serializer(),
|
||||
)
|
||||
|
||||
// Passthrough JsonElement results: callers keep their existing legacy decoders.
|
||||
val SUBAGENT_TAIL: RpcMethod<SubagentTailParams, JsonElement> =
|
||||
RpcMethod(
|
||||
WsMethods.SUBAGENT_TAIL,
|
||||
SubagentTailParams.serializer(),
|
||||
JsonElement.serializer(),
|
||||
)
|
||||
|
||||
/** Every typed method. GatewayContractTest iterates this; future migrations append here. */
|
||||
val all: List<RpcMethod<*, *>> =
|
||||
listOf(
|
||||
@@ -374,5 +390,7 @@ object RpcMethods {
|
||||
CONNECTORS_TOOLS,
|
||||
CONNECTION_RESPOND,
|
||||
CONNECTORS_OPERATION_WAKE,
|
||||
SUBAGENT_LIST,
|
||||
SUBAGENT_TAIL,
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.m57.hermescontrol.data.ws.contract
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class SubagentTailParams(
|
||||
@SerialName("session_id") val sessionId: String,
|
||||
@SerialName("subagent_id") val subagentId: String,
|
||||
)
|
||||
Reference in new issue
Block a user