feat: use ProcessId in exec-server (#15866)

Use a full struct for the ProcessId to increase readability and make it
easier in the future to make it evolve if needed
This commit is contained in:
jif-oai authored and GitHub committed 2026-03-26 16:45:36 +01:00
1 parent a5824e37db
commit 6d2f4aaafc
11 files changed
+137 -90

No files matched your search

@@ -603,7 +603,7 @@ impl UnifiedExecProcessManager {
let started = environment let started = environment
.get_exec_backend() .get_exec_backend()
.start(codex_exec_server::ExecParams { .start(codex_exec_server::ExecParams {
process_id: exec_server_process_id(process_id), process_id: exec_server_process_id(process_id).into(),
argv: env.command.clone(), argv: env.command.clone(),
cwd: env.cwd.clone(), cwd: env.cwd.clone(),
env: env.env.clone(), env: env.env.clone(),
+24 -18
View File
@@ -113,7 +113,7 @@ struct Inner {
// process on the connection. Keep a local process_id -> session registry so // process on the connection. Keep a local process_id -> session registry so
// we can turn those connection-global notifications into process wakeups // we can turn those connection-global notifications into process wakeups
// without making notifications the source of truth for output delivery. // without making notifications the source of truth for output delivery.
sessions: ArcSwap<HashMap<String, Arc<SessionState>>>, sessions: ArcSwap<HashMap<ProcessId, Arc<SessionState>>>,
// ArcSwap makes reads cheap on the hot notification path, but writes still // ArcSwap makes reads cheap on the hot notification path, but writes still
// need serialization so concurrent register/remove operations do not // need serialization so concurrent register/remove operations do not
// overwrite each other's copy-on-write updates. // overwrite each other's copy-on-write updates.
@@ -225,7 +225,7 @@ impl ExecServerClient {
pub async fn write( pub async fn write(
&self, &self,
process_id: &str, process_id: &ProcessId,
chunk: Vec<u8>, chunk: Vec<u8>,
) -> Result<WriteResponse, ExecServerError> { ) -> Result<WriteResponse, ExecServerError> {
self.inner self.inner
@@ -233,7 +233,7 @@ impl ExecServerClient {
.call( .call(
EXEC_WRITE_METHOD, EXEC_WRITE_METHOD,
&WriteParams { &WriteParams {
process_id: process_id.to_string(), process_id: process_id.clone(),
chunk: chunk.into(), chunk: chunk.into(),
}, },
) )
@@ -241,13 +241,16 @@ impl ExecServerClient {
.map_err(Into::into) .map_err(Into::into)
} }
pub async fn terminate(&self, process_id: &str) -> Result<TerminateResponse, ExecServerError> { pub async fn terminate(
&self,
process_id: &ProcessId,
) -> Result<TerminateResponse, ExecServerError> {
self.inner self.inner
.client .client
.call( .call(
EXEC_TERMINATE_METHOD, EXEC_TERMINATE_METHOD,
&TerminateParams { &TerminateParams {
process_id: process_id.to_string(), process_id: process_id.clone(),
}, },
) )
.await .await
@@ -330,7 +333,7 @@ impl ExecServerClient {
pub(crate) async fn register_session( pub(crate) async fn register_session(
&self, &self,
process_id: &str, process_id: &ProcessId,
) -> Result<Session, ExecServerError> { ) -> Result<Session, ExecServerError> {
let state = Arc::new(SessionState::new()); let state = Arc::new(SessionState::new());
self.inner self.inner
@@ -338,12 +341,12 @@ impl ExecServerClient {
.await?; .await?;
Ok(Session { Ok(Session {
client: self.clone(), client: self.clone(),
process_id: process_id.to_string().into(), process_id: process_id.clone(),
state, state,
}) })
} }
pub(crate) async fn unregister_session(&self, process_id: &str) { pub(crate) async fn unregister_session(&self, process_id: &ProcessId) {
self.inner.remove_session(process_id).await; self.inner.remove_session(process_id).await;
} }
@@ -487,7 +490,7 @@ impl Session {
match self match self
.client .client
.read(ReadParams { .read(ReadParams {
process_id: self.process_id.to_string(), process_id: self.process_id.clone(),
after_seq, after_seq,
max_bytes, max_bytes,
wait_ms, wait_ms,
@@ -519,13 +522,13 @@ impl Session {
} }
impl Inner { impl Inner {
fn get_session(&self, process_id: &str) -> Option<Arc<SessionState>> { fn get_session(&self, process_id: &ProcessId) -> Option<Arc<SessionState>> {
self.sessions.load().get(process_id).cloned() self.sessions.load().get(process_id).cloned()
} }
async fn insert_session( async fn insert_session(
&self, &self,
process_id: &str, process_id: &ProcessId,
session: Arc<SessionState>, session: Arc<SessionState>,
) -> Result<(), ExecServerError> { ) -> Result<(), ExecServerError> {
let _sessions_write_guard = self.sessions_write_lock.lock().await; let _sessions_write_guard = self.sessions_write_lock.lock().await;
@@ -536,12 +539,12 @@ impl Inner {
))); )));
} }
let mut next_sessions = sessions.as_ref().clone(); let mut next_sessions = sessions.as_ref().clone();
next_sessions.insert(process_id.to_string(), session); next_sessions.insert(process_id.clone(), session);
self.sessions.store(Arc::new(next_sessions)); self.sessions.store(Arc::new(next_sessions));
Ok(()) Ok(())
} }
async fn remove_session(&self, process_id: &str) -> Option<Arc<SessionState>> { async fn remove_session(&self, process_id: &ProcessId) -> Option<Arc<SessionState>> {
let _sessions_write_guard = self.sessions_write_lock.lock().await; let _sessions_write_guard = self.sessions_write_lock.lock().await;
let sessions = self.sessions.load(); let sessions = self.sessions.load();
let session = sessions.get(process_id).cloned(); let session = sessions.get(process_id).cloned();
@@ -552,7 +555,7 @@ impl Inner {
session session
} }
async fn take_all_sessions(&self) -> HashMap<String, Arc<SessionState>> { async fn take_all_sessions(&self) -> HashMap<ProcessId, Arc<SessionState>> {
let _sessions_write_guard = self.sessions_write_lock.lock().await; let _sessions_write_guard = self.sessions_write_lock.lock().await;
let sessions = self.sessions.load(); let sessions = self.sessions.load();
let drained_sessions = sessions.as_ref().clone(); let drained_sessions = sessions.as_ref().clone();
@@ -640,6 +643,7 @@ mod tests {
use super::ExecServerClient; use super::ExecServerClient;
use super::ExecServerClientConnectOptions; use super::ExecServerClientConnectOptions;
use crate::ProcessId;
use crate::connection::JsonRpcConnection; use crate::connection::JsonRpcConnection;
use crate::protocol::EXEC_EXITED_METHOD; use crate::protocol::EXEC_EXITED_METHOD;
use crate::protocol::EXEC_OUTPUT_DELTA_METHOD; use crate::protocol::EXEC_OUTPUT_DELTA_METHOD;
@@ -718,12 +722,14 @@ mod tests {
.await .await
.expect("client should connect"); .expect("client should connect");
let noisy_process_id = ProcessId::from("noisy");
let quiet_process_id = ProcessId::from("quiet");
let _noisy_session = client let _noisy_session = client
.register_session("noisy") .register_session(&noisy_process_id)
.await .await
.expect("noisy session should register"); .expect("noisy session should register");
let quiet_session = client let quiet_session = client
.register_session("quiet") .register_session(&quiet_process_id)
.await .await
.expect("quiet session should register"); .expect("quiet session should register");
let mut quiet_wake_rx = quiet_session.subscribe_wake(); let mut quiet_wake_rx = quiet_session.subscribe_wake();
@@ -734,7 +740,7 @@ mod tests {
method: EXEC_OUTPUT_DELTA_METHOD.to_string(), method: EXEC_OUTPUT_DELTA_METHOD.to_string(),
params: Some( params: Some(
serde_json::to_value(ExecOutputDeltaNotification { serde_json::to_value(ExecOutputDeltaNotification {
process_id: "noisy".to_string(), process_id: noisy_process_id.clone(),
seq, seq,
stream: ExecOutputStream::Stdout, stream: ExecOutputStream::Stdout,
chunk: b"x".to_vec().into(), chunk: b"x".to_vec().into(),
@@ -751,7 +757,7 @@ mod tests {
method: EXEC_EXITED_METHOD.to_string(), method: EXEC_EXITED_METHOD.to_string(),
params: Some( params: Some(
serde_json::to_value(ExecExitedNotification { serde_json::to_value(ExecExitedNotification {
process_id: "quiet".to_string(), process_id: quiet_process_id,
seq: 1, seq: 1,
exit_code: 17, exit_code: 17,
}) })
+2 -1
View File
@@ -159,6 +159,7 @@ mod tests {
use super::Environment; use super::Environment;
use super::EnvironmentManager; use super::EnvironmentManager;
use crate::ProcessId;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
#[tokio::test] #[tokio::test]
@@ -195,7 +196,7 @@ mod tests {
let response = environment let response = environment
.get_exec_backend() .get_exec_backend()
.start(crate::ExecParams { .start(crate::ExecParams {
process_id: "default-env-proc".to_string(), process_id: ProcessId::from("default-env-proc"),
argv: vec!["true".to_string()], argv: vec!["true".to_string()],
cwd: std::env::current_dir().expect("read current dir"), cwd: std::env::current_dir().expect("read current dir"),
env: Default::default(), env: Default::default(),
+2 -1
View File
@@ -6,6 +6,7 @@ mod file_system;
mod local_file_system; mod local_file_system;
mod local_process; mod local_process;
mod process; mod process;
mod process_id;
mod protocol; mod protocol;
mod remote_file_system; mod remote_file_system;
mod remote_process; mod remote_process;
@@ -43,8 +44,8 @@ pub use file_system::ReadDirectoryEntry;
pub use file_system::RemoveOptions; pub use file_system::RemoveOptions;
pub use process::ExecBackend; pub use process::ExecBackend;
pub use process::ExecProcess; pub use process::ExecProcess;
pub use process::ProcessId;
pub use process::StartedExecProcess; pub use process::StartedExecProcess;
pub use process_id::ProcessId;
pub use protocol::ExecClosedNotification; pub use protocol::ExecClosedNotification;
pub use protocol::ExecExitedNotification; pub use protocol::ExecExitedNotification;
pub use protocol::ExecOutputDeltaNotification; pub use protocol::ExecOutputDeltaNotification;
+12 -12
View File
@@ -75,7 +75,7 @@ enum ProcessEntry {
struct Inner { struct Inner {
notifications: RpcNotificationSender, notifications: RpcNotificationSender,
processes: Mutex<HashMap<String, ProcessEntry>>, processes: Mutex<HashMap<ProcessId, ProcessEntry>>,
initialize_requested: AtomicBool, initialize_requested: AtomicBool,
initialized: AtomicBool, initialized: AtomicBool,
} }
@@ -420,7 +420,7 @@ impl ExecBackend for LocalProcess {
.map_err(map_handler_error)?; .map_err(map_handler_error)?;
Ok(StartedExecProcess { Ok(StartedExecProcess {
process: Arc::new(LocalExecProcess { process: Arc::new(LocalExecProcess {
process_id: response.process_id.into(), process_id: response.process_id,
backend: self.clone(), backend: self.clone(),
wake_tx, wake_tx,
}), }),
@@ -461,13 +461,13 @@ impl ExecProcess for LocalExecProcess {
impl LocalProcess { impl LocalProcess {
async fn read( async fn read(
&self, &self,
process_id: &str, process_id: &ProcessId,
after_seq: Option<u64>, after_seq: Option<u64>,
max_bytes: Option<usize>, max_bytes: Option<usize>,
wait_ms: Option<u64>, wait_ms: Option<u64>,
) -> Result<ReadResponse, ExecServerError> { ) -> Result<ReadResponse, ExecServerError> {
self.exec_read(ReadParams { self.exec_read(ReadParams {
process_id: process_id.to_string(), process_id: process_id.clone(),
after_seq, after_seq,
max_bytes, max_bytes,
wait_ms, wait_ms,
@@ -478,20 +478,20 @@ impl LocalProcess {
async fn write( async fn write(
&self, &self,
process_id: &str, process_id: &ProcessId,
chunk: Vec<u8>, chunk: Vec<u8>,
) -> Result<WriteResponse, ExecServerError> { ) -> Result<WriteResponse, ExecServerError> {
self.exec_write(WriteParams { self.exec_write(WriteParams {
process_id: process_id.to_string(), process_id: process_id.clone(),
chunk: chunk.into(), chunk: chunk.into(),
}) })
.await .await
.map_err(map_handler_error) .map_err(map_handler_error)
} }
async fn terminate(&self, process_id: &str) -> Result<(), ExecServerError> { async fn terminate(&self, process_id: &ProcessId) -> Result<(), ExecServerError> {
self.terminate_process(TerminateParams { self.terminate_process(TerminateParams {
process_id: process_id.to_string(), process_id: process_id.clone(),
}) })
.await .await
.map_err(map_handler_error)?; .map_err(map_handler_error)?;
@@ -507,7 +507,7 @@ fn map_handler_error(error: JSONRPCErrorError) -> ExecServerError {
} }
async fn stream_output( async fn stream_output(
process_id: String, process_id: ProcessId,
stream: ExecOutputStream, stream: ExecOutputStream,
mut receiver: tokio::sync::mpsc::Receiver<Vec<u8>>, mut receiver: tokio::sync::mpsc::Receiver<Vec<u8>>,
inner: Arc<Inner>, inner: Arc<Inner>,
@@ -560,7 +560,7 @@ async fn stream_output(
} }
async fn watch_exit( async fn watch_exit(
process_id: String, process_id: ProcessId,
exit_rx: tokio::sync::oneshot::Receiver<i32>, exit_rx: tokio::sync::oneshot::Receiver<i32>,
inner: Arc<Inner>, inner: Arc<Inner>,
output_notify: Arc<Notify>, output_notify: Arc<Notify>,
@@ -605,7 +605,7 @@ async fn watch_exit(
} }
} }
async fn finish_output_stream(process_id: String, inner: Arc<Inner>) { async fn finish_output_stream(process_id: ProcessId, inner: Arc<Inner>) {
{ {
let mut processes = inner.processes.lock().await; let mut processes = inner.processes.lock().await;
let Some(ProcessEntry::Running(process)) = processes.get_mut(&process_id) else { let Some(ProcessEntry::Running(process)) = processes.get_mut(&process_id) else {
@@ -620,7 +620,7 @@ async fn finish_output_stream(process_id: String, inner: Arc<Inner>) {
maybe_emit_closed(process_id, inner).await; maybe_emit_closed(process_id, inner).await;
} }
async fn maybe_emit_closed(process_id: String, inner: Arc<Inner>) { async fn maybe_emit_closed(process_id: ProcessId, inner: Arc<Inner>) {
let notification = { let notification = {
let mut processes = inner.processes.lock().await; let mut processes = inner.processes.lock().await;
let Some(ProcessEntry::Running(process)) = processes.get_mut(&process_id) else { let Some(ProcessEntry::Running(process)) = processes.get_mut(&process_id) else {
+1 -41
View File
@@ -1,58 +1,18 @@
use std::fmt;
use std::ops::Deref;
use std::sync::Arc; use std::sync::Arc;
use async_trait::async_trait; use async_trait::async_trait;
use tokio::sync::watch; use tokio::sync::watch;
use crate::ExecServerError; use crate::ExecServerError;
use crate::ProcessId;
use crate::protocol::ExecParams; use crate::protocol::ExecParams;
use crate::protocol::ReadResponse; use crate::protocol::ReadResponse;
use crate::protocol::WriteResponse; use crate::protocol::WriteResponse;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ProcessId(String);
pub struct StartedExecProcess { pub struct StartedExecProcess {
pub process: Arc<dyn ExecProcess>, pub process: Arc<dyn ExecProcess>,
} }
impl ProcessId {
pub fn as_str(&self) -> &str {
&self.0
}
pub fn into_inner(self) -> String {
self.0
}
}
impl Deref for ProcessId {
type Target = str;
fn deref(&self) -> &Self::Target {
self.as_str()
}
}
impl AsRef<str> for ProcessId {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl fmt::Display for ProcessId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
impl From<String> for ProcessId {
fn from(value: String) -> Self {
Self(value)
}
}
#[async_trait] #[async_trait]
pub trait ExecProcess: Send + Sync { pub trait ExecProcess: Send + Sync {
fn process_id(&self) -> &ProcessId; fn process_id(&self) -> &ProcessId;
+74
View File
@@ -0,0 +1,74 @@
use std::borrow::Borrow;
use std::fmt;
use std::ops::Deref;
use serde::Deserialize;
use serde::Serialize;
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
#[serde(transparent)]
pub struct ProcessId(String);
impl ProcessId {
pub fn new(value: impl Into<String>) -> Self {
Self(value.into())
}
pub fn as_str(&self) -> &str {
&self.0
}
pub fn into_inner(self) -> String {
self.0
}
}
impl Deref for ProcessId {
type Target = str;
fn deref(&self) -> &Self::Target {
self.as_str()
}
}
impl Borrow<str> for ProcessId {
fn borrow(&self) -> &str {
self.as_str()
}
}
impl AsRef<str> for ProcessId {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl fmt::Display for ProcessId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
impl From<String> for ProcessId {
fn from(value: String) -> Self {
Self(value)
}
}
impl From<&str> for ProcessId {
fn from(value: &str) -> Self {
Self(value.to_string())
}
}
impl From<&String> for ProcessId {
fn from(value: &String) -> Self {
Self(value.clone())
}
}
impl From<ProcessId> for String {
fn from(value: ProcessId) -> Self {
value.0
}
}
+10 -8
View File
@@ -5,6 +5,8 @@ use base64::engine::general_purpose::STANDARD as BASE64_STANDARD;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use crate::ProcessId;
pub const INITIALIZE_METHOD: &str = "initialize"; pub const INITIALIZE_METHOD: &str = "initialize";
pub const INITIALIZED_METHOD: &str = "initialized"; pub const INITIALIZED_METHOD: &str = "initialized";
pub const EXEC_METHOD: &str = "process/start"; pub const EXEC_METHOD: &str = "process/start";
@@ -53,7 +55,7 @@ pub struct InitializeResponse {}
pub struct ExecParams { pub struct ExecParams {
/// Client-chosen logical process handle scoped to this connection/session. /// Client-chosen logical process handle scoped to this connection/session.
/// This is a protocol key, not an OS pid. /// This is a protocol key, not an OS pid.
pub process_id: String, pub process_id: ProcessId,
pub argv: Vec<String>, pub argv: Vec<String>,
pub cwd: PathBuf, pub cwd: PathBuf,
pub env: HashMap<String, String>, pub env: HashMap<String, String>,
@@ -64,13 +66,13 @@ pub struct ExecParams {
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ExecResponse { pub struct ExecResponse {
pub process_id: String, pub process_id: ProcessId,
} }
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ReadParams { pub struct ReadParams {
pub process_id: String, pub process_id: ProcessId,
pub after_seq: Option<u64>, pub after_seq: Option<u64>,
pub max_bytes: Option<usize>, pub max_bytes: Option<usize>,
pub wait_ms: Option<u64>, pub wait_ms: Option<u64>,
@@ -98,7 +100,7 @@ pub struct ReadResponse {
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct WriteParams { pub struct WriteParams {
pub process_id: String, pub process_id: ProcessId,
pub chunk: ByteChunk, pub chunk: ByteChunk,
} }
@@ -120,7 +122,7 @@ pub struct WriteResponse {
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct TerminateParams { pub struct TerminateParams {
pub process_id: String, pub process_id: ProcessId,
} }
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
@@ -140,7 +142,7 @@ pub enum ExecOutputStream {
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ExecOutputDeltaNotification { pub struct ExecOutputDeltaNotification {
pub process_id: String, pub process_id: ProcessId,
pub seq: u64, pub seq: u64,
pub stream: ExecOutputStream, pub stream: ExecOutputStream,
pub chunk: ByteChunk, pub chunk: ByteChunk,
@@ -149,7 +151,7 @@ pub struct ExecOutputDeltaNotification {
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ExecExitedNotification { pub struct ExecExitedNotification {
pub process_id: String, pub process_id: ProcessId,
pub seq: u64, pub seq: u64,
pub exit_code: i32, pub exit_code: i32,
} }
@@ -157,7 +159,7 @@ pub struct ExecExitedNotification {
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ExecClosedNotification { pub struct ExecClosedNotification {
pub process_id: String, pub process_id: ProcessId,
pub seq: u64, pub seq: u64,
} }
@@ -6,6 +6,7 @@ use pretty_assertions::assert_eq;
use tokio::sync::mpsc; use tokio::sync::mpsc;
use super::ExecServerHandler; use super::ExecServerHandler;
use crate::ProcessId;
use crate::protocol::ExecParams; use crate::protocol::ExecParams;
use crate::protocol::InitializeResponse; use crate::protocol::InitializeResponse;
use crate::protocol::TerminateParams; use crate::protocol::TerminateParams;
@@ -18,7 +19,7 @@ fn exec_params(process_id: &str) -> ExecParams {
env.insert("PATH".to_string(), path.to_string_lossy().into_owned()); env.insert("PATH".to_string(), path.to_string_lossy().into_owned());
} }
ExecParams { ExecParams {
process_id: process_id.to_string(), process_id: ProcessId::from(process_id),
argv: vec![ argv: vec![
"bash".to_string(), "bash".to_string(),
"-lc".to_string(), "-lc".to_string(),
@@ -84,7 +85,7 @@ async fn terminate_reports_false_after_process_exit() {
loop { loop {
let response = handler let response = handler
.terminate(TerminateParams { .terminate(TerminateParams {
process_id: "proc-1".to_string(), process_id: ProcessId::from("proc-1"),
}) })
.await .await
.expect("terminate response"); .expect("terminate response");
+6 -5
View File
@@ -9,6 +9,7 @@ use codex_exec_server::Environment;
use codex_exec_server::ExecBackend; use codex_exec_server::ExecBackend;
use codex_exec_server::ExecParams; use codex_exec_server::ExecParams;
use codex_exec_server::ExecProcess; use codex_exec_server::ExecProcess;
use codex_exec_server::ProcessId;
use codex_exec_server::ReadResponse; use codex_exec_server::ReadResponse;
use codex_exec_server::StartedExecProcess; use codex_exec_server::StartedExecProcess;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
@@ -47,7 +48,7 @@ async fn assert_exec_process_starts_and_exits(use_remote: bool) -> Result<()> {
let session = context let session = context
.backend .backend
.start(ExecParams { .start(ExecParams {
process_id: "proc-1".to_string(), process_id: ProcessId::from("proc-1"),
argv: vec!["true".to_string()], argv: vec!["true".to_string()],
cwd: std::env::current_dir()?, cwd: std::env::current_dir()?,
env: Default::default(), env: Default::default(),
@@ -119,7 +120,7 @@ async fn assert_exec_process_streams_output(use_remote: bool) -> Result<()> {
let session = context let session = context
.backend .backend
.start(ExecParams { .start(ExecParams {
process_id: process_id.clone(), process_id: process_id.clone().into(),
argv: vec![ argv: vec![
"/bin/sh".to_string(), "/bin/sh".to_string(),
"-c".to_string(), "-c".to_string(),
@@ -148,7 +149,7 @@ async fn assert_exec_process_write_then_read(use_remote: bool) -> Result<()> {
let session = context let session = context
.backend .backend
.start(ExecParams { .start(ExecParams {
process_id: process_id.clone(), process_id: process_id.clone().into(),
argv: vec![ argv: vec![
"/usr/bin/python3".to_string(), "/usr/bin/python3".to_string(),
"-c".to_string(), "-c".to_string(),
@@ -184,7 +185,7 @@ async fn assert_exec_process_preserves_queued_events_before_subscribe(
let session = context let session = context
.backend .backend
.start(ExecParams { .start(ExecParams {
process_id: "proc-queued".to_string(), process_id: ProcessId::from("proc-queued"),
argv: vec![ argv: vec![
"/bin/sh".to_string(), "/bin/sh".to_string(),
"-c".to_string(), "-c".to_string(),
@@ -214,7 +215,7 @@ async fn remote_exec_process_reports_transport_disconnect() -> Result<()> {
let session = context let session = context
.backend .backend
.start(ExecParams { .start(ExecParams {
process_id: "proc-disconnect".to_string(), process_id: ProcessId::from("proc-disconnect"),
argv: vec![ argv: vec![
"/bin/sh".to_string(), "/bin/sh".to_string(),
"-c".to_string(), "-c".to_string(),
+2 -1
View File
@@ -6,6 +6,7 @@ use codex_app_server_protocol::JSONRPCMessage;
use codex_app_server_protocol::JSONRPCResponse; use codex_app_server_protocol::JSONRPCResponse;
use codex_exec_server::ExecResponse; use codex_exec_server::ExecResponse;
use codex_exec_server::InitializeParams; use codex_exec_server::InitializeParams;
use codex_exec_server::ProcessId;
use common::exec_server::exec_server; use common::exec_server::exec_server;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
@@ -62,7 +63,7 @@ async fn exec_server_starts_process_over_websocket() -> anyhow::Result<()> {
assert_eq!( assert_eq!(
process_start_response, process_start_response,
ExecResponse { ExecResponse {
process_id: "proc-1".to_string() process_id: ProcessId::from("proc-1")
} }
); );