mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 17:30:23 +08:00
refactor: 大规模模块拆分与代码精简,新增 ai-pipeline/data-contracts 独立 crate
- 新增 aether-ai-pipeline 和 aether-data-contracts crate,将 pipeline 逻辑与数据契约从 gateway 中解耦 - 重构 admin handlers:拆分单体模块为 auth/billing/endpoint/features/model/observability/provider/system 等独立子模块 - 合并 chat/cli 重复代码路径:精简 conversion、finalize、planner 中的 sync/chat/cli 分支 - 重构 scheduler/executor/data 层,引入 facade 模式降低模块间耦合 - 移除冗余的 intent 模块,将 plan_fallback/policy/stream_path/sync_path 迁移至 executor - 前端适配:调整 admin API 调用和 provider 模型测试对话框
This commit is contained in:
@@ -10,24 +10,18 @@ use super::{
|
||||
};
|
||||
use crate::ai_pipeline::finalize::maybe_build_sync_finalize_outcome;
|
||||
use crate::ai_pipeline::planner as ai_planner;
|
||||
use crate::ai_pipeline::planner::{
|
||||
maybe_build_stream_plan_payload, maybe_build_sync_plan_payload,
|
||||
};
|
||||
use crate::ai_pipeline::planner::{maybe_build_stream_plan_payload, maybe_build_sync_plan_payload};
|
||||
use crate::constants::{
|
||||
CONTROL_EXECUTED_HEADER, EXECUTION_PATH_EXECUTION_RUNTIME_STREAM,
|
||||
EXECUTION_PATH_EXECUTION_RUNTIME_SYNC,
|
||||
};
|
||||
use crate::control::GatewayControlDecision;
|
||||
use crate::control::GatewayPublicRequestContext;
|
||||
use crate::execution_runtime::{
|
||||
execute_execution_runtime_stream, execute_execution_runtime_sync,
|
||||
};
|
||||
use crate::handlers::{
|
||||
use crate::execution_runtime::{execute_execution_runtime_stream, execute_execution_runtime_sync};
|
||||
use crate::handlers::shared::{
|
||||
InternalGatewayAuthContextRequest, InternalGatewayExecuteRequest, InternalGatewayResolveRequest,
|
||||
};
|
||||
use crate::tunnel::{
|
||||
is_tunnel_heartbeat_path, is_tunnel_node_status_path, TUNNEL_ROUTE_FAMILY,
|
||||
};
|
||||
use crate::tunnel::{is_tunnel_heartbeat_path, is_tunnel_node_status_path, TUNNEL_ROUTE_FAMILY};
|
||||
use crate::{AppState, GatewayError};
|
||||
use aether_data::repository::proxy_nodes::{
|
||||
ProxyNodeHeartbeatMutation, ProxyNodeTunnelStatusMutation,
|
||||
@@ -680,10 +674,9 @@ pub(crate) async fn maybe_build_local_internal_proxy_response_impl(
|
||||
"invalid internal gateway report-sync payload",
|
||||
)));
|
||||
};
|
||||
let payload = match serde_json::from_slice::<
|
||||
crate::usage::GatewaySyncReportRequest,
|
||||
>(request_body)
|
||||
{
|
||||
let payload = match serde_json::from_slice::<crate::usage::GatewaySyncReportRequest>(
|
||||
request_body,
|
||||
) {
|
||||
Ok(payload) => payload,
|
||||
Err(_) => {
|
||||
return Ok(Some(build_internal_control_error_response(
|
||||
@@ -705,10 +698,9 @@ pub(crate) async fn maybe_build_local_internal_proxy_response_impl(
|
||||
"invalid internal gateway report-stream payload",
|
||||
)));
|
||||
};
|
||||
let payload = match serde_json::from_slice::<
|
||||
crate::usage::GatewayStreamReportRequest,
|
||||
>(request_body)
|
||||
{
|
||||
let payload = match serde_json::from_slice::<crate::usage::GatewayStreamReportRequest>(
|
||||
request_body,
|
||||
) {
|
||||
Ok(payload) => payload,
|
||||
Err(_) => {
|
||||
return Ok(Some(build_internal_control_error_response(
|
||||
@@ -730,10 +722,9 @@ pub(crate) async fn maybe_build_local_internal_proxy_response_impl(
|
||||
"invalid internal gateway finalize-sync payload",
|
||||
)));
|
||||
};
|
||||
let payload = match serde_json::from_slice::<
|
||||
crate::usage::GatewaySyncReportRequest,
|
||||
>(request_body)
|
||||
{
|
||||
let payload = match serde_json::from_slice::<crate::usage::GatewaySyncReportRequest>(
|
||||
request_body,
|
||||
) {
|
||||
Ok(payload) => payload,
|
||||
Err(_) => {
|
||||
return Ok(Some(build_internal_control_error_response(
|
||||
|
||||
@@ -12,8 +12,8 @@ use crate::execution_runtime::{
|
||||
maybe_build_local_video_success_outcome, resolve_local_sync_error_background_report_kind,
|
||||
resolve_local_sync_success_background_report_kind,
|
||||
};
|
||||
use crate::handlers::admin::provider_oauth_refresh::build_internal_control_error_response;
|
||||
use crate::handlers::{
|
||||
use crate::handlers::admin::provider::oauth::build_internal_control_error_response;
|
||||
use crate::handlers::shared::{
|
||||
unix_secs_to_rfc3339, InternalTunnelHeartbeatRequest, InternalTunnelNodeStatusRequest,
|
||||
};
|
||||
use crate::video_tasks::{
|
||||
@@ -269,8 +269,7 @@ pub(crate) async fn maybe_build_internal_finalize_video_response(
|
||||
}
|
||||
match outcome.report_mode {
|
||||
crate::video_tasks::VideoTaskSyncReportMode::InlineSync => {
|
||||
crate::usage::submit_sync_report(state, trace_id, outcome.report_payload)
|
||||
.await?;
|
||||
crate::usage::submit_sync_report(state, trace_id, outcome.report_payload).await?;
|
||||
}
|
||||
crate::video_tasks::VideoTaskSyncReportMode::Background => {
|
||||
crate::usage::spawn_sync_report(
|
||||
@@ -314,11 +313,7 @@ pub(crate) async fn maybe_build_internal_finalize_video_response(
|
||||
{
|
||||
let mut report_payload = payload.clone();
|
||||
report_payload.report_kind = success_report_kind.to_string();
|
||||
crate::usage::spawn_sync_report(
|
||||
state.clone(),
|
||||
trace_id.to_string(),
|
||||
report_payload,
|
||||
);
|
||||
crate::usage::spawn_sync_report(state.clone(), trace_id.to_string(), report_payload);
|
||||
}
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static(CONTROL_EXECUTED_HEADER),
|
||||
@@ -334,11 +329,7 @@ pub(crate) async fn maybe_build_internal_finalize_video_response(
|
||||
{
|
||||
let mut report_payload = payload.clone();
|
||||
report_payload.report_kind = error_report_kind.to_string();
|
||||
crate::usage::spawn_sync_report(
|
||||
state.clone(),
|
||||
trace_id.to_string(),
|
||||
report_payload,
|
||||
);
|
||||
crate::usage::spawn_sync_report(state.clone(), trace_id.to_string(), report_payload);
|
||||
}
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static(CONTROL_EXECUTED_HEADER),
|
||||
@@ -408,11 +399,11 @@ pub(crate) fn parse_internal_tunnel_heartbeat_request(
|
||||
|| payload
|
||||
.proxy_version
|
||||
.as_deref()
|
||||
.is_some_and(|value| value.chars().count() > 20)
|
||||
.is_some_and(|value: &str| value.chars().count() > 20)
|
||||
|| payload
|
||||
.proxy_metadata
|
||||
.as_ref()
|
||||
.is_some_and(|value| !value.is_object())
|
||||
.is_some_and(|value: &serde_json::Value| !value.is_object())
|
||||
{
|
||||
return Err(build_internal_control_error_response(
|
||||
http::StatusCode::BAD_REQUEST,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::admin::provider_oauth_refresh::build_internal_control_error_response;
|
||||
use super::admin::provider::oauth::build_internal_control_error_response;
|
||||
|
||||
mod gateway_helpers;
|
||||
use self::gateway_helpers::*;
|
||||
|
||||
Reference in New Issue
Block a user