use crate::a2a::git_credentials::{GitCredentialQuery, request_git_credentials};
use anyhow::Result;
use reqwest::Client;
pub(super) async fn load_github_password(
workspace_id: &str,
host: String,
path: String,
) -> Result<Option<String>> {
let Ok(server) = std::env::var("CODETETHER_SERVER") else {
return Ok(None);
};
let credentials = request_git_credentials(
&server,
&std::env::var("CODETETHER_TOKEN").ok(),
std::env::var("CODETETHER_WORKER_ID").ok().as_deref(),
workspace_id,
"get",
&GitCredentialQuery {
protocol: Some("https".to_string()),
host: Some(host),
path: Some(path),
},
)
.await?;
Ok(credentials.map(|credentials| credentials.password))
}