mirror of
https://github.com/openai/codex.git
synced 2026-10-30 19:18:49 +00:00
fix(runtime-install): address API review feedback
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use codex_app_server_protocol::JSONRPCErrorError;
|
||||
use codex_exec_server::ExecServerError;
|
||||
|
||||
const INVALID_PARAMS_ERROR_CODE: i64 = -32602;
|
||||
const INTERNAL_ERROR_CODE: i64 = -32603;
|
||||
@@ -11,6 +12,17 @@ pub(crate) fn internal_error(message: impl Into<String>) -> JSONRPCErrorError {
|
||||
error(INTERNAL_ERROR_CODE, message)
|
||||
}
|
||||
|
||||
pub(crate) fn exec_server_error_to_jsonrpc(err: ExecServerError) -> JSONRPCErrorError {
|
||||
match err {
|
||||
ExecServerError::Server { code, message } => JSONRPCErrorError {
|
||||
code,
|
||||
message,
|
||||
data: None,
|
||||
},
|
||||
_ => internal_error(err.to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
fn error(code: i64, message: impl Into<String>) -> JSONRPCErrorError {
|
||||
JSONRPCErrorError {
|
||||
code,
|
||||
|
||||
@@ -17,6 +17,7 @@ use codex_utils_path_uri::PathUri;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::errors::exec_server_error_to_jsonrpc;
|
||||
use crate::errors::internal_error;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
@@ -55,7 +56,10 @@ pub(crate) struct RuntimeExecutor {
|
||||
|
||||
impl RuntimeExecutor {
|
||||
pub(crate) async fn new(environment: &Environment) -> Result<Self, JSONRPCErrorError> {
|
||||
let codex_home = environment.codex_home().await?;
|
||||
let codex_home = environment
|
||||
.codex_home()
|
||||
.await
|
||||
.map_err(exec_server_error_to_jsonrpc)?;
|
||||
Ok(Self {
|
||||
backend: environment.get_exec_backend(),
|
||||
filesystem: environment.get_filesystem(),
|
||||
|
||||
Reference in New Issue
Block a user