pub struct CodexClientBuilder { /* private fields */ }Expand description
Builder for crate::CodexClient.
CLI parity planning and implementation history lives under .archived/project_management/next/
(see .archived/project_management/next/codex-cli-parity/) and the parity ADRs in docs/adr/.
Implementations§
Source§impl CodexClientBuilder
impl CodexClientBuilder
Sourcepub fn binary(self, binary: impl Into<PathBuf>) -> Self
pub fn binary(self, binary: impl Into<PathBuf>) -> Self
Sets the path to the Codex binary.
Defaults to CODEX_BINARY when present or codex on PATH. Use this to pin a packaged
binary, e.g. the path returned from crate::resolve_bundled_binary when your app ships Codex
inside an isolated bundle.
Sourcepub fn codex_home(self, home: impl Into<PathBuf>) -> Self
pub fn codex_home(self, home: impl Into<PathBuf>) -> Self
Sets a custom CODEX_HOME path that will be applied per command.
Directories are created by default; disable via Self::create_home_dirs.
Sourcepub fn create_home_dirs(self, enable: bool) -> Self
pub fn create_home_dirs(self, enable: bool) -> Self
Controls whether the CODEX_HOME directory tree should be created if missing.
Defaults to true when Self::codex_home is set.
Sourcepub fn model(self, model: impl Into<String>) -> Self
pub fn model(self, model: impl Into<String>) -> Self
Sets the model that should be used for every codex exec call.
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
Overrides the maximum amount of time to wait for Codex to respond.
Sourcepub fn color_mode(self, color_mode: ColorMode) -> Self
pub fn color_mode(self, color_mode: ColorMode) -> Self
Controls whether Codex may emit ANSI colors (--color). Defaults to ColorMode::Never.
Sourcepub fn working_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn working_dir(self, dir: impl Into<PathBuf>) -> Self
Forces Codex to run with the provided working directory instead of a fresh temp dir.
Sourcepub fn add_dir(self, path: impl Into<PathBuf>) -> Self
pub fn add_dir(self, path: impl Into<PathBuf>) -> Self
Requests that codex exec include one or more --add-dir flags when the
probed binary supports them. Unsupported or unknown capability results
skip the flag to avoid CLI errors.
Sourcepub fn add_dirs<I, P>(self, dirs: I) -> Self
pub fn add_dirs<I, P>(self, dirs: I) -> Self
Replaces the current add-dir list with the provided collection.
Sourcepub fn image(self, path: impl Into<PathBuf>) -> Self
pub fn image(self, path: impl Into<PathBuf>) -> Self
Adds an image to the prompt by passing --image <path> to codex exec.
Sourcepub fn images<I, P>(self, images: I) -> Self
pub fn images<I, P>(self, images: I) -> Self
Replaces the current image list with the provided collection.
Sourcepub fn json(self, enable: bool) -> Self
pub fn json(self, enable: bool) -> Self
Enables Codex’s JSONL output mode (--json).
Prompts are piped via stdin when enabled. Events include thread.started
(or thread.resumed when continuing), turn.started/turn.completed/turn.failed,
and item.created/item.updated with item.type such as agent_message or reasoning.
Pair with .mirror_stdout(false) if you plan to parse the stream instead of just mirroring it.
Sourcepub fn output_schema(self, enable: bool) -> Self
pub fn output_schema(self, enable: bool) -> Self
Requests the --output-schema flag when the probed binary reports
support. When capability detection is inconclusive, the flag is skipped
to maintain compatibility with older releases.
Sourcepub fn mirror_stdout(self, enable: bool) -> Self
pub fn mirror_stdout(self, enable: bool) -> Self
Controls whether Codex stdout should be mirrored to the console while
also being captured. Disable this when you plan to parse JSONL output or
tee the stream to a log file (see crates/codex/examples/stream_with_log.rs).
Sourcepub fn json_event_log(self, path: impl Into<PathBuf>) -> Self
pub fn json_event_log(self, path: impl Into<PathBuf>) -> Self
Tees each JSONL event line from crate::CodexClient::stream_exec into a log file.
Logs append to existing files, flush after each line, and create parent directories as
needed. crate::ExecStreamRequest::json_event_log overrides this default per request.
Sourcepub fn config_override(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn config_override( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Adds a --config key=value override that will be applied to every Codex invocation.
Sourcepub fn config_override_raw(self, raw: impl Into<String>) -> Self
pub fn config_override_raw(self, raw: impl Into<String>) -> Self
Adds a preformatted --config key=value override without parsing the input.
Sourcepub fn config_overrides<I, K, V>(self, overrides: I) -> Self
pub fn config_overrides<I, K, V>(self, overrides: I) -> Self
Replaces the config overrides with the provided collection.
Sourcepub fn profile(self, profile: impl Into<String>) -> Self
pub fn profile(self, profile: impl Into<String>) -> Self
Selects a Codex config profile (--profile).
Sourcepub fn reasoning_effort(self, effort: ReasoningEffort) -> Self
pub fn reasoning_effort(self, effort: ReasoningEffort) -> Self
Sets model_reasoning_effort via --config.
Sourcepub fn reasoning_summary(self, summary: ReasoningSummary) -> Self
pub fn reasoning_summary(self, summary: ReasoningSummary) -> Self
Sets model_reasoning_summary via --config.
Sourcepub fn reasoning_verbosity(self, verbosity: ModelVerbosity) -> Self
pub fn reasoning_verbosity(self, verbosity: ModelVerbosity) -> Self
Sets model_verbosity via --config.
Sourcepub fn reasoning_summary_format(self, format: ReasoningSummaryFormat) -> Self
pub fn reasoning_summary_format(self, format: ReasoningSummaryFormat) -> Self
Sets model_reasoning_summary_format via --config.
Sourcepub fn supports_reasoning_summaries(self, enable: bool) -> Self
pub fn supports_reasoning_summaries(self, enable: bool) -> Self
Sets model_supports_reasoning_summaries via --config.
Sourcepub fn auto_reasoning_defaults(self, enable: bool) -> Self
pub fn auto_reasoning_defaults(self, enable: bool) -> Self
Controls whether GPT-5* reasoning defaults should be injected automatically.
Sourcepub fn approval_policy(self, policy: ApprovalPolicy) -> Self
pub fn approval_policy(self, policy: ApprovalPolicy) -> Self
Sets the approval policy for Codex subprocesses.
Sourcepub fn sandbox_mode(self, mode: SandboxMode) -> Self
pub fn sandbox_mode(self, mode: SandboxMode) -> Self
Sets the sandbox mode for Codex subprocesses.
Sourcepub fn full_auto(self, enable: bool) -> Self
pub fn full_auto(self, enable: bool) -> Self
Applies the --full-auto safety override unless explicit sandbox/approval options are set.
Sourcepub fn dangerously_bypass_approvals_and_sandbox(self, enable: bool) -> Self
pub fn dangerously_bypass_approvals_and_sandbox(self, enable: bool) -> Self
Applies the --dangerously-bypass-approvals-and-sandbox override.
Sourcepub fn cd(self, dir: impl Into<PathBuf>) -> Self
pub fn cd(self, dir: impl Into<PathBuf>) -> Self
Applies --cd <dir> to Codex invocations while keeping the process cwd set to working_dir.
Sourcepub fn remote(self, remote: impl Into<String>) -> Self
pub fn remote(self, remote: impl Into<String>) -> Self
Selects a remote Codex target (--remote).
Sourcepub fn remote_auth_token_env(self, env_var: impl Into<String>) -> Self
pub fn remote_auth_token_env(self, env_var: impl Into<String>) -> Self
Selects the env var that provides the remote auth token (--remote-auth-token-env).
Sourcepub fn local_provider(self, provider: LocalProvider) -> Self
pub fn local_provider(self, provider: LocalProvider) -> Self
Selects a local provider backend (--local-provider).
Sourcepub fn oss(self, enable: bool) -> Self
pub fn oss(self, enable: bool) -> Self
Requests the CLI --oss flag to favor OSS/local backends when available.
Sourcepub fn enable_feature(self, name: impl Into<String>) -> Self
pub fn enable_feature(self, name: impl Into<String>) -> Self
Adds a --enable <feature> toggle to Codex invocations.
Sourcepub fn disable_feature(self, name: impl Into<String>) -> Self
pub fn disable_feature(self, name: impl Into<String>) -> Self
Adds a --disable <feature> toggle to Codex invocations.
Sourcepub fn search(self, enable: bool) -> Self
pub fn search(self, enable: bool) -> Self
Controls whether --search is passed through to Codex.
Sourcepub fn capability_overrides(self, overrides: CapabilityOverrides) -> Self
pub fn capability_overrides(self, overrides: CapabilityOverrides) -> Self
Supplies manual capability data to skip probes or adjust feature flags.
Sourcepub fn capability_feature_overrides(
self,
overrides: CapabilityFeatureOverrides,
) -> Self
pub fn capability_feature_overrides( self, overrides: CapabilityFeatureOverrides, ) -> Self
Convenience to apply feature overrides or vendor hints without touching versions.
Sourcepub fn capability_feature_hints(self, features: CodexFeatureFlags) -> Self
pub fn capability_feature_hints(self, features: CodexFeatureFlags) -> Self
Convenience to opt into specific feature flags while leaving other probes intact.
Sourcepub fn capability_snapshot(self, snapshot: CodexCapabilities) -> Self
pub fn capability_snapshot(self, snapshot: CodexCapabilities) -> Self
Supplies a precomputed capability snapshot for pinned or bundled Codex builds.
Combine with write_capabilities_snapshot / read_capabilities_snapshot
to persist probe results between processes.
Sourcepub fn capability_version_override(self, version: CodexVersionInfo) -> Self
pub fn capability_version_override(self, version: CodexVersionInfo) -> Self
Overrides the probed version data with caller-provided metadata.
Sourcepub fn capability_cache_policy(self, policy: CapabilityCachePolicy) -> Self
pub fn capability_cache_policy(self, policy: CapabilityCachePolicy) -> Self
Controls how capability probes interact with the in-process cache.
Use crate::CapabilityCachePolicy::Refresh to enforce a TTL/backoff when
binaries are hot-swapped without changing fingerprints.
Sourcepub fn bypass_capability_cache(self, bypass: bool) -> Self
pub fn bypass_capability_cache(self, bypass: bool) -> Self
Convenience to bypass the capability cache when a fresh snapshot is required. Bypass skips cache reads and writes for the probe.
Sourcepub fn build(self) -> CodexClient
pub fn build(self) -> CodexClient
Builds the crate::CodexClient.
Trait Implementations§
Source§impl Clone for CodexClientBuilder
impl Clone for CodexClientBuilder
Source§fn clone(&self) -> CodexClientBuilder
fn clone(&self) -> CodexClientBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more