(
State(state): State<Arc<ServerState>>,
Path(id): Path<String>,
Json(req): Json<ExecuteShellRequest>,
)
| 1937 | } |
| 1938 | |
| 1939 | async fn execute_shell( |
| 1940 | State(state): State<Arc<ServerState>>, |
| 1941 | Path(id): Path<String>, |
| 1942 | Json(req): Json<ExecuteShellRequest>, |
| 1943 | ) -> Result<Json<serde_json::Value>> { |
| 1944 | let mut sessions = state.sessions.lock().await; |
| 1945 | let session = sessions |
| 1946 | .get_mut(&id) |
| 1947 | .ok_or_else(|| ApiError::SessionNotFound(id.clone()))?; |
| 1948 | session.add_user_message(format!("$ {}", req.command)); |
| 1949 | let assistant = session.add_assistant_message(); |
| 1950 | assistant.add_text(format!("Shell command queued: {}", req.command)); |
| 1951 | let assistant_id = assistant.id.clone(); |
| 1952 | drop(sessions); |
| 1953 | persist_sessions_if_enabled(&state).await; |
| 1954 | |
| 1955 | Ok(Json(serde_json::json!({ |
| 1956 | "executed": true, |
| 1957 | "command": req.command, |
| 1958 | "workdir": req.workdir, |
| 1959 | "message_id": assistant_id, |
| 1960 | }))) |
| 1961 | } |
| 1962 | |
| 1963 | #[derive(Debug, Deserialize)] |
| 1964 | pub struct TextPartInput { |
nothing calls this directly
no test coverage detected