refactor: fold ai surfaces into formats

This commit is contained in:
fawney19
2026-05-02 18:19:39 +08:00
parent bfd1ea72b3
commit 47ee8b9c13
114 changed files with 600 additions and 622 deletions

View File

@@ -28,7 +28,7 @@ pub(crate) use crate::ai_serving::{
pub(crate) use crate::ai_serving::{
AiExecutionDecision, AiExecutionPlanPayload, AiStreamAttempt, AiSyncAttempt,
};
pub(crate) use aether_ai_surfaces::api::{
pub(crate) use aether_ai_formats::api::{
build_core_error_body_for_client_format, core_error_background_report_kind,
core_error_default_client_api_format, core_success_background_report_kind,
encode_kiro_sse_events, implicit_sync_finalize_report_kind, is_core_error_finalize_kind,
@@ -37,7 +37,7 @@ pub(crate) use aether_ai_surfaces::api::{
resolve_claude_sync_spec, resolve_gemini_stream_spec, resolve_gemini_sync_spec,
resolve_local_image_stream_spec, resolve_local_image_sync_spec,
resolve_local_same_format_stream_spec, resolve_local_same_format_sync_spec,
ExecutionRuntimeAuthContext, GatewayControlPlanRequest, LocalCoreSyncErrorKind,
AiControlPlanRequest, ExecutionRuntimeAuthContext, LocalCoreSyncErrorKind,
LocalOpenAiImageSpec, LocalSameFormatProviderFamily, LocalSameFormatProviderSpec,
LocalStandardSourceFamily, LocalStandardSourceMode, LocalStandardSpec,
StreamingStandardTerminalObserver, EXECUTION_RUNTIME_STREAM_DECISION_ACTION,
@@ -52,7 +52,7 @@ pub(crate) fn parse_direct_request_body(
parts: &http::request::Parts,
body_bytes: &axum::body::Bytes,
) -> Option<(serde_json::Value, Option<String>)> {
aether_ai_surfaces::api::parse_direct_request_body(
aether_ai_formats::api::parse_direct_request_body(
is_json_request(&parts.headers),
body_bytes.as_ref(),
)
@@ -62,7 +62,7 @@ pub(crate) fn resolve_execution_runtime_stream_plan_kind(
parts: &http::request::Parts,
decision: &GatewayControlDecision,
) -> Option<&'static str> {
aether_ai_surfaces::api::resolve_execution_runtime_stream_plan_kind(
aether_ai_formats::api::resolve_execution_runtime_stream_plan_kind(
decision.route_class.as_deref(),
decision.route_family.as_deref(),
decision.route_kind.as_deref(),
@@ -75,7 +75,7 @@ pub(crate) fn resolve_execution_runtime_sync_plan_kind(
parts: &http::request::Parts,
decision: &GatewayControlDecision,
) -> Option<&'static str> {
aether_ai_surfaces::api::resolve_execution_runtime_sync_plan_kind(
aether_ai_formats::api::resolve_execution_runtime_sync_plan_kind(
decision.route_class.as_deref(),
decision.route_family.as_deref(),
decision.route_kind.as_deref(),
@@ -93,28 +93,28 @@ pub(crate) fn is_matching_stream_request(
crate::ai_serving::planner_is_matching_stream_request(plan_kind, parts, body_json, body_base64)
}
pub(crate) fn supports_sync_scheduler_decision_kind(plan_kind: &str) -> bool {
aether_ai_surfaces::api::supports_sync_scheduler_decision_kind(plan_kind)
pub(crate) fn supports_sync_execution_decision_kind(plan_kind: &str) -> bool {
aether_ai_formats::api::supports_sync_execution_decision_kind(plan_kind)
}
pub(crate) fn supports_stream_scheduler_decision_kind(plan_kind: &str) -> bool {
aether_ai_surfaces::api::supports_stream_scheduler_decision_kind(plan_kind)
pub(crate) fn supports_stream_execution_decision_kind(plan_kind: &str) -> bool {
aether_ai_formats::api::supports_stream_execution_decision_kind(plan_kind)
}
pub(crate) fn aggregate_openai_chat_stream_sync_response(body: &[u8]) -> Option<serde_json::Value> {
aether_ai_surfaces::api::aggregate_openai_chat_stream_sync_response(body)
aether_ai_formats::api::aggregate_openai_chat_stream_sync_response(body)
}
pub(crate) fn aggregate_openai_responses_stream_sync_response(
body: &[u8],
) -> Option<serde_json::Value> {
aether_ai_surfaces::api::aggregate_openai_responses_stream_sync_response(body)
aether_ai_formats::api::aggregate_openai_responses_stream_sync_response(body)
}
pub(crate) fn aggregate_claude_stream_sync_response(body: &[u8]) -> Option<serde_json::Value> {
aether_ai_surfaces::api::aggregate_claude_stream_sync_response(body)
aether_ai_formats::api::aggregate_claude_stream_sync_response(body)
}
pub(crate) fn aggregate_gemini_stream_sync_response(body: &[u8]) -> Option<serde_json::Value> {
aether_ai_surfaces::api::aggregate_gemini_stream_sync_response(body)
aether_ai_formats::api::aggregate_gemini_stream_sync_response(body)
}

View File

@@ -3,8 +3,8 @@ use crate::ai_serving::{
is_matching_stream_http_request as is_matching_stream_http_request_impl,
resolve_execution_runtime_stream_plan_kind as resolve_execution_runtime_stream_plan_kind_impl,
resolve_execution_runtime_sync_plan_kind as resolve_execution_runtime_sync_plan_kind_impl,
supports_stream_scheduler_decision_kind as supports_stream_scheduler_decision_kind_impl,
supports_sync_scheduler_decision_kind as supports_sync_scheduler_decision_kind_impl,
supports_stream_execution_decision_kind as supports_stream_execution_decision_kind_impl,
supports_sync_execution_decision_kind as supports_sync_execution_decision_kind_impl,
};
pub(crate) fn resolve_execution_runtime_stream_plan_kind(
@@ -42,12 +42,12 @@ pub(crate) fn is_matching_stream_request(
is_matching_stream_http_request_impl(plan_kind, parts, body_json, body_base64)
}
pub(crate) fn supports_sync_scheduler_decision_kind(plan_kind: &str) -> bool {
supports_sync_scheduler_decision_kind_impl(plan_kind)
pub(crate) fn supports_sync_execution_decision_kind(plan_kind: &str) -> bool {
supports_sync_execution_decision_kind_impl(plan_kind)
}
pub(crate) fn supports_stream_scheduler_decision_kind(plan_kind: &str) -> bool {
supports_stream_scheduler_decision_kind_impl(plan_kind)
pub(crate) fn supports_stream_execution_decision_kind(plan_kind: &str) -> bool {
supports_stream_execution_decision_kind_impl(plan_kind)
}
#[cfg(test)]
@@ -57,8 +57,8 @@ mod tests {
use super::{
is_matching_stream_request, resolve_execution_runtime_stream_plan_kind,
resolve_execution_runtime_sync_plan_kind, supports_stream_scheduler_decision_kind,
supports_sync_scheduler_decision_kind,
resolve_execution_runtime_sync_plan_kind, supports_stream_execution_decision_kind,
supports_sync_execution_decision_kind,
};
use crate::ai_serving::GatewayControlDecision;
@@ -78,7 +78,7 @@ mod tests {
}
#[test]
fn resolves_openai_chat_plan_kinds_via_surface_crate() {
fn resolves_openai_chat_plan_kinds_via_format_crate() {
let request = Request::builder()
.method(Method::POST)
.uri("/v1/chat/completions")
@@ -118,8 +118,8 @@ mod tests {
&serde_json::json!({"stream": true}),
None,
));
assert!(supports_sync_scheduler_decision_kind("openai_chat_sync"));
assert!(supports_stream_scheduler_decision_kind(
assert!(supports_sync_execution_decision_kind("openai_chat_sync"));
assert!(supports_stream_execution_decision_kind(
"openai_chat_stream"
));
}

View File

@@ -1,4 +1,4 @@
pub(crate) use aether_ai_surfaces::api::{
pub(crate) use aether_ai_formats::api::{
aggregate_claude_stream_sync_response, aggregate_gemini_stream_sync_response,
aggregate_openai_chat_stream_sync_response, aggregate_openai_responses_stream_sync_response,
aggregate_standard_chat_stream_sync_response, aggregate_standard_cli_stream_sync_response,
@@ -62,11 +62,11 @@ pub(crate) use aether_ai_surfaces::api::{
resolve_local_video_sync_spec, resolve_openai_chat_max_tokens,
resolve_openai_responses_stream_spec, resolve_openai_responses_sync_spec,
resolve_requested_openai_image_model_for_request, stream_body_contains_error_event,
supports_stream_scheduler_decision_kind, supports_sync_scheduler_decision_kind,
supports_stream_execution_decision_kind, supports_sync_execution_decision_kind,
sync_chat_response_conversion_kind, sync_cli_response_conversion_kind,
transform_provider_private_stream_line, value_as_u64, AiSurfaceFinalizeError,
AiSurfaceStreamRewriter, CanonicalStreamFrame, ClaudeClientEmitter, ClaudeProviderState,
ExecutionRuntimeAuthContext, FinalizeStreamRewriteMode, GatewayControlPlanRequest,
transform_provider_private_stream_line, value_as_u64, AiControlPlanRequest,
AiSurfaceFinalizeError, AiSurfaceStreamRewriter, CanonicalStreamFrame, ClaudeClientEmitter,
ClaudeProviderState, ExecutionRuntimeAuthContext, FinalizeStreamRewriteMode,
GeminiClientEmitter, GeminiProviderState, KiroToClaudeCliStreamState, LocalCoreSyncErrorKind,
LocalGeminiFilesSpec, LocalOpenAiImageSpec, LocalOpenAiResponsesSpec,
LocalSameFormatProviderFamily, LocalSameFormatProviderSpec, LocalStandardSourceFamily,