- Add CodexRuntime for process management and JSON-RPC communication - Add CodexConfigBridge for AI Gateway configuration - Add ModeSwitcher for OpenClaw Gateway mode switching (local/remote/offline) - Add AgentRegistry for agent registration and discovery - Add RuntimeCoordinator for unified coordination - Add Rust FFI bindings for native integration - Add comprehensive test coverage Phase 1-4 features: - Configuration bridging to AI Gateway - Mode switching between local/remote/offline - Agent registration protocol - Cloud memory sync capability - Offline fallback support CI/CD: - GitHub Actions workflow for Rust FFI build - Build scripts for macOS universal binary - Integration with Flutter build process Co-authored-by: Codex CLI Integration <codex@openai.com>
60 lines
1.8 KiB
Rust
60 lines
1.8 KiB
Rust
//! Error types for Codex FFI.
|
|
|
|
use std::fmt;
|
|
|
|
/// Error type for Codex operations.
|
|
#[derive(Debug, Clone)]
|
|
pub enum CodexError {
|
|
/// Invalid argument.
|
|
InvalidArgument(String),
|
|
/// Runtime not initialized.
|
|
NotInitialized,
|
|
/// Runtime already initialized.
|
|
AlreadyInitialized,
|
|
/// IO error.
|
|
Io(String),
|
|
/// JSON-RPC error.
|
|
Rpc { code: i32, message: String },
|
|
/// Timeout error.
|
|
Timeout(String),
|
|
/// Process error.
|
|
Process(String),
|
|
/// Thread error.
|
|
Thread(String),
|
|
/// Configuration error.
|
|
Config(String),
|
|
/// Unknown error.
|
|
Unknown(String),
|
|
}
|
|
|
|
impl fmt::Display for CodexError {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
match self {
|
|
CodexError::InvalidArgument(msg) => write!(f, "Invalid argument: {}", msg),
|
|
CodexError::NotInitialized => write!(f, "Runtime not initialized"),
|
|
CodexError::AlreadyInitialized => write!(f, "Runtime already initialized"),
|
|
CodexError::Io(msg) => write!(f, "IO error: {}", msg),
|
|
CodexError::Rpc { code, message } => write!(f, "RPC error ({}): {}", code, message),
|
|
CodexError::Timeout(msg) => write!(f, "Timeout: {}", msg),
|
|
CodexError::Process(msg) => write!(f, "Process error: {}", msg),
|
|
CodexError::Thread(msg) => write!(f, "Thread error: {}", msg),
|
|
CodexError::Config(msg) => write!(f, "Configuration error: {}", msg),
|
|
CodexError::Unknown(msg) => write!(f, "Unknown error: {}", msg),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl std::error::Error for CodexError {}
|
|
|
|
impl From<std::io::Error> for CodexError {
|
|
fn from(err: std::io::Error) -> Self {
|
|
CodexError::Io(err.to_string())
|
|
}
|
|
}
|
|
|
|
impl From<serde_json::Error> for CodexError {
|
|
fn from(err: serde_json::Error) -> Self {
|
|
CodexError::Config(err.to_string())
|
|
}
|
|
}
|