mirror of
https://github.com/openai/codex.git
synced 2026-11-20 22:40:37 +00:00
1. Use requirement-resolved config.features as the plugin gate. 2. Guard plugin/list, plugin/read, and related flows behind that gate. 3. Skip bad marketplace.json files instead of failing the whole list. 4. Simplify plugin state and caching.
77 lines
2.4 KiB
Rust
77 lines
2.4 KiB
Rust
use clap::Parser;
|
|
use codex_app_server::AppServerTransport;
|
|
use codex_app_server::run_main_with_transport;
|
|
use codex_arg0::Arg0DispatchPaths;
|
|
use codex_arg0::arg0_dispatch_or_else;
|
|
use codex_core::config_loader::LoaderOverrides;
|
|
use codex_protocol::protocol::SessionSource;
|
|
use codex_utils_cli::CliConfigOverrides;
|
|
use std::path::PathBuf;
|
|
|
|
// Debug-only test hook: lets integration tests point the server at a temporary
|
|
// managed config file without writing to /etc.
|
|
const MANAGED_CONFIG_PATH_ENV_VAR: &str = "CODEX_APP_SERVER_MANAGED_CONFIG_PATH";
|
|
|
|
#[derive(Debug, Parser)]
|
|
struct AppServerArgs {
|
|
/// Transport endpoint URL. Supported values: `stdio://` (default),
|
|
/// `ws://IP:PORT`.
|
|
#[arg(
|
|
long = "listen",
|
|
value_name = "URL",
|
|
default_value = AppServerTransport::DEFAULT_LISTEN_URL
|
|
)]
|
|
listen: AppServerTransport,
|
|
|
|
/// Session source stamped into new threads started by this app-server.
|
|
///
|
|
/// Known values such as `vscode`, `cli`, `exec`, and `mcp` map to built-in
|
|
/// sources. Any other non-empty value is recorded as a custom source.
|
|
#[arg(
|
|
long = "session-source",
|
|
value_name = "SOURCE",
|
|
default_value = "vscode"
|
|
)]
|
|
session_source: String,
|
|
}
|
|
|
|
fn main() -> anyhow::Result<()> {
|
|
arg0_dispatch_or_else(|arg0_paths: Arg0DispatchPaths| async move {
|
|
let args = AppServerArgs::parse();
|
|
let managed_config_path = managed_config_path_from_debug_env();
|
|
let loader_overrides = LoaderOverrides {
|
|
managed_config_path,
|
|
..Default::default()
|
|
};
|
|
let transport = args.listen;
|
|
let session_source = SessionSource::from_startup_arg(args.session_source.as_str())
|
|
.map_err(|err| anyhow::anyhow!("invalid --session-source: {err}"))?;
|
|
|
|
run_main_with_transport(
|
|
arg0_paths,
|
|
CliConfigOverrides::default(),
|
|
loader_overrides,
|
|
/*default_analytics_enabled*/ false,
|
|
transport,
|
|
session_source,
|
|
)
|
|
.await?;
|
|
Ok(())
|
|
})
|
|
}
|
|
|
|
fn managed_config_path_from_debug_env() -> Option<PathBuf> {
|
|
#[cfg(debug_assertions)]
|
|
{
|
|
if let Ok(value) = std::env::var(MANAGED_CONFIG_PATH_ENV_VAR) {
|
|
return if value.is_empty() {
|
|
None
|
|
} else {
|
|
Some(PathBuf::from(value))
|
|
};
|
|
}
|
|
}
|
|
|
|
None
|
|
}
|