mirror of
https://github.com/openai/codex.git
synced 2026-09-13 11:47:17 +00:00
## Summary - match the exec-process structure to filesystem PR #15232 - expose `ExecProcess` on `Environment` - make `LocalProcess` the real implementation and `RemoteProcess` a thin network proxy over `ExecServerClient` - make `ProcessHandler` a thin RPC adapter delegating to `LocalProcess` - add a shared local/remote process test ## Validation - `just fmt` - `CARGO_TARGET_DIR=~/.cache/cargo-target/codex cargo test -p codex-exec-server` - `just fix -p codex-exec-server` --------- Co-authored-by: Codex <noreply@openai.com>
71 lines
1.9 KiB
Rust
71 lines
1.9 KiB
Rust
use codex_app_server_protocol::JSONRPCErrorError;
|
|
|
|
use crate::local_process::LocalProcess;
|
|
use crate::protocol::ExecParams;
|
|
use crate::protocol::ExecResponse;
|
|
use crate::protocol::InitializeResponse;
|
|
use crate::protocol::ReadParams;
|
|
use crate::protocol::ReadResponse;
|
|
use crate::protocol::TerminateParams;
|
|
use crate::protocol::TerminateResponse;
|
|
use crate::protocol::WriteParams;
|
|
use crate::protocol::WriteResponse;
|
|
use crate::rpc::RpcNotificationSender;
|
|
|
|
#[derive(Clone)]
|
|
pub(crate) struct ProcessHandler {
|
|
process: LocalProcess,
|
|
}
|
|
|
|
impl ProcessHandler {
|
|
pub(crate) fn new(notifications: RpcNotificationSender) -> Self {
|
|
Self {
|
|
process: LocalProcess::new(notifications),
|
|
}
|
|
}
|
|
|
|
pub(crate) async fn shutdown(&self) {
|
|
self.process.shutdown().await;
|
|
}
|
|
|
|
pub(crate) fn initialize(&self) -> Result<InitializeResponse, JSONRPCErrorError> {
|
|
self.process.initialize()
|
|
}
|
|
|
|
pub(crate) fn initialized(&self) -> Result<(), String> {
|
|
self.process.initialized()
|
|
}
|
|
|
|
pub(crate) fn require_initialized_for(
|
|
&self,
|
|
method_family: &str,
|
|
) -> Result<(), JSONRPCErrorError> {
|
|
self.process.require_initialized_for(method_family)
|
|
}
|
|
|
|
pub(crate) async fn exec(&self, params: ExecParams) -> Result<ExecResponse, JSONRPCErrorError> {
|
|
self.process.exec(params).await
|
|
}
|
|
|
|
pub(crate) async fn exec_read(
|
|
&self,
|
|
params: ReadParams,
|
|
) -> Result<ReadResponse, JSONRPCErrorError> {
|
|
self.process.exec_read(params).await
|
|
}
|
|
|
|
pub(crate) async fn exec_write(
|
|
&self,
|
|
params: WriteParams,
|
|
) -> Result<WriteResponse, JSONRPCErrorError> {
|
|
self.process.exec_write(params).await
|
|
}
|
|
|
|
pub(crate) async fn terminate(
|
|
&self,
|
|
params: TerminateParams,
|
|
) -> Result<TerminateResponse, JSONRPCErrorError> {
|
|
self.process.terminate_process(params).await
|
|
}
|
|
}
|