Support multiple managed environments (#18401)

## Summary
- refactor EnvironmentManager to own keyed environments with
default/local lookup helpers
- keep remote exec-server client creation lazy until exec/fs use
- preserve disabled agent environment access separately from internal
local environment access

## Validation
- not run (per Codex worktree instruction to avoid tests/builds unless
requested)

---------

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
starr-openai
2026-04-21 15:29:35 -07:00
committed by GitHub
co-authored by Codex
parent 27d9673273
commit ddbe2536be
44 changed files with 606 additions and 432 deletions
+6 -5
View File
@@ -9,7 +9,7 @@ use crate::ExecProcess;
use crate::ExecProcessEventReceiver;
use crate::ExecServerError;
use crate::StartedExecProcess;
use crate::client::ExecServerClient;
use crate::client::LazyRemoteExecServerClient;
use crate::client::Session;
use crate::protocol::ExecParams;
use crate::protocol::ReadResponse;
@@ -17,7 +17,7 @@ use crate::protocol::WriteResponse;
#[derive(Clone)]
pub(crate) struct RemoteProcess {
client: ExecServerClient,
client: LazyRemoteExecServerClient,
}
struct RemoteExecProcess {
@@ -25,7 +25,7 @@ struct RemoteExecProcess {
}
impl RemoteProcess {
pub(crate) fn new(client: ExecServerClient) -> Self {
pub(crate) fn new(client: LazyRemoteExecServerClient) -> Self {
trace!("remote process new");
Self { client }
}
@@ -35,8 +35,9 @@ impl RemoteProcess {
impl ExecBackend for RemoteProcess {
async fn start(&self, params: ExecParams) -> Result<StartedExecProcess, ExecServerError> {
let process_id = params.process_id.clone();
let session = self.client.register_session(&process_id).await?;
if let Err(err) = self.client.exec(params).await {
let client = self.client.get().await?;
let session = client.register_session(&process_id).await?;
if let Err(err) = client.exec(params).await {
session.unregister().await;
return Err(err);
}