Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

[codex] Add auth mode to plugin manager constructor (#27652)

felixxia-oaiaef40ad91fdb
diff --git a/codex-rs/core-plugins/src/manager.rs b/codex-rs/core-plugins/src/manager.rs
index 6f7e46f3e9..da9b7d1172 100644
--- a/codex-rs/core-plugins/src/manager.rs
+++ b/codex-rs/core-plugins/src/manager.rs
@@ -354,12 +354,13 @@ struct PluginLoadCacheKey {
impl PluginsManager {
pub fn new(codex_home: PathBuf) -> Self {
- Self::new_with_restriction_product(codex_home, Some(Product::Codex))
+ Self::new_with_options(codex_home, Some(Product::Codex), /*auth_mode*/ None)
}
- pub fn new_with_restriction_product(
+ pub fn new_with_options(
codex_home: PathBuf,
restriction_product: Option<Product>,
+ auth_mode: Option<AuthMode>,
) -> Self {
// Product restrictions are enforced at marketplace admission time for a given CODEX_HOME:
// listing, install, and curated refresh all consult this restriction context before new
@@ -386,7 +387,7 @@ impl PluginsManager {
GlobalRemoteCatalogCacheRefreshState::default(),
),
restriction_product,
- auth_mode: RwLock::new(None),
+ auth_mode: RwLock::new(auth_mode),
analytics_events_client: RwLock::new(None),
}
}
diff --git a/codex-rs/core-plugins/src/manager_tests.rs b/codex-rs/core-plugins/src/manager_tests.rs
index 1a268a4888..fa80eca5cf 100644
--- a/codex-rs/core-plugins/src/manager_tests.rs
+++ b/codex-rs/core-plugins/src/manager_tests.rs
@@ -61,6 +61,13 @@ fn plugins_manager_tracks_auth_mode() {
assert_eq!(manager.auth_mode(), Some(AuthMode::ChatgptAuthTokens));
assert!(manager.set_auth_mode(/*auth_mode*/ None));
assert_eq!(manager.auth_mode(), None);
+
+ let manager_with_auth = PluginsManager::new_with_options(
+ tmp.path().join("auth"),
+ Some(Product::Codex),
+ Some(AuthMode::Chatgpt),
+ );
+ assert_eq!(manager_with_auth.auth_mode(), Some(AuthMode::Chatgpt));
}
fn write_plugin_with_version(
@@ -3038,9 +3045,10 @@ plugins = true
let mut config = load_config(tmp.path(), tmp.path()).await;
config.chatgpt_base_url = format!("{}/backend-api/", server.uri());
- let manager = PluginsManager::new_with_restriction_product(
+ let manager = PluginsManager::new_with_options(
tmp.path().to_path_buf(),
Some(Product::Chatgpt),
+ /*auth_mode*/ None,
);
let featured_plugin_ids = manager
@@ -3074,9 +3082,10 @@ plugins = true
let mut config = load_config(tmp.path(), tmp.path()).await;
config.chatgpt_base_url = format!("{}/backend-api/", server.uri());
- let manager = PluginsManager::new_with_restriction_product(
+ let manager = PluginsManager::new_with_options(
tmp.path().to_path_buf(),
/*restriction_product*/ None,
+ /*auth_mode*/ None,
);
let featured_plugin_ids = manager
diff --git a/codex-rs/core/src/thread_manager.rs b/codex-rs/core/src/thread_manager.rs
index 123f89cf8f..19070898dd 100644
--- a/codex-rs/core/src/thread_manager.rs
+++ b/codex-rs/core/src/thread_manager.rs
@@ -273,11 +273,11 @@ impl ThreadManager {
let codex_home = config.codex_home.clone();
let restriction_product = session_source.restriction_product();
let (thread_created_tx, _) = broadcast::channel(THREAD_CREATED_CHANNEL_CAPACITY);
- let plugins_manager = Arc::new(PluginsManager::new_with_restriction_product(
+ let plugins_manager = Arc::new(PluginsManager::new_with_options(
codex_home.to_path_buf(),
restriction_product,
+ auth_manager.get_api_auth_mode(),
));
- plugins_manager.set_auth_mode(auth_manager.get_api_auth_mode());
let mcp_manager = Arc::new(McpManager::new_with_extensions(
Arc::clone(&plugins_manager),
Arc::clone(&extensions),
@@ -368,11 +368,11 @@ impl ThreadManager {
};
let (thread_created_tx, _) = broadcast::channel(THREAD_CREATED_CHANNEL_CAPACITY);
let restriction_product = SessionSource::Exec.restriction_product();
- let plugins_manager = Arc::new(PluginsManager::new_with_restriction_product(
+ let plugins_manager = Arc::new(PluginsManager::new_with_options(
codex_home.clone(),
restriction_product,
+ auth_manager.get_api_auth_mode(),
));
- plugins_manager.set_auth_mode(auth_manager.get_api_auth_mode());
let mcp_manager = Arc::new(McpManager::new(Arc::clone(&plugins_manager)));
let skills_manager = Arc::new(SkillsManager::new_with_restriction_product(
skills_codex_home,