clean up legacy openai cli adapter names

This commit is contained in:
fawney19
2026-04-26 21:12:57 +08:00
parent 5b914aa78c
commit ea3dc3257e
47 changed files with 412 additions and 572 deletions

View File

@@ -44,15 +44,11 @@ pub use crate::contracts::{
GEMINI_VIDEO_CREATE_SYNC_FINALIZE_REPORT_KIND, GEMINI_VIDEO_CREATE_SYNC_PLAN_KIND,
OPENAI_CHAT_STREAM_PLAN_KIND, OPENAI_CHAT_STREAM_SUCCESS_REPORT_KIND,
OPENAI_CHAT_SYNC_ERROR_REPORT_KIND, OPENAI_CHAT_SYNC_FINALIZE_REPORT_KIND,
OPENAI_CHAT_SYNC_PLAN_KIND, OPENAI_CHAT_SYNC_SUCCESS_REPORT_KIND, OPENAI_CLI_STREAM_PLAN_KIND,
OPENAI_CLI_STREAM_SUCCESS_REPORT_KIND, OPENAI_CLI_SYNC_ERROR_REPORT_KIND,
OPENAI_CLI_SYNC_FINALIZE_REPORT_KIND, OPENAI_CLI_SYNC_PLAN_KIND,
OPENAI_CLI_SYNC_SUCCESS_REPORT_KIND, OPENAI_COMPACT_STREAM_PLAN_KIND,
OPENAI_COMPACT_SYNC_ERROR_REPORT_KIND, OPENAI_COMPACT_SYNC_FINALIZE_REPORT_KIND,
OPENAI_COMPACT_SYNC_PLAN_KIND, OPENAI_IMAGE_STREAM_PLAN_KIND,
OPENAI_IMAGE_STREAM_SUCCESS_REPORT_KIND, OPENAI_IMAGE_SYNC_FINALIZE_REPORT_KIND,
OPENAI_IMAGE_SYNC_PLAN_KIND, OPENAI_IMAGE_SYNC_SUCCESS_REPORT_KIND,
OPENAI_RESPONSES_COMPACT_STREAM_PLAN_KIND, OPENAI_RESPONSES_COMPACT_STREAM_SUCCESS_REPORT_KIND,
OPENAI_CHAT_SYNC_PLAN_KIND, OPENAI_CHAT_SYNC_SUCCESS_REPORT_KIND,
OPENAI_IMAGE_STREAM_PLAN_KIND, OPENAI_IMAGE_STREAM_SUCCESS_REPORT_KIND,
OPENAI_IMAGE_SYNC_FINALIZE_REPORT_KIND, OPENAI_IMAGE_SYNC_PLAN_KIND,
OPENAI_IMAGE_SYNC_SUCCESS_REPORT_KIND, OPENAI_RESPONSES_COMPACT_STREAM_PLAN_KIND,
OPENAI_RESPONSES_COMPACT_STREAM_SUCCESS_REPORT_KIND,
OPENAI_RESPONSES_COMPACT_SYNC_ERROR_REPORT_KIND,
OPENAI_RESPONSES_COMPACT_SYNC_FINALIZE_REPORT_KIND, OPENAI_RESPONSES_COMPACT_SYNC_PLAN_KIND,
OPENAI_RESPONSES_COMPACT_SYNC_SUCCESS_REPORT_KIND, OPENAI_RESPONSES_STREAM_PLAN_KIND,
@@ -169,12 +165,6 @@ pub use crate::planner::specialized::{
LocalVideoCreateSpec,
},
};
#[allow(deprecated)]
pub use crate::planner::standard::apply_openai_compact_special_body_edits;
#[allow(deprecated)]
pub use crate::planner::standard::{
apply_codex_openai_cli_special_body_edits, apply_codex_openai_cli_special_headers,
};
pub use crate::planner::standard::{
apply_codex_openai_responses_special_body_edits, apply_codex_openai_responses_special_headers,
apply_openai_responses_compact_special_body_edits, build_cross_format_openai_chat_request_body,

View File

@@ -23,8 +23,7 @@ pub use plan_kinds::{
GEMINI_FILES_DOWNLOAD_PLAN_KIND, GEMINI_FILES_GET_PLAN_KIND, GEMINI_FILES_LIST_PLAN_KIND,
GEMINI_FILES_UPLOAD_PLAN_KIND, GEMINI_VIDEO_CANCEL_SYNC_PLAN_KIND,
GEMINI_VIDEO_CREATE_SYNC_PLAN_KIND, OPENAI_CHAT_STREAM_PLAN_KIND, OPENAI_CHAT_SYNC_PLAN_KIND,
OPENAI_CLI_STREAM_PLAN_KIND, OPENAI_CLI_SYNC_PLAN_KIND, OPENAI_COMPACT_STREAM_PLAN_KIND,
OPENAI_COMPACT_SYNC_PLAN_KIND, OPENAI_IMAGE_STREAM_PLAN_KIND, OPENAI_IMAGE_SYNC_PLAN_KIND,
OPENAI_IMAGE_STREAM_PLAN_KIND, OPENAI_IMAGE_SYNC_PLAN_KIND,
OPENAI_RESPONSES_COMPACT_STREAM_PLAN_KIND, OPENAI_RESPONSES_COMPACT_SYNC_PLAN_KIND,
OPENAI_RESPONSES_STREAM_PLAN_KIND, OPENAI_RESPONSES_SYNC_PLAN_KIND,
OPENAI_VIDEO_CANCEL_SYNC_PLAN_KIND, OPENAI_VIDEO_CONTENT_PLAN_KIND,
@@ -45,9 +44,6 @@ pub use report_kinds::{
GEMINI_CLI_SYNC_SUCCESS_REPORT_KIND, GEMINI_VIDEO_CREATE_SYNC_FINALIZE_REPORT_KIND,
OPENAI_CHAT_STREAM_SUCCESS_REPORT_KIND, OPENAI_CHAT_SYNC_ERROR_REPORT_KIND,
OPENAI_CHAT_SYNC_FINALIZE_REPORT_KIND, OPENAI_CHAT_SYNC_SUCCESS_REPORT_KIND,
OPENAI_CLI_STREAM_SUCCESS_REPORT_KIND, OPENAI_CLI_SYNC_ERROR_REPORT_KIND,
OPENAI_CLI_SYNC_FINALIZE_REPORT_KIND, OPENAI_CLI_SYNC_SUCCESS_REPORT_KIND,
OPENAI_COMPACT_SYNC_ERROR_REPORT_KIND, OPENAI_COMPACT_SYNC_FINALIZE_REPORT_KIND,
OPENAI_IMAGE_STREAM_SUCCESS_REPORT_KIND, OPENAI_IMAGE_SYNC_FINALIZE_REPORT_KIND,
OPENAI_IMAGE_SYNC_SUCCESS_REPORT_KIND, OPENAI_RESPONSES_COMPACT_STREAM_SUCCESS_REPORT_KIND,
OPENAI_RESPONSES_COMPACT_SYNC_ERROR_REPORT_KIND,

View File

@@ -16,16 +16,12 @@ pub const CLAUDE_CHAT_STREAM_PLAN_KIND: &str = "claude_chat_stream";
pub const GEMINI_CHAT_STREAM_PLAN_KIND: &str = "gemini_chat_stream";
pub const OPENAI_RESPONSES_STREAM_PLAN_KIND: &str = "openai_responses_stream";
pub const OPENAI_RESPONSES_COMPACT_STREAM_PLAN_KIND: &str = "openai_responses_compact_stream";
pub const OPENAI_CLI_STREAM_PLAN_KIND: &str = "openai_cli_stream";
pub const OPENAI_COMPACT_STREAM_PLAN_KIND: &str = "openai_compact_stream";
pub const CLAUDE_CLI_STREAM_PLAN_KIND: &str = "claude_cli_stream";
pub const GEMINI_CLI_STREAM_PLAN_KIND: &str = "gemini_cli_stream";
pub const OPENAI_VIDEO_CREATE_SYNC_PLAN_KIND: &str = "openai_video_create_sync";
pub const OPENAI_CHAT_SYNC_PLAN_KIND: &str = "openai_chat_sync";
pub const OPENAI_RESPONSES_SYNC_PLAN_KIND: &str = "openai_responses_sync";
pub const OPENAI_RESPONSES_COMPACT_SYNC_PLAN_KIND: &str = "openai_responses_compact_sync";
pub const OPENAI_CLI_SYNC_PLAN_KIND: &str = "openai_cli_sync";
pub const OPENAI_COMPACT_SYNC_PLAN_KIND: &str = "openai_compact_sync";
pub const CLAUDE_CHAT_SYNC_PLAN_KIND: &str = "claude_chat_sync";
pub const GEMINI_CHAT_SYNC_PLAN_KIND: &str = "gemini_chat_sync";
pub const CLAUDE_CLI_SYNC_PLAN_KIND: &str = "claude_cli_sync";
@@ -34,19 +30,13 @@ pub const GEMINI_CLI_SYNC_PLAN_KIND: &str = "gemini_cli_sync";
pub fn is_openai_responses_stream_plan_kind(plan_kind: &str) -> bool {
matches!(
plan_kind,
OPENAI_RESPONSES_STREAM_PLAN_KIND
| OPENAI_RESPONSES_COMPACT_STREAM_PLAN_KIND
| OPENAI_CLI_STREAM_PLAN_KIND
| OPENAI_COMPACT_STREAM_PLAN_KIND
OPENAI_RESPONSES_STREAM_PLAN_KIND | OPENAI_RESPONSES_COMPACT_STREAM_PLAN_KIND
)
}
pub fn is_openai_responses_sync_plan_kind(plan_kind: &str) -> bool {
matches!(
plan_kind,
OPENAI_RESPONSES_SYNC_PLAN_KIND
| OPENAI_RESPONSES_COMPACT_SYNC_PLAN_KIND
| OPENAI_CLI_SYNC_PLAN_KIND
| OPENAI_COMPACT_SYNC_PLAN_KIND
OPENAI_RESPONSES_SYNC_PLAN_KIND | OPENAI_RESPONSES_COMPACT_SYNC_PLAN_KIND
)
}

View File

@@ -1,8 +1,8 @@
use crate::contracts::{
CLAUDE_CHAT_SYNC_PLAN_KIND, CLAUDE_CLI_SYNC_PLAN_KIND, GEMINI_CHAT_SYNC_PLAN_KIND,
GEMINI_CLI_SYNC_PLAN_KIND, OPENAI_CHAT_SYNC_PLAN_KIND, OPENAI_CLI_SYNC_PLAN_KIND,
OPENAI_COMPACT_SYNC_PLAN_KIND, OPENAI_IMAGE_STREAM_PLAN_KIND, OPENAI_IMAGE_SYNC_PLAN_KIND,
OPENAI_RESPONSES_COMPACT_SYNC_PLAN_KIND, OPENAI_RESPONSES_SYNC_PLAN_KIND,
GEMINI_CLI_SYNC_PLAN_KIND, OPENAI_CHAT_SYNC_PLAN_KIND, OPENAI_IMAGE_STREAM_PLAN_KIND,
OPENAI_IMAGE_SYNC_PLAN_KIND, OPENAI_RESPONSES_COMPACT_SYNC_PLAN_KIND,
OPENAI_RESPONSES_SYNC_PLAN_KIND,
};
pub const OPENAI_CHAT_SYNC_FINALIZE_REPORT_KIND: &str = "openai_chat_sync_finalize";
@@ -11,13 +11,13 @@ pub const GEMINI_CHAT_SYNC_FINALIZE_REPORT_KIND: &str = "gemini_chat_sync_finali
pub const OPENAI_RESPONSES_SYNC_FINALIZE_REPORT_KIND: &str = "openai_responses_sync_finalize";
pub const OPENAI_RESPONSES_COMPACT_SYNC_FINALIZE_REPORT_KIND: &str =
"openai_responses_compact_sync_finalize";
pub const OPENAI_CLI_SYNC_FINALIZE_REPORT_KIND: &str = "openai_cli_sync_finalize";
pub const OPENAI_COMPACT_SYNC_FINALIZE_REPORT_KIND: &str = "openai_compact_sync_finalize";
pub const OPENAI_IMAGE_SYNC_FINALIZE_REPORT_KIND: &str = "openai_image_sync_finalize";
pub const CLAUDE_CLI_SYNC_FINALIZE_REPORT_KIND: &str = "claude_cli_sync_finalize";
pub const GEMINI_CLI_SYNC_FINALIZE_REPORT_KIND: &str = "gemini_cli_sync_finalize";
pub const OPENAI_VIDEO_CREATE_SYNC_FINALIZE_REPORT_KIND: &str = "openai_video_create_sync_finalize";
pub const GEMINI_VIDEO_CREATE_SYNC_FINALIZE_REPORT_KIND: &str = "gemini_video_create_sync_finalize";
const LEGACY_OPENAI_CLI_SYNC_FINALIZE_REPORT_KIND: &str = "openai_cli_sync_finalize";
const LEGACY_OPENAI_COMPACT_SYNC_FINALIZE_REPORT_KIND: &str = "openai_compact_sync_finalize";
pub const OPENAI_CHAT_SYNC_SUCCESS_REPORT_KIND: &str = "openai_chat_sync_success";
pub const CLAUDE_CHAT_SYNC_SUCCESS_REPORT_KIND: &str = "claude_chat_sync_success";
@@ -25,7 +25,6 @@ pub const GEMINI_CHAT_SYNC_SUCCESS_REPORT_KIND: &str = "gemini_chat_sync_success
pub const OPENAI_RESPONSES_SYNC_SUCCESS_REPORT_KIND: &str = "openai_responses_sync_success";
pub const OPENAI_RESPONSES_COMPACT_SYNC_SUCCESS_REPORT_KIND: &str =
"openai_responses_compact_sync_success";
pub const OPENAI_CLI_SYNC_SUCCESS_REPORT_KIND: &str = "openai_cli_sync_success";
pub const OPENAI_IMAGE_SYNC_SUCCESS_REPORT_KIND: &str = "openai_image_sync_success";
pub const CLAUDE_CLI_SYNC_SUCCESS_REPORT_KIND: &str = "claude_cli_sync_success";
pub const GEMINI_CLI_SYNC_SUCCESS_REPORT_KIND: &str = "gemini_cli_sync_success";
@@ -36,7 +35,6 @@ pub const GEMINI_CHAT_STREAM_SUCCESS_REPORT_KIND: &str = "gemini_chat_stream_suc
pub const OPENAI_RESPONSES_STREAM_SUCCESS_REPORT_KIND: &str = "openai_responses_stream_success";
pub const OPENAI_RESPONSES_COMPACT_STREAM_SUCCESS_REPORT_KIND: &str =
"openai_responses_compact_stream_success";
pub const OPENAI_CLI_STREAM_SUCCESS_REPORT_KIND: &str = "openai_cli_stream_success";
pub const OPENAI_IMAGE_STREAM_SUCCESS_REPORT_KIND: &str = "openai_image_stream_success";
pub const CLAUDE_CLI_STREAM_SUCCESS_REPORT_KIND: &str = "claude_cli_stream_success";
pub const GEMINI_CLI_STREAM_SUCCESS_REPORT_KIND: &str = "gemini_cli_stream_success";
@@ -47,8 +45,6 @@ pub const GEMINI_CHAT_SYNC_ERROR_REPORT_KIND: &str = "gemini_chat_sync_error";
pub const OPENAI_RESPONSES_SYNC_ERROR_REPORT_KIND: &str = "openai_responses_sync_error";
pub const OPENAI_RESPONSES_COMPACT_SYNC_ERROR_REPORT_KIND: &str =
"openai_responses_compact_sync_error";
pub const OPENAI_CLI_SYNC_ERROR_REPORT_KIND: &str = "openai_cli_sync_error";
pub const OPENAI_COMPACT_SYNC_ERROR_REPORT_KIND: &str = "openai_compact_sync_error";
pub const CLAUDE_CLI_SYNC_ERROR_REPORT_KIND: &str = "claude_cli_sync_error";
pub const GEMINI_CLI_SYNC_ERROR_REPORT_KIND: &str = "gemini_cli_sync_error";
@@ -61,8 +57,6 @@ pub fn implicit_sync_finalize_report_kind(plan_kind: &str) -> Option<&'static st
OPENAI_RESPONSES_COMPACT_SYNC_PLAN_KIND => {
Some(OPENAI_RESPONSES_COMPACT_SYNC_FINALIZE_REPORT_KIND)
}
OPENAI_CLI_SYNC_PLAN_KIND => Some(OPENAI_CLI_SYNC_FINALIZE_REPORT_KIND),
OPENAI_COMPACT_SYNC_PLAN_KIND => Some(OPENAI_COMPACT_SYNC_FINALIZE_REPORT_KIND),
OPENAI_IMAGE_SYNC_PLAN_KIND => Some(OPENAI_IMAGE_SYNC_FINALIZE_REPORT_KIND),
CLAUDE_CLI_SYNC_PLAN_KIND => Some(CLAUDE_CLI_SYNC_FINALIZE_REPORT_KIND),
GEMINI_CLI_SYNC_PLAN_KIND => Some(GEMINI_CLI_SYNC_FINALIZE_REPORT_KIND),
@@ -77,8 +71,8 @@ pub fn core_error_default_client_api_format(report_kind: &str) -> Option<&'stati
GEMINI_CHAT_SYNC_FINALIZE_REPORT_KIND => Some("gemini:chat"),
OPENAI_RESPONSES_SYNC_FINALIZE_REPORT_KIND => Some("openai:responses"),
OPENAI_RESPONSES_COMPACT_SYNC_FINALIZE_REPORT_KIND => Some("openai:responses:compact"),
OPENAI_CLI_SYNC_FINALIZE_REPORT_KIND => Some("openai:responses"),
OPENAI_COMPACT_SYNC_FINALIZE_REPORT_KIND => Some("openai:responses:compact"),
LEGACY_OPENAI_CLI_SYNC_FINALIZE_REPORT_KIND => Some("openai:responses"),
LEGACY_OPENAI_COMPACT_SYNC_FINALIZE_REPORT_KIND => Some("openai:responses:compact"),
OPENAI_IMAGE_SYNC_FINALIZE_REPORT_KIND => Some("openai:image"),
CLAUDE_CLI_SYNC_FINALIZE_REPORT_KIND => Some("claude:cli"),
GEMINI_CLI_SYNC_FINALIZE_REPORT_KIND => Some("gemini:cli"),
@@ -95,9 +89,12 @@ pub fn core_error_background_report_kind(report_kind: &str) -> Option<&'static s
OPENAI_RESPONSES_COMPACT_SYNC_FINALIZE_REPORT_KIND => {
Some(OPENAI_RESPONSES_COMPACT_SYNC_ERROR_REPORT_KIND)
}
OPENAI_CLI_SYNC_FINALIZE_REPORT_KIND | OPENAI_COMPACT_SYNC_FINALIZE_REPORT_KIND => {
LEGACY_OPENAI_CLI_SYNC_FINALIZE_REPORT_KIND => {
Some(OPENAI_RESPONSES_SYNC_ERROR_REPORT_KIND)
}
LEGACY_OPENAI_COMPACT_SYNC_FINALIZE_REPORT_KIND => {
Some(OPENAI_RESPONSES_COMPACT_SYNC_ERROR_REPORT_KIND)
}
CLAUDE_CLI_SYNC_FINALIZE_REPORT_KIND => Some(CLAUDE_CLI_SYNC_ERROR_REPORT_KIND),
GEMINI_CLI_SYNC_FINALIZE_REPORT_KIND => Some(GEMINI_CLI_SYNC_ERROR_REPORT_KIND),
_ => None,
@@ -116,8 +113,12 @@ pub fn core_success_background_report_kind(report_kind: &str) -> Option<&'static
OPENAI_RESPONSES_COMPACT_SYNC_FINALIZE_REPORT_KIND => {
Some(OPENAI_RESPONSES_COMPACT_SYNC_SUCCESS_REPORT_KIND)
}
OPENAI_COMPACT_SYNC_FINALIZE_REPORT_KIND => Some(OPENAI_RESPONSES_SYNC_SUCCESS_REPORT_KIND),
OPENAI_CLI_SYNC_FINALIZE_REPORT_KIND => Some(OPENAI_RESPONSES_SYNC_SUCCESS_REPORT_KIND),
LEGACY_OPENAI_CLI_SYNC_FINALIZE_REPORT_KIND => {
Some(OPENAI_RESPONSES_SYNC_SUCCESS_REPORT_KIND)
}
LEGACY_OPENAI_COMPACT_SYNC_FINALIZE_REPORT_KIND => {
Some(OPENAI_RESPONSES_COMPACT_SYNC_SUCCESS_REPORT_KIND)
}
CLAUDE_CLI_SYNC_FINALIZE_REPORT_KIND => Some(CLAUDE_CLI_SYNC_SUCCESS_REPORT_KIND),
GEMINI_CLI_SYNC_FINALIZE_REPORT_KIND => Some(GEMINI_CLI_SYNC_SUCCESS_REPORT_KIND),
_ => None,

View File

@@ -41,7 +41,6 @@ pub enum SyncCliResponseConversionKind {
const NON_COMPACT_STANDARD_CANDIDATE_API_FORMATS: &[&str] = &[
"openai:chat",
"openai:responses",
"openai:cli",
"claude:chat",
"claude:cli",
"gemini:chat",
@@ -98,7 +97,7 @@ pub fn request_candidate_api_formats(
client_api_format.as_str(),
"openai:compact" | "openai:responses:compact"
) {
return vec!["openai:responses:compact", "openai:compact"];
return vec!["openai:responses:compact"];
}
if parse_non_compact_standard_api_format(client_api_format.as_str()).is_none() {
return Vec::new();
@@ -490,7 +489,7 @@ mod tests {
const STANDARD_SURFACES: &[&str] = &[
"openai:chat",
"openai:cli",
"openai:responses",
"claude:chat",
"claude:cli",
"gemini:chat",
@@ -500,7 +499,7 @@ mod tests {
fn expected_request_conversion_kind(provider_api_format: &str) -> RequestConversionKind {
match provider_api_format {
"openai:chat" => RequestConversionKind::ToOpenAIChat,
"openai:cli" => RequestConversionKind::ToOpenAiResponses,
"openai:responses" => RequestConversionKind::ToOpenAiResponses,
"claude:chat" | "claude:cli" => RequestConversionKind::ToClaudeStandard,
"gemini:chat" | "gemini:cli" => RequestConversionKind::ToGeminiStandard,
other => panic!("unexpected provider api format: {other}"),
@@ -510,7 +509,7 @@ mod tests {
#[test]
fn request_conversion_registry_supports_bidirectional_standard_matrix() {
assert_eq!(
request_conversion_kind("openai:chat", "openai:cli"),
request_conversion_kind("openai:chat", "openai:responses"),
Some(RequestConversionKind::ToOpenAiResponses)
);
assert_eq!(
@@ -518,23 +517,19 @@ mod tests {
Some(RequestConversionKind::ToClaudeStandard)
);
assert_eq!(
request_conversion_kind("openai:cli", "openai:chat"),
request_conversion_kind("openai:responses", "openai:chat"),
Some(RequestConversionKind::ToOpenAIChat)
);
assert_eq!(
request_conversion_kind("gemini:chat", "claude:chat"),
Some(RequestConversionKind::ToClaudeStandard)
);
assert_eq!(
request_conversion_kind("openai:compact", "gemini:cli"),
request_conversion_kind("openai:responses:compact", "gemini:cli"),
None
);
assert_eq!(
request_conversion_kind("gemini:cli", "openai:compact"),
request_conversion_kind("gemini:cli", "openai:responses:compact"),
None
);
assert_eq!(
request_conversion_kind("openai:chat", "openai:compact"),
request_conversion_kind("openai:chat", "openai:responses:compact"),
None
);
assert_eq!(
@@ -545,6 +540,10 @@ mod tests {
request_conversion_kind("openai:compact", "openai:responses:compact"),
None
);
assert_eq!(
request_conversion_kind("gemini:chat", "claude:chat"),
Some(RequestConversionKind::ToClaudeStandard)
);
assert_eq!(
request_conversion_kind("claude:chat", "claude:cli"),
Some(RequestConversionKind::ToClaudeStandard)
@@ -588,19 +587,19 @@ mod tests {
Some(SyncChatResponseConversionKind::ToOpenAIChat)
);
assert_eq!(
sync_cli_response_conversion_kind("openai:cli", "gemini:cli"),
sync_cli_response_conversion_kind("openai:responses", "gemini:cli"),
Some(SyncCliResponseConversionKind::ToGeminiCli)
);
assert_eq!(
sync_cli_response_conversion_kind("claude:chat", "openai:cli"),
sync_cli_response_conversion_kind("claude:chat", "openai:responses"),
Some(SyncCliResponseConversionKind::ToOpenAiResponses)
);
assert_eq!(
sync_cli_response_conversion_kind("claude:cli", "openai:compact"),
sync_cli_response_conversion_kind("claude:cli", "openai:responses:compact"),
Some(SyncCliResponseConversionKind::ToOpenAiResponses)
);
assert_eq!(
sync_cli_response_conversion_kind("openai:compact", "claude:cli"),
sync_cli_response_conversion_kind("openai:responses:compact", "claude:cli"),
None
);
assert_eq!(
@@ -643,7 +642,7 @@ mod tests {
}
}
for client_api_format in ["openai:cli", "claude:cli", "gemini:cli"] {
for client_api_format in ["openai:responses", "claude:cli", "gemini:cli"] {
let actual =
sync_cli_response_conversion_kind(provider_api_format, client_api_format);
if *provider_api_format == client_api_format {
@@ -653,7 +652,7 @@ mod tests {
);
} else {
let expected = match client_api_format {
"openai:cli" => SyncCliResponseConversionKind::ToOpenAiResponses,
"openai:responses" => SyncCliResponseConversionKind::ToOpenAiResponses,
"claude:cli" => SyncCliResponseConversionKind::ToClaudeCli,
"gemini:cli" => SyncCliResponseConversionKind::ToGeminiCli,
other => panic!("unexpected cli client api format: {other}"),
@@ -677,16 +676,14 @@ mod tests {
"claude:chat",
"gemini:chat",
"openai:responses",
"openai:cli",
"claude:cli",
"gemini:cli",
]
);
assert_eq!(
request_candidate_api_formats("openai:cli", false),
request_candidate_api_formats("openai:responses", false),
vec![
"openai:responses",
"openai:cli",
"claude:cli",
"gemini:cli",
"openai:chat",
@@ -695,10 +692,9 @@ mod tests {
]
);
assert_eq!(
request_candidate_api_formats("openai:responses", false),
request_candidate_api_formats("openai:cli", false),
vec![
"openai:responses",
"openai:cli",
"claude:cli",
"gemini:cli",
"openai:chat",
@@ -711,7 +707,6 @@ mod tests {
vec![
"claude:cli",
"openai:responses",
"openai:cli",
"gemini:cli",
"claude:chat",
"openai:chat",
@@ -720,14 +715,14 @@ mod tests {
);
assert_eq!(
request_candidate_api_formats("openai:compact", false),
vec!["openai:responses:compact", "openai:compact"]
vec!["openai:responses:compact"]
);
}
#[test]
fn request_candidate_registry_prefers_same_kind_before_same_family_fallbacks() {
assert_eq!(
request_candidate_api_format_preference("claude:cli", "openai:cli"),
request_candidate_api_format_preference("claude:cli", "openai:responses"),
Some((1, 0))
);
assert_eq!(
@@ -748,10 +743,10 @@ mod tests {
));
assert!(request_conversion_requires_enable_flag(
"openai:chat",
"openai:cli"
"openai:responses"
));
assert!(request_conversion_requires_enable_flag(
"openai:cli",
"openai:responses",
"openai:chat"
));
assert!(request_conversion_requires_enable_flag(

View File

@@ -3226,7 +3226,7 @@ mod tests {
});
let body_json = maybe_build_openai_responses_same_family_sync_body_from_normalized_payload(
"openai_compact_sync_finalize",
"openai_responses_compact_sync_finalize",
200,
Some(&report_context),
None,
@@ -3385,7 +3385,7 @@ mod tests {
});
let body_json = maybe_build_openai_responses_same_family_sync_body_from_normalized_payload(
"openai_compact_sync_finalize",
"openai_responses_compact_sync_finalize",
200,
Some(&report_context),
None,
@@ -3412,7 +3412,7 @@ mod tests {
});
let body_json = maybe_build_openai_responses_same_family_sync_body_from_normalized_payload(
"openai_compact_sync_finalize",
"openai_responses_compact_sync_finalize",
200,
Some(&report_context),
Some(&provider_body_json),
@@ -4006,7 +4006,7 @@ mod tests {
let product =
maybe_build_openai_responses_cross_format_sync_product_from_normalized_payload(
"openai_compact_sync_finalize",
"openai_responses_compact_sync_finalize",
200,
Some(&report_context),
Some(&provider_body_json),
@@ -4109,7 +4109,7 @@ mod tests {
});
let product = maybe_build_standard_sync_finalize_product_from_normalized_payload(
"openai_compact_sync_finalize",
"openai_responses_compact_sync_finalize",
200,
Some(&report_context),
Some(&provider_body_json),

View File

@@ -7,8 +7,7 @@ use crate::contracts::{
GEMINI_FILES_DOWNLOAD_PLAN_KIND, GEMINI_FILES_GET_PLAN_KIND, GEMINI_FILES_LIST_PLAN_KIND,
GEMINI_FILES_UPLOAD_PLAN_KIND, GEMINI_VIDEO_CANCEL_SYNC_PLAN_KIND,
GEMINI_VIDEO_CREATE_SYNC_PLAN_KIND, OPENAI_CHAT_STREAM_PLAN_KIND, OPENAI_CHAT_SYNC_PLAN_KIND,
OPENAI_CLI_STREAM_PLAN_KIND, OPENAI_CLI_SYNC_PLAN_KIND, OPENAI_COMPACT_STREAM_PLAN_KIND,
OPENAI_COMPACT_SYNC_PLAN_KIND, OPENAI_IMAGE_STREAM_PLAN_KIND, OPENAI_IMAGE_SYNC_PLAN_KIND,
OPENAI_IMAGE_STREAM_PLAN_KIND, OPENAI_IMAGE_SYNC_PLAN_KIND,
OPENAI_RESPONSES_COMPACT_STREAM_PLAN_KIND, OPENAI_RESPONSES_COMPACT_SYNC_PLAN_KIND,
OPENAI_RESPONSES_STREAM_PLAN_KIND, OPENAI_RESPONSES_SYNC_PLAN_KIND,
OPENAI_VIDEO_CANCEL_SYNC_PLAN_KIND, OPENAI_VIDEO_CONTENT_PLAN_KIND,
@@ -280,8 +279,6 @@ pub fn is_matching_stream_request(
| CLAUDE_CHAT_STREAM_PLAN_KIND
| OPENAI_RESPONSES_STREAM_PLAN_KIND
| OPENAI_RESPONSES_COMPACT_STREAM_PLAN_KIND
| OPENAI_CLI_STREAM_PLAN_KIND
| OPENAI_COMPACT_STREAM_PLAN_KIND
| CLAUDE_CLI_STREAM_PLAN_KIND
| OPENAI_IMAGE_STREAM_PLAN_KIND => body_json
.get("stream")
@@ -301,8 +298,6 @@ pub fn supports_sync_scheduler_decision_kind(plan_kind: &str) -> bool {
| OPENAI_IMAGE_SYNC_PLAN_KIND
| OPENAI_RESPONSES_SYNC_PLAN_KIND
| OPENAI_RESPONSES_COMPACT_SYNC_PLAN_KIND
| OPENAI_CLI_SYNC_PLAN_KIND
| OPENAI_COMPACT_SYNC_PLAN_KIND
| CLAUDE_CHAT_SYNC_PLAN_KIND
| CLAUDE_CLI_SYNC_PLAN_KIND
| GEMINI_CHAT_SYNC_PLAN_KIND
@@ -328,9 +323,7 @@ pub fn supports_stream_scheduler_decision_kind(plan_kind: &str) -> bool {
| GEMINI_CHAT_STREAM_PLAN_KIND
| OPENAI_RESPONSES_STREAM_PLAN_KIND
| OPENAI_RESPONSES_COMPACT_STREAM_PLAN_KIND
| OPENAI_CLI_STREAM_PLAN_KIND
| OPENAI_IMAGE_STREAM_PLAN_KIND
| OPENAI_COMPACT_STREAM_PLAN_KIND
| CLAUDE_CLI_STREAM_PLAN_KIND
| GEMINI_CLI_STREAM_PLAN_KIND
| GEMINI_FILES_DOWNLOAD_PLAN_KIND

View File

@@ -37,7 +37,7 @@ fn is_codex_openai_responses_request(provider_type: &str, provider_api_format: &
)
}
fn is_openai_compact_request(provider_api_format: &str) -> bool {
fn is_openai_responses_compact_request(provider_api_format: &str) -> bool {
matches!(
provider_api_format.trim().to_ascii_lowercase().as_str(),
"openai:responses:compact" | "openai:compact"
@@ -282,7 +282,7 @@ pub fn apply_openai_responses_compact_special_body_edits(
provider_request_body: &mut Value,
provider_api_format: &str,
) {
if !is_openai_compact_request(provider_api_format) {
if !is_openai_responses_compact_request(provider_api_format) {
return;
}
@@ -294,17 +294,6 @@ pub fn apply_openai_responses_compact_special_body_edits(
body_object.remove("store");
}
#[deprecated(
since = "0.1.0",
note = "use apply_openai_responses_compact_special_body_edits"
)]
pub fn apply_openai_compact_special_body_edits(
provider_request_body: &mut Value,
provider_api_format: &str,
) {
apply_openai_responses_compact_special_body_edits(provider_request_body, provider_api_format);
}
pub fn apply_codex_openai_responses_special_body_edits(
provider_request_body: &mut Value,
provider_type: &str,
@@ -332,7 +321,7 @@ pub fn apply_codex_openai_responses_special_body_edits(
if !body_rules_handle_path(body_rules, "metadata") {
body_object.remove("metadata");
}
if is_openai_compact_request(provider_api_format) {
if is_openai_responses_compact_request(provider_api_format) {
body_object.remove("store");
} else if !body_rules_handle_path(body_rules, "store") {
body_object.insert("store".to_string(), json!(false));
@@ -363,26 +352,6 @@ pub fn apply_codex_openai_responses_special_body_edits(
);
}
#[deprecated(
since = "0.1.0",
note = "use apply_codex_openai_responses_special_body_edits"
)]
pub fn apply_codex_openai_cli_special_body_edits(
provider_request_body: &mut Value,
provider_type: &str,
provider_api_format: &str,
body_rules: Option<&Value>,
user_api_key_id: Option<&str>,
) {
apply_codex_openai_responses_special_body_edits(
provider_request_body,
provider_type,
provider_api_format,
body_rules,
user_api_key_id,
);
}
pub fn apply_codex_openai_responses_special_headers(
provider_request_headers: &mut BTreeMap<String, String>,
provider_request_body: &Value,
@@ -457,30 +426,6 @@ pub fn apply_codex_openai_responses_special_headers(
}
}
#[deprecated(
since = "0.1.0",
note = "use apply_codex_openai_responses_special_headers"
)]
pub fn apply_codex_openai_cli_special_headers(
provider_request_headers: &mut BTreeMap<String, String>,
provider_request_body: &Value,
original_headers: &http::HeaderMap,
provider_type: &str,
provider_api_format: &str,
request_id: Option<&str>,
decrypted_auth_config_raw: Option<&str>,
) {
apply_codex_openai_responses_special_headers(
provider_request_headers,
provider_request_body,
original_headers,
provider_type,
provider_api_format,
request_id,
decrypted_auth_config_raw,
);
}
#[cfg(test)]
mod tests {
use super::{

View File

@@ -165,7 +165,7 @@ mod tests {
const STANDARD_SURFACES: &[&str] = &[
"openai:chat",
"openai:cli",
"openai:responses",
"claude:chat",
"claude:cli",
"gemini:chat",
@@ -185,7 +185,7 @@ mod tests {
}),
"/v1/chat/completions",
),
"openai:cli" => (
"openai:responses" => (
json!({
"model": "source-model",
"instructions": "Be concise.",
@@ -227,7 +227,7 @@ mod tests {
fn assert_stream_flag(provider_api_format: &str, upstream_is_stream: bool, converted: &Value) {
match provider_api_format {
"openai:chat" | "openai:cli" | "claude:chat" | "claude:cli" => {
"openai:chat" | "openai:responses" | "claude:chat" | "claude:cli" => {
assert_eq!(
converted
.get("stream")
@@ -262,24 +262,24 @@ mod tests {
])
}
fn legacy_openai_responses_alias_request_body(
fn legacy_openai_responses_request_body(
request: &Value,
provider_api_format: &str,
upstream_is_stream: bool,
) -> Value {
let chat_canonical = normalize_standard_request_to_openai_chat_request(
request,
"openai:cli",
"openai:responses",
"/v1/responses",
)
.expect("legacy openai responses alias normalization should succeed");
.expect("legacy openai responses normalization should succeed");
build_standard_request_body_from_canonical(
&chat_canonical,
"mapped-model",
provider_api_format,
upstream_is_stream,
)
.expect("legacy openai responses alias target conversion should succeed")
.expect("legacy openai responses target conversion should succeed")
}
fn legacy_openai_chat_request_body(
@@ -430,7 +430,7 @@ mod tests {
for upstream_is_stream in [false, true] {
let converted = build_standard_request_body(
&request,
"openai:cli",
"openai:responses",
"mapped-model",
"custom",
provider_api_format,
@@ -440,14 +440,14 @@ mod tests {
None,
)
.expect("typed canonical route should build");
let legacy = legacy_openai_responses_alias_request_body(
let legacy = legacy_openai_responses_request_body(
&request,
provider_api_format,
upstream_is_stream,
);
assert_eq!(
converted, legacy,
"typed canonical openai:cli -> {provider_api_format} changed payload with upstream_is_stream={upstream_is_stream}"
"typed canonical openai:responses -> {provider_api_format} changed payload with upstream_is_stream={upstream_is_stream}"
);
}
}
@@ -609,8 +609,8 @@ mod tests {
for provider_api_format in [
"openai:chat",
"openai:cli",
"openai:compact",
"openai:responses",
"openai:responses:compact",
"gemini:chat",
"gemini:cli",
] {
@@ -691,8 +691,8 @@ mod tests {
for provider_api_format in [
"openai:chat",
"openai:cli",
"openai:compact",
"openai:responses",
"openai:responses:compact",
"claude:chat",
"claude:cli",
] {
@@ -735,14 +735,14 @@ mod tests {
client_api_format,
"gpt-5.5",
"codex",
"openai:cli",
"openai:responses",
request_path,
true,
Some(&body_rules),
Some("key-1"),
)
.unwrap_or_else(|| {
panic!("{client_api_format} -> openai:cli should build with codex body rules")
panic!("{client_api_format} -> openai:responses should build with codex body rules")
});
assert_eq!(converted["model"], "gpt-5.5");
@@ -753,7 +753,7 @@ mod tests {
assert!(converted.get("top_p").is_none());
assert!(
converted.get("instructions").is_some(),
"{client_api_format} -> openai:cli should keep or inject instructions"
"{client_api_format} -> openai:responses should keep or inject instructions"
);
}
}
@@ -932,7 +932,7 @@ mod tests {
let converted = build_standard_request_body(
&request,
"openai:cli",
"openai:responses",
"gpt-5",
"openai",
"openai:chat",

View File

@@ -6,12 +6,6 @@ pub mod matrix;
pub mod normalize;
pub mod openai_responses;
#[allow(deprecated)]
pub use codex::apply_openai_compact_special_body_edits;
#[allow(deprecated)]
pub use codex::{
apply_codex_openai_cli_special_body_edits, apply_codex_openai_cli_special_headers,
};
pub use codex::{
apply_codex_openai_responses_special_body_edits, apply_codex_openai_responses_special_headers,
apply_openai_responses_compact_special_body_edits, CODEX_OPENAI_IMAGE_DEFAULT_MODEL,

View File

@@ -1,10 +1,8 @@
use crate::contracts::{
OPENAI_CLI_STREAM_PLAN_KIND, OPENAI_CLI_SYNC_PLAN_KIND, OPENAI_COMPACT_STREAM_PLAN_KIND,
OPENAI_COMPACT_SYNC_PLAN_KIND, OPENAI_RESPONSES_COMPACT_STREAM_PLAN_KIND,
OPENAI_RESPONSES_COMPACT_STREAM_SUCCESS_REPORT_KIND, OPENAI_RESPONSES_COMPACT_SYNC_PLAN_KIND,
OPENAI_RESPONSES_COMPACT_SYNC_SUCCESS_REPORT_KIND, OPENAI_RESPONSES_STREAM_PLAN_KIND,
OPENAI_RESPONSES_STREAM_SUCCESS_REPORT_KIND, OPENAI_RESPONSES_SYNC_PLAN_KIND,
OPENAI_RESPONSES_SYNC_SUCCESS_REPORT_KIND,
OPENAI_RESPONSES_COMPACT_STREAM_PLAN_KIND, OPENAI_RESPONSES_COMPACT_STREAM_SUCCESS_REPORT_KIND,
OPENAI_RESPONSES_COMPACT_SYNC_PLAN_KIND, OPENAI_RESPONSES_COMPACT_SYNC_SUCCESS_REPORT_KIND,
OPENAI_RESPONSES_STREAM_PLAN_KIND, OPENAI_RESPONSES_STREAM_SUCCESS_REPORT_KIND,
OPENAI_RESPONSES_SYNC_PLAN_KIND, OPENAI_RESPONSES_SYNC_SUCCESS_REPORT_KIND,
};
#[derive(Debug, Clone, Copy)]
@@ -32,20 +30,6 @@ pub fn resolve_sync_spec(plan_kind: &str) -> Option<LocalOpenAiResponsesSpec> {
compact: true,
require_streaming: false,
}),
OPENAI_CLI_SYNC_PLAN_KIND => Some(LocalOpenAiResponsesSpec {
api_format: "openai:responses",
decision_kind: OPENAI_CLI_SYNC_PLAN_KIND,
report_kind: "openai_cli_sync_success",
compact: false,
require_streaming: false,
}),
OPENAI_COMPACT_SYNC_PLAN_KIND => Some(LocalOpenAiResponsesSpec {
api_format: "openai:responses:compact",
decision_kind: OPENAI_COMPACT_SYNC_PLAN_KIND,
report_kind: OPENAI_RESPONSES_SYNC_SUCCESS_REPORT_KIND,
compact: true,
require_streaming: false,
}),
_ => None,
}
}
@@ -66,20 +50,6 @@ pub fn resolve_stream_spec(plan_kind: &str) -> Option<LocalOpenAiResponsesSpec>
compact: true,
require_streaming: true,
}),
OPENAI_CLI_STREAM_PLAN_KIND => Some(LocalOpenAiResponsesSpec {
api_format: "openai:responses",
decision_kind: OPENAI_CLI_STREAM_PLAN_KIND,
report_kind: "openai_cli_stream_success",
compact: false,
require_streaming: true,
}),
OPENAI_COMPACT_STREAM_PLAN_KIND => Some(LocalOpenAiResponsesSpec {
api_format: "openai:responses:compact",
decision_kind: OPENAI_COMPACT_STREAM_PLAN_KIND,
report_kind: OPENAI_RESPONSES_STREAM_SUCCESS_REPORT_KIND,
compact: true,
require_streaming: true,
}),
_ => None,
}
}
@@ -98,29 +68,11 @@ mod tests {
}
#[test]
fn resolves_legacy_openai_cli_sync_spec() {
let spec = resolve_sync_spec("openai_cli_sync").expect("spec");
assert_eq!(spec.api_format, "openai:responses");
assert_eq!(spec.report_kind, "openai_cli_sync_success");
assert!(!spec.compact);
assert!(!spec.require_streaming);
}
#[test]
fn resolves_openai_compact_stream_spec() {
fn resolves_openai_responses_compact_stream_spec() {
let spec = resolve_stream_spec("openai_responses_compact_stream").expect("spec");
assert_eq!(spec.api_format, "openai:responses:compact");
assert_eq!(spec.report_kind, "openai_responses_compact_stream_success");
assert!(spec.compact);
assert!(spec.require_streaming);
}
#[test]
fn resolves_legacy_openai_compact_stream_spec() {
let spec = resolve_stream_spec("openai_compact_stream").expect("spec");
assert_eq!(spec.api_format, "openai:responses:compact");
assert_eq!(spec.report_kind, "openai_responses_stream_success");
assert!(spec.compact);
assert!(spec.require_streaming);
}
}

View File

@@ -2851,7 +2851,7 @@ mod tests {
});
let payload = GatewayStreamReportRequest {
trace_id: "trace-stream-provider-chunks-usage-1".to_string(),
report_kind: "openai_cli_stream_success".to_string(),
report_kind: "openai_responses_stream_success".to_string(),
report_context: Some(json!({
"client_api_format": "openai:responses",
"provider_api_format": "openai:responses",
@@ -2917,14 +2917,14 @@ mod tests {
"event: response.created\n",
"data: {\"type\":\"response.created\",\"response\":{\"id\":\"resp_123\",\"object\":\"response\",\"model\":\"gpt-5.4\",\"status\":\"in_progress\"}}\n\n",
"event: response.output_text.delta\n",
"data: {\"type\":\"response.output_text.delta\",\"delta\":\"Hello from CLI stream\"}\n\n",
"data: {\"type\":\"response.output_text.delta\",\"delta\":\"Hello from Responses stream\"}\n\n",
"event: response.completed\n",
"data: {\"type\":\"response.completed\",\"response\":{\"id\":\"resp_123\",\"object\":\"response\",\"model\":\"gpt-5.4\",\"status\":\"completed\",\"output\":[{\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"Hello from CLI stream\"}]}],\"usage\":{\"input_tokens\":3,\"input_tokens_details\":{\"cached_tokens\":2,\"cached_creation_tokens\":1},\"output_tokens\":5,\"output_tokens_details\":{\"reasoning_tokens\":1},\"total_tokens\":8}}}\n\n",
"data: {\"type\":\"response.completed\",\"response\":{\"id\":\"resp_123\",\"object\":\"response\",\"model\":\"gpt-5.4\",\"status\":\"completed\",\"output\":[{\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"Hello from Responses stream\"}]}],\"usage\":{\"input_tokens\":3,\"input_tokens_details\":{\"cached_tokens\":2,\"cached_creation_tokens\":1},\"output_tokens\":5,\"output_tokens_details\":{\"reasoning_tokens\":1},\"total_tokens\":8}}}\n\n",
"data: [DONE]\n",
);
let payload = GatewayStreamReportRequest {
trace_id: "trace-stream-usage-2".to_string(),
report_kind: "openai_cli_stream_success".to_string(),
report_kind: "openai_responses_stream_success".to_string(),
report_context: Some(json!({
"client_api_format": "openai:responses",
"provider_api_format": "openai:responses",
@@ -2963,7 +2963,7 @@ mod tests {
},
{
"type": "response.output_text.delta",
"delta": "Hello from CLI stream"
"delta": "Hello from Responses stream"
},
{
"type": "response.completed",
@@ -2979,7 +2979,7 @@ mod tests {
"content": [
{
"type": "output_text",
"text": "Hello from CLI stream"
"text": "Hello from Responses stream"
}
]
}
@@ -3146,7 +3146,7 @@ mod tests {
};
let payload = GatewaySyncReportRequest {
trace_id: "trace-sync-upstream-stream-1".to_string(),
report_kind: "openai_cli_sync_success".to_string(),
report_kind: "openai_responses_sync_success".to_string(),
report_context: Some(json!({
"client_api_format": "openai:responses",
"provider_api_format": "openai:responses",
@@ -3326,7 +3326,7 @@ mod tests {
};
let payload = GatewaySyncReportRequest {
trace_id: "trace-sync-body-ref-1".to_string(),
report_kind: "openai_cli_sync_success".to_string(),
report_kind: "openai_responses_sync_success".to_string(),
report_context: Some(json!({
"client_api_format": "openai:responses",
"provider_api_format": "openai:responses",
@@ -3475,7 +3475,7 @@ mod tests {
};
let payload = GatewayStreamReportRequest {
trace_id: "trace-stream-usage-large-1".to_string(),
report_kind: "openai_cli_stream_success".to_string(),
report_kind: "openai_responses_stream_success".to_string(),
report_context: Some(json!({
"client_api_format": "openai:responses",
"provider_api_format": "openai:responses",