feat: codex sampler (#17784)

Add a pure sampler using the Codex auth and model config. To be used by
other binary such as tape recorder
This commit is contained in:
jif-oai
2026-04-14 17:00:18 +01:00
committed by GitHub
parent 4f2fc3e3fa
commit b3ae531b3a
4 changed files with 245 additions and 0 deletions

View File

@@ -40,11 +40,14 @@ mod app_cmd;
mod desktop_app;
mod marketplace_cmd;
mod mcp_cmd;
mod responses_cmd;
#[cfg(not(windows))]
mod wsl_paths;
use crate::marketplace_cmd::MarketplaceCli;
use crate::mcp_cmd::McpCli;
use crate::responses_cmd::ResponsesCommand;
use crate::responses_cmd::run_responses_command;
use codex_core::config::Config;
use codex_core::config::ConfigOverrides;
@@ -151,6 +154,10 @@ enum Subcommand {
#[clap(hide = true)]
ResponsesApiProxy(ResponsesApiProxyArgs),
/// Internal: send one raw Responses API payload through Codex auth.
#[clap(hide = true)]
Responses(ResponsesCommand),
/// Internal: relay stdio to a Unix domain socket.
#[clap(hide = true, name = "stdio-to-uds")]
StdioToUds(StdioToUdsCommand),
@@ -1015,6 +1022,14 @@ async fn cli_main(arg0_paths: Arg0DispatchPaths) -> anyhow::Result<()> {
tokio::task::spawn_blocking(move || codex_responses_api_proxy::run_main(args))
.await??;
}
Some(Subcommand::Responses(ResponsesCommand {})) => {
reject_remote_mode_for_subcommand(
root_remote.as_deref(),
root_remote_auth_token_env.as_deref(),
"responses",
)?;
run_responses_command(root_config_overrides).await?;
}
Some(Subcommand::StdioToUds(cmd)) => {
reject_remote_mode_for_subcommand(
root_remote.as_deref(),
@@ -1666,6 +1681,15 @@ mod tests {
);
}
#[test]
fn responses_subcommand_is_hidden_from_help_but_parses() {
let help = MultitoolCli::command().render_help().to_string();
assert!(!help.contains("responses"));
let cli = MultitoolCli::try_parse_from(["codex", "responses"]).expect("parse");
assert!(matches!(cli.subcommand, Some(Subcommand::Responses(_))));
}
fn sample_exit_info(conversation_id: Option<&str>, thread_name: Option<&str>) -> AppExitInfo {
let token_usage = TokenUsage {
output_tokens: 2,