Stringly typed config (#5463)
This commit is contained in:
@@ -10,7 +10,7 @@ use tokio::process::Command;
|
||||
use super::base::{ConfigKey, Provider, ProviderMetadata, ProviderUsage, Usage};
|
||||
use super::errors::ProviderError;
|
||||
use super::utils::RequestLog;
|
||||
use crate::config::Config;
|
||||
use crate::config::{Config, GooseMode};
|
||||
use crate::conversation::message::{Message, MessageContent};
|
||||
use crate::model::ModelConfig;
|
||||
use rmcp::model::Tool;
|
||||
@@ -338,10 +338,8 @@ impl ClaudeCodeProvider {
|
||||
|
||||
// Add permission mode based on GOOSE_MODE setting
|
||||
let config = Config::global();
|
||||
if let Ok(goose_mode) = config.get_param::<String>("GOOSE_MODE") {
|
||||
if goose_mode.as_str() == "auto" {
|
||||
cmd.arg("--permission-mode").arg("acceptEdits");
|
||||
}
|
||||
if let Ok(GooseMode::Auto) = config.get_goose_mode() {
|
||||
cmd.arg("--permission-mode").arg("acceptEdits");
|
||||
}
|
||||
|
||||
cmd.stdout(Stdio::piped()).stderr(Stdio::piped());
|
||||
@@ -523,18 +521,6 @@ mod tests {
|
||||
use super::ModelConfig;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_permission_mode_flag_construction() {
|
||||
// Test that in auto mode, the --permission-mode acceptEdits flag is added
|
||||
std::env::set_var("GOOSE_MODE", "auto");
|
||||
|
||||
let config = Config::global();
|
||||
let goose_mode: String = config.get_param("GOOSE_MODE").unwrap();
|
||||
assert_eq!(goose_mode, "auto");
|
||||
|
||||
std::env::remove_var("GOOSE_MODE");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_claude_code_invalid_model_no_fallback() {
|
||||
// Test that an invalid model is kept as-is (no fallback)
|
||||
|
||||
@@ -235,7 +235,7 @@ impl GithubCopilotProvider {
|
||||
.get_access_token()
|
||||
.await
|
||||
.context("unable to login into github")?;
|
||||
config.set_secret("GITHUB_COPILOT_TOKEN", Value::String(token.clone()))?;
|
||||
config.set_secret("GITHUB_COPILOT_TOKEN", &token)?;
|
||||
token
|
||||
}
|
||||
_ => return Err(err.into()),
|
||||
@@ -500,7 +500,7 @@ impl Provider for GithubCopilotProvider {
|
||||
|
||||
// Save the token
|
||||
config
|
||||
.set_secret("GITHUB_COPILOT_TOKEN", Value::String(token))
|
||||
.set_secret("GITHUB_COPILOT_TOKEN", &token)
|
||||
.map_err(|e| ProviderError::ExecutionError(format!("Failed to save token: {}", e)))?;
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -6,6 +6,7 @@ use super::utils::{
|
||||
get_model, handle_response_openai_compat, handle_status_openai_compat, RequestLog,
|
||||
};
|
||||
use crate::config::declarative_providers::DeclarativeProviderConfig;
|
||||
use crate::config::GooseMode;
|
||||
use crate::conversation::message::Message;
|
||||
use crate::conversation::Conversation;
|
||||
|
||||
@@ -199,8 +200,12 @@ impl Provider for OllamaProvider {
|
||||
tools: &[Tool],
|
||||
) -> Result<(Message, ProviderUsage), ProviderError> {
|
||||
let config = crate::config::Config::global();
|
||||
let goose_mode = config.get_param("GOOSE_MODE").unwrap_or("auto".to_string());
|
||||
let filtered_tools = if goose_mode == "chat" { &[] } else { tools };
|
||||
let goose_mode = config.get_goose_mode().unwrap_or(GooseMode::Auto);
|
||||
let filtered_tools = if goose_mode == GooseMode::Chat {
|
||||
&[]
|
||||
} else {
|
||||
tools
|
||||
};
|
||||
|
||||
let payload = create_request(
|
||||
&self.model,
|
||||
|
||||
Reference in New Issue
Block a user