Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ members = [
"crates/llm-access",
"crates/llm-access-core",
"crates/llm-access-codex",
"crates/llm-access-codex-image",
"crates/llm-access-kiro",
"crates/llm-access-migrations",
"crates/llm-access-store",
Expand Down
71 changes: 71 additions & 0 deletions crates/frontend/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6066,6 +6066,10 @@ const fn default_true() -> bool {
true
}

const fn default_codex_image_generation_max_concurrency() -> u64 {
3
}

fn default_kiro_pool_strategy() -> String {
llm_store::default_kiro_pool_strategy()
}
Expand Down Expand Up @@ -6095,6 +6099,12 @@ pub struct AdminLlmGatewayKeyView {
pub usage_output_tokens: u64,
pub usage_credit_total: f64,
pub usage_credit_missing_events: u64,
#[serde(default)]
pub codex_image_usage_tokens: u64,
#[serde(default)]
pub codex_image_usage_missing_events: u64,
#[serde(default)]
pub codex_image_last_used_at: Option<i64>,
pub remaining_billable: i64,
pub last_used_at: Option<i64>,
pub created_at: i64,
Expand All @@ -6112,6 +6122,8 @@ pub struct AdminLlmGatewayKeyView {
pub codex_fast_enabled: bool,
#[serde(default)]
pub codex_strict_session_rejection_enabled: bool,
#[serde(default)]
pub codex_image_generation_enabled: bool,
#[serde(default = "default_true")]
pub kiro_request_validation_enabled: bool,
#[serde(default = "default_true")]
Expand Down Expand Up @@ -6170,6 +6182,10 @@ pub struct AdminLlmGatewayKeysSummaryView {
pub usage_billable_tokens_sum: u64,
pub usage_credit_total: f64,
pub usage_credit_missing_events: u64,
#[serde(default)]
pub codex_image_usage_tokens_sum: u64,
#[serde(default)]
pub codex_image_usage_missing_events: u64,
}

/// Combined admin payload for the key inventory screen.
Expand Down Expand Up @@ -8956,6 +8972,9 @@ pub async fn create_admin_llm_gateway_key(
usage_output_tokens: 0,
usage_credit_total: 0.0,
usage_credit_missing_events: 0,
codex_image_usage_tokens: 0,
codex_image_usage_missing_events: 0,
codex_image_last_used_at: None,
remaining_billable: quota_billable_limit as i64,
last_used_at: None,
created_at: 0,
Expand Down Expand Up @@ -8985,6 +9004,7 @@ pub async fn create_admin_llm_gateway_key(
uses_global_kiro_billable_model_multipliers: true,
codex_fast_enabled: true,
codex_strict_session_rejection_enabled: false,
codex_image_generation_enabled: false,
kiro_candidate_credit_summary: None,
})
}
Expand Down Expand Up @@ -9032,6 +9052,7 @@ pub struct PatchAdminLlmGatewayKeyRequest<'a> {
pub request_min_start_interval_ms: Option<u64>,
pub codex_fast_enabled: Option<bool>,
pub codex_strict_session_rejection_enabled: Option<bool>,
pub codex_image_generation_enabled: Option<bool>,
pub kiro_request_validation_enabled: Option<bool>,
pub kiro_cache_estimation_enabled: Option<bool>,
pub kiro_zero_cache_debug_enabled: Option<bool>,
Expand Down Expand Up @@ -9068,6 +9089,7 @@ pub async fn patch_admin_llm_gateway_key(
request.request_min_start_interval_ms,
request.codex_fast_enabled,
request.codex_strict_session_rejection_enabled,
request.codex_image_generation_enabled,
request.kiro_request_validation_enabled,
request.kiro_cache_estimation_enabled,
request.kiro_zero_cache_debug_enabled,
Expand Down Expand Up @@ -9179,6 +9201,12 @@ pub async fn patch_admin_llm_gateway_key(
serde_json::Value::Bool(enabled),
);
}
if let Some(enabled) = request.codex_image_generation_enabled {
body.insert(
"codex_image_generation_enabled".to_string(),
serde_json::Value::Bool(enabled),
);
}
if let Some(kiro_request_validation_enabled) = request.kiro_request_validation_enabled {
body.insert(
"kiro_request_validation_enabled".to_string(),
Expand Down Expand Up @@ -9855,6 +9883,10 @@ pub struct AccountSummaryView {
pub auto_refresh_enabled: bool,
pub request_max_concurrency: Option<u64>,
pub request_min_start_interval_ms: Option<u64>,
#[serde(default)]
pub codex_image_generation_enabled: bool,
#[serde(default = "default_codex_image_generation_max_concurrency")]
pub codex_image_generation_max_concurrency: u64,
pub proxy_mode: String,
pub proxy_config_id: Option<String>,
pub effective_proxy_source: String,
Expand Down Expand Up @@ -9883,6 +9915,9 @@ impl Default for AccountSummaryView {
auto_refresh_enabled: true,
request_max_concurrency: None,
request_min_start_interval_ms: None,
codex_image_generation_enabled: false,
codex_image_generation_max_concurrency: default_codex_image_generation_max_concurrency(
),
proxy_mode: "inherit".to_string(),
proxy_config_id: None,
effective_proxy_source: "binding".to_string(),
Expand Down Expand Up @@ -10248,6 +10283,9 @@ pub async fn import_admin_llm_gateway_account(
auto_refresh_enabled: true,
request_max_concurrency: None,
request_min_start_interval_ms: None,
codex_image_generation_enabled: false,
codex_image_generation_max_concurrency: default_codex_image_generation_max_concurrency(
),
proxy_mode: "inherit".to_string(),
proxy_config_id: None,
effective_proxy_source: "binding".to_string(),
Expand Down Expand Up @@ -10347,6 +10385,8 @@ pub struct PatchAdminLlmGatewayAccountInput {
pub proxy_config_id: Option<String>,
pub request_max_concurrency: Option<u64>,
pub request_min_start_interval_ms: Option<u64>,
pub codex_image_generation_enabled: Option<bool>,
pub codex_image_generation_max_concurrency: Option<u64>,
pub request_max_concurrency_unlimited: bool,
pub request_min_start_interval_ms_unlimited: bool,
}
Expand All @@ -10373,6 +10413,10 @@ pub async fn patch_admin_llm_gateway_account(
auto_refresh_enabled: input.auto_refresh_enabled.unwrap_or(true),
request_max_concurrency: input.request_max_concurrency,
request_min_start_interval_ms: input.request_min_start_interval_ms,
codex_image_generation_enabled: input.codex_image_generation_enabled.unwrap_or(false),
codex_image_generation_max_concurrency: input
.codex_image_generation_max_concurrency
.unwrap_or_else(default_codex_image_generation_max_concurrency),
proxy_mode: input
.proxy_mode
.clone()
Expand Down Expand Up @@ -10430,6 +10474,9 @@ pub async fn refresh_admin_llm_gateway_account(name: &str) -> Result<AccountSumm
auto_refresh_enabled: true,
request_max_concurrency: None,
request_min_start_interval_ms: None,
codex_image_generation_enabled: false,
codex_image_generation_max_concurrency: default_codex_image_generation_max_concurrency(
),
proxy_mode: "inherit".to_string(),
proxy_config_id: None,
effective_proxy_source: "binding".to_string(),
Expand Down Expand Up @@ -10492,6 +10539,9 @@ pub async fn refresh_admin_llm_gateway_account_auth(
auto_refresh_enabled: true,
request_max_concurrency: None,
request_min_start_interval_ms: None,
codex_image_generation_enabled: false,
codex_image_generation_max_concurrency: default_codex_image_generation_max_concurrency(
),
proxy_mode: "inherit".to_string(),
proxy_config_id: None,
effective_proxy_source: "binding".to_string(),
Expand Down Expand Up @@ -10563,6 +10613,9 @@ pub async fn consume_admin_llm_gateway_account_rate_limit_reset_credit(
auto_refresh_enabled: true,
request_max_concurrency: None,
request_min_start_interval_ms: None,
codex_image_generation_enabled: false,
codex_image_generation_max_concurrency:
default_codex_image_generation_max_concurrency(),
proxy_mode: "inherit".to_string(),
proxy_config_id: None,
effective_proxy_source: "binding".to_string(),
Expand Down Expand Up @@ -11196,6 +11249,9 @@ pub async fn create_admin_kiro_key(
usage_output_tokens: 0,
usage_credit_total: 0.0,
usage_credit_missing_events: 0,
codex_image_usage_tokens: 0,
codex_image_usage_missing_events: 0,
codex_image_last_used_at: None,
remaining_billable: quota_billable_limit as i64,
last_used_at: None,
created_at: 0,
Expand Down Expand Up @@ -11225,6 +11281,7 @@ pub async fn create_admin_kiro_key(
uses_global_kiro_billable_model_multipliers: true,
codex_fast_enabled: true,
codex_strict_session_rejection_enabled: false,
codex_image_generation_enabled: false,
kiro_candidate_credit_summary: None,
})
}
Expand Down Expand Up @@ -11960,6 +12017,18 @@ mod tests {

assert!(!key.kiro_full_request_logging_enabled);
assert!(!key.kiro_remote_media_resolution_enabled);
assert!(!key.codex_image_generation_enabled);
}

#[test]
fn admin_gateway_key_view_defaults_codex_image_usage_to_zero() {
let key: AdminLlmGatewayKeyView =
serde_json::from_str(r#"{"id":"k","name":"K","provider_type":"codex"}"#)
.expect("key should parse");

assert_eq!(key.codex_image_usage_tokens, 0);
assert_eq!(key.codex_image_usage_missing_events, 0);
assert_eq!(key.codex_image_last_used_at, None);
}

#[test]
Expand Down Expand Up @@ -12084,6 +12153,8 @@ mod tests {
.expect("account summary should parse");

assert_eq!(account.rate_limit_reset_credits_available, Some(2));
assert!(!account.codex_image_generation_enabled);
assert_eq!(account.codex_image_generation_max_concurrency, 3);
}

#[test]
Expand Down
2 changes: 2 additions & 0 deletions crates/frontend/src/pages/admin_kiro_gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1899,6 +1899,7 @@ fn kiro_key_editor_card(props: &KiroKeyEditorCardProps) -> Html {
request_min_start_interval_ms: None,
codex_fast_enabled: None,
codex_strict_session_rejection_enabled: None,
codex_image_generation_enabled: None,
kiro_request_validation_enabled: Some(kiro_request_validation_enabled_value),
kiro_cache_estimation_enabled: Some(kiro_cache_estimation_enabled_value),
kiro_zero_cache_debug_enabled: Some(kiro_zero_cache_debug_enabled_value),
Expand Down Expand Up @@ -2006,6 +2007,7 @@ fn kiro_key_editor_card(props: &KiroKeyEditorCardProps) -> Html {
request_min_start_interval_ms: None,
codex_fast_enabled: None,
codex_strict_session_rejection_enabled: None,
codex_image_generation_enabled: None,
kiro_request_validation_enabled: None,
kiro_cache_estimation_enabled: Some(kiro_cache_estimation_enabled_value),
kiro_zero_cache_debug_enabled: Some(kiro_zero_cache_debug_enabled_value),
Expand Down
Loading
Loading