mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-11-30 15:55:49 +08:00
- 新增 CommitSettingsCard 组件,支持选择生成模型与编辑提示词 - 新增 /settings/commit GET/PUT 接口及 CommitSettings 持久化 - 实现 WriteGitCommitMessage RPC 本地生成,空 model_id 时直连转发 - 新增 NetworkService/IsConnected 探针响应,防止流式生成被中断 - 添加 commit prompt 模板及 proto 消息定义 - 补充 zh-CN / en-US 国际化词条
52 lines
1.7 KiB
Rust
52 lines
1.7 KiB
Rust
//! Implements Cursor tab metadata services.
|
|
use axum::{
|
|
body::Body,
|
|
extract::{Extension, State},
|
|
http::{Request, Response},
|
|
routing::post,
|
|
Router,
|
|
};
|
|
|
|
use crate::{api::cursor::proxy, cursor::transport::TransportRegistry, Result};
|
|
|
|
pub const TAB_PATHS: [&str; 16] = [
|
|
"/aiserver.v1.AiService/StreamCpp",
|
|
"/aiserver.v1.AiService/StreamNextCursorPrediction",
|
|
"/aiserver.v1.AiService/GetCppEditClassification",
|
|
"/aiserver.v1.AiService/RefreshTabContext",
|
|
"/aiserver.v1.AiService/CppConfig",
|
|
"/aiserver.v1.AiService/CppEditHistoryStatus",
|
|
"/aiserver.v1.AiService/CppAppend",
|
|
"/aiserver.v1.AiService/CppEditHistoryAppend",
|
|
"/aiserver.v1.AiService/ReportAiCodeChangeMetrics",
|
|
"/aiserver.v1.AiService/WriteGitBranchName",
|
|
"/aiserver.v1.CppService/AvailableModels",
|
|
"/aiserver.v1.CppService/RecordCppFate",
|
|
"/aiserver.v1.FileSyncService/FSSyncFile",
|
|
"/aiserver.v1.FileSyncService/FSIsEnabledForUser",
|
|
"/aiserver.v1.FileSyncService/FSConfig",
|
|
"/aiserver.v1.FileSyncService/FSUploadFile",
|
|
];
|
|
|
|
pub fn is_tab_path(path: &str) -> bool {
|
|
TAB_PATHS.contains(&path)
|
|
}
|
|
|
|
pub fn router() -> Router<TransportRegistry> {
|
|
TAB_PATHS.into_iter().fold(Router::new(), |router, path| {
|
|
router.route(path, post(forward))
|
|
})
|
|
}
|
|
|
|
async fn forward(
|
|
State(registry): State<TransportRegistry>,
|
|
Extension(upstream): Extension<proxy::CursorProxy>,
|
|
request: Request<Body>,
|
|
) -> Result<Response<Body>> {
|
|
let settings = registry.store().tab_settings().await?;
|
|
match settings.service_url() {
|
|
Some(service_url) => proxy::forward_to_service(&upstream, request, service_url).await,
|
|
None => proxy::forward(Extension(upstream), request).await,
|
|
}
|
|
}
|