Skip to main content

AppServerBuilder

Struct AppServerBuilder 

Source
pub struct AppServerBuilder { /* private fields */ }
Expand description

Builder for launching a Codex app-server process.

Produces commands of the form: codex [-c k=v]... app-server --listen stdio:// [extra]...

All model, sandbox, and approval configuration that isn’t expressible as a CLI flag is done via JSON-RPC requests after connecting. For everything that is a CLI flag, see config_override and extra_args.

Implementations§

Source§

impl AppServerBuilder

Source

pub fn new() -> Self

Create a new builder with default settings.

Source

pub fn command<P: Into<PathBuf>>(self, path: P) -> Self

Set custom path to the codex binary.

Source

pub fn working_directory<P: Into<PathBuf>>(self, dir: P) -> Self

Set the working directory for the app-server process.

Source

pub fn config_override<K, V>(self, key: K, value: V) -> Self
where K: Into<String>, V: Into<String>,

Append a -c key=value global config override.

Repeatable. Each call appends one override; order is preserved on the command line. The value is passed to codex unparsed — codex tries TOML, then falls back to the raw string. The caller is responsible for any quoting / escaping the value itself needs (e.g. arrays: ("sandbox_permissions", r#"["disk-full-read-access"]"#)).

-c flags are placed before the app-server subcommand because they’re parsed as global codex options, not subcommand args.

§Example
use codex_codes::AppServerBuilder;

let builder = AppServerBuilder::new()
    .config_override("sandbox_mode", "workspace-write")
    .config_override("approval_policy", "on-request");
Source

pub fn extra_args<I, S>(self, args: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Append raw arguments to the app-server subcommand invocation.

Inserted after the hardcoded --listen stdio://, so they land as subcommand args. Use this for flags the SDK doesn’t model yet — e.g. --strict-config, or --session-source app-server once that becomes available on the multitool subcommand.

For -c key=value global overrides use config_override instead; those need to be placed before the subcommand.

§Example
use codex_codes::AppServerBuilder;

let builder = AppServerBuilder::new()
    .extra_args(["--strict-config"]);
Source

pub async fn spawn(self) -> Result<Child>

Spawn the app-server process asynchronously.

Source

pub fn spawn_sync(self) -> Result<Child>

Spawn the app-server process synchronously.

Trait Implementations§

Source§

impl Clone for AppServerBuilder

Source§

fn clone(&self) -> AppServerBuilder

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AppServerBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AppServerBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.