Skip to main content

EnvironmentManager

Struct EnvironmentManager 

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

Owns the execution/filesystem environments available to the Codex runtime.

EnvironmentManager is a shared registry for concrete environments. Its default constructor preserves the legacy CODEX_EXEC_SERVER_URL behavior while configured construction accepts a provider-supplied snapshot.

Setting CODEX_EXEC_SERVER_URL=none disables environment access by leaving the default environment unset and omitting the local environment. Callers use default_environment().is_some() as the signal for model-facing shell/filesystem tool availability.

Remote environments begin connecting when added to the manager. Their filesystem and execution backends share that startup result and reconnect after later disconnects as needed.

Implementations§

Source§

impl EnvironmentManager

Source

pub fn default_for_tests() -> Self

Builds a test-only manager without configured sandbox helper paths.

Source

pub fn without_environments() -> Self

Builds a manager with no configured execution environments.

Source

pub async fn create_for_tests( exec_server_url: Option<String>, local_runtime_paths: Option<ExecServerRuntimePaths>, ) -> Self

Builds a test-only manager from a raw exec-server URL value.

Source

pub async fn from_codex_home( codex_home: impl AsRef<Path>, local_runtime_paths: Option<ExecServerRuntimePaths>, ) -> Result<Self, ExecServerError>

Builds a manager from CODEX_HOME and local runtime paths used when creating local filesystem helpers.

If CODEX_HOME/environments.toml is present, it defines the configured environments. Otherwise this preserves the legacy CODEX_EXEC_SERVER_URL behavior.

Source

pub async fn from_env( local_runtime_paths: Option<ExecServerRuntimePaths>, ) -> Result<Self, ExecServerError>

Builds a manager from the legacy environment-variable provider without reading user config files from CODEX_HOME.

Source

pub async fn create_for_tests_with_local( exec_server_url: Option<String>, local_runtime_paths: ExecServerRuntimePaths, ) -> Self

Builds a test-only manager that keeps the provider default while also allowing tests to select the local environment explicitly.

Source

pub fn default_environment(&self) -> Option<Arc<Environment>>

Returns the default environment instance.

Source

pub fn default_environment_id(&self) -> Option<&str>

Returns the id of the default environment.

Source

pub fn default_environment_ids(&self) -> Vec<String>

Returns the ordered environment ids used for new thread startup.

Source

pub fn try_local_environment(&self) -> Option<Arc<Environment>>

Returns the local environment instance when one is configured.

Source

pub fn get_environment(&self, environment_id: &str) -> Option<Arc<Environment>>

Returns a named environment instance.

Source

pub async fn get_environment_status( &self, environment_id: &str, ) -> Option<EnvironmentObservedStatus>

Returns the current status of one named environment when it is configured.

Source

pub fn upsert_environment( &self, environment_id: String, exec_server_url: String, connect_timeout: Option<Duration>, ) -> Result<(), ExecServerError>

Adds or replaces a named remote environment without changing the manager’s default environment selection. Uses the default WebSocket connection timeout when none is provided.

Source

pub fn register_deferred_noise_environment( &self, environment_id: String, provider: Arc<dyn NoiseRendezvousConnectProvider>, ) -> Result<DeferredEnvironmentRegistration, ExecServerError>

Adds or replaces a Noise rendezvous environment that will become ready later.

Source

pub fn upsert_noise_environment( &self, environment_id: String, provider: Arc<dyn NoiseRendezvousConnectProvider>, ) -> Result<(), ExecServerError>

Adds or replaces a named remote environment that connects through an authenticated, end-to-end encrypted rendezvous stream.

The provider is retained so every reconnect obtains fresh authorization. This transport never falls back to the URL-only remote environment path.

Source§

impl EnvironmentManager

Source

pub fn inspect_selected_capability_roots( &self, selected_roots: &[SelectedCapabilityRoot], ) -> SelectedCapabilityRootsStatus

Inspects selected roots without starting or waiting for an environment.

Starting or recovering environments are omitted. Missing environments and terminal connection failures are returned as warnings so read-only catalog clients can distinguish them from an empty catalog.

Environment IDs are stable identities, so callers can safely resolve a returned root by ID when they read it.

Source

pub async fn resolve_selected_capability_roots( &self, selected_roots: &[SelectedCapabilityRoot], captured_environments: &HashMap<String, Option<Arc<Environment>>>, ) -> Vec<ResolvedSelectedCapabilityRoot>

Resolves selected roots whose stable environments are ready for the current model step.

Environment identity comes from the selected root’s stable environment ID. A ready environment captured for the step carries its exact process-local handle so readiness and execution cannot come from different registry snapshots. Missing, starting, or failed environments are omitted. A lazy environment is started for a later step.

Trait Implementations§

Source§

impl Debug for EnvironmentManager

Source§

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

Formats the value using the given formatter. 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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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

Source§

fn rama_from(value: T) -> U

Source§

impl<T, U, CrateMarker> RamaInto<U, CrateMarker> for T
where U: RamaFrom<T, CrateMarker>,

Source§

fn rama_into(self) -> U

Source§

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

Source§

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

Source§

fn rama_try_from(value: T) -> Result<U, <U as RamaTryFrom<T>>::Error>

Source§

impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for T
where U: RamaTryFrom<T, CrateMarker>,

Source§

type Error = <U as RamaTryFrom<T, CrateMarker>>::Error

Source§

fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more