feat: Complete LLMX v0.1.0 - Rebrand from Codex with LiteLLM Integration
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>
This commit is contained in:
204
llmx-rs/execpolicy/src/arg_resolver.rs
Normal file
204
llmx-rs/execpolicy/src/arg_resolver.rs
Normal file
@@ -0,0 +1,204 @@
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::arg_matcher::ArgMatcher;
|
||||
use crate::arg_matcher::ArgMatcherCardinality;
|
||||
use crate::error::Error;
|
||||
use crate::error::Result;
|
||||
use crate::valid_exec::MatchedArg;
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
|
||||
pub struct PositionalArg {
|
||||
pub index: usize,
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
pub fn resolve_observed_args_with_patterns(
|
||||
program: &str,
|
||||
args: Vec<PositionalArg>,
|
||||
arg_patterns: &Vec<ArgMatcher>,
|
||||
) -> Result<Vec<MatchedArg>> {
|
||||
// Naive matching implementation. Among `arg_patterns`, there is allowed to
|
||||
// be at most one vararg pattern. Assuming `arg_patterns` is non-empty, we
|
||||
// end up with either:
|
||||
//
|
||||
// - all `arg_patterns` in `prefix_patterns`
|
||||
// - `arg_patterns` split across `prefix_patterns` (which could be empty),
|
||||
// one `vararg_pattern`, and `suffix_patterns` (which could also empty).
|
||||
//
|
||||
// From there, we start by matching everything in `prefix_patterns`.
|
||||
// Then we calculate how many positional args should be matched by
|
||||
// `suffix_patterns` and use that to determine how many args are left to
|
||||
// be matched by `vararg_pattern` (which could be zero).
|
||||
//
|
||||
// After associating positional args with `vararg_pattern`, we match the
|
||||
// `suffix_patterns` with the remaining args.
|
||||
let ParitionedArgs {
|
||||
num_prefix_args,
|
||||
num_suffix_args,
|
||||
prefix_patterns,
|
||||
suffix_patterns,
|
||||
vararg_pattern,
|
||||
} = partition_args(program, arg_patterns)?;
|
||||
|
||||
let mut matched_args = Vec::<MatchedArg>::new();
|
||||
|
||||
let prefix = get_range_checked(&args, 0..num_prefix_args)?;
|
||||
let mut prefix_arg_index = 0;
|
||||
for pattern in prefix_patterns {
|
||||
let n = pattern
|
||||
.cardinality()
|
||||
.is_exact()
|
||||
.ok_or(Error::InternalInvariantViolation {
|
||||
message: "expected exact cardinality".to_string(),
|
||||
})?;
|
||||
for positional_arg in &prefix[prefix_arg_index..prefix_arg_index + n] {
|
||||
let matched_arg = MatchedArg::new(
|
||||
positional_arg.index,
|
||||
pattern.arg_type(),
|
||||
&positional_arg.value.clone(),
|
||||
)?;
|
||||
matched_args.push(matched_arg);
|
||||
}
|
||||
prefix_arg_index += n;
|
||||
}
|
||||
|
||||
if num_suffix_args > args.len() {
|
||||
return Err(Error::NotEnoughArgs {
|
||||
program: program.to_string(),
|
||||
args,
|
||||
arg_patterns: arg_patterns.clone(),
|
||||
});
|
||||
}
|
||||
|
||||
let initial_suffix_args_index = args.len() - num_suffix_args;
|
||||
if prefix_arg_index > initial_suffix_args_index {
|
||||
return Err(Error::PrefixOverlapsSuffix {});
|
||||
}
|
||||
|
||||
if let Some(pattern) = vararg_pattern {
|
||||
let vararg = get_range_checked(&args, prefix_arg_index..initial_suffix_args_index)?;
|
||||
match pattern.cardinality() {
|
||||
ArgMatcherCardinality::One => {
|
||||
return Err(Error::InternalInvariantViolation {
|
||||
message: "vararg pattern should not have cardinality of one".to_string(),
|
||||
});
|
||||
}
|
||||
ArgMatcherCardinality::AtLeastOne => {
|
||||
if vararg.is_empty() {
|
||||
return Err(Error::VarargMatcherDidNotMatchAnything {
|
||||
program: program.to_string(),
|
||||
matcher: pattern,
|
||||
});
|
||||
} else {
|
||||
for positional_arg in vararg {
|
||||
let matched_arg = MatchedArg::new(
|
||||
positional_arg.index,
|
||||
pattern.arg_type(),
|
||||
&positional_arg.value.clone(),
|
||||
)?;
|
||||
matched_args.push(matched_arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
ArgMatcherCardinality::ZeroOrMore => {
|
||||
for positional_arg in vararg {
|
||||
let matched_arg = MatchedArg::new(
|
||||
positional_arg.index,
|
||||
pattern.arg_type(),
|
||||
&positional_arg.value.clone(),
|
||||
)?;
|
||||
matched_args.push(matched_arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let suffix = get_range_checked(&args, initial_suffix_args_index..args.len())?;
|
||||
let mut suffix_arg_index = 0;
|
||||
for pattern in suffix_patterns {
|
||||
let n = pattern
|
||||
.cardinality()
|
||||
.is_exact()
|
||||
.ok_or(Error::InternalInvariantViolation {
|
||||
message: "expected exact cardinality".to_string(),
|
||||
})?;
|
||||
for positional_arg in &suffix[suffix_arg_index..suffix_arg_index + n] {
|
||||
let matched_arg = MatchedArg::new(
|
||||
positional_arg.index,
|
||||
pattern.arg_type(),
|
||||
&positional_arg.value.clone(),
|
||||
)?;
|
||||
matched_args.push(matched_arg);
|
||||
}
|
||||
suffix_arg_index += n;
|
||||
}
|
||||
|
||||
if matched_args.len() < args.len() {
|
||||
let extra_args = get_range_checked(&args, matched_args.len()..args.len())?;
|
||||
Err(Error::UnexpectedArguments {
|
||||
program: program.to_string(),
|
||||
args: extra_args.to_vec(),
|
||||
})
|
||||
} else {
|
||||
Ok(matched_args)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct ParitionedArgs {
|
||||
num_prefix_args: usize,
|
||||
num_suffix_args: usize,
|
||||
prefix_patterns: Vec<ArgMatcher>,
|
||||
suffix_patterns: Vec<ArgMatcher>,
|
||||
vararg_pattern: Option<ArgMatcher>,
|
||||
}
|
||||
|
||||
fn partition_args(program: &str, arg_patterns: &Vec<ArgMatcher>) -> Result<ParitionedArgs> {
|
||||
let mut in_prefix = true;
|
||||
let mut partitioned_args = ParitionedArgs::default();
|
||||
|
||||
for pattern in arg_patterns {
|
||||
match pattern.cardinality().is_exact() {
|
||||
Some(n) => {
|
||||
if in_prefix {
|
||||
partitioned_args.prefix_patterns.push(pattern.clone());
|
||||
partitioned_args.num_prefix_args += n;
|
||||
} else {
|
||||
partitioned_args.suffix_patterns.push(pattern.clone());
|
||||
partitioned_args.num_suffix_args += n;
|
||||
}
|
||||
}
|
||||
None => match partitioned_args.vararg_pattern {
|
||||
None => {
|
||||
partitioned_args.vararg_pattern = Some(pattern.clone());
|
||||
in_prefix = false;
|
||||
}
|
||||
Some(existing_pattern) => {
|
||||
return Err(Error::MultipleVarargPatterns {
|
||||
program: program.to_string(),
|
||||
first: existing_pattern,
|
||||
second: pattern.clone(),
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Ok(partitioned_args)
|
||||
}
|
||||
|
||||
fn get_range_checked<T>(vec: &[T], range: std::ops::Range<usize>) -> Result<&[T]> {
|
||||
if range.start > range.end {
|
||||
Err(Error::RangeStartExceedsEnd {
|
||||
start: range.start,
|
||||
end: range.end,
|
||||
})
|
||||
} else if range.end > vec.len() {
|
||||
Err(Error::RangeEndOutOfBounds {
|
||||
end: range.end,
|
||||
len: vec.len(),
|
||||
})
|
||||
} else {
|
||||
Ok(&vec[range])
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user