This commit is contained in:
9 files changed
+203
-30
No files matched your search
@@ -0,0 +1,11 @@
|
||||
package com.m57.hermescontrol.data.model
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
/** Body for POST api/credentials/pool. `apiKey` serializes as `api_key`. */
|
||||
@Serializable
|
||||
data class CredentialPoolAddRequest(
|
||||
val provider: String,
|
||||
val apiKey: String,
|
||||
val label: String? = null,
|
||||
)
|
||||
@@ -9,3 +9,8 @@ data class DebugShareResponse(
|
||||
val redacted: Boolean? = null,
|
||||
val auto_delete_seconds: Long? = null,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class DebugShareRequest(
|
||||
val redact: Boolean? = null,
|
||||
)
|
||||
@@ -17,3 +17,19 @@ data class HookEntry(
|
||||
val approved_at: String? = null,
|
||||
val executable: Boolean? = null,
|
||||
)
|
||||
|
||||
/** Body for POST api/ops/hooks. The backend field is `approve` (writes the consent allowlist entry). */
|
||||
@Serializable
|
||||
data class HookCreateRequest(
|
||||
val event: String,
|
||||
val command: String,
|
||||
val matcher: String? = null,
|
||||
val timeout: Int? = null,
|
||||
val approve: Boolean? = null,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class HookDeleteRequest(
|
||||
val event: String,
|
||||
val command: String,
|
||||
)
|
||||
@@ -96,3 +96,9 @@ data class McpOAuthFlowResponse(
|
||||
val authorizationUrl: String? = null,
|
||||
val error: String? = null,
|
||||
)
|
||||
|
||||
/** Body for PUT api/mcp/servers/{name}; only the fields being changed are sent. */
|
||||
@Serializable
|
||||
data class McpServerUpdateRequest(
|
||||
val env: Map<String, String>? = null,
|
||||
)
|
||||
@@ -20,10 +20,12 @@ import com.m57.hermescontrol.data.model.CreateCronJobRequest
|
||||
import com.m57.hermescontrol.data.model.CreateProfileRequest
|
||||
import com.m57.hermescontrol.data.model.CreateTaskBody
|
||||
import com.m57.hermescontrol.data.model.CreateWebhookRequest
|
||||
import com.m57.hermescontrol.data.model.CredentialPoolAddRequest
|
||||
import com.m57.hermescontrol.data.model.CredentialPoolResponse
|
||||
import com.m57.hermescontrol.data.model.CronBlueprintListResponse
|
||||
import com.m57.hermescontrol.data.model.CronJob
|
||||
import com.m57.hermescontrol.data.model.CuratorResponse
|
||||
import com.m57.hermescontrol.data.model.DebugShareRequest
|
||||
import com.m57.hermescontrol.data.model.DebugShareResponse
|
||||
import com.m57.hermescontrol.data.model.DeleteWebhookResponse
|
||||
import com.m57.hermescontrol.data.model.DeliveryTargetsResponse
|
||||
@@ -38,6 +40,8 @@ import com.m57.hermescontrol.data.model.EnvVarUpdate
|
||||
import com.m57.hermescontrol.data.model.GatewayMigrationPlan
|
||||
import com.m57.hermescontrol.data.model.GatewayMigrationStartResponse
|
||||
import com.m57.hermescontrol.data.model.HealthStatus
|
||||
import com.m57.hermescontrol.data.model.HookCreateRequest
|
||||
import com.m57.hermescontrol.data.model.HookDeleteRequest
|
||||
import com.m57.hermescontrol.data.model.HookResponse
|
||||
import com.m57.hermescontrol.data.model.InstantiateBlueprintRequest
|
||||
import com.m57.hermescontrol.data.model.KanbanBoardResponse
|
||||
@@ -57,6 +61,7 @@ import com.m57.hermescontrol.data.model.McpOAuthFlowResponse
|
||||
import com.m57.hermescontrol.data.model.McpServer
|
||||
import com.m57.hermescontrol.data.model.McpServerTestResponse
|
||||
import com.m57.hermescontrol.data.model.McpServerToggleRequest
|
||||
import com.m57.hermescontrol.data.model.McpServerUpdateRequest
|
||||
import com.m57.hermescontrol.data.model.McpServersResponse
|
||||
import com.m57.hermescontrol.data.model.MemoryProviderConfigResponse
|
||||
import com.m57.hermescontrol.data.model.MemoryProviderConfigUpdateRequest
|
||||
@@ -583,7 +588,7 @@ interface HermesApiService : KanbanApiService {
|
||||
@PUT("api/mcp/servers/{name}")
|
||||
suspend fun updateMcpServer(
|
||||
@Path("name") name: String,
|
||||
@Body body: Map<String, Any>,
|
||||
@Body body: McpServerUpdateRequest,
|
||||
): Response<McpServer>
|
||||
|
||||
@POST("api/mcp/servers/{name}/auth")
|
||||
@@ -602,7 +607,7 @@ interface HermesApiService : KanbanApiService {
|
||||
@POST("api/mcp/catalog/install")
|
||||
suspend fun installMcpCatalogEntry(
|
||||
@Body body: McpCatalogInstallRequest,
|
||||
): Response<Map<String, Any>>
|
||||
): Response<ActionResponse>
|
||||
|
||||
@GET("api/webhooks")
|
||||
suspend fun getWebhooks(): Response<WebhooksResponse>
|
||||
@@ -881,7 +886,7 @@ interface HermesApiService : KanbanApiService {
|
||||
@PUT("api/curator/paused")
|
||||
suspend fun setCuratorPaused(
|
||||
@Body body: Map<String, Boolean>,
|
||||
): Response<Map<String, Any>>
|
||||
): Response<ActionResponse>
|
||||
|
||||
@POST("api/curator/run")
|
||||
suspend fun runCurator(): Response<ActionResponse>
|
||||
@@ -918,14 +923,14 @@ interface HermesApiService : KanbanApiService {
|
||||
|
||||
@POST("api/credentials/pool")
|
||||
suspend fun addCredentialPoolEntry(
|
||||
@Body body: Map<String, String>,
|
||||
): Response<Map<String, Any>>
|
||||
@Body body: CredentialPoolAddRequest,
|
||||
): Response<ActionResponse>
|
||||
|
||||
@DELETE("api/credentials/pool/{provider}/{index}")
|
||||
suspend fun removeCredentialPoolEntry(
|
||||
@Path("provider") provider: String,
|
||||
@Path("index") index: Int,
|
||||
): Response<Map<String, Any>>
|
||||
): Response<ActionResponse>
|
||||
|
||||
// ── Admin: Operations ─────────────────────────────────────────────
|
||||
@POST("api/ops/security-audit")
|
||||
@@ -968,7 +973,7 @@ interface HermesApiService : KanbanApiService {
|
||||
// ── Admin: Debug share ────────────────────────────────────────────
|
||||
@POST("api/ops/debug-share")
|
||||
suspend fun runDebugShare(
|
||||
@Body body: Map<String, Any>,
|
||||
@Body body: DebugShareRequest,
|
||||
): Response<DebugShareResponse>
|
||||
|
||||
// ── Admin: Checkpoints ────────────────────────────────────────────
|
||||
@@ -984,13 +989,13 @@ interface HermesApiService : KanbanApiService {
|
||||
|
||||
@POST("api/ops/hooks")
|
||||
suspend fun createHook(
|
||||
@Body body: Map<String, Any>,
|
||||
): Response<Map<String, Any>>
|
||||
@Body body: HookCreateRequest,
|
||||
): Response<ActionResponse>
|
||||
|
||||
@DELETE("api/ops/hooks")
|
||||
@HTTP(method = "DELETE", path = "api/ops/hooks", hasBody = true)
|
||||
suspend fun deleteHook(
|
||||
@Body body: Map<String, String>,
|
||||
): Response<Map<String, Any>>
|
||||
@Body body: HookDeleteRequest,
|
||||
): Response<ActionResponse>
|
||||
|
||||
// ── Admin: Action status (log viewer) ────────────────────────────
|
||||
@GET("api/actions/{name}/status")
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.m57.hermescontrol.data.model.McpOAuthFlowResponse
|
||||
import com.m57.hermescontrol.data.model.McpServer
|
||||
import com.m57.hermescontrol.data.model.McpServerTestResponse
|
||||
import com.m57.hermescontrol.data.model.McpServerToggleRequest
|
||||
import com.m57.hermescontrol.data.model.McpServerUpdateRequest
|
||||
import com.m57.hermescontrol.data.model.McpServersResponse
|
||||
import com.m57.hermescontrol.data.remote.ApiClient
|
||||
import com.m57.hermescontrol.data.remote.NetworkError
|
||||
@@ -458,7 +459,12 @@ class McpServersViewModel(
|
||||
val updatedEnv = existingEnv + (key to value)
|
||||
val result =
|
||||
withContext(ioDispatcher) {
|
||||
safeApiCall { ApiClient.hermesApi.updateMcpServer(serverName, mapOf("env" to updatedEnv)) }
|
||||
safeApiCall {
|
||||
ApiClient.hermesApi.updateMcpServer(
|
||||
serverName,
|
||||
McpServerUpdateRequest(env = updatedEnv),
|
||||
)
|
||||
}
|
||||
}
|
||||
when (result) {
|
||||
is NetworkResult.Success -> {
|
||||
@@ -490,7 +496,12 @@ class McpServersViewModel(
|
||||
val updatedEnv = existingEnv - key
|
||||
val result =
|
||||
withContext(ioDispatcher) {
|
||||
safeApiCall { ApiClient.hermesApi.updateMcpServer(serverName, mapOf("env" to updatedEnv)) }
|
||||
safeApiCall {
|
||||
ApiClient.hermesApi.updateMcpServer(
|
||||
serverName,
|
||||
McpServerUpdateRequest(env = updatedEnv),
|
||||
)
|
||||
}
|
||||
}
|
||||
when (result) {
|
||||
is NetworkResult.Success -> {
|
||||
|
||||
@@ -11,11 +11,15 @@ import com.m57.hermescontrol.data.model.ActionResponse
|
||||
import com.m57.hermescontrol.data.model.ActionStatusResponse
|
||||
import com.m57.hermescontrol.data.model.BackupTriggerRequest
|
||||
import com.m57.hermescontrol.data.model.CheckpointsResponse
|
||||
import com.m57.hermescontrol.data.model.CredentialPoolAddRequest
|
||||
import com.m57.hermescontrol.data.model.CredentialPoolProvider
|
||||
import com.m57.hermescontrol.data.model.CuratorResponse
|
||||
import com.m57.hermescontrol.data.model.DebugShareRequest
|
||||
import com.m57.hermescontrol.data.model.DebugShareResponse
|
||||
import com.m57.hermescontrol.data.model.DoctorResponse
|
||||
import com.m57.hermescontrol.data.model.GatewayMigrationPlan
|
||||
import com.m57.hermescontrol.data.model.HookCreateRequest
|
||||
import com.m57.hermescontrol.data.model.HookDeleteRequest
|
||||
import com.m57.hermescontrol.data.model.HookResponse
|
||||
import com.m57.hermescontrol.data.model.PortalResponse
|
||||
import com.m57.hermescontrol.data.model.StatusResponse
|
||||
@@ -531,11 +535,11 @@ class SystemViewModel(
|
||||
_uiState.update { it.copy(addingCred = true) }
|
||||
viewModelScope.launch {
|
||||
val body =
|
||||
buildMap {
|
||||
put("provider", state.credProvider)
|
||||
put("token", state.credKey)
|
||||
if (state.credLabel.isNotBlank()) put("label", state.credLabel)
|
||||
}
|
||||
CredentialPoolAddRequest(
|
||||
provider = state.credProvider,
|
||||
apiKey = state.credKey,
|
||||
label = state.credLabel.ifBlank { null },
|
||||
)
|
||||
val result =
|
||||
withContext(Dispatchers.IO) {
|
||||
safeApiCall { ApiClient.hermesApi.addCredentialPoolEntry(body) }
|
||||
@@ -780,7 +784,7 @@ class SystemViewModel(
|
||||
viewModelScope.launch {
|
||||
val result =
|
||||
withContext(Dispatchers.IO) {
|
||||
safeApiCall { ApiClient.hermesApi.runDebugShare(mapOf("redact" to shareRedact)) }
|
||||
safeApiCall { ApiClient.hermesApi.runDebugShare(DebugShareRequest(redact = shareRedact)) }
|
||||
}
|
||||
when (result) {
|
||||
is NetworkResult.Success -> {
|
||||
@@ -849,13 +853,13 @@ class SystemViewModel(
|
||||
_uiState.update { it.copy(creatingHook = true) }
|
||||
viewModelScope.launch {
|
||||
val body =
|
||||
buildMap<String, Any> {
|
||||
put("event", state.hookEvent)
|
||||
put("command", state.hookCommand)
|
||||
if (state.hookMatcher.isNotBlank()) put("matcher", state.hookMatcher)
|
||||
if (state.hookTimeout.isNotBlank()) put("timeout", state.hookTimeout.toIntOrNull() ?: 30)
|
||||
put("allowed", state.hookApprove)
|
||||
}
|
||||
HookCreateRequest(
|
||||
event = state.hookEvent,
|
||||
command = state.hookCommand,
|
||||
matcher = state.hookMatcher.ifBlank { null },
|
||||
timeout = if (state.hookTimeout.isBlank()) null else state.hookTimeout.toIntOrNull() ?: 30,
|
||||
approve = state.hookApprove,
|
||||
)
|
||||
val result =
|
||||
withContext(Dispatchers.IO) {
|
||||
safeApiCall { ApiClient.hermesApi.createHook(body) }
|
||||
@@ -894,7 +898,7 @@ class SystemViewModel(
|
||||
viewModelScope.launch {
|
||||
val result =
|
||||
withContext(Dispatchers.IO) {
|
||||
safeApiCall { ApiClient.hermesApi.deleteHook(mapOf("event" to event, "command" to command)) }
|
||||
safeApiCall { ApiClient.hermesApi.deleteHook(HookDeleteRequest(event, command)) }
|
||||
}
|
||||
when (result) {
|
||||
is NetworkResult.Success -> {
|
||||
|
||||
Reference in new issue
Block a user