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

Function run_non_interactive_attach

crates/opencode-cli/src/main.rs:1284–1331  ·  view source on GitHub ↗
(
    base_url: String,
    input: String,
    command: Option<String>,
    continue_last: bool,
    session: Option<String>,
    fork: bool,
    share: bool,
    model: Option<String>,
    variant: O

Source from the content-addressed store, hash-verified

1282}
1283
1284async fn run_non_interactive_attach(
1285 base_url: String,
1286 input: String,
1287 command: Option<String>,
1288 continue_last: bool,
1289 session: Option<String>,
1290 fork: bool,
1291 share: bool,
1292 model: Option<String>,
1293 variant: Option<String>,
1294 format: RunOutputFormat,
1295 title: Option<String>,
1296) -> anyhow::Result<()> {
1297 let client = reqwest::Client::new();
1298 let session_id =
1299 resolve_remote_session(&client, &base_url, continue_last, session, fork, title).await?;
1300 maybe_share_remote_session(&client, &base_url, &session_id, share).await?;
1301
1302 let content = if let Some(command_name) = command {
1303 if input.trim().is_empty() {
1304 format!("/{}", command_name)
1305 } else {
1306 format!("/{} {}", command_name, input)
1307 }
1308 } else {
1309 input
1310 };
1311
1312 let endpoint = server_url(&base_url, &format!("/session/{}/stream", session_id));
1313 let response = client
1314 .post(endpoint)
1315 .json(&serde_json::json!({
1316 "content": content,
1317 "model": model,
1318 "variant": variant,
1319 "stream": true
1320 }))
1321 .send()
1322 .await?;
1323
1324 if !response.status().is_success() {
1325 let status = response.status();
1326 let body = response.text().await.unwrap_or_default();
1327 anyhow::bail!("Remote run failed ({}): {}", status, body);
1328 }
1329
1330 consume_remote_sse(response, &session_id, format).await
1331}
1332
1333async fn run_non_interactive(
1334 message: Vec<String>,

Callers 1

run_non_interactiveFunction · 0.85

Calls 9

newFunction · 0.85
resolve_remote_sessionFunction · 0.85
server_urlFunction · 0.85
consume_remote_sseFunction · 0.85
is_emptyMethod · 0.80
sendMethod · 0.45
statusMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected