mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
Stop using AuthManager as the source of codex_home (#8846)
This commit is contained in:
1 parent
c31960b13a
commit
018de994b0
13 files changed
+79
-47
No files matched your search
@@ -52,6 +52,7 @@ impl MessageProcessor {
|
|||||||
config.cli_auth_credentials_store_mode,
|
config.cli_auth_credentials_store_mode,
|
||||||
);
|
);
|
||||||
let thread_manager = Arc::new(ThreadManager::new(
|
let thread_manager = Arc::new(ThreadManager::new(
|
||||||
|
config.codex_home.clone(),
|
||||||
auth_manager.clone(),
|
auth_manager.clone(),
|
||||||
SessionSource::VSCode,
|
SessionSource::VSCode,
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -32,11 +32,7 @@ use crate::token_data::parse_id_token;
|
|||||||
use crate::util::try_parse_error_message;
|
use crate::util::try_parse_error_message;
|
||||||
use codex_client::CodexHttpClient;
|
use codex_client::CodexHttpClient;
|
||||||
use codex_protocol::account::PlanType as AccountPlanType;
|
use codex_protocol::account::PlanType as AccountPlanType;
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
|
||||||
use tempfile::TempDir;
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@@ -66,9 +62,6 @@ const REFRESH_TOKEN_UNKNOWN_MESSAGE: &str =
|
|||||||
const REFRESH_TOKEN_URL: &str = "https://auth.openai.com/oauth/token";
|
const REFRESH_TOKEN_URL: &str = "https://auth.openai.com/oauth/token";
|
||||||
pub const REFRESH_TOKEN_URL_OVERRIDE_ENV_VAR: &str = "CODEX_REFRESH_TOKEN_URL_OVERRIDE";
|
pub const REFRESH_TOKEN_URL_OVERRIDE_ENV_VAR: &str = "CODEX_REFRESH_TOKEN_URL_OVERRIDE";
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
|
||||||
static TEST_AUTH_TEMP_DIRS: Lazy<Mutex<Vec<TempDir>>> = Lazy::new(|| Mutex::new(Vec::new()));
|
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum RefreshTokenError {
|
pub enum RefreshTokenError {
|
||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
@@ -672,18 +665,12 @@ impl AuthManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
#[expect(clippy::expect_used)]
|
|
||||||
/// Create an AuthManager with a specific CodexAuth, for testing only.
|
/// Create an AuthManager with a specific CodexAuth, for testing only.
|
||||||
pub fn from_auth_for_testing(auth: CodexAuth) -> Arc<Self> {
|
pub fn from_auth_for_testing(auth: CodexAuth) -> Arc<Self> {
|
||||||
let cached = CachedAuth { auth: Some(auth) };
|
let cached = CachedAuth { auth: Some(auth) };
|
||||||
let temp_dir = tempfile::tempdir().expect("temp codex home");
|
|
||||||
let codex_home = temp_dir.path().to_path_buf();
|
|
||||||
TEST_AUTH_TEMP_DIRS
|
|
||||||
.lock()
|
|
||||||
.expect("lock test codex homes")
|
|
||||||
.push(temp_dir);
|
|
||||||
Arc::new(Self {
|
Arc::new(Self {
|
||||||
codex_home,
|
codex_home: PathBuf::from("non-existent"),
|
||||||
inner: RwLock::new(cached),
|
inner: RwLock::new(cached),
|
||||||
enable_codex_api_key_env: false,
|
enable_codex_api_key_env: false,
|
||||||
auth_credentials_store_mode: AuthCredentialsStoreMode::File,
|
auth_credentials_store_mode: AuthCredentialsStoreMode::File,
|
||||||
@@ -707,10 +694,6 @@ impl AuthManager {
|
|||||||
self.inner.read().ok().and_then(|c| c.auth.clone())
|
self.inner.read().ok().and_then(|c| c.auth.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn codex_home(&self) -> &Path {
|
|
||||||
&self.codex_home
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Force a reload of the auth information from auth.json. Returns
|
/// Force a reload of the auth information from auth.json. Returns
|
||||||
/// whether the auth value changed.
|
/// whether the auth value changed.
|
||||||
pub fn reload(&self) -> bool {
|
pub fn reload(&self) -> bool {
|
||||||
|
|||||||
@@ -3479,7 +3479,10 @@ mod tests {
|
|||||||
let conversation_id = ThreadId::default();
|
let conversation_id = ThreadId::default();
|
||||||
let auth_manager =
|
let auth_manager =
|
||||||
AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
|
AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
|
||||||
let models_manager = Arc::new(ModelsManager::new(auth_manager.clone()));
|
let models_manager = Arc::new(ModelsManager::new(
|
||||||
|
config.codex_home.clone(),
|
||||||
|
auth_manager.clone(),
|
||||||
|
));
|
||||||
let agent_control = AgentControl::default();
|
let agent_control = AgentControl::default();
|
||||||
let exec_policy = ExecPolicyManager::default();
|
let exec_policy = ExecPolicyManager::default();
|
||||||
let agent_status = Arc::new(RwLock::new(AgentStatus::PendingInit));
|
let agent_status = Arc::new(RwLock::new(AgentStatus::PendingInit));
|
||||||
@@ -3570,7 +3573,10 @@ mod tests {
|
|||||||
let conversation_id = ThreadId::default();
|
let conversation_id = ThreadId::default();
|
||||||
let auth_manager =
|
let auth_manager =
|
||||||
AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
|
AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
|
||||||
let models_manager = Arc::new(ModelsManager::new(auth_manager.clone()));
|
let models_manager = Arc::new(ModelsManager::new(
|
||||||
|
config.codex_home.clone(),
|
||||||
|
auth_manager.clone(),
|
||||||
|
));
|
||||||
let agent_control = AgentControl::default();
|
let agent_control = AgentControl::default();
|
||||||
let exec_policy = ExecPolicyManager::default();
|
let exec_policy = ExecPolicyManager::default();
|
||||||
let agent_status = Arc::new(RwLock::new(AgentStatus::PendingInit));
|
let agent_status = Arc::new(RwLock::new(AgentStatus::PendingInit));
|
||||||
|
|||||||
@@ -47,8 +47,7 @@ pub struct ModelsManager {
|
|||||||
|
|
||||||
impl ModelsManager {
|
impl ModelsManager {
|
||||||
/// Construct a manager scoped to the provided `AuthManager`.
|
/// Construct a manager scoped to the provided `AuthManager`.
|
||||||
pub fn new(auth_manager: Arc<AuthManager>) -> Self {
|
pub fn new(codex_home: PathBuf, auth_manager: Arc<AuthManager>) -> Self {
|
||||||
let codex_home = auth_manager.codex_home().to_path_buf();
|
|
||||||
Self {
|
Self {
|
||||||
local_models: builtin_model_presets(auth_manager.get_auth_mode()),
|
local_models: builtin_model_presets(auth_manager.get_auth_mode()),
|
||||||
remote_models: RwLock::new(Self::load_remote_models_from_file().unwrap_or_default()),
|
remote_models: RwLock::new(Self::load_remote_models_from_file().unwrap_or_default()),
|
||||||
@@ -62,8 +61,11 @@ impl ModelsManager {
|
|||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
/// Construct a manager scoped to the provided `AuthManager` with a specific provider. Used for integration tests.
|
/// Construct a manager scoped to the provided `AuthManager` with a specific provider. Used for integration tests.
|
||||||
pub fn with_provider(auth_manager: Arc<AuthManager>, provider: ModelProviderInfo) -> Self {
|
pub fn with_provider(
|
||||||
let codex_home = auth_manager.codex_home().to_path_buf();
|
codex_home: PathBuf,
|
||||||
|
auth_manager: Arc<AuthManager>,
|
||||||
|
provider: ModelProviderInfo,
|
||||||
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
local_models: builtin_model_presets(auth_manager.get_auth_mode()),
|
local_models: builtin_model_presets(auth_manager.get_auth_mode()),
|
||||||
remote_models: RwLock::new(Self::load_remote_models_from_file().unwrap_or_default()),
|
remote_models: RwLock::new(Self::load_remote_models_from_file().unwrap_or_default()),
|
||||||
@@ -422,7 +424,8 @@ mod tests {
|
|||||||
let auth_manager =
|
let auth_manager =
|
||||||
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
|
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
|
||||||
let provider = provider_for(server.uri());
|
let provider = provider_for(server.uri());
|
||||||
let manager = ModelsManager::with_provider(auth_manager, provider);
|
let manager =
|
||||||
|
ModelsManager::with_provider(codex_home.path().to_path_buf(), auth_manager, provider);
|
||||||
|
|
||||||
manager
|
manager
|
||||||
.refresh_available_models_with_cache(&config)
|
.refresh_available_models_with_cache(&config)
|
||||||
@@ -481,7 +484,8 @@ mod tests {
|
|||||||
AuthCredentialsStoreMode::File,
|
AuthCredentialsStoreMode::File,
|
||||||
));
|
));
|
||||||
let provider = provider_for(server.uri());
|
let provider = provider_for(server.uri());
|
||||||
let manager = ModelsManager::with_provider(auth_manager, provider);
|
let manager =
|
||||||
|
ModelsManager::with_provider(codex_home.path().to_path_buf(), auth_manager, provider);
|
||||||
|
|
||||||
manager
|
manager
|
||||||
.refresh_available_models_with_cache(&config)
|
.refresh_available_models_with_cache(&config)
|
||||||
@@ -535,7 +539,8 @@ mod tests {
|
|||||||
AuthCredentialsStoreMode::File,
|
AuthCredentialsStoreMode::File,
|
||||||
));
|
));
|
||||||
let provider = provider_for(server.uri());
|
let provider = provider_for(server.uri());
|
||||||
let manager = ModelsManager::with_provider(auth_manager, provider);
|
let manager =
|
||||||
|
ModelsManager::with_provider(codex_home.path().to_path_buf(), auth_manager, provider);
|
||||||
|
|
||||||
manager
|
manager
|
||||||
.refresh_available_models_with_cache(&config)
|
.refresh_available_models_with_cache(&config)
|
||||||
@@ -605,7 +610,8 @@ mod tests {
|
|||||||
let auth_manager =
|
let auth_manager =
|
||||||
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
|
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
|
||||||
let provider = provider_for(server.uri());
|
let provider = provider_for(server.uri());
|
||||||
let mut manager = ModelsManager::with_provider(auth_manager, provider);
|
let mut manager =
|
||||||
|
ModelsManager::with_provider(codex_home.path().to_path_buf(), auth_manager, provider);
|
||||||
manager.cache_ttl = Duration::ZERO;
|
manager.cache_ttl = Duration::ZERO;
|
||||||
|
|
||||||
manager
|
manager
|
||||||
@@ -653,10 +659,12 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn build_available_models_picks_default_after_hiding_hidden_models() {
|
fn build_available_models_picks_default_after_hiding_hidden_models() {
|
||||||
|
let codex_home = tempdir().expect("temp dir");
|
||||||
let auth_manager =
|
let auth_manager =
|
||||||
AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
|
AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
|
||||||
let provider = provider_for("http://example.test".to_string());
|
let provider = provider_for("http://example.test".to_string());
|
||||||
let mut manager = ModelsManager::with_provider(auth_manager, provider);
|
let mut manager =
|
||||||
|
ModelsManager::with_provider(codex_home.path().to_path_buf(), auth_manager, provider);
|
||||||
manager.local_models = Vec::new();
|
manager.local_models = Vec::new();
|
||||||
|
|
||||||
let hidden_model = remote_model_with_visibility("hidden", "Hidden", 0, "hide");
|
let hidden_model = remote_model_with_visibility("hidden", "Hidden", 0, "hide");
|
||||||
|
|||||||
@@ -59,14 +59,19 @@ pub(crate) struct ThreadManagerState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ThreadManager {
|
impl ThreadManager {
|
||||||
pub fn new(auth_manager: Arc<AuthManager>, session_source: SessionSource) -> Self {
|
pub fn new(
|
||||||
|
codex_home: PathBuf,
|
||||||
|
auth_manager: Arc<AuthManager>,
|
||||||
|
session_source: SessionSource,
|
||||||
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state: Arc::new(ThreadManagerState {
|
state: Arc::new(ThreadManagerState {
|
||||||
threads: Arc::new(RwLock::new(HashMap::new())),
|
threads: Arc::new(RwLock::new(HashMap::new())),
|
||||||
models_manager: Arc::new(ModelsManager::new(auth_manager.clone())),
|
models_manager: Arc::new(ModelsManager::new(
|
||||||
skills_manager: Arc::new(SkillsManager::new(
|
codex_home.clone(),
|
||||||
auth_manager.codex_home().to_path_buf(),
|
auth_manager.clone(),
|
||||||
)),
|
)),
|
||||||
|
skills_manager: Arc::new(SkillsManager::new(codex_home)),
|
||||||
auth_manager,
|
auth_manager,
|
||||||
session_source,
|
session_source,
|
||||||
}),
|
}),
|
||||||
@@ -94,17 +99,16 @@ impl ThreadManager {
|
|||||||
provider: ModelProviderInfo,
|
provider: ModelProviderInfo,
|
||||||
codex_home: PathBuf,
|
codex_home: PathBuf,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let auth_manager = AuthManager::from_auth_for_testing_with_home(auth, codex_home);
|
let auth_manager = AuthManager::from_auth_for_testing(auth);
|
||||||
Self {
|
Self {
|
||||||
state: Arc::new(ThreadManagerState {
|
state: Arc::new(ThreadManagerState {
|
||||||
threads: Arc::new(RwLock::new(HashMap::new())),
|
threads: Arc::new(RwLock::new(HashMap::new())),
|
||||||
models_manager: Arc::new(ModelsManager::with_provider(
|
models_manager: Arc::new(ModelsManager::with_provider(
|
||||||
|
codex_home.clone(),
|
||||||
auth_manager.clone(),
|
auth_manager.clone(),
|
||||||
provider,
|
provider,
|
||||||
)),
|
)),
|
||||||
skills_manager: Arc::new(SkillsManager::new(
|
skills_manager: Arc::new(SkillsManager::new(codex_home)),
|
||||||
auth_manager.codex_home().to_path_buf(),
|
|
||||||
)),
|
|
||||||
auth_manager,
|
auth_manager,
|
||||||
session_source: SessionSource::Exec,
|
session_source: SessionSource::Exec,
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -574,7 +574,11 @@ async fn prefers_apikey_when_config_prefers_apikey_even_with_chatgpt_tokens() {
|
|||||||
Ok(None) => panic!("No CodexAuth found in codex_home"),
|
Ok(None) => panic!("No CodexAuth found in codex_home"),
|
||||||
Err(e) => panic!("Failed to load CodexAuth: {e}"),
|
Err(e) => panic!("Failed to load CodexAuth: {e}"),
|
||||||
};
|
};
|
||||||
let thread_manager = ThreadManager::new(auth_manager, SessionSource::Exec);
|
let thread_manager = ThreadManager::new(
|
||||||
|
codex_home.path().to_path_buf(),
|
||||||
|
auth_manager,
|
||||||
|
SessionSource::Exec,
|
||||||
|
);
|
||||||
let NewThread { thread: codex, .. } = thread_manager
|
let NewThread { thread: codex, .. } = thread_manager
|
||||||
.start_thread(config)
|
.start_thread(config)
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -320,6 +320,7 @@ async fn remote_models_preserve_builtin_presets() -> Result<()> {
|
|||||||
..built_in_model_providers()["openai"].clone()
|
..built_in_model_providers()["openai"].clone()
|
||||||
};
|
};
|
||||||
let manager = ModelsManager::with_provider(
|
let manager = ModelsManager::with_provider(
|
||||||
|
codex_home.path().to_path_buf(),
|
||||||
codex_core::auth::AuthManager::from_auth_for_testing(auth),
|
codex_core::auth::AuthManager::from_auth_for_testing(auth),
|
||||||
provider,
|
provider,
|
||||||
);
|
);
|
||||||
@@ -377,6 +378,7 @@ async fn remote_models_hide_picker_only_models() -> Result<()> {
|
|||||||
..built_in_model_providers()["openai"].clone()
|
..built_in_model_providers()["openai"].clone()
|
||||||
};
|
};
|
||||||
let manager = ModelsManager::with_provider(
|
let manager = ModelsManager::with_provider(
|
||||||
|
codex_home.path().to_path_buf(),
|
||||||
codex_core::auth::AuthManager::from_auth_for_testing(auth),
|
codex_core::auth::AuthManager::from_auth_for_testing(auth),
|
||||||
provider,
|
provider,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -286,7 +286,11 @@ pub async fn run_main(cli: Cli, codex_linux_sandbox_exe: Option<PathBuf>) -> any
|
|||||||
true,
|
true,
|
||||||
config.cli_auth_credentials_store_mode,
|
config.cli_auth_credentials_store_mode,
|
||||||
);
|
);
|
||||||
let thread_manager = ThreadManager::new(auth_manager.clone(), SessionSource::Exec);
|
let thread_manager = ThreadManager::new(
|
||||||
|
config.codex_home.clone(),
|
||||||
|
auth_manager.clone(),
|
||||||
|
SessionSource::Exec,
|
||||||
|
);
|
||||||
let default_model = thread_manager
|
let default_model = thread_manager
|
||||||
.get_models_manager()
|
.get_models_manager()
|
||||||
.get_model(&config.model, &config)
|
.get_model(&config.model, &config)
|
||||||
|
|||||||
@@ -58,7 +58,11 @@ impl MessageProcessor {
|
|||||||
false,
|
false,
|
||||||
config.cli_auth_credentials_store_mode,
|
config.cli_auth_credentials_store_mode,
|
||||||
);
|
);
|
||||||
let thread_manager = Arc::new(ThreadManager::new(auth_manager, SessionSource::Mcp));
|
let thread_manager = Arc::new(ThreadManager::new(
|
||||||
|
config.codex_home.clone(),
|
||||||
|
auth_manager,
|
||||||
|
SessionSource::Mcp,
|
||||||
|
));
|
||||||
Self {
|
Self {
|
||||||
outgoing,
|
outgoing,
|
||||||
initialized: false,
|
initialized: false,
|
||||||
|
|||||||
@@ -344,7 +344,11 @@ impl App {
|
|||||||
let (app_event_tx, mut app_event_rx) = unbounded_channel();
|
let (app_event_tx, mut app_event_rx) = unbounded_channel();
|
||||||
let app_event_tx = AppEventSender::new(app_event_tx);
|
let app_event_tx = AppEventSender::new(app_event_tx);
|
||||||
|
|
||||||
let thread_manager = Arc::new(ThreadManager::new(auth_manager.clone(), SessionSource::Cli));
|
let thread_manager = Arc::new(ThreadManager::new(
|
||||||
|
config.codex_home.clone(),
|
||||||
|
auth_manager.clone(),
|
||||||
|
SessionSource::Cli,
|
||||||
|
));
|
||||||
let mut model = thread_manager
|
let mut model = thread_manager
|
||||||
.get_models_manager()
|
.get_models_manager()
|
||||||
.get_model(&config.model, &config)
|
.get_model(&config.model, &config)
|
||||||
|
|||||||
@@ -366,6 +366,7 @@ async fn make_chatwidget_manual(
|
|||||||
skills: None,
|
skills: None,
|
||||||
});
|
});
|
||||||
let auth_manager = AuthManager::from_auth_for_testing(CodexAuth::from_api_key("test"));
|
let auth_manager = AuthManager::from_auth_for_testing(CodexAuth::from_api_key("test"));
|
||||||
|
let codex_home = cfg.codex_home.clone();
|
||||||
let widget = ChatWidget {
|
let widget = ChatWidget {
|
||||||
app_event_tx,
|
app_event_tx,
|
||||||
codex_op_tx: op_tx,
|
codex_op_tx: op_tx,
|
||||||
@@ -374,7 +375,7 @@ async fn make_chatwidget_manual(
|
|||||||
config: cfg,
|
config: cfg,
|
||||||
model: resolved_model.clone(),
|
model: resolved_model.clone(),
|
||||||
auth_manager: auth_manager.clone(),
|
auth_manager: auth_manager.clone(),
|
||||||
models_manager: Arc::new(ModelsManager::new(auth_manager)),
|
models_manager: Arc::new(ModelsManager::new(codex_home, auth_manager)),
|
||||||
session_header: SessionHeader::new(resolved_model),
|
session_header: SessionHeader::new(resolved_model),
|
||||||
initial_user_message: None,
|
initial_user_message: None,
|
||||||
token_info: None,
|
token_info: None,
|
||||||
@@ -415,7 +416,10 @@ async fn make_chatwidget_manual(
|
|||||||
fn set_chatgpt_auth(chat: &mut ChatWidget) {
|
fn set_chatgpt_auth(chat: &mut ChatWidget) {
|
||||||
chat.auth_manager =
|
chat.auth_manager =
|
||||||
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
|
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
|
||||||
chat.models_manager = Arc::new(ModelsManager::new(chat.auth_manager.clone()));
|
chat.models_manager = Arc::new(ModelsManager::new(
|
||||||
|
chat.config.codex_home.clone(),
|
||||||
|
chat.auth_manager.clone(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn make_chatwidget_manual_with_sender() -> (
|
pub(crate) async fn make_chatwidget_manual_with_sender() -> (
|
||||||
|
|||||||
@@ -407,7 +407,11 @@ impl App {
|
|||||||
let (app_event_tx, mut app_event_rx) = unbounded_channel();
|
let (app_event_tx, mut app_event_rx) = unbounded_channel();
|
||||||
let app_event_tx = AppEventSender::new(app_event_tx);
|
let app_event_tx = AppEventSender::new(app_event_tx);
|
||||||
|
|
||||||
let thread_manager = Arc::new(ThreadManager::new(auth_manager.clone(), SessionSource::Cli));
|
let thread_manager = Arc::new(ThreadManager::new(
|
||||||
|
config.codex_home.clone(),
|
||||||
|
auth_manager.clone(),
|
||||||
|
SessionSource::Cli,
|
||||||
|
));
|
||||||
let mut model = thread_manager
|
let mut model = thread_manager
|
||||||
.get_models_manager()
|
.get_models_manager()
|
||||||
.get_model(&config.model, &config)
|
.get_model(&config.model, &config)
|
||||||
|
|||||||
@@ -363,6 +363,7 @@ async fn make_chatwidget_manual(
|
|||||||
skills: None,
|
skills: None,
|
||||||
});
|
});
|
||||||
let auth_manager = AuthManager::from_auth_for_testing(CodexAuth::from_api_key("test"));
|
let auth_manager = AuthManager::from_auth_for_testing(CodexAuth::from_api_key("test"));
|
||||||
|
let codex_home = cfg.codex_home.clone();
|
||||||
let widget = ChatWidget {
|
let widget = ChatWidget {
|
||||||
app_event_tx,
|
app_event_tx,
|
||||||
codex_op_tx: op_tx,
|
codex_op_tx: op_tx,
|
||||||
@@ -371,7 +372,7 @@ async fn make_chatwidget_manual(
|
|||||||
config: cfg,
|
config: cfg,
|
||||||
model: resolved_model.clone(),
|
model: resolved_model.clone(),
|
||||||
auth_manager: auth_manager.clone(),
|
auth_manager: auth_manager.clone(),
|
||||||
models_manager: Arc::new(ModelsManager::new(auth_manager)),
|
models_manager: Arc::new(ModelsManager::new(codex_home, auth_manager)),
|
||||||
session_header: SessionHeader::new(resolved_model),
|
session_header: SessionHeader::new(resolved_model),
|
||||||
initial_user_message: None,
|
initial_user_message: None,
|
||||||
token_info: None,
|
token_info: None,
|
||||||
@@ -410,7 +411,10 @@ async fn make_chatwidget_manual(
|
|||||||
fn set_chatgpt_auth(chat: &mut ChatWidget) {
|
fn set_chatgpt_auth(chat: &mut ChatWidget) {
|
||||||
chat.auth_manager =
|
chat.auth_manager =
|
||||||
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
|
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
|
||||||
chat.models_manager = Arc::new(ModelsManager::new(chat.auth_manager.clone()));
|
chat.models_manager = Arc::new(ModelsManager::new(
|
||||||
|
chat.config.codex_home.clone(),
|
||||||
|
chat.auth_manager.clone(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn make_chatwidget_manual_with_sender() -> (
|
pub(crate) async fn make_chatwidget_manual_with_sender() -> (
|
||||||
|
|||||||
Reference in new issue
Block a user