mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-12-01 01:05:10 +08:00
feat: initialize server structure and database schema
- Added initial server setup with Cargo.toml defining dependencies and project structure. - Created build.rs for generating protobuf bindings and validating wire contracts. - Established database schema with initial migration files for conversations, messages, and runs. - Introduced tools and prompts for Cursor functionality, enhancing user interaction capabilities.
This commit is contained in:
1 parent
d200b3791d
commit
44e2d8057a
206 files changed
+37923
-21
No files matched your search
@@ -0,0 +1,52 @@
|
||||
//! 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; 17] = [
|
||||
"/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/WriteGitCommitMessage",
|
||||
"/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,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user