MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / execute_shell

Function execute_shell

crates/opencode-server/src/routes.rs:1939–1961  ·  view source on GitHub ↗
(
    State(state): State<Arc<ServerState>>,
    Path(id): Path<String>,
    Json(req): Json<ExecuteShellRequest>,
)

Source from the content-addressed store, hash-verified

1937}
1938
1939async 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)]
1964pub struct TextPartInput {

Callers

nothing calls this directly

Calls 6

add_textMethod · 0.80
get_mutMethod · 0.45
cloneMethod · 0.45
add_user_messageMethod · 0.45
add_assistant_messageMethod · 0.45

Tested by

no test coverage detected