This release represents a comprehensive transformation of the codebase from Codex to LLMX, enhanced with LiteLLM integration to support 100+ LLM providers through a unified API. ## Major Changes ### Phase 1: Repository & Infrastructure Setup - Established new repository structure and branching strategy - Created comprehensive project documentation (CLAUDE.md, LITELLM-SETUP.md) - Set up development environment and tooling configuration ### Phase 2: Rust Workspace Transformation - Renamed all Rust crates from `codex-*` to `llmx-*` (30+ crates) - Updated package names, binary names, and workspace members - Renamed core modules: codex.rs → llmx.rs, codex_delegate.rs → llmx_delegate.rs - Updated all internal references, imports, and type names - Renamed directories: codex-rs/ → llmx-rs/, codex-backend-openapi-models/ → llmx-backend-openapi-models/ - Fixed all Rust compilation errors after mass rename ### Phase 3: LiteLLM Integration - Integrated LiteLLM for multi-provider LLM support (Anthropic, OpenAI, Azure, Google AI, AWS Bedrock, etc.) - Implemented OpenAI-compatible Chat Completions API support - Added model family detection and provider-specific handling - Updated authentication to support LiteLLM API keys - Renamed environment variables: OPENAI_BASE_URL → LLMX_BASE_URL - Added LLMX_API_KEY for unified authentication - Enhanced error handling for Chat Completions API responses - Implemented fallback mechanisms between Responses API and Chat Completions API ### Phase 4: TypeScript/Node.js Components - Renamed npm package: @codex/codex-cli → @valknar/llmx - Updated TypeScript SDK to use new LLMX APIs and endpoints - Fixed all TypeScript compilation and linting errors - Updated SDK tests to support both API backends - Enhanced mock server to handle multiple API formats - Updated build scripts for cross-platform packaging ### Phase 5: Configuration & Documentation - Updated all configuration files to use LLMX naming - Rewrote README and documentation for LLMX branding - Updated config paths: ~/.codex/ → ~/.llmx/ - Added comprehensive LiteLLM setup guide - Updated all user-facing strings and help text - Created release plan and migration documentation ### Phase 6: Testing & Validation - Fixed all Rust tests for new naming scheme - Updated snapshot tests in TUI (36 frame files) - Fixed authentication storage tests - Updated Chat Completions payload and SSE tests - Fixed SDK tests for new API endpoints - Ensured compatibility with Claude Sonnet 4.5 model - Fixed test environment variables (LLMX_API_KEY, LLMX_BASE_URL) ### Phase 7: Build & Release Pipeline - Updated GitHub Actions workflows for LLMX binary names - Fixed rust-release.yml to reference llmx-rs/ instead of codex-rs/ - Updated CI/CD pipelines for new package names - Made Apple code signing optional in release workflow - Enhanced npm packaging resilience for partial platform builds - Added Windows sandbox support to workspace - Updated dotslash configuration for new binary names ### Phase 8: Final Polish - Renamed all assets (.github images, labels, templates) - Updated VSCode and DevContainer configurations - Fixed all clippy warnings and formatting issues - Applied cargo fmt and prettier formatting across codebase - Updated issue templates and pull request templates - Fixed all remaining UI text references ## Technical Details **Breaking Changes:** - Binary name changed from `codex` to `llmx` - Config directory changed from `~/.codex/` to `~/.llmx/` - Environment variables renamed (CODEX_* → LLMX_*) - npm package renamed to `@valknar/llmx` **New Features:** - Support for 100+ LLM providers via LiteLLM - Unified authentication with LLMX_API_KEY - Enhanced model provider detection and handling - Improved error handling and fallback mechanisms **Files Changed:** - 578 files modified across Rust, TypeScript, and documentation - 30+ Rust crates renamed and updated - Complete rebrand of UI, CLI, and documentation - All tests updated and passing **Dependencies:** - Updated Cargo.lock with new package names - Updated npm dependencies in llmx-cli - Enhanced OpenAPI models for LLMX backend This release establishes LLMX as a standalone project with comprehensive LiteLLM integration, maintaining full backward compatibility with existing functionality while opening support for a wide ecosystem of LLM providers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Sebastian Krüger <support@pivoine.art>
357 lines
13 KiB
Rust
357 lines
13 KiB
Rust
use anyhow::Result;
|
|
use app_test_support::McpProcess;
|
|
use app_test_support::create_fake_rollout;
|
|
use app_test_support::to_response;
|
|
use llmx_app_server_protocol::JSONRPCNotification;
|
|
use llmx_app_server_protocol::JSONRPCResponse;
|
|
use llmx_app_server_protocol::ListConversationsParams;
|
|
use llmx_app_server_protocol::ListConversationsResponse;
|
|
use llmx_app_server_protocol::NewConversationParams; // reused for overrides shape
|
|
use llmx_app_server_protocol::RequestId;
|
|
use llmx_app_server_protocol::ResumeConversationParams;
|
|
use llmx_app_server_protocol::ResumeConversationResponse;
|
|
use llmx_app_server_protocol::ServerNotification;
|
|
use llmx_app_server_protocol::SessionConfiguredNotification;
|
|
use llmx_core::protocol::EventMsg;
|
|
use llmx_protocol::models::ContentItem;
|
|
use llmx_protocol::models::ResponseItem;
|
|
use pretty_assertions::assert_eq;
|
|
use tempfile::TempDir;
|
|
use tokio::time::timeout;
|
|
|
|
const DEFAULT_READ_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10);
|
|
|
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
|
async fn test_list_and_resume_conversations() -> Result<()> {
|
|
// Prepare a temporary LLMX_HOME with a few fake rollout files.
|
|
let llmx_home = TempDir::new()?;
|
|
create_fake_rollout(
|
|
llmx_home.path(),
|
|
"2025-01-02T12-00-00",
|
|
"2025-01-02T12:00:00Z",
|
|
"Hello A",
|
|
Some("openai"),
|
|
)?;
|
|
create_fake_rollout(
|
|
llmx_home.path(),
|
|
"2025-01-01T13-00-00",
|
|
"2025-01-01T13:00:00Z",
|
|
"Hello B",
|
|
Some("openai"),
|
|
)?;
|
|
create_fake_rollout(
|
|
llmx_home.path(),
|
|
"2025-01-01T12-00-00",
|
|
"2025-01-01T12:00:00Z",
|
|
"Hello C",
|
|
None,
|
|
)?;
|
|
|
|
let mut mcp = McpProcess::new(llmx_home.path()).await?;
|
|
timeout(DEFAULT_READ_TIMEOUT, mcp.initialize()).await??;
|
|
|
|
// Request first page with size 2
|
|
let req_id = mcp
|
|
.send_list_conversations_request(ListConversationsParams {
|
|
page_size: Some(2),
|
|
cursor: None,
|
|
model_providers: None,
|
|
})
|
|
.await?;
|
|
let resp: JSONRPCResponse = timeout(
|
|
DEFAULT_READ_TIMEOUT,
|
|
mcp.read_stream_until_response_message(RequestId::Integer(req_id)),
|
|
)
|
|
.await??;
|
|
let ListConversationsResponse { items, next_cursor } =
|
|
to_response::<ListConversationsResponse>(resp)?;
|
|
|
|
assert_eq!(items.len(), 2);
|
|
// Newest first; preview text should match
|
|
assert_eq!(items[0].preview, "Hello A");
|
|
assert_eq!(items[1].preview, "Hello B");
|
|
assert_eq!(items[0].model_provider, "openai");
|
|
assert_eq!(items[1].model_provider, "openai");
|
|
assert!(items[0].path.is_absolute());
|
|
assert!(next_cursor.is_some());
|
|
|
|
// Request the next page using the cursor
|
|
let req_id2 = mcp
|
|
.send_list_conversations_request(ListConversationsParams {
|
|
page_size: Some(2),
|
|
cursor: next_cursor,
|
|
model_providers: None,
|
|
})
|
|
.await?;
|
|
let resp2: JSONRPCResponse = timeout(
|
|
DEFAULT_READ_TIMEOUT,
|
|
mcp.read_stream_until_response_message(RequestId::Integer(req_id2)),
|
|
)
|
|
.await??;
|
|
let ListConversationsResponse {
|
|
items: items2,
|
|
next_cursor: next2,
|
|
..
|
|
} = to_response::<ListConversationsResponse>(resp2)?;
|
|
assert_eq!(items2.len(), 1);
|
|
assert_eq!(items2[0].preview, "Hello C");
|
|
assert_eq!(items2[0].model_provider, "litellm");
|
|
assert_eq!(next2, None);
|
|
|
|
// Add a conversation with an explicit non-OpenAI provider for filter tests.
|
|
create_fake_rollout(
|
|
llmx_home.path(),
|
|
"2025-01-01T11-30-00",
|
|
"2025-01-01T11:30:00Z",
|
|
"Hello TP",
|
|
Some("test-provider"),
|
|
)?;
|
|
|
|
// Filtering by model provider should return only matching sessions.
|
|
let filter_req_id = mcp
|
|
.send_list_conversations_request(ListConversationsParams {
|
|
page_size: Some(10),
|
|
cursor: None,
|
|
model_providers: Some(vec!["test-provider".to_string()]),
|
|
})
|
|
.await?;
|
|
let filter_resp: JSONRPCResponse = timeout(
|
|
DEFAULT_READ_TIMEOUT,
|
|
mcp.read_stream_until_response_message(RequestId::Integer(filter_req_id)),
|
|
)
|
|
.await??;
|
|
let ListConversationsResponse {
|
|
items: filtered_items,
|
|
next_cursor: filtered_next,
|
|
} = to_response::<ListConversationsResponse>(filter_resp)?;
|
|
assert_eq!(filtered_items.len(), 1);
|
|
assert_eq!(filtered_next, None);
|
|
assert_eq!(filtered_items[0].preview, "Hello TP");
|
|
assert_eq!(filtered_items[0].model_provider, "test-provider");
|
|
|
|
// Empty filter should include every session regardless of provider metadata.
|
|
let unfiltered_req_id = mcp
|
|
.send_list_conversations_request(ListConversationsParams {
|
|
page_size: Some(10),
|
|
cursor: None,
|
|
model_providers: Some(Vec::new()),
|
|
})
|
|
.await?;
|
|
let unfiltered_resp: JSONRPCResponse = timeout(
|
|
DEFAULT_READ_TIMEOUT,
|
|
mcp.read_stream_until_response_message(RequestId::Integer(unfiltered_req_id)),
|
|
)
|
|
.await??;
|
|
let ListConversationsResponse {
|
|
items: unfiltered_items,
|
|
next_cursor: unfiltered_next,
|
|
} = to_response::<ListConversationsResponse>(unfiltered_resp)?;
|
|
assert_eq!(unfiltered_items.len(), 4);
|
|
assert!(unfiltered_next.is_none());
|
|
|
|
let empty_req_id = mcp
|
|
.send_list_conversations_request(ListConversationsParams {
|
|
page_size: Some(10),
|
|
cursor: None,
|
|
model_providers: Some(vec!["other".to_string()]),
|
|
})
|
|
.await?;
|
|
let empty_resp: JSONRPCResponse = timeout(
|
|
DEFAULT_READ_TIMEOUT,
|
|
mcp.read_stream_until_response_message(RequestId::Integer(empty_req_id)),
|
|
)
|
|
.await??;
|
|
let ListConversationsResponse {
|
|
items: empty_items,
|
|
next_cursor: empty_next,
|
|
} = to_response::<ListConversationsResponse>(empty_resp)?;
|
|
assert!(empty_items.is_empty());
|
|
assert!(empty_next.is_none());
|
|
|
|
let first_item = &items[0];
|
|
|
|
// Now resume one of the sessions from an explicit rollout path.
|
|
let resume_req_id = mcp
|
|
.send_resume_conversation_request(ResumeConversationParams {
|
|
path: Some(first_item.path.clone()),
|
|
conversation_id: None,
|
|
history: None,
|
|
overrides: Some(NewConversationParams {
|
|
model: Some("o3".to_string()),
|
|
..Default::default()
|
|
}),
|
|
})
|
|
.await?;
|
|
|
|
// Expect a llmx/event notification with msg.type == sessionConfigured
|
|
let notification: JSONRPCNotification = timeout(
|
|
DEFAULT_READ_TIMEOUT,
|
|
mcp.read_stream_until_notification_message("sessionConfigured"),
|
|
)
|
|
.await??;
|
|
let session_configured: ServerNotification = notification.try_into()?;
|
|
let ServerNotification::SessionConfigured(SessionConfiguredNotification {
|
|
model,
|
|
rollout_path,
|
|
initial_messages: session_initial_messages,
|
|
..
|
|
}) = session_configured
|
|
else {
|
|
unreachable!("expected sessionConfigured notification");
|
|
};
|
|
assert_eq!(model, "o3");
|
|
assert_eq!(rollout_path, first_item.path.clone());
|
|
let session_initial_messages = session_initial_messages
|
|
.expect("expected initial messages when resuming from rollout path");
|
|
match session_initial_messages.as_slice() {
|
|
[EventMsg::UserMessage(message)] => {
|
|
assert_eq!(message.message, first_item.preview.clone());
|
|
}
|
|
other => panic!("unexpected initial messages from rollout resume: {other:#?}"),
|
|
}
|
|
|
|
// Then the response for resumeConversation
|
|
let resume_resp: JSONRPCResponse = timeout(
|
|
DEFAULT_READ_TIMEOUT,
|
|
mcp.read_stream_until_response_message(RequestId::Integer(resume_req_id)),
|
|
)
|
|
.await??;
|
|
let ResumeConversationResponse {
|
|
conversation_id,
|
|
model: resume_model,
|
|
initial_messages: response_initial_messages,
|
|
..
|
|
} = to_response::<ResumeConversationResponse>(resume_resp)?;
|
|
// conversation id should be a valid UUID
|
|
assert!(!conversation_id.to_string().is_empty());
|
|
assert_eq!(resume_model, "o3");
|
|
let response_initial_messages =
|
|
response_initial_messages.expect("expected initial messages in resume response");
|
|
match response_initial_messages.as_slice() {
|
|
[EventMsg::UserMessage(message)] => {
|
|
assert_eq!(message.message, first_item.preview.clone());
|
|
}
|
|
other => panic!("unexpected initial messages in resume response: {other:#?}"),
|
|
}
|
|
|
|
// Resuming with only a conversation id should locate the rollout automatically.
|
|
let resume_by_id_req_id = mcp
|
|
.send_resume_conversation_request(ResumeConversationParams {
|
|
path: None,
|
|
conversation_id: Some(first_item.conversation_id),
|
|
history: None,
|
|
overrides: Some(NewConversationParams {
|
|
model: Some("o3".to_string()),
|
|
..Default::default()
|
|
}),
|
|
})
|
|
.await?;
|
|
let notification: JSONRPCNotification = timeout(
|
|
DEFAULT_READ_TIMEOUT,
|
|
mcp.read_stream_until_notification_message("sessionConfigured"),
|
|
)
|
|
.await??;
|
|
let session_configured: ServerNotification = notification.try_into()?;
|
|
let ServerNotification::SessionConfigured(SessionConfiguredNotification {
|
|
model,
|
|
rollout_path,
|
|
initial_messages: session_initial_messages,
|
|
..
|
|
}) = session_configured
|
|
else {
|
|
unreachable!("expected sessionConfigured notification");
|
|
};
|
|
assert_eq!(model, "o3");
|
|
assert_eq!(rollout_path, first_item.path.clone());
|
|
let session_initial_messages = session_initial_messages
|
|
.expect("expected initial messages when resuming from conversation id");
|
|
match session_initial_messages.as_slice() {
|
|
[EventMsg::UserMessage(message)] => {
|
|
assert_eq!(message.message, first_item.preview.clone());
|
|
}
|
|
other => panic!("unexpected initial messages from conversation id resume: {other:#?}"),
|
|
}
|
|
let resume_resp: JSONRPCResponse = timeout(
|
|
DEFAULT_READ_TIMEOUT,
|
|
mcp.read_stream_until_response_message(RequestId::Integer(resume_by_id_req_id)),
|
|
)
|
|
.await??;
|
|
let ResumeConversationResponse {
|
|
conversation_id: by_id_conversation_id,
|
|
model: by_id_model,
|
|
initial_messages: by_id_initial_messages,
|
|
..
|
|
} = to_response::<ResumeConversationResponse>(resume_resp)?;
|
|
assert!(!by_id_conversation_id.to_string().is_empty());
|
|
assert_eq!(by_id_model, "o3");
|
|
let by_id_initial_messages = by_id_initial_messages
|
|
.expect("expected initial messages when resuming from conversation id response");
|
|
match by_id_initial_messages.as_slice() {
|
|
[EventMsg::UserMessage(message)] => {
|
|
assert_eq!(message.message, first_item.preview.clone());
|
|
}
|
|
other => {
|
|
panic!("unexpected initial messages in conversation id resume response: {other:#?}")
|
|
}
|
|
}
|
|
|
|
// Resuming with explicit history should succeed even without a stored rollout.
|
|
let fork_history_text = "Hello from history";
|
|
let history = vec![ResponseItem::Message {
|
|
id: None,
|
|
role: "user".to_string(),
|
|
content: vec![ContentItem::InputText {
|
|
text: fork_history_text.to_string(),
|
|
}],
|
|
}];
|
|
let resume_with_history_req_id = mcp
|
|
.send_resume_conversation_request(ResumeConversationParams {
|
|
path: None,
|
|
conversation_id: None,
|
|
history: Some(history),
|
|
overrides: Some(NewConversationParams {
|
|
model: Some("o3".to_string()),
|
|
..Default::default()
|
|
}),
|
|
})
|
|
.await?;
|
|
let notification: JSONRPCNotification = timeout(
|
|
DEFAULT_READ_TIMEOUT,
|
|
mcp.read_stream_until_notification_message("sessionConfigured"),
|
|
)
|
|
.await??;
|
|
let session_configured: ServerNotification = notification.try_into()?;
|
|
let ServerNotification::SessionConfigured(SessionConfiguredNotification {
|
|
model,
|
|
initial_messages: session_initial_messages,
|
|
..
|
|
}) = session_configured
|
|
else {
|
|
unreachable!("expected sessionConfigured notification");
|
|
};
|
|
assert_eq!(model, "o3");
|
|
assert!(
|
|
session_initial_messages.as_ref().is_none_or(Vec::is_empty),
|
|
"expected no initial messages when resuming from explicit history but got {session_initial_messages:#?}"
|
|
);
|
|
let resume_resp: JSONRPCResponse = timeout(
|
|
DEFAULT_READ_TIMEOUT,
|
|
mcp.read_stream_until_response_message(RequestId::Integer(resume_with_history_req_id)),
|
|
)
|
|
.await??;
|
|
let ResumeConversationResponse {
|
|
conversation_id: history_conversation_id,
|
|
model: history_model,
|
|
initial_messages: history_initial_messages,
|
|
..
|
|
} = to_response::<ResumeConversationResponse>(resume_resp)?;
|
|
assert!(!history_conversation_id.to_string().is_empty());
|
|
assert_eq!(history_model, "o3");
|
|
assert!(
|
|
history_initial_messages.as_ref().is_none_or(Vec::is_empty),
|
|
"expected no initial messages in resume response when history is provided but got {history_initial_messages:#?}"
|
|
);
|
|
|
|
Ok(())
|
|
}
|