feat: 添加MCP调试插件并优化流式超时处理
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled

refactor(relay): 将Provider Key管理路由移至model_config模块
fix(saas): 修复demo_keys与provider_keys的匹配逻辑
perf(runtime): 将流式响应超时从60秒延长至180秒以适配思考型模型
docs: 新增模块化审计和上线前功能测试方案文档
chore: 添加tauri-plugin-mcp依赖及相关配置
This commit is contained in:
iven
2026-04-08 13:39:06 +08:00
parent 81d1702484
commit ade534d1ce
18 changed files with 2051 additions and 627 deletions

View File

@@ -5,10 +5,10 @@ pub mod service;
pub mod handlers;
pub mod key_pool;
use axum::routing::{delete, get, post, put};
use axum::routing::{get, post};
use crate::state::AppState;
/// 中转服务路由 (需要认证)
/// 中转服务路由 (需要认证 + quota 中间件)
pub fn routes() -> axum::Router<AppState> {
axum::Router::new()
// Relay 核心端点
@@ -17,9 +17,4 @@ pub fn routes() -> axum::Router<AppState> {
.route("/api/v1/relay/tasks/:id", get(handlers::get_task))
.route("/api/v1/relay/tasks/:id/retry", post(handlers::retry_task))
.route("/api/v1/relay/models", get(handlers::list_available_models))
// Key Pool 管理 (admin only)
.route("/api/v1/providers/:provider_id/keys", get(handlers::list_provider_keys))
.route("/api/v1/providers/:provider_id/keys", post(handlers::add_provider_key))
.route("/api/v1/providers/:provider_id/keys/:key_id/toggle", put(handlers::toggle_provider_key))
.route("/api/v1/providers/:provider_id/keys/:key_id", delete(handlers::delete_provider_key))
}

View File

@@ -15,8 +15,9 @@ use super::types::*;
/// 上游无数据时,发送 SSE 心跳注释行的间隔
const STREAMBRIDGE_HEARTBEAT_INTERVAL: Duration = Duration::from_secs(15);
/// 上游无数据时,丢弃连接的超时阈值(90s = 6 个心跳,给 thinking 模型更多时间
const STREAMBRIDGE_TIMEOUT: Duration = Duration::from_secs(90);
/// 上游无数据时,丢弃连接的超时阈值(180s = 12 个心跳)
/// 实测 Kimi for Coding 的 thinking→content 间隔可达 60s+,需要更宽容的超时。
const STREAMBRIDGE_TIMEOUT: Duration = Duration::from_secs(180);
/// 流结束后延迟清理的时间窗口
const STREAMBRIDGE_CLEANUP_DELAY: Duration = Duration::from_secs(60);
@@ -767,9 +768,9 @@ fn build_stream_bridge(
idle_heartbeats as u64 * STREAMBRIDGE_HEARTBEAT_INTERVAL.as_secs(),
);
// After 6 consecutive heartbeats without real data (90s),
// After 12 consecutive heartbeats without real data (180s),
// terminate the stream to prevent connection leaks.
if idle_heartbeats >= 6 {
if idle_heartbeats >= 12 {
tracing::warn!(
"[StreamBridge] Timeout ({:?}) no real data, closing stream for task {}",
STREAMBRIDGE_TIMEOUT,