Skip to content
This repository was archived by the owner on Apr 5, 2026. It is now read-only.

Commit c3bfb3b

Browse files
committed
0.1.3-rc.5.2.5
1 parent 5071997 commit c3bfb3b

29 files changed

Lines changed: 1008 additions & 874 deletions

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,9 @@ GENERAL_TIMEZONE=Asia/Shanghai
131131

132132
# 使用内嵌的Claude.ai官方提示词作为默认提示词,如果是claude-开头的模型优先级大于DEFAULT_INSTRUCTIONS
133133
USE_OFFICIAL_CLAUDE_PROMPTS=false
134+
135+
# 真实额度(由于Cursor服务本身的问题,需要等待约5秒;由于架构原因,流式可能有bug),否则全零
136+
REAL_USAGE=false
137+
138+
# 安全哈希,checksum生成更慢
139+
SAFE_HASH=true

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cargo-features = ["profile-rustflags", "trim-paths"]
22

33
[package]
44
name = "cursor-api"
5-
version = "0.1.3-rc.5.2.4"
5+
version = "0.1.3-rc.5.2.5"
66
edition = "2024"
77
authors = ["wisdgod <nav@wisdgod.com>"]
88
description = "OpenAI format compatibility layer for the Cursor API"
@@ -25,6 +25,7 @@ flate2 = { version = "1", default-features = false, features = ["rust_backend"]
2525
futures = { version = "^0.3", default-features = false, features = ["std"] }
2626
gif = { version = "^0.13", default-features = false, features = ["std"] }
2727
hex = { version = "^0.4", default-features = false, features = ["std"] }
28+
http = "1"
2829
image = { version = "^0.25", default-features = false, features = ["jpeg", "png", "gif", "webp"] }
2930
lasso = { version = "^0.7", features = ["inline-more", "multi-threaded"] }
3031
memmap2 = "^0.9"
@@ -34,11 +35,10 @@ paste = "^1.0"
3435
prost = "^0.13"
3536
prost-types = "^0.13"
3637
rand = { version = "^0.9", default-features = false, features = ["thread_rng"] }
37-
regex = { version = "^1.11", default-features = false, features = ["std", "perf"] }
38-
reqwest = { version = "^0.12", default-features = false, features = ["gzip", "brotli", "json", "stream", "socks", "__tls", "charset", "rustls-tls-native-roots", "macos-system-configuration"] }
38+
reqwest = { version = "^0.12", default-features = false, features = ["gzip", "brotli", "json", "stream", "socks", "__tls", "charset", "rustls-tls-webpki-roots", "macos-system-configuration"] }
3939
rkyv = { version = "^0.7", default-features = false, features = ["alloc", "std", "bytecheck", "size_64", "validation", "std"] }
4040
serde = { version = "^1.0", default-features = false, features = ["std", "derive", "rc"] }
41-
serde_json = { package = "sonic-rs", version = "^0.4" }
41+
serde_json = { package = "sonic-rs", version = "0.5" }
4242
# serde_json = "^1.0"
4343
sha2 = { version = "^0.10", default-features = false }
4444
sysinfo = { version = "^0.34", default-features = false, features = ["system"] }

README.md

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,46 @@ deepseek-v3
8080
deepseek-r1
8181
o3-mini
8282
grok-2
83+
deepseek-v3.1
84+
grok-3-beta
85+
grok-3-mini-beta
86+
gpt-4.1
87+
```
88+
89+
支持思考:
90+
```
91+
claude-3.7-sonnet-thinking
92+
claude-3.7-sonnet-thinking-max
93+
o1-mini
94+
o1-preview
95+
o1
96+
gemini-2.5-pro-exp-03-25
97+
gemini-2.5-pro-max
98+
gemini-2.0-flash-thinking-exp
99+
deepseek-r1
100+
o3-mini
101+
```
102+
103+
支持图像:
104+
```
105+
claude-3.5-sonnet
106+
claude-3.7-sonnet
107+
claude-3.7-sonnet-thinking
108+
claude-3.7-sonnet-max
109+
claude-3.7-sonnet-thinking-max
110+
gpt-4
111+
gpt-4o
112+
gpt-4.5-preview
113+
claude-3-opus
114+
gpt-4-turbo-2024-04-09
115+
gpt-4o-128k
116+
claude-3-haiku-200k
117+
claude-3-5-sonnet-200k
118+
gpt-4o-mini
119+
claude-3.5-haiku
120+
gemini-2.5-pro-exp-03-25
121+
gemini-2.5-pro-max
122+
gpt-4.1
83123
```
84124

85125
## 接口说明
@@ -961,9 +1001,12 @@ string
9611001
}
9621002
],
9631003
"delays": [
1004+
"string",
9641005
[
965-
"string",
966-
number
1006+
[
1007+
number, // chars count
1008+
number // time
1009+
]
9671010
]
9681011
],
9691012
"usage": { // optional

src/app/constant.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
mod header;
2+
pub use header::*;
3+
14
#[macro_export]
25
macro_rules! def_pub_const {
36
// 单个常量定义
@@ -78,27 +81,12 @@ def_pub_const!(
7881
STATUS_FAILURE => "failure"
7982
);
8083

81-
// Header constants
82-
def_pub_const!(
83-
HEADER_NAME_GHOST_MODE => "x-ghost-mode"
84-
);
85-
8684
// Boolean constants
8785
def_pub_const!(
8886
TRUE => "true",
8987
FALSE => "false"
9088
);
9189

92-
// Content type constants
93-
def_pub_const!(
94-
CONTENT_TYPE_PROTO => "application/proto",
95-
CONTENT_TYPE_CONNECT_PROTO => "application/connect+proto",
96-
CONTENT_TYPE_TEXT_HTML_WITH_UTF8 => "text/html;charset=utf-8",
97-
CONTENT_TYPE_TEXT_PLAIN_WITH_UTF8 => "text/plain;charset=utf-8",
98-
CONTENT_TYPE_TEXT_CSS_WITH_UTF8 => "text/css;charset=utf-8",
99-
CONTENT_TYPE_TEXT_JS_WITH_UTF8 => "text/javascript;charset=utf-8"
100-
);
101-
10290
// Authorization constants
10391
def_pub_const!(
10492
AUTHORIZATION_BEARER_PREFIX => "Bearer "

src/app/constant/header.rs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
macro_rules! def_header_name {
2+
($($name:ident => $value:expr),+ $(,)?) => {
3+
$(paste::paste! {
4+
#[inline]
5+
pub(crate) fn [<header_name_ $name>]() -> &'static http::header::HeaderName {
6+
static HEADER_NAME: std::sync::OnceLock<http::header::HeaderName> = std::sync::OnceLock::new();
7+
HEADER_NAME.get_or_init(|| http::header::HeaderName::from_static($value))
8+
}
9+
})+
10+
};
11+
}
12+
13+
macro_rules! def_header_value {
14+
($($name:ident => $value:expr),+ $(,)?) => {
15+
$(paste::paste! {
16+
#[inline]
17+
pub fn [<header_value_ $name>]() -> &'static http::header::HeaderValue {
18+
static HEADER_NAME: std::sync::OnceLock<http::header::HeaderValue> = std::sync::OnceLock::new();
19+
HEADER_NAME.get_or_init(|| http::header::HeaderValue::from_static($value))
20+
}
21+
})+
22+
};
23+
}
24+
25+
def_header_value!(
26+
one => "1",
27+
encoding => "gzip",
28+
encodings => "gzip,br",
29+
accept => "*/*",
30+
language => "en-US",
31+
empty => "empty",
32+
cors => "cors",
33+
no_cache => "no-cache",
34+
no_cache_revalidate => "no-cache, must-revalidate",
35+
ua_win => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
36+
same_origin => "same-origin",
37+
keep_alive => "keep-alive",
38+
trailers => "trailers",
39+
u_eq_0 => "u=0",
40+
connect_es => "connect-es/1.6.1",
41+
not_a_brand => "\"Not-A.Brand\";v=\"99\", \"Chromium\";v=\"124\"",
42+
mobile_no => "?0",
43+
windows => "\"Windows\"",
44+
ua_cursor => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Cursor/0.42.5 Chrome/124.0.6367.243 Electron/30.4.0 Safari/537.36",
45+
vscode_origin => "vscode-file://vscode-app",
46+
cross_site => "cross-site",
47+
gzip_deflate => "gzip, deflate",
48+
event_stream => "text/event-stream",
49+
chunked => "chunked",
50+
json => "application/json",
51+
proto => "application/proto",
52+
connect_proto => "application/connect+proto",
53+
54+
// Content type constants
55+
text_html_utf8 => "text/html;charset=utf-8",
56+
text_plain_utf8 => "text/plain;charset=utf-8",
57+
text_css_utf8 => "text/css;charset=utf-8",
58+
text_js_utf8 => "text/javascript;charset=utf-8"
59+
);
60+
61+
def_header_name!(
62+
proxy_host => "x-co",
63+
connect_accept_encoding => "connect-accept-encoding",
64+
connect_protocol_version => "connect-protocol-version",
65+
ghost_mode => "x-ghost-mode",
66+
amzn_trace_id => "x-amzn-trace-id",
67+
client_key => "x-client-key",
68+
cursor_checksum => "x-cursor-checksum",
69+
cursor_client_version => "x-cursor-client-version",
70+
cursor_timezone => "x-cursor-timezone",
71+
request_id => "x-request-id",
72+
sec_ch_ua => "sec-ch-ua",
73+
sec_ch_ua_mobile => "sec-ch-ua-mobile",
74+
sec_ch_ua_platform => "sec-ch-ua-platform",
75+
sec_fetch_dest => "sec-fetch-dest",
76+
sec_fetch_mode => "sec-fetch-mode",
77+
sec_fetch_site => "sec-fetch-site",
78+
sec_gpc => "sec-gpc",
79+
priority => "priority",
80+
);

0 commit comments

Comments
 (0)